diff mbox

Automatic device driver back-porting with media_build

Message ID 5673E393.8050309@free.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Mason Dec. 18, 2015, 10:44 a.m. UTC
On 17/12/2015 18:03, Mason wrote:

> The media_build process prints:
> 
> "Preparing to compile for kernel version 3.4.3913"
> 
> In fact, the custom kernel's Makefile contains:
> 
> VERSION = 3
> PATCHLEVEL = 4
> SUBLEVEL = 39
> EXTRAVERSION = 13
> NAME = Saber-toothed Squirrel
> 
> Is it possible that the build process gets confused by the EXTRAVERSION field?

Here's the problem:

v4l/Makefile writes to KERNELRELEASE and v4l/.version

	-e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
	-e '	$$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \

$ cat v4l/.version 
VERSION=3
PATCHLEVEL:=4
SUBLEVEL:=39
KERNELRELEASE:=3.4.3913
SRCDIR:=/tmp/sandbox/custom-linux-3.4

Then $(MAKE) -C ../linux apply_patches calls
patches_for_kernel.pl 3.4.3913

which computes kernel_version
= 3 << 16 + 4 << 8 + 3913 = 0x031349

which is incorrectly interpreted as kernel 3.19.73
thus the correct patches are not applied.

Trivial patch follows. Will test right away.

Regards.


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Mauro Carvalho Chehab Dec. 18, 2015, 11:03 a.m. UTC | #1
Em Fri, 18 Dec 2015 11:44:35 +0100
Mason <slash.tmp@free.fr> escreveu:

> On 17/12/2015 18:03, Mason wrote:
> 
> > The media_build process prints:
> > 
> > "Preparing to compile for kernel version 3.4.3913"
> > 
> > In fact, the custom kernel's Makefile contains:
> > 
> > VERSION = 3
> > PATCHLEVEL = 4
> > SUBLEVEL = 39
> > EXTRAVERSION = 13
> > NAME = Saber-toothed Squirrel
> > 
> > Is it possible that the build process gets confused by the EXTRAVERSION field?
> 
> Here's the problem:
> 
> v4l/Makefile writes to KERNELRELEASE and v4l/.version
> 
> 	-e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
> 	-e '	$$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \
> 
> $ cat v4l/.version 
> VERSION=3
> PATCHLEVEL:=4
> SUBLEVEL:=39
> KERNELRELEASE:=3.4.3913
> SRCDIR:=/tmp/sandbox/custom-linux-3.4
> 
> Then $(MAKE) -C ../linux apply_patches calls
> patches_for_kernel.pl 3.4.3913
> 
> which computes kernel_version
> = 3 << 16 + 4 << 8 + 3913 = 0x031349
> 
> which is incorrectly interpreted as kernel 3.19.73
> thus the correct patches are not applied.
> 
> Trivial patch follows. Will test right away.
> 
> Regards.
> 
> diff --git a/v4l/Makefile b/v4l/Makefile
> index 1542092004fa..9147a98639b7 100644
> --- a/v4l/Makefile
> +++ b/v4l/Makefile
> @@ -233,9 +233,9 @@ ifneq ($(DIR),)
>         -e '    elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \
>         -e '    elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/ || /^MAKEARGS\s*:=\s*-C\s*(\S.*)\n/)' \
>         -e '        { $$o=$$d; $$d=$$1; goto S; }' \
>         -e '};' \
> -       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
> +       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s.%s\n",' \
>         -e '    $$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \

Hmm... that doesn't sound right on upstream Kernels.

For example, the extra version on the media_build current Kernel is:

Makefile:EXTRAVERSION = -rc2

So, I guess we'll need a different regex, like:

         -e '    elsif (/^EXTRAVERSION\s*=\s*(\d+)\n/){ $$extra=".$$1"; }' \
         -e '    elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mauro Carvalho Chehab Dec. 18, 2015, 11:22 a.m. UTC | #2
Em Fri, 18 Dec 2015 09:03:45 -0200
Mauro Carvalho Chehab <mchehab@osg.samsung.com> escreveu:

