[PATCH v4 13/14] cxl: Add a dev_dbg() when a decoder was added to a port

Robert Richter posted 14 patches 11 months, 1 week ago
There is a newer version of this series
[PATCH v4 13/14] cxl: Add a dev_dbg() when a decoder was added to a port
Posted by Robert Richter 11 months, 1 week ago
Improve debugging by adding and unifying messages whenever a decoder
was added to a port. It is especially useful to get the decoder
mapping of the involved CXL host bridge or PCI device. This avoids a
complex lookup of the decoder/port/device mappings in sysfs.

Example log messages:

  cxl_acpi ACPI0017:00: decoder0.0 added to root0
  cxl_acpi ACPI0017:00: decoder0.1 added to root0
  ...
   pci0000:e0: decoder1.0 added to port1
   pci0000:e0: decoder1.1 added to port1
  ...
  cxl_mem mem0: decoder5.0 added to endpoint5
  cxl_mem mem0: decoder5.1 added to endpoint5

Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Tested-by: Gregory Price <gourry@gourry.net>
---
 drivers/cxl/acpi.c     | 10 +++++++++-
 drivers/cxl/core/hdm.c |  3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index cb14829bb9be..3e75e612cbc4 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -421,7 +421,15 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
 	rc = cxl_decoder_add(cxld, target_map);
 	if (rc)
 		return rc;
-	return cxl_root_decoder_autoremove(dev, no_free_ptr(cxlrd));
+
+	rc = cxl_root_decoder_autoremove(dev, no_free_ptr(cxlrd));
+	if (rc)
+		return rc;
+
+	dev_dbg(root_port->dev.parent, "%s added to %s\n",
+		dev_name(&cxld->dev), dev_name(&root_port->dev));
+
+	return 0;
 }
 
 static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index 70cae4ebf8a4..00c2de629a34 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -34,7 +34,8 @@ static int add_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
 	if (rc)
 		return rc;
 
-	dev_dbg(&cxld->dev, "Added to port %s\n", dev_name(&port->dev));
+	dev_dbg(port->uport_dev, "%s added to %s\n",
+		dev_name(&cxld->dev), dev_name(&port->dev));
 
 	return 0;
 }
-- 
2.39.5
Re: [PATCH v4 13/14] cxl: Add a dev_dbg() when a decoder was added to a port
Posted by Alison Schofield 9 months, 4 weeks ago
On Thu, Mar 06, 2025 at 05:44:47PM +0100, Robert Richter wrote:
> Improve debugging by adding and unifying messages whenever a decoder
> was added to a port. It is especially useful to get the decoder
> mapping of the involved CXL host bridge or PCI device. This avoids a
> complex lookup of the decoder/port/device mappings in sysfs.
> 
> Example log messages:
> 
>   cxl_acpi ACPI0017:00: decoder0.0 added to root0
>   cxl_acpi ACPI0017:00: decoder0.1 added to root0
>   ...
>    pci0000:e0: decoder1.0 added to port1
>    pci0000:e0: decoder1.1 added to port1
>   ...
>   cxl_mem mem0: decoder5.0 added to endpoint5
>   cxl_mem mem0: decoder5.1 added to endpoint5
> 
> Signed-off-by: Robert Richter <rrichter@amd.com>
> Reviewed-by: Gregory Price <gourry@gourry.net>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Tested-by: Gregory Price <gourry@gourry.net>
> ---

Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Re: [PATCH v4 13/14] cxl: Add a dev_dbg() when a decoder was added to a port
Posted by Dan Williams 11 months, 1 week ago
Robert Richter wrote:
> Improve debugging by adding and unifying messages whenever a decoder
> was added to a port. It is especially useful to get the decoder
> mapping of the involved CXL host bridge or PCI device. This avoids a
> complex lookup of the decoder/port/device mappings in sysfs.

I am not opposed to this debug statement, but I hope that most use cases
for associating objects are handled by tooling and we don't need to keep
extending kernel debug statements for these queries.

E.g.: show all the decoders and targets of port1

# cxl list -PT -p 1 -Di
[
  {
    "port":"port1",
    "host":"pci0000:34",
    "depth":1,
    "decoders_committed":0,
    "nr_dports":1,
    "dports":[
      {
        "dport":"0000:34:00.0",
        "id":0
      }
    ],
    "decoders:port1":[
      {
        "decoder":"decoder2.0",
        "interleave_ways":1,
        "state":"disabled"
      },
      {
        "decoder":"decoder2.1",
        "interleave_ways":1,
        "state":"disabled"
      },
      {
        "decoder":"decoder2.2",
        "interleave_ways":1,
        "state":"disabled"
      },
      {
        "decoder":"decoder2.3",
        "interleave_ways":1,
        "state":"disabled"
      },
      {
        "decoder":"decoder1.0",
        "interleave_ways":1,
        "state":"disabled",
        "nr_targets":1,
        "targets":[
          {
            "target":"0000:34:00.0",
            "position":0,
            "id":0
          }
        ]
      }
    ]
  }
]
Re: [PATCH v4 13/14] cxl: Add a dev_dbg() when a decoder was added to a port
Posted by Robert Richter 9 months, 2 weeks ago
Dan,

thanks for all your reviews.

On 06.03.25 13:06:20, Dan Williams wrote:
> Robert Richter wrote:
> > Improve debugging by adding and unifying messages whenever a decoder
> > was added to a port. It is especially useful to get the decoder
> > mapping of the involved CXL host bridge or PCI device. This avoids a
> > complex lookup of the decoder/port/device mappings in sysfs.
> 
> I am not opposed to this debug statement, but I hope that most use cases
> for associating objects are handled by tooling and we don't need to keep
> extending kernel debug statements for these queries.
> 
> E.g.: show all the decoders and targets of port1
> 
> # cxl list -PT -p 1 -Di

I kept the patch in the v5 series that I sent yesterday.

The issue I am seeing is that in case of failures the devices
including their sysfs entries are not created or bound to a driver.
Tools do not see them then nor there is a hint why there was a
failure.

-Robert