Revision 1 as of 2005-05-28 20:33:54

Clear message


 * W O R K - I N - P R O G R E S S
 * It seems that I'm going to have to leave town for the better part of 2 weeks. If someone would like to continue working on this document, I will not be offended ;)

What is DMA?

DMA or Direct Memory Access is a feature provided by most modern IDE chipsets that allows the IDE interfaces to talk to one another using the system memory; therefore using substatially less system processing power.

For a detailed description of DMA visit the IEEE


WARNING: Enabling DMA can be dangerous in some cases. Usually issues are directly related to faulty hardware, poorly written drivers, or using settings that are unsupported by your system. USING HDPARM INCORECTLY CAN CAUSE MAJOR DATA CURRUPTION/LOSS. The good news is that most new systems will support DMA beautifully Smile :-)

NOTE: If your drives are configured in Cable Select mode and while running hdparm commands you receive erros related to timeouts or drive not ready, try changing the drive to be a master or slave device depending on your system configuration. This does require opening the case and as far as I know most drives are set to Cable Select from the manufacturer. I plan to add a tutorial for doing this with some more specific error messages.

Understanding the "hdparm" command

As with most other [CLI] (I plan to write a "using the CLI" tutorial soon) applications in linux, there is a man page for hdparm Since hdparm and most other Linux applications are well documented, it is ALWAYS a good idea to read the man page. Most of the specifics for hdparm in this document are taken from the man pages.

/*** To access the hdparm man page ***/
$ man hdparm 

/*** To run an hdparm test on /dev/hda ***/
$ sudo hdparm -tT /dev/hda

/*** To see what the hdparm settings are on /dev/hda ***/
$ sudo hdparm /dev/hda

/*** For more detailed information about /dev/hda ***/
$ sudo hdparm -i /dev/hda

It is important to note that the hdparm speed test is not a very accurate representation of system performance. It does, however, give you a pretty good idea of throughput on your drives. There are other utilities that will provide more accurate results. Perhaps I will include a list of these at a later time. Below is an example hdparm test with DMA turned off.

$ sudo hdparm -d0 /dev/hda   //Turn off DMA
/*** Output removed ***/

$ sudo hdparm -tT /dev/hda

 Timing cached reads:   1460 MB in  2.00 seconds = 729.38 MB/sec
 Timing buffered disk reads:    8 MB in  3.02 seconds =   2.65 MB/sec

Configuring your system

Now that you're a pro with hdparm and know everything about every option and feature that it provides let's take a look at a real-world example. In this particular example I'm running: P4 2.53Ghz; 512Mb RAM; 533Mhz FSB; Intel ICH4 Chipset; 7200RPM 80G /dev/hda; Hoary Hedgehog; 2.6.10-686 (will put $uname -r). Below are the initial settings for my /dev/hda right after a fresh Hoary install:

# current_speed (X) -- Represents that current speed of the IDE Channel (69=UDMA5)
# io_32bit      (c) -- Data transfer resolution (0=16bit, 1=32bit, 3=32bit w/ sync)
# multcount     (m) -- DANGEROUS. Number of sectors to read at one time (0-32, most will use 16)
# unmaskirq     (u) -- DANGEROUS. Allow access to other interrupts while waiting for response (0=off, 1=on) 
# using_dma     (d) -- Simply enables (1) or disables (0) Direct Memory Access

$ cat /proc/ide/hda/settings
name                    value   min     max     mode
----                    -----   ---     ---     ----
current_speed           69      0       70      rw
io_32bit                0       0       3       rw
multcount               0       0       16      rw
unmaskirq               0       0       1       rw
using_dma               1       0       1       rw
/*** Removed some options to maintain document scope ***/

Now that we've examined our current settings and know a little bit about what the options for hdparm do, let's play! First let's try some basic settings. Let's enable DMA and 32bit transfers.

$ sudo hdparm -d1c1 /dev/hda
 setting using_dma flag to 1
 setting 32-bit IO_support flag to 1
 IO_support   =  1 (32-bit)
 using_dma    =  1 (on)

$ sudo hdparm -tT /dev/hda

YAY -- how speedy Smile :) Let's take it one step further and see if enabling Multiple Sector Reading will help.

$ sudo hdparm -m16 /dev/hda    //multiple_sector_count=16

 setting multcount to 16
 multcount    = 16 (on)

$ sudo hdparm -tT /dev/hda

Applying settings at boot

In order for the settings to be automatically applied at boot there are a few methods, both with ups and downs. In Ubuntu there is an /etc/hdparm.conf script. This script will enable DMA for Hard Disk Drives Only as it runs before any other drivers are loaded. This may not be the case on ALL systems but in my experience... The other option is to add some lines to /etc/init.d/

/*** These are from my /etc/init.d/ ***/
/sbin/hdparm -m16C3 /dev/hda             # sets multcount=16 && 32bit w/sync
/sbin/hdparm -m16C3 /dev/hdb             # sets multcount=16 && 32bit w/sync
/sbin/hdparm -d1u1c1X66 /dev/hdc         # dma=on unmaskirq=on 32bit UDMA2
/sbin/hdparm -d1u1c1X66 /dev/hdd         # dma=on unmaskirq=on 32bit UDMA2