Skip to contentSkip to conversation

hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE

PATCH Applied Thomas Huth 4 participants 7 messages Nov 19, 2021 – Nov 22, 2021 SiFive drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

---
 docs/about/deprecated.rst | 6 ++++++
 hw/misc/sifive_u_otp.c    | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
docs/about/deprecated.rst +6 -0
index c03fcf951f..ff7488cb63 100644
@@ -192,6 +192,12 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
 However, short-form booleans are deprecated and full explicit ``arg_name=on``
 form is preferred.
 
+``-drive if=none`` for the sifive_u OTP device (since 6.2)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Using ``-drive if=none`` to configure the OTP device of the sifive_u
+RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
+
 
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
hw/misc/sifive_u_otp.c +8 -1
index 18aa0bd55d..cf6098ff2c 100644
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                           TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 
-    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);
+        if (dinfo) {
+            warn_report("using \"-drive if=none\" for the OTP is deprecated, "
+                        "use \"-drive if=pflash\" instead.");
+        }
+    }
     if (dinfo) {
         int ret;
         uint64_t perm;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 20 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

---
 docs/about/deprecated.rst | 6 ++++++
 hw/misc/sifive_u_otp.c    | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
hw/misc/sifive_u_otp.c +0 -0
index 18aa0bd55d..cf6098ff2c 100644

hw/misc/sifive_u_otp.c static void sifive_u_otp_realize(DeviceState *dev, Error **errp) · line 214

Quoted 7 lines
hw/misc/sifive_u_otp.c +3 -1
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                           TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 
-    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);

Isn't it a bug to call drive_get_next() from DeviceRealize()?

Shouldn't drive_get_next() be restricted to the MachineClass?

#2 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

---
  docs/about/deprecated.rst | 6 ++++++
  hw/misc/sifive_u_otp.c    | 9 ++++++++-
  2 files changed, 14 insertions(+), 1 deletion(-)
hw/misc/sifive_u_otp.c +0 -0
index 18aa0bd55d..cf6098ff2c 100644
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                            TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
      sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 
Quoted 8 lines

hw/misc/sifive_u_otp.c static void sifive_u_otp_realize(DeviceState *dev, Error **errp) · line 214

Quoted 4 lines
hw/misc/sifive_u_otp.c +3 -1
-    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);

Isn't it a bug to call drive_get_next() from DeviceRealize()?

Shouldn't drive_get_next() be restricted to the MachineClass?

Yes, that would certainly be better - but considering that we are already past RC1 of the 6.2 release, I'd rather prefer to keep this patch rather as small as possible and do such refactorings during the next development cycle instead.

Thomas

#3 lore raw
Quoted 32 lines · Thomas Huth
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

---
  docs/about/deprecated.rst | 6 ++++++
  hw/misc/sifive_u_otp.c    | 9 ++++++++-

  2 files changed, 14 insertions(+), 1 deletion(-)
hw/misc/sifive_u_otp.c +0 -0
index 18aa0bd55d..cf6098ff2c 100644

hw/misc/sifive_u_otp.c static void sifive_u_otp_realize(DeviceState · line 215

Quoted 7 lines
hw/misc/sifive_u_otp.c +3 -0
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState
 *dev, Error **errp)
                             TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
       sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
   -    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);

Isn't it a bug to call drive_get_next() from DeviceRealize()?

Quoted 6 lines
Quoted 1 line

Shouldn't drive_get_next() be restricted to the MachineClass?

Yes, that would certainly be better - but considering that we are already past RC1 of the 6.2 release, I'd rather prefer to keep this patch rather as small as possible and do such refactorings during the next development cycle instead.

OK. For pflash:

Reviewed-by
#4 lore raw
In reply to Thomas Huth
Quoted 17 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

---
  docs/about/deprecated.rst | 6 ++++++
  hw/misc/sifive_u_otp.c    | 9 ++++++++-
  2 files changed, 14 insertions(+), 1 deletion(-)
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
hw/misc/sifive_u_otp.c +0 -0
index 18aa0bd55d..cf6098ff2c 100644
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                            TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
Quoted 8 lines

hw/misc/sifive_u_otp.c static void sifive_u_otp_realize(DeviceState *dev, Error **errp) · line 214

Quoted 5 lines
hw/misc/sifive_u_otp.c +3 -0
      sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
  -    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);

Isn't it a bug to call drive_get_next() from DeviceRealize()? Shouldn't drive_get_next() be restricted to the MachineClass?

drive_get_next() needs to die:

Subject: [PATCH v2 00/13] Eliminate drive_get_next()
Message-Id: <[email protected]>

Not for 6.2.

Quoted 4 lines

Yes, that would certainly be better - but considering that we are already past RC1 of the 6.2 release, I'd rather prefer to keep this patch rather as small as possible and do such refactorings during the next development cycle instead.

Concur.

Your patch conflicts with mine. No worries, I'll rebase.

Reviewed-by on v1 1/1
#5 lore raw
In reply to Thomas Huth
Quoted 11 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

Alistair

Quoted 46 lines
---
 docs/about/deprecated.rst | 6 ++++++
 hw/misc/sifive_u_otp.c    | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
docs/about/deprecated.rst +6 -0
index c03fcf951f..ff7488cb63 100644
@@ -192,6 +192,12 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
 However, short-form booleans are deprecated and full explicit ``arg_name=on``
 form is preferred.
 
+``-drive if=none`` for the sifive_u OTP device (since 6.2)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Using ``-drive if=none`` to configure the OTP device of the sifive_u
+RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
+
 
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
hw/misc/sifive_u_otp.c +8 -2
index 18aa0bd55d..cf6098ff2c 100644
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                           TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 
-    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);
+        if (dinfo) {
+            warn_report("using \"-drive if=none\" for the OTP is deprecated, "
+                        "use \"-drive if=pflash\" instead.");
+        }
+    }
     if (dinfo) {
         int ret;
         uint64_t perm;
--

2.27.0

#6 lore raw
In reply to Thomas Huth
Quoted 11 lines · Thomas Huth

Configuring a drive with "if=none" is meant for creation of a backend only, it should not get automatically assigned to a device frontend. Use "if=pflash" for the One-Time-Programmable device instead (like it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).

Since the old way of configuring the device has already been published with the previous QEMU versions, we cannot remove this immediately, but have to deprecate it and support it for at least two more releases.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 46 lines
---
 docs/about/deprecated.rst | 6 ++++++
 hw/misc/sifive_u_otp.c    | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
docs/about/deprecated.rst +6 -0
index c03fcf951f..ff7488cb63 100644
@@ -192,6 +192,12 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
 However, short-form booleans are deprecated and full explicit ``arg_name=on``
 form is preferred.
 
+``-drive if=none`` for the sifive_u OTP device (since 6.2)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Using ``-drive if=none`` to configure the OTP device of the sifive_u
+RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
+
 
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
hw/misc/sifive_u_otp.c +8 -2
index 18aa0bd55d..cf6098ff2c 100644
@@ -209,7 +209,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
                           TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 
-    dinfo = drive_get_next(IF_NONE);
+    dinfo = drive_get_next(IF_PFLASH);
+    if (!dinfo) {
+        dinfo = drive_get_next(IF_NONE);
+        if (dinfo) {
+            warn_report("using \"-drive if=none\" for the OTP is deprecated, "
+                        "use \"-drive if=pflash\" instead.");
+        }
+    }
     if (dinfo) {
         int ret;
         uint64_t perm;
--

2.27.0