> Em Fri, 18 Dec 2015 11:44:35 +0100
> Mason <slash.tmp@free.fr> escreveu:
> 
> > On 17/12/2015 18:03, Mason wrote:
> > 
> > > The media_build process prints:
> > > 
> > > "Preparing to compile for kernel version 3.4.3913"
> > > 
> > > In fact, the custom kernel's Makefile contains:
> > > 
> > > VERSION = 3
> > > PATCHLEVEL = 4
> > > SUBLEVEL = 39
> > > EXTRAVERSION = 13
> > > NAME = Saber-toothed Squirrel
> > > 
> > > Is it possible that the build process gets confused by the EXTRAVERSION field?
> > 
> > Here's the problem:
> > 
> > v4l/Makefile writes to KERNELRELEASE and v4l/.version
> > 
> > 	-e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
> > 	-e '	$$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \
> > 
> > $ cat v4l/.version 
> > VERSION=3
> > PATCHLEVEL:=4
> > SUBLEVEL:=39
> > KERNELRELEASE:=3.4.3913
> > SRCDIR:=/tmp/sandbox/custom-linux-3.4
> > 
> > Then $(MAKE) -C ../linux apply_patches calls
> > patches_for_kernel.pl 3.4.3913
> > 
> > which computes kernel_version
> > = 3 << 16 + 4 << 8 + 3913 = 0x031349
> > 
> > which is incorrectly interpreted as kernel 3.19.73
> > thus the correct patches are not applied.
> > 
> > Trivial patch follows. Will test right away.
> > 
> > Regards.
> > 
> > diff --git a/v4l/Makefile b/v4l/Makefile
> > index 1542092004fa..9147a98639b7 100644
> > --- a/v4l/Makefile
> > +++ b/v4l/Makefile
> > @@ -233,9 +233,9 @@ ifneq ($(DIR),)
> >         -e '    elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \
> >         -e '    elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/ || /^MAKEARGS\s*:=\s*-C\s*(\S.*)\n/)' \
> >         -e '        { $$o=$$d; $$d=$$1; goto S; }' \
> >         -e '};' \
> > -       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
> > +       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s.%s\n",' \
> >         -e '    $$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \
> 
> Hmm... that doesn't sound right on upstream Kernels.
> 
> For example, the extra version on the media_build current Kernel is:
> 
> Makefile:EXTRAVERSION = -rc2
> 
> So, I guess we'll need a different regex, like:
> 
>          -e '    elsif (/^EXTRAVERSION\s*=\s*(\d+)\n/){ $$extra=".$$1"; }' \
>          -e '    elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \

Yes, this works. Changing a 2.6.32 kernel to:

	VERSION = 2
	PATCHLEVEL = 6
	SUBLEVEL = 32
	EXTRAVERSION = 99

It gets:
	Forcing compiling to version 2.6.32.99
	make[1]: Leaving directory '/devel/v4l/media_build/v4l'

And
	KERNELRELEASE:=2.6.32.99

Changing EXTRAVERSION to:
	EXTRAVERSION = -rc99

It gets:
	Forcing compiling to version 2.6.32-rc99
And
	 KERNELRELEASE:=2.6.32-rc99	

Patch applied.

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mason Dec. 18, 2015, 12:10 p.m. UTC | #3
On 18/12/2015 12:22, Mauro Carvalho Chehab wrote:

> Patch applied.

Great! Thanks.

Using the latest media_build master + my writel_relaxed work-around,
compilation proceeds much further, then dies on device tree stuff:
(same error with vanilla and custom kernel)

