lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEg-Je_XadeDiXBeXckZ=UQ2wYHtGppdM3nPmardyYx7SBgCrg@mail.gmail.com>
Date: Wed, 12 Feb 2025 10:47:21 -0500
From: Neal Gompa <neal@...pa.dev>
To: Alyssa Rosenzweig <alyssa@...enzweig.io>
Cc: Sven Peter <sven@...npeter.dev>, asahi@...ts.linux.dev, 
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org, 
	Asahi Lina <lina@...hilina.net>
Subject: Re: [PATCH] soc: apple: rtkit: Check & log more failures

On Tue, Feb 11, 2025 at 1:00 PM Alyssa Rosenzweig <alyssa@...enzweig.io> wrote:
>
> From: Asahi Lina <lina@...hilina.net>
>
> Check and log the following failures:
>
> * regular messages
> * management messages
> * failed buffer requests
>
> This helps debugging.
>
> Signed-off-by: Asahi Lina <lina@...hilina.net>
> Signed-off-by: Alyssa Rosenzweig <alyssa@...enzweig.io>
> ---
> Originally multiple commits by Asahi Lina, squashed here and
> checkpatch.pl warn fixed.
> ---
>  drivers/soc/apple/rtkit.c | 44 ++++++++++++++++++++++++++++++++++----------
>  1 file changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c
> index e6d940292c9fbdfc4cd42020e89aca2662c5cdce..f8077a1ec3a42265eb9565a0ea1ca6a4cf7e79dc 100644
> --- a/drivers/soc/apple/rtkit.c
> +++ b/drivers/soc/apple/rtkit.c
> @@ -97,12 +97,19 @@ bool apple_rtkit_is_crashed(struct apple_rtkit *rtk)
>  }
>  EXPORT_SYMBOL_GPL(apple_rtkit_is_crashed);
>
> -static void apple_rtkit_management_send(struct apple_rtkit *rtk, u8 type,
> +static int apple_rtkit_management_send(struct apple_rtkit *rtk, u8 type,
>                                         u64 msg)
>  {
> +       int ret;
> +
>         msg &= ~APPLE_RTKIT_MGMT_TYPE;
>         msg |= FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, type);
> -       apple_rtkit_send_message(rtk, APPLE_RTKIT_EP_MGMT, msg, NULL, false);
> +       ret = apple_rtkit_send_message(rtk, APPLE_RTKIT_EP_MGMT, msg, NULL, false);
> +
> +       if (ret)
> +               dev_err(rtk->dev, "RTKit: Failed to send management message: %d\n", ret);
> +
> +       return ret;
>  }
>
>  static void apple_rtkit_management_rx_hello(struct apple_rtkit *rtk, u64 msg)
> @@ -295,6 +302,9 @@ static int apple_rtkit_common_rx_get_buffer(struct apple_rtkit *rtk,
>         return 0;
>
>  error:
> +       dev_err(rtk->dev, "RTKit: failed buffer request for 0x%zx bytes (%d)\n",
> +               buffer->size, err);
> +
>         buffer->buffer = NULL;
>         buffer->iomem = NULL;
>         buffer->iova = 0;
> @@ -588,11 +598,18 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message,
>                 .msg1 = ep,
>         };
>
> -       if (rtk->crashed)
> +       if (rtk->crashed) {
> +               dev_warn(rtk->dev,
> +                        "RTKit: Device is crashed, cannot send message\n");
>                 return -EINVAL;
> +       }
> +
>         if (ep >= APPLE_RTKIT_APP_ENDPOINT_START &&
> -           !apple_rtkit_is_running(rtk))
> +           !apple_rtkit_is_running(rtk)) {
> +               dev_warn(rtk->dev,
> +                        "RTKit: Endpoint 0x%02x is not running, cannot send message\n", ep);
>                 return -EINVAL;
> +       }
>
>         /*
>          * The message will be sent with a MMIO write. We need the barrier
> @@ -742,8 +759,10 @@ static int apple_rtkit_set_ap_power_state(struct apple_rtkit *rtk,
>         reinit_completion(&rtk->ap_pwr_ack_completion);
>
>         msg = FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, state);
> -       apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_AP_PWR_STATE,
> -                                   msg);
> +       ret = apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_AP_PWR_STATE,
> +                                         msg);
> +       if (ret)
> +               return ret;
>
>         ret = apple_rtkit_wait_for_completion(&rtk->ap_pwr_ack_completion);
>         if (ret)
> @@ -763,8 +782,10 @@ static int apple_rtkit_set_iop_power_state(struct apple_rtkit *rtk,
>         reinit_completion(&rtk->iop_pwr_ack_completion);
>
>         msg = FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, state);
> -       apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE,
> -                                   msg);
> +       ret = apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE,
> +                                         msg);
> +       if (ret)
> +               return ret;
>
>         ret = apple_rtkit_wait_for_completion(&rtk->iop_pwr_ack_completion);
>         if (ret)
> @@ -865,6 +886,7 @@ EXPORT_SYMBOL_GPL(apple_rtkit_quiesce);
>  int apple_rtkit_wake(struct apple_rtkit *rtk)
>  {
>         u64 msg;
> +       int ret;
>
>         if (apple_rtkit_is_running(rtk))
>                 return -EINVAL;
> @@ -876,8 +898,10 @@ int apple_rtkit_wake(struct apple_rtkit *rtk)
>          * will wait for the completion anyway.
>          */
>         msg = FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, APPLE_RTKIT_PWR_STATE_ON);
> -       apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE,
> -                                   msg);
> +       ret = apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE,
> +                                         msg);
> +       if (ret)
> +               return ret;
>
>         return apple_rtkit_boot(rtk);
>  }
>
> ---
> base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
> change-id: 20250211-rtkit-more-logging-79cbbbe21eee
>
> Best regards,
> --
> Alyssa Rosenzweig <alyssa@...enzweig.io>
>
>

Looks good to me.

Reviewed-by: Neal Gompa <neal@...pa.dev>


-- 
真実はいつも一つ!/ Always, there's only one truth!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