Re: [PATCH v3] PM / core: conditionally skip system pm in device/driver model

From: Florian Fainelli
Date: Mon Feb 26 2024 - 13:40:28 EST


On 2/26/24 02:28, Guan-Yu Lin wrote:
On Sat, Feb 24, 2024 at 2:20 AM Florian Fainelli <f.fainelli@xxxxxxxxx> wrote:

On 2/23/24 06:38, Guan-Yu Lin wrote:
In systems with a main processor and a co-processor, asynchronous
controller management can lead to conflicts. One example is the main
processor attempting to suspend a device while the co-processor is
actively using it. To address this, we introduce a new sysfs entry
called "conditional_skip". This entry allows the system to selectively
skip certain device power management state transitions. To use this
feature, set the value in "conditional_skip" to indicate the type of
state transition you want to avoid. Please review /Documentation/ABI/
testing/sysfs-devices-power for more detailed information.

This looks like a poor way of dealing with a lack of adequate resource
tracking from Linux on behalf of the co-processor(s) and I really do not
understand how someone is supposed to use that in a way that works.

Cannot you use a HW maintained spinlock between your host processor and
the co-processor such that they can each claim exclusive access to the
hardware and you can busy-wait until one or the other is done using the
device? How is your partitioning between host processor owned blocks and
co-processor(s) owned blocks? Is it static or is it dynamic?
--
Florian


This patch enables devices to selectively participate in system power
transitions. This is crucial when multiple processors, managed by
different operating system kernels, share the same controller. One
processor shouldn't enforce the same power transition procedures on
the controller – another processor might be using it at that moment.
While a spinlock is necessary for synchronizing controller access, we
still need to add the flexibility to dynamically customize power
transition behavior for each device. And that's what this patch is
trying to do.
In our use case, the host processor and co-processor are managed by
separate operating system kernels. This arrangement is static.

OK, so now the question is whether the peripheral is entirely visible to Linux, or is it entirely owned by the co-processor, or is there a combination of both and the usage of the said device driver is dynamic between Linux and your co-processor?

A sysfs entry does not seem like the appropriate way to described which states need to be skipped and which ones can remain under control of Linux, you would have to use your firmware's description for that (ACPI, Device Tree, etc.) such that you have a more comprehensive solution that can span a bigger scope.
--
Florian