linux/drivers/cxl/core
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.h cxl/core/hdm: Add CXL standard decoder enumeration to the core 2022-02-08 22:57:30 -08:00
hdm.c cxl/core/port: Handle invalid decoders 2022-02-08 23:15:10 -08:00
Makefile PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00
mbox.c cxl/mbox: fix logical vs bitwise typo 2022-04-28 10:18:31 -07:00
memdev.c cxl: Replace lockdep_mutex with local lock classes 2022-04-28 14:01:54 -07:00
pci.c cxl/port: Enable HDM Capability after validating DVSEC Ranges 2022-05-20 12:30:53 -07:00
pmem.c cxl: Drop cxl_device_lock() 2022-04-28 14:01:55 -07:00
port.c cxl: Drop cxl_device_lock() 2022-04-28 14:01:55 -07:00
regs.c cxl/regs: Fix size of CXL Capability Header Register 2022-02-08 23:15:33 -08:00
suspend.c PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00