# [SOLVED] HDPARM please validate settings.

## SAngeli

Hi,

I have two CD-Roms and wish to make sure I have them set properly.

IDE0 (Master) I have a CD-RW LG HL-DT-ST GCE-8526B

```
/dev/hda:

 Model=HL-DT-ST GCE-8526B, FwRev=1.00, SerialNo=

 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }

 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0

 BuffType=unknown, BuffSize=0kB, MaxMultSect=0

 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0

 IORDY=yes, tPIO={min:227,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4

 DMA modes:  mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 udma2

 AdvancedPM=no

 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 3a:

/dev/hda:

 IO_support   =  1 (32-bit)

 unmaskirq    =  1 (on)

 using_dma    =  0 (off)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 HDIO_GETGEO failed: Invalid argument
```

IDE0 (Slave) I have a DVD-RW LG HL-DT-STDVDRRW GSA-4166B

```
/dev/hdb:

 Model=HL-DT-STDVDRRW GSA-4166B, FwRev=1.01, SerialNo=

 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }

 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0

 BuffType=unknown, BuffSize=0kB, MaxMultSect=0

 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0

 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4

 DMA modes:  sdma0 sdma1 sdma2 mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 udma2

 AdvancedPM=no

 Drive conforms to: device does not report version:

/dev/hdb:

 IO_support   =  0 (default 16-bit)

 unmaskirq    =  0 (off)

 using_dma    =  0 (off)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 HDIO_GETGEO failed: Invalid argument
```

Is it possible please to tell me what command would go into the file /etc/conf.d/hdparm?

I currently have: 

hda_args="-c1d1u1 -X66"

hdb_args="-c1d1u1 -X66"

Also, how to verify if after gentoo finishes to boot hdparm implemented these changes?

Thank you,

SpiroLast edited by SAngeli on Mon Jan 02, 2006 6:41 pm; edited 1 time in total

----------

## NeddySeagoon

SAngeli,

You have DMA off, so I suspect your kerle is missing support for your IDE chipset.

hdparm is not needed if your kernel is right.

----------

## SAngeli

Hi,

How do I know if I have my CD and DVD working being optimized?

Also, I was under the impression that hdparm should always be used. As a matter of fact, if I run to check DMA I get:

```
# hdparm -d /dev/hdb

/dev/hdb:

 using_dma    =  0 (off)

~ # hdparm -d /dev/hda

/dev/hda:

 using_dma    =  0 (off)

# hdparm -Tt /dev/hda

/dev/hda:

 Timing cached reads:   4236 MB in  2.00 seconds = 2116.21 MB/sec

 Timing buffered disk reads:    8 MB in  3.01 seconds =   2.66 MB/sec

# hdparm -Tt /dev/hdb

/dev/hdb:

 Timing cached reads:   4028 MB in  2.00 seconds = 2012.29 MB/sec

 Timing buffered disk reads:    6 MB in  3.08 seconds =   1.95 MB/sec
```

It seems DVD is slower. Humm...

Here is my kernel settings:

```
<*> ATA/ATAPI/MFM/RLL support

<*>   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support

<*>     Include IDE/ATA-2 DISK support

<*>     Include IDE/ATAPI CDROM support

<*>     generic/default IDE chipset support

[*]     PCI IDE chipset support

[*]       Generic PCI bus-master DMA support 

[*]         Use PCI DMA by default when available
```

What is that I have missing and what is that I do not understand? Please explain if possible.

// EDIT //

What about this setting in /etc/conf.d/hdparm for my devices?

```
hda_args="-A1 -d1 -u1 -c3 -X66 -W1 -m16"

hdb_args="$hda_args" 
```

// EDIT //

thanks,

Spiro

----------

## gringo

 *Quote:*   

> [*]         Use PCI DMA by default when available
> 
> [ ]           Enable DMA only for disks

 

in the same kernel section you have the above options. How are these set ?

Anyways, what does a hdparm -d1 /dev/hdX return ? 

A DMA enabled drive is a bit snappier than 2 MB/sec  :Wink: 

 *Quote:*   

> What about this setting in /etc/conf.d/hdparm for my devices? 

 

did you add the hdparm script to a runlevel ?

cheers

----------

## NeddySeagoon

SAngeli,

You dont say what your IDE chipset is - lspci will tell you.

Then in the same menu as 

```
<*> ATA/ATAPI/MFM/RLL support

<*>   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support

<*>     Include IDE/ATA-2 DISK support

<*>     Include IDE/ATAPI CDROM support

<*>     generic/default IDE chipset support

[*]     PCI IDE chipset support

[*]       Generic PCI bus-master DMA support

[*]         Use PCI DMA by default when available
```

choose your chipset driver as built in (they are all at the bottom of the menu).

Now rebuild and reinstall your kernel.

----------

## SAngeli

Hi,

here is the output of my lspci:

