2023-01-31 18:10:25

by Saurabh Singh Sengar

[permalink] [raw]
Subject: [PATCH v2 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and
thus it can't be used for non-ACPI builds. Initaly there won't be
hibernate support for non ACPI builds.

This change will help adding device tree support in subsequent commits.

Signed-off-by: Saurabh Sengar <[email protected]>
---
drivers/hv/hv_common.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 52a6f89ccdbd..370ec20d1993 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);

bool hv_is_hibernation_supported(void)
{
+#ifdef CONFIG_ACPI
return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
+#else
+ return false;
+#endif
}
EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);

--
2.25.1



2023-02-01 17:47:54

by Michael Kelley (LINUX)

[permalink] [raw]
Subject: RE: [PATCH v2 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

From: Saurabh Sengar <[email protected]> Sent: Tuesday, January 31, 2023 10:10 AM
>
> acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and
> thus it can't be used for non-ACPI builds. Initaly there won't be

s/Initaly/Initially/

> hibernate support for non ACPI builds.

s/hibernate/hibernation/

>
> This change will help adding device tree support in subsequent commits.
>
> Signed-off-by: Saurabh Sengar <[email protected]>
> ---
> drivers/hv/hv_common.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 52a6f89ccdbd..370ec20d1993 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
>
> bool hv_is_hibernation_supported(void)
> {
> +#ifdef CONFIG_ACPI
> return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
> +#else
> + return false;
> +#endif

Is this patch needed? If CONFIG_ACPI is not set, then per
arch/x86/Kconfig, CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
is not selected. In that case, the #ifdef in include/acpi/acpi_bus.h
provides a stub for acpi_sleep_state_supported() that returns "false".
So it seems like the existing code should compile and correctly return
"false" when CONFIG_ACPI is not set.

Michael

> }
> EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
>
> --
> 2.25.1


2023-02-02 14:50:12

by Saurabh Singh Sengar

[permalink] [raw]
Subject: Re: [PATCH v2 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

On Wed, Feb 01, 2023 at 05:47:44PM +0000, Michael Kelley (LINUX) wrote:
> From: Saurabh Sengar <[email protected]> Sent: Tuesday, January 31, 2023 10:10 AM
> >
> > acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and
> > thus it can't be used for non-ACPI builds. Initaly there won't be
>
> s/Initaly/Initially/

OK

>
> > hibernate support for non ACPI builds.
>
> s/hibernate/hibernation/

OK

>
> >
> > This change will help adding device tree support in subsequent commits.
> >
> > Signed-off-by: Saurabh Sengar <[email protected]>
> > ---
> > drivers/hv/hv_common.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > index 52a6f89ccdbd..370ec20d1993 100644
> > --- a/drivers/hv/hv_common.c
> > +++ b/drivers/hv/hv_common.c
> > @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
> >
> > bool hv_is_hibernation_supported(void)
> > {
> > +#ifdef CONFIG_ACPI
> > return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
> > +#else
> > + return false;
> > +#endif
>
> Is this patch needed? If CONFIG_ACPI is not set, then per
> arch/x86/Kconfig, CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
> is not selected. In that case, the #ifdef in include/acpi/acpi_bus.h
> provides a stub for acpi_sleep_state_supported() that returns "false".
> So it seems like the existing code should compile and correctly return
> "false" when CONFIG_ACPI is not set.

You are right, if CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT is not set
acpi_sleep_state_supported will return false, but this is applicable only
when CONFIG_ACPI is enable. If CONFIG_ACPI is not enable both these
functions are not defined.

Regards,
Saurabh


>
> Michael
>
> > }
> > EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
> >
> > --
> > 2.25.1

2023-02-02 15:39:28

by Michael Kelley (LINUX)

[permalink] [raw]
Subject: RE: [PATCH v2 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

From: Saurabh Singh Sengar <[email protected]> Sent: Thursday, February 2, 2023 6:49 AM
>
> On Wed, Feb 01, 2023 at 05:47:44PM +0000, Michael Kelley (LINUX) wrote:
> > From: Saurabh Sengar <[email protected]> Sent: Tuesday, January 31,
> 2023 10:10 AM
> > >
> > > acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and
> > > thus it can't be used for non-ACPI builds. Initaly there won't be
> >
> > s/Initaly/Initially/
>
> OK
>
> >
> > > hibernate support for non ACPI builds.
> >
> > s/hibernate/hibernation/
>
> OK
>
> >
> > >
> > > This change will help adding device tree support in subsequent commits.
> > >
> > > Signed-off-by: Saurabh Sengar <[email protected]>
> > > ---
> > > drivers/hv/hv_common.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > > index 52a6f89ccdbd..370ec20d1993 100644
> > > --- a/drivers/hv/hv_common.c
> > > +++ b/drivers/hv/hv_common.c
> > > @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
> > >
> > > bool hv_is_hibernation_supported(void)
> > > {
> > > +#ifdef CONFIG_ACPI
> > > return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
> > > +#else
> > > + return false;
> > > +#endif
> >
> > Is this patch needed? If CONFIG_ACPI is not set, then per
> > arch/x86/Kconfig, CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
> > is not selected. In that case, the #ifdef in include/acpi/acpi_bus.h
> > provides a stub for acpi_sleep_state_supported() that returns "false".
> > So it seems like the existing code should compile and correctly return
> > "false" when CONFIG_ACPI is not set.
>
> You are right, if CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT is not set
> acpi_sleep_state_supported will return false, but this is applicable only
> when CONFIG_ACPI is enable. If CONFIG_ACPI is not enable both these
> functions are not defined.
>

Indeed, you are right. Most of include/acpi/acpi_bus.h is bracketed with
#ifdef CONFIG_ACPI, including the stub acpi_sleep_state_supported().
Oh well. :-(

Michael