From patchwork Tue Oct 18 13:23:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010507 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 DD8E7C433FE for ; Tue, 18 Oct 2022 13:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbiJRNYO (ORCPT ); Tue, 18 Oct 2022 09:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbiJRNYN (ORCPT ); Tue, 18 Oct 2022 09:24:13 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563C6C90DC; Tue, 18 Oct 2022 06:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f4m6zYIVdFVTkQag0r1wcRHykMFLI+EC+1oxOgXVJqmGCmV7KXUHWNXl0hwBV3ZqWLha5nMP/wf5dQsi99i4jfViKLxlNdJzc9NgDuHmpEmryeimE8p3cmHw5FgAt7gzlyZIb3m/m/cG5vTpYdpp2UREXGqGZK85fg1iEv6QmRFdWZYQo4RHn4dc6TAs9KAXE+ZGfm39l9mBQsH4PyAmIQITq3LPfZSaRMTIaGS4kwOMDExo0wpbzb7Dc0NdWQEEeu35Byp0PdTwidgDrR0yQ3Erdr/YWEA8+jcPhS2gISSI11z8PPkZN2YwfW2DJF1POQwIPydWb8UTDIHVrVdvsw== 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=f/a9B99D9lL5e4OLFYu9Rds+YYIxrhyEH/lIibAjCuc=; b=Jd1G3itwddBUPSmh3CD6OFAfvUAocMdM6pX8GpfnSh3XlwDcn8k70y2RX1zhqAy3HBl6DcVlt3Ruz1Z4/bKeCvjVXtGefUskq189pqgI3Ft/BE46JBdLxF45Jf2cgbyLBkqXdA6R2Q0iwproJfqZveNp2DsttudKpMgAkVijXXPwOCqqQgzJCP+zFiOLkNh5yiN8vGNy2KjBy4C8KGdG8waCMI2dLw+QV4ie+N6Kji8+7jaDP+AbA/Ld6lq49PHZLub3vfQIX7M/Hoh3fzT+tQ3BRzHSqOPwt8poj9/Fa6slLm1hash+5cIiL3LDA5sHE22j1mU+5K4eaOXdaG1tdQ== 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=f/a9B99D9lL5e4OLFYu9Rds+YYIxrhyEH/lIibAjCuc=; b=gsuadDpu/BBZL7lgDFf3kZlGQolagQCYIC+tjf/GTu2PXxl6EtWXlxx3rspCQ3O8UAHpkn6R8OfR8gIlrfcaRKihipwJyy1RUlDsSoV4qHUef7+e0LrN08KZliNHFhYMYL4EEtJasYsdK5J+gtT2TUxl+42Y9/dw0Pq7KHf+b68= Received: from BN9PR03CA0982.namprd03.prod.outlook.com (2603:10b6:408:109::27) by DS7PR12MB6214.namprd12.prod.outlook.com (2603:10b6:8:96::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:24:08 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::b2) by BN9PR03CA0982.outlook.office365.com (2603:10b6:408:109::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:24:08 +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 BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24: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.31; Tue, 18 Oct 2022 08:24:05 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter , "kernel test robot" Subject: [PATCH v2 01/12] cxl/core: Remove duplicate declaration of devm_cxl_iomap_block() Date: Tue, 18 Oct 2022 15:23:29 +0200 Message-ID: <20221018132341.76259-2-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT033:EE_|DS7PR12MB6214:EE_ X-MS-Office365-Filtering-Correlation-Id: df98865c-7bc1-41b2-50aa-08dab10c0978 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +QjmsPqXIgcFQ1yCSlA1XCmF5MhTj6JvfvMQHVUHRBDNk18wz2qR+mxRELEcaROu6t02d9EVeQVqjkkiymfsJp2u/JGJUA1VAXKrFdbo11mDwQ2/UlM8ZiHuECg5H+qa685YU2HxerQsuKfM5KrdkyIZR85ExGrWjT2wtcQFem8F7EAhwKyekCe2EMxmMIWjRLrFriUJnbQLDRPNpr5TorQRlPPiusujpnIGJPR3mraTz8HFbJSLu241j+DaFFfsUoMjlYusqViEvDuXq5Xuly0B0Lk8tVoSkW+Ro1Zyrx1VOcLJqKYBUqP8V2ZnINmGyMoIwIYIJZgw4QZcT0W1FFDEp8epXTQ/ISscBCGYZd0a16CmfeHODVNXNyiw5GVq9a/Vr7V4nSulPh2hPZx6qDGeRLTUwPBgZ1KXRb1HpXWIBX8SoJg8lmGuzQAu/W1Rl67w6aMSeHiBat57tXtUR86t93ijnQAif99W1q5/mjHetNePf66n8PRTZsdDzgYg/yJDRcr30k8IP05GkFvRY1z30ORhoc8RnuMMBni7NXJ5q6QnrM6ibXPT4H45HNxtBct+UzRSC2NOwEIcPkw1KtbA7HXmgb83o72nEzAisCQxz4ACDKBLqZFadnouCQ0a9Tau3JuGl3NzhUnieyeQZFrMGidrvbS9s4qIWhfxG+6a2q/vJ5jkcGRyqvNSZez6URDj8loHdnZ+NlAacj/qLcgZSi8k2exDTALaV9RDkWUKARabCd37Rc2ZJwn2vM6FNOTJQOqxBr2DblwjkuGUrXNPn4KbosKx3rYxOj+NawNxMgK8A4QwN4K/X24btSK5 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(46966006)(36840700001)(40470700004)(40480700001)(54906003)(316002)(110136005)(478600001)(6666004)(41300700001)(26005)(8676002)(4326008)(8936002)(2616005)(36756003)(5660300002)(70586007)(70206006)(2906002)(186003)(1076003)(16526019)(7416002)(83380400001)(81166007)(356005)(40460700003)(36860700001)(47076005)(426003)(336012)(82740400003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:08.2481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df98865c-7bc1-41b2-50aa-08dab10c0978 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: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6214 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. Fixing build error in regs.c found by kernel test robot by including "core.h" there. Signed-off-by: Robert Richter Reported-by: kernel test robot Reviewed-by: Jonathan Cameron Reviewed-by: Davidlohr Bueso Reviewed-by: Dan Williams --- drivers/cxl/core/regs.c | 2 ++ drivers/cxl/cxl.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 39a129c57d40..6522931df3f7 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -7,6 +7,8 @@ #include #include +#include "core.h" + /** * DOC: cxl registers * 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 Tue Oct 18 13:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010508 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 2A2F9C4332F for ; Tue, 18 Oct 2022 13:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbiJRNYQ (ORCPT ); Tue, 18 Oct 2022 09:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiJRNYO (ORCPT ); Tue, 18 Oct 2022 09:24:14 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468BEC90F6; Tue, 18 Oct 2022 06:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZrIT8Au7mHz0qvqVAt9uqAD2Cen8qmaxCm6NcI8cU9qGijxLOOTCs2OXplI50m4z+WqhRxnW19jq8FgrbCGN99XYrSPwoutzk4SNgh/DCo4ni50dAqmyWQv0rLuqBRtOjef0Pa3kt5uDvKcaPIFoQZC8OWQUKmCiUPc07FDtAbNsVOuWajjUQAwiAkaHdjuw1eRT2ZIMTqa9T6r5eD650jUD94t7vw81SroMrspJO1Y5VwxXz2GsrE3eakvkYsv1Otlo29NUVPo1Od/cdePvNEhxUCIKHaUiH7g1I8kk4UnuJpO5sEFOKpw/6T/UhBrzCBSlUvLZ5y1x6j173j/P/w== 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=47+f61TpEsMFiD0B0ONpB5IacOSc5hZ2xFu1rQIZLYA=; b=QDVoRboyd2nwcvNeEq4Yu0NGn07/FrWVDoqDrTpE7EYjO5o0mCo5vC5jb3X3jW+/+en5YfCNbRiaWM5zRPBN0r4RG9jeo/UDy4b8AAx9R/2KXuCsHGJG/8oVL+7Dpqmqr3DlMqItjR74M1HPT20q02SkBoUNo0L05Qz/VXiJbrWUVhIsc17pXbR0gMNCqN6zuDjXg/Pg5wiZMlFFJVZo+abvYWzI8LYCRY3y1QrmShQazDWESQKDpKdaUVFhzx/JRncmPafta/bbNrl1YN65q101QXQIxVRCHMg5J8J5uBjsHv9H0KBhQvGKN+nnKo0exvU2+oi5VK/cmU0g7IyAfw== 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=47+f61TpEsMFiD0B0ONpB5IacOSc5hZ2xFu1rQIZLYA=; b=fwjihMT4m0+pRbjS8TES0P4QVj6WTUyAfGDsJRUlItlJQD+NYw84OuMXxDglTRQF3+q1gWNfM1OUQS/YkS1EoJoAZR5bfbCsUY82sfRytNfj7diPWUvvvzaAIOeTj7tPlyxIYbqmnCM2eJ1oRLYlHThSaorHC5TP9Xaujeck+qA= Received: from BN7PR06CA0040.namprd06.prod.outlook.com (2603:10b6:408:34::17) by CY5PR12MB6407.namprd12.prod.outlook.com (2603:10b6:930:3c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:24:11 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::60) by BN7PR06CA0040.outlook.office365.com (2603:10b6:408:34::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:10 +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 BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:10 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:08 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 02/12] cxl/core: Check physical address before mapping it in devm_cxl_iomap_block() Date: Tue, 18 Oct 2022 15:23:30 +0200 Message-ID: <20221018132341.76259-3-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT098:EE_|CY5PR12MB6407:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d7d4f90-a23d-4aa2-f163-08dab10c0af3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bqzvaQFEHaOv71jBntGsTaO8EChuJlLpUVPyofvD9jsMVwV/ZgsQYqiS3QGYm79P1q9FL41c0YjIcyO/Kwh9QUJNYlbeghDDnEbnR2RXi9gBz/iwGD7Q1M8qvNAlPuZhtJI5dFHPngn1AYvnR4FLL3BYQwIH+vLpY0pzABPMUbA7sqmFAVDnz5ck59hZ9/yFlV0FmGgG2F+7/E0t6sk6TvjCewUKTLXGRJ9GPkMymQMu06yqc5MY+abWYUYvMCYV6utrbaBIt3Y5WDDEDoLlpWY7I9hA4wn6R+GrqLqfNcFzJVFl0AdN84/uI15sTxaUBv64LvH9m8HAlEfwtL2x51+GMszQEa0mwFthS4hVz1xPX1UxlBvAGb3QfTc6+dhIiulZtKGuwb38D2rdr7ouC0uI8+AlgYnGdrJcicIys6xgX4YqJnwrBF82LWoIHHfgI6FbsllkkVV38eXrgfMwzX+DzrIOQzBf74637BWrwkf3XnSFRmH8+Fh6E9c4qiaMScWyPgoN+9vxAcf1qZH0yq4MoodGv6Snq18tAV1nW1SlIrJXcblRy+L7b3mDDRDuzb7Uva2Kwz2Uxq8IgaijDkCqjxD6Kx6mQhOtr1SZSghCyCMnzOqngoE+FB6Rv0riDqJXIi601YbUnLe/ktfSvF8f7u0NUWx9Rs1HHGxQIURa/R4ituumpjt3/RGVOEuhdZ9X8MbXd7vXH3y0k783yTqwdl7vz4e1NbNgSW7Xo78itZqWlvqXaJ8PsUEdExw1DOQgXpPxYcUeQbMdMBfZq7t/BJPqRlOmTz0H1N0udq7H8j69csjaXIMuEgvQFte7 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(6666004)(41300700001)(110136005)(82310400005)(316002)(26005)(5660300002)(54906003)(8936002)(40460700003)(40480700001)(81166007)(356005)(4326008)(478600001)(36756003)(70586007)(8676002)(83380400001)(7416002)(70206006)(47076005)(186003)(16526019)(1076003)(2616005)(2906002)(336012)(36860700001)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:10.7360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d7d4f90-a23d-4aa2-f163-08dab10c0af3 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: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6407 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. In general software shall prevent such situations, but it is hard to proof this may never happen. E.g. in add_port_attach_ep() there this the following: component_reg_phys = find_component_registers(uport_dev); port = devm_cxl_add_port(&parent_port->dev, uport_dev, component_reg_phys, parent_dport); find_component_registers() and subsequent functions (e.g. cxl_regmap_to_base()) may return CXL_RESOURCE_NONE. But it is written to port without any further check in cxl_port_alloc(): port->component_reg_phys = component_reg_phys; It is then later directly used in devm_cxl_setup_hdm() to map io ranges with devm_cxl_iomap_block(). Just an example... Check this condition. Also do not fail silently like an ioremap() failure, use a WARN_ON_ONCE() for it. 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 6522931df3f7..ec178e69b18f 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -167,6 +167,9 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, void __iomem *ret_val; struct resource *res; + if (WARN_ON_ONCE(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 Tue Oct 18 13:23:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010509 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 B2D34C433FE for ; Tue, 18 Oct 2022 13:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbiJRNY3 (ORCPT ); Tue, 18 Oct 2022 09:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiJRNYS (ORCPT ); Tue, 18 Oct 2022 09:24:18 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2084.outbound.protection.outlook.com [40.107.244.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BD8C90E9; Tue, 18 Oct 2022 06:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvekJYqY1nNyuoyTQGmXABUzUe6OhqankkHNa8g30SUqgDEz9ejrXE8wScXg+mIls43TvFLgI9fyDAfG0VVtIMNaMRuR6rW2ICu4d01KB2ihpq5S7XePL+MjXfgTyDo7IGSkoSFOwtQAlxB2SKWDMo8PL3cyHN1UyXQXptBFl6bCIriksPEAUFlPSdSCKAgwUkHqR1zbkreVQNwgj9MQOCWWNuLHWT9xo23h+elfndjOYEQERmy/CL57Q5zbrawziOPSnMXBDIL4L/jhMrIJ86CnNznpH/pZlCzD19wNgk70g1vJRg1+m+AxgifWpv+vwQM4SbH5+mxuI+Bv7DwAqg== 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=7VI7/Md+lydGPyjBUrpWJnTZAnscxR9jQx0xHAMMwxI=; b=Fl+8k6XU/tg/2mni+CT3zORfaiR4Ry4hPe1jkhFTU511f0EjfascWBWjca990sJAEbwwKJFK3EhjcGR6VzIZQecNEL8ksDet1hMENVMs15Nv1oSSpz1lXO5/aI9u2xYAcomzD+vO9wGDC8yrpiizHRAu7GOakjscqQJAbfB7/NzHxlEGbHO+/v+q2EWVxxRhv4na/m4O8aEPwnoaJn7wxsGA5LgWBFOfvo6c5FKmgjHkIatwgBZ9XJH2/d9SLtweooqlnuEmXpWUgymNqSp3P5YtoEa9dTVSW/QXiBN+KJHfr3KUwD3TCWlFWqIPzua7RS2blG2giuNpIF3GO5ZcVw== 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=7VI7/Md+lydGPyjBUrpWJnTZAnscxR9jQx0xHAMMwxI=; b=pN/g8q4eqKMlqriLXADB+RqxMCeGRzS6yNyAy/z48f72vgLnzCDIwIb2dp9CIDtIU94urW8NFAhoa1DiUisVPVPPC27/8XELdB76tg+IuTGzDCASFuN/59RL8v5Bg6OkdqfKgvhjigSb2K6+UpBSwJVcBA77q4+Ki3ybP1ZldPE= Received: from BN8PR16CA0032.namprd16.prod.outlook.com (2603:10b6:408:4c::45) by SA0PR12MB4493.namprd12.prod.outlook.com (2603:10b6:806:72::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:14 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::b0) by BN8PR16CA0032.outlook.office365.com (2603:10b6:408:4c::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26 via Frontend Transport; Tue, 18 Oct 2022 13:24:14 +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 BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24: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.31; Tue, 18 Oct 2022 08:24:11 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 03/12] cxl: Unify debug messages when calling devm_cxl_add_port() Date: Tue, 18 Oct 2022 15:23:31 +0200 Message-ID: <20221018132341.76259-4-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT009:EE_|SA0PR12MB4493:EE_ X-MS-Office365-Filtering-Correlation-Id: 55624dd2-140a-4275-3dbd-08dab10c0cbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwj/PHQH/F/b3AErb47P9wTmU3v34TiZDF7Pc7BtLrkrsu9GmhWRyaKeaity82Qd0bBn+XW6pq0Tbn03JGZBLXaESP5dDUn0tLQrPVlFl4NEqbXR3k7wSPX/dtgdKsddOKe+JMsX8/5GsMpegf49t/Q+8mtuVUqANBooUnCpRkdHmszbLYiF0qgAp316WjQpdxfvkWiB4X7xmECT8vv5zUHu9lTnFXcmIrtQOx38QnPrPSpE27cLJLY85LSxLRIKCJ0rvaLw7Nq0ygCR+1ec5iKGnEO4dWMEwQJMjnwEfp4b2N9zYimMe29SjwgBdAP1otGfppudBKO74waNEp6b1i44cjv5UhqTxL3x6iJVroWp50QFFl7F60v5P4JUqkf7PaSopGXD9gre1tfM1IWqeJ/wKJ8mXR6v1Jas66Kg8AF3KIFTlMVHdt0XG1lUtav50Ya7crzMTIWClW9NT5q2UHzc3kMTpft3kiTLHudzVmtox28kPyVDmVPg2Y3w683Ew4ge8L0Ci7TG9igzjMdHAZpwVVedyaQTJynpHwSH3tkGW+9rhKXcqHFrPnUYNiuohkl/+fK+8pd9CNBqe7hhWFNI2wpJuo4YZ00ZR6cg2FYBM2GJkOfW2Fa25zCf6uoALxfTrj1p9qay2sHpLMUjzyBDRQYDB8dqZY2WOuEQQgdtiLQIEydbKXLlrEZA2rMQbZowuyGLw6hpta30LOIAaGP1ZhtsuzIi7NpltEFqncxGBowWRFdpXTcvZMZT0SNTdxnbvZHSHQCirR+Y7WZarnOb8eWE+CvNyBNi3S2V3X800xnKC/7FED3AGt9O3ipW X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(2906002)(15650500001)(7416002)(8676002)(54906003)(70206006)(4326008)(110136005)(70586007)(36756003)(36860700001)(478600001)(5660300002)(6666004)(8936002)(41300700001)(26005)(83380400001)(316002)(47076005)(426003)(40480700001)(40460700003)(81166007)(356005)(336012)(186003)(1076003)(16526019)(82740400003)(82310400005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:13.7395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55624dd2-140a-4275-3dbd-08dab10c0cbe 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: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4493 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. Use a __devm_cxl_add_port() wrapper to keep the readability of the error exits. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 2 -- drivers/cxl/core/port.c | 51 +++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 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..9bfd01b4e5b5 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -655,16 +655,10 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, return ERR_PTR(rc); } -/** - * devm_cxl_add_port - register a cxl_port in CXL memory decode hierarchy - * @host: host device for devm operations - * @uport: "physical" device implementing this upstream port - * @component_reg_phys: (optional) for configurable cxl_port instances - * @parent_dport: next hop up in the CXL memory decode hierarchy - */ -struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, - resource_size_t component_reg_phys, - struct cxl_dport *parent_dport) +static 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 device *dev; @@ -702,6 +696,41 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, put_device(dev); return ERR_PTR(rc); } + +/** + * devm_cxl_add_port - register a cxl_port in CXL memory decode hierarchy + * @host: host device for devm operations + * @uport: "physical" device implementing this upstream port + * @component_reg_phys: (optional) for configurable cxl_port instances + * @parent_dport: next hop up in the CXL memory decode hierarchy + */ +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, *parent_port; + + port = __devm_cxl_add_port(host, uport, component_reg_phys, + parent_dport); + + parent_port = parent_dport ? parent_dport->port : NULL; + if (IS_ERR(port)) { + dev_dbg(uport, "Failed to add %s%s%s%s: %ld\n", + dev_name(&port->dev), + parent_port ? " to " : "", + parent_port ? dev_name(&parent_port->dev) : "", + parent_port ? "" : " (root port)", + PTR_ERR(port)); + } else { + dev_dbg(uport, "%s added%s%s%s\n", + dev_name(&port->dev), + parent_port ? " to " : "", + parent_port ? dev_name(&parent_port->dev) : "", + parent_port ? "" : " (root port)"); + } + + return port; +} EXPORT_SYMBOL_NS_GPL(devm_cxl_add_port, CXL); struct pci_bus *cxl_port_to_pci_bus(struct cxl_port *port) @@ -1140,8 +1169,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 Tue Oct 18 13:23:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010510 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 83FBDC433FE for ; Tue, 18 Oct 2022 13:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbiJRNYd (ORCPT ); Tue, 18 Oct 2022 09:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbiJRNYb (ORCPT ); Tue, 18 Oct 2022 09:24:31 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49700100C; Tue, 18 Oct 2022 06:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfhQNpFw96RsM5zs4c995JcvRmRkgwW3Cs+CkNqkljkwv90nxEz696GjEa3493fx+1bau3ngtaBH4dW4AnejCVXHGRK/sfdmaLuOWTw45tjTiO4BTPrFZvbpb/6wIB81NsRuNiIz/Km0dYiY83Gs/xc5tw+kwSMh5HN45ulQDrh/GMON6H/uqpiiGEsBwiE9leKs5MmR6rlYCRRsMMWkrf2IRLMH77+F4rA3Vd2Lz4IfpnV0aR15FcGKk1BYAp8Ry55ESs8w437frtcLcWj2Rab9egc1lle62MOoLfcyuzC4dLrP81G9CxzHLcEAwUIi2uUNJeKDxCjtLbhu7PEZaA== 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=ecXAcyzW+KTrtytwxsF6pUH5ze1HJh2cUj2l01F0pU4=; b=OGSKUtYLPffNE1AyZXJsm1+JpevptvDjtytvfQvS4STOpVYAgyGI6hNqGZ0pH/kbf2MP43Lt/nRDV7mbrLz2jpcC05eMgd4jRBfZ6Raz7prd84xWqfLfzOaILM1x+wGEZh3mKv1B16oicyIamcErEbwCKo9f3ZeU+Uu+NbHAeRsp61zNl2jR4rLw5Aa+T5EepavWybPw6aF7l5cscUvV5XEbuYm0sYFv02dnwReBAd7dktgXl+gZ7Bs83JSGLyyYBjLyIdGnM3MrYwpx62UXqS8+wjvtS4K62TkpAtBjSa7rHEppKsP2k+Uuq8Qx/2/QQ31afrFnuXPEP1Ptrk685g== 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=ecXAcyzW+KTrtytwxsF6pUH5ze1HJh2cUj2l01F0pU4=; b=fU9JuQnjllBRmtBRJ6OIJZrkcvrgv7zsL/ifEqoNCWIxufR9De8QxtA8PcxX2caD9S3mBNzoG+d4XmHf9AwD6loh2XA5cSE7D8LynfZBdmnzrvafks3HIbCjOQIS+ZkuhzeQr3+o1QGnWJxYrEMsJIiBthk8/RvExuoZC0szFKU= Received: from BN9PR03CA0360.namprd03.prod.outlook.com (2603:10b6:408:f6::35) by BL1PR12MB5062.namprd12.prod.outlook.com (2603:10b6:208:313::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Tue, 18 Oct 2022 13:24:17 +0000 Received: from BN8NAM11FT115.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::79) by BN9PR03CA0360.outlook.office365.com (2603:10b6:408:f6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:24:17 +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 BN8NAM11FT115.mail.protection.outlook.com (10.13.177.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:17 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:14 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 04/12] cxl: Unify debug messages when calling devm_cxl_add_dport() Date: Tue, 18 Oct 2022 15:23:32 +0200 Message-ID: <20221018132341.76259-5-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT115:EE_|BL1PR12MB5062:EE_ X-MS-Office365-Filtering-Correlation-Id: a1662cbd-af51-484c-6b37-08dab10c0ec0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kglsqrHRe4x/9r3HZ92F/D4Mu1v8BioDytlvKDW5Ndzd6/X4cl8j2PKeXEPP9K/ajPdKeadZIJ/Mm8rHhl1tgMzF5QhcyuVZFlVM0o/46+abWtFYaoVH2nOru2HU8gZwuMx2WcbcGK607QBRz5KdeECHrveOJ/f4xGZDlrtsaJAENCqZuVTEGAsjX+lv/q105So3HeYkzSxIiGAaHJnvZozoHLkx4T4Qhbj0M0x+xubOPevjRlGGdu06r6b9wkb3/AZEystWLntePwDqKf8QoYz7HHbSazAME8wqwfyw4c9aTpBhh9kO+DE0W8jhuMHKDX/m/BbS5e9t1eiYW/Ydb9jQx6VVgvxCRkKuReqqcukZ61McAS9gAulGmWUGk4m4HTuAFONWcz6WKRLUQP2wMSFcgEDeX/w2KQKBwRgzvtMCkJTl2aOcytNVaJlJpuGlajR/598yHenZSZ/mF/bXeqod6vXAdeY7s1e4D2OkqoBm/0tWXvQtnEvPkASacUYBOpEsYaBPt0Xnm40Rxuq7NgVBiIDBsLSkGov3bYAwCuVa4uNmrDHw0Ntf4vbTyXP3hvQuLsAcngKpwVxTpx/kWBW1DqiJ2oUSQgI8sKl6VPy3uTrGODtCPCZQVermYui66CrcTNkBGR1A7MJisMIG/BizqjhqOn74gx60FXC6eQLWhAVvkf2z43vlPG89q1VZc/F4xH++/Uul2hx99mMp/XbfrBTq6lMQj0TejxW3VGkwmZcMhFHOO9qnWRcH6xV0mJQOhbvxGM1YkF0maEu9WssvEx4+M43onX3E7eoxUkQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(26005)(41300700001)(40460700003)(186003)(6666004)(1076003)(16526019)(336012)(478600001)(2616005)(82310400005)(36756003)(2906002)(7416002)(5660300002)(4326008)(8936002)(36860700001)(110136005)(54906003)(82740400003)(40480700001)(316002)(426003)(47076005)(8676002)(70586007)(83380400001)(356005)(81166007)(70206006)(15650500001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:17.1249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1662cbd-af51-484c-6b37-08dab10c0ec0 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: BN8NAM11FT115.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5062 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. Use a __devm_cxl_add_dport() wrapper to keep the readability of the error exits. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 7 ++---- drivers/cxl/core/pci.c | 2 -- drivers/cxl/core/port.c | 48 +++++++++++++++++++++++++----------- tools/testing/cxl/test/cxl.c | 8 +----- 4 files changed, 37 insertions(+), 28 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 9bfd01b4e5b5..0431ed860d8e 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -892,20 +892,10 @@ static void cxl_dport_unlink(void *data) sysfs_remove_link(&port->dev.kobj, link_name); } -/** - * devm_cxl_add_dport - append downstream port data to a cxl_port - * @port: the cxl_port that references this dport - * @dport_dev: firmware or PCI device representing the dport - * @port_id: identifier for this dport in a decoder's target list - * @component_reg_phys: optional location of CXL component registers - * - * Note that dports are appended to the devm release action's of the - * either the port's host (for root ports), or the port itself (for - * switch ports) - */ -struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, - struct device *dport_dev, int port_id, - resource_size_t component_reg_phys) +static struct cxl_dport *__devm_cxl_add_dport(struct cxl_port *port, + struct device *dport_dev, + int port_id, + resource_size_t component_reg_phys) { char link_name[CXL_TARGET_STRLEN]; struct cxl_dport *dport; @@ -957,6 +947,36 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, return dport; } + +/** + * devm_cxl_add_dport - append downstream port data to a cxl_port + * @port: the cxl_port that references this dport + * @dport_dev: firmware or PCI device representing the dport + * @port_id: identifier for this dport in a decoder's target list + * @component_reg_phys: optional location of CXL component registers + * + * Note that dports are appended to the devm release action's of the + * either the port's host (for root ports), or the port itself (for + * switch ports) + */ +struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, + struct device *dport_dev, int port_id, + resource_size_t component_reg_phys) +{ + struct cxl_dport *dport; + + dport = __devm_cxl_add_dport(port, dport_dev, port_id, + component_reg_phys); + if (IS_ERR(dport)) { + dev_dbg(dport_dev, "failed to add dport to %s: %ld\n", + dev_name(&port->dev), PTR_ERR(dport)); + } else { + dev_dbg(dport_dev, "dport added to %s\n", + dev_name(&port->dev)); + } + + return dport; +} EXPORT_SYMBOL_NS_GPL(devm_cxl_add_dport, CXL); static int add_ep(struct cxl_ep *new) 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 Tue Oct 18 13:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010511 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 D8118C4332F for ; Tue, 18 Oct 2022 13:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbiJRNYp (ORCPT ); Tue, 18 Oct 2022 09:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiJRNYe (ORCPT ); Tue, 18 Oct 2022 09:24:34 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF31BBF74; Tue, 18 Oct 2022 06:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XT/kY6E5q/unoJElgXcUx3CGdZE6vB95W79++5nRCFJeq73HgOa08VySFcYzj5ii2zb/T+/LtqchNQIpNokW4KAkvjzs9OLpKXR7hSeO8MtRhwmVs0cGMkjAdbeVfHvAgizviXk2y7krCUEMbJbMtUnac30rvOcVkEwE7+zSZ9SUvWgTZaeZ0FSbMi2fv0ZAB3VkIAeOPZXLoRbUhP7iBX5NqCIwoQ1X6ZukB78AW9EfoJ41mcfkzhxpfGHbQjqWjKLN01tteeBMVinXW1ltjQHlMxSgURdj32z4wdPRv7tnN1S5qiCYzG3MV1S0I6MphHj69WXNJB/FZkMFMJaEKA== 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=WHNFlrO4qrQBm018055H1tLywEzE/PzkskChRQ3S8nk=; b=iUKMzpMNjgjj44CX6YRPqoR4AYZ71qrrcxEM88QakZEh/qyVSWof4x1eaPaSDqRasMSex1TJl5Oj5K5Ec2hvT6Q5hDmzwYXF3DGSaKHXlKNpOiERJ/erBVEH9hrAgC2NzYGkgJLOJkpmaTu8F1tWrfJswTl3eLfltsfNC3q3mM6q/O5NPyIiyrZBt9WXoYik8JaCoy9oNZvHiIuNcLEcuOUMH+wPDAF2pYk6QdqCNoiYDQw2z1Ta2SP8ceA8+OV15NQnOMlFVBikq5HhGZ1wk74F533lrE3GPsWQGZFZHgFfiu11bto594saHOO9wAhuLMvEFFGB/Um8Ls4IZAa6pA== 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=WHNFlrO4qrQBm018055H1tLywEzE/PzkskChRQ3S8nk=; b=sO1XXoavW+7LMQM/p7ksixE9AeKEi8Iz8/FPkL9ENw+vn8TKBkWwlMLT6cidD5Dr1PmUnbq9I3cRjlEiRcp6IetspdjviOL6UblPRMGfGcfJmnmDRzI9X3iA1ZB7PAvVyc/zD1p0K1nGVTPDnVFB1H2F2q9TMraqHcTmZw7zxRE= Received: from BN7PR02CA0005.namprd02.prod.outlook.com (2603:10b6:408:20::18) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:24:20 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::95) by BN7PR02CA0005.outlook.office365.com (2603:10b6:408:20::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33 via Frontend Transport; Tue, 18 Oct 2022 13:24:20 +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 BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:19 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:17 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 05/12] cxl/acpi: Improve debug messages in cxl_acpi_probe() Date: Tue, 18 Oct 2022 15:23:33 +0200 Message-ID: <20221018132341.76259-6-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT050:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1d0c91-bca4-4b02-4d2c-08dab10c1076 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XhWQCfsP4w/GCtNoFXqXkXguiAV1vVxLeNBh9bALY+XLZa+pg3Udd8m8wWPi+8rg+dqVxHNvLkcx5pCTXHCSKwQOgSJrdJMMyVDMUqN2pFjnud8vdMz/h8zFrpYlO83ZHf8YKOA+dYke6QRf7yCFz6bIkePQjOoBG9HsMgPbszr8RucLD3cbf1aYTPiv0sC9qBKVXTUJam0tGRCEDehIihtNMqnDBA09W8r1Nk2UoAMXzeGlMgtsMTwKk5oXTfco7T8tkIDC18iCQzfLWcYwlFINjlsQBrcGnkcJ8gmAqGz5d12SummXWXYDfyS5GsbwsXDDbguApf6yUlrJ/LeuACNNvGLhmDSMMWKymVUOpkapS99a0CjOrePWbtsvDBsl0VCqyPnw+xnQFLuFQwZKko7zH1NrdlEeQFLNFt4bAf+6hU7QygoNqTguT0bxKx/YnzdImkla2BFnPNhZv5XXimqwNCkYqdSQ71W2tp962RdCQ0w/Mj4caISR995oNISDGIdZb+ssPPL+FWsRWhgxH1PTUhfqCVputOBV7ckkZKSHvv1io8kPpY/r3UNiXARcKk5wuQOiF7+Z7xugbmNw9NTREz7/C/FCXZPeXy6jlac5e/rF7w4brfM8r0oN+S79zC/el4URRPeLfjtYzhCJ4NOhayIS31Ln1X/GUq5pF1FTyXfpuh5PW1TFtY77iTn0xU5AGlYcYgIE507AERkCVwBPXFrM9PgDdCY3m+oD0O63MD1cl/En8Foy9xhCQ08lSyOwXxtcBmu+llRpjS4huMriDEBZcb6qwAGvm/2jbJDtjVUVeTpE3PsdZPIwzN5q X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(40470700004)(36840700001)(46966006)(83380400001)(8676002)(36860700001)(316002)(70206006)(6666004)(186003)(16526019)(81166007)(356005)(1076003)(110136005)(54906003)(5660300002)(47076005)(70586007)(426003)(7416002)(40480700001)(8936002)(40460700003)(82740400003)(336012)(36756003)(15650500001)(4326008)(478600001)(2616005)(26005)(82310400005)(41300700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:19.9790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1d0c91-bca4-4b02-4d2c-08dab10c1076 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In cxl_acpi_probe() the iterator bus_for_each_dev() walks through all CXL hosts. Since all dev_*() debug messages point to the ACPI0017 device which is the CXL root for all hosts, the device information is pointless as it is always the same device. Change this to use the host device for this instead. Also, add additional host specific information such as CXL support, UID and CHBCR. This is an example log: acpi ACPI0016:00: UID found: 4 acpi ACPI0016:00: CHBCR found: 0x28090000000 acpi ACPI0016:00: dport added to root0 acpi ACPI0016:00: host-bridge: ACPI0016:00 pci0000:7f: host supports CXL Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 31e104f0210f..fb9f72813067 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -221,6 +221,8 @@ static int add_host_bridge_uport(struct device *match, void *arg) if (IS_ERR(port)) return PTR_ERR(port); + dev_info(pci_root->bus->bridge, "host supports CXL\n"); + return 0; } @@ -264,11 +266,12 @@ static int add_host_bridge_dport(struct device *match, void *arg) status = acpi_evaluate_integer(bridge->handle, METHOD_NAME__UID, NULL, &uid); if (status != AE_OK) { - dev_err(host, "unable to retrieve _UID of %s\n", - dev_name(match)); + dev_err(match, "unable to retrieve _UID\n"); return -ENODEV; } + dev_dbg(match, "UID found: %lld\n", uid); + ctx = (struct cxl_chbs_context) { .dev = host, .uid = uid, @@ -276,11 +279,12 @@ static int add_host_bridge_dport(struct device *match, void *arg) acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); if (ctx.chbcr == 0) { - dev_warn(host, "No CHBS found for Host Bridge: %s\n", - dev_name(match)); + dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } + dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); + dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); if (IS_ERR(dport)) return PTR_ERR(dport); From patchwork Tue Oct 18 13:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010512 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 BC465C433FE for ; Tue, 18 Oct 2022 13:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiJRNYp (ORCPT ); Tue, 18 Oct 2022 09:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiJRNYf (ORCPT ); Tue, 18 Oct 2022 09:24:35 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2051.outbound.protection.outlook.com [40.107.101.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A314140B3; Tue, 18 Oct 2022 06:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISpqoUL9RAMcB78m33fW1psXBDsSg7BxtH3ISb21lOgp2tARMrDKbSmZUXXJs4QuKrhlzbpTFTA51yg6JQlMHMbemtQK+X0lBmEKTmiQA52DW5DtmCoRl+qUDRkKnbyIOdWg5v488AQrNQ+jDvw4JIitt0NxCYCrsWkgVHPoOMZVLedICC367oFw31nf4YfsolRkUyKKdUyRG9ALgSBWZ2QqXRb8evw9TH7JiLAWWwVQ2wNZJ0O9cyyNaJ+nYxhZfzLLPmVkEdsFjXrUuygdXXrundJuj9Dg9++iwMs+hesuPj/sVQBZtVvvporj6Hj9OCBvd6gRnezzngTgotm9Yg== 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=wVjwz2jaYW2t613ACvCnJfgCx2sRIEoo1AFxWYaapRo=; b=FczGjqyc8WRRqjz6zrHWa8Por1tRmd9KodVVAW6YaqExYVJVGJbAsVcIVLqhBgCru0GPQ7R4ezOVJ4nv9IjePRQeAFn61u6JeNHjZQqhWaBe+ycMZcvm/+t1Xk964p2NbdhdBtx/W4Zwp8GWCYoltcT+2UO7a2zgAtcikojfolFsKJ1szwDKV76zYYyL5E6OXvt7g9p1c9bE+XWHgaGk8SRWUhoy261vGjsZShGFRFd8gmIE2ENYxU8N1wyegSuJIcYLe7iWHsrwKSn02zvAKRm+as7TMTFJu+wQbRzmnFQm19P/CgAxXWObLuGV4m0jmafkPDB/3325yRjoLWLWUw== 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=wVjwz2jaYW2t613ACvCnJfgCx2sRIEoo1AFxWYaapRo=; b=zsqzRNZAt3duRSCvCuKuvw83ArjU/ZEJmW3GBaspzx8AUfq8HJjlFzWbEi9PAv6UGBxhn8WOrzLhknA6SIHsc5NMkRz44F9Pap/le4vh5cpddYv8Gr0VN5JueKhjiXnUQsDUsUZ94ZXf8KmJ7gZmVHHpIu3plFgH57EY02nkIT0= Received: from BN9P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::22) by BN9PR12MB5305.namprd12.prod.outlook.com (2603:10b6:408:102::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Tue, 18 Oct 2022 13:24:23 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::66) by BN9P220CA0017.outlook.office365.com (2603:10b6:408:13e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:23 +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 BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:23 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:20 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter , Terry Bowman Subject: [PATCH v2 06/12] cxl/acpi: Extract component registers of restricted hosts from RCRB Date: Tue, 18 Oct 2022 15:23:34 +0200 Message-ID: <20221018132341.76259-7-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|BN9PR12MB5305:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d1d5869-1341-4b32-89a5-08dab10c1244 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TLrg3RxoS8c3Iw4iQmKYS7I9jn2YaPpamA1jgugsSVVINx+iyfYheycQKluMYBHkdIr4NuO/jnegWyi8ogbhMlm3MW8ZYbXSXYHtHaO25hM/MwsKCsafbtWamL2Z3Im3hP1Jl3tkIlcXq+wBKfUxwnhaUmKL/YXFTNIg3lbunMCnEsa+0MA+cCVdnmGunjazNJdAY0jOlt5l7GsJXnlRBODsn98LPNlVHCQDIYCImUbbBEzbcpedFMGTKooGEc9nRDBxjoLoJDDJaCAd4sqqRuKBPKDwrsUmMHio9SYdzM3m/Xdtu1+9F8qyg01rZAPM3eqGO2YeLMNUWIKRpMyhyEk6eFKkUnpjRE20iljHIszRVAM/jrGceNveFd4K4Oo5v2CP6d/KMreBYoFiw2MhOmDZRYUzjMMHipy5eSahdswmgofbv7XawWTcksGulSKbtBsCsI0uwb2VXZn762knaIAYWDKn+wCulEec3+2sNW8doojZwgq2hWO9HKP+C3tAPvHt/W1os9ntRYIk23J7z6WIEemtAeVWX/qHkoa+gPn4/WZWZfWNcPBmthMadKC77Kwc9QSogpYVQEJ0kNcSXOhJy+msqoxkc30sUz8ojRAL0RaLn303j0mS8PABd53CkfmY/Onj9QKGH15+3yUf8gEywgqW/JZ/ODGmNpQ8HGb8lIr/xmcOZne0TS1F0t8W/zIoe3BG4GYfSiQSwo2up8ZBOZsM+hQ81h4Nb5GTpfLcYgeG9yQ+7o6WX/NAdxCDDRfzw9RIrcNrMB5512IqC7DYRRXPwfu+F5RxA9tiiEY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(26005)(41300700001)(40460700003)(186003)(6666004)(1076003)(16526019)(336012)(478600001)(2616005)(82310400005)(36756003)(2906002)(7416002)(5660300002)(4326008)(8936002)(36860700001)(110136005)(54906003)(82740400003)(40480700001)(316002)(426003)(47076005)(8676002)(70586007)(83380400001)(356005)(81166007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:23.0083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d1d5869-1341-4b32-89a5-08dab10c1244 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: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5305 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org A downstream port must be connected to a component register block. For restricted hosts the base address is determined from the RCRB. The RCRB is provided by the host's CEDT CHBS entry. Rework CEDT parser to get the RCRB and add code to extract the component register block from it. RCRB's BAR[0..1] point to the component block containing CXL subsystem component registers. MEMBAR extraction follows the PCI base spec here, esp. 64 bit extraction and memory range alignment (6.0, 7.5.1.2.1). Note: Right now the component register block is used for HDM decoder capability only which is optional for RCDs. If unsupported by the RCD, the HDM init will fail. It is future work to bypass it in this case. Signed-off-by: Terry Bowman Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 79 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index fb9f72813067..a92d5d7b7a92 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -9,6 +9,8 @@ #include "cxlpci.h" #include "cxl.h" +#define CXL_RCRB_SIZE SZ_8K + static unsigned long cfmws_to_decoder_flags(int restrictions) { unsigned long flags = CXL_DECODER_F_ENABLE; @@ -229,27 +231,82 @@ static int add_host_bridge_uport(struct device *match, void *arg) struct cxl_chbs_context { struct device *dev; unsigned long long uid; - resource_size_t chbcr; + struct acpi_cedt_chbs chbs; }; -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, - const unsigned long end) +static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, + const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; - if (ctx->chbcr) + if (ctx->chbs.base) return 0; chbs = (struct acpi_cedt_chbs *) header; if (ctx->uid != chbs->uid) return 0; - ctx->chbcr = chbs->base; + ctx->chbs = *chbs; return 0; } +static resource_size_t cxl_get_chbcr(struct cxl_chbs_context *ctx) +{ + struct acpi_cedt_chbs *chbs = &ctx->chbs; + resource_size_t component_reg_phys, rcrb; + u32 bar0, bar1; + void *addr; + + if (!chbs->base) + return CXL_RESOURCE_NONE; + + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) + return chbs->base; + + /* Extract RCRB */ + + if (chbs->length != CXL_RCRB_SIZE) + return CXL_RESOURCE_NONE; + + rcrb = chbs->base; + + dev_dbg(ctx->dev, "RCRB found for UID %lld: 0x%08llx\n", + ctx->uid, (u64)rcrb); + + /* + * RCRB's BAR[0..1] point to component block containing CXL + * subsystem component registers. MEMBAR extraction follows + * the PCI Base spec here, esp. 64 bit extraction and memory + * ranges alignment (6.0, 7.5.1.2.1). + */ + addr = ioremap(rcrb, PCI_BASE_ADDRESS_0 + SZ_8); + 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 & (CXL_RCRB_SIZE - 1)) + return CXL_RESOURCE_NONE; + + return component_reg_phys; +} + static int add_host_bridge_dport(struct device *match, void *arg) { acpi_status status; @@ -259,6 +316,7 @@ static int add_host_bridge_dport(struct device *match, void *arg) struct cxl_port *root_port = arg; struct device *host = root_port->dev.parent; struct acpi_device *bridge = to_cxl_host_bridge(host, match); + resource_size_t component_reg_phys; if (!bridge) return 0; @@ -273,19 +331,20 @@ static int add_host_bridge_dport(struct device *match, void *arg) dev_dbg(match, "UID found: %lld\n", uid); ctx = (struct cxl_chbs_context) { - .dev = host, + .dev = match, .uid = uid, }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); - if (ctx.chbcr == 0) { + component_reg_phys = cxl_get_chbcr(&ctx); + if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } - dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); + dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)component_reg_phys); - dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); + dport = devm_cxl_add_dport(root_port, match, uid, component_reg_phys); if (IS_ERR(dport)) return PTR_ERR(dport); From patchwork Tue Oct 18 13:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010513 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 07440C4332F for ; Tue, 18 Oct 2022 13:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbiJRNZQ (ORCPT ); Tue, 18 Oct 2022 09:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbiJRNZF (ORCPT ); Tue, 18 Oct 2022 09:25:05 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2059.outbound.protection.outlook.com [40.107.244.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26168646C; Tue, 18 Oct 2022 06:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FqzTLk8NJ5CV8JiXMIECcc/o3yhg/hx4dcuPIi2uURd4GGC78hXb46rFCzJVF1eoQmvZcUUQSEBd1BoS6aOz7Irqel7AkkNES5tbtRngjCFK/tj7DmTwXp0yoK9+o825gwo3jws1uakAYc4I5XNFHMxMhI0iLPUsyOfxq9tOslrjyJkN97GdC1gpV3OBPxVEVuKhwilQ8XZvu/5JvVQE2XUo3iC1zIzIxHVgsO0DJrrDM4SKqIjzB/zRPX6yILP4qKu2oZyWWf4KvTe4YSN6gnPel8LSceBQBP2/f/4/I5oZ/oLTRnZQda78SjjAu1lhszrbivYCKl26dPfI6b52fA== 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=ff1xR0YOfwo6pDKZ/aMhaDAK8y4R4QFXmkwuW0YPl/M=; b=mNlfuT0ov5nRMI7L+v9uFLEBjZuTPYSUuTTvkT14DYV2g+j+WSlfH6kWtdt91hV3ILo75/QBLSqZmg53v1vnNTS8mm4pRWnLGquyXCZIIFIy9sC9jwUMrj8IJ6TAoNR+i3POTxtW7Q+bENWJ08OTfvnxHI3pNpB5k85yJFeVMTh66TTPkTkXbUrzY1uJRLH568rGXt9UBUZht67KJpUxi2h/nf4teHWAB8cAj0AKo57MTH8LGdbuFf6y0xX2qo/3bITcldXRo2WvUb9jT1fBxYquFiF7iWHBYzIBN2zko0qOgLrjPWywmWAN84XbNUqqH3ceh4rHM7cHTyaFP9G1IA== 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=ff1xR0YOfwo6pDKZ/aMhaDAK8y4R4QFXmkwuW0YPl/M=; b=PGP/jNuBhuAScFD6/srce4AsXD4YvJTC3zcaooX5hNU9e58DDAt7tkT14K0kjsZ8fnA1/ipCOFBFu2FUGSxrLe7RN6UMDxEAVg357jxSiZzCZeGOgokjpqRDi329tpQdq+d7n7jjjbppd4VmU1AVCzszAl1JiKkx78vxd4YEOfA= Received: from BN1PR10CA0009.namprd10.prod.outlook.com (2603:10b6:408:e0::14) by CH2PR12MB5516.namprd12.prod.outlook.com (2603:10b6:610:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:28 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e0:cafe::8e) by BN1PR10CA0009.outlook.office365.com (2603:10b6:408:e0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +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 BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:27 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:23 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 07/12] cxl: Remove dev_is_cxl_root_child() check in devm_cxl_enumerate_ports() Date: Tue, 18 Oct 2022 15:23:35 +0200 Message-ID: <20221018132341.76259-8-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|CH2PR12MB5516:EE_ X-MS-Office365-Filtering-Correlation-Id: 10e63684-827a-40d5-ed81-08dab10c1530 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rCCd0zjDacK8EoEH3u2Y0rQvD5Rx1x/witQi2WaZoscWOsw6xgyLhMKcngyDTQkZmi/fkTM5M+lJibieYOLSVAim5uKhi11mU6ZsPexj/CK/rZN0t2KyTjsqO7IvnxjPHcD+7lckmJygmvpWJh/U/0lrTetYgw5L5v31GvMHVTW3Sk7+aPbNnzD8jjrdpQCKT66oBbtlsLUtdo1nMEIktlzU4iNL4wh0uPoILqk8pPvKvHAFYr7hvqWrFyf1f42HTcLrDIlPfXOAJ9YXEoEkeG3g0+DOZMH2XfnbLUHj9NV154kUulphZAATxcxlT24kNl5iTl66MdURhJiZXdU/U10jeTWMQb8M4p6GhL0SZAzb7kaamTFKfRXA1S3CQPsVwco3tXmedTxYIaKZOH38r0zFhfO3nGAoDBc+VSkE5EH6JbCujQFFBT0GQTHcpLkfO4Z0cZ5HPB7aieeYn/hRNwj0Mx+JklnRmLkRQM31IYZBihzJLFo3UEdtif6KDyLYG8HIDcRWCn1NOi4qBsuLlzuCcOMNK3wAYyYjc8xBWXMZghwgF1UTtOIqnJysZA5QdGJm1RINA9+sA/J4a1khE0nNsoYrPrivCDt05hsUF4CBH18JgHCoGElRn8Xk3iIne62LWcFL9Mjd5V1OTxcivT59MpvffsFrtoAbbn30t+7wstxL4g6czR15eK+4E6IaSdDuD2CqBgQMOm8/wgqa5xearJLUHcZvT2SfFj0ITZYOX3YCb1Y2z8Dx3dKy58F3YvzSN2EIKZS8R5Bu7WxTT6E81CssIi2Q09vpnC8jPES1wC3Vx2rGCKBHeV1vdQ21 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199015)(36840700001)(46966006)(40470700004)(2616005)(26005)(6666004)(478600001)(36860700001)(83380400001)(336012)(16526019)(186003)(1076003)(40480700001)(2906002)(5660300002)(7416002)(40460700003)(54906003)(110136005)(316002)(4326008)(8676002)(41300700001)(70206006)(8936002)(82310400005)(70586007)(47076005)(426003)(36756003)(81166007)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:27.9285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10e63684-827a-40d5-ed81-08dab10c1530 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: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5516 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The dev_is_cxl_root_child() check adds complexity to the control flow of the iterator loop in devm_cxl_enumerate_ports(). This check is unnecessary and can safely be removed: If the port of a dport_dev is connected to the cxl root port, the grandparent of dport_dev will be null. This is checked early in the iterator loop and the function is left in this case. Drop this check to ease the control flow in devm_cxl_enumerate_ ports(). This change is a prerequisite of factoring out parts of the loop. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 0431ed860d8e..9af2d91db9bf 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1395,6 +1395,7 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) "found already registered port %s:%s\n", dev_name(&port->dev), dev_name(port->uport)); rc = cxl_add_ep(dport, &cxlmd->dev); + put_device(&port->dev); /* * If the endpoint already exists in the port's list, @@ -1403,19 +1404,11 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) * the parent_port lock as the current port may be being * reaped. */ - if (rc && rc != -EBUSY) { - put_device(&port->dev); + if (rc && rc != -EBUSY) return rc; - } /* Any more ports to add between this one and the root? */ - if (!dev_is_cxl_root_child(&port->dev)) { - put_device(&port->dev); - continue; - } - - put_device(&port->dev); - return 0; + continue; } rc = add_port_attach_ep(cxlmd, uport_dev, dport_dev); From patchwork Tue Oct 18 13:23:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010516 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 95DB5C433FE for ; Tue, 18 Oct 2022 13:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230419AbiJRNZi (ORCPT ); Tue, 18 Oct 2022 09:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJRNZL (ORCPT ); Tue, 18 Oct 2022 09:25:11 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2060.outbound.protection.outlook.com [40.107.100.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B11215803; Tue, 18 Oct 2022 06:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gb4M5dxm1KN6Y2P4pJP6Hiv5gNvZLZ18wq4eMI+v1Kqy3UnKgdUTr7iKw/TGzhhEhGA2rOShRaP2G6cfX2BqRFlb258tVmOI3YG00kf4o4j79Is9MaMHQonU1X11P4jy8p0bmD1gJY0IgVVhuBKV7w8Vj3f20UbeKmum1vG4QC4aRkF5xLk90iNHTxjY6tPxGEP4g5U9NIh8XmTM9t0c8bYxOFV++5NK91dXJtlzFJA5aMxyCxLjYrCMs2rKYfocmDECyF9apuhDP5lomutYKG3ZsOABGokO55HtQXizw3GjJQin0nr7cP/4GvsuW1FKXCS+WrMyy9UcwX4sO8fdEQ== 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=Jo2Lg1CBLmLriTl/NpqSzdE8UaXgVmfhgM1KORTc794=; b=MgD0cXLS/eFRzmhgHvDgJraPud2J9Sps6XDFpAKw6vovaqWUA8lNbE/RMXZM04xu3Ege0huayB/KRsRNkAY2zhuLT3iskl/e2suxAgEKELf+Z6xeQB+oTJxXMWP+fy8cOeNbXLszGYfj/sbiZ8K/RBxEeiPdsjhZoP8fbPyxEYk2sykLOAEmhr0LyvngKJxlJtzosvZJRaAcoBVnVK/zazaFdMgTPv9XS2THAzrEiG3jd1tPnnqZl6K3JBshGK6Af36l06ijbB9DHIAO54x5LrCfVuSY6aHiSaDmmGJPPvVnZSI30+GEodjyD9VJqM84VCyrDja0SdbfbM8S2TBA3A== 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=Jo2Lg1CBLmLriTl/NpqSzdE8UaXgVmfhgM1KORTc794=; b=1rOGaMUdVSkp8q4sExtcMVTRObBz3nV03WBzDnoLNc0gs01RaLp2oF1QTDNPVxd7kLmdLfdLI9CBjJ6F+M3L3ZI1o9XYv46NwS5CQKkd7TseWUZdmyInf/zcdeXhkiV+1e41BFLqG/dGfUm14DFbj4mAeOVz+nC3Ryci9IcxizU= Received: from BN9PR03CA0860.namprd03.prod.outlook.com (2603:10b6:408:13d::25) by SA1PR12MB6773.namprd12.prod.outlook.com (2603:10b6:806:258::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:24:28 +0000 Received: from BN8NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::2e) by BN9PR03CA0860.outlook.office365.com (2603:10b6:408:13d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +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 BN8NAM11FT086.mail.protection.outlook.com (10.13.176.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:26 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 08/12] cxl: Factor out code in devm_cxl_enumerate_ports() to find_port_attach_ep() Date: Tue, 18 Oct 2022 15:23:36 +0200 Message-ID: <20221018132341.76259-9-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT086:EE_|SA1PR12MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: c78db01a-9cc5-446e-4ee1-08dab10c15a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 05CNkMk0OF8A2mAbo+VxWEJOfJNQ+WHnKCRX54UjR+KpttCyOsvMKjzLFvFZIHS+5yR2tIvlvhjhSmU39GXWpDgUxsTOeP1D96xXH61pZ4BQyjcAptzAIFjZKK9gkd/LiXchPZLHB9vkL8ecK9/a7mV27wDBLqUoMeQrZO/ET29bhkL4mzq5YT+p+dxcspEqWrewpkKcs29If636NdIBYJID/OWkfN8HU+I1pa+F5BGbjoFq+Rzzxefcgybqh5vEmDqFVvUvbHeCu8AlOHjsuAZ+y2POACQ3sfg9hN6p8rqoO56bSrgrcOfjj1kpGT+FOzI/P538UHOPkQX+RJ9rEj76vo8y/tWVKdUOQxJn1hTC5tytb24G4aL8NEsAIMKF9QYauwOhB1uUOMpgjStuNiZUYmo5SIueIL0Q5dciPGkiXlBHqfVosOxPEWNe1iwu9h3nIt2bWRNQI4glGPaD0/AZD460Zq09x7fqXUYOAKV1gcRQQk/Q8Xsdrf4QzZHnykPcRmtlKsXqPXarxm/AF+ye3dTm8i+UG58wdpNRYS7bT8T8unDuyGo/2/ZLvtyy50N26iIlsv1CEQUcGGK6FOnX+tjWOolePB30qp5sLYiqE2WxPSX/6A+rL1dHmndPE+0xUa5iUgHMS8zbrImeJFEGckyOFgfmtSJqdprxstCOxChn+h+kqi6/3dzKWYSOc1m+BUsBJ+Rpdp/T8f1an82st0+zM6XFPX9b7JxNC0ABRUFts7PbYxJuOl7h+VVJt0h8w6jX5Osi0FYAEMCgg5pH57Knn4hk2jkeqdQFkFAL6WuL+GLrDxacXu4pGEuSsNJb4AdcZ1ydZRWuKtvmqA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(41300700001)(4326008)(40480700001)(83380400001)(110136005)(54906003)(70206006)(26005)(316002)(16526019)(186003)(7416002)(1076003)(81166007)(5660300002)(356005)(2616005)(82740400003)(8936002)(36756003)(336012)(426003)(40460700003)(70586007)(2906002)(6666004)(478600001)(47076005)(8676002)(82310400005)(36860700001)(37363002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:28.6822 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c78db01a-9cc5-446e-4ee1-08dab10c15a6 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: BN8NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6773 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Factor out the code to attach an EP to an existing port. It will be reused to implement RCH discovery. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 66 +++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 9af2d91db9bf..4b15481426f7 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1286,6 +1286,36 @@ static resource_size_t find_component_registers(struct device *dev) return cxl_regmap_to_base(pdev, &map); } +static int find_port_attach_ep(struct cxl_memdev *cxlmd, + struct device *uport_dev, + struct device *dport_dev, + struct device *origin) +{ + struct device *dev = &cxlmd->dev; + struct cxl_dport *dport; + struct cxl_port *port; + int rc; + + dev_dbg(dev, "scan: origin: %s dport_dev: %s parent: %s\n", + dev_name(origin), dev_name(dport_dev), + uport_dev ? dev_name(uport_dev) : "(null)"); + + port = find_cxl_port(dport_dev, &dport); + if (!port) + return 0; + + dev_dbg(dev, "found already registered port %s:%s\n", + dev_name(&port->dev), dev_name(port->uport)); + + rc = cxl_add_ep(dport, &cxlmd->dev); + put_device(&port->dev); + if (rc) + return rc; + + /* Continue to add more ports between this one and the root. */ + return 1; +} + static int add_port_attach_ep(struct cxl_memdev *cxlmd, struct device *uport_dev, struct device *dport_dev) @@ -1373,8 +1403,6 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) for (iter = dev; iter; iter = grandparent(iter)) { struct device *dport_dev = grandparent(iter); struct device *uport_dev; - struct cxl_dport *dport; - struct cxl_port *port; if (!dport_dev) return 0; @@ -1386,30 +1414,18 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) 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)); - port = find_cxl_port(dport_dev, &dport); - if (port) { - dev_dbg(&cxlmd->dev, - "found already registered port %s:%s\n", - dev_name(&port->dev), dev_name(port->uport)); - rc = cxl_add_ep(dport, &cxlmd->dev); - put_device(&port->dev); - - /* - * If the endpoint already exists in the port's list, - * that's ok, it was added on a previous pass. - * Otherwise, retry in add_port_attach_ep() after taking - * the parent_port lock as the current port may be being - * reaped. - */ - if (rc && rc != -EBUSY) - return rc; - - /* Any more ports to add between this one and the root? */ + rc = find_port_attach_ep(cxlmd, uport_dev, dport_dev, iter); + /* + * If the endpoint already exists in the port's list, + * that's ok, it was added on a previous pass. + * Otherwise, retry in add_port_attach_ep() after taking + * the parent_port lock as the current port may be being + * reaped. + */ + if (rc > 0 || rc == -EBUSY) continue; - } + if (rc) + return rc; rc = add_port_attach_ep(cxlmd, uport_dev, dport_dev); /* port missing, try to add parent */ From patchwork Tue Oct 18 13:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010514 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 BDB1EC433FE for ; Tue, 18 Oct 2022 13:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbiJRNZY (ORCPT ); Tue, 18 Oct 2022 09:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbiJRNZI (ORCPT ); Tue, 18 Oct 2022 09:25:08 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6998522B1C; Tue, 18 Oct 2022 06:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8qDgr9W5c5nuqUsGeqEl/h/OZMvFmq/BejYIkBoB3u1KgaX/CW9OKz7YVHZg3nds22/ieeGisLZ+bN3/Cx1uMz5/HGOwFYytIMqQBha2iBxII+VV8psXaxh/ho0FncFa+Lvs0uXzZTZtQgXDIbjH/dQH90kfVE4zTHH209Du6sp+RtubEoOIOAB5f9RlC6teDMnIF+b5bZEbNxb+ZpmuF1fEjOPibUUBcha3gJiZAgbb7EA5B+OrKMuIOwJAY+v7tk1UWrZ/e0e7tZqbyK0n6ALZkwA75ZOVs/jhOxEVF0nUu5a/o0961NZtOmBcLQJyqR5tL9coH4bfOqVR+drBg== 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=h/hKkrxafFtc9IpK9px5m8cyyUbCJBZGiYZhwWSJUc8=; b=MT03qCk+OCyKqaV/DE3kypo/nPcYKJnOJC/Y+o5sZNN+E3dk0iJe1uJV/cujBLPl0J1XAIq4ZPUm4nUTOg4qwkcXO5qNPmtdZ6hoRDWrpyuBhbRsia/FNU4YMS0v/bwnEV9MNeeN7DoPukRpX5Kx3Mi153VgTLqK8Onzfwo3cQyb6SutRka3NNAfP0FWzr0RUDoH5YJ8uieBGIvUNadM5GnD8ku3SyTfKVZ7le6UhfovqR3/sN3VDGCcvh7SqdTQbApuKAkgDeZRVnc3cS3QJMMZZOKGF56z4QfCONYtrgbYQWTPcE2P7cDjlrXp++K9TZol4ilMf1ouXzqwHOaNmA== 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=h/hKkrxafFtc9IpK9px5m8cyyUbCJBZGiYZhwWSJUc8=; b=XEs6srevGB8rHWZtPIipvD/UuE/KEIuz35zAiBJgbJB+4fGwIlNGX/2TYL9fzuOkZjnV+di7UhA4wKkd7vWuS7LJ5PjxJDQPnNiNAebDxsMR5nZUmN1r3U/0qdNAVZDyzG4xEe1sP2Q34Ki1TT9cg53W08mak2o2H6HSdZZG66s= Received: from BN7PR06CA0066.namprd06.prod.outlook.com (2603:10b6:408:34::43) by PH7PR12MB6633.namprd12.prod.outlook.com (2603:10b6:510:1ff::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:31 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::8d) by BN7PR06CA0066.outlook.office365.com (2603:10b6:408:34::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Tue, 18 Oct 2022 13:24:31 +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 BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:31 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:28 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 09/12] cxl: Extend devm_cxl_enumerate_ports() to support restricted devices (RCDs) Date: Tue, 18 Oct 2022 15:23:37 +0200 Message-ID: <20221018132341.76259-10-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT098:EE_|PH7PR12MB6633:EE_ X-MS-Office365-Filtering-Correlation-Id: 32af808b-a9af-4e45-f158-08dab10c1751 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uakOhso2KtVFaqdyH1pcMOhWGYgnpVyrvUVkbAw2bx78JfBjpXz+MNuU8GAPbJfBVYrPpBrtn14AtgGj6LPUslnVyT5HXXwi5b98OB4ErTNqIM5GDZwvND65ngFLYMHCgiTT5U8gYC9uSwa1BiI5CZYHMaORcUC6X3kWObM0tMtzSTMrHOB+lHS10J19ipes/XmzyIE6grfL2qovDkdueSZB1D+VgD2PTdlDrigkjyvhbaJHCDGM20u/V7pZ/+ky4Ac80AC9KmgIkSQ2Uwve6L1oSO0gHa5IdmPN26Y98ZJK1uiNxM2LkUKrTzKso9vHSuGtDZEWseTfjxWn6paNGc524ue3Kqz1AFW/DmGwDhRCbZtDM90dk+/5v3d86Ff1KlIi71nobrJcncaDseEqvnd2hT0eJTLoC1psPIoowC6FSjqQGYz3BTlO6oU03sfP73uAbfakIa20ZFLnHkA2ozKgxVHvjjl7cmumOxiAU6VnCa5/n8r4wccf0k/7kbcaQwK2EVJMlTlazQEHaIy3rL0UlbITMli1w+NnQZNmHmHCR3xGbmZwCQZQ6fNlxe0JEQMLlfzm5mtpvKu8wt7iMP/K7arjdAvBsSjhYYCHGI1jg2VmpJ/YS+fFXj0hif3G8O3w7TvIuHQ7u27XHzcpGksXr/xpdEwu+MND0RZzkguTf0Al5J+vS3iEJj85M6N0Kr6r/7eXdiBmdQvZpV1jaIu/TJpLgdQI5XheDR8lCzmF7cuJH0NT53BwApaYWWVmyzdiA3bpZUK5IndjJ8NgoXudPo//1AOJ510IJL1U7tVVMJZSTa3MxFcOpv1hZf8f X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199015)(40470700004)(46966006)(36840700001)(82740400003)(81166007)(2906002)(40460700003)(356005)(8936002)(5660300002)(7416002)(70586007)(41300700001)(70206006)(8676002)(4326008)(36860700001)(316002)(54906003)(83380400001)(110136005)(186003)(16526019)(40480700001)(82310400005)(426003)(36756003)(1076003)(47076005)(2616005)(336012)(6666004)(26005)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:31.4847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32af808b-a9af-4e45-f158-08dab10c1751 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: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6633 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The PCIe Software View of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP. Its downstream and upstream ports are hidden to the PCI hierarchy. This different PCI topology requires a different handling of RCHs. Extend devm_cxl_enumerate_ports() to support restricted devices (RCDs). If an RCD is detected all to do is to search its corresponding RCH's port and attach the EP to it. Update cxl_mem_find_port() for proper removal of the EP in delete_endpoint(). Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 4b15481426f7..35f8fa98904e 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1384,16 +1384,56 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, return rc; } +static inline bool is_cxl_restricted(struct cxl_memdev *cxlmd) +{ + struct device *parent = cxlmd->dev.parent; + if (!dev_is_pci(parent)) + return false; + return pci_pcie_type(to_pci_dev(parent)) == PCI_EXP_TYPE_RC_END; +} + +static int restricted_host_enumerate_port(struct cxl_memdev *cxlmd) +{ + struct device *dev, *dport_dev, *uport_dev; + int count; + + if (!is_cxl_restricted(cxlmd)) + return 0; + + /* + * The cxlmd is an RCD, the dport_dev of it is the PCI device + * and the uport_dev is its host bridge which is the parent of + * the PCI device. + */ + dev = &cxlmd->dev; /* cxlmd */ + dport_dev = dev->parent; /* pci_dev */ + uport_dev = dev->parent->parent; /* pci_host_bridge */ + + count = find_port_attach_ep(cxlmd, uport_dev, dport_dev, dev); + + /* If missing the host is not yet ready. */ + if (!count) + return -EAGAIN; + + return count; +} + int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) { struct device *dev = &cxlmd->dev; struct device *iter; - int rc; + int count, rc; rc = devm_add_action_or_reset(&cxlmd->dev, cxl_detach_ep, cxlmd); if (rc) return rc; + count = restricted_host_enumerate_port(cxlmd); + if (count < 0) + return count; + if (count) + return 0; + /* * Scan for and add all cxl_ports in this device's ancestry. * Repeat until no more ports are added. Abort if a port add @@ -1445,6 +1485,9 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { + if (is_cxl_restricted(cxlmd)) + return find_cxl_port(cxlmd->dev.parent, dport); + return find_cxl_port(grandparent(&cxlmd->dev), dport); } EXPORT_SYMBOL_NS_GPL(cxl_mem_find_port, CXL); From patchwork Tue Oct 18 13:23:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010517 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 96E70C4332F for ; Tue, 18 Oct 2022 13:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230527AbiJRN0D (ORCPT ); Tue, 18 Oct 2022 09:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiJRNZk (ORCPT ); Tue, 18 Oct 2022 09:25:40 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A8BC58A5; Tue, 18 Oct 2022 06:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYzbO3ndLtkhbyTZNwPXLuK1JJyHDMcz9u0GiYRr2F97ePRlSBtUU8ZNIuZlwhlFGZerxtdtjUVKLb8+Y/7bAOTNvfyi33Mg9u3gLxgKkHlXxzuDgtDXwRbeaO1RAePBmWhN5G9pCbvUTNyeleI67hT+ALWruAeLrd2bOQjpoIHIUWVH/jblObEw53M6Tjbh51KO95SNa9hRyVKULwk5nWhUCe7+BBtCHMbPKN+rxZJrB9cWq+u3305tuU3rR+quFLx3p5QzIZ/8AbKEXyEnyzihsifGLmW0oU6lsOJQrj9tlau1ZXYGFDm0/ATf2atxOYTHib1nU2OV6EzipPmfpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=VXLiGJWadu4wGvN269dSRAYiwYoBv6cy6WzT7yLiZ86l/E19XKzkdMrrtVSxCTwvFpGYS5c6hoU1ME2coteDo9CbQVNc9tGvpUe1TbMPWq5aBIT3jq1vEe1W4FRLOxipll7+pQeQSxO3HjtR41DMGqxWkZDsxsR/DsqoHJTJRSBXR9qpC1rekWhpo7Ur2fE8B0E67ZHJsDWTrmzFSCjofxFk5W1u4zaPYucaA+sk0nPnWjYg2EkpLAcp8KM9ugTieLn3ZEAT0tJC1Fv7TbrIDqGvFcjoH9ERcEN6+2ZmkACWfo36mkQL8kUKUkGo4ev9TKKA7gq0TwBIZvc64jZe/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=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=Q4FotHxSQAj+0WyqGqBou+zLC3uVczELIcdQfwDo7LYv8lBsIaIfx/DbcKNSbRbqAqql3Xt5FvPMcRugL5eS2tUd6RtTZYzAe9QMmbQBBRIyRRygVzfiNWy4PMKuGzjOnNgfld+u/h42zTPlBTPnmpMFFQqf/u2wp3ynevZQI5c= Received: from BN9PR03CA0590.namprd03.prod.outlook.com (2603:10b6:408:10d::25) by DM4PR12MB7696.namprd12.prod.outlook.com (2603:10b6:8:100::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:25:00 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::f4) by BN9PR03CA0590.outlook.office365.com (2603:10b6:408:10d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Tue, 18 Oct 2022 13:25: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 BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25: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.31; Tue, 18 Oct 2022 08:24:31 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 10/12] cxl: Do not ignore PCI config read errors in match_add_dports() Date: Tue, 18 Oct 2022 15:23:38 +0200 Message-ID: <20221018132341.76259-11-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|DM4PR12MB7696:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a992286-763e-4550-d5a8-08dab10c2887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h1Lbfk/ShqNgnXB3bi5ZoTgpkClfgdf0DJt/h3M/RWecx7h1t7vhr4GGiDYVwUEeA+nVT6PBOgWxPqd7k1C0S2DsNSmvpIvdAsOWfhK8dYi08UcNH5LrYtGx0Acs0yI4H41lSzXbsz5qwHpVBMz53BYHvgtpvEFGm0+SqGE34gkSGEMR4WThl7Msj0EP2fm48srlvM9vwpJbHLJ4t7qKxZoj8Fki6u9QquAkUwVZGu655qJfAgf/AmSfVxFxuBZSOcF1CT4F0r2tB+vuo0r1OGGRp4C9j3EsMoKpHMlHBgC2PvYKqv/jsLvWzs28DbbOiw/zHshsJzbQqqVC/TJh0mLEpwCUFiTKU/m/Cpe8ftvoAvk/l76/Zn7fY/YtAPqVdEeBZ/dukaNeDVSGU0nVD+5Dt1d7PrE/zOYibtwPjlHBHjXXLR5sEXEuQSSKpw7gNsjFeXa0tim6GQ+iHSFP7cfTh1nDxpVqOz1C12Bu5dIzy5zu2qTigy5Z5m/fNa/kBYLuQV97+hoYXp8BQvcJCjz0fIdT1EL6Lt0i2fTPyBPb3t6w4BUWIQVVRp02HKIUbt2WSs7fp9Ls/tLO17nGiPYItHDatxPCLUS95L/OCCdOarJyiTYPrleDVbyORHMXclUQxO+8rAF7vZ1UippOZ2ZbEAIvUFjagPpmTz8DrQMwNxTjZF7fJhtEfG8AloqVHWtekfln2GklKqkfBZyVhuiwLpTFnpx7Yh85+M6VTovlHEQkCOu+6jH4dE+Yx/9hjHsbmmvPTUou+TWwZzDfmQqchUMj9FSQnM6n/8ofhtI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(478600001)(41300700001)(8936002)(4326008)(316002)(110136005)(54906003)(8676002)(36756003)(36860700001)(81166007)(356005)(40480700001)(40460700003)(186003)(82740400003)(2616005)(336012)(1076003)(16526019)(82310400005)(26005)(70206006)(83380400001)(47076005)(426003)(2906002)(70586007)(5660300002)(7416002)(4744005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:00.3592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a992286-763e-4550-d5a8-08dab10c2887 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: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7696 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The link capabilities of a PCI device are read when enumerating its dports. This is done by reading the PCI config space. If that fails port enumeration ignores that error. However, reading the PCI config space should reliably work. To reduce some complexity to the code flow when factoring out parts of the code in match_add_dports() for later reuse, change this to throw an error. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 0dbbe8d39b07..8271b8abde7a 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -47,7 +47,7 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, &lnkcap)) - return 0; + return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) From patchwork Tue Oct 18 13:23:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010518 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 26367C4332F for ; Tue, 18 Oct 2022 13:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiJRN0G (ORCPT ); Tue, 18 Oct 2022 09:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbiJRNZs (ORCPT ); Tue, 18 Oct 2022 09:25:48 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A765DC8216; Tue, 18 Oct 2022 06:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOTqOrtnZ2s8gkBg8G3jT5kND5/0oFbFZ6EQpXbNtDvHwmqp7CEXJ1dFxTvsHnXCfuQUl7wRmr4JIa1uaL02ERFNZLrfO+drnq3FER5KHq5eki9x0R8usUZd2k23e713vQ8Go32i8chDVCpBl5ikG+6KJ1ABtu0OpmwFoMOqYnsN4mu47SDTWd9rPg3OjUQwjDUZ1fIgSQ9BbImzw610qryTRddJ+tv10/7GVpyLjQ/s8RDHVSHvynSY/OjMkuUfjSPTKB2cxEO9AdyotqcKenoz30Jy8+IY0wsi/CejnRz+JTQliAVEDO8B9BTHOq5oCKSRyO6mVieoWhgpbE9yiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=WZV7qBjQD/42f8dN6RbGANVi4Sryz2j362pCr6Kv+lX8KB64lWKPknnj2q+gIFmfPqi1B2SnBjSxiMJsF5UVoDwdl9gXWxpJrnsT5gzAzzONleujJIhJiVMqcARzLDPqx+wn0nT4KX7Iq2qUGlJYdv606JaTDlJUaZakrJKfgXPADrCGocaazzwcXZBLddk0TBhzz3BIcZ4/GRuoatkhH1Z5F/sIHNwMFVwBHSx7Yk67BWoOtH1xJqEvj1+K5znSwYX/+GBlIEqWTVm7K3Fjm4YCxbjv4QAYM1xglOHbnFRSyu9K6L5z0op79isbN7hYbvVo+qDB7HsjPXqePr4A9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=ta3A3EmrRY72kYcFuny5f8FyfNICnbuXjIutvm2SUZm07eLpBMWlTWksO46tucKn3KYiuTJt9aFFF2eObybwvS7BT//Gk9w61gumS81632Twrz+ZHzZWKiz93o3Sj58SgNEsZoxZuojTDECWI8+jg8dfDw8tsjyKCxxDH7Wvyj8= Received: from BN9PR03CA0581.namprd03.prod.outlook.com (2603:10b6:408:10d::16) by CH0PR12MB5266.namprd12.prod.outlook.com (2603:10b6:610:d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:25:01 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::94) by BN9PR03CA0581.outlook.office365.com (2603:10b6:408:10d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:25: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 BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25: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.31; Tue, 18 Oct 2022 08:24:56 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 11/12] cxl: Factor out code in match_add_dports() to pci_dev_add_dport() Date: Tue, 18 Oct 2022 15:23:39 +0200 Message-ID: <20221018132341.76259-12-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|CH0PR12MB5266:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f9f280b-fa20-4503-465a-08dab10c28db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGWAmxUBc5wQVTyVa10/bDMqRGlfRFQRZNB+5Y1WJa5CTt+8urbdwRDM+Ml3Rl4B2NV/rOMYJFzquRoCTvF7zyNy/eVV8GqYD8IVRUP/pwhkhrjJuQq+RwlvLZVSYv1RiCWA6qERINYMueD9s7Wt3rp2LESC2Pbqscbth4V7uAQbrYPOR1JtCSA989JXp/VMKol5UysUl/FoXM6W/a44fboMjFA32vZsVrx/PJ186djf+hdUxULSoz14QmdWeqzPkJ2ximfYN7Fb9I6l4jCd9xgFSY0a9WHN2ulGHibJgME/A20D6AGml/cDHKUmziEXgXlTDV8CuOR3XAeVfqsA6PXVQpV2w3J8cNwh/1Ykx7xzQNBdxYfEnGTlSTy9Fpoaba1OnAkG0WR9WjJ4BkPoO/v+V8RvOJ94l8REr28bjBH4OtI6IA2cJpBlTmCgZKWrn7Xo9zK76qQLr7nPzjpgxx22uWKgnybZhkHQhdJAbsqPjrXSBod6oXq0a5/uCxTSpLFEmhD65TVL08m9R27Cgpwj0reoPCS1Mhx4avOucBG6YV2V3y0ifBD6Bwf5j7YoAL6PtcgjcHcZkEorJqyB/wN0nlwCdd+aAEFT6Luyg/TSQIvMJohuGbquHd40uX+42jeE8pUB16wmfhxUtuc7C7hR1Uhvlzz2t+5eqXbVlrleR9wa/RRWQWm0esmOoA+fc2b31wd04Gz7LS+WcPWWejEeVMqPslg8uC5bpElPL3jqGYKMSi6KVZnlYzOQXpjIzOqZCx11l7Xr0rjd2Zg5jZy7phDKqOhx2qg/EWgjR5o= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(110136005)(54906003)(4326008)(8676002)(7416002)(5660300002)(316002)(40460700003)(70586007)(70206006)(36860700001)(6666004)(478600001)(82310400005)(2906002)(41300700001)(36756003)(8936002)(83380400001)(186003)(1076003)(336012)(16526019)(426003)(47076005)(82740400003)(40480700001)(356005)(26005)(2616005)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:00.9216 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f9f280b-fa20-4503-465a-08dab10c28db 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: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5266 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Factor out the code to register a PCI device's dport to a port. It will be reused to implement RCD mode. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 8271b8abde7a..667de4f125f6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -29,14 +29,32 @@ struct cxl_walk_context { int count; }; +static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, + resource_size_t component_reg_phys) +{ + struct cxl_dport *dport; + u32 lnkcap, port_num; + + if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, + &lnkcap)) + return -ENXIO; + + port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); + dport = devm_cxl_add_dport(port, &pdev->dev, port_num, + component_reg_phys); + if (IS_ERR(dport)) + return PTR_ERR(dport); + + return 0; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; struct cxl_port *port = ctx->port; int type = pci_pcie_type(pdev); struct cxl_register_map map; - struct cxl_dport *dport; - u32 lnkcap, port_num; + resource_size_t component_reg_phys; int rc; if (pdev->bus != ctx->bus) @@ -45,21 +63,18 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (type != ctx->type) return 0; - if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, - &lnkcap)) - return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_dbg(&port->dev, "failed to find component registers\n"); - port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); - dport = devm_cxl_add_dport(port, &pdev->dev, port_num, - cxl_regmap_to_base(pdev, &map)); - if (IS_ERR(dport)) { - ctx->error = PTR_ERR(dport); - return PTR_ERR(dport); + component_reg_phys = cxl_regmap_to_base(pdev, &map); + rc = pci_dev_add_dport(pdev, port, component_reg_phys); + if (rc) { + ctx->error = rc; + return rc; } + ctx->count++; return 0; From patchwork Tue Oct 18 13:23:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13010519 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 05BA2C433FE for ; Tue, 18 Oct 2022 13:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbiJRN0G (ORCPT ); Tue, 18 Oct 2022 09:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbiJRNZu (ORCPT ); Tue, 18 Oct 2022 09:25:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4364220F4A; Tue, 18 Oct 2022 06:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g5XVzVLTsDyXNLRszvyUfBUaj3/9H1O1jVus0TTgns8q1lHNcLh4n+lkBzs1IQKwo0A8qTS5LPie60e8ea+PkX9dBDcsW4GZiRbRRlohX33i2p5SPU6xTra87J21DOIbp3S7ZpZTRyGNt9hVJpeHTcpm0JH3JBx0zm0wYsawqty4m2c8sT443FQnxTTozvW8szTBWVPoonGQIg4vUt2bXBB7/WKeZ9K8Q3pV2b6pWKWBEbndZAXWvrmN6MhQiiMyx1Sbit9IWXM2iH+9hlTfHLSYC93mU88AsBzdE5j7Q/3+moC8/kRgBfcpjCAt11cDYzvupEwgJf3BgLBI5QhKGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=CeiUuGeX0xJahZOuAXfr2viorXXlbK9wm1mfPj27enWlkd0/YYlgPyxmoWxR7K8ESMmVmmKmkxUWnOeBPEpauw5TBA3Ny4BMAFrdW2OaVRov+j2rFFx8AMFLnFpp0mk18X4wCzN67vUOHiwsB10nvg2XVPq1kl4Ot5l0erlHYOK8XyzXFpAxn/hsuqP/FQjHpQ/EVXHDM7fyEuPMdtJEwg+Fe/sjY0fWnSwUUm/Vx1pu3Fdh/V+153t9RKMmeVQvJi0iisY3bojB1KDeuUY8fos0ZFhy62APzfuiPrCiVlk75U8NKYysLdp5oA8dlHkFEaE8az4NTQhBpQCMggrmhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=HA5fncxaNr90T1rxQ7CupP3lGQPVX+1QqR6y9J6ob2vepKWNEAG4Pmk9bKl7YUdqobE647jvuQkLNCxL3GMR7HWveGmqUPc/ZA10im3wZd/mCy2jdZriCmzradSqfTBWwS5OY2zFfFB6MgnVGY7RdgQFLo+XkqNhlyqs4hnguAk= Received: from BN9PR03CA0666.namprd03.prod.outlook.com (2603:10b6:408:10e::11) by BY5PR12MB4113.namprd12.prod.outlook.com (2603:10b6:a03:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:25:02 +0000 Received: from BN8NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::e2) by BN9PR03CA0666.outlook.office365.com (2603:10b6:408:10e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33 via Frontend Transport; Tue, 18 Oct 2022 13:25:02 +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 BN8NAM11FT078.mail.protection.outlook.com (10.13.176.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25:02 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:59 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 12/12] cxl: Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH) Date: Tue, 18 Oct 2022 15:23:40 +0200 Message-ID: <20221018132341.76259-13-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-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-TrafficTypeDiagnostic: BN8NAM11FT078:EE_|BY5PR12MB4113:EE_ X-MS-Office365-Filtering-Correlation-Id: 54cd921f-b359-4d0c-667b-08dab10c298d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Es/Uqk0Pq4ACISn1odl+Wc75MKbuifwqpeiQv7f2PfsVWoPS0DFN3RU0doKYobmR5aeQKHti871q2gJDbe5vKqu0AteWKYqzC9Tdjwj+aL6nJC2H6GYHkNbQpU1uJvjnS/O1QcKBhfNw9IPDzjIKELCUf/VmTW5NpZIoynpFa9VypY2PEpiTJSRxWr+6brJG9ybtn8Hu+fpbU1L59ETvOTCeiC3NoCDnlQCgqwt+QfOMduTqnrsjeqRksbM78AFtskbF3xSSKPeYGwV9FKfZYgeiKO3j+LXL+v1Dp40dNuS0cVbxQkuiBubdyYM0flTzyWaUrfHOdXQb/MUglmdT9f2CfTYHlGHStvpo+Nh6Hu92rDEavrQBEOJLtMMSgNvokeFdTWQbZiU5rUEqB9FDi/78s6xErfcyivMGToUc5kXJqtPUwbs9s/deE/JjzeTFuqxkS2Uv+fLD0nzjyxiSynnarL9Fmi/Y6DiTzUgHhvHR8kkTKeVvyYOWLO72ZUuSFxXi1xASuO8fHVZaQfe3B/L4uQEEZo7lxheq7t39oxPQcWjd3qFFLOXbPTCskVsKfPzmuEjxek8G3+hnL1he6UWlCHe6VUSR4mvYDvvYqelyeii5SbKfM3nKDFzw04m190S/617BIw4LnynkSip/5EUfmeUmqITbXLVAHsqNvPmSLU+iHl1fbq9GyaBFbgkfD60fqCY3oS11DNfm3bIOS90DGTCxyIAAflnJ+aWbzee613qmFsDSOTVVSsy1X14GdFeiZqWdBOKXaeKOR5AtJscv8rlIUMJOwtdXt8uduIeLk+YpD2ISI8tKXpE3kqsM X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(336012)(83380400001)(81166007)(426003)(8936002)(356005)(36860700001)(47076005)(82740400003)(5660300002)(70206006)(41300700001)(8676002)(4326008)(82310400005)(70586007)(2906002)(7416002)(186003)(2616005)(1076003)(110136005)(26005)(54906003)(6666004)(40480700001)(316002)(478600001)(16526019)(40460700003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:02.0734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54cd921f-b359-4d0c-667b-08dab10c298d 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: BN8NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4113 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The PCIe Software View of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP. Its downstream and upstream ports are hidden to the PCI hierarchy. This different PCI topology requires a different handling of RCHs. Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH). If an RCH is detected, register its port as dport to the device. An RCH is found if the host's dev 0 func 0 devices is an RCiEP with an existing PCIe DVSEC for CXL Devices (ID 0000h). Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 667de4f125f6..a6b1a1501db3 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -48,6 +48,37 @@ static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, return 0; } +static int restricted_host_enumerate_dport(struct cxl_port *port, + struct pci_bus *bus) +{ + struct pci_dev *pdev; + bool is_restricted_host; + int rc; + + /* Check CXL DVSEC of dev 0 func 0 */ + pdev = pci_get_slot(bus, PCI_DEVFN(0, 0)); + + is_restricted_host = pdev + && (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END) + && pci_find_dvsec_capability(pdev, + PCI_DVSEC_VENDOR_ID_CXL, + CXL_DVSEC_PCIE_DEVICE); + if (is_restricted_host) + rc = pci_dev_add_dport(pdev, port, CXL_RESOURCE_NONE); + + pci_dev_put(pdev); + + if (!is_restricted_host) + return 0; + + dev_dbg(bus->bridge, "CXL restricted host found\n"); + + if (rc) + return rc; + + return 1; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; @@ -91,11 +122,15 @@ int devm_cxl_port_enumerate_dports(struct cxl_port *port) { struct pci_bus *bus = cxl_port_to_pci_bus(port); struct cxl_walk_context ctx; - int type; + int type, count; if (!bus) return -ENXIO; + count = restricted_host_enumerate_dport(port, bus); + if (count) + return count; + if (pci_is_root_bus(bus)) type = PCI_EXP_TYPE_ROOT_PORT; else