From nobody Sun Nov 10 04:11:03 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC0DA142E69; Thu, 11 Apr 2024 08:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712824321; cv=none; b=Cnz0Qxv83KSgCuI+PAdjBORJMZ1kIIhLFHMr9zbMWtYXLjCu/nVZuBq72qp/XFAjJlNsNE93FXkU0mcbyFa63i/CEpZCTliAmP6dLAkX/+HNT/X2Y83QU/4An2JkEgaeFuP1b1cnct/SnPtMy992rcO69RcyiudOs0vXFLo+ffw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712824321; c=relaxed/simple; bh=F6W/HVSlQd+0v0oSIGT3n+veRGpMV08z19t8e68fgfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GGQs3HFjWAQeCjj8LPGHL/V/YKLeGMEcQ+0jToQf5pySAaIJy1TaWEJ2PEdHAEv7Myp/iQqnXP0FygdS65wCyV0ZXHvKSGOtocnzn/+UQ5QZUo+A7BfYyDd0MjYpV1bm+VvQmGoV24L8wVCyNrbgX/x9cu8hWs7f7Fh83w6UG3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=vFs4T7kg; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="vFs4T7kg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712824318; bh=F6W/HVSlQd+0v0oSIGT3n+veRGpMV08z19t8e68fgfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFs4T7kgxZRrWTniL6Jn9u3Mej6ZOZ/CSGrMQZq3BR1TazZCtSzoEjhWEs9SSn4fT zwe97X0Di+YJsQ5BSzON/hHMsw/kEMSC/0wjQhgvPcfSDoVHcDOb7HcaIM8ickZb5B l9ll2Z6UhQezIskO8/FFba8uL0TKKgGZ8ljo9g6bk3E06TgOG6HN44qYPZrWJKDG1w L7V0ygg2WL8TsFx84csFpBDOnegXI/gUCkrPSgKm5xOdcPgoQKbsx8IU6NB4lZMrM5 R8YRNLjs7cIOYgb6v2efgRczHJDDL4F1Gv83Nwv8lB3sQqPeQ/bqhaWsxHZ5ZlasCR SLRRK0aabh3zQ== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E0A863782132; Thu, 11 Apr 2024 08:31:56 +0000 (UTC) From: AngeloGioacchino Del Regno To: linux-scsi@vger.kernel.org Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, peter.wang@mediatek.com, chu.stanley@gmail.com, jejb@linux.ibm.com, martin.petersen@oracle.com, lgirdwood@gmail.com, broonie@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, stanley.chu@mediatek.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v1 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property Date: Thu, 11 Apr 2024 10:31:44 +0200 Message-ID: <20240411083149.78537-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411083149.78537-1-angelogioacchino.delregno@collabora.com> References: <20240411083149.78537-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 b= indings") Signed-off-by: AngeloGioacchino Del Regno --- 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-mediate= k.c index 90cd11d4a026..16a76b02c934 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -544,51 +544,55 @@ static int ufs_mtk_init_host_clk(struct ufs_hba *hba,= const char *name, return ret; } =20 -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 =3D ufshcd_get_variant(hba); struct ufs_mtk_crypt_cfg *cfg; struct device *dev =3D hba->dev; struct regulator *reg; u32 volt; - - host->crypt =3D devm_kzalloc(dev, sizeof(*(host->crypt)), - GFP_KERNEL); - if (!host->crypt) - goto disable_caps; + int ret; =20 reg =3D 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 =3D PTR_ERR(reg); + if (ret =3D=3D -EPROBE_DEFER) + return ret; + + return 0; } =20 - if (of_property_read_u32(dev->of_node, "mediatek,boost-crypt-microvolt", - &volt)) { + ret =3D of_property_read_u32(dev->of_node, "mediatek,boost-crypt-microvol= t", &volt); + if (ret) { dev_info(dev, "failed to get mediatek,boost-crypt-microvolt"); - goto disable_caps; + return 0; } =20 + host->crypt =3D devm_kzalloc(dev, sizeof(*host->crypt), GFP_KERNEL); + if (!host->crypt) + return -ENOMEM; + cfg =3D host->crypt; - if (ufs_mtk_init_host_clk(hba, "crypt_mux", - &cfg->clk_crypt_mux)) - goto disable_caps; + ret =3D ufs_mtk_init_host_clk(hba, "crypt_mux", &cfg->clk_crypt_mux); + if (ret) + goto out; =20 - if (ufs_mtk_init_host_clk(hba, "crypt_lp", - &cfg->clk_crypt_lp)) - goto disable_caps; + ret =3D ufs_mtk_init_host_clk(hba, "crypt_lp", &cfg->clk_crypt_lp); + if (ret) + goto out; =20 - if (ufs_mtk_init_host_clk(hba, "crypt_perf", - &cfg->clk_crypt_perf)) - goto disable_caps; + ret =3D ufs_mtk_init_host_clk(hba, "crypt_perf", &cfg->clk_crypt_perf); + if (ret) + goto out; =20 cfg->reg_vcore =3D reg; cfg->vcore_volt =3D volt; host->caps |=3D UFS_MTK_CAP_BOOST_CRYPT_ENGINE; =20 -disable_caps: - return; +out: + if (ret) + devm_kfree(dev, host->crypt); + return 0; } =20 static int ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba) @@ -617,8 +621,9 @@ static int ufs_mtk_init_host_caps(struct ufs_hba *hba) struct device_node *np =3D hba->dev->of_node; int ret; =20 - if (of_property_read_bool(np, "mediatek,ufs-boost-crypt")) - ufs_mtk_init_boost_crypt(hba); + ret =3D ufs_mtk_init_boost_crypt(hba); + if (ret) + return ret; =20 ret =3D ufs_mtk_init_va09_pwr_ctrl(hba); if (ret) --=20 2.44.0