mbox series

[0/5] mmc: sdhci: Reduce maximum time under spinlock in sdhci_send_command()

Message ID 20200412090349.1607-1-adrian.hunter@intel.com (mailing list archive)
Headers show
Series mmc: sdhci: Reduce maximum time under spinlock in sdhci_send_command() | expand

Message

Adrian Hunter April 12, 2020, 9:03 a.m. UTC
Hi

Here are some patches to reduce maximum time under spinlock in
sdhci_send_command(), but also pave the way for an atomic request
function.

I haven't tried it, but with these patches, something like below
should work.



static int sdhci_atomic_request(struct mmc_host *mmc,
				struct mmc_request *mrq)
{
	struct sdhci_host *host = mmc_priv(mmc);
	struct mmc_command *cmd;
	unsigned long flags;
	int ret = 0;

	spin_lock_irqsave(&host->lock, flags);

	if (sdhci_present_error(host, mrq->cmd, true))
		goto out_finish;

	cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;

	if (sdhci_send_command(host, cmd))
		sdhci_led_activate(host);
	else
		ret = -EBUSY;

	spin_unlock_irqrestore(&host->lock, flags);

	return ret;

out_finish:
	sdhci_finish_mrq(host, mrq);
	spin_unlock_irqrestore(&host->lock, flags);
	return 0;
}



Adrian Hunter (5):
      mmc: sdhci: Add helpers for the auto-CMD23 flag
      mmc: sdhci: Stop exporting sdhci_send_command()
      mmc: sdhci: Remove unneeded forward declaration of sdhci_finish_data()
      mmc: sdhci: Tidy sdhci_request() a bit
      mmc: sdhci: Reduce maximum time under spinlock in sdhci_send_command()

 drivers/mmc/host/sdhci.c | 182 +++++++++++++++++++++++++++++++++++------------
 drivers/mmc/host/sdhci.h |   2 +-
 2 files changed, 139 insertions(+), 45 deletions(-)



Regards
Adrian

Comments

Baolin Wang April 13, 2020, 2:46 a.m. UTC | #1
Hi Adrian,

On Sun, Apr 12, 2020 at 5:04 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Hi
>
> Here are some patches to reduce maximum time under spinlock in
> sdhci_send_command(), but also pave the way for an atomic request
> function.
>
> I haven't tried it, but with these patches, something like below
> should work.
>
>
>
> static int sdhci_atomic_request(struct mmc_host *mmc,
>                                 struct mmc_request *mrq)
> {
>         struct sdhci_host *host = mmc_priv(mmc);
>         struct mmc_command *cmd;
>         unsigned long flags;
>         int ret = 0;
>
>         spin_lock_irqsave(&host->lock, flags);
>
>         if (sdhci_present_error(host, mrq->cmd, true))
>                 goto out_finish;
>
>         cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
>
>         if (sdhci_send_command(host, cmd))
>                 sdhci_led_activate(host);
>         else
>                 ret = -EBUSY;
>
>         spin_unlock_irqrestore(&host->lock, flags);
>
>         return ret;
>
> out_finish:
>         sdhci_finish_mrq(host, mrq);
>         spin_unlock_irqrestore(&host->lock, flags);
>         return 0;
> }

Yes, this looks good to me, and I've tested on my platform with
re-implementing sdhci_request_atomic() based on your patch set, it
worked well. Thanks for your help.
Tested-by: Baolin Wang <baolin.wang7@gmail.com>

> Adrian Hunter (5):
>       mmc: sdhci: Add helpers for the auto-CMD23 flag
>       mmc: sdhci: Stop exporting sdhci_send_command()
>       mmc: sdhci: Remove unneeded forward declaration of sdhci_finish_data()
>       mmc: sdhci: Tidy sdhci_request() a bit
>       mmc: sdhci: Reduce maximum time under spinlock in sdhci_send_command()
>
>  drivers/mmc/host/sdhci.c | 182 +++++++++++++++++++++++++++++++++++------------
>  drivers/mmc/host/sdhci.h |   2 +-
>  2 files changed, 139 insertions(+), 45 deletions(-)
>
>
>
> Regards
> Adrian
Ulf Hansson April 17, 2020, 11:29 a.m. UTC | #2
On Sun, 12 Apr 2020 at 11:04, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Hi
>
> Here are some patches to reduce maximum time under spinlock in
> sdhci_send_command(), but also pave the way for an atomic request
> function.
>
> I haven't tried it, but with these patches, something like below
> should work.
>
>
>
> static int sdhci_atomic_request(struct mmc_host *mmc,
>                                 struct mmc_request *mrq)
> {
>         struct sdhci_host *host = mmc_priv(mmc);
>         struct mmc_command *cmd;
>         unsigned long flags;
>         int ret = 0;
>
>         spin_lock_irqsave(&host->lock, flags);
>
>         if (sdhci_present_error(host, mrq->cmd, true))
>                 goto out_finish;
>
>         cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
>
>         if (sdhci_send_command(host, cmd))
>                 sdhci_led_activate(host);
>         else
>                 ret = -EBUSY;
>
>         spin_unlock_irqrestore(&host->lock, flags);
>
>         return ret;
>
> out_finish:
>         sdhci_finish_mrq(host, mrq);
>         spin_unlock_irqrestore(&host->lock, flags);
>         return 0;
> }
>
>
>
> Adrian Hunter (5):
>       mmc: sdhci: Add helpers for the auto-CMD23 flag
>       mmc: sdhci: Stop exporting sdhci_send_command()
>       mmc: sdhci: Remove unneeded forward declaration of sdhci_finish_data()
>       mmc: sdhci: Tidy sdhci_request() a bit
>       mmc: sdhci: Reduce maximum time under spinlock in sdhci_send_command()
>
>  drivers/mmc/host/sdhci.c | 182 +++++++++++++++++++++++++++++++++++------------
>  drivers/mmc/host/sdhci.h |   2 +-
>  2 files changed, 139 insertions(+), 45 deletions(-)
>

Applied for next, thanks!

Kind regards
Uffe