1
0
Fork 0
alistair23-linux/drivers/base
Rafael J. Wysocki 15cfb09416 driver core: Fix adding device links to probing suppliers
Currently, it is not valid to add a device link from a consumer
driver ->probe callback to a supplier that is still probing too, but
generally this is a valid use case.  For example, if the consumer has
just acquired a resource that can only be available if the supplier
is functional, adding a device link to that supplier right away
should be safe (and even desirable arguably), but device_link_add()
doesn't handle that case correctly and the initial state of the link
created by it is wrong then.

To address this problem, change the initial state of device links
added between a probing supplier and a probing consumer to
DL_STATE_CONSUMER_PROBE and update device_links_driver_bound() to
skip such links on the supplier side.

With this change, if the supplier probe completes first,
device_links_driver_bound() called for it will skip the link state
update and when it is called for the consumer, the link state will
be updated to "active".  In turn, if the consumer probe completes
first, device_links_driver_bound() called for it will change the
state of the link to "active" and when it is called for the
supplier, the link status update will be skipped.

However, in principle the supplier or consumer probe may still fail
after the link has been added, so modify device_links_no_driver() to
change device links in the "active" or "consumer probe" state to
"dormant" on the supplier side and update __device_links_no_driver()
to change the link state to "available" only if it is "consumer
probe" or "active".

Then, if the supplier probe fails first, the leftover link to the
probing consumer will become "dormant" and device_links_no_driver()
called for the consumer (when its probe fails) will clean it up.
In turn, if the consumer probe fails first, it will either drop the
link, or change its state to "available" and, in the latter case,
when device_links_no_driver() is called for the supplier, it will
update the link state to "dormant".  [If the supplier probe fails,
but the consumer probe succeeds, which should not happen as long as
the consumer driver is correct, the link still will be around, but
it will be "dormant" until the supplier is probed again.]

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-01 10:04:08 +01:00
..
firmware_loader firmware_loader: move firmware/ to drivers/base/firmware_loader/builtin/ 2019-01-22 10:23:18 +01:00
power driver core: Fix handling of runtime PM flags in device_link_add() 2019-02-01 10:04:08 +01:00
regmap Merge remote-tracking branch 'regmap/topic/irq' into regmap-next 2018-12-19 18:38:33 +00:00
test driver core: Rewrite test_async_driver_probe to cover serialization and NUMA affinity 2019-01-31 14:20:54 +01:00
Kconfig firmware_loader: move kconfig FW_LOADER entries to its own file 2018-05-14 16:43:10 +02:00
Makefile drivers: base: Introducing software nodes to the firmware node framework 2018-11-26 18:19:11 +01:00
arch_topology.c sched/topology, drivers/base/arch_topology: Rebuild the sched_domain hierarchy when capacities change 2018-09-10 11:05:47 +02:00
attribute_container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
base.h driver core: Probe devices asynchronously instead of the driver 2019-01-31 14:20:53 +01:00
bus.c driver core: Probe devices asynchronously instead of the driver 2019-01-31 14:20:53 +01:00
cacheinfo.c drivers: base: cacheinfo: Do not populate sysfs for unknown cache types 2018-10-04 23:02:17 +02:00
class.c driver core: move device->knode_class to device_private 2019-01-18 16:55:48 +01:00
component.c component: convert to DEFINE_SHOW_ATTRIBUTE 2018-12-20 16:33:18 +01:00
container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
core.c driver core: Fix adding device links to probing suppliers 2019-02-01 10:04:08 +01:00
cpu.c drivers: base: Use __printf markup to silence compiler 2019-01-31 19:28:40 +01:00
dd.c driver core: Attach devices on CPU local to device node 2019-01-31 14:20:54 +01:00
devcon.c drivers: base: Unified device connection lookup 2018-03-22 13:10:29 +01:00
devcoredump.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
devres.c devres: Align data[] to ARCH_KMALLOC_MINALIGN 2018-11-11 11:40:04 -08:00
devtmpfs.c vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled 2018-12-20 16:32:56 +00:00
driver.c driver-core: return EINVAL error instead of BUG_ON() 2018-05-25 18:18:45 +02:00
firmware.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
hypervisor.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
init.c base: fix order of OF initialization 2018-07-07 17:54:29 +02:00
isa.c Merge 4.15-rc3 into driver-core-next 2017-12-11 08:50:05 +01:00
map.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
memory.c Driver core patches for 4.21-rc1 2018-12-28 20:44:29 -08:00
module.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
node.c mm, proc: add KReclaimable to /proc/meminfo 2018-10-26 16:26:32 -07:00
pinctrl.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
platform-msi.c platform-msi: Free descriptors in platform_msi_domain_free() 2018-12-13 09:35:31 +00:00
platform.c drivers/base/platform.c: kmemleak ignore a known leak 2019-01-04 13:13:48 -08:00
property.c device property: fix fwnode_graph_get_next_endpoint() documentation 2018-12-18 23:39:45 +01:00
soc.c base: soc: use put_device() instead of kfree() 2018-03-15 14:37:03 +01:00
swnode.c drivers: base: swnode: check if swnode is NULL before dereferencing it 2018-12-26 10:50:36 +01:00
syscore.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
topology.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
transport_class.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00