1
0
Fork 0
alistair23-linux/drivers
Vadim Pasternak fa882fc80d platform/x86: mlx-platform: Fix parent device in i2c-mux-reg device registration
Fix the issue found while running kernel with the option
CONFIG_DEBUG_TEST_DRIVER_REMOVE.
Driver 'mlx-platform' registers 'i2c_mlxcpld' device and then registers
few underlying 'i2c-mux-reg' devices:
	priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", nr,
							 NULL, 0);
	...
	for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) {
		priv->pdev_mux[i] = platform_device_register_resndata(
						&mlxplat_dev->dev,
						"i2c-mux-reg", i, NULL,
						0, &mlxplat_mux_data[i],
						sizeof(mlxplat_mux_data[i]));

But actual parent of "i2c-mux-reg" device is priv->pdev_i2c->dev and
not mlxplat_dev->dev.
Patch fixes parent device parameter in a call to
platform_device_register_resndata() for "i2c-mux-reg".

It solves the race during initialization flow while 'i2c_mlxcpld.1' is
removing after probe, while 'i2c-mux-reg.0' is still in probing flow:
'i2c_mlxcpld.1'	flow:	probe -> remove -> probe.
'i2c-mux-reg.0'	flow:		  probe -> ...

[   12:621096] Registering platform device 'i2c_mlxcpld.1'. Parent at platform
[   12:621117] device: 'i2c_mlxcpld.1': device_add
[   12:621155] bus: 'platform': add device i2c_mlxcpld.1
[   12:621384] Registering platform device 'i2c-mux-reg.0'. Parent at mlxplat
[   12:621395] device: 'i2c-mux-reg.0': device_add
[   12:621425] bus: 'platform': add device i2c-mux-reg.0
[   12:621806] Registering platform device 'i2c-mux-reg.1'. Parent at mlxplat
[   12:621828] device: 'i2c-mux-reg.1': device_add
[   12:621892] bus: 'platform': add device i2c-mux-reg.1
[   12:621906] bus: 'platform': add driver i2c_mlxcpld
[   12:621996] bus: 'platform': driver_probe_device: matched device i2c_mlxcpld.1 with driver i2c_mlxcpld
[   12:622003] bus: 'platform': really_probe: probing driver i2c_mlxcpld with device i2c_mlxcpld.1
[   12:622100] i2c_mlxcpld i2c_mlxcpld.1: no default pinctrl state
[   12:622293] device: 'i2c-1': device_add
[   12:627280] bus: 'i2c': add device i2c-1
[   12:627692] device: 'i2c-1': device_add
[   12.629639] bus: 'platform': add driver i2c-mux-reg
[   12.629718] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
[   12.629723] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
[   12.629818] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
[   12.629981] platform i2c-mux-reg.0: Driver i2c-mux-reg requests probe deferral
[   12.629986] platform i2c-mux-reg.0: Added to deferred list
[   12.629992] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.1 with driver i2c-mux-reg
[   12.629997] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.1
[   12.630091] i2c-mux-reg i2c-mux-reg.1: no default pinctrl state
[   12.630247] platform i2c-mux-reg.1: Driver i2c-mux-reg requests probe deferral
[   12.630252] platform i2c-mux-reg.1: Added to deferred list
[   12.640892] devices_kset: Moving i2c-mux-reg.0 to end of list
[   12.640900] platform i2c-mux-reg.0: Retrying from deferred list
[   12.640911] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
[   12.640919] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
[   12.640999] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
[   12.641177] platform i2c-mux-reg.0: Driver i2c-mux-reg requests probe deferral
[   12.641187] platform i2c-mux-reg.0: Added to deferred list
[   12.641198] devices_kset: Moving i2c-mux-reg.1 to end of list
[   12.641219] platform i2c-mux-reg.1: Retrying from deferred list
[   12.641237] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.1 with driver i2c-mux-reg
[   12.641247] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.1
[   12.641331] i2c-mux-reg i2c-mux-reg.1: no default pinctrl state
[   12.641465] platform i2c-mux-reg.1: Driver i2c-mux-reg requests probe deferral
[   12.641469] platform i2c-mux-reg.1: Added to deferred list
[   12.646427] device: 'i2c-1': device_add
[   12.646647] bus: 'i2c': add device i2c-1
[   12.647104] device: 'i2c-1': device_add
[   12.669231] devices_kset: Moving i2c-mux-reg.0 to end of list
[   12.669240] platform i2c-mux-reg.0: Retrying from deferred list
[   12.669258] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
[   12.669263] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
[   12.669343] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
[   12.669585] device: 'i2c-2': device_add
[   12.669795] bus: 'i2c': add device i2c-2
[   12.670201] device: 'i2c-2': device_add
[   12.671427] i2c i2c-1: Added multiplexed i2c bus 2
[   12.671514] device: 'i2c-3': device_add
[   12.671724] bus: 'i2c': add device i2c-3
[   12.672136] device: 'i2c-3': device_add
[   12.673378] i2c i2c-1: Added multiplexed i2c bus 3
[   12.673472] device: 'i2c-4': device_add
[   12.673676] bus: 'i2c': add device i2c-4
[   12.674060] device: 'i2c-4': device_add
[   12.675861] i2c i2c-1: Added multiplexed i2c bus 4
[   12.675941] device: 'i2c-5': device_add
[   12.676150] bus: 'i2c': add device i2c-5
[   12.676550] device: 'i2c-5': device_add
[   12.678103] i2c i2c-1: Added multiplexed i2c bus 5
[   12.678193] device: 'i2c-6': device_add
[   12.678395] bus: 'i2c': add device i2c-6
[   12.678774] device: 'i2c-6': device_add
[   12.679969] i2c i2c-1: Added multiplexed i2c bus 6
[   12.680065] device: 'i2c-7': device_add
[   12.680275] bus: 'i2c': add device i2c-7
[   12.680913] device: 'i2c-7': device_add
[   12.682506] i2c i2c-1: Added multiplexed i2c bus 7
[   12.682600] device: 'i2c-8': device_add
[   12.682808] bus: 'i2c': add device i2c-8
[   12.683189] device: 'i2c-8': device_add
[   12.683907] device: 'i2c-1': device_unregister
[   12.683945] device: 'i2c-1': device_unregister
[   12.684387] device: 'i2c-1': device_create_release
[   12.684536] bus: 'i2c': remove device i2c-1
[   12.686019] i2c i2c-8: Failed to create compatibility class link
[   12.686086] ------------[ cut here ]------------
[   12.686087] can't create symlink to mux device
[   12.686224] Workqueue: events deferred_probe_work_func
[   12.686135] WARNING: CPU: 7 PID: 436 at drivers/i2c/i2c-mux.c:416 i2c_mux_add_adapter+0x729/0x7d0 [i2c_mux]
[   12.686232] RIP: 0010:i2c_mux_add_adapter+0x729/0x7d0 [i2c_mux]
[   0x190/0x190 [i2c_mux]
[   12.686300]  ? i2c_mux_alloc+0xac/0x110 [i2c_mux]
[   12.686306]  ? i2c_mux_reg_set+0x200/0x200 [i2c_mux_reg]
[   12.686313]  i2c_mux_reg_probe+0x22c/0x731 [i2c_mux_reg]
[   12.686322]  ? i2c_mux_reg_deselect+0x60/0x60 [i2c_mux_reg]
[   12.686346]  platform_drv_probe+0xa8/0x110
[   12.686351]  really_probe+0x185/0x720
[   12.686358]  driver_probe_device+0xdf/0x1f0
...
[   12.686522] i2c i2c-1: Added multiplexed i2c bus 8
[   12.686621] device: 'i2c-9': device_add
[   12.686626] kobject_add_internal failed for i2c-9 (error: -2 parent: i2c-1)
[   12.694729] i2c-core: adapter 'i2c-1-mux (chan_id 8)': can't register device (-2)
[   12.705726] i2c i2c-1: failed to add mux-adapter 8 as bus 9 (error=-2)
[   12.714494] device: 'i2c-8': device_unregister
[   12.714537] device: 'i2c-8': device_unregister

Fixes: 6613d18e90 ("platform/x86: mlx-platform: Move module from arch/x86")
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2019-06-12 11:54:16 +03:00
..
accessibility
acpi One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
amba amba: tegra-ahb: Mark PM functions as __maybe_unused 2019-05-08 14:40:39 +02:00
android Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
ata for-5.2/block-post-20190516 2019-05-16 19:08:15 -07:00
atm
auxdisplay
base More power management updates for 5.2-rc1 2019-05-15 08:46:44 -07:00
bcma
block for-5.2/block-post-20190516 2019-05-16 19:08:15 -07:00
bluetooth Bluetooth: hci_qca: Rename STATE_<flags> to QCA_<flags> 2019-05-05 19:34:00 +02:00
bus ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
cdrom
char Some minor cleanups for the IPMI driver. 2019-05-08 10:34:17 -07:00
clk One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
clocksource Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 11:11:20 -07:00
connector
counter
cpufreq One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
cpuidle
crypto ARM: SoC platform updates 2019-05-16 08:31:32 -07:00
dax libnvdimm fixes 5.2-rc1 2019-05-15 18:56:50 -07:00
dca
devfreq
dio
dma dmaengine updates for v5.2-rc1 2019-05-09 08:51:45 -07:00
dma-buf drm i915, amdgpu, nouveau, msm, panfrost, bridge, pl111 fixes 2019-05-16 07:22:42 -07:00
edac * Do not build mpc85_edac as a module (Michael Ellerman) 2019-05-16 11:55:35 -07:00
eisa
extcon Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
firewire drivers/firewire/core-iso.c: convert to use vm_map_pages_zero() 2019-05-14 09:47:50 -07:00
firmware Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 10:58:45 -07:00
fmc
fpga ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
fsi
gnss Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
gpio Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 10:58:45 -07:00
gpu One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
hid treewide: prefix header search paths with $(srctree)/ 2019-05-18 11:49:57 +09:00
hsi
hv
hwmon Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2019-05-16 16:16:18 -07:00
hwspinlock
hwtracing Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
i2c i2c: core: add device-managed version of i2c_new_dummy 2019-05-17 19:29:40 +02:00
i3c * Fix a shift wrap bug in the core 2019-05-07 08:50:40 -07:00
ide ide: officially deprecated the legacy IDE driver 2019-05-08 16:47:23 -07:00
idle
iio power supply and reset changes for the v5.2 series 2019-05-15 18:50:40 -07:00
infiniband 5.2 Merge Window second pull request 2019-05-14 20:56:31 -07:00
input ARM: SoC platform updates 2019-05-16 08:31:32 -07:00
interconnect
iommu Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 10:58:45 -07:00
ipack
irqchip Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 10:58:45 -07:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-05-07 22:03:58 -07:00
leds - Core Frameworks 2019-05-14 10:39:08 -07:00
lightnvm lightnvm: pblk: use nvm_rq_to_ppa_list() 2019-05-06 10:19:19 -06:00
macintosh
mailbox One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
mcb
md - Improve DM snapshot target's scalability by using finer grained 2019-05-16 15:55:48 -07:00
media media: prefix header search paths with $(srctree)/ 2019-05-18 11:49:56 +09:00
memory One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
memstick MMC core: 2019-05-07 12:56:19 -07:00
message
mfd One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
misc Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 11:11:20 -07:00
mmc One more patch to remove io.h from clk-provider.h. We used to need this 2019-05-16 19:05:35 -07:00
mtd treewide: replace #include <asm/sizes.h> with #include <linux/sizes.h> 2019-05-14 19:52:52 -07:00
mux
net treewide: prefix header search paths with $(srctree)/ 2019-05-18 11:49:57 +09:00
nfc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-05-07 22:03:58 -07:00
ntb
nubus
nvdimm libnvdimm fixes 5.2-rc1 2019-05-15 18:56:50 -07:00
nvme for-5.2/block-post-20190516 2019-05-16 19:08:15 -07:00
nvmem ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
of of_net: Fix missing of_find_device_by_node ref count drop 2019-05-13 08:52:37 -07:00
opp
oprofile
parisc parisc: Skip registering LED when running in QEMU 2019-05-03 23:47:39 +02:00
parport DMA mapping updates for 5.2 2019-05-09 08:40:55 -07:00
pci pci-v5.2-changes 2019-05-14 10:30:10 -07:00
pcmcia treewide: replace #include <asm/sizes.h> with #include <linux/sizes.h> 2019-05-14 19:52:52 -07:00
perf
phy USB/PHY patches for 5.2-rc1 2019-05-08 10:03:52 -07:00
pinctrl - Core Frameworks 2019-05-14 10:39:08 -07:00
platform platform/x86: mlx-platform: Fix parent device in i2c-mux-reg device registration 2019-06-12 11:54:16 +03:00
pnp
power power: supply: olpc_battery: Allow building the driver on non-x86 2019-05-20 17:27:08 +03:00
powercap
pps pps: pps-gpio PPS ECHO implementation 2019-05-14 19:52:51 -07:00
ps3
ptp ptp_qoriq: fix NULL access if ptp dt node missing 2019-05-09 09:19:26 -07:00
pwm Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 11:11:20 -07:00
rapidio rapidio: fix a NULL pointer dereference when create_workqueue() fails 2019-05-14 19:52:50 -07:00
ras
regulator Merge branch 'regulator-5.2' into regulator-next 2019-05-06 22:52:14 +09:00
remoteproc
reset ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
rpmsg
rtc ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
s390 s390 updates for the 5.2 merge window #2 2019-05-17 10:08:59 -07:00
sbus mm/gup: change GUP fast to use flags rather than a write 'bool' 2019-05-14 09:47:46 -07:00
scsi mm/gup: change GUP fast to use flags rather than a write 'bool' 2019-05-14 09:47:46 -07:00
sfi
sh treewide: replace #include <asm/sizes.h> with #include <linux/sizes.h> 2019-05-14 19:52:52 -07:00
siox
slimbus
sn
soc Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 10:58:45 -07:00
soundwire
spi ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
spmi
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-05-07 22:03:58 -07:00
staging media updates for v5.2-rc1 2019-05-16 11:57:16 -07:00
target treewide: prefix header search paths with $(srctree)/ 2019-05-18 11:49:57 +09:00
tc
tee ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
thermal Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2019-05-16 16:16:18 -07:00
thunderbolt Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
tty RISC-V Patches for the 5.2 Merge Window, Part 1 v3 2019-05-19 09:56:36 -07:00
uio
usb treewide: prefix header search paths with $(srctree)/ 2019-05-18 11:49:57 +09:00
uwb
vfio mm/gup: change GUP fast to use flags rather than a write 'bool' 2019-05-14 09:47:46 -07:00
vhost virtio: fixes, features 2019-05-14 14:12:59 -07:00
video fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types 2019-05-17 11:07:42 +02:00
virt drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl 2019-05-14 19:52:52 -07:00
virtio virtio/virtio_ring: do some comment fixes 2019-05-12 13:11:35 -04:00
visorbus
vlynq
vme
w1 Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
watchdog ARM: SoC platform updates 2019-05-16 08:31:32 -07:00
xen xen: fixes and features for 5.2-rc1 2019-05-15 18:44:52 -07:00
zorro
Kconfig
Makefile