Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754374AbcJDVU6 (ORCPT ); Tue, 4 Oct 2016 17:20:58 -0400 Received: from mail-by2nam03on0118.outbound.protection.outlook.com ([104.47.42.118]:10560 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753722AbcJDVU5 (ORCPT ); Tue, 4 Oct 2016 17:20:57 -0400 X-Greylist: delayed 1984 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Oct 2016 17:20:57 EDT From: KY Srinivasan To: Long Li , Haiyang Zhang , Bjorn Helgaas CC: "devel@linuxdriverproject.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 1/2 v3] pci-hyperv: properly handle pci bus remove Thread-Topic: [PATCH 1/2 v3] pci-hyperv: properly handle pci bus remove Thread-Index: AQHSHfsEm6IioZB+AkCYLp3K+JyO56CYxS0g Date: Tue, 4 Oct 2016 20:47:51 +0000 Message-ID: References: <1475563367-16511-1-git-send-email-longli@exchange.microsoft.com> In-Reply-To: <1475563367-16511-1-git-send-email-longli@exchange.microsoft.com> 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=kys@microsoft.com; x-originating-ip: [2001:4898:80e8:d::7c2] x-ms-office365-filtering-correlation-id: c738c7d4-3e10-4baf-c73c-08d3ec97b55b x-microsoft-exchange-diagnostics: 1;BN3PR03MB2226;7:pyVGnCyHYsHn0mOpgEzPn4uudVOVnmZCb+w/34RZDsV1tjdqzpwYioy964B0AkRpy4BzJNtYIF5eECsgut6p6a83KB+soLW7iW6qEtkfvszqmDWzvAvTkDuiDCentTE/QEGsOt4jqcXpjYBlG2OfwIh8vbxpB6Igt0tAxShlo1cwybSQffpTHonMwk0krhpDb64eLT+WUQSeEKatv3eSl5RCXUkP8WxFdUOi6IoTZBjS2O5kCajR4f6K08H9Yt496UEvpnkcM2XjtBju066dQ0M7yUOzcAYfphyUJi//siMsbZkXc16V5qGYLS+lA+BIsDstozFl4+khhHwrReTtWg== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2226; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(211936372134217); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(61426038)(61427038);SRVR:BN3PR03MB2226;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2226; x-forefront-prvs: 00851CA28B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(189002)(13464003)(377454003)(199003)(189998001)(7846002)(81166006)(8676002)(2906002)(76576001)(50986999)(33656002)(106356001)(5001770100001)(2421001)(15198665003)(68736007)(97736004)(76176999)(106116001)(54356999)(87936001)(11100500001)(305945005)(4326007)(74316002)(81156014)(5002640100001)(7696004)(5660300001)(5005710100001)(3280700002)(2561002)(8936002)(105586002)(19580395003)(19580405001)(92566002)(86362001)(122556002)(86612001)(586003)(1511001)(99286002)(10090500001)(2900100001)(7736002)(3900700001)(102836003)(8990500004)(3660700001)(10400500002)(77096005)(10290500002)(6116002)(9686002)(1720100001)(101416001)(2950100002)(15395725005)(15975445007)(3826002)(10090945008);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB2226;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Oct 2016 20:47:51.4317 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2226 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u94LL96Q009628 Content-Length: 3264 Lines: 93 > -----Original Message----- > From: Long Li > Sent: Monday, October 3, 2016 11:43 PM > To: KY Srinivasan ; Haiyang Zhang > ; Bjorn Helgaas > Cc: devel@linuxdriverproject.org; linux-pci@vger.kernel.org; linux- > kernel@vger.kernel.org; Long Li > Subject: [PATCH 1/2 v3] pci-hyperv: properly handle pci bus remove > > This sender failed our fraud detection checks and may not be who they > appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing > > From: Long Li > > hv_pci_devices_present is called in hv_pci_remove when we remove a PCI > device from host (e.g. by disabling SRIOV on a device). In hv_pci_remove, > the bus is already removed before the call, so we don't need to rescan the > bus in the workqueue scheduled from hv_pci_devices_present. By > introducing status hv_pcibus_removed, we can avoid this situation. > > Signed-off-by: Long Li > Tested-by: Cathy Avery > Reported-by: Xiaofeng Wang Acked-by: KY Srinivasan > --- > drivers/pci/host/pci-hyperv.c | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index a8deeca..4a37598 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -348,6 +348,7 @@ enum hv_pcibus_state { > hv_pcibus_init = 0, > hv_pcibus_probed, > hv_pcibus_installed, > + hv_pcibus_removed, > hv_pcibus_maximum > }; > > @@ -1481,13 +1482,24 @@ static void pci_devices_present_work(struct > work_struct *work) > put_pcichild(hpdev, hv_pcidev_ref_initial); > } > > - /* Tell the core to rescan bus because there may have been changes. */ > - if (hbus->state == hv_pcibus_installed) { > + switch (hbus->state) { > + case hv_pcibus_installed: > + /* > + * Tell the core to rescan bus > + * because there may have been changes. > + */ > pci_lock_rescan_remove(); > pci_scan_child_bus(hbus->pci_bus); > pci_unlock_rescan_remove(); > - } else { > + break; > + > + case hv_pcibus_init: > + case hv_pcibus_probed: > survey_child_resources(hbus); > + break; > + > + default: > + break; > } > > up(&hbus->enum_sem); > @@ -2163,6 +2175,7 @@ static int hv_pci_probe(struct hv_device *hdev, > hbus = kzalloc(sizeof(*hbus), GFP_KERNEL); > if (!hbus) > return -ENOMEM; > + hbus->state = hv_pcibus_init; > > /* > * The PCI bus "domain" is what is called "segment" in ACPI and > @@ -2305,6 +2318,7 @@ static int hv_pci_remove(struct hv_device *hdev) > pci_stop_root_bus(hbus->pci_bus); > pci_remove_root_bus(hbus->pci_bus); > pci_unlock_rescan_remove(); > + hbus->state = hv_pcibus_removed; > } > > ret = hv_send_resources_released(hdev); > -- > 1.8.5.6