Commit b36235df authored by Matthew Wilcox's avatar Matthew Wilcox

NVMe: Detect commands that are completed twice

Set the context value to CMD_CTX_COMPLETED, and print a message in the
sync_completion handler if we see it.
Signed-off-by: default avatarMatthew Wilcox <matthew.r.wilcox@intel.com>
parent be7b6275
...@@ -169,12 +169,15 @@ enum { ...@@ -169,12 +169,15 @@ enum {
#define CMD_CTX_BASE (POISON_POINTER_DELTA + sync_completion_id) #define CMD_CTX_BASE (POISON_POINTER_DELTA + sync_completion_id)
#define CMD_CTX_CANCELLED (0x2008 + CMD_CTX_BASE) #define CMD_CTX_CANCELLED (0x2008 + CMD_CTX_BASE)
#define CMD_CTX_COMPLETED (0x2010 + CMD_CTX_BASE)
static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid) static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid)
{ {
unsigned long data; unsigned long data;
unsigned offset = cmdid + BITS_TO_LONGS(nvmeq->q_depth);
data = nvmeq->cmdid_data[cmdid + BITS_TO_LONGS(nvmeq->q_depth)]; data = nvmeq->cmdid_data[offset];
nvmeq->cmdid_data[offset] = CMD_CTX_COMPLETED;
clear_bit(cmdid, nvmeq->cmdid_data); clear_bit(cmdid, nvmeq->cmdid_data);
wake_up(&nvmeq->sq_full); wake_up(&nvmeq->sq_full);
return data; return data;
...@@ -182,8 +185,8 @@ static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid) ...@@ -182,8 +185,8 @@ static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid)
static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid) static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid)
{ {
nvmeq->cmdid_data[cmdid + BITS_TO_LONGS(nvmeq->q_depth)] = unsigned offset = cmdid + BITS_TO_LONGS(nvmeq->q_depth);
CMD_CTX_CANCELLED; nvmeq->cmdid_data[offset] = CMD_CTX_CANCELLED;
} }
static struct nvme_queue *get_nvmeq(struct nvme_ns *ns) static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
...@@ -402,6 +405,12 @@ static void sync_completion(struct nvme_queue *nvmeq, void *ctx, ...@@ -402,6 +405,12 @@ static void sync_completion(struct nvme_queue *nvmeq, void *ctx,
struct sync_cmd_info *cmdinfo = ctx; struct sync_cmd_info *cmdinfo = ctx;
if ((unsigned long)cmdinfo == CMD_CTX_CANCELLED) if ((unsigned long)cmdinfo == CMD_CTX_CANCELLED)
return; return;
if (unlikely((unsigned long)cmdinfo == CMD_CTX_COMPLETED)) {
dev_warn(nvmeq->q_dmadev,
"completed id %d twice on queue %d\n",
cqe->command_id, le16_to_cpup(&cqe->sq_id));
return;
}
cmdinfo->result = le32_to_cpup(&cqe->result); cmdinfo->result = le32_to_cpup(&cqe->result);
cmdinfo->status = le16_to_cpup(&cqe->status) >> 1; cmdinfo->status = le16_to_cpup(&cqe->status) >> 1;
wake_up_process(cmdinfo->task); wake_up_process(cmdinfo->task);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment