Skip to content

Commit 1a6fe74

Browse files
amlutoaxboe
authored andcommitted
nvme: Pass pointers, not dma addresses, to nvme_get/set_features()
Any user I can imagine that needs a buffer at all will want to pass a pointer directly. There are no currently callers that use buffers, so this change is painless, and it will make it much easier to start using features that use buffers (e.g. APST). Signed-off-by: Andy Lutomirski <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Jay Freyensee <[email protected]> Tested-by: Jay Freyensee <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 26501db commit 1a6fe74

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

drivers/nvme/host/core.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid,
599599
}
600600

601601
int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid,
602-
dma_addr_t dma_addr, u32 *result)
602+
void *buffer, size_t buflen, u32 *result)
603603
{
604604
struct nvme_command c;
605605
struct nvme_completion cqe;
@@ -608,31 +608,29 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid,
608608
memset(&c, 0, sizeof(c));
609609
c.features.opcode = nvme_admin_get_features;
610610
c.features.nsid = cpu_to_le32(nsid);
611-
c.features.dptr.prp1 = cpu_to_le64(dma_addr);
612611
c.features.fid = cpu_to_le32(fid);
613612

614-
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0,
613+
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, buffer, buflen, 0,
615614
NVME_QID_ANY, 0, 0);
616615
if (ret >= 0 && result)
617616
*result = le32_to_cpu(cqe.result);
618617
return ret;
619618
}
620619

621620
int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11,
622-
dma_addr_t dma_addr, u32 *result)
621+
void *buffer, size_t buflen, u32 *result)
623622
{
624623
struct nvme_command c;
625624
struct nvme_completion cqe;
626625
int ret;
627626

628627
memset(&c, 0, sizeof(c));
629628
c.features.opcode = nvme_admin_set_features;
630-
c.features.dptr.prp1 = cpu_to_le64(dma_addr);
631629
c.features.fid = cpu_to_le32(fid);
632630
c.features.dword11 = cpu_to_le32(dword11);
633631

634-
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0,
635-
NVME_QID_ANY, 0, 0);
632+
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe,
633+
buffer, buflen, 0, NVME_QID_ANY, 0, 0);
636634
if (ret >= 0 && result)
637635
*result = le32_to_cpu(cqe.result);
638636
return ret;
@@ -666,7 +664,7 @@ int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
666664
u32 result;
667665
int status, nr_io_queues;
668666

669-
status = nvme_set_features(ctrl, NVME_FEAT_NUM_QUEUES, q_count, 0,
667+
status = nvme_set_features(ctrl, NVME_FEAT_NUM_QUEUES, q_count, NULL, 0,
670668
&result);
671669
if (status < 0)
672670
return status;

drivers/nvme/host/nvme.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid,
293293
struct nvme_id_ns **id);
294294
int nvme_get_log_page(struct nvme_ctrl *dev, struct nvme_smart_log **log);
295295
int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid,
296-
dma_addr_t dma_addr, u32 *result);
296+
void *buffer, size_t buflen, u32 *result);
297297
int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11,
298-
dma_addr_t dma_addr, u32 *result);
298+
void *buffer, size_t buflen, u32 *result);
299299
int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
300300
void nvme_start_keep_alive(struct nvme_ctrl *ctrl);
301301
void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);

drivers/nvme/host/scsi.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ static int nvme_trans_log_temperature(struct nvme_ns *ns, struct sg_io_hdr *hdr,
906906
kfree(smart_log);
907907

908908
/* Get Features for Temp Threshold */
909-
res = nvme_get_features(ns->ctrl, NVME_FEAT_TEMP_THRESH, 0, 0,
909+
res = nvme_get_features(ns->ctrl, NVME_FEAT_TEMP_THRESH, 0, NULL, 0,
910910
&feature_resp);
911911
if (res != NVME_SC_SUCCESS)
912912
temp_c_thresh = LOG_TEMP_UNKNOWN;
@@ -1039,7 +1039,7 @@ static int nvme_trans_fill_caching_page(struct nvme_ns *ns,
10391039
if (len < MODE_PAGE_CACHING_LEN)
10401040
return -EINVAL;
10411041

1042-
nvme_sc = nvme_get_features(ns->ctrl, NVME_FEAT_VOLATILE_WC, 0, 0,
1042+
nvme_sc = nvme_get_features(ns->ctrl, NVME_FEAT_VOLATILE_WC, 0, NULL, 0,
10431043
&feature_resp);
10441044
res = nvme_trans_status_code(hdr, nvme_sc);
10451045
if (res)
@@ -1328,7 +1328,7 @@ static int nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr,
13281328
case MODE_PAGE_CACHING:
13291329
dword11 = ((mode_page[2] & CACHING_MODE_PAGE_WCE_MASK) ? 1 : 0);
13301330
nvme_sc = nvme_set_features(ns->ctrl, NVME_FEAT_VOLATILE_WC,
1331-
dword11, 0, NULL);
1331+
dword11, NULL, 0, NULL);
13321332
res = nvme_trans_status_code(hdr, nvme_sc);
13331333
break;
13341334
case MODE_PAGE_CONTROL:

0 commit comments

Comments
 (0)