Subject: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

There is no need to have a property that activates the inline crypto
boost feature, as this needs many things: a regulator, three clocks,
and the mediatek,boost-crypt-microvolt property to be set.

If any one of these is missing, the feature won't be activated,
hence, it is useless to have yet one more property to enable that.

While at it, also address another two issues:
1. Give back the return value to the caller and make sure to fail
probing if we get an -EPROBE_DEFER or -ENOMEM; and
2. Free the ufs_mtk_crypt_cfg structure allocated in the crypto
boost function if said functionality could not be enabled because
it's not supported, as that'd be only wasted memory.

Last but not least, move the devm_kzalloc() call for ufs_mtk_crypt_cfg
to after getting the dvfsrc-vcore regulator and the boost microvolt
property, as if those fail there's no reason to even allocate that.

Fixes: ac8c2459091c ("scsi: ufs-mediatek: Decouple features from platform bindings")
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/ufs/host/ufs-mediatek.c | 55 ++++++++++++++++++---------------
1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 688d85909ad6..47f16e6720f4 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -575,51 +575,55 @@ static int ufs_mtk_init_host_clk(struct ufs_hba *hba, const char *name,
return ret;
}

-static void ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
+static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct ufs_mtk_crypt_cfg *cfg;
struct device *dev = hba->dev;
struct regulator *reg;
u32 volt;
-
- host->crypt = devm_kzalloc(dev, sizeof(*(host->crypt)),
- GFP_KERNEL);
- if (!host->crypt)
- goto disable_caps;
+ int ret;

reg = devm_regulator_get_optional(dev, "dvfsrc-vcore");
if (IS_ERR(reg)) {
- dev_info(dev, "failed to get dvfsrc-vcore: %ld",
- PTR_ERR(reg));
- goto disable_caps;
+ ret = PTR_ERR(reg);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+
+ return 0;
}

- if (of_property_read_u32(dev->of_node, "mediatek,boost-crypt-microvolt",
- &volt)) {
+ ret = of_property_read_u32(dev->of_node, "mediatek,boost-crypt-microvolt", &volt);
+ if (ret) {
dev_info(dev, "failed to get mediatek,boost-crypt-microvolt");
- goto disable_caps;
+ return 0;
}

+ host->crypt = devm_kzalloc(dev, sizeof(*host->crypt), GFP_KERNEL);
+ if (!host->crypt)
+ return -ENOMEM;
+
cfg = host->crypt;
- if (ufs_mtk_init_host_clk(hba, "crypt_mux",
- &cfg->clk_crypt_mux))
- goto disable_caps;
+ ret = ufs_mtk_init_host_clk(hba, "crypt_mux", &cfg->clk_crypt_mux);
+ if (ret)
+ goto out;

- if (ufs_mtk_init_host_clk(hba, "crypt_lp",
- &cfg->clk_crypt_lp))
- goto disable_caps;
+ ret = ufs_mtk_init_host_clk(hba, "crypt_lp", &cfg->clk_crypt_lp);
+ if (ret)
+ goto out;

- if (ufs_mtk_init_host_clk(hba, "crypt_perf",
- &cfg->clk_crypt_perf))
- goto disable_caps;
+ ret = ufs_mtk_init_host_clk(hba, "crypt_perf", &cfg->clk_crypt_perf);
+ if (ret)
+ goto out;

cfg->reg_vcore = reg;
cfg->vcore_volt = volt;
host->caps |= UFS_MTK_CAP_BOOST_CRYPT_ENGINE;

-disable_caps:
- return;
+out:
+ if (ret)
+ devm_kfree(dev, host->crypt);
+ return 0;
}

static int ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba)
@@ -648,8 +652,9 @@ static int ufs_mtk_init_host_caps(struct ufs_hba *hba)
struct device_node *np = hba->dev->of_node;
int ret;

- if (of_property_read_bool(np, "mediatek,ufs-boost-crypt"))
- ufs_mtk_init_boost_crypt(hba);
+ ret = ufs_mtk_init_boost_crypt(hba);
+ if (ret)
+ return ret;

ret = ufs_mtk_init_va09_pwr_ctrl(hba);
if (ret)
--
2.44.0



2024-04-16 07:03:41

by Peter Wang (王信友)

[permalink] [raw]
Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

