Message ID | 20211203214544.343460-3-axboe@kernel.dk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support for list issue | expand |
On 12/3/21 10:45 PM, Jens Axboe wrote: > We'll need it for batched submit as well. > > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> > Signed-off-by: Jens Axboe <axboe@kernel.dk> > --- > drivers/nvme/host/pci.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 8637538f3fd5..09ea21f75439 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -500,6 +500,15 @@ static inline void nvme_write_sq_db(struct nvme_queue *nvmeq, bool write_sq) > nvmeq->last_sq_tail = nvmeq->sq_tail; > } > > +static inline void nvme_sq_copy_cmd(struct nvme_queue *nvmeq, > + struct nvme_command *cmd) > +{ > + memcpy(nvmeq->sq_cmds + (nvmeq->sq_tail << nvmeq->sqes), cmd, > + sizeof(*cmd)); > + if (++nvmeq->sq_tail == nvmeq->q_depth) > + nvmeq->sq_tail = 0; > +} > + > /** > * nvme_submit_cmd() - Copy a command into a queue and ring the doorbell > * @nvmeq: The queue to use > @@ -510,10 +519,7 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, > bool write_sq) > { > spin_lock(&nvmeq->sq_lock); > - memcpy(nvmeq->sq_cmds + (nvmeq->sq_tail << nvmeq->sqes), > - cmd, sizeof(*cmd)); > - if (++nvmeq->sq_tail == nvmeq->q_depth) > - nvmeq->sq_tail = 0; > + nvme_sq_copy_cmd(nvmeq, cmd); > nvme_write_sq_db(nvmeq, write_sq); > spin_unlock(&nvmeq->sq_lock); > } > Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes
As mentioned last time I really don't like the proliferation of tiny helpers with just two callers. See my patch I responded with for my alternative.
On 12/6/21 12:38 AM, Christoph Hellwig wrote: > As mentioned last time I really don't like the proliferation of > tiny helpers with just two callers. See my patch I responded with > for my alternative. I tend to agree with you, but for this particular case I really don't think it's better to not have the helper. I did try that version too, but you end up with several sites duplicating it. So while I agree in general, I don't think this one applies.
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8637538f3fd5..09ea21f75439 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -500,6 +500,15 @@ static inline void nvme_write_sq_db(struct nvme_queue *nvmeq, bool write_sq) nvmeq->last_sq_tail = nvmeq->sq_tail; } +static inline void nvme_sq_copy_cmd(struct nvme_queue *nvmeq, + struct nvme_command *cmd) +{ + memcpy(nvmeq->sq_cmds + (nvmeq->sq_tail << nvmeq->sqes), cmd, + sizeof(*cmd)); + if (++nvmeq->sq_tail == nvmeq->q_depth) + nvmeq->sq_tail = 0; +} + /** * nvme_submit_cmd() - Copy a command into a queue and ring the doorbell * @nvmeq: The queue to use @@ -510,10 +519,7 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, bool write_sq) { spin_lock(&nvmeq->sq_lock); - memcpy(nvmeq->sq_cmds + (nvmeq->sq_tail << nvmeq->sqes), - cmd, sizeof(*cmd)); - if (++nvmeq->sq_tail == nvmeq->q_depth) - nvmeq->sq_tail = 0; + nvme_sq_copy_cmd(nvmeq, cmd); nvme_write_sq_db(nvmeq, write_sq); spin_unlock(&nvmeq->sq_lock); }