# Persistently adding new PCI ID for ahci driver

## quadbox

Hi all.  

My motherboard happens to have a sata controller on it who's pci ids arent in the AHCI driver by default (a marvell chipset of one flavour or another), and so requires that ID to be added before it'll work.  The workaround being to write those IDs in via "echo 1b4b 917a > /sys/bus/pci/drivers/ahci/new_id", the two strings being the vendor ID and device ID.

What I cannot work out is an elegant way to have this happen correctly on boot, short of editing init scripts.  It needs to happen before filesystems are mounted, which rules out putting a script in /etc/local.d as that's not loaded in the boot runlevel.  I *think* the correct way to do this is to make an appropriate udev rule, but I havent got that working right, possibly I'm approaching it wrong or something.  What I've attempted is:

```

SUBSYSTEM=="pci", SYSFS{idVendor}=="1b4b", SYSFS{idProduct}=="917a", RUN=="/bin/echo 1b4b 917a >/sys/bus/pci/drivers/ahci/new_id"

```

This will add the rule, but mounting the partition on boot still fails because it's happening after filesystems are mounted.

The relevant line for the controller from lspci:

```

01:00.0 IDE interface: Marvell Technology Group Ltd. Device 917a (rev 11)

```

Anyone got a suggestion as to how to make this play nice?

EDIT - Fixed a typo and some missing info

----------

## roarinelk

Apply this patch to your kernel tree and tell me if it works reliably (i.e. no data errors):

```
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c

index 79a1e9d..e1691f7 100644

--- a/drivers/ata/ahci.c

+++ b/drivers/ata/ahci.c

@@ -396,6 +396,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {

          .driver_data = board_ahci_yes_fbs },                  /* 88se9125 */

        { PCI_DEVICE(0x1b4b, 0x91a3),

          .driver_data = board_ahci_yes_fbs },

+       { PCI_DEVICE(0x1b4b, 0x917a),

+         .driver_data = board_ahci_yes_fbs },

 

        /* Promise */

        { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci },   /* PDC42819 */

```

Can you set some modes for it in the BIOS?  By default most/all newer AHCI controllers

use another class code to identify themselves; only when you switch them into alternate

modes (IDE or RAID for example) they aren't immediately recognized by "default" drivers.

----------

## quadbox

Yeah, sure enough there was an option in the bios to set it to AHCI, which did solve my problem.  Thanks for the suggestion.

I havent tried your patch, however I was using the controller for a few months just adding the pci IDs via sysfs as I mentioned and it worked reliably.  so I'd imagine the patch'd work fine since it's just doing the same thing.

If it's of interest btw, with the controller set to AHCI in the bios lspci shows it as:

```

01:00.0 SATA controller: Marvell Technology Group Ltd. 88SE9172 SATA 6Gb/s Controller (rev 11)

```

----------

