Bug 10674

Summary: The patch file is not applied to linux-yocto by yocto-kernel add patch command in 2.1.2 rc1
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Yi Zhao <yi.zhao>
Component: meta-yoctoAssignee: Leonardo Sandoval Gonzalez <leonardo.sandoval.gonzalez>
Status: VERIFIED FIXED QA Contact: Yi Zhao <yi.zhao>
Severity: normal    
Priority: Medium CC: akuster, jose.perez.carranza, poky.bs.watcher, poky.watcher, yi.zhao
Version: 2.1.2   
Target Milestone: 2.1.3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Regression (Found by QA test)
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Char driver that can be used as a (safe) patch example
none
log.do_patch
none
log.do_compile none

Description Yi Zhao 2016-11-16 06:27:05 UTC
This issue is cloned from bug 9120 which already fixed in 2.2. More details can check with it.

Steps:
1. Follow the https://wiki.yoctoproject.org/wiki/Transcript:_Using_the_Yocto_BSP_tools_to_create_a_qemu_BSP to create a myqemuarm layer:

##############################
$ yocto-bsp create myqemuarm qemu
Checking basic git connectivity...
+Done.

Which qemu architecture would you like to use? [default: i386]
	1) i386    (32-bit)
	2) x86_64  (64-bit)
	3) ARM     (32-bit)
	4) PowerPC (32-bit)
	5) MIPS    (32-bit)
	6) MIPS64  (64-bit)
3
Would you like to use the default (4.1) kernel? (y/n) [default: y]
 

Do you need a new machine branch for this BSP (the alternative is to re-use an existing branch)? [y/n] [default: y] n     <--------- DO NOT use default setting, choose *NO*


Getting branches from remote repo git://git.yoctoproject.org/linux-yocto-4.1.git...
Please choose an existing machine branch to use for this BSP: [default: standard/arm-versatile-926ejs]
	1) standard/arm-versatile-926ejs
	2) standard/base
	3) standard/beagleboard
	4) standard/beaglebone
	5) standard/edgerouter
	6) standard/fsl-mpc8315e-rdb
	7) standard/mti-malta32
	8) standard/mti-malta64
	9) standard/qemuarm64
	10) standard/qemuppc
1
Would you like SMP support? (y/n) [default: y] 
Does your BSP have a touchscreen? (y/n) [default: n] 
Does your BSP have a keyboard? (y/n) [default: y] 

New qemu BSP created in meta-myqemuarm

################################

2. Follow the https://wiki.yoctoproject.org/wiki/Transcript:_Using_the_Yocto_BSP_tools_to_manage_kernel_patches_and_config_items to add a patch (see the attachment):

#######################
$ yocto-kernel patch add myqemuarm ./yocto-testmod.patch
Added patches:
	yocto-testmod.patch
$ yocto-kernel config add myqemuarm CONFIG_MISC_DEVICES=y
Added item:
	CONFIG_MISC_DEVICES=y
$ yocto-kernel config add myqemuarm CONFIG_YOCTO_TESTMOD=y
Added item:
	CONFIG_YOCTO_TESTMOD=y

#######################

3. Run bitbake linux-yocto
Comment 1 Yi Zhao 2016-11-16 06:45:26 UTC
*** Bug 10673 has been marked as a duplicate of this bug. ***
Comment 2 Yi Zhao 2017-06-12 06:15:20 UTC
This issue still exist in 2.1.3 rc1 build.
Git rev: krogoth/fe7fb002216f7886d49942333ea6d8592339bb05
Comment 3 Leonardo Sandoval Gonzalez 2017-06-12 21:41:13 UTC
Patch sent to review:

