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);