Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4212479pxv; Mon, 19 Jul 2021 20:39:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeC/HrS4OrS1H5Q6f9fS7dIr0wQhX+Dh6FI+1p3ZESHUw4Xw33JakUTXUWTR49nqZ4Jypa X-Received: by 2002:a92:b74d:: with SMTP id c13mr19078676ilm.176.1626752366249; Mon, 19 Jul 2021 20:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626752366; cv=none; d=google.com; s=arc-20160816; b=f8o9cURgc5K3QVrKwzHRs042ZvCVOuKWsG8D2ntt0sAL8GCkbgruBtslFO4s/8Rvte YNKeMd3Kog1Lpqg5IG/Z8oX9vKoYZWtcVWjeufPjm3lkYnAITw0xNcHUxL9DtL7NEwa7 oeokgz0hKNqCTq1rP/TZYvR6pmQ+SlNg8vyA7FMofKBlqgDR7/tCXP2L5tesTPAnn/wt Tsb3yObey2i4asOIC/PjL4U5L2dm3AS6W5OcYgnLuyBmUBipApy/3fQV9xDLJYjwF2FD 7x/OFqK02CHU6mlUVwSns6ZZClbSVxUfvpsIDRPa2dNKAISzBT1jH1Cl4v15e2RnJHgs K7sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=h+df99qSf3zh12y8ORytzSLFUivMOvK6z9tVZ1RpBfY=; b=CPrYWhuOub7TtAMZ4ygeR2W6L3SBNTeOzLY8xl+uhzUbqNPvY2uRMFgMtssix4ngaM i6XB9urGe8GrywONPTyTyANap7mzRiCIqowcAHSFnqjF0itHnF9e99uhlGrWO5mbZ0vG WAlSbvls3LVfPdxAkUuCnpMboFjlax7DIsyAJbrDGZsy8vjZI6TXzEJyMzWrJCai1An0 dopF9zWJngqn0Kw105JSHpVginB4q6rV9M+f2HDm8vuf9Y0nczLHtnvgp8sX2orqaAde /Rfu8eafiroPvnamde2RGTTcnZHxMzcgrvMOdRRjixnh/bQZsIOOnTxJ1yrMmKWy9pNI FwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=BhYWFYhT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si21279250ils.118.2021.07.19.20.39.15; Mon, 19 Jul 2021 20:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=BhYWFYhT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245004AbhGTCxm (ORCPT + 99 others); Mon, 19 Jul 2021 22:53:42 -0400 Received: from linux.microsoft.com ([13.77.154.182]:40636 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239743AbhGTCvA (ORCPT ); Mon, 19 Jul 2021 22:51:00 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 59C9020B7188; Mon, 19 Jul 2021 20:31:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 59C9020B7188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1626751893; bh=h+df99qSf3zh12y8ORytzSLFUivMOvK6z9tVZ1RpBfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhYWFYhTnTsF4OUfI6ZFkG5kDOrGTbyAz/x6AFzwBeQBoR0EXVeGGy5Ca2cb/9ATU nMstZCSMaAWBrj8JnReIfLuEZvKU9+iSZQ6x//zEWxKBF0886Xgwvr+dMiKP9QSXwh 2E4TGv6pgA5E/ePQKnIdTnVaCVsXH0wtKv8XTUdA= From: longli@linuxonhyperv.com To: linux-fs@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: Long Li , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui Subject: [Patch v4 1/3] Drivers: hv: vmbus: add support to ignore certain PCIE devices Date: Mon, 19 Jul 2021 20:31:04 -0700 Message-Id: <1626751866-15765-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626751866-15765-1-git-send-email-longli@linuxonhyperv.com> References: <1626751866-15765-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li 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 Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Wei Liu Cc: Dexuan Cui Signed-off-by: Long Li --- 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 caf6d0c4bc1b..705e95d7a040 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); -- 2.25.1