All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/acpi: some cosmetic improvements to existing code
@ 2021-07-21 14:07 Ani Sinha
  2021-07-21 14:11 ` Ani Sinha
  0 siblings, 1 reply; 9+ messages in thread
From: Ani Sinha @ 2021-07-21 14:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, Ani Sinha, Michael S. Tsirkin

From: Ani Sinha <anirban.sinha@nokia.com>

All existing code using acpi_get_i386_pci_host() checks for a non-null
return from this function call. This change brings the same check to
acpi_pcihp_disable_root_bus() function. Also adds a comment describing
why we unconditionally pass a truth value to the last argument when calling
acpi_pcihp_reset() from ich9 platform.

Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 hw/acpi/ich9.c  | 1 +
 hw/acpi/pcihp.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 778e27b659..58d8430eb9 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
     pm->smi_en_wmask = ~0;
 
     if (pm->use_acpi_hotplug_bridge) {
+        /* on root PCIE bus, we always use native or SHPC based hotplug */
         acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
     }
 
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index f4d706e47d..856c6e1b47 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
         return;
     }
 
+    if (!host) {
+        root_hp_disabled = true;
+        return;
+    }
+
     bus = PCI_HOST_BRIDGE(host)->bus;
     if (bus) {
         /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
-- 
2.25.1



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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-21 14:07 [PATCH] hw/acpi: some cosmetic improvements to existing code Ani Sinha
@ 2021-07-21 14:11 ` Ani Sinha
  0 siblings, 0 replies; 9+ messages in thread
From: Ani Sinha @ 2021-07-21 14:11 UTC (permalink / raw)
  To: Ani Sinha; +Cc: Igor Mammedov, qemu-devel, Ani Sinha, Michael S. Tsirkin

Please scratch this. I will resend with my nokia email removed. This work
does not involve Nokia.

Ani


On Wed, 21 Jul 2021, Ani Sinha wrote:

> From: Ani Sinha <anirban.sinha@nokia.com>
>
> All existing code using acpi_get_i386_pci_host() checks for a non-null
> return from this function call. This change brings the same check to
> acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> why we unconditionally pass a truth value to the last argument when calling
> acpi_pcihp_reset() from ich9 platform.
>
> Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
>
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  hw/acpi/ich9.c  | 1 +
>  hw/acpi/pcihp.c | 5 +++++
>  2 files changed, 6 insertions(+)
>
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 778e27b659..58d8430eb9 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
>      pm->smi_en_wmask = ~0;
>
>      if (pm->use_acpi_hotplug_bridge) {
> +        /* on root PCIE bus, we always use native or SHPC based hotplug */
>          acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
>      }
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index f4d706e47d..856c6e1b47 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
>          return;
>      }
>
> +    if (!host) {
> +        root_hp_disabled = true;
> +        return;
> +    }
> +
>      bus = PCI_HOST_BRIDGE(host)->bus;
>      if (bus) {
>          /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
> --
> 2.25.1
>
>


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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-26 13:29     ` Igor Mammedov
@ 2021-07-26 13:50       ` Ani Sinha
  0 siblings, 0 replies; 9+ messages in thread
From: Ani Sinha @ 2021-07-26 13:50 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: Ani Sinha, jusual, qemu-devel, Michael S. Tsirkin



> > > > diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> > > > index f4d706e47d..856c6e1b47 100644
> > > > --- a/hw/acpi/pcihp.c
> > > > +++ b/hw/acpi/pcihp.c
> > > > @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
> > > >          return;
> > > >      }
> > > >
> > > > +    if (!host) {
> > > > +        root_hp_disabled = true;
> > > > +        return;
> > > > +    }
> > > It should be a separate patch,
> > > when this could return NULL?
> > > If it should never be null then assert here would be better.
> >
> > I have sent a v2 without the comment addition. I left the code this way
> > because everywhere else, the code checking host for NULL value is similar.
> > I wanted to keep the symmetry. However, if you strongly feel about the
> > assertion, I will send a v3.
>
> So the first thing is to confirm if NULL return value is valid or not.
> When it clear we can decide whether copy existing check like you do or
> replace all such checks with asserts.

