Bug 55681

Summary: Build fails with CONFIG_I2C=m
Product: v4l-dvb Reporter: Bernhard Seibold (mail)
Component: v4l-coreAssignee: v4l-dvb_v4l-core (v4l-dvb_v4l-core)
Status: CLOSED CODE_FIX    
Severity: normal CC: alan, mchehab
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.9-rc3 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: Config file used on my test with Kernel 3.9-rc4
broken config
Fix compilation breakage when VIDEO_DEV=y, I2C=m, V4L2=m

Description Bernhard Seibold 2013-03-23 15:26:46 UTC
The kernel fails to build with CONFIG_I2C=m and CONFIG_V4L2=m. It builds ok with CONFIG_I2C=y.

The link error is as follows:
+ ld -m elf_x86_64 --build-id -o .tmp_vmlinux1 -T /.../linux-3.9-rc3/arch/x86/kernel/vmlinux.lds arch/x86/kernel/head_64.o arch/x86/kernel/head64.o arch/x86/kernel/head.o init/built-in.o --start-group usr/built-in.o arch/x86/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o lib/lib.a arch/x86/lib/lib.a lib/built-in.o arch/x86/lib/built-in.o drivers/built-in.o sound/built-in.o firmware/built-in.o arch/x86/pci/built-in.o arch/x86/power/built-in.o arch/x86/video/built-in.o net/built-in.o --end-group
drivers/built-in.o: In function `v4l2_device_unregister':
/.../linux-3.9-rc3/drivers/media/v4l2-core/v4l2-device.c:125: undefined reference to `i2c_unregister_device'


The commit that introduced this is 7b34be71db533f3e0cf93d53cf62d036cdb5418a.
More specifically, it's this change:

diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 98a7f5e..8ed5da2 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -112,7 +112,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
 	/* Unregister subdevs */
 	list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list) {
 		v4l2_device_unregister_subdev(sd);
-#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
+#if IS_ENABLED(CONFIG_I2C)
 		if (sd->flags & V4L2_SUBDEV_FL_IS_I2C) {
 			struct i2c_client *client = v4l2_get_subdevdata(sd);
Comment 1 Mauro Carvalho Chehab 2013-03-25 14:04:59 UTC
I did a clean compilation with Kernel v3.9-rc4. Everything went fine, except for a few warnings below:

arch/x86/mm/init_64.c:1023: warning: ‘kernel_physical_mapping_remove’ defined but not used
arch/x86/kvm/mmu.c: In function ‘kvm_test_age_rmapp’:
arch/x86/kvm/mmu.c:1386: warning: ‘iter.desc’ may be used uninitialized in this function
kernel/workqueue.c: In function ‘__queue_work’:
kernel/workqueue.c:489: warning: array subscript is above array bounds
lib/raid6/recov_avx2.c:11:5: warning: "CONFIG_AS_AVX2" is not defined
lib/raid6/recov_avx2.c:322:2: warning: #warning "your version of binutils lacks AVX2 support"
net/unix/af_unix.c: In function ‘unix_bind’:
net/unix/af_unix.c:893: warning: ‘path.dentry’ may be used uninitialized in this function
net/unix/af_unix.c:893: warning: ‘path.mnt’ may be used uninitialized in this function
drivers/gpu/drm/i915/i915_gem_gtt.c: In function ‘gen6_ggtt_insert_entries’:
drivers/gpu/drm/i915/i915_gem_gtt.c:440: warning: ‘addr’ may be used uninitialized in this function
drivers/isdn/hardware/mISDN/hfcpci.c: In function ‘hfcpci_softirq’:
drivers/isdn/hardware/mISDN/hfcpci.c:2298: warning: ignoring return value of ‘driver_for_each_device’, declared with attribute warn_unused_result
WARNING: drivers/iommu/built-in.o(.text+0x647c): Section mismatch in reference from the function iommu_init_pci() to the function .init.text:amd_iommu_erratum_746_workaround()
The function iommu_init_pci() references
the function __init amd_iommu_erratum_746_workaround().
This is often because iommu_init_pci lacks a __init 
annotation or the annotation of amd_iommu_erratum_746_workaround is wrong.

drivers/scsi/aic94xx/aic94xx_sds.c: In function ‘asd_process_ctrl_a_user’:
drivers/scsi/aic94xx/aic94xx_sds.c:985: warning: ‘offs’ may be used uninitialized in this function
drivers/net/wireless/wl3501_cs.c: In function ‘wl3501_receive’:
drivers/net/wireless/wl3501_cs.c:756: warning: ‘next_addr’ may be used uninitialized in this function
drivers/net/wireless/wl3501_cs.c:785: warning: ‘next_addr1’ may be used uninitialized in this function
drivers/md/dm-raid.c: In function ‘validate_raid_redundancy’:
drivers/md/dm-raid.c:383: warning: ‘rebuilds_per_group’ may be used uninitialized in this function
WARNING: drivers/built-in.o(.text+0x1dcc4c): Section mismatch in reference from the function iommu_init_pci() to the function .init.text:amd_iommu_erratum_746_workaround()
The function iommu_init_pci() references
the function __init amd_iommu_erratum_746_workaround().
This is often because iommu_init_pci lacks a __init 
annotation or the annotation of amd_iommu_erratum_746_workaround is wrong.

/home/remote/mchehab/linus/usr/include/linux/kexec.h:49: userspace cannot reference function or variable defined in the kernel
/home/remote/mchehab/linus/usr/include/linux/soundcard.h:1054: userspace cannot reference function or variable defined in the kernel
Documentation/misc-devices/mei/mei-amt-version.c: In function ‘main’:
Documentation/misc-devices/mei/mei-amt-version.c:381: warning: dereferencing pointer ‘response.31’ does break strict-aliasing rules
Documentation/misc-devices/mei/mei-amt-version.c:418: note: initialized from here
WARNING: vmlinux.o(.text+0x46bb7c): Section mismatch in reference from the function iommu_init_pci() to the function .init.text:amd_iommu_erratum_746_workaround()
The function iommu_init_pci() references
the function __init amd_iommu_erratum_746_workaround().
This is often because iommu_init_pci lacks a __init 
annotation or the annotation of amd_iommu_erratum_746_workaround is wrong.

Setup is 15148 bytes (padded to 15360 bytes).
System is 4217 kB
CRC 2ee9cecc

Perhaps it was something dirty on your building system. Did you do a "make clean" before compiling it?
Comment 2 Mauro Carvalho Chehab 2013-03-25 14:08:57 UTC
Created attachment 96111 [details]
Config file used on my test with Kernel 3.9-rc4

This is the .config I used for compilation here.

If the error persists after "make clean && make", please enclose the .config file for the broken setup.
Comment 3 Bernhard Seibold 2013-03-25 14:59:34 UTC
I can confirm that your config compiles while mine doesn't. Tested with latest git kernel.
Comment 4 Bernhard Seibold 2013-03-25 15:00:18 UTC
Created attachment 96121 [details]
broken config
Comment 5 Mauro Carvalho Chehab 2013-03-25 15:39:38 UTC
Created attachment 96131 [details]
Fix compilation breakage when VIDEO_DEV=y, I2C=m, V4L2=m

The issue happens when VIDEO_DEV=y, I2C=m, V4L2=m, as now a needed I2C code is compiled builtin, while I2C core is a module.

The enclosed patch fixes it.

Thanks for reporting it!