From patchwork Mon Mar 5 19:22:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881619 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="RGpupETC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8xt217Vz9sYX for ; Tue, 6 Mar 2018 06:25:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932462AbeCETZF (ORCPT ); Mon, 5 Mar 2018 14:25:05 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752841AbeCETWV (ORCPT ); Mon, 5 Mar 2018 14:22:21 -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=vxCIrSoAZrlKw9gBWMMUtwbcEj/n0Rn78xMG3DArWYc=; b=RGpupETCqbySM8BkSvtI0hwbbTq7HOu4mc76LWkuBOVW+ICNj4AxP4C6dF2Q3LGJMxJOrsm13O/ZnhU01PXA91IORpPZ4QsJ2DJkHnOfs6CfsL64d6s4ciOGWlrqE+StRySjAA3uRzIQJ3h6wMzBueZZkI5JQFSAsRl/uFjw6YA= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:13 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:13 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , "stable@vger.kernel.org" Subject: [PATCH v2 1/6] PCI: hv: fix a comment typo in _hv_pcifront_read_config() Thread-Topic: [PATCH v2 1/6] PCI: hv: fix a comment typo in _hv_pcifront_read_config() Thread-Index: AQHTtLdDye0SosGGjkSB+GGEOLKKDg== Date: Mon, 5 Mar 2018 19:22:13 +0000 Message-ID: <20180305192134.32207-2-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 7:DIQacIwhDGDThZr8gRr2CSuBldaNkiynCHZllVmWgvKb40zh9XLgh2qh01RdJES/R5Tm4qOWNQHkzvYnaWFaLvS2Op7072GgIy2js3ZfyMMpocVtWCmw94dUJtHPNcLPWZg3iewtcFCOmvtQdX/7bSiYqlEtPXT4GNDbK0w06ACj6SbMe6T18y1TtC22hqdvhzPlIT3M2aylbzEyQMiC0DE4Xr20vUj/HyfZlC6T695xBDKNDD3+KMxMBrFCqMGk; 20:5pVyzSHIUpbDJ1n+GXJemtegCjxjkLH4OZfOx2ufhngIIZtPnBry7/yathJVc/O3sPBSUwdOREqHJsJxSP5KqGiMqWYXlD7LYQ5iV6DW2tPnm+/Z/wWgt4/Rz1IJeGQQd3LYCCe9Jghc1gVUhHxRZFahn8imE1p1kOKHD+eioZw= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: dc8805a9-641e-4c91-ada6-08d582ce6683 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(59450400001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: SsHnRiH8DmlH2rLN6M0qKSv4/W8IUaOp2deL1UiXGwBlWI0lm+BvP7JKBSi/5OJCuMAb6qiXC2IMKiWIBlghd3jDDqySCvlgOLY5yOHGnevGWcodfSB9rjGoJfQmsLySn8UwI0NgAfmVF9nOP6BoIIF1HyYcbkSbxaNRtHOexC9jrSlFVqJaYSumbOqpbVJ1QmUFN8j0QCgb7pHm67+29IRbUYi0kLIoGWo0BSiYDOC4afER0ugqJGILzwFMzWl/aGN7JiBqzer5HAfgGua4UjzKUU5B9GTSv4HuE/oCz3EMBWA+NA9z9D+HHqVvgPkKi8bsUofrABKwC8yBm3jYEQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc8805a9-641e-4c91-ada6-08d582ce6683 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:13.1617 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org No functional change. Signed-off-by: Dexuan Cui Fixes: bdd74440d9e8 ("PCI: hv: Add explicit barriers to config space access") Cc: Vitaly Kuznetsov Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan --- drivers/pci/host/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 2faf38eab785..1233300f41c6 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -653,7 +653,7 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, break; } /* - * Make sure the write was done before we release the spinlock + * Make sure the read was done before we release the spinlock * allowing consecutive reads/writes. */ mb(); From patchwork Mon Mar 5 19:22:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881616 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="ITzLkvEj"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8wg19r5z9s1q for ; Tue, 6 Mar 2018 06:24:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752937AbeCETW1 (ORCPT ); Mon, 5 Mar 2018 14:22:27 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752931AbeCETWX (ORCPT ); Mon, 5 Mar 2018 14:22:23 -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=+Hhm9N3q2CK6Hm61XPJ+Ffw7pjJ9voBSDqTWohRxk+M=; b=ITzLkvEj1NwhA1zrUGcK9wXrsjP0I5YB1Cm0kvHJj0D/STk70nl5mwGqguqeLdvadzKKn0zZncOQUmvR57alCDrLrM9yMaCbI5SeWPmLWGm3hZ8ipFzyH+dxxeno2ZcXbkHyQSUz7CPmv3XWgTWpCfF/J8XCtugKIIMyMbukWP0= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:15 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:15 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , Jack Morgenstein , "stable@vger.kernel.org" Subject: [PATCH v2 2/6] PCI: hv: hv_eject_device_work(): remove the bogus test Thread-Topic: [PATCH v2 2/6] PCI: hv: hv_eject_device_work(): remove the bogus test Thread-Index: AQHTtLdEG5adpemEOka8xO9TE6oauw== Date: Mon, 5 Mar 2018 19:22:15 +0000 Message-ID: <20180305192134.32207-3-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 7:ZHIuEH/jCC21s57m9kxGiw1qOSKoNf+armBta/Ct79BLVMYz5rscO6lSfYFoMz9VhfZzVS7oiI3GblSal65dgx/THmAQ3XHUyKJ39AssnxleNwPQHSSVxUHmiaZ5H94vq7v7bCpcCaQ8XiRkB1rQ48WvgTsb/WBXLtTmfDeJ3ug3nNcBLPrPN+nOT4hp0ZyGEhCWGjY8cHe+N1yC9yfXs1uk2aHpDtenRepSo8L62/VpplldHW78/iGK6GZ//rr1; 20:/OyH0CyQlkL5fwjqocmYKsZ03PhEyl3FJWlmmnWIc/Pob/4XuWmaxFamG77+ncX2PP9mu49YD20crN7Y1yYdUnRrbFO0LgQlRaqO8n8uVx+nIql3a4yurQUeFRcBaAW1cF3odYIs3IQHoc5i2rQkyrC/i8hGKLRR6xAXb8DWpag= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 62b96d2b-80c0-4a63-7e18-08d582ce67ab x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: NujxJ5Lmd8iw7dRzjKAsU/19Jw9MpiETkNgeSKd1e4mvtx6FHb0vF8dV4tRxXsO0yO8CMHMtdlum7HiXeOsYjvGEm+C7Xr9/I8QxixHmqnsiXXlNJdomccWNvB5FAzKw5FEG3gHDhOnTGFXV6eDRkxqbDQN0VzMdt2oQeAPntb+Rmub9t3ZUs232lRSaf7NEK+2x7MiMrbXT4KrK8YZP1XtA2DCCXNM/6Q+23hEnZkQcE/7NX82GCwUjBvYdLVOk6aT7t8sIxfKjoZyTazTW8HIqPddpOpjW+80lydykaLbtpDwbYmW/CpHzRBzKvYT+EyHPB/9fhEKBg1vTvGt87A== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62b96d2b-80c0-4a63-7e18-08d582ce67ab X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:15.1074 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When we're in the function, hpdev->state must be hv_pcichild_ejecting: see hv_pci_eject_device(). Signed-off-by: Dexuan Cui Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan Cc: Michael Kelley (EOSG) --- drivers/pci/host/pci-hyperv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 1233300f41c6..04edb24c92ee 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1796,10 +1796,7 @@ static void hv_eject_device_work(struct work_struct *work) hpdev = container_of(work, struct hv_pci_dev, wrk); - if (hpdev->state != hv_pcichild_ejecting) { - put_pcichild(hpdev, hv_pcidev_ref_pnp); - return; - } + WARN_ON(hpdev->state != hv_pcichild_ejecting); /* * Ejection can come before or after the PCI bus has been set up, so From patchwork Mon Mar 5 19:22:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881617 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="lReeaGQL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8xT2Tr3z9s1q for ; Tue, 6 Mar 2018 06:25:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932370AbeCETYp (ORCPT ); Mon, 5 Mar 2018 14:24:45 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752935AbeCETWZ (ORCPT ); Mon, 5 Mar 2018 14:22:25 -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=fI09oBugTBMw/6wJrr5UWqNpvgm9pXkZrMeZGwGi6Ao=; b=lReeaGQLCJj2HwTeaaeNG87idFI8XUKyHNY5v7so6iJxFbk8OYf1gmp8kvGNs+JO+a1pYGF5ztNuSoHu5NUg0txHBAOvsBUlN4naybho+cGCgLFX6Jk57HXw1ADcQB9VrM+E6CWMlwG4GqA75NwQo8+va60jl4RsTSyfevSlID0= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:17 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:17 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , Jack Morgenstein , "stable@vger.kernel.org" Subject: [PATCH v2 3/6] PCI: hv: serialize the present/eject work items Thread-Topic: [PATCH v2 3/6] PCI: hv: serialize the present/eject work items Thread-Index: AQHTtLdF9VixgM1SgE2S1sRr4R78NQ== Date: Mon, 5 Mar 2018 19:22:17 +0000 Message-ID: <20180305192134.32207-4-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 7:vCnXLLktDG9wM9uw0/ZEZI+QhTjhA/+x1Dw0hTRrqRw6/lQOF1GKhIMe0RuH7yda1Azx4RCgfV52m+yCLTniZOR0aAXXam7BsnUYxjJNx+WRZhjIo28cpWxCbMHhaqImPTZYXskTPY72WWbcbCFwo4YqWWYEphCJffJKpr/kXA2mudZrjezSzSLkRV5WccDVG/WbNyBmp36e9RX0loMOhVW/95gjVnFOevxLbhWJ56nCI6RFH6FGYen2W0VrYhWN; 20:BMIgCHOjLa3kcajAuWaXLSlf2Kw+CBdKZxdXT/91Oci7hCpLVG8gHhc7xKSc7nX8geFaELiJkU+YfPGCx3StpwOGHTYiqFvV/AuyeQho9TtswUE0MnWyAqnc6T1NwPNrAvKbbzqQMvxwIPA2IismqGUvDlZOQaIwHu2km3HcQiE= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 623ac24b-c760-401e-1983-08d582ce68d0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(59450400001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: oRGgeVPi4o4BUfpQJL9T7XFe43eTi3uunLbbXCJlhMe80sPwYZHajIG9MANgLlE+T85RmNTg6YafFJNyELT+ApohGyn7QZlbPcYvvKttQzC9iuoqTtm+YI6RcYW10vYSJFNrrPHRtA2yGhH4UvR0IMmiKVnaXidCAdkEQXdYLn/l0vrTN3z9zJsURQxJvIzPRCtyM51xwR6gdsly5daFflwrNi8+EU6SnQgh/JG71fPvDtkfO/IA/tLE0aqB4ITtkdKl6rTcI7QZwD8V1aZqZDoBB10A7lgzeCN31BHnKrsJSxvJs4iOvrCzk7iDSkkEWUK+6xodC0nsX5oQ+DdUig== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 623ac24b-c760-401e-1983-08d582ce68d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:17.0320 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When we hot-remove the device, we first receive a PCI_EJECT message and then receive a PCI_BUS_RELATIONS message with bus_rel->device_count == 0. The first message is offloaded to hv_eject_device_work(), and the second is offloaded to pci_devices_present_work(). Both the paths can be running list_del(&hpdev->list_entry), causing general protection fault, because system_wq can run them concurrently. The patch eliminates the race condition. Signed-off-by: Dexuan Cui Tested-by: Adrian Suhov Tested-by: Chris Valean Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan --- drivers/pci/host/pci-hyperv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 04edb24c92ee..aaee41faf55f 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -461,6 +461,8 @@ struct hv_pcibus_device { struct retarget_msi_interrupt retarget_msi_interrupt_params; spinlock_t retarget_msi_interrupt_lock; + + struct workqueue_struct *wq; }; /* @@ -1770,7 +1772,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, spin_unlock_irqrestore(&hbus->device_list_lock, flags); get_hvpcibus(hbus); - schedule_work(&dr_wrk->wrk); + queue_work(hbus->wq, &dr_wrk->wrk); } /** @@ -1845,7 +1847,7 @@ static void hv_pci_eject_device(struct hv_pci_dev *hpdev) get_pcichild(hpdev, hv_pcidev_ref_pnp); INIT_WORK(&hpdev->wrk, hv_eject_device_work); get_hvpcibus(hpdev->hbus); - schedule_work(&hpdev->wrk); + queue_work(hpdev->hbus->wq, &hpdev->wrk); } /** @@ -2460,11 +2462,17 @@ static int hv_pci_probe(struct hv_device *hdev, spin_lock_init(&hbus->retarget_msi_interrupt_lock); sema_init(&hbus->enum_sem, 1); init_completion(&hbus->remove_event); + hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, + hbus->sysdata.domain); + if (!hbus->wq) { + ret = -ENOMEM; + goto free_bus; + } ret = vmbus_open(hdev->channel, pci_ring_size, pci_ring_size, NULL, 0, hv_pci_onchannelcallback, hbus); if (ret) - goto free_bus; + goto destroy_wq; hv_set_drvdata(hdev, hbus); @@ -2533,6 +2541,8 @@ static int hv_pci_probe(struct hv_device *hdev, hv_free_config_window(hbus); close: vmbus_close(hdev->channel); +destroy_wq: + destroy_workqueue(hbus->wq); free_bus: free_page((unsigned long)hbus); return ret; @@ -2612,6 +2622,7 @@ static int hv_pci_remove(struct hv_device *hdev) irq_domain_free_fwnode(hbus->sysdata.fwnode); put_hvpcibus(hbus); wait_for_completion(&hbus->remove_event); + destroy_workqueue(hbus->wq); free_page((unsigned long)hbus); return 0; } From patchwork Mon Mar 5 19:22:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881611 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="Eo0mVGnq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8vC6P2Hz9s1q for ; Tue, 6 Mar 2018 06:23:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbeCETWa (ORCPT ); Mon, 5 Mar 2018 14:22:30 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752904AbeCETW1 (ORCPT ); Mon, 5 Mar 2018 14:22:27 -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=VDTAi36vNiAF4XVqq9pvE55MGIRQ1Z0hdhYgldmKj1I=; b=Eo0mVGnqKTMhOx1i9C+YREb8IKnbiH6b3VwfUyQGsO9CKt2we1CYAYyo/HH0UTjnJOsmJn9KSnxJrsNH5sbMpW72pEvN9iCNIzGw83vwRq6at+OxnvWUTQQUehrFIwKmOtwseY6+nILxWY7YaE0P4FMLeSeZdbc7XZ48d1MJ6AI= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:19 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:19 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , Jack Morgenstein , "stable@vger.kernel.org" Subject: [PATCH v2 4/6] PCI: hv: remove hbus->enum_sem Thread-Topic: [PATCH v2 4/6] PCI: hv: remove hbus->enum_sem Thread-Index: AQHTtLdHnsXJFvisFEWUranPC/7lKA== Date: Mon, 5 Mar 2018 19:22:19 +0000 Message-ID: <20180305192134.32207-5-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 7:x81PwCpgpcrUfrCeYtHzbxNL9fiDheUprilufofgfLw1sxNj/OEP1fXTzx1wqRynCGNJ7XZH/thIkDLpIiBANjlWkbmphwXn0I0NNesUe/c9Mq/WvWWIZbO3TZKjcpAG/HycPr094X9/0a8MCt4JhJdhHYgE8v22MkjllQvUmYYU4UCWcH6BW4x4dCKKbf8Ry/6lAT+rRa8DTwLZ/hlR6KGwnCickIEW5BI90eWBtW0b8i/ufgKWSBirUA+j4t+a; 20:1oyyCrzpkMxnckorcUJZm9Vaj2Po7Mq6aJ9f8F97yb849RT35gSj+EQqpu8rSQa1mw0p40hc6Mom5m7d/lRu3/A/NYQAgpUTlsFW4lhXy+0VDQmhbXTV1N8JPsif5JhzmYBfGmNq6Gmo1fuZmosTHN49+kv53/eyl1cLrYCS3yQ= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e4317f52-3c8a-4a1c-920f-08d582ce6a11 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(59450400001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: eEUAGJ0cKpiodAoC7XUXhVAc4m0BKQdkkWnxnfB8lQDwHwTWlqNOgZUkCdJY9QoOmZQERAj01xbTa5G71at51zupuek2B90VjN9HEQeF+ASqYKergnQQc5SNv2bISW5sRd1BndNwczFYDvHGDYosXqe7dHXx27MrhijXHnZzQKu3VnF7s96I20e6/RUE7UjHK0YA5HC0dfDvErRMB3N93vkQYZmpP3kH/P+nh+ORX7l7zDThTa9I9K0wEC+Q8CigwSGdbvOrXnGKRgxHwkpLMOPNAnnYyur7O4r15TQFs2CaoCDcaCBfJJg7tRdWwODD+zD1JqbTa+a3ZFIS2bOhQA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4317f52-3c8a-4a1c-920f-08d582ce6a11 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:19.0978 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Since we serialize the present/eject work items now, we don't need the semaphore any more. This is suggested by Michael Kelley. Signed-off-by: Dexuan Cui Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan Cc: Michael Kelley (EOSG) --- drivers/pci/host/pci-hyperv.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index aaee41faf55f..3a385212f666 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -447,7 +447,6 @@ struct hv_pcibus_device { spinlock_t device_list_lock; /* Protect lists below */ void __iomem *cfg_addr; - struct semaphore enum_sem; struct list_head resources_for_children; struct list_head children; @@ -1592,12 +1591,8 @@ static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, * It must also treat the omission of a previously observed device as * notification that the device no longer exists. * - * Note that this function is a work item, and it may not be - * invoked in the order that it was queued. Back to back - * updates of the list of present devices may involve queuing - * multiple work items, and this one may run before ones that - * were sent later. As such, this function only does something - * if is the last one in the queue. + * Note that this function is serialized with hv_eject_device_work(), + * because both are pushed to the ordered workqueue hbus->wq. */ static void pci_devices_present_work(struct work_struct *work) { @@ -1618,11 +1613,6 @@ static void pci_devices_present_work(struct work_struct *work) INIT_LIST_HEAD(&removed); - if (down_interruptible(&hbus->enum_sem)) { - put_hvpcibus(hbus); - return; - } - /* Pull this off the queue and process it if it was the last one. */ spin_lock_irqsave(&hbus->device_list_lock, flags); while (!list_empty(&hbus->dr_list)) { @@ -1639,7 +1629,6 @@ static void pci_devices_present_work(struct work_struct *work) spin_unlock_irqrestore(&hbus->device_list_lock, flags); if (!dr) { - up(&hbus->enum_sem); put_hvpcibus(hbus); return; } @@ -1726,7 +1715,6 @@ static void pci_devices_present_work(struct work_struct *work) break; } - up(&hbus->enum_sem); put_hvpcibus(hbus); kfree(dr); } @@ -2460,7 +2448,6 @@ static int hv_pci_probe(struct hv_device *hdev, spin_lock_init(&hbus->config_lock); spin_lock_init(&hbus->device_list_lock); spin_lock_init(&hbus->retarget_msi_interrupt_lock); - sema_init(&hbus->enum_sem, 1); init_completion(&hbus->remove_event); hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, hbus->sysdata.domain); From patchwork Mon Mar 5 19:22:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881612 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="i1AzemWC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8vW2BLRz9s1q for ; Tue, 6 Mar 2018 06:23:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753040AbeCETXC (ORCPT ); Mon, 5 Mar 2018 14:23:02 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752963AbeCETW3 (ORCPT ); Mon, 5 Mar 2018 14:22:29 -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=3X+k/zYkDzLvAO9Zy1mFNJwWI9QHGDGXg1nx/GXzySE=; b=i1AzemWCK/x9uY40brFUCCgLy/ZM8SD+jjQx/3MB81Rc4j7oWVjAk9rj+YRcTwq4ge2ymo5Yv3xOmN78dEPASwzi7IMnQB8LZQyr4bqk3IGbu2ztx/P3xHioDtJLa1bIv9X5N8k3NE4FhXGu1htTIr8sfVGN0IVGRDKA1SzRjI4= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:22 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:22 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , Jack Morgenstein , "stable@vger.kernel.org" Subject: [PATCH v2 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary Thread-Topic: [PATCH v2 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary Thread-Index: AQHTtLdILulEelG7Ik+GDDlpqOy57A== Date: Mon, 5 Mar 2018 19:22:21 +0000 Message-ID: <20180305192134.32207-6-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 7:AFLsZq+AiL1Ca24yjT0ovpDz/cO7BIFQPO3+EYvbmtNVtAQpdZcd8kZOLK4gOh79ak2a5DcLrfsp7R7dzmAZwDq4pfXFq8W8JAU8tXm0FCnAp22OQ8JRzy0hzuPv6BNc+yzKjNq2Z1WpWpe4QPi7gwPGhnmzX0BYP3Nt7yG54sh+HGFcEX/0eSx4pVCIKQbfAum/uJfnwJDhkGBex9t8JO8w3zy2poy6q9DqwoFggX/Q88KG2uYmylbXhI+8mlvq; 20:h1LCPwCNnEvW79cTbjHdowfEbiiavrP1MYcqPSVz53Y0CwEMvVUGSs7VTtHcRwIQR0Hq5XVNsqsCjxnxc+59WE7X1R4TN0N8AF2ekY34j1Y/aJVIVSQ1pzq9C3JPvbkQhqpsCAlOUUKjG2QMnyvAz0NWnsRiIAEze6pd4vnhkpw= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d50c2a34-c783-4c5f-2e25-08d582ce6bbd x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(59450400001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: KQ1ql4XAY+gW4MxI/c9CQL3dv7Ys7D5qhami4a7FK+pyNkJS8Rar8vUNddQSJYFi7fID6eqeanbuxsD5x6FUUVUsq+HJwcuSyYh4Bg8wALzltYlQ4iCxtD4LTocJ4XaifKOcikOYEikizLcoZK40xRwOjOfWVmFd0btMHv8qAGhakKVgpPhd6hafFPSJU6jy3dInIZqXtCPjZcyo15xqDllAIjHctiqws07saKHvTl7mfr3QL/TT7gpRlTG1ULYuKgrH6IY/6lP0whzUPpjd85yckMZneibFM3log+Y8fdZ91v4EIVnoc3CW5XyoSuwYBwpKG/jHY1gqmNZGgVUJ8Q== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d50c2a34-c783-4c5f-2e25-08d582ce6bbd X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:21.8992 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If there is a pending work, we just need to add the new dr into the dr_list. This is suggested by Michael Kelley. Signed-off-by: Dexuan Cui Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan Cc: Michael Kelley (EOSG) --- drivers/pci/host/pci-hyperv.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 3a385212f666..d3aa6736a9bb 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1733,6 +1733,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, struct hv_dr_state *dr; struct hv_dr_work *dr_wrk; unsigned long flags; + bool pending_dr; dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT); if (!dr_wrk) @@ -1756,11 +1757,23 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, } spin_lock_irqsave(&hbus->device_list_lock, flags); + + /* + * If pending_dr is true, we have already queued a work, + * which will see the new dr. Otherwise, we need to + * queue a new work. + */ + pending_dr = !list_empty(&hbus->dr_list); list_add_tail(&dr->list_entry, &hbus->dr_list); - spin_unlock_irqrestore(&hbus->device_list_lock, flags); - get_hvpcibus(hbus); - queue_work(hbus->wq, &dr_wrk->wrk); + if (pending_dr) { + kfree(dr_wrk); + } else { + get_hvpcibus(hbus); + queue_work(hbus->wq, &dr_wrk->wrk); + } + + spin_unlock_irqrestore(&hbus->device_list_lock, flags); } /** From patchwork Mon Mar 5 19:22:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 881610 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="mOg91EKv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zw8tm2VPsz9sYq for ; Tue, 6 Mar 2018 06:22:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753000AbeCETWg (ORCPT ); Mon, 5 Mar 2018 14:22:36 -0500 Received: from mail-pu1apc01on0111.outbound.protection.outlook.com ([104.47.126.111]:38336 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752969AbeCETWb (ORCPT ); Mon, 5 Mar 2018 14:22:31 -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=tAOOSSQQsqXNLgTPumpQNKaAHNv0N1+erEoP8A8AHWM=; b=mOg91EKvTWPMrBtLfOgjJwrz2BrZChjXw4IEv6R8BUh6YI95L9b3TfLlaSkekgq53wrdV6Cz6JMksBrWi3IPKDIAzjjt7jvb1D6h2GDGayWHgFosckXTznlx4DPmgEBmTZp2tbWYeGmaqHGiyRxlwHAhi4kNZtB16iFztV9MTws= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0039.APCP153.PROD.OUTLOOK.COM (10.170.168.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Mon, 5 Mar 2018 19:22:24 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Mon, 5 Mar 2018 19:22:24 +0000 From: Dexuan Cui To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" , Dexuan Cui , "stable@vger.kernel.org" , Jack Morgenstein Subject: [PATCH v2 6/6] PCI: hv: fix 2 hang issues in hv_compose_msi_msg() Thread-Topic: [PATCH v2 6/6] PCI: hv: fix 2 hang issues in hv_compose_msi_msg() Thread-Index: AQHTtLdKnncg+QyU5kGvRKAFXQRGnw== Date: Mon, 5 Mar 2018 19:22:24 +0000 Message-ID: <20180305192134.32207-7-decui@microsoft.com> References: <20180305192134.32207-1-decui@microsoft.com> In-Reply-To: <20180305192134.32207-1-decui@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.15.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0039; 20:a5UhjxpHMRwvjA9iZJKbdILsDz/tsAwSEv32p4woN0IbUTSMt579p6CwX9Nmv6ZQTzzljKlLnnR1KRXyCfTwFimTG4gt1vhzD1O8S42fJW+74DpHovdj4jjzlQVGymIH7M5Iqt/OtI2M1jAcLgqru2HY0Uci6mmJP0cBhKbWVXI= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 49c2159a-2049-45e4-1f08-08d582ce6d27 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0039; x-ms-traffictypediagnostic: KL1P15301MB0039: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0039; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0039; x-forefront-prvs: 06022AA85F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(396003)(366004)(376002)(39860400002)(199004)(189003)(1076002)(7416002)(5660300001)(6116002)(316002)(76176011)(86362001)(106356001)(36756003)(4326008)(105586002)(2950100002)(77096007)(26005)(25786009)(3846002)(22452003)(110136005)(2201001)(59450400001)(99286004)(102836004)(6506007)(54906003)(186003)(86612001)(8936002)(66066001)(68736007)(3280700002)(81156014)(478600001)(1511001)(14454004)(8676002)(6436002)(81166006)(3660700001)(53936002)(2501003)(10290500003)(2906002)(6486002)(2900100001)(7736002)(6512007)(50226002)(305945005)(10090500001)(97736004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0039; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Xy+xeOz5EuX4ZmEgKi4sds1TSc7EyCfdcjZxi6tWegQwFzJ8cKKnY2UifP9+6ne8BbSfv4fnCUSkXwAzLhKyRdTMkpu3wX6xadO+bHAczUnbCZ7Yj7oDuuX39bI9sJB/IevIr3fG0fywSA7xTjIlsw4M41ODCLHdg9ttWrE9NXX5zjJ0GgXeeXLqXwgk6Qdmi2zc0NM+rOKiyDpriDVNofCAXZn7UI5RJFpx7/YpwgLO2KDnku9qOcRjYsr5XlYK1Cr6pceFCnWhompBEgKhfVvWCE7ArQ+jec95RgqHihAO1pmQCdDyEtAbF8QwY03x/RaEHZA+LJsnULtLx+mGlg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49c2159a-2049-45e4-1f08-08d582ce6d27 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2018 19:22:24.2612 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0039 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 1. With the patch "x86/vector/msi: Switch to global reservation mode" (4900be8360), the recent v4.15 and newer kernels always hang for 1-vCPU Hyper-V VM with SR-IOV. This is because when we reach hv_compose_msi_msg() by request_irq() -> request_threaded_irq() -> __setup_irq()->irq_startup() -> __irq_startup() -> irq_domain_activate_irq() -> ... -> msi_domain_activate() -> ... -> hv_compose_msi_msg(), local irq is disabled in __setup_irq(). Fix this by polling the channel. 2. If the host is ejecting the VF device before we reach hv_compose_msi_msg(), in a UP VM, we can hang in hv_compose_msi_msg() forever, because at this time the host doesn't respond to the CREATE_INTERRUPT request. This issue also happens to old kernels like v4.14, v4.13, etc. Fix this by polling the channel for the PCI_EJECT message and hpdev->state, and by checking the PCI vendor ID. Note: actually the above issues also happen to a SMP VM, if "hbus->hdev->channel->target_cpu == smp_processor_id()" is true. Signed-off-by: Dexuan Cui Tested-by: Adrian Suhov Tested-by: Chris Valean Cc: stable@vger.kernel.org Cc: Stephen Hemminger Cc: K. Y. Srinivasan Cc: Vitaly Kuznetsov Cc: Jack Morgenstein --- drivers/pci/host/pci-hyperv.c | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index d3aa6736a9bb..114624dfbd97 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -521,6 +521,8 @@ struct hv_pci_compl { s32 completion_status; }; +static void hv_pci_onchannelcallback(void *context); + /** * hv_pci_generic_compl() - Invoked for a completion packet * @context: Set up by the sender of the packet. @@ -665,6 +667,31 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, } } +static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) +{ + u16 ret; + unsigned long flags; + void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + + PCI_VENDOR_ID; + + spin_lock_irqsave(&hpdev->hbus->config_lock, flags); + + /* Choose the function to be read. (See comment above) */ + writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); + /* Make sure the function was chosen before we start reading. */ + mb(); + /* Read from that function's config space. */ + ret = readw(addr); + /* + * mb() is not required here, because the spin_unlock_irqrestore() + * is a barrier. + */ + + spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); + + return ret; +} + /** * _hv_pcifront_write_config() - Internal PCI config write * @hpdev: The PCI driver's representation of the device @@ -1107,8 +1134,37 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) * Since this function is called with IRQ locks held, can't * do normal wait for completion; instead poll. */ - while (!try_wait_for_completion(&comp.comp_pkt.host_event)) + while (!try_wait_for_completion(&comp.comp_pkt.host_event)) { + /* 0xFFFF means an invalid PCI VENDOR ID. */ + if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { + dev_err_once(&hbus->hdev->device, + "the device has gone\n"); + goto free_int_desc; + } + + /* + * When the higher level interrupt code calls us with + * interrupt disabled, we must poll the channel by calling + * the channel callback directly when channel->target_cpu is + * the current CPU. When the higher level interrupt code + * calls us with interrupt enabled, let's add the + * local_bh_disable()/enable() to avoid race. + */ + local_bh_disable(); + + if (hbus->hdev->channel->target_cpu == smp_processor_id()) + hv_pci_onchannelcallback(hbus); + + local_bh_enable(); + + if (hpdev->state == hv_pcichild_ejecting) { + dev_err_once(&hbus->hdev->device, + "the device is being ejected\n"); + goto free_int_desc; + } + udelay(100); + } if (comp.comp_pkt.completion_status < 0) { dev_err(&hbus->hdev->device,