From patchwork Thu Apr 20 02:40:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 13217748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97EFEC77B7C for ; Thu, 20 Apr 2023 02:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbjDTClP (ORCPT ); Wed, 19 Apr 2023 22:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjDTClO (ORCPT ); Wed, 19 Apr 2023 22:41:14 -0400 Received: from BN6PR00CU002.outbound.protection.outlook.com (mail-eastus2azon11021014.outbound.protection.outlook.com [52.101.57.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F4D2F2; Wed, 19 Apr 2023 19:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gK4duflaRTqQaWN8Q/JTtR9fQ/K4dgM31DYIiVP1BFPZMKQVKtcEPRSU+6P4we8fYvONv/B01LvsdEj/fLWEgzVbS2jCRfnJQQMhHaleerUNT4b9xQeN6xLy9hhREVn5XbP6J+WC89Cn2XE+JVteYWZPdcBwqrU3e7M+s7VEsIIbjQ2WCv/Yrtjyk3yec4Vf8qdRHFGJrbjOz+JHIkLgeJlrgoj5y9WXBTL8G3ZoJQ284sR0rp7IcDHXg3FaD0BHvYThAPI+DNuJtyuRd4Qvc+7XWI3kTmvIwUIJRV6U67jqycYkssrtnPexoGNenZAEhwHdt6DI7i4sUiNKr0vs+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WOM67pBbZqEU6233oIAMYg9ABoV9tHU8HDvLg4S3tWk=; b=i648LT68ELLroRtT00SSayFymIglVrfrsoHr0tuqIkmAtpCj1n3X7oULcohCsSnuuh9ebVco8BoFlixxZGTl8opEJQ3XObIYSeaVBaWyk1VeHRpbjghCcsS7D3OWabsdP+grrgI5ibQBjjKa3hQyRJsbzhLGsN883d75rma3LfzD6mDpI+Q2N2GMySX452LWpVQtyjdWt7XQPA3I22ncQWWBXXcRfND3vS9BVmCyrtomoacWfu+ce4j/A17LMIi9zLZxeOBMkvFuf9t7BQhP1DrK5bqMIBTcIxuPa5XNcPSRTARnKIUuQ819Z9swxkpp4BFVDpi4Yqnjzj7kDwsWqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WOM67pBbZqEU6233oIAMYg9ABoV9tHU8HDvLg4S3tWk=; b=fUZ/Zvln2FSc8X9D1kbZ6Jn3314LAtDlOBXG2zPVev9TcHjqZ8INtGhGeW1wvkJQ/UI46qJ3O7VcOrrwq+0X34fK3rUZgs5FmakLQixYZ4XKpJuUaGlj43JK23dSqLn5w6gOTjP1zm+SnbQCoUDZb+OHWWZJSS0QAqYRoYz5zrA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BL0PR2101MB1092.namprd21.prod.outlook.com (2603:10b6:207:30::23) by SJ1PR21MB3411.namprd21.prod.outlook.com (2603:10b6:a03:451::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.7; Thu, 20 Apr 2023 02:41:09 +0000 Received: from BL0PR2101MB1092.namprd21.prod.outlook.com ([fe80::932e:24fe:fc1b:5d30]) by BL0PR2101MB1092.namprd21.prod.outlook.com ([fe80::932e:24fe:fc1b:5d30%5]) with mapi id 15.20.6340.009; Thu, 20 Apr 2023 02:41:09 +0000 From: Dexuan Cui To: bhelgaas@google.com, davem@davemloft.net, decui@microsoft.com, edumazet@google.com, haiyangz@microsoft.com, jakeo@microsoft.com, kuba@kernel.org, kw@linux.com, kys@microsoft.com, leon@kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, mikelley@microsoft.com, pabeni@redhat.com, robh@kernel.org, saeedm@nvidia.com, wei.liu@kernel.org, longli@microsoft.com, boqun.feng@gmail.com, ssengar@microsoft.com, helgaas@kernel.org Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, josete@microsoft.com Subject: [PATCH v3 0/6] pci-hyper: Fix race condition bugs for fast device hotplug Date: Wed, 19 Apr 2023 19:40:31 -0700 Message-Id: <20230420024037.5921-1-decui@microsoft.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: MW4P221CA0023.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::28) To BL0PR2101MB1092.namprd21.prod.outlook.com (2603:10b6:207:30::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL0PR2101MB1092:EE_|SJ1PR21MB3411:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cf5489e-10a5-4630-c22c-08db4148b1e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t+EnossUVzShVk4zQQjEqIvVI2w9my18HmvktoHvu4GgX8kPkpb66riYBONFwLqB5MzFCzzzOLyYsn+hk8m9BsQPICgno88IOwwKu1GJDJvLrP9ZEyiSirevxa8LJPttmc/04zMH5K/DaVvNc0/yR6E5Olki0FLksPodRWQz1wYodPXymV01C9oonGMha49PeVZoY4niScTNC28gJCZL1LDi53485cFkveJR7FHjkkk/6/JsqK4HnGYHb71DUCMFbG7ZMsNB6HYsxevmD8nSOVzvIscvvhg8ZRB4ps9g304bI1KA+UGQIZbdeAwd1mpMysbHZn15wjuLP1IGkrGpEbvnzgglay7VwuGU5Euyn+KEuG9K7sZv139XuVAVso0o7lc6PrQOW1XvuiLt7dHedwc2XjJK/s87w/gMsWM5MLCI2SywYXNjpfkoCpj90B4VgoYckMkV4tVn3aeVXU5PHKJ24hLGfOlTwE5Xs0VV19BKkKIaUCcYRWoKsVtgTHaftS24hfwlLAGJu+KY0lfVr8qjnNWcyUzHtyF0BCzNYJRAlZu3T8DCYm2RHI7jwB/MRIhOUOdJIhuX1QDGUrHQdeLgTbLaJ7+brRDiu+56BwQgcp6yZtTh9MlaojhBk3WWqTXrHcondrfy/p1Etlt8R+enchtXLY3h7/G/OVF5K2za0pVRel0rB00kBKrkgPAq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR2101MB1092.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(2616005)(83380400001)(36756003)(186003)(6486002)(6512007)(1076003)(6506007)(966005)(6666004)(52116002)(66946007)(66556008)(10290500003)(66476007)(478600001)(4326008)(316002)(41300700001)(82950400001)(82960400001)(921005)(786003)(8676002)(8936002)(38100700002)(5660300002)(7416002)(107886003)(86362001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KO/8tbPh5kwQ1LehDBhw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iByHXfYh+WU8mxd41VRwGG/qnuKrSM/69/xAASIeZbR11LtH/EPQp5GU2iTHbKlxLn3MTDtR6a09mp8iYPlEpj1iEkHvwGohRbhSGxvuAX8706bAsP4LuHPQ6QF+QS+AyuV9WLwIEZ76S7WJ8UnNpdrUX+HgSLmorbhXWDpVBPdukfj1W00a7pDyaB6gM9PLReGg5mMhEpJy828Od0pkSjOPKnFXGQlBqE3zsWPfFTHnhoQxY2W5X+bkKF0kPm8Sn8RT6ukccwx2Z1lJTdda0F5e7D2dKxGcuWverlIBq9PvoQMP4lXpBSM+oKx80435f5UWraMNBBJ6VLcSaNH14Z48Mb/17wbf8rv13axwOL/rMSThKdtucR/CjFKvBdOF1M0re3lPQpAvZFtd3WTs9PV22mhfgAK6eICRIUzQwMffa92umFk774fmSEuOBQadsREhhqv/39Z+Wnqw7sdH8M/hrhC0ojTekfleUcFOnGglPv9NS/QeBwOEj+c8jLRm/Iun0khWlXdIcSGp4SaB9q4d41xOR+ask22wXhaX/+u4YQd X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cf5489e-10a5-4630-c22c-08db4148b1e9 X-MS-Exchange-CrossTenant-AuthSource: BL0PR2101MB1092.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2023 02:41:08.5575 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rcK6EDcBhE0XYTba+e/yB8nJMWoQirzkQJGFjTHoGdanMCgO6IAmn1FB8DiL/p462h6b/YH21ZGnlH5grgGT6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR21MB3411 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Before the guest finishes probing a device, the host may be already starting to remove the device. Currently there are multiple race condition bugs in the pci-hyperv driver, which can cause the guest to panic. The patchset fixes the crashes. The patchset also does some cleanup work: patch 3 removes the useless hv_pcichild_state, and patch 4 reverts an old patch which is not really useful (without patch 4, it would be hard to make patch 5 clean). Patch 6 removes the use of a global mutex lock, and enables async-probing to allow concurrent device probing for faster boot. v3 is based on v6.3-rc5. No code change since v2. I just added Michael's and Long Li's Reviewed-by. The patchset is also availsble in my github branch: https://github.com/dcui/tdx/commits/decui/vpci/v6.3-rc5-v3 v2 can be found here: https://lwn.net/ml/linux-kernel/20230404020545.32359-1-decui@microsoft.com/ Please review. Thanks! Dexuan Cui (6): PCI: hv: Fix a race condition bug in hv_pci_query_relations() PCI: hv: Fix a race condition in hv_irq_unmask() that can cause panic PCI: hv: Remove the useless hv_pcichild_state from struct hv_pci_dev Revert "PCI: hv: Fix a timing issue which causes kdump to fail occasionally" PCI: hv: Add a per-bus mutex state_lock PCI: hv: Use async probing to reduce boot time drivers/pci/controller/pci-hyperv.c | 145 +++++++++++++++++----------- 1 file changed, 86 insertions(+), 59 deletions(-)