# Can I choose between different drivers?

## Luda

Hi.

If I've got a kernel with

CONFIG_ATA_PIIX=y

and

CONFIG_BLK_DEV_PIIX=y

is there a way to choose which driver the system uses?

The reason for this question:

The new one (CONFIG_ATA_PIIX) seems to be broken:

The HDD in my laptop has 160 GB, which is approximately 149 Gibibyte.

- New driver: fdisk /dev/sda reports 137.4 GB, cfdisk says "FATAL ERROR: Bad primary partition 1: Partition ends after end-of-disk"

- Old driver: fdisk /dev/hda reports 160 GB, cfdisk works (partitiontable is fine)

Another way to solve this problem would be a (small)  live-cd with CONFIG_BLK_DEV_PIIX=m (or not set), CONFIG_BLK_DEV_PIIX=y/m, ATA_OVER_ETH=y/m and vblade installed.

----------

## msalerno

Why not just reconfigure your kernel and recompile?

There might be something in here: http://www.kernel.org/doc/Documentation/kernel-parameters.txt

----------

## Luda

Hi msalerno, thanks for your reply.

Sadly I didn't find anything that sounds useful to me in that list. There are some libata-options, but I none of them switches to the old (deprecated) driver.

I didn't want to reconfigure the kernel because it's not a problem with any of my gentoo-installations:

I have got a laptop with a Pentium-M 1.6, which is quite slow.

So I boot a small system (right now it's a grml-live-cd) and start "vblade 0 0 eth0 /dev/sda2". The Partition can then by used by my desktop-computer (ATA_OVER_ETHERNET rocks).

I "cryptsetup luksOpen" the partition so I can see the LVM, mount the partitions I wanna mount, chroot into my laptops system and can use the power of my desktop computers CPU to "emerge -DuNav world" in no time.

It (basically) works.. I just can't mount the "last" two partitions.

So.. yeah, I think I could do some changes to the live-cd. Or I could install a small gentoo-system on the last partition, that gets copied into RAM before booting it...

I couls even try to boot grml with my gentoo-kernel, altough I'm quite sure that won't work...

----------

## Hu

Is this a regression over an earlier kernel which handled your drive correctly using the ATA_PIIX driver or has this never worked?  Either way, you should consider reporting this bug upstream.  If the old driver really is able to access regions that cannot be reached by the new driver, something is wrong.  Either the old driver is allowing writes into a reserved region (unlikely) or the new driver is mishandling the drive in some way.

----------

## NeddySeagoon

Luda,

When you have a kernel with two drivers configured for the same hardware, such as 

```
CONFIG_ATA_PIIX=y

and

CONFIG_BLK_DEV_PIIX=y 
```

they fight over the hardware and usually neither works properely.

```
fdisk /dev/sda reports 137.4 GB
```

 suggests that You are having issues with an old BIOS and the 137G limit for the old LBA standard.

Larger drives support 48bit Logical Block Addressing, as has the kernel for a very long time.

I suspect you have a jumper fitted to the drive to make it lie about its size to the BIOS. Its often called clipping but the kernel drivers, both of them, should see the fill size of the drive.

Set your kernel like this and report back. I'm assuming you have an Intel ICHx chipset but not having seen your lspci, I don't know for sure.

----------

## Luda

Hi

Yes, it's an ICH-Chipset, I will post the lspci -v-output in a second.

I've seen this behavior with Gentoo, different versions of Ubuntu and GRML.

There s no jumper on my HDD (Seagate ST9160821A) to set the maximum size.

And there is no BIOS-Update (Sony Vaio PCG-V505CP)

The GRML-kernel isn't actually configured 

```

CONFIG_ATA_PIIX=y

and

CONFIG_BLK_DEV_PIIX=y 

```

http://git.grml.org/?p=grml-kernel.git;a=blob;f=config/config-2.6.33-grml;hb=HEAD

I just thought I could compile and use the old driver If I knew how to tell the kernel which driver it should use for which piece of hardware.

```
blue ~ # lspci -v

00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 03)

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, fast devsel, latency 0

        Memory at e0000000 (32-bit, prefetchable) [size=256M]

        Capabilities: [e4] Vendor Specific Information: Len=04 <?>

        Capabilities: [a0] AGP version 2.0

        Kernel driver in use: agpgart-intel

        Kernel modules: intel-agp

00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 03) (prog-if 00 [Normal decode])

        Flags: bus master, 66MHz, fast devsel, latency 96

        Bus: primary=00, secondary=01, subordinate=01, sec-latency=64

        I/O behind bridge: 00003000-00003fff

        Memory behind bridge: d0100000-d01fffff

        Prefetchable memory behind bridge: d8000000-dfffffff

00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 03) (prog-if 00 [UHCI])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 9

        I/O ports at 1800 [size=32]

        Kernel driver in use: uhci_hcd

00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 03) (prog-if 00 [UHCI])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 9

        I/O ports at 1820 [size=32]

        Kernel driver in use: uhci_hcd

00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 03) (prog-if 00 [UHCI])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 9

        I/O ports at 1840 [size=32]

        Kernel driver in use: uhci_hcd

00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 03) (prog-if 20 [EHCI])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 9

        Memory at d0000000 (32-bit, non-prefetchable) [size=1K]

        Capabilities: [50] Power Management version 2

        Capabilities: [58] Debug port: BAR=1 offset=0080

        Kernel driver in use: ehci_hcd

00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 83) (prog-if 00 [Normal decode])

        Flags: bus master, fast devsel, latency 0

        Bus: primary=00, secondary=02, subordinate=06, sec-latency=168

        I/O behind bridge: 00004000-00004fff

        Memory behind bridge: d0200000-d02fffff

        Prefetchable memory behind bridge: 60000000-63ffffff

00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 03)

        Flags: bus master, medium devsel, latency 0

00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 03) (prog-if 8a [Master SecP PriP])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 255

        I/O ports at 01f0 [size=8]

        I/O ports at 03f4 [size=1]

        I/O ports at 0170 [size=8]

        I/O ports at 0374 [size=1]

        I/O ports at 1860 [size=16]

        Memory at 64000000 (32-bit, non-prefetchable) [size=1K]

        Kernel driver in use: PIIX_IDE

00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 03)

        Subsystem: Sony Corporation Device 816a

        Flags: medium devsel, IRQ 255

        I/O ports at 1880 [size=32]

00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 03)

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 0, IRQ 9

        I/O ports at 1c00 [size=256]

        I/O ports at 18c0 [size=64]

        Memory at d0000c00 (32-bit, non-prefetchable) [size=512]

        Memory at d0000800 (32-bit, non-prefetchable) [size=256]

        Capabilities: [50] Power Management version 2

        Kernel driver in use: Intel ICH

00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 03) (prog-if 00 [Generic])

        Subsystem: Sony Corporation Device 816a

        Flags: medium devsel, IRQ 9

        I/O ports at 2400 [size=256]

        I/O ports at 2000 [size=128]

        Capabilities: [50] Power Management version 2

01:00.0 VGA compatible controller: ATI Technologies Inc M9+ 5C61 [Radeon Mobility 9200 (AGP)] (rev 01) (prog-if 00 [VGA controller])

        Subsystem: Sony Corporation Device 816b

        Flags: bus master, fast Back2Back, 66MHz, medium devsel, latency 66, IRQ 9

        Memory at d8000000 (32-bit, prefetchable) [size=128M]

        I/O ports at 3000 [size=256]

        Memory at d0100000 (32-bit, non-prefetchable) [size=64K]

        [virtual] Expansion ROM at d0120000 [disabled] [size=128K]

        Capabilities: [58] AGP version 2.0

        Capabilities: [50] Power Management version 2

        Kernel driver in use: radeonfb

02:05.0 CardBus bridge: Ricoh Co Ltd RL5c475 (rev b8)

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 168, IRQ 9

        Memory at d0204000 (32-bit, non-prefetchable) [size=4K]

        Bus: primary=02, secondary=03, subordinate=06, sec-latency=176

        Memory window 0: 60000000-63fff000 (prefetchable)

        Memory window 1: 68000000-6bfff000

        I/O window 0: 00004400-000044ff

        I/O window 1: 00004800-000048ff

        16-bit legacy interface ports at 0001

        Kernel driver in use: yenta_cardbus

02:05.1 FireWire (IEEE 1394): Ricoh Co Ltd R5C551 IEEE 1394 Controller (prog-if 10 [OHCI])

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 64, IRQ 9

        Memory at d0203000 (32-bit, non-prefetchable) [size=2K]

        Capabilities: [dc] Power Management version 2

        Kernel driver in use: ohci1394

        Kernel modules: ohci1394

02:08.0 Ethernet controller: Intel Corporation 82801DB PRO/100 VE (MOB) Ethernet Controller (rev 83)

        Subsystem: Sony Corporation Device 816a

        Flags: bus master, medium devsel, latency 66, IRQ 9

        Memory at d0202000 (32-bit, non-prefetchable) [size=4K]

        I/O ports at 4000 [size=64]

        Capabilities: [dc] Power Management version 2

        Kernel driver in use: e100

02:0b.0 Network controller: Intersil Corporation ISL3886 [Prism Javelin/Prism Xbow] (rev 01)

        Subsystem: Z-Com, Inc. Device 0036

        Flags: bus master, medium devsel, latency 80, IRQ 9

        Memory at d0200000 (32-bit, non-prefetchable) [size=8K]

        Capabilities: [dc] Power Management version 1

        Kernel driver in use: p54pci

        Kernel modules: p54pci

blue ~ #
```

----------

## Luda

 *NeddySeagoon wrote:*   

> [...]
> 
> Set your kernel like this and report back.

 

New config:

```

[...]

 --- Serial ATA and Parallel ATA drivers                  

 [*]   Verbose ATA error reporting                        

 [*]   ATA ACPI Support                                   

 [*]   SATA Port Multiplier support                       

       *** Controllers with non-SFF native interface ***  

 < >   AHCI SATA support                                  

 < >   Platform AHCI SATA support                         

 < >   Initio 162x SATA support                           

 < >   Silicon Image 3124/3132 SATA support               

 [*]   ATA SFF support                                    

         *** SFF controllers with custom DMA interface ***

 < >     Pacific Digital ADMA support                     

 < >     Pacific Digital SATA QStor support               

 < >     Promise SATA SX4 support (Experimental)          

 [*]     ATA BMDMA support                                

           *** SATA SFF controllers with BMDMA ***        

 <*>       Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support 

[...]

```

Building and booting this kernel will take some time, I'll report back when it's done  :Wink: 

----------

## Luda

Wow.

I'm quite sure I didn't do anything different than before, but it works. 

The device is namend /dev/sda, the partitiontable is fine and the drive is reported with 160 GB.

I think I'll try this .config with an older kernel ans see If it was my fault or if it was a bug.

Thank you all very much =)

