Hi,
Here is a bunch of small fixes for the ahci driver which accumulated over the last week.
cheers, Gerd
Gerd Hoffmann (4): ahci: set dma feature flag ahci: enable io/mem/dma ahci: fix off-by-one in port count ahci: set controller id
src/ahci.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/ahci.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/ahci.c b/src/ahci.c index ee404d4..ed37b38 100644 --- a/src/ahci.c +++ b/src/ahci.c @@ -50,6 +50,7 @@ static void sata_prep_readwrite(struct sata_cmd_fis *fis, command = (iswrite ? ATA_CMD_WRITE_DMA : ATA_CMD_READ_DMA); } + SET_FLATPTR(fis->feature, 1); /* dma */ SET_FLATPTR(fis->command, command); SET_FLATPTR(fis->sector_count, op->count); SET_FLATPTR(fis->lba_low, lba); @@ -62,6 +63,7 @@ static void sata_prep_atapi(struct sata_cmd_fis *fis, u16 blocksize) { memset_fl(fis, 0, sizeof(*fis)); SET_FLATPTR(fis->command, ATA_CMD_PACKET); + SET_FLATPTR(fis->feature, 1); /* dma */ SET_FLATPTR(fis->lba_mid, blocksize); SET_FLATPTR(fis->lba_high, blocksize >> 8); }
Make sure IO, MMIO and DMA are enabled in pci config space before using the device.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/ahci.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/ahci.c b/src/ahci.c index ed37b38..b906cc5 100644 --- a/src/ahci.c +++ b/src/ahci.c @@ -433,6 +433,7 @@ ahci_init_controller(int bdf) { struct ahci_ctrl_s *ctrl = malloc_fseg(sizeof(*ctrl)); u32 val; + u16 cmd;
if (!ctrl) { warn_noalloc(); @@ -444,6 +445,12 @@ ahci_init_controller(int bdf) dprintf(1, "AHCI controller at %02x.%x, iobase %x, irq %d\n", bdf >> 3, bdf & 7, ctrl->iobase, ctrl->irq);
+ cmd = pci_config_readw(bdf, PCI_COMMAND); + cmd |= PCI_COMMAND_IO; + cmd |= PCI_COMMAND_MEMORY; + cmd |= PCI_COMMAND_MASTER; + pci_config_writew(bdf, PCI_COMMAND, cmd); + val = ahci_ctrl_readl(ctrl, HOST_CTL); ahci_ctrl_writel(ctrl, HOST_CTL, val | HOST_CTL_AHCI_EN);
On Wed, Dec 08, 2010 at 11:24:12AM +0100, Gerd Hoffmann wrote:
Make sure IO, MMIO and DMA are enabled in pci config space before using the device.
[...]
- cmd = pci_config_readw(bdf, PCI_COMMAND);
- cmd |= PCI_COMMAND_IO;
- cmd |= PCI_COMMAND_MEMORY;
- cmd |= PCI_COMMAND_MASTER;
- pci_config_writew(bdf, PCI_COMMAND, cmd);
One can use pci_config_maskw() for this.
-Kevin
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/ahci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/ahci.c b/src/ahci.c index b906cc5..17bd522 100644 --- a/src/ahci.c +++ b/src/ahci.c @@ -414,7 +414,7 @@ ahci_detect(void *data) int rc;
max = ctrl->caps & 0x1f; - for (pnr = 0; pnr < max; pnr++) { + for (pnr = 0; pnr <= max; pnr++) { if (!(ctrl->ports & (1 << pnr))) continue; dprintf(2, "AHCI/%d: probing\n", pnr);
Fill the controller id in the drive struct with the port number so we get a sane boot menu ordering with multiple hard disks attached.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/ahci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/ahci.c b/src/ahci.c index 17bd522..fde8034 100644 --- a/src/ahci.c +++ b/src/ahci.c @@ -342,6 +342,7 @@ ahci_port_init(struct ahci_ctrl_s *ctrl, u32 pnr) }
port->drive.type = DTYPE_AHCI; + port->drive.cntl_id = pnr; port->drive.removable = (buffer[0] & 0x80) ? 1 : 0; port->drive.desc = malloc_tmp(MAXDESCSIZE); if (!port->drive.desc) {