linux/drivers/base
Saravana Kannan d122e95dc6 BACKPORT: driver core: Fix SYNC_STATE_ONLY device link implementation
When SYNC_STATE_ONLY support was added in commit 05ef983e0d ("driver
core: Add device link support for SYNC_STATE_ONLY flag"),
device_link_add() incorrectly skipped adding the new SYNC_STATE_ONLY
device link to the supplier's and consumer's "device link" list.

This causes multiple issues:
- The device link is lost forever from driver core if the caller
  didn't keep track of it (caller typically isn't expected to). This is
  a memory leak.
- The device link is also never visible to any other code path after
  device_link_add() returns.

If we fix the "device link" list handling, that exposes a bunch of
issues.

1. The device link "status" state management code rightfully doesn't
handle the case where a DL_FLAG_MANAGED device link exists between a
supplier and consumer, but the consumer manages to probe successfully
before the supplier. The addition of DL_FLAG_SYNC_STATE_ONLY links break
this assumption. This causes device_links_driver_bound() to throw a
warning when this happens.

Since DL_FLAG_SYNC_STATE_ONLY device links are mainly used for creating
proxy device links for child device dependencies and aren't useful once
the consumer device probes successfully, this patch just deletes
DL_FLAG_SYNC_STATE_ONLY device links once its consumer device probes.
This way, we avoid the warning, free up some memory and avoid
complicating the device links "status" state management code.

2. Creating a DL_FLAG_STATELESS device link between two devices that
already have a DL_FLAG_SYNC_STATE_ONLY device link will result in the
DL_FLAG_STATELESS flag not getting set correctly. This patch also fixes
this.

Lastly, this patch also fixes minor whitespace issues.

Cc: stable@vger.kernel.org
Fixes: 05ef983e0d ("driver core: Add device link support for SYNC_STATE_ONLY flag")
Signed-off-by: Saravana Kannan <saravanak@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20200519063000.128819-1-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 21c27f0658)
Bug: 157103558
[minor dev_dbg vs dev_info conflict resolution]
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: Icb091de185c7efbb7db0ec86267675ac0472f379
2020-05-28 14:59:57 -07:00
..
firmware_loader This is the 4.19.116 stable release 2020-04-18 13:33:51 +02:00
power ANDROID: power: wakeup_reason: wake reason enhancements 2020-04-09 15:27:37 +00:00
regmap ANDROID: GKI: regmap: irq: Add support to clear ack registers 2020-04-08 00:21:27 -07:00
test
arch_topology.c ANDROID: implement max frequency capping 2018-10-26 12:25:24 +01:00
attribute_container.c
base.h driver core: Establish order of operations for device_add and device_del via bitflag 2019-08-09 17:52:28 +02:00
bus.c kobject: return error code if writing /sys/.../uevent fails 2019-02-12 19:47:06 +01:00
cacheinfo.c drivers: base: cacheinfo: Ensure cpu hotplug work is done before Intel RDT 2019-07-21 09:03:03 +02:00
class.c
component.c component: Silence bind error on -EPROBE_DEFER 2020-05-27 17:37:33 +02:00
container.c
core.c BACKPORT: driver core: Fix SYNC_STATE_ONLY device link implementation 2020-05-28 14:59:57 -07:00
cpu.c This is the 4.19.84 stable release 2019-11-14 14:15:21 +08:00
dd.c driver core: Add device link flag DL_FLAG_AUTOPROBE_CONSUMER 2020-03-20 11:55:58 +01:00
devcon.c
devcoredump.c
devres.c devres: Align data[] to ARCH_KMALLOC_MINALIGN 2019-02-12 19:46:56 +01:00
devtmpfs.c
driver.c
firmware.c
hypervisor.c
init.c
isa.c
Kconfig UPSTREAM: Make anon_inodes unconditional 2019-08-12 13:36:37 -04:00
Makefile
map.c
memory.c mm/memory_hotplug: fix try_offline_node() 2020-01-29 16:43:27 +01:00
module.c
node.c This is the 4.19.100 stable release 2020-01-29 17:10:45 +01:00
pinctrl.c
platform-msi.c platform-msi: Free descriptors in platform_msi_domain_free() 2019-01-09 17:38:42 +01:00
platform.c driver core: platform: fix u32 greater or equal to zero comparison 2020-02-24 08:34:50 +01:00
property.c
soc.c ANDROID: GKI: drivers: base: soc: export symbols for socinfo 2020-04-10 18:15:14 -07:00
syscore.c ANDROID: power: wakeup_reason: add an API to log wakeup reasons 2018-12-05 09:48:13 -08:00
topology.c
transport_class.c