From patchwork Wed Nov 9 10:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17449 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261287wru; Wed, 9 Nov 2022 02:42:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM6ii3aI1suQSJdKVnCZ0xXvgFSD0IyEvhKuJqEwBb64n6yeLP1GZccHpgoGsAf/LgriHAuA X-Received: by 2002:a05:6a00:1ac6:b0:56d:919b:f4a1 with SMTP id f6-20020a056a001ac600b0056d919bf4a1mr49068303pfv.50.1667990533225; Wed, 09 Nov 2022 02:42:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990533; cv=pass; d=google.com; s=arc-20160816; b=sgmUs6EXSU/dyaQq3N5XxFVgjwUcU6Kl97MVzKM2PP2OsuQoiyTML8u0VcfH+Bu2Os 82c/ayVHV21lKJFWCwLJ7aCTQispBgR3vbkwWaiGwJ0Vr4rWKJAL98lbI7pCkCn4U8lL jffoDLcueqRRBEvg46dTGXakDrDyHKDWiG6Ga6llHAuUMXK4IX4pOTfWqgP6AdIhs4K8 14XyRlq/Ir9gVcqk0NFoGm3ialR5N5xiUHcOSswY/CZZZWt6Ddh5MAaT7rVCQ37+MAoc KbxR4kzlT2gPrIz4oI8I7CE7jR3I20poaKvkWv4s1A0Nt4QzuZmb8XBDMokVheZbcty4 t5AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rmjvucrWL76xaSkdcKMv2J/9l8rMe5rFH3S3fU9xz8k=; b=bZLyfUQ5qkZkuzzOaymkqa54gQlAQFxxDQPuE5coS1QnWMHduvHzdOb8ZihyKLAABW YOKVYtZ3KBz6WxE2X5tCp7/N2bfhIbrLt1UA7ncfnl/vN1flF6usCACeeVdcJSQqu4Xa 5u0NnBiY27jHm9nNw6FRlQt12VCf9/3KsxaKncdusUFX9ygYYFlZeNPKzQ5hB2wdRftb JDVfOAcgwHMb2txcvp9Lvv50F8hlabxGwGxUECAJcPGcgjweIjUJ+kI6Z1YKPCnvwocD +7KeeQ5/C5vyt06v991DjCLFg41ixQCa+EeT0YoJSjEsJpqJdJ2pxx8PlE3Mi51JnGm4 7mgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fY1mU1tQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020aa78e11000000b00557c8a20395si13831431pfr.120.2022.11.09.02.41.59; Wed, 09 Nov 2022 02:42:13 -0800 (PST) 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=fY1mU1tQ; 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 S231131AbiKIKll (ORCPT + 99 others); Wed, 9 Nov 2022 05:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbiKIKlb (ORCPT ); Wed, 9 Nov 2022 05:41:31 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C461C10D; Wed, 9 Nov 2022 02:41:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UA8oIOaJxhWvXdGaDYgV9R2YA1WN8A+B7WueAXUtm+0KuCghOVrbdlZipdqlIgqJA/aRWFpPNk6vBsADY1vmCEVfCw4TPdeiDMQ/UmCEGttwT/B0SnTMxb7/SQKTg+Ti8zP0f2SgcfSzeivcs5/KLL/Zi3W/PB54lA8hsxz8jQdbZmT9KUVXRyQo8dOqZ+U7O8vHaR2oEYDpssitWId2BG5FBvj/V1DRqb0lwzlOCjd9jOR/qXjlD65sosNO//SvIQOtOXXT+Aa0zZnqMrUgrsXeFJXjYZlTCu/MizOk9Ib5DKgugH06IyeCdMCkKZlQJbZFT+fAJnASvX8sQX+f4A== 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=rmjvucrWL76xaSkdcKMv2J/9l8rMe5rFH3S3fU9xz8k=; b=SG2h2kXPddqsbBYQVXWYMgrCiaJ8CSH7vhNXJP+JEB94LubGv6kO2N0rVQnLNfW5SSBJFBx9dejOq4r1yjsAg7qlwlH0IeBpPYoRGW/8akVoZsUS31llzBxdzj0yrsGuM+7TArchet1mNFvZoibNMRj3yBf7ZJX1lyYAKqokbRZDRV1eTHTxcxWQj4XVW//IPdh1Aly/NTzD7ugwneqhAGEpVT7BA0tZ+esy0pdvZnv3hvnUJukY6caX3xMWdUds4bYv/AnkMH3XNn+XIALpuuYWaFFrwt6akAT3FYio+YbrGD/Fdhl6VMH1WVnwlJ5AqE3iZHqd1dMDjBMoqiGBlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=rmjvucrWL76xaSkdcKMv2J/9l8rMe5rFH3S3fU9xz8k=; b=fY1mU1tQdbYVhO6/YUBgs3GPzETZEgqw9tXkAtt/JuoUS9PlHekacRrVTu0UZG6lIJVIzaR0f8USXaWfPFghI1NCWHJdlOW4oWTBkhTzruBfE8LSe29+PIEFaipqqeYdAqomLOXWh3a4BfqMcsJT0veCuLXRbUySmDKVNQoUIvY= Received: from BN9P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::27) by PH8PR12MB6700.namprd12.prod.outlook.com (2603:10b6:510:1cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:28 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::1b) by BN9P220CA0022.outlook.office365.com (2603:10b6:408:13e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:22 +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 BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:22 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:20 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 1/9] cxl/acpi: Register CXL host ports by bridge device Date: Wed, 9 Nov 2022 11:40:51 +0100 Message-ID: <20221109104059.766720-2-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT036:EE_|PH8PR12MB6700:EE_ X-MS-Office365-Filtering-Correlation-Id: b57c4e48-c5ec-47cf-ecf8-08dac23ef1d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jaqi4CV/5UMVEI0BVvEJ0t+u/FolCQ6P1FRuc/uqeTpLTP06T3e+aVUct4Kbp1uIenye3eByx3sgUant5j7RFTjEJSyEMDB350HU1vd90EVwTuXrvVHKgHdLBzD9OsCUAIpJL/Dq6CfaAD77z4pSHTPveyWylrwao/a4g0mM+78tKFwQE12VKb5VSxtH5IFHs1EgOPsu8ZduLXaKbBIkR37jKTIdsvUKbr0mvsjVzjM/l5g4z+/OOY4RfpL0N+cUAIz9a12MYgRaLb1kMNAdZj22GBzGMRpV81ZxdDLg0yvPXwAIzb2hjO+14oaORk9x13OE4zA+1lwMSGu/P7jw6kjtciRC88iN5G8lL9e9ORSQxsPoaMUegxcAP05i0no1A/1MrA7ruYtMipu+fLJ7gF2Dm+NQUSgAQvHfyClfn6pLG5L7lNAtFUHpqbv/+K83JSv0iXqMA07K5LteYoEnO8NAlS3grGfsg+YBb6sbh0gNbF44b5jurR+CnZ8KuBj6+kVtQ02/15/UYKMYnEpv2KzopVai94K5xBfqElfvYHoKNk++KmtD8nNOIuNtmKzHrWSAACAmxrfqWFr0dfjroOWLSK4X02+sNOM/7jEAqRovHUUvnnMSh6WI4DX2lQY0nM46R8cFXil0eegOaomrimmLbVlIqdnJO/q06SPyV4lOs01kIe+wJ9bBfHOradqk8M5Kkvp44ZEbxk5IKtE9q813a3yJs0BQ2/Va4iE8dr5YPIl2hEjUa2WsCzKkxquj7VzHKWFQnUnW175D3+QqDr4LKu9rhBWcgvLqppyNnSCP1O9cYwd0ykcfOS6jK9aC 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:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(36840700001)(40470700004)(46966006)(186003)(36756003)(8676002)(4326008)(26005)(41300700001)(81166007)(70206006)(7416002)(6666004)(40460700003)(356005)(2616005)(70586007)(16526019)(1076003)(8936002)(5660300002)(316002)(110136005)(54906003)(83380400001)(82740400003)(2906002)(426003)(36860700001)(82310400005)(336012)(47076005)(40480700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:22.6604 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b57c4e48-c5ec-47cf-ecf8-08dac23ef1d9 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: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6700 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014841309929777?= X-GMAIL-MSGID: =?utf-8?q?1749014841309929777?= A port of a CXL host bridge links to the bridge's acpi device (&adev->dev) with its corresponding uport/dport device (uport_dev and dport_dev respectively). The device is not a direct parent device in the PCI topology as pdev->dev.parent points to a PCI bridge's (struct pci_host_bridge) device. The following CXL memory device hierarchy would be valid for an endpoint once an RCD EP would be enabled (note this will be done in a later patch): VH mode: cxlmd->dev.parent->parent ^^^\^^^^^^\ ^^^^^^\ \ \ pci_dev (Type 1, Downstream Port) \ pci_dev (Type 0, PCI Express Endpoint) cxl mem device RCD mode: cxlmd->dev.parent->parent ^^^\^^^^^^\ ^^^^^^\ \ \ pci_host_bridge \ pci_dev (Type 0, RCiEP) cxl mem device In VH mode a downstream port is created by port enumeration and thus always exists. Now, in RCD mode the host bridge also already exists but it references to an ACPI device. A port lookup by the PCI device's parent device will fail as a direct link to the registered port is missing. The ACPI device of the bridge must be determined first. To prevent this, change port registration of a CXL host to use the bridge device instead. Do this also for the VH case as port topology will better reflect the PCI topology then. If a mock device is registered by a test driver, the bridge pointer can be NULL. Keep using the matching ACPI device (&adev->dev) as a fallback in this case. Signed-off-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Dan Williams --- drivers/cxl/acpi.c | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index fb9f72813067..06150c953f58 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -185,6 +185,17 @@ __mock struct acpi_device *to_cxl_host_bridge(struct device *host, return NULL; } +static inline struct acpi_pci_root *to_cxl_pci_root(struct device *host, + struct device *match) +{ + struct acpi_device *adev = to_cxl_host_bridge(host, match); + + if (!adev) + return NULL; + + return acpi_pci_find_root(adev->handle); +} + /* * A host bridge is a dport to a CFMWS decode and it is a uport to the * dport (PCIe Root Ports) in the host bridge. @@ -193,35 +204,35 @@ static int add_host_bridge_uport(struct device *match, void *arg) { struct cxl_port *root_port = arg; struct device *host = root_port->dev.parent; - struct acpi_device *bridge = to_cxl_host_bridge(host, match); - struct acpi_pci_root *pci_root; + struct acpi_pci_root *pci_root = to_cxl_pci_root(host, match); struct cxl_dport *dport; struct cxl_port *port; + struct device *bridge; int rc; - if (!bridge) + if (!pci_root) return 0; - dport = cxl_find_dport_by_dev(root_port, match); + /* + * If it is a mock dev, the bridge can be NULL, use matching + * device (&adev->dev) as a fallback then then. + */ + bridge = pci_root->bus->bridge ?: match; + dport = cxl_find_dport_by_dev(root_port, bridge); if (!dport) { dev_dbg(host, "host bridge expected and not found\n"); return 0; } - /* - * Note that this lookup already succeeded in - * to_cxl_host_bridge(), so no need to check for failure here - */ - pci_root = acpi_pci_find_root(bridge->handle); - rc = devm_cxl_register_pci_bus(host, match, pci_root->bus); + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); if (rc) return rc; - port = devm_cxl_add_port(host, match, dport->component_reg_phys, dport); + port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, dport); if (IS_ERR(port)) return PTR_ERR(port); - dev_info(pci_root->bus->bridge, "host supports CXL\n"); + dev_info(bridge, "host supports CXL\n"); return 0; } @@ -258,13 +269,16 @@ static int add_host_bridge_dport(struct device *match, void *arg) struct cxl_chbs_context ctx; struct cxl_port *root_port = arg; struct device *host = root_port->dev.parent; - struct acpi_device *bridge = to_cxl_host_bridge(host, match); + struct acpi_pci_root *pci_root = to_cxl_pci_root(host, match); + struct device *bridge; + acpi_handle handle; - if (!bridge) + if (!pci_root) return 0; - status = acpi_evaluate_integer(bridge->handle, METHOD_NAME__UID, NULL, - &uid); + bridge = pci_root->bus->bridge ?: match; + handle = pci_root->device->handle; + status = acpi_evaluate_integer(handle, METHOD_NAME__UID, NULL, &uid); if (status != AE_OK) { dev_err(match, "unable to retrieve _UID\n"); return -ENODEV; @@ -285,7 +299,7 @@ static int add_host_bridge_dport(struct device *match, void *arg) dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); - dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); + dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.chbcr); if (IS_ERR(dport)) return PTR_ERR(dport); From patchwork Wed Nov 9 10:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261359wru; Wed, 9 Nov 2022 02:42:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FsQV7KJ/ONqVjx/vUXU7KlWiJHjJeOxneDITlP8gk7tHnLXWobtsoLGpBPULQeH4Bhpse X-Received: by 2002:a65:5607:0:b0:470:59dc:b5ba with SMTP id l7-20020a655607000000b0047059dcb5bamr17389873pgs.207.1667990548600; Wed, 09 Nov 2022 02:42:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990548; cv=pass; d=google.com; s=arc-20160816; b=R2uuBRFAZTu1nkS5bVz+v+/fKKTGiLP+ji+34FSI+V4jWoe9Tzea2zxYxqp0fqdycP b+58Zbsb0r3ryM2VNbJFwWGDp1+tvx1zsMR/CaxljUKWD5T0CgByiTB6XczPcraI3Q0J 1XTE4UpxmPFI2qAdpIah/DDu0KvmUBOsdWJJ0eGxvmPnyrKFMbJa7L6HJ9bb2muVkfIn ikKTWIp+VUkXf6gW/9HzV3fXU7FRurv3i3uqXy4Wh4xNEAd2jA0++yp5K/3bL95BWdA9 xULEfBHqGX6trnLQC/ZC35LaEgXy1a2wd+ZOOSvivuXSBIZlABL9tLc6PuGQcXCi6xbw LlgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6m51gZr/Au402nQk28eiPuqysiEP2aEYXRP0YUNs5RU=; b=qc3b5ZRmNIRxsfaVBX8XbSDOZWWDWwwyDmd3hIlCeUQsglXBVSK5xR8ddxnPH25K0R gWlOnvh8LXR1M9779brYy08H7S/7F/nOwEguGZvY0pvfLVBYPfC37F4RRmtfvQAb3ZyS fVi0tPv8ijXq9AsycwKUdnjHXv8KgN/Xdfe322pzKMUCkF+unOA9IGMRz824Br6ICpBr 6Cn/iyN6MOrDZOi2CLsRyQeZAXZLWjKbA2B0oJSeU5nctj/YTiUfFHF3CBIuUtgZGTG5 tA9yukXxMDVA1tFN0ZQeoQCTNpu/GVyJiXrYMA1cFqArRVf1WmFimcol5nQjWi0bMoUR 97Lg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=bQs4W61C; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w184-20020a6382c1000000b0046ebb8fc292si17327118pgd.7.2022.11.09.02.42.14; Wed, 09 Nov 2022 02:42:28 -0800 (PST) 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=bQs4W61C; 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 S231152AbiKIKlo (ORCPT + 99 others); Wed, 9 Nov 2022 05:41:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbiKIKlg (ORCPT ); Wed, 9 Nov 2022 05:41:36 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9392F20F53; Wed, 9 Nov 2022 02:41:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K9lCMjtg8fSYmtfpfULWM5yVsxDvbUoxrFAZrGFQzaTnjM6GxIxQMe3f3yVMXSIa7PvMFmYPyAUgMsyscdKSW9QKkd9aacRLWo3E1sZOgH8l0j8sYUgLB8KdXN9AggQP8LC6m7c4l+G9NXZAJNRStjbCRAX0NhOVPrjFPHU0/QvHpXnAZhiPm/Y57g0O74nANHqx17o1imX+CBuc+WKWLiNPIo4cmgQqOJ8u+6vK1j9Q8SKxW0ETMbG/uKgBkwCxy5bff6X2kriypePglIMZbv2/EF9nY/qHgbZ1o24/uY77cAvdSUUsPRGfNk85vEkucH7qCE6RHidBfNeJwzUbZA== 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=6m51gZr/Au402nQk28eiPuqysiEP2aEYXRP0YUNs5RU=; b=g/XhWxDyYxZ18qH6o3yHteGw8Do4l9UJeMCns0FY73TtKI1K3Q3qshNdNK0Slg0Nw7xQzN0ifjAqL7qT4Ulr79zwmCVxpaedjttLwt3fx8Ur0KlcPTAEuyCoFKtShStpk1rSHTpfMeRZjQHnE7PenD5Ctrbq1gVvnr8Nf22IGx5AIqWC3kdn2wqSmn0l9xFgof4bmoyEObjMtHdELUZz9l/afHOaAewcIUkib1WKWhctzQ/x7YoljZaPphRKicvceGIyaQw7DHalmhXr+uB5NITWPBM1w1i+/NGmaKqQUwjSYxPfXUH/JlYgkFlOIvjz4lD9toMGoo2GlLSQOx//pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=6m51gZr/Au402nQk28eiPuqysiEP2aEYXRP0YUNs5RU=; b=bQs4W61CxuGS1n3hzTtc3D2wV5chWZ2g3jeeFAJvf8fOUyl/pmhGc+oKvfmjar/B0eNXvA7qtm8L1bYejt0xvvG/qMU1hvCvJRisKWm7WiUReilLru9v9GVAMIigyePVktLKhST2JpAGin2G6QtS8Wb5JrVqdljH6Hl0HLgqWxw= Received: from BN9P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::7) by CH2PR12MB4923.namprd12.prod.outlook.com (2603:10b6:610:6a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Wed, 9 Nov 2022 10:41:29 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::81) by BN9P220CA0002.outlook.office365.com (2603:10b6:408:13e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:29 +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 BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:29 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:23 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter , Terry Bowman Subject: [PATCH v3 2/9] cxl/acpi: Extract component registers of restricted hosts from RCRB Date: Wed, 9 Nov 2022 11:40:52 +0100 Message-ID: <20221109104059.766720-3-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT036:EE_|CH2PR12MB4923:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a6d1dab-4814-41d7-8e06-08dac23ef5d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wmkdADamZuswThwb1jWVgc7+BuSEywsgFc6v7y+YZWi5YUdKp8h24+50ai2O7FyxePqlCSKjIV4ykOIltHfcFfIQE0KsM1BX2d6G5giWOuQFEl5LpKkYkLeSjK7BPST1L0bTse2RCN8ru33j+K0ZvLoMa7n8EvUzYb5U1uH1tpmVGLE22+SRD11b4PiDMRKB67/LKlO0AgGtgUynJRVyp9oZIIwPBm+DNkj4w8nEd42nK1ef7zaVwRREIzuIJwpT+kM4gLf5qCIxiJ2ejq5e6XhVgvnVqr4wwhOZuNqxi2EaI/MkSqGvoY0lNqfyY8k5rwFCxVXFExhLpH9dsTvkxDgDUgMsklGf0L9gRhZE/v1NPCx6JwOZxIvRP+d0VI7PhWGAYPu63zYUsTUy05RfAj4fLFLHuGo+h9HTteWLZJoi/A983xFvxGAckKF/vTovu2nGYeHCzKP1BiOWZTjsArh/TtWCCc1YprQJd34FKRZL853Xo5Tgl5l8k9du/v0orRzX6FDRdRH48BYSiSIHvkBwnUWMiU4XDGsvs+4hTGfFS/Y43LVvhBUHpsS3wV9n21QOXClwQ0ap44BqofCMIO66XoLYKZiDFd0wdaqwSavnOfnSYDBzvK9ebHN2nlokR3QCSBX1PkZZcDIqJ6H80wx8yO3JMFf5ClvMFTe6H3N0cX4v5cCkvDxF2fZhZAbHQ0QfIs1CVLbENRrWCNbrjnvs/r0GvWlN7dv8fflr8eZ5MG+l4FhLVr8PnQF8JL2F4Rv1dvc4bfZff8F+dfeZBWwc2njCwcGGt5yZmTZJmt0= 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:(13230022)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(478600001)(356005)(110136005)(81166007)(6666004)(54906003)(316002)(336012)(36860700001)(82740400003)(70206006)(70586007)(4326008)(26005)(41300700001)(8676002)(8936002)(36756003)(2616005)(186003)(1076003)(16526019)(5660300002)(7416002)(2906002)(40480700001)(47076005)(426003)(83380400001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:29.3789 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a6d1dab-4814-41d7-8e06-08dac23ef5d1 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: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4923 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014857683281523?= X-GMAIL-MSGID: =?utf-8?q?1749014857683281523?= A downstream port must be connected to a component register block. For restricted hosts the base address is determined from the RCRB. The RCRB is provided by the host's CEDT CHBS entry. Rework CEDT parser to get the RCRB and add code to extract the component register block from it. RCRB's BAR[0..1] point to the component block containing CXL subsystem component registers. MEMBAR extraction follows the PCI base spec here, esp. 64 bit extraction and memory range alignment (6.0, 7.5.1.2.1). Note: Right now the component register block is used for HDM decoder capability only which is optional for RCDs. If unsupported by the RCD, the HDM init will fail. It is future work to bypass it in this case. Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 43 +++++++++++++++++++++++++++++--------- drivers/cxl/core/regs.c | 46 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 8 +++++++ 3 files changed, 87 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 06150c953f58..caea42cf9522 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -9,6 +9,8 @@ #include "cxlpci.h" #include "cxl.h" +#define CXL_RCRB_SIZE SZ_8K + static unsigned long cfmws_to_decoder_flags(int restrictions) { unsigned long flags = CXL_DECODER_F_ENABLE; @@ -240,27 +242,46 @@ static int add_host_bridge_uport(struct device *match, void *arg) struct cxl_chbs_context { struct device *dev; unsigned long long uid; - resource_size_t chbcr; + struct acpi_cedt_chbs chbs; }; -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, - const unsigned long end) +static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, + const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; - if (ctx->chbcr) + if (ctx->chbs.base) return 0; chbs = (struct acpi_cedt_chbs *) header; if (ctx->uid != chbs->uid) return 0; - ctx->chbcr = chbs->base; + ctx->chbs = *chbs; return 0; } +static resource_size_t cxl_get_chbcr(struct cxl_chbs_context *ctx) +{ + struct acpi_cedt_chbs *chbs = &ctx->chbs; + + if (!chbs->base) + return CXL_RESOURCE_NONE; + + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) + return chbs->base; + + if (chbs->length != CXL_RCRB_SIZE) + return CXL_RESOURCE_NONE; + + dev_dbg(ctx->dev, "RCRB found for UID %lld: 0x%08llx\n", + ctx->uid, (u64)chbs->base); + + return cxl_rcrb_to_component(ctx->dev, chbs->base, CXL_RCRB_DOWNSTREAM); +} + static int add_host_bridge_dport(struct device *match, void *arg) { acpi_status status; @@ -272,6 +293,7 @@ static int add_host_bridge_dport(struct device *match, void *arg) struct acpi_pci_root *pci_root = to_cxl_pci_root(host, match); struct device *bridge; acpi_handle handle; + resource_size_t component_reg_phys; if (!pci_root) return 0; @@ -287,19 +309,20 @@ static int add_host_bridge_dport(struct device *match, void *arg) dev_dbg(match, "UID found: %lld\n", uid); ctx = (struct cxl_chbs_context) { - .dev = host, + .dev = match, .uid = uid, }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); - if (ctx.chbcr == 0) { + component_reg_phys = cxl_get_chbcr(&ctx); + if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } - dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); + dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)component_reg_phys); - dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.chbcr); + dport = devm_cxl_add_dport(root_port, bridge, uid, component_reg_phys); if (IS_ERR(dport)) return PTR_ERR(dport); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index ec178e69b18f..7a5bde81e949 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -307,3 +307,49 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, return -ENODEV; } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); + +resource_size_t cxl_rcrb_to_component(struct device *dev, + resource_size_t rcrb, + enum cxl_rcrb which) +{ + resource_size_t component_reg_phys; + u32 bar0, bar1; + void *addr; + + if (which == CXL_RCRB_UPSTREAM) + rcrb += SZ_4K; + + /* + * RCRB's BAR[0..1] point to component block containing CXL + * subsystem component registers. MEMBAR extraction follows + * the PCI Base spec here, esp. 64 bit extraction and memory + * ranges alignment (6.0, 7.5.1.2.1). + */ + addr = ioremap(rcrb, PCI_BASE_ADDRESS_0 + SZ_8); + if (!addr) { + dev_err(dev, "Failed to map region %pr\n", addr); + return CXL_RESOURCE_NONE; + } + + bar0 = readl(addr + PCI_BASE_ADDRESS_0); + bar1 = readl(addr + PCI_BASE_ADDRESS_1); + iounmap(addr); + + /* sanity check */ + if (bar0 & (PCI_BASE_ADDRESS_MEM_TYPE_1M | PCI_BASE_ADDRESS_SPACE_IO)) + return CXL_RESOURCE_NONE; + + component_reg_phys = bar0 & PCI_BASE_ADDRESS_MEM_MASK; + if (bar0 & PCI_BASE_ADDRESS_MEM_TYPE_64) + component_reg_phys |= ((u64)bar1) << 32; + + if (!component_reg_phys) + return CXL_RESOURCE_NONE; + + /* MEMBAR is block size (64k) aligned. */ + if (!IS_ALIGNED(component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE)) + return CXL_RESOURCE_NONE; + + return component_reg_phys; +} +EXPORT_SYMBOL_NS_GPL(cxl_rcrb_to_component, CXL); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index ac8998b627b5..d6b4fe68a821 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -219,6 +219,14 @@ enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); +enum cxl_rcrb { + CXL_RCRB_DOWNSTREAM, + CXL_RCRB_UPSTREAM, +}; +resource_size_t cxl_rcrb_to_component(struct device *dev, + resource_size_t rcrb, + enum cxl_rcrb which); + #define CXL_RESOURCE_NONE ((resource_size_t) -1) #define CXL_TARGET_STRLEN 20 From patchwork Wed Nov 9 10:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17448 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261213wru; Wed, 9 Nov 2022 02:42:00 -0800 (PST) X-Google-Smtp-Source: AMsMyM4XQqg0NAKgnn63qnT/72fJK5Zn4GWvu0+1qmbX4pE7q/VTDjuIliQICoQKlY4DjMINaNe2 X-Received: by 2002:a05:6a00:1943:b0:563:8173:b46a with SMTP id s3-20020a056a00194300b005638173b46amr59279276pfk.34.1667990520226; Wed, 09 Nov 2022 02:42:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990520; cv=pass; d=google.com; s=arc-20160816; b=u0UNbOwlYp3YBL4pTiqeXA7ilNM9dQGBmpTMTGQ58CyaiV1J63bFbXM5ObWiDmsPWz k9soOa0NmgulE3JjXFJb33dlhJu5dZ0zWWXuXmjso181ejoJHaNJfLe3OYCzKxcon7dS DJezL3s1rF+iATumMjJautrbbxr7cJdorFeqgye7aYZDLIEtMv0H9DwIHP/SjjkU7CC/ BPMvQB8klniCxF29cb8JgKD4vviuBz14Ve7vqOa2FQEMhe1o7XLohCDKFLLTXpNgaqOM W4Cfzxb8FXgF4r/QzpJdyrt4s5cQw74Uuep+BVaHiCpOXukX6E5rv1cGb+bHwKnUm8iX xqXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vY6nb0G97usEt0cDMnExs1IMZ62wo437PxZzDGThDaM=; b=R7wBIdmSqUUBe6aFreefLWIvbgzU6A15TdOyqZoYmnkwabzVr+TKyVWXSOdVlWHBJr dQo9BE/VGsVKkl+jWlPGWGthgFQ7BpEZb6jKcdK4URchsZefQOWCrAudoTrEVNwzOEuG fQymKlx2IwFlKjqHLBRbIYOwfKJjthiGZVuIdQRx/fXHu7wn01MlZG8miG53OMnantK+ UHFQ8hRvo7cTtAYvHoAeusrhuxrii3Oa3t2mDjWbEIekdqMUuY/96aGv2L/rwgcJ05m9 2MI9XrXMGuypobVeQV0eiB9NLjNnD6TdXu5SU7Oc1P1Zub4f2XOS5TV98hkmEwCiAKxg APbA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="C8/eUbzW"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170902d50900b00182b78df2f8si21219985plg.495.2022.11.09.02.41.47; Wed, 09 Nov 2022 02:42:00 -0800 (PST) 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="C8/eUbzW"; 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 S230510AbiKIKlj (ORCPT + 99 others); Wed, 9 Nov 2022 05:41:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbiKIKlc (ORCPT ); Wed, 9 Nov 2022 05:41:32 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938AE209BC; Wed, 9 Nov 2022 02:41:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HOR8b15qD7tdeCGe9HJwEgm3VsdWS4hdX+vnEPvyN9mya2ip39o4oCbCrgUXmriyWGWnh5Z0+0l9x8kEjxQ7ODm1ApDxZ/I8I14c46fzINqWh4ix3KmGHNl0uqx1sJbKIJo/QVJSZ1mHPLTdJYZ/kPDp16Z0ijBzpGu2ybx3SCThrJsixZwm7HKtzwt0hj9SJ5/kIV5VVCmQBs3cTNyAk9FFE3+Xh8jg0J7RQpD3KUwmXnxTzY/v29kWNDUcXqZxuUS1xCmUWNt4i/DPxHznpmW0VSdv+/RaYvnZSZ6gFPeiUsD8sqrbRWOMT+smVKXZXi57BWFus8OB3r8ZRW1Ptg== 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=vY6nb0G97usEt0cDMnExs1IMZ62wo437PxZzDGThDaM=; b=URmszr6qmkhORvZ/YuoFLIa42biAvgOO6nF7ZOJ43tdDBABJ28bAtsT2mVfNVRHOf6BEYSflTTi8S7+nRYsxD9NNNwG3lnCEyYDmmEqkiU/GR6R5nsigrLBB0L4J/ipigQkHW7mV4TUkCSSoteSGLwvNq7m7hRgWNrmAts9o66Mfaddsy0rpHUm59wCwAMnQZt9J43zVwpxV+gP11BpMCij8Pf22CFt0xIDalpwwyjNLouJbkk5DmRqRYOb5N9eqgKMLJEw/0Pt86jz85bcOBgBtBZn7dEd5X/A0ceqeRn9VxJU/k2gZBZwdu8J8XrPmh9bOHOyxR1hThMSVWEI/rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=vY6nb0G97usEt0cDMnExs1IMZ62wo437PxZzDGThDaM=; b=C8/eUbzWZAfZoxqIAYiFm+qM6iEeB8Jj698TvLdVI8J8Fwpo4cWsPMWjL++bWo8app4JgqQqqIwt8iYCAQE9AR1FnhNJjN6AaskdM9QtY3b982hIjv5DvrTYDcMgjU4ksDt/Luy0Sr3/8VYUuc+vC11MOw7SVM0JeCdb3ocmk84= Received: from BN9P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::16) by BN9PR12MB5275.namprd12.prod.outlook.com (2603:10b6:408:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:29 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::f8) by BN9P220CA0011.outlook.office365.com (2603:10b6:408:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:29 +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 BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:29 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:26 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 3/9] cxl/mem: Adjust cxl_mem_find_port() to find an RCH's port Date: Wed, 9 Nov 2022 11:40:53 +0100 Message-ID: <20221109104059.766720-4-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT036:EE_|BN9PR12MB5275:EE_ X-MS-Office365-Filtering-Correlation-Id: f8ed6df7-a314-4116-779b-08dac23ef5fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: REEzWynFfBy8dikKxSV+hXuZAuNdeB94+/WFPs6o7b0bLcDOxbTYJwDN6PCpst381Wm1CvkJVlvICJI4pb1jj2Iz9YC4QmnfxG4TxcebwNltjzr8u/ZouuXGnQVlHgUbVc9D3eKXhXC7WC7Gd5YCnVRd4EUrms4JIxzyx+NTzYn8s23ngye64x42oUbwrDsUhQZsjWniU3anIp2/pb0lW3a1WWzLAUV/PhjljaPD8zSJfRjyvzYMUX77VSy8gAaMHFhtTT1r0WpNko+pC3gdlnLZRqEpwrXwVwC9SQI/1L87m3Jjn/obqxIPzQ8ZC4sZ3y2E7s/PIdhJGugN/FZ5E+WNqUw7PXUlTt2HoOp6S4rWW1zJSfQHC92XgbWC0OB4FN9z9Lr8FH9JFWI/cn0Da5EZ/Q+tCCly+Tm0eiZii1bmH6wZeITk5QsL2Iy8Q/V+LnMIexI+B6GkYSoJX8/iMTqofcELru1MW+85JJ8v9qrOySln8NqJLM3sXKvfX3fFgdhgljTJhLMqnMJZ+7n4HShdRSXpkPY4ceoaivXZO5HhiWe892rH5Fx3DGmA/bQ+ZFWpF3iZLcmtDqcuNtMGbxgHtBgflDo2XS5E03U8hK4c43anhORO7e4rJ3S2wQ2swxQf6bruoW0DQCQssNzUE0WnHVDGJAQvAQYvdoyjqCRmSeKWGZxbEodyoy2ZwmPCT8nQDExpGVN8uHACIjFd0i8fc/1tVDlS+m/yiRCDD5PCXn4mzuOB2Z0Fpg8l5NuAETkVEYd/YkU8JwKePhpG9tAqkjzb/8P4v7cUayzfJp0xqmv7RVCMa3uxDY/M5v00QSBzW0G1qBArFwgJRzEcjg== 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:(13230022)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199015)(36840700001)(40470700004)(46966006)(47076005)(186003)(426003)(336012)(16526019)(1076003)(70586007)(36860700001)(26005)(2906002)(7416002)(40460700003)(40480700001)(2616005)(110136005)(316002)(4326008)(478600001)(82310400005)(6666004)(5660300002)(8936002)(41300700001)(70206006)(54906003)(8676002)(36756003)(81166007)(82740400003)(356005)(37363002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:29.6602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8ed6df7-a314-4116-779b-08dac23ef5fc 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: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5275 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014827771661420?= X-GMAIL-MSGID: =?utf-8?q?1749014827771661420?= The PCIe software view of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP with a parent already pointing to a PCI bridge (struct pci_host_bridge). In contrast, in VH mode an PCI Express Endpoint is a PCI type 0 device with a PCI type 1 device as parent (struct pci_dev, most of the time a downstream switch port, but could also be a root port). The following hierarchy applies in VH mode: CXL memory device, cxl_memdev endpoint └──PCIe Endpoint (type 0), pci_dev | └──Downstream Port (type 1), pci_dev (Nth switch) portN └──Upstream Port (type 1), pci_dev (Nth switch) | : : └──Downstream Port (type 1), pci_dev (1st switch) port1 └──Upstream Port (type 1), pci_dev (1st switch) | └──Root Port (type 1), pci_dev | └──PCI host bridge, pci_host_bridge port0 : | :..ACPI0017, acpi_dev root (There can be zero or any other number of switches in between.) An iterator through the grandparents takes us to the root port which is registered as dport to the bridge. The next port an endpoint is connected to can be determined by using the grandparent of the memory device as a dport_dev in cxl_mem_find_port(). The same does not work in RCD mode where only an RCiEP is connected to the host bridge: CXL memory device, cxl_memdev endpoint └──PCIe Endpoint (type 0), pci_dev | └──PCI host bridge, pci_host_bridge port0 : | :..ACPI0017, acpi_dev root Here, an endpoint is directly connected to the host bridge without a type 1 PCI device (root or downstream port) in between. To link the endpoint to the correct port, the endpoint's PCI device (parent of the memory device) must be taken as dport_dev arg in cxl_mem_find_port(). Change cxl_mem_find_port() to find an RCH's port. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 0431ed860d8e..d10c3580719b 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1354,6 +1354,14 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, return rc; } +static inline bool is_cxl_restricted(struct cxl_memdev *cxlmd) +{ + struct device *parent = cxlmd->dev.parent; + if (!dev_is_pci(parent)) + return false; + return pci_pcie_type(to_pci_dev(parent)) == PCI_EXP_TYPE_RC_END; +} + int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) { struct device *dev = &cxlmd->dev; @@ -1433,9 +1441,39 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) } EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); +/* + * CXL memory device and port hierarchy: + * + * VH mode: + * + * CXL memory device, cxl_memdev endpoint + * └──PCIe Endpoint (type 0), pci_dev | + * └──Downstream Port (type 1), pci_dev (Nth switch) portN + * └──Upstream Port (type 1), pci_dev (Nth switch) | + * : : + * └──Downstream Port (type 1), pci_dev (1st switch) port1 + * └──Upstream Port (type 1), pci_dev (1st switch) | + * └──Root Port (type 1), pci_dev | + * └──PCI host bridge, pci_host_bridge port0 + * : | + * :..ACPI0017, acpi_dev root + * + * (There can be zero or any other number of switches in between.) + * + * RCD mode: + * + * CXL memory device, cxl_memdev endpoint + * └──PCIe Endpoint (type 0), pci_dev | + * └──PCI host bridge, pci_host_bridge port0 + * : | + * :..ACPI0017, acpi_dev root + */ struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { + if (is_cxl_restricted(cxlmd)) + return find_cxl_port(cxlmd->dev.parent, dport); + return find_cxl_port(grandparent(&cxlmd->dev), dport); } EXPORT_SYMBOL_NS_GPL(cxl_mem_find_port, CXL); From patchwork Wed Nov 9 10:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261307wru; Wed, 9 Nov 2022 02:42:18 -0800 (PST) X-Google-Smtp-Source: AMsMyM7LPXDlkAwKGEIxF6iR52ZU8Dcp76J5oTwJkKshLfad3fZVQpNNm5j+ubH+V6dUO/6xcnis X-Received: by 2002:a17:902:c702:b0:186:e151:6b27 with SMTP id p2-20020a170902c70200b00186e1516b27mr61618768plp.69.1667990537532; Wed, 09 Nov 2022 02:42:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990537; cv=pass; d=google.com; s=arc-20160816; b=AOHpMFBti4v/bxqCKic3uoME4kiSIG4P24YGCW1tquOh5mUYdaWjWTAjxtotAnrB9B I/6WuZn/opYR9dXX81T0eod8mQdQ55dgx2XkNtzOXx/8yJOTQpa1CvL22ANZ+3kALRkJ odNkNIFtDjXzsp1rtakrLzBeVTSxukn4vWlqwkajQuoikKVW6ZYqg9O7EsX4lH/jO8eE ni2FnSydhcHyh77lDmJ/I59F3NnkYbI7YjMMBn7Evkl/+7dNGUJxqprW6arEP9Ka8Bvw GnLVOE+Oo78B1oeeRqMR7EobOpdChMP771any1o8Z/RdGeIbqIRSwPYcCNnwOlFsaoER 0xvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=73NwBsh+4VgARIZnefxl1VUD3O8ZaMkAlO+5ST6uapw=; b=ASl1xz8FKEVgG9HR8MuA7SUDU3/2rTJwl/IGH9ygcbNZe2Kt1jqkWpdA+Qekfp/T8a qOAgufeAgqoz7w7Ao7wVTHZMMso+h/TM7YMWZyt+5aB87n3pv+L4+J7okExIVZBxgOg5 vHVzpTjYKN/5GheGojcZs6n8jwPTzqdklGplOkgyWF1r7smVABdkMXQkSb0GiwcGcP39 Pt0rGMSBvRQyBluMoDtS3sediQ6J6mbUR+8/1f1VLk/R37zZ7lXMFTA8irN/C6sqHevx A4e7i6KX+E6Fx/sBFF9fRQq7tMSK8oqm+XHDoEW6OBqMH7kPp6Kh/zF6rkO6AVuzOudT 8NWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pk4QiuI2; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170902ed8c00b001886cce9ab1si15167631plj.247.2022.11.09.02.42.04; Wed, 09 Nov 2022 02:42:17 -0800 (PST) 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=pk4QiuI2; 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 S231166AbiKIKlr (ORCPT + 99 others); Wed, 9 Nov 2022 05:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbiKIKlh (ORCPT ); Wed, 9 Nov 2022 05:41:37 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2086.outbound.protection.outlook.com [40.107.220.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE40822BD8; Wed, 9 Nov 2022 02:41:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJTEcmIM8Clu+YV4zjzekBpYqoWF0kUvAB7GTRuE8YShl5ZKDeOrEpmZE2p5sRO/5AsVFeX5YxnX17Oa0+rSNqYNfZXW5iZV2J5HdSgCzslRNtEt4cHnQTHqwwhWqcDTEvTKcuDEfbpsvJRmlhTRBk8/x9Fn56ERPAio6vV5Bz+kKCFs9bBCKtCGVe5uYOZTLBVkNX7DvqVridrDhlsmHtf1tgbPWIGux8NHOIPUUXJJNSTyBisojlEh6z+mfAETXM7VRcY+dfbOERZLFdGpumYaTbyfcMGQ6HqoqQq9wbIysXfVsFQ2MMMqEq9jyo+3Fner2ZBqpTrPEpffqJyiKg== 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=73NwBsh+4VgARIZnefxl1VUD3O8ZaMkAlO+5ST6uapw=; b=UQ58EmE7yXELtA5l31/qGJOeEy7qSXpAR50onXICE/lyAa5Lfw5h8gDlEIb+BfQV1xtNROSLqqL5yyynT2DOYanGF82m5hbaX5DElx+SzcECAs+rK4AHCFnr9cIOvgLRvRBKwqAAP9+QhW8Zw4671IExwbDHngAnjwgdO/zBIwhwajQEcI1Fithpzgknnkc7V/HnUG26PoY8xt62T3vyepPP2jjeGrFO1+JmhNyxaRQo842YIizkB5EZ5REbG2KrIeb6A9Q5y32ZKQLlqePMVhn7ekgNDb6iDKZ28YYD1hooWAsDTJ3iGzfDTuR/5q8oP1O/RS5pP/AnmAwh9eAMKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=73NwBsh+4VgARIZnefxl1VUD3O8ZaMkAlO+5ST6uapw=; b=pk4QiuI2MfaNBSCzScbbEN+AlWU3klOcUqE7abOndZMB+M334xDdYQc+MzQEReM7vQ54ZPjpT71aGkp35xY0wfFBXVQISvrKJK9xtcQjniF5ON5yw1CUDtJkcUYlc5elSlFFmalQkNUjSxhkb7hK+Hh8lPubzSlPUwIwpW2ajOQ= Received: from BN0PR04CA0079.namprd04.prod.outlook.com (2603:10b6:408:ea::24) by DM6PR12MB4217.namprd12.prod.outlook.com (2603:10b6:5:219::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Wed, 9 Nov 2022 10:41:32 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::c8) by BN0PR04CA0079.outlook.office365.com (2603:10b6:408:ea::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:32 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:32 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:29 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 4/9] cxl/mem: Skip intermediate port enumeration of restricted endpoints (RCDs) Date: Wed, 9 Nov 2022 11:40:54 +0100 Message-ID: <20221109104059.766720-5-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT031:EE_|DM6PR12MB4217:EE_ X-MS-Office365-Filtering-Correlation-Id: f02be110-c5fe-4432-c41d-08dac23ef78e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FfGGGblVlpaC5xC8B9kIIV8/QMzZl+3QX7kfyHCVzq2jfPK/1Box8j9P5o8fWKVp2j8AOjHt6Hncug/CvrStzfO8LbX2jk4Y26/neDhFO+AEkfqMioWAL5XGBIPU059vh/Mwfr0bKRmcD1sox/VNXv8AJfFxet8DJbXfhGKJSvDmML1NIC7iw25QLbnmuKdAYz6I2nHuCa2g/oSdeqBmz8K/Xt7n/5aAemorkz/tt6MFoC5AFfr64EvzM+CDUUJLkb3Zbk/b/CBOVBwKhoneMZKhoPNgZf4Wz49xFGs1tXgJ5zODV/dC2Ajx+rhC5c9aX8Jk7o6oV6yzjYIbXmsYzhTmcrn2BI1X1BtCuJN1xnW4G7LweQbCc53GvhQdEX9lX+UNlm0uiraQAgwPSkrcnqjPPm2nxwcmEC7CRFnU62y6lNH1LSUKBHudgz3g+L6HLMWEbbovciq6PGPVRefKHjNTcrpIJ3xSv0SfBaWJ2OFdwDhO7UhlRMmmP9Wq8WWIluRAv1LZk+ldDUjguMGpwTQSTRhSVcWxYDJWvOFWBGkvdCG87AG4jSFjUxawIKDsOAN/aHkiocwb5+Z6uV8dP/lbE/qCyT8cQfCPVPXPl/u6mKb0fgdghpVNXgpJgNTdq6BDza+kJNC0MLOaYC25Kkl4VTZ5lLx6VkZwgbTqhlQrMoG2PQmAEq1yHfL+AQ9YgHoo7tNfNk3Vnex2BfOUy9OcqTi8sT8iVQCEv3xhqCORpUY/ARupMPo1VH+12c4WklNv2yh1vXN0RKsKRQIdaaABgmMJW3EgMIGr6+2fKiS5D+SyEQeJ/vLnAFkhTs9U 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:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(478600001)(356005)(6666004)(81166007)(54906003)(110136005)(316002)(26005)(426003)(47076005)(40480700001)(70206006)(70586007)(4326008)(82740400003)(8676002)(7416002)(41300700001)(5660300002)(8936002)(36756003)(2616005)(186003)(1076003)(16526019)(40460700003)(83380400001)(2906002)(36860700001)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:32.2967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f02be110-c5fe-4432-c41d-08dac23ef78e 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4217 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014846064279643?= X-GMAIL-MSGID: =?utf-8?q?1749014846064279643?= When an endpoint is found, all ports in beetween the endpoint and the CXL host bridge need to be created. In the RCH case there are no ports in between a host bridge and the endpoint. Skip the enumeration of intermediate ports. The port enumeration does not only create all ports, it also initializes the endpoint chain by adding the endpoint to every downstream port up to the root bridge. This must be done also in RCD mode, but is much more simple as the endpoint only needs to be added to the host bridge's dport. Note: For endpoint removal the cxl_detach_ep() is not needed as it is released in cxl_port_release(). Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index d10c3580719b..e21a9c3fe4da 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1366,8 +1366,24 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) { struct device *dev = &cxlmd->dev; struct device *iter; + struct cxl_dport *dport; + struct cxl_port *port; int rc; + /* + * Skip intermediate port enumeration in the RCH case, there + * are no ports in between a host bridge and an endpoint. Only + * initialize the EP chain. + */ + if (is_cxl_restricted(cxlmd)) { + port = cxl_mem_find_port(cxlmd, &dport); + if (!port) + return -ENXIO; + rc = cxl_add_ep(dport, &cxlmd->dev); + put_device(&port->dev); + return rc; + } + rc = devm_add_action_or_reset(&cxlmd->dev, cxl_detach_ep, cxlmd); if (rc) return rc; @@ -1381,8 +1397,6 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) for (iter = dev; iter; iter = grandparent(iter)) { struct device *dport_dev = grandparent(iter); struct device *uport_dev; - struct cxl_dport *dport; - struct cxl_port *port; if (!dport_dev) return 0; From patchwork Wed Nov 9 10:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261479wru; Wed, 9 Nov 2022 02:42:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM7of6aBpY2XzaVI/d+VRCq4BUA/7NF784NhVe9nG07fp/YumYxJ9VzhrEWuIdZdPuy1vyO4 X-Received: by 2002:a05:6a00:1781:b0:561:7f7f:dc38 with SMTP id s1-20020a056a00178100b005617f7fdc38mr61225219pfg.42.1667990571122; Wed, 09 Nov 2022 02:42:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990571; cv=pass; d=google.com; s=arc-20160816; b=IE477PX12t9MtcQcxPa7q+7wP1BxbXiAONpJlWqEgYslzDgpDSlEXl9kIvwpKgpzRD HmBf8r5b7/FR/01fXjDL0WVoJDQJ7/t9TT8aM7Z7oelNAL1No4fe75uod53EupdSSzAV 8oZ7Xu8V1j1IId0vomdcyN2Yp1p8Sj7q0r8Ra+NtuQBNa862Y5tarwr7ofV2TokITK+q TB/RhsU3aDIMPuzdaRT4m81f6rRCkix40s3wy5bR2BP6xbUjWcVqJjIPl0rz3YK0dp55 2le8VL42tVn4Z6h2bTKU8zGzwwfwZNIh+hH5+PDlZ8vI9+mhS7cvziz39M6b9yeGPvii YmFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nS3RJuVhOl31ZYeV432y068pJtOlAuTnnT5e2/RDVFE=; b=fmF37LlfIAnBmCw7HpQ5KtsmPGxqZA4+7KAsqzvL6Dnn+7cwR/HtQt+6SLS0VsKmY+ jf7kycMAKTebIEOj9Tw5Q6Us/r1uSfVJzF3zme9k90RBZkVzAP4sjBe6RmJPFlHkfN4Y UIAobqgQOfmRWT93v/ERoO0hevZQ8QL2U8Mw11Z44P0TL4S0DtHJNM+3Pz73DCVfGts8 vBR6Fwc2wxil/gHIMJyASFrgoilw7RACNmFW5b5vNOIQNaxTUQnUPh0gqG9ZvvAhW48N aDroaMfBgaWCzfWF5zfVSpXA31WDy80YLgzY8Iwg1VUDqOC4T45Vn/LWem1J8RNstero qztw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=KUpyQ9Fu; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a655a45000000b0044d6999624asi19061565pgs.339.2022.11.09.02.42.37; Wed, 09 Nov 2022 02:42:51 -0800 (PST) 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=KUpyQ9Fu; 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 S231148AbiKIKmC (ORCPT + 99 others); Wed, 9 Nov 2022 05:42:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbiKIKlq (ORCPT ); Wed, 9 Nov 2022 05:41:46 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 588D02655B; Wed, 9 Nov 2022 02:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YlQ711kwq5wBQwi7ZyQDAjnZC/bZmCFyCpGAPP6VKtdBiGlWOoM7CwUIp1mJ4nJjsMXgEYoptTFJi5jt9MEX6KgXLXdOnSH09SR9YwTcC/+TL1oGynW4USk97XrVvB1pPwLIVaSbhJOaDsbS+8kJUyN/4pI99QCApbZ4mbiL7Yro8Ud9/2MyHzAGrAKDumbcDjpiMNP5upfCU4fymbcuEfX31Zk2wI+V+EieS+ObIVQI2ZCNgnQZbM9OkXqzRmiS0zo/U7djgLn1+LlU4iXdhGWa436DsVniJDeTNOh2VP7GJ8Ka3DmutqVEbRVnF8OVgQqIy8UsxPWUBPHfxuZlQw== 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=nS3RJuVhOl31ZYeV432y068pJtOlAuTnnT5e2/RDVFE=; b=gMssLs4XiWU0SrJNyWiFVtutHi5c8Lb/uaejiQpQ8fzs4diiOh1WvOoi0CFJlxX9CdfEjZ8XF3lTCXhU1qD/0owhYQyguOwuaRHCsw0XXhy36nChb/VA8p37qRME95a8NIMRJo+hgKNC4mjJfIuubS3IUNsyVOCUyO0pBZm3vUv+LKj0Uy30/aNrVFR6WcLnT/c7hHRy8G+QL29f9PhMYablbOswz1c0y6QtooKbMgrwc6ggM7IqVaObgm014eLiodmv2z6Cgi6SqwgEur7X3UONWMPus5TO7MstBjIx2mjPHDIb/glYbuIz0+9MvmttPxyx3Bp0ncNIEfVBvJSlCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=nS3RJuVhOl31ZYeV432y068pJtOlAuTnnT5e2/RDVFE=; b=KUpyQ9FuArG6hySGCLlGJnOeM57od8hunbRTaA2ynHtQRkAlFqLzAsaGBbny+AvF+ztUt8bLHW95VVe/kHvriCbtRcBjLja7Bizj0MU8HsUKGldhYOG+zhZ8TspbMFQexpr63VsqQSdUW/LU9TOzB0gNQ9IymrNcYrZFhVtBeIQ= Received: from BN0PR04CA0062.namprd04.prod.outlook.com (2603:10b6:408:ea::7) by MW4PR12MB7239.namprd12.prod.outlook.com (2603:10b6:303:228::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:41 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::22) by BN0PR04CA0062.outlook.office365.com (2603:10b6:408:ea::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:41 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:41 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:32 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 5/9] cxl/pci: Only register RCDs with device 0, function 0 as CXL memory device Date: Wed, 9 Nov 2022 11:40:55 +0100 Message-ID: <20221109104059.766720-6-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT031:EE_|MW4PR12MB7239:EE_ X-MS-Office365-Filtering-Correlation-Id: ddd8ab70-2fa1-40b1-f37c-08dac23efccc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y6/d7+PK4NJVWpH1W0AwtNNJLHO1LEtagbmHg2WGeJsfb0cmXvpPqSDWMUhkKt7yiszXCCNZAoTZrCVbaMR9N5COoMz2MkrkokyyHSEge4Ik0PpdKjDbiniGkrhLoCHAh5aBS4yqndaTRSzKIU8W32pv10mq/b/gvX8wmOv1Am6VpGLPkjtaPzw2OGDLyfeZPRABE2PxspIruvKHFT3O1vCSaMDc08GU0jB8sQfGKqHDd13NLJaWFSBJoAdra83UW6UU9SdUUSCVD3muDAL2bdDlDZ6wQhvlEirt1WhsSpEkZpi/atFyaOY91liHWid158PmC9QaGzsoOma1Z/fYVzltPfNgYsW8vRBPAbwt7aoKAZ5g9uDk4XFDG/Q88yb8MSZgW3T+ZC0/Su9kezd0JoXKKtZhS1o6ZS9MxQDTw0Nw7Lrg8PHxWaoN3GXFfAXEsQiYE1m1Fdy/yQWvHRgWo/jLfaKckt7YwwojVmgLWMdi041I4J/dREQWKsLYOGrgDB2T2nko1CTMFQoP3dWOOR6t2HPx4MqbTv8veepGua0m0FPq40Qpb2q75V8btEOalq8eu1Nv+UnV4uanQyigI8nLyaL3bYjuP7DQmb/9W7WHgXW2nB6lgvZfZPKnalt0uNslvzbTVur3f16MhIEJkuu7wevzumX/HMzLFSBVpo0YmepMcZhS0NUwqOCT32xakXnocvE2QuBdhUZuQyzxdJS5ior21GMd6iajssBb8wNKvCs0qgZa6cGnljkcPpsevTHpjLj7pBFANsT+JD72I3xwnMyVmTH/m/23oTanktUf0sk9fxaVyQjpPrVA0c/+ 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(40470700004)(46966006)(36840700001)(356005)(81166007)(36756003)(26005)(2616005)(40460700003)(82740400003)(82310400005)(7416002)(8936002)(83380400001)(2906002)(5660300002)(8676002)(70206006)(4326008)(41300700001)(54906003)(70586007)(40480700001)(316002)(186003)(1076003)(478600001)(16526019)(47076005)(426003)(336012)(6666004)(36860700001)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:41.0928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddd8ab70-2fa1-40b1-f37c-08dac23efccc 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7239 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014881208379795?= X-GMAIL-MSGID: =?utf-8?q?1749014881208379795?= The Device 0, Function 0 DVSEC controls the CXL functionality of the entire device. Add a check to prevent registration of any other PCI device on the bus as a CXL memory device. Signed-off-by: Robert Richter --- drivers/cxl/pci.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index faeb5d9d7a7a..cc4f206f24b3 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -428,11 +428,26 @@ static void devm_cxl_pci_create_doe(struct cxl_dev_state *cxlds) } } +static int check_restricted_device(struct pci_dev *pdev, u16 pcie_dvsec) +{ + if (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_END) + return 0; /* no RCD */ + + if (pdev->devfn == PCI_DEVFN(0, 0) && pcie_dvsec) + return 0; /* ok */ + + dev_warn(&pdev->dev, "Skipping RCD: devfn=0x%02x dvsec=%u\n", + pdev->devfn, pcie_dvsec); + + return -ENODEV; +} + static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct cxl_register_map map; struct cxl_memdev *cxlmd; struct cxl_dev_state *cxlds; + u16 pcie_dvsec; int rc; /* @@ -442,6 +457,13 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) BUILD_BUG_ON(offsetof(struct cxl_regs, memdev) != offsetof(struct cxl_regs, device_regs.memdev)); + pcie_dvsec = pci_find_dvsec_capability( + pdev, PCI_DVSEC_VENDOR_ID_CXL, CXL_DVSEC_PCIE_DEVICE); + + rc = check_restricted_device(pdev, pcie_dvsec); + if (rc) + return rc; + rc = pcim_enable_device(pdev); if (rc) return rc; @@ -451,8 +473,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return PTR_ERR(cxlds); cxlds->serial = pci_get_dsn(pdev); - cxlds->cxl_dvsec = pci_find_dvsec_capability( - pdev, PCI_DVSEC_VENDOR_ID_CXL, CXL_DVSEC_PCIE_DEVICE); + cxlds->cxl_dvsec = pcie_dvsec; if (!cxlds->cxl_dvsec) dev_warn(&pdev->dev, "Device DVSEC not present, skip CXL.mem init\n"); From patchwork Wed Nov 9 10:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261357wru; Wed, 9 Nov 2022 02:42:27 -0800 (PST) X-Google-Smtp-Source: AMsMyM4U/1jojAIMTgmvceYfZ4yHwA6t5YHYhDemxSKJwPXg7rUu1PDrDw0l8fIYgQSFjnlXYwLL X-Received: by 2002:a17:90a:1994:b0:212:f4e9:cebf with SMTP id 20-20020a17090a199400b00212f4e9cebfmr79773807pji.51.1667990547523; Wed, 09 Nov 2022 02:42:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990547; cv=pass; d=google.com; s=arc-20160816; b=hQ/FFwU+QVsC536SxH/1rWsJJAUVja1zCbr0CsVwm3iMZfKARi4j0N7/PyyzggYACv WTiuq0q2/dYbrf9aCa7Fb1vn/0bFwF7yvFKto4zng0XvpCjyG+D0aM64iuWFEMUbh8AH diBqmZHtiH2PMlI4EReHhbTOYx3+MG3DbTUWYhnGoEhkbrF1Wc7Tg4pwVeDUUOVrZk7Q 1Q4xnFSQaGbhaCtp5VVIirIZJQCaiG/sb8jwpKFEybH4DqJpPfsY+dl+I5gkf33AsUbG 720RsGqLPl+JOT7Pjw8aaNa8hqlWHwHOXQjIDqpLRbhNi8GKzQwDMND2997YZm5ZrD6m D2fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=NggE6whZ9O2ZwYPyrD638QcqCvrdB9HK6aPlyQTsL5/nrmmPsuecb7735bE6bHJjwI WQImXyPw2tSTITzNU0jKJfgOWLMilyUn0i2EP+tssMZEI52o7E8lfPOZafvXz199RbOL qe0EdCD2V/BmK/1asVoPlsaiBb8JlpwtZwndfwDU2pQtGPcnt30BC4eD9nsggEp4ZUaK 2Sl45iLXWz3JNwTUPsA0DWwT+Oy8P50VNhWKYnJ61M9HxmrCJRUiip7mcGjY7I8+34dz 6QRdP2LnMA1uxyofkZ+OLROWKWgbMoJr4R3HxOPf0WIBxeaDGc7FqrC/dRugauddJR3Q LURQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=l5DsRSvO; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa9-20020a17090b1bc900b00214021e87d1si1082910pjb.173.2022.11.09.02.42.14; Wed, 09 Nov 2022 02:42:27 -0800 (PST) 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=l5DsRSvO; 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 S231160AbiKIKl7 (ORCPT + 99 others); Wed, 9 Nov 2022 05:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbiKIKlq (ORCPT ); Wed, 9 Nov 2022 05:41:46 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2052.outbound.protection.outlook.com [40.107.223.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDEB024F23; Wed, 9 Nov 2022 02:41:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U0EF3RDR/MQ69mFnypHmA0Sb9xc7Y+HnnGljlXBEm4heeaA2PvZ58c4uf7crcXEgnbrnhZxVYla/kU8WIrptu8Jkv7NVUtU0/7l/z0WSFxCFxk1H3thkOny+vQeNaqz/DvwvSjlBV6xqRvzwj7/cNwh+Kly64hl6JjJ0NO1iXd0IpaOAaPnlQShn9geFhfEGOukO+8bRsxOq/OsnmYTXVTjaN2j6tgkhmDi41lPCKShCy5Y3F06oBOEyH/Zk9uU5ipMq64hl1wQiXjKRa6fuYARiXW+e38cXpc1SYXtr/mMqxmbIXueY52Qftx0jKBOpyM9WNTtcLPaC8Xmuil0c2Q== 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=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=DaoiE1VN4PiEX2xN7ZrRibee/OY8ng7ZOsi5fTBbLyx4Y5M0KPru8K+2IhtVgg3i9S1HXjTAuSOumkxrGUeN1yffnK+1WxvbasSo14mw4/jRveSGnuFUiO4PGE8NyIVnLFfvK1f/7ga0UP7MPo+FI1G5gQvvI39T/9UVbslzUsaWa4GqEsmNWQkLUCuJBrUnvcNJkipWFHgx6q8Wu6EbPakqdA8q4xESmxcyrzzpmCKbGYaLU6LGRewnDZ5nvecM+n5K8bjuA/h+ezD9Ua6l0+M7ejTdTGpQPjY9gcZ9XrJ0NVUMENYRF1rMYQcQy1bPSCucLh9llhMviz0ffP8DUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=l5DsRSvOWaCoBky6agsyALWXlOZOn4A9+U7QflZNlhABpUguSjJDjnkW0bEksK3wVBvigoBw7h2I0RY5MeQnEYoa2gT68xSV/49NmzEN4kePBcA+m9e8vAimQS0KwSJvcmt2GUTSYCLOmUNNruLKZxsqr6D9HJSPoXaZOYy91S0= Received: from BN0PR04CA0071.namprd04.prod.outlook.com (2603:10b6:408:ea::16) by PH7PR12MB6717.namprd12.prod.outlook.com (2603:10b6:510:1b0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26; Wed, 9 Nov 2022 10:41:43 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::98) by BN0PR04CA0071.outlook.office365.com (2603:10b6:408:ea::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:42 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:42 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:35 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 6/9] cxl/pci: Do not ignore PCI config read errors in match_add_dports() Date: Wed, 9 Nov 2022 11:40:56 +0100 Message-ID: <20221109104059.766720-7-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT031:EE_|PH7PR12MB6717:EE_ X-MS-Office365-Filtering-Correlation-Id: 41817502-b894-4b91-6bfd-08dac23efdce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jSBKg9rAB7T2XDBxfRmsslVdR47pvkd9pKrQL3qCRyUF/1LVyVlPiv822U9V+L3Vy6SqyhZaG0C6Fe/PalewkI+/Uu04irRHLyQHPjOFhqmGptYldBkRpSCZNkvt9SATlxzO0tcAVNh2Z7WfsMN1DJRz5aVndRW5pqamJgMl2x5urWhkDtCrb8142zNWtjsy+FbZ/AWjrK9qOl2upRDOaXtYbYDpOQ14IhTFXoe1WLNuCmMiFHZ7RWikpYNFEJPhWmXpXLfOcFZY4mEWD+IIbxHKbDZ/tECr2MAB687WIJZkmZx+7nO/uqR5PRmCcwhxLkcf/5FfIxINUx0MFZmapRJMVYTpMgLitCCfUyc+ycUZlbD9PWIhHvNa8JLQwcWu65sz/cOKsqbmRmTUgAvbmPz3Z5FjdO75m3bdUw9qCK+3G/HP6S1c1ZRQjeWDfKXGR2UpYUroqgYZvUBsD6Wub4ZRBdJcCwK0ZRdyPJj9qbztd3dz4lGnIUHxhd7o/YODujqcL5qHphOrY5FSCAAb43lrYHuY61LJEL47C/Hqj3VtBHF6OtSDrgLoO9VZ2dBvpLJgZQDSeRCYGFbke4SoeC22/gKcKqdLXnQfggxrZFpRF3tVOUxII5C+LcbAQ20NZMHa2CH9TSqJ41pDEYOSHdEkV89aZecZZUHQGrLDOTbdqRMmZfPO2NXX8ykw9f013H83yGuiKAJdZtGJygak69xEM4LMTJxP9TXXOOWH/Oo58Wa+DKT9qJAsmICOUciaXX7NQ6UF1U12kG7rShcd6sVNRUR4pCl/f950bcJJRK8= 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:(13230022)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199015)(40470700004)(46966006)(36840700001)(316002)(82740400003)(110136005)(36756003)(4744005)(6666004)(8936002)(356005)(40460700003)(1076003)(81166007)(54906003)(186003)(83380400001)(16526019)(336012)(70206006)(4326008)(8676002)(41300700001)(70586007)(2616005)(82310400005)(2906002)(7416002)(478600001)(36860700001)(26005)(5660300002)(40480700001)(47076005)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:42.7802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41817502-b894-4b91-6bfd-08dac23efdce 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6717 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014856317793727?= X-GMAIL-MSGID: =?utf-8?q?1749014856317793727?= The link capabilities of a PCI device are read when enumerating its dports. This is done by reading the PCI config space. If that fails port enumeration ignores that error. However, reading the PCI config space should reliably work. To reduce some complexity to the code flow when factoring out parts of the code in match_add_dports() for later reuse, change this to throw an error. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 0dbbe8d39b07..8271b8abde7a 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -47,7 +47,7 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, &lnkcap)) - return 0; + return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) From patchwork Wed Nov 9 10:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261596wru; Wed, 9 Nov 2022 02:43:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM5HpmJiYD74UZLi1Y0e/7EcLdskPVeDvD8yYALHhH5P99lTz3OCxNDyjRo3rIXl22hYD4d9 X-Received: by 2002:a17:902:e88d:b0:186:c544:8b04 with SMTP id w13-20020a170902e88d00b00186c5448b04mr61265291plg.51.1667990592735; Wed, 09 Nov 2022 02:43:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990592; cv=pass; d=google.com; s=arc-20160816; b=wb2hHaXSWzQnm7O4hf/+S0XKzq81DZ89biinjHBlA/CGMMMsZaJtXmyFe4Vcp2VwG3 AsMMHi4wqf9FvqN185HtkoYfgBHiWRNisg1DxyGTlcjmuMRJflGOW5iWMMKt2jyjKo+q jkTR/oHIArhqkfUQjGOAa4tuLsHdK/+A/Z0vOaeRT5/f0szshTB8UDt51fOt78uADR2O XjvEae09Ed5vrRRyWymZZBYDHyiaUcUbbpif6CRGXPaf0KSKvZaEzGuzLBTzqTLzDnKd LMGzuMGgZATTGLyA/eVjYjl470aRHAX4zHZDvGaefZ4ueekR5lqNwY55Sjj2gfTG4+k4 KU+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=ZMmoTpyYX16q75qsgztEuZTUmmKvEyJpnZ3GKUfuNPKpFoqymL6Fe8b61363uBmuvw aG+e3FHTLzno06t2IGoAF/KSPFE039p2gfO4uWRRSSlJC+Oo+2Za3HTli97Y368HDGuW P0kjBSRWOP3DxxW4gKOn8UfvnLAjrO2C4sg2kvi0BwFOS7sr6Nz5UknS+6b/q61ZPPU5 /VF0JUErEtUFKYWuGyU1HayAm7wGhAup+cU+uQVQf5uJVp1l9iBANOjxd5WPFL12Y05M e3C/jZySePM9DpxoMsEydQ3S1oGWRaaBL07+CELoFTOjmMhrgr1P8L10PNlEtyDALWC3 nVDQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=vHd+1d43; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a056a000c8e00b0056282b4a984si17565493pfv.126.2022.11.09.02.42.59; Wed, 09 Nov 2022 02:43:12 -0800 (PST) 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=vHd+1d43; 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 S231200AbiKIKmJ (ORCPT + 99 others); Wed, 9 Nov 2022 05:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbiKIKl4 (ORCPT ); Wed, 9 Nov 2022 05:41:56 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2042.outbound.protection.outlook.com [40.107.95.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 023AD24BF5; Wed, 9 Nov 2022 02:41:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=USCOF7w3xwcxEoLfGpqF42/Xu41D/oAu5CVlQ+K3lcweACqHSF/mAGdmHAsL66BmA7vpDjrb5twzQGUZme4I7/YVaqR10XdhTyY956IHBb/qwdl+6LOlDzd4olG0Ph0XJ8YUTT3X8Gltmq+/X63xe5HRgKxRTtQjRJVyeM+OCIQypzBISj23DzLXL1ThIwC9TFYYPWrmJjN2Lp2giz5PX0WuDLl6kqLTP7OBwqQfLzCozZR/aXkdYGeCMLMdzWb0LKhzxxXujIvylInqOwjKvufQId2nYKSoAaBSljUd6xsI1buw/I6nNsEqgC/0ZN2szTi2D7P6QoAVfqtMfOD1Og== 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=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=Y9cOTi6WVx0pxiHSOcgYLTyJ9YENtpcJmMnSpVEUbFWKTfYZh81Ochtu8OvKa5ULxwRYzyK8cPr6LtwQZoETK5algqV6Gz8CNYt7YnH+rLs4N5BIO4Lifm4IixVIyBA9PvW9w6NwldLgz9Z89MkeE3pWSUAPgYKgk5+wJ09PXZkO75EHgK7IRNZJcb7J9byczSFk3/PsX+4dcTn09eD9MxVF3hPLVbXSbtvNrURPP/JAA1IdmQYPlFExTfSknQIenXIO6MlWW5RNMAvzY+XnUX/HyHXKRY7B/nOnxaOeMVkUN7EEPVudQwsEhfztmhKX/2YqsPTxOgIOzXtoTtya2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=vHd+1d43xMCPm00zPhiVwRtid5K5I6WXpwUB3e+kjRrGq14/17R3HBby8zzuQX4VqBV6EkjCZgI9udmU1GLtb9TbWYlCncsmS3mAD3yhWVWLhAOBO6u9g5MdpABloQs2Bm54CiYzQDGOukaA7IRvBF4nOXZqeAFT7f8ccFa/xjw= Received: from BN0PR04CA0063.namprd04.prod.outlook.com (2603:10b6:408:ea::8) by DM4PR12MB5216.namprd12.prod.outlook.com (2603:10b6:5:398::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:43 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::88) by BN0PR04CA0063.outlook.office365.com (2603:10b6:408:ea::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:43 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:43 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:38 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 7/9] cxl/pci: Factor out code in match_add_dports() to pci_dev_add_dport() Date: Wed, 9 Nov 2022 11:40:57 +0100 Message-ID: <20221109104059.766720-8-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT031:EE_|DM4PR12MB5216:EE_ X-MS-Office365-Filtering-Correlation-Id: e76397c1-a1ee-485a-0157-08dac23efe48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7zqoFqo/jzW42iUUSv6lS1sllGBlfaJDATCNc9zvjjUZfcTG408m4+JKnlVpOlkmBc6qMfPL6wMO+qx07ZssHQCJT4uVQ4bb4d3ekqJNnvgIakJcCXo5gxdksSa3MrImo2V/Q6O50QZffQbGaG1YPwIWSHdmkVnUtfpJrINmS2AvkmUEf8UpXx9XfZljLvReuycWcf4fXZ7ncLWc2vhMeIOt/f+D+csduUiz/dsoVTSwRiqVbC3oGmkI/fYWVybySJaCx8cbZLI/tPIxHf4SNMCFoCnzqhOCo+rRhbbCmW/TXqTAA1bxYDKGfYBvNw2y/+6Ik4tZqyK2b1tph6o3Drw0U4uPtczaflI4NK/RP5cTUosiz1T3Tl1UOyFyKPOTWONHHc0jZOlsXiCWllDsVxqKwwVETvB6TLbmBeAp0/iM45ZaDAGLPp5bQ92DAHqaxU2/+foqjT5T+NPlDdEJ2eQCi7lwn6CtB4H1GKMgulcNN+Gyd+AE4PPIeaE3z37viwGcrvOq5ak1gncZMMY4BfAwHSeKyPmK0tSVk2tofjVRe2hASReDLhf90ceJ6aQ9CTkb8YN8sKb47jOi+YRdBTdhHMAz297FMKPAoOYgMegYDpOnfiUlx3EHkmArY4VAgLP4iLhy3leCqc0cT1+9GbQM3WBCHSRSsAHyEB2bsm2ENivP6zYTjMy7fLFM/taejoDpBrI1NX8+URmgxMk9CPqfTNZCKalzE+bX3OH5l9wj4PfCpiooAPG7WyzZql5yx5uAjXdvkcq4PAmWqB9aj8WKUCjzz9fS/d0DonR0RP0= 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:(13230022)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199015)(36840700001)(46966006)(40470700004)(26005)(82740400003)(356005)(36860700001)(81166007)(82310400005)(8936002)(70586007)(41300700001)(8676002)(70206006)(4326008)(7416002)(5660300002)(110136005)(316002)(478600001)(40480700001)(54906003)(6666004)(40460700003)(426003)(47076005)(83380400001)(336012)(16526019)(1076003)(2906002)(186003)(36756003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:43.5770 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e76397c1-a1ee-485a-0157-08dac23efe48 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5216 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014903728555165?= X-GMAIL-MSGID: =?utf-8?q?1749014903728555165?= Factor out the code to register a PCI device's dport to a port. It will be reused to implement RCD mode. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 8271b8abde7a..667de4f125f6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -29,14 +29,32 @@ struct cxl_walk_context { int count; }; +static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, + resource_size_t component_reg_phys) +{ + struct cxl_dport *dport; + u32 lnkcap, port_num; + + if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, + &lnkcap)) + return -ENXIO; + + port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); + dport = devm_cxl_add_dport(port, &pdev->dev, port_num, + component_reg_phys); + if (IS_ERR(dport)) + return PTR_ERR(dport); + + return 0; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; struct cxl_port *port = ctx->port; int type = pci_pcie_type(pdev); struct cxl_register_map map; - struct cxl_dport *dport; - u32 lnkcap, port_num; + resource_size_t component_reg_phys; int rc; if (pdev->bus != ctx->bus) @@ -45,21 +63,18 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (type != ctx->type) return 0; - if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, - &lnkcap)) - return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_dbg(&port->dev, "failed to find component registers\n"); - port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); - dport = devm_cxl_add_dport(port, &pdev->dev, port_num, - cxl_regmap_to_base(pdev, &map)); - if (IS_ERR(dport)) { - ctx->error = PTR_ERR(dport); - return PTR_ERR(dport); + component_reg_phys = cxl_regmap_to_base(pdev, &map); + rc = pci_dev_add_dport(pdev, port, component_reg_phys); + if (rc) { + ctx->error = rc; + return rc; } + ctx->count++; return 0; From patchwork Wed Nov 9 10:40:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261608wru; Wed, 9 Nov 2022 02:43:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM7lInWFNJ4Hs2WVEmSv2aTfmdUwMoZ44eKyMwZVjUJFh9uFnkyfDqPjh+thdJTVUYn8qvcP X-Received: by 2002:a17:90a:b10b:b0:212:fbc3:e623 with SMTP id z11-20020a17090ab10b00b00212fbc3e623mr62552053pjq.5.1667990595625; Wed, 09 Nov 2022 02:43:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990595; cv=pass; d=google.com; s=arc-20160816; b=y58LS1EtRFX2ilPWI/HrxygGVQf4nKby49HN/FT3prhspSAEgqfB0GxLN2yUQ1TS8j vJefIVCumjt4FZvs4Qz938V7D+iDjM5HvZ/7ToVXzwQP4DkZ8RCjW9sk0JR3m9V227m1 x8TYteQNZjg73To+QL7hdb4fLElJgUfI2jVZZURJJ1bvjnVRuIVHYyJx7bRJ03Qr5FZn Tclp27ZKdzYWA7hg5X5LqPxdePZja+KLIHqKxheUMtVPXjQXYHORA6pWMkdtsaanKUuO aGV6tvOdI7g7/GvbgGPXr7QY3QSGWdelK+fTWT7QQUFp/+OR3WHlpB+OZVuxnTwwt6oP 6jIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=E0DU9rHmyABrvFb5wFrzUyXCzAMOufJrZzdM8sw53wg6E5qF9Nck9Iqqrqhcwu+viW F9UW1ApMaUr9JBPlGBRdLsIieTOxypKH+pyf5rOKbDBhgWLJNkU5lf5rp2qsMFHLqb74 XrFO+8JhKCEAaUA8Snl9BVdJkuVzeUyO64ywotCyjPN2RbDB4jLRy4Pxf+dvpoBwi5kT 8r2J7j0c7U61s+hKjVjZdQw7jnNliIUclX/XDq88b6GiqDCtNpKewnpUu0ivAwAo0gRz GCB7g6CuG4eZXdcQe89n2zZA4/sL29zOLSzsVy1tZCIpscD7meQh28Fmpf7KVImVZppo 9wxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=uvGKs8Gx; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056a00114b00b0056c94208afcsi18718553pfm.6.2022.11.09.02.43.02; Wed, 09 Nov 2022 02:43:15 -0800 (PST) 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=uvGKs8Gx; 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 S231211AbiKIKmO (ORCPT + 99 others); Wed, 9 Nov 2022 05:42:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbiKIKl4 (ORCPT ); Wed, 9 Nov 2022 05:41:56 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2065.outbound.protection.outlook.com [40.107.102.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3A1222A2; Wed, 9 Nov 2022 02:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Skqh2ro1lyYt/n/IT5XzZ92Cb/KdU5qOxprqrC1z+2kKGfPTYHFjgnVlIDBWylfU+eht2K3jSu0Fd/JQMf+bCrvgNOuhwy2LrvzN+C4IvkYpiH1kJ+34wTm4OcU+e0j+VW1oD3g8vSHSBSds+kQRKqqUi08xqML39EWI5ljiEm1em9pQHiJbiEKMNjISpqgn2yWIfbY0lUyCakq+jYZAXSt5NiPJ+3yfKsF9d/gXM52r2NgP6bSoHb2stjyy1KvF0HlpdBsotvE6Ap01MfFhxdwiPsauf3PwrBGvCpOQ74RTyBmXsmy/HnQDLCDWNF5hBdT7jij7RqXw31fp8Ew79A== 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=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=FqOr4sSUl9yS2KZx8xfdPkUo8+Pftp7K0RlMiifiewqkN+nFSZJqZ885OfZ7I6hdEdsASbcAYvI2pU2bNjw5OR5JTyqt8Aq2WTk2qjSVeTGOR+3k9BNJO6EziaIArnd+/82kTZh58O4vDdzVivVd7eEbfv9ftbhBVUqj6tg8MIKuOe2rO9lViHcsKkLaPXlstmBM2AargCWwYx90aYaaoKjea7U1Q803aeIh2Uloc6RSOH+s4tgwC5uNTE2FALGewyOR2ft7XSYvNBTrvM7SYtVxAuaDBiCTPVWsGTAzdMmnIo6QwtCeVIJxYdPUK7Lg4J1YAI3KvfVOcfN1M2YNdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=uvGKs8Gxtarg4rtxIMvXQQRMOX/VcLw61lVGHH3vRoS0Oq4hYFvvUV8Q59yJW4EX8iwIJAUDTB5UBbdp149Nc23TTpPB2KW6j3jKfrMhAaPBEPLI+FX2Ds3FA0OLVpyVEFlzHlRDG8hBiHhYY5AjfZI+HiQvCBfU8TQnMIo+2eU= Received: from BN0PR04CA0088.namprd04.prod.outlook.com (2603:10b6:408:ea::33) by DM6PR12MB4481.namprd12.prod.outlook.com (2603:10b6:5:2af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:45 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::cb) by BN0PR04CA0088.outlook.office365.com (2603:10b6:408:ea::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:44 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:44 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:41 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter Subject: [PATCH v3 8/9] cxl/pci: Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH) Date: Wed, 9 Nov 2022 11:40:58 +0100 Message-ID: <20221109104059.766720-9-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT031:EE_|DM6PR12MB4481:EE_ X-MS-Office365-Filtering-Correlation-Id: 0287038a-b35f-4394-b974-08dac23eff06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lEsqxFwAYunNQNz5kz9lhhq6GukyPJ3BoB8+i+cC4Cj6HdX9JooaRTJzpNM68r71lXzVK5knrM7mHI5gvK9fAEY6jTYu5EaEvBbxLirPm/kDmIkFywkhcAkX6pmgahWPdvKcW3XFlY5YGk3pvN+pJZibRe2KycBFOwJM0+Osi9hrPxafkZ7V34fMMbTJVLRS15vdy3e8yS3n3gb0nAvrExpycrkS/zOm8NYtY86goCj2LDO5yIyM3HX/sMqj1N71xGhSYgJtA3tYvXvPNiVNaF4HSvcbCSDlWlsTwxvJco7WwcGL6vdvLRAAKP5Ki5pPWz81TPHHiQKn0XKHb2Vg8QRVstfxXmVVzNRW4Mdhuusog/JYdRlzI7Z/3zGZ+3jUWIL24j2muQ5oPZj5C+nOlgvxCWpvC4lcgs48sfBlMhB7ZEI2/hxCKVundMtrH3x/JyoBC4+hM/wm1VjfRdmM5V7U7zRx0uYCTAOjLTcM0MhUrRLQ6XXsIiG4nGzveATg/PSb403XhVXRrEP0VGvpbpFUTTq/KN0uHpLKxvAs7yU7ur2Z1cJs5z0mWfPl45Y+5gAeTJZma9eNLyzIJWl5LSSDyFQOxal1sL6Wmed4c/PdsrnyNcHwywuCQx9V/S2oVWd7DtCuQ0pDwH1LcKmIsVyYCGnIH7+hIZeESh3JI6Z67xjvYESUvGn1snDcPwRL6gvfR/VxOZTHBoQzHt1XXycnDNOVHcQ+ebrVr2Y3DuVTbjnM0HWfvSe9o8Pi++xjrIJovv3zwpB4Y6KiqQ/U2c5siCTuwAVnosZKMCQdWAa/vhDblSFFg0JsQYir+WdG 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:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(83380400001)(47076005)(426003)(40480700001)(2906002)(478600001)(81166007)(356005)(40460700003)(36756003)(82740400003)(336012)(82310400005)(36860700001)(26005)(1076003)(186003)(2616005)(16526019)(4326008)(70586007)(316002)(8676002)(70206006)(41300700001)(54906003)(6666004)(8936002)(7416002)(110136005)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:44.8269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0287038a-b35f-4394-b974-08dac23eff06 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4481 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014906791973594?= X-GMAIL-MSGID: =?utf-8?q?1749014906791973594?= The PCIe Software View of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP. Its downstream and upstream ports are hidden to the PCI hierarchy. This different PCI topology requires a different handling of RCHs. Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH). If an RCH is detected, register its port as dport to the device. An RCH is found if the host's dev 0 func 0 devices is an RCiEP with an existing PCIe DVSEC for CXL Devices (ID 0000h). Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 667de4f125f6..a6b1a1501db3 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -48,6 +48,37 @@ static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, return 0; } +static int restricted_host_enumerate_dport(struct cxl_port *port, + struct pci_bus *bus) +{ + struct pci_dev *pdev; + bool is_restricted_host; + int rc; + + /* Check CXL DVSEC of dev 0 func 0 */ + pdev = pci_get_slot(bus, PCI_DEVFN(0, 0)); + + is_restricted_host = pdev + && (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END) + && pci_find_dvsec_capability(pdev, + PCI_DVSEC_VENDOR_ID_CXL, + CXL_DVSEC_PCIE_DEVICE); + if (is_restricted_host) + rc = pci_dev_add_dport(pdev, port, CXL_RESOURCE_NONE); + + pci_dev_put(pdev); + + if (!is_restricted_host) + return 0; + + dev_dbg(bus->bridge, "CXL restricted host found\n"); + + if (rc) + return rc; + + return 1; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; @@ -91,11 +122,15 @@ int devm_cxl_port_enumerate_dports(struct cxl_port *port) { struct pci_bus *bus = cxl_port_to_pci_bus(port); struct cxl_walk_context ctx; - int type; + int type, count; if (!bus) return -ENXIO; + count = restricted_host_enumerate_dport(port, bus); + if (count) + return count; + if (pci_is_root_bus(bus)) type = PCI_EXP_TYPE_ROOT_PORT; else From patchwork Wed Nov 9 10:40:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp261786wru; Wed, 9 Nov 2022 02:43:45 -0800 (PST) X-Google-Smtp-Source: AMsMyM6bz/6TiaWmoHyA+ygE+SCJse17QEdQ3kli391k/RXBcIoEkbi40nGun8kiXYHq7SWdwZoc X-Received: by 2002:a65:6e4a:0:b0:438:874c:53fd with SMTP id be10-20020a656e4a000000b00438874c53fdmr52713328pgb.355.1667990624758; Wed, 09 Nov 2022 02:43:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667990624; cv=pass; d=google.com; s=arc-20160816; b=DaP3A4sGVl5RUyrfeaZo5b48B1XV5bgt5HTVP5i3HlU0mQ7XijjxTNSmcLoNtQDkKP GBLz8Qvc4OJ4dOjf6W50hSLy1kzJlntKMnEcY8xx0ncaPkoGQLx5/Rmc6aQPpNeyye3x 6WhTOZtxA0uQjRj62q55x1UdJAoW4GmtOckc6yHDLx2FZl2p4kAWHz1KFCg0qZ3MCwI0 HHDCSDI+cIZsdAgU2vqgXiSfQ5VUVlzd+3ABvbCBtYUZ11y+JAoA95kNoO9hr0vEwHhs 3B7SFeDlVB7RBr+2HqwT4dgAyke/fuDj67BNIS8BVFG5hfYbs+2a4qe+Wir4FQWDrvDh aMAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JSIyl6waVDcHfCsJjAro/YA6c3cWSEtPh8eZJxbZJEQ=; b=inYry6icVZFkzQBGkRMbiAif6UbnvjweeR16f8KBmxU68yFhPEcBPh5eUDxXFJvW1+ 3DdjamEGfYAHORrVgCFWtT1i3E1pzhnA5mRMux9CoXJdOlTxd11Pk8Mq5OWX3dyTvl+o d+AeLfSiAGtUfEduHUn+1x+xRmaYQjcOFQczc1ODnyU8r0kO+W254+n0O3z6BM2LsTtD A02z6sOtTs/zMAqbje1C2u1ORPUWBaPxMFBjZsHfPMX2e0QC6zRgUMtDTZrc1KpgPTMJ ccd9C8OmsTNNQX3GeiIoDebW4zo5T3BlDkf99trlryhQ7dY9gWxA8csgi2oWH64lZPSD 9QbQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TunuBCBC; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170903024800b0018863062f04si1611264plh.432.2022.11.09.02.43.31; Wed, 09 Nov 2022 02:43:44 -0800 (PST) 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=TunuBCBC; 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 S231162AbiKIKmQ (ORCPT + 99 others); Wed, 9 Nov 2022 05:42:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiKIKl4 (ORCPT ); Wed, 9 Nov 2022 05:41:56 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF13B1BEB6; Wed, 9 Nov 2022 02:41:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZTHL5XDY3wRKmLDAGeyf3wJ8QWKYFapm93v8vWFJmILs+E99sL1DgXDXDp7FL9PjFZbCbZ4qZRdHMZT7tLzSA/EmGRAxQQ6CTRU4hwk/lKX1ARdV65VOlS4s7plC3nkgsj7IWBzQrZ+rDswqYrLyhoWaeS4Rnr7ZaN12A09zEKmEfEuhKvKPvGEarcNbmTSvoWPZcsea6u5d6Nkcy9LS9rREmlT6aXbLtzPTcUgGuTZY66POwuhxZaFQUwbKalB9+8o5g3hbUnrJgiQt1cKvakgxQ0td4lW7snm1BARXvJhqEV6SZvA/t+u6rFks10vBy43sfwLiBbDJCxRC/NhCw== 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=JSIyl6waVDcHfCsJjAro/YA6c3cWSEtPh8eZJxbZJEQ=; b=dgg340pH6rygpPKbX5HJMzvBcMSNjLiFxP9FVfHOTBDKwhkPMQKB9Ta8bK7Llgwpct+lhoazgoPXhRQpw7BCPr4SdmE9OTtM8mkxl57jEvtA/erz5VR0vss4GFEcO1vaURmDxinr4EeiNZW71NzoGppj/cvWYQDmzqWIgWjxbTwZF7+V2LQgF1urdRl9dVx1mCUGiQ6/KfI/IcAfINzgIoSaR3iP0ZlEmrvC1WwRtNbyqEp5CWfQXLwQQt8Vxu865pa6sTHaezSFviE1T061WfWnlUebQ/DPaypPOigGr+/91J1CDJiG0JAOv+tfUF3nHrLzoeL6Zpby9V3gKiX1AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=JSIyl6waVDcHfCsJjAro/YA6c3cWSEtPh8eZJxbZJEQ=; b=TunuBCBCEwFBrYJzzBZqPHiIblSFEFnA20gsHGY0ZX8FIDnh/nYjAp1oA43RoGsI7hKQVqAscztbYbFLPQaTWHyXEXrqwIbMSCHGfufrgwSzaNjGwl/lDC16ELMFBAh2ePg0F3rapd14wZwB4AKYQU5VhOEhKijS+noBT4FY7Fo= Received: from BN8PR04CA0035.namprd04.prod.outlook.com (2603:10b6:408:70::48) by PH7PR12MB5687.namprd12.prod.outlook.com (2603:10b6:510:13e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:41:49 +0000 Received: from BN8NAM11FT105.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::ab) by BN8PR04CA0035.outlook.office365.com (2603:10b6:408:70::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 10:41:49 +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 BN8NAM11FT105.mail.protection.outlook.com (10.13.176.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 10:41:48 +0000 Received: from rric.localdomain (10.180.168.240) 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.2375.31; Wed, 9 Nov 2022 04:41:44 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , Bjorn Helgaas , "Rafael J. Wysocki" CC: , , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Dave Jiang , Robert Richter , Terry Bowman , , Subject: [PATCH v3 9/9] cxl/acpi: Set ACPI's CXL _OSC to indicate CXL1.1 support Date: Wed, 9 Nov 2022 11:40:59 +0100 Message-ID: <20221109104059.766720-10-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221109104059.766720-1-rrichter@amd.com> References: <20221109104059.766720-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT105:EE_|PH7PR12MB5687:EE_ X-MS-Office365-Filtering-Correlation-Id: 323ab923-8b23-4f2a-e6da-08dac23f0151 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fax13Wjkm/oqgVNzJHzV5ilUftsAMVBjzQzFccCVDSIBzUK8KXCGEXouyz0bhZTiO6k1UIAr34pRS81P3/8Z+Gwqw8FKI2umx6DDI/ALw7r8xSvPa6zK8+mbtk6X0KKDRCwHuAjggwwnVcNsvsVoOsIcZYUN7Djd7/SBg3RTi7TIsJo2Q+EThhj/cVwwrZX9U5g41nJc1H28JLCQxnmoIeSEIhhn32mHEu0Hi2KYaQdFaF2SWEkMalgeiLx6UFf694/RlQJm8VwMTdZoWaiMheYJ+0vH0AHDnXMT/r8l0dGfjOeJdlfB1+YNOi7W3g3w7uphQcfMWXz0Fg12QHlyRJ5mtIlxuEiQx+68asL9vOgTjLeq1UV9j7dCtbGzgNnWVnhfUGTvcFJavfg2SDito226JWc7etMKkR4etxMtw85NHAazfnvLm8BzTDleEQsbuPYj9lgc1CgkKS20ujBzxX64nip7TO6qFo5gkmoF8TRa/QDd/7QWmx7JtT2wtSTUwSIw1GeOPRS2+CPTQX3SpMZCDumDIgXd99JOGBb/gxD+4chFtK+38aVdXys6udutUc8WW4bRwV8eb4e7mibKmddgi4p2WshACw4oT7eaz+m1M+My9Z2o3dKxR1kcdgZfS0yI9l5RFM7llnsO0Cfp1J4pqoAkGnxmPTv4LiYWSnWBAwJ9TQ0sqw2McV35cK0olLcdfha/1c37iVDUWcYhJtO6mmhF8jd4tAL8BtE6FqUrQUg+Zn6k7Nhzc8ZpcFOhOjD+IeoeYHEy4n9lX3AlKg/2AGrI1IJmwgaWNo9hfwyOZcoy9fJrUEcROalNfbNf 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:(13230022)(4636009)(39860400002)(376002)(136003)(396003)(346002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(478600001)(54906003)(81166007)(110136005)(6666004)(356005)(316002)(47076005)(2906002)(40480700001)(26005)(4326008)(8676002)(70586007)(70206006)(82740400003)(7416002)(2616005)(36756003)(8936002)(41300700001)(5660300002)(16526019)(186003)(1076003)(83380400001)(40460700003)(426003)(336012)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:41:48.6750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 323ab923-8b23-4f2a-e6da-08dac23f0151 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: BN8NAM11FT105.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5687 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749014937183573658?= X-GMAIL-MSGID: =?utf-8?q?1749014937183573658?= From: Terry Bowman ACPI includes a CXL _OSC support procedure to communicate the available CXL support to FW. The CXL support _OSC includes a field to indicate CXL1.1 RCH RCD support. The OS sets this bit to 1 if it supports access to RCD and RCH Port registers.[1] FW can potentially change it's operation depending on the _OSC support setting reported by the OS. The ACPI driver does not currently set the ACPI _OSC support to indicate CXL1.1 RCD RCH support. Change the capability reported to include CXL1.1. [1] CXL3.0 Table 9-26 'Interpretation of CXL _OSC Support Field' Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Acked-by: Rafael J. Wysocki --- drivers/acpi/pci_root.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index c8385ef54c37..094a59b216ae 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -492,6 +492,7 @@ static u32 calculate_cxl_support(void) u32 support; support = OSC_CXL_2_0_PORT_DEV_REG_ACCESS_SUPPORT; + support |= OSC_CXL_1_1_PORT_REG_ACCESS_SUPPORT; if (pci_aer_available()) support |= OSC_CXL_PROTOCOL_ERR_REPORTING_SUPPORT; if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))