From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
Cc: Patrick Daly <pdaly@codeaurora.org>,
Jeffrey Hugo <jhugo@codeaurora.org>,
MSM <linux-arm-msm@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will.deacon@arm.com>,
lkml <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org,
Vivek Gautam <vivek.gautam@codeaurora.org>,
Robin Murphy <robin.murphy@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC 2/2] iommu: arm-smmu: Don't blindly use first SMR to calculate mask
Date: Wed, 12 Jun 2019 11:28:52 -0700 [thread overview]
Message-ID: <20190612182852.GA4814@minitux> (raw)
In-Reply-To: <CAOCk7Nocb7VO5xCcuK1FAPVdPr9U-7z8qOL4yt3ig=05e7brgg@mail.gmail.com>
On Wed 12 Jun 10:58 PDT 2019, Jeffrey Hugo wrote:
> On Wed, Jun 5, 2019 at 3:09 PM Bjorn Andersson
> <bjorn.andersson@linaro.org> wrote:
> >
> > With the SMRs inherited from the bootloader the first SMR might actually
> > be valid and in use. As such probing the SMR mask using the first SMR
> > might break a stream in use. Search for an unused stream and use this to
> > probe the SMR mask.
> >
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
>
> Reviewed-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
>
> I don't quite like the situation where the is no SMR to compute the mask, but I
> think the way you've handled it is the best option/
>
Right, if this happens we would end up using the smr_mask that was
previously calculated. We just won't update it based on the hardware.
> I'm curious, why is this not included in patch #1? Seems like patch
> #1 introduces
> the issue, yet doesn't also fix it.
>
You're right, didn't think about that. This needs to either predate that
patch or be included in it.
Thanks,
Bjorn
> > ---
> > drivers/iommu/arm-smmu.c | 20 ++++++++++++++++----
> > 1 file changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> > index c8629a656b42..0c6f5fe6f382 100644
> > --- a/drivers/iommu/arm-smmu.c
> > +++ b/drivers/iommu/arm-smmu.c
> > @@ -1084,23 +1084,35 @@ static void arm_smmu_test_smr_masks(struct arm_smmu_device *smmu)
> > {
> > void __iomem *gr0_base = ARM_SMMU_GR0(smmu);
> > u32 smr;
> > + int idx;
> >
> > if (!smmu->smrs)
> > return;
> >
> > + for (idx = 0; idx < smmu->num_mapping_groups; idx++) {
> > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx));
> > + if (!(smr & SMR_VALID))
> > + break;
> > + }
> > +
> > + if (idx == smmu->num_mapping_groups) {
> > + dev_err(smmu->dev, "Unable to compute streamid_mask\n");
> > + return;
> > + }
> > +
> > /*
> > * SMR.ID bits may not be preserved if the corresponding MASK
> > * bits are set, so check each one separately. We can reject
> > * masters later if they try to claim IDs outside these masks.
> > */
> > smr = smmu->streamid_mask << SMR_ID_SHIFT;
> > - writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(0));
> > - smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(0));
> > + writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(idx));
> > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx));
> > smmu->streamid_mask = smr >> SMR_ID_SHIFT;
> >
> > smr = smmu->streamid_mask << SMR_MASK_SHIFT;
> > - writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(0));
> > - smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(0));
> > + writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(idx));
> > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx));
> > smmu->smr_mask_mask = smr >> SMR_MASK_SHIFT;
> > }
> >
> > --
> > 2.18.0
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2019-06-12 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 21:08 [RFC 0/2] iommu: arm-smmu: Inherit SMR and CB config during init Bjorn Andersson
2019-06-05 21:08 ` [RFC 1/2] iommu: arm-smmu: Handoff SMR registers and context banks Bjorn Andersson
2019-06-12 18:07 ` Jeffrey Hugo
2019-06-12 18:42 ` Bjorn Andersson
2019-06-12 19:16 ` Jeffrey Hugo
2019-06-13 11:23 ` Robin Murphy
2019-06-13 22:49 ` Bjorn Andersson
2019-06-05 21:08 ` [RFC 2/2] iommu: arm-smmu: Don't blindly use first SMR to calculate mask Bjorn Andersson
2019-06-12 17:58 ` Jeffrey Hugo
2019-06-12 18:28 ` Bjorn Andersson [this message]
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=20190612182852.GA4814@minitux \
--to=bjorn.andersson@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jeffrey.l.hugo@gmail.com \
--cc=jhugo@codeaurora.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pdaly@codeaurora.org \
--cc=robin.murphy@arm.com \
--cc=vivek.gautam@codeaurora.org \
--cc=will.deacon@arm.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).