nvme: Convert nvme_build_prpl() to nvme_prpl_xfer()
Rename nvme_build_prpl() to nvme_prpl_xfer() and directly invoke nvme_io_xfer() or nvme_bounce_xfer() from that function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Alexander Graf <graf@amazon.com>
This commit is contained in:
parent
4eff93e7b0
commit
9404f597b2
|
@ -125,7 +125,6 @@ struct nvme_namespace {
|
||||||
|
|
||||||
/* Page List */
|
/* Page List */
|
||||||
u32 prpl_len;
|
u32 prpl_len;
|
||||||
void *prp1;
|
|
||||||
u64 prpl[NVME_MAX_PRPL_ENTRIES];
|
u64 prpl[NVME_MAX_PRPL_ENTRIES];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -498,10 +498,13 @@ static int nvme_add_prpl(struct nvme_namespace *ns, u64 base)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nvme_build_prpl(struct nvme_namespace *ns, void *op_buf, u16 count)
|
// Transfer data using page list (if applicable)
|
||||||
|
static int
|
||||||
|
nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, void *buf, u16 count,
|
||||||
|
int write)
|
||||||
{
|
{
|
||||||
int first_page = 1;
|
int first_page = 1;
|
||||||
u32 base = (long)op_buf;
|
u32 base = (long)buf;
|
||||||
s32 size;
|
s32 size;
|
||||||
|
|
||||||
if (count > ns->max_req_size)
|
if (count > ns->max_req_size)
|
||||||
|
@ -511,31 +514,32 @@ static int nvme_build_prpl(struct nvme_namespace *ns, void *op_buf, u16 count)
|
||||||
|
|
||||||
size = count * ns->block_size;
|
size = count * ns->block_size;
|
||||||
/* Special case for transfers that fit into PRP1, but are unaligned */
|
/* Special case for transfers that fit into PRP1, but are unaligned */
|
||||||
if (((size + (base & ~NVME_PAGE_MASK)) <= NVME_PAGE_SIZE)) {
|
if (((size + (base & ~NVME_PAGE_MASK)) <= NVME_PAGE_SIZE))
|
||||||
ns->prp1 = op_buf;
|
return nvme_io_xfer(ns, lba, buf, count, write);
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Every request has to be page aligned */
|
/* Every request has to be page aligned */
|
||||||
if (base & ~NVME_PAGE_MASK)
|
if (base & ~NVME_PAGE_MASK)
|
||||||
return 0;
|
goto bounce;
|
||||||
|
|
||||||
/* Make sure a full block fits into the last chunk */
|
/* Make sure a full block fits into the last chunk */
|
||||||
if (size & (ns->block_size - 1ULL))
|
if (size & (ns->block_size - 1ULL))
|
||||||
return 0;
|
goto bounce;
|
||||||
|
|
||||||
for (; size > 0; base += NVME_PAGE_SIZE, size -= NVME_PAGE_SIZE) {
|
for (; size > 0; base += NVME_PAGE_SIZE, size -= NVME_PAGE_SIZE) {
|
||||||
if (first_page) {
|
if (first_page) {
|
||||||
/* First page is special */
|
/* First page is special */
|
||||||
ns->prp1 = (void*)base;
|
|
||||||
first_page = 0;
|
first_page = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (nvme_add_prpl(ns, base))
|
if (nvme_add_prpl(ns, base))
|
||||||
return 0;
|
goto bounce;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return nvme_io_xfer(ns, lba, buf, count, write);
|
||||||
|
|
||||||
|
bounce:
|
||||||
|
/* Use bounce buffer to make transfer */
|
||||||
|
return nvme_bounce_xfer(ns, lba, buf, count, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -736,24 +740,14 @@ nvme_scan(void)
|
||||||
static int
|
static int
|
||||||
nvme_cmd_readwrite(struct nvme_namespace *ns, struct disk_op_s *op, int write)
|
nvme_cmd_readwrite(struct nvme_namespace *ns, struct disk_op_s *op, int write)
|
||||||
{
|
{
|
||||||
u16 i, blocks;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < op->count;) {
|
for (i = 0; i < op->count;) {
|
||||||
u16 blocks_remaining = op->count - i;
|
u16 blocks_remaining = op->count - i;
|
||||||
char *op_buf = op->buf_fl + i * ns->block_size;
|
char *op_buf = op->buf_fl + i * ns->block_size;
|
||||||
|
int blocks = nvme_prpl_xfer(ns, op->lba + i, op_buf,
|
||||||
blocks = nvme_build_prpl(ns, op_buf, blocks_remaining);
|
blocks_remaining, write);
|
||||||
if (blocks) {
|
if (blocks < 0)
|
||||||
int res = nvme_io_xfer(ns, op->lba + i, ns->prp1, blocks, write);
|
return DISK_RET_EBADTRACK;
|
||||||
if (res < 0)
|
|
||||||
return DISK_RET_EBADTRACK;
|
|
||||||
} else {
|
|
||||||
int res = nvme_bounce_xfer(ns, op->lba + i, op_buf, blocks, write);
|
|
||||||
if (res < 0)
|
|
||||||
return DISK_RET_EBADTRACK;
|
|
||||||
blocks = res;
|
|
||||||
}
|
|
||||||
|
|
||||||
i += blocks;
|
i += blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue