quirk broken namespace identifiers
Christoph Hellwig
maintainerHi all,
this series adds a quirk to ignore namespace identifiers on controllers where they are completely broken and then quirks two controllers for it.
Christoph Hellwig
maintainerPATCH 1/3 nvme: add a quirk to disable namespace identifiers
Add a quirk to disable using and exporting namespace identifiers for controllers where they are broken beyond repair.
--- drivers/nvme/host/core.c | 24 ++++++++++++++++++------ drivers/nvme/host/nvme.h | 5 +++++ 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +18 -6
@@ -1282,6 +1282,8 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,switch (cur->nidt) {case NVME_NIDT_EUI64 : +if (ctrl->quirks &NVME_QUIRK_BOGUS_NID ) +return NVME_NIDT_EUI64_LEN ;if (cur->nidl !=NVME_NIDT_EUI64_LEN ) {dev_warn (ctrl->device,"%s %d for NVME_NIDT_EUI64\n" , warn_str, cur->nidl);
@@ -1290,6 +1292,8 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,memcpy (ids->eui64, data +sizeof (*cur),NVME_NIDT_EUI64_LEN );return NVME_NIDT_EUI64_LEN ;case NVME_NIDT_NGUID : +if (ctrl->quirks &NVME_QUIRK_BOGUS_NID ) +return NVME_NIDT_NGUID_LEN ;if (cur->nidl !=NVME_NIDT_NGUID_LEN ) {dev_warn (ctrl->device,"%s %d for NVME_NIDT_NGUID\n" , warn_str, cur->nidl);
@@ -1298,6 +1302,8 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,memcpy (ids->nguid, data +sizeof (*cur),NVME_NIDT_NGUID_LEN );return NVME_NIDT_NGUID_LEN ;case NVME_NIDT_UUID : +if (ctrl->quirks &NVME_QUIRK_BOGUS_NID ) +return NVME_NIDT_UUID_LEN ;if (cur->nidl !=NVME_NIDT_UUID_LEN ) {dev_warn (ctrl->device,"%s %d for NVME_NIDT_UUID\n" , warn_str, cur->nidl);
@@ -1399,12 +1405,18 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,if ((*id)->ncap ==0 )/* namespace not allocated or attached */ goto out_free_id; -if (ctrl->vs >=NVME_VS (1 ,1 ,0 ) && - !memchr_inv (ids->eui64,0 ,sizeof (ids->eui64))) -memcpy (ids->eui64, (*id)->eui64,sizeof (ids->eui64)); -if (ctrl->vs >=NVME_VS (1 ,2 ,0 ) && - !memchr_inv (ids->nguid,0 ,sizeof (ids->nguid))) -memcpy (ids->nguid, (*id)->nguid,sizeof (ids->nguid)); + +if (ctrl->quirks &NVME_QUIRK_BOGUS_NID ) { +dev_info (ctrl->device, +"Ignoring bogus Namespace Identifiers\n" ); + }else { +if (ctrl->vs >=NVME_VS (1 ,1 ,0 ) && + !memchr_inv (ids->eui64,0 ,sizeof (ids->eui64))) +memcpy (ids->eui64, (*id)->eui64,sizeof (ids->eui64)); +if (ctrl->vs >=NVME_VS (1 ,2 ,0 ) && + !memchr_inv (ids->nguid,0 ,sizeof (ids->nguid))) +memcpy (ids->nguid, (*id)->nguid,sizeof (ids->nguid)); + }return 0 ;
drivers/nvme/host/nvme.h +5 -0
@@ -144,6 +144,11 @@ enum nvme_quirks {* encoding the generation sequence number. */ NVME_QUIRK_SKIP_CID_GEN = (1 <<17 ), + +/* +* Reports garbage in the namespace identifiers (eui64, nguid, uuid). +*/ + NVME_QUIRK_BOGUS_NID = (1 << 18), };/*
Signature · 1 line
2.30.2
Re: [PATCH 1/3] nvme: add a quirk to disable namespace identifiers
Quoted 5 lines · Christoph Hellwig
Add a quirk to disable using and exporting namespace identifiers for controllers where they are broken beyond repair.
Signed-off-by Christoph Hellwig <[email protected]>---
if possible take that quirk check out see [1] it is but more code but look much clean, either way looks good.
-ck
[1] totally untested :-
+static int nvme_id_check_quirk(u64 nidt)
+{
+ switch (cur->nidt) {
+ case NVME_NIDT_EUI64:
+ if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
+ return NVME_NIDT_EUI64_LEN;
+ return 0;
+ case NVME_NIDT_NGUID:
+ if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
+ return NVME_NIDT_NGUID_LEN;
+ return 0;
+ case NVME_NIDT_UUID:
+ if (ctrl->quirks & NVME_QUIRK_BOGUS_NID)
+ return NVME_NIDT_UUID_LEN;
+ return 0;
+ default:
+ return 0;
+ }
+}
+
static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, structnvme_ns_ids *ids,
struct nvme_ns_id_desc *cur, bool *csi_seen)
{
const char *warn_str = "ctrl returned bogus length:";
void *data = cur;+ int ret;
+
+ ret = nvme_id_check_quirk(cur->nidt);
+ if (ret)
+ return ret;
switch (cur->nidt) {
case NVME_NIDT_EUI64:Christoph Hellwig
maintainerRe: [PATCH 1/3] nvme: add a quirk to disable namespace identifiers
Review
Quoted 3 lines · Chaitanya Kulkarni
(quoted diff) +3
-0+ ret = nvme_id_check_quirk(cur->nidt); + if (ret) + return ret;
We still need to process the list to find the CSI. This is actually relevant for modern qemu, which supports multiple command sets.
Re: [PATCH 1/3] nvme: add a quirk to disable namespace identifiers
In reply to Christoph HellwigKeith Busch
maintainerRe: [PATCH 1/3] nvme: add a quirk to disable namespace identifiers
In reply to Christoph Hellwigdrivers/nvme/host/core.c static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids, · line 1289
Quoted 9 lines · Christoph Hellwig
drivers/nvme/host/core.c +2
-0@@ -1282,6 +1282,8 @@ static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,switch (cur->nidt) {case NVME_NIDT_EUI64 : +if (ctrl->quirks &NVME_QUIRK_BOGUS_NID ) +return NVME_NIDT_EUI64_LEN ;if (cur->nidl !=NVME_NIDT_EUI64_LEN ) {dev_warn (ctrl->device,"%s %d for NVME_NIDT_EUI64\n" , warn_str, cur->nidl);
Shouldn't we still verify that cur->nidl is accurate rather than assume the length? If it is the wrong length, then we have a corrupt descriptor list and should abort the process.
Christoph Hellwig
maintainerPATCH 2/3 nvme-pci: disable namespace identifiers for the MAXIO MAP1202
In reply to Christoph HellwigThe MAXIO MAP1202 controllers reports completely bogus Namespace identifiers that even change after suspend cycles. Disable using the Identifiers entirely.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3447,6 +3447,8 @@ static const struct pci_device_id nvme_id_table[] = { .driver_data = NVME_QUIRK_NO_DEEPEST_PS, }, { PCI_DEVICE(0x2646, 0x2263), /* KINGSTON A2000 NVMe SSD */ .driver_data = NVME_QUIRK_NO_DEEPEST_PS, }, + { PCI_DEVICE(0x1e4B, 0x1202), /* MAXIO MAP1202 */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0061), .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0065),
Signature · 1 line
2.30.2
Re: [PATCH 2/3] nvme-pci: disable namespace identifiers for the MAXIO MAP1202
Quoted 7 lines · Christoph Hellwig
The MAXIO MAP1202 controllers reports completely bogus Namespace identifiers that even change after suspend cycles. Disable using the Identifiers entirely.
Reported-by 金韬 <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by 金韬 <[email protected]>
Looks good.
-ck
Re: [PATCH 2/3] nvme-pci: disable namespace identifiers for the MAXIO MAP1202
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 3/3 nvme-pci: disable namespace identifiers for Qemu controllers
In reply to Christoph HellwigQemu unconditionally reports a UUID, which depending on the qemu version is either all-null (which is incorrect but harmless) or contains a single bit set for all controllers. In addition it can also optionally report a eui64 which needs to be manually set. Disable namespace identifiers for Qemu controlles entirely even if in some cases they could be set corretly through manual intervention.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3410,6 +3410,8 @@ static const struct pci_device_id nvme_id_table[] = { { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ .driver_data =NVME_QUIRK_IDENTIFY_CNS | NVME_QUIRK_DISABLE_WRITE_ZEROES, }, + { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, }, { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
Signature · 1 line
2.30.2
Re: [PATCH 3/3] nvme-pci: disable namespace identifiers for Qemu controllers
Quoted 29 lines · Christoph Hellwig
Qemu unconditionally reports a UUID, which depending on the qemu version is either all-null (which is incorrect but harmless) or contains a single bit set for all controllers. In addition it can also optionally report a eui64 which needs to be manually set. Disable namespace identifiers for Qemu controlles entirely even if in some cases they could be set corretly through manual intervention.
Reported-by Luis Chamberlain <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)drivers/nvme/host/pci.c +2
-0@@ -3410,6 +3410,8 @@ static const struct pci_device_id nvme_id_table[] = { { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ .driver_data =NVME_QUIRK_IDENTIFY_CNS | NVME_QUIRK_DISABLE_WRITE_ZEROES, }, + { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, }, { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */Signature · 1 line
2.30.2
When I fix this in QEMU properly, can we move this quirk to the core_quirks and match on firmware revision? That way I don't have to request a new DID.
Christoph Hellwig
maintainerRe: [PATCH 3/3] nvme-pci: disable namespace identifiers for Qemu controllers
Quoted 4 lines · Klaus Jensen
Quoted 4 lines
drivers/nvme/host/pci.c +2
-0+ { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
Quoted 8 lines
Quoted 4 lines
{
PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */Signature · 1 line
2.30.2When I fix this in QEMU properly, can we move this quirk to the
core_quirksand match on firmware revision? That way I don't have to request a new DID.
Do we known that only one firmware revision reported by Qemu is actually broken? For now I'd like to get the regression fixed ASAP, and I don't think Qemu ever fully got identifiers right so far. We can always change it later if needed.
Re: [PATCH 3/3] nvme-pci: disable namespace identifiers for Qemu controllers
Quoted 14 lines · Christoph Hellwig
Quoted 4 lines · Klaus Jensen
Quoted 4 lines
drivers/nvme/host/pci.c +2
-0+ { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },Quoted 8 lines
Quoted 4 lines
{
PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */Signature · 1 line
2.30.2When I fix this in QEMU properly, can we move this quirk to the
core_quirksand match on firmware revision? That way I don't have to request a new DID.
Quoted 5 lines
Do we known that only one firmware revision reported by Qemu is actually broken? For now I'd like to get the regression fixed ASAP, and I don't think Qemu ever fully got identifiers right so far. We can always change it later if needed.
To my knowledge, QEMU has only ever used 1.0 in FR, but I will check.
In any case, I did not want you to change this *now*, so I am totally fine with this getting changed later if required.
Re: [PATCH 3/3] nvme-pci: disable namespace identifiers for Qemu controllers
In reply to Christoph Hellwig