Re: [RFC] MMIO accessors & barriers documentation



Benjamin Herrenschmidt wrote:
Ah ? What about the comment in e1000 saying that it needs a wmb()
between descriptor updates in memory and the mmio to kick them ? That
would typically be a memory_to_io_wb(). Or are your MMIOs ordered cs.
your cacheable stores ?

That's likely just following existing practice found in many network drivers. The following two design patterns have been copied across a great many network drivers:

1) When in a loop, reading through a DMA ring, put an "rmb()" at the top of the loop, to ensure that the compiler does not optimize out all memory loads after the first.

2) Use "wmb()" to ensure that just-written-to memory is visible to a PCI device that will be reading said memory region via DMA.

I don't claim that either of these is correct, just that's existing practice, perhaps in some case perpetuated by my own arch ignorance.

So, in a perfect world where I was designing my own API, I would create two new API functions:

prepare_to_read_dma_memory()
and
make_memory_writes_visible_to_dmaing_devices()

and leave the existing APIs untouched. Those are the two fundamental operations that are needed.

Jeff


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: starting and ending location in memory?
    ... think reading the memory will be fun or easy if not just impossible. ... It's a basic game when it comes to chatting and all that. ... How the heck do I "hook" onto an API on the fly ...
    (comp.programming)
  • Re: Recover/defrag memory API
    ... I can see that somehow it does recover a lot of memory. ... The answers you have been getting is that there IS NO SUCH API IT CAN USE. ... THAT CAN DEFRAG AND/OR RECOVER APPLICATION MEMORY. ... unless you, too, want to create fraud which destroys overall system performance. ...
    (microsoft.public.vc.mfc)
  • Re: [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation
    ... > The problem is that our driver and library implement an API that we don't ... > tells the library to register it. ... The app then goes on its merry way until ... at which point it tells the library to deregister the memory. ...
    (Linux-Kernel)
  • Re: Library design for downloading an unknown amount of data?
    ... easy to use api for all supported devices. ... The first one is the device layer, which itself consist of a protocol layer and a memory layout layer. ... An single dive is also a blob of binary data, but with some additional metadata that is required for parsing that data, such as current time at the time of the download, model/serial number, firmware revision, etc. ...
    (comp.lang.c)
  • Re: CE6.0 Driver Pointer Marshalling - passing pointers out only?
    ... VirtualAllocEx can be used to allocate memory in a specified process. ... Read/WriteProcessMemory can be used to access this memory. ... structures that relate to API parameters. ... Use VirtualCopyEx to map a region of kernel memory to the client's ...
    (microsoft.public.windowsce.platbuilder)