Message ID | 20250211-rtkit-more-logging-v1-1-93334e9c1c77@rosenzweig.io (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | soc: apple: rtkit: Check & log more failures | expand |
On Tue, Feb 11, 2025 at 1:00 PM Alyssa Rosenzweig <alyssa@rosenzweig.io> wrote: > > From: Asahi Lina <lina@asahilina.net> > > Check and log the following failures: > > * regular messages > * management messages > * failed buffer requests > > This helps debugging. > > Signed-off-by: Asahi Lina <lina@asahilina.net> > Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.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@rosenzweig.io> > > Looks good to me. Reviewed-by: Neal Gompa <neal@gompa.dev>
On Tue, 11 Feb 2025 12:59:44 -0500, Alyssa Rosenzweig wrote: > Check and log the following failures: > > * regular messages > * management messages > * failed buffer requests > > This helps debugging. > > [...] Applied, thanks! [1/1] soc: apple: rtkit: Check & log more failures commit: ca0272d8638a4c50ecc2c63719f81e022d3450f1 Best regards,
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); }