Skip to contentSkip to conversation

nvme-pci: Verify the CMB's Controller Base Address.

PATCH New [email protected] 1 participant 1 message Feb 23, 2024 1 message not in the archive NVMe

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20240219043044epcas5p357dd2ded89cd5698a2b3726a5214a315@epcas5p3.samsung.com

#1 lore raw

PATCH v2 1/1 nvme-pci: Verify the CMB's Controller Base Address.

From: Sathyavathi M <[email protected]>

As per the NVMe Base Specification, CMB should not be enabled if the CMB's Controller Base Address(CMBMSC.CBA) is invalid. This patch detects if the CMB's Controller Base Address is valid or not.

---
 drivers/nvme/host/pci.c | 2 ++
 include/linux/nvme.h    | 5 +++++
 2 files changed, 7 insertions(+)
drivers/nvme/host/pci.c +2 -0
index e6267a6..5e508db 100644
@@ -1856,6 +1856,8 @@ static void nvme_map_cmb(struct nvme_dev *dev)
 		hi_lo_writeq(NVME_CMBMSC_CRE | NVME_CMBMSC_CMSE |
 			     (pci_bus_address(pdev, bar) + offset),
 			     dev->bar + NVME_REG_CMBMSC);
+		if (readl(dev->bar + NVME_REG_CMBSTS) & NVME_CMBSTS_CBAI)
+			return;
 	}
 
 	/*
include/linux/nvme.h +5 -0
index bc605ec..b55cacd 100644
@@ -145,6 +145,7 @@ enum {
 	NVME_REG_CMBMSC = 0x0050,	/* Controller Memory Buffer Memory
 					 * Space Control
 					 */
+	NVME_REG_CMBSTS	= 0x0058,	/* Controller Memory Buffer Status */
 	NVME_REG_CRTO	= 0x0068,	/* Controller Ready Timeouts */
 	NVME_REG_PMRCAP	= 0x0e00,	/* Persistent Memory Capabilities */
 	NVME_REG_PMRCTL	= 0x0e04,	/* Persistent Memory Region Control */
@@ -245,6 +246,10 @@ enum {
 	NVME_CAP_CRMS_CRIMS	= 1ULL << 60,
 };
 
+enum {
+	NVME_CMBSTS_CBAI	= 1 << 0,
+};
+
 struct nvme_id_power_state {
 	__le16			max_power;	/* centiwatts */
 	__u8			rsvd2;
Signature · 1 line
1.8.3.1