From patchwork Wed Aug 31 08:15:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57110C3DA6B for ; Wed, 31 Aug 2022 08:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbiHaIQ7 (ORCPT ); Wed, 31 Aug 2022 04:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbiHaIQz (ORCPT ); Wed, 31 Aug 2022 04:16:55 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2084.outbound.protection.outlook.com [40.107.95.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE78C59C7; Wed, 31 Aug 2022 01:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSXP4QQtj2rJGr37s4JlXCz1SzLR5e0t8z3Y/9H0Ox4igvLPlfsn0uz03dEmdMJ2h6NvC39OrwoieUQis8rX97pvQBjboPoebHiF/2+VZsBbNCnyxFQA40SJAeA6q31RBmJL/Y7tIGXQghIfU4jwl4vJ4sXgIJRk7EJeJNuXX+C9QPNSIs79haZVRAHRgD4FnassI2z3KMze84eaOQkVdeZgCg8dMt542/gYgQkDyJiDU+xtRgO+kOPM5THiXGQGWRJIHqySvswWgfWgLx1hxiJCCZVBtNhDLm3i7iR5kyKSnLLM+rITxOoR+6toB6UBwr/UiqhRwzYL9681QxYfUg== 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=hx+YIdjMjwNEQVovUFvkwuaREKypEdzCaGtwbgDT9zA=; b=KWFtMtfRSuX8y0pECPiNs5NYKUZSHUuTU2Fl5xbLd19VfmnOyDD6MqTTeajPl0QftaSvhersnjazYRhTLu1DI31kDjphGN+nZfL9rqyR0b5VKjT5GX0m+Qh4nEZtY3m6FcPkw2Bm3Kbap5lbaYIP/3omSsDyVClhXhFw/bODJh7JLuo62LCBPa/QK//PQtkzoTWzWGpjhX9MEqZPUQy+v+SPNYzm9x8m0y2HTDb/zyCja5Wg7ks5ycZ++JUwQ4bLpAj8o0ebevKxMSFqpZCZzdpT1YonAWKiGvfEwSrJobEGZ0POTIOdAw4RODHb9wWD6zQIjizuqNM3SuSrly1Nuw== 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=hx+YIdjMjwNEQVovUFvkwuaREKypEdzCaGtwbgDT9zA=; b=GBWkzdJmCxQkg+nRXFmieTWDBh0vWRGIgDgUvx0znjfFU2PfZe2P15C7hV/7NWS89/6zjb4WuulTjxCqpDNjvtUB0ZBVARfcZaYNEg+g4eG19T3U45+HYZn7fu3SoCmspMvLktiXa/GrKHRX6Qv7FXFKHiKm+9adKYSIjeQ2X/4= Received: from MW4PR03CA0281.namprd03.prod.outlook.com (2603:10b6:303:b5::16) by BL0PR12MB4849.namprd12.prod.outlook.com (2603:10b6:208:1c2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:16:45 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::e5) by MW4PR03CA0281.outlook.office365.com (2603:10b6:303:b5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 31 Aug 2022 08:16:45 +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 CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:45 +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.28; Wed, 31 Aug 2022 03:16:38 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 01/15] cxl/core: Remove duplicate declaration of devm_cxl_iomap_block() Date: Wed, 31 Aug 2022 10:15:49 +0200 Message-ID: <20220831081603.3415-2-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd3bffab-9b27-4544-f7de-08da8b2924fd X-MS-TrafficTypeDiagnostic: BL0PR12MB4849:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qSZGZjDjv0ihQDt8wqQUo5rq0Lh/8+/YOPdAHcSG/jP9momyaGzJtOeY6EDUnbMHe+nhiKHeeqpcfumHbD9RTw3+bvwKBSBxqm8KX8ItMx6ILh/ehEIhKIZ83t7Cfrl7M5SsKqy1rnZ2cRt+aBG6EgNy/wbmyi9CtRK1tGj0v9Ji4h3cMjmhdbZz7JxgU0KtANV7FlQKuwTsda6aAVNSQsFtXTfvg2/mlFiSQAGKg1qF49HMWwmX+v6yV+hWf24n5XCIFf0lwYme8LVL0ddzWQdef1aCZhhDKifSiQzFhkyMZ/hS48oePwq1ANqVFYaBbutStDkhp8XSpcWdQ22MVtnfuH7j5k/cqVhkGkdJcn/2PlMzoivbAcH4lSde9IJjRQjtj8HA3seOSvq7cQPfHx4aiKjTqoaRTJbbFVrqf7BAAl8QOtWOtUynkm4CLOuBV6zTOe817GTGp3q0B9zIPzvgruleSWsvQTOtqqajfdJQa6FeWy2t3wQC0UWTbtxJ+scMV5jElIBN0aQWOmR2h4kcXoXMs8qzz7OvWsG5BnJsvajddQl0HMqDwHgfKnfs9iAnIZnnFjTGM0erJm3g6qxm1EqAGgKTVlRYRDAyzMC4WqZVTzgUfxYMTF1kHS0aaavpDTXb/QbZLNX0H0Qv3qWhLdsTcOIUkTwG55hFYUEMTxwRsUDjXNF4qkD/lCboSJyRQTnHd19Pwql7MBWR1EsIv+bPBfNJdAogNArk50/3FkaNCsVFTmvA/H2dDTlJaRXp3rpVhCW4hzpJ1lx4ZfeLno5A0IWOQI98MhOm8GNHdd/7pP74YPNTS9qfpyV6 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:(13230016)(4636009)(376002)(396003)(39860400002)(136003)(346002)(40470700004)(46966006)(36840700001)(426003)(47076005)(26005)(186003)(1076003)(336012)(16526019)(2616005)(40480700001)(7416002)(4744005)(5660300002)(8936002)(36756003)(478600001)(41300700001)(6666004)(36860700001)(40460700003)(356005)(83380400001)(82310400005)(8676002)(4326008)(110136005)(54906003)(2906002)(316002)(70206006)(82740400003)(81166007)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:45.5015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd3bffab-9b27-4544-f7de-08da8b2924fd 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: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4849 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The function devm_cxl_iomap_block() is only used in the core code. There are two declarations in header files of it, in drivers/cxl/core/core.h and drivers/cxl/cxl.h. Remove its unused declaration in drivers/cxl/cxl.h. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron Reviewed-by: Davidlohr Bueso Reviewed-by: Dan Williams --- drivers/cxl/cxl.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index f680450f0b16..ac8998b627b5 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -218,8 +218,6 @@ int cxl_map_device_regs(struct pci_dev *pdev, enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); -void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, - resource_size_t length); #define CXL_RESOURCE_NONE ((resource_size_t) -1) #define CXL_TARGET_STRLEN 20 From patchwork Wed Aug 31 08:15:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960515 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A01C7ECAAD1 for ; Wed, 31 Aug 2022 08:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbiHaIRC (ORCPT ); Wed, 31 Aug 2022 04:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbiHaIQ6 (ORCPT ); Wed, 31 Aug 2022 04:16:58 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A23AC59EA; Wed, 31 Aug 2022 01:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XqKowGid0VCHW2HI06KFe5KIiWOuJeIQIT5jsE7XWw3M9wMwJcaeE/olyYmcZCKqDe2x9DsAHUN8cOxlnUjgA74NDBzwaQDQgfifNTwlZYxf8UgM6Bw3CydaHphoXGdkEyXUQD6AEqB17v5oNGSarJ822f8b58f4m2QJbtTPekBLnss5Pg42z0sDkQoGST+tmSQM3QMZLyer9pHr4SuOFzAr+8fhO7B80xURsQV91JTNFTMU9o9yn2d70+BfMxihJT7O8LolZnIGOOX5Za6UJaAMGfGf8VapI+cNJqlpCpmGBYHAjWovtOi3HX+Gk4WqefH/2EQKStRqwm5WFi3ggQ== 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=ej+pItJOBPaWy64t4W0XWbAdeK8lWkJUJ44Rq1Ur+vo=; b=kHfQLEe8zjagZ+GMqDc9q+CFONOCZlLlwC4exOOEAHezu2sdInt7bM61Wb0tevVS21qypm/kaaU56ZdRLjbiuQgnCE+bcDd03arX4yZw+zRhL0MVsvP7kWTHXdp246Ro6YAboFiqaugAd3Y3ZnCo5yno9/R5mBgev8MK8YZ2OcuWrU/tX//JxJYv9sGoL5swA93PECRx2pGpJqTHmx/1gpeJTrKfnV7FE2VafHs4odhqcKrQ/8ReOU6N1J+8v2tp4xWswcLMGgJR8MEvytlJPepfb/kRZiw0SsMLmn+YKVwgKOxt3Xb2ZZl2R1zwXeeKIsqEGOI7+1fF5HkAJa5jmg== 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=ej+pItJOBPaWy64t4W0XWbAdeK8lWkJUJ44Rq1Ur+vo=; b=YZuAl+5iC15Q4wfp68ZH8Z1xwjug57yBldkX25GSTGaz4M5cqXjHaV3IID0v4Eq1D7jhu3BGXPNK0ZNBurrEj641mfnAVu6NQsH5yBjbOx/2+Xwvp3ACsrqUY4/jbrEw3arLhv6J52JySSRnm/CBtQOtDUzTzhJ/au/oI0IUoXc= Received: from MW4PR03CA0279.namprd03.prod.outlook.com (2603:10b6:303:b5::14) by DM6PR12MB4266.namprd12.prod.outlook.com (2603:10b6:5:21a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 31 Aug 2022 08:16:48 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::78) by MW4PR03CA0279.outlook.office365.com (2603:10b6:303:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:47 +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 CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:47 +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.28; Wed, 31 Aug 2022 03:16:41 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 02/15] cxl/core: Check physical address before mapping it in devm_cxl_iomap_block() Date: Wed, 31 Aug 2022 10:15:50 +0200 Message-ID: <20220831081603.3415-3-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a524fb3-f5cf-429e-bada-08da8b29264b X-MS-TrafficTypeDiagnostic: DM6PR12MB4266:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FOBIN3QzXOpL+o11i7RHsCyH3xqLnq+makXie2cluk0Oev4fvU9sf7FbJEjVZ0neWFa93s/EitWPfmssYi5nja4Oq9grd9cpSh5EfmMfR3oZ/T9qYZA5PPWuaVY5PlCpOROQ5/OF+fDX9lg85VYvvfNPHs1G962VVAezxlaMdcRrs3/ziIXSkJUR05PH+m3kdQNEbxzrMWa2UhqFkgUf+KOZr63h6epST2ht8IN3Cy2wCF/9xP0J3AxCEv5334zohlixY2EdJsL70rcx7YyazdjHT4qlVdU6wpGYGN0opgLs3ogBWdFr5vmBowOhXFhGyY3q4S8zokpTBlo0cicJTKtAuxKaZLn+ps/BtuZHx9TSdfojAFZf1xlsShSCehRFZNO7oFrNCXkmXPbFCNt8iDapTo+8Ede0kJQt8dJWl3TjVTQrLNpC8mYys4ySA2nfthLhN0Kg1MvRYp5qqtAPFEIraVdoV8mfi2lReDWkka15rfdFI0n7q9cfrPWqwOXXT8UHnvk3U7/T3tx6I9aLjkwMGoRLetidet5x3kqquJ8wWUcXpKUaPmXzh6ACMCyUmeircQpPuDG5B9uMvnzQr+S9iKB8NF6hwlde8jcMmrqkfbXWsNV4Cw1KBl1xklA5Ql4VWN6roMV7+9W8BS64GPFlD4Y4oz83f/Jg42LIp5Zb+jo8LTzv/YgMXiZrt6CKF+tPMJaU7ozCP70L89qmeXTLp7IHpKwlyCH5J6iUVLFK1h1IvFDx3tULewz+JuZ1vw7x1pY5K5eqMwE7oOPAkQYvqwx4kv4v3wikB03ByE9WkRLwU/6/MYsLdeYPIvnq 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:(13230016)(4636009)(39860400002)(346002)(396003)(376002)(136003)(46966006)(40470700004)(36840700001)(2906002)(82740400003)(82310400005)(6666004)(2616005)(426003)(47076005)(26005)(83380400001)(16526019)(36860700001)(40480700001)(336012)(110136005)(8676002)(70586007)(40460700003)(4326008)(70206006)(54906003)(4744005)(186003)(81166007)(316002)(1076003)(41300700001)(7416002)(356005)(8936002)(478600001)(36756003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:47.6888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a524fb3-f5cf-429e-bada-08da8b29264b 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: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4266 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The physical base address of a CXL range can be invalid and is then set to CXL_RESOURCE_NONE. Early check this case before mapping a memory block in devm_cxl_iomap_block(). Signed-off-by: Robert Richter --- drivers/cxl/core/regs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 39a129c57d40..f216c017a474 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -165,6 +165,9 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, void __iomem *ret_val; struct resource *res; + if (addr == CXL_RESOURCE_NONE) + return NULL; + res = devm_request_mem_region(dev, addr, length, dev_name(dev)); if (!res) { resource_size_t end = addr + length - 1; From patchwork Wed Aug 31 08:15: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: 12960512 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FCB6ECAAD3 for ; Wed, 31 Aug 2022 08:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230516AbiHaIQ5 (ORCPT ); Wed, 31 Aug 2022 04:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbiHaIQz (ORCPT ); Wed, 31 Aug 2022 04:16:55 -0400 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 A45FAC59E8; Wed, 31 Aug 2022 01:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KIznUkMvw4+JyhRyhDvlGdH1TeYm604zowdNdgBMvgdL+g6boJ374G6m9voJ5k65o4tjkuYTO/n8jXEiFzlh7/gDFWN+CpIcMVktZ8FfhYSsf5mqpKR4IRQ91kd4/86cHp05OpgJCN6vREOy0Cr2y2wZKsWCd+1anLJ3EqmaHJ6DuXksc9oUNNGxoXtGTfaAptH+Z6+G9iW2HKMwjprowtgHno0S4e55CP3k88GYKX7Uo02gINwVnQZpBVKxFM5oe4TCHZVd+0HbyBWQ1SvtBgsnKs2A4YWiSknJYXDh5Ek+SCVLYLXbR8gzXI7TVIhZqPJT4ydw0BEfS48YssDW1Q== 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=g7OsswjDIf269tkBH66DhqIXK/bbAziXiPPDXTXXjmw=; b=fSqWUrn73bX8/8vA+cHnWLdaXoqnTQHtMyyzjmvyFIYyrsLCxnT59U7hkgccwzRQ228JM8WJ698dYH7BlAZ1KoTO2uKcDbjzU7wJU53qZ+r4qrDqbCqkYBcZodoEURi1UgJCPKoAg9imcRfCU+qhJQ8kRIK7waukBeaIslBPgng2R87KgvR2Z4EK1ya6CoZ+CkkfjH6MwaGvaAnSViO2IIp8eq3b8e38Sfu1CPKbm7E1YpnZXePh3qqi1etrC77ZeJtpedAQF19F7AfljUudKxzcIYt5kz/9TlIUaCtlv35AsrovPDwiYk3LBEbtWlVwtv8MLA4PxiUgmqKwKi2N1Q== 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=g7OsswjDIf269tkBH66DhqIXK/bbAziXiPPDXTXXjmw=; b=z5tjTO8tzuwgjMMG6Jh0S8F2BsFVQN90/Gp6Tr+7+lO9+rfxHnSdJArB99gs1ftgLj27XH53TEv05GCbFPp8IobxqOSa7+PM9CJJmg/dt6XJAaPy0T3t2fNSk9pkx0gxLFyHoRB1jKXEl3+VC6sBpunzo7kbkfpkka+RFOtxH7I= Received: from MW4PR03CA0021.namprd03.prod.outlook.com (2603:10b6:303:8f::26) by SA0PR12MB4431.namprd12.prod.outlook.com (2603:10b6:806:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 31 Aug 2022 08:16:48 +0000 Received: from CO1NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::ed) by MW4PR03CA0021.outlook.office365.com (2603:10b6:303:8f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 31 Aug 2022 08:16:48 +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 CO1NAM11FT100.mail.protection.outlook.com (10.13.175.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16: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.28; Wed, 31 Aug 2022 03:16:43 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 03/15] cxl: Unify debug messages when calling devm_cxl_add_port() Date: Wed, 31 Aug 2022 10:15:51 +0200 Message-ID: <20220831081603.3415-4-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 234b2cd0-d6ec-4dbf-1f72-08da8b2926a2 X-MS-TrafficTypeDiagnostic: SA0PR12MB4431:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X1gJPzFqMy6y/ZdofZ85yCDOWhn4IxvZJL1zbHsKyXxZUuxC7QNxtIUGDu/STvljSXbJnLl3AAMslXL15JeJ9oWGReYtPyON49fgWpB3IBim1EpBEeVs1YCRE9INPcvbs/TgWwOnZhZUmkhcGjs5cgM2sPSLsDoZ9Ylt7Iszz32v4PbunngNf1v/VRrIhNrDBBpKKDRJnC7nKlEO64d7Tm4grV0DgPfAU7/KhhMUMsTJT7zNRMHmc3wIFz85yOSipoBGKj9v+e1cHn12BNru/zkUuvB7X2ZY9yshUFL+PXays0l597DPNf+XVi0XlyoYheqfJpPhgTaodHl17rK3y7k/t0fH4a3nKduJS67Bx2Ec1v8j+JEfPVCyLosy2B1H0blBxDDGUvjC/vp/q5WNZHq3WmYJraELHyJgU6IcGKvghWdvbzqik4mCcm0PVaUSV9yS/DWoXFbU4lUWatj04fbQFD06EPQexDeS+loqDVM5eVz/lMRafvLE9RHipP8fnFq4C8AW/9XFg01fQhMxLe3lm6n0G3laKStbfrTGwLqVDurZxW/4LuZM72TDobH4XHSZ3y69QFT+WDjxS8o4uTD11Ci/uiUiqi54AkH75iazUrcd8cT7Sl0on05cYh6UkrzCpOuUEFff2dg83PTVyy4/o+9uRUxsrwUWmTunKncawEzGc4npAIQiGYj+PKZOGIYpFR8P3f2Ufj6ExKef2XZ/qb2l5wAigBHLqPwu5ziYWUtoGns7dzfCPvjZo2a0q7jiDM8ghmNJmJxOBZgl8ERWBNZw+IgC+NEWzyGY0bGEWsOiAJF4SpWfbCkaI5He 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:(13230016)(4636009)(376002)(39860400002)(136003)(346002)(396003)(46966006)(36840700001)(40470700004)(26005)(6666004)(426003)(478600001)(16526019)(47076005)(83380400001)(336012)(1076003)(7416002)(186003)(41300700001)(54906003)(5660300002)(316002)(40480700001)(110136005)(82310400005)(40460700003)(2906002)(2616005)(15650500001)(4326008)(70206006)(81166007)(8676002)(8936002)(70586007)(356005)(82740400003)(36756003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:48.2550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 234b2cd0-d6ec-4dbf-1f72-08da8b2926a2 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: CO1NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4431 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org CXL ports are added in a couple of code paths using devm_cxl_add_port(). Debug messages are individually generated, but are incomplete and inconsistent. Change this by moving its generation to devm_cxl_add_port(). This unifies the messages and reduces code duplication. Also, generate messages on failure. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron Reviewed-by: Davidlohr Bueso --- drivers/cxl/acpi.c | 2 -- drivers/cxl/core/port.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index fb649683dd3a..767a91f44221 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -220,7 +220,6 @@ static int add_host_bridge_uport(struct device *match, void *arg) port = devm_cxl_add_port(host, match, dport->component_reg_phys, dport); if (IS_ERR(port)) return PTR_ERR(port); - dev_dbg(host, "%s: add: %s\n", dev_name(match), dev_name(&port->dev)); return 0; } @@ -466,7 +465,6 @@ static int cxl_acpi_probe(struct platform_device *pdev) root_port = devm_cxl_add_port(host, host, CXL_RESOURCE_NONE, NULL); if (IS_ERR(root_port)) return PTR_ERR(root_port); - dev_dbg(host, "add: %s\n", dev_name(&root_port->dev)); rc = bus_for_each_dev(adev->dev.bus, NULL, root_port, add_host_bridge_dport); diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index bffde862de0b..8604cda88787 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -666,13 +666,17 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { - struct cxl_port *port; + struct cxl_port *port, *parent_port; struct device *dev; int rc; + parent_port = parent_dport ? parent_dport->port : NULL; + port = cxl_port_alloc(uport, component_reg_phys, parent_dport); - if (IS_ERR(port)) - return port; + if (IS_ERR(port)) { + rc = PTR_ERR(port); + goto err_out; + } dev = &port->dev; if (is_cxl_memdev(uport)) @@ -682,24 +686,39 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, else rc = dev_set_name(dev, "root%d", port->id); if (rc) - goto err; + goto err_put; rc = device_add(dev); if (rc) - goto err; + goto err_put; rc = devm_add_action_or_reset(host, unregister_port, port); if (rc) - return ERR_PTR(rc); + goto err_out; rc = devm_cxl_link_uport(host, port); if (rc) - return ERR_PTR(rc); + goto err_out; - return port; + dev_dbg(host, "added %s as%s port of device %s%s%s\n", + dev_name(&port->dev), + parent_port ? "" : " root", + dev_name(uport), + parent_port ? " to parent port " : "", + parent_port ? dev_name(&parent_port->dev) : ""); -err: + return port; +err_put: put_device(dev); +err_out: + dev_dbg(host, "failed to add %s as%s port of device %s%s%s: %d\n", + dev_name(&port->dev), + parent_port ? "" : " root", + dev_name(uport), + parent_port ? " to parent port " : "", + parent_port ? dev_name(&parent_port->dev) : "", + rc); + return ERR_PTR(rc); } EXPORT_SYMBOL_NS_GPL(devm_cxl_add_port, CXL); @@ -1140,8 +1159,6 @@ int devm_cxl_add_endpoint(struct cxl_memdev *cxlmd, if (IS_ERR(endpoint)) return PTR_ERR(endpoint); - dev_dbg(&cxlmd->dev, "add: %s\n", dev_name(&endpoint->dev)); - rc = cxl_endpoint_autoremove(cxlmd, endpoint); if (rc) return rc; From patchwork Wed Aug 31 08:15: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: 12960514 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4877ECAAD4 for ; Wed, 31 Aug 2022 08:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbiHaIRB (ORCPT ); Wed, 31 Aug 2022 04:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbiHaIQ6 (ORCPT ); Wed, 31 Aug 2022 04:16:58 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 718B5C58FF; Wed, 31 Aug 2022 01:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZUQ2URG2av7/0fSBrg55uAQkfZSfM8oOZ4tigcZn4YlrowAKMiIGcbUOjkNYprS/EW8hoZkQyr46k+Ri6mx+loH6mi+HEJ99/YzO9WDjnnn613kIRs0yw+7nTH4K6lMmFQLqqkQ32hFCWX1cjpHsLWvDyksT0hKl9wqAs7XOWF94bIxoB4t4LQlDEToeDGsr7n6l04N3bz1lYVJdmQiLQOuT5AR6IzGKWGYzfjiFPyJ/BCI6y5+N4irGbKaZPlvco8ZoYTeaHr6LD8Mmj0+bCspDlorWMO2a9szJ/WNdr5BRD5McOC+M+MXQP4u9981Bm9ecrNqpflOwMYhp1j9dA== 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=w6nwYpwrohXVsCCquXQdqgxdR0LK6//seX9QT6C5AHc=; b=D4YXf4IOK99xKCHPVjc8Bm2EUI1hNBJJuGeW78r+Ukth9NpX2sLjR2mX9/DoXYcYvv8eYgp+4HmukTL/Xgm/VZlRrmGAcwr9ok/ipefhPErd7OwFgbtINY4rkSoAGT3fD40Ar9GqCwhAU1zQJmH2Wj9TKGB4DVCKgmcVjg8ZWDu0bzW3xa9Agj5Wdjb9+0HerdKOGMzjknxCPWNb13lxjOWZuMKakW7Yz2XUc8T+BAizWGgTEVNm+HLp2maurW748v7GihSboVrOmW3pf0jdRz+OgcpBfs4VlQLIbzb1ZYFzNx5ImBk0S11P/tKbUXd0bZDLls1M+smOzcQAPd5xwA== 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=w6nwYpwrohXVsCCquXQdqgxdR0LK6//seX9QT6C5AHc=; b=EiFa6ZfAS6p9K9jda63gY2CySc4G60hNZUZ+P2awLSu7SnAFZWHCX1PQBQDAK6NnTIeFHPAeijn9m8KZ7RhUW0A6xD1aBCJWGUnDbcTlUVBRqsGpU6TCX6R8qwCTcSk6OKm71z9KcF6S61t5Vqy7x+u+IUM5ERwFM0tI4SeDmBI= Received: from MW4PR03CA0284.namprd03.prod.outlook.com (2603:10b6:303:b5::19) by BL1PR12MB5302.namprd12.prod.outlook.com (2603:10b6:208:31d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 31 Aug 2022 08:16:49 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::ba) by MW4PR03CA0284.outlook.office365.com (2603:10b6:303:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16: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 CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:49 +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.28; Wed, 31 Aug 2022 03:16:47 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 04/15] cxl: Unify debug messages when calling devm_cxl_add_dport() Date: Wed, 31 Aug 2022 10:15:52 +0200 Message-ID: <20220831081603.3415-5-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c4d9b8f-28a6-4abc-29d4-08da8b292759 X-MS-TrafficTypeDiagnostic: BL1PR12MB5302:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JgPR/0I49GDnLeCskSwruLeHv+Q+Pi3BV1Twwk4iIXOVpA5MjYh0R6AamIGoHoF4zUiTxaaDt01Wpf6L0LkoP+7M6ba6w1X/98l7LfXrlCH4Vn4+CEHtOYixkL8ZCuFAPOceeR75NXJZExdx7ELQ6AQfqTIe1tIeZd/6/II9ePSYJjfSpFF2B6EbDzl/FIocPkgt5iHwdvRFciCKULEP6Y4gE5uoUFUq8i+t/E4+ikroFbI9T5tUcjH6aZahn52LTZ6Dya0FaIqNaJWkdZNZlYTnX52D5SvTvVkKAjc+j1MaUY0yOwkUY02M8fBNtk2lm3f3C0WUZHh+lAz6zc9ksExHqrdEKTeJrl3kK4FrsZD+Sac/POcoToUq5IjjB+Q+O4KXrGbHCbxCd5zghZ2TrDIAEdEt4O8V1mYy5JE7bmouhfTayaW3gYxC0zLImZl94huPmbhPcWBp9YBVJcJEQk84bnd1UyyKPms6+Inak/q623Wjfca8Bi1ldBH3/zyY4W/kluEF15YrWPGGKghCH8vErnhQpOsTpKuvu2LhbFtHPnL8abpKsu5GszKEN2T/seweLYDrqM+Kjk4kMySp1TJ5+usSl0uSYDkYnA2eaOtv3qLscUKXzY1kIiovuU3RhP6cDgsHqPOPNynuRBvZ0oAUEerZLo6sFzW0VFvJugy20scIbnqnWzLT9sUj9TM0M38K0h69T158fLmtAOg1riLjJBD/Jvcf6Hg8b++k2AGgdYA2di29QBOwz87jbuzj27+T37eM+cQJHoPWba60lFeCgnbjRFrVGkdQ81lFEzw= 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:(13230016)(4636009)(376002)(346002)(136003)(39860400002)(396003)(36840700001)(40470700004)(46966006)(5660300002)(41300700001)(478600001)(7416002)(2906002)(15650500001)(70206006)(6666004)(4326008)(26005)(47076005)(2616005)(426003)(8676002)(336012)(186003)(1076003)(8936002)(16526019)(83380400001)(40460700003)(82740400003)(356005)(70586007)(81166007)(36860700001)(40480700001)(36756003)(110136005)(54906003)(82310400005)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:49.4546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c4d9b8f-28a6-4abc-29d4-08da8b292759 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: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5302 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org CXL dports are added in a couple of code paths using devm_cxl_add_dport(). Debug messages are individually generated, but are incomplete and inconsistent. Change this by moving its generation to devm_cxl_add_dport(). This unifies the messages and reduces code duplication. Also, generate messages on failure. Signed-off-by: Robert Richter Reviewed-by: Davidlohr Bueso --- drivers/cxl/acpi.c | 7 ++----- drivers/cxl/core/pci.c | 2 -- drivers/cxl/core/port.c | 28 ++++++++++++++++++++-------- tools/testing/cxl/test/cxl.c | 8 +------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 767a91f44221..31e104f0210f 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -282,12 +282,9 @@ static int add_host_bridge_dport(struct device *match, void *arg) } dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); - if (IS_ERR(dport)) { - dev_err(host, "failed to add downstream port: %s\n", - dev_name(match)); + if (IS_ERR(dport)) return PTR_ERR(dport); - } - dev_dbg(host, "add dport%llu: %s\n", uid, dev_name(match)); + return 0; } diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 9240df53ed87..0dbbe8d39b07 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -62,8 +62,6 @@ static int match_add_dports(struct pci_dev *pdev, void *data) } ctx->count++; - dev_dbg(&port->dev, "add dport%d: %s\n", port_num, dev_name(&pdev->dev)); - return 0; } diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 8604cda88787..61e9915162d5 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -914,12 +914,16 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, } if (snprintf(link_name, CXL_TARGET_STRLEN, "dport%d", port_id) >= - CXL_TARGET_STRLEN) - return ERR_PTR(-EINVAL); + CXL_TARGET_STRLEN) { + rc = -EINVAL; + goto err; + } dport = devm_kzalloc(host, sizeof(*dport), GFP_KERNEL); - if (!dport) - return ERR_PTR(-ENOMEM); + if (!dport) { + rc = -ENOMEM; + goto err; + } dport->dport = dport_dev; dport->port_id = port_id; @@ -930,22 +934,30 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, rc = add_dport(port, dport); cond_cxl_root_unlock(port); if (rc) - return ERR_PTR(rc); + goto err; get_device(dport_dev); rc = devm_add_action_or_reset(host, cxl_dport_remove, dport); if (rc) - return ERR_PTR(rc); + goto err; rc = sysfs_create_link(&port->dev.kobj, &dport_dev->kobj, link_name); if (rc) - return ERR_PTR(rc); + goto err; rc = devm_add_action_or_reset(host, cxl_dport_unlink, dport); if (rc) - return ERR_PTR(rc); + goto err; + + dev_dbg(&port->dev, "added %s (%s) as dport of device %s\n", + dev_name(&port->dev), link_name, dev_name(dport_dev)); return dport; +err: + dev_dbg(&port->dev, "failed to add %s (%s) as dport of device %s: %d\n", + dev_name(&port->dev), link_name, dev_name(dport_dev), rc); + + return ERR_PTR(rc); } EXPORT_SYMBOL_NS_GPL(devm_cxl_add_dport, CXL); diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index a072b2d3e726..c610625e8261 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -582,14 +582,8 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) dport = devm_cxl_add_dport(port, &pdev->dev, pdev->id, CXL_RESOURCE_NONE); - if (IS_ERR(dport)) { - dev_err(dev, "failed to add dport: %s (%ld)\n", - dev_name(&pdev->dev), PTR_ERR(dport)); + if (IS_ERR(dport)) return PTR_ERR(dport); - } - - dev_dbg(dev, "add dport%d: %s\n", pdev->id, - dev_name(&pdev->dev)); } return 0; From patchwork Wed Aug 31 08:15:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960516 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59D27ECAAD3 for ; Wed, 31 Aug 2022 08:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231404AbiHaIRG (ORCPT ); Wed, 31 Aug 2022 04:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiHaIRA (ORCPT ); Wed, 31 Aug 2022 04:17:00 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9644B2CD6; Wed, 31 Aug 2022 01:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Czu1EQ1+nscdc7n33PnaIE+vXViSFlJNnm1FYsVCB63WANBYLPl5mOL1M3vOUYs3BeaD47Ob9OQtook1UCa0wx1hprfYrKD8qt48hFtsvOChYMUl1dP4ClI07Ho8phVgRRSH3FpF7ajVpA3KbZEGtVVUg6p+tXq8k2+paVFLleSHGGJrwobSiIu+bFx94w0msb4dGj28PW+hVyyVPzF4GwDAvK8s5ggGuVu+bIquCiqgBx0xIFCCi8Zg1Z1OQWFhkYCVyTdjFPUFSy562p1wsNUFW1esiKl6tQKeUEP6s3WOp6qiPGa6tPu8w0hentJh28bGLJG6grXQKUCQkhGldA== 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=1B5VY1HjhZEMKCLCZO4n9Eaju7hECBVd6zhD+PuvTk8=; b=Esa3v2s0o1JxKHLTZl0ImAImQRZbPe3CPJK7IRegJlJHuYSHU69FnlfDmTNY1umJ0Vt18sqJ3Y1nUA4v/4gIFpeup4JMWJb8svkRoC+nSvi54lVXijbpk8XuS7RA7ZrL58gmUZLyhcq7UeEpdUWUfo+rJXDLNiBGIMAljdJ5up3z7YtsYPsVK/bmhTVCft7djZreYKSS4pVXRU+PX80LQ2hkzvBieEZNTCSX91tI5O3Cay6pRSGimJRUqfZrv9AZJP7IqJtNttkanTscyVSitMKh8IFl5zsrnLMgdhH3mozAjiijcxaX3/s4PxN5BWad5cghhWYRpxZMgIjBqjbfsw== 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=1B5VY1HjhZEMKCLCZO4n9Eaju7hECBVd6zhD+PuvTk8=; b=YiXGS4N1+vVidP7WZow96lsbJvzPc/KYnhz/TwUQS7y6hN4ygtg4qQ6PTSpOtnh+61COsjnWkhr72Tv4YiG4JTdBSZp1I1l5nys5rTX+E7zI8BQ3L7xnoEAS6ODplL3tyGbfBtkIG8ZgHeH2vJi602QDZxQnGpDvj1nPqkS2Src= Received: from MW4PR03CA0282.namprd03.prod.outlook.com (2603:10b6:303:b5::17) by DM4PR12MB6350.namprd12.prod.outlook.com (2603:10b6:8:a3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:16:53 +0000 Received: from CO1NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::f1) by MW4PR03CA0282.outlook.office365.com (2603:10b6:303:b5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:52 +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 CO1NAM11FT052.mail.protection.outlook.com (10.13.174.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:52 +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.28; Wed, 31 Aug 2022 03:16:49 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 05/15] cxl/acpi: Add probe function to detect restricted CXL hosts in RCD mode Date: Wed, 31 Aug 2022 10:15:53 +0200 Message-ID: <20220831081603.3415-6-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bbf119f-4c6c-4346-5d31-08da8b29293b X-MS-TrafficTypeDiagnostic: DM4PR12MB6350:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: niPQiPFAfZmeTmSG3hKN98exB5bUg8gnFXAb7lRh3g12ANbifBSIPalS1qqpP/RLH6uIIwNhLAeukn617tMazDs/bDSYjoeBO27EiZsS3eCAbFj8YIrsS/42tv+wsQLV6t7l4VEKqdT+CHKVlr/Za6KJsxEDQ5Zma2K+vf0Tr2N59DQvyZ8COwwCggpLsXmsThcA6ArSA0s8Ic+M3EYALn4QY3Bxsi1/YdCaqeAhp+fYeeconuFJdneNF0JbRxV6ObzkMo/AoluN8o0oeiOoZGGTdkaiGLGTvgarU21BLD1t808OCAnPgzPqRnp5qapusAHqzBbhvlLomC4eQO4Ht/x4IY1Zfl8LIMJtuXdFwcD8/X5Mr09/3Yp4gEf9AeOrWuFhwy9yAtznFn3weVAb8Gy/B8eiSSidDeFq8q81yXEZJMNZiORNvxdhlD/a7dLpNLlLkQqJ5d3XuXhwWU9fLu1kgrwtbI0eqb0um6yaiqIgmmX6zVK8ZTkOS1kxz41sDDDTHzt4X5UsiAz5c6urtcNydwBbNZH420f8M2XqWh+sKa0AHi/2Tds/jP+bfhhJjGtA40amieB2/TzTSYCm81WSkZyZbtYHwji9DpPwmllP6EamDZp9RdTCkVjZwZKsI52+pAE/FJzjh2GrCENIZKqRtVHgb328BUzYBfKLKM6qhCMb9IABgf7+KmzbQXFjvtQkpu/8NKNjZXrv5kv7c100DF3IEj18VDLAoiiGGrgeJ3ZCEz9ijyEqw62ZMAoki5FfRmdjFW+JpfZXaMFHh/0AZsdr7wVxKeIXXXnByaqokzXVn/Zt/JqhIX9RNTSS 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:(13230016)(4636009)(376002)(39860400002)(346002)(396003)(136003)(40470700004)(36840700001)(46966006)(336012)(36756003)(2616005)(16526019)(2906002)(8676002)(4326008)(26005)(41300700001)(6666004)(47076005)(83380400001)(1076003)(426003)(186003)(7416002)(36860700001)(5660300002)(40480700001)(54906003)(316002)(81166007)(478600001)(8936002)(82310400005)(356005)(70206006)(70586007)(110136005)(40460700003)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:52.6304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bbf119f-4c6c-4346-5d31-08da8b29293b 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: CO1NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6350 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Restricted CXL device (RCD) mode (formerly CXL 1.1) uses a different enumeration scheme other than CXL VH (formerly CXL 2.0). In RCD mode a host/device (RCH-RCD) pair shows up as a legal PCIe hierarchy with an ACPI host bridge ("PNP0A08" or "ACPI0016" HID) and RCiEP connected to it with a description of the CXL device. Add function cxl_restricted_host_probe() to probe RCD enumerated devices. The function implements a loop that detects all CXL capable ACPI PCI root bridges in the system (RCD mode only). The iterator function cxl_find_next_rch() is introduced to walk through all of the CXL hosts. The loop will then enable all CXL devices connected to the host. For now, only implement an empty loop with an iterator that returns all pci host bridges in the system. The probe function is triggered by adding an own root device for RCHs. This is different to CXL VH where an ACPI "ACPI0017" root device exists. Its detection starts the CXL host detection. In RCD mode such a device does not necessarily exists, so solve this by creating a plain platform device that is not an ACPI device and is root only for RCHs. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 71 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 31e104f0210f..a19e3154dd44 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -312,6 +312,33 @@ static int add_root_nvdimm_bridge(struct device *match, void *data) return 1; } +struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) +{ + struct pci_bus *bus = host ? host->bus : NULL; + + while ((bus = pci_find_next_bus(bus)) != NULL) { + host = bus ? to_pci_host_bridge(bus->bridge) : NULL; + if (!host) + continue; + + dev_dbg(&host->dev, "PCI bridge found\n"); + + return host; + } + + return NULL; +} + +static int __init cxl_restricted_host_probe(struct platform_device *pdev) +{ + struct pci_host_bridge *host = NULL; + + while ((host = cxl_find_next_rch(host)) != NULL) { + } + + return 0; +} + static struct lock_class_key cxl_root_key; static void cxl_acpi_lock_reset_class(void *dev) @@ -445,6 +472,13 @@ static int cxl_acpi_probe(struct platform_device *pdev) struct acpi_device *adev = ACPI_COMPANION(host); struct cxl_cfmws_context ctx; + /* + * For RCH (CXL 1.1 hosts) the probe is triggered by a plain + * platform dev which does not have an acpi companion. + */ + if (!adev) + return cxl_restricted_host_probe(pdev); + device_lock_set_class(&pdev->dev, &cxl_root_key); rc = devm_add_action_or_reset(&pdev->dev, cxl_acpi_lock_reset_class, &pdev->dev); @@ -518,6 +552,7 @@ MODULE_DEVICE_TABLE(acpi, cxl_acpi_ids); static const struct platform_device_id cxl_test_ids[] = { { "cxl_acpi" }, + { "cxl_root" }, { }, }; MODULE_DEVICE_TABLE(platform, cxl_test_ids); @@ -531,7 +566,41 @@ static struct platform_driver cxl_acpi_driver = { .id_table = cxl_test_ids, }; -module_platform_driver(cxl_acpi_driver); +static void cxl_acpi_device_release(struct device *dev) { } + +static struct platform_device cxl_acpi_device = { + .name = "cxl_root", + .id = PLATFORM_DEVID_NONE, + .dev = { + .release = cxl_acpi_device_release, + } +}; + +static int __init cxl_host_init(void) +{ + int rc; + + /* Kick off restricted host (CXL 1.1) detection */ + rc = platform_device_register(&cxl_acpi_device); + if (rc) { + platform_device_put(&cxl_acpi_device); + return rc; + } + rc = platform_driver_register(&cxl_acpi_driver); + if (rc) + platform_device_unregister(&cxl_acpi_device); + return rc; +} + +static void __exit cxl_host_exit(void) +{ + platform_driver_unregister(&cxl_acpi_driver); + platform_device_unregister(&cxl_acpi_device); +} + +module_init(cxl_host_init); +module_exit(cxl_host_exit); + MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(CXL); MODULE_IMPORT_NS(ACPI); From patchwork Wed Aug 31 08:15: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: 12960517 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 428DFC0502C for ; Wed, 31 Aug 2022 08:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbiHaIR2 (ORCPT ); Wed, 31 Aug 2022 04:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbiHaIRC (ORCPT ); Wed, 31 Aug 2022 04:17:02 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2048.outbound.protection.outlook.com [40.107.102.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA67FC59E6; Wed, 31 Aug 2022 01:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LbgOo4MeFeukGZ7w4mk7h7txK4yXqCP8n+CVGU91OOUTYryskfY+IKE2nIFPuw16hzeLgeg9X8+P9qKBo81gYXnw1ZvWs0MIgHC+rrWOq92MpNxRi1K799BNS4qpFPyY5mh4pEnXQESsZNsCNbgiQizbk71HGkJfgVKhORkzZw48ZtfAGrxxNaL14leRm0DUXyVVIXez+wn/r++2bC4hAXp36R5kWOoT8+ZV0FIWcqOzmoisKm8IGWJZhxUUdbkwfuDZRanBjK8Err55TEukPgspO9C7l16VBFiAACnXMfZLoJydvbL5AbVKfndJZiOZ3uzxvGQRw9HbYov45FtpsA== 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=m8z+Z6Tdn5o+4nlS7uEC+Ocqx9JQK16JI4XKVYon7zY=; b=L3FBB6E84h96V6YxXRfk34bDxe80enw5WeJGWxHHQ0PVbECCYGGHY49O3gmeEqrvnyaeh1rJgG4kAwT285btUxArh+vTxGkcBvaB+/LlzBVQCtJ+euwYGinSIzC+Ccj2XYIKgFbfOHLr6vBNdcqJ1ka3nqPVKyEB6Mb4NOAKcgU5IUmq7+7Lgy4wFXUGu3ysMyfiIC85UwFXbyCzXA1lCH5Orxd6VMsTLIVaHZKkZb3Q+ULfkh1y1Sq8t3l1mleFgAhh1DT/q4oXZGYAgBF/l1j3NrHF7O1RvWwcgK154tvK0l5PLATe2NTov43WnVNmo9nNNiQSrBFxuaGeUP0F/A== 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=m8z+Z6Tdn5o+4nlS7uEC+Ocqx9JQK16JI4XKVYon7zY=; b=KNJanmfiPR69xoKNG7xy2jQmQdE0jtAj48x+0MyxIHbJsjHOXL8tRa3Ps2ADh/D87EA0YonOGUIT+b+NKhgLne1z4gNPGGhrR5y3a+sESXHnV6Zmaqaw8kkehVctZV/jpM2BSQgjdRIj8XOz9UGG1nWJLy5DlOwJjxIbWO7P2yI= Received: from MW3PR06CA0008.namprd06.prod.outlook.com (2603:10b6:303:2a::13) by CY5PR12MB6153.namprd12.prod.outlook.com (2603:10b6:930:27::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Wed, 31 Aug 2022 08:16:56 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::9c) by MW3PR06CA0008.outlook.office365.com (2603:10b6:303:2a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:55 +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 CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:55 +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.28; Wed, 31 Aug 2022 03:16:52 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , Bjorn Helgaas , "Rafael J. Wysocki" CC: , , Len Brown , Robert Richter , , Subject: [PATCH 06/15] PCI/ACPI: Link host bridge to its ACPI fw node Date: Wed, 31 Aug 2022 10:15:54 +0200 Message-ID: <20220831081603.3415-7-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2513867e-e42e-41ec-0c6f-08da8b292af4 X-MS-TrafficTypeDiagnostic: CY5PR12MB6153:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8oN+BDWLUbIf40FJ3oRMxAQjpdvD/yy+pV3+N1wv+ILrLgX6JaSBqgxjw0pUZyvCbIJFkLmnDQSWeuhVwbHFOVVaJz4TMEkLN9tlHcMS+m6knI0GYlJGFLOah93fLrSZ6gYXLTpwfY48hr+h0BlnAuu9AG6FR8WNj3AZiu5lPCaB8Qc3gJM+Ua8n9URQBW+M0wJpek8UiNlNLkeEgtazAQuaOHyfKavvnZ8v2Q8zf+JCexyY52LkO3FwM+1cVbpbmlB17KZCXVkOxssbA+yj2qWa5PURCDi09mZDfLSC0Cc9dJbsG8Bqnj1AYwERnJX2RJyTxU+5gFSAM2e7TfrSazFbc6E47yRJ1SZ3yJ+XvNXyLyVgqf0Q7CvC+BY0UUWbeTIroPtMqxXr0O9b1jNlbGLD+TCqlO0fWoEmTHHGm8DbrHTqUWQCTaU8FYKrwJjUrj3ZxfPzFqTZq0vPeTziIWiD91AZEcparNHaGF6MrELH2U2GAJoNx0czx0/MxDG+i4ZwZHClidwyVQ+nkn0IcWPQE89v3dUiKEAftqrWnUSrGPCr7P9u414wpNGVQD8BY82ZShDAMs06FHnreQ8lpH9h4m/T5z8/8Ljr+6AxEojDBsWAnstYnnBhPKCSwJ96xWmih9jm1SRDa++9bKAi79OTe49Zcp3WE/znn0UPoBDeIKQLqpHbji1/gLQtAVVptbTzhE/8BAhbWGDw7vvBRnItuSVXuIwxPUaAy/FX9iz/f8MmGCyJuw17gAvW2OpP6NKEMGM/TM+TdPDVAAlpoX9vjyXyckFoa9O2X9q5RCUr9yamVLozXhJPbzCdLMFx 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:(13230016)(4636009)(396003)(376002)(136003)(346002)(39860400002)(36840700001)(40470700004)(46966006)(26005)(2906002)(36860700001)(82740400003)(82310400005)(2616005)(426003)(40480700001)(47076005)(1076003)(186003)(16526019)(336012)(40460700003)(316002)(54906003)(8676002)(70586007)(70206006)(4326008)(110136005)(36756003)(41300700001)(81166007)(7416002)(356005)(5660300002)(8936002)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:55.5028 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2513867e-e42e-41ec-0c6f-08da8b292af4 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: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6153 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org A lookup of a host bridge's corresponding acpi device (struct acpi_device) is not possible, for example: adev = ACPI_COMPANION(&host_bridge->dev); This could be useful to find a host bridge's fwnode handle and to determine and call additional host bridge ACPI parameters and methods such as HID/CID or _UID. Make this work by linking the host bridge to its ACPI fw node. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- 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 d57cf8454b93..846c979e4c29 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -1083,6 +1083,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, goto out_release_info; host_bridge = to_pci_host_bridge(bus->bridge); + host_bridge->dev.fwnode = acpi_fwnode_handle(device); if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) host_bridge->native_pcie_hotplug = 0; if (!(root->osc_control_set & OSC_PCI_SHPC_NATIVE_HP_CONTROL)) From patchwork Wed Aug 31 08:15: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: 12960518 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3214ECAAD1 for ; Wed, 31 Aug 2022 08:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231447AbiHaIRo (ORCPT ); Wed, 31 Aug 2022 04:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbiHaIRG (ORCPT ); Wed, 31 Aug 2022 04:17:06 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5C9C650F; Wed, 31 Aug 2022 01:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z4EOWw8MYIDBcCuNyFqvSHzPARdQ91J7QqmsdN2sYc1qsRHwof838UojuC/79njuO5Mh3BRhnqRyMdaHJheqX28NlYv9wci0vSD5ZnvEftWnIUezb4bwOTueWS3OVqi68CctSwdG2Ir02zZYGWAbSOV9yvZBFR/pNlcxKZKEEGPDBpI2DXQ/9fVsXM+iHN3fDOJ1WRXISYJpSdlSSIpFxPp/dhk+t0jvyAKOoU7ulg78ISfE1Si2uivxr+gfS0zoimHTbztFQcqGMFT8tknbVJQdBCJRLr5LuagU8xctX9jyiTbjSLS4nbc+7WAoa/UEjgD7UxBSIWk1q0RrHsyMhA== 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=cVB4yDHDaygl1aA4bRinjSuYPXrxKGhj/7fWwwTUHW4=; b=RZYhSNONxEXWSQN70w0CgYctXB0V/B1ziTu9W6iPLchPNOJOJxoWxKMK8BJgMHD1yWQhDF6lCQwvy7LhfjVamCrka10twamXvFpV0VNUYC88Yi4i8hqg+YWuH39fnLJ+QoKSvmzWYYE/YIQWYk05zKMkYm7d3c8oXO7ZXvGgvdFPDfEJ+d3nXhpB5yQBZh29gzE784Rwk6ycv5PmWKZq3I7viaEy8AfS22AKhwOjwuD5BQiW3l4PIye49mWtm0z9X1if5R5+T0LNzSTdueLskqGTaHG0YC1rG/+AyzeJqmtpkNMdH2OU5l9wHNx6q8zJuADD64HOjlnterhO8LN1sg== 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=cVB4yDHDaygl1aA4bRinjSuYPXrxKGhj/7fWwwTUHW4=; b=l65D6olE0YogOPgMOOgDWZGVbbkzHEPMHG/nTFIqbHNdTjNXw0SmJOW6PuWPo3rkRIeVV8kO/MkqQlkROMP2RjJDOl5Lz6PAlu2uIqNeTpHUc5P5Z4psUrHUYphpHgeMxzF5rTc3wmkR55xi+Box0ayNQqQsRfw5ufE3OzKDipE= Received: from MW4PR04CA0245.namprd04.prod.outlook.com (2603:10b6:303:88::10) by SA1PR12MB7344.namprd12.prod.outlook.com (2603:10b6:806:2b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:16:58 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::ee) by MW4PR04CA0245.outlook.office365.com (2603:10b6:303:88::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 31 Aug 2022 08:16:58 +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 CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:16:58 +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.28; Wed, 31 Aug 2022 03:16:55 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 07/15] cxl/acpi: Check RCH's PCIe Host Bridge ACPI ID Date: Wed, 31 Aug 2022 10:15:55 +0200 Message-ID: <20220831081603.3415-8-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 372dad74-62e0-4231-b773-08da8b292c8a X-MS-TrafficTypeDiagnostic: SA1PR12MB7344:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4uQPGTioVanKdMprnd8Sbej2+YeNydzIfkQ/82eTV0AhogQVYS12jRkEarpiFfhrqau621tI1zW97Dj4xFGbgHEUdBCZdM6Ywt7qc8C008jjlpy14cgJjUGstDy82P43cEZ2eyJne67lu0CWpGkuOlkqHV1rJxSpPWqdGAUmxe1hECjZnwpmuIPOM4DLcNKb/Du7lnttOrJ4l4Q0IMtILng+9wYd6P+1I453GDSVSqD3VttSy4RJzlHtjexo7cjDbKzGWW50RDFXWNzu8Q3t8wcUquOcIjXJLifld77l4S3LfhzqgHDAHVh433zEn2O184aRGNsoEkUn2yc6N+ZOdeU1aB/FUTF1AbgaalhAZy3ITh8K2+7TfeTRqrAEJbR4cEWeBHJfQ7J/ns7HsZr+egkYSxwZbptiU/Xc7+OtAivHEtuGXa0nrgj3VXnTPUzxmzQfCDUjbQymTheXuqAI+nsaFXy78u0e4ZTG3YejvCtAFcdFEUx9eDILNL0nlfyFg121B0NGnJTcujPq5qIu3qsGyGIfJQZfbrEFT3hGf624BH45hhTyQ4Z72EiIH/gxuh7kUsyk/O+zd8UtiYUgzGSliGcM/M3M1iyqGa9cADqmCWzSka0/fHEHklFy4x4Ap92cq2FmVsxS6Zu0oA9Th3GumGyjho7zKY4Ak0vBmsrhNkIZIU2iv8bFeeEZn6rs+tvy7Litfo3v5yCCXyTG2R9kyN7xBInGpUwjzz0Gn31dCICKUCDLjMVo582s88UP7SBLOFhdqHBA8vmc4jb32YXZMMhuROBPswZ29U4B4fk= 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:(13230016)(4636009)(376002)(396003)(346002)(39860400002)(136003)(46966006)(36840700001)(40470700004)(41300700001)(478600001)(316002)(82310400005)(110136005)(54906003)(82740400003)(36860700001)(40460700003)(2616005)(356005)(26005)(16526019)(336012)(1076003)(426003)(81166007)(47076005)(7416002)(186003)(36756003)(40480700001)(4326008)(2906002)(8936002)(5660300002)(8676002)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:16:58.1836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 372dad74-62e0-4231-b773-08da8b292c8a 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: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7344 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org An RCH is a root bridge and has "PNP0A08" or "ACPI0016" ACPI ID set. Check this. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index a19e3154dd44..ffdf439adb87 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -312,9 +312,16 @@ static int add_root_nvdimm_bridge(struct device *match, void *data) return 1; } +static const struct acpi_device_id cxl_host_ids[] = { + { "ACPI0016", 0 }, + { "PNP0A08", 0 }, + { }, +}; + struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) { struct pci_bus *bus = host ? host->bus : NULL; + struct acpi_device *adev; while ((bus = pci_find_next_bus(bus)) != NULL) { host = bus ? to_pci_host_bridge(bus->bridge) : NULL; @@ -323,6 +330,19 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) dev_dbg(&host->dev, "PCI bridge found\n"); + /* Must be a root bridge */ + if (host->bus->parent) + continue; + + dev_dbg(&host->dev, "PCI bridge is root bridge\n"); + + adev = ACPI_COMPANION(&host->dev); + if (acpi_match_device_ids(adev, cxl_host_ids)) + continue; + + dev_dbg(&host->dev, "PCI ACPI host found: %s\n", + acpi_dev_name(adev)); + return host; } From patchwork Wed Aug 31 08:15: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: 12960519 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42DAFECAAD1 for ; Wed, 31 Aug 2022 08:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231472AbiHaIRs (ORCPT ); Wed, 31 Aug 2022 04:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbiHaIR2 (ORCPT ); Wed, 31 Aug 2022 04:17:28 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF53C59D0; Wed, 31 Aug 2022 01:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MMXmgGwtgBAdc7bjvQNfZKi3M0p9gc89ekzfuiYkY1zYFgwBxLllJjK6cS25Ph95V0FgujFPs/VJMH33RuzEd9hUVl3hm0wjR442/epUGF5WcL7lZAQPlgnkHAbP6PqPBJRBrJ4O1O/REUSVMo1bCYnxKsszEvTvj76+eO0HoplTg4txUd0iE5n8vagYFRb6sNgLjwbhx03CLOpAA+AlmXounpzLYj+xVkqYil6gAAVz+a7Q9kcDE0AijFxEjROnkhxWsIOYt9hcdH71goDyBI8uo/ippL4EV9QRr17GdQFii7f5NCMjgcclyd73lKSNVzVZkojKa77XGvii60Pz5w== 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=PoviwZVPNLcYTYalH4CFjJxP5kWwzC64jvAekJwioO4=; b=V5MK7x9vBptoYoVRI/mKe0eXyfLGzlhGJjH8JwiVhDpLWHyVzj8zced24M7rVNQawzMaTo0mnjz17N4g+dl024GgxXh/uWrTa61bBPG07Ot/7g1zYLO8sdMDxhFLB1LRHdNQQ+aMsdaTdXOKOcut2FaS5llAhnumjm0tXEN7vQDlXu1xI6fCmZSV73oVZmLeQOGdqDU0KHxo0LBWEW/jPHpSEualApBnTv3PM4lOl7Lw2wa4NVM3XsiLsGFa4x6mFK2QseTHipAo61jcUGpjTjbUvTZVWbJUH+7nM2chP2lgvqX2InDg/z1xH4r0Q8u2YT1KNoCnU9zrk8X7HCAIUw== 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=PoviwZVPNLcYTYalH4CFjJxP5kWwzC64jvAekJwioO4=; b=UBmjm6ieSYKedlqPg5cSxXasIYnSEuGm42819a7xb06nyphm92ikNAHIWDpu9tBbvXRL2tzcg56NUuTE0rHKm+JbWqfMJDAgt/CSYHcbgVrXn8qyKe1VMM19fcS8zC3f91WK15/0NurmGb60QTZjsElOpumQZuPTp5A+oPsnQoI= Received: from MW4PR04CA0250.namprd04.prod.outlook.com (2603:10b6:303:88::15) by BL1PR12MB5350.namprd12.prod.outlook.com (2603:10b6:208:31d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 31 Aug 2022 08:17:01 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::3a) by MW4PR04CA0250.outlook.office365.com (2603:10b6:303:88::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 31 Aug 2022 08:17:00 +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 CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:00 +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.28; Wed, 31 Aug 2022 03:16:57 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 08/15] cxl/acpi: Check RCH's CXL DVSEC capabilities Date: Wed, 31 Aug 2022 10:15:56 +0200 Message-ID: <20220831081603.3415-9-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7b1bb8d-d717-4eed-8d69-08da8b292deb X-MS-TrafficTypeDiagnostic: BL1PR12MB5350:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n914PJTb7HvsA+vcqP9NOjf7f/ObOKmyhSJF1FXMDA0AIvg8V9wKEsAOdONATKZuJoTX3HiV9kT8p70pUU9HfbBsTf/FdPnunj7c4n5C1vqJSmuPeK5VSrMQ0Bo8YPTsdRDxY6UFmiXsBo7x87z/6aTzGqoDVLfLHmdqBrZMJXio+ag1j56E8Eew2KIbX3KxMmqa6lrnZH70U4pEZYOi7LzH2RXu/ZuiAUhwEnb1Qvufz0py2swDg9djCPo5XyyFjn+EKP1gqVKw4HGbHWpknB4FXEfb60Lsc998YU/OvN9cn50alkJEvOZf2jS+AhWwQ2Q140x81ODf4znMN+K5JMMH94PSu0S4twSRIC+Du9hKXLD2M32VzKK45rj8olRV5wHP03sHgP48tjfLqIxTlB0VpT0oT3I2fFUZ6x861/DaBWopyh3unickKHE6mevdbbAty70GVpGcxyJn+vuLZ+yweBlYnPeth8km4b8Vmwun34kBUB4umZDEP8GBd4uUHBgePiaAmwNOWhPS7/OQ8KKZ9acKwo0vC/KSNS0hHndFyQ8AN1goGEoDRLCPZDmF0yXW1kDlLpkKVVVomFq/ItkYp4lFR3iti+GnuPxG+gxrfv1Cn+2PE+LOJxBv8ivv6373kApg4t1c+uNg6D5Eqn3MjBNhETGLZEO51yX2BvAZgFkWKhzePgIXfUbvnpz0M+G3t8Z+yCmRbNmKmsevawe+YQVCcXJ8NvuHkO9d+aa08MHXPyBvVeyWUpYkDvIH8J6UqNpDNy7Vpz0uIBLDoXY4PHlONcuL29G+OkfKnu5ve6bCq9TjI/kQSeUXj2WV 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:(13230016)(4636009)(39860400002)(136003)(346002)(396003)(376002)(36840700001)(40470700004)(46966006)(356005)(70586007)(316002)(110136005)(4326008)(8676002)(70206006)(5660300002)(36756003)(8936002)(54906003)(478600001)(41300700001)(7416002)(81166007)(2616005)(26005)(82740400003)(47076005)(82310400005)(2906002)(36860700001)(1076003)(336012)(426003)(16526019)(40460700003)(40480700001)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:00.4959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7b1bb8d-d717-4eed-8d69-08da8b292deb 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: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5350 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org An RCH has an RCiEP connected to it with CXL DVSEC capabilities present and the CXL PCIe DVSEC included. Check this. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index ffdf439adb87..f9cdf23a91a8 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -322,6 +322,8 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) { struct pci_bus *bus = host ? host->bus : NULL; struct acpi_device *adev; + struct pci_dev *pdev; + bool is_restricted_host; while ((bus = pci_find_next_bus(bus)) != NULL) { host = bus ? to_pci_host_bridge(bus->bridge) : NULL; @@ -343,6 +345,20 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) dev_dbg(&host->dev, "PCI ACPI host found: %s\n", acpi_dev_name(adev)); + /* 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); + pci_dev_put(pdev); + + if (!is_restricted_host) + continue; + + dev_dbg(&host->dev, "CXL restricted host found\n"); + return host; } @@ -354,6 +370,7 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) struct pci_host_bridge *host = NULL; while ((host = cxl_find_next_rch(host)) != NULL) { + dev_info(&host->dev, "host supports CXL\n"); } return 0; From patchwork Wed Aug 31 08:15: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: 12960520 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65DCDECAAD1 for ; Wed, 31 Aug 2022 08:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbiHaIRu (ORCPT ); Wed, 31 Aug 2022 04:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiHaIR3 (ORCPT ); Wed, 31 Aug 2022 04:17:29 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2087.outbound.protection.outlook.com [40.107.96.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82D98C59EA; Wed, 31 Aug 2022 01:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzIYonHnW04KQAo3rskZ9iIYR5lDEaq6j4VeUB1orTAGPwU4JqfKbCg+gOMK5A7g1r67Z3KfBV7CgDaQQ6YlPh22F5+2bVcZpyJFtjS+iOlgvZ6oWfIk4zdGJnfpLfFroc5eopCaJ9KRhoxhrnGBYbI3RKMfi51QndzM0EvYUyBbnHkHSXJhvxTfOi9TE+4PnEDOAdkGiiXfmgjuqUpTnZw7PO1ilEBkY9D+e67j+ZB7rPZi1+9NCCn7CuXq1zW4rfar6z+S4yGpEkDgEIjbA5Jj5Npq4faUFZ0ANvn4VI1psi3de62vzIuKmWwAizgStwgBNYGf90CGLRE9cScPqA== 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=BmEK2yubcX2euJpR8tmTwMJbmJFxVv2NN8CwXcClx6Q=; b=WTo2EaXsZ0oLAnB87wmCcxUAJqUS5ojy1DnSzVgGkBW6QS+mUcAcwUZatSfqscTHWo3azb2Yobmi43gl+FtYaVzwPE4304a/wNyQZIdqpnZaoKRqDfv4n31YeN9blx3V9KP21fJT0+B42Q1TuqW/o9JZlVI/1y0khN+IQKjuI+2ZvxdFnRxmLySju0MIVutXgbGV+2dw00DqirUpVZEm9QTzE0gaqI0r/OMG7h7GoH7ZVGNP4LPhkvJdLtoxtuxRKg9eJWF+sFa/qwtqxHlHf1xGMS+pflHaJC7aUQ2wdawADXtuMlCSRFn7UlggXHF0O/w3rzCsAW68DA7tuVzUUw== 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=BmEK2yubcX2euJpR8tmTwMJbmJFxVv2NN8CwXcClx6Q=; b=G80mD5GuUGCbbmng6VGfS6PIdekLvJP4qwuRXJNZ1gorOf7Ppo+Hul0LJkmqARzFJRfZxUARK2fm/IOUpmA8bBRx6YqC8COHlvKzwjE9sWqekkYRYfw0UpNmqKRpMEBOfWvAyU1nhqjMu4TPedg08A2+PZYXlyXV/3oQHlPMJWM= Received: from MW4PR04CA0242.namprd04.prod.outlook.com (2603:10b6:303:88::7) by BY5PR12MB4164.namprd12.prod.outlook.com (2603:10b6:a03:207::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:17:03 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::65) by MW4PR04CA0242.outlook.office365.com (2603:10b6:303:88::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:03 +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 CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:03 +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.28; Wed, 31 Aug 2022 03:17:00 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 09/15] cxl/acpi: Determine PCI host bridge's ACPI UID Date: Wed, 31 Aug 2022 10:15:57 +0200 Message-ID: <20220831081603.3415-10-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52dd6f28-f93a-4ebd-d43b-08da8b292f9f X-MS-TrafficTypeDiagnostic: BY5PR12MB4164:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JfcToTMR2eokj+jaTF2Y9k7Ks5cIrQhxP2Mhk0zDxfsWExWFQHTeQpIh8D0gKUMh1SQg3H7WVrjjrM4ghGwNqEgfqKZp6c2yVjbjCrg8ysaWgYlbXqWs3lFgGCWe8nrMR0TWmjFQum7e1itYKtpyZR9PYs9d/LqLZ53QvKuWOlRDTUH31qW1MnThM/Tl6gE4k6+mOkCHwOZO7qEnaWz48nwy7h90u5/trWwbrRQmjXv8ejPMPkdvANBkIWBSxxSj3LGNdmOz8EA9j11VbbRUjjRI6pVtgcEu6ieHxSaSijtb732VVPlzWr/FVq+NkS5LzxAXPqN5HAiAMPisNriA744IdBwd4Pi5FLo+K69LtNaZS9ALcVhLchnxEiHPBApC+BBITXNQOu//8fl5uMUdGGthvSuIvooz/Cb09a7H3urmlSP+8/qPAhGWYQYZjhX1tEloRoxmHkrueEpmTb9BS1RogQlGElXET6FOAAnEdipV2iT1YsvWW5NGAO5fkElU2s8d0bv5u2ksh5ClZ7ObAALOUO5QjWhXZywcpfyJpyfYqJoQuCc8K5lfHkO5pujVYaGXa0LCUhrEseYpFZq1UWmmlFHdgpJcb66nJ2ZP90mj+7bPAy+xAbQCSsUk8UlspQklA7nPEq8MqGzfiqj7FjmZ4EFhruJ5jRTXTafnZqbCzESemdk8AeAvj/k6AKtNdVJQ3OkWn5v7yc/xRuAfkrFRQMa5IlEUW0NrZd/fDGvgjGNSzuwTT+2sSCTnyHhioY7TeL9tl7NHBw/PPAzn0+4Vq8l57jzQjmI8B0Qlz9MxnGS5qVhJITQeRApYd5ML 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:(13230016)(4636009)(376002)(39860400002)(346002)(396003)(136003)(40470700004)(36840700001)(46966006)(336012)(36756003)(2616005)(16526019)(2906002)(8676002)(4326008)(26005)(41300700001)(6666004)(47076005)(1076003)(426003)(186003)(7416002)(36860700001)(5660300002)(40480700001)(54906003)(316002)(81166007)(478600001)(8936002)(4744005)(82310400005)(356005)(70206006)(70586007)(110136005)(40460700003)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:03.3395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52dd6f28-f93a-4ebd-d43b-08da8b292f9f 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: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4164 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The UID is needed to read the RCH's CEDT entry with the RCRB base address. Determine the host's UID from its ACPI fw node. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index f9cdf23a91a8..b3146b7ae922 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -368,8 +368,20 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) static int __init cxl_restricted_host_probe(struct platform_device *pdev) { struct pci_host_bridge *host = NULL; + struct acpi_device *adev; + unsigned long long uid = ~0; while ((host = cxl_find_next_rch(host)) != NULL) { + adev = ACPI_COMPANION(&host->dev); + if (!adev || !adev->pnp.unique_id || + (kstrtoull(adev->pnp.unique_id, 10, &uid) < 0)) + continue; + + dev_dbg(&adev->dev, "host uid: %llu\n", uid); + + if (uid > U32_MAX) + continue; + dev_info(&host->dev, "host supports CXL\n"); } From patchwork Wed Aug 31 08:15: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: 12960521 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A760ECAAD1 for ; Wed, 31 Aug 2022 08:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbiHaIRx (ORCPT ); Wed, 31 Aug 2022 04:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbiHaIRi (ORCPT ); Wed, 31 Aug 2022 04:17:38 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBD4C697C; Wed, 31 Aug 2022 01:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=llA89JxQCdbPj6buUTP1xqejwdcLV+oTrhsD0yhdrZcPWOsYyXwLj7qmQD2+yL/h5ybuEPRcGOSiwr7HA5JDDtdyVFyHB0O4IZ38jHqPVUiGC99azq/uh9KH9zYuYCD+NeGmaww4JY7OCvbFVOgLqOx9NdOw7NIDJvkDYbwsbq9mwz4OJkktcUqGKKw7Dy8UnszHbpLd6+RyZo2DFqRk13HevLqax9cGLvt+L8fFe0QusEm9xTl5khAPFjVy2DGJHMHiosAWd6CpveMP+2SkGKv9bGaVmbM9hX9ZLsaRreuXQvM4m9Nc7k0y1qouADpVvyF+EzChkiqriosx1VcvPQ== 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=um7hzKWI4ePkiyGH3rZmr4gvxOVSzvmMAV0swzZYtp0=; b=LHv+KszgB4Ax6so+JMWjjQaCPlMuYB9zJhDb3aAyx5p0Qp7n7z55JkzADpdgRpQO3y6+5WWS+yzg179ITc6LX01aoXz5lWR89nA6Hyel3RltX1t38zj0A0IiV3WbwwJROj1cdnCgULRrlo3NeTASyc9aQxDHjSDJBzm/paFcUSD6/bmLkbyBRNfCv4xb1cfRKEig4ZWFaz1f2yFW+U0GXUtztVDx+rTfIzv1z50Pjs46uGBvFJmnT2E1bnlsmorMi34mpFSBi0lLMChKRF8GMiqmOY8thTBZab6CRpNO3wPSOtLrPvjjBOgmAl3QkwyUH38QZKwUb/e1kmQIfJ3Iug== 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=um7hzKWI4ePkiyGH3rZmr4gvxOVSzvmMAV0swzZYtp0=; b=JAe4u7xyvym6GUlNLa8CPwr3cAFqxZhN9ZJNQA/NYiFnhA3HmxpYlA4TZwuL8dkE067hQEvcFqhTfvBEuDabDpY+8dmrKvrY3rzvp9VbDJ10cnb3foKFdYu6V5uqbEgSYsQcX7lVxpGep43ng51KXsh5JCZNIpvZ0612zanpN2E= Received: from MW4PR03CA0268.namprd03.prod.outlook.com (2603:10b6:303:b4::33) by CY5PR12MB6371.namprd12.prod.outlook.com (2603:10b6:930:f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Wed, 31 Aug 2022 08:17:06 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::af) by MW4PR03CA0268.outlook.office365.com (2603:10b6:303:b4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:06 +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 CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:06 +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.28; Wed, 31 Aug 2022 03:17:03 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 10/15] cxl/acpi: Extract the RCH's RCRB base address from CEDT Date: Wed, 31 Aug 2022 10:15:58 +0200 Message-ID: <20220831081603.3415-11-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f56fa265-d6de-4c00-dd9e-08da8b29316e X-MS-TrafficTypeDiagnostic: CY5PR12MB6371:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xoMMCQwC4iE2tyuJCkHx1IWt6sLAEK4VKUPiSoW88MKTCD5c2E51NUrY/R5Nb80Sl44owfDgqoTW7bD9MR7HIJONK16SwkeU3qpsV3oB84tKHHhFv5HbZ8f2VXQxUVLXWp65qvN9i5MBrJFSPvXAVr0LVj9/W6wL+hY2UMEb4jTOa8R2RElgFDHdAusNFnm38v1A9vJRSxp4x7RBinv6lnqDOcP7pDRQcD9EMlJuCb9zVfObUXIwQ3DJm6mKeQbpLYBKep9sF1Zj31QNNTwf95sxIUpX2l4OrXRnZLqD6E/8i2LqfS8YtLTRwnhBo8QSQ71M0FESatLxCEUy/5YVuRNpbTYUlxJPX6aFhesYLeaHM+qVQkQd73IWeQ7ra5We0hyL0m6CyfRT24aLLYAfy9UvLNxOOWt/97yBzLSLExAZATtKTeeOy54YiSBpRWemSqw9Gb3a6/VOt08H1yaGykjQPCOvFtAAjuteuD8IvIC6UlToknffmlcfuMSP5jX4cSpRQ3A4+m61gIEcV31nxOmanUMe0rgGciOb1DwIFZwybY8lySPo+cdmcTieCrIgcHzKx6fTLGb9mKpLNzF0/f2J89xsfniLh4i49RuZt3dH6KLEx1ZmGOTzNzLBIbv0T+5SEo3xIBSQuqxchFWnVw1hdSxR0qvoO220Et2SLlpIKKjaAaZpkABDws7EzyOZ5qsUtW3+NhKItdw8RKyId6tqtd3iDzjKbsYyLngnStb8S1vJQPMJCByb1SZlakCkMEyrHI8YLMro39XLUATTHmsOiOnSHw383xSW6a+JYlxK1yOJa/zKsBKM8Jyxe9fY 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:(13230016)(4636009)(376002)(39860400002)(136003)(346002)(396003)(40470700004)(46966006)(36840700001)(36860700001)(5660300002)(82740400003)(7416002)(8936002)(2906002)(478600001)(36756003)(16526019)(110136005)(316002)(70206006)(4326008)(70586007)(81166007)(83380400001)(54906003)(40480700001)(336012)(426003)(2616005)(82310400005)(47076005)(41300700001)(6666004)(186003)(40460700003)(356005)(26005)(1076003)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:06.3897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f56fa265-d6de-4c00-dd9e-08da8b29316e 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: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6371 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The downstream and upstream port Root Complex Register Blocks (RCRBs) are needed to control the ports and CXL devices connected to it. It also includes the location of the RCH/RCD downstream and upstream port component registers in MEMBAR0. Extract the RCRB from the host's CEDT entry. Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index b3146b7ae922..439df9df2741 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -365,11 +365,48 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) return NULL; } +static int __cxl_get_rcrb(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) + return 0; + + chbs = (struct acpi_cedt_chbs *)header; + + if (ctx->uid != chbs->uid) + return 0; + + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) + return 0; + + if (chbs->length != SZ_8K) + return 0; + + ctx->chbcr = chbs->base; + + return 0; +} + +static resource_size_t cxl_get_rcrb(u32 uid) +{ + struct cxl_chbs_context ctx = { + .uid = uid, + }; + + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, __cxl_get_rcrb, &ctx); + + return ctx.chbcr; +} + static int __init cxl_restricted_host_probe(struct platform_device *pdev) { struct pci_host_bridge *host = NULL; struct acpi_device *adev; unsigned long long uid = ~0; + resource_size_t rcrb; while ((host = cxl_find_next_rch(host)) != NULL) { adev = ACPI_COMPANION(&host->dev); @@ -382,6 +419,12 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) if (uid > U32_MAX) continue; + rcrb = cxl_get_rcrb(uid); + if (!rcrb) + continue; + + dev_dbg(&host->dev, "RCRB found: 0x%08llx\n", (u64)rcrb); + dev_info(&host->dev, "host supports CXL\n"); } From patchwork Wed Aug 31 08:15: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: 12960523 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DD6FECAAD3 for ; Wed, 31 Aug 2022 08:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbiHaISX (ORCPT ); Wed, 31 Aug 2022 04:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbiHaIRs (ORCPT ); Wed, 31 Aug 2022 04:17:48 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB86C6954; Wed, 31 Aug 2022 01:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k7GOQjEDGJ0dtIp03ncxt/UOclDvY5jnBF7GXW9mx3dBcax1Jttnb2jQYAPcoJu9IUIDeRN3cuc6bubUPyXSRHQxlC7DEtLtUTQ1NvHkrshjB+oBVIC9XHAQfXPa74swRyNc32HosYdy5nLj61QF0KQt+/of8m/apcWBOce/X+9oNEktYs+Ftc3EkYTk2WfV2Zf/Mvlg2LaBcxvpXvcVFUY4AsVcgjsMVtaE2Xte7W06SVJGyHZ7lpdhkVVmlp1crV6qEiKWY0iAsQQRzV9zWhDFROn6SeqohsxUOyCXH3/ybU3g8QcZbQqTz1e5KQbjGRThP8D11P/F+TquTYau9A== 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=UAQ21ronJ5wXoc2m9ir1X7VABURfwzylIVMW8sW83lk=; b=BBT6Qoe+p9izQ9lmkGRxQSVLwKF4OLWQOW+n+dvOjEs3UTLG7PcgM3yod+gWa9ttLErW1NjYhK+FYZhTbSvcdkokGT4e02Xw477/64ayM12kP+SaKHOSHFTd2PiQqi+alxB15tr21YCwYF+8KfMZk1jm8uEDLRdyG3PqM+uyTCl+hUK7/WJAB8OBDD4R7PswBS6mZsb4X3m4ShGz0iAKa0BzopudgmoJvVQvb0GLShMLbNwGHHpXecoa1q9kIkWa8+Of/pLzeZUxMxm8OhP59ysjWsCXHQpaYNb1cH2XTBJUTeTdi7HybCIGxZrS/xbRG1ldPrGMzL/HnGFcsafFAw== 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=UAQ21ronJ5wXoc2m9ir1X7VABURfwzylIVMW8sW83lk=; b=l3HyvTynqPaQQNtexKiQO+JAZCefaj13BFbJ80EKwNt8CuAcdIuSv8rVaQwMgiI/88Bv9iDIzB6+c0zhoKmJuNfi7tKKLu+y+7qdzJmO2+Kt32Svy7xvHHFMoorYkLBYWMZzs/PxOxGycGh8Suh0trNGZWRX2dh+BhB7nS4FAWA= Received: from MW4PR03CA0205.namprd03.prod.outlook.com (2603:10b6:303:b8::30) by LV2PR12MB5872.namprd12.prod.outlook.com (2603:10b6:408:173::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Wed, 31 Aug 2022 08:17:09 +0000 Received: from CO1NAM11FT109.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::6d) by MW4PR03CA0205.outlook.office365.com (2603:10b6:303:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:09 +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 CO1NAM11FT109.mail.protection.outlook.com (10.13.174.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:08 +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.28; Wed, 31 Aug 2022 03:17:05 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter , Terry Bowman Subject: [PATCH 11/15] cxl/acpi: Extract the host's component register base address from RCRB Date: Wed, 31 Aug 2022 10:15:59 +0200 Message-ID: <20220831081603.3415-12-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 682f27f5-b0b2-4607-d48d-08da8b2932f0 X-MS-TrafficTypeDiagnostic: LV2PR12MB5872:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vo45bC94gBVvI35we4tqHBSfPENmEXfgpBt4KjOqj1VY59N0N8vDBgF5vfqbLq8IAa1pOTVBY0LRsbN2t9IupMqkb6Eku2XOR78HVWXl3F/mKdt1hrnlSJNWZptoSJRlmRNjrO3md91hXp0svpo84S/bmp4MHfIt6sk+wTOt135bqjXNmKN0uQYuWUIYlvCf9wxpBruhU9Mpmk311BzDLRUzAcpYe4OoP6fhdtX7O25+m0zIlUMjkqooltPOzKNFxO9LfLP8TiY8wPqH6LKhEKtBnOX3SAgv+OfnXXLEm1UJhiWY7CPAstYP349gpaonXzQTFH+vTbjEEUD/hGqFXa0rsqZzBzSxGSDPc6Li6drXg/c0QmGogbNdthlifBawo6s8mZcH6qD9k977cj/MpeAErXVoH9lrXobJOfAPdj1kxZhprJ0Hj9nkCrWNk7ep1mRHP7jbwbd6evuUUlLLNX+f3+ta6sc7gtWFt9ClLHyka+NVJF4L6KAtisKhZ2e64wuOl3ev+qn18PUu2NJ96Jnsz6jKrAHb2XPqaJcKzevvz0u/5iITj2MBoStRlt1tP9tXtwpjcOCWi1Z9s1kmn5D9sVp0xUX7CkD/N1MYTWjPAYUGXfZXq+FdmpxhwiYv3N0aJruA8cGOgGgOfEaZroOde9VaBq5SVJlwGnESwrMmXT8cWtgcY9DMTZSRkoPROY1GMUkl8w89p6F9NN70YE/5bQCNFrZyNWtwAuSRc89CFQsMTcO+eDloCfTbytaiOlaH09IGXw4sH1Lcj+WuF3KzpnnZD69GiwnB5LTavEo6ttVbBCh/7bNTr08LiADF 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:(13230016)(4636009)(396003)(376002)(346002)(136003)(39860400002)(46966006)(40470700004)(36840700001)(26005)(54906003)(110136005)(1076003)(81166007)(70206006)(316002)(8676002)(40460700003)(36756003)(4326008)(70586007)(478600001)(41300700001)(8936002)(5660300002)(7416002)(356005)(6666004)(82310400005)(82740400003)(2616005)(2906002)(40480700001)(36860700001)(16526019)(47076005)(426003)(83380400001)(186003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:08.9191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 682f27f5-b0b2-4607-d48d-08da8b2932f0 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: CO1NAM11FT109.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5872 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org A downstream port must be connected to a component register block. Determine its base address from the RCRB. The implementation is analog to how cxl_setup_regs() is implemented for CXL VH mode. A struct cxl_component_reg_map is filled in, mapped and probed. Signed-off-by: Terry Bowman Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 439df9df2741..88bbd2bb61fc 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -401,12 +401,84 @@ static resource_size_t cxl_get_rcrb(u32 uid) return ctx.chbcr; } +static resource_size_t cxl_get_component_reg_phys(resource_size_t rcrb) +{ + resource_size_t component_reg_phys; + u32 bar0, bar1; + void *addr; + + /* + * RCRB's BAR[0..1] point to component block containing CXL subsystem + * component registers. + * CXL 8.2.4 - Component Register Layout Definition. + * + * Also, RCRB accesses must use MMIO readl()/readq() to guarantee + * 32/64-bit access. + * CXL 8.2.2 - CXL 1.1 Upstream and Downstream Port Subsystem Component + * Registers + */ + addr = ioremap(rcrb, PCI_BASE_ADDRESS_0 + SZ_8); + 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; + + /* + * Must be 8k aligned (size of combined CXL 1.1 Downstream and + * Upstream Port RCRBs). + */ + if (component_reg_phys & (SZ_8K - 1)) + return CXL_RESOURCE_NONE; + + return component_reg_phys; +} + +static int cxl_setup_component_reg(struct device *parent, + resource_size_t component_reg_phys) +{ + struct cxl_component_reg_map comp_map; + void __iomem *base; + + if (component_reg_phys == CXL_RESOURCE_NONE) + return -EINVAL; + + base = ioremap(component_reg_phys, SZ_64K); + if (!base) { + dev_err(parent, "failed to map registers\n"); + return -ENOMEM; + } + + cxl_probe_component_regs(parent, base, &comp_map); + iounmap(base); + + if (!comp_map.hdm_decoder.valid) { + dev_err(parent, "HDM decoder registers not found\n"); + return -ENXIO; + } + + dev_dbg(parent, "Set up component registers\n"); + + return 0; +} + static int __init cxl_restricted_host_probe(struct platform_device *pdev) { struct pci_host_bridge *host = NULL; struct acpi_device *adev; unsigned long long uid = ~0; resource_size_t rcrb; + resource_size_t component_reg_phys; + int rc; while ((host = cxl_find_next_rch(host)) != NULL) { adev = ACPI_COMPANION(&host->dev); @@ -425,10 +497,18 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) dev_dbg(&host->dev, "RCRB found: 0x%08llx\n", (u64)rcrb); + component_reg_phys = cxl_get_component_reg_phys(rcrb); + rc = cxl_setup_component_reg(&host->dev, component_reg_phys); + if (rc) + goto fail; + dev_info(&host->dev, "host supports CXL\n"); } return 0; +fail: + dev_err(&host->dev, "failed to initialize CXL host: %d\n", rc); + return rc; } static struct lock_class_key cxl_root_key; From patchwork Wed Aug 31 08:16:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960522 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B599ECAAD1 for ; Wed, 31 Aug 2022 08:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbiHaIST (ORCPT ); Wed, 31 Aug 2022 04:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231451AbiHaIRq (ORCPT ); Wed, 31 Aug 2022 04:17:46 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05FDFC6B6D; Wed, 31 Aug 2022 01:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etrKwr49L9l5gwhkYQtweUz99Z6a0sRYNLA0+teNXVsqAmU6FqzhfRwthlCBAso+J7fpcvnJoOMIu2RfDzCXUDqEZKohqg0PKTFbTbmuqdxBfo7kxozg4KKwB0tCKkvYRavJzqL2sr0hQ31VXXO46U25S4lsvq8ZKW+v+4eN+NPq93rBwgUjYgpocr39t8CMyizjBSINj1Vp8AAckI5Y0hShY+vWT7mPgpcE8UNK7TAAuspsEFaFujmegaiTuGth6SeCVbsBiZaErlQAyazHgGEZu0Hm7laLRF3DPTSsTGNhNLac2BCsqm7iXb5w3gzSPuO83oNQh3DfirB36mDoYg== 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=SsnhNCKPTAHYFFnSjZCo3SPpqvwq1VPCUKkE9GXII/Q=; b=jzZKnPTx/b0Iw5uScEWUIhZe2tOu8Fu9UQvm63yXmNRzcPlHg8cVM4YRQF5OGS+41c2wXmyiI/Fzc6+c4Dbp7KzFW43/P0LjToDMDChP81kx1yXEhuoUKmwlDrjNM+5d8aDkAB/vqMdePikN4+9esDZKgnnhTPnMeMJVz8fGcl7dKEjS2glvr29vxUFivTmsJSi98OlxRKQcfl7hCp8DG4jMSM4jt44j0abB8yugNbP3/lwfy6o+u8zJHe1XLj9CWHSq5kUqH0IopgLbKPNmu6NqSCP2xIMF0bzP7dSgss/kLtSIcS7b4Fu4K10vW4u5rwQwjwGkoE8miLiOraWYlw== 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=SsnhNCKPTAHYFFnSjZCo3SPpqvwq1VPCUKkE9GXII/Q=; b=uJea5qe2l3jCJFTSAcASgNgTJyuQIHBD7OBTVl4L7WKq8gyaF9PiA1qkJoKbHIXE+Teb3UoA1PkkmE/a6LXUKRCdO87ctZNeEdocwxHztkMLqnxATN43o9t0pBZUSf4uJ2C7PDlBrWayRu5TzWf+8sKOMssaiK973PmAr9SoXzg= Received: from MW4PR03CA0207.namprd03.prod.outlook.com (2603:10b6:303:b8::32) by SN7PR12MB7346.namprd12.prod.outlook.com (2603:10b6:806:299::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:17:11 +0000 Received: from CO1NAM11FT109.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::57) by MW4PR03CA0207.outlook.office365.com (2603:10b6:303:b8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:11 +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 CO1NAM11FT109.mail.protection.outlook.com (10.13.174.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:11 +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.28; Wed, 31 Aug 2022 03:17:08 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 12/15] cxl/acpi: Skip devm_cxl_port_enumerate_dports() when in RCD mode Date: Wed, 31 Aug 2022 10:16:00 +0200 Message-ID: <20220831081603.3415-13-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 911d3b03-8eff-41b8-81dd-08da8b293469 X-MS-TrafficTypeDiagnostic: SN7PR12MB7346:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BC3V7m72CdyCnqmdNBN+5WDI6W+WfoljQDczVc9mKdR76gCWCmfrCre1EETUQ6B8bFOJXpIvtt0eFxQdPq+aDlvVPqRd1TO9pnmQgRqgJ2M6+rCrNsgYlmymD0B6UpR2hRmWFdRzckfePu4qljPWFsApLwHzDQ10+hHIfDWWqe/s08XstNR/4u0YJcXSJsojCPTJVHmegM+eeTdBh1FdGJXZelnJN/CyFTJdFOeqx69r3BiGfY8K26Tc3UZd8uEuNSlsqmgB9y/ZQ+g3JrhjqOunysMjiIzu4ngOSDAwFHOpBHwu3/KlFEhQvyIqD18UPVERYChpK8NaVHAIpikiAxEKOKqMkF6g4YEYAMjDtjqucUz5MhSAlmHN2KMtGwEpeMP/pBCsf3JVroGYK+HUlszKJDet4EcAGxerw+ArNfOV0xUrohNl9/ynNI5pCwPpz744p9VCIj1DACxw151c9bJOZHkBDJIGRMYV2asr++BRoTyzzHQRL96opZhSxaQDmZV6TTbeqi50QsjSqiMX5A59X3HBqNESwwAI9e/Hgg+GLDZlSikMj/mI8Yy/OqTYYAW1VyQtFGhOhOE4o9IXlBKtvQM0TITyAjqrq8xpNVO2mEArx2w9sSnVnazEVW/ajBF6x6dkjIp+QaQNcVAjMj9JTF+QDYjBamSlFXBujMROyDUA41VBlXRH6FZGmWNJk2uw9Dvlcxq3+UYvxruuq6akyRA8QFjsG+GdMD0Syi2M4XMw5UQ6nAEiAEIGHYPJxJCEIq00SmGaqwM0a7QABEEkXZKV6ppRkBrD/YybdF3OzQEhA/SQ6XdWwQbwCpst 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:(13230016)(4636009)(396003)(376002)(39860400002)(346002)(136003)(40470700004)(36840700001)(46966006)(478600001)(6666004)(41300700001)(40480700001)(36756003)(316002)(26005)(82310400005)(54906003)(110136005)(356005)(81166007)(426003)(1076003)(47076005)(16526019)(186003)(2616005)(336012)(83380400001)(2906002)(5660300002)(8936002)(4326008)(8676002)(7416002)(70206006)(70586007)(36860700001)(40460700003)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:11.3721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 911d3b03-8eff-41b8-81dd-08da8b293469 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: CO1NAM11FT109.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7346 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org RCD mode has a different enumeration scheme other than in CXL VH mode. An RCD is directly connected to an RCH without downstream and upstream ports showing up in between in the PCI hierarchy. Skip dport enumeration for RCHs. Upstream and downstream ports of RCH and RCD will be setup separately in a later patch. Introduce the function is_rch_uport() to detect an RCH port. For RCHs the parent root port is not the "ACPI0017" device and instead does not have a fw node connected to it. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 0dbbe8d39b07..86ed112eb262 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -65,6 +65,15 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; } +/* + * A parent of an RCH (CXL 1.1 host) is a plain platform device while + * a 2.0 host links to the ACPI0017 root device. + */ +static inline bool is_rch_uport(struct cxl_port *port) +{ + return is_cxl_port(&port->dev) && !port->dev.parent->fwnode; +} + /** * devm_cxl_port_enumerate_dports - enumerate downstream ports of the upstream port * @port: cxl_port whose ->uport is the upstream of dports to be enumerated @@ -74,10 +83,19 @@ static int match_add_dports(struct pci_dev *pdev, void *data) */ int devm_cxl_port_enumerate_dports(struct cxl_port *port) { - struct pci_bus *bus = cxl_port_to_pci_bus(port); + struct pci_bus *bus; struct cxl_walk_context ctx; int type; + /* + * Skip enumeration in Restricted CXL Device mode as the + * device has been already registered at the host's dport + * during host discovery. + */ + if (is_rch_uport(port)) + return 0; + + bus = cxl_port_to_pci_bus(port); if (!bus) return -ENXIO; From patchwork Wed Aug 31 08:16:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960524 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67732ECAAD4 for ; Wed, 31 Aug 2022 08:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbiHaISY (ORCPT ); Wed, 31 Aug 2022 04:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbiHaIRs (ORCPT ); Wed, 31 Aug 2022 04:17:48 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0407CC6B7C; Wed, 31 Aug 2022 01:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQT4EhNO8xna9j5Bs7Oz55sYQOq0IzB2V7eAxaumENriLnXitjgakqmn3J/KPFn8XrXCOWFuO3KS7t5iu1ffTDiuz+l22qZF4vHAa2IjRoOg3mbdIQjtiZhwR9zelm2/NJpOwiYxpPF2SReprFAf+k0r+RgN8qqqnj/thnuJu2Ne0Df4x+LQyWWZ5u6xTxoEhLzqXbNPXb2jJbW2FIMQNTawt10VC6a/bxTEXy33EPC1g+bVC+ifwGIClnAnZUvKl+76q3F856F3DLPbl7mzthh486uOLu9gZb/gAavMEb43+0OAf4nx0bZ5Di3Jk4/Y/+fnuOcNzZ02xgK/b1kRTQ== 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=npmUcNfBPE1lgkLP1GY2kCBueBj/1FtBwIB5Pz3Gz+M=; b=aCJGzbAChKu7eEYklGMRAzNc0eKSfawG3lEYlhSjhyY/T96aZfoFgaugkVbwj3o5yk9B0G86k9dBoaeLyIuG47X4yyA/YHZhypioPiZdl3fHFAn58D+Np6/z334jdYveeynMc8unXOHtIcdEQkHWWspfPdC/kfGTFaPUylac8yeJ78Zrmp7jFrPfaeIeVq5Tin9vCfoAMQATLZ9EEXDrbxUR+M/MhKLnbOexEG8/7VEqRYTjSYDEDg0ClDT5mGy6WVikRdUD9ia9mMmX7xlvpC4oUAwM18d+EFBQs5Z0OS2Gx+1rL/UqHGHDJvk5EVbb13pyWigx6mgoHd5ba+PO4w== 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=npmUcNfBPE1lgkLP1GY2kCBueBj/1FtBwIB5Pz3Gz+M=; b=TYEMo0JlyMpKwneqrdJDEis+r1IORfjwAXPMGrZq0+1gsBZX1e85L/Fz2aVnN4Jn1g1SI2Twf4NvmoQRwtUJHooHXzBoivxsZ96Gg6OGS+tZj9B1JLS5+lPciI8zcCHHal5B9HQOGrZ7S5f2Rj6TSaNdVbI1srCalw4Dl+OU6v0= Received: from MW4PR03CA0086.namprd03.prod.outlook.com (2603:10b6:303:b6::31) by DM4PR12MB6495.namprd12.prod.outlook.com (2603:10b6:8:bc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Wed, 31 Aug 2022 08:17:14 +0000 Received: from CO1NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::88) by MW4PR03CA0086.outlook.office365.com (2603:10b6:303:b6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.18 via Frontend Transport; Wed, 31 Aug 2022 08:17:13 +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 CO1NAM11FT027.mail.protection.outlook.com (10.13.174.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:13 +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.28; Wed, 31 Aug 2022 03:17:11 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 13/15] cxl/acpi: Rework devm_cxl_enumerate_ports() to support RCD mode Date: Wed, 31 Aug 2022 10:16:01 +0200 Message-ID: <20220831081603.3415-14-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6875b152-ee97-41ce-477c-08da8b2935ba X-MS-TrafficTypeDiagnostic: DM4PR12MB6495:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8SFTM7nGyFMrJrgCl+uIbfYByPBqK5BaIhOXJMwK0s7sP70LQVXWm5fJch6+T299d+aTwgRCB1+xP0FIbqM+tCQ1UGx/Txyzx3a0dou95afbDjhTHDrBKhrewCzgeoNkTYOOkyPFo/61A3xnKoi3XRrzi1dnlOdVOEDnKgyRZtRCuUKL6k+oA0Z+R3MBSEO1srHTTD60l9HH9jr2xPaKTFcJ5bUByX1uWoeskqUoXXQN1GbzBYsi2eGq7ozT0mBc1cY/OGbd+tP7PfIJiVc9LR8SgWkQOW56+U9h3IkqwqRLWnsLULcnUSJTCTl4XPtUCqkQeQpgBdvQoSYEtG0dPKD2Xj9Hhq7/5bRfVnxglGPK7E6/gj7mx4LvvdJojAYOVaVIEKb5My3CgJsROOdNVjMdjmKtYlR+Mtik2Vn/tHSTLHHZiF7cu+h88hF/XdKC78LE+kEmV5bjHWTrJM/vtdmAAr+sxrRBkaXQOccFrb/Q/W1JVbmPIOcBPg4RA8G+D6CfhGQRGWOe9OXluQzSoAcjeShylM8zZAaefqzY5y5NsqaEdZch0oXUxtBGToIAxzK2p/YbwIYuOVEsKJtjFBSYproL7KDjdXIPdyHoXasIWG9ZJRyH2JZSw+EoMnlqVk7/i2hBRDkb3UlmLAbqCCnPwp2ELnN2M8V7833xFwv5epmKCZqKCVCGVb8so1RUumqPHboFfSVuLoFOknmd8tglV7woos3NoCIs/ojCRmjaBfTA8wZHO87e7gFfEaqKrPPtzG+IG3QycGnk8DTBGY7IqLFWtPT+pCXSGbYRt7rjGYrlDSC9iGIkk3ZMAvjd 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:(13230016)(4636009)(376002)(396003)(136003)(346002)(39860400002)(46966006)(36840700001)(40470700004)(7416002)(81166007)(4326008)(8676002)(356005)(70206006)(70586007)(36860700001)(36756003)(82740400003)(47076005)(478600001)(83380400001)(426003)(336012)(16526019)(41300700001)(1076003)(6666004)(26005)(186003)(40480700001)(316002)(5660300002)(54906003)(40460700003)(110136005)(82310400005)(2616005)(2906002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:13.5792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6875b152-ee97-41ce-477c-08da8b2935ba 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: CO1NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6495 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org RCD mode has a different enumeration scheme other than in CXL VH mode. An RCD is directly connected to an RCH without downstream and upstream ports showing up in between in the PCI hierarchy. Due to the direct connection of RCD and RCH, the host bridge is always the RCD's parent instead of the grandparent. Modify devm_cxl_enumerate_ports() respectively. Implement this by introducing a function to determine the device's downstream port. The 'for' loop is adjusted for RCD mode and in this case find_cxl_port() will always find the host's associated port and the loop iteration stops. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 61e9915162d5..08b99423dbf8 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1084,6 +1084,22 @@ static struct device *grandparent(struct device *dev) return NULL; } +static struct device *cxl_mem_dport_dev(struct cxl_memdev *cxlmd) +{ + struct device *dev = cxlmd->dev.parent; + struct pci_dev *pdev = to_pci_dev(cxlmd->dev.parent); + + /* + * An RCiEP is directly connected to the root bridge without + * any PCI bridges/ports in between. Reduce the parent level + * for those. + */ + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END) + return dev; + + return dev->parent; +} + static void delete_endpoint(void *data) { struct cxl_memdev *cxlmd = data; @@ -1339,7 +1355,7 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) { struct device *dev = &cxlmd->dev; - struct device *iter; + struct device *dport_dev; int rc; rc = devm_add_action_or_reset(&cxlmd->dev, cxl_detach_ep, cxlmd); @@ -1352,25 +1368,21 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) * attempt fails. */ retry: - for (iter = dev; iter; iter = grandparent(iter)) { - struct device *dport_dev = grandparent(iter); + for (dport_dev = cxl_mem_dport_dev(cxlmd); dport_dev; + dport_dev = grandparent(dport_dev)) { struct device *uport_dev; struct cxl_dport *dport; struct cxl_port *port; - if (!dport_dev) - return 0; - uport_dev = dport_dev->parent; if (!uport_dev) { - dev_warn(dev, "at %s no parent for dport: %s\n", - dev_name(iter), dev_name(dport_dev)); + dev_warn(dev, "no parent for dport: %s\n", + dev_name(dport_dev)); return -ENXIO; } - dev_dbg(dev, "scan: iter: %s dport_dev: %s parent: %s\n", - dev_name(iter), dev_name(dport_dev), - dev_name(uport_dev)); + dev_dbg(dev, "scan: dport_dev: %s parent: %s\n", + dev_name(dport_dev), dev_name(uport_dev)); port = find_cxl_port(dport_dev, &dport); if (port) { dev_dbg(&cxlmd->dev, @@ -1418,7 +1430,7 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { - return find_cxl_port(grandparent(&cxlmd->dev), dport); + return find_cxl_port(cxl_mem_dport_dev(cxlmd), dport); } EXPORT_SYMBOL_NS_GPL(cxl_mem_find_port, CXL); From patchwork Wed Aug 31 08:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960525 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 116EFECAAD1 for ; Wed, 31 Aug 2022 08:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbiHaISa (ORCPT ); Wed, 31 Aug 2022 04:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbiHaIRv (ORCPT ); Wed, 31 Aug 2022 04:17:51 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E75EC6B6F; Wed, 31 Aug 2022 01:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kzds1h/SkOy5tZe7Ju2O/1g5p87vERiQnbwAjy+WSZF0/yAwzrOcIrxNTR7VnpnxWeDL1oXghKaTHgzRF3dkHJcIO7AHE34jd4AxmYTmdpxaI45gdkJpkxccUAQUjvkFxAgonrWoPATANpnqpGAqG9l4X0IObmJP0GdQEaWecZg7f1bdjtR+6/N5MAA3sRtH/99d2K2QJG+HSi/wAW/Tvz4mmHKMopwzGtYihq/YnJnwC2vW7B4QAJl8BGbfVdb2lWP5ASWW9XCab+sRkvYeV/t4HFM8d2s/HCtTsvagnmOKrvp4DyZvHjaStuCBUrmxgB4MF8Z35+lRvFQlHXkWjA== 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=/tD11eTB7Seon+9xLVhsmgPup6swLgTbyewqtaoOHko=; b=ARTvR0WEkSjfgvAux3Grh6Iw6Qa1VRpl/Ax+vJ6qpeNYwq4A6dV4yfbVSEAzfuGIWrR47/x+VsPgj6HeodZczp/0072IaXxgj+SNgSPE5NLaZ6HwATaXjn5f2nGMutkLqf4BlqTrvFQ2+s4z4zbfs+g6bDmS3DNOyJ2DG2Well4/c6Os1/aHOF7KdvyM9HPEYtun0zveykdbCrg0L6huSivWmtb9kqjBSBTG2XncwuypI1qGP0En4L3U/CEy7e1QE8qcClAowbaOKD760xQG1bn6k3y5yMgTeZQlWMpN/I2BH1uuvP28uUp4mJs2jBpeB5E5hJCJiIDB8ABwCyQSmA== 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=/tD11eTB7Seon+9xLVhsmgPup6swLgTbyewqtaoOHko=; b=T336QQElAfh6AskhY0rfDZqBdGLYNVx3YiMpHVC9qMF4xSAK1qAdcd6f/JKqG57PG6j3Pbx/ivuD8bQp4zaK/s/7DMSW5EKHZG4c8Qn0RTzz7b4OJeOe3c9iLnbjX98shpfGuRPGyFwIkb/YQcJMs5V8qMcv3DP1Q/lDWvXgHK0= Received: from MW4PR03CA0065.namprd03.prod.outlook.com (2603:10b6:303:b6::10) by MN2PR12MB4334.namprd12.prod.outlook.com (2603:10b6:208:1d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:17:17 +0000 Received: from CO1NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::c5) by MW4PR03CA0065.outlook.office365.com (2603:10b6:303:b6::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 31 Aug 2022 08:17:16 +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 CO1NAM11FT027.mail.protection.outlook.com (10.13.174.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:16 +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.28; Wed, 31 Aug 2022 03:17:13 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 14/15] cxl/acpi: Enumerate ports in RCD mode to enable RCHs and RCDs Date: Wed, 31 Aug 2022 10:16:02 +0200 Message-ID: <20220831081603.3415-15-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3bb18cbd-c17b-41c4-3d13-08da8b29377f X-MS-TrafficTypeDiagnostic: MN2PR12MB4334:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T8IZVY5j7IvAZ5OtvnEgBLWS7AtGGMplMlUfR+aDDntg8SmRq4BSpwDQzXZYIqN3OOUPXG+6nxB4khU7SqCKNhL19SrxaSLPFDnxWa5lb0d2FVa1eM7q4r+vnuCpp221XJqvAXfQh7le+ubdnomHs+rNmUQJ4SfhsRCJtGoWR09DIxd5MHvMZBeYNs2PbdrsZUKxH4wQp25R6+teJ5jc3/lNphH410CyReKi9VTS2HGOGOJg6XYDmZHc9ZvEKR5+BfqSFCn0Xv+fcDGh9DbtblkK9GQalGVea9OCeOC2080zf7Sr8bjhtcCU8SMk6qq0GTmFcP3ZSSU+j0wk5BBzWnU8/6sxl6+3Mm78s3UuVX5Vc4PjMpOcpiC1TQFG7S3wIEnEfmy1MJUd9K69tFcVVtkasTFCxYeeiQ4YkbHctzFD/MDDNcjxb3iBb45u9R4pD59LPXDOQs+jngO10wgjMGl+q87/m8zG33vKeSjzgSm7SNcII9R3OMmPUE5vqONcPkXvpkJIO5XlIo7oBntUH6rOEL1qq8fAw0GfoZrnBmXFAQpFnRcYSsi1+r1s2QkCBW4CLDhL3J1+p4R6CRAkJrYjbLlrwOlUwmZ3NJH4+/D3+R5i4FMDIOyfLI80c3CoHlGczWeZDcASPtf5v1NADw6W9Qr4y9Av/DpXLdAX4bFYcCzWeECpewlr4tx+wpKSgydLwJkum9+By0/wAdy238mTwLEdwbE0QJHtlvlUfWcWj0oTnokDb/JB2Zat0fF+feZWNvVmqjKBciu0etKQmXOi+Zd5X8uwAZ90sBNOT/C53eYouQXJvHpvMFP9nRcJ 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:(13230016)(4636009)(376002)(136003)(39860400002)(396003)(346002)(46966006)(36840700001)(40470700004)(8676002)(478600001)(26005)(4326008)(8936002)(186003)(41300700001)(336012)(7416002)(5660300002)(40460700003)(47076005)(16526019)(426003)(1076003)(6666004)(2616005)(82740400003)(70586007)(2906002)(70206006)(316002)(54906003)(82310400005)(110136005)(81166007)(356005)(36860700001)(40480700001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:16.5477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3bb18cbd-c17b-41c4-3d13-08da8b29377f 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: CO1NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4334 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Do the plumbing of ports to enable RCD/RCH pairs. Do this by enumerating all necessary ports an endpoint needs to connect to. This includes: 1) A CXL root port with dport links to the RCHs. The port links to the CXL root platform device for RCH mode. 2) RCH ports with dport links to its endpoints. Port connects to the pci host bridge device. 3) CXL device endpoint connected to the RCH. The port creation for the endpoint (3) is already implemented and works in RCD mode too. Thus, it is not scope of this patch. Only the endpoints must be registered at the host bridge port. Implement this by introducing the function cxl_enumerate_rch_ports(). It registers a CXL host at the CXL root device, creates the host's port and registers the existing CXL memory device endpoint at it. The port of the CXL root device is created with the first CXL host being registered. Once enumerated, CXL restricted hosts show up in sysfs with CXL devices connected as endpoints to it. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 88bbd2bb61fc..56b2d222afcc 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -471,13 +471,52 @@ static int cxl_setup_component_reg(struct device *parent, return 0; } +static int cxl_enumerate_rch_ports(struct device *root_dev, + struct cxl_port *cxl_root, + struct pci_host_bridge *host, + resource_size_t component_reg_phys, + int port_id) +{ + struct cxl_dport *dport; + struct cxl_port *port; + struct pci_dev *pdev; + + dport = devm_cxl_add_dport(cxl_root, &host->dev, port_id, + component_reg_phys); + if (IS_ERR(dport)) + return PTR_ERR(dport); + + port = devm_cxl_add_port(root_dev, &host->dev, + component_reg_phys, dport); + if (IS_ERR(port)) + return PTR_ERR(port); + + pdev = pci_get_slot(host->bus, PCI_DEVFN(0, 0)); + if (!pdev) + return -ENXIO; + + /* Note: The endpoint provides the component reg base. */ + dport = devm_cxl_add_dport(port, &pdev->dev, 0, + CXL_RESOURCE_NONE); + + pci_dev_put(pdev); + + if (IS_ERR(dport)) + return PTR_ERR(dport); + + return 0; +} + static int __init cxl_restricted_host_probe(struct platform_device *pdev) { + struct device *root_dev = &pdev->dev; struct pci_host_bridge *host = NULL; struct acpi_device *adev; + struct cxl_port *cxl_root = NULL; unsigned long long uid = ~0; resource_size_t rcrb; resource_size_t component_reg_phys; + int port_id = 0; int rc; while ((host = cxl_find_next_rch(host)) != NULL) { @@ -497,11 +536,30 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) dev_dbg(&host->dev, "RCRB found: 0x%08llx\n", (u64)rcrb); + /* + * For CXL 1.1 hosts we create a root device other + * than the ACPI0017 device to hold the devm data and + * the uport ref. + */ + if (!cxl_root) { + cxl_root = devm_cxl_add_port(root_dev, root_dev, + CXL_RESOURCE_NONE, NULL); + if (IS_ERR(cxl_root)) { + rc = PTR_ERR(cxl_root); + goto fail; + } + } + component_reg_phys = cxl_get_component_reg_phys(rcrb); rc = cxl_setup_component_reg(&host->dev, component_reg_phys); if (rc) goto fail; + rc = cxl_enumerate_rch_ports(root_dev, cxl_root, host, + component_reg_phys, port_id++); + if (rc) + goto fail; + dev_info(&host->dev, "host supports CXL\n"); } From patchwork Wed Aug 31 08:16:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 12960526 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB004ECAAD1 for ; Wed, 31 Aug 2022 08:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbiHaITR (ORCPT ); Wed, 31 Aug 2022 04:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbiHaISj (ORCPT ); Wed, 31 Aug 2022 04:18:39 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76C42C650F; Wed, 31 Aug 2022 01:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emhaj+U3ItD2FsoUb8T2W649Lt0tbuAkv6L/NTTS3lKFcIFe2BwW4J5nl/D6B7bqnw5xC2AX+NZ4BpkZaK0WXsesJSSTvYXFT3RGubXkBGB3rjF4J8gMx8wNYDwFK2sIeZO1Btpin9GqMluySCMs1IdnnRscGbHIjzviIEDKGYfxlxzhiXdc8Mc1ug07WGYlSMFiwRPO/8RPHEiAt28xHfUGMryRCtHVTxcaxQ3MPApTW5lzqBcl5Y4Aii+CVilOQEXoZwe2A/qTMNEaWNCDSnnWTtAAhB6B87yWwlENk/OC82bYZZ+jdiyR3Rrkk9H+0QPns2mOA5fSE7BDik5/mg== 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=zM143r0hLso7D2Wup38yeyCHmpqUSbqxvkXNLlj+lqI=; b=E1te9WJF8J62wFXCfzSqq7YDpMWVPhbBS6Wow+YvCFrsFLzFDnY1w9LoyTFyMt7eik+EUGJg6SnJFgMG+KwJk3XGRgtmW/z6gWy7n6617UmjF01uxec85woij9DJDyqdk75MfcMbN+QF+9sv8Tbki8cVuovBNQC33sR6u1lyouU7VtTg8NNXMYi8BqS4UVdZRm53H3cifnGeLyCGymB3kb+tIpE3R65sE+lFcItfll4x4NR2IPCCZLYJd5swZEnrvxmpWWpdvxVA8tL+Ad8KAMBykg7KfDC9N90AmHM6y9HeI0Dr4Iub2xLHC6oAuMyt+eDpd+BRJ6SpNoiC0P6sXQ== 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=zM143r0hLso7D2Wup38yeyCHmpqUSbqxvkXNLlj+lqI=; b=FDnckVyO4eB9Rvd4MJczFJJYbIcLtP6RB6MRDZouO1AdHD6waLesG6l6uktZKs1wohwQy4Bpi9+sCvFblA1rMdTFfrgDCLHXOY1Eht7ilkc+Fq8lo3pHOBLZQMfJk0o+0kyL4V5KnpPmG3Cl8JNJybNvyMTt5I8a13UafLAxFYs= Received: from MW4PR03CA0079.namprd03.prod.outlook.com (2603:10b6:303:b6::24) by SJ0PR12MB5406.namprd12.prod.outlook.com (2603:10b6:a03:3ae::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 08:17:37 +0000 Received: from CO1NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::d9) by MW4PR03CA0079.outlook.office365.com (2603:10b6:303:b6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:37 +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 CO1NAM11FT027.mail.protection.outlook.com (10.13.174.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Wed, 31 Aug 2022 08:17:37 +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.28; Wed, 31 Aug 2022 03:17:16 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Robert Richter Subject: [PATCH 15/15] cxl/acpi: Specify module load order dependency for the cxl_acpi module Date: Wed, 31 Aug 2022 10:16:03 +0200 Message-ID: <20220831081603.3415-16-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220831081603.3415-1-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f78cded-e3fe-4e4e-6b37-08da8b2943d8 X-MS-TrafficTypeDiagnostic: SJ0PR12MB5406:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3BpeFaP8B3aW8FbY8Wz7Dvggn7654vE4hnJPSTnm/rC1UtF8YLF/q79vnH9m9ICOcKIxM/DA4cvcVrcCOI00HkruG/L/+pKOCw3nyQAo2faAKpHZez39Hdxo6AnHQBG2lU6zmoi+OL8gK4e3pDdRV60784qWKWibKdscYP/gVa5wEn607GOz05e5ShIlmXNCNOv+VNR8eutwqTQ5SIGSV2BESusn+7wQm+2Z5JOMGFhEDz3vljICord1YjK6RwdqWM63xfO4ck3iQIu4UKicWmiPIbFELpxzZejE0YUupAcbFpPftRXWXOCvgz83XlqhBZqeVsfp9ZbXDC2WR8VTWfP0EJaE++tiRmZ3uLVzm3GywIKCzqNZWrHGTETS7YT1x1er7BVtrg/Jq920sFRVy/DB85mGSdkfajKEX00xRRYnh6Q6WAd1ZKHvpLZoCOBpxFohE5OSSEzwwNatb6BiyqdAEuF8PElUE+Z893g/LRvVB/9uvjgodIb0hfgQslg4EU/AA07BO4jZlgMrqkQnggBLXJ8Nj8weMmSjO0Zuh4WL2YSgg602d/c8zEw/Qg7nPiiIQkl7acdwE6iNDNSGkDKRwGtk23UZU6PM99okMbKvnDcWNV3O1FnPbewN5szcoohAP4RGw78rMpStBiagEEO3C6jLz0pz/WaTEMalRiw4r45koeZZNYusiq5ZWDGSvn2vlJfkF2SHPbhq3ZN/pYp6qJjwMVFRq9GLCyVzoGySi5oasUxvywXK56mHC4kI/iSyjBWNMKA8UQyspo5YMmcPYpEIJRn+MDndYOdt7d6Hm5fFVdGteqfEUn+Q/njy 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:(13230016)(4636009)(39860400002)(376002)(346002)(136003)(396003)(46966006)(40470700004)(36840700001)(83380400001)(316002)(426003)(336012)(16526019)(47076005)(186003)(1076003)(54906003)(110136005)(2616005)(8936002)(36756003)(2906002)(26005)(356005)(40460700003)(36860700001)(82310400005)(40480700001)(478600001)(70586007)(70206006)(8676002)(4326008)(41300700001)(5660300002)(7416002)(6666004)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:17:37.2648 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f78cded-e3fe-4e4e-6b37-08da8b2943d8 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: CO1NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5406 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In RCD mode the CXL mem dev may be detected on the PCI bus before a CXL host is brought up. This may cause a CXL mem initialization failure as it expects the CXL host already detected. Address this by specifying the module dependencies using MODULE_SOFTDEP(). The following additional dependencies exist: * cxl_mem depends on cxl_acpi: The CXL hosts must be discovered before the CXL device is initialized. * cxl_acpi depends on cxl_port: The acpi driver adds ports to the cxl bus, the port driver should be loaded before. This might also work if modules are loaded in different order, but a) it aligns with the existing cxl_mem/cxl_port softdep and b) it always guarantees a fix module load order. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 1 + drivers/cxl/mem.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 56b2d222afcc..63a1cb295c07 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -834,3 +834,4 @@ module_exit(cxl_host_exit); MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(CXL); MODULE_IMPORT_NS(ACPI); +MODULE_SOFTDEP("pre: cxl_port"); diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 64ccf053d32c..ae13ec7d9894 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -128,3 +128,4 @@ MODULE_ALIAS_CXL(CXL_DEVICE_MEMORY_EXPANDER); * endpoint registration. */ MODULE_SOFTDEP("pre: cxl_port"); +MODULE_SOFTDEP("pre: cxl_acpi");