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