Skip to content

Commit 1037b82

Browse files
davejiangdjbw
authored andcommitted
cxl: Store the access coordinates for the generic ports
Each CXL host bridge is represented by an ACPI0016 device. A generic port device handle that is an ACPI device is represented by a string of ACPI0016 device HID and UID. Create a device handle from the ACPI device and retrieve the access coordinates from the stored memory targets. The access coordinates are stored under the cxl_dport that is associated with the CXL host bridge. The access coordinates struct is dynamically allocated under cxl_dport in order for code later on to detect whether the data exists or not. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/170319623196.2212653.17916695743464172534.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent f2202f9 commit 1037b82

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

drivers/cxl/acpi.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,29 @@ static int cxl_get_chbs(struct device *dev, struct acpi_device *hb,
513513
return 0;
514514
}
515515

516+
static int get_genport_coordinates(struct device *dev, struct cxl_dport *dport)
517+
{
518+
struct acpi_device *hb = to_cxl_host_bridge(NULL, dev);
519+
u32 uid;
520+
int rc;
521+
522+
if (kstrtou32(acpi_device_uid(hb), 0, &uid))
523+
return -EINVAL;
524+
525+
rc = acpi_get_genport_coordinates(uid, &dport->hb_coord);
526+
if (rc < 0)
527+
return rc;
528+
529+
/* Adjust back to picoseconds from nanoseconds */
530+
dport->hb_coord.read_latency *= 1000;
531+
dport->hb_coord.write_latency *= 1000;
532+
533+
return 0;
534+
}
535+
516536
static int add_host_bridge_dport(struct device *match, void *arg)
517537
{
538+
int ret;
518539
acpi_status rc;
519540
struct device *bridge;
520541
struct cxl_dport *dport;
@@ -564,6 +585,10 @@ static int add_host_bridge_dport(struct device *match, void *arg)
564585
if (IS_ERR(dport))
565586
return PTR_ERR(dport);
566587

588+
ret = get_genport_coordinates(match, dport);
589+
if (ret)
590+
dev_dbg(match, "Failed to get generic port perf coordinates.\n");
591+
567592
return 0;
568593
}
569594

drivers/cxl/cxl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ struct cxl_rcrb_info {
661661
* @port: reference to cxl_port that contains this downstream port
662662
* @regs: Dport parsed register blocks
663663
* @sw_coord: access coordinates (performance) for switch from CDAT
664+
* @hb_coord: access coordinates (performance) from ACPI generic port (host bridge)
664665
* @link_latency: calculated PCIe downstream latency
665666
*/
666667
struct cxl_dport {
@@ -672,6 +673,7 @@ struct cxl_dport {
672673
struct cxl_port *port;
673674
struct cxl_regs regs;
674675
struct access_coordinate sw_coord;
676+
struct access_coordinate hb_coord;
675677
long link_latency;
676678
};
677679

0 commit comments

Comments
 (0)