mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"avri.altman@wdc.com" <avri.altman@wdc.com>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"michael@walle.cc" <michael@walle.cc>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"robh@kernel.org" <robh@kernel.org>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Subject: Re: [PATCH v5 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property
Date: Fri, 14 Jun 2024 06:34:25 +0000	[thread overview]
Message-ID: <eb47587159484abca8e6d65dddcf0844822ce99f.camel@mediatek.com> (raw)
In-Reply-To: <20240612074309.50278-4-angelogioacchino.delregno@collabora.com>

On Wed, 2024-06-12 at 09:43 +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 <
> angelogioacchino.delregno@collabora.com>
> ---
>  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 23271eb1a244..8d0e7ea52541 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -576,51 +576,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)
> @@ -649,8 +653,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);
> 

Hi AngeloGioacchino,

As previously explained, removing these DTS settings will make what was
originally a simple task 
more complicated. In addition, it will require MediaTek to put in extra
effort to migrate the kernel. 
We do not believe that such changes have any benefits.

Thanks.
Peter




> +	ret = ufs_mtk_init_boost_crypt(hba);
> +	if (ret)
> +		return ret;
>  
>  	ret = ufs_mtk_init_va09_pwr_ctrl(hba);
>  	if (ret)

  reply	other threads:[~2024-06-14  6:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  7:43 [PATCH v5 0/8] MediaTek UFS fixes and cleanups - Part 1 AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 1/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-support-va09 property AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 2/8] scsi: ufs: ufs-mediatek: Fix property name for crypt boost voltage AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property AngeloGioacchino Del Regno
2024-06-14  6:34   ` Peter Wang (王信友) [this message]
2024-06-12  7:43 ` [PATCH v5 4/8] scsi: ufs: ufs-mediatek: Avoid underscores in crypt clock names AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 5/8] dt-bindings: ufs: mediatek,ufs: Document MT8192 compatible with MT8183 AngeloGioacchino Del Regno
2024-06-14  6:32   ` Peter Wang (王信友)
2024-06-12  7:43 ` [PATCH v5 6/8] dt-bindings: ufs: mediatek,ufs: Document MT8195 compatible AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 7/8] dt-bindings: ufs: mediatek,ufs: Document additional clocks AngeloGioacchino Del Regno
2024-06-12  7:43 ` [PATCH v5 8/8] dt-bindings: ufs: mediatek,ufs: Document optional dvfsrc/va09 regulators AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb47587159484abca8e6d65dddcf0844822ce99f.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=avri.altman@wdc.com \
    --cc=broonie@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthias.bgg@gmail.com \
    --cc=michael@walle.cc \
    --cc=robh@kernel.org \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®