Skip to contentSkip to conversation

EINJ, CXL: Fix CXL device SBDF calculation

PATCH RESEND In review Ben Cheatham 3 participants 3 messages Sep 27, 2024 – Sep 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 EINJ, CXL: Fix CXL device SBDF calculation

The SBDF of the target CXL 2.0 compliant root port is required to inject a CXL protocol error as per ACPI 6.5. The SBDF given has to be in the following format:

31 24 23 16 15 11 10 8 7 0

+-------------------------------------------------+
| segment |   bus  | device | function | reserved |
+-------------------------------------------------+

The SBDF calculated in cxl_dport_get_sbdf() doesn't account for the reserved bits currently, causing the wrong SBDF to be used. Fix said calculation to properly shift the SBDF.

Without this fix, error injection into CXL 2.0 root ports through the CXL debugfs interface (<debugfs>/cxl) is broken. Injection through the legacy interface (<debugfs>/apei/einj/) will still work because the SBDF is manually provided by the user.

Fixes 12fb28ea6b1cf ("EINJ: Add CXL error type support")

---

Resent to add linux-cxl list and Srinivasulu to CC

---
 drivers/acpi/apei/einj-cxl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/einj-cxl.c +1 -1
index 8b8be0c90709..d64e2713aae4 100644
@@ -63,7 +63,7 @@ static int cxl_dport_get_sbdf(struct pci_dev *dport_dev, u64 *sbdf)
 		seg = bridge->domain_nr;
 
 	bus = pbus->number;
-	*sbdf = (seg << 24) | (bus << 16) | dport_dev->devfn;
+	*sbdf = (seg << 24) | (bus << 16) | (dport_dev->devfn << 8);
 
 	return 0;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Ben Cheatham

The SBDF of the target CXL 2.0 compliant root port is required to inject a CXL protocol error as per ACPI 6.5. The SBDF given has to be in the following format:

31 24 23 16 15 11 10 8 7 0

+-------------------------------------------------+
| segment |   bus  | device | function | reserved |
+-------------------------------------------------+

The SBDF calculated in cxl_dport_get_sbdf() doesn't account for the reserved bits currently, causing the wrong SBDF to be used. Fix said calculation to properly shift the SBDF.

Quoted 7 lines

Without this fix, error injection into CXL 2.0 root ports through the CXL debugfs interface (<debugfs>/cxl) is broken. Injection through the legacy interface (<debugfs>/apei/einj/) will still work because the SBDF is manually provided by the user.

Fixes 12fb28ea6b1cf ("EINJ: Add CXL error type support")

Looks good to me.

Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to Ben Cheatham

Micron Confidential

Micron Confidential

Quoted 27 lines

-----Original Message-----
From: Ben Cheatham <[email protected]>
Sent: Friday, September 27, 2024 10:04 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Srinivasulu Thanneeru <[email protected]>; Ben Cheatham <[email protected]>
Subject: [EXT] [RESEND][PATCH] EINJ, CXL: Fix CXL device SBDF calculation

CAUTION: EXTERNAL EMAIL. Do not click links or open attachments unless you recognize the sender and were expecting this message.

The SBDF of the target CXL 2.0 compliant root port is required to inject a CXL protocol error as per ACPI 6.5. The SBDF given has to be in the following format:

31 24 23 16 15 11 10 8 7 0

+-------------------------------------------------+
| segment |   bus  | device | function | reserved |
+-------------------------------------------------+

The SBDF calculated in cxl_dport_get_sbdf() doesn't account for the reserved bits currently, causing the wrong SBDF to be used. Fix said calculation to properly shift the SBDF.

Quoted 7 lines

Without this fix, error injection into CXL 2.0 root ports through the CXL debugfs interface (<debugfs>/cxl) is broken. Injection through the legacy interface (<debugfs>/apei/einj/) will still work because the SBDF is manually provided by the user.

Fixes 12fb28ea6b1cf ("EINJ: Add CXL error type support")

Tried this patch, working fine.

Quoted 25 lines

---

Resent to add linux-cxl list and Srinivasulu to CC

---
drivers/acpi/apei/einj-cxl.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/einj-cxl.c +1 -1
index 8b8be0c90709..d64e2713aae4 100644
@@ -63,7 +63,7 @@ static int cxl_dport_get_sbdf(struct pci_dev *dport_dev, u64
 *sbdf)
               seg = bridge->domain_nr;
 
       bus = pbus->number;
-       *sbdf = (seg << 24) | (bus << 16) | dport_dev->devfn;
+       *sbdf = (seg << 24) | (bus << 16) | (dport_dev->devfn << 8);
 
       return 0;

}
--
2.34.1