Add the debugfs path to the CXL library context. This will be used by
library functions that access information from the CXL debugfs to
retrieve information.

The default path is the normal mount point for the debugfs
(/sys/kernel/debug) but the debugfs mount point can vary. Add a library
API call for setting the debugfs path for cases where the debugfs isn't
mounted at the default.

Signed-off-by: Ben Cheatham <benjamin.cheat...@amd.com>
---
 cxl/lib/libcxl.c   | 7 +++++++
 cxl/lib/libcxl.sym | 5 +++++
 cxl/libcxl.h       | 1 +
 3 files changed, 13 insertions(+)

diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index 63aa4ef..e86d00f 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -54,6 +54,7 @@ struct cxl_ctx {
        struct kmod_ctx *kmod_ctx;
        struct daxctl_ctx *daxctl_ctx;
        void *private_data;
+       const char *debugfs;
 };
 
 static void free_pmem(struct cxl_pmem *pmem)
@@ -294,6 +295,7 @@ CXL_EXPORT int cxl_new(struct cxl_ctx **ctx)
        c->udev = udev;
        c->udev_queue = udev_queue;
        c->timeout = 5000;
+       c->debugfs = "/sys/kernel/debug";
 
        return 0;
 
@@ -3265,6 +3267,11 @@ CXL_EXPORT int cxl_port_decoders_committed(struct 
cxl_port *port)
        return port->decoders_committed;
 }
 
+CXL_EXPORT void cxl_set_debugfs(struct cxl_ctx *ctx, const char *debugfs)
+{
+       ctx->debugfs = debugfs;
+}
+
 static void *add_cxl_bus(void *parent, int id, const char *cxlbus_base)
 {
        const char *devname = devpath_to_devname(cxlbus_base);
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
index 763151f..61553c0 100644
--- a/cxl/lib/libcxl.sym
+++ b/cxl/lib/libcxl.sym
@@ -287,3 +287,8 @@ global:
        cxl_memdev_trigger_poison_list;
        cxl_region_trigger_poison_list;
 } LIBCXL_7;
+
+LIBCXL_9 {
+global:
+       cxl_set_debugfs;
+} LIBECXL_8;
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
index 43c082a..f3f11ad 100644
--- a/cxl/libcxl.h
+++ b/cxl/libcxl.h
@@ -32,6 +32,7 @@ void cxl_set_userdata(struct cxl_ctx *ctx, void *userdata);
 void *cxl_get_userdata(struct cxl_ctx *ctx);
 void cxl_set_private_data(struct cxl_ctx *ctx, void *data);
 void *cxl_get_private_data(struct cxl_ctx *ctx);
+void cxl_set_debugfs(struct cxl_ctx *ctx, const char *debugfs);
 
 enum cxl_fwl_status {
        CXL_FWL_STATUS_UNKNOWN,
-- 
2.34.1


Reply via email to