[PATCH V4 3/3] nvme-pci: get rid of the division in the fast path

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Thu Jul 16 20:51:39 EDT 2020


Since we have a macro for calculating the size of the ctrl page we can
remove the division in the fast path for nvme-pci in nvme_unmap_data().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3c852a8f18ed..616db1ae137c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -513,7 +513,8 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)
 static void nvme_unmap_data(struct nvme_dev *dev, struct request *req)
 {
 	struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
-	const int last_prp = NVME_CTRL_PAGE_SIZE / sizeof(__le64) - 1;
+	const int last_prp = (NVME_CTRL_PAGE_SIZE >> ilog2(sizeof(__le64))) - 1;
+
 	dma_addr_t dma_addr = iod->first_dma, next_dma_addr;
 	int i;
 
-- 
2.26.0




More information about the Linux-nvme mailing list