From: David Jander <david@protonic.nl>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [RFC] [PATCH 3/3] drivers: spi: spi.c: Don't use the message queue if possible in spi_sync
Date: Wed, 8 Jun 2022 09:54:09 +0200 [thread overview]
Message-ID: <20220608095409.2d8c46fb@erd992> (raw)
In-Reply-To: <Yp+ZX4XITW7bQtjn@sirena.org.uk>
On Tue, 7 Jun 2022 19:30:55 +0100
Mark Brown <broonie@kernel.org> wrote:
> On Wed, May 25, 2022 at 04:46:03PM +0200, David Jander wrote:
> > David Jander <david@protonic.nl> wrote:
>
> > > +static void __spi_transfer_message_noqueue(struct spi_controller *ctlr, struct spi_message *msg)
> > > +{
> > > + bool was_busy;
> > > + int ret;
> > > +
> > > + mutex_lock(&ctlr->io_mutex);
> > > +
> > > + /* If another context is idling the device then wait */
> > > + while (ctlr->idling) {
> > > + printk(KERN_INFO "spi sync message processing: controller is idling!\n");
> > > + usleep_range(10000, 11000);
> > > + }
>
> > This is dead ugly of course, and it needs to be removed. Not yet sure how,
> > hence the RFC. Maybe the idle -> not busy transition can be included inside
> > the io_mutex? That way this while will never be hit and can be removed...
>
> I'm not sure it's even quite right from a safety point of view - idling
> is protected by queue_lock but this now only takes io_mutex.
True. This is broken.
> Moving idling (and all the was_busy stuff) within the io_mutex would
> definitely resolve the issue, the async submission context is the only one
> that really needs the spinlock and it doesn't care about idling. I can't
> think what you could do with the io_mutex when idling so it seems to
> fit.
Ok, so we could agree on a way to fix this particular issue: put the idling
transition into the io_mutex. Thanks.
Looking forward to read comments on the rest of the code, and the general idea
of what I am trying to accomplish.
Best regards,
--
David Jander
next prev parent reply other threads:[~2022-06-08 8:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 14:29 [RFC] [PATCH 0/3] Optimize spi_sync path David Jander
2022-05-25 14:29 ` [RFC] [PATCH 1/3] drivers: spi: API: spi_finalize_current_message -> spi_finalize_message David Jander
2022-05-25 14:29 ` [RFC] [PATCH 2/3] drivers: spi: spi.c: Move ctlr->cur_msg_prepared to struct spi_message David Jander
2022-05-25 14:29 ` [RFC] [PATCH 3/3] drivers: spi: spi.c: Don't use the message queue if possible in spi_sync David Jander
2022-05-25 14:46 ` David Jander
2022-06-07 18:30 ` Mark Brown
2022-06-08 7:54 ` David Jander [this message]
2022-06-08 11:29 ` Mark Brown
2022-06-09 15:34 ` David Jander
2022-06-09 16:31 ` Mark Brown
2022-06-10 7:27 ` David Jander
2022-06-10 13:41 ` Mark Brown
2022-06-10 18:17 ` Mark Brown
2022-06-13 9:05 ` David Jander
2022-06-13 11:56 ` Mark Brown
2022-07-15 7:47 ` Thomas Kopp
2022-07-15 9:02 ` Thomas Kopp
2022-06-08 13:43 ` Andy Shevchenko
2022-06-08 14:55 ` David Jander
2022-05-30 12:06 ` [RFC] [PATCH 0/3] Optimize spi_sync path 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=20220608095409.2d8c46fb@erd992 \
--to=david@protonic.nl \
--cc=andrew@lunn.ch \
--cc=broonie@kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mkl@pengutronix.de \
/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).