]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cxl/port: Fix cxl_bus_rescan() vs bus_rescan_devices()
authorDan Williams <dan.j.williams@intel.com>
Wed, 23 Oct 2024 01:43:32 +0000 (18:43 -0700)
committerIra Weiny <ira.weiny@intel.com>
Fri, 25 Oct 2024 21:07:03 +0000 (16:07 -0500)
commit3d6ebf16438de5d712030fefbb4182b46373d677
tree4e8dbaf13856a7f9376d67e441e52443aa831ba6
parent6575b268157f37929948a8d1f3bafb3d7c055bc1
cxl/port: Fix cxl_bus_rescan() vs bus_rescan_devices()

It turns out since its original introduction, pre-2.6.12,
bus_rescan_devices() has skipped devices that might be in the process of
attaching or detaching from their driver. For CXL this behavior is
unwanted and expects that cxl_bus_rescan() is a probe barrier.

That behavior is simple enough to achieve with bus_for_each_dev() paired
with call to device_attach(), and it is unclear why bus_rescan_devices()
took the position of lockless consumption of dev->driver which is racy.

The "Fixes:" but no "Cc: stable" on this patch reflects that the issue
is merely by inspection since the bug that triggered the discovery of
this potential problem [1] is fixed by other means.  However, a stable
backport should do no harm.

Fixes: 8dd2bc0f8e02 ("cxl/mem: Add the cxl_mem driver")
Link: http://lore.kernel.org/20241004212504.1246-1-gourry@gourry.net
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://patch.msgid.link/172964781104.81806.4277549800082443769.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
drivers/cxl/core/port.c