DMA
5699
Comment: imported from the old wiki
|
3282
adding note that this works out of the box in dapper
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= DMA = | == Introduction == |
Line 3: | Line 3: |
{{{ * 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 ;) }}} |
If you experience jumpy DVD playback, slow CD ripping, or a general slow down when accessing optical drive(s) it may be because DMA is not enabled. DMA, or Direct Memory Access, lets hard drives and CD/DVD drives access the system memory. |
Line 8: | Line 5: |
== What is DMA? == | DMA is automatically enabled for drives that support it as from Ubuntu 6.06 (Dapper Drake). |
Line 10: | Line 7: |
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 INCORRECTLY CAN CAUSE MAJOR DATA CORRUPTION AND/OR LOSS. Most systems newer than 4 years support DMA.''' == Enabling DMA == To enable DMA, you need to use the {{{hdparm}}} command and the configuration file {{{hdparm.conf}}}. These instructions assume that you are trying to enable 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. To do this use this command: {{{sudo gedit /etc/hdparm.conf}}} Add the following to the end of your hdparm.conf {{{ /dev/hdc { dma = on } }}} (another way avoiding edit of hdparm.conf file is to simply run {{{sudo hdparm -d1 -k1 /dev/hdc}}} to keep saved the dma flag). == Troubleshooting == If your drives are configured in [Cable Select] mode and while running `hdparm` commands you receive errors 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. Sometimes step 3 above can fail with a "operation not permitted" message. You can fix this by editing the file /etc/modules: For an intel cpu put the lines {{{piix}}} {{{ide-core}}} above the line {{{ide-cd}}} For an amd cpu put the line {{{amd74xx}}} above {{{ide-cd}}} For a VIA Chipset put {{{via82cxxx}}} above {{{ide-cd}}} Then reboot and try steps 3-4 again.... == 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 17: | Line 81: |
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 :-) |
|
Line 20: | Line 82: |
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. |
|
Line 23: | Line 83: |
== Understanding the "hdparm" command == | == Problems == * My new 200G SATA drive does not support DMA at all. {{{ $ sudo hdparm -d1 /dev/sda |
Line 25: | Line 88: |
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 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. 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 /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 |
/dev/sda: setting using_dma to 1 (on) HDIO_SET_DMA failed: Inappropriate ioctl for device $ cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: SAMSUNG SP2004C Rev: VM10 Type: Direct-Access ANSI SCSI revision: 05 |
Line 51: | Line 98: |
== 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 TEST OUTPUT HERE }}} YAY -- how speedy :) 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 /dev/hda: setting multcount to 16 multcount = 16 (on) $ sudo hdparm -tT /dev/hda TEST OUTPUT HERE }}} == 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 # 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 }}} |
CategoryDocumentation |
Introduction
If you experience jumpy DVD playback, slow CD ripping, or a general slow down when accessing optical drive(s) it may be because DMA is not enabled. DMA, or Direct Memory Access, lets hard drives and CD/DVD drives access the system memory.
DMA is automatically enabled for drives that support it as from Ubuntu 6.06 (Dapper Drake).
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 INCORRECTLY CAN CAUSE MAJOR DATA CORRUPTION AND/OR LOSS. Most systems newer than 4 years support DMA.
Enabling DMA
To enable DMA, you need to use the hdparm command and the configuration file hdparm.conf.
These instructions assume that you are trying to enable DMA on hdc, usually the CD-rom drive.
See the what the settings are on /dev/hdc
sudo hdparm /dev/hdc
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.
Enable DMA on /dev/hdc
sudo hdparm -d1 /dev/hdc
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. To do this use this command: sudo gedit /etc/hdparm.conf
Add the following to the end of your hdparm.conf
/dev/hdc { dma = on }
(another way avoiding edit of hdparm.conf file is to simply run sudo hdparm -d1 -k1 /dev/hdc to keep saved the dma flag).
Troubleshooting
If your drives are configured in [Cable Select] mode and while running hdparm commands you receive errors 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.
Sometimes step 3 above can fail with a "operation not permitted" message. You can fix this by editing the file /etc/modules: For an intel cpu put the lines
piix
ide-core
above the line
ide-cd
For an amd cpu put the line
amd74xx
above
ide-cd
For a VIA Chipset put
via82cxxx
above
ide-cd
Then reboot and try steps 3-4 again....
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
Problems
* My new 200G SATA drive does not support DMA at all.
$ sudo hdparm -d1 /dev/sda /dev/sda: setting using_dma to 1 (on) HDIO_SET_DMA failed: Inappropriate ioctl for device $ cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: SAMSUNG SP2004C Rev: VM10 Type: Direct-Access ANSI SCSI revision: 05
DMA (last edited 2008-08-06 16:20:37 by localhost)