All of lore.kernel.org
 help / color / mirror / Atom feed
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 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use
Date: Tue, 28 Jul 2015 16:52:55 +0100	[thread overview]
Message-ID: <20150728155255.GP29209@arm.com> (raw)
In-Reply-To: <55B7A22B.6010608-5wv7dgnIgG8@public.gmane.org>

On Tue, Jul 28, 2015 at 04:39:23PM +0100, Robin Murphy wrote:
> On 28/07/15 11:17, Will Deacon wrote:
> >> +	if (cfg->tlb->flush_pgtable)
> >
> > Why would you have both a dev and a flush callback? In which cases is the
> > DMA API insufficient?
> 
> a) Bisectability given existing users.

You could still make it an if (dev) .. else if (flush_pgtable) ... though.
Then we could put the wmb() in the if () clause after the DMA-api calls
and remove the conditional once everybody has been ported over.

> >> +static void __arm_lpae_set_pte(arm_lpae_iopte *ptep, arm_lpae_iopte pte,
> >> +			       struct io_pgtable_cfg *cfg, void *cookie)
> >> +{
> >> +	struct device *dev = cfg->iommu_dev;
> >> +
> >> +	*ptep = pte;
> >> +
> >> +	if (dev)
> >> +		dma_sync_single_for_device(dev, __arm_lpae_dma(dev, ptep),
> >> +					   sizeof(pte), DMA_TO_DEVICE);
> >> +	if (cfg->tlb->flush_pgtable)
> >> +		cfg->tlb->flush_pgtable(ptep, sizeof(pte), cookie);
> >
> > Could we kill the flush_pgtable callback completely and just stick in a
> > dma_wmb() here? Ideally, we've have something like dma_store_release,
> > which we could use to set the parent page table entry, but that's left
> > as a future exercise ;)
> 
> I couldn't convince myself that there wouldn't never be some weird case 
> where an IOMMU driver still needs to do something funky for a coherent 
> device, so I left it in. Given that the existing implementations are 
> either dsb or nothing, however, I agree it may be worth taking out now 
> and only bringing back later if proven necessary.

Yeah, let's keep it as simple as we can and avoid giving people callbacks
unless they actually need them.

> I would think we'd need at least wmb() though, since dma_wmb() only 
> gives us a dmb on arm64; if the PTE is going from invalid to valid (i.e. 
> no TLB involved), we'd have the normal cacheable write of the PTE 
> potentially racing with an MMIO write after we return (the "do DMA with 
> this address" command to the master) and I think we might need a dsb to 
> avoid that - if the PTE write hasn't got far enough for the IOMMU to 
> snoop it, the walk hits the stale invalid entry, aborts the incoming 
> transaction and kills the device.

Yes, you're right. I was in a CPU-centric mindset and forgot that we can't
deal with transient faults when going from invalid -> valid for a device
mapping.

Will

      parent reply	other threads:[~2015-07-28 15:52 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
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 [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=20150728155255.GP29209@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.