linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Jander <david@protonic.nl>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	linux-spi <linux-spi@vger.kernel.org>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v3 03/11] spi: Lock controller idling transition inside the io_mutex
Date: Wed, 29 Jun 2022 15:08:17 +0200	[thread overview]
Message-ID: <20220629150817.159ee022@erd992> (raw)
In-Reply-To: <CAHp75VeHcdcRMYxsJ3At+YyFZEauDPp-+deXbsBpcqKdxaicfg@mail.gmail.com>

On Tue, 21 Jun 2022 15:36:23 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Jun 21, 2022 at 8:15 AM David Jander <david@protonic.nl> wrote:
> >
> > This way, the spi sync path does not need to deal with the idling
> > transition.  
> 
> ...
> 
> > -       mutex_lock(&ctlr->io_mutex);
> >         ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
> >         mutex_unlock(&ctlr->io_mutex);
> >
> >         /* Prod the scheduler in case transfer_one() was busy waiting */  
> 
> >         if (!ret)
> >                 cond_resched();  
> 
> In the similar way
> 
> 
> ret = ...
> if (ret)
>   goto out_unlock;
> 
> mutex_unlock();
> cond_resched();
> return;

Trying to add this change as an incremental patch to the whole series now that
it hit linux-next, I am not so sure about how to do this, since this code has
changed:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/spi/spi.c?id=dc3029056b02414c29b6627e3dd7b16624725ae9#n1729

I understand that the blank line at line 1730 should go after 1732, so that
the ret = ... and the if (!ret) kthread... are not separated by a blank line.

So far so good, but modifying the rest of the code into this "if (!ret)
goto..." idiom will mess that up, since the code in lines 1733 and 1734 is now
common to both paths, so the simplest way I see it is to move those two lines
in between the "ret = ..." and "if (!ret)...". Is that more desirable than not
having the "if (!ret) goto" idiom?

Code would look like this:

	ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
	ctlr->cur_msg = NULL;
	ctlr->fallback = false;
	if (!ret) {
		kthread_queue_work(ctlr->kworker, &ctlr->pump_messages);
		goto out_mutex;
	}

	mutex_unlock(&ctlr->io_mutex);

	/* Prod the scheduler in case transfer_one() was busy waiting */
	cond_resched();
	return;

out_unlock:
	spin_unlock_irqrestore(&ctlr->queue_lock, flags);
out_mutex:
	mutex_unlock(&ctlr->io_mutex);
}

Please advice: is this really more desirable to what it is now? Or can I
better leave it as is and only move the blank line?

> > +       return;
> > +
> > +out_unlock:
> > +       mutex_unlock(&ctlr->io_mutex);  
> 

Best regards,

-- 
David Jander

  reply	other threads:[~2022-06-29 13:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21  6:12 [PATCH v3 00/11] Optimize spi_sync path David Jander
2022-06-21  6:12 ` [PATCH v3 01/11] spi: Move ctlr->cur_msg_prepared to struct spi_message David Jander
2022-06-21  6:12 ` [PATCH v3 02/11] spi: Don't use the message queue if possible in spi_sync David Jander
2022-06-21  6:12 ` [PATCH v3 03/11] spi: Lock controller idling transition inside the io_mutex David Jander
2022-06-21 13:36   ` Andy Shevchenko
2022-06-29 13:08     ` David Jander [this message]
2022-06-21  6:12 ` [PATCH v3 04/11] spi: __spi_pump_messages: Consolidate spin_unlocks to goto target David Jander
2022-06-21  6:12 ` [PATCH v3 05/11] spi: Remove check for controller idling in spi sync path David Jander
2022-06-21  6:12 ` [PATCH v3 06/11] spi: Remove check for idling in __spi_pump_messages() David Jander
2022-06-21  6:12 ` [PATCH v3 07/11] spi: Remove the now unused ctlr->idling flag David Jander
2022-06-21  6:12 ` [PATCH v3 08/11] spi: Remove unneeded READ_ONCE for ctlr->busy flag David Jander
2022-06-21  6:12 ` [PATCH v3 09/11] spi: Set ctlr->cur_msg also in the sync transfer case David Jander
2022-06-21  6:12 ` [PATCH v3 10/11] spi: Ensure the io_mutex is held until spi_finalize_current_message() David Jander
2022-06-21 13:41   ` Andy Shevchenko
2022-06-21  6:12 ` [PATCH v3 11/11] spi: opportunistically skip ctlr->cur_msg_completion David Jander
2022-06-21 13:46   ` Andy Shevchenko
2022-06-21 17:21 ` [PATCH v3 00/11] Optimize spi_sync path Mark Brown
2022-06-24 20:31 ` Mark Brown
2022-06-28  6:32   ` David Jander
2022-06-28 10:31     ` Mark Brown
2022-06-28 10:31 ` Mark Brown
2022-07-15 14:13 ` Thomas Kopp
2022-07-18  6:02   ` David Jander

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=20220629150817.159ee022@erd992 \
    --to=david@protonic.nl \
    --cc=andrew@lunn.ch \
    --cc=andy.shevchenko@gmail.com \
    --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).