[PATCH 01/26] nvme: use barebox-appropriate 64-bit type for timeouts

Ahmad Fatoum a.fatoum at barebox.org
Fri Jun 26 01:42:12 PDT 2026


The unsigned timeout that is used across the nvme support is in terms of
jiffies in Linux, where unsigned as type makes sense.

barebox has no jiffies though and we use the parameter to hold a nanosecond
time duration instead, which already overflows for ADMIN_TIMEOUT and
SHUTDOWN_TIMEOUT (60s and 5s, respectively) as they exceed the ~4s max.

Switch over to passing ktime_t around to fix this.

Fixes: aedcb568afe4 ("drivers: Import a very basic NVME implementation from Linux")
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 drivers/nvme/host/core.c | 2 +-
 drivers/nvme/host/nvme.h | 4 ++--
 drivers/nvme/host/pci.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index fcc21677638a..98731ffe7cb2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -8,7 +8,7 @@ int __nvme_submit_sync_cmd(struct nvme_ctrl *ctrl,
 			   struct nvme_command *cmd,
 			   union nvme_result *result,
 			   void *buffer, unsigned bufflen,
-			   unsigned timeout, int qid)
+			   ktime_t timeout, int qid)
 {
 	return ctrl->ops->submit_sync_cmd(ctrl, cmd, result, buffer, bufflen,
 					  timeout, qid);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 90121bd7a3e0..11942140ce32 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -77,7 +77,7 @@ struct nvme_ctrl_ops {
 			       union nvme_result *result,
 			       void *buffer,
 			       unsigned bufflen,
-			       unsigned timeout, int qid);
+			       ktime_t timeout, int qid);
 };
 
 static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl)
@@ -120,7 +120,7 @@ int __nvme_submit_sync_cmd(struct nvme_ctrl *ctrl,
 			   struct nvme_command *cmd,
 			   union nvme_result *result,
 			   void *buffer, unsigned bufflen,
-			   unsigned timeout, int qid);
+			   ktime_t timeout, int qid);
 int nvme_submit_sync_cmd(struct nvme_ctrl *ctrl,
 			 struct nvme_command *cmd,
 			 void *buffer, unsigned bufflen);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 672c4cc2331a..765821aa0a65 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -384,7 +384,7 @@ static int nvme_pci_submit_sync_cmd(struct nvme_ctrl *ctrl,
 				    union nvme_result *result,
 				    void *buffer,
 				    unsigned int buffer_len,
-				    unsigned timeout, int qid)
+				    ktime_t timeout, int qid)
 {
 	struct nvme_dev *dev = to_nvme_dev(ctrl);
 	struct nvme_queue *nvmeq = &dev->queues[qid];
-- 
2.47.3




More information about the barebox mailing list