From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BBBACCFA05 for ; Fri, 7 Nov 2025 10:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xtCvqvqE2moApnUy0rRq93DPemmekDa5Xqa8B/wZ19c=; b=KgWvj7PeTzt0unlT4kQfLJPCdy xxQ3/5gpBR7dgxP+oRK7Eu2MGPSPXR0iKd1BGox8oSwoeNn//nxsy/D9QhwU42ImaLQuEqm4EJOhP bc8eMqtFNTB0qgQbXVy3hAtk6P3RNVAXeemeAjeRAvNRq0Oidk8zRu/IuepTQj0ekGD2PurnjylEg +kdMywySD8ECOkpQyy0HMW03TVICidTZBVszVd60rKMAw3sT6++iwfIEdlHdB8VNVFQ6UbcPeofY1 U/NxfiB1P/vsHjJG/1GTNpsZ5HMA9aTRhOdUgQoxkAQCKdILuj3yPBDcoEBTZ9I6niMjpcLwI/+H/ Jlrb9vIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vHJps-0000000H7Jm-0efU; Fri, 07 Nov 2025 10:36:52 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vHJpq-0000000H7Hj-1zZB; Fri, 07 Nov 2025 10:36:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1762511806; bh=W3XA4O4boMpqyIDRv4Vw7fYsHQbOO+0xJ0SlKyYcqI0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=pYufGIN7RYAeRlellj6N2gZSHDdPM/SyGPzwncHtmDa3CybeRRFucgw8OAIhNnmLo /9gukKEt1mLLCxvDb964d14ur0TsHUks6z6L/+6Eq/w+VNenF3jWckg3RG1MDOLTq6 GqpHMmLKrT/yzbcd2Qip7j4u7wdher+hX1WDr6Q6oIStNzkz5IzWcPDMrWHXEKi0/X gywJc5QADo3ZfucXonoeoilwp9h/oVkhmbXD+XfhQFokN1FF/ioQAnXCjrOAxovXfe iPtuh3bWr8GTf6q9vPLEs36wxgqk7YBUaVglgujSp+L8HyAnUviL1kgNRGk+s19XGU ydOsrMZath9dw== Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id BC34A17E0364; Fri, 7 Nov 2025 11:36:45 +0100 (CET) Message-ID: <6f1bbbc7-ca54-43f9-953d-725902af7b10@collabora.com> Date: Fri, 7 Nov 2025 11:36:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 20/21] pmdomain: mediatek: Add bus protect control flow for MT8189 To: "irving.ch.lin" , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , Ulf Hansson , Richard Cochran Cc: Qiqi Wang , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, netdev@vger.kernel.org, Project_Global_Chrome_Upstream_Group@mediatek.com, sirius.wang@mediatek.com, vince-wl.liu@mediatek.com, jh.hsu@mediatek.com References: <20251106124330.1145600-1-irving-ch.lin@mediatek.com> <20251106124330.1145600-21-irving-ch.lin@mediatek.com> From: AngeloGioacchino Del Regno Content-Language: en-US In-Reply-To: <20251106124330.1145600-21-irving-ch.lin@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251107_023650_693655_7C24FE7D X-CRM114-Status: GOOD ( 22.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Il 06/11/25 13:42, irving.ch.lin ha scritto: > From: Irving-CH Lin > > In MT8189 mminfra power domain, the bus protect policy separates > into two parts, one is set before subsys clocks enabled, and another > need to enable after subsys clocks enable. > > Signed-off-by: Irving-CH Lin > --- > drivers/pmdomain/mediatek/mtk-pm-domains.c | 31 ++++++++++++++++++---- > drivers/pmdomain/mediatek/mtk-pm-domains.h | 5 ++++ > 2 files changed, 31 insertions(+), 5 deletions(-) > > diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c > index 164c6b519af3..222846e52daf 100644 > --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c > +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c > @@ -250,7 +250,7 @@ static int scpsys_bus_protect_set(struct scpsys_domain *pd, > MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); > } > > -static int scpsys_bus_protect_enable(struct scpsys_domain *pd) > +static int scpsys_bus_protect_enable(struct scpsys_domain *pd, u8 flags) > { > for (int i = 0; i < SPM_MAX_BUS_PROT_DATA; i++) { > const struct scpsys_bus_prot_data *bpd = &pd->data->bp_cfg[i]; > @@ -259,6 +259,10 @@ static int scpsys_bus_protect_enable(struct scpsys_domain *pd) > if (!bpd->bus_prot_set_clr_mask) > break; > > + if ((bpd->flags & BUS_PROT_IGNORE_SUBCLK) != > + (flags & BUS_PROT_IGNORE_SUBCLK)) > + continue; > + > if (bpd->flags & BUS_PROT_INVERTED) > ret = scpsys_bus_protect_clear(pd, bpd); > else > @@ -270,7 +274,7 @@ static int scpsys_bus_protect_enable(struct scpsys_domain *pd) > return 0; > } > > -static int scpsys_bus_protect_disable(struct scpsys_domain *pd) > +static int scpsys_bus_protect_disable(struct scpsys_domain *pd, u8 flags) > { > for (int i = SPM_MAX_BUS_PROT_DATA - 1; i >= 0; i--) { > const struct scpsys_bus_prot_data *bpd = &pd->data->bp_cfg[i]; > @@ -279,6 +283,10 @@ static int scpsys_bus_protect_disable(struct scpsys_domain *pd) > if (!bpd->bus_prot_set_clr_mask) > continue; > > + if ((bpd->flags & BUS_PROT_IGNORE_SUBCLK) != Is that the right name for this flag? As far as I understand, you have to set bus protection in two steps, right? So in the first step you're setting bus protection for the MM_INFRA and for MM_INFRA_2ND - and in the second step you're setting MM_INFRA_IGN and 2_IGN. So the first step (the prots with BUS_PROT_IGNORE_SUBCLK) unlocks SUBSYS clks and SRAM ISO access, the second one does the rest. I think that a better name for this, at this point would be... if ((bpd->flags & local_flags) & BUS_PROT_SRAM_PROTECTION) continue; What do you think? Regards, Angelo > + (flags & BUS_PROT_IGNORE_SUBCLK)) > + continue; > + > if (bpd->flags & BUS_PROT_INVERTED) > ret = scpsys_bus_protect_set(pd, bpd); > else > @@ -632,6 +640,15 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) > if (ret) > goto err_pwr_ack; > > + /* > + * In MT8189 mminfra power domain, the bus protect policy separates > + * into two parts, one is set before subsys clocks enabled, and another > + * need to enable after subsys clocks enable. > + */ > + ret = scpsys_bus_protect_disable(pd, BUS_PROT_IGNORE_SUBCLK); > + if (ret < 0) > + goto err_pwr_ack; > + > /* > * In few Mediatek platforms(e.g. MT6779), the bus protect policy is > * stricter, which leads to bus protect release must be prior to bus > @@ -648,7 +665,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) > if (ret < 0) > goto err_disable_subsys_clks; > > - ret = scpsys_bus_protect_disable(pd); > + ret = scpsys_bus_protect_disable(pd, 0); > if (ret < 0) > goto err_disable_sram; > > @@ -662,7 +679,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) > return 0; > > err_enable_bus_protect: > - scpsys_bus_protect_enable(pd); > + scpsys_bus_protect_enable(pd, 0); > err_disable_sram: > scpsys_sram_disable(pd); > err_disable_subsys_clks: > @@ -683,7 +700,7 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) > bool tmp; > int ret; > > - ret = scpsys_bus_protect_enable(pd); > + ret = scpsys_bus_protect_enable(pd, 0); > if (ret < 0) > return ret; > > @@ -697,6 +714,10 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) > > clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks); > > + ret = scpsys_bus_protect_enable(pd, BUS_PROT_IGNORE_SUBCLK); > + if (ret < 0) > + return ret; > + > if (MTK_SCPD_CAPS(pd, MTK_SCPD_MODEM_PWRSEQ)) > scpsys_modem_pwrseq_off(pd); > else > diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.h b/drivers/pmdomain/mediatek/mtk-pm-domains.h > index f608e6ec4744..a5dca24cbc2f 100644 > --- a/drivers/pmdomain/mediatek/mtk-pm-domains.h > +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.h > @@ -56,6 +56,7 @@ enum scpsys_bus_prot_flags { > BUS_PROT_REG_UPDATE = BIT(1), > BUS_PROT_IGNORE_CLR_ACK = BIT(2), > BUS_PROT_INVERTED = BIT(3), > + BUS_PROT_IGNORE_SUBCLK = BIT(4), > }; > > enum scpsys_bus_prot_block { > @@ -95,6 +96,10 @@ enum scpsys_bus_prot_block { > _BUS_PROT(_hwip, _mask, _set, _clr, _mask, _sta, \ > BUS_PROT_REG_UPDATE) > > +#define BUS_PROT_WR_IGN_SUBCLK(_hwip, _mask, _set, _clr, _sta) \ > + _BUS_PROT(_hwip, _mask, _set, _clr, _mask, _sta, \ > + BUS_PROT_IGNORE_CLR_ACK | BUS_PROT_IGNORE_SUBCLK) > + > #define BUS_PROT_INFRA_UPDATE_TOPAXI(_mask) \ > BUS_PROT_UPDATE(INFRA, _mask, \ > INFRA_TOPAXI_PROTECTEN, \