diff mbox

[2/2] arm64: dts: rockchip: add eMMC's power domain support for rk3399

Message ID 20160827134103.28160-3-xzy.xu@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

ziyuan Aug. 27, 2016, 1:41 p.m. UTC
Control power domain for eMMC via genpd to reduce power consumption.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

---

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Shawn Lin Aug. 27, 2016, 3:05 p.m. UTC | #1
On 2016/8/27 21:41, Ziyuan Xu wrote:
> Control power domain for eMMC via genpd to reduce power consumption.
>
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>

It looks nice to me. But this should be merged after applying that[0]
as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
without it[0]. Moreover, Elaine should make sure that upstreamed
rockchip power domain stuff would not off pd for emmc, *otherwise*, I
should update my patch to make sure we update clkmul every time when
doing suspend 2 resume..



[0]: https://patchwork.kernel.org/patch/9300971/

> ---
>
>  arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
> index 32aebc8..71733d4 100644
> --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
> +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
> @@ -239,6 +239,7 @@
>  		#clock-cells = <0>;
>  		phys = <&emmc_phy>;
>  		phy-names = "phy_arasan";
> +		power-domains = <&power RK3399_PD_EMMC>;
>  		status = "disabled";
>  	};
>
> @@ -611,6 +612,11 @@
>  		status = "disabled";
>  	};
>
> +	qos_emmc: qos@ffa58000 {
> +		compatible = "syscon";
> +		reg = <0x0 0xffa58000 0x0 0x20>;
> +	};
> +
>  	qos_hdcp: qos@ffa90000 {
>  		compatible = "syscon";
>  		reg = <0x0 0xffa90000 0x0 0x20>;
> @@ -739,6 +745,11 @@
>  			};
>
>  			/* These power domains are grouped by VD_LOGIC */
> +			pd_emmc@RK3399_PD_EMMC {
> +				reg = <RK3399_PD_EMMC>;
> +				clocks = <&cru ACLK_EMMC>;
> +				pm_qos = <&qos_emmc>;
> +			};
>  			pd_vio@RK3399_PD_VIO {
>  				reg = <RK3399_PD_VIO>;
>  				#address-cells = <1>;
>
zhangqing Aug. 29, 2016, 1:58 a.m. UTC | #2
On 08/27/2016 11:05 PM, Shawn Lin wrote:
> On 2016/8/27 21:41, Ziyuan Xu wrote:
>> Control power domain for eMMC via genpd to reduce power consumption.
>>
>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>
>
> It looks nice to me. But this should be merged after applying that[0]
> as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
> without it[0]. Moreover, Elaine should make sure that upstreamed
> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
> should update my patch to make sure we update clkmul every time when
> doing suspend 2 resume..
>
It looks nice to me. I was going on to submit with other Pds.

>
>
> [0]: https://patchwork.kernel.org/patch/9300971/
>
>> ---
>>
>>  arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> index 32aebc8..71733d4 100644
>> --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> @@ -239,6 +239,7 @@
>>          #clock-cells = <0>;
>>          phys = <&emmc_phy>;
>>          phy-names = "phy_arasan";
>> +        power-domains = <&power RK3399_PD_EMMC>;
>>          status = "disabled";
>>      };
>>
>> @@ -611,6 +612,11 @@
>>          status = "disabled";
>>      };
>>
>> +    qos_emmc: qos@ffa58000 {
>> +        compatible = "syscon";
>> +        reg = <0x0 0xffa58000 0x0 0x20>;
>> +    };
>> +
>>      qos_hdcp: qos@ffa90000 {
>>          compatible = "syscon";
>>          reg = <0x0 0xffa90000 0x0 0x20>;
>> @@ -739,6 +745,11 @@
>>              };
>>
>>              /* These power domains are grouped by VD_LOGIC */
>> +            pd_emmc@RK3399_PD_EMMC {
>> +                reg = <RK3399_PD_EMMC>;
>> +                clocks = <&cru ACLK_EMMC>;
>> +                pm_qos = <&qos_emmc>;
>> +            };
>>              pd_vio@RK3399_PD_VIO {
>>                  reg = <RK3399_PD_VIO>;
>>                  #address-cells = <1>;
>>
>
>
zhangqing Aug. 29, 2016, 2:50 a.m. UTC | #3
On 08/27/2016 11:05 PM, Shawn Lin wrote:
> On 2016/8/27 21:41, Ziyuan Xu wrote:
>> Control power domain for eMMC via genpd to reduce power consumption.
>>
>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>
>
> It looks nice to me. But this should be merged after applying that[0]
> as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
> without it[0]. Moreover, Elaine should make sure that upstreamed
> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
> should update my patch to make sure we update clkmul every time when
> doing suspend 2 resume..
>
>
Forgot to say:
If use pd, Although there is no call to power odd the pd_emmc,
it will be power off when the system doing suspend 2 resume.
(Because the system call 
__device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)

And it's important to note:
If the pd has been power off, some grf regs will be back to the default 
value.(which grf regs in this pd)
So if the pd support power off , this grf regs need to save and restore 
or reinit.
For example:
pd_emmc
	aclk_emmc_grf

If the pd is always on,and this pd have wakeup func.
The device need to add device_init_wakeup() to make the pd always on 
when the system doing suspend 2 resume.

>
> [0]: https://patchwork.kernel.org/patch/9300971/
>
>> ---
>>
>>  arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> index 32aebc8..71733d4 100644
>> --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>> @@ -239,6 +239,7 @@
>>          #clock-cells = <0>;
>>          phys = <&emmc_phy>;
>>          phy-names = "phy_arasan";
>> +        power-domains = <&power RK3399_PD_EMMC>;
>>          status = "disabled";
>>      };
>>
>> @@ -611,6 +612,11 @@
>>          status = "disabled";
>>      };
>>
>> +    qos_emmc: qos@ffa58000 {
>> +        compatible = "syscon";
>> +        reg = <0x0 0xffa58000 0x0 0x20>;
>> +    };
>> +
>>      qos_hdcp: qos@ffa90000 {
>>          compatible = "syscon";
>>          reg = <0x0 0xffa90000 0x0 0x20>;
>> @@ -739,6 +745,11 @@
>>              };
>>
>>              /* These power domains are grouped by VD_LOGIC */
>> +            pd_emmc@RK3399_PD_EMMC {
>> +                reg = <RK3399_PD_EMMC>;
>> +                clocks = <&cru ACLK_EMMC>;
>> +                pm_qos = <&qos_emmc>;
>> +            };
>>              pd_vio@RK3399_PD_VIO {
>>                  reg = <RK3399_PD_VIO>;
>>                  #address-cells = <1>;
>>
>
>
Shawn Lin Aug. 29, 2016, 3:25 a.m. UTC | #4
On 2016/8/29 10:50, Elaine Zhang wrote:
>
>
> On 08/27/2016 11:05 PM, Shawn Lin wrote:
>> On 2016/8/27 21:41, Ziyuan Xu wrote:
>>> Control power domain for eMMC via genpd to reduce power consumption.
>>>
>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>>
>>
>> It looks nice to me. But this should be merged after applying that[0]
>> as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
>> without it[0]. Moreover, Elaine should make sure that upstreamed
>> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
>> should update my patch to make sure we update clkmul every time when
>> doing suspend 2 resume..
>>
>>
> Forgot to say:
> If use pd, Although there is no call to power odd the pd_emmc,
> it will be power off when the system doing suspend 2 resume.
> (Because the system call
> __device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)

Thanks for explaining this. I checked the code a bit and actually I
don't need to updata clkmul since it was recorded, although it is still
reset to 0x10 reading from syscon. So for that, we can now pick it
up without waiting for my sdhci-of-arasan's update.

Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>



>
> And it's important to note:
> If the pd has been power off, some grf regs will be back to the default
> value.(which grf regs in this pd)
> So if the pd support power off , this grf regs need to save and restore
> or reinit.
> For example:
> pd_emmc
>     aclk_emmc_grf
>
> If the pd is always on,and this pd have wakeup func.
> The device need to add device_init_wakeup() to make the pd always on
> when the system doing suspend 2 resume.
>
>>
>> [0]: https://patchwork.kernel.org/patch/9300971/
>>
>>> ---
>>>
>>>  arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++++++++++
>>>  1 file changed, 11 insertions(+)
>>>
>>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>>> b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>>> index 32aebc8..71733d4 100644
>>> --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>>> +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
>>> @@ -239,6 +239,7 @@
>>>          #clock-cells = <0>;
>>>          phys = <&emmc_phy>;
>>>          phy-names = "phy_arasan";
>>> +        power-domains = <&power RK3399_PD_EMMC>;
>>>          status = "disabled";
>>>      };
>>>
>>> @@ -611,6 +612,11 @@
>>>          status = "disabled";
>>>      };
>>>
>>> +    qos_emmc: qos@ffa58000 {
>>> +        compatible = "syscon";
>>> +        reg = <0x0 0xffa58000 0x0 0x20>;
>>> +    };
>>> +
>>>      qos_hdcp: qos@ffa90000 {
>>>          compatible = "syscon";
>>>          reg = <0x0 0xffa90000 0x0 0x20>;
>>> @@ -739,6 +745,11 @@
>>>              };
>>>
>>>              /* These power domains are grouped by VD_LOGIC */
>>> +            pd_emmc@RK3399_PD_EMMC {
>>> +                reg = <RK3399_PD_EMMC>;
>>> +                clocks = <&cru ACLK_EMMC>;
>>> +                pm_qos = <&qos_emmc>;
>>> +            };
>>>              pd_vio@RK3399_PD_VIO {
>>>                  reg = <RK3399_PD_VIO>;
>>>                  #address-cells = <1>;
>>>
>>
>>
>
>
>
Doug Anderson Aug. 31, 2016, 5:42 p.m. UTC | #5
Hi,

On Sun, Aug 28, 2016 at 8:25 PM, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> On 2016/8/29 10:50, Elaine Zhang wrote:
>>
>>
>>
>> On 08/27/2016 11:05 PM, Shawn Lin wrote:
>>>
>>> On 2016/8/27 21:41, Ziyuan Xu wrote:
>>>>
>>>> Control power domain for eMMC via genpd to reduce power consumption.
>>>>
>>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>>>
>>>
>>> It looks nice to me. But this should be merged after applying that[0]
>>> as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
>>> without it[0]. Moreover, Elaine should make sure that upstreamed
>>> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
>>> should update my patch to make sure we update clkmul every time when
>>> doing suspend 2 resume..
>>>
>>>
>> Forgot to say:
>> If use pd, Although there is no call to power odd the pd_emmc,
>> it will be power off when the system doing suspend 2 resume.
>> (Because the system call
>> __device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)
>
>
> Thanks for explaining this. I checked the code a bit and actually I
> don't need to updata clkmul since it was recorded, although it is still
> reset to 0x10 reading from syscon. So for that, we can now pick it
> up without waiting for my sdhci-of-arasan's update.
>
> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>

This is fine to pick up _only_ if you don't care about suspend/resume.
If you care about suspend/resume then someone needs to first write a
patch that will re-init all "corecfg" values after power is turned on.

Technically I think this should probably use "pm runtime" and not
normal suspend/resume hooks.  Any time we end up pm runtime suspended
then I think our power will go off (because of genpd?) and we need to
restore values.

I'm not sure if this should be done in a generic way where we try to
save and restore all values in the "sdhci_arasan_soc_ctl_map" or if we
should try to be smarter...


-Doug
ziyuan Sept. 1, 2016, 2:29 a.m. UTC | #6
Hi,


On 2016年09月01日 01:42, Doug Anderson wrote:
> Hi,
>
> On Sun, Aug 28, 2016 at 8:25 PM, Shawn Lin <shawn.lin@rock-chips.com> wrote:
>> On 2016/8/29 10:50, Elaine Zhang wrote:
>>>
>>>
>>> On 08/27/2016 11:05 PM, Shawn Lin wrote:
>>>> On 2016/8/27 21:41, Ziyuan Xu wrote:
>>>>> Control power domain for eMMC via genpd to reduce power consumption.
>>>>>
>>>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>>>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>>>>
>>>> It looks nice to me. But this should be merged after applying that[0]
>>>> as your patch will break bind/unbind test for sdhci-of-arasan on rk3399
>>>> without it[0]. Moreover, Elaine should make sure that upstreamed
>>>> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
>>>> should update my patch to make sure we update clkmul every time when
>>>> doing suspend 2 resume..
>>>>
>>>>
>>> Forgot to say:
>>> If use pd, Although there is no call to power odd the pd_emmc,
>>> it will be power off when the system doing suspend 2 resume.
>>> (Because the system call
>>> __device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)
>>
>> Thanks for explaining this. I checked the code a bit and actually I
>> don't need to updata clkmul since it was recorded, although it is still
>> reset to 0x10 reading from syscon. So for that, we can now pick it
>> up without waiting for my sdhci-of-arasan's update.
>>
>> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> This is fine to pick up _only_ if you don't care about suspend/resume.
> If you care about suspend/resume then someone needs to first write a
> patch that will re-init all "corecfg" values after power is turned on.

Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we 
don't need to strore/re-init it after resume.
corecfg_clockmultiplier is only used to fetch host->clk_mul, and 
host->clk_mul has been a fixed value at run-time, unless driver unbind.
The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to 
check the xin_clk at probe time, we don't reference it at run-time.
BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC 
works fine.

>
> Technically I think this should probably use "pm runtime" and not
> normal suspend/resume hooks.  Any time we end up pm runtime suspended
> then I think our power will go off (because of genpd?) and we need to
> restore values.

I understand your consideration. BUT genpd is in charge of on/off pd if 
the corresponding device node has "power-domains" property. RPM is 
unnecessary for this situation, we will not use autosuspend, right?

@shawn, what's your opinion?

>
> I'm not sure if this should be done in a generic way where we try to
> save and restore all values in the "sdhci_arasan_soc_ctl_map" or if we
> should try to be smarter...
>
>
> -Doug
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>
>
>
Shawn Lin Sept. 1, 2016, 3:23 a.m. UTC | #7
在 2016/9/1 10:29, Ziyuan Xu 写道:
> Hi,
>
>
> On 2016年09月01日 01:42, Doug Anderson wrote:
>> Hi,
>>
>> On Sun, Aug 28, 2016 at 8:25 PM, Shawn Lin <shawn.lin@rock-chips.com>
>> wrote:
>>> On 2016/8/29 10:50, Elaine Zhang wrote:
>>>>
>>>>
>>>> On 08/27/2016 11:05 PM, Shawn Lin wrote:
>>>>> On 2016/8/27 21:41, Ziyuan Xu wrote:
>>>>>> Control power domain for eMMC via genpd to reduce power consumption.
>>>>>>
>>>>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>>>>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>>>>>
>>>>> It looks nice to me. But this should be merged after applying that[0]
>>>>> as your patch will break bind/unbind test for sdhci-of-arasan on
>>>>> rk3399
>>>>> without it[0]. Moreover, Elaine should make sure that upstreamed
>>>>> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
>>>>> should update my patch to make sure we update clkmul every time when
>>>>> doing suspend 2 resume..
>>>>>
>>>>>
>>>> Forgot to say:
>>>> If use pd, Although there is no call to power odd the pd_emmc,
>>>> it will be power off when the system doing suspend 2 resume.
>>>> (Because the system call
>>>> __device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)
>>>
>>> Thanks for explaining this. I checked the code a bit and actually I
>>> don't need to updata clkmul since it was recorded, although it is still
>>> reset to 0x10 reading from syscon. So for that, we can now pick it
>>> up without waiting for my sdhci-of-arasan's update.
>>>
>>> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>> This is fine to pick up _only_ if you don't care about suspend/resume.
>> If you care about suspend/resume then someone needs to first write a
>> patch that will re-init all "corecfg" values after power is turned on.
>
> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
> don't need to strore/re-init it after resume.
> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
> host->clk_mul has been a fixed value at run-time, unless driver unbind.
> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to
> check the xin_clk at probe time, we don't reference it at run-time.

correct. That is why we don't need to update it even we power off pd.

> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC
> works fine.
>
>>
>> Technically I think this should probably use "pm runtime" and not
>> normal suspend/resume hooks.  Any time we end up pm runtime suspended
>> then I think our power will go off (because of genpd?) and we need to
>> restore values.
>
> I understand your consideration. BUT genpd is in charge of on/off pd if
> the corresponding device node has "power-domains" property. RPM is
> unnecessary for this situation, we will not use autosuspend, right?

That is irrelevant to rpm as what we need is just to control genpd here.
If we need to support rmp, we need some extra patches to do it,
including genpd off, clk-disable, etc...

>
> @shawn, what's your opinion?
>
>>
>> I'm not sure if this should be done in a generic way where we try to
>> save and restore all values in the "sdhci_arasan_soc_ctl_map" or if we
>> should try to be smarter...

I am prone to keep it as-is, unless we see a stronge requirement for
coming users who argue that they have some extra corecfg_* need to
recovery due to whatever reason.:)

