From: Olaf Hering <olaf@aepfle.de>
To: linux-ide@vger.kernel.org
Cc: KY Srinivasan <kys@microsoft.com>,
devel@linuxdriverproject.org, gregkh@suse.de,
linux-kernel@vger.kernel.org, virtualization@lists.osdl.org
Subject: [PATCH RFC] ata_piix: ignore disks in a hyper-v guest
Date: Thu, 1 Sep 2011 17:43:40 +0200 [thread overview]
Message-ID: <20110901154340.GA12375@aepfle.de> (raw)
In-Reply-To: <20110831091156.GA16104@aepfle.de>
On Wed, Aug 31, Olaf Hering wrote:
> After some more testing it looks like the hv_blkvsc driver claimed the
> ide major #3, so the ide_core could not bind to the emulated IDE
> hardware. The modprobe.conf rules prevented that ata_piix gets loaded.
> If I force a module load order of 'ata_piix ;hv_blkvsc' both ata_piix
> and hv_blkvsc will bind to the same drive, just as shown in my previous
> mail. So there is appearently no way to shutdown the IDE ports like it
> is done with xen_emul_unplug= option for Xen guests.
>
> Maybe some hack is needed for a hyper-v specific unplug if Windows does
> indeed lack that feature. Now that ata_piix is compiled into the kernel,
> there is nothing to a modprobe.conf rule can "fix".
Here is an attempt to ignore disks in a hyper-v disks, and let ata_piix
handle only the configured cdrom devices (iso of physical).
If the disks are not ignored, they will appear twice, once through
ata_piix and once through hv_storvsc.
Once hv_storvsc can also handle the configured cdrom devices, the added
piix_pata_read_id() function can be removed again. Only the check in
piix_init() or something similar needs to be done.
Maybe there is a better way enable only ATA_DEV_ATAPI?
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/ata/ata_piix.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -98,6 +98,10 @@
#define DRV_NAME "ata_piix"
#define DRV_VERSION "2.13"
+#if defined(CONFIG_HYPERV_STORAGE) || defined(CONFIG_HYPERV_STORAGE_MODULE)
+#define PIIX_IGNORE_ATA_ON_HYPERV 1
+#endif
+
enum {
PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
ICH5_PMR = 0x90, /* port mapping register */
@@ -164,6 +168,7 @@ struct piix_host_priv {
static int piix_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent);
static void piix_remove_one(struct pci_dev *pdev);
+static unsigned int piix_pata_read_id(struct ata_device *adev, struct ata_taskfile *tf, u16 *id);
static int piix_pata_prereset(struct ata_link *link, unsigned long deadline);
static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev);
static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev);
@@ -346,6 +351,7 @@ static struct ata_port_operations piix_p
.set_piomode = piix_set_piomode,
.set_dmamode = piix_set_dmamode,
.prereset = piix_pata_prereset,
+ .read_id = piix_pata_read_id,
};
static struct ata_port_operations piix_vmw_ops = {
@@ -619,6 +625,24 @@ MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
MODULE_VERSION(DRV_VERSION);
+#if defined(PIIX_IGNORE_ATA_ON_HYPERV)
+static int piix_msft_hyperv(void)
+{
+ static const struct dmi_system_id hv_dmi_ident[] = {
+ {
+ .ident = "Hyper-V",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
+ DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
+ },
+ },
+ { } /* terminate list */
+ };
+ return !!dmi_check_system(hv_dmi_ident);
+}
+#endif
+
struct ich_laptop {
u16 device;
u16 subvendor;
@@ -702,6 +726,29 @@ static int piix_pata_prereset(struct ata
return ata_sff_prereset(link, deadline);
}
+/**
+ *
+ */
+static unsigned int piix_pata_read_id(struct ata_device *adev, struct ata_taskfile *tf, u16 *id)
+{
+ unsigned int err_mask = ata_do_dev_read_id(adev, tf, id);
+#if defined(PIIX_IGNORE_ATA_ON_HYPERV)
+ /*
+ * Ignore disks in a hyper-v guest.
+ * There is no unplug protocol like it is done with xen_emul_unplug= option.
+ * Emulate the unplug by ignoring disks when the hv_storvsc driver is enabled.
+ * If the disks are not ignored, they will appear twice: once through piix and once through hv_storvsc.
+ * Because hv_storvsc does not handle ATAPI devices, the piix driver is still required.
+ * Once hv_storvsc handles all devices, this function can be removed and the whole driver should be disabled in a hyper-v guest.
+ */
+ if (ata_id_is_ata(id) && piix_msft_hyperv()) {
+ ata_dev_printk(adev, KERN_WARNING, "ATA device ignored in Hyper-V guest\n");
+ id[ATA_ID_CONFIG] |= (1 << 15);
+ }
+#endif
+ return err_mask;
+}
+
static DEFINE_SPINLOCK(piix_lock);
/**
@@ -1679,6 +1726,13 @@ static int __init piix_init(void)
{
int rc;
+#if defined(PIIX_IGNORE_ATA_ON_HYPERV)
+ /* disabled until hv_storvsc drives also cdrom devices */
+ if (0 && piix_msft_hyperv()) {
+ printk(KERN_DEBUG "%s: hv_storvsc will bind to storage\n", __func__);
+ return -ENODEV;
+ }
+#endif
DPRINTK("pci_register_driver\n");
rc = pci_register_driver(&piix_pci_driver);
if (rc)
next prev parent reply other threads:[~2011-09-01 15:43 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-27 18:31 [PATCH 0000/0046] Staging: hv: Driver cleanup K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 01/46] Staging: hv: storvsc: Inline free_stor_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 02/46] Staging: hv: storvsc: Do not aquire an unnecessary reference on stor_device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 03/46] Staging: hv: storvsc: Rename must_get_stor_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 04/46] Staging: hv: storvsc: Rename get_stor_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 05/46] Staging: hv: storvsc: Cleanup alloc_stor_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 06/46] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 07/46] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is being destroyed K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 08/46] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 09/46] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 10/46] Staging: hv: storvsc: Get rid of the reference counting in struct storvsc_device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 11/46] Staging: hv: netvsc: Inline the code for free_net_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 12/46] Staging: hv: netvsc: Cleanup alloc_net_device() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 13/46] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 14/46] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 15/46] Staging: hv: netvsc: Get rid of release_outbound_net_device() by inlining the code K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 16/46] Staging: hv: netvsc: Get rid of release_inbound_net_device() " K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 17/46] Staging: hv: netvsc: Get rid of the refcnt field in struct netvsc_device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 18/46] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver K. Y. Srinivasan
2011-08-30 11:07 ` Dan Carpenter
2011-08-27 18:31 ` [PATCH 19/46] Staging: hv: storvsc: Handle " K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 20/46] Staging: hv: blkvsc: Get rid of blkvsc_drv.c as this code is not used K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 21/46] Staging: hv: storvsc: Optimize bounce buffer handling for the "write" case K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 22/46] Staging: hv: storvsc: Optimize the bounce buffer handling in the "read" case K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 23/46] Staging: hv: storvsc: Include storvsc.c in storvsc_drv.c K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 24/46] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 25/46] Staging: hv: storvsc: Add the contents of hyperv_storage.h to storvsc_drv.c K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 26/46] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 27/46] Staging: hv: storvsc: Fixup srb and scsi status for INQUIRY and MODE_SENSE K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 28/46] Staging: hv: storvsc: Fix a typo K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 29/46] Staging: hv: storvsc: In case of scsi errors offline the device K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 30/46] Staging: hv: storvsc: No need to copy from bounce buffer in case of a failure K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 31/46] Staging: hv: util: Forcefully shutdown when shutdown is requested K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 32/46] Staging: hv: util: Adjust guest time in a process context K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 33/46] Staging: hv: vmbus: Check before invoking the channel callback K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 34/46] Staging: hv: vmbus: Properly deal with de-registering " K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 35/46] Staging: hv: Fix a bug in vmbus_match() K. Y. Srinivasan
2011-08-29 18:00 ` Greg KH
2011-08-27 18:31 ` [PATCH 36/46] Staging: hv: vmbus: Get rid of vmbus_on_isr() by inlining the code K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 37/46] Staging: hv: vmbus: Check for events before messages K. Y. Srinivasan
2011-08-29 18:05 ` Greg KH
2011-08-30 17:06 ` KY Srinivasan
2011-08-30 17:38 ` Greg KH
2011-08-31 14:22 ` KY Srinivasan
2011-08-27 18:31 ` [PATCH 38/46] Staging: hv: vmbus: Do not enable auto eoi K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 39/46] Staging: hv: vmbus: Fixup indentation in vmbus_acpi_add() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 40/46] Staging: hv: vmbus: Get rid of some dated/redundant comments K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 41/46] Staging: hv: vmbus: Fix a bug in error handling in vmbus_bus_init() K. Y. Srinivasan
2011-08-29 18:08 ` Greg KH
2011-08-30 10:29 ` Dan Carpenter
2011-08-30 14:07 ` Greg KH
2011-08-30 17:25 ` KY Srinivasan
2011-08-30 17:07 ` KY Srinivasan
2011-08-27 18:31 ` [PATCH 42/46] Staging: hv: vmbus: Get rid of an unnecessary check in vmbus_connect() K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 43/46] Staging: hv: vmbus: Fix a checkpatch warning in ring_buffer.c K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 44/46] Staging: hv: vmbus: Fix checkpatch warnings in connection.c K. Y. Srinivasan
2011-08-28 6:56 ` Joe Perches
2011-08-30 17:03 ` KY Srinivasan
2011-08-29 18:09 ` Greg KH
2011-08-30 17:11 ` KY Srinivasan
2011-08-30 17:41 ` Greg KH
2011-08-31 14:21 ` KY Srinivasan
2011-08-27 18:31 ` [PATCH 45/46] Staging: hv: mousevsc: Fix checkpatch errors and warnings K. Y. Srinivasan
2011-08-27 18:31 ` [PATCH 46/46] Staging: hv: Update the TODO file K. Y. Srinivasan
2011-08-29 18:12 ` Greg KH
2011-08-30 17:13 ` KY Srinivasan
2011-08-29 18:15 ` [PATCH 0000/0046] Staging: hv: Driver cleanup Greg KH
2011-08-30 17:27 ` KY Srinivasan
2011-08-30 12:48 ` Olaf Hering
2011-08-30 17:22 ` KY Srinivasan
2011-08-30 17:43 ` Greg KH
2011-08-30 18:04 ` Olaf Hering
2011-08-30 18:19 ` Greg KH
2011-08-31 9:11 ` Olaf Hering
2011-09-01 15:43 ` Olaf Hering [this message]
2011-08-31 14:27 ` KY Srinivasan
2011-08-31 14:18 ` KY Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110901154340.GA12375@aepfle.de \
--to=olaf@aepfle.de \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=kys@microsoft.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).