[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YkcD25gTJ07h7XDK@kuha.fi.intel.com>
Date: Fri, 1 Apr 2022 16:53:31 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: tanveer1.alam@...el.com
Cc: gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org, abhijeet.rao@...el.com
Subject: Re: [PATCH] usb: typec: mux: intel_pmc_mux: Add retry logic to a PMC
command
On Mon, Mar 28, 2022 at 04:21:37PM +0530, tanveer1.alam@...el.com wrote:
> From: Tanveer Alam <tanveer1.alam@...el.com>
>
> There are few scenerio when PMC reports 'busy condition' and command
> fail.
>
> If PMC receives a high priority command while servicing a low priority
> command then it discards the low priority command and start servicing
> the high priority command. The lower priority command fail and driver
> returns error. If the same command resend to the PMC then PMC latches
> the command and service it accordingly.
>
> Thus adds the retry logic for the PMC command.
>
> Signed-off-by: Tanveer Alam <tanveer1.alam@...el.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
> drivers/usb/typec/mux/intel_pmc_mux.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index 2cdd22130834..da6b381ddf00 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -173,7 +173,7 @@ static int hsl_orientation(struct pmc_usb_port *port)
> return port->orientation - 1;
> }
>
> -static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
> +static int pmc_usb_send_command(struct intel_scu_ipc_dev *ipc, u8 *msg, u32 len)
> {
> u8 response[4];
> u8 status_res;
> @@ -184,7 +184,7 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
> * Status can be checked from the response message if the
> * function intel_scu_ipc_dev_command succeeds.
> */
> - ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg,
> + ret = intel_scu_ipc_dev_command(ipc, PMC_USBC_CMD, 0, msg,
> len, response, sizeof(response));
>
> if (ret)
> @@ -203,6 +203,23 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
> return 0;
> }
>
> +static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
> +{
> + int retry_count = 3;
> + int ret;
> +
> + /*
> + * If PMC is busy then retry the command once again
> + */
> + while (retry_count--) {
> + ret = pmc_usb_send_command(port->pmc->ipc, msg, len);
> + if (ret != -EBUSY)
> + break;
> + }
> +
> + return ret;
> +}
> +
> static int
> pmc_usb_mux_dp_hpd(struct pmc_usb_port *port, struct typec_displayport_data *dp)
> {
thanks,
--
heikki
Powered by blists - more mailing lists