OSDN Git Service

cxl/pmem: Introduce a find_cxl_root() helper
authorDan Williams <dan.j.williams@intel.com>
Tue, 1 Feb 2022 00:34:40 +0000 (16:34 -0800)
committerDan Williams <dan.j.williams@intel.com>
Wed, 9 Feb 2022 06:57:29 +0000 (22:57 -0800)
commita46cfc0f011ce77d120e1cdbf973f733d18f0105
tree23e0e0255d7b091d6532c672725d2adc253b61ac
parent5ff7316f6fea4798c66b1ba953d1ebe6617503e4
cxl/pmem: Introduce a find_cxl_root() helper

In preparation for switch port enumeration while also preserving the
potential for multi-domain / multi-root CXL topologies. Introduce a
'struct device' generic mechanism for retrieving a root CXL port, if one
is registered. Note that the only known multi-domain CXL configurations
are running the cxl_test unit test on a system that also publishes an
ACPI0017 device.

With this in hand the nvdimm-bridge lookup can be with
device_find_child() instead of bus_find_device() + custom mocked lookup
infrastructure in cxl_test.

The mechanism looks for a 2nd level port since the root level topology
is platform-firmware specific and the 2nd level down follows standard
PCIe topology expectations. The cxl_acpi 2nd level is associated with a
PCIe Root Port.

Reported-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/164367562182.225521.9488555616768096049.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/pmem.c
drivers/cxl/core/port.c
drivers/cxl/cxl.h
tools/testing/cxl/Kbuild
tools/testing/cxl/mock_pmem.c [deleted file]