|
|
26ccd9 |
From dba61cf8bb9bb96cde8dcf2c9a2dcc663074698b Mon Sep 17 00:00:00 2001
|
|
|
26ccd9 |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
26ccd9 |
Date: Fri, 5 Aug 2022 13:38:08 -0700
|
|
|
26ccd9 |
Subject: [PATCH 203/217] cxl/list: Add region to decoder listings
|
|
|
26ccd9 |
|
|
|
26ccd9 |
While decoders can be matched with regions by physical address, or filtered
|
|
|
26ccd9 |
by region, it is also useful to get a plain listing of the association.
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Link: https://lore.kernel.org/r/165973188860.1528532.17427805440366364536.stgit@dwillia2-xfh.jf.intel.com
|
|
|
26ccd9 |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
26ccd9 |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
26ccd9 |
---
|
|
|
26ccd9 |
Documentation/cxl/lib/libcxl.txt | 7 +++++++
|
|
|
26ccd9 |
cxl/json.c | 8 ++++++++
|
|
|
26ccd9 |
cxl/lib/libcxl.c | 34 ++++++++++++++++++++++++++++++++
|
|
|
26ccd9 |
cxl/lib/libcxl.sym | 1 +
|
|
|
26ccd9 |
cxl/libcxl.h | 1 +
|
|
|
26ccd9 |
5 files changed, 51 insertions(+)
|
|
|
26ccd9 |
|
|
|
26ccd9 |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
|
26ccd9 |
index 50b0c9c..6756d2f 100644
|
|
|
26ccd9 |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
|
26ccd9 |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
|
26ccd9 |
@@ -398,6 +398,7 @@ int cxl_decoder_set_dpa_size(struct cxl_decoder *decoder, unsigned long long siz
|
|
|
26ccd9 |
const char *cxl_decoder_get_devname(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
int cxl_decoder_get_id(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
int cxl_decoder_get_nr_targets(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
+struct cxl_region *cxl_decoder_get_region(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
|
|
|
26ccd9 |
enum cxl_decoder_target_type {
|
|
|
26ccd9 |
CXL_DECODER_TTYPE_UNKNOWN,
|
|
|
26ccd9 |
@@ -446,6 +447,12 @@ Platform firmware may setup the CXL decode hierarchy before the OS
|
|
|
26ccd9 |
boots, and may additionally require that the OS not change the decode
|
|
|
26ccd9 |
settings. This property is indicated by the cxl_decoder_is_locked() API.
|
|
|
26ccd9 |
|
|
|
26ccd9 |
+When a decoder is associated with a region cxl_decoder_get_region()
|
|
|
26ccd9 |
+returns that region object. Note that it is only applicable to switch
|
|
|
26ccd9 |
+and endpoint decoders as root decoders have a 1:N relationship with
|
|
|
26ccd9 |
+regions. Use cxl_region_foreach() for the similar functionality for
|
|
|
26ccd9 |
+root decoders.
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
==== TARGETS
|
|
|
26ccd9 |
A root or switch level decoder takes an SPA (system-physical-address) as
|
|
|
26ccd9 |
input and routes it to a downstream port. Which downstream port depends
|
|
|
26ccd9 |
diff --git a/cxl/json.c b/cxl/json.c
|
|
|
26ccd9 |
index ada1dbe..c3d9299 100644
|
|
|
26ccd9 |
--- a/cxl/json.c
|
|
|
26ccd9 |
+++ b/cxl/json.c
|
|
|
26ccd9 |
@@ -442,6 +442,7 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
|
|
|
26ccd9 |
const char *devname = cxl_decoder_get_devname(decoder);
|
|
|
26ccd9 |
struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
26ccd9 |
struct json_object *jdecoder, *jobj;
|
|
|
26ccd9 |
+ struct cxl_region *region;
|
|
|
26ccd9 |
u64 val, size;
|
|
|
26ccd9 |
|
|
|
26ccd9 |
jdecoder = json_object_new_object();
|
|
|
26ccd9 |
@@ -486,6 +487,13 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
|
|
|
26ccd9 |
}
|
|
|
26ccd9 |
}
|
|
|
26ccd9 |
|
|
|
26ccd9 |
+ region = cxl_decoder_get_region(decoder);
|
|
|
26ccd9 |
+ if (region) {
|
|
|
26ccd9 |
+ jobj = json_object_new_string(cxl_region_get_devname(region));
|
|
|
26ccd9 |
+ if (jobj)
|
|
|
26ccd9 |
+ json_object_object_add(jdecoder, "region", jobj);
|
|
|
26ccd9 |
+ }
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
if (size == 0) {
|
|
|
26ccd9 |
jobj = json_object_new_string("disabled");
|
|
|
26ccd9 |
if (jobj)
|
|
|
26ccd9 |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
26ccd9 |
index c7dc2b0..ff85b23 100644
|
|
|
26ccd9 |
--- a/cxl/lib/libcxl.c
|
|
|
26ccd9 |
+++ b/cxl/lib/libcxl.c
|
|
|
26ccd9 |
@@ -2124,6 +2124,40 @@ cxl_decoder_get_interleave_ways(struct cxl_decoder *decoder)
|
|
|
26ccd9 |
return decoder->interleave_ways;
|
|
|
26ccd9 |
}
|
|
|
26ccd9 |
|
|
|
26ccd9 |
+CXL_EXPORT struct cxl_region *
|
|
|
26ccd9 |
+cxl_decoder_get_region(struct cxl_decoder *decoder)
|
|
|
26ccd9 |
+{
|
|
|
26ccd9 |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
26ccd9 |
+ struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
|
|
|
26ccd9 |
+ char *path = decoder->dev_buf;
|
|
|
26ccd9 |
+ char buf[SYSFS_ATTR_SIZE];
|
|
|
26ccd9 |
+ struct cxl_region *region;
|
|
|
26ccd9 |
+ struct cxl_decoder *iter;
|
|
|
26ccd9 |
+ int rc;
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ if (cxl_port_is_root(port))
|
|
|
26ccd9 |
+ return NULL;
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ sprintf(path, "%s/region", decoder->dev_path);
|
|
|
26ccd9 |
+ rc = sysfs_read_attr(ctx, path, buf);
|
|
|
26ccd9 |
+ if (rc < 0) {
|
|
|
26ccd9 |
+ err(ctx, "failed to read region name: %s\n", strerror(-rc));
|
|
|
26ccd9 |
+ return NULL;
|
|
|
26ccd9 |
+ }
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ if (strcmp(buf, "") == 0)
|
|
|
26ccd9 |
+ return NULL;
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ while (!cxl_port_is_root(port))
|
|
|
26ccd9 |
+ port = cxl_port_get_parent(port);
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ cxl_decoder_foreach(port, iter)
|
|
|
26ccd9 |
+ cxl_region_foreach(iter, region)
|
|
|
26ccd9 |
+ if (strcmp(cxl_region_get_devname(region), buf) == 0)
|
|
|
26ccd9 |
+ return region;
|
|
|
26ccd9 |
+ return NULL;
|
|
|
26ccd9 |
+}
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
CXL_EXPORT struct cxl_region *
|
|
|
26ccd9 |
cxl_decoder_create_pmem_region(struct cxl_decoder *decoder)
|
|
|
26ccd9 |
{
|
|
|
26ccd9 |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
26ccd9 |
index 549f88d..385a8f0 100644
|
|
|
26ccd9 |
--- a/cxl/lib/libcxl.sym
|
|
|
26ccd9 |
+++ b/cxl/lib/libcxl.sym
|
|
|
26ccd9 |
@@ -214,4 +214,5 @@ global:
|
|
|
26ccd9 |
cxl_decoder_get_interleave_granularity;
|
|
|
26ccd9 |
cxl_decoder_get_interleave_ways;
|
|
|
26ccd9 |
cxl_decoder_get_max_available_extent;
|
|
|
26ccd9 |
+ cxl_decoder_get_region;
|
|
|
26ccd9 |
} LIBCXL_2;
|
|
|
26ccd9 |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
26ccd9 |
index 61c7fc4..2498fa1 100644
|
|
|
26ccd9 |
--- a/cxl/libcxl.h
|
|
|
26ccd9 |
+++ b/cxl/libcxl.h
|
|
|
26ccd9 |
@@ -201,6 +201,7 @@ bool cxl_decoder_is_locked(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
unsigned int
|
|
|
26ccd9 |
cxl_decoder_get_interleave_granularity(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
unsigned int cxl_decoder_get_interleave_ways(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
+struct cxl_region *cxl_decoder_get_region(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
struct cxl_region *cxl_decoder_create_pmem_region(struct cxl_decoder *decoder);
|
|
|
26ccd9 |
struct cxl_decoder *cxl_decoder_get_by_name(struct cxl_ctx *ctx,
|
|
|
26ccd9 |
const char *ident);
|
|
|
26ccd9 |
--
|
|
|
26ccd9 |
2.27.0
|
|
|
26ccd9 |
|