https://lists.yoctoproject.org/pipermail/poky/2017-June/011022.html
Comment 4 Leonardo Sandoval Gonzalez 2017-06-12 21:56:12 UTC
(In reply to comment #2)
> This issue still exist in 2.1.3 rc1 build.
> Git rev: krogoth/fe7fb002216f7886d49942333ea6d8592339bb05

Yi, the only stable branch not containing poky path 720ae184031db33049f9be6326f9735224183492 was morty (2.2.x) and comment 3 provides the appropriate fix. krogoth, 2.1.x, the branch you are reporting the problem, does have the patch the line [1] so I believe something else is raising this issue. I will test again in both stable branches and let you know my findings.

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/bsp/kernel.py?h=krogoth#n336
Comment 5 Leonardo Sandoval Gonzalez 2017-06-13 20:24:58 UTC
I have tested on Krogoth  (2.1.x) and it is failing because the patch being introduced into the kernel does now apply:

| (1/1) yocto-testmod.patch
| [INFO]: check of .kernel-meta/patches/standard/arm-versatile-926ejs/links/files/yocto-testmod.patch with "git am" did not pass, trying reduced context.
| [INFO]: Context reduced git-am of .kernel-meta/patches/standard/arm-versatile-926ejs/links/files/yocto-testmod.patch with "git am" did not work, trying "apply".
| error: patch failed: drivers/misc/Kconfig:392
| error: drivers/misc/Kconfig: patch does not apply
| Context reduced to (1/1) to apply fragment at 39
| [ERROR]: Application of .kernel-meta/patches/standard/arm-versatile-926ejs/links/files/yocto-testmod.patch failed.
|          Patch needs to be refreshed. Sample resolution script:
|              .git/rebase-apply/resolve_rejects
| ERROR. could not update git tree
| WARNING: /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-krogoth/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.4.26+gitAUTOINC+c3f8900923_dbf351c65c-r0.4/temp/run.do_patch.35153:1 exit 1 from 'patchme myqemuarm'
| ERROR: Function failed: do_patch (log file is located at /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-krogoth/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.4.26+gitAUTOINC+c3f8900923_dbf351c65c-r0.4/temp/log.do_patch.35153)
ERROR: Task 3 (/home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.4.bb, do_patch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 360 tasks of which 322 didn't need to be rerun and 1 failed.
Waiting for 0 running tasks to finish:

Summary: 1 task failed:
  /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.4.bb, do_patch
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
lsandov1@yctb05:~/poky-testing/poky-linux-yocto-yocto-kernel/build-krogoth>


I will test it with a patch that can be merged all the time so I am able to reproduce the issue.


In the other, I test it on morty with patch on comment 3 applied and the error log is different but at the end, it is a patching error:

Initialising tasks: 100% |######################################################################################################################################################################################################| Time: 0:00:00
Checking sstate mirror object availability: 100% |##############################################################################################################################################################################| Time: 0:00:04
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: linux-yocto-4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4 do_kernel_version_sanity_check: Package Version (4.8.18+gitAUTOINC+c84532b647_f25e3a184b) does not match of kernel being built (4.8.24). Please update the PV variable to match the kernel source.
ERROR: linux-yocto-4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4 do_kernel_version_sanity_check: Function failed: do_kernel_version_sanity_check (log file is located at /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/log.do_kernel_version_sanity_check.596)
ERROR: Logfile of failure stored in: /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/log.do_kernel_version_sanity_check.596
ERROR: Task (/home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.8.bb:do_kernel_version_sanity_check) failed with exit code '1'
ERROR: linux-yocto-4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4 do_patch: Function failed: do_patch (log file is located at /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/log.do_patch.595)
ERROR: Logfile of failure stored in: /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/log.do_patch.595
Log data follows:
| DEBUG: Executing shell function do_patch
| (1/1) yocto-testmod.patch
| [INFO]: check of .kernel-meta//patches//./yocto-testmod.patch with "git am" did not pass, trying reduced context.
| [INFO]: Context reduced git-am of .kernel-meta//patches//./yocto-testmod.patch with "git am" did not work, trying "apply".
| error: patch failed: drivers/misc/Kconfig:392
| error: drivers/misc/Kconfig: patch does not apply
| Context reduced to (1/1) to apply fragment at 38
| [ERROR]: Application of .kernel-meta//patches//./yocto-testmod.patch failed.
|          Patch needs to be refreshed. Sample resolution script:
|              .git/rebase-apply/resolve_rejects
| WARNING: /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/run.do_patch.595:1 exit 1 from 'kgit-s2q --gen -v --patches .kernel-meta/'
| ERROR: Function failed: do_patch (log file is located at /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/build-morty/tmp/work/myqemuarm-poky-linux-gnueabi/linux-yocto/4.8.18+gitAUTOINC+c84532b647_f25e3a184b-r0.4/temp/log.do_patch.595)
ERROR: Task (/home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.8.bb:do_patch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 384 tasks of which 334 didn't need to be rerun and 2 failed.

Summary: 2 tasks failed:
  /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.8.bb:do_kernel_version_sanity_check
  /home/lsandov1/poky-testing/poky-linux-yocto-yocto-kernel/meta/recipes-kernel/linux/linux-yocto_4.8.bb:do_patch
Summary: There were 3 ERROR messages shown, returning a non-zero exit code.


Will work on both issues.
Comment 6 Leonardo Sandoval Gonzalez 2017-06-14 19:54:12 UTC
Created attachment 3817 [details]
Char driver that can be used as  a (safe) patch example
Comment 7 Leonardo Sandoval Gonzalez 2017-06-14 19:57:10 UTC
Yi,

can you retest it with the patch I included? That is a driver that gets patched in its own directory (drivers/char/dummy) so avoiding any patching issues. With it, I did not observe what you reported.

I tested on morty and krogoth branches, both giving the same results.
Comment 8 Yi Zhao 2017-06-15 07:15:52 UTC
(In reply to comment #7)
> Yi,
> 
> can you retest it with the patch I included? That is a driver that gets
> patched in its own directory (drivers/char/dummy) so avoiding any patching
> issues. With it, I did not observe what you reported.
> 
> I tested on morty and krogoth branches, both giving the same results.

Hi Leonardo,

Currently I only did a rough test with your patch on krogoth branch due to time limitation. bitbake linux-yocto worked fine with this patch. Next I will try to build an image to see if this kernel module works on the runtime system. I will give you the final result tomorrow.
Comment 9 Yi Zhao 2017-06-16 02:59:15 UTC
Hi Leonardo,

Although there is no error for patching, the dummy driver isn't built even if I set CONFIG_YOCTO_DUMMY=y.

In lod.do_patch:
###############################
   mark <-- qemu-ppc32-standard.scc
      branch ===> standard/qemuppc/myqemuppc
   mark --> myqemuppc.scc
   mark --> myqemuppc-user-patches.scc
         patch yocto-testmod.patch (.kernel-meta/patches/standard/qemuppc/myqemuppc/series)
   mark <-- myqemuppc-user-patches.scc
   mark <-- myqemuppc.scc
   mark <-- myqemuppc-standard.scc
(1/1) yocto-testmod.patch
[INFO]: check of .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.patch with "git am" did not pass, trying reduced context.
[INFO]: Context reduced git-am of .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.patch with "git am" did not work, trying "apply".
/buildarea/jenkins-yocto/workspace/Yocto2.1-yocto-bsp_create_qemu_bsp/build_1/tmp/work-shared/myqemuppc/kernel-source/.git/rebase-apply/patch:11: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
   mark --> patch_marker.scc
   mark <-- patch_marker.scc
#########################################

But there is no any message for building this driver in log.do_compile

I attached the log.do_patch and log.do_compile
Comment 10 Yi Zhao 2017-06-16 02:59:48 UTC
Created attachment 3825 [details]
log.do_patch
Comment 11 Yi Zhao 2017-06-16 03:00:11 UTC
Created attachment 3826 [details]
log.do_compile
Comment 12 Stephen K Jolley 2017-06-16 16:25:03 UTC
Questions answered
Comment 13 Leonardo Sandoval Gonzalez 2017-06-16 17:01:00 UTC
(In reply to comment #9)
> Hi Leonardo,

Hi Yi

> 
> Although there is no error for patching, the dummy driver isn't built even
> if I set CONFIG_YOCTO_DUMMY=y.

ok, so the patching issue is gone which is the reported problem.

> 
> In lod.do_patch:
> ###############################
>    mark <-- qemu-ppc32-standard.scc
>       branch ===> standard/qemuppc/myqemuppc
>    mark --> myqemuppc.scc
>    mark --> myqemuppc-user-patches.scc
>          patch yocto-testmod.patch
> (.kernel-meta/patches/standard/qemuppc/myqemuppc/series)
>    mark <-- myqemuppc-user-patches.scc
>    mark <-- myqemuppc.scc
>    mark <-- myqemuppc-standard.scc
> (1/1) yocto-testmod.patch
> [INFO]: check of
> .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.
> patch with "git am" did not pass, trying reduced context.

yocto-testmod is the patch that cannot be applied, so make sure you are using the one I provided.


> [INFO]: Context reduced git-am of
> .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.
> patch with "git am" did not work, trying "apply".
> /buildarea/jenkins-yocto/workspace/Yocto2.1-yocto-bsp_create_qemu_bsp/
> build_1/tmp/work-shared/myqemuppc/kernel-source/.git/rebase-apply/patch:11:
> new blank line at EOF.
> +
> warning: 1 line adds whitespace errors.
>    mark --> patch_marker.scc
>    mark <-- patch_marker.scc
> #########################################
> 
> But there is no any message for building this driver in log.do_compile
> 
> I attached the log.do_patch and log.do_compile

before looking into this problem (it could be another one, not related to the patch problem), please use the patch I provided, so the log would look like

   mark --> myqemuarm-user-patches.scc
         patch 0001-dummy-char-example-driver.patch (.kernel-meta/patches/standard/arm-versatile-926ejs/series)
   mark <-- myqemuarm-user-patches.scc
Comment 14 Yi Zhao 2017-06-19 02:06:50 UTC
(In reply to comment #13)
> (In reply to comment #9)
> > Hi Leonardo,
> 
> Hi Yi
> 
> > 
> > Although there is no error for patching, the dummy driver isn't built even
> > if I set CONFIG_YOCTO_DUMMY=y.
> 
> ok, so the patching issue is gone which is the reported problem.
> 
> > 
> > In lod.do_patch:
> > ###############################
> >    mark <-- qemu-ppc32-standard.scc
> >       branch ===> standard/qemuppc/myqemuppc
> >    mark --> myqemuppc.scc
> >    mark --> myqemuppc-user-patches.scc
> >          patch yocto-testmod.patch
> > (.kernel-meta/patches/standard/qemuppc/myqemuppc/series)
> >    mark <-- myqemuppc-user-patches.scc
> >    mark <-- myqemuppc.scc
> >    mark <-- myqemuppc-standard.scc
> > (1/1) yocto-testmod.patch
> > [INFO]: check of
> > .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.
> > patch with "git am" did not pass, trying reduced context.
> 
> yocto-testmod is the patch that cannot be applied, so make sure you are
> using the one I provided.
> 
> 
> > [INFO]: Context reduced git-am of
> > .kernel-meta/patches/standard/qemuppc/myqemuppc/links/files/yocto-testmod.
> > patch with "git am" did not work, trying "apply".
> > /buildarea/jenkins-yocto/workspace/Yocto2.1-yocto-bsp_create_qemu_bsp/
> > build_1/tmp/work-shared/myqemuppc/kernel-source/.git/rebase-apply/patch:11:
> > new blank line at EOF.
> > +
> > warning: 1 line adds whitespace errors.
> >    mark --> patch_marker.scc
> >    mark <-- patch_marker.scc
> > #########################################
> > 
> > But there is no any message for building this driver in log.do_compile
> > 
> > I attached the log.do_patch and log.do_compile
> 
> before looking into this problem (it could be another one, not related to
> the patch problem), please use the patch I provided, so the log would look
> like
> 
>    mark --> myqemuarm-user-patches.scc
>          patch 0001-dummy-char-example-driver.patch
> (.kernel-meta/patches/standard/arm-versatile-926ejs/series)
>    mark <-- myqemuarm-user-patches.scc

Hi Leonardo,

I just renamed your patch to yocto-testmod.patch in order to run my original test script.

Yi
Comment 15 Stephen K Jolley 2017-06-23 19:33:05 UTC
It appears the question has been answered.
Comment 16 Leonardo Sandoval Gonzalez 2017-06-29 21:00:41 UTC
Yi,

Can you test using meta layer [1]?

lets focus on the patch issue and if this is solve we can resolve this bug. Again, I am **NOT** seeing a problem when patching the kernel, to demonstrate it, use [1] then compile the kernel and open a devshell (of course, for the myqemuarm machine). For the compilation issue, raise another bug if necessary.


yctb05:~/poky-testing/poky-linux-yocto-yocto-kernel/build/tmp/work-shared/myqemuarm/kernel-source # git whatchanged | head -20
commit f0ddcc469ca743d19ca2011e5ecd8f9acad24342
Author: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Date:   Wed Jun 14 12:10:39 2017 -0700

    dummy: char example driver
    
    Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

:100644 100644 a043107da2af... 9f81a26831ed... M        drivers/char/Kconfig
:000000 100644 000000000000... d0a63ec096a5... A        drivers/char/dummy/Kconfig
:000000 100644 000000000000... b320d255db44... A        drivers/char/dummy/Makefile
:000000 100644 000000000000... dd055a24496f... A        drivers/char/dummy/dummy.c

[1] https://github.com/lsandoval/meta-myqemuarm
Comment 17 Yi Zhao 2017-06-30 07:07:31 UTC
Hi Leonardo,

I re-tested this case with 2.1.3 rc2 build. It works fine. There is no errors in  do_patch and do_compile. Thank you for the great help. I think we can close this bug.

Yi
Comment 18 Yi Zhao 2017-06-30 07:20:44 UTC
Hi Leonardo, 

You could mark this bug as FIXED and I will mark it as VERIFIED.
Comment 19 Leonardo Sandoval Gonzalez 2017-06-30 14:42:22 UTC
Based on last comment from Yi, resolving it as fixed.
Comment 20 Yi Zhao 2017-07-03 07:09:08 UTC
Verified with 2.1.3 rc2 build.
Git rev: krogoth/3cf0e093481ea260d4f41bed24336ea7f0102bde