Will look into it. Any idea? :-(

By the way, if I was not clear, I'm cross-compiling for an ARM platform.

  CC [M]  /tmp/sandbox/media_build/v4l/v4l2-of.o
/tmp/sandbox/media_build/v4l/v4l2-of.c: In function 'v4l2_of_parse_csi_bus':
/tmp/sandbox/media_build/v4l/v4l2-of.c:38:4: error: implicit declaration of function 'of_prop_next_u32' [-Werror=implicit-function-declaration]
    lane = of_prop_next_u32(prop, lane, &v);
    ^
/tmp/sandbox/media_build/v4l/v4l2-of.c:38:9: warning: assignment makes pointer from integer without a cast
    lane = of_prop_next_u32(prop, lane, &v);
         ^
/tmp/sandbox/media_build/v4l/v4l2-of.c:52:13: warning: assignment makes pointer from integer without a cast
    polarity = of_prop_next_u32(prop, polarity, &v);
             ^
/tmp/sandbox/media_build/v4l/v4l2-of.c: In function 'v4l2_of_parse_link':
/tmp/sandbox/media_build/v4l/v4l2-of.c:287:24: warning: passing argument 1 of 'of_parse_phandle' discards 'const' qualifier from pointer target type
  np = of_parse_phandle(node, "remote-endpoint", 0);
                        ^
In file included from include/linux/i2c.h:36:0,
                 from /tmp/sandbox/media_build/v4l/compat.h:977,
                 from <command-line>:0:
include/linux/of.h:237:28: note: expected 'struct device_node *' but argument is of type 'const struct device_node *'
 extern struct device_node *of_parse_phandle(struct device_node *np,
                            ^
cc1: some warnings being treated as errors
make[3]: *** [/tmp/sandbox/media_build/v4l/v4l2-of.o] Error 1
make[2]: *** [_module_/tmp/sandbox/media_build/v4l] Error 2
make[2]: Leaving directory `/tmp/sandbox/linux-3.4.39'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/tmp/sandbox/media_build/v4l'
make: *** [all] Error 2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mason Dec. 18, 2015, 12:59 p.m. UTC | #4
On 18/12/2015 13:10, Mason wrote:

> On 18/12/2015 12:22, Mauro Carvalho Chehab wrote:
> 
>> Patch applied.
> 
> Great! Thanks.
> 
> Using the latest media_build master + my writel_relaxed work-around,
> compilation proceeds much further, then dies on device tree stuff:
> (same error with vanilla and custom kernel)
> 
> Will look into it. Any idea? :-(
> 
> By the way, if I was not clear, I'm cross-compiling for an ARM platform.
> 
>   CC [M]  /tmp/sandbox/media_build/v4l/v4l2-of.o
> /tmp/sandbox/media_build/v4l/v4l2-of.c: In function 'v4l2_of_parse_csi_bus':
> /tmp/sandbox/media_build/v4l/v4l2-of.c:38:4: error: implicit declaration of function 'of_prop_next_u32' [-Werror=implicit-function-declaration]
>     lane = of_prop_next_u32(prop, lane, &v);
>     ^

of_prop_next_u32() was introduced by commit c541adc637066
$ git describe --contains c541adc637066
v3.5-rc1~176^2~34

So it seems something needs to be done for kernels older than 3.5

I'll hack around it by adding

static inline const __be32 *of_prop_next_u32(struct property *prop,
		const __be32 *cur, u32 *pu)
{
	return NULL;
}

What's the correct fix?

> /tmp/sandbox/media_build/v4l/v4l2-of.c: In function 'v4l2_of_parse_link':
> /tmp/sandbox/media_build/v4l/v4l2-of.c:287:24: warning: passing argument 1 of 'of_parse_phandle' discards 'const' qualifier from pointer target type
>   np = of_parse_phandle(node, "remote-endpoint", 0);
>                         ^

Commit b8fbdc42c5c5d made the first parameter const.

$ git describe --contains b8fbdc42c5c5d
v3.8-rc1~105^2~13

I suppose I can live with the warning for now.

Regards.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mason Dec. 18, 2015, 1:40 p.m. UTC | #5
On 18/12/2015 13:59, Mason wrote: [snip previous work-arounds]

Compilation completes.

make -C /tmp/sandbox/custom-linux-3.4 SUBDIRS=/tmp/sandbox/media_build/v4l  modules
make[2]: Entering directory `/tmp/sandbox/custom-linux-3.4'
  Building modules, stage 2.
  MODPOST 209 modules
WARNING: "of_graph_parse_endpoint" [/tmp/sandbox/media_build/v4l/videodev.ko] undefined!
WARNING: "of_get_next_parent" [/tmp/sandbox/media_build/v4l/videodev.ko] undefined!
WARNING: "nsecs_to_jiffies" [/tmp/sandbox/media_build/v4l/gpio-ir-recv.ko] undefined!
make[2]: Leaving directory `/tmp/sandbox/custom-linux-3.4'
./scripts/rmmod.pl check
found 209 modules
make[1]: Leaving directory `/tmp/sandbox/media_build/v4l'


A few link problems, two from device tree:

of_graph_parse_endpoint() commit fd9fdb78a9bf8

of_get_next_parent() was not exported until commit 6695be6863b75

nsecs_to_jiffies() was not exported until commit d560fed6abe0f

How would you fix those?

I will try building a kernel with CONFIG_OF=n

Regards.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mason Dec. 18, 2015, 3:13 p.m. UTC | #6
On 18/12/2015 14:40, Mason wrote:

> I will try building a kernel with CONFIG_OF=n

Build works much better with CONFIG_OF=n
I suppose OF support with ancient kernels is untested.
(My setup didn't need it anyway.)

The remaining issue is:

WARNING: "nsecs_to_jiffies" [/tmp/sandbox/media_build/v4l/gpio-ir-recv.ko] undefined!

$ git describe --contains d560fed6abe0f
v3.17-rc1~109^2~40

The actual call site was added recently by commit 3fb136f3392d
(Hasn't even it linux-stable yet, I only see it in next-20151123)

I think a patch is needed for kernels < 3.17 right?

Regards.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/v4l/Makefile b/v4l/Makefile
index 1542092004fa..9147a98639b7 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -233,9 +233,9 @@  ifneq ($(DIR),)
        -e '    elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \
        -e '    elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/ || /^MAKEARGS\s*:=\s*-C\s*(\S.*)\n/)' \
        -e '        { $$o=$$d; $$d=$$1; goto S; }' \
        -e '};' \
-       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
+       -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s.%s\n",' \
        -e '    $$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \
        -e 'print "OUTDIR:=$$o\n" if($$o);' \
        -e 'print "SRCDIR:=$$d\n";' > $(obj)/.version
        @cat .version|grep KERNELRELEASE:|sed s,'KERNELRELEASE:=','Forcing compiling to version ',