[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zf1YGe9M4ZjDTYMS@kuha.fi.intel.com>
Date: Fri, 22 Mar 2024 12:06:17 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: "Christian A. Ehrhardt" <lk@...e.de>
Cc: linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Prashant Malani <pmalani@...omium.org>,
Jameson Thies <jthies@...gle.com>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
Neil Armstrong <neil.armstrong@...aro.org>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
Samuel Čavoj <samuel@...oj.net>,
linux-usb@...r.kernel.org, Kenneth Crudup <kenny@...ix.com>
Subject: Re: [PATCH 5/5] usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE
before reset
On Wed, Mar 20, 2024 at 08:39:26AM +0100, Christian A. Ehrhardt wrote:
> Check the UCSI_CCI_RESET_COMPLETE complete flag before starting
> another reset. Use a UCSI_SET_NOTIFICATION_ENABLE command to clear
> the flag if it is set.
>
> Signed-off-by: Christian A. Ehrhardt <lk@...e.de>
Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 36 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 63f340dbd867..85e507df7fa8 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1264,13 +1264,47 @@ static int ucsi_reset_connector(struct ucsi_connector *con, bool hard)
>
> static int ucsi_reset_ppm(struct ucsi *ucsi)
> {
> - u64 command = UCSI_PPM_RESET;
> + u64 command;
> unsigned long tmo;
> u32 cci;
> int ret;
>
> mutex_lock(&ucsi->ppm_lock);
>
> + ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
> + if (ret < 0)
> + goto out;
> +
> + /*
> + * If UCSI_CCI_RESET_COMPLETE is already set we must clear
> + * the flag before we start another reset. Send a
> + * UCSI_SET_NOTIFICATION_ENABLE command to achieve this.
> + * Ignore a timeout and try the reset anyway if this fails.
> + */
> + if (cci & UCSI_CCI_RESET_COMPLETE) {
> + command = UCSI_SET_NOTIFICATION_ENABLE;
> + ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
> + sizeof(command));
> + if (ret < 0)
> + goto out;
> +
> + tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
> + do {
> + ret = ucsi->ops->read(ucsi, UCSI_CCI,
> + &cci, sizeof(cci));
> + if (ret < 0)
> + goto out;
> + if (cci & UCSI_CCI_COMMAND_COMPLETE)
> + break;
> + if (time_is_before_jiffies(tmo))
> + break;
> + msleep(20);
> + } while (1);
> +
> + WARN_ON(cci & UCSI_CCI_RESET_COMPLETE);
> + }
> +
> + command = UCSI_PPM_RESET;
> ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
> sizeof(command));
> if (ret < 0)
> --
> 2.40.1
--
heikki
Powered by blists - more mailing lists