All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
@ 2012-03-29 17:28 Andy Whitcroft
  2012-03-30  9:14   ` Victor Miasnikov
                   ` (3 more replies)
  0 siblings, 4 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-03-29 17:28 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling

When we are hosted on a Hyper-V hypervisor the guest disks are exposed
both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
controller.  We want to use the paravirtualised drivers where possible as
they are much more performant.  The Hyper-V paravirtualised drivers only
expose the virtual hard disk devices, the CDROM/DVD devices must still
be enumerated on the virtualised SATA controller.  As we have no control
over kernel probe order for these two drivers especially when one driver
is builtin to the kernel and the other a module, we need to prevent the
ata_piix driver from claiming the disks devices by default when running
on a Hyper-V hypervisor.

When enumerating the drives look at the aquired device ID and if it
appears to be a disk device then report it as disconnected.  Limit this
behaviour to when we have detected a Hyper-V hypervisor.  Finally allow
this behaviour to be overriden via a new module parameter.

BugLink: http://bugs.launchpad.net/bugs/929545
BugLink: http://bugs.launchpad.net/bugs/942316
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 drivers/ata/ata_piix.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

    This was discovered when doing some boot testing on a Hyper-V
    host.  Performance was found to be bad as out builtin ata_piix
    driver was grabbing the disks.  I am Cc:ing a couple of the
    Microsoft people who worked on the HV driver set as well.

    Note that the device id data is converted from device to host
    order in the caller which makes examining the data problematic.
    As this code only make sense on X86 and we know we are in
    matching order we can access the data without first fixing it.
    Alternativly we could add a new callback from the ata core
    after the code has been fixed for validation.

    Comments?

    -apw

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 68013f9..64895f8 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -94,6 +94,9 @@
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/dmi.h>
+#ifdef CONFIG_X86
+#include <asm/hypervisor.h>
+#endif
 
 #define DRV_NAME	"ata_piix"
 #define DRV_VERSION	"2.13"
@@ -188,6 +191,29 @@ static int piix_pci_device_resume(struct pci_dev *pdev);
 
 static unsigned int in_module_init = 1;
 
+static int prefer_ms_hyperv = 1;
+
+unsigned int ata_piix_read_id(struct ata_device *dev,
+					struct ata_taskfile *tf, u16 *id)
+{
+	int ret = ata_do_dev_read_id(dev, tf, id);
+
+#ifdef CONFIG_X86
+	/* XXX: note that the device id is in little-endian order, the caller
+	 * will shift it to host order, but we are working with little-endian.
+	 * As this is _only_ used on x86 we can actually directly access it
+	 * as host is also little-endian.
+	 */
+	if (!ret && prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv &&
+							ata_id_is_ata(id)) {
+		ata_dev_printk(dev, KERN_WARNING, "ATA disk ignored deferring to Hyper-V paravirt driver\n");
+
+		return AC_ERR_DEV|AC_ERR_NODEV_HINT;
+	}
+#endif
+	return ret;
+}
+
 static const struct pci_device_id piix_pci_tbl[] = {
 	/* Intel PIIX3 for the 430HX etc */
 	{ 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
@@ -359,6 +385,7 @@ static struct ata_port_operations piix_pata_ops = {
 	.set_piomode		= piix_set_piomode,
 	.set_dmamode		= piix_set_dmamode,
 	.prereset		= piix_pata_prereset,
+	.read_id		= ata_piix_read_id,
 };
 
 static struct ata_port_operations piix_vmw_ops = {
@@ -1703,3 +1730,5 @@ static void __exit piix_exit(void)
 
 module_init(piix_init);
 module_exit(piix_exit);
+
+module_param(prefer_ms_hyperv, int, 0);
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
  2012-03-29 17:28 [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default Andy Whitcroft
@ 2012-03-30  9:14   ` Victor Miasnikov
  2012-04-10 16:08 ` KY Srinivasan
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 35+ messages in thread
From: Victor Miasnikov @ 2012-03-30  9:14 UTC (permalink / raw)
  To: Andy Whitcroft, Jeff Garzik, linux-ide
  Cc: linux-kernel, K. Y. Srinivasan, Mike Sterling


Hi!

----- Original Message ----- 
From: "Andy Whitcroft" apw
Sent: Thursday, March 29, 2012 8:28 PM
Subject: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default

> guest disks are exposed both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
> controller.   . . .  we need to prevent the
> ata_piix driver from claiming the disks devices by default when running
> on a Hyper-V hypervisor.

 Yes

Thanks for patch!

>    Comments?

 This patch is  "UBUNTU Way" Solution described in

See
http://vvm.blog.tut.by/2012/03/29/linux-on-hyper-v-use-hv_storvsc-instead-of-ata_piix-to-handle-the-ide-disks-devices-but-not-for-the-dvd-rom-cd-rom-device-handling/
Or

http://marc.info/?l=linux-kernel&m=133302969709312&w=2
==
List: linux-kernel
Subject: Linux on Hyper-V -- use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the 
DVD-ROM / CD-ROM device handling) Fw: [PATCH RFC] ata_piix: ignore disks in a hyper-v guest
From: "Victor Miasnikov"
Date: 2012-03-29 14:00:05

. . .

"UBUNTU Way" Solution -- tested with
Ubuntu 12.04 LTS (Precise Pangolin) Daily Build 2012-03-13
precise-desktop-amd64.iso
, work Ok
. . .
==



i.e. "[PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default"  is fully worked solution to 
the described problem


Best regards, Victor Miasnikov
Blog:  http://vvm.blog.tut.by/ 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
@ 2012-03-30  9:14   ` Victor Miasnikov
  0 siblings, 0 replies; 35+ messages in thread
From: Victor Miasnikov @ 2012-03-30  9:14 UTC (permalink / raw)
  To: Andy Whitcroft, Jeff Garzik, linux-ide
  Cc: linux-kernel, K. Y. Srinivasan, Mike Sterling


Hi!

----- Original Message ----- 
From: "Andy Whitcroft" apw
Sent: Thursday, March 29, 2012 8:28 PM
Subject: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default

> guest disks are exposed both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
> controller.   . . .  we need to prevent the
> ata_piix driver from claiming the disks devices by default when running
> on a Hyper-V hypervisor.

 Yes

Thanks for patch!

>    Comments?

 This patch is  "UBUNTU Way" Solution described in

See
http://vvm.blog.tut.by/2012/03/29/linux-on-hyper-v-use-hv_storvsc-instead-of-ata_piix-to-handle-the-ide-disks-devices-but-not-for-the-dvd-rom-cd-rom-device-handling/
Or

http://marc.info/?l=linux-kernel&m=133302969709312&w=2
==
List: linux-kernel
Subject: Linux on Hyper-V -- use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the 
DVD-ROM / CD-ROM device handling) Fw: [PATCH RFC] ata_piix: ignore disks in a hyper-v guest
From: "Victor Miasnikov"
Date: 2012-03-29 14:00:05

. . .

"UBUNTU Way" Solution -- tested with
Ubuntu 12.04 LTS (Precise Pangolin) Daily Build 2012-03-13
precise-desktop-amd64.iso
, work Ok
. . .
==



i.e. "[PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default"  is fully worked solution to 
the described problem


Best regards, Victor Miasnikov
Blog:  http://vvm.blog.tut.by/ 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
  2012-03-29 17:28 [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default Andy Whitcroft
  2012-03-30  9:14   ` Victor Miasnikov
@ 2012-04-10 16:08 ` KY Srinivasan
  2012-04-12 15:55 ` Andy Whitcroft
  2012-04-12 20:03 ` Jeff Garzik
  3 siblings, 0 replies; 35+ messages in thread
From: KY Srinivasan @ 2012-04-10 16:08 UTC (permalink / raw)
  To: Andy Whitcroft, Jeff Garzik, linux-ide; +Cc: linux-kernel, Mike Sterling



> -----Original Message-----
> From: Andy Whitcroft [mailto:apw@canonical.com]
> Sent: Thursday, March 29, 2012 1:29 PM
> To: Jeff Garzik; linux-ide@vger.kernel.org
> Cc: Andy Whitcroft; linux-kernel@vger.kernel.org; KY Srinivasan; Mike Sterling
> Subject: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers
> by default
> 
> When we are hosted on a Hyper-V hypervisor the guest disks are exposed
> both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
> controller.  We want to use the paravirtualised drivers where possible as
> they are much more performant.  The Hyper-V paravirtualised drivers only
> expose the virtual hard disk devices, the CDROM/DVD devices must still
> be enumerated on the virtualised SATA controller.  As we have no control
> over kernel probe order for these two drivers especially when one driver
> is builtin to the kernel and the other a module, we need to prevent the
> ata_piix driver from claiming the disks devices by default when running
> on a Hyper-V hypervisor.
> 
> When enumerating the drives look at the aquired device ID and if it
> appears to be a disk device then report it as disconnected.  Limit this
> behaviour to when we have detected a Hyper-V hypervisor.  Finally allow
> this behaviour to be overriden via a new module parameter.

Jeff,

Your feedback here would be greatly appreciated. If there are issues with this
please, do let us know.

Regards,

K. Y 
> 
> BugLink: http://bugs.launchpad.net/bugs/929545
> BugLink: http://bugs.launchpad.net/bugs/942316
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>  drivers/ata/ata_piix.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
>     This was discovered when doing some boot testing on a Hyper-V
>     host.  Performance was found to be bad as out builtin ata_piix
>     driver was grabbing the disks.  I am Cc:ing a couple of the
>     Microsoft people who worked on the HV driver set as well.
> 
>     Note that the device id data is converted from device to host
>     order in the caller which makes examining the data problematic.
>     As this code only make sense on X86 and we know we are in
>     matching order we can access the data without first fixing it.
>     Alternativly we could add a new callback from the ata core
>     after the code has been fixed for validation.
> 
>     Comments?
> 
>     -apw
> 
> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 68013f9..64895f8 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -94,6 +94,9 @@
>  #include <scsi/scsi_host.h>
>  #include <linux/libata.h>
>  #include <linux/dmi.h>
> +#ifdef CONFIG_X86
> +#include <asm/hypervisor.h>
> +#endif
> 
>  #define DRV_NAME	"ata_piix"
>  #define DRV_VERSION	"2.13"
> @@ -188,6 +191,29 @@ static int piix_pci_device_resume(struct pci_dev *pdev);
> 
>  static unsigned int in_module_init = 1;
> 
> +static int prefer_ms_hyperv = 1;
> +
> +unsigned int ata_piix_read_id(struct ata_device *dev,
> +					struct ata_taskfile *tf, u16 *id)
> +{
> +	int ret = ata_do_dev_read_id(dev, tf, id);
> +
> +#ifdef CONFIG_X86
> +	/* XXX: note that the device id is in little-endian order, the caller
> +	 * will shift it to host order, but we are working with little-endian.
> +	 * As this is _only_ used on x86 we can actually directly access it
> +	 * as host is also little-endian.
> +	 */
> +	if (!ret && prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv
> &&
> +							ata_id_is_ata(id)) {
> +		ata_dev_printk(dev, KERN_WARNING, "ATA disk ignored
> deferring to Hyper-V paravirt driver\n");
> +
> +		return AC_ERR_DEV|AC_ERR_NODEV_HINT;
> +	}
> +#endif
> +	return ret;
> +}
> +
>  static const struct pci_device_id piix_pci_tbl[] = {
>  	/* Intel PIIX3 for the 430HX etc */
>  	{ 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
> @@ -359,6 +385,7 @@ static struct ata_port_operations piix_pata_ops = {
>  	.set_piomode		= piix_set_piomode,
>  	.set_dmamode		= piix_set_dmamode,
>  	.prereset		= piix_pata_prereset,
> +	.read_id		= ata_piix_read_id,
>  };
> 
>  static struct ata_port_operations piix_vmw_ops = {
> @@ -1703,3 +1730,5 @@ static void __exit piix_exit(void)
> 
>  module_init(piix_init);
>  module_exit(piix_exit);
> +
> +module_param(prefer_ms_hyperv, int, 0);
> --
> 1.7.9.1
> 
> 
> 




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
  2012-03-29 17:28 [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default Andy Whitcroft
  2012-03-30  9:14   ` Victor Miasnikov
  2012-04-10 16:08 ` KY Srinivasan
@ 2012-04-12 15:55 ` Andy Whitcroft
  2012-04-12 20:03 ` Jeff Garzik
  3 siblings, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-12 15:55 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide

On Thu, Mar 29, 2012 at 6:28 PM, Andy Whitcroft <apw@canonical.com> wrote:
> When we are hosted on a Hyper-V hypervisor the guest disks are exposed
> both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
> controller.  We want to use the paravirtualised drivers where possible as
> they are much more performant.  The Hyper-V paravirtualised drivers only
> expose the virtual hard disk devices, the CDROM/DVD devices must still
> be enumerated on the virtualised SATA controller.  As we have no control
> over kernel probe order for these two drivers especially when one driver
> is builtin to the kernel and the other a module, we need to prevent the
> ata_piix driver from claiming the disks devices by default when running
> on a Hyper-V hypervisor.
>
> When enumerating the drives look at the aquired device ID and if it
> appears to be a disk device then report it as disconnected.  Limit this
> behaviour to when we have detected a Hyper-V hypervisor.  Finally allow
> this behaviour to be overriden via a new module parameter.
>
> BugLink: http://bugs.launchpad.net/bugs/929545
> BugLink: http://bugs.launchpad.net/bugs/942316
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>  drivers/ata/ata_piix.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
>
>    This was discovered when doing some boot testing on a Hyper-V
>    host.  Performance was found to be bad as out builtin ata_piix
>    driver was grabbing the disks.  I am Cc:ing a couple of the
>    Microsoft people who worked on the HV driver set as well.
>
>    Note that the device id data is converted from device to host
>    order in the caller which makes examining the data problematic.
>    As this code only make sense on X86 and we know we are in
>    matching order we can access the data without first fixing it.
>    Alternativly we could add a new callback from the ata core
>    after the code has been fixed for validation.
>
>    Comments?
>
>    -apw
>
> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 68013f9..64895f8 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -94,6 +94,9 @@
>  #include <scsi/scsi_host.h>
>  #include <linux/libata.h>
>  #include <linux/dmi.h>
> +#ifdef CONFIG_X86
> +#include <asm/hypervisor.h>
> +#endif
>
>  #define DRV_NAME       "ata_piix"
>  #define DRV_VERSION    "2.13"
> @@ -188,6 +191,29 @@ static int piix_pci_device_resume(struct pci_dev *pdev);
>
>  static unsigned int in_module_init = 1;
>
> +static int prefer_ms_hyperv = 1;
> +
> +unsigned int ata_piix_read_id(struct ata_device *dev,
> +                                       struct ata_taskfile *tf, u16 *id)
> +{
> +       int ret = ata_do_dev_read_id(dev, tf, id);
> +
> +#ifdef CONFIG_X86
> +       /* XXX: note that the device id is in little-endian order, the caller
> +        * will shift it to host order, but we are working with little-endian.
> +        * As this is _only_ used on x86 we can actually directly access it
> +        * as host is also little-endian.
> +        */
> +       if (!ret && prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv &&
> +                                                       ata_id_is_ata(id)) {
> +               ata_dev_printk(dev, KERN_WARNING, "ATA disk ignored deferring to Hyper-V paravirt driver\n");
> +
> +               return AC_ERR_DEV|AC_ERR_NODEV_HINT;
> +       }
> +#endif
> +       return ret;
> +}
> +
>  static const struct pci_device_id piix_pci_tbl[] = {
>        /* Intel PIIX3 for the 430HX etc */
>        { 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
> @@ -359,6 +385,7 @@ static struct ata_port_operations piix_pata_ops = {
>        .set_piomode            = piix_set_piomode,
>        .set_dmamode            = piix_set_dmamode,
>        .prereset               = piix_pata_prereset,
> +       .read_id                = ata_piix_read_id,
>  };
>
>  static struct ata_port_operations piix_vmw_ops = {
> @@ -1703,3 +1730,5 @@ static void __exit piix_exit(void)
>
>  module_init(piix_init);
>  module_exit(piix_exit);
> +
> +module_param(prefer_ms_hyperv, int, 0);

Jeff, any thoughts on this patch?

-apw

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
  2012-03-29 17:28 [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default Andy Whitcroft
                   ` (2 preceding siblings ...)
  2012-04-12 15:55 ` Andy Whitcroft
@ 2012-04-12 20:03 ` Jeff Garzik
  2012-04-13  7:37   ` Andy Whitcroft
  2012-04-14 15:53   ` [PATCH 0/2] Hyper-V disk support Andy Whitcroft
  3 siblings, 2 replies; 35+ messages in thread
From: Jeff Garzik @ 2012-04-12 20:03 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling

On 03/29/2012 01:28 PM, Andy Whitcroft wrote:
> When we are hosted on a Hyper-V hypervisor the guest disks are exposed
> both via the Hyper-V paravirtualised drivers and via an emulated SATA disk
> controller.  We want to use the paravirtualised drivers where possible as
> they are much more performant.  The Hyper-V paravirtualised drivers only
> expose the virtual hard disk devices, the CDROM/DVD devices must still
> be enumerated on the virtualised SATA controller.  As we have no control
> over kernel probe order for these two drivers especially when one driver
> is builtin to the kernel and the other a module, we need to prevent the
> ata_piix driver from claiming the disks devices by default when running
> on a Hyper-V hypervisor.
>
> When enumerating the drives look at the aquired device ID and if it
> appears to be a disk device then report it as disconnected.  Limit this
> behaviour to when we have detected a Hyper-V hypervisor.  Finally allow
> this behaviour to be overriden via a new module parameter.
>
> BugLink: http://bugs.launchpad.net/bugs/929545
> BugLink: http://bugs.launchpad.net/bugs/942316
> Signed-off-by: Andy Whitcroft<apw@canonical.com>
> ---
>   drivers/ata/ata_piix.c |   29 +++++++++++++++++++++++++++++
>   1 files changed, 29 insertions(+), 0 deletions(-)
>
>      This was discovered when doing some boot testing on a Hyper-V
>      host.  Performance was found to be bad as out builtin ata_piix
>      driver was grabbing the disks.  I am Cc:ing a couple of the
>      Microsoft people who worked on the HV driver set as well.
>
>      Note that the device id data is converted from device to host
>      order in the caller which makes examining the data problematic.
>      As this code only make sense on X86 and we know we are in
>      matching order we can access the data without first fixing it.
>      Alternativly we could add a new callback from the ata core
>      after the code has been fixed for validation.
>
>      Comments?
>
>      -apw
>
> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 68013f9..64895f8 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -94,6 +94,9 @@
>   #include<scsi/scsi_host.h>
>   #include<linux/libata.h>
>   #include<linux/dmi.h>
> +#ifdef CONFIG_X86
> +#include<asm/hypervisor.h>
> +#endif
>
>   #define DRV_NAME	"ata_piix"
>   #define DRV_VERSION	"2.13"
> @@ -188,6 +191,29 @@ static int piix_pci_device_resume(struct pci_dev *pdev);
>
>   static unsigned int in_module_init = 1;
>
> +static int prefer_ms_hyperv = 1;
> +
> +unsigned int ata_piix_read_id(struct ata_device *dev,
> +					struct ata_taskfile *tf, u16 *id)
> +{
> +	int ret = ata_do_dev_read_id(dev, tf, id);
> +
> +#ifdef CONFIG_X86
> +	/* XXX: note that the device id is in little-endian order, the caller
> +	 * will shift it to host order, but we are working with little-endian.
> +	 * As this is _only_ used on x86 we can actually directly access it
> +	 * as host is also little-endian.
> +	 */
> +	if (!ret&&  prefer_ms_hyperv&&  x86_hyper ==&x86_hyper_ms_hyperv&&
> +							ata_id_is_ata(id)) {
> +		ata_dev_printk(dev, KERN_WARNING, "ATA disk ignored deferring to Hyper-V paravirt driver\n");
> +
> +		return AC_ERR_DEV|AC_ERR_NODEV_HINT;
> +	}
> +#endif
> +	return ret;
> +}
> +
>   static const struct pci_device_id piix_pci_tbl[] = {
>   	/* Intel PIIX3 for the 430HX etc */
>   	{ 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
> @@ -359,6 +385,7 @@ static struct ata_port_operations piix_pata_ops = {
>   	.set_piomode		= piix_set_piomode,
>   	.set_dmamode		= piix_set_dmamode,
>   	.prereset		= piix_pata_prereset,
> +	.read_id		= ata_piix_read_id,

Platform quirks should be handled in piix_init_one, not with this 
haphazard read_id callback.  If prefer_ms_hyperv && hypervisor-detected, 
then set ATA_HOST_IGNORE_ATA flag or similar.

	Jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default
  2012-04-12 20:03 ` Jeff Garzik
@ 2012-04-13  7:37   ` Andy Whitcroft
  2012-04-14 15:53   ` [PATCH 0/2] Hyper-V disk support Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-13  7:37 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling

On Thu, Apr 12, 2012 at 04:03:42PM -0400, Jeff Garzik wrote:

> Platform quirks should be handled in piix_init_one, not with this
> haphazard read_id callback.  If prefer_ms_hyperv &&
> hypervisor-detected, then set ATA_HOST_IGNORE_ATA flag or similar.

That does sound better.  I'll whip something up.

-apw

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 0/2] Hyper-V disk support
  2012-04-12 20:03 ` Jeff Garzik
  2012-04-13  7:37   ` Andy Whitcroft
@ 2012-04-14 15:53   ` Andy Whitcroft
  2012-04-14 15:53     ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
  2012-04-14 15:53     ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  1 sibling, 2 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-14 15:53 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling

Add support for ignoring disks devices on specific host controllers to
libata.  Use this support to trigger us to ignore Hyper-V disk devices
on the emulated SATA device.

-apw

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  ata_piix: defer disks to the Hyper-V drivers by default

 drivers/ata/ata_piix.c    |   20 ++++++++++++++++++++
 drivers/ata/libata-core.c |    7 +++++++
 include/linux/libata.h    |    1 +
 3 files changed, 28 insertions(+)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 1/2] libata: add a host flag to ignore detected ATA devices
  2012-04-14 15:53   ` [PATCH 0/2] Hyper-V disk support Andy Whitcroft
@ 2012-04-14 15:53     ` Andy Whitcroft
  2012-04-14 15:53     ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-14 15:53 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling

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 <apw@canonical.com>
---
 drivers/ata/libata-core.c |    7 +++++++
 include/linux/libata.h    |    1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index e0bda9f..a85e338 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1973,6 +1973,13 @@ 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 42378d6..198c8f1 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.9.5

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-14 15:53   ` [PATCH 0/2] Hyper-V disk support Andy Whitcroft
  2012-04-14 15:53     ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
@ 2012-04-14 15:53     ` Andy Whitcroft
  2012-04-14 16:02       ` Alan Cox
  1 sibling, 1 reply; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-14 15:53 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling

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 <apw@canonical.com>
---
 drivers/ata/ata_piix.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 68013f9..b52d8ab 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -94,6 +94,9 @@
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/dmi.h>
+#ifdef CONFIG_X86
+#include <asm/hypervisor.h>
+#endif
 
 #define DRV_NAME	"ata_piix"
 #define DRV_VERSION	"2.13"
@@ -1567,6 +1570,11 @@ static bool piix_broken_system_poweroff(struct pci_dev *pdev)
  *	Zero on success, or -ERRNO value.
  */
 
+#ifdef CONFIG_X86
+static int prefer_ms_hyperv = 1;
+module_param(prefer_ms_hyperv, int, 0);
+#endif
+
 static int __devinit piix_init_one(struct pci_dev *pdev,
 				   const struct pci_device_id *ent)
 {
@@ -1667,6 +1675,18 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
 	}
 	host->flags |= ATA_HOST_PARALLEL_SCAN;
 
+#ifdef CONFIG_X86
+	/* 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.
+	 */
+	if (prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv) {
+		host->flags |= ATA_HOST_IGNORE_ATA;
+		dev_info(&pdev->dev, "Hyper-V hypervisor detected, ignoring ATA disks\n");
+	}
+#endif
+
 	pci_set_master(pdev);
 	return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-14 15:53     ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
@ 2012-04-14 16:02       ` Alan Cox
  2012-04-15  0:10         ` KY Srinivasan
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  0 siblings, 2 replies; 35+ messages in thread
From: Alan Cox @ 2012-04-14 16:02 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: Jeff Garzik, linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling

O> +#ifdef CONFIG_X86
> +	/* 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.
> +	 */
> +	if (prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv) {
> +		host->flags |= ATA_HOST_IGNORE_ATA;
> +		dev_info(&pdev->dev, "Hyper-V hypervisor detected, ignoring ATA disks\n");
> +	}
> +#endif

Does hyper-v not set its own unique and identifable pci
subvendor/subdevice ?

Alan

^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-14 16:02       ` Alan Cox
@ 2012-04-15  0:10         ` KY Srinivasan
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: KY Srinivasan @ 2012-04-15  0:10 UTC (permalink / raw)
  To: Alan Cox, Andy Whitcroft
  Cc: Jeff Garzik, linux-ide, linux-kernel, Mike Sterling



> -----Original Message-----
> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Sent: Saturday, April 14, 2012 12:02 PM
> To: Andy Whitcroft
> Cc: Jeff Garzik; linux-ide@vger.kernel.org; linux-kernel@vger.kernel.org; KY
> Srinivasan; Mike Sterling
> Subject: Re: [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
> 
> O> +#ifdef CONFIG_X86
> > +	/* 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.
> > +	 */
> > +	if (prefer_ms_hyperv && x86_hyper == &x86_hyper_ms_hyperv) {
> > +		host->flags |= ATA_HOST_IGNORE_ATA;
> > +		dev_info(&pdev->dev, "Hyper-V hypervisor detected, ignoring
> ATA disks\n");
> > +	}
> > +#endif
> 
> Does hyper-v not set its own unique and identifable pci
> subvendor/subdevice ?

Number of elements of the virtual BIOS we present the guest can be used
to detect that we are running on Hyper-V. Additionally, we are exporting state based
on CPU detection which is what Andy is using here. As far as I know these are the only
ways to detect that we are running on Hyper-V. 

Regards,

K. Y
> 
> Alan
> 
> 




^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 0/2] Hyper-V disk support V3
  2012-04-14 16:02       ` Alan Cox
  2012-04-15  0:10         ` KY Srinivasan
@ 2012-04-16 11:20         ` Andy Whitcroft
  2012-04-16 11:20           ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
                             ` (3 more replies)
  1 sibling, 4 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-16 11:20 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

Add support for ignoring disks devices on specific host controllers to
libata.  Use this support to trigger us to ignore Hyper-V disk devices
on the emulated SATA device based on the system DMI information.

Jeff, I believe the first patch is what you had in mind in your comments.
Alan, the piix sadly has no subvendor/subdevice identifiers at all
though we are able to detect the platform from the DMI information,
this any better?

-apw

V3
  - switch detection method to DMI information

V2 
  - create a generic libata quirk
  - switch detection to piix_init_one

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  ata_piix: defer disks to the Hyper-V drivers by default

 drivers/ata/ata_piix.c    |   20 ++++++++++++++++++++
 drivers/ata/libata-core.c |    7 +++++++
 include/linux/libata.h    |    1 +
 3 files changed, 28 insertions(+)

-- 
1.7.9.5


*** BLURB HERE ***

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by
    default

 drivers/ata/ata_piix.c    |   38 ++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c |    6 ++++++
 include/linux/libata.h    |    1 +
 3 files changed, 45 insertions(+)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 1/2] libata: add a host flag to ignore detected ATA devices
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
@ 2012-04-16 11:20           ` Andy Whitcroft
  2012-04-16 11:20           ` [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-16 11:20 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 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 e0bda9f..18e87bf 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 42378d6..198c8f1 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.9.5


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  2012-04-16 11:20           ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
@ 2012-04-16 11:20           ` Andy Whitcroft
  2012-04-16 11:28             ` Sergei Shtylyov
  2012-04-16 11:26           ` [PATCH 0/2] Hyper-V disk support V3 Alan Cox
  2012-04-16 15:32           ` [PATCH 0/2] Hyper-V disk support V3 Jeff Garzik
  3 siblings, 1 reply; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-16 11:20 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 drivers/ata/ata_piix.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 68013f9..05e0ffa 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1552,6 +1552,41 @@ 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)
+{
+	static const struct dmi_system_id ignore_devices[] = {
+		{
+			/* 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"),
+			},
+			.driver_data = (void *)ATA_HOST_IGNORE_ATA,
+		},
+
+		{ }	/* terminate list */
+	};
+	const struct dmi_system_id *dmi = dmi_first_match(ignore_devices);
+
+	if (dmi) {
+		unsigned long flags = (unsigned long)dmi->driver_data;
+
+		host->flags |= flags;
+		dev_info(host->dev, "%s detected, device ignore set %08lx\n",
+			dmi->ident, flags);
+	}
+}
+
 /**
  *	piix_init_one - Register PIIX ATA PCI device with kernel services
  *	@pdev: PCI device to register
@@ -1667,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.9.5


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  2012-04-16 11:20           ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
  2012-04-16 11:20           ` [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
@ 2012-04-16 11:26           ` Alan Cox
  2012-04-16 18:29             ` Andy Whitcroft
  2012-04-16 15:32           ` [PATCH 0/2] Hyper-V disk support V3 Jeff Garzik
  3 siblings, 1 reply; 35+ messages in thread
From: Alan Cox @ 2012-04-16 11:26 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: Jeff Garzik, linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling

On Mon, 16 Apr 2012 12:20:27 +0100
Andy Whitcroft <apw@canonical.com> wrote:

> Add support for ignoring disks devices on specific host controllers to
> libata.  Use this support to trigger us to ignore Hyper-V disk devices
> on the emulated SATA device based on the system DMI information.
> 
> Jeff, I believe the first patch is what you had in mind in your comments.
> Alan, the piix sadly has no subvendor/subdevice identifiers at all

So its 0x0000,0x0000 ?

> though we are able to detect the platform from the DMI information,
> this any better?

What happens if you have a PIIX device which is being passed through from
the underlying hardware or will hyper-v never support pass through ?

Alan

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-16 11:20           ` [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
@ 2012-04-16 11:28             ` Sergei Shtylyov
  0 siblings, 0 replies; 35+ messages in thread
From: Sergei Shtylyov @ 2012-04-16 11:28 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: Jeff Garzik, linux-ide, linux-kernel, K. Y. Srinivasan,
	Mike Sterling, Alan Cox

Hello.

On 16-04-2012 15:20, Andy Whitcroft wrote:

> 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<apw@canonical.com>
> ---
>   drivers/ata/ata_piix.c |   38 ++++++++++++++++++++++++++++++++++++++
>   1 file changed, 38 insertions(+)

> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 68013f9..05e0ffa 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -1552,6 +1552,41 @@ 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)
> +{
> +	static const struct dmi_system_id ignore_devices[] = {
> +		{
> +			/* 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.

    '*' not needed here.

> +			 */
> +			.ident = "Hyper-V Virtual Machine",
> +			.matches = {
> +				DMI_MATCH(DMI_SYS_VENDOR,
> +						"Microsoft Corporation"),
> +				DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
> +			},
> +			.driver_data = (void *)ATA_HOST_IGNORE_ATA,
> +		},
> +
> +		{ }	/* terminate list */
> +	};
> +	const struct dmi_system_id *dmi = dmi_first_match(ignore_devices);
> +
> +	if (dmi) {
> +		unsigned long flags = (unsigned long)dmi->driver_data;
> +
> +		host->flags |= flags;
> +		dev_info(host->dev, "%s detected, device ignore set %08lx\n",

    dev_dbg()?

MBR, Sergei

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
                             ` (2 preceding siblings ...)
  2012-04-16 11:26           ` [PATCH 0/2] Hyper-V disk support V3 Alan Cox
@ 2012-04-16 15:32           ` Jeff Garzik
  2012-04-16 18:28             ` Andy Whitcroft
  3 siblings, 1 reply; 35+ messages in thread
From: Jeff Garzik @ 2012-04-16 15:32 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

On 04/16/2012 07:20 AM, Andy Whitcroft wrote:
> Jeff, I believe the first patch is what you had in mind in your comments.
> Alan, the piix sadly has no subvendor/subdevice identifiers at all
> though we are able to detect the platform from the DMI information,
> this any better?

Please post "lspci -vvv" for this device...


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 15:32           ` [PATCH 0/2] Hyper-V disk support V3 Jeff Garzik
@ 2012-04-16 18:28             ` Andy Whitcroft
  0 siblings, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-16 18:28 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

On Mon, Apr 16, 2012 at 11:32:22AM -0400, Jeff Garzik wrote:
> On 04/16/2012 07:20 AM, Andy Whitcroft wrote:
> >Jeff, I believe the first patch is what you had in mind in your comments.
> >Alan, the piix sadly has no subvendor/subdevice identifiers at all
> >though we are able to detect the platform from the DMI information,
> >this any better?
> 
> Please post "lspci -vvv" for this device...

lspci -nnvvv:

00:07.1 IDE interface [0101]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086:7111] (rev 01) (prog-if 80 [Master])
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Region 0: [virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8]
	Region 1: [virtual] Memory at 000003f0 (type 3, non-prefetchable) [size=1]
	Region 2: [virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8]
	Region 3: [virtual] Memory at 00000370 (type 3, non-prefetchable) [size=1]
	Region 4: I/O ports at ffa0 [size=16]
	Kernel driver in use: ata_piix

-apw

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 11:26           ` [PATCH 0/2] Hyper-V disk support V3 Alan Cox
@ 2012-04-16 18:29             ` Andy Whitcroft
  2012-04-16 18:41               ` KY Srinivasan
  0 siblings, 1 reply; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-16 18:29 UTC (permalink / raw)
  To: Alan Cox
  Cc: Jeff Garzik, linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling

On Mon, Apr 16, 2012 at 12:26:34PM +0100, Alan Cox wrote:
> On Mon, 16 Apr 2012 12:20:27 +0100
> Andy Whitcroft <apw@canonical.com> wrote:
> 
> > Add support for ignoring disks devices on specific host controllers to
> > libata.  Use this support to trigger us to ignore Hyper-V disk devices
> > on the emulated SATA device based on the system DMI information.
> > 
> > Jeff, I believe the first patch is what you had in mind in your comments.
> > Alan, the piix sadly has no subvendor/subdevice identifiers at all
> 
> So its 0x0000,0x0000 ?
> 
> > though we are able to detect the platform from the DMI information,
> > this any better?
> 
> What happens if you have a PIIX device which is being passed through from
> the underlying hardware or will hyper-v never support pass through ?

A good question indeed.  KY perhaps you can comment.

-apw

^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 18:29             ` Andy Whitcroft
@ 2012-04-16 18:41               ` KY Srinivasan
  2012-04-18 20:12                 ` Alan Cox
  0 siblings, 1 reply; 35+ messages in thread
From: KY Srinivasan @ 2012-04-16 18:41 UTC (permalink / raw)
  To: Andy Whitcroft, Alan Cox
  Cc: Jeff Garzik, linux-ide, linux-kernel, Mike Sterling



> -----Original Message-----
> From: Andy Whitcroft [mailto:apw@canonical.com]
> Sent: Monday, April 16, 2012 2:29 PM
> To: Alan Cox
> Cc: Jeff Garzik; linux-ide@vger.kernel.org; linux-kernel@vger.kernel.org; KY
> Srinivasan; Mike Sterling
> Subject: Re: [PATCH 0/2] Hyper-V disk support V3
> 
> On Mon, Apr 16, 2012 at 12:26:34PM +0100, Alan Cox wrote:
> > On Mon, 16 Apr 2012 12:20:27 +0100
> > Andy Whitcroft <apw@canonical.com> wrote:
> >
> > > Add support for ignoring disks devices on specific host controllers to
> > > libata.  Use this support to trigger us to ignore Hyper-V disk devices
> > > on the emulated SATA device based on the system DMI information.
> > >
> > > Jeff, I believe the first patch is what you had in mind in your comments.
> > > Alan, the piix sadly has no subvendor/subdevice identifiers at all
> >
> > So its 0x0000,0x0000 ?
> >
> > > though we are able to detect the platform from the DMI information,
> > > this any better?
> >
> > What happens if you have a PIIX device which is being passed through from
> > the underlying hardware or will hyper-v never support pass through ?

The notion of "pass through" in Hyper-V  is a little different. IDE devices can be configured
under either one of the supported controllers and these devices can either be virtual disks
(VHDs) or physical disks. In either case these will be presented to the guest as IDE devices.

Regards,

K. Y




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-16 18:41               ` KY Srinivasan
@ 2012-04-18 20:12                 ` Alan Cox
  2012-04-18 20:21                   ` KY Srinivasan
  2012-04-19  7:40                   ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  0 siblings, 2 replies; 35+ messages in thread
From: Alan Cox @ 2012-04-18 20:12 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Andy Whitcroft, Jeff Garzik, linux-ide, linux-kernel, Mike Sterling

> The notion of "pass through" in Hyper-V  is a little different. IDE devices can be configured
> under either one of the supported controllers and these devices can either be virtual disks
> (VHDs) or physical disks. In either case these will be presented to the guest as IDE devices.

So what ensures that by skipping it at the ATA device level we will
always find it as a VHD ?

Alan

^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH 0/2] Hyper-V disk support V3
  2012-04-18 20:12                 ` Alan Cox
@ 2012-04-18 20:21                   ` KY Srinivasan
  2012-04-19  8:15                       ` Victor Miasnikov
  2012-04-19  7:40                   ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  1 sibling, 1 reply; 35+ messages in thread
From: KY Srinivasan @ 2012-04-18 20:21 UTC (permalink / raw)
  To: Alan Cox
  Cc: Andy Whitcroft, Jeff Garzik, linux-ide, linux-kernel, Mike Sterling



> -----Original Message-----
> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Sent: Wednesday, April 18, 2012 4:13 PM
> To: KY Srinivasan
> Cc: Andy Whitcroft; Jeff Garzik; linux-ide@vger.kernel.org; linux-
> kernel@vger.kernel.org; Mike Sterling
> Subject: Re: [PATCH 0/2] Hyper-V disk support V3
> 
> > The notion of "pass through" in Hyper-V  is a little different. IDE devices can be
> configured
> > under either one of the supported controllers and these devices can either be
> virtual disks
> > (VHDs) or physical disks. In either case these will be presented to the guest as
> IDE devices.
> 
> So what ensures that by skipping it at the ATA device level we will
> always find it as a VHD ?

If the Hyper-V storage driver is  present, then the Hyper-V storage driver will
manage the root device (and other devices skipped by the ata driver). 
So, the check if we are running on Hyper-V is not enough
to skip the device in the ata_piix driver; we need to also make sure that the Hyper-V
block driver is available to handle the skipped devices. I think the correct approach here is to
have a kernel (or an ata_piix module parameter) that can be set to override the skipping
of the block device by the ata driver. Distros that are including the Hyper-V storage driver
can set this parameter so that when running on Hyper-V, ata can skip the block device.

Regards,

K. Y
> 
> Alan
> 
> 




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 0/2] Hyper-V disk support V3
  2012-04-18 20:12                 ` Alan Cox
  2012-04-18 20:21                   ` KY Srinivasan
@ 2012-04-19  7:40                   ` Andy Whitcroft
  2012-04-19 13:17                     ` KY Srinivasan
  2012-04-19 14:33                     ` [PATCH 0/2] Hyper-V disk support V4 Andy Whitcroft
  1 sibling, 2 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-19  7:40 UTC (permalink / raw)
  To: Alan Cox
  Cc: KY Srinivasan, Jeff Garzik, linux-ide, linux-kernel, Mike Sterling

On Wed, Apr 18, 2012 at 09:12:35PM +0100, Alan Cox wrote:
> > The notion of "pass through" in Hyper-V  is a little different. IDE devices can be configured
> > under either one of the supported controllers and these devices can either be virtual disks
> > (VHDs) or physical disks. In either case these will be presented to the guest as IDE devices.
> 
> So what ensures that by skipping it at the ATA device level we will
> always find it as a VHD ?

My understanding of things is that the if you have disks assigned to the
guest that they will always appear both on the virtualised SATA contoller
and on the paravirtualised driver channel.  So that assuming a valid
configuration in which both drivers initialise they will be picked up by
one or the other.

KY for clarity are we saying the only way a disk can appear in the guest
is either on the emulated controller or paravirtualised, we will never
expose real devices into the guest.

Reading my own statement that ought to imply we really should only default
preferring paravirtualised to 'on' when the hyperv paravirtualised drivers
is enabled too; easy enough to do.  Howeever in a perfect world the
override would also have the inverse effect even if the paravirtualised
driver initialises first; not so easy but I assume we with some fiddling
we could make both drivers handle the same parameter.

/me considers this further.

-apw

^ permalink raw reply	[flat|nested] 35+ messages in thread

* 1) boot flag to disable the Hyper-V IDE drivers: ata_piix.prefer_ms_hyperv=0 2) PIIX_IGNORE_ATA_ON_HYPERV Re: [PATCH 0/2] Hyper-V disk support V3 RE: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the CD-ROM)
  2012-04-18 20:21                   ` KY Srinivasan
@ 2012-04-19  8:15                       ` Victor Miasnikov
  0 siblings, 0 replies; 35+ messages in thread
From: Victor Miasnikov @ 2012-04-19  8:15 UTC (permalink / raw)
  To: KY Srinivasan, Andy Whitcroft, Alan Cox
  Cc: Jeff Garzik, linux-ide, linux-kernel, Mike Sterling


Hi!

 Shortly:

1) 
The flag to disable the Hyper-V IDE drivers is:
 ata_piix.prefer_ms_hyperv=02)

#ifdef CONFIG_X86 
#if defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
#define ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 1
#endif
#endif


---

>>Alan Cox:
>> So what ensures that by 
>> skipping it at the ATA device level we will always find it as a VHD ?

> KY Srinivasan:
> So, the check if we are running on Hyper-V is not enough
> to skip the device in the ata_piix driver; 
> we need to also make sure that the Hyper-V block driver is available to handle the skipped devices. 

>  I think the correct approach here is to have a kernel (or an ata_piix module parameter) 
> that can be set to override the skipping of the block device by the ata driver. 

 Already implemented, see:
module_param(prefer_ms_hyperv, int, 0);

 and work as need in real life:

http://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg3482442.html
==
Tim Miller Dyck
Wed, 14 Mar 2012 07:15:52 -0700
 . . .
The boot flags can be viewed by pressing F5? F6? (one of those) on the
setup boot screen and then navigating to the boot line with cursor keys
and adding the boot parameter below before the double dash at the end of
the line.
The flag to disable the Hyper-V IDE drivers is:

 ata_piix.prefer_ms_hyperv=0  . . .
==
> Distros that are including the Hyper-V storage driver can set this parameter so 
> that when running on Hyper-V, ata can skip the block device.


 Best:
Distros that are not-including the Hyper-V storage driver don't worry about "ata can skip" etc.:

See re-incarnatin Olaf Hering idea:

#ifdef CONFIG_X86 
#if defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
#define ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 1
#endif
#endif

 and

#ifdef CONFIG_X86 

 replace to

#ifdef ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 


Best regards, Victor Miasnikov
Blog:  http://vvm.blog.tut.by/



^ permalink raw reply	[flat|nested] 35+ messages in thread

* 1) boot flag to disable the Hyper-V IDE drivers: ata_piix.prefer_ms_hyperv=0 2) PIIX_IGNORE_ATA_ON_HYPERV Re: [PATCH 0/2] Hyper-V disk support V3 RE: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the CD-ROM)
@ 2012-04-19  8:15                       ` Victor Miasnikov
  0 siblings, 0 replies; 35+ messages in thread
From: Victor Miasnikov @ 2012-04-19  8:15 UTC (permalink / raw)
  To: KY Srinivasan, Andy Whitcroft, Alan Cox
  Cc: Jeff Garzik, linux-ide, linux-kernel, Mike Sterling


Hi!

 Shortly:

1) 
The flag to disable the Hyper-V IDE drivers is:
 ata_piix.prefer_ms_hyperv=02)

#ifdef CONFIG_X86 
#if defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
#define ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 1
#endif
#endif


---

>>Alan Cox:
>> So what ensures that by 
>> skipping it at the ATA device level we will always find it as a VHD ?

> KY Srinivasan:
> So, the check if we are running on Hyper-V is not enough
> to skip the device in the ata_piix driver; 
> we need to also make sure that the Hyper-V block driver is available to handle the skipped devices. 

>  I think the correct approach here is to have a kernel (or an ata_piix module parameter) 
> that can be set to override the skipping of the block device by the ata driver. 

 Already implemented, see:
module_param(prefer_ms_hyperv, int, 0);

 and work as need in real life:

http://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg3482442.html
==
Tim Miller Dyck
Wed, 14 Mar 2012 07:15:52 -0700
 . . .
The boot flags can be viewed by pressing F5? F6? (one of those) on the
setup boot screen and then navigating to the boot line with cursor keys
and adding the boot parameter below before the double dash at the end of
the line.
The flag to disable the Hyper-V IDE drivers is:

 ata_piix.prefer_ms_hyperv=0  . . .
==
> Distros that are including the Hyper-V storage driver can set this parameter so 
> that when running on Hyper-V, ata can skip the block device.


 Best:
Distros that are not-including the Hyper-V storage driver don't worry about "ata can skip" etc.:

See re-incarnatin Olaf Hering idea:

#ifdef CONFIG_X86 
#if defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
#define ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 1
#endif
#endif

 and

#ifdef CONFIG_X86 

 replace to

#ifdef ATA_PIIX_IGNORE_ATA_DISKS_ON_HYPERV 


Best regards, Victor Miasnikov
Blog:  http://vvm.blog.tut.by/



^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH 0/2] Hyper-V disk support V3
  2012-04-19  7:40                   ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
@ 2012-04-19 13:17                     ` KY Srinivasan
  2012-04-19 14:33                     ` [PATCH 0/2] Hyper-V disk support V4 Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: KY Srinivasan @ 2012-04-19 13:17 UTC (permalink / raw)
  To: Andy Whitcroft, Alan Cox
  Cc: Jeff Garzik, linux-ide, linux-kernel, Mike Sterling



> -----Original Message-----
> From: Andy Whitcroft [mailto:apw@canonical.com]
> Sent: Thursday, April 19, 2012 3:40 AM
> To: Alan Cox
> Cc: KY Srinivasan; Jeff Garzik; linux-ide@vger.kernel.org; linux-
> kernel@vger.kernel.org; Mike Sterling
> Subject: Re: [PATCH 0/2] Hyper-V disk support V3
> 
> On Wed, Apr 18, 2012 at 09:12:35PM +0100, Alan Cox wrote:
> > > The notion of "pass through" in Hyper-V  is a little different. IDE devices can
> be configured
> > > under either one of the supported controllers and these devices can either
> be virtual disks
> > > (VHDs) or physical disks. In either case these will be presented to the guest as
> IDE devices.
> >
> > So what ensures that by skipping it at the ATA device level we will
> > always find it as a VHD ?
> 
> My understanding of things is that the if you have disks assigned to the
> guest that they will always appear both on the virtualised SATA contoller
> and on the paravirtualised driver channel.  So that assuming a valid
> configuration in which both drivers initialise they will be picked up by
> one or the other.
> 
> KY for clarity are we saying the only way a disk can appear in the guest
> is either on the emulated controller or paravirtualised, we will never
> expose real devices into the guest.

You are right. Depending on how the device is configured for the guest, even
in the pass through case, the device will show up as either an emulated device
(if configured under the IDE controllers) or as a device under the synthetic scsi
controller (as seen by the guest). The storvsc driver can handle both these configurations
while the native ata driver can only handle emulated devices. Since, presently we can 
only boot off of a device configured under the IDE controller, we have the issue which your
patch addresses.

K. Y 




^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 0/2] Hyper-V disk support V4
  2012-04-19  7:40                   ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
  2012-04-19 13:17                     ` KY Srinivasan
@ 2012-04-19 14:33                     ` Andy Whitcroft
  2012-04-19 14:33                       ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
  2012-04-19 14:33                       ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  1 sibling, 2 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-19 14:33 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

Add support for ignoring disks devices on specific host controllers to
libata.  Use this support to trigger us to ignore Hyper-V disk devices
on the emulated SATA device based on the system DMI information.

I have cleaned up the Hyper-V detection so it is only included when the
paravirtualised drivers are enabled.  I have also reintroduced the
override which had mysteriously gone missing in V3.

Comments?

-apw

V4
  - only enable the quirk when the paravirtualised drivers are compiled
  - fix up the command line flag to disable this support

V3
  - switch detection method to DMI information

V2 
  - create a generic libata quirk
  - switch detection to piix_init_one

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  ata_piix: defer disks to the Hyper-V drivers by default

 drivers/ata/ata_piix.c    |   20 ++++++++++++++++++++
 drivers/ata/libata-core.c |    7 +++++++
 include/linux/libata.h    |    1 +
 3 files changed, 28 insertions(+)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 1/2] libata: add a host flag to ignore detected ATA devices
  2012-04-19 14:33                     ` [PATCH 0/2] Hyper-V disk support V4 Andy Whitcroft
@ 2012-04-19 14:33                       ` Andy Whitcroft
  2012-04-19 14:33                       ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-19 14:33 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 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 e0bda9f..18e87bf 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 42378d6..198c8f1 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.9.5


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-19 14:33                     ` [PATCH 0/2] Hyper-V disk support V4 Andy Whitcroft
  2012-04-19 14:33                       ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
@ 2012-04-19 14:33                       ` Andy Whitcroft
  2012-04-19 15:54                         ` Sergei Shtylyov
  1 sibling, 1 reply; 35+ messages in thread
From: Andy Whitcroft @ 2012-04-19 14:33 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 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 68013f9..c410ba9 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1552,6 +1552,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 defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
+	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, SATA device ignore set\n",
+			dmi->ident);
+	}
+#endif
+}
+
 /**
  *	piix_init_one - Register PIIX ATA PCI device with kernel services
  *	@pdev: PCI device to register
@@ -1667,6 +1700,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.9.5

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-04-19 14:33                       ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
@ 2012-04-19 15:54                         ` Sergei Shtylyov
  2012-05-04 21:15                           ` [PATCH 0/2] Hyper-V disk support V5 Andy Whitcroft
  0 siblings, 1 reply; 35+ messages in thread
From: Sergei Shtylyov @ 2012-04-19 15:54 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: Jeff Garzik, linux-ide, linux-kernel, K. Y. Srinivasan,
	Mike Sterling, Alan Cox

Hello.

On 04/19/2012 06:33 PM, Andy Whitcroft wrote:

> 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<apw@canonical.com>
> ---
>   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 68013f9..c410ba9 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -1552,6 +1552,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 defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)

    You could instead use:

#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, SATA device ignore set\n",

    s/SATA/ATA/.

MBR, Sergei

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 0/2] Hyper-V disk support V5
  2012-04-19 15:54                         ` Sergei Shtylyov
@ 2012-05-04 21:15                           ` Andy Whitcroft
  2012-05-04 21:15                             ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
  2012-05-04 21:15                             ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  0 siblings, 2 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-05-04 21:15 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

Add support for ignoring disks devices on specific host controllers to
libata.  Use this support to trigger us to ignore Hyper-V disk devices
on the emulated SATA device based on the system DMI information.

Fixes based on feedback Sergei Shtylyov, thanks.  Jeff I think this is
about done, any objections to merging?

Comments?

-apw

V5
  - switched to IS_ENABLED
  - fixed device type in device ignored messages

V4
  - only enable the quirk when the paravirtualised drivers are compiled
  - fix up the command line flag to disable this support

V3
  - switch detection method to DMI information

V2 
  - create a generic libata quirk
  - switch detection to piix_init_one

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  ata_piix: defer disks to the Hyper-V drivers by default

 drivers/ata/ata_piix.c    |   20 ++++++++++++++++++++
 drivers/ata/libata-core.c |    7 +++++++
 include/linux/libata.h    |    1 +
 3 files changed, 28 insertions(+)

-- 
1.7.9.5

Andy Whitcroft (2):
  libata: add a host flag to ignore detected ATA devices
  ata_piix: defer disks to the Hyper-V drivers by default

 drivers/ata/ata_piix.c    |   36 ++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c |    6 ++++++
 include/linux/libata.h    |    1 +
 3 files changed, 43 insertions(+)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 1/2] libata: add a host flag to ignore detected ATA devices
  2012-05-04 21:15                           ` [PATCH 0/2] Hyper-V disk support V5 Andy Whitcroft
@ 2012-05-04 21:15                             ` Andy Whitcroft
  2012-05-07 19:43                               ` Jeff Garzik
  2012-05-04 21:15                             ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
  1 sibling, 1 reply; 35+ messages in thread
From: Andy Whitcroft @ 2012-05-04 21:15 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 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 e0bda9f..18e87bf 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 42378d6..198c8f1 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.9.5

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default
  2012-05-04 21:15                           ` [PATCH 0/2] Hyper-V disk support V5 Andy Whitcroft
  2012-05-04 21:15                             ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
@ 2012-05-04 21:15                             ` Andy Whitcroft
  1 sibling, 0 replies; 35+ messages in thread
From: Andy Whitcroft @ 2012-05-04 21:15 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide
  Cc: Andy Whitcroft, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

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 <apw@canonical.com>
---
 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 68013f9..8fea06b 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1552,6 +1552,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
@@ -1667,6 +1700,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.9.5

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] libata: add a host flag to ignore detected ATA devices
  2012-05-04 21:15                             ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
@ 2012-05-07 19:43                               ` Jeff Garzik
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Garzik @ 2012-05-07 19:43 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: linux-ide, linux-kernel, K. Y. Srinivasan, Mike Sterling, Alan Cox

On 05/04/2012 05:15 PM, Andy Whitcroft wrote:
> 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<apw@canonical.com>

applied 1-2




^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2012-05-07 19:44 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 17:28 [PATCH 1/1] ata_piix: defer disks to the Hyper-V paravirtualised drivers by default Andy Whitcroft
2012-03-30  9:14 ` Victor Miasnikov
2012-03-30  9:14   ` Victor Miasnikov
2012-04-10 16:08 ` KY Srinivasan
2012-04-12 15:55 ` Andy Whitcroft
2012-04-12 20:03 ` Jeff Garzik
2012-04-13  7:37   ` Andy Whitcroft
2012-04-14 15:53   ` [PATCH 0/2] Hyper-V disk support Andy Whitcroft
2012-04-14 15:53     ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
2012-04-14 15:53     ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
2012-04-14 16:02       ` Alan Cox
2012-04-15  0:10         ` KY Srinivasan
2012-04-16 11:20         ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
2012-04-16 11:20           ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
2012-04-16 11:20           ` [PATCH 2/2] UBUNTU: SAUCE: ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
2012-04-16 11:28             ` Sergei Shtylyov
2012-04-16 11:26           ` [PATCH 0/2] Hyper-V disk support V3 Alan Cox
2012-04-16 18:29             ` Andy Whitcroft
2012-04-16 18:41               ` KY Srinivasan
2012-04-18 20:12                 ` Alan Cox
2012-04-18 20:21                   ` KY Srinivasan
2012-04-19  8:15                     ` 1) boot flag to disable the Hyper-V IDE drivers: ata_piix.prefer_ms_hyperv=0 2) PIIX_IGNORE_ATA_ON_HYPERV Re: [PATCH 0/2] Hyper-V disk support V3 RE: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the CD-ROM) Victor Miasnikov
2012-04-19  8:15                       ` Victor Miasnikov
2012-04-19  7:40                   ` [PATCH 0/2] Hyper-V disk support V3 Andy Whitcroft
2012-04-19 13:17                     ` KY Srinivasan
2012-04-19 14:33                     ` [PATCH 0/2] Hyper-V disk support V4 Andy Whitcroft
2012-04-19 14:33                       ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
2012-04-19 14:33                       ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
2012-04-19 15:54                         ` Sergei Shtylyov
2012-05-04 21:15                           ` [PATCH 0/2] Hyper-V disk support V5 Andy Whitcroft
2012-05-04 21:15                             ` [PATCH 1/2] libata: add a host flag to ignore detected ATA devices Andy Whitcroft
2012-05-07 19:43                               ` Jeff Garzik
2012-05-04 21:15                             ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Andy Whitcroft
2012-04-16 15:32           ` [PATCH 0/2] Hyper-V disk support V3 Jeff Garzik
2012-04-16 18:28             ` Andy Whitcroft

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.