From: longli@linuxonhyperv.com
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hyperv@vger.kernel.org
Cc: Long Li <longli@microsoft.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>
Subject: [Patch v5 1/3] Drivers: hv: vmbus: add support to ignore certain PCIE devices
Date: Thu, 5 Aug 2021 00:00:10 -0700 [thread overview]
Message-ID: <1628146812-29798-2-git-send-email-longli@linuxonhyperv.com> (raw)
In-Reply-To: <1628146812-29798-1-git-send-email-longli@linuxonhyperv.com>
From: Long Li <longli@microsoft.com>
Under certain configurations when Hyper-v presents a device to VMBUS, it
may have a VMBUS channel and a PCIe channel. The PCIe channel is not used
in Linux and does not have a backing PCIE device on Hyper-v. For such
devices, ignore those PCIe channels so they are not getting probed by the
PCI subsystem.
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/hv/channel_mgmt.c | 48 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index caf6d0c..705e95d 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -26,6 +26,21 @@
static void init_vp_index(struct vmbus_channel *channel);
+/*
+ * For some VMBUS devices, Hyper-v also presents certain PCIE devices as
+ * part of the host device implementation. Those devices have no real
+ * PCI implementation in Hyper-V, and should be ignored and not presented
+ * to the PCI layer.
+ */
+static const guid_t vpci_ignore_instances[] = {
+ /*
+ * Azure Blob instance ID in VPCI
+ * {d4573da2-2caa-4711-a8f9-bbabf4ee9685}
+ */
+ GUID_INIT(0xd4573da2, 0x2caa, 0x4711, 0xa8, 0xf9,
+ 0xbb, 0xab, 0xf4, 0xee, 0x96, 0x85),
+};
+
const struct vmbus_device vmbus_devs[] = {
/* IDE */
{ .dev_type = HV_IDE,
@@ -187,20 +202,19 @@ static bool is_unsupported_vmbus_devs(const guid_t *guid)
return false;
}
-static u16 hv_get_dev_type(const struct vmbus_channel *channel)
+static u16 hv_get_dev_type(const guid_t *guid)
{
- const guid_t *guid = &channel->offermsg.offer.if_type;
u16 i;
- if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
+ if (is_unsupported_vmbus_devs(guid))
return HV_UNKNOWN;
for (i = HV_IDE; i < HV_UNKNOWN; i++) {
if (guid_equal(guid, &vmbus_devs[i].guid))
- return i;
+ return vmbus_devs[i].dev_type;
}
pr_info("Unknown GUID: %pUl\n", guid);
- return i;
+ return HV_UNKNOWN;
}
/**
@@ -487,6 +501,16 @@ void vmbus_free_channels(void)
}
}
+static bool ignore_pcie_device(guid_t *if_instance)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vpci_ignore_instances); i++)
+ if (guid_equal(&vpci_ignore_instances[i], if_instance))
+ return true;
+ return false;
+}
+
/* Note: the function can run concurrently for primary/sub channels. */
static void vmbus_add_channel_work(struct work_struct *work)
{
@@ -910,7 +934,11 @@ static void vmbus_setup_channel_state(struct vmbus_channel *channel,
sizeof(struct vmbus_channel_offer_channel));
channel->monitor_grp = (u8)offer->monitorid / 32;
channel->monitor_bit = (u8)offer->monitorid % 32;
- channel->device_id = hv_get_dev_type(channel);
+ if (is_hvsock_channel(channel))
+ channel->device_id = HV_UNKNOWN;
+ else
+ channel->device_id =
+ hv_get_dev_type(&channel->offermsg.offer.if_type);
}
/*
@@ -972,6 +1000,14 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
trace_vmbus_onoffer(offer);
+ /* Check to see if we should ignore this PCIe channel */
+ if (hv_get_dev_type(&offer->offer.if_type) == HV_PCIE &&
+ ignore_pcie_device(&offer->offer.if_instance)) {
+ pr_debug("Ignore instance %pUl over VPCI\n",
+ &offer->offer.if_instance);
+ return;
+ }
+
if (!vmbus_is_valid_device(&offer->offer.if_type)) {
pr_err_ratelimited("Invalid offer %d from the host supporting isolation\n",
offer->child_relid);
--
1.8.3.1
next prev parent reply other threads:[~2021-08-05 7:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 7:00 [Patch v5 0/3] Introduce a driver to support host accelerated access to Microsoft Azure Blob for Azure VM longli
2021-08-05 7:00 ` longli [this message]
2021-08-05 7:00 ` [Patch v5 2/3] Drivers: hv: add Azure Blob driver longli
2021-08-05 7:11 ` Greg Kroah-Hartman
2021-08-05 18:07 ` Long Li
2021-08-05 18:16 ` Greg Kroah-Hartman
2021-08-05 17:06 ` Bart Van Assche
2021-08-05 18:10 ` Long Li
2021-08-05 18:17 ` Greg Kroah-Hartman
2021-09-07 21:42 ` Michael Kelley
2021-08-05 7:00 ` [Patch v5 3/3] Drivers: hv: Add to maintainer for Hyper-V/Azure drivers longli
2021-08-05 7:08 ` [Patch v5 0/3] Introduce a driver to support host accelerated access to Microsoft Azure Blob for Azure VM Greg Kroah-Hartman
2021-08-05 18:27 ` Long Li
2021-08-05 18:33 ` Greg Kroah-Hartman
2021-08-05 17:09 ` Bart Van Assche
2021-08-05 18:24 ` Long Li
2021-08-05 18:34 ` Greg Kroah-Hartman
2021-08-07 18:29 ` Long Li
2021-08-08 5:14 ` Greg Kroah-Hartman
2021-08-10 3:01 ` Long Li
2021-09-22 23:55 ` Long Li
2021-09-30 22:25 ` Long Li
2021-10-01 7:36 ` Greg Kroah-Hartman
2021-10-07 18:15 ` Long Li
2021-10-08 5:54 ` Greg Kroah-Hartman
2021-10-08 11:11 ` Vitaly Kuznetsov
2021-10-08 11:19 ` Greg Kroah-Hartman
2021-10-08 13:28 ` Vitaly Kuznetsov
2021-10-11 17:57 ` Long Li
2021-10-13 0:58 ` Long Li
2021-10-13 7:03 ` Greg Kroah-Hartman
2021-10-11 17:55 ` Long Li
2021-10-11 17:46 ` Long Li
2021-10-11 17:58 ` Greg Kroah-Hartman
2021-10-11 19:38 ` Long Li
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=1628146812-29798-2-git-send-email-longli@linuxonhyperv.com \
--to=longli@linuxonhyperv.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.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 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.