From: Pranjal Shrivastava <praan@google.com>
To: Mostafa Saleh <smostafa@google.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Nicolin Chen <nicolinc@nvidia.com>,
Daniel Mentz <danielmentz@google.com>,
iommu@lists.linux.dev
Subject: Re: [RFC PATCH 1/5] iommu/arm-smmu-v3: Refactor arm_smmu_setup_irqs
Date: Fri, 21 Mar 2025 07:26:11 +0000 [thread overview]
Message-ID: <Z90Uk6UiBij2nXKH@google.com> (raw)
In-Reply-To: <Z9yW1r1rkYbCPUIX@google.com>
On Thu, Mar 20, 2025 at 10:29:42PM +0000, Mostafa Saleh wrote:
> On Wed, Mar 19, 2025 at 12:42:50AM +0000, Pranjal Shrivastava wrote:
> > Refactor arm_smmu_setup_irqs by splitting it into two parts, one for
> > registering interrupt handlers and the other one for enabling interrupt
> > generation in the hardware. This refactor helps in re-initialization of
> > hardware interrupts as part of a subsequent patch that enables runtime
> > power management for the arm-smmu-v3 driver.
> >
> > Signed-off-by: Pranjal Shrivastava <praan@google.com>
> > ---
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 50 ++++++++++++++++-----
> > 1 file changed, 38 insertions(+), 12 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 358072b4e293..80362d9f293b 100644
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > @@ -3985,12 +3985,24 @@ static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu)
> > }
> > }
> >
> > -static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
> > +static void arm_smmu_enable_irqs(struct arm_smmu_device *smmu)
> > {
> > - int ret, irq;
> > + int ret;
> > u32 irqen_flags = IRQ_CTRL_EVTQ_IRQEN | IRQ_CTRL_GERROR_IRQEN;
> >
> > - /* Disable IRQs first */
> > + if (smmu->features & ARM_SMMU_FEAT_PRI)
> > + irqen_flags |= IRQ_CTRL_PRIQ_IRQEN;
> > +
> > + ret = arm_smmu_write_reg_sync(smmu, irqen_flags,
> > + ARM_SMMU_IRQ_CTRL, ARM_SMMU_IRQ_CTRLACK);
> > + if (ret)
> > + dev_warn(smmu->dev, "failed to enable irqs\n");
> > +}
> > +
> > +static int arm_smmu_disable_irqs(struct arm_smmu_device *smmu)
> > +{
> > + int ret;
> > +
> > ret = arm_smmu_write_reg_sync(smmu, 0, ARM_SMMU_IRQ_CTRL,
> > ARM_SMMU_IRQ_CTRLACK);
> > if (ret) {
> > @@ -3998,6 +4010,19 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
> > return ret;
> > }
> >
> > + return 0;
> > +}
> > +
> > +static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
> > +{
> > + int ret, irq;
> > +
> > + /* Disable IRQs first */
> > + ret = arm_smmu_disable_irqs(smmu);
> > +
> > + if (ret)
> > + return ret;
> > +
> > irq = smmu->combined_irq;
> > if (irq) {
> > /*
> > @@ -4014,15 +4039,6 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
> > } else
> > arm_smmu_setup_unique_irqs(smmu);
> >
> > - if (smmu->features & ARM_SMMU_FEAT_PRI)
> > - irqen_flags |= IRQ_CTRL_PRIQ_IRQEN;
> > -
> > - /* Enable interrupt generation on the SMMU */
> > - ret = arm_smmu_write_reg_sync(smmu, irqen_flags,
> > - ARM_SMMU_IRQ_CTRL, ARM_SMMU_IRQ_CTRLACK);
> > - if (ret)
> > - dev_warn(smmu->dev, "failed to enable irqs\n");
> > -
> > return 0;
> > }
> >
> > @@ -4171,6 +4187,9 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
> > return ret;
> > }
> >
> > + /* Enable interrupt generation on the SMMU */
> > + arm_smmu_enable_irqs(smmu);
> > +
> > if (is_kdump_kernel())
> > enables &= ~(CR0_EVTQEN | CR0_PRIQEN);
> >
> > @@ -4754,6 +4773,13 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> > /* Check for RMRs and install bypass STEs if any */
> > arm_smmu_rmr_install_bypass_ste(smmu);
> >
> > + /* Setup interrupt handlers */
> > + ret = arm_smmu_setup_irqs(smmu);
> > + if (ret) {
> > + dev_err(smmu->dev, "failed to setup irqs\n");
>
> Every path that can fail in this function has a print already, I’d say
> remove the ones inside and keep this one, that also simplifies
> arm_smmu_disable_irqs() to one line.
I guess as per Nicolin's comment, this call would go away and only be
called during probe. But yes the enable_irqs() will be here. I guess I
could move the print statement out of enable irqs and put it here?
The arm_smmu_disable_irqs will be called from the setup_irqs mainly,
during probe, so I think we could leave it's print as is..
>
> Otherwise, besides Nicolin’s comment, it looks good.
>
> Thanks,
> Mostafa
Thanks,
Praan
next prev parent reply other threads:[~2025-03-21 7:26 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 0:42 [RFC PATCH 0/5] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 1/5] iommu/arm-smmu-v3: Refactor arm_smmu_setup_irqs Pranjal Shrivastava
2025-03-19 4:50 ` Nicolin Chen
2025-03-19 7:43 ` Pranjal Shrivastava
2025-03-20 22:29 ` Mostafa Saleh
2025-03-21 7:26 ` Pranjal Shrivastava [this message]
2025-03-25 16:19 ` Daniel Mentz
2025-03-26 19:35 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 2/5] iommu/arm-smmu-v3: Add a helper to wait till cmdq drains Pranjal Shrivastava
2025-03-20 22:30 ` Mostafa Saleh
2025-03-21 8:09 ` Pranjal Shrivastava
2025-03-25 17:50 ` Daniel Mentz
2025-03-26 19:36 ` Pranjal Shrivastava
2025-03-26 4:51 ` Daniel Mentz
2025-03-26 20:10 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 3/5] iommu/arm-smmu-v3: Implement pm_runtime & system sleep ops Pranjal Shrivastava
2025-03-20 22:33 ` Mostafa Saleh
2025-03-21 8:13 ` Pranjal Shrivastava
2025-03-26 4:52 ` Daniel Mentz
2025-03-28 7:47 ` Pranjal Shrivastava
2025-04-14 17:57 ` Nicolin Chen
2025-04-14 21:26 ` Nicolin Chen
2025-04-15 20:47 ` Pranjal Shrivastava
2025-04-15 22:28 ` Nicolin Chen
2025-04-16 10:24 ` Pranjal Shrivastava
2025-04-16 12:02 ` Jason Gunthorpe
2025-04-16 12:29 ` Pranjal Shrivastava
2025-04-16 12:42 ` Jason Gunthorpe
2025-04-16 12:52 ` Pranjal Shrivastava
2025-04-16 13:07 ` Jason Gunthorpe
2025-04-16 14:32 ` Pranjal Shrivastava
2025-04-15 20:37 ` Pranjal Shrivastava
2025-04-15 22:13 ` Nicolin Chen
2025-04-16 8:29 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 4/5] iommu/arm-smmu-v3: Enable pm_runtime and setup devlinks Pranjal Shrivastava
2025-03-20 22:34 ` Mostafa Saleh
2025-03-19 0:42 ` [RFC PATCH 5/5] iommu/arm-smmu-v3: Invoke pm_runtime before hw access Pranjal Shrivastava
2025-03-19 12:04 ` Jason Gunthorpe
2025-03-20 7:25 ` Pranjal Shrivastava
2025-03-20 12:54 ` Jason Gunthorpe
2025-03-20 13:22 ` Robin Murphy
2025-03-20 14:21 ` Pranjal Shrivastava
2025-03-20 22:36 ` Mostafa Saleh
2025-03-19 11:57 ` [RFC PATCH 0/5] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops Jason Gunthorpe
2025-03-19 16:07 ` Robin Murphy
2025-03-20 22:25 ` Mostafa Saleh
2025-03-21 14:18 ` Pranjal Shrivastava
2025-03-21 17:35 ` Robin Murphy
2025-03-24 17:36 ` Pranjal Shrivastava
2025-03-27 17:27 ` Mostafa Saleh
2025-03-28 9:13 ` Pranjal Shrivastava
2025-03-28 9:19 ` Pranjal Shrivastava
2025-03-28 13:18 ` Jason Gunthorpe
2025-03-28 15:08 ` Pranjal Shrivastava
2025-03-28 18:21 ` Jason Gunthorpe
2025-03-19 18:22 ` Robin Murphy
2025-03-19 19:46 ` Jason Gunthorpe
2025-03-20 21:00 ` Pranjal Shrivastava
2025-03-20 23:08 ` Jason Gunthorpe
2025-03-21 14:36 ` Pranjal Shrivastava
2025-03-22 0:00 ` Jason Gunthorpe
2025-03-20 22:28 ` Mostafa Saleh
2025-03-20 23:05 ` Jason Gunthorpe
2025-03-21 14:44 ` Pranjal Shrivastava
2025-03-21 15:30 ` Jason Gunthorpe
2025-03-24 17:53 ` Pranjal Shrivastava
2025-03-25 13:55 ` Jason Gunthorpe
2025-03-27 17:39 ` Mostafa Saleh
2025-03-28 13:21 ` Jason Gunthorpe
2025-03-20 14:13 ` Pranjal Shrivastava
2025-03-20 14:54 ` Jason Gunthorpe
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=Z90Uk6UiBij2nXKH@google.com \
--to=praan@google.com \
--cc=danielmentz@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.com \
--cc=will@kernel.org \
/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