```
0000:00:00.0 Memory controller: nVidia Corporation CK804 Memory Controller (rev a3)

0000:00:01.0 ISA bridge: nVidia Corporation CK804 ISA Bridge (rev a3)

0000:00:01.1 SMBus: nVidia Corporation CK804 SMBus (rev a2)

0000:00:02.0 USB Controller: nVidia Corporation CK804 USB Controller (rev a2)

0000:00:02.1 USB Controller: nVidia Corporation CK804 USB Controller (rev a3)

0000:00:04.0 Multimedia audio controller: nVidia Corporation CK804 AC'97 Audio Controller (rev a2)

0000:00:06.0 IDE interface: nVidia Corporation CK804 IDE (rev f2)

0000:00:07.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)

0000:00:08.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)

0000:00:09.0 PCI bridge: nVidia Corporation CK804 PCI Bridge (rev a2)

0000:00:0b.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

0000:00:0c.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

0000:00:0d.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

0000:00:0e.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

0000:00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration

0000:00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map

0000:00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller

0000:00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control

0000:01:00.0 VGA compatible controller: nVidia Corporation NV43 [GeForce 6600 GT] (rev a2)

0000:05:06.0 Ethernet controller: 3Com Corporation 3c905C-TX/TX-M [Tornado] (rev 74)

0000:05:0b.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22/A IEEE-1394a-2000 Controller (PHY/Link)
```

Which one whould it be?  Could it be this one? 

< >         AMD and nVidia IDE support

Also, to make sure i got this right: By selecting this in my kernel I:

1) Do not have to select any hdparm setting in /etc/conf.d/hdparm ?

2) Hence, I do not need hdparm | boot in rc-update at all

Correct?

Thanks,

Spiro

----------

## Kaapeli

Correct. As soon as you have proper support for your hardware built in your kernel and you have the "Use PCI DMA by default when available" option enabled aswell, there is no need to manually enable DMA for disks or CD/DVD drives, the kernel will enable it automatically on boot.

----------

## SAngeli

Hi Kaapeli,

two questions then:

1) Do I still have to manually run rc-update add hdparm boot?

2) What is the proper kernel entry based on my lspci for dma?

thanks,

Spiro

----------

## NeddySeagoon

SAngeli,

When your kernel is correct, there is no need to run hdparm at boot. You should 

```
rc-update del 
```

it.

You correctly identified

```
< > AMD and nVidia IDE support
```

as the option to build into your kernel

----------

## SAngeli

Hi,

thank you so much. I now know how to handle for future installs hdparm

One more question. When I make changes to my kernel and recompile I have to manually cp few files.

Is it possible to create a script or similar file that would:

- cd /usr/src/linux

- prompts a worning saying "Are you sure you wish to proceed [Y/n]"

- make && make modules_install

- mount /dev/sda1 /boot

- cp arch/x86_64/boot/bzImage /boot/bzImage-2.6.12-r9-k8 

- cp System.map /boot/System-2.6.12-r9-k8.map

- cp .config /boot/kernel_backup-2.6.12-r9-k8

- ls -l /boot/System-2.6.12-r9-k8.map && ls -l /boot/bzImage-2.6.12-r9-k8  && ls -l /boot/kernel_bk-2.6.12-r9-k8

- umount /boot

- Worning message saying "DONE"

This way I can always run it and avoid typing all the times the same code lines.

Where would I save it, what permissions would I give, what ownership?

Also, if I wish to pass a new file name (ex: instead of bzImage-2.6.12-r9-k8 I wish to give bzImage-2.6.13-r1-k8) what would I type inside this script so than when I run it I will also pass the new name? Like at konsole I would type "<script_name> 13-r1-k8" as an example?

Lastly, if I do enable dma from kernel and do not need hdparm to activate it at boot, what about those customizations I could implement? What about them? Can I still apply them? If so, where and how?

Thanks

Spiro

----------

## NeddySeagoon

SAngeli,

You wrote it - the only thing I have not done is the 'Are you sure'

Its not tested either

```
#!/bin/bash

echo "This script is in the public domain"

echo " If it breaks you get to keep all the pieces"

cd /usr/src/linux

#prompts a worning saying "Are you sure you wish to proceed [Y/n]"

make 

make modules_install

mount /dev/sda1 /boot

cp arch/x86_64/boot/bzImage /boot/bzImage-2.6.12-r9-k8

cp System.map /boot/System-2.6.12-r9-k8.map

cp .config /boot/kernel_backup-2.6.12-r9-k8

ls -l /boot/System-2.6.12-r9-k8.map

ls -l /boot/bzImage-2.6.12-r9-k8

ls -l /boot/kernel_bk-2.6.12-r9-k8

umount /boot

echo "Worning message saying DONE" 
```

The script contains commands that can only be executed by root, so it must run as root. It should therefore be owned by root.

It will need eXecute permissions, since it needs to run.

To pass in a new name use the &1 parameter

&1 is the first paramter passed to the script on its command line.

&2 the second and so on.

----------

## SAngeli

does it matter where I would save it and where would you advice to save it?

And what about this?

 *Quote:*   

> Lastly, if I do enable dma from kernel and do not need hdparm to activate it at boot, what about those customizations I could implement? What about them? Can I still apply them? If so, where and how? 

 

Any idea?

Happy new Year!!

Spiro

----------

## NeddySeagoon

SAngeli,

There are no useful customisations that do not result in slowing down the data trasfer rate.

You can still run hdparm by hand if you want to or you can leave it in rc-update so these customisations will be applied automatically.

Which ones did you have in mind ?

edit =====

You can save the script in /root or your /home/SAngeli or even in /usr/src

----------

## SAngeli

Hi NeddySeagoon,

(happy new year to you!)

Based on what I first posted in this thread, I was thinking on:

hda_args="-c1d1u1 -X66"

hdb_args="-c1d1u1 -X66" 

After I applied kernel changes, removed "hdparm boot" from run level and rebooted my PC I get:

First HD on IDE0 (Master)

CD-RW LG HL-DT-ST GCE-8526B

```
~ # hdparm /dev/hda

/dev/hda:

 IO_support   =  1 (32-bit)

 unmaskirq    =  1 (on)

 using_dma    =  1 (on)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 HDIO_GETGEO failed: Invalid argument
```

```
~ # hdparm -d /dev/hdb

/dev/hdb:

 using_dma    =  1 (on)
```

```
hdparm -i /dev/hda

/dev/hda:

 Model=HL-DT-ST GCE-8526B, FwRev=1.00, SerialNo=

 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }

 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0

 BuffType=unknown, BuffSize=0kB, MaxMultSect=0

 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0

 IORDY=yes, tPIO={min:227,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4

 DMA modes:  mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 *udma2

 AdvancedPM=no

 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 3a:

 * signifies the current active mode
```

```
~ # hdparm -I /dev/hda

/dev/hda:

ATAPI CD-ROM, with removable media

        Model Number:       HL-DT-ST GCE-8526B

        Serial Number:

        Firmware Revision:  1.00

Standards:

        Supported: CD-ROM ATAPI-3 -4 -5 -6

Configuration:

        DRQ response: 50us.

        Packet size: 12 bytes

Capabilities:

        LBA, IORDY(cannot be disabled)

        DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2

             Cycle time: min=120ns recommended=120ns

        PIO: pio0 pio1 pio2 pio3 pio4

             Cycle time: no flow control=227ns  IORDY flow control=120ns

Commands/features:

        Enabled Supported:

                DEVICE RESET cmd

                PACKET command feature set

HW reset results:

        CBLID- below Vih

        Device num = 0
```

Second HD on IDE0 (Slave)

DVD-RW LG HL-DT-STDVDRRW GSA-4166B

```
~ # hdparm /dev/hdb

/dev/hdb:

 IO_support   =  1 (32-bit)

 unmaskirq    =  1 (on)

 using_dma    =  1 (on)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 HDIO_GETGEO failed: Invalid argument
```

```
~ # hdparm -d /dev/hda

/dev/hda:

 using_dma    =  1 (on)
```

```
~ # hdparm -i /dev/hdb

/dev/hdb:

 Model=HL-DT-STDVDRRW GSA-4166B, FwRev=1.01, SerialNo=

 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }

 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0

 BuffType=unknown, BuffSize=0kB, MaxMultSect=0

 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0

 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4

 DMA modes:  sdma0 sdma1 sdma2 mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 udma2

 AdvancedPM=no

 Drive conforms to: device does not report version:

 * signifies the current active mode
```

```
~ # hdparm -I /dev/hdb

/dev/hdb:

ATAPI CD-ROM, with removable media

        Model Number:       HL-DT-STDVDRRW GSA-4166B

        Serial Number:

        Firmware Revision:  1.01

Standards:

        Likely used CD-ROM ATAPI-1

Configuration:

        DRQ response: 50us.

        Packet size: 12 bytes

Capabilities:

        LBA, IORDY(can be disabled)

        DMA: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 *udma4

             Cycle time: min=120ns recommended=120ns

        PIO: pio0 pio1 pio2 pio3 pio4

             Cycle time: no flow control=120ns  IORDY flow control=120ns
```

Are the above settings ok? I believe so. But please confirm this for me.

If so, indeed I do not need any kind of custom change and you are correct: no need for anything else.

thank you,

Spiro

----------

## NeddySeagoon

SAngeli,

(happy new year to you too)

```
hdb_args="-c1d1u1 -X66" 
```

You no longer need -d1 and -X66 is dangerous. This way you can actually set the drive and the chip set to do different things at the same time. Your data will probably not survive. -u1 can cause the system to drop out of DMA mode altogether. It allows other IRQs to be serviced in the middle of a disk read, when the extra time for these IRQs results in a DMA timeout, the kernel will turn DMA off.

That leaves -c1, which turns on 32 bit transfers from the controller to memory (its still 16 bit from the drive to the controller)

You need to test this one. Do you get different hdparm -tT resuslts? 

If not, go with the kernel defualts and drop hdparm from you boot sequence.

----------

## SAngeli

Hi,

I believe all works great without any kind of custom settings.

thank you for explaining to my hdparm install.

Spiro

----------

