public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 1/3] ARM: mm: allow sub-architectures to override PCI I/O memory type
Date: Wed, 21 May 2014 10:20:57 +0200	[thread overview]
Message-ID: <8688804.rOhvi9AvoE@wuerfel> (raw)
In-Reply-To: <20140521052007.GA14888@obsidianresearch.com>

On Tuesday 20 May 2014 23:20:07 Jason Gunthorpe wrote:
> On Fri, May 16, 2014 at 10:53:33AM +0100, Will Deacon wrote:
> 
> > > Correct. Assume a PCI device uses PIO and DMA. It sends a DMA to main memory
> > > and lets the CPU know about the data using a level (IntA as opposed to MSI)
> > > interrupt. The CPU performs an outl() operation to an I/O port to let the
> > > hardware know it has received the IRQ and the response of the outl() is
> > > guaranteed to flush the DMA transaction: by the time the outl() completes
> > > we know that the data in memory is valid because it is strongly ordered
> > > relative to the DMA.
> 
> Keep in mind that the IntA message itself is going to flush the DMA,
> no sane host bridge implementation should process the IntA until all
> prior DMA writes are completed, just like MSI.

I was thinking of PCI, not PCIe here, where the interrupt can be directly
wired to the irqchip.

> Also, legacy non-MSI interrupts are always sharable, so the ISR must
> always start with a read of a device specific status reguster, which
> will also flush any DMA writes.

Right, good point.

> The simplest common scenario to show synchronous outl is this:
> 
> void pci_isr()
> {
>    if (inl(status_reg) & INT_PENDING)
>       outl(ACK_INT,status_reg);
> }
> 
> Where the outl is not expected to complete at the CPU until the device
> has lowered the level triggered interrupt line.
> 
> If outl is not synchronous then a spurious interrupt will be caused.
> 
> When converting a driver to MMIO you'd often have to do this:
> 
> void pci_isr()
> {
>    if (readl(status_reg) & INT_PENDING) {
>       writel(ACK_INT,status_reg);
>       readl(status_reg); // Synchronizing read, flushes write.
>    }
> }
> 
> Which is one of the software visible impacts of io vs mmio.
> 
> > Hmm, when you say `guaranteed to flush the DMA transaction', is that a PCI
> > requirement? If so, whether or not that DMA data is then visible to the CPU
> > is really specific to the host-controller implementation. It could easily be
> > buffered somewhere between the host controller and memory, for example.
> 
> PCI has the producer/consumer ordering model as part of the
> driving concept in the spec. Basically it wants to see the ordering
> model preserved right to the driver code itself.
> 
> Realistically, way back, archs that couldn't do the synchronous IO
> (like my old MIPS design) had to convert their drivers to MMIO and run
> that way. It never worked 100% properly, or made sense to try an use an
> async outl, even though some systems provided it 

Thanks for the extra background information!

	Arnd

  reply	other threads:[~2014-05-21  8:20 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15  9:18 [PATCHv3 0/3] ARM: implement workaround for Cortex-A9/PL310/PCIe deadlock Thomas Petazzoni
2014-05-15  9:18 ` [PATCHv3 1/3] ARM: mm: allow sub-architectures to override PCI I/O memory type Thomas Petazzoni
2014-05-15 13:21   ` Arnd Bergmann
2014-05-15 13:51     ` Thomas Petazzoni
2014-05-15 14:29       ` Will Deacon
2014-05-15 14:32         ` Arnd Bergmann
2014-05-15 15:34           ` Will Deacon
2014-05-15 15:55             ` Arnd Bergmann
2014-05-16  9:53               ` Will Deacon
2014-05-19 13:19                 ` Arnd Bergmann
2014-05-19 14:23                   ` Will Deacon
2014-05-19 16:40                     ` Arnd Bergmann
2014-05-19 16:50                       ` Will Deacon
2014-05-19 17:04                         ` Arnd Bergmann
2014-05-21  5:20                 ` Jason Gunthorpe
2014-05-21  8:20                   ` Arnd Bergmann [this message]
2014-05-15 17:53             ` Jason Gunthorpe
2014-05-16  9:57               ` Will Deacon
2014-05-16 15:33                 ` Jason Gunthorpe
2014-05-15  9:18 ` [PATCHv3 2/3] ARM: mm: add support for HW coherent systems in PL310 Thomas Petazzoni
2014-05-15  9:36   ` Catalin Marinas
2014-05-15 11:39     ` Thomas Petazzoni
2014-05-15 13:23   ` Arnd Bergmann
2014-05-15 13:35   ` Rob Herring
2014-05-15 13:46     ` Thomas Petazzoni
2014-05-15  9:18 ` [PATCHv3 3/3] ARM: mvebu: implement L2/PCIe deadlock workaround Thomas Petazzoni
2014-05-15  9:36   ` Catalin Marinas
2014-05-15 13:21   ` Jason Cooper
2014-05-15 13:50     ` Thomas Petazzoni
2014-05-15 15:31       ` Jason Cooper
2014-05-16  7:19         ` Thomas Petazzoni
2014-05-15 13:26   ` Arnd Bergmann
2014-05-15 14:22     ` Thomas Petazzoni

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=8688804.rOhvi9AvoE@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.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