Re: [PATCH 3/3] usb: typec: ucsi_glink: drop special handling for CCI_BUSY

From: Heikki Krogerus
Date: Tue Apr 09 2024 - 02:30:18 EST


On Mon, Apr 08, 2024 at 04:04:17AM +0300, Dmitry Baryshkov wrote:
> Newer Qualcomm platforms (sm8450+) successfully handle busy state and
> send the Command Completion after sending the Busy state. Older devices
> have firmware bug and can not continue after sending the CCI_BUSY state,
> but the command that leads to CCI_BUSY is already forbidden by the
> NO_PARTNER_PDOS quirk.
>
> Follow other UCSI glue drivers and drop special handling for CCI_BUSY
> event. Let the UCSI core properly handle this state.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>

One minor nitpick below, but feel free to ignore that one.

Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

> ---
> drivers/usb/typec/ucsi/ucsi_glink.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index 9ffea20020e7..b91d2d15d7d9 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -176,7 +176,8 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset,
> left = wait_for_completion_timeout(&ucsi->sync_ack, 5 * HZ);
> if (!left) {
> dev_err(ucsi->dev, "timeout waiting for UCSI sync write response\n");
> - ret = -ETIMEDOUT;
> + /* return 0 here and let core UCSI code handle the CCI_BUSY */
> + ret = 0;
> } else if (ucsi->sync_val) {
> dev_err(ucsi->dev, "sync write returned: %d\n", ucsi->sync_val);
> }
> @@ -243,10 +244,7 @@ static void pmic_glink_ucsi_notify(struct work_struct *work)
> ucsi_connector_change(ucsi->ucsi, con_num);
> }
>
> - if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) {
> - ucsi->sync_val = -EBUSY;
> - complete(&ucsi->sync_ack);
> - } else if (ucsi->sync_pending &&
> + if (ucsi->sync_pending &&
> (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) {

Looks like you forgot to fix the alignment.

> complete(&ucsi->sync_ack);
> }
>
> --
> 2.39.2

--
heikki