Skip to content

Commit ca53543

Browse files
davejiangdjbw
authored andcommitted
acpi: numa: Add helper function to retrieve the performance attributes
Add helper to retrieve the performance attributes based on the device handle. The helper function is exported so the CXL driver can use that to acquire the performance data between the CPU and the CXL host bridge. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/170319618721.2212653.5552947472849081786.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent a3a3e34 commit ca53543

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

drivers/acpi/numa/hmat.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,47 @@ static struct memory_target *find_mem_target(unsigned int mem_pxm)
108108
return NULL;
109109
}
110110

111+
static struct memory_target *acpi_find_genport_target(u32 uid)
112+
{
113+
struct memory_target *target;
114+
u32 target_uid;
115+
u8 *uid_ptr;
116+
117+
list_for_each_entry(target, &targets, node) {
118+
uid_ptr = target->gen_port_device_handle + 8;
119+
target_uid = *(u32 *)uid_ptr;
120+
if (uid == target_uid)
121+
return target;
122+
}
123+
124+
return NULL;
125+
}
126+
127+
/**
128+
* acpi_get_genport_coordinates - Retrieve the access coordinates for a generic port
129+
* @uid: ACPI unique id
130+
* @coord: The access coordinates written back out for the generic port
131+
*
132+
* Return: 0 on success. Errno on failure.
133+
*
134+
* Only supports device handles that are ACPI. Assume ACPI0016 HID for CXL.
135+
*/
136+
int acpi_get_genport_coordinates(u32 uid,
137+
struct access_coordinate *coord)
138+
{
139+
struct memory_target *target;
140+
141+
guard(mutex)(&target_lock);
142+
target = acpi_find_genport_target(uid);
143+
if (!target)
144+
return -ENOENT;
145+
146+
*coord = target->coord[NODE_ACCESS_CLASS_GENPORT_SINK];
147+
148+
return 0;
149+
}
150+
EXPORT_SYMBOL_NS_GPL(acpi_get_genport_coordinates, CXL);
151+
111152
static __init void alloc_memory_initiator(unsigned int cpu_pxm)
112153
{
113154
struct memory_initiator *initiator;

include/linux/acpi.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/mod_devicetable.h>
1616
#include <linux/property.h>
1717
#include <linux/uuid.h>
18+
#include <linux/node.h>
1819

1920
struct irq_domain;
2021
struct irq_domain_ops;
@@ -424,6 +425,16 @@ extern int acpi_blacklisted(void);
424425
extern void acpi_osi_setup(char *str);
425426
extern bool acpi_osi_is_win8(void);
426427

428+
#ifdef CONFIG_ACPI_HMAT
429+
int acpi_get_genport_coordinates(u32 uid, struct access_coordinate *coord);
430+
#else
431+
static inline int acpi_get_genport_coordinates(u32 uid,
432+
struct access_coordinate *coord)
433+
{
434+
return -EOPNOTSUPP;
435+
}
436+
#endif
437+
427438
#ifdef CONFIG_ACPI_NUMA
428439
int acpi_map_pxm_to_node(int pxm);
429440
int acpi_get_node(acpi_handle handle);

0 commit comments

Comments
 (0)