Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp355922rdf; Tue, 21 Nov 2023 04:55:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAGs+EDt252tbXUbMUY2/DkSdaFjAyrYNGMyKK/oaQl43psgVLV6h3kRJ9iRjJ/jmB3arB X-Received: by 2002:a17:902:650a:b0:1cf:7439:690c with SMTP id b10-20020a170902650a00b001cf7439690cmr588043plk.11.1700571306040; Tue, 21 Nov 2023 04:55:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700571306; cv=none; d=google.com; s=arc-20160816; b=O6sce0/ym77N7/PNX0zK64nN1bC4fXh+7ca0tQfU+gmegvx3bCwcimyv3zmz3h5h4u tNyg6QZSaJ+246NGoTtRAuXGwNNIllTEyouN/tS6jFZykflZ0jk3tQWk0T8/5APZdpPf 1+kkjyhZsffxBBfe4dpBP3PALVRdXNE1txkmKh/NPu2rd2STjN1nhp8DYifaLlLE61pR tVUwLJpMc/wRDFE+m3n9PlpaUDx1OIC7EpyJkZkFG7QFlDZa3Z94CCpJglgsve2wuspN m5A7LvI61eZk5NHKRSQuKOPm8RZc0Mwms4FWEQats1gm3cxrHRroEkvCI6clDmFT+f5u tYew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KpBUxqYvBKX4tX03KjbJxbiKYB0CW1q5AbspkuYc90k=; fh=m5p6pcg3y47Sg5VKYWXj0f0nOzgFq4l5+GGYwGce+t4=; b=JMRBcpBiB1eXNuxhsoVTF77irNg93E/09gWK+2eZAH8klkpMaarP/tzzjB+DyC7V/u r6O0/coV3PXtMKQCFR2CMhnz+c00YSJ9q6hyPNShP8OBLPXkWApf0dd7wsoruQhRoVk1 gBYCVOo7l2TrVNoV+xHY9WG/6Gon/+YgZizjgboMSLYGqs7SjmpZxY9UK91fSCWrt+K0 D8scNT/lKBfrrrmlt8nEAPRL/S/hhlVMHc7sHZV3KUvkTWs5xIRyi4BixAzH98O42bUS jLeQ5rbfEQPGpMGUsy4YAcktui89HLIyP3ybcbCN3uPanxHaYlXuN5SjvREXWMgvFqkW SFcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MZro2lpE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l64-20020a638843000000b005b7d9aace9dsi10218269pgd.46.2023.11.21.04.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 04:55:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MZro2lpE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3FB31803E7B8; Tue, 21 Nov 2023 04:52:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234176AbjKUMvr (ORCPT + 99 others); Tue, 21 Nov 2023 07:51:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233946AbjKUMvR (ORCPT ); Tue, 21 Nov 2023 07:51:17 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90A8010EB; Tue, 21 Nov 2023 04:51:09 -0800 (PST) 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 madras.collabora.co.uk (Postfix) with ESMTPSA id 16530660731B; Tue, 21 Nov 2023 12:51:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1700571067; bh=XEVVBoXHkUpKz+mYu2BhuD+v7qTvXaba6bcEiQ5SYSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MZro2lpEW2iayt+uvYR2PTq9KhFa++lNx+CbzXMb7cp3Ubs0sFYy4r78aUbs/fvpg UH8SHKdesT/NlI//U1jqxnS1toFZ5MWz1lNuyZKDGrEa/rzp4P/ZTsqHQBIsbzRlp2 YVJjVdpWaVxlz9MHvFHIPIylXH54DLlstNsxIpSMEqEAt3+wxN5syNY2WpYRMG5MOq JTa3vp1ecqa2ak+7zz1hJXTYAu+ukJJDGN/NRUKyiPQC5gj+nEMxUa9ijkRcAcUsXb qvs2VoU7LgveWfsgQzDB6at+oArRypvPS8vZDUi8P3kXxtV3l+SNXkZ3CxeWO2NCEF gPs80gfSkhxkQ== From: AngeloGioacchino Del Regno To: matthias.bgg@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, robh+dt@kernel.org, angelogioacchino.delregno@collabora.com, p.zabel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, wenst@chromium.org Subject: [PATCH v3 16/20] soc: mediatek: mtk-svs: Check if SVS mode is available in the beginning Date: Tue, 21 Nov 2023 13:50:40 +0100 Message-ID: <20231121125044.78642-17-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231121125044.78642-1-angelogioacchino.delregno@collabora.com> References: <20231121125044.78642-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 04:52:15 -0800 (PST) The svs_init01() and svs_init02() functions are already checking if the INIT01 and INIT02 modes are available - but that's done in for loops and for each SVS bank. Give those a shortcut to get out early if no SVS bank features the desired init mode: this is especially done to avoid some locking in the svs_init01(), but also to avoid multiple for loops to check the same, when no bank supports a specific mode. Signed-off-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index ae0cc22a2941..16a16c5a3f24 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1400,6 +1400,16 @@ static irqreturn_t svs_isr(int irq, void *data) return IRQ_HANDLED; } +static bool svs_mode_available(struct svs_platform *svsp, u8 mode) +{ + int i; + + for (i = 0; i < svsp->bank_max; i++) + if (svsp->banks[i].mode_support & mode) + return true; + return false; +} + static int svs_init01(struct svs_platform *svsp) { struct svs_bank *svsb; @@ -1408,6 +1418,9 @@ static int svs_init01(struct svs_platform *svsp) int ret = 0, r; u32 opp_freq, opp_vboot, buck_volt, idx, i; + if (!svs_mode_available(svsp, SVSB_MODE_INIT01)) + return 0; + /* Keep CPUs' core power on for svs_init01 initialization */ cpuidle_pause_and_lock(); @@ -1575,6 +1588,9 @@ static int svs_init02(struct svs_platform *svsp) int ret; u32 idx; + if (!svs_mode_available(svsp, SVSB_MODE_INIT02)) + return 0; + for (idx = 0; idx < svsp->bank_max; idx++) { svsb = &svsp->banks[idx]; -- 2.42.0