diff mbox series

cxl: Add cxl_num_decoders_committed() usage to cxl_test

Message ID 169903435790.565298.13848186970380289757.stgit@djiang5-mobl3
State Superseded
Headers show
Series cxl: Add cxl_num_decoders_committed() usage to cxl_test | expand

Commit Message

Dave Jiang Nov. 3, 2023, 5:59 p.m. UTC
Commit 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper") missed the
conversion for cxl_test. Add usage of cxl_num_decoders_committed() to
replace the open coding.

Suggested-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/cxl/core/port.c      |    1 +
 tools/testing/cxl/test/cxl.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Dan Williams Nov. 4, 2023, 8:16 p.m. UTC | #1
Dave Jiang wrote:
> Commit 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper") missed the
> conversion for cxl_test. Add usage of cxl_num_decoders_committed() to
> replace the open coding.
> 
> Suggested-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/cxl/core/port.c      |    1 +
>  tools/testing/cxl/test/cxl.c |    2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 38441634e4c6..26d17c205408 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -43,6 +43,7 @@ int cxl_num_decoders_committed(struct cxl_port *port)
>  
>  	return port->commit_end + 1;
>  }
> +EXPORT_SYMBOL_NS_GPL(cxl_num_decoders_committed, CXL);

I don't like the fact that this export only exists for the test module
to consume it. I would prefer hiding this export in the modified
cxl_core.ko that gets built by tools/testing/cxl/Kbuild. Perhaps even
refactor the duplicated code between mock_decoder_commit() and
cxl_decoder_commit() into a common helper, but in general try not to
pollute the production code with cxl_test-isms.
diff mbox series

Patch

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 38441634e4c6..26d17c205408 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -43,6 +43,7 @@  int cxl_num_decoders_committed(struct cxl_port *port)
 
 	return port->commit_end + 1;
 }
+EXPORT_SYMBOL_NS_GPL(cxl_num_decoders_committed, CXL);
 
 static ssize_t devtype_show(struct device *dev, struct device_attribute *attr,
 			    char *buf)
diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
index b88546299902..f42ec896962a 100644
--- a/tools/testing/cxl/test/cxl.c
+++ b/tools/testing/cxl/test/cxl.c
@@ -669,7 +669,7 @@  static int mock_decoder_commit(struct cxl_decoder *cxld)
 		return 0;
 
 	dev_dbg(&port->dev, "%s commit\n", dev_name(&cxld->dev));
-	if (port->commit_end + 1 != id) {
+	if (cxl_num_decoders_committed(port) != id) {
 		dev_dbg(&port->dev,
 			"%s: out of order commit, expected decoder%d.%d\n",
 			dev_name(&cxld->dev), port->id, port->commit_end + 1);