Linux Input/HID development
 help / color / mirror / Atom feed
From: Jakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jakob Unterwurzacher <jakobunt@gmail.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Tony Lindgren <tony@atomide.com>
Cc: Joseph Chen <chenjh@rock-chips.com>, Lee Jones <lee@kernel.org>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-input@vger.kernel.org, mfd@lists.linux.dev,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 1/4] Input: rk805-pwrkey - enable the wakeup interrupt during system suspend
Date: Fri, 20 Nov 2026 14:42:57 +0100	[thread overview]
Message-ID: <7bec766f-14b1-4eac-96c7-d7f1cf38021d@cherry.de> (raw)
In-Reply-To: <avUGEQhSKlko0Fm9@google.com>

Hi,

On 11/12/26 01:25, Dmitry Torokhov wrote:
> [You don't often get email from dmitry.torokhov@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Hi Jakob,
> 
> On Thu, Oct 29, 2026 at 11:06:23AM +0100, Jakob Unterwurzacher wrote:
>> From: Jakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
>>
>> The driver marks the device as wakeup capable, but never enables the
>> power key interrupt as a wakeup interrupt. As a consequence, the PMIC
>> interrupt line is masked during system suspend and the power key cannot
>> wake up the system, e.g. from suspend-to-ram on RK3588 with an RK806.
>>
>> Enable the interrupt as wakeup interrupt in the suspend callback if the
>> device may wake up the system, and disable it again on resume.
>>
>> This is done in the regular suspend phase on purpose, rather than with
>> dev_pm_set_wake_irq(), which arms the wakeup in the noirq phase: there,
>> enabling it updates the PMIC's interrupt registers through regmap-irq,
>> which fails when the PMIC is connected via SPI:
>>
>>    spi_master spi2: Failed to power device: -13
>>    rk8xx-spi spi2.0: Failed to sync masks in 7a
> 
> Sounds like this needs to be solved in PM core rather than hacked around
> in individual driver? Let's CC Tony and Rafael.

How about something like this, copy-pasted below? If no immediate 
objections I'll post it as a proper patch.

With this, rk805-pwrkey can use dev_pm_set_wake_irq with no issues 
(tested on RK3588-Tiger).

Thanks,
Jakob

> commit ad2298eb4cf079b087a590231f09e7cb3ed594d1
> Author: Jakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
> Date:   Thu Nov 19 12:03:24 2026 +0100
> 
>     spi: rockchip: keep the controller active during system sleep transitions
>     
>     The controller is suspended in the noirq phase of system suspend, after
>     its child devices. Runtime PM is disabled from the late suspend phase
>     until the early resume phase, so a transfer in that window can only work
>     if the controller is still runtime-active. If it has already been
>     autosuspended, pm_runtime_get_sync() fails with -EACCES.
>     
>     Child devices do need the bus in that window. With an RK806 PMIC on SPI,
>     arming its power key as a wakeup interrupt in the noirq phase (e.g. with
>     dev_pm_set_wake_irq()) writes the PMIC's interrupt mask registers, and a
>     wakeup by the power key is handled as soon as interrupts are re-enabled
>     at the end of the noirq resume phase. On RK3588-Tiger we get this:
>     
>       spi_master spi2: Failed to power device: -13
>       spi_master spi2: noqueue transfer failed
>       rk8xx-spi spi2.0: Failed to read IRQ status: -13
>     
>     Take a runtime PM reference in the regular suspend phase and drop it on
>     resume. This keeps the controller usable until its noirq suspend
>     callback, and since it was active then, pm_runtime_force_resume()
>     restores it in the noirq resume phase, before interrupts of child
>     devices are handled again.
>     
>     Signed-off-by: Jakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
> 
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 1a81fd94b4396..504068b15c184 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -938,7 +938,27 @@ static void rockchip_spi_remove(struct platform_device *pdev)
>                 dma_release_channel(ctlr->dma_rx);
>  }
>  
> +/*
> + * Child devices (e.g. an RK806 PMIC with its interrupt controller and wakeup
> + * interrupts) can still need the bus during the late and noirq phases of
> + * system suspend and resume, while runtime PM is disabled. Keep the controller
> + * runtime-active from the regular suspend phase on, so that such transfers
> + * work and pm_runtime_force_resume() restores the controller in the noirq
> + * resume phase, before child device interrupts are handled again.
> + */
>  static int rockchip_spi_suspend(struct device *dev)
> +{
> +       return pm_runtime_resume_and_get(dev);
> +}
> +
> +static int rockchip_spi_resume(struct device *dev)
> +{
> +       pm_runtime_put_autosuspend(dev);
> +
> +       return 0;
> +}
> +
> +static int rockchip_spi_suspend_noirq(struct device *dev)
>  {
>         int ret;
>         struct spi_controller *ctlr = dev_get_drvdata(dev);
> @@ -958,7 +978,7 @@ static int rockchip_spi_suspend(struct device *dev)
>         return 0;
>  }
>  
> -static int rockchip_spi_resume(struct device *dev)
> +static int rockchip_spi_resume_noirq(struct device *dev)
>  {
>         int ret;
>         struct spi_controller *ctlr = dev_get_drvdata(dev);
> @@ -1001,7 +1021,9 @@ static int rockchip_spi_runtime_resume(struct device *dev)
>  }
>  
>  static const struct dev_pm_ops rockchip_spi_pm = {
> -       NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
> +       SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
> +       NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend_noirq,
> +                                 rockchip_spi_resume_noirq)
>         RUNTIME_PM_OPS(rockchip_spi_runtime_suspend,
>                        rockchip_spi_runtime_resume, NULL)
>  };


  reply	other threads:[~2026-11-20 13:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 10:06 [PATCH 0/4] Suspend-to-RAM fixes for RK3588 + SPI-connected RK806 PMIC, enable PMIC sleep on RK3588 Tiger Jakob Unterwurzacher
2026-10-29 10:06 ` [PATCH 1/4] Input: rk805-pwrkey - enable the wakeup interrupt during system suspend Jakob Unterwurzacher
2026-11-12  0:25   ` Dmitry Torokhov
2026-11-20 13:42     ` Jakob Unterwurzacher [this message]
2026-10-29 10:06 ` [PATCH 2/4] mfd: rk8xx-core: keep the PMIC interrupt disabled " Jakob Unterwurzacher
2026-10-29 10:21   ` sashiko-bot
2026-11-19 19:27   ` Lee Jones
2026-10-29 10:06 ` [PATCH 3/4] mfd: rk8xx-spi: add system sleep PM ops Jakob Unterwurzacher
2026-10-29 10:06 ` [PATCH 4/4] arm64: dts: rockchip: put the PMIC into sleep mode in suspend on RK3588 Tiger Jakob Unterwurzacher
2026-10-29 19:31 ` [PATCH 0/4] Suspend-to-RAM fixes for RK3588 + SPI-connected RK806 PMIC, enable PMIC sleep " Quentin Schulz
2026-11-12  0:03   ` Sebastian Reichel
2026-11-19  9:12   ` Jakob Unterwurzacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bec766f-14b1-4eac-96c7-d7f1cf38021d@cherry.de \
    --to=jakob.unterwurzacher@cherry.de \
    --cc=chenjh@rock-chips.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=heiko@sntech.de \
    --cc=jakobunt@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mfd@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox