diff mbox

mmc: debugfs: add runtime pm when cat ios or clock file node

Message ID 1493017393-13785-1-git-send-email-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bough Chen April 24, 2017, 7:03 a.m. UTC
MMC core code add 'MMC_CAP_RUNTIME_RESUME', postpone the real card
resume operation from bus_resume to bus_runtime_resume. So after
system resume, for non-removable-card, it still not really resume.
At this point, if user cat the ios or clock node, only can get zero
data although the mmc/sd card is still present.

This patch add mmc_get_card() to make sure card really resume back
when user cat ios or clock debugfs file node, then user can get the
correct information.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/core/debugfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Adrian Hunter April 24, 2017, 7:16 a.m. UTC | #1
On 24/04/17 10:03, Haibo Chen wrote:
> MMC core code add 'MMC_CAP_RUNTIME_RESUME', postpone the real card
> resume operation from bus_resume to bus_runtime_resume. So after
> system resume, for non-removable-card, it still not really resume.
> At this point, if user cat the ios or clock node, only can get zero
> data although the mmc/sd card is still present.

If you ask me, getting zero is correct.

> 
> This patch add mmc_get_card() to make sure card really resume back
> when user cat ios or clock debugfs file node, then user can get the
> correct information.

Can't the user runtime resume the card / host controller and then look at ios?

> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/mmc/core/debugfs.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index a1fba57..23ec9d3 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -58,6 +58,9 @@ static int mmc_ios_show(struct seq_file *s, void *data)
>  	struct mmc_ios	*ios = &host->ios;
>  	const char *str;
>  
> +	if (host->card)
> +		mmc_get_card(host->card);
> +
>  	seq_printf(s, "clock:\t\t%u Hz\n", ios->clock);
>  	if (host->actual_clock)
>  		seq_printf(s, "actual clock:\t%u Hz\n", host->actual_clock);
> @@ -194,6 +197,9 @@ static int mmc_ios_show(struct seq_file *s, void *data)
>  	}
>  	seq_printf(s, "driver type:\t%u (%s)\n", ios->drv_type, str);
>  
> +	if (host->card)
> +		mmc_put_card(host->card);
> +
>  	return 0;
>  }
>  
> @@ -213,7 +219,11 @@ static int mmc_clock_opt_get(void *data, u64 *val)
>  {
>  	struct mmc_host *host = data;
>  
> +	if (host->card)
> +		mmc_get_card(host->card);
>  	*val = host->ios.clock;
> +	if (host->card)
> +		mmc_put_card(host->card);
>  
>  	return 0;
>  }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson April 24, 2017, 8:12 a.m. UTC | #2
On 24 April 2017 at 09:16, Adrian Hunter <adrian.hunter@intel.com> wrote:
> On 24/04/17 10:03, Haibo Chen wrote:
>> MMC core code add 'MMC_CAP_RUNTIME_RESUME', postpone the real card
>> resume operation from bus_resume to bus_runtime_resume. So after
>> system resume, for non-removable-card, it still not really resume.
>> At this point, if user cat the ios or clock node, only can get zero
>> data although the mmc/sd card is still present.
>
> If you ask me, getting zero is correct.

I fully agree!

The job for the debugfs ios node, is to report the current state, not
to change it.

