Skip to content

Commit cd00608

Browse files
Andy WhitcroftJeff Garzik
Andy Whitcroft
authored and
Jeff Garzik
committed
ata_piix: defer disks to the Hyper-V drivers by default
When we are hosted on a Microsoft Hyper-V hypervisor the guest disks are exposed both via the Hyper-V paravirtualised drivers and via an emulated SATA disk drive. In this case we want to use the paravirtualised drivers if we can as they are much more efficient. Note that the Hyper-V paravirtualised drivers only expose the virtual hard disk devices, the CDROM/DVD devices must still be enumerated. Mark the host controller ATA_HOST_IGNORE_ATA to prevent enumeration of disk devices. BugLink: http://bugs.launchpad.net/bugs/929545 BugLink: http://bugs.launchpad.net/bugs/942316 Signed-off-by: Andy Whitcroft <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
1 parent db63a4c commit cd00608

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

drivers/ata/ata_piix.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,39 @@ static bool piix_broken_system_poweroff(struct pci_dev *pdev)
15541554
return false;
15551555
}
15561556

1557+
static int prefer_ms_hyperv = 1;
1558+
module_param(prefer_ms_hyperv, int, 0);
1559+
1560+
static void piix_ignore_devices_quirk(struct ata_host *host)
1561+
{
1562+
#if IS_ENABLED(CONFIG_HYPERV_STORAGE)
1563+
static const struct dmi_system_id ignore_hyperv[] = {
1564+
{
1565+
/* On Hyper-V hypervisors the disks are exposed on
1566+
* both the emulated SATA controller and on the
1567+
* paravirtualised drivers. The CD/DVD devices
1568+
* are only exposed on the emulated controller.
1569+
* Request we ignore ATA devices on this host.
1570+
*/
1571+
.ident = "Hyper-V Virtual Machine",
1572+
.matches = {
1573+
DMI_MATCH(DMI_SYS_VENDOR,
1574+
"Microsoft Corporation"),
1575+
DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
1576+
},
1577+
},
1578+
{ } /* terminate list */
1579+
};
1580+
const struct dmi_system_id *dmi = dmi_first_match(ignore_hyperv);
1581+
1582+
if (dmi && prefer_ms_hyperv) {
1583+
host->flags |= ATA_HOST_IGNORE_ATA;
1584+
dev_info(host->dev, "%s detected, ATA device ignore set\n",
1585+
dmi->ident);
1586+
}
1587+
#endif
1588+
}
1589+
15571590
/**
15581591
* piix_init_one - Register PIIX ATA PCI device with kernel services
15591592
* @pdev: PCI device to register
@@ -1669,6 +1702,9 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
16691702
}
16701703
host->flags |= ATA_HOST_PARALLEL_SCAN;
16711704

1705+
/* Allow hosts to specify device types to ignore when scanning. */
1706+
piix_ignore_devices_quirk(host);
1707+
16721708
pci_set_master(pdev);
16731709
return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
16741710
}

0 commit comments

Comments
 (0)