I thought about this a little and I am now inclined to put assertions
everywhere. On i386 we have either q35 or i440fx host bridges. Having a
null host bridge does not sound right. I will make the change, build and
make check before sending out v3 with assertions.



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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-26 11:59 ` Igor Mammedov
  2021-07-26 12:56   ` Ani Sinha
@ 2021-07-26 13:44   ` Ani Sinha
  1 sibling, 0 replies; 9+ messages in thread
From: Ani Sinha @ 2021-07-26 13:44 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: Ani Sinha, jusual, qemu-devel, Michael S. Tsirkin



On Mon, 26 Jul 2021, Igor Mammedov wrote:

> On Wed, 21 Jul 2021 19:46:10 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > All existing code using acpi_get_i386_pci_host() checks for a non-null
> > return from this function call. This change brings the same check to
> > acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> > why we unconditionally pass a truth value to the last argument when calling
> > acpi_pcihp_reset() from ich9 platform.
> >
> > Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  hw/acpi/ich9.c  | 1 +
> >  hw/acpi/pcihp.c | 5 +++++
> >  2 files changed, 6 insertions(+)
> >
> > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> > index 778e27b659..58d8430eb9 100644
> > --- a/hw/acpi/ich9.c
> > +++ b/hw/acpi/ich9.c
> > @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
> >      pm->smi_en_wmask = ~0;
> >
> >      if (pm->use_acpi_hotplug_bridge) {
> > +        /* on root PCIE bus, we always use native or SHPC based hotplug */
> I had an impression that root bus doesn't support hotplug at all,
> and to have hotplug there one should attach a root-port to root bus at
> start up time.

Yes this is correct.
https://github.com/qemu/qemu/blob/master/docs/pcie.txt
https://libvirt.org/pci-hotplug.html

I will update the comment accordingly.



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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-26 12:56   ` Ani Sinha
@ 2021-07-26 13:29     ` Igor Mammedov
  2021-07-26 13:50       ` Ani Sinha
  0 siblings, 1 reply; 9+ messages in thread
From: Igor Mammedov @ 2021-07-26 13:29 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Mon, 26 Jul 2021 18:26:28 +0530 (IST)
Ani Sinha <ani@anisinha.ca> wrote:

> On Mon, 26 Jul 2021, Igor Mammedov wrote:
> 
> > On Wed, 21 Jul 2021 19:46:10 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >  
> > > All existing code using acpi_get_i386_pci_host() checks for a non-null
> > > return from this function call. This change brings the same check to
> > > acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> > > why we unconditionally pass a truth value to the last argument when calling
> > > acpi_pcihp_reset() from ich9 platform.
> > >
> > > Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
> > >
> > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > ---
> > >  hw/acpi/ich9.c  | 1 +
> > >  hw/acpi/pcihp.c | 5 +++++
> > >  2 files changed, 6 insertions(+)
> > >
> > > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> > > index 778e27b659..58d8430eb9 100644
> > > --- a/hw/acpi/ich9.c
> > > +++ b/hw/acpi/ich9.c
> > > @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
> > >      pm->smi_en_wmask = ~0;
> > >
> > >      if (pm->use_acpi_hotplug_bridge) {
> > > +        /* on root PCIE bus, we always use native or SHPC based hotplug */  
> > I had an impression that root bus doesn't support hotplug at all,
> > and to have hotplug there one should attach a root-port to root bus at
> > start up time.  
> 
> I think you are right. However, I will let others confirm this and update
> the comment accordingly in a separate patch.
> 
> 
> >  
> > >          acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
> > >      }
> > >
> > > diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> > > index f4d706e47d..856c6e1b47 100644
> > > --- a/hw/acpi/pcihp.c
> > > +++ b/hw/acpi/pcihp.c
> > > @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
> > >          return;
> > >      }
> > >
> > > +    if (!host) {
> > > +        root_hp_disabled = true;
> > > +        return;
> > > +    }  
> > It should be a separate patch,
> > when this could return NULL?
> > If it should never be null then assert here would be better.  
> 
> I have sent a v2 without the comment addition. I left the code this way
> because everywhere else, the code checking host for NULL value is similar.
> I wanted to keep the symmetry. However, if you strongly feel about the
> assertion, I will send a v3.

