DMA

Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2005-07-15 03:08:12
Size: 5335
Editor: S0106000000cc07fc
Comment: minor tweaks, this page needs work
Revision 5 as of 2005-07-21 09:02:37
Size: 2058
Editor: S0106000000cc07fc
Comment: further work
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== What is DMA? == DMA or Direct Memory Access is a feature that allows harddrives and CD/DVD drives to access the system memory. The most common sign of DMA not being enabled is jumpy DVD playback.
Line 3: Line 3:
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. '''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 CORRUPTION AND/OR LOSS. Most systems newer than 3 years will support DMA.'''

== Enabling DMA ==

To enable DMA, you need to use the {{{hdparm}} command and the configuration file {{{hdparm.conf}}}.

This tutorial assumes you are trying to enabled DMA on hdc, usually the CD-rom drive.

 1. See the what the settings are on /dev/hdc
   {{{
   sudo hdparm /dev/hdc
   }}}
 1. If you get a line like {{{ using_dma = 1 (on)}}}, DMA is already enabled. Skip to step 4 to see if it has been enabled at boot time.
 1. Enable DMA on /dev/hdc
   {{{
   sudo hdparm -d1 /dev/hdc
   }}}
 1. You have now enabled DMA for the drive. However, in order for the settings to be automatically applied at boot there you need to edit the {{{/etc/hdparm.conf}}}} script. Add the following to the end of your hdparm.conf
   {{{
   /dev/hdc {
   dma = on
   }
   }}}

== Troubleshooting ==
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.

== Further reading ==
The hdparm has a further options that may be more risky. They can be seen using the {{{man hdparm}}} command in the terminal.
Line 10: Line 38:
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 CORRUPTION AND/OR LOSS. Most systems newer than 3 years will support DMA.

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] applications in linux, there is a man page for hdparm http://www.rt.com/man/hdparm.8.html. 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. 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

/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 ==
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-5-686. 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
}}}

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

/dev/hda:
 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/bootmisc.sh.

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

From GregTaylor Mon Jun 6 19:26:43 +0100 2005
From: Greg Taylor
Date: Mon, 06 Jun 2005 19:26:43 +0100
Subject: DMA/HDparm
Message-ID: <20050606192643+0100@https://www.ubuntulinux.org>

Shouldn't this hdparm tutorial be on a hdparm page rather than DMA? hdparm encompasses a lot more than DMA.
CategoryDocumentation

DMA or Direct Memory Access is a feature that allows harddrives and CD/DVD drives to access the system memory. The most common sign of DMA not being enabled is jumpy DVD playback.

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 CORRUPTION AND/OR LOSS. Most systems newer than 3 years will support DMA.

Enabling DMA

To enable DMA, you need to use the hdparm}} command and the configuration file {{{hdparm.conf.

This tutorial assumes you are trying to enabled DMA on hdc, usually the CD-rom drive.

  1. See the what the settings are on /dev/hdc
    •    sudo hdparm /dev/hdc
  2. If you get a line like  using_dma    =  1 (on), DMA is already enabled. Skip to step 4 to see if it has been enabled at boot time.

  3. Enable DMA on /dev/hdc
    •    sudo hdparm -d1 /dev/hdc
  4. You have now enabled DMA for the drive. However, in order for the settings to be automatically applied at boot there you need to edit the /etc/hdparm.conf} script. Add the following to the end of your hdparm.conf

    •    /dev/hdc {
         dma = on
         }

Troubleshooting

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.

Further reading

The hdparm has a further options that may be more risky. They can be seen using the man hdparm command in the terminal.

For a detailed description of DMA visit the IEEE http://standards.ieee.org/reading/ieee/std_public/description/busarch/1212.1-1993_desc.html

IDE, EIDE and UDMA http://www.spcug.org/reviews/bl0108.htm

CategoryDocumentation

DMA (last edited 2008-08-06 16:20:37 by localhost)