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