[PATCH] soc: apple: rtkit: Add function to poweroff

Sven Peter posted 1 patch 3 weeks ago
There is a newer version of this series
drivers/soc/apple/rtkit.c       | 17 +++++++++++++++++
include/linux/soc/apple/rtkit.h |  7 +++++++
2 files changed, 24 insertions(+)
[PATCH] soc: apple: rtkit: Add function to poweroff
Posted by Sven Peter 3 weeks ago
Add a function to put a co-processor into the lowest possible power
state from which recovery usually isn't possible without a full SoC
reset. This is required for the USB4/Thunderbolt co-processors which
can be restarted since the entire USB4 root complex can be completely
reset independently of the rest of the SoC.

Signed-off-by: Sven Peter <sven@kernel.org>
---
 drivers/soc/apple/rtkit.c       | 17 +++++++++++++++++
 include/linux/soc/apple/rtkit.h |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c
index b8d4da147d23f7e99e76eea314e4d976cddbd1c6..381faaf74d5982163d2c44d1e2c6e0ddad07bd73 100644
--- a/drivers/soc/apple/rtkit.c
+++ b/drivers/soc/apple/rtkit.c
@@ -851,6 +851,23 @@ int apple_rtkit_shutdown(struct apple_rtkit *rtk)
 }
 EXPORT_SYMBOL_GPL(apple_rtkit_shutdown);
 
+int apple_rtkit_poweroff(struct apple_rtkit *rtk)
+{
+	int ret;
+
+	ret = apple_rtkit_set_ap_power_state(rtk,
+					     APPLE_RTKIT_PWR_STATE_OFF);
+	if (ret)
+		return ret;
+
+	ret = apple_rtkit_set_iop_power_state(rtk, APPLE_RTKIT_PWR_STATE_OFF);
+	if (ret)
+		return ret;
+
+	return apple_rtkit_reinit(rtk);
+}
+EXPORT_SYMBOL_GPL(apple_rtkit_poweroff);
+
 int apple_rtkit_idle(struct apple_rtkit *rtk)
 {
 	int ret;
diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h
index 736f530180179bd144cf85eb0f0bd93844d7188a..bda3c528b51553c13f7fe5685ab60f7fc675361b 100644
--- a/include/linux/soc/apple/rtkit.h
+++ b/include/linux/soc/apple/rtkit.h
@@ -125,6 +125,13 @@ int apple_rtkit_wake(struct apple_rtkit *rtk);
  */
 int apple_rtkit_shutdown(struct apple_rtkit *rtk);
 
+/*
+ * Put the co-processor into the lowest power state. Note that it usually
+ * is not possible to recover from this state without a full SoC reset.
+ */
+
+int apple_rtkit_poweroff(struct apple_rtkit *rtk);
+
 /*
  * Put the co-processor into idle mode
  */

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20260117-apple-rtkit-poweroff-bc3bb1f4a105

Best regards,
-- 
Sven Peter <sven@kernel.org>
Re: [PATCH] soc: apple: rtkit: Add function to poweroff
Posted by Janne Grunau 3 weeks ago
On Sat, Jan 17, 2026 at 06:24:44PM +0100, Sven Peter wrote:
> Add a function to put a co-processor into the lowest possible power
> state from which recovery usually isn't possible without a full SoC
> reset. This is required for the USB4/Thunderbolt co-processors which
> can be restarted since the entire USB4 root complex can be completely
> reset independently of the rest of the SoC.
> 
> Signed-off-by: Sven Peter <sven@kernel.org>
> ---
>  drivers/soc/apple/rtkit.c       | 17 +++++++++++++++++
>  include/linux/soc/apple/rtkit.h |  7 +++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c
> index b8d4da147d23f7e99e76eea314e4d976cddbd1c6..381faaf74d5982163d2c44d1e2c6e0ddad07bd73 100644
> --- a/drivers/soc/apple/rtkit.c
> +++ b/drivers/soc/apple/rtkit.c
> @@ -851,6 +851,23 @@ int apple_rtkit_shutdown(struct apple_rtkit *rtk)
>  }
>  EXPORT_SYMBOL_GPL(apple_rtkit_shutdown);
>  
> +int apple_rtkit_poweroff(struct apple_rtkit *rtk)
> +{
> +	int ret;
> +
> +	ret = apple_rtkit_set_ap_power_state(rtk,
> +					     APPLE_RTKIT_PWR_STATE_OFF);
> +	if (ret)
> +		return ret;
> +
> +	ret = apple_rtkit_set_iop_power_state(rtk, APPLE_RTKIT_PWR_STATE_OFF);

inconsistent line wrapping. It's wrapped for AP power state which is 1
character shorter. I would wrap neither it only moves the statement 4
places to the left.

> +	if (ret)
> +		return ret;
> +
> +	return apple_rtkit_reinit(rtk);
> +}
> +EXPORT_SYMBOL_GPL(apple_rtkit_poweroff);
> +
>  int apple_rtkit_idle(struct apple_rtkit *rtk)
>  {
>  	int ret;
> diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h
> index 736f530180179bd144cf85eb0f0bd93844d7188a..bda3c528b51553c13f7fe5685ab60f7fc675361b 100644
> --- a/include/linux/soc/apple/rtkit.h
> +++ b/include/linux/soc/apple/rtkit.h
> @@ -125,6 +125,13 @@ int apple_rtkit_wake(struct apple_rtkit *rtk);
>   */
>  int apple_rtkit_shutdown(struct apple_rtkit *rtk);
>  
> +/*
> + * Put the co-processor into the lowest power state. Note that it usually
> + * is not possible to recover from this state without a full SoC reset.
> + */
> +
> +int apple_rtkit_poweroff(struct apple_rtkit *rtk);
> +
>  /*
>   * Put the co-processor into idle mode
>   */
> 

Feel free to fix without sending a v2

Reviewed-by: Janne Grunau <j@jannau.net>

Janne
Re: [PATCH] soc: apple: rtkit: Add function to poweroff
Posted by Sven Peter 3 weeks ago
Hi,

On 1/17/26 18:38, Janne Grunau wrote:
> On Sat, Jan 17, 2026 at 06:24:44PM +0100, Sven Peter wrote:
>> Add a function to put a co-processor into the lowest possible power
>> state from which recovery usually isn't possible without a full SoC
>> reset. This is required for the USB4/Thunderbolt co-processors which
>> can be restarted since the entire USB4 root complex can be completely
>> reset independently of the rest of the SoC.
>>
>> Signed-off-by: Sven Peter <sven@kernel.org>
>> ---
>>   drivers/soc/apple/rtkit.c       | 17 +++++++++++++++++
>>   include/linux/soc/apple/rtkit.h |  7 +++++++
>>   2 files changed, 24 insertions(+)
>>
>> diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c
>> index b8d4da147d23f7e99e76eea314e4d976cddbd1c6..381faaf74d5982163d2c44d1e2c6e0ddad07bd73 100644
>> --- a/drivers/soc/apple/rtkit.c
>> +++ b/drivers/soc/apple/rtkit.c
>> @@ -851,6 +851,23 @@ int apple_rtkit_shutdown(struct apple_rtkit *rtk)
>>   }
>>   EXPORT_SYMBOL_GPL(apple_rtkit_shutdown);
>>   
>> +int apple_rtkit_poweroff(struct apple_rtkit *rtk)
>> +{
>> +	int ret;
>> +
>> +	ret = apple_rtkit_set_ap_power_state(rtk,
>> +					     APPLE_RTKIT_PWR_STATE_OFF);
>> +	if (ret)
>> +		return ret;
>> +
>> +	ret = apple_rtkit_set_iop_power_state(rtk, APPLE_RTKIT_PWR_STATE_OFF);
> inconsistent line wrapping. It's wrapped for AP power state which is 1
> character shorter. I would wrap neither it only moves the statement 4
> places to the left.

Good catch, will fix it.
>
>> +	if (ret)
>> +		return ret;
>> +
>> +	return apple_rtkit_reinit(rtk);
>> +}
>> +EXPORT_SYMBOL_GPL(apple_rtkit_poweroff);
>> +
>>   int apple_rtkit_idle(struct apple_rtkit *rtk)
>>   {
>>   	int ret;
>> diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h
>> index 736f530180179bd144cf85eb0f0bd93844d7188a..bda3c528b51553c13f7fe5685ab60f7fc675361b 100644
>> --- a/include/linux/soc/apple/rtkit.h
>> +++ b/include/linux/soc/apple/rtkit.h
>> @@ -125,6 +125,13 @@ int apple_rtkit_wake(struct apple_rtkit *rtk);
>>    */
>>   int apple_rtkit_shutdown(struct apple_rtkit *rtk);
>>   
>> +/*
>> + * Put the co-processor into the lowest power state. Note that it usually
>> + * is not possible to recover from this state without a full SoC reset.
>> + */
>> +
>> +int apple_rtkit_poweroff(struct apple_rtkit *rtk);
>> +
>>   /*
>>    * Put the co-processor into idle mode
>>    */
>>
> Feel free to fix without sending a v2
>
> Reviewed-by: Janne Grunau <j@jannau.net>

Thanks! b4 makes sending that v2 very easy luckily :)


Thanks,

Sven