So the first thing is to confirm if NULL return value is valid or not.
When it clear we can decide whether copy existing check like you do or
replace all such checks with asserts.

> 
> 
> >  
> > > +
> > >      bus = PCI_HOST_BRIDGE(host)->bus;
> > >      if (bus) {
> > >          /* setting the hotplug handler to NULL makes the bus non-hotpluggable */  
> >
> >  
> 



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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-26 11:59 ` Igor Mammedov
@ 2021-07-26 12:56   ` Ani Sinha
  2021-07-26 13:29     ` Igor Mammedov
  2021-07-26 13:44   ` Ani Sinha
  1 sibling, 1 reply; 9+ messages in thread
From: Ani Sinha @ 2021-07-26 12:56 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: Ani Sinha, jusual, qemu-devel, Michael S. Tsirkin



On Mon, 26 Jul 2021, Igor Mammedov wrote:

> On Wed, 21 Jul 2021 19:46:10 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > All existing code using acpi_get_i386_pci_host() checks for a non-null
> > return from this function call. This change brings the same check to
> > acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> > why we unconditionally pass a truth value to the last argument when calling
> > acpi_pcihp_reset() from ich9 platform.
> >
> > Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  hw/acpi/ich9.c  | 1 +
> >  hw/acpi/pcihp.c | 5 +++++
> >  2 files changed, 6 insertions(+)
> >
> > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> > index 778e27b659..58d8430eb9 100644
> > --- a/hw/acpi/ich9.c
> > +++ b/hw/acpi/ich9.c
> > @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
> >      pm->smi_en_wmask = ~0;
> >
> >      if (pm->use_acpi_hotplug_bridge) {
> > +        /* on root PCIE bus, we always use native or SHPC based hotplug */
> I had an impression that root bus doesn't support hotplug at all,
> and to have hotplug there one should attach a root-port to root bus at
> start up time.

I think you are right. However, I will let others confirm this and update
the comment accordingly in a separate patch.


>
> >          acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
> >      }
> >
> > diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> > index f4d706e47d..856c6e1b47 100644
> > --- a/hw/acpi/pcihp.c
> > +++ b/hw/acpi/pcihp.c
> > @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
> >          return;
> >      }
> >
> > +    if (!host) {
> > +        root_hp_disabled = true;
> > +        return;
> > +    }
> It should be a separate patch,
> when this could return NULL?
> If it should never be null then assert here would be better.

I have sent a v2 without the comment addition. I left the code this way
because everywhere else, the code checking host for NULL value is similar.
I wanted to keep the symmetry. However, if you strongly feel about the
assertion, I will send a v3.


>
> > +
> >      bus = PCI_HOST_BRIDGE(host)->bus;
> >      if (bus) {
> >          /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
>
>


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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-21 14:16 Ani Sinha
  2021-07-25  7:14 ` Ani Sinha
@ 2021-07-26 11:59 ` Igor Mammedov
  2021-07-26 12:56   ` Ani Sinha
  2021-07-26 13:44   ` Ani Sinha
  1 sibling, 2 replies; 9+ messages in thread
From: Igor Mammedov @ 2021-07-26 11:59 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Wed, 21 Jul 2021 19:46:10 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> All existing code using acpi_get_i386_pci_host() checks for a non-null
> return from this function call. This change brings the same check to
> acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> why we unconditionally pass a truth value to the last argument when calling
> acpi_pcihp_reset() from ich9 platform.
> 
> Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  hw/acpi/ich9.c  | 1 +
>  hw/acpi/pcihp.c | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 778e27b659..58d8430eb9 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
>      pm->smi_en_wmask = ~0;
>  
>      if (pm->use_acpi_hotplug_bridge) {
> +        /* on root PCIE bus, we always use native or SHPC based hotplug */
I had an impression that root bus doesn't support hotplug at all,
and to have hotplug there one should attach a root-port to root bus at
start up time.

>          acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
>      }
>  
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index f4d706e47d..856c6e1b47 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
>          return;
>      }
>  
> +    if (!host) {
> +        root_hp_disabled = true;
> +        return;
> +    }
It should be a separate patch,
when this could return NULL?
If it should never be null then assert here would be better.
 
