Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp338985lqg; Thu, 11 Apr 2024 04:55:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXT29/SKbpaC5akKotbZFExopelxbP8DkG/LKPhSQFtY0NG6Yd8tdxjLp2Spm+1FRqkjAo2wVc4w4aaQtZVdOnRQVXOVUHXgPCv9oe9zA== X-Google-Smtp-Source: AGHT+IHznET4acAHMxXXLxmDYvFbtsxI/MxnXp0DQ+tnz1/TMBIRiqtVs/18OXr8qwhk50GJKWN9 X-Received: by 2002:a05:6358:d38e:b0:183:4d1e:19f0 with SMTP id mp14-20020a056358d38e00b001834d1e19f0mr6930147rwb.9.1712836538593; Thu, 11 Apr 2024 04:55:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712836538; cv=pass; d=google.com; s=arc-20160816; b=hqNL3lmKoA5z1npISc6VLEaoXlxHaYrX0xb1RXF7XbDwjVWj2F23Qc56mzcHPlxuXv KrO3cV2V7s5qY5o/gtVkptnSOTrh4Y6LRrsYbgfB3tbzF/BEB+itLbtsOJ1ZXI8GNN09 1I5J7GwMZiJx+W5+7EY6sa3x/GHuF+06MFY4Hyda7vhiAL/Q5+tOXs7YzE0tcSp0l/W3 tuCltWCuYxgShJkFujM8gWy6dli27zyK3fOFXHMdOD+VlhcX8Sa1/N/ebDvBT7SrQPc4 Q2aX9NIO422rxMCcQpDXR7S9kBB4nd26RjnVmU617PXSvfqJkQtuyEeew6NcE1sZeUL3 0OAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RfDPBLKaioX72UMsfzkGtBIsjdpxTnoJS8fvO2iTDJY=; fh=YO+sIdXsWdUU+5L7O0nZBZ8oGksKYVzXes8TS5B+v/M=; b=k3Uq0jnud0mratkfWpFmNu1cwv1n+DAUZ7hkCqgShdzVwhsGG7GlxeIhlgyx6z0SuX uUA4KK6QsoLgEw72cUV650M+agQvr0EX9Zcp8G1NtS1nwi/mXT3VGY1yF84uvIS5lgHz eq5fMp8xSxnzbShsVA+75dghlWpqZpRjaLDHLHpYoIBRgjFS1bueOBtQd8KQnOi2RrYb TJrlj2DftD4+VAaDrbnbG5lxrWnlV8PbZKdaHfD06awi/nCPbnZqnQEDxe5fdNTAbnpT irqQcXdZVvGPfB1P+Vk4vU0iCtTr2Y1be8/7RDlhQRWORx8tzrEh90dnL6KNiNkGphos mEcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=j9XVPWIj; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-140361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e8-20020a630f08000000b005dc4912432csi1164432pgl.577.2024.04.11.04.55.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 04:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=j9XVPWIj; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-140361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9EEB0B254CA for ; Thu, 11 Apr 2024 11:44:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E0F814D283; Thu, 11 Apr 2024 11:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="j9XVPWIj" 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 3863714AD24; Thu, 11 Apr 2024 11:43:11 +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=1712835793; cv=none; b=j4jOekzbTZc0Pi52LCyXyk6PlS32K6WeBqCEISLuxY5AE4kVYTM6Um5eTZ1L1Jqe2kg8uXbmJrDmgvIjPwar3R2wUTCnO9tdEdY8AuIMD/eq5EeLGrMEX46zibgnYR2x/f6iYTKy255eVNwao1cPngkQ6eQfAKi1ZNPCcQxAiKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712835793; c=relaxed/simple; bh=oAmHrFWJ0AgBwXeTr9PuBA8AXz2vtp9jcoIAQcxeovA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nUwqY4kQrQoK6vwEPNbJ9vknHPciaooj/dZ2EZfC40ablDJ81H48gNai5NhFoL/m/KcAYEjEJGm2G0a5rYJ1mEvy7Zux1TRm++V+6EayWm65dzpXlUbLo2qocmaD2plqpJnShxCR+kPv3pYr8sERtL35sMxsUFDg4JmL+oSGokU= 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=j9XVPWIj; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712835789; bh=oAmHrFWJ0AgBwXeTr9PuBA8AXz2vtp9jcoIAQcxeovA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9XVPWIjQPk/W+/nYel0ynUdz6j1CWueMboBNJKgLGJpjT1JEdWyM4/rBGWpqJ7kR 2sWg609GC7imQ15b8IglcRSJr51G/KexJrlLQnNb/XkXyR4D/co2UglmLFgb9FJgzI BWP259Il3E179TgSePdra1DH1J4t2CGcvVbKRUYvC2oCxk83bPxmxfTw6WxmGF44Ua RIPt8E4G/GgRgpTjqAXl5nrBLFQ5Ub4TG+PGOQ6r/sGpe/sUaXsL7I9HADnV4zcEvh ND3J5dF029veBHwD1jc1WwNrYXI62YUy351pPuejCO9T5ao2KcxLBxykrqxBAeyMpy WudB93kezAUuQ== 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 6990B3782117; Thu, 11 Apr 2024 11:43:08 +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 Subject: [PATCH v2 3/8] scsi: ufs: ufs-mediatek: Remove useless mediatek,ufs-boost-crypt property Date: Thu, 11 Apr 2024 13:42:55 +0200 Message-ID: <20240411114300.169055-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411114300.169055-1-angelogioacchino.delregno@collabora.com> References: <20240411114300.169055-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: 8bit 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 --- 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