From patchwork Thu Mar 15 14:22:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10284563 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 F232D602C2 for ; Thu, 15 Mar 2018 14:22:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF43B27F90 for ; Thu, 15 Mar 2018 14:22:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0D18283BB; Thu, 15 Mar 2018 14:22:32 +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=unavailable 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 5543927F90 for ; Thu, 15 Mar 2018 14:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932330AbeCOOWT (ORCPT ); Thu, 15 Mar 2018 10:22:19 -0400 Received: from mail-sg2apc01on0131.outbound.protection.outlook.com ([104.47.125.131]:34627 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932327AbeCOOWP (ORCPT ); Thu, 15 Mar 2018 10:22:15 -0400 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=yFzIcPJPnpTb0Sr6VT7PLOR1G1Mn7aLPRN28I6cTeoQ=; b=Jk0jY9p2F3Lsm933Dnjgr4bKtIjjJJAqJ90nKoh/I8zvPOs50gw919JkMoqMmIXkr/NYzL1QidbSuPUqgIoEroO+gSDICxEB/CfeFKlhEeq/za7Kcn4jCfzzgJIimPSq3fjYY34XB2XG3xSTm5lBSOpUbsczwtGr/e/3LUbk6d0= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0069.APCP153.PROD.OUTLOOK.COM (10.170.168.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.6; Thu, 15 Mar 2018 14:22:01 +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.0609.006; Thu, 15 Mar 2018 14:22:01 +0000 From: Dexuan Cui To: "lorenzo.pieralisi@arm.com" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , "Michael Kelley (EOSG)" Subject: [PATCH v4 4/4] PCI: hv: Only queue a new work in hv_pci_devices_present() if necessary Thread-Topic: [PATCH v4 4/4] PCI: hv: Only queue a new work in hv_pci_devices_present() if necessary Thread-Index: AdO8O+5kR8xWt6mdRW2rNfrvNdXo1Q== Date: Thu, 15 Mar 2018 14:22:00 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-03-15T14:21:58.1991440Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [2601:600:a27f:df20:d8b5:442c:6a7d:25c6] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0069; 7:vYEgZCyCYXHce0A0ppOlN/d7VVVopweu9H4kK/ZI7uDTAFOx/+xjdsc2m6fx5929H3FwGC+TdcBlmyOAVQz5zQPCypChbJV6QAfnp3RTpaxdsH81gZy4oAV+SwFrut13aw2GmKTf9juEnvMt+oI1bvWZJkKtqX19e48BqUmtrSY1E0Kd2ZYsexU4XwccJ+0qyW6nylEiwE4ePoBvZv49QWIRhjG+w0iqX7Cs9HA9lNYBtPtTcJiFI/VHVZhEuE2B; 20:6xda291qB3uSDDrQ6wXsZcLZDKOxaKU5UybysvDcIJiey9Fff+E2bgr5+tb1T7KXeOtOHh/30xnkM2vS9CbRpl6dOgbG4/+66YYFyD240GBq7NrDAAG4yGJ++psgo1jpTVtGUtAYYKQljNXDo6JJd/Xs+bd1HO0nGj6zZRpPnIA= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 459a910f-dff4-48c7-f225-08d58a801e39 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:KL1P15301MB0069; x-ms-traffictypediagnostic: KL1P15301MB0069: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501244)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:KL1P15301MB0069; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0069; x-forefront-prvs: 0612E553B4 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39380400002)(346002)(366004)(39860400002)(376002)(199004)(189003)(105586002)(77096007)(8990500004)(7416002)(2501003)(102836004)(106356001)(1511001)(6506007)(5660300001)(186003)(3280700002)(2201001)(4326008)(8936002)(86362001)(33656002)(3660700001)(2906002)(10090500001)(68736007)(25786009)(8676002)(81166006)(81156014)(59450400001)(6436002)(6116002)(7736002)(74316002)(46003)(305945005)(107886003)(110136005)(54906003)(53936002)(86612001)(478600001)(22452003)(14454004)(316002)(6636002)(97736004)(9686003)(7696005)(99286004)(10290500003)(55016002)(2900100001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0069; 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: 3JZ5wDy/2t70fJ18mLkRjDaH28IO4Ge1JO2YpEn+99NQN110ydfnCSV4O3V69107+jBFJlmDvQ35L2b7BjRYbsMU4YPv0iohrN3fUjq24NdXOzf7psTm/+DIGH4XGvsnZTcE2gSgJLTEbpQYYg8xcCs3WcUMCQamoNDSj/0+ptnDwyYCg3A8ITUgHucpJbXhOvpEmyWdATBXMh158bb3Jxr+sb0zilsxO7zt5wG42mJBOazL7tiotpWbScscW9gMqzzndtqFh6KBP/8xfZtzyueCpkUlir4eN9g/vhz05BtiNRfKqvEiW6MlFTHrzvUlC7IfxbHVARxHIU7gYaXkjw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 459a910f-dff4-48c7-f225-08d58a801e39 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2018 14:22:00.4729 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0069 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 If there is a pending work, we just need to add the new dr into the dr_list. Signed-off-by: Dexuan Cui Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: Stephen Hemminger Cc: K. Y. Srinivasan --- drivers/pci/host/pci-hyperv.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 0dc2ecdbbe45..50cdefe3f6d3 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1789,6 +1789,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) @@ -1812,11 +1813,21 @@ 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); + } } /**