From bf73f974c973d33f7b9a519900ee05e8e0e5cc87 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 30 May 2012 12:49:00 +0000 Subject: [PATCH] [x86] ata_piix: defer disks to the Hyper-V drivers by default svn path=/dists/sid/linux-2.6/; revision=19045 --- debian/changelog | 1 + ...t-flag-to-ignore-detected-ATA-device.patch | 49 +++++++++++ ...isks-to-the-Hyper-V-drivers-by-defau.patch | 82 +++++++++++++++++++ debian/patches/series/base | 2 + 4 files changed, 134 insertions(+) create mode 100644 debian/patches/features/x86/hyperv/0078-libata-add-a-host-flag-to-ignore-detected-ATA-device.patch create mode 100644 debian/patches/features/x86/hyperv/0079-ata_piix-defer-disks-to-the-Hyper-V-drivers-by-defau.patch diff --git a/debian/changelog b/debian/changelog index a5ff2b901..e7796c8ea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ linux-2.6 (3.2.18-2) UNRELEASED; urgency=low - Add support for Skyhawk cards * net/sched: Add codel and fq_codel from Linux 3.5-rc1 * [x86] udeb: Add hyperv-modules containing Hyper-V paravirtualised drivers + * [x86] ata_piix: defer disks to the Hyper-V drivers by default -- Ben Hutchings Sun, 27 May 2012 01:12:44 +0100 diff --git a/debian/patches/features/x86/hyperv/0078-libata-add-a-host-flag-to-ignore-detected-ATA-device.patch b/debian/patches/features/x86/hyperv/0078-libata-add-a-host-flag-to-ignore-detected-ATA-device.patch new file mode 100644 index 000000000..f26a0de96 --- /dev/null +++ b/debian/patches/features/x86/hyperv/0078-libata-add-a-host-flag-to-ignore-detected-ATA-device.patch @@ -0,0 +1,49 @@ +From: Andy Whitcroft +Date: Fri, 4 May 2012 22:15:10 +0100 +Subject: [PATCH 78/79] libata: add a host flag to ignore detected ATA devices + +commit db63a4c8115a0bb904496e1cdd3e7488e68b0d06 upstream. + +Where devices are visible via more than one host we sometimes wish to +indicate that cirtain devices should be ignored on a specific host. Add a +host flag indicating that this host wishes to ignore ATA specific devices. + +Signed-off-by: Andy Whitcroft +Signed-off-by: Jeff Garzik +--- + drivers/ata/libata-core.c | 6 ++++++ + include/linux/libata.h | 1 + + 2 files changed, 7 insertions(+) + +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c +index 23763a1..d31ee55 100644 +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -1973,6 +1973,12 @@ retry: + if (class == ATA_DEV_ATA) { + if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) + goto err_out; ++ if (ap->host->flags & ATA_HOST_IGNORE_ATA && ++ ata_id_is_ata(id)) { ++ ata_dev_dbg(dev, ++ "host indicates ignore ATA devices, ignored\n"); ++ return -ENOENT; ++ } + } else { + if (ata_id_is_ata(id)) + goto err_out; +diff --git a/include/linux/libata.h b/include/linux/libata.h +index e926df7..6e887c7 100644 +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -247,6 +247,7 @@ enum { + ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */ + ATA_HOST_STARTED = (1 << 1), /* Host started */ + ATA_HOST_PARALLEL_SCAN = (1 << 2), /* Ports on this host can be scanned in parallel */ ++ ATA_HOST_IGNORE_ATA = (1 << 3), /* Ignore ATA devices on this host. */ + + /* bits 24:31 of host->flags are reserved for LLD specific flags */ + +-- +1.7.10 + diff --git a/debian/patches/features/x86/hyperv/0079-ata_piix-defer-disks-to-the-Hyper-V-drivers-by-defau.patch b/debian/patches/features/x86/hyperv/0079-ata_piix-defer-disks-to-the-Hyper-V-drivers-by-defau.patch new file mode 100644 index 000000000..0ebfd3777 --- /dev/null +++ b/debian/patches/features/x86/hyperv/0079-ata_piix-defer-disks-to-the-Hyper-V-drivers-by-defau.patch @@ -0,0 +1,82 @@ +From: Andy Whitcroft +Date: Fri, 4 May 2012 22:15:11 +0100 +Subject: [PATCH 79/79] ata_piix: defer disks to the Hyper-V drivers by + default + +commit cd006086fa5d91414d8ff9ff2b78fbb593878e3c upstream. + +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 +Signed-off-by: Jeff Garzik +--- + drivers/ata/ata_piix.c | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c +index 7857e8f..3c809bf 100644 +--- a/drivers/ata/ata_piix.c ++++ b/drivers/ata/ata_piix.c +@@ -1554,6 +1554,39 @@ static bool piix_broken_system_poweroff(struct pci_dev *pdev) + return false; + } + ++static int prefer_ms_hyperv = 1; ++module_param(prefer_ms_hyperv, int, 0); ++ ++static void piix_ignore_devices_quirk(struct ata_host *host) ++{ ++#if IS_ENABLED(CONFIG_HYPERV_STORAGE) ++ static const struct dmi_system_id ignore_hyperv[] = { ++ { ++ /* On Hyper-V hypervisors the disks are exposed on ++ * both the emulated SATA controller and on the ++ * paravirtualised drivers. The CD/DVD devices ++ * are only exposed on the emulated controller. ++ * Request we ignore ATA devices on this host. ++ */ ++ .ident = "Hyper-V Virtual Machine", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, ++ "Microsoft Corporation"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), ++ }, ++ }, ++ { } /* terminate list */ ++ }; ++ const struct dmi_system_id *dmi = dmi_first_match(ignore_hyperv); ++ ++ if (dmi && prefer_ms_hyperv) { ++ host->flags |= ATA_HOST_IGNORE_ATA; ++ dev_info(host->dev, "%s detected, ATA device ignore set\n", ++ dmi->ident); ++ } ++#endif ++} ++ + /** + * piix_init_one - Register PIIX ATA PCI device with kernel services + * @pdev: PCI device to register +@@ -1669,6 +1702,9 @@ static int __devinit piix_init_one(struct pci_dev *pdev, + } + host->flags |= ATA_HOST_PARALLEL_SCAN; + ++ /* Allow hosts to specify device types to ignore when scanning. */ ++ piix_ignore_devices_quirk(host); ++ + pci_set_master(pdev); + return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht); + } +-- +1.7.10 + diff --git a/debian/patches/series/base b/debian/patches/series/base index 2f2437bed..478372fb3 100644 --- a/debian/patches/series/base +++ b/debian/patches/series/base @@ -158,6 +158,8 @@ + features/x86/hyperv/0075-Tools-hv-Support-enumeration-from-all-the-pools.patch + features/x86/hyperv/0076-net-hyperv-Fix-the-code-handling-tx-busy.patch + features/x86/hyperv/0077-hv-remove-the-second-argument-of-k-un-map_atomic.patch ++ features/x86/hyperv/0078-libata-add-a-host-flag-to-ignore-detected-ATA-device.patch ++ features/x86/hyperv/0079-ata_piix-defer-disks-to-the-Hyper-V-drivers-by-defau.patch + features/x86/efi-stub/0001-x86-Add-missing-bzImage-fields-to-struct-setup_heade.patch + features/x86/efi-stub/0002-x86-Don-t-use-magic-strings-for-EFI-loader-signature.patch