From: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
To: Robin Murphy <Robin.Murphy-5wv7dgnIgG8@public.gmane.org>
Cc: "laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org"
<laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
"linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org"
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
"iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage
Date: Tue, 28 Jul 2015 17:06:32 +0100 [thread overview]
Message-ID: <20150728160632.GQ29209@arm.com> (raw)
In-Reply-To: <55B7A439.3000007-5wv7dgnIgG8@public.gmane.org>
On Tue, Jul 28, 2015 at 04:48:09PM +0100, Robin Murphy wrote:
> On 28/07/15 11:18, Will Deacon wrote:
> > On Mon, Jul 27, 2015 at 07:18:10PM +0100, Robin Murphy wrote:
> >> With the correct DMA API calls now integrated into the io-pgtable code,
> >> let that handle the flushing of non-coherent page table updates.
> >>
> >> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
> >> ---
> >> drivers/iommu/arm-smmu.c | 23 +++++++----------------
> >> 1 file changed, 7 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> >> index 9a59bef..9501668 100644
> >> --- a/drivers/iommu/arm-smmu.c
> >> +++ b/drivers/iommu/arm-smmu.c
> >> @@ -610,24 +610,13 @@ static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size,
> >> static void arm_smmu_flush_pgtable(void *addr, size_t size, void *cookie)
> >> {
> >> struct arm_smmu_domain *smmu_domain = cookie;
> >> - struct arm_smmu_device *smmu = smmu_domain->smmu;
> >> - unsigned long offset = (unsigned long)addr & ~PAGE_MASK;
> >>
> >> -
> >> - /* Ensure new page tables are visible to the hardware walker */
> >> - if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK) {
> >> + /*
> >> + * Ensure new page tables are visible to a coherent hardware walker.
> >> + * The page table code deals with flushing for the non-coherent case.
> >> + */
> >> + if (smmu_domain->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)
> >> dsb(ishst);
> >> - } else {
> >> - /*
> >> - * If the SMMU can't walk tables in the CPU caches, treat them
> >> - * like non-coherent DMA since we need to flush the new entries
> >> - * all the way out to memory. There's no possibility of
> >> - * recursion here as the SMMU table walker will not be wired
> >> - * through another SMMU.
> >> - */
> >> - dma_map_page(smmu->dev, virt_to_page(addr), offset, size,
> >> - DMA_TO_DEVICE);
> >> - }
> >> }
> >>
> >> static struct iommu_gather_ops arm_smmu_gather_ops = {
> >> @@ -899,6 +888,8 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
> >> .oas = oas,
> >> .tlb = &arm_smmu_gather_ops,
> >> };
> >> + if (!(smmu->features & ARM_SMMU_FEAT_COHERENT_WALK))
> >> + pgtbl_cfg.iommu_dev = smmu->dev;
> >
> > Ideally, I'd like to set the dev unconditionally and kill the flush_pgtable
> > callback. See my comments on the other patch.
>
> I'm not sure setting dev unconditionally would be right - we'd end up
> doing a load of busy work in the DMA API to decide to do nothing and
> never get a barrier out of it. We could have a "bool coherent" in the
> cfg to make the wmb() happen, but the mere absence of dev would do that
> job just as well (wmb() isn't going to need it to report anything,
> unlike the DMA API path); either way flush_pgtable can go.
I think we should move to using the DMA API as step (1), then discuss its
inefficiencies in step (2) :) No point working around perceived performance
issues before we know they're actually hurting us.
Will
next prev parent reply other threads:[~2015-07-28 16:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 18:18 [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use Robin Murphy
[not found] ` <c8cc82fea26044e393ff857014d4146faac5ec1e.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-27 18:18 ` [PATCH 2/5] iommu/arm-smmu: Sort out coherency Robin Murphy
[not found] ` <4d5880f2131854bc59107ccc917993136e511341.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-28 9:43 ` Will Deacon
[not found] ` <20150728094349.GE29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:17 ` Robin Murphy
2015-07-27 18:18 ` [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage Robin Murphy
[not found] ` <921980a38ec7d35610c68e8e94235c55318ba80c.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-28 10:18 ` Will Deacon
[not found] ` <20150728101810.GG29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:48 ` Robin Murphy
[not found] ` <55B7A439.3000007-5wv7dgnIgG8@public.gmane.org>
2015-07-28 16:06 ` Will Deacon [this message]
2015-07-27 18:18 ` [PATCH 4/5] iommu/arm-smmu-v3: " Robin Murphy
2015-07-27 18:18 ` [PATCH 5/5] iommu/ipmmu-vmsa: " Robin Murphy
2015-07-28 10:17 ` [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use Will Deacon
[not found] ` <20150728101722.GF29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:39 ` Robin Murphy
[not found] ` <55B7A22B.6010608-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:52 ` Will Deacon
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=20150728160632.GQ29209@arm.com \
--to=will.deacon-5wv7dgnigg8@public.gmane.org \
--cc=Robin.Murphy-5wv7dgnIgG8@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.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