If we see something like this:

if(of_device_is_compatible(A))
  	update X
else if (of_device_is_compatible(B))
	update Y
.....

Then we could consider trying to save & restrore all the values.


>>
>>
>> -Doug
>>
>> _______________________________________________
>> Linux-rockchip mailing list
>> Linux-rockchip@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>>
>>
>>
>
>
>
>
Doug Anderson Sept. 1, 2016, 4:20 a.m. UTC | #8
Hi,

On Wed, Aug 31, 2016 at 7:29 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>> This is fine to pick up _only_ if you don't care about suspend/resume.
>> If you care about suspend/resume then someone needs to first write a
>> patch that will re-init all "corecfg" values after power is turned on.
>
>
> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
> don't need to strore/re-init it after resume.
> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
> host->clk_mul has been a fixed value at run-time, unless driver unbind.
> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to check
> the xin_clk at probe time, we don't reference it at run-time.
> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC works
> fine.

I guess I don't actually know how the corecfg_clockmultiplier and
corecfg_baseclkfreq fields are actually used, but I presume that they
actually do something useful and aren't used to just communicate back
to software?

I know that:

1. If I don't pick this patch and I suspend/resume,
corecfg_clockmultiplier and corecfg_baseclkfreq are still fine after
suspend / resume.

2. If I do pick this patch and I suspend/resume,
corecfg_clockmultiplier and corecfg_baseclkfreq are wrong after
suspend/resume (tested by reading /dev/mem directly from userspace
after suspend/resume).


Are you saying that it is unimportant that corecfg_clockmultiplier and
corecfg_baseclkfreq are wrong?

>> Technically I think this should probably use "pm runtime" and not
>> normal suspend/resume hooks.  Any time we end up pm runtime suspended
>> then I think our power will go off (because of genpd?) and we need to
>> restore values.
>
>
> I understand your consideration. BUT genpd is in charge of on/off pd if the
> corresponding device node has "power-domains" property. RPM is unnecessary
> for this situation, we will not use autosuspend, right?
>
> @shawn, what's your opinion?

I haven't dug.  If Runtime PM isn't enabled for sdhci-of-arasan then I
guess we can just worry about suspend/resume, though.

-Doug
ziyuan Sept. 1, 2016, 6:56 a.m. UTC | #9
Hi


On 2016年09月01日 12:20, Doug Anderson wrote:
> Hi,
>
> On Wed, Aug 31, 2016 at 7:29 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>>> This is fine to pick up _only_ if you don't care about suspend/resume.
>>> If you care about suspend/resume then someone needs to first write a
>>> patch that will re-init all "corecfg" values after power is turned on.
>>
>> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
>> don't need to strore/re-init it after resume.
>> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
>> host->clk_mul has been a fixed value at run-time, unless driver unbind.
>> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to check
>> the xin_clk at probe time, we don't reference it at run-time.
>> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC works
>> fine.
> I guess I don't actually know how the corecfg_clockmultiplier and
> corecfg_baseclkfreq fields are actually used, but I presume that they
> actually do something useful and aren't used to just communicate back
> to software?

Take corecfg_clockmultiplier as example.
1. sdhci driver fetch host->clk_mul from corecfg_clockmultiplier
2. mmc->f_min and mmc->f_max are calculated via host->clk_mul, they're 
used for further initialization.
3. if the corecfg_clockmultiplier is incorrect, sdhci will use improper 
frequency to play.

I think we don't need to store it due to it's a fixed value at run-time, 
even if it is reset after a power cycle, the above will not be changed 
via software, except for dirver unbind .

>
> I know that:
>
> 1. If I don't pick this patch and I suspend/resume,
> corecfg_clockmultiplier and corecfg_baseclkfreq are still fine after
> suspend / resume.
>
> 2. If I do pick this patch and I suspend/resume,
> corecfg_clockmultiplier and corecfg_baseclkfreq are wrong after
> suspend/resume (tested by reading /dev/mem directly from userspace
> after suspend/resume).
>
>
> Are you saying that it is unimportant that corecfg_clockmultiplier and
> corecfg_baseclkfreq are wrong?

Yup, corecfg_* stuff will be reset after a power cycle.
I mean that we need only to guarantee they're correct at probe time.

>
>>> Technically I think this should probably use "pm runtime" and not
>>> normal suspend/resume hooks.  Any time we end up pm runtime suspended
>>> then I think our power will go off (because of genpd?) and we need to
>>> restore values.
>>
>> I understand your consideration. BUT genpd is in charge of on/off pd if the
>> corresponding device node has "power-domains" property. RPM is unnecessary
>> for this situation, we will not use autosuspend, right?
>>
>> @shawn, what's your opinion?
> I haven't dug.  If Runtime PM isn't enabled for sdhci-of-arasan then I
> guess we can just worry about suspend/resume, though.
>
> -Doug
>
>
>
Ulf Hansson Sept. 1, 2016, 1:45 p.m. UTC | #10
On 1 September 2016 at 05:23, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> 在 2016/9/1 10:29, Ziyuan Xu 写道:
>>
>> Hi,
>>
>>
>> On 2016年09月01日 01:42, Doug Anderson wrote:
>>>
>>> Hi,
>>>
>>> On Sun, Aug 28, 2016 at 8:25 PM, Shawn Lin <shawn.lin@rock-chips.com>
>>> wrote:
>>>>
>>>> On 2016/8/29 10:50, Elaine Zhang wrote:
>>>>>
>>>>>
>>>>>
>>>>> On 08/27/2016 11:05 PM, Shawn Lin wrote:
>>>>>>
>>>>>> On 2016/8/27 21:41, Ziyuan Xu wrote:
>>>>>>>
>>>>>>> Control power domain for eMMC via genpd to reduce power consumption.
>>>>>>>
>>>>>>> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
>>>>>>> Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
>>>>>>>
>>>>>> It looks nice to me. But this should be merged after applying that[0]
>>>>>> as your patch will break bind/unbind test for sdhci-of-arasan on
>>>>>> rk3399
>>>>>> without it[0]. Moreover, Elaine should make sure that upstreamed
>>>>>> rockchip power domain stuff would not off pd for emmc, *otherwise*, I
>>>>>> should update my patch to make sure we update clkmul every time when
>>>>>> doing suspend 2 resume..
>>>>>>
>>>>>>
>>>>> Forgot to say:
>>>>> If use pd, Although there is no call to power odd the pd_emmc,
>>>>> it will be power off when the system doing suspend 2 resume.
>>>>> (Because the system call
>>>>> __device_suspend_noirq->pm_genpd_suspend_noirq->rockchip_pd_power_off)
>>>>
>>>>
>>>> Thanks for explaining this. I checked the code a bit and actually I
>>>> don't need to updata clkmul since it was recorded, although it is still
>>>> reset to 0x10 reading from syscon. So for that, we can now pick it
>>>> up without waiting for my sdhci-of-arasan's update.
>>>>
>>>> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>>>
>>> This is fine to pick up _only_ if you don't care about suspend/resume.
>>> If you care about suspend/resume then someone needs to first write a
>>> patch that will re-init all "corecfg" values after power is turned on.
>>
>>
>> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
>> don't need to strore/re-init it after resume.
>> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
>> host->clk_mul has been a fixed value at run-time, unless driver unbind.
>> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to
>> check the xin_clk at probe time, we don't reference it at run-time.
>
>
> correct. That is why we don't need to update it even we power off pd.
>
>> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC
>> works fine.
>>
>>>
>>> Technically I think this should probably use "pm runtime" and not
>>> normal suspend/resume hooks.  Any time we end up pm runtime suspended
>>> then I think our power will go off (because of genpd?) and we need to
>>> restore values.
>>
>>
>> I understand your consideration. BUT genpd is in charge of on/off pd if
>> the corresponding device node has "power-domains" property. RPM is
>> unnecessary for this situation, we will not use autosuspend, right?
>
>
> That is irrelevant to rpm as what we need is just to control genpd here.
> If we need to support rmp, we need some extra patches to do it,
> including genpd off, clk-disable, etc...
>
>>
>> @shawn, what's your opinion?
>>
>>>
>>> I'm not sure if this should be done in a generic way where we try to
>>> save and restore all values in the "sdhci_arasan_soc_ctl_map" or if we
>>> should try to be smarter...
>
>
> I am prone to keep it as-is, unless we see a stronge requirement for
> coming users who argue that they have some extra corecfg_* need to
> recovery due to whatever reason.:)
>
> If we see something like this:
>
> if(of_device_is_compatible(A))
>         update X
> else if (of_device_is_compatible(B))
>         update Y
> .....
>
> Then we could consider trying to save & restrore all the values.
>
>

I was reading the discussion regarding this change and browsing the DT
documentation around this... Can you guys explain what really goes on
here, please.

To me, it seems like you are managing one device's resources in one
separate genpd. One genpd per device. Is that correct?

Perhaps each device actually has its own PM domain and thus it makes
sense to assign one genpd per device?

In other case, I would not recommend this method, mainly because my
experience tells me that it becomes hard to keep drivers portable from
a PM point of view, but also that it becomes tricky to optimize for
power savings.

No matter what, deploying runtime PM for the device's driver/bus is
important, as genpd relies on device's runtime PM status to be able to
take correct decisions.

My point is, start by deploying runtime PM in the driver, then deploy
system PM. Hopefully you can use the runtime PM centric approach, as
described here[1] and then get system PM support for "free".

Sorry for jumping into this discussions like this, I hope I don't add
too much of confusions.

Kind regards
Uffe

[1]
http://www.linaro.org/blog/core-dump/dont-waste-power-when-idle/
Doug Anderson Sept. 1, 2016, 9:29 p.m. UTC | #11
Hi,

On Wed, Aug 31, 2016 at 11:56 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
> Hi
>
>
> On 2016年09月01日 12:20, Doug Anderson wrote:
>>
>> Hi,
>>
>> On Wed, Aug 31, 2016 at 7:29 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>>>>
>>>> This is fine to pick up _only_ if you don't care about suspend/resume.
>>>> If you care about suspend/resume then someone needs to first write a
>>>> patch that will re-init all "corecfg" values after power is turned on.
>>>
>>>
>>> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
>>> don't need to strore/re-init it after resume.
>>> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
>>> host->clk_mul has been a fixed value at run-time, unless driver unbind.
>>> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to check
>>> the xin_clk at probe time, we don't reference it at run-time.
>>> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC
>>> works
>>> fine.
>>
>> I guess I don't actually know how the corecfg_clockmultiplier and
>> corecfg_baseclkfreq fields are actually used, but I presume that they
>> actually do something useful and aren't used to just communicate back
>> to software?
>
>
> Take corecfg_clockmultiplier as example.
> 1. sdhci driver fetch host->clk_mul from corecfg_clockmultiplier
> 2. mmc->f_min and mmc->f_max are calculated via host->clk_mul, they're used
> for further initialization.
> 3. if the corecfg_clockmultiplier is incorrect, sdhci will use improper
> frequency to play.
>
> I think we don't need to store it due to it's a fixed value at run-time,
> even if it is reset after a power cycle, the above will not be changed via
> software, except for dirver unbind .
>
>>
>> I know that:
>>
>> 1. If I don't pick this patch and I suspend/resume,
>> corecfg_clockmultiplier and corecfg_baseclkfreq are still fine after
>> suspend / resume.
>>
>> 2. If I do pick this patch and I suspend/resume,
>> corecfg_clockmultiplier and corecfg_baseclkfreq are wrong after
>> suspend/resume (tested by reading /dev/mem directly from userspace
>> after suspend/resume).
>>
>>
>> Are you saying that it is unimportant that corecfg_clockmultiplier and
>> corecfg_baseclkfreq are wrong?
>
>
> Yup, corecfg_* stuff will be reset after a power cycle.
> I mean that we need only to guarantee they're correct at probe time.

So are you saying that the entire purpose of "corecfg_clockmultiplier"
is that causes the "ClockMultiplier" field of the "EMMCCORE_CAP"
register to get a certain value?
...and that the entire purpose of "corecfg_baseclkfreq" is that it
causes the "BaseClockFreqSDClock" field of the "EMMCCORE_CAP" register
to get a certain value?

That would have been nice to know before.  I had assumed that those
"corecfg" settings did something else more useful.

If it is indeed true that these corecfg values are as silly as it
seems, then I guess it's not terribly important to re-set them after
suspend/resume.  Eventually it would be nice/clean to actually do so
(in case the SDHCI driver eventually changes), but I guess we wouldn't
need to block. this patch from landing.

Can you please confirm my understanding above?


-Doug
Doug Anderson Sept. 1, 2016, 9:50 p.m. UTC | #12
Hi,

On Thu, Sep 1, 2016 at 6:45 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> I was reading the discussion regarding this change and browsing the DT
> documentation around this... Can you guys explain what really goes on
> here, please.
>
> To me, it seems like you are managing one device's resources in one
> separate genpd. One genpd per device. Is that correct?
>
> Perhaps each device actually has its own PM domain and thus it makes
> sense to assign one genpd per device?

I'm not as familiar with genpd as I should be, so hopefully this makes sense.

...in hardware there is a "pd_emmc" that is the power domain for just
eMMC.  That will be referenced hooked up via device tree, like:

power-domains = <&power RK3399_PD_EMMC>;

I believe that means that power will automatically be removed whenever
the device is runtime suspended or suspended.

If w're not supporting "autosuspend" and nobody is tweaking anything
manually, then it's possible (I think) that runtime suspend happens at
exactly the same time as suspend.  ...but my point was that it was
cleaner to actually do it any restoring in the "runtime resume" hooks
to match what genpd does.  This matches what you say: use runtime PM.

...but it also sounds like it might not be terribly important to
restore these values since they're a bit silly to begin with.  If
that's true then I guess we don't need to do anything special here.


Did that all make sense (it's entirely possible it didn't since
somehow my brain still hasn't absorbed all runtime PM and genpd
concepts)

-Doug
ziyuan Sept. 2, 2016, 2:35 a.m. UTC | #13
On 2016年09月02日 05:29, Doug Anderson wrote:
> Hi,
>
> On Wed, Aug 31, 2016 at 11:56 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>> Hi
>>
>>
>> On 2016年09月01日 12:20, Doug Anderson wrote:
>>> Hi,
>>>
>>> On Wed, Aug 31, 2016 at 7:29 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>>>>> This is fine to pick up _only_ if you don't care about suspend/resume.
>>>>> If you care about suspend/resume then someone needs to first write a
>>>>> patch that will re-init all "corecfg" values after power is turned on.
>>>>
>>>> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
>>>> don't need to strore/re-init it after resume.
>>>> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
>>>> host->clk_mul has been a fixed value at run-time, unless driver unbind.
>>>> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to check
>>>> the xin_clk at probe time, we don't reference it at run-time.
>>>> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC
>>>> works
>>>> fine.
>>> I guess I don't actually know how the corecfg_clockmultiplier and
>>> corecfg_baseclkfreq fields are actually used, but I presume that they
>>> actually do something useful and aren't used to just communicate back
>>> to software?
>>
>> Take corecfg_clockmultiplier as example.
>> 1. sdhci driver fetch host->clk_mul from corecfg_clockmultiplier
>> 2. mmc->f_min and mmc->f_max are calculated via host->clk_mul, they're used
>> for further initialization.
>> 3. if the corecfg_clockmultiplier is incorrect, sdhci will use improper
>> frequency to play.
>>
>> I think we don't need to store it due to it's a fixed value at run-time,
>> even if it is reset after a power cycle, the above will not be changed via
>> software, except for dirver unbind .
>>
>>> I know that:
>>>
>>> 1. If I don't pick this patch and I suspend/resume,
>>> corecfg_clockmultiplier and corecfg_baseclkfreq are still fine after
>>> suspend / resume.
>>>
>>> 2. If I do pick this patch and I suspend/resume,
>>> corecfg_clockmultiplier and corecfg_baseclkfreq are wrong after
>>> suspend/resume (tested by reading /dev/mem directly from userspace
>>> after suspend/resume).
>>>
>>>
>>> Are you saying that it is unimportant that corecfg_clockmultiplier and
>>> corecfg_baseclkfreq are wrong?
>>
>> Yup, corecfg_* stuff will be reset after a power cycle.
>> I mean that we need only to guarantee they're correct at probe time.
> So are you saying that the entire purpose of "corecfg_clockmultiplier"
> is that causes the "ClockMultiplier" field of the "EMMCCORE_CAP"
> register to get a certain value?
> ...and that the entire purpose of "corecfg_baseclkfreq" is that it
> causes the "BaseClockFreqSDClock" field of the "EMMCCORE_CAP" register
> to get a certain value?
Yes, on rk3399:
corecfg_clockmultiplier <===> EMMCCORE_CAP1[23:16] ClockMultiplier
corecfg_baseclkfreq <===> EMMCCORE_CAP[15:8] BaseClockFreqSDClock

If you re-write to either corecfg_* stuff,  the corresponding CAP 
register field will be changed too.
sdhci driver will fetch CAP register for initialization, we only need to 
guarantee they're correct at probe time.

Did that all make sense?
>
> That would have been nice to know before.  I had assumed that those
> "corecfg" settings did something else more useful.
>
> If it is indeed true that these corecfg values are as silly as it
> seems, then I guess it's not terribly important to re-set them after
> suspend/resume.  Eventually it would be nice/clean to actually do so
> (in case the SDHCI driver eventually changes), but I guess we wouldn't
> need to block. this patch from landing.
>
> Can you please confirm my understanding above?
>
>
> -Doug
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
Doug Anderson Sept. 2, 2016, 5:22 a.m. UTC | #14
Hi,

On Thu, Sep 1, 2016 at 7:35 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>
>
> On 2016年09月02日 05:29, Doug Anderson wrote:
>>
>> Hi,
>>
>> On Wed, Aug 31, 2016 at 11:56 PM, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
>>>
>>> Hi
>>>
>>>
>>> On 2016年09月01日 12:20, Doug Anderson wrote:
>>>>
>>>> Hi,
>>>>
>>>> On Wed, Aug 31, 2016 at 7:29 PM, Ziyuan Xu <xzy.xu@rock-chips.com>
>>>> wrote:
>>>>>>
>>>>>> This is fine to pick up _only_ if you don't care about suspend/resume.
>>>>>> If you care about suspend/resume then someone needs to first write a
>>>>>> patch that will re-init all "corecfg" values after power is turned on.
>>>>>
>>>>>
>>>>> Do you mean corecfg_clockmultiplier and corecfg_baseclkfreq, if yes, we
>>>>> don't need to strore/re-init it after resume.
>>>>> corecfg_clockmultiplier is only used to fetch host->clk_mul, and
>>>>> host->clk_mul has been a fixed value at run-time, unless driver unbind.
>>>>> The same as corecfg_clockmultiplier, corecfg_baseclkfreq is used to
>>>>> check
>>>>> the xin_clk at probe time, we don't reference it at run-time.
>>>>> BTW, I have tested suspend/resume on rk3399 prior to this sumbit, eMMC
>>>>> works
>>>>> fine.
>>>>
>>>> I guess I don't actually know how the corecfg_clockmultiplier and
>>>> corecfg_baseclkfreq fields are actually used, but I presume that they
>>>> actually do something useful and aren't used to just communicate back
>>>> to software?
>>>
>>>
>>> Take corecfg_clockmultiplier as example.
>>> 1. sdhci driver fetch host->clk_mul from corecfg_clockmultiplier
>>> 2. mmc->f_min and mmc->f_max are calculated via host->clk_mul, they're
>>> used
>>> for further initialization.
>>> 3. if the corecfg_clockmultiplier is incorrect, sdhci will use improper
>>> frequency to play.
>>>
>>> I think we don't need to store it due to it's a fixed value at run-time,
>>> even if it is reset after a power cycle, the above will not be changed
>>> via
>>> software, except for dirver unbind .
>>>
>>>> I know that:
>>>>
>>>> 1. If I don't pick this patch and I suspend/resume,
>>>> corecfg_clockmultiplier and corecfg_baseclkfreq are still fine after
>>>> suspend / resume.
>>>>
>>>> 2. If I do pick this patch and I suspend/resume,
>>>> corecfg_clockmultiplier and corecfg_baseclkfreq are wrong after
>>>> suspend/resume (tested by reading /dev/mem directly from userspace
>>>> after suspend/resume).
>>>>
>>>>
>>>> Are you saying that it is unimportant that corecfg_clockmultiplier and
>>>> corecfg_baseclkfreq are wrong?
>>>
>>>
>>> Yup, corecfg_* stuff will be reset after a power cycle.
>>> I mean that we need only to guarantee they're correct at probe time.
>>
>> So are you saying that the entire purpose of "corecfg_clockmultiplier"
>> is that causes the "ClockMultiplier" field of the "EMMCCORE_CAP"
>> register to get a certain value?
>> ...and that the entire purpose of "corecfg_baseclkfreq" is that it
>> causes the "BaseClockFreqSDClock" field of the "EMMCCORE_CAP" register
>> to get a certain value?
>
> Yes, on rk3399:
> corecfg_clockmultiplier <===> EMMCCORE_CAP1[23:16] ClockMultiplier
> corecfg_baseclkfreq <===> EMMCCORE_CAP[15:8] BaseClockFreqSDClock
>
> If you re-write to either corecfg_* stuff,  the corresponding CAP register
> field will be changed too.
> sdhci driver will fetch CAP register for initialization, we only need to
> guarantee they're correct at probe time.
>
> Did that all make sense?

Yes.  Very odd, but it makes sense.

It would still be nice to get these restored after runtime resume just
for cleanliness, but it's not a blocker IMHO.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Ulf Hansson Sept. 2, 2016, 10:24 a.m. UTC | #15
On 1 September 2016 at 23:50, Doug Anderson <dianders@chromium.org> wrote:
> Hi,
>
> On Thu, Sep 1, 2016 at 6:45 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> I was reading the discussion regarding this change and browsing the DT
>> documentation around this... Can you guys explain what really goes on
>> here, please.
>>
>> To me, it seems like you are managing one device's resources in one
>> separate genpd. One genpd per device. Is that correct?
>>
>> Perhaps each device actually has its own PM domain and thus it makes
>> sense to assign one genpd per device?
>
> I'm not as familiar with genpd as I should be, so hopefully this makes sense.
>
> ...in hardware there is a "pd_emmc" that is the power domain for just
> eMMC.  That will be referenced hooked up via device tree, like:
>
> power-domains = <&power RK3399_PD_EMMC>;

Yes, I noticed that and this is what puzzles me a bit.

>
> I believe that means that power will automatically be removed whenever
> the device is runtime suspended or suspended.

Well, it depends if the genpd has a subdomain or other devices in it
being runtime resumed.
The genpd will not power off unless all devices within it are runtime
enabled+suspended and that its subdomains are also powered off.

So, in case you only have one device and no subdomains, then your
statement is correct.

>
> If w're not supporting "autosuspend" and nobody is tweaking anything

I guess you mean runtime PM autosuspend? Then why don't you support this?

Wouldn't that allow you to avoid wasting power in runtime when the
device is idle?

> manually, then it's possible (I think) that runtime suspend happens at
> exactly the same time as suspend.  ...but my point was that it was

I am not sure I follow you here. You must not rely on that the device
always becomes runtime suspended during system suspend, as there are
no guarantees for this.

Instead that is something you need to take care of in the
subsystem/driver for the device, of course.

> cleaner to actually do it any restoring in the "runtime resume" hooks
> to match what genpd does.  This matches what you say: use runtime PM.

Yes!

Using genpd without deploying runtime PM for the devices doesn't make
much sense, at least to me.

>
> ...but it also sounds like it might not be terribly important to
> restore these values since they're a bit silly to begin with.  If
> that's true then I guess we don't need to do anything special here.
>
>
> Did that all make sense (it's entirely possible it didn't since
> somehow my brain still hasn't absorbed all runtime PM and genpd
> concepts)

No worries. I understand this might be a bit tricky, that's why I also
tries to help review related changes.

Kind regards
Uffe
ziyuan Sept. 2, 2016, 2:23 p.m. UTC | #16
Hi Ulf,


On 2016年09月02日 18:24, Ulf Hansson wrote:
> On 1 September 2016 at 23:50, Doug Anderson<dianders@chromium.org>  wrote:
>> >Hi,
>> >
>> >On Thu, Sep 1, 2016 at 6:45 AM, Ulf Hansson<ulf.hansson@linaro.org>  wrote:
>>> >>I was reading the discussion regarding this change and browsing the DT
>>> >>documentation around this... Can you guys explain what really goes on
>>> >>here, please.
>>> >>
>>> >>To me, it seems like you are managing one device's resources in one
>>> >>separate genpd. One genpd per device. Is that correct?
>>> >>
>>> >>Perhaps each device actually has its own PM domain and thus it makes
>>> >>sense to assign one genpd per device?
>> >
>> >I'm not as familiar with genpd as I should be, so hopefully this makes sense.
>> >
>> >...in hardware there is a "pd_emmc" that is the power domain for just
>> >eMMC.  That will be referenced hooked up via device tree, like:
>> >
>> >power-domains = <&power RK3399_PD_EMMC>;
> Yes, I noticed that and this is what puzzles me a bit.
>
>> >
>> >I believe that means that power will automatically be removed whenever
>> >the device is runtime suspended or suspended.
> Well, it depends if the genpd has a subdomain or other devices in it
> being runtime resumed.
> The genpd will not power off unless all devices within it are runtime
> enabled+suspended and that its subdomains are also powered off.
>
> So, in case you only have one device and no subdomains, then your
> statement is correct.

Yup, pd_emmc is a individual power domain which is only deployed to eMMC 
on rk3399. It has no subdomains.

>
>> >
>> >If w're not supporting "autosuspend" and nobody is tweaking anything
> I guess you mean runtime PM autosuspend? Then why don't you support this?
>
> Wouldn't that allow you to avoid wasting power in runtime when the
> device is idle?

pd_emmc manages the sdhci controller, phy and corecfg_* stuff, if we 
support autosuspend in driver, we have to re-init context. I didn't test 
the latency, if it's acceptable, we will apply it.:-)
But it's not a blocker, right?

>
>> >manually, then it's possible (I think) that runtime suspend happens at
>> >exactly the same time as suspend.  ...but my point was that it was
> I am not sure I follow you here. You must not rely on that the device
> always becomes runtime suspended during system suspend, as there are
> no guarantees for this.
>
> Instead that is something you need to take care of in the
> subsystem/driver for the device, of course.
>
>> >cleaner to actually do it any restoring in the "runtime resume" hooks
>> >to match what genpd does.  This matches what you say: use runtime PM.
> Yes!
>
> Using genpd without deploying runtime PM for the devices doesn't make
> much sense, at least to me.
>
>> >
>> >...but it also sounds like it might not be terribly important to
>> >restore these values since they're a bit silly to begin with.  If
>> >that's true then I guess we don't need to do anything special here.
>> >
>> >
>> >Did that all make sense (it's entirely possible it didn't since
>> >somehow my brain still hasn't absorbed all runtime PM and genpd
>> >concepts)
> No worries. I understand this might be a bit tricky, that's why I also
> tries to help review related changes.
>
> Kind regards
> Uffe
>
>
>
Ulf Hansson Sept. 6, 2016, 12:34 p.m. UTC | #17
On 2 September 2016 at 16:23, Ziyuan Xu <xzy.xu@rock-chips.com> wrote:
> Hi Ulf,
>
>
> On 2016年09月02日 18:24, Ulf Hansson wrote:
>>
>> On 1 September 2016 at 23:50, Doug Anderson<dianders@chromium.org>  wrote:
>>>
>>> >Hi,
>>> >
>>> >On Thu, Sep 1, 2016 at 6:45 AM, Ulf Hansson<ulf.hansson@linaro.org>
>>> > wrote:
>>>>
>>>> >>I was reading the discussion regarding this change and browsing the DT
>>>> >>documentation around this... Can you guys explain what really goes on
>>>> >>here, please.
>>>> >>
>>>> >>To me, it seems like you are managing one device's resources in one
>>>> >>separate genpd. One genpd per device. Is that correct?
>>>> >>
>>>> >>Perhaps each device actually has its own PM domain and thus it makes
>>>> >>sense to assign one genpd per device?
>>>
>>> >
>>> >I'm not as familiar with genpd as I should be, so hopefully this makes
>>> > sense.
>>> >
>>> >...in hardware there is a "pd_emmc" that is the power domain for just
>>> >eMMC.  That will be referenced hooked up via device tree, like:
>>> >
>>> >power-domains = <&power RK3399_PD_EMMC>;
>>
>> Yes, I noticed that and this is what puzzles me a bit.
>>
>>> >
>>> >I believe that means that power will automatically be removed whenever
>>> >the device is runtime suspended or suspended.
>>
>> Well, it depends if the genpd has a subdomain or other devices in it
>> being runtime resumed.
>> The genpd will not power off unless all devices within it are runtime
>> enabled+suspended and that its subdomains are also powered off.
>>
>> So, in case you only have one device and no subdomains, then your
>> statement is correct.
>
>
> Yup, pd_emmc is a individual power domain which is only deployed to eMMC on
> rk3399. It has no subdomains.
>
>>
>>> >
>>> >If w're not supporting "autosuspend" and nobody is tweaking anything
>>
>> I guess you mean runtime PM autosuspend? Then why don't you support this?
>>
>> Wouldn't that allow you to avoid wasting power in runtime when the
>> device is idle?
>
>
> pd_emmc manages the sdhci controller, phy and corecfg_* stuff, if we support

Ohh, there are already mmc drivers dealing with phys. We can add this
for you driver as well.

Regarding corecfg_*, unless that also can be managed via a generic
interface (perhaps through syscon), then you need to manage that via
genpd. Is that the case?

> autosuspend in driver, we have to re-init context. I didn't test the

Yes, that's a common scenario, many device drivers do this - as to
avoid wasting power.

> latency, if it's acceptable, we will apply it.:-)

Latency constraints may be controlled via the genpd governor.

Moreover we also have the runtime PM autosuspend feature, which is
useful when you don't wont to runtime suspend the device between each
and every request. Thus avoiding latencies when there are a "burst" of
requests.

> But it's not a blocker, right?
>

Hmm, I just want to make sure we do the right things. Else it might
just bite us in the other end.

Again, my recommendation is to start with runtime PM then continue
with system PM. I can imagine you will get system PM "free" if using
the runtime PM centric approach.

Kind regards
Uffe
diff mbox

Patch

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 32aebc8..71733d4 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -239,6 +239,7 @@ 
 		#clock-cells = <0>;
 		phys = <&emmc_phy>;
 		phy-names = "phy_arasan";
+		power-domains = <&power RK3399_PD_EMMC>;
 		status = "disabled";
 	};
 
@@ -611,6 +612,11 @@ 
 		status = "disabled";
 	};
 
+	qos_emmc: qos@ffa58000 {
+		compatible = "syscon";
+		reg = <0x0 0xffa58000 0x0 0x20>;
+	};
+
 	qos_hdcp: qos@ffa90000 {
 		compatible = "syscon";
 		reg = <0x0 0xffa90000 0x0 0x20>;
@@ -739,6 +745,11 @@ 
 			};
 
 			/* These power domains are grouped by VD_LOGIC */
+			pd_emmc@RK3399_PD_EMMC {
+				reg = <RK3399_PD_EMMC>;
+				clocks = <&cru ACLK_EMMC>;
+				pm_qos = <&qos_emmc>;
+			};
 			pd_vio@RK3399_PD_VIO {
 				reg = <RK3399_PD_VIO>;
 				#address-cells = <1>;