| Direct Memory Access |
Article Index for Direct |
Website Links For Direct |
Information AboutDirect Memory Access |
| CATEGORIES ABOUT DIRECT MEMORY ACCESS | |
| computer memory | |
| motherboard | |
|
Without DMA, using Programmed Input/output (PIO) mode, the CPU typically has to be occupied for the entire time it's performing a transfer. With DMA, the CPU would initiate the transfer, do other operations while the transfer is in progress, and receive an interrupt from the DMA controller once the operation has been done. This is especially useful in Real-time Computing applications where not stalling behind concurrent operations is critical. PRINCIPLE DMA is an essential feature of all modern computers, as it allows devices to transfer data without subjecting the CPU to a heavy overhead. Otherwise, the CPU would have to copy each piece of data from the source to the destination. This is typically slower than copying normal blocks of memory since access to I/O devices over a peripheral bus is generally slower than normal system RAM. During this time the CPU would be unavailable for any other tasks involving CPU bus access, although it could continue doing any work which did not require bus access. A DMA transfer essentially copies a block of memory from one device to another. While the CPU initiates the transfer, it does not execute it. For so-called "third party" DMA, as is normally used with the ISA bus, the transfer is performed by a DMA controller which is typically part of the motherboard chipset. More advanced bus designs such as PCI typically use Bus Mastering DMA, where the device takes control of the bus and performs the transfer itself. A typical usage of DMA is copying a block of memory from system RAM to or from a buffer on the device. Such an operation does not stall the processor, which as a result can be scheduled to perform other tasks. DMA transfers are essential to high performance Embedded System s. It is also essential in providing so-called Zero-copy implementations of peripheral Device Driver s as well as functionalities such as Network Packet Routing , Audio Playback and Streaming Video . CACHE COHERENCY PROBLEM DMA can lead to Cache Coherency problems. Imagine a CPU equipped with a cache and an external memory, which can be accessed directly by devices using DMA. When the CPU accesses location X in the memory, the current value will be stored in the cache. Subsequent operations on X will update its cached copy. If the cache is not flushed to the memory before the next time a device tries to access X, the device will receive a stale value of X. Similarly, if the cached copy of X is not invalidated when a device writes a new value to the memory, then the CPU will operate on a stale value of X. DMA ENGINES In addition to hardware interaction, DMA can also be used to offload expensive memory operations, such as large copies or scatter-gather operations, from the CPU to a dedicated DMA engine. While normal memory copies are typically too small to be worthwhile to offload on today's desktop computers, they are frequently offloaded on Embedded Device s due to more limited resources.1 Newer Intel Xeon processors also include a DMA engine technology called I/OAT, meant to improve network performance on high-throughput network interfaces, in particular Gigabit Ethernet and faster.2 However, various benchmarks with this approach by Intel's Linux Kernel developer Andrew Grover indicate no more than 10% improvement in CPU utilization with receiving workloads, and no improvement when transmitting data.3 Reconfigurable DMA circuits, for instance, based on GAG Generic Address Generator s, provide the enabling technology of Auto-sequencing Memory , programmable by Flowware to generate the data streams for running system architectures based on the Anti Machine paradigm, which could be called a DMA engine. EXAMPLES ISA For example, a PC's ISA DMA controller has 16 DMA channels of which 7 are available for use by the PC's CPU. Each DMA channel has associated with it a 16-bit address register and a 16-bit count register. To initiate a data transfer the device driver sets up the DMA channel's address and count registers together with the direction of the data transfer, read or write. It then instructs the DMA hardware to begin the transfer. When the transfer is complete, the device interrupts the CPU. " Scatter-gather " DMA allows the transfer of data to and from multiple memory areas in a single DMA transaction. It is equivalent to the chaining together of multiple simple DMA requests. Again, the motivation is to off-load multiple Input/output interrupt and data copy tasks from the CPU. DRQ stands for DMA request; DACK for DMA acknowledge. These symbols are generally seen on hardware Schematic s of computer systems with DMA functionality. They represent electronic signaling lines between the CPU and DMA controller. PCI As mentioned above, a PCI architecture has no central DMA controller, unlike ISA. Instead, any PCI component can request control of the bus ("become the Bus Master ") and request to read and write from the system memory. More precisely, a PCI component requests bus ownership from the PCI bus controller (usually the Southbridge in a modern PC design), which will arbitrate if several devices request bus ownership simultaneously, since there can only be one bus master at one time. When the component is granted ownership, it will issue normal read and write commands on the PCI bus, which will be claimed by the bus controller and forwarded to the memory controller using a scheme which is specific to every chipset. As an example, on a modern AMD Socket AM2 -based PC, the southbridge will forward the transactions to the Northbridge (which is integrated on the CPU die) using HyperTransport , which will in turn convert them to DDR2 operations and send them out on the DDR2 memory bus. As can be seen, there are quite a number of steps involved in a PCI DMA transfer; however, since the components outside the PCI bus are faster than the PCI bus itself by almost an order of magnitude or more (see List Of Device Bandwidths ), that poses little problem. AHB In operation. SEE ALSO REFERENCES
|
|
|