From: Vignesh R <vigneshr-l0cyMroinI0@public.gmane.org>
To: "Heiko Stübner" <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
"Mark Brown" <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Kevin Hilman <khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
"linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] spi: don't lock the bus in __spi_pump_messages if it is already locked
Date: Fri, 18 Mar 2016 10:53:07 +0530 [thread overview]
Message-ID: <56EB90BB.3070802@ti.com> (raw)
In-Reply-To: <1848110.TJtF6nar8z@diego>
On 03/18/2016 04:48 AM, Heiko Stübner wrote:
> External users may use spi_bus_lock to get exclusive access. This will
> also grab the bus_lock_mutex and may therefore result in a deadlock if
> __spi_pump_messages also tries to get the mutex.
I suggest bus_locked flag passed to __spi_pump_messages() by
__spi_sync() be updated to take care of the fact that spi_bus_lock() may
have acquired the mutex, so that below changes in __spi_pump_messages()
are not needed.
>
> Fixes: 49023d2e4ead ("spi: core: Fix deadlock when sending messages")
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> drivers/spi/spi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index de2f2f9..62f962b 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1160,7 +1160,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
> }
> }
>
> - if (!bus_locked)
> + if (!bus_locked && !master->bus_lock_flag)
> mutex_lock(&master->bus_lock_mutex);
>
> trace_spi_message_start(master->cur_msg);
> @@ -1192,7 +1192,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
> }
>
> out:
> - if (!bus_locked)
> + if (!bus_locked && !master->bus_lock_flag)
> mutex_unlock(&master->bus_lock_mutex);
>
> /* Prod the scheduler in case transfer_one() was busy waiting */
>
--
Regards
Vignesh
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2016-03-18 5:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 23:18 [PATCH] spi: don't lock the bus in __spi_pump_messages if it is already locked Heiko Stübner
2016-03-18 5:23 ` Vignesh R [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56EB90BB.3070802@ti.com \
--to=vigneshr-l0cymroini0@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).