Skip to contentSkip to conversation

hw/block/nvme: fix bad clearing of CAP

PATCH In review Klaus Jensen 3 participants 4 messages Dec 8, 2020 – Dec 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/block/nvme: fix bad clearing of CAP

From: Klaus Jensen <[email protected]>

Commit 37712e00b1f0 ("hw/block/nvme: factor out pmr setup") changed the control flow such that the CAP register is erronously cleared after nvme_init_pmr() has configured it. Since the entire NvmeCtrl structure is zero-filled initially, there is no need for the explicit clearing, so just remove it.

Fixes 37712e00b1f0 ("hw/block/nvme: factor out pmr setup")
---
 hw/block/nvme.c | 1 -
 1 file changed, 1 deletion(-)
hw/block/nvme.c +0 -1
index 8814201364c1..28416b18a5c0 100644
@@ -3040,7 +3040,6 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     id->psd[0].enlat = cpu_to_le32(0x10);
     id->psd[0].exlat = cpu_to_le32(0x4);
 
-    n->bar.cap = 0;
     NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
     NVME_CAP_SET_CQR(n->bar.cap, 1);
     NVME_CAP_SET_TO(n->bar.cap, 0xf);
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Commit 37712e00b1f0 ("hw/block/nvme: factor out pmr setup") changed the control flow such that the CAP register is erronously cleared after nvme_init_pmr() has configured it. Since the entire NvmeCtrl structure is zero-filled initially, there is no need for the explicit clearing, so just remove it.

Fixes 37712e00b1f0 ("hw/block/nvme: factor out pmr setup")

Oops, nice catch.

Quoted 19 lines
---
 hw/block/nvme.c | 1 -
 1 file changed, 1 deletion(-)
hw/block/nvme.c +0 -1
index 8814201364c1..28416b18a5c0 100644
@@ -3040,7 +3040,6 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     id->psd[0].enlat = cpu_to_le32(0x10);
     id->psd[0].exlat = cpu_to_le32(0x4);
 
-    n->bar.cap = 0;
     NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
     NVME_CAP_SET_CQR(n->bar.cap, 1);
     NVME_CAP_SET_TO(n->bar.cap, 0xf);
Signature · 1 line
2.29.2
#3 lore raw
In reply to Klaus Jensen
Quoted 30 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Commit 37712e00b1f0 ("hw/block/nvme: factor out pmr setup") changed the control flow such that the CAP register is erronously cleared after nvme_init_pmr() has configured it. Since the entire NvmeCtrl structure is zero-filled initially, there is no need for the explicit clearing, so just remove it.

Fixes 37712e00b1f0 ("hw/block/nvme: factor out pmr setup")
---
 hw/block/nvme.c | 1 -
 1 file changed, 1 deletion(-)
hw/block/nvme.c +0 -1
index 8814201364c1..28416b18a5c0 100644
@@ -3040,7 +3040,6 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     id->psd[0].enlat = cpu_to_le32(0x10);
     id->psd[0].exlat = cpu_to_le32(0x4);
 
-    n->bar.cap = 0;
     NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
     NVME_CAP_SET_CQR(n->bar.cap, 1);
     NVME_CAP_SET_TO(n->bar.cap, 0xf);
Signature · 1 line
2.29.2

Thanks for the reviews, applied to nvme-next.