diff options
author | Jim Harris <jimharris@FreeBSD.org> | 2013-07-19 21:33:24 +0000 |
---|---|---|
committer | Jim Harris <jimharris@FreeBSD.org> | 2013-07-19 21:33:24 +0000 |
commit | 2fb37e8f1a08e8aff27062e768c5ada5dbdb1559 (patch) | |
tree | fefe5bbb7bdf05aa24b1eb44299388d1777ddcd8 /sys/dev/nvme | |
parent | c3e9dd893b9a79c6949803a45ac36910313499dd (diff) | |
download | src-2fb37e8f1a08e8aff27062e768c5ada5dbdb1559.tar.gz src-2fb37e8f1a08e8aff27062e768c5ada5dbdb1559.zip |
Fix nvme(4) and nvd(4) to support non 512-byte sector sizes.
Recent testing with QEMU that has variable sector size support for
NVMe uncovered some of these issues. Chatham prototype boards supported
only 512 byte sectors.
Sponsored by: Intel
Reviewed by: carl
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=253474
Diffstat (limited to 'sys/dev/nvme')
-rw-r--r-- | sys/dev/nvme/nvme_ns.c | 12 | ||||
-rw-r--r-- | sys/dev/nvme/nvme_ns_cmd.c | 7 |
2 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 4658c7495ec3..fb31852bec35 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -155,7 +155,7 @@ nvme_ns_get_max_io_xfer_size(struct nvme_namespace *ns) uint32_t nvme_ns_get_sector_size(struct nvme_namespace *ns) { - return (1 << ns->data.lbaf[0].lbads); + return (1 << ns->data.lbaf[ns->data.flbas.format].lbads); } uint64_t @@ -310,6 +310,16 @@ nvme_ns_construct(struct nvme_namespace *ns, uint16_t id, } #endif + /* + * Note: format is a 0-based value, so > is appropriate here, + * not >=. + */ + if (ns->data.flbas.format > ns->data.nlbaf) { + printf("lba format %d exceeds number supported (%d)\n", + ns->data.flbas.format, ns->data.nlbaf+1); + return (1); + } + if (ctrlr->cdata.oncs.dsm) ns->flags |= NVME_NS_DEALLOCATE_SUPPORTED; diff --git a/sys/dev/nvme/nvme_ns_cmd.c b/sys/dev/nvme/nvme_ns_cmd.c index 50ec120d0721..b5c45dcbedf5 100644 --- a/sys/dev/nvme/nvme_ns_cmd.c +++ b/sys/dev/nvme/nvme_ns_cmd.c @@ -36,7 +36,8 @@ nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload, uint64_t lba, struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, cb_arg); + req = nvme_allocate_request_vaddr(payload, + lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg); if (req == NULL) return (ENOMEM); @@ -89,8 +90,8 @@ nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba, struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, - cb_arg); + req = nvme_allocate_request_vaddr(payload, + lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg); if (req == NULL) return (ENOMEM); |