Commit 49742188 authored by Matthew Wilcox's avatar Matthew Wilcox

NVMe: Fix DMA mapping for admin commands

We were always mapping as DMA_FROM_DEVICE then unmapping with
DMA_TO_DEVICE which was clearly not correct.  Follow the same pattern as
nvme_submit_io() and key off the bottom bit of the opcode to determine
whether this is a read or a write.
Signed-off-by: default avatarMatthew Wilcox <matthew.r.wilcox@intel.com>
parent ff976d72
...@@ -1165,7 +1165,8 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns, ...@@ -1165,7 +1165,8 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns,
length = cmd.data_len; length = cmd.data_len;
if (cmd.data_len) { if (cmd.data_len) {
iod = nvme_map_user_pages(dev, 1, cmd.addr, length); iod = nvme_map_user_pages(dev, cmd.opcode & 1, cmd.addr,
length);
if (IS_ERR(iod)) if (IS_ERR(iod))
return PTR_ERR(iod); return PTR_ERR(iod);
length = nvme_setup_prps(dev, &c.common, iod, length, length = nvme_setup_prps(dev, &c.common, iod, length,
...@@ -1178,7 +1179,8 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns, ...@@ -1178,7 +1179,8 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns,
status = nvme_submit_admin_cmd(dev, &c, NULL); status = nvme_submit_admin_cmd(dev, &c, NULL);
if (cmd.data_len) { if (cmd.data_len) {
nvme_unmap_user_pages(dev, 0, cmd.addr, cmd.data_len, iod); nvme_unmap_user_pages(dev, cmd.opcode & 1, cmd.addr,
cmd.data_len, iod);
nvme_free_iod(dev, iod); nvme_free_iod(dev, iod);
} }
return status; return status;
......
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