hw/block/nvme: misc fixes
cover hw/block/nvme: misc fixes
From: Klaus Jensen <[email protected]>
Small set of misc fixes from Gollu.
Gollu Appalanaidu (3):
hw/block/nvme: nvme_identify fixes hw/block/nvme: fix potential compilation error hw/block/nvme: report non-mdts command size limit for dsm
hw/block/nvme.h | 1 + include/block/nvme.h | 11 +++++++++++ hw/block/nvme.c | 46 +++++++++++++++++++++++++++---------------- hw/block/trace-events | 2 ++ 4 files changed, 43 insertions(+), 17 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/3 hw/block/nvme: nvme_identify fixes
From: Gollu Appalanaidu <[email protected]>
Remove an unnecessary le_to_cpu conversion and add trace event for Identify.
--- hw/block/nvme.c | 5 ++++- hw/block/trace-events | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
hw/block/nvme.c +4 -1
@@ -3415,7 +3415,10 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd; -switch (le32_to_cpu (c->cns)) { +trace_pci_nvme_identify (nvme_cid (req), c->cns,le16_to_cpu (c->ctrlid), + c->csi); + +switch (c->cns) {case NVME_ID_CNS_NS :/* fall through */ case NVME_ID_CNS_NS_PRESENT :
hw/block/trace-events +1 -0
@@ -61,6 +61,7 @@ pci_nvme_create_sq(uint64_t addr, uint16_t sqid, uint16_t cqid, uint16_t qsize, pci_nvme_create_cq(uint64_t addr, uint16_t cqid, uint16_t vector, uint16_t size, uint16_t qflags, int ien) "create completion queue, addr=0x%"PRIx64", cqid=%"PRIu16", vector=%"PRIu16", qsize=%"PRIu16", qflags=%"PRIu16", ien=%d" pci_nvme_del_sq(uint16_t qid) "deleting submission queue sqid=%"PRIu16"" pci_nvme_del_cq(uint16_t cqid) "deleted completion queue, cqid=%"PRIu16"" +pci_nvme_identify(uint16_t cid, uint8_t cns, uint16_t ctrlid, uint8_t csi) "cid %"PRIu16" cns 0x%"PRIx8" ctrlid %"PRIu16" csi 0x%"PRIx8"" pci_nvme_identify_ctrl(void) "identify controller" pci_nvme_identify_ctrl_csi(uint8_t csi) "identify controller, csi=0x%"PRIx8"" pci_nvme_identify_ns(uint32_t ns) "nsid %"PRIu32""
Signature · 1 line
2.30.1
Re: [PATCH 1/3] hw/block/nvme: nvme_identify fixes
Quoted 17 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
Remove an unnecessary
le_to_cpuconversion and add trace event for Identify.Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.c | 5 ++++- hw/block/trace-events | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)hw/block/nvme.c +0
-0
hw/block/nvme.c static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) · line 3419
Quoted 6 lines
hw/block/nvme.c +2
-1@@ -3415,7 +3415,10 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd; -switch (le32_to_cpu (c->cns)) { +trace_pci_nvme_identify (nvme_cid (req), c->cns,le16_to_cpu (c->ctrlid), + c->csi);
I think it would be great if it can be separated into two. Anyway, changes look good to me.
Quoted 21 lines
hw/block/nvme.c +2
-0+ +switch (c->cns) {case NVME_ID_CNS_NS :/* fall through */ case NVME_ID_CNS_NS_PRESENT :hw/block/trace-events +1
-0@@ -61,6 +61,7 @@ pci_nvme_create_sq(uint64_t addr, uint16_t sqid, uint16_t cqid, uint16_t qsize, pci_nvme_create_cq(uint64_t addr, uint16_t cqid, uint16_t vector, uint16_t size, uint16_t qflags, int ien) "create completion queue, addr=0x%"PRIx64", cqid=%"PRIu16", vector=%"PRIu16", qsize=%"PRIu16", qflags=%"PRIu16", ien=%d" pci_nvme_del_sq(uint16_t qid) "deleting submission queue sqid=%"PRIu16"" pci_nvme_del_cq(uint16_t cqid) "deleted completion queue, cqid=%"PRIu16"" +pci_nvme_identify(uint16_t cid, uint8_t cns, uint16_t ctrlid, uint8_t csi) "cid %"PRIu16" cns 0x%"PRIx8" ctrlid %"PRIu16" csi 0x%"PRIx8"" pci_nvme_identify_ctrl(void) "identify controller" pci_nvme_identify_ctrl_csi(uint8_t csi) "identify controller, csi=0x%"PRIx8"" pci_nvme_identify_ns(uint32_t ns) "nsid %"PRIu32""Signature · 1 line
2.30.1
Re: [PATCH 1/3] hw/block/nvme: nvme_identify fixes
Quoted 21 lines · Minwoo Im
Quoted 20 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
Remove an unnecessary
le_to_cpuconversion and add trace event for Identify.Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.c | 5 ++++- hw/block/trace-events | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)hw/block/nvme.c +0
-0@@ -3415,7 +3415,10 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd;
Quoted 5 lines
hw/block/nvme.c static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) · line 3419
Quoted 3 lines
hw/block/nvme.c +2
-1-switch (le32_to_cpu (c->cns)) { +trace_pci_nvme_identify (nvme_cid (req), c->cns,le16_to_cpu (c->ctrlid), + c->csi);I think it would be great if it can be separated into two.
Agreed.
Quoted 3 lines
Anyway, changes look good to me.
Reviewed-by Minwoo Im <[email protected]>
PATCH 2/3 hw/block/nvme: fix potential compilation error
In reply to Klaus JensenFrom: Gollu Appalanaidu <[email protected]>
assert may be compiled to a noop and we could end up returning an uninitialized status.
Fix this by always returning Internal Device Error as a fallback.
--- hw/block/nvme.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/block/nvme.c +5 -6
@@ -1232,7 +1232,7 @@ static uint16_t nvme_check_zone_write(NvmeNamespace *ns, NvmeZone *zone,static uint16_t nvme_check_zone_state_for_read (NvmeZone *zone) { -uint16_t status; +uint64_t zslba = zone->d.zslba;switch (nvme_get_zone_state (zone)) {case NVME_ZONE_STATE_EMPTY :
@@ -1241,16 +1241,15 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone)case NVME_ZONE_STATE_FULL :case NVME_ZONE_STATE_CLOSED :case NVME_ZONE_STATE_READ_ONLY : - status =NVME_SUCCESS ; -break ; +return NVME_SUCCESS ;case NVME_ZONE_STATE_OFFLINE : - status =NVME_ZONE_OFFLINE ; -break ; +trace_pci_nvme_err_zone_is_offline (zslba); +return NVME_ZONE_OFFLINE ;default :assert (false); } -return status; +return NVME_INTERNAL_DEV_ERROR ; } static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
Signature · 1 line
2.30.1
Re: [PATCH 2/3] hw/block/nvme: fix potential compilation error
Quoted 27 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
assert may be compiled to a noop and we could end up returning an uninitialized status.
Fix this by always returning Internal Device Error as a fallback.
Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)hw/block/nvme.c +1
-1@@ -1232,7 +1232,7 @@ static uint16_t nvme_check_zone_write(NvmeNamespace *ns, NvmeZone *zone,static uint16_t nvme_check_zone_state_for_read (NvmeZone *zone) { -uint16_t status; +uint64_t zslba = zone->d.zslba;switch (nvme_get_zone_state (zone)) {case NVME_ZONE_STATE_EMPTY :
hw/block/nvme.c static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone) · line 1246
Quoted 10 lines
hw/block/nvme.c +2
-4@@ -1241,16 +1241,15 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone)case NVME_ZONE_STATE_FULL :case NVME_ZONE_STATE_CLOSED :case NVME_ZONE_STATE_READ_ONLY : - status =NVME_SUCCESS ; -break ; +return NVME_SUCCESS ;case NVME_ZONE_STATE_OFFLINE : - status =NVME_ZONE_OFFLINE ; -break ; +trace_pci_nvme_err_zone_is_offline (zslba);
This also is a tiny addition to the potential error fix. Anyway, it can be shorten to: (if zslba is used in a place only)
trace_pci_nvme_err_zone_is_offline(zone->d.zslba);
Quoted 14 lines
hw/block/nvme.c +2
-1+return NVME_ZONE_OFFLINE ;default :assert (false); } -return status; +return NVME_INTERNAL_DEV_ERROR ; } static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,Signature · 1 line
2.30.1
Re: [PATCH 2/3] hw/block/nvme: fix potential compilation error
In reply to Klaus JensenQuoted 4 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
assert may be compiled to a noop and we could end up returning an uninitialized status.
Per commit 262a69f4282 ("osdep.h: Prohibit disabling assert() in supported builds") this shouldn't be possible. Anyhow cleanup is good.
Quoted 44 lines
Fix this by always returning Internal Device Error as a fallback.
Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)hw/block/nvme.c +5
-6@@ -1232,7 +1232,7 @@ static uint16_t nvme_check_zone_write(NvmeNamespace *ns, NvmeZone *zone,static uint16_t nvme_check_zone_state_for_read (NvmeZone *zone) { -uint16_t status; +uint64_t zslba = zone->d.zslba;switch (nvme_get_zone_state (zone)) {case NVME_ZONE_STATE_EMPTY :@@ -1241,16 +1241,15 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone)case NVME_ZONE_STATE_FULL :case NVME_ZONE_STATE_CLOSED :case NVME_ZONE_STATE_READ_ONLY : - status =NVME_SUCCESS ; -break ; +return NVME_SUCCESS ;case NVME_ZONE_STATE_OFFLINE : - status =NVME_ZONE_OFFLINE ; -break ; +trace_pci_nvme_err_zone_is_offline (zslba); +return NVME_ZONE_OFFLINE ;default :assert (false); } -return status; +return NVME_INTERNAL_DEV_ERROR ; } static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
PATCH 3/3 hw/block/nvme: report non-mdts command size limit for dsm
In reply to Klaus JensenFrom: Gollu Appalanaidu <[email protected]>
Dataset Management is not subject to MDTS, but exceeded a certain size per range causes internal looping. Report this limit (DMRSL) in the NVM command set specific identify controller data structure.
--- hw/block/nvme.h | 1 + include/block/nvme.h | 11 +++++++++++ hw/block/nvme.c | 30 ++++++++++++++++++++---------- hw/block/trace-events | 1 + 4 files changed, 33 insertions(+), 10 deletions(-)
hw/block/nvme.h +1 -0
@@ -172,6 +172,7 @@ typedef struct NvmeCtrl {int aer_queued;uint8_t zasl; +uint32_t dmrsl;NvmeSubsystem *subsys;
include/block/nvme.h +11 -0
@@ -1041,6 +1041,16 @@ typedef struct NvmeIdCtrlZoned {uint8_t rsvd1[4095 ]; } NvmeIdCtrlZoned; +typedef struct NvmeIdCtrlNvm { +uint8_t vsl; +uint8_t wzsl; +uint8_t wusl; +uint8_t dmrl; +uint32_t dmrsl; +uint64_t dmsl; +uint8_t rsvd16[4080 ]; +}NvmeIdCtrlNvm ; +enum NvmeIdCtrlOacs {NVME_OACS_SECURITY =1 <<0 ,NVME_OACS_FORMAT =1 <<1 ,
@@ -1396,6 +1406,7 @@ static inline void _nvme_check_size(void)QEMU_BUILD_BUG_ON (sizeof (NvmeEffectsLog) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrl) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlZoned) !=4096 ); +QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlNvm) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAF) !=4 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAFE) !=16 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdNs) !=4096 );
hw/block/nvme.c +20 -10
@@ -1777,6 +1777,10 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)trace_pci_nvme_dsm_deallocate (nvme_cid (req),nvme_nsid (ns), slba, nlb); +if (nlb > n->dmrsl) { +trace_pci_nvme_dsm_single_range_limit_exceeded (nlb, n->dmrsl); + } + offset =nvme_l2b (ns, slba); len =nvme_l2b (ns, nlb);
@@ -3202,21 +3206,24 @@ static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeRequest *req)static uint16_t nvme_identify_ctrl_csi (NvmeCtrl *n,NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd; -NvmeIdCtrlZoned id = {}; +uint8_t id[NVME_IDENTIFY_DATA_SIZE ] = {};trace_pci_nvme_identify_ctrl_csi (c->csi); -if (c->csi ==NVME_CSI_NVM ) { -return nvme_rpt_empty_id_struct (n, req); - }else if (c->csi ==NVME_CSI_ZONED ) { -if (n->params.zasl_bs) { - id.zasl = n->zasl; - } -return nvme_dma (n, (uint8_t *)&id,sizeof (id), -DMA_DIRECTION_FROM_DEVICE , req); +switch (c->csi) { +case NVME_CSI_NVM : + ((NvmeIdCtrlNvm *)&id)->dmrsl =cpu_to_le32 (n->dmrsl); +break ; + +case NVME_CSI_ZONED : + ((NvmeIdCtrlZoned *)&id)->zasl = n->zasl; +break ; + +default : +return NVME_INVALID_FIELD |NVME_DNR ; } -return NVME_INVALID_FIELD |NVME_DNR ; +return nvme_dma (n, id,sizeof (id),DMA_DIRECTION_FROM_DEVICE , req); }static uint16_t nvme_identify_ns (NvmeCtrl *n,NvmeRequest *req)
@@ -4670,6 +4677,9 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) n->namespaces[nsid -1 ] = ns; + n->dmrsl =MIN_NON_ZERO (n->dmrsl, +BDRV_REQUEST_MAX_BYTES /nvme_l2b (ns,1 )); +return 0 ; }
hw/block/trace-events +1 -0
@@ -51,6 +51,7 @@ pci_nvme_copy_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_block_status(int64_t offset, int64_t bytes, int64_t pnum, int ret, bool zeroed) "offset %"PRId64" bytes %"PRId64" pnum %"PRId64" ret 0x%x zeroed %d" pci_nvme_dsm(uint16_t cid, uint32_t nsid, uint32_t nr, uint32_t attr) "cid %"PRIu16" nsid %"PRIu32" nr %"PRIu32" attr 0x%"PRIx32"" pci_nvme_dsm_deallocate(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba %"PRIu64" nlb %"PRIu32"" +pci_nvme_dsm_single_range_limit_exceeded(uint32_t nlb, uint32_t dmrsl) "nlb %"PRIu32" dmrsl %"PRIu32"" pci_nvme_compare(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba 0x%"PRIx64" nlb %"PRIu32"" pci_nvme_compare_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_aio_discard_cb(uint16_t cid) "cid %"PRIu16""
Signature · 1 line
2.30.1
Re: [PATCH 3/3] hw/block/nvme: report non-mdts command size limit for dsm
Quoted 85 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
Dataset Management is not subject to MDTS, but exceeded a certain size per range causes internal looping. Report this limit (DMRSL) in the NVM command set specific identify controller data structure.
Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.h | 1 + include/block/nvme.h | 11 +++++++++++ hw/block/nvme.c | 30 ++++++++++++++++++++---------- hw/block/trace-events | 1 + 4 files changed, 33 insertions(+), 10 deletions(-)hw/block/nvme.h +1
-0@@ -172,6 +172,7 @@ typedef struct NvmeCtrl {int aer_queued;uint8_t zasl; +uint32_t dmrsl;NvmeSubsystem *subsys;include/block/nvme.h +11
-0@@ -1041,6 +1041,16 @@ typedef struct NvmeIdCtrlZoned {uint8_t rsvd1[4095 ]; } NvmeIdCtrlZoned; +typedef struct NvmeIdCtrlNvm { +uint8_t vsl; +uint8_t wzsl; +uint8_t wusl; +uint8_t dmrl; +uint32_t dmrsl; +uint64_t dmsl; +uint8_t rsvd16[4080 ]; +}NvmeIdCtrlNvm ; +enum NvmeIdCtrlOacs {NVME_OACS_SECURITY =1 <<0 ,NVME_OACS_FORMAT =1 <<1 ,@@ -1396,6 +1406,7 @@ static inline void _nvme_check_size(void)QEMU_BUILD_BUG_ON (sizeof (NvmeEffectsLog) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrl) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlZoned) !=4096 ); +QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlNvm) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAF) !=4 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAFE) !=16 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdNs) !=4096 );hw/block/nvme.c +5
-6@@ -1777,6 +1777,10 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)trace_pci_nvme_dsm_deallocate (nvme_cid (req),nvme_nsid (ns), slba, nlb); +if (nlb > n->dmrsl) { +trace_pci_nvme_dsm_single_range_limit_exceeded (nlb, n->dmrsl); + } + offset =nvme_l2b (ns, slba); len =nvme_l2b (ns, nlb);@@ -3202,21 +3206,24 @@ static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeRequest *req)static uint16_t nvme_identify_ctrl_csi (NvmeCtrl *n,NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd; -NvmeIdCtrlZoned id = {}; +uint8_t id[NVME_IDENTIFY_DATA_SIZE ] = {};trace_pci_nvme_identify_ctrl_csi (c->csi); -if (c->csi ==NVME_CSI_NVM ) { -return nvme_rpt_empty_id_struct (n, req); - }else if (c->csi ==NVME_CSI_ZONED ) { -if (n->params.zasl_bs) { - id.zasl = n->zasl;
hw/block/nvme.c static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeRequest *req) · line 3219
Quoted 10 lines
hw/block/nvme.c +7
-3- } -return nvme_dma (n, (uint8_t *)&id,sizeof (id), -DMA_DIRECTION_FROM_DEVICE , req); +switch (c->csi) { +case NVME_CSI_NVM : + ((NvmeIdCtrlNvm *)&id)->dmrsl =cpu_to_le32 (n->dmrsl); +break ; + +case NVME_CSI_ZONED : + ((NvmeIdCtrlZoned *)&id)->zasl = n->zasl;
Question. Are we okay without checking this like above ? :)
if (n->params.zasl_bs) {
((NvmeIdCtrlZoned *)&id)->zasl = n->zasl;
}Quoted 37 lines
hw/block/nvme.c +8
-1+break ; + +default : +return NVME_INVALID_FIELD |NVME_DNR ; } -return NVME_INVALID_FIELD |NVME_DNR ; +return nvme_dma (n, id,sizeof (id),DMA_DIRECTION_FROM_DEVICE , req); }static uint16_t nvme_identify_ns (NvmeCtrl *n,NvmeRequest *req)@@ -4670,6 +4677,9 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) n->namespaces[nsid -1 ] = ns; + n->dmrsl =MIN_NON_ZERO (n->dmrsl, +BDRV_REQUEST_MAX_BYTES /nvme_l2b (ns,1 )); +return 0 ; }hw/block/trace-events +1
-0@@ -51,6 +51,7 @@ pci_nvme_copy_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_block_status(int64_t offset, int64_t bytes, int64_t pnum, int ret, bool zeroed) "offset %"PRId64" bytes %"PRId64" pnum %"PRId64" ret 0x%x zeroed %d" pci_nvme_dsm(uint16_t cid, uint32_t nsid, uint32_t nr, uint32_t attr) "cid %"PRIu16" nsid %"PRIu32" nr %"PRIu32" attr 0x%"PRIx32"" pci_nvme_dsm_deallocate(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba %"PRIu64" nlb %"PRIu32"" +pci_nvme_dsm_single_range_limit_exceeded(uint32_t nlb, uint32_t dmrsl) "nlb %"PRIu32" dmrsl %"PRIu32"" pci_nvme_compare(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba 0x%"PRIx64" nlb %"PRIu32"" pci_nvme_compare_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_aio_discard_cb(uint16_t cid) "cid %"PRIu16""Signature · 1 line
2.30.1
Re: [PATCH 3/3] hw/block/nvme: report non-mdts command size limit for dsm
Quoted 99 lines · Minwoo Im
Quoted 85 lines · Klaus Jensen
From: Gollu Appalanaidu <[email protected]>
Dataset Management is not subject to MDTS, but exceeded a certain size per range causes internal looping. Report this limit (DMRSL) in the NVM command set specific identify controller data structure.
Signed-off-by Gollu Appalanaidu <[email protected]>Signed-off-by Klaus Jensen <[email protected]>--- hw/block/nvme.h | 1 + include/block/nvme.h | 11 +++++++++++ hw/block/nvme.c | 30 ++++++++++++++++++++---------- hw/block/trace-events | 1 + 4 files changed, 33 insertions(+), 10 deletions(-)hw/block/nvme.h +1
-0@@ -172,6 +172,7 @@ typedef struct NvmeCtrl {int aer_queued;uint8_t zasl; +uint32_t dmrsl;NvmeSubsystem *subsys;include/block/nvme.h +11
-0@@ -1041,6 +1041,16 @@ typedef struct NvmeIdCtrlZoned {uint8_t rsvd1[4095 ]; } NvmeIdCtrlZoned; +typedef struct NvmeIdCtrlNvm { +uint8_t vsl; +uint8_t wzsl; +uint8_t wusl; +uint8_t dmrl; +uint32_t dmrsl; +uint64_t dmsl; +uint8_t rsvd16[4080 ]; +}NvmeIdCtrlNvm ; +enum NvmeIdCtrlOacs {NVME_OACS_SECURITY =1 <<0 ,NVME_OACS_FORMAT =1 <<1 ,@@ -1396,6 +1406,7 @@ static inline void _nvme_check_size(void)QEMU_BUILD_BUG_ON (sizeof (NvmeEffectsLog) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrl) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlZoned) !=4096 ); +QEMU_BUILD_BUG_ON (sizeof (NvmeIdCtrlNvm) !=4096 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAF) !=4 );QEMU_BUILD_BUG_ON (sizeof (NvmeLBAFE) !=16 );QEMU_BUILD_BUG_ON (sizeof (NvmeIdNs) !=4096 );hw/block/nvme.c +5
-6@@ -1777,6 +1777,10 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)trace_pci_nvme_dsm_deallocate (nvme_cid (req),nvme_nsid (ns), slba, nlb); +if (nlb > n->dmrsl) { +trace_pci_nvme_dsm_single_range_limit_exceeded (nlb, n->dmrsl); + } + offset =nvme_l2b (ns, slba); len =nvme_l2b (ns, nlb);@@ -3202,21 +3206,24 @@ static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeRequest *req)static uint16_t nvme_identify_ctrl_csi (NvmeCtrl *n,NvmeRequest *req) {NvmeIdentify *c = (NvmeIdentify *)&req->cmd; -NvmeIdCtrlZoned id = {}; +uint8_t id[NVME_IDENTIFY_DATA_SIZE ] = {};trace_pci_nvme_identify_ctrl_csi (c->csi); -if (c->csi ==NVME_CSI_NVM ) { -return nvme_rpt_empty_id_struct (n, req); - }else if (c->csi ==NVME_CSI_ZONED ) { -if (n->params.zasl_bs) { - id.zasl = n->zasl;hw/block/nvme.c static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeRequest *req) · line 3219
Quoted 10 lines
hw/block/nvme.c +7
-3- } -return nvme_dma (n, (uint8_t *)&id,sizeof (id), -DMA_DIRECTION_FROM_DEVICE , req); +switch (c->csi) { +case NVME_CSI_NVM : + ((NvmeIdCtrlNvm *)&id)->dmrsl =cpu_to_le32 (n->dmrsl); +break ; + +case NVME_CSI_ZONED : + ((NvmeIdCtrlZoned *)&id)->zasl = n->zasl;Question. Are we okay without checking this like above ? :)
Quoted 4 lines
if (n->params.zasl_bs) {
((NvmeIdCtrlZoned *)&id)->zasl = n->zasl;
}Ah yeah. Thanks!
I forgot about that zasl_bs vs zasl quirkiness.
Quoted 37 lines
Quoted 37 lines
hw/block/nvme.c +8
-1+break ; + +default : +return NVME_INVALID_FIELD |NVME_DNR ; } -return NVME_INVALID_FIELD |NVME_DNR ; +return nvme_dma (n, id,sizeof (id),DMA_DIRECTION_FROM_DEVICE , req); }static uint16_t nvme_identify_ns (NvmeCtrl *n,NvmeRequest *req)@@ -4670,6 +4677,9 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) n->namespaces[nsid -1 ] = ns; + n->dmrsl =MIN_NON_ZERO (n->dmrsl, +BDRV_REQUEST_MAX_BYTES /nvme_l2b (ns,1 )); +return 0 ; }hw/block/trace-events +1
-0@@ -51,6 +51,7 @@ pci_nvme_copy_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_block_status(int64_t offset, int64_t bytes, int64_t pnum, int ret, bool zeroed) "offset %"PRId64" bytes %"PRId64" pnum %"PRId64" ret 0x%x zeroed %d" pci_nvme_dsm(uint16_t cid, uint32_t nsid, uint32_t nr, uint32_t attr) "cid %"PRIu16" nsid %"PRIu32" nr %"PRIu32" attr 0x%"PRIx32"" pci_nvme_dsm_deallocate(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba %"PRIu64" nlb %"PRIu32"" +pci_nvme_dsm_single_range_limit_exceeded(uint32_t nlb, uint32_t dmrsl) "nlb %"PRIu32" dmrsl %"PRIu32"" pci_nvme_compare(uint16_t cid, uint32_t nsid, uint64_t slba, uint32_t nlb) "cid %"PRIu16" nsid %"PRIu32" slba 0x%"PRIx64" nlb %"PRIu32"" pci_nvme_compare_cb(uint16_t cid) "cid %"PRIu16"" pci_nvme_aio_discard_cb(uint16_t cid) "cid %"PRIu16""Signature · 1 line
2.30.1
Signature · 1 line
One of us - No more doubt, silence or taboo about mental illness.