[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_ds09xFjwedjTam@kuha.fi.intel.com>
Date: Thu, 10 Apr 2025 10:01:39 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Andrei Kuchynski <akuchynski@...omium.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jameson Thies <jthies@...gle.com>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
Benson Leung <bleung@...omium.org>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>,
Pooja Katiyar <pooja.katiyar@...el.com>,
Madhu M <madhu.m@...el.com>, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 1/2] usb: typec: ucsi: displayport: Fix deadlock
Hi Andrei,
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1922,6 +1922,42 @@ void ucsi_set_drvdata(struct ucsi *ucsi, void *data)
> }
> EXPORT_SYMBOL_GPL(ucsi_set_drvdata);
>
> +/**
> + * ucsi_con_mutex_lock - Acquire the connector mutex
> + * @con: The connector interface to lock
> + *
> + * Returns true on success, false if the connector is disconnected
> + */
> +bool ucsi_con_mutex_lock(struct ucsi_connector *con)
> +{
> + bool mutex_locked = false;
> + bool connected = true;
> +
> + while (connected && !mutex_locked) {
> + mutex_locked = mutex_trylock(&con->lock) != 0;
> + connected = UCSI_CONSTAT(con, CONNECTED);
> + if (connected && !mutex_locked)
> + msleep(20);
> + }
> +
> + connected = connected && con->partner;
> + if (!connected && mutex_locked)
> + mutex_unlock(&con->lock);
> +
> + return connected;
> +}
> +EXPORT_SYMBOL_GPL(ucsi_con_mutex_lock);
> +
> +/**
> + * ucsi_con_mutex_unlock - Release the connector mutex
> + * @con: The connector interface to unlock
> + */
> +void ucsi_con_mutex_unlock(struct ucsi_connector *con)
> +{
> + mutex_unlock(&con->lock);
> +}
> +EXPORT_SYMBOL_GPL(ucsi_con_mutex_unlock);
No need to export these.
thanks,
--
heikki
Powered by blists - more mailing lists