Skip to contentSkip to conversation

hw/ufs: avoid generating the same ID string for different LU devices

PATCH In review Akinobu Mita 3 participants 5 messages Dec 4, 2023 – Dec 5, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ufs: avoid generating the same ID string for different LU devices

QEMU would not start when trying to create two UFS host controllers and a UFS logical unit for each with the following options:

-device ufs,id=bus0 \
-device ufs-lu,drive=drive1,bus=bus0,lun=0 \
-device ufs,id=bus1 \
-device ufs-lu,drive=drive2,bus=bus1,lun=0 \

This is because the same ID string ("0:0:0/scsi-disk") is generated for both UFS logical units.

To fix this issue, prepend the parent pci device's path to make the ID string unique.
("0000:00:03.0/0:0:0/scsi-disk" and "0000:00:04.0/0:0:0/scsi-disk")

Fixes 096434fea13a ("hw/ufs: Modify lu.c to share codes with SCSI subsystem")
---
 hw/ufs/ufs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ufs/ufs.c +8 -0
index 68c5f1f6c9..eccdb852a0 100644
@@ -1323,9 +1323,17 @@ static bool ufs_bus_check_address(BusState *qbus, DeviceState *qdev,
     return true;
 }
 
+static char *ufs_bus_get_dev_path(DeviceState *dev)
+{
+    BusState *bus = qdev_get_parent_bus(dev);
+
+    return qdev_get_dev_path(bus->parent);
+}
+
 static void ufs_bus_class_init(ObjectClass *class, void *data)
 {
     BusClass *bc = BUS_CLASS(class);
+    bc->get_dev_path = ufs_bus_get_dev_path;
     bc->check_address = ufs_bus_check_address;
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Akinobu Mita

QEMU would not start when trying to create two UFS host controllers and a UFS logical unit for each with the following options:

(quoted diff) +0 -4
-device ufs,id=bus0 \
-device ufs-lu,drive=drive1,bus=bus0,lun=0 \
-device ufs,id=bus1 \
-device ufs-lu,drive=drive2,bus=bus1,lun=0 \

This is because the same ID string ("0:0:0/scsi-disk") is generated for both UFS logical units.

Quoted 6 lines

To fix this issue, prepend the parent pci device's path to make the ID string unique.
("0000:00:03.0/0:0:0/scsi-disk" and "0000:00:04.0/0:0:0/scsi-disk")

Fixes 096434fea13a ("hw/ufs: Modify lu.c to share codes with SCSI subsystem")
Quoted 26 lines
---
  hw/ufs/ufs.c | 8 ++++++++
  1 file changed, 8 insertions(+)
hw/ufs/ufs.c +8 -0
index 68c5f1f6c9..eccdb852a0 100644
@@ -1323,9 +1323,17 @@ static bool ufs_bus_check_address(BusState *qbus, DeviceState *qdev,
      return true;
  }
 
+static char *ufs_bus_get_dev_path(DeviceState *dev)
+{
+    BusState *bus = qdev_get_parent_bus(dev);
+
+    return qdev_get_dev_path(bus->parent);
+}
+
  static void ufs_bus_class_init(ObjectClass *class, void *data)
  {
      BusClass *bc = BUS_CLASS(class);
+    bc->get_dev_path = ufs_bus_get_dev_path;
      bc->check_address = ufs_bus_check_address;
  }
 
#2 lore raw

Hi Jeuk,

Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Akinobu Mita

QEMU would not start when trying to create two UFS host controllers and a UFS logical unit for each with the following options:

(quoted diff) +0 -4
-device ufs,id=bus0 \
-device ufs-lu,drive=drive1,bus=bus0,lun=0 \
-device ufs,id=bus1 \
-device ufs-lu,drive=drive2,bus=bus1,lun=0 \
Quoted 8 lines
Quoted 8 lines

This is because the same ID string ("0:0:0/scsi-disk") is generated for both UFS logical units.

To fix this issue, prepend the parent pci device's path to make the ID string unique.
("0000:00:03.0/0:0:0/scsi-disk" and "0000:00:04.0/0:0:0/scsi-disk")

Fixes 096434fea13a ("hw/ufs: Modify lu.c to share codes with SCSI subsystem")

If you think this must be fixed for the 8.2 release, please assign a release blocker issues to the GitLab 8.2 milestone here:
https://gitlab.com/qemu-project/qemu/-/milestones/10

Quoted 30 lines
Quoted 1 line
Quoted 25 lines

---
  hw/ufs/ufs.c | 8 ++++++++

  1 file changed, 8 insertions(+)
hw/ufs/ufs.c +8 -0
index 68c5f1f6c9..eccdb852a0 100644
@@ -1323,9 +1323,17 @@ static bool ufs_bus_check_address(BusState 
 *qbus, DeviceState *qdev,
       return true;
   }
+static char *ufs_bus_get_dev_path(DeviceState *dev)
+{
+    BusState *bus = qdev_get_parent_bus(dev);
+
+    return qdev_get_dev_path(bus->parent);
+}
+
   static void ufs_bus_class_init(ObjectClass *class, void *data)
   {
       BusClass *bc = BUS_CLASS(class);
+    bc->get_dev_path = ufs_bus_get_dev_path;
       bc->check_address = ufs_bus_check_address;
   }
#3 lore raw

Hi Philippe,

Thank you for informing me.
I want this issue is fixed for the 8.2 release.

I created an issue like you said, but I couldn't assign the milestone (I'm guessing it's a permission problem).
https://gitlab.com/qemu-project/qemu/-/issues/2018
Could you help me with this?

Regardless, I'm going to submit a pull request to fix the issue right away.

Thank you.

Quoted 55 lines · Philippe Mathieu-Daudé

Hi Jeuk,

Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Akinobu Mita

QEMU would not start when trying to create two UFS host controllers and a UFS logical unit for each with the following options:

(quoted diff) +0 -4
-device ufs,id=bus0 \
-device ufs-lu,drive=drive1,bus=bus0,lun=0 \
-device ufs,id=bus1 \
-device ufs-lu,drive=drive2,bus=bus1,lun=0 \

This is because the same ID string ("0:0:0/scsi-disk") is generated for both UFS logical units.

Quoted 6 lines
Quoted 6 lines

To fix this issue, prepend the parent pci device's path to make the ID string unique.
("0000:00:03.0/0:0:0/scsi-disk" and "0000:00:04.0/0:0:0/scsi-disk")

Fixes 096434fea13a ("hw/ufs: Modify lu.c to share codes with SCSI

subsystem")

If you think this must be fixed for the 8.2 release, please assign a release blocker issues to the GitLab 8.2 milestone here:
https://gitlab.com/qemu-project/qemu/-/milestones/10

Quoted 29 lines
Quoted 1 line
Quoted 25 lines

---
  hw/ufs/ufs.c 8 ++++++++

  1 file changed, 8 insertions(+)
hw/ufs/ufs.c +8 -0
index 68c5f1f6c9..eccdb852a0 100644
@@ -1323,9 +1323,17 @@ static bool ufs_bus_check_address(BusState
 *qbus, DeviceState *qdev,
       return true;
   }
+static char *ufs_bus_get_dev_path(DeviceState *dev)
+{
+    BusState *bus = qdev_get_parent_bus(dev);
+
+    return qdev_get_dev_path(bus->parent);
+}
+
   static void ufs_bus_class_init(ObjectClass *class, void *data)
   {
       BusClass *bc = BUS_CLASS(class);
+    bc->get_dev_path = ufs_bus_get_dev_path;
       bc->check_address = ufs_bus_check_address;
   }
Reviewed-by
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Akinobu Mita

QEMU would not start when trying to create two UFS host controllers and a UFS logical unit for each with the following options:

(quoted diff) +0 -4
-device ufs,id=bus0 \
-device ufs-lu,drive=drive1,bus=bus0,lun=0 \
-device ufs,id=bus1 \
-device ufs-lu,drive=drive2,bus=bus1,lun=0 \

This is because the same ID string ("0:0:0/scsi-disk") is generated for both UFS logical units.

Quoted 6 lines

To fix this issue, prepend the parent pci device's path to make the ID string unique.
("0000:00:03.0/0:0:0/scsi-disk" and "0000:00:04.0/0:0:0/scsi-disk")

Fixes 096434fea13a ("hw/ufs: Modify lu.c to share codes with SCSI subsystem")

Thank you!