> +
>      bus = PCI_HOST_BRIDGE(host)->bus;
>      if (bus) {
>          /* setting the hotplug handler to NULL makes the bus non-hotpluggable */



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

* Re: [PATCH] hw/acpi: some cosmetic improvements to existing code
  2021-07-21 14:16 Ani Sinha
@ 2021-07-25  7:14 ` Ani Sinha
  2021-07-26 11:59 ` Igor Mammedov
  1 sibling, 0 replies; 9+ messages in thread
From: Ani Sinha @ 2021-07-25  7:14 UTC (permalink / raw)
  To: Ani Sinha; +Cc: Igor Mammedov, jusual, qemu-devel, Michael S. Tsirkin

ping ...

On Wed, 21 Jul 2021, Ani Sinha wrote:

> All existing code using acpi_get_i386_pci_host() checks for a non-null
> return from this function call. This change brings the same check to
> acpi_pcihp_disable_root_bus() function. Also adds a comment describing
> why we unconditionally pass a truth value to the last argument when calling
> acpi_pcihp_reset() from ich9 platform.
>
> Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
>
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  hw/acpi/ich9.c  | 1 +
>  hw/acpi/pcihp.c | 5 +++++
>  2 files changed, 6 insertions(+)
>
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 778e27b659..58d8430eb9 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
>      pm->smi_en_wmask = ~0;
>
>      if (pm->use_acpi_hotplug_bridge) {
> +        /* on root PCIE bus, we always use native or SHPC based hotplug */
>          acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
>      }
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index f4d706e47d..856c6e1b47 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
>          return;
>      }
>
> +    if (!host) {
> +        root_hp_disabled = true;
> +        return;
> +    }
> +
>      bus = PCI_HOST_BRIDGE(host)->bus;
>      if (bus) {
>          /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
> --
> 2.25.1
>
>


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

* [PATCH] hw/acpi: some cosmetic improvements to existing code
@ 2021-07-21 14:16 Ani Sinha
  2021-07-25  7:14 ` Ani Sinha
  2021-07-26 11:59 ` Igor Mammedov
  0 siblings, 2 replies; 9+ messages in thread
From: Ani Sinha @ 2021-07-21 14:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

All existing code using acpi_get_i386_pci_host() checks for a non-null
return from this function call. This change brings the same check to
acpi_pcihp_disable_root_bus() function. Also adds a comment describing
why we unconditionally pass a truth value to the last argument when calling
acpi_pcihp_reset() from ich9 platform.

Fixes: c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 hw/acpi/ich9.c  | 1 +
 hw/acpi/pcihp.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 778e27b659..58d8430eb9 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -281,6 +281,7 @@ static void pm_reset(void *opaque)
     pm->smi_en_wmask = ~0;
 
     if (pm->use_acpi_hotplug_bridge) {
+        /* on root PCIE bus, we always use native or SHPC based hotplug */
         acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);
     }
 
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index f4d706e47d..856c6e1b47 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -136,6 +136,11 @@ static void acpi_pcihp_disable_root_bus(void)
         return;
     }
 
+    if (!host) {
+        root_hp_disabled = true;
+        return;
+    }
+
     bus = PCI_HOST_BRIDGE(host)->bus;
     if (bus) {
         /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
-- 
2.25.1



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

end of thread, other threads:[~2021-07-26 13:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 14:07 [PATCH] hw/acpi: some cosmetic improvements to existing code Ani Sinha
2021-07-21 14:11 ` Ani Sinha
2021-07-21 14:16 Ani Sinha
2021-07-25  7:14 ` Ani Sinha
2021-07-26 11:59 ` Igor Mammedov
2021-07-26 12:56   ` Ani Sinha
2021-07-26 13:29     ` Igor Mammedov
2021-07-26 13:50       ` Ani Sinha
2021-07-26 13:44   ` Ani Sinha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.