qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
@ 2023-11-20 11:51 Philippe Mathieu-Daudé
  2023-11-20 15:34 ` Peter Maydell
  2023-11-21  9:23 ` Markus Armbruster
  0 siblings, 2 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-20 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Jean-Christophe Dubois, qemu-arm,
	Peter Maydell, Philippe Mathieu-Daudé

Both i.MX25 and i.MX6 SoC models ignore the Error argument when
setting the PHY number. Pick &error_abort which is the error
used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
the FEC PHY on i.MX7 processor").

Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/fsl-imx25.c | 3 ++-
 hw/arm/fsl-imx6.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 24c4374590..9aabbf7f58 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -169,7 +169,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
                                             epit_table[i].irq));
     }
 
-    object_property_set_uint(OBJECT(&s->fec), "phy-num", s->phy_num, &err);
+    object_property_set_uint(OBJECT(&s->fec), "phy-num", s->phy_num,
+                             &error_abort);
     qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
 
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->fec), errp)) {
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 4fa7f0b95e..7dc42cbfe6 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -379,7 +379,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                                             spi_table[i].irq));
     }
 
-    object_property_set_uint(OBJECT(&s->eth), "phy-num", s->phy_num, &err);
+    object_property_set_uint(OBJECT(&s->eth), "phy-num", s->phy_num,
+                             &error_abort);
     qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]);
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->eth), errp)) {
         return;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
  2023-11-20 11:51 [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument Philippe Mathieu-Daudé
@ 2023-11-20 15:34 ` Peter Maydell
  2023-11-21  6:40   ` Markus Armbruster
       [not found]   ` <87y1ermx1b.fsf@pond.sub.org>
  2023-11-21  9:23 ` Markus Armbruster
  1 sibling, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2023-11-20 15:34 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Markus Armbruster, Jean-Christophe Dubois, qemu-arm

On Mon, 20 Nov 2023 at 11:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Both i.MX25 and i.MX6 SoC models ignore the Error argument when
> setting the PHY number. Pick &error_abort which is the error
> used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
> the FEC PHY on i.MX7 processor").
>
> Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
> Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
  2023-11-20 15:34 ` Peter Maydell
@ 2023-11-21  6:40   ` Markus Armbruster
  2023-11-21  8:11     ` Philippe Mathieu-Daudé
       [not found]   ` <87y1ermx1b.fsf@pond.sub.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2023-11-21  6:40 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Philippe Mathieu-Daudé, qemu-devel, Jean-Christophe Dubois,
	qemu-arm

Peter Maydell <peter.maydell@linaro.org> writes:

> On Mon, 20 Nov 2023 at 11:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Both i.MX25 and i.MX6 SoC models ignore the Error argument when
>> setting the PHY number. Pick &error_abort which is the error
>> used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
>> the FEC PHY on i.MX7 processor").
>>
>> Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
>> Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>
>
>
> Applied to target-arm.next, thanks.

With or without my commit message clarification?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
       [not found]   ` <87y1ermx1b.fsf@pond.sub.org>
@ 2023-11-21  7:55     ` Markus Armbruster
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2023-11-21  7:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Philippe Mathieu-Daudé, qemu-devel, Jean-Christophe Dubois,
	qemu-arm

Markus Armbruster <armbru@redhat.com> writes:

> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On Mon, 20 Nov 2023 at 11:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>
>>> Both i.MX25 and i.MX6 SoC models ignore the Error argument when
>>> setting the PHY number. Pick &error_abort which is the error
>>> used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
>>> the FEC PHY on i.MX7 processor").
>>>
>>> Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
>>> Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>
>>
>>
>> Applied to target-arm.next, thanks.
>
> With or without my commit message clarification?

Uh-oh, I had mail trouble.  Resending stuck messages.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
  2023-11-21  6:40   ` Markus Armbruster
@ 2023-11-21  8:11     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-21  8:11 UTC (permalink / raw)
  To: Markus Armbruster, Peter Maydell
  Cc: qemu-devel, Jean-Christophe Dubois, qemu-arm

Hi Markus,

On 21/11/23 07:40, Markus Armbruster wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
> 
>> On Mon, 20 Nov 2023 at 11:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>
>>> Both i.MX25 and i.MX6 SoC models ignore the Error argument when
>>> setting the PHY number. Pick &error_abort which is the error
>>> used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
>>> the FEC PHY on i.MX7 processor").
>>>
>>> Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
>>> Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>
>>
>>
>> Applied to target-arm.next, thanks.
> 
> With or without my commit message clarification?

I didn't get your email on this patch, but per the other
ones on similar fixes:
https://lore.kernel.org/all/87cyw3mu4r.fsf@pond.sub.org/
https://lore.kernel.org/all/87il5vlemo.fsf@pond.sub.org/
I assume you want:

   Both i.MX25 and i.MX6 SoC models ignore the Error argument when
   setting the PHY number with object_property_set_uint(). If this
   @errp argument is set, its following use via sysbus_realize()
   might potentially triggers an assertion in error_setv().

   Pick &error_abort which is the error used by the i.MX7 SoC (see
   commit 1f7197deb0 "ability to change the FEC PHY on i.MX7 processor").

If that is OK with you, Peter, do you mind updating the description?

Thanks both!

Phil.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument
  2023-11-20 11:51 [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument Philippe Mathieu-Daudé
  2023-11-20 15:34 ` Peter Maydell
@ 2023-11-21  9:23 ` Markus Armbruster
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2023-11-21  9:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Jean-Christophe Dubois, qemu-arm, Peter Maydell

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> Both i.MX25 and i.MX6 SoC models ignore the Error argument when
> setting the PHY number. Pick &error_abort which is the error
> used by the i.MX7 SoC (see commit 1f7197deb0 "ability to change
> the FEC PHY on i.MX7 processor").
>
> Fixes: 74c1330582 ("ability to change the FEC PHY on i.MX25 processor")
> Fixes: a9c167a3c4 ("ability to change the FEC PHY on i.MX6 processor")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/fsl-imx25.c | 3 ++-
>  hw/arm/fsl-imx6.c  | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
> index 24c4374590..9aabbf7f58 100644
> --- a/hw/arm/fsl-imx25.c
> +++ b/hw/arm/fsl-imx25.c
> @@ -169,7 +169,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
>                                              epit_table[i].irq));
>      }
>  
> -    object_property_set_uint(OBJECT(&s->fec), "phy-num", s->phy_num, &err);

This is actually worse than "ignore the Error argument".  If this fails,
we continue with @err not null.  If we actually reach the next use of
@err...

> +    object_property_set_uint(OBJECT(&s->fec), "phy-num", s->phy_num,
> +                             &error_abort);
>      qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
>  
>      if (!sysbus_realize(SYS_BUS_DEVICE(&s->fec), errp)) {
           return;
       }
       sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
       sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
                          qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));

       if (!sysbus_realize(SYS_BUS_DEVICE(&s->rngc), errp)) {
           return;
       }
       
       [...]

       /* initialize 2 x 16 KB ROM */

... here, we pass a non-null @err to memory_region_init_rom().  Any
error will trip error_setv()'s assertion.

       memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
                              FSL_IMX25_ROM0_SIZE, &err);
       if (err) {
           error_propagate(errp, err);
           return;
       }

This is an instance of an anti-pattern: passing &err or errp without
checking for failure.  Three possible fixes:

1. Check for failure.

2. Pass &error_abort instead.  This is appropriate for programming
   errors.

3. Pass NULL instead.  This is appropriate when errors don't matter.
   Which is rare.

You go with 2., which looks good to me.

> diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
> index 4fa7f0b95e..7dc42cbfe6 100644
> --- a/hw/arm/fsl-imx6.c
> +++ b/hw/arm/fsl-imx6.c
> @@ -379,7 +379,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
>                                              spi_table[i].irq));
>      }
>  
> -    object_property_set_uint(OBJECT(&s->eth), "phy-num", s->phy_num, &err);
> +    object_property_set_uint(OBJECT(&s->eth), "phy-num", s->phy_num,
> +                             &error_abort);
>      qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]);
>      if (!sysbus_realize(SYS_BUS_DEVICE(&s->eth), errp)) {
>          return;

Same.

Suggest to clarify the commit message like this:

  Both i.MX25 and i.MX6 SoC pass &err to object_property_set_uint()
  without checking for failure.  Running into another failure will trip
  error_setv()'s assertion.

  Pass &error_abort instead, like the i.MX7 SoC does (see commit
  1f7197deb0 "ability to change the FEC PHY on i.MX7 processor").

With something like that:
Reviewed-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-21  9:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-20 11:51 [PATCH-for-8.2?] hw/arm/fsl-imx: Do not ignore Error argument Philippe Mathieu-Daudé
2023-11-20 15:34 ` Peter Maydell
2023-11-21  6:40   ` Markus Armbruster
2023-11-21  8:11     ` Philippe Mathieu-Daudé
     [not found]   ` <87y1ermx1b.fsf@pond.sub.org>
2023-11-21  7:55     ` Markus Armbruster
2023-11-21  9:23 ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).