Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp248154rwb; Tue, 25 Jul 2023 15:19:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlG9133xQBlRERWFM5467xMPo9eeJISTAAnwq9lG7DA0z98Sy+/ivWTTw0MfdAkp5iJNhPlH X-Received: by 2002:a2e:a1c4:0:b0:2b6:a22b:42dc with SMTP id c4-20020a2ea1c4000000b002b6a22b42dcmr68731ljm.16.1690323572394; Tue, 25 Jul 2023 15:19:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690323572; cv=pass; d=google.com; s=arc-20160816; b=HRAo1BN+BUaFhz+Y4gaG/0ZwiX+3VA4daHLhhJ4Cci0ahf1a1aCGnISuA1OKfvukwd hJDcPZ07KFe4xcv1BDwEVc8o0IzceS8dFz0GxJe/Kuo9q+Au0qsdwgpGfWyPP1ljO03q FRPrNG5OVt3yTwwG9ORH7BoFlIuIwhS6a7BSuhFNVwzP2MmzMap5sJOo/XOj3N0DjyxQ /Eow9PeRmGgIFmwcAEY1mcbB3MGPskNIru4rfurtqxkm/cc3Z1OR983WgaGwrREgp38I gXVD+lrS4rc3+GG5x0qGCT4KeGxyhlW6R9V3bML1cPmm8EE1czeD8mAvDlPgeTElRYtZ 1h0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OjXllyAyHppdTnvS6sbsaIuNb2aA8ZEh9Ydwdm5jURs=; fh=7qEUnvroiVGqNbV2BsznAhWWl5a9gsasDQnJyIlYZRk=; b=S7TGAWG3vp4/ApMEH0i2pI482h9gLU6WAxG7E8SXck6/bwXsL8BtSqGqOYBcug/z2D TrVs3S+MoTaTgrSja2uboL2AvjgdNPjmpXcQuLajxohvdFI0XGIB/e9uFt7rhj1YHlYF kVO1Kbb4A5K0jPazIiOMPHfNmCL+e9f8OzjckE7VZebflqtHpFxE7OSLRVGzE19rkYzY Xtjzhzv9W9NkYnALJ2NI2Z7cX1M+xaWMEBXG8+CxmHFZZ4CORNKFzo50HlBFwwhZFwGE 5Q475Rlk9wgN8tnKyD/nR1iIRIbhWVxVTOaMo5zhlTIyDXG/Gw+Q3lIBSHcHqfFUu8GM NZ1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ZrpcOXJV; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p19-20020a17090628d300b00988919c8a70si8786882ejd.59.2023.07.25.15.19.07; Tue, 25 Jul 2023 15:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ZrpcOXJV; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbjGYWQs (ORCPT + 99 others); Tue, 25 Jul 2023 18:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231330AbjGYWPm (ORCPT ); Tue, 25 Jul 2023 18:15:42 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1EBE78; Tue, 25 Jul 2023 15:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ltCIc3LdQqXQRJSXgJQBKxjSUl7moL7nIfoiLo9o8+HpHaU5CfdE7G5e394Uz8TDSoZ6f0KeeuEF2vWY7TaHX0jTJW3Lejy3/Tp4xL3B9ftg3/DnXo8YF55UXIHWjRUF2eYkVY7s7goJZdaa6u5f6SGLbOxuHO+s9ECFqECdYx5SPNXaUS0gqpYaQ4+L84orLnAo3hMHazpBxKu5H3h/Zarf86RVgSM+bwqHtpM9WCQATLmkrJaTv+J61TSh0Jfo7g4U89jH6jeaFDb7t1pZOOBUVKOkDQmTwGgB8RUcDX90Rvte9V3bjBICAGUlj+wmr3mP4WXHUUHsEHXoC6M85w== 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=OjXllyAyHppdTnvS6sbsaIuNb2aA8ZEh9Ydwdm5jURs=; b=I1ajfILUMW0txgM7mQbWQ7SZN6qHYYz/hoNMe6+qxB6ATxZVWocqg62L5rKnp8aYbURA+iCPg6UFPAjaEHQAEbv9s/Vaal3ZZZLaeSF7D4heYzdwgZZbFv/IYB9MidBdd+B3smLJSwMHrxguG3Q6Alal2ZFPGWkGaJWTKvFcS55HxEdGH4C08bqicEuRuZmhe0jprQdh265U/JImRYGN0spG8ZOY1M7fBXAsQyKmHkA3kAV/k85/S8omIgJkNEm/vA0GzNWrb8kt9uYoBkKeyj1KaqSEeA4qSyb9YMckjmHa8sp1FhdHPzfrNXUQsFFgJI69cOk5jfhfo0dfc4XzfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OjXllyAyHppdTnvS6sbsaIuNb2aA8ZEh9Ydwdm5jURs=; b=ZrpcOXJV59Dg2igCs/8yq+jFveHbejHkQrl3wa1GAo8QKS7CETk0sjS2YY34HntlX2CmveJzKaP27bX+l/OqWe7AriCEmNmEoVs5+HCVsDzo6pFj9r+utG9/H+MfPshwvb6LjIUoF5MKyn0d9PKzpsmwCvVoiYO60jY7WUPuOaM= Received: from MW4PR03CA0060.namprd03.prod.outlook.com (2603:10b6:303:8e::35) by DS0PR12MB7632.namprd12.prod.outlook.com (2603:10b6:8:11f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 22:15:38 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::ff) by MW4PR03CA0060.outlook.office365.com (2603:10b6:303:8e::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 22:15:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 22:15:35 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 25 Jul 2023 17:15:34 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 25 Jul 2023 17:15:34 -0500 Received: from xsjlizhih40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 25 Jul 2023 17:15:33 -0500 From: Lizhi Hou To: , , , CC: Lizhi Hou , , , Subject: [PATCH V11 5/5] of: unittest: Add pci_dt_testdrv pci driver Date: Tue, 25 Jul 2023 15:15:18 -0700 Message-ID: <1690323318-6103-6-git-send-email-lizhi.hou@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1690323318-6103-1-git-send-email-lizhi.hou@amd.com> References: <1690323318-6103-1-git-send-email-lizhi.hou@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT053:EE_|DS0PR12MB7632:EE_ X-MS-Office365-Filtering-Correlation-Id: e31bab93-db96-45d5-59a2-08db8d5cab66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EYL7UYznrONYIdiexdlcEOe9zrWwM7BIBX1DWRIfqdZxbBdLFLldxukeBNLpPjOX3Dhg/MY0zAkKUEMPepPD3JloIeapWvfPtFy2DfGcu6aTyb6zMPzQXvCS2qKGhFGPALiGXRwhM6objdAYqYrHq73fOVIQACUZQpR6hdDFjrFY0VWmMPC8WkecnH5zEfKwuAYCnY2v7JN2MXEZzf/u7JAXf1bbcVAbU4WpESE4UgIDBgoGfW4NrByeAKjsEcgduV1jQTaMA9/RzqpXD4d5ekg6l6W2q/UQjAuH0vVQ5CsFfGgZry5C0PE3X4kVhKZl4FNKEWd//WOn9gapetPzrCwaQoxQbrKNICv4gDQG5fUNZGgwu9jVsGugHgR3f0YrmbCEzHK86vpcx790dGDtaXg69MeZX6rIjoIbJECcHFGQ0wZTSYARsPazJYm54vrqrMhEnoPhlvAatY4Y2r4fXmaeX+jjjj6WwfakdctWgVTbP2pgiwfGQ2Bx3ZbebiY5MGfoQKccVoBSKBHzsUKFKkL0tXTO5NP4vDzso02QhaYIZZOqJyGgFhgYksFtLf0QJXCkuavcdhVzux0gL6eKdRkPVZEMTHsaWzNHTlFrnvnEesIOwFGrZv7+yuuviSLihLypNV+l0tb6j/t/ums31nzgZ6gW+XxM3bqPQ78Vk1jiafqZ6AnA/0Q2VK62zxu7Q/Er67DjIvQg4wqQBhcNjlD3zutjqrAoWxTaAJ+OstCBn7qkoA4csbUzuwNqwekmYbt/cxl8X0c1y0AZ5Qt0Ow== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(82310400008)(451199021)(36840700001)(46966006)(40470700004)(70206006)(70586007)(83380400001)(54906003)(6666004)(86362001)(4326008)(47076005)(316002)(2616005)(426003)(41300700001)(478600001)(110136005)(5660300002)(356005)(8936002)(8676002)(44832011)(336012)(186003)(40460700003)(26005)(36756003)(36860700001)(40480700001)(82740400003)(81166007)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 22:15:35.3457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e31bab93-db96-45d5-59a2-08db8d5cab66 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7632 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pci_dt_testdrv is bound to QEMU PCI Test Device. It reads overlay_pci_node fdt fragment and apply it to Test Device. Then it calls of_platform_default_populate() to populate the platform devices. Tested-by: Herve Codina Signed-off-by: Lizhi Hou --- drivers/of/unittest-data/Makefile | 3 +- .../of/unittest-data/overlay_pci_node.dtso | 22 ++ drivers/of/unittest.c | 189 ++++++++++++++++++ drivers/pci/quirks.c | 1 + 4 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 drivers/of/unittest-data/overlay_pci_node.dtso diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile index ea5f4da68e23..1aa875088159 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -32,7 +32,8 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtbo.o \ overlay_gpio_02b.dtbo.o \ overlay_gpio_03.dtbo.o \ overlay_gpio_04a.dtbo.o \ - overlay_gpio_04b.dtbo.o + overlay_gpio_04b.dtbo.o \ + overlay_pci_node.dtbo.o # enable creation of __symbols__ node DTC_FLAGS_overlay += -@ diff --git a/drivers/of/unittest-data/overlay_pci_node.dtso b/drivers/of/unittest-data/overlay_pci_node.dtso new file mode 100644 index 000000000000..c05e52e9e44a --- /dev/null +++ b/drivers/of/unittest-data/overlay_pci_node.dtso @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/ { + fragment@0 { + target-path=""; + __overlay__ { + #address-cells = <3>; + #size-cells = <2>; + pci-ep-bus@0 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x0 0x0 0x1000>; + reg = <0 0 0 0 0>; + unittest-pci@100 { + compatible = "unittest-pci"; + reg = <0x100 0x200>; + }; + }; + }; + }; +}; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 7bff6c4cb653..f9895ea832f3 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -3324,6 +3325,7 @@ OVERLAY_INFO_EXTERN(overlay_gpio_02b); OVERLAY_INFO_EXTERN(overlay_gpio_03); OVERLAY_INFO_EXTERN(overlay_gpio_04a); OVERLAY_INFO_EXTERN(overlay_gpio_04b); +OVERLAY_INFO_EXTERN(overlay_pci_node); OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node); OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop); OVERLAY_INFO_EXTERN(overlay_bad_phandle); @@ -3359,6 +3361,7 @@ static struct overlay_info overlays[] = { OVERLAY_INFO(overlay_gpio_03, 0), OVERLAY_INFO(overlay_gpio_04a, 0), OVERLAY_INFO(overlay_gpio_04b, 0), + OVERLAY_INFO(overlay_pci_node, 0), OVERLAY_INFO(overlay_bad_add_dup_node, -EINVAL), OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL), @@ -3729,6 +3732,191 @@ static inline __init void of_unittest_overlay_high_level(void) {} #endif +#ifdef CONFIG_PCI_DYNAMIC_OF_NODES + +int of_unittest_pci_dev_num; +int of_unittest_pci_child_num; + +/* + * PCI device tree node test driver + */ +static const struct pci_device_id testdrv_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, 0x5), }, /* PCI_VENDOR_ID_REDHAT */ + { 0, } +}; + +static int testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct overlay_info *info; + struct device_node *dn; + int ret, ovcs_id; + u32 size; + + dn = pdev->dev.of_node; + if (!dn) { + dev_err(&pdev->dev, "does not find bus endpoint"); + return -EINVAL; + } + + for (info = overlays; info && info->name; info++) { + if (!strcmp(info->name, "overlay_pci_node")) + break; + } + if (!info || !info->name) { + dev_err(&pdev->dev, "no overlay data for overlay_pci_node"); + return -ENODEV; + } + + size = info->dtbo_end - info->dtbo_begin; + ret = of_overlay_fdt_apply(info->dtbo_begin, size, &ovcs_id, dn); + of_node_put(dn); + if (ret) + return ret; + + of_platform_default_populate(dn, NULL, &pdev->dev); + pci_set_drvdata(pdev, (void *)(uintptr_t)ovcs_id); + + return 0; +} + +static void testdrv_remove(struct pci_dev *pdev) +{ + int ovcs_id = (int)(uintptr_t)pci_get_drvdata(pdev); + + of_platform_depopulate(&pdev->dev); + of_overlay_remove(&ovcs_id); +} + +static struct pci_driver testdrv_driver = { + .name = "pci_dt_testdrv", + .id_table = testdrv_pci_ids, + .probe = testdrv_probe, + .remove = testdrv_remove, +}; + +static int unittest_pci_probe(struct platform_device *pdev) +{ + struct resource *res; + struct device *dev; + u64 exp_addr; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + dev = &pdev->dev; + while (dev && !dev_is_pci(dev)) + dev = dev->parent; + if (!dev) { + pr_err("unable to find parent device\n"); + return -ENODEV; + } + + exp_addr = pci_resource_start(to_pci_dev(dev), 0) + 0x100; + unittest(res->start == exp_addr, "Incorrect translated address %llx, expected %llx\n", + (u64)res->start, exp_addr); + + of_unittest_pci_child_num++; + + return 0; +} + +static const struct of_device_id unittest_pci_of_match[] = { + { .compatible = "unittest-pci" }, + { } +}; + +static struct platform_driver unittest_pci_driver = { + .probe = unittest_pci_probe, + .driver = { + .name = "unittest-pci", + .of_match_table = unittest_pci_of_match, + }, +}; + +static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add) +{ + struct device_node *pnp, *np = NULL; + struct device *child_dev; + char *path = NULL; + const __be32 *reg; + int rc = 0; + + pnp = pdev->dev.of_node; + unittest(pnp, "Failed creating PCI dt node\n"); + if (!pnp) + return -ENODEV; + + if (add) { + path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0/unittest-pci@100", pnp); + np = of_find_node_by_path(path); + unittest(np, "Failed to get unittest-pci node under PCI node\n"); + if (!np) { + rc = -ENODEV; + goto failed; + } + + reg = of_get_property(np, "reg", NULL); + unittest(reg, "Failed to get reg property\n"); + if (!reg) + rc = -ENODEV; + } else { + path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0", pnp); + np = of_find_node_by_path(path); + unittest(!np, "Child device tree node is not removed\n"); + child_dev = device_find_any_child(&pdev->dev); + unittest(!child_dev, "Child device is not removed\n"); + } + +failed: + kfree(path); + if (np) + of_node_put(np); + + return rc; +} + +static void __init of_unittest_pci_node(void) +{ + struct pci_dev *pdev = NULL; + int rc; + + rc = pci_register_driver(&testdrv_driver); + unittest(!rc, "Failed to register pci test driver; rc = %d\n", rc); + if (rc) + return; + + rc = platform_driver_register(&unittest_pci_driver); + if (unittest(!rc, "Failed to register unittest pci driver\n")) { + pci_unregister_driver(&testdrv_driver); + return; + } + + while ((pdev = pci_get_device(PCI_VENDOR_ID_REDHAT, 0x5, pdev)) != NULL) { + of_unittest_pci_node_verify(pdev, true); + of_unittest_pci_dev_num++; + } + if (pdev) + pci_dev_put(pdev); + + unittest(of_unittest_pci_dev_num, + "No test PCI device been found. Please run QEMU with '-device pci-testdev'\n"); + unittest(of_unittest_pci_dev_num == of_unittest_pci_child_num, + "Child device number %d is not expected %d", of_unittest_pci_child_num, + of_unittest_pci_dev_num); + + platform_driver_unregister(&unittest_pci_driver); + pci_unregister_driver(&testdrv_driver); + + while ((pdev = pci_get_device(PCI_VENDOR_ID_REDHAT, 0x5, pdev)) != NULL) + of_unittest_pci_node_verify(pdev, false); + if (pdev) + pci_dev_put(pdev); +} +#else +static void __init of_unittest_pci_node(void) { } +#endif + static int __init of_unittest(void) { struct device_node *np; @@ -3779,6 +3967,7 @@ static int __init of_unittest(void) of_unittest_platform_populate(); of_unittest_overlay(); of_unittest_lifecycle(); + of_unittest_pci_node(); /* Double check linkage after removing testcase data */ of_unittest_check_tree_linkage(); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 6c0e7b6bbdd1..a8223ff52939 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -6149,3 +6149,4 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a31, dpc_log_size); */ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5020, of_pci_make_dev_node); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5021, of_pci_make_dev_node); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REDHAT, 0x0005, of_pci_make_dev_node); -- 2.34.1