nvme/pci: Split 8-byte reads
PATCH v4 1/1 nvme/pci: Split 8-byte reads
The nvme pci driver had split 8-byte register reads using lo_hi_readq() due to nvme controllers that do not support that sized access. This behavior was inadvertently changed to readq(), which may break those controllers. Restore the previous behavior.
---
v4: update comment and commit text according to Keith's guidance
v3: add comment explaining why we need the split read
v2: drop WARN_ON(), add reference to commit that [re-]introduced the issue
--- drivers/nvme/host/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nvme/host/pci.c +6 -1
@@ -2672,7 +2672,12 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)static int nvme_pci_reg_read64 (struct nvme_ctrl *ctrl,u32 off,u64 *val) { - *val =readq (to_nvme_dev (ctrl)->bar + off); +/* +* Split the 8-byte read into two 4-byte reads since all controllers +* support 4 byte register reads, but some do not support the larger +* access size. +*/ + *val =lo_hi_readq (to_nvme_dev (ctrl)->bar + off);return 0 ; }
Signature · 7 lines
2.20.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 7 lines · Ard Biesheuvel
The nvme pci driver had split 8-byte register reads using
lo_hi_readq()due to nvme controllers that do not support that sized access. This behavior was inadvertently changed toreadq(), which may break those controllers. Restore the previous behavior.Fixes 7fd8930f26be4 ("nvme: add a common helper to read Identify Controller data")Signed-off-by Ard Biesheuvel <[email protected]>
Looks good to me.
Quoted 25 lines
--- drivers/nvme/host/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/nvme/host/pci.c +6
-1@@ -2672,7 +2672,12 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)static int nvme_pci_reg_read64 (struct nvme_ctrl *ctrl,u32 off,u64 *val) { - *val =readq (to_nvme_dev (ctrl)->bar + off); +/* +* Split the 8-byte read into two 4-byte reads since all controllers +* support 4 byte register reads, but some do not support the larger +* access size. +*/ + *val =lo_hi_readq (to_nvme_dev (ctrl)->bar + off);return 0 ; }Signature · 1 line
2.20.1
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Looks good,
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme