cxl/core/port: Fix unregister_port() lock assertion
authorDan Williams <dan.j.williams@intel.com>
Wed, 9 Feb 2022 07:37:28 +0000 (23:37 -0800)
committerDan Williams <dan.j.williams@intel.com>
Fri, 11 Feb 2022 21:26:49 +0000 (13:26 -0800)
commit5c3c067b601bcbcd381214e3a40e666fda5f3d6f
treef5186bce2f7f40c457e678e0e276cb51a1da85bf
parent74b0fe80409733055971bbfaf33c80a33fddeeb3
cxl/core/port: Fix unregister_port() lock assertion

The device_lock_assert() in unregister_port() fails to pick the right
device leading to splats like the following from:

echo "ACPI0017:00" > /sys/bus/platform/drivers/cxl_acpi/unbind

 WARNING: CPU: 32 PID: 1147 at include/linux/device.h:787 unregister_port+0x49/0x50 [cxl_c
 [..]
 RIP: 0010:unregister_port+0x49/0x50 [cxl_core]
 [..]
 Call Trace:
  <TASK>
  release_nodes+0x63/0x80
  devres_release_all+0x8b/0xc0
  __device_release_driver+0x190/0x240
  device_driver_detach+0x3e/0xa0
  unbind_store+0x113/0x130

Fix it up to assert on the device_lock() for ACPI0017 for root and 1st
level ports, and parent ports for all the rest.

Fixes: 54cdbf845cf7 ("cxl/port: Add a driver for 'struct cxl_port' objects")
Reported-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Ben Widawsky <ben.widawsky@intel.com>
Link: https://lore.kernel.org/r/164439224893.2941117.18331456248117887720.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/port.c