[...]

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bough Chen April 24, 2017, 9:06 a.m. UTC | #3
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBVbGYgSGFuc3NvbiBbbWFpbHRv
OnVsZi5oYW5zc29uQGxpbmFyby5vcmddDQo+IFNlbnQ6IE1vbmRheSwgQXByaWwgMjQsIDIwMTcg
NDoxMiBQTQ0KPiBUbzogQWRyaWFuIEh1bnRlciA8YWRyaWFuLmh1bnRlckBpbnRlbC5jb20+OyBC
b3VnaCBDaGVuDQo+IDxoYWliby5jaGVuQG54cC5jb20+D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GFuZ2UgaXQuDQoNCkdvdCBpdC4gIA0KDQpJIGhhdmUgb25lIG1vcmUg
cXVlc3Rpb246IHRha2Ugc2RoY2kgYW5kIHNkaGNpLWVzZGhjLWlteCBhcyBleGFtcGxlLCBpZiBj
b250cm9sbGVyIGluIHJ1bnRpbWUgc3VzcGVuZCwgIHRoZW4gY2F0IHRoZSBpb3MsIHdlIHdpbGwg
c2VlIHRoZSB2YWx1ZSBpbmNsdWRpbmcgY2xvY2ssIGJ1dCBpbiBzZGhjaS1lc2RoYy1pbXgsIHdl
IGFscmVhZHkgZGlzYWJsZSB0aGUgdXNkaGMgY2xvY2sgaW4gcnVudGltZSBzdXNwZW5kLCB0aGUg
dHdvIGFyZSBub3QgbWF0Y2gsIEknbSBjb25mdXNlZCBvZiB0aGlzLg0KDQpCUg0KSGFpYm8NCj4g
DQo+IFsuLi5dDQo+IA0KPiBLaW5kIHJlZ2FyZHMNCj4gVWZmZQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson April 24, 2017, 9:47 a.m. UTC | #4
On 24 April 2017 at 11:06, Bough Chen <haibo.chen@nxp.com> wrote:
>> -----Original Message-----
>> From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
>> Sent: Monday, April 24, 2017 4:12 PM
>> To: Adrian Hunter <adrian.hunter@intel.com>; Bough Chen
>> <haibo.chen@nxp.com>
>> Cc: linux-mmc@vger.kernel.org; A.S. Dong <aisheng.dong@nxp.com>
>> Subject: Re: [PATCH] mmc: debugfs: add runtime pm when cat ios or clock file
>> node
>>
>> On 24 April 2017 at 09:16, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> > On 24/04/17 10:03, Haibo Chen wrote:
>> >> MMC core code add 'MMC_CAP_RUNTIME_RESUME', postpone the real
>> card
>> >> resume operation from bus_resume to bus_runtime_resume. So after
>> >> system resume, for non-removable-card, it still not really resume.
>> >> At this point, if user cat the ios or clock node, only can get zero
>> >> data although the mmc/sd card is still present.
>> >
>> > If you ask me, getting zero is correct.
>>
>> I fully agree!
>>
>> The job for the debugfs ios node, is to report the current state, not to change it.
>
> Got it.
>
> I have one more question: take sdhci and sdhci-esdhc-imx as example, if controller in runtime suspend,  then cat the ios, we will see the value including clock, but in sdhci-esdhc-imx, we already disable the usdhc clock in runtime suspend, the two are not match, I'm confused of this.

Correct. The main purpose of the debugfs ios node is to provide
information about the current operation conditions for the card and
not really for the host. I can see it is a bit confusing, however
that's how it has been a very long long time.

If you need to know about current operation conditions for the host,
those needs to be implemented in the host driver. Typical information
could be a register dump of the controller.

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index a1fba57..23ec9d3 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -58,6 +58,9 @@  static int mmc_ios_show(struct seq_file *s, void *data)
 	struct mmc_ios	*ios = &host->ios;
 	const char *str;
 
+	if (host->card)
+		mmc_get_card(host->card);
+
 	seq_printf(s, "clock:\t\t%u Hz\n", ios->clock);
 	if (host->actual_clock)
 		seq_printf(s, "actual clock:\t%u Hz\n", host->actual_clock);
@@ -194,6 +197,9 @@  static int mmc_ios_show(struct seq_file *s, void *data)
 	}
 	seq_printf(s, "driver type:\t%u (%s)\n", ios->drv_type, str);
 
+	if (host->card)
+		mmc_put_card(host->card);
+
 	return 0;
 }
 
@@ -213,7 +219,11 @@  static int mmc_clock_opt_get(void *data, u64 *val)
 {
 	struct mmc_host *host = data;
 
+	if (host->card)
+		mmc_get_card(host->card);
 	*val = host->ios.clock;
+	if (host->card)
+		mmc_put_card(host->card);
 
 	return 0;
 }