Re: [PATCH v4 03/23] cxl: Add support for reading CXL switch CDAT table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4/24/23 3:08 PM, Dan Williams wrote:
Dave Jiang wrote:
Move read_cdat_data() from endpoint probe to general port probe to
allow reading of CDAT data for CXL switches as well as CXL device.
Add wrapper support for cxl_test to bypass the cdat reading.

Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx>
Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx>

---
v4:
- Remove cxl_test wrapper. (Ira)
---
  drivers/cxl/core/pci.c |   20 +++++++++++++++-----
  drivers/cxl/port.c     |    6 +++---
  2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index 9c7e2f69d9ca..1c415b26e866 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -546,16 +546,26 @@ static unsigned char cdat_checksum(void *buf, size_t size)
   */
  void read_cdat_data(struct cxl_port *port)
  {
-	struct pci_doe_mb *cdat_doe;
-	struct device *dev = &port->dev;
  	struct device *uport = port->uport;
-	struct cxl_memdev *cxlmd = to_cxl_memdev(uport);
-	struct cxl_dev_state *cxlds = cxlmd->cxlds;
-	struct pci_dev *pdev = to_pci_dev(cxlds->dev);
+	struct device *dev = &port->dev;
+	struct cxl_dev_state *cxlds;
+	struct pci_doe_mb *cdat_doe;
+	struct cxl_memdev *cxlmd;
+	struct pci_dev *pdev;
  	size_t cdat_length;
  	void *cdat_table;
  	int rc;
+ if (is_cxl_memdev(uport)) {
+		cxlmd = to_cxl_memdev(uport);
+		cxlds = cxlmd->cxlds;
+		pdev = to_pci_dev(cxlds->dev);

Per this fix [1], there's no need to reference cxlds, the parent of the
memory device is the device this wants, and needs to be careful that not
all 'struct cxl_memdev' instances are hosted by pci devices.

[1]: http://lore.kernel.org/r/168213190748.708404.16215095414060364800.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx

Ok will pull this fix patch in and rebase against that.

Otherwise, looks good to me.



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux