mbox series

[V2,0/2] mmc: sdhci-sprd: Add SD HS mode online tuning

Message ID 20230815014057.13589-1-wenchao.chen@unisoc.com (mailing list archive)
Headers show
Series mmc: sdhci-sprd: Add SD HS mode online tuning | expand

Message

Wenchao Chen Aug. 15, 2023, 1:40 a.m. UTC
Change in v2:
- add mmc_sd_switch() and mmc_send_status() to the header file
- split up core changes from host driver changes
- Use pr_debug instead of dev_info and dev_dbg
- Optimize the best sampled value algorithm

Wenchao Chen (2):
  mmc: core: Add host specific tuning support for SD HS mode
  mmc: sdhci-sprd: Add SD HS mode online tuning

 drivers/mmc/core/sd.c         |  12 +++
 drivers/mmc/core/sd_ops.c     |   1 +
 drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
 include/linux/mmc/host.h      |   8 ++
 4 files changed, 173 insertions(+)

Comments

Adrian Hunter Aug. 15, 2023, 6:20 a.m. UTC | #1
On 15/08/23 04:40, Wenchao Chen wrote:
> Change in v2:
> - add mmc_sd_switch() and mmc_send_status() to the header file
> - split up core changes from host driver changes
> - Use pr_debug instead of dev_info and dev_dbg
> - Optimize the best sampled value algorithm

What about hooking ->set_ios() as Ulf suggested?

> 
> Wenchao Chen (2):
>   mmc: core: Add host specific tuning support for SD HS mode
>   mmc: sdhci-sprd: Add SD HS mode online tuning
> 
>  drivers/mmc/core/sd.c         |  12 +++
>  drivers/mmc/core/sd_ops.c     |   1 +
>  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
>  include/linux/mmc/host.h      |   8 ++
>  4 files changed, 173 insertions(+)
>
Wenchao Chen Aug. 15, 2023, 10:29 a.m. UTC | #2
On Tue, Aug 15, 2023 at 2:21 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 15/08/23 04:40, Wenchao Chen wrote:
> > Change in v2:
> > - add mmc_sd_switch() and mmc_send_status() to the header file
> > - split up core changes from host driver changes
> > - Use pr_debug instead of dev_info and dev_dbg
> > - Optimize the best sampled value algorithm
>
> What about hooking ->set_ios() as Ulf suggested?
>

I've tried that, but it's not a good way to do it.
We found that sdhci_runtime_resume_host() calls ->set_ios, but we
don't want to do that.
We just need SD HS mode tuning at mmc_sd_init_card().

> >
> > Wenchao Chen (2):
> >   mmc: core: Add host specific tuning support for SD HS mode
> >   mmc: sdhci-sprd: Add SD HS mode online tuning
> >
> >  drivers/mmc/core/sd.c         |  12 +++
> >  drivers/mmc/core/sd_ops.c     |   1 +
> >  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
> >  include/linux/mmc/host.h      |   8 ++
> >  4 files changed, 173 insertions(+)
> >
>
Adrian Hunter Aug. 15, 2023, 10:37 a.m. UTC | #3
On 15/08/23 13:29, Wenchao Chen wrote:
> On Tue, Aug 15, 2023 at 2:21 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 15/08/23 04:40, Wenchao Chen wrote:
>>> Change in v2:
>>> - add mmc_sd_switch() and mmc_send_status() to the header file
>>> - split up core changes from host driver changes
>>> - Use pr_debug instead of dev_info and dev_dbg
>>> - Optimize the best sampled value algorithm
>>
>> What about hooking ->set_ios() as Ulf suggested?
>>
> 
> I've tried that, but it's not a good way to do it.
> We found that sdhci_runtime_resume_host() calls ->set_ios, but we
> don't want to do that.

Given that sdhci_sprd_runtime_resume() calls sdhci_runtime_resume_host(),
it should be possible to determine when to tune, right?

> We just need SD HS mode tuning at mmc_sd_init_card().
> 
>>>
>>> Wenchao Chen (2):
>>>   mmc: core: Add host specific tuning support for SD HS mode
>>>   mmc: sdhci-sprd: Add SD HS mode online tuning
>>>
>>>  drivers/mmc/core/sd.c         |  12 +++
>>>  drivers/mmc/core/sd_ops.c     |   1 +
>>>  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
>>>  include/linux/mmc/host.h      |   8 ++
>>>  4 files changed, 173 insertions(+)
>>>
>>
Wenchao Chen Aug. 15, 2023, 10:55 a.m. UTC | #4
On Tue, Aug 15, 2023 at 6:37 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 15/08/23 13:29, Wenchao Chen wrote:
> > On Tue, Aug 15, 2023 at 2:21 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>
> >> On 15/08/23 04:40, Wenchao Chen wrote:
> >>> Change in v2:
> >>> - add mmc_sd_switch() and mmc_send_status() to the header file
> >>> - split up core changes from host driver changes
> >>> - Use pr_debug instead of dev_info and dev_dbg
> >>> - Optimize the best sampled value algorithm
> >>
> >> What about hooking ->set_ios() as Ulf suggested?
> >>
> >
> > I've tried that, but it's not a good way to do it.
> > We found that sdhci_runtime_resume_host() calls ->set_ios, but we
> > don't want to do that.
>
> Given that sdhci_sprd_runtime_resume() calls sdhci_runtime_resume_host(),
> it should be possible to determine when to tune, right?
>

You mean like this? For example:
static int sdhci_sprd_runtime_resume(struct device *dev)
{
...
sprd_host->need_hs_tuning = false;
sdhci_runtime_resume_host(host, 1);
sprd_host->need_hs_tuning = true;
...
}

> > We just need SD HS mode tuning at mmc_sd_init_card().
> >
> >>>
> >>> Wenchao Chen (2):
> >>>   mmc: core: Add host specific tuning support for SD HS mode
> >>>   mmc: sdhci-sprd: Add SD HS mode online tuning
> >>>
> >>>  drivers/mmc/core/sd.c         |  12 +++
> >>>  drivers/mmc/core/sd_ops.c     |   1 +
> >>>  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
> >>>  include/linux/mmc/host.h      |   8 ++
> >>>  4 files changed, 173 insertions(+)
> >>>
> >>
>
Adrian Hunter Aug. 15, 2023, 11:19 a.m. UTC | #5
On 15/08/23 13:55, Wenchao Chen wrote:
> On Tue, Aug 15, 2023 at 6:37 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 15/08/23 13:29, Wenchao Chen wrote:
>>> On Tue, Aug 15, 2023 at 2:21 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>>>
>>>> On 15/08/23 04:40, Wenchao Chen wrote:
>>>>> Change in v2:
>>>>> - add mmc_sd_switch() and mmc_send_status() to the header file
>>>>> - split up core changes from host driver changes
>>>>> - Use pr_debug instead of dev_info and dev_dbg
>>>>> - Optimize the best sampled value algorithm
>>>>
>>>> What about hooking ->set_ios() as Ulf suggested?
>>>>
>>>
>>> I've tried that, but it's not a good way to do it.
>>> We found that sdhci_runtime_resume_host() calls ->set_ios, but we
>>> don't want to do that.
>>
>> Given that sdhci_sprd_runtime_resume() calls sdhci_runtime_resume_host(),
>> it should be possible to determine when to tune, right?
>>
> 
> You mean like this? For example:
> static int sdhci_sprd_runtime_resume(struct device *dev)
> {
> ...
> sprd_host->need_hs_tuning = false;
> sdhci_runtime_resume_host(host, 1);
> sprd_host->need_hs_tuning = true;

Yes

> ...
> }
> 
>>> We just need SD HS mode tuning at mmc_sd_init_card().
>>>
>>>>>
>>>>> Wenchao Chen (2):
>>>>>   mmc: core: Add host specific tuning support for SD HS mode
>>>>>   mmc: sdhci-sprd: Add SD HS mode online tuning
>>>>>
>>>>>  drivers/mmc/core/sd.c         |  12 +++
>>>>>  drivers/mmc/core/sd_ops.c     |   1 +
>>>>>  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
>>>>>  include/linux/mmc/host.h      |   8 ++
>>>>>  4 files changed, 173 insertions(+)
>>>>>
>>>>
>>
Wenchao Chen Aug. 16, 2023, 2:33 a.m. UTC | #6
On Tue, Aug 15, 2023 at 7:19 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 15/08/23 13:55, Wenchao Chen wrote:
> > On Tue, Aug 15, 2023 at 6:37 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>
> >> On 15/08/23 13:29, Wenchao Chen wrote:
> >>> On Tue, Aug 15, 2023 at 2:21 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>>>
> >>>> On 15/08/23 04:40, Wenchao Chen wrote:
> >>>>> Change in v2:
> >>>>> - add mmc_sd_switch() and mmc_send_status() to the header file
> >>>>> - split up core changes from host driver changes
> >>>>> - Use pr_debug instead of dev_info and dev_dbg
> >>>>> - Optimize the best sampled value algorithm
> >>>>
> >>>> What about hooking ->set_ios() as Ulf suggested?
> >>>>
> >>>
> >>> I've tried that, but it's not a good way to do it.
> >>> We found that sdhci_runtime_resume_host() calls ->set_ios, but we
> >>> don't want to do that.
> >>
> >> Given that sdhci_sprd_runtime_resume() calls sdhci_runtime_resume_host(),
> >> it should be possible to determine when to tune, right?
> >>
> >
> > You mean like this? For example:
> > static int sdhci_sprd_runtime_resume(struct device *dev)
> > {
> > ...
> > sprd_host->need_hs_tuning = false;
> > sdhci_runtime_resume_host(host, 1);
> > sprd_host->need_hs_tuning = true;
>
> Yes
>

This works, but we found a problem: if sd hs tuning fails, ->set_ios
is of type void with no return value.

> > ...
> > }
> >
> >>> We just need SD HS mode tuning at mmc_sd_init_card().
> >>>
> >>>>>
> >>>>> Wenchao Chen (2):
> >>>>>   mmc: core: Add host specific tuning support for SD HS mode
> >>>>>   mmc: sdhci-sprd: Add SD HS mode online tuning
> >>>>>
> >>>>>  drivers/mmc/core/sd.c         |  12 +++
> >>>>>  drivers/mmc/core/sd_ops.c     |   1 +
> >>>>>  drivers/mmc/host/sdhci-sprd.c | 152 ++++++++++++++++++++++++++++++++++
> >>>>>  include/linux/mmc/host.h      |   8 ++
> >>>>>  4 files changed, 173 insertions(+)
> >>>>>
> >>>>
> >>
>