[v4,2/3] mmc: host: sdhci: Add request_done ops for struct sdhci_ops
diff mbox series

Message ID 487c2e45810c6dc6485638474136e375cb567807.1571722391.git.baolin.wang@linaro.org
State New
Headers show
Series
  • Add MMC software queue support
Related show

Commit Message

(Exiting) Baolin Wang Oct. 22, 2019, 5:58 a.m. UTC
Add request_done ops for struct sdhci_ops as a preparation in case some
host controllers have different method to complete one request, such as
supporting request completion of MMC software queue.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/mmc/host/sdhci.c |   12 ++++++++++--
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

Comments

Adrian Hunter Oct. 28, 2019, 8:19 a.m. UTC | #1
On 22/10/19 8:58 AM, Baolin Wang wrote:
> Add request_done ops for struct sdhci_ops as a preparation in case some
> host controllers have different method to complete one request, such as
> supporting request completion of MMC software queue.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> ---
>  drivers/mmc/host/sdhci.c |   12 ++++++++++--
>  drivers/mmc/host/sdhci.h |    2 ++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index b056400..850241f 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2729,7 +2729,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
>  
>  	spin_unlock_irqrestore(&host->lock, flags);
>  
> -	mmc_request_done(host->mmc, mrq);
> +	if (host->ops->request_done)
> +		host->ops->request_done(host, mrq);

For hsq, couldn't this result in sdhci_request() being called interrupt
context here.

To prevent that you would need to add a condition to sdhci_defer_done() so
it always defers when using hsq.

That would be a separate patch.

> +	else
> +		mmc_request_done(host->mmc, mrq);
>  
>  	return false;
>  }
> @@ -3157,7 +3160,12 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  
>  	/* Process mrqs ready for immediate completion */
>  	for (i = 0; i < SDHCI_MAX_MRQS; i++) {
> -		if (mrqs_done[i])
> +		if (!mrqs_done[i])
> +			continue;
> +
> +		if (host->ops->request_done)
> +			host->ops->request_done(host, mrqs_done[i]);
> +		else
>  			mmc_request_done(host->mmc, mrqs_done[i]);
>  	}
>  
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 0ed3e0e..d89cdb9 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -644,6 +644,8 @@ struct sdhci_ops {
>  	void	(*voltage_switch)(struct sdhci_host *host);
>  	void	(*adma_write_desc)(struct sdhci_host *host, void **desc,
>  				   dma_addr_t addr, int len, unsigned int cmd);
> +	void	(*request_done)(struct sdhci_host *host,
> +				struct mmc_request *mrq);
>  };
>  
>  #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
>
(Exiting) Baolin Wang Oct. 28, 2019, 8:27 a.m. UTC | #2
Hi Adrian,

On Mon, 28 Oct 2019 at 16:20, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 22/10/19 8:58 AM, Baolin Wang wrote:
> > Add request_done ops for struct sdhci_ops as a preparation in case some
> > host controllers have different method to complete one request, such as
> > supporting request completion of MMC software queue.
> >
> > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > ---
> >  drivers/mmc/host/sdhci.c |   12 ++++++++++--
> >  drivers/mmc/host/sdhci.h |    2 ++
> >  2 files changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index b056400..850241f 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -2729,7 +2729,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
> >
> >       spin_unlock_irqrestore(&host->lock, flags);
> >
> > -     mmc_request_done(host->mmc, mrq);
> > +     if (host->ops->request_done)
> > +             host->ops->request_done(host, mrq);
>
> For hsq, couldn't this result in sdhci_request() being called interrupt
> context here.

Right, now it did not support.

>
> To prevent that you would need to add a condition to sdhci_defer_done() so
> it always defers when using hsq.

