linux/drivers/cxl
Dan Williams 34e37b4c43 cxl/port: Enable HDM Capability after validating DVSEC Ranges
CXL memory expanders that support the CXL 2.0 memory device class code
include an "HDM Decoder Capability" mechanism to supplant the "CXL DVSEC
Range" mechanism originally defined in CXL 1.1. Both mechanisms depend
on a "mem_enable" bit being set in configuration space before either
mechanism activates. When the HDM Decoder Capability is enabled the CXL
DVSEC Range settings are ignored.

Previously, the cxl_mem driver was relying on platform-firmware to set
"mem_enable". That is an invalid assumption as there is no requirement
that platform-firmware sets the bit before the driver sees a device,
especially in hot-plug scenarios. Additionally, ACPI-platforms that
support CXL 2.0 devices also support the ACPI CEDT (CXL Early Discovery
Table). That table outlines the platform permissible address ranges for
CXL operation. So, there is a need for the driver to set "mem_enable",
and there is information available to determine the validity of the CXL
DVSEC Ranges.

Arrange for the driver to optionally enable the HDM Decoder Capability
if "mem_enable" was not set by platform firmware, or the CXL DVSEC Range
configuration was invalid. Be careful to only disable memory decode if
the kernel was the one to enable it. In other words, if CXL is backing
all of kernel memory at boot the device needs to maintain "mem_enable"
and "HDM Decoder enable" all the way up to handoff back to platform
firmware (e.g. ACPI S5 state entry may require CXL memory to stay
active).

Fixes: 560f785590 ("cxl/pci: Retrieve CXL DVSEC memory info")
Cc: Dan Carpenter <dan.carpenter@oracle.com>
[dan: fix early terminiation of range-allowed loop]
Cc: Ariel Sibley <ariel.sibley@microchip.com>
[ariel: Memory_size must be non-zero]
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/165307136375.2499769.861793697156744166.stgit@dwillia2-xfh
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2022-05-20 12:30:53 -07:00
..
core cxl/port: Enable HDM Capability after validating DVSEC Ranges 2022-05-20 12:30:53 -07:00
acpi.c cxl/acpi: Add root device lockdep validation 2022-04-28 14:01:54 -07:00
cxl.h cxl: Drop cxl_device_lock() 2022-04-28 14:01:55 -07:00
cxlmem.h cxl/mem: Consolidate CXL DVSEC Range enumeration in the core 2022-05-19 08:50:41 -07:00
cxlpci.h cxl/port: Reuse 'struct cxl_hdm' context for hdm init 2022-05-19 08:50:42 -07:00
Kconfig PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00
Makefile PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00
mem.c cxl/port: Move endpoint HDM Decoder Capability init to port driver 2022-05-19 08:50:41 -07:00
pci.c cxl/mem: Consolidate CXL DVSEC Range enumeration in the core 2022-05-19 08:50:41 -07:00
pmem.c cxl: Drop cxl_device_lock() 2022-04-28 14:01:55 -07:00
port.c cxl/port: Reuse 'struct cxl_hdm' context for hdm init 2022-05-19 08:50:42 -07:00