mbox series

[0/3] riscv: sbi: Switch to the sys-off handler API

Message ID 20221228161915.13194-1-samuel@sholland.org (mailing list archive)
Headers show
Series riscv: sbi: Switch to the sys-off handler API | expand

Message

Samuel Holland Dec. 28, 2022, 4:19 p.m. UTC
I want to convert the axp20x PMIC poweroff handler to use the sys-off
API, so it can be used as a fallback for if the SBI poweroff handler
is unavailable. But the SBI poweroff handler still uses pm_power_off, so
done alone, this would cause the axp20x callback to be called first,
before the SBI poweroff handler has a chance to run.

In order to prevent this change in behavior, the SBI poweroff handler
needs to be converted to the sys-off API first, at a higher priority.

This series performs the conversion, after accounting for the fact that
the SBI poweroff handler is registered quite early during boot.

The first patch is a dependency for both this series and the PSCI
series[1], so I would like to get at least patch 1 merged soon.

[1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/


Samuel Holland (3):
  kernel/reboot: Use the static sys-off handler for any priority
  riscv: sbi: Share the code for unsupported extension warnings
  riscv: sbi: Switch to the sys-off handler API

 arch/riscv/include/asm/sbi.h |  1 -
 arch/riscv/kernel/sbi.c      | 63 +++++++++++++++++++++---------------
 kernel/reboot.c              | 10 +++---
 3 files changed, 41 insertions(+), 33 deletions(-)

Comments

Conor Dooley Dec. 28, 2022, 6:30 p.m. UTC | #1
Hey Samuel,

On Wed, Dec 28, 2022 at 10:19:12AM -0600, Samuel Holland wrote:
> I want to convert the axp20x PMIC poweroff handler to use the sys-off
> API, so it can be used as a fallback for if the SBI poweroff handler
> is unavailable. But the SBI poweroff handler still uses pm_power_off, so
> done alone, this would cause the axp20x callback to be called first,
> before the SBI poweroff handler has a chance to run.
> 
> In order to prevent this change in behavior, the SBI poweroff handler
> needs to be converted to the sys-off API first, at a higher priority.
> 
> This series performs the conversion, after accounting for the fact that
> the SBI poweroff handler is registered quite early during boot.
> 
> The first patch is a dependency for both this series and the PSCI
> series[1], so I would like to get at least patch 1 merged soon.
> 
> [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
> 
> 
> Samuel Holland (3):
>   kernel/reboot: Use the static sys-off handler for any priority
>   riscv: sbi: Share the code for unsupported extension warnings
>   riscv: sbi: Switch to the sys-off handler API

Not what other stuff has reboot support, so I gave it a whirl on
PolarFire SoC & it seemed to work as expected:
Tested-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.
Conor Dooley Jan. 3, 2023, 10:54 a.m. UTC | #2
On Wed, Dec 28, 2022 at 06:30:11PM +0000, Conor Dooley wrote:
> Hey Samuel,
> 
> On Wed, Dec 28, 2022 at 10:19:12AM -0600, Samuel Holland wrote:
> > I want to convert the axp20x PMIC poweroff handler to use the sys-off
> > API, so it can be used as a fallback for if the SBI poweroff handler
> > is unavailable. But the SBI poweroff handler still uses pm_power_off, so
> > done alone, this would cause the axp20x callback to be called first,
> > before the SBI poweroff handler has a chance to run.
> > 
> > In order to prevent this change in behavior, the SBI poweroff handler
> > needs to be converted to the sys-off API first, at a higher priority.
> > 
> > This series performs the conversion, after accounting for the fact that
> > the SBI poweroff handler is registered quite early during boot.
> > 
> > The first patch is a dependency for both this series and the PSCI
> > series[1], so I would like to get at least patch 1 merged soon.
> > 
> > [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
> > 
> > 
> > Samuel Holland (3):
> >   kernel/reboot: Use the static sys-off handler for any priority
> >   riscv: sbi: Share the code for unsupported extension warnings
> >   riscv: sbi: Switch to the sys-off handler API
> 
> Not what other stuff has reboot support, so I gave it a whirl on

I happened to see this today and could barely understand what I wrote.
s/Not what/Not sure what"

> PolarFire SoC & it seemed to work as expected:
> Tested-by: Conor Dooley <conor.dooley@microchip.com>
> 
> Thanks,
> Conor.
Palmer Dabbelt May 11, 2023, 8:53 p.m. UTC | #3
On Wed, 28 Dec 2022 08:19:12 PST (-0800), samuel@sholland.org wrote:
> I want to convert the axp20x PMIC poweroff handler to use the sys-off
> API, so it can be used as a fallback for if the SBI poweroff handler
> is unavailable. But the SBI poweroff handler still uses pm_power_off, so
> done alone, this would cause the axp20x callback to be called first,
> before the SBI poweroff handler has a chance to run.
>
> In order to prevent this change in behavior, the SBI poweroff handler
> needs to be converted to the sys-off API first, at a higher priority.
>
> This series performs the conversion, after accounting for the fact that
> the SBI poweroff handler is registered quite early during boot.
>
> The first patch is a dependency for both this series and the PSCI
> series[1], so I would like to get at least patch 1 merged soon.
>
> [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
>
>
> Samuel Holland (3):
>   kernel/reboot: Use the static sys-off handler for any priority
>   riscv: sbi: Share the code for unsupported extension warnings
>   riscv: sbi: Switch to the sys-off handler API
>
>  arch/riscv/include/asm/sbi.h |  1 -
>  arch/riscv/kernel/sbi.c      | 63 +++++++++++++++++++++---------------
>  kernel/reboot.c              | 10 +++---
>  3 files changed, 41 insertions(+), 33 deletions(-)

Samuel: do you mind rebasing this and resending it with the reboot folks 
in the To list?  That way we might be able to get an Ack on the generic 
bits.

Thanks!
Palmer Dabbelt May 12, 2023, 9:50 p.m. UTC | #4
On Wed, 28 Dec 2022 10:30:11 PST (-0800), Conor Dooley wrote:
> Hey Samuel,
>
> On Wed, Dec 28, 2022 at 10:19:12AM -0600, Samuel Holland wrote:
>> I want to convert the axp20x PMIC poweroff handler to use the sys-off
>> API, so it can be used as a fallback for if the SBI poweroff handler
>> is unavailable. But the SBI poweroff handler still uses pm_power_off, so
>> done alone, this would cause the axp20x callback to be called first,
>> before the SBI poweroff handler has a chance to run.
>> 
>> In order to prevent this change in behavior, the SBI poweroff handler
>> needs to be converted to the sys-off API first, at a higher priority.
>> 
>> This series performs the conversion, after accounting for the fact that
>> the SBI poweroff handler is registered quite early during boot.
>> 
>> The first patch is a dependency for both this series and the PSCI
>> series[1], so I would like to get at least patch 1 merged soon.
>> 
>> [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
>> 
>> 
>> Samuel Holland (3):
>>   kernel/reboot: Use the static sys-off handler for any priority
>>   riscv: sbi: Share the code for unsupported extension warnings
>>   riscv: sbi: Switch to the sys-off handler API
>
> Not what other stuff has reboot support, so I gave it a whirl on
> PolarFire SoC & it seemed to work as expected:
> Tested-by: Conor Dooley <conor.dooley@microchip.com>

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>

in case the reboot folks want to take these.  I'm also happy to take the 
reboot change through the RISC-V tree with an Ack.  There's some 
discussion about this in the previous patches.

>
> Thanks,
> Conor.
Palmer Dabbelt May 12, 2023, 9:51 p.m. UTC | #5
On Fri, 12 May 2023 14:50:17 PDT (-0700), Palmer Dabbelt wrote:
> On Wed, 28 Dec 2022 10:30:11 PST (-0800), Conor Dooley wrote:
>> Hey Samuel,
>>
>> On Wed, Dec 28, 2022 at 10:19:12AM -0600, Samuel Holland wrote:
>>> I want to convert the axp20x PMIC poweroff handler to use the sys-off
>>> API, so it can be used as a fallback for if the SBI poweroff handler
>>> is unavailable. But the SBI poweroff handler still uses pm_power_off, so
>>> done alone, this would cause the axp20x callback to be called first,
>>> before the SBI poweroff handler has a chance to run.
>>>
>>> In order to prevent this change in behavior, the SBI poweroff handler
>>> needs to be converted to the sys-off API first, at a higher priority.
>>>
>>> This series performs the conversion, after accounting for the fact that
>>> the SBI poweroff handler is registered quite early during boot.
>>>
>>> The first patch is a dependency for both this series and the PSCI
>>> series[1], so I would like to get at least patch 1 merged soon.
>>>
>>> [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
>>>
>>>
>>> Samuel Holland (3):
>>>   kernel/reboot: Use the static sys-off handler for any priority
>>>   riscv: sbi: Share the code for unsupported extension warnings
>>>   riscv: sbi: Switch to the sys-off handler API
>>
>> Not what other stuff has reboot support, so I gave it a whirl on
>> PolarFire SoC & it seemed to work as expected:
>> Tested-by: Conor Dooley <conor.dooley@microchip.com>
>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
>
> in case the reboot folks want to take these.  I'm also happy to take the
> reboot change through the RISC-V tree with an Ack.  There's some
> discussion about this in the previous patches.

sorry, this is the old version -- I just got lost...

>
>>
>> Thanks,
>> Conor.