From: Pranjal Shrivastava <praan@google.com>
To: Xueqi Zhang <xueqi.zhang@mediatek.com>
Cc: Yong Wu <yong.wu@mediatek.com>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Project_Global_Chrome_Upstream_Group@mediatek.com,
Ning li <ning.li@mediatek.com>,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
iommu@lists.linux.dev
Subject: Re: [RFC PATCH 7/8] iommu/arm-smmu-v3: Invoke rpm operation before accessing the hw
Date: Mon, 16 Jun 2025 20:54:07 +0000 [thread overview]
Message-ID: <aFCEb744WpRpcDxM@google.com> (raw)
In-Reply-To: <20250616025628.25454-8-xueqi.zhang@mediatek.com>
On Mon, Jun 16, 2025 at 10:56:13AM +0800, Xueqi Zhang wrote:
Hi Xueqi,
> Invoke rpm operation before accessing the SMMU hw.
>
> Signed-off-by: Xueqi Zhang <xueqi.zhang@mediatek.com>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 84 ++++++++++++++++++++-
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +
> 2 files changed, 85 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 154417b380fa..88912b0f8132 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -122,6 +122,22 @@ static void parse_driver_options(struct arm_smmu_device *smmu)
> } while (arm_smmu_options[++i].opt);
> }
>
> +static int arm_smmu_rpm_get(struct arm_smmu_device *smmu)
> +{
> + if (smmu && smmu->impl && smmu->impl->smmu_power_get)
> + return smmu->impl->smmu_power_get(smmu);
> +
> + return 0;
> +}
> +
> +static int arm_smmu_rpm_put(struct arm_smmu_device *smmu)
> +{
> + if (smmu && smmu->impl && smmu->impl->smmu_power_put)
> + return smmu->impl->smmu_power_put(smmu);
> +
> + return 0;
> +}
> +
I've been working on enabling PM runtime for arm-smmu-v3 for a while,
I just posted the RFCv3 for that series [1]. I see that you need some
implementation specific rpm calls too, I think it would be nice if we
could align on this?
Perhaps, you could rebase this on top of my series OR we can collaborate
for the runtime PM series where you can contribute only the rpm patches
from this series to handle your implmentation?
Let me know what you think!
> /* Low-level queue manipulation functions */
> static bool queue_has_space(struct arm_smmu_ll_queue *q, u32 n)
> {
> @@ -2082,23 +2098,35 @@ static irqreturn_t arm_smmu_gerror_handler(int irq, void *dev)
> static irqreturn_t arm_smmu_combined_irq_thread(int irq, void *dev)
> {
> struct arm_smmu_device *smmu = dev;
> + int ret;
> +
> + ret = arm_smmu_rpm_get(smmu);
> + if (ret)
> + return IRQ_NONE;
>
> arm_smmu_evtq_thread(irq, dev);
> if (smmu->features & ARM_SMMU_FEAT_PRI)
> arm_smmu_priq_thread(irq, dev);
>
> + arm_smmu_rpm_put(smmu);
> return IRQ_HANDLED;
> }
>
> static irqreturn_t arm_smmu_combined_irq_handler(int irq, void *dev)
> {
> +
> + ret = arm_smmu_rpm_get(smmu);
> + if (ret)
> + return IRQ_WAKE_THREAD;
>
> arm_smmu_gerror_handler(irq, dev);
>
> if (smmu->impl && smmu->impl->combined_irq_handle)
> smmu->impl->combined_irq_handle(irq, smmu);
>
> + arm_smmu_rpm_put(smmu);
> return IRQ_WAKE_THREAD;
> }
>
> @@ -2255,6 +2283,11 @@ static void arm_smmu_tlb_inv_context(void *cookie)
> struct arm_smmu_domain *smmu_domain = cookie;
> struct arm_smmu_device *smmu = smmu_domain->smmu;
> struct arm_smmu_cmdq_ent cmd;
> + int ret;
> +
> + ret = arm_smmu_rpm_get(smmu);
> + if (ret)
> + return;
>
> /*
> * NOTE: when io-pgtable is in non-strict mode, we may get here with
> @@ -2271,6 +2304,8 @@ static void arm_smmu_tlb_inv_context(void *cookie)
> arm_smmu_cmdq_issue_cmd_with_sync(smmu, &cmd);
> }
> arm_smmu_atc_inv_domain(smmu_domain, 0, 0);
> +
> + arm_smmu_rpm_put(smmu);
> }
>
> static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,
> @@ -2353,6 +2388,11 @@ static void arm_smmu_tlb_inv_range_domain(unsigned long iova, size_t size,
> .leaf = leaf,
> },
> };
> + int ret;
> +
> + ret = arm_smmu_rpm_get(smmu_domain->smmu);
> + if (ret)
> + return;
I'm afraid we aren't going for a hard rpm_get in such functions in our
design as per the the discussions in the rpm series[1]. It would be
great if you could review that too and drop some comments there, I'd be
happy to understand and collaborate to meet your requirements as well :)
[...]
> static const struct of_device_id arm_smmu_of_match[] = {
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> index f45c4bf84bc1..cd96ff9cbc54 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> @@ -792,6 +792,7 @@ struct arm_smmu_device {
>
> struct rb_root streams;
> struct mutex streams_mutex;
> +
> const struct arm_smmu_v3_impl *impl;
> };
>
> @@ -1004,6 +1005,8 @@ struct arm_smmu_v3_impl {
> int (*combined_irq_handle)(int irq, struct arm_smmu_device *smmu_dev);
> int (*smmu_evt_handler)(int irq, struct arm_smmu_device *smmu_dev,
> u64 *evt, struct ratelimit_state *rs);
> + int (*smmu_power_get)(struct arm_smmu_device *smmu);
> + int (*smmu_power_put)(struct arm_smmu_device *smmu);
> };
>
> struct arm_smmu_device *arm_smmu_v3_impl_init(struct arm_smmu_device *smmu);
> --
> 2.46.0
>
Thanks,
Praan
[1] https://lore.kernel.org/all/20250616203149.2649118-1-praan@google.com/
next prev parent reply other threads:[~2025-06-16 20:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 2:56 [RFC PATCH 0/8] Add mt8196 SMMU support Xueqi Zhang
2025-06-16 2:56 ` [RFC PATCH 1/8] dt-bindings: iommu: mediatek: Add mt8196 support Xueqi Zhang
2025-06-16 4:40 ` Rob Herring (Arm)
2025-06-16 14:27 ` Rob Herring
2025-06-17 6:28 ` Krzysztof Kozlowski
2025-06-16 2:56 ` [RFC PATCH 2/8] iommu/arm-smmu-v3: Add SMMU implementation Xueqi Zhang
2025-06-16 21:17 ` Pranjal Shrivastava
2025-06-16 2:56 ` [RFC PATCH 3/8] iommu/arm-smmu-v3: Add implementation for MT8196 MM SMMU Xueqi Zhang
2025-06-16 2:56 ` [RFC PATCH 4/8] iommu/arm-smmu-v3: Add implementation for MT8196 APU SMMU Xueqi Zhang
2025-06-16 2:56 ` [RFC PATCH 5/8] iommu/arm-smmu-v3: Add IRQ handle for smmu impl Xueqi Zhang
2025-06-16 21:32 ` Pranjal Shrivastava
2025-06-16 2:56 ` [RFC PATCH 6/8] iommu/arm-smmu-v3: mediatek: Add wrapper handle for IRQ Xueqi Zhang
2025-06-24 11:22 ` Will Deacon
2025-06-25 16:54 ` Marc Zyngier
2025-06-16 2:56 ` [RFC PATCH 7/8] iommu/arm-smmu-v3: Invoke rpm operation before accessing the hw Xueqi Zhang
2025-06-16 20:54 ` Pranjal Shrivastava [this message]
2025-06-16 2:56 ` [RFC PATCH 8/8] iommu/arm-smmu-v3: mediatek: Implement rpm get/put function Xueqi Zhang
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=aFCEb744WpRpcDxM@google.com \
--to=praan@google.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ning.li@mediatek.com \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=xueqi.zhang@mediatek.com \
--cc=yong.wu@mediatek.com \
/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;
as well as URLs for NNTP newsgroup(s).