I'm still not sure if I want to use a live-cd (and which one) or create a minimal gentoo-installation that I copy to a RAM-drive before booting though.

----------

## Luda

Booted 2.6.35-gentoo-r2, drive worked fine

$ cd /usr/src/

$ cp linux-2.6.35-gentoo-r2/.config  linux-2.6.34-gentoo-r1/

$ rm linux

$ ln -s linux-2.6.34-gentoo-r1/ linux

$ cd linux

$ make oldconfig

$ genkernel all

$ reboot

Drive is reported to have 137 GB.

I guess it actually was due to a buggy driver and I started this thread shortly after the bug was fixed.

Thanks again =)

/edit:

I saw that with the new driver there is some unusual output while booting:

dmesg: http://pastebin.com/zDvHZ9iW

 *Quote:*   

> 
> 
> sd 0:0:0:0: [sda] 268435455 512-byte logical blocks: (137 GB/127 GiB)
> 
> ...
> ...

 

looks fine (I think...)

 *Quote:*   

> 
> 
> PCI: PCI BIOS revision 2.10 entry at 0xfd9c3, last bus=2
> 
> PCI: Using configuration type 1 for base access
> ...

 

on the other hand...

Okay, now I tried to boot the system with the irqpoll-option, which caused the system to slow down and then freeze while booting (tried it 3 times)

After that, I booted without the irqpoll option and everything worked just fine, without the error(?) messages.

I'm a bit confused right now...

----------

## NeddySeagoon

Luda,

There are a few issues in your dmesg.

```
irq 9: nobody cared (try booting with the "irqpoll" option)

...

Disabling IRQ #9
```

means that whatever was trying to use IRQ9 isn't working.  Add irqpoll to your kernel line in grub.conf.

It means the device will get polled instead of using an IRQ, which is slower, but it will still work.

Overall,

```
 sd 0:0:0:0: [sda] 268435455 512-byte logical blocks: (137 GB/127 GiB)

...

sda: p2 size 312319665 extends beyond EOD, enabling native capacity

ata1: soft resetting link

ata1.00: n_sectors mismatch 268435455 != 312581808

ata1.00: new n_sectors matches native, probably late HPA unlock, n_sectors updated

ata1.00: configured for UDMA/100

ata1: EH complete

sd 0:0:0:0: [sda] 312581808 512-byte logical blocks: (160 GB/149 GiB)

sda: detected capacity change from 137438952960 to 160041885696 
```

is ok.

Drives bigger than 137G report their size in two different areas of response to the identify command.

The first area reports 137G as thats the biggest number that fits in the allocated space.

The real size is reported in the LBA 48 area, which allocates 48 bits for the purpose.

However, drives can be programmed to lie about their size as space can be reserved for a Host Protected Area (HPA), which you won't normally see.

Laptop vendors typically put recovery information here as it takes some effort to delete it. Its not something you would do accidently. 

I'm not sure if your have a HPA or not. I suspect not or you would not see 

```
sda: p2 size 312319665 extends beyond EOD, enabling native capacity
```

since you would not be able to make a partition that extended into the HPA

----------

## Luda

 *NeddySeagoon wrote:*   

> Luda,
> 
> [...] Add irqpoll to your kernel line in grub.conf. [...]
> 
> 

 

I have already tried that:

 *Luda wrote:*   

> 
> 
> Okay, now I tried to boot the system with the irqpoll-option, which caused the system to slow down and then freeze while booting (tried it 3 times)
> 
> After that, I booted without the irqpoll option and everything worked just fine, without the error(?) messages.
> ...

 

 *NeddySeagoon wrote:*   

> 
> 
> [...] Laptop vendors typically put recovery information here as it takes some effort to delete it. Its not something you would do accidently. [...]
> 
> 

 

THe laptop came with a 40GB HDD, the 160 GB drive was purchased seperately.

From what I can see right now everything works just fine.

All I have to do now is find/build a small system I can run in RAM so I can use my HDD with ATA over Ethernet.

Thanks guys =)

----------

## pappy_mcfae

Luda,

Post the results of lspci -n and cat /proc/cpuinfo, as well as your /etc/fstab file and your .config (sent via pastebin. See my sig line for details.

Cheers,

Pappy

----------

