]> git.itanic.dy.fi Git - linux-stable/commit
cxl/port: Enable the HDM decoder capability for switch ports
authorDan Williams <dan.j.williams@intel.com>
Thu, 18 May 2023 03:19:43 +0000 (20:19 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 18 May 2023 20:18:49 +0000 (13:18 -0700)
commiteb0764b822b9b26880b28ccb9100b2983e01bc17
tree2f36af9d02fb292903e4c2795fbad46d669bc0c4
parentf1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
cxl/port: Enable the HDM decoder capability for switch ports

Derick noticed, when testing hot plug, that hot-add behaves nominally
after a removal. However, if the hot-add is done without a prior
removal, CXL.mem accesses fail. It turns out that the original
implementation of the port driver and region programming wrongly assumed
that platform-firmware always enables the host-bridge HDM decoder
capability. Add support turning on switch-level HDM decoders in the case
where platform-firmware has not.

The implementation is careful to only arrange for the enable to be
undone if the current instance of the driver was the one that did the
enable. This is to interoperate with platform-firmware that may expect
CXL.mem to remain active after the driver is shutdown. This comes at the
cost of potentially not shutting down the enable on kexec flows, but it
is mitigated by the fact that the related HDM decoders still need to be
enabled on an individual basis.

Cc: <stable@vger.kernel.org>
Reported-by: Derick Marks <derick.w.marks@intel.com>
Fixes: 54cdbf845cf7 ("cxl/port: Add a driver for 'struct cxl_port' objects")
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/168437998331.403037.15719879757678389217.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/pci.c
drivers/cxl/cxl.h
drivers/cxl/port.c
tools/testing/cxl/Kbuild
tools/testing/cxl/test/mock.c