nvme: initialize CMB only if supported
PATCH 1/1 nvme: initialize CMB only if supported
According to the NVMe specification revision 1.4 (CMBS):
"If set to ‘1’, this bit indicates that the controller supports the Controller Memory Buffer, and that addresses supplied by the host are permitted to reference the Controller Memory Buffer only if the host has enabled the Controller Memory Buffer’s controller memory space. If the controller supports the Controller Memory Buffer, this bit shall be set to ‘1’."
Also, while we're here, add more macro definitions related to CMB registers added to revision 1.4 of the spec.
--- drivers/nvme/host/pci.c | 5 ++++- include/linux/nvme.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/nvme/host/pci.c +4 -1
@@ -1762,6 +1762,10 @@ static void nvme_map_cmb(struct nvme_dev *dev)struct pci_dev *pdev =to_pci_dev (dev->dev);int bar; +if (readl (dev->bar +NVME_REG_VS ) >=NVME_VS (1 ,4 ,0 ) && + !NVME_CAP_CMBS (dev->ctrl.cap)) +return ; +if (dev->cmb_size)return ;
@@ -2364,7 +2368,6 @@ static int nvme_pci_enable(struct nvme_dev *dev) dev->q_depth); } -nvme_map_cmb (dev);pci_enable_pcie_error_reporting (pdev);
include/linux/nvme.h +11 -0
@@ -116,6 +116,10 @@ enum {NVME_REG_BPMBL =0x0048 ,/* Boot Partition Memory Buffer * Location */ +NVME_REG_CMBMSC =0x0050 ,/* Controller Memory Buffer Memory +* Space Control +*/ +NVME_REG_CMBSTS =0x0058 ,/* Controller Memory Buffer Status */ NVME_REG_PMRCAP =0x0e00 ,/* Persistent Memory Capabilities */ NVME_REG_PMRCTL =0x0e04 ,/* Persistent Memory Region Control */ NVME_REG_PMRSTS = 0x0e08, /* Persistent Memory Region Status */
@@ -134,8 +138,15 @@ enum {#define NVME_CAP_NSSRC (cap) (((cap) >> 36) & 0x1)#define NVME_CAP_MPSMIN (cap) (((cap) >> 48) & 0xf)#define NVME_CAP_MPSMAX (cap) (((cap) >> 52) & 0xf) +#define NVME_CAP_CMBS (cap) (((cap) >> 57) & 0x1)#define NVME_CMB_BIR (cmbloc) ((cmbloc) & 0x7) +#define NVME_CMB_QMMS (cmbloc) (((cmbloc) >> 3) & 0x1) +#define NVME_CMB_QPDS (cmbloc) (((cmbloc) >> 4) & 0x1) +#define NVME_CMB_DPMLS (cmbloc) (((cmbloc) >> 5) & 0x1) +#define NVME_CMB_DPCILS (cmbloc) (((cmbloc) >> 6) & 0x1) +#define NVME_CMB_DMMMS (cmbloc) (((cmbloc) >> 7) & 0x1) +#define NVME_CMB_QDA (cmbloc) (((cmbloc) >> 8) & 0x1)#define NVME_CMB_OFST (cmbloc) (((cmbloc) >> 12) & 0xfffff)enum {
Signature · 7 lines
1.8.3.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 10 lines · Max Gurtovoy
According to the NVMe specification revision 1.4 (CMBS):
"If set to ‘1’, this bit indicates that the controller supports the Controller Memory Buffer, and that addresses supplied by the host are permitted to reference the Controller Memory Buffer only if the host has enabled the Controller Memory Buffer’s controller memory space. If the controller supports the Controller Memory Buffer, this bit shall be set to ‘1’."Also, while we're here, add more macro definitions related to CMB registers added to revision 1.4 of the spec.
Please read my comment on the previous patch that tried this about a week or two ago.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme