linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy()
@ 2022-01-26  3:45 Saravana Kannan
  2022-01-31 15:45 ` Ulf Hansson
  0 siblings, 1 reply; 5+ messages in thread
From: Saravana Kannan @ 2022-01-26  3:45 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson, Philipp Zabel
  Cc: Linux MMC List, LKML, Android Kernel Team

I'm trying to understand the MMC suspend path a bit.

I looked at the commit message of 6fa79651cc808f68db6f6f297be5a950ccd5dffb.

IIUC, if MMC_CAP_WAIT_WHILE_BUSY is set then the mmc framework is
going to depend on the card_busy() op to ensure correctness instead of
using the S_A_TIMEOUT value from the card.

But I see a lot of mmc host drivers that implement card_busy() but
don't set the MMC_CAP_WAIT_WHILE_BUSY flag. That doesn't seem right to
me if my understanding is correct.

If it's supposed to be "we'll use card_busy() if
MMC_CAP_WAIT_WHILE_BUSY isn't set", then why do we have some mmc host
drivers that have both?

What am I misunderstanding?

-Saravana

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy()
  2022-01-26  3:45 Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy() Saravana Kannan
@ 2022-01-31 15:45 ` Ulf Hansson
  2022-01-31 20:14   ` Saravana Kannan
  0 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2022-01-31 15:45 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Jaehoon Chung, Philipp Zabel, Linux MMC List, LKML, Android Kernel Team

On Wed, 26 Jan 2022 at 04:46, Saravana Kannan <saravanak@google.com> wrote:
>
> I'm trying to understand the MMC suspend path a bit.
>
> I looked at the commit message of 6fa79651cc808f68db6f6f297be5a950ccd5dffb.
>
> IIUC, if MMC_CAP_WAIT_WHILE_BUSY is set then the mmc framework is
> going to depend on the card_busy() op to ensure correctness instead of
> using the S_A_TIMEOUT value from the card.

MMC_CAP_WAIT_WHILE_BUSY indicates whether the mmc controller supports
IRQ based busy detection completion. In other words, the mmc host
driver can receive an IRQ when busy signaling is completed on DAT0 by
the eMMC card.

However, to avoid waiting for the IRQ forever, there is a maximum
timeout that is specified by the mmc core, for the particular command
in question. For eMMC sleep, the S_A_TIMEOUT.

>
> But I see a lot of mmc host drivers that implement card_busy() but
> don't set the MMC_CAP_WAIT_WHILE_BUSY flag. That doesn't seem right to
> me if my understanding is correct.

That's perfectly okay. MMC_CAP_WAIT_WHILE_BUSY is IRQ based, while the
->card_busy() ops is used to poll for busy completion.

>
> If it's supposed to be "we'll use card_busy() if
> MMC_CAP_WAIT_WHILE_BUSY isn't set", then why do we have some mmc host
> drivers that have both?
>
> What am I misunderstanding?

There are some additional complexity for the corresponding code. This
has mostly ended up there because we also need to deal with mmc
controller's HW limitations around this feature.

For example, some mmc controllers have a HW limit for the length of
the timeout that can be set. If the needed timeout is longer than what
can be supported, we can't use IRQ based busy completion.

Did this make it more clear?

>
> -Saravana

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy()
  2022-01-31 15:45 ` Ulf Hansson
@ 2022-01-31 20:14   ` Saravana Kannan
  2022-02-01  8:24     ` Ulf Hansson
  0 siblings, 1 reply; 5+ messages in thread
From: Saravana Kannan @ 2022-01-31 20:14 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Jaehoon Chung, Philipp Zabel, Linux MMC List, LKML, Android Kernel Team

On Mon, Jan 31, 2022 at 7:46 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Wed, 26 Jan 2022 at 04:46, Saravana Kannan <saravanak@google.com> wrote:
> >
> > I'm trying to understand the MMC suspend path a bit.
> >
> > I looked at the commit message of 6fa79651cc808f68db6f6f297be5a950ccd5dffb.
> >
> > IIUC, if MMC_CAP_WAIT_WHILE_BUSY is set then the mmc framework is
> > going to depend on the card_busy() op to ensure correctness instead of
> > using the S_A_TIMEOUT value from the card.
>
> MMC_CAP_WAIT_WHILE_BUSY indicates whether the mmc controller supports
> IRQ based busy detection completion. In other words, the mmc host
> driver can receive an IRQ when busy signaling is completed on DAT0 by
> the eMMC card.
>
> However, to avoid waiting for the IRQ forever, there is a maximum
> timeout that is specified by the mmc core, for the particular command
> in question. For eMMC sleep, the S_A_TIMEOUT.

Ah ok, thanks for the explanation.

>
> >
> > But I see a lot of mmc host drivers that implement card_busy() but
> > don't set the MMC_CAP_WAIT_WHILE_BUSY flag. That doesn't seem right to
> > me if my understanding is correct.
>
> That's perfectly okay. MMC_CAP_WAIT_WHILE_BUSY is IRQ based, while the
> ->card_busy() ops is used to poll for busy completion.

Yeah, it makes sense now.

One thing I noticed when playing with some hardware is that during
suspend, when MMC_CAP_WAIT_WHILE_BUSY isn't set and we have a
card_busy() implementation, we don't seem to be using card_busy() op
and just always using the timeout from S_A_TIMEOUT. To be more
specific, I'm talking about this code path:
_mmc_suspend() -> mmc_sleep() -> mmc_delay() -> msleep()

I'd think card_busy() could be used here if it's implemented. Is there
a reason for not using it in this path?

> >
> > If it's supposed to be "we'll use card_busy() if
> > MMC_CAP_WAIT_WHILE_BUSY isn't set", then why do we have some mmc host
> > drivers that have both?
> >
> > What am I misunderstanding?
>
> There are some additional complexity for the corresponding code. This
> has mostly ended up there because we also need to deal with mmc
> controller's HW limitations around this feature.
>
> For example, some mmc controllers have a HW limit for the length of
> the timeout that can be set. If the needed timeout is longer than what
> can be supported, we can't use IRQ based busy completion.
>
> Did this make it more clear?

Yes, it does. Much appreciated!

Thanks,
Saravana

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy()
  2022-01-31 20:14   ` Saravana Kannan
@ 2022-02-01  8:24     ` Ulf Hansson
  2022-02-01 17:47       ` Saravana Kannan
  0 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2022-02-01  8:24 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Jaehoon Chung, Philipp Zabel, Linux MMC List, LKML, Android Kernel Team

On Mon, 31 Jan 2022 at 21:15, Saravana Kannan <saravanak@google.com> wrote:
>
> On Mon, Jan 31, 2022 at 7:46 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Wed, 26 Jan 2022 at 04:46, Saravana Kannan <saravanak@google.com> wrote:
> > >
> > > I'm trying to understand the MMC suspend path a bit.
> > >
> > > I looked at the commit message of 6fa79651cc808f68db6f6f297be5a950ccd5dffb.
> > >
> > > IIUC, if MMC_CAP_WAIT_WHILE_BUSY is set then the mmc framework is
> > > going to depend on the card_busy() op to ensure correctness instead of
> > > using the S_A_TIMEOUT value from the card.
> >
> > MMC_CAP_WAIT_WHILE_BUSY indicates whether the mmc controller supports
> > IRQ based busy detection completion. In other words, the mmc host
> > driver can receive an IRQ when busy signaling is completed on DAT0 by
> > the eMMC card.
> >
> > However, to avoid waiting for the IRQ forever, there is a maximum
> > timeout that is specified by the mmc core, for the particular command
> > in question. For eMMC sleep, the S_A_TIMEOUT.
>
> Ah ok, thanks for the explanation.
>
> >
> > >
> > > But I see a lot of mmc host drivers that implement card_busy() but
> > > don't set the MMC_CAP_WAIT_WHILE_BUSY flag. That doesn't seem right to
> > > me if my understanding is correct.
> >
> > That's perfectly okay. MMC_CAP_WAIT_WHILE_BUSY is IRQ based, while the
> > ->card_busy() ops is used to poll for busy completion.
>
> Yeah, it makes sense now.
>
> One thing I noticed when playing with some hardware is that during
> suspend, when MMC_CAP_WAIT_WHILE_BUSY isn't set and we have a
> card_busy() implementation, we don't seem to be using card_busy() op
> and just always using the timeout from S_A_TIMEOUT. To be more
> specific, I'm talking about this code path:
> _mmc_suspend() -> mmc_sleep() -> mmc_delay() -> msleep()
>
> I'd think card_busy() could be used here if it's implemented. Is there
> a reason for not using it in this path?

That was exactly what commit 6fa79651cc80 ("mmc: core: Enable eMMC
sleep commands to use HW busy polling") implemented. The commit was
introduced in v5.14.

If it doesn't work, there is a bug somewhere.

[...]

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy()
  2022-02-01  8:24     ` Ulf Hansson
@ 2022-02-01 17:47       ` Saravana Kannan
  0 siblings, 0 replies; 5+ messages in thread
From: Saravana Kannan @ 2022-02-01 17:47 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Jaehoon Chung, Philipp Zabel, Linux MMC List, LKML, Android Kernel Team

On Tue, Feb 1, 2022 at 12:24 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Mon, 31 Jan 2022 at 21:15, Saravana Kannan <saravanak@google.com> wrote:
> >
> > On Mon, Jan 31, 2022 at 7:46 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > >
> > > On Wed, 26 Jan 2022 at 04:46, Saravana Kannan <saravanak@google.com> wrote:
> > > >
> > > > I'm trying to understand the MMC suspend path a bit.
> > > >
> > > > I looked at the commit message of 6fa79651cc808f68db6f6f297be5a950ccd5dffb.
> > > >
> > > > IIUC, if MMC_CAP_WAIT_WHILE_BUSY is set then the mmc framework is
> > > > going to depend on the card_busy() op to ensure correctness instead of
> > > > using the S_A_TIMEOUT value from the card.
> > >
> > > MMC_CAP_WAIT_WHILE_BUSY indicates whether the mmc controller supports
> > > IRQ based busy detection completion. In other words, the mmc host
> > > driver can receive an IRQ when busy signaling is completed on DAT0 by
> > > the eMMC card.
> > >
> > > However, to avoid waiting for the IRQ forever, there is a maximum
> > > timeout that is specified by the mmc core, for the particular command
> > > in question. For eMMC sleep, the S_A_TIMEOUT.
> >
> > Ah ok, thanks for the explanation.
> >
> > >
> > > >
> > > > But I see a lot of mmc host drivers that implement card_busy() but
> > > > don't set the MMC_CAP_WAIT_WHILE_BUSY flag. That doesn't seem right to
> > > > me if my understanding is correct.
> > >
> > > That's perfectly okay. MMC_CAP_WAIT_WHILE_BUSY is IRQ based, while the
> > > ->card_busy() ops is used to poll for busy completion.
> >
> > Yeah, it makes sense now.
> >
> > One thing I noticed when playing with some hardware is that during
> > suspend, when MMC_CAP_WAIT_WHILE_BUSY isn't set and we have a
> > card_busy() implementation, we don't seem to be using card_busy() op
> > and just always using the timeout from S_A_TIMEOUT. To be more
> > specific, I'm talking about this code path:
> > _mmc_suspend() -> mmc_sleep() -> mmc_delay() -> msleep()
> >
> > I'd think card_busy() could be used here if it's implemented. Is there
> > a reason for not using it in this path?
>
> That was exactly what commit 6fa79651cc80 ("mmc: core: Enable eMMC
> sleep commands to use HW busy polling") implemented. The commit was
> introduced in v5.14.
>
> If it doesn't work, there is a bug somewhere.

Ah I was checking an older kernel and meant to check the latest
mainline before I sent this email, but then forgot to do it. Thanks
for the pointer! Let me backport and see if it helps.

-Saravana

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-01 17:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26  3:45 Relation between MMC_CAP_WAIT_WHILE_BUSY and card_busy() Saravana Kannan
2022-01-31 15:45 ` Ulf Hansson
2022-01-31 20:14   ` Saravana Kannan
2022-02-01  8:24     ` Ulf Hansson
2022-02-01 17:47       ` Saravana Kannan

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).