diff options
author | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2011-02-06 07:53:23 -0500 |
---|---|---|
committer | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2011-11-04 15:52:55 -0400 |
commit | be7b62754e097adc0cb16c25c9ee86ee20de62fb (patch) | |
tree | 0f625fd57e9ba1ace93888cc302ab7f455f7759f /drivers/block/nvme.c | |
parent | 58ffacb545f76fc2c65d1fbfa5acf5184a2a09e6 (diff) |
NVMe: Use a symbolic name to represent cancelled commands instead of 0
I have plans for other special values in sync_completion. Plus, this
is more self-documenting, and lets us detect bogus usages.
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers/block/nvme.c')
-rw-r--r-- | drivers/block/nvme.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c index 60c3786bc787..802d763d9d06 100644 --- a/drivers/block/nvme.c +++ b/drivers/block/nvme.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/poison.h> | ||
34 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
35 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
36 | #include <linux/types.h> | 37 | #include <linux/types.h> |
@@ -158,15 +159,17 @@ static int alloc_cmdid_killable(struct nvme_queue *nvmeq, void *ctx, | |||
158 | } | 159 | } |
159 | 160 | ||
160 | /* If you need more than four handlers, you'll need to change how | 161 | /* If you need more than four handlers, you'll need to change how |
161 | * alloc_cmdid and nvme_process_cq work. Also, aborted commands take | 162 | * alloc_cmdid and nvme_process_cq work. Consider using a special |
162 | * the sync_completion path (if they complete), so don't put anything | 163 | * CMD_CTX value instead, if that works for your situation. |
163 | * else in slot zero. | ||
164 | */ | 164 | */ |
165 | enum { | 165 | enum { |
166 | sync_completion_id = 0, | 166 | sync_completion_id = 0, |
167 | bio_completion_id, | 167 | bio_completion_id, |
168 | }; | 168 | }; |
169 | 169 | ||
170 | #define CMD_CTX_BASE (POISON_POINTER_DELTA + sync_completion_id) | ||
171 | #define CMD_CTX_CANCELLED (0x2008 + CMD_CTX_BASE) | ||
172 | |||
170 | static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid) | 173 | static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid) |
171 | { | 174 | { |
172 | unsigned long data; | 175 | unsigned long data; |
@@ -177,9 +180,10 @@ static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid) | |||
177 | return data; | 180 | return data; |
178 | } | 181 | } |
179 | 182 | ||
180 | static void clear_cmdid_data(struct nvme_queue *nvmeq, int cmdid) | 183 | static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid) |
181 | { | 184 | { |
182 | nvmeq->cmdid_data[cmdid + BITS_TO_LONGS(nvmeq->q_depth)] = 0; | 185 | nvmeq->cmdid_data[cmdid + BITS_TO_LONGS(nvmeq->q_depth)] = |
186 | CMD_CTX_CANCELLED; | ||
183 | } | 187 | } |
184 | 188 | ||
185 | static struct nvme_queue *get_nvmeq(struct nvme_ns *ns) | 189 | static struct nvme_queue *get_nvmeq(struct nvme_ns *ns) |
@@ -396,8 +400,8 @@ static void sync_completion(struct nvme_queue *nvmeq, void *ctx, | |||
396 | struct nvme_completion *cqe) | 400 | struct nvme_completion *cqe) |
397 | { | 401 | { |
398 | struct sync_cmd_info *cmdinfo = ctx; | 402 | struct sync_cmd_info *cmdinfo = ctx; |
399 | if (!cmdinfo) | 403 | if ((unsigned long)cmdinfo == CMD_CTX_CANCELLED) |
400 | return; /* Command aborted */ | 404 | return; |
401 | cmdinfo->result = le32_to_cpup(&cqe->result); | 405 | cmdinfo->result = le32_to_cpup(&cqe->result); |
402 | cmdinfo->status = le16_to_cpup(&cqe->status) >> 1; | 406 | cmdinfo->status = le16_to_cpup(&cqe->status) >> 1; |
403 | wake_up_process(cmdinfo->task); | 407 | wake_up_process(cmdinfo->task); |
@@ -480,7 +484,7 @@ static irqreturn_t nvme_irq_check(int irq, void *data) | |||
480 | static void nvme_abort_command(struct nvme_queue *nvmeq, int cmdid) | 484 | static void nvme_abort_command(struct nvme_queue *nvmeq, int cmdid) |
481 | { | 485 | { |
482 | spin_lock_irq(&nvmeq->q_lock); | 486 | spin_lock_irq(&nvmeq->q_lock); |
483 | clear_cmdid_data(nvmeq, cmdid); | 487 | cancel_cmdid_data(nvmeq, cmdid); |
484 | spin_unlock_irq(&nvmeq->q_lock); | 488 | spin_unlock_irq(&nvmeq->q_lock); |
485 | } | 489 | } |
486 | 490 | ||