Yes, but now the condition can be matched in sdhci_defer_done()  when
using hsq. So no need to worry that the sdhci_request() will be called
in interrupt
context in this patch set. Thanks.
(Exiting) Baolin Wang Oct. 28, 2019, 8:38 a.m. UTC | #3
On Mon, 28 Oct 2019 at 16:27, Baolin Wang <baolin.wang@linaro.org> wrote:
>
> Hi Adrian,
>
> On Mon, 28 Oct 2019 at 16:20, Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > On 22/10/19 8:58 AM, Baolin Wang wrote:
> > > Add request_done ops for struct sdhci_ops as a preparation in case some
> > > host controllers have different method to complete one request, such as
> > > supporting request completion of MMC software queue.
> > >
> > > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > > ---
> > >  drivers/mmc/host/sdhci.c |   12 ++++++++++--
> > >  drivers/mmc/host/sdhci.h |    2 ++
> > >  2 files changed, 12 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > > index b056400..850241f 100644
> > > --- a/drivers/mmc/host/sdhci.c
> > > +++ b/drivers/mmc/host/sdhci.c
> > > @@ -2729,7 +2729,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
> > >
> > >       spin_unlock_irqrestore(&host->lock, flags);
> > >
> > > -     mmc_request_done(host->mmc, mrq);
> > > +     if (host->ops->request_done)
> > > +             host->ops->request_done(host, mrq);
> >
> > For hsq, couldn't this result in sdhci_request() being called interrupt
> > context here.
>
> Right, now it did not support.
>
> >
> > To prevent that you would need to add a condition to sdhci_defer_done() so
> > it always defers when using hsq.
>
> Yes, but now the condition can be matched in sdhci_defer_done()  when
> using hsq. So no need to worry that the sdhci_request() will be called
> in interrupt
> context in this patch set. Thanks.
>