On Mon, 2024-04-15 at 13:00 +0200, AngeloGioacchino Del Regno wrote:
> There is no need to have a property that activates the inline crypto
> boost feature, as this needs many things: a regulator, three clocks,
> and the mediatek,boost-crypt-microvolt property to be set.
>
> If any one of these is missing, the feature won't be activated,
> hence, it is useless to have yet one more property to enable that.
>
> While at it, also address another two issues:
> 1. Give back the return value to the caller and make sure to fail
> probing if we get an -EPROBE_DEFER or -ENOMEM; and
> 2. Free the ufs_mtk_crypt_cfg structure allocated in the crypto
> boost function if said functionality could not be enabled because
> it's not supported, as that'd be only wasted memory.
>
> Last but not least, move the devm_kzalloc() call for
> ufs_mtk_crypt_cfg
> to after getting the dvfsrc-vcore regulator and the boost microvolt
> property, as if those fail there's no reason to even allocate that.
>
> Fixes: ac8c2459091c ("scsi: ufs-mediatek: Decouple features from
> platform bindings")
> Signed-off-by: AngeloGioacchino Del Regno <
> [email protected]>
> ---
> drivers/ufs/host/ufs-mediatek.c | 55 ++++++++++++++++++-------------
> --
> 1 file changed, 30 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
> mediatek.c
> index 688d85909ad6..47f16e6720f4 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -575,51 +575,55 @@ static int ufs_mtk_init_host_clk(struct ufs_hba
> *hba, const char *name,
> return ret;
> }
>
> -static void ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
> +static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> struct ufs_mtk_crypt_cfg *cfg;
> struct device *dev = hba->dev;
> struct regulator *reg;
> u32 volt;
> -
> - host->crypt = devm_kzalloc(dev, sizeof(*(host->crypt)),
> - GFP_KERNEL);
> - if (!host->crypt)
> - goto disable_caps;
> + int ret;
>
> reg = devm_regulator_get_optional(dev, "dvfsrc-vcore");
> if (IS_ERR(reg)) {
> - dev_info(dev, "failed to get dvfsrc-vcore: %ld",
> - PTR_ERR(reg));
> - goto disable_caps;
> + ret = PTR_ERR(reg);
> + if (ret == -EPROBE_DEFER)
> + return ret;
> +
> + return 0;
> }
>
> - if (of_property_read_u32(dev->of_node, "mediatek,boost-crypt-
> microvolt",
> - &volt)) {
> + ret = of_property_read_u32(dev->of_node, "mediatek,boost-crypt-
> microvolt", &volt);
> + if (ret) {
> dev_info(dev, "failed to get mediatek,boost-crypt-
> microvolt");
> - goto disable_caps;
> + return 0;
> }
>
> + host->crypt = devm_kzalloc(dev, sizeof(*host->crypt),
> GFP_KERNEL);
> + if (!host->crypt)
> + return -ENOMEM;
> +
>

Hi Angelo,

If retrun -ENOMEN, host will init fail.
But previous is skip boost crypt feature only.
It change the driver behavior.




> cfg = host->crypt;
> - if (ufs_mtk_init_host_clk(hba, "crypt_mux",
> - &cfg->clk_crypt_mux))
> - goto disable_caps;
> + ret = ufs_mtk_init_host_clk(hba, "crypt_mux", &cfg-
> >clk_crypt_mux);
> + if (ret)
> + goto out;
>
> - if (ufs_mtk_init_host_clk(hba, "crypt_lp",
> - &cfg->clk_crypt_lp))
> - goto disable_caps;
> + ret = ufs_mtk_init_host_clk(hba, "crypt_lp", &cfg-
> >clk_crypt_lp);
> + if (ret)
> + goto out;
>
> - if (ufs_mtk_init_host_clk(hba, "crypt_perf",
> - &cfg->clk_crypt_perf))
> - goto disable_caps;
> + ret = ufs_mtk_init_host_clk(hba, "crypt_perf", &cfg-
> >clk_crypt_perf);
> + if (ret)
> + goto out;
>
> cfg->reg_vcore = reg;
> cfg->vcore_volt = volt;
> host->caps |= UFS_MTK_CAP_BOOST_CRYPT_ENGINE;
>
> -disable_caps:
> - return;
> +out:
> + if (ret)
> + devm_kfree(dev, host->crypt);
> + return 0;
> }
>
> static int ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba)
> @@ -648,8 +652,9 @@ static int ufs_mtk_init_host_caps(struct ufs_hba
> *hba)
> struct device_node *np = hba->dev->of_node;
> int ret;
>
> - if (of_property_read_bool(np, "mediatek,ufs-boost-crypt"))
> - ufs_mtk_init_boost_crypt(hba);
> + ret = ufs_mtk_init_boost_crypt(hba);
> + if (ret)
> + return ret;
>

Most ufs-mediatek platform dosen't need "mediatek,ufs-boost-crypt"
Remove this property will casue most platform try error and add init
latency.

Thanks.
Peter



> ret = ufs_mtk_init_va09_pwr_ctrl(hba);
> if (ret)

Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

Il 16/04/24 09:03, Peter Wang (王信友) ha scritto:
> On Mon, 2024-04-15 at 13:00 +0200, AngeloGioacchino Del Regno wrote:
>> There is no need to have a property that activates the inline crypto
>> boost feature, as this needs many things: a regulator, three clocks,
>> and the mediatek,boost-crypt-microvolt property to be set.
>>
>> If any one of these is missing, the feature won't be activated,
>> hence, it is useless to have yet one more property to enable that.
>>
>> While at it, also address another two issues:
>> 1. Give back the return value to the caller and make sure to fail
>> probing if we get an -EPROBE_DEFER or -ENOMEM; and
>> 2. Free the ufs_mtk_crypt_cfg structure allocated in the crypto
>> boost function if said functionality could not be enabled because
>> it's not supported, as that'd be only wasted memory.
>>
>> Last but not least, move the devm_kzalloc() call for
>> ufs_mtk_crypt_cfg
>> to after getting the dvfsrc-vcore regulator and the boost microvolt
>> property, as if those fail there's no reason to even allocate that.
>>
>> Fixes: ac8c2459091c ("scsi: ufs-mediatek: Decouple features from
>> platform bindings")
>> Signed-off-by: AngeloGioacchino Del Regno <
>> [email protected]>
>> ---
>> drivers/ufs/host/ufs-mediatek.c | 55 ++++++++++++++++++-------------
>> --
>> 1 file changed, 30 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
>> mediatek.c
>> index 688d85909ad6..47f16e6720f4 100644
>> --- a/drivers/ufs/host/ufs-mediatek.c
>> +++ b/drivers/ufs/host/ufs-mediatek.c
>> @@ -575,51 +575,55 @@ static int ufs_mtk_init_host_clk(struct ufs_hba
>> *hba, const char *name,
>> return ret;
>> }
>>
>> -static void ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
>> +static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
>> {
>> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
>> struct ufs_mtk_crypt_cfg *cfg;
>> struct device *dev = hba->dev;
>> struct regulator *reg;
>> u32 volt;
>> -
>> - host->crypt = devm_kzalloc(dev, sizeof(*(host->crypt)),
>> - GFP_KERNEL);
>> - if (!host->crypt)
>> - goto disable_caps;
>> + int ret;
>>
>> reg = devm_regulator_get_optional(dev, "dvfsrc-vcore");
>> if (IS_ERR(reg)) {
>> - dev_info(dev, "failed to get dvfsrc-vcore: %ld",
>> - PTR_ERR(reg));
>> - goto disable_caps;
>> + ret = PTR_ERR(reg);
>> + if (ret == -EPROBE_DEFER)
>> + return ret;
>> +
>> + return 0;
>> }
>>
>> - if (of_property_read_u32(dev->of_node, "mediatek,boost-crypt-
>> microvolt",
>> - &volt)) {
>> + ret = of_property_read_u32(dev->of_node, "mediatek,boost-crypt-
>> microvolt", &volt);
>> + if (ret) {
>> dev_info(dev, "failed to get mediatek,boost-crypt-
>> microvolt");
>> - goto disable_caps;
>> + return 0;
>> }
>>
>> + host->crypt = devm_kzalloc(dev, sizeof(*host->crypt),
>> GFP_KERNEL);
>> + if (!host->crypt)
>> + return -ENOMEM;
>> +
>>
>
> Hi Angelo,
>
> If retrun -ENOMEN, host will init fail.
> But previous is skip boost crypt feature only.
> It change the driver behavior.
>

This is fully intentional: if a platform supports boost-crypt, this means that the
feature *MUST* be enabled, and must *not* be disabled if a memory allocation fails,
as that is relative to available pages at boot, and not to SoC feature support.

Keep in mind that the allocation was moved to *after* checking if such platform
does indeed support the boost-crypt feature, and it is critical to FAIL probing
if there was no memory to allocate the host->crypt structure.

>
>
>
>> cfg = host->crypt;
>> - if (ufs_mtk_init_host_clk(hba, "crypt_mux",
>> - &cfg->clk_crypt_mux))
>> - goto disable_caps;
>> + ret = ufs_mtk_init_host_clk(hba, "crypt_mux", &cfg-
>>> clk_crypt_mux);
>> + if (ret)
>> + goto out;
>>
>> - if (ufs_mtk_init_host_clk(hba, "crypt_lp",
>> - &cfg->clk_crypt_lp))
>> - goto disable_caps;
>> + ret = ufs_mtk_init_host_clk(hba, "crypt_lp", &cfg-
>>> clk_crypt_lp);
>> + if (ret)
>> + goto out;
>>
>> - if (ufs_mtk_init_host_clk(hba, "crypt_perf",
>> - &cfg->clk_crypt_perf))
>> - goto disable_caps;
>> + ret = ufs_mtk_init_host_clk(hba, "crypt_perf", &cfg-
>>> clk_crypt_perf);
>> + if (ret)
>> + goto out;
>>
>> cfg->reg_vcore = reg;
>> cfg->vcore_volt = volt;
>> host->caps |= UFS_MTK_CAP_BOOST_CRYPT_ENGINE;
>>
>> -disable_caps:
>> - return;
>> +out:
>> + if (ret)
>> + devm_kfree(dev, host->crypt);
>> + return 0;
>> }
>>
>> static int ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba)
>> @@ -648,8 +652,9 @@ static int ufs_mtk_init_host_caps(struct ufs_hba
>> *hba)
>> struct device_node *np = hba->dev->of_node;
>> int ret;
>>
>> - if (of_property_read_bool(np, "mediatek,ufs-boost-crypt"))
>> - ufs_mtk_init_boost_crypt(hba);
>> + ret = ufs_mtk_init_boost_crypt(hba);
>> + if (ret)
>> + return ret;
>>
>
> Most ufs-mediatek platform dosen't need "mediatek,ufs-boost-crypt"
> Remove this property will casue most platform try error and add init
> latency.
>

Yes this causes -> less than half of a millisecond <- of additional boot time
if the dvfsrc-supply is present but boost-microvolt is not.

I really don't see the problem with that :-)

Regards,
Angelo

> Thanks.
> Peter
>
>
>
>> ret = ufs_mtk_init_va09_pwr_ctrl(hba);
>> if (ret)


2024-04-16 10:31:47

by Peter Wang (王信友)

[permalink] [raw]
Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property


> Yes this causes -> less than half of a millisecond <- of additional
> boot time
> if the dvfsrc-supply is present but boost-microvolt is not.
>
> I really don't see the problem with that :-)
>

Adding a little bit of boot time to one smartphone might not be a
problem, but when you consider a billion smartphones each adding a
little bit, the cumulative effect becomes significant. The power
consumption of these accumulated times will continue to increase,
contributing to the Earth's carbon emissions. Moreover, removing the
master switch for this feature doesn't seem to have any benefits other
than not having to set it in the DTS. Similarly, the master switch for
VA09 seems to have more disadvantage.


> Regards,
> Angelo
>
> > Thanks.
> > Peter
> >
> >
> >
> > > ret = ufs_mtk_init_va09_pwr_ctrl(hba);
> > > if (ret)
>
>

Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

Il 16/04/24 12:31, Peter Wang (王信友) ha scritto:
>
>> Yes this causes -> less than half of a millisecond <- of additional
>> boot time
>> if the dvfsrc-supply is present but boost-microvolt is not.
>>
>> I really don't see the problem with that :-)
>>
>
> Adding a little bit of boot time to one smartphone might not be a
> problem, but when you consider a billion smartphones each adding a
> little bit, the cumulative effect becomes significant. The power
> consumption of these accumulated times will continue to increase,
> contributing to the Earth's carbon emissions. Moreover, removing the
> master switch for this feature doesn't seem to have any benefits other
> than not having to set it in the DTS. Similarly, the master switch for
> VA09 seems to have more disadvantage.
>

Sorry, but I still don't see how a few *microseconds* more of boot time can
be significant, even related to power consumption during boot.

If that was a few milliseconds, then I'd agree with you, but that's not the case.

Removing the master switch has a benefit: you *lose* a few microseconds of boot
time (so, boots in *few microseconds LESS*) on platforms that would have this set
in devicetree, as this property is redundant with the other activation checks
for those features.

So, there you go: if the majority of MediaTek platforms are already using this
crypt boost feature, then this commit reduces carbon emissions, as those would
boot in a few less microseconds.

Regards,
Angelo

>
>> Regards,
>> Angelo
>>
>>> Thanks.
>>> Peter
>>>
>>>
>>>
>>>> ret = ufs_mtk_init_va09_pwr_ctrl(hba);
>>>> if (ret)
>>
>>



2024-04-16 13:06:19

by Peter Wang (王信友)

[permalink] [raw]
Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

On Tue, 2024-04-16 at 12:38 +0200, AngeloGioacchino Del Regno wrote:
> Il 16/04/24 12:31, Peter Wang (王信友) ha scritto:
> >
> > > Yes this causes -> less than half of a millisecond <- of
> > > additional
> > > boot time
> > > if the dvfsrc-supply is present but boost-microvolt is not.
> > >
> > > I really don't see the problem with that :-)
> > >
> >
> > Adding a little bit of boot time to one smartphone might not be a
> > problem, but when you consider a billion smartphones each adding a
> > little bit, the cumulative effect becomes significant. The power
> > consumption of these accumulated times will continue to increase,
> > contributing to the Earth's carbon emissions. Moreover, removing
> > the
> > master switch for this feature doesn't seem to have any benefits
> > other
> > than not having to set it in the DTS. Similarly, the master switch
> > for
> > VA09 seems to have more disadvantage.
> >
>
> Sorry, but I still don't see how a few *microseconds* more of boot
> time can
> be significant, even related to power consumption during boot.
>
> If that was a few milliseconds, then I'd agree with you, but that's
> not the case.
>
> Removing the master switch has a benefit: you *lose* a few
> microseconds of boot
> time (so, boots in *few microseconds LESS*) on platforms that would
> have this set
> in devicetree, as this property is redundant with the other
> activation checks
> for those features.
>
> So, there you go: if the majority of MediaTek platforms are already
> using this
> crypt boost feature, then this commit reduces carbon emissions, as
> those would
> boot in a few less microseconds.
>

But the majority platfomrs dosen't need this feature.
This feature is only for legacy chip which at least 4 years ago.

Thanks
Peter


> Regards,
> Angelo
>
> >
> > > Regards,
> > > Angelo
> > >
> > > > Thanks.
> > > > Peter
> > > >
> > > >
> > > >
> > > > > ret = ufs_mtk_init_va09_pwr_ctrl(hba);
> > > > > if (ret)
> > >
> > >
>
>

Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

Il 16/04/24 15:05, Peter Wang (王信友) ha scritto:
> On Tue, 2024-04-16 at 12:38 +0200, AngeloGioacchino Del Regno wrote:
>> Il 16/04/24 12:31, Peter Wang (王信友) ha scritto:
>>>
>>>> Yes this causes -> less than half of a millisecond <- of
>>>> additional
>>>> boot time
>>>> if the dvfsrc-supply is present but boost-microvolt is not.
>>>>
>>>> I really don't see the problem with that :-)
>>>>
>>>
>>> Adding a little bit of boot time to one smartphone might not be a
>>> problem, but when you consider a billion smartphones each adding a
>>> little bit, the cumulative effect becomes significant. The power
>>> consumption of these accumulated times will continue to increase,
>>> contributing to the Earth's carbon emissions. Moreover, removing
>>> the
>>> master switch for this feature doesn't seem to have any benefits
>>> other
>>> than not having to set it in the DTS. Similarly, the master switch
>>> for
>>> VA09 seems to have more disadvantage.
>>>
>>
>> Sorry, but I still don't see how a few *microseconds* more of boot
>> time can
>> be significant, even related to power consumption during boot.
>>
>> If that was a few milliseconds, then I'd agree with you, but that's
>> not the case.
>>
>> Removing the master switch has a benefit: you *lose* a few
>> microseconds of boot
>> time (so, boots in *few microseconds LESS*) on platforms that would
>> have this set
>> in devicetree, as this property is redundant with the other
>> activation checks
>> for those features.
>>
>> So, there you go: if the majority of MediaTek platforms are already
>> using this
>> crypt boost feature, then this commit reduces carbon emissions, as
>> those would
>> boot in a few less microseconds.
>>
>
> But the majority platfomrs dosen't need this feature.
> This feature is only for legacy chip which at least 4 years ago.
>

Upstream supports platforms that do and don't need this feature, and having
redundant device tree properties performing the same checks is not just
suboptimal but plain wrong.

Adding to this, devicetree describes the hardware - and there is no physical
hardware switch that needs this redundant property, this means that the
property that is getting removed in this commit (and the va09 one in another
commit of this series) is a *software switch*, not HW.

Keep in mind, also, that this feature (and again, the va09 one as well) has
a specific requirement to be supported - and this is what the code does even
without the software switch to add it.

In case there's any need to disallow such feature from a specific SoC, the DT
bindings can be modified such that a specific compatible string would disallow
adding the required regulator and/or boost-microvolt properties.

Besides, I want to remind you that there is no reason to drop support, or have
them unreliably working, or use hacks, for SoCs that are "old" - especially
when this is a driver that works on both old and new ones.

Regards,
Angelo

2024-04-17 09:30:03

by Peter Wang (王信友)

[permalink] [raw]
Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

On Wed, 2024-04-17 at 10:14 +0200, AngeloGioacchino Del Regno wrote:
>
>
> Upstream supports platforms that do and don't need this feature, and
> having
> redundant device tree properties performing the same checks is not
> just
> suboptimal but plain wrong.
>
> Adding to this, devicetree describes the hardware - and there is no
> physical
> hardware switch that needs this redundant property, this means that
> the
> property that is getting removed in this commit (and the va09 one in
> another
> commit of this series) is a *software switch*, not HW.
>
> Keep in mind, also, that this feature (and again, the va09 one as
> well) has
> a specific requirement to be supported - and this is what the code
> does even
> without the software switch to add it.
>
> In case there's any need to disallow such feature from a specific
> SoC, the DT
> bindings can be modified such that a specific compatible string would
> disallow
> adding the required regulator and/or boost-microvolt properties.
>
> Besides, I want to remind you that there is no reason to drop
> support, or have
> them unreliably working, or use hacks, for SoCs that are "old" -
> especially
> when this is a driver that works on both old and new ones.
>
> Regards,
> Angelo

Hi Angelo,

These two property(boost and va09) is not software switch, they
are hardware switch. Because if platform support crypto boost, we set
boost property in device tree. And if platform support ufs va09, we set
va09 proberty in device tree. These property are main hardware switch.

We don't use sub switch like voltage or clock setting becasue it is
not intiutive. Especially when va09 is not used by ufs (No va09
property but have va09 voltage), The behavior should be wrong if ufs
control va09 which used by other module.

Thanks.
Peter



Subject: Re: [PATCH v4 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property

Il 17/04/24 11:29, Peter Wang (王信友) ha scritto:
> On Wed, 2024-04-17 at 10:14 +0200, AngeloGioacchino Del Regno wrote:
>>
>>
>> Upstream supports platforms that do and don't need this feature, and
>> having
>> redundant device tree properties performing the same checks is not
>> just
>> suboptimal but plain wrong.
>>
>> Adding to this, devicetree describes the hardware - and there is no
>> physical
>> hardware switch that needs this redundant property, this means that
>> the
>> property that is getting removed in this commit (and the va09 one in
>> another
>> commit of this series) is a *software switch*, not HW.
>>
>> Keep in mind, also, that this feature (and again, the va09 one as
>> well) has
>> a specific requirement to be supported - and this is what the code
>> does even
>> without the software switch to add it.
>>
>> In case there's any need to disallow such feature from a specific
>> SoC, the DT
>> bindings can be modified such that a specific compatible string would
>> disallow
>> adding the required regulator and/or boost-microvolt properties.
>>
>> Besides, I want to remind you that there is no reason to drop
>> support, or have
>> them unreliably working, or use hacks, for SoCs that are "old" -
>> especially
>> when this is a driver that works on both old and new ones.
>>
>> Regards,
>> Angelo
>
> Hi Angelo,
>
> These two property(boost and va09) is not software switch, they
> are hardware switch. Because if platform support crypto boost, we set
> boost property in device tree. And if platform support ufs va09, we set
> va09 proberty in device tree. These property are main hardware switch.

I disagree. If a platform supports crypto boost, it will have the dvfsrc
regulator and the supported voltage for the boost; if a platform supports
ufs va09, it will have the va09 regulator assigned in the ufshci devicetree
node.

>
> We don't use sub switch like voltage or clock setting becasue it is
> not intiutive. Especially when va09 is not used by ufs (No va09
> property but have va09 voltage), The behavior should be wrong if ufs
> control va09 which used by other module.
>

As I said, devicetree describes hardware - and this strategy being intuitive
or not boils down to personal opinions and nothing else.
Aside personal opinions, again, properties not describing hardware are wrong.

And again, if VA09 shall not be controlled by the UFSHCI driver on a specific
platform, then the regulator shall not be assigned to the UFSHCI node on that
specific platform.

Regards,
Angelo