From patchwork Mon Feb 13 18:10:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 9570543 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5CD66045D for ; Mon, 13 Feb 2017 18:10:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6FC3271CB for ; Mon, 13 Feb 2017 18:10:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB9C52793A; Mon, 13 Feb 2017 18:10:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51CCA271CB for ; Mon, 13 Feb 2017 18:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751727AbdBMSKQ (ORCPT ); Mon, 13 Feb 2017 13:10:16 -0500 Received: from mail-cys01nam02on0117.outbound.protection.outlook.com ([104.47.37.117]:65018 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751617AbdBMSKP (ORCPT ); Mon, 13 Feb 2017 13:10:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BAE/DjPCor+6dxkDpue/m9RqUzAYLFlS8ZUuFvLKW24=; b=jHv8p2ENIlf1CcqgHNFR0XnKBpSQ5zm4P81ViQihoT/Ts9daYrbsDOlneOcNi+7XIyif245zk5CrbwgvnvIsI370b2JEH2WIGTjCwleyMfo+MDxpDgfbfBwMftYgx9+g2uhOu340aREn7CWeH+Cw9NPXYCMg4YEY7k3NccsfVuI= Received: from BLUPR03MB1412.namprd03.prod.outlook.com (10.163.81.146) by BLUPR03MB1410.namprd03.prod.outlook.com (10.163.81.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Mon, 13 Feb 2017 18:10:12 +0000 Received: from BLUPR03MB1412.namprd03.prod.outlook.com ([10.163.81.146]) by BLUPR03MB1412.namprd03.prod.outlook.com ([10.163.81.146]) with mapi id 15.01.0888.030; Mon, 13 Feb 2017 18:10:11 +0000 From: Haiyang Zhang To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" CC: Haiyang Zhang , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "vkuznets@redhat.com" , "driverdev-devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] pci-hyperv: Use device serial number as PCI domain Thread-Topic: [PATCH] pci-hyperv: Use device serial number as PCI domain Thread-Index: AdKGJE2HZfxfADCjQxeJscZGzow0Dg== Date: Mon, 13 Feb 2017 18:10:11 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=haiyangz@microsoft.com; x-originating-ip: [72.74.33.140] x-ms-office365-filtering-correlation-id: f1d7f37d-4951-415b-ce93-08d4543b8d7f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:BLUPR03MB1410; x-microsoft-exchange-diagnostics: 1; BLUPR03MB1410; 7:akQQRrTjvHHeWprKtAzd6dskg+ZhGJj11P8KAO+732tCYTlbi4ae7qx+9j5EoG7gsk3mXs7h3qOpbSZHCVgwqzaIyrGgB+jnjglsuty50h3kFwya+9Pxw1INpiLTAWWWxkI4PhG4/7llBJCaw6+i7x5yUOkx8+hPizkZoTwk7LUEmZzOlGCPcLnVShhBmJaWoqesW1Uyfup96+jPABIsSgaNTBiYx2Wm/CH8uoQJ0K8PEfRg/X03vo5eE6K20GPYNdp4OXuxK9VDU0wWzM4M+KQabVG3cmrbFD23zbriDUFbnsLCl3X8TFCwuZybKDa+61HLOTaJo28r98lD1q1v2zvsb6S9tDv1RK0YU1t7CmJej8vvrnypL3SdvMCSBaYJNRLyZGOqlQwsmMAg+pX0lLglsG1CNDNrJw+YLyE59GrbKSDobWD8u1jJZxAb6NQ31QgXgEu27pt6bv/LL3M1mmgrOzCTBq+yag9jX1eL0U5AXgmz2C9qG4UUsXl6DZ061zN8vJPRKhnaR7gt0lUeYyMsQxa5+9wmKKmJBlz9vrs= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123564025)(20161123555025)(20161123558025)(20161123560025)(20161123562025)(6072148); SRVR:BLUPR03MB1410; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1410; x-forefront-prvs: 02176E2458 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39860400002)(39850400002)(39840400002)(39450400003)(39410400002)(40224003)(189002)(199003)(2900100001)(122556002)(3846002)(5660300001)(66066001)(4326007)(86612001)(33656002)(102836003)(6116002)(10090500001)(81166006)(5005710100001)(8936002)(92566002)(81156014)(10290500002)(8990500004)(8676002)(106356001)(305945005)(7736002)(68736007)(105586002)(74316002)(53936002)(189998001)(77096006)(55016002)(99286003)(54906002)(6436002)(9686003)(97736004)(6506006)(25786008)(2906002)(2501003)(3660700001)(50986999)(54356999)(3280700002)(101416001)(38730400002)(7696004)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB1410; H:BLUPR03MB1412.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2017 18:10:11.6136 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1410 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows PCI domain numbers starts with 1, and also unique on the same VM. So names, such as VF NIC names, that include domain number as part of the name, can be shorter than that based on part of bus UUID previously. The new names will also stay same for VMs created with copied VHD and same number of devices. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan Signed-off-by: Stephen Hemminger --- drivers/pci/host/pci-hyperv.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 3efcc7b..b92b565 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1315,6 +1315,16 @@ static void put_pcichild(struct hv_pci_dev *hpdev, get_pcichild(hpdev, hv_pcidev_ref_initial); get_pcichild(hpdev, hv_pcidev_ref_childlist); spin_lock_irqsave(&hbus->device_list_lock, flags); + /* When a device is being added into the bus, we set the PCI domain + * number to be the device serial number, which is non zero and + * unique on the same VM. The serial numbers start with 1, and + * increase by 1 for each device. So device names including this + * can have shorter names than based on the bus instance UUID. + * Only the first device serial number is used for domain, so the + * domain number will not change after the first device is added. + */ + if (list_empty(&hbus->children)) + hbus->sysdata.domain = desc->ser; list_add_tail(&hpdev->list_entry, &hbus->children); spin_unlock_irqrestore(&hbus->device_list_lock, flags); return hpdev;