Direct memory access (DMA) channels are system pathways used by many devices including hard disk drives to transfer information directly to and from memory without having to contact other parts of the PC for help with the transfers.
DMA channels are not as popular as IRQs. This is mostly for a good reason: there are fewer of them around and they are used by many fewer devices, and hence they usually cause fewer problems with system setup. However, conflicts on DMA channels can cause very strange system problems and can be very difficult to diagnose. DMAs are used most commonly today by floppy disk drives, tape drives and sound cards.
DMA Channel Functions and Operations
This section takes a look at DMA channels and how they work. This includes an explanation of the different types of DMA channels, the DMA controller, and a summary of the different DMA channels used in the PC.
Why DMA Channels Were Invented
As you know, the processor is the "brain" of the machine, and in many ways it can also be likened to the conductor of an orchestra. In early machines the processor really did almost everything. In addition to running programs it was also responsible for transferring data to and from peripherals. Unfortunately, having the processor perform these transfers is very inefficient, because the processor is tied up doing other things and other tasks are put in a queue and completed only after the original task has been completed.
The advent of DMA enabled devices to cut out the "middle man", allowing the processor to do other work and the peripherals to transfer data themselves without any CPU intervention thus resulting in increased system performance. Special channels were created, along with circuitry to control them, which allowed the transfer of information without the processor doing anything. This circuitry is normally part of the system chipset on the motherboard.
It's important to note that DMA is an older technology and channels are only on the ISA bus (and EISA and VLB, since they are derivatives of it). PCI devices do not employ any DMA techniques.
Third-Party and First-Party DMA (Bus Mastering)
DMA is often referred to as "third party" DMA. This refers to the system DMA controller performing data transmission. There is also a DMA technique labelled "first party" DMA. In this scenario the peripheral doing the transferring of data actually takes control of the system bus to perform the transfer, a concept known as bus mastering. Bus mastering offers higher system performance than regular DMA because modern devices have much smarter and faster DMA circuitry built into them; older DMA based devices do not have this smarter technology built into them.
In addition to the older DMA technologies, newer DMA modes are available including Ultra DMA (mode 3 or DMA-33) and Ultra DMA (mode 4 or DMA 66) that provide for very high transfer rates.
Limitations Imposed By Standard DMA Technologies
While the use of DMA provided a significant improvement over processor-controlled data transfers, it too eventually reached a point where its performance became more of a bottleneck then a benefit. DMA on the ISA bus has been stuck at the same performance level for more than 10 years. For old 10 MB XT hard disks (now considered obsolete), DMA was a top performer. For a modern hard disk larger than 40 gigabytes (GB), DMA is insufficient.
On newer machines, disks are controlled using either programmed I/O (PIO) or first-party DMA (bus mastering) on the PCI bus, and not using the standard ISA DMA that is used for devices like sound cards. This type of DMA does not rely on the slow ISA DMA controllers, and allocates these high-performance devices the bandwidth required for DMA devices to perform adequately. In fact, many of the devices that once used DMA on the ISA bus employed bus mastering techniques over the PCI bus for faster performance. This includes newer high-end SCSI cards, and even network, video, and sound cards.
Standard DMA transfers are managed by the DMA controller, built into the system chipset on modern PCs. The original PC and XT based systems had one of these controllers and supported 4 DMA channels, 0 through 3.
Starting with the IBM AT, a second DMA controller was added. Much in the way that the second interrupt controller was cascaded with the first, the first DMA controller is cascaded to the second. The difference is that with IRQs, the second controller is cascaded to the first, but with DMAs the first is cascaded to the second. As a result, there are 8 DMAs, from 0 to 7, but DMA 4 is not usable. There is no rerouting as with IRQ2 and IRQ9 here, because all of the original DMAs (0 to 3) are still usable directly.
DMA Channels and the System Bus
All of the DMA channels except channel 4 are accessible to devices on the ISA system bus. Channel 4 is used to cascade the two DMA controllers together. PCI devices do not use standard system DMA channels.
As was the case with IRQs, the second DMA controller was added when the ISA bus was expanded to 16 bits with the creation of the AT. The lines to access these extra DMA channels were placed on the second part of the AT slot that is used by 16-bit cards. This means that only 16-bit cards can access DMA channels 5, 6 or 7. Unfortunately, many devices even today are still only 8-bit cards. You can tell by looking at them and seeing that they only use the first part of the two-part ISA bus connector on the motherboard.
DMA Request (DRQ) and DMA Acknowledgment (DACK)
Each DMA channel is comprised of two signals: the DMA request signal (DRQ) and the DMA acknowledgment signal (DACK). Some peripheral cards have separate jumpers for these instead of a single DMA channel jumper. If this is the case, make sure that the DRQ and DACK are set to the same number, otherwise the device won't work (I wonder what goes through the minds of some peripheral card designers
DMA, Multiple Devices and Conflicts
Like interrupts, DMA channels are single-device resources. If two devices try to use the same DMA channel at the same time, information will get mixed up between the two devices trying to use it, and any number of problems can be the result. DMA channel conflicts can be very difficult to diagnose. See here for more details on resource conflicts.
It is possible to share a DMA channel among more than one device, but only under limited conditions. In essence, if you have two devices that you seldom use, and that you never use simultaneously, you may be able to have them share a channel. However, this is not the preferred method since it is much more prone to problems than just giving each device its own resource.
One problem area with DMA channels is that most devices want to use DMA channels with numbers 0 to 3 (on the first DMA controller). DMA channels 5 to 7 are relatively unused because they require 16-bit cards. Considering that DMA channel 0 is never available, and DMA 2 is used for the floppy disk controller, that doesn't leave many options. On one of my systems I wanted to set up an ECP parallel port, a tape accelerator and a voice modem in addition to my sound card. I ran out of DMA channels between 1 and 3 very quickly. I still had DMA channels 6 and 7 open but could not use them because all the devices I wanted to use were either on 8-bit cards or wouldn't support the higher numbers for software reasons.
Speaking of the ECP parallel port, this is another new area of concern regarding DMA resource conflicts. Many people don't realize that this high-speed parallel port option requires the use of a DMA channel. (Your BIOS setup program will usually have a setting to select the DMA channel, right under where you enable ECP. This should be a good hint but still a lot of people don't notice this. The usual default for this port is DMA 3, which is also used by many other types of devices. The conflict resolution area of the Troubleshooting Expert can sometimes help with these situations.1
1-Portions of this article have been reprinted with permission from a variety of resources around the Web.