All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: David Jander <david@protonic.nl>
Cc: linux-spi@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Oleksij Rempel <o.rempel@pengutronix.de>
Subject: Re: [RFC] [PATCH 3/3] drivers: spi: spi.c: Don't use the message queue if possible in spi_sync
Date: Mon, 13 Jun 2022 12:56:48 +0100	[thread overview]
Message-ID: <YqcmANJXrsLXI6LB@sirena.org.uk> (raw)
In-Reply-To: <20220613110550.772c5023@erd992>

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

On Mon, Jun 13, 2022 at 11:05:50AM +0200, David Jander wrote:

> Thinking out loud here, so correct me if I am wrong.
> Basically what is happening in that scenario, if we had several async
> messages queued up, is this:

>  1. __pump_messages() gets first message off queue, stores in cur_msg.
>  2. __pump_messages() calls ->transfer_one_message().
>  3. transfer_one_message() triggers an IRQ or other context *A*.
>  4. transfer_one_message() returns before message is finished.
>  5. work queue idles. If someone calls spi_async() now, it will not queue
>  work, since ctlr->busy is still true.
>  6. *A*: IRQ or other context calls spi_finalize_current_message()
>  7. spi_finalize_current_message() schedules new work.
>  8. Goto 1.

>  Total ctx switches message->message: 2 (at steps 3->6 and 7->8).

Yes, plus also any transition to the context that submitted the message
from completing the message.

> In this scenario, the io_mutex is taken at step 1 and released at step 9,
> inside the same function. The io_mutex is released either after
> transfer_one_message() returns, or after spi_finalize_current_message() is
> called, whatever comes _LAST_. I think I like this. Any potential problems
> I am missing?

I think that about covers it, I'm not seeing any issues right now.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-06-13 14:55 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
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 [this message]
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=YqcmANJXrsLXI6LB@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=david@protonic.nl \
    --cc=linux-spi@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.