Wait, sorry, I realized some drivers may not select the
SDHCI_REQ_USE_DMA flag in sdhci_defer_done()  when using hsq. OK, So
how about below changes?

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 850241f..6c7a396 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3035,7 +3035,7 @@ static inline bool sdhci_defer_done(struct
sdhci_host *host,
 {
        struct mmc_data *data = mrq->data;

-       return host->pending_reset ||
+       return IS_ENABLED(CONFIG_MMC_HSQ) || host->pending_reset ||
               ((host->flags & SDHCI_REQ_USE_DMA) && data &&
                data->host_cookie == COOKIE_MAPPED);
 }
Adrian Hunter Oct. 28, 2019, 9:10 a.m. UTC | #4
On 28/10/19 10:38 AM, Baolin Wang wrote:
> On Mon, 28 Oct 2019 at 16:27, Baolin Wang <baolin.wang@linaro.org> wrote:
>>
>> Hi Adrian,
>>
>> On Mon, 28 Oct 2019 at 16:20, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>>
>>> On 22/10/19 8:58 AM, Baolin Wang wrote:
>>>> Add request_done ops for struct sdhci_ops as a preparation in case some
>>>> host controllers have different method to complete one request, such as
>>>> supporting request completion of MMC software queue.
>>>>
>>>> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
>>>> ---
>>>>  drivers/mmc/host/sdhci.c |   12 ++++++++++--
>>>>  drivers/mmc/host/sdhci.h |    2 ++
>>>>  2 files changed, 12 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>>>> index b056400..850241f 100644
>>>> --- a/drivers/mmc/host/sdhci.c
>>>> +++ b/drivers/mmc/host/sdhci.c
>>>> @@ -2729,7 +2729,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
>>>>
>>>>       spin_unlock_irqrestore(&host->lock, flags);
>>>>
>>>> -     mmc_request_done(host->mmc, mrq);
>>>> +     if (host->ops->request_done)
>>>> +             host->ops->request_done(host, mrq);
>>>
>>> For hsq, couldn't this result in sdhci_request() being called interrupt
>>> context here.
>>
>> Right, now it did not support.
>>
>>>
>>> To prevent that you would need to add a condition to sdhci_defer_done() so
>>> it always defers when using hsq.
>>
>> Yes, but now the condition can be matched in sdhci_defer_done()  when
>> using hsq. So no need to worry that the sdhci_request() will be called
>> in interrupt
>> context in this patch set. Thanks.
>>
> 
> Wait, sorry, I realized some drivers may not select the
> SDHCI_REQ_USE_DMA flag in sdhci_defer_done()  when using hsq. OK, So
> how about below changes?
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 850241f..6c7a396 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3035,7 +3035,7 @@ static inline bool sdhci_defer_done(struct
> sdhci_host *host,
>  {
>         struct mmc_data *data = mrq->data;
> 
> -       return host->pending_reset ||
> +       return IS_ENABLED(CONFIG_MMC_HSQ) || host->pending_reset ||

Just because it is configured does not mean it is used.  How about adding a
variable host->always_defer_done and set it in sdhci_sprd_probe().

>                ((host->flags & SDHCI_REQ_USE_DMA) && data &&
>                 data->host_cookie == COOKIE_MAPPED);
>  }
>
Baolin Wang Oct. 28, 2019, 9:15 a.m. UTC | #5
On Mon, Oct 28, 2019 at 5:11 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 28/10/19 10:38 AM, Baolin Wang wrote:
> > On Mon, 28 Oct 2019 at 16:27, Baolin Wang <baolin.wang@linaro.org> wrote:
> >>
> >> Hi Adrian,
> >>
> >> On Mon, 28 Oct 2019 at 16:20, Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>>
> >>> On 22/10/19 8:58 AM, Baolin Wang wrote:
> >>>> Add request_done ops for struct sdhci_ops as a preparation in case some
> >>>> host controllers have different method to complete one request, such as
> >>>> supporting request completion of MMC software queue.
> >>>>
> >>>> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> >>>> ---
> >>>>  drivers/mmc/host/sdhci.c |   12 ++++++++++--
> >>>>  drivers/mmc/host/sdhci.h |    2 ++
> >>>>  2 files changed, 12 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> >>>> index b056400..850241f 100644
> >>>> --- a/drivers/mmc/host/sdhci.c
> >>>> +++ b/drivers/mmc/host/sdhci.c
> >>>> @@ -2729,7 +2729,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
> >>>>
> >>>>       spin_unlock_irqrestore(&host->lock, flags);
> >>>>
> >>>> -     mmc_request_done(host->mmc, mrq);
> >>>> +     if (host->ops->request_done)
> >>>> +             host->ops->request_done(host, mrq);
> >>>
> >>> For hsq, couldn't this result in sdhci_request() being called interrupt
> >>> context here.
> >>
> >> Right, now it did not support.
> >>
> >>>
> >>> To prevent that you would need to add a condition to sdhci_defer_done() so
> >>> it always defers when using hsq.
> >>
> >> Yes, but now the condition can be matched in sdhci_defer_done()  when
> >> using hsq. So no need to worry that the sdhci_request() will be called
> >> in interrupt
> >> context in this patch set. Thanks.
> >>
> >
> > Wait, sorry, I realized some drivers may not select the
> > SDHCI_REQ_USE_DMA flag in sdhci_defer_done()  when using hsq. OK, So
> > how about below changes?
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index 850241f..6c7a396 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -3035,7 +3035,7 @@ static inline bool sdhci_defer_done(struct
> > sdhci_host *host,
> >  {
> >         struct mmc_data *data = mrq->data;
> >
> > -       return host->pending_reset ||
> > +       return IS_ENABLED(CONFIG_MMC_HSQ) || host->pending_reset ||
>
> Just because it is configured does not mean it is used.  How about adding a
> variable host->always_defer_done and set it in sdhci_sprd_probe().

Sure, sounds reasonable to me. Thanks.

Patch
diff mbox series

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b056400..850241f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2729,7 +2729,10 @@  static bool sdhci_request_done(struct sdhci_host *host)
 
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	mmc_request_done(host->mmc, mrq);
+	if (host->ops->request_done)
+		host->ops->request_done(host, mrq);
+	else
+		mmc_request_done(host->mmc, mrq);
 
 	return false;
 }
@@ -3157,7 +3160,12 @@  static irqreturn_t sdhci_irq(int irq, void *dev_id)
 
 	/* Process mrqs ready for immediate completion */
 	for (i = 0; i < SDHCI_MAX_MRQS; i++) {
-		if (mrqs_done[i])
+		if (!mrqs_done[i])
+			continue;
+
+		if (host->ops->request_done)
+			host->ops->request_done(host, mrqs_done[i]);
+		else
 			mmc_request_done(host->mmc, mrqs_done[i]);
 	}
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0ed3e0e..d89cdb9 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -644,6 +644,8 @@  struct sdhci_ops {
 	void	(*voltage_switch)(struct sdhci_host *host);
 	void	(*adma_write_desc)(struct sdhci_host *host, void **desc,
 				   dma_addr_t addr, int len, unsigned int cmd);
+	void	(*request_done)(struct sdhci_host *host,
+				struct mmc_request *mrq);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS