mbox series

[v4,0/3] Add AHCI support for Tegra186

Message ID 1617758731-12380-1-git-send-email-skomatineni@nvidia.com
Headers show
Series Add AHCI support for Tegra186 | expand

Message

Sowjanya Komatineni April 7, 2021, 1:25 a.m. UTC
Re-sending dt-binding and ahci_tegra driver patches as v4 as device
tree patches from v3 are merged but not the AHCI Tegra driver.

Missed to add Jens Axboe to mailing list in v3. Adding for v4.

This series adds support for AHCI-compliant SATA to Tegra186 SoC.

This series includes patches for
- Converting text based dt-binding document to YAML.
- Adding dt-bindings for Tegra186.
- Adding Tegra186 support to Tegra AHCI driver.

Delta between patch versions:
[v4]:	Same as v3 except removed device tree patches as they are
	merged.
[v3]:	fixed yaml example to pass dt_binding_check
[v2]:	v1 feedback related to yaml dt-binding.
	Removed conditional reset order in yaml and updated dts files
	to maintain same order for commonly available resets across
	Tegra124 thru Tegra186.


Sowjanya Komatineni (3):
  dt-bindings: ata: tegra: Convert binding documentation to YAML
  dt-binding: ata: tegra: Add dt-binding documentation for Tegra186
  ata: ahci_tegra: Add AHCI support for Tegra186

 .../devicetree/bindings/ata/nvidia,tegra-ahci.yaml | 176 +++++++++++++++++++++
 .../bindings/ata/nvidia,tegra124-ahci.txt          |  44 ------
 drivers/ata/ahci_tegra.c                           |  60 +++++--
 3 files changed, 223 insertions(+), 57 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/nvidia,tegra-ahci.yaml
 delete mode 100644 Documentation/devicetree/bindings/ata/nvidia,tegra124-ahci.txt

Comments

Thierry Reding April 7, 2021, 3:04 p.m. UTC | #1
On Tue, Apr 06, 2021 at 06:25:30PM -0700, Sowjanya Komatineni wrote:
> This patch adds dt-bindings documentation for Tegra186 AHCI
> controller.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
> ---
>  .../devicetree/bindings/ata/nvidia,tegra-ahci.yaml | 38 ++++++++++++++++++++++
>  1 file changed, 38 insertions(+)

Acked-by: Thierry Reding <treding@nvidia.com>
Jens Axboe April 7, 2021, 3:44 p.m. UTC | #2
On 4/6/21 7:25 PM, Sowjanya Komatineni wrote:
> Re-sending dt-binding and ahci_tegra driver patches as v4 as device
> tree patches from v3 are merged but not the AHCI Tegra driver.
> 
> Missed to add Jens Axboe to mailing list in v3. Adding for v4.
> 
> This series adds support for AHCI-compliant SATA to Tegra186 SoC.
> 
> This series includes patches for
> - Converting text based dt-binding document to YAML.
> - Adding dt-bindings for Tegra186.
> - Adding Tegra186 support to Tegra AHCI driver.
> 
> Delta between patch versions:
> [v4]:	Same as v3 except removed device tree patches as they are
> 	merged.
> [v3]:	fixed yaml example to pass dt_binding_check
> [v2]:	v1 feedback related to yaml dt-binding.
> 	Removed conditional reset order in yaml and updated dts files
> 	to maintain same order for commonly available resets across
> 	Tegra124 thru Tegra186.

Assuming the libata tree is the best way for this to go in, so I applied
it for 5.13.
Thierry Reding April 7, 2021, 4:18 p.m. UTC | #3
On Wed, Apr 07, 2021 at 09:44:58AM -0600, Jens Axboe wrote:
> On 4/6/21 7:25 PM, Sowjanya Komatineni wrote:
> > Re-sending dt-binding and ahci_tegra driver patches as v4 as device
> > tree patches from v3 are merged but not the AHCI Tegra driver.
> > 
> > Missed to add Jens Axboe to mailing list in v3. Adding for v4.
> > 
> > This series adds support for AHCI-compliant SATA to Tegra186 SoC.
> > 
> > This series includes patches for
> > - Converting text based dt-binding document to YAML.
> > - Adding dt-bindings for Tegra186.
> > - Adding Tegra186 support to Tegra AHCI driver.
> > 
> > Delta between patch versions:
> > [v4]:	Same as v3 except removed device tree patches as they are
> > 	merged.
> > [v3]:	fixed yaml example to pass dt_binding_check
> > [v2]:	v1 feedback related to yaml dt-binding.
> > 	Removed conditional reset order in yaml and updated dts files
> > 	to maintain same order for commonly available resets across
> > 	Tegra124 thru Tegra186.
> 
> Assuming the libata tree is the best way for this to go in, so I applied
> it for 5.13.

Perfect! Thanks Jens.

Thierry
Sowjanya Komatineni April 7, 2021, 10:57 p.m. UTC | #4
On 4/7/21 2:36 PM, Dmitry Osipenko wrote:
> 07.04.2021 04:25, Sowjanya Komatineni пишет:
>> +	if (!tegra->pdev->dev.pm_domain) {
>> +		ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA,
>> +							tegra->sata_clk,
>> +							tegra->sata_rst);
>> +		if (ret)
>> +			goto disable_regulators;
>> +	}
>>   
> Hi,
>
> Why you haven't added condition for tegra_powergate_power_off()? I think
> it should break GENPD and legacy PD API isn't not supported by T186 at all.
>
> I'm also not sure whether the power up/down sequence is correct using GENPD.
>
> Moreover the driver doesn't support runtime PM, so GENPD should be
> always off?

This driver already using legacy PD API's so thought its supported and 
added power domain device check during powergate_sequence_power_up and 
yes same should apply for powergate_power_off as well. But if legacy PD 
is not supported by T186 then not sure why original driver even using 
these API's.

Preetham/Thierry, Can you please comment ?

But as RPM is not implemented yet for this driver, GENPD will be OFF but 
SATA is not in power-gate by the time kernel starts and functionally works.

But with RPM implementation, I guess we can do proper power gate on/off.
Sowjanya Komatineni April 7, 2021, 11 p.m. UTC | #5
On 4/7/21 3:57 PM, Sowjanya Komatineni wrote:
>
> On 4/7/21 2:36 PM, Dmitry Osipenko wrote:
>> 07.04.2021 04:25, Sowjanya Komatineni пишет:
>>> +    if (!tegra->pdev->dev.pm_domain) {
>>> +        ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA,
>>> +                            tegra->sata_clk,
>>> +                            tegra->sata_rst);
>>> +        if (ret)
>>> +            goto disable_regulators;
>>> +    }
>> Hi,
>>
>> Why you haven't added condition for tegra_powergate_power_off()? I think
>> it should break GENPD and legacy PD API isn't not supported by T186 
>> at all.
>>
>> I'm also not sure whether the power up/down sequence is correct using 
>> GENPD.
>>
>> Moreover the driver doesn't support runtime PM, so GENPD should be
>> always off?
>
> This driver already using legacy PD API's so thought its supported and 
> added power domain device check during powergate_sequence_power_up and 
> yes same should apply for powergate_power_off as well. But if legacy 
> PD is not supported by T186 then not sure why original driver even 
> using these API's.
>
>
Sorry just took a look and driver supports T210 and prior tegra as well. 
T210 and prior supports legacy PD and this check is applicable for 
those. So we should add power domain device check for power off as well.

But for T186, we should have GENPD working once we add runtime PM 
support to driver.

Preetham/Thierry, Can you confirm where SATA is un powergated prior to 
kernel?


> But as RPM is not implemented yet for this driver, GENPD will be OFF 
> but SATA is not in power-gate by the time kernel starts and 
> functionally works.
>
> But with RPM implementation, I guess we can do proper power gate on/off.
>
Thierry Reding April 8, 2021, 1:06 p.m. UTC | #6
On Thu, Apr 08, 2021 at 02:25:19AM +0300, Dmitry Osipenko wrote:
> 08.04.2021 02:00, Sowjanya Komatineni пишет:

> > 

> > On 4/7/21 3:57 PM, Sowjanya Komatineni wrote:

> >>

> >> On 4/7/21 2:36 PM, Dmitry Osipenko wrote:

> >>> 07.04.2021 04:25, Sowjanya Komatineni пишет:

> >>>> +    if (!tegra->pdev->dev.pm_domain) {

> >>>> +        ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA,

> >>>> +                            tegra->sata_clk,

> >>>> +                            tegra->sata_rst);

> >>>> +        if (ret)

> >>>> +            goto disable_regulators;

> >>>> +    }

> >>> Hi,

> >>>

> >>> Why you haven't added condition for tegra_powergate_power_off()? I think

> >>> it should break GENPD and legacy PD API isn't not supported by T186

> >>> at all.

> >>>

> >>> I'm also not sure whether the power up/down sequence is correct using

> >>> GENPD.

> >>>

> >>> Moreover the driver doesn't support runtime PM, so GENPD should be

> >>> always off?

> >>

> >> This driver already using legacy PD API's so thought its supported and

> >> added power domain device check during powergate_sequence_power_up and

> >> yes same should apply for powergate_power_off as well. But if legacy

> >> PD is not supported by T186 then not sure why original driver even

> >> using these API's.

> >>

> >>

> > Sorry just took a look and driver supports T210 and prior tegra as well.

> > T210 and prior supports legacy PD and this check is applicable for

> > those. So we should add power domain device check for power off as well.

> 

> You could fix it with a follow up patch. Please try to test that

> power-off works properly, at least try to unload the driver module and

> re-load it.


Agreed, this should have the same check as above for
tegra_powergate_power_off(). It currently works fine because on Tegra186
tegra_powergate_power_off() (and all the other legacy APIs for that
matter) will abort early since no power gates are implemented. The AHCI
driver doesn't check for errors, so this will just fail silently. It's
better to be symmetric, though, and add the check in both paths.

> > But for T186, we should have GENPD working once we add runtime PM

> > support to driver.

> > 

> > Preetham/Thierry, Can you confirm where SATA is un powergated prior to

> > kernel?

> > 

> > 

> >> But as RPM is not implemented yet for this driver, GENPD will be OFF

> >> but SATA is not in power-gate by the time kernel starts and

> >> functionally works.

> >>

> >> But with RPM implementation, I guess we can do proper power gate on/off.

> >>

> 

> I now recalled that GENPD turns ON all domains by default and then turns

> them OFF only when driver entered into the RPM-suspended state. This

> means that AHCI GENPD should be always-ON for T186, which should be okay

> if this doesn't break power sequences.


Yeah, the generic PM domain will just stay enabled after probe and until
remove. This does not impact the power sequences because they have to be
completely implemented in the power domains code anyway. With the legacy
API we used to need more rigorous sequences in the individual drivers,
but with generic PM domains none of that should be necessary, though it
also doesn't hurt, so some of the unnecessary clock enablement code is
kept for simplicity.

To be honest, I'm not sure if it's worth adding runtime PM support for
this driver. If this top-level layer has a way of getting notification
when no device was detected, then it might make some sense to turn off
the power domain and the regulators again, but I'm not sure if that's
the case. tegra_ahci_host_stop() seems like it might be usable for that
so yeah, that might work. We currently do turn off the powergate in that
case, so extending that power optimization to Tegra186 using runtime PM
makes sense.

Thierry
Dmitry Osipenko April 8, 2021, 2:41 p.m. UTC | #7
08.04.2021 16:06, Thierry Reding пишет:
> On Thu, Apr 08, 2021 at 02:25:19AM +0300, Dmitry Osipenko wrote:

>> 08.04.2021 02:00, Sowjanya Komatineni пишет:

>>>

>>> On 4/7/21 3:57 PM, Sowjanya Komatineni wrote:

>>>>

>>>> On 4/7/21 2:36 PM, Dmitry Osipenko wrote:

>>>>> 07.04.2021 04:25, Sowjanya Komatineni пишет:

>>>>>> +    if (!tegra->pdev->dev.pm_domain) {

>>>>>> +        ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA,

>>>>>> +                            tegra->sata_clk,

>>>>>> +                            tegra->sata_rst);

>>>>>> +        if (ret)

>>>>>> +            goto disable_regulators;

>>>>>> +    }

>>>>> Hi,

>>>>>

>>>>> Why you haven't added condition for tegra_powergate_power_off()? I think

>>>>> it should break GENPD and legacy PD API isn't not supported by T186

>>>>> at all.

>>>>>

>>>>> I'm also not sure whether the power up/down sequence is correct using

>>>>> GENPD.

>>>>>

>>>>> Moreover the driver doesn't support runtime PM, so GENPD should be

>>>>> always off?

>>>>

>>>> This driver already using legacy PD API's so thought its supported and

>>>> added power domain device check during powergate_sequence_power_up and

>>>> yes same should apply for powergate_power_off as well. But if legacy

>>>> PD is not supported by T186 then not sure why original driver even

>>>> using these API's.

>>>>

>>>>

>>> Sorry just took a look and driver supports T210 and prior tegra as well.

>>> T210 and prior supports legacy PD and this check is applicable for

>>> those. So we should add power domain device check for power off as well.

>>

>> You could fix it with a follow up patch. Please try to test that

>> power-off works properly, at least try to unload the driver module and

>> re-load it.

> 

> Agreed, this should have the same check as above for

> tegra_powergate_power_off(). It currently works fine because on Tegra186

> tegra_powergate_power_off() (and all the other legacy APIs for that

> matter) will abort early since no power gates are implemented. The AHCI

> driver doesn't check for errors, so this will just fail silently. It's

> better to be symmetric, though, and add the check in both paths.


I missed that tegra_powergate_power_off() usage isn't fatal if GENPD is
used, thank you for the clarification.

>>> But for T186, we should have GENPD working once we add runtime PM

>>> support to driver.

>>>

>>> Preetham/Thierry, Can you confirm where SATA is un powergated prior to

>>> kernel?

>>>

>>>

>>>> But as RPM is not implemented yet for this driver, GENPD will be OFF

>>>> but SATA is not in power-gate by the time kernel starts and

>>>> functionally works.

>>>>

>>>> But with RPM implementation, I guess we can do proper power gate on/off.

>>>>

>>

>> I now recalled that GENPD turns ON all domains by default and then turns

>> them OFF only when driver entered into the RPM-suspended state. This

>> means that AHCI GENPD should be always-ON for T186, which should be okay

>> if this doesn't break power sequences.

> 

> Yeah, the generic PM domain will just stay enabled after probe and until

> remove. This does not impact the power sequences because they have to be

> completely implemented in the power domains code anyway. With the legacy

> API we used to need more rigorous sequences in the individual drivers,

> but with generic PM domains none of that should be necessary, though it

> also doesn't hurt, so some of the unnecessary clock enablement code is

> kept for simplicity.

> 

> To be honest, I'm not sure if it's worth adding runtime PM support for

> this driver. If this top-level layer has a way of getting notification

> when no device was detected, then it might make some sense to turn off

> the power domain and the regulators again, but I'm not sure if that's

> the case. tegra_ahci_host_stop() seems like it might be usable for that

> so yeah, that might work. We currently do turn off the powergate in that

> case, so extending that power optimization to Tegra186 using runtime PM

> makes sense.


Alright, then this all should be good as-is.