linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <alexandru.tachici@analog.com>
To: <linux-kernel@vger.kernel.org>, <linux-spi@vger.kernel.org>,
	<broonie@kernel.org>
Cc: <nuno.sa@analog.com>, <bootc@bootc.net>, <swarren@wwwdotorg.org>,
	<bcm-kernel-feedback-list@broadcom.com>, <rjui@broadcom.com>,
	<f.fainelli@gmail.com>, <nsaenz@kernel.org>,
	Alexandru Tachici <alexandru.tachici@analog.com>
Subject: [PATCH 0/1] spi: spi-bcm2835: Fix deadlock
Date: Sat, 17 Jul 2021 00:02:44 +0300	[thread overview]
Message-ID: <20210716210245.13240-1-alexandru.tachici@analog.com> (raw)

From: Alexandru Tachici <alexandru.tachici@analog.com>

The bcm2835_spi_transfer_one function can create a deadlock
if it is called while another thread already has the
CCF lock.

This behavior was observed at boot and when trying to
print the clk_summary debugfs. I had registered
at the time multiple clocks of AD9545 through the CCF.
Tested this using an RPi 4 connected to AD9545 through SPI.

See upstream attempt here:
https://lore.kernel.org/lkml/20210614070718.78041-3-alexandru.tachici@analog.com/T/

This can happen to any other clock that needs to read
the rate/phase from hardware using the SPI. Because
when issuing a clk_get_rate/phase, the requesting thread
already holds the CCF lock. If another thread, in this case
the one that does the spi transfer tries the same, it will cause
a deadlock. This happens by chance because not always
every spi request gets deferred to a khthread.

Alexandru Tachici (1):
  spi: spi-bcm2835: Fix deadlock

 drivers/spi/spi-bcm2835.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--
2.25.1

             reply	other threads:[~2021-07-16 20:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16 21:02 alexandru.tachici [this message]
2021-07-16 21:02 ` [PATCH 1/1] spi: spi-bcm2835: Fix deadlock alexandru.tachici
2021-07-19 23:50   ` Florian Fainelli
2021-07-20 12:33 ` [PATCH 0/1] " Mark Brown
2021-07-20 18:48 ` Mark Brown
2021-07-21  6:47   ` Sa, Nuno
2021-07-21 12:32     ` Mark Brown

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=20210716210245.13240-1-alexandru.tachici@analog.com \
    --to=alexandru.tachici@analog.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bootc@bootc.net \
    --cc=broonie@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=nsaenz@kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=rjui@broadcom.com \
    --cc=swarren@wwwdotorg.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).