From patchwork Tue May 23 23:21:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253105 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 7555DC77B75 for ; Tue, 23 May 2023 23:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238579AbjEWXXQ (ORCPT ); Tue, 23 May 2023 19:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238569AbjEWXXP (ORCPT ); Tue, 23 May 2023 19:23:15 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7D413E; Tue, 23 May 2023 16:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J6MP2pH90xpbOM324RdqNioCNGt0L7XiriUvB0U2UYqHfaqfonwC9RusoFp2GpDPKn73b7beiv7CGRC4igJ6WdEQKH1bhCIDb78tABIq3VHkVUjiM8fde4cn+GhAV3jzvWJRwf8by6U14boHZD0UT9CuiufdAULELIFZFgSDSvrHez8tzrPnLfB5gJlnY1YGca0lfy7SuCkiCEca9h0kPvAAQWZsXUrrA6x5q3sdl6+O3S7UXkbcyXTQSd89Zy1LhrRCcLJE01KqQJXs7jhG7UVGdkwp4/LGa/NfvcbFmsXFWqR23M6rfqpgDI464OdiCuLxD3XE90d7NuDwmNPsog== 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=egDokfXXDszvweDL9NrXTgSRRESJBnnhw+oPJSrt11I=; b=dfeQRWwvch6PSrCOHVLpwYAB0Kiro5fvr8ZLAmW+jma8sVRPlywYt5WA4t2ijm+vs8iQBZluuCt6VlSwMm0OJ61FbYafk+MEWN01+MyUrW96bGVbJD7UjIB/MS9NuvgSQ4GzRPhWaeDlcazBKv0/qp3f1iluZMWkPNjNCWSQCBhJ2tf9oO6l37UqMjQKL0uQrrRwU2nWLEbHZEVFJtQ7Irk6RnLQPyoWjCC54D6qyKkAr2JGSmMpr82Mq6cbtYbPEGdShqPA9x5RTOr2Ek0tRyf7kwV4jFHw9Xbqo1TLHqLpmPDM2PitKD+7Ti6zx5e8i/zuvI7tY7KzRdIVTdbRpQ== 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=egDokfXXDszvweDL9NrXTgSRRESJBnnhw+oPJSrt11I=; b=wSmvpgPEAcsMIKg4FpyUsS2rJrpu3nWozXoyMVQdgFElNPUlsFYJFSBlVM983zv3q6cpPxi/xZ80u5dpNLzSGgKG6F2CGdqSc8kWV1q4sQPbgK6rQ6jc42kPxH0TxRRJcSmBOAylArYORpFuHE0U2FfeNSSIWOgHvSPbyzX9kmM= Received: from MW4PR03CA0167.namprd03.prod.outlook.com (2603:10b6:303:8d::22) by MW4PR12MB7190.namprd12.prod.outlook.com (2603:10b6:303:225::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:23:11 +0000 Received: from CO1NAM11FT074.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::e2) by MW4PR03CA0167.outlook.office365.com (2603:10b6:303:8d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:23:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT074.mail.protection.outlook.com (10.13.174.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:23:11 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:23:10 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 01/23] cxl/acpi: Probe RCRB later during RCH downstream port creation Date: Tue, 23 May 2023 18:21:52 -0500 Message-ID: <20230523232214.55282-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT074:EE_|MW4PR12MB7190:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e8a6e56-2aa3-4cfc-2020-08db5be4ad08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pt5bM0FB74zJFwIGCx16CbS4dmJ0oBLnEfKuXEnvjl+4ZyxVme4Xxtho09nn6f8YZoBY71BMYTIMmwXRHQpvIYpA4v9cryI9DoEB/Wdl5Q7agGfqs/CX5cNihim7U1YE8Ul8plYGZNPIE7UviPFBMVG8tcM6QAmNyvnxKpYImcxLA1MS/NvhNGY6nKdWVqGI5lAkLhRbu9dW9hB4VEGMC9vWlog20emSYTxh8N1N127mCufUcC3kMmjlYnbQnSkEVtmqppoOAghG5+4edFCrgwty+nR4G48HRaTVo+WVy2C1d/1afGG0MUcuOqne+86NYxLXpCzzvJgPzFA8JIjJ6PsxT9dYDTtWoqqAcr/ammxsPK46VaJ1tWifF6HGXCybsw8dTe4/um6BPLlKXl6ubt0S8m9mT0dewD1L5vk+slL4ucaPCrX0/1s7tVQ87v6gAA5nC4tOcutbYhHonTrlFjZxkKrhDN49KdWYnzWNXIRIamqZN0hldXIITUfvftANGy+734F+Yd8vkPihVSJ2dHWF9QZxJ6RbMfMc8gc+2LDwtfeNt5Cjyclkuxh8Znruq7oIx8LTS+5nr3t5KFLE0P0k1my7b/Rb1f2zH57tmOFwh+VSOCq1yBcDztEcwZ4eE6bsoAIf8XXN95EF7tJjoYnf4EFXHRi/n9/2DKRq4Vt/RDRXH4DF6boeGWjvAAiIKWmzAM1P7/wKcE/TrEL+XBt0TBPb2uq4N47zSt3iT738JBJd7hCT8myi1puOmrvX4rtax1NwM8xmj/iCfcm5yA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(40470700004)(36840700001)(46966006)(2906002)(5660300002)(44832011)(47076005)(426003)(336012)(82310400005)(7416002)(83380400001)(70586007)(70206006)(8676002)(8936002)(40460700003)(4326008)(36756003)(316002)(110136005)(54906003)(41300700001)(478600001)(40480700001)(7696005)(6666004)(86362001)(16526019)(186003)(356005)(81166007)(82740400003)(36860700001)(1076003)(26005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:23:11.5312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e8a6e56-2aa3-4cfc-2020-08db5be4ad08 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: CO1NAM11FT074.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7190 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The RCRB is extracted already during ACPI CEDT table parsing while the data of this is needed not earlier than dport creation. This implementation comes with drawbacks: During ACPI table scan there is already MMIO access including mapping and unmapping, but only ACPI data should be collected here. The collected data must be transferred through a couple of interfaces until it is finally consumed when creating the dport. This causes complex data structures and function interfaces. Additionally, RCRB parsing will be extended to also extract AER data, it would be much easier do this at a later point during port and dport creation when the data structures are available to hold that data. To simplify all that, probe the RCRB at a later point during RCH downstream port creation. Change ACPI table parser to only extract the base address of either the component registers or the RCRB. Parse and extract the RCRB in devm_cxl_add_rch_dport(). This is in preparation to centralize all RCRB scanning. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 52 ++++++++++++++++------------------------- drivers/cxl/core/port.c | 21 +++++++++++++---- drivers/cxl/cxl.h | 1 - 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 7e1765b09e04..39227070da9b 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -373,20 +373,18 @@ 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 rcrb; - resource_size_t chbcr; + resource_size_t base; u32 cxl_version; }; -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, +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->base) return 0; chbs = (struct acpi_cedt_chbs *) header; @@ -395,23 +393,16 @@ static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, return 0; ctx->cxl_version = chbs->cxl_version; - ctx->rcrb = CXL_RESOURCE_NONE; - ctx->chbcr = CXL_RESOURCE_NONE; + ctx->base = CXL_RESOURCE_NONE; if (!chbs->base) return 0; - if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) { - ctx->chbcr = chbs->base; + if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 && + chbs->length != CXL_RCRB_SIZE) return 0; - } - if (chbs->length != CXL_RCRB_SIZE) - return 0; - - ctx->rcrb = chbs->base; - ctx->chbcr = cxl_rcrb_to_component(ctx->dev, chbs->base, - CXL_RCRB_DOWNSTREAM); + ctx->base = chbs->base; return 0; } @@ -440,36 +431,33 @@ 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 = 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) { + if (!ctx.base) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } - if (ctx.rcrb != CXL_RESOURCE_NONE) - dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.rcrb); - - if (ctx.chbcr == CXL_RESOURCE_NONE) { - dev_warn(match, "CHBCR invalid for Host Bridge (UID %lld)\n", + if (ctx.base == CXL_RESOURCE_NONE) { + dev_warn(match, "CHBS invalid for Host Bridge (UID %lld)\n", uid); return 0; } - dev_dbg(match, "CHBCR found: %pa\n", &ctx.chbcr); - pci_root = acpi_pci_find_root(hb->handle); bridge = pci_root->bus->bridge; - if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) - dport = devm_cxl_add_rch_dport(root_port, bridge, uid, - ctx.chbcr, ctx.rcrb); - else - dport = devm_cxl_add_dport(root_port, bridge, uid, - ctx.chbcr); + + if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) { + dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.base); + dport = devm_cxl_add_rch_dport(root_port, bridge, uid, ctx.base); + } else { + dev_dbg(match, "CHBCR found for UID %lld: %pa\n", uid, &ctx.base); + dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.base); + } + if (IS_ERR(dport)) return PTR_ERR(dport); diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index e7c284c890bc..1a3f8729a616 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -938,12 +938,25 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, if (!dport) return ERR_PTR(-ENOMEM); + if (rcrb != CXL_RESOURCE_NONE) { + component_reg_phys = cxl_rcrb_to_component(dport_dev, + rcrb, CXL_RCRB_DOWNSTREAM); + if (component_reg_phys == CXL_RESOURCE_NONE) { + dev_warn(dport_dev, "Invalid Component Registers in RCRB"); + return ERR_PTR(-ENXIO); + } + + dport->rch = true; + } + + if (component_reg_phys != CXL_RESOURCE_NONE) + dev_dbg(dport_dev, "Component Registers found for dport: %pa\n", + &component_reg_phys); + dport->dport = dport_dev; dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; - if (rcrb != CXL_RESOURCE_NONE) - dport->rch = true; dport->rcrb = rcrb; cond_cxl_root_lock(port); @@ -1004,14 +1017,12 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_add_dport, CXL); * @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 * @rcrb: mandatory location of a Root Complex Register Block * * See CXL 3.0 9.11.8 CXL Devices Attached to an RCH */ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, struct device *dport_dev, int port_id, - resource_size_t component_reg_phys, resource_size_t rcrb) { struct cxl_dport *dport; @@ -1022,7 +1033,7 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, } dport = __devm_cxl_add_dport(port, dport_dev, port_id, - component_reg_phys, rcrb); + CXL_RESOURCE_NONE, rcrb); if (IS_ERR(dport)) { dev_dbg(dport_dev, "failed to add RCH dport to %s: %ld\n", dev_name(&port->dev), PTR_ERR(dport)); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index f93a28538962..a5cd661face2 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -671,7 +671,6 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, resource_size_t component_reg_phys); struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, struct device *dport_dev, int port_id, - resource_size_t component_reg_phys, resource_size_t rcrb); struct cxl_decoder *to_cxl_decoder(struct device *dev); From patchwork Tue May 23 23:21:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253106 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 B0B46C7EE26 for ; Tue, 23 May 2023 23:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238574AbjEWXXj (ORCPT ); Tue, 23 May 2023 19:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbjEWXXi (ORCPT ); Tue, 23 May 2023 19:23:38 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5D8F126; Tue, 23 May 2023 16:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NP45ow41d/nGsZbltVa2lmNdPhqJKbi/WwyBeY7aTYcZT7IwW9OvkbT6kUi3zjfSdIwrOQ7eK1egK3cY1/Gf40vEcpCW5I5HC7bBI1z1Ao9WcDaWmY9dxlYyDlQqztpA45gJjmtJs5M9zBHc0ejJXQa0RdCNdGhGOeCaKfhll5H0pujn2so3ZZmtooPWVWBAHnpKAA/WTg6EgDtATL3J1X95l3Q5KpS5gonwzmfuI+j2u9OzRyv5+c8xnhiWxPb+txMUzkfzSGHsrv9H9ThbM97bskTphQMzy+Aihx52W3W17UfpifqzHfmp1NzOq3c2orTlWWfArb52uQFUgwYcNQ== 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=/oQKaCuHIW1mJdkqfX9KyRHf6RHjbGMoMHREq9RKndM=; b=E4sBu7rKn4EtBvH8O38Aks2sj3uonKefaik2Fl297eRO1m5+5rmKCPQc2Ie7JGbCTV0zvG0NdNMUN1wE0TBJCgBYzusDs2V3W1GBttRsVoNEY7oZ0Par2t0edzSVtku4h4+h75N5yS1utUNaick4ArxEcnui3Pa+U7qJMhrEA2/PP2w0HFPswJyEfDHona/q3ZznqV5LveciHgTCaQsNLs79Em1NwzbmnrDo/eUdFsirLz1eCFhMNy6LoIRH/i2/haZQcfSp59tbpxNyCSQSuCxrt0QjG/QdBrhnOfO17hMumlhkcwWCK6f3BI51GS9CdoocRJ+pIcfZrTqO5GsHUQ== 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=/oQKaCuHIW1mJdkqfX9KyRHf6RHjbGMoMHREq9RKndM=; b=sIP2QXXQybTsGeku7/hSSgpMck36P8xt1b8cOe1Qm2NqoXhBL8X967/JsD5pZsqYu6jPhArhlBOYCXUuYRzoO0jCbS64ZhE0+1SgHkz/rFrZ/08Z2099cSdDgnIMgQo5EfUSkHLYNchhwbNsn7FV0q+k4paBawAINMhpZxA7Qno= Received: from MW4PR04CA0387.namprd04.prod.outlook.com (2603:10b6:303:81::32) by PH7PR12MB5653.namprd12.prod.outlook.com (2603:10b6:510:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:23:22 +0000 Received: from CO1NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::c9) by MW4PR04CA0387.outlook.office365.com (2603:10b6:303:81::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:23:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT045.mail.protection.outlook.com (10.13.175.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:23:22 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:23:21 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 02/23] cxl/rch: Prepare for caching the MMIO mapped PCIe AER capability Date: Tue, 23 May 2023 18:21:53 -0500 Message-ID: <20230523232214.55282-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT045:EE_|PH7PR12MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 480804b0-3f4a-4f29-f1c1-08db5be4b38e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YwcJxux0rYZDPMbAUe+7h1eEzQQkmikwj6kJw3yLENwoLM8+bLkaXqtbAJsYwJeEOgvuQvYvOfOSgBxI3j0W5l9VCFPkLeuW8+FF5m4kJrcJ0bbjWVD1KpUCDWl8Itxhr/xiRKvdPURKJta7AylN/aaRS7rm1UGv1JIk6e+7Eq05XhZzLpAN5u1VAffbiEHqrUjFjqDG5guzRyGNc0myuLqSzx+3G6rWPI/wbGRcS08g8eTfLuZH2TBta43cyOxRTsyXbQntCgCdDzPGeQfNfsZOhDG/16JKiy9lD+qpEhO4jBv6AgMD8youeZ5RbzK9FlNcUZL+L6gtSrdyljgNIvflhPfDChGPcJcCFGDNgscmam6lqQucCAm4/Bqx9UaZRpuD/5EhOQPMoxnWs22VTbznzegf5WuA44ubwaNfX/UkHd6ABnvxpgIIUTtInFcaWjMN53FIIGStgRTr/hQGd2yqZEd9oEmaatbFX54HcTjBnLQr1DzcHHkiw1DBRAB7tftZJM38JrOgN6Y8/aDZP1kJhSZ/jfiz5/J8uBLIpEJ9mttM23skgIOr9eJaARMZjbD2AHn9HQb2pGtggzlMc2zPocYVt//06rOd21QK/9HbSILPNPFCfU69woRMQ0pzMPWAASUNP658mouVGwjDuw74Tk7XoHlve5UortzmmYifuN1EoEVc5tqhxk9LmQYmVDnYUSrZ/OOUz1SkdQnUl7A81ICST0mA0TXHneFk9FzSR0jQoP/Lz2BJeF7ClHrYBFrmRZXgNXIps7J+/N6V8w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(36840700001)(40470700004)(46966006)(41300700001)(70206006)(70586007)(2906002)(40480700001)(186003)(1076003)(44832011)(478600001)(4326008)(6666004)(7696005)(26005)(316002)(54906003)(5660300002)(110136005)(7416002)(8936002)(8676002)(36860700001)(40460700003)(16526019)(81166007)(356005)(36756003)(47076005)(2616005)(426003)(336012)(83380400001)(82310400005)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:23:22.4655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 480804b0-3f4a-4f29-f1c1-08db5be4b38e 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: CO1NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5653 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Dan Williams Prepare cxl_probe_rcrb() for retrieving more than just the component register block. The RCH AER handling code wants to get back to the AER capability that happens to be MMIO mapped rather then configuration cycles. Move RCRB specific downstream port data, like the RCRB base and the AER capability offset, into its own data structure ('struct cxl_rcrb_info') for cxl_probe_rcrb() to fill. Extend 'struct cxl_dport' to include a 'struct cxl_rcrb_info' attribute. This centralizes all RCRB scanning in one routine. Signed-off-by: Dan Williams Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman --- drivers/cxl/core/port.c | 7 ++++--- drivers/cxl/core/regs.c | 10 ++++++---- drivers/cxl/cxl.h | 19 ++++++++++++------- drivers/cxl/mem.c | 16 +++++++++------- tools/testing/cxl/Kbuild | 2 +- tools/testing/cxl/test/cxl.c | 10 ++++++---- tools/testing/cxl/test/mock.c | 12 ++++++------ tools/testing/cxl/test/mock.h | 7 ++++--- 8 files changed, 48 insertions(+), 35 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 1a3f8729a616..618865ca6a9f 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -939,8 +939,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENOMEM); if (rcrb != CXL_RESOURCE_NONE) { - component_reg_phys = cxl_rcrb_to_component(dport_dev, - rcrb, CXL_RCRB_DOWNSTREAM); + component_reg_phys = + cxl_probe_rcrb(dport_dev, rcrb, &dport->rcrb, + CXL_RCRB_DOWNSTREAM); if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(dport_dev, "Invalid Component Registers in RCRB"); return ERR_PTR(-ENXIO); @@ -957,7 +958,7 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; - dport->rcrb = rcrb; + dport->rcrb.base = rcrb; cond_cxl_root_lock(port); rc = add_dport(port, dport); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 1476a0299c9b..08da4c917f99 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -332,9 +332,8 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); -resource_size_t cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) +resource_size_t cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, + struct cxl_rcrb_info *ri, enum cxl_rcrb which) { resource_size_t component_reg_phys; void __iomem *addr; @@ -344,6 +343,8 @@ resource_size_t cxl_rcrb_to_component(struct device *dev, if (which == CXL_RCRB_UPSTREAM) rcrb += SZ_4K; + else if (ri) + ri->base = rcrb; /* * RCRB's BAR[0..1] point to component block containing CXL @@ -364,6 +365,7 @@ resource_size_t cxl_rcrb_to_component(struct device *dev, cmd = readw(addr + PCI_COMMAND); bar0 = readl(addr + PCI_BASE_ADDRESS_0); bar1 = readl(addr + PCI_BASE_ADDRESS_1); + iounmap(addr); release_mem_region(rcrb, SZ_4K); @@ -395,4 +397,4 @@ resource_size_t cxl_rcrb_to_component(struct device *dev, return component_reg_phys; } -EXPORT_SYMBOL_NS_GPL(cxl_rcrb_to_component, CXL); +EXPORT_SYMBOL_NS_GPL(cxl_probe_rcrb, CXL); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a5cd661face2..29e0bd2b8f2a 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -267,9 +267,9 @@ enum cxl_rcrb { CXL_RCRB_DOWNSTREAM, CXL_RCRB_UPSTREAM, }; -resource_size_t cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which); +struct cxl_rcrb_info; +resource_size_t cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, + struct cxl_rcrb_info *ri, enum cxl_rcrb which); #define CXL_RESOURCE_NONE ((resource_size_t) -1) #define CXL_TARGET_STRLEN 20 @@ -587,22 +587,27 @@ cxl_find_dport_by_dev(struct cxl_port *port, const struct device *dport_dev) return xa_load(&port->dports, (unsigned long)dport_dev); } +struct cxl_rcrb_info { + resource_size_t base; + u16 aer_cap; +}; + /** * struct cxl_dport - CXL downstream port * @dport: PCI bridge or firmware device representing the downstream link + * @port: reference to cxl_port that contains this downstream port * @port_id: unique hardware identifier for dport in decoder target list * @component_reg_phys: downstream port component registers - * @rcrb: base address for the Root Complex Register Block * @rch: Indicate whether this dport was enumerated in RCH or VH mode - * @port: reference to cxl_port that contains this downstream port + * @rcrb: Data about the Root Complex Register Block layout */ struct cxl_dport { struct device *dport; + struct cxl_port *port; int port_id; resource_size_t component_reg_phys; - resource_size_t rcrb; bool rch; - struct cxl_port *port; + struct cxl_rcrb_info rcrb; }; /** diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 519edd0eb196..7ecdaa7f9315 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -51,7 +51,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, struct cxl_port *parent_port = parent_dport->port; struct cxl_dev_state *cxlds = cxlmd->cxlds; struct cxl_port *endpoint, *iter, *down; - resource_size_t component_reg_phys; int rc; /* @@ -71,12 +70,15 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, * host-bridge RCRB if they are not already mapped via the * typical register locator mechanism. */ - if (parent_dport->rch && cxlds->component_reg_phys == CXL_RESOURCE_NONE) - component_reg_phys = cxl_rcrb_to_component( - &cxlmd->dev, parent_dport->rcrb, CXL_RCRB_UPSTREAM); - else - component_reg_phys = cxlds->component_reg_phys; - endpoint = devm_cxl_add_port(host, &cxlmd->dev, component_reg_phys, + if (parent_dport->rch && + cxlds->component_reg_phys == CXL_RESOURCE_NONE) { + cxlds->component_reg_phys = + cxl_probe_rcrb(&cxlmd->dev, parent_dport->rcrb.base, + NULL, CXL_RCRB_UPSTREAM); + } + + endpoint = devm_cxl_add_port(host, &cxlmd->dev, + cxlds->component_reg_phys, parent_dport); if (IS_ERR(endpoint)) return PTR_ERR(endpoint); diff --git a/tools/testing/cxl/Kbuild b/tools/testing/cxl/Kbuild index 6f9347ade82c..32b9d398d399 100644 --- a/tools/testing/cxl/Kbuild +++ b/tools/testing/cxl/Kbuild @@ -12,7 +12,7 @@ ldflags-y += --wrap=devm_cxl_enumerate_decoders ldflags-y += --wrap=cxl_await_media_ready ldflags-y += --wrap=cxl_hdm_decode_init ldflags-y += --wrap=cxl_dvsec_rr_decode -ldflags-y += --wrap=cxl_rcrb_to_component +ldflags-y += --wrap=cxl_probe_rcrb DRIVERS := ../../../drivers CXL_SRC := $(DRIVERS)/cxl diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index bf00dc52fe96..790dec597a70 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -971,12 +971,14 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) return 0; } -resource_size_t mock_cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) +resource_size_t mock_cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, + struct cxl_rcrb_info *ri, enum cxl_rcrb which) { dev_dbg(dev, "rcrb: %pa which: %d\n", &rcrb, which); + if (which == CXL_RCRB_DOWNSTREAM) + ri->base = rcrb; + return (resource_size_t) which + 1; } @@ -988,7 +990,7 @@ static struct cxl_mock_ops cxl_mock_ops = { .is_mock_dev = is_mock_dev, .acpi_table_parse_cedt = mock_acpi_table_parse_cedt, .acpi_evaluate_integer = mock_acpi_evaluate_integer, - .cxl_rcrb_to_component = mock_cxl_rcrb_to_component, + .cxl_probe_rcrb = mock_cxl_probe_rcrb, .acpi_pci_find_root = mock_acpi_pci_find_root, .devm_cxl_port_enumerate_dports = mock_cxl_port_enumerate_dports, .devm_cxl_setup_hdm = mock_cxl_setup_hdm, diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c index 284416527644..4790055fe25a 100644 --- a/tools/testing/cxl/test/mock.c +++ b/tools/testing/cxl/test/mock.c @@ -259,9 +259,9 @@ int __wrap_cxl_dvsec_rr_decode(struct device *dev, int dvsec, } EXPORT_SYMBOL_NS_GPL(__wrap_cxl_dvsec_rr_decode, CXL); -resource_size_t __wrap_cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) +resource_size_t __wrap_cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, + struct cxl_rcrb_info *ri, + enum cxl_rcrb which) { int index; resource_size_t component_reg_phys; @@ -269,14 +269,14 @@ resource_size_t __wrap_cxl_rcrb_to_component(struct device *dev, if (ops && ops->is_mock_port(dev)) component_reg_phys = - ops->cxl_rcrb_to_component(dev, rcrb, which); + ops->cxl_probe_rcrb(dev, rcrb, ri, which); else - component_reg_phys = cxl_rcrb_to_component(dev, rcrb, which); + component_reg_phys = cxl_probe_rcrb(dev, rcrb, ri, which); put_cxl_mock_ops(index); return component_reg_phys; } -EXPORT_SYMBOL_NS_GPL(__wrap_cxl_rcrb_to_component, CXL); +EXPORT_SYMBOL_NS_GPL(__wrap_cxl_probe_rcrb, CXL); MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(ACPI); diff --git a/tools/testing/cxl/test/mock.h b/tools/testing/cxl/test/mock.h index bef8817b01f2..7ef21356d052 100644 --- a/tools/testing/cxl/test/mock.h +++ b/tools/testing/cxl/test/mock.h @@ -15,9 +15,10 @@ struct cxl_mock_ops { acpi_string pathname, struct acpi_object_list *arguments, unsigned long long *data); - resource_size_t (*cxl_rcrb_to_component)(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which); + resource_size_t (*cxl_probe_rcrb)(struct device *dev, + resource_size_t rcrb, + struct cxl_rcrb_info *ri, + enum cxl_rcrb which); struct acpi_pci_root *(*acpi_pci_find_root)(acpi_handle handle); bool (*is_mock_bus)(struct pci_bus *bus); bool (*is_mock_port)(struct device *dev); From patchwork Tue May 23 23:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253107 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 7FF83C77B75 for ; Tue, 23 May 2023 23:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238663AbjEWXX4 (ORCPT ); Tue, 23 May 2023 19:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbjEWXXz (ORCPT ); Tue, 23 May 2023 19:23:55 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05CAB196; Tue, 23 May 2023 16:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X2osHJ9usoZSz4dVqPGzV64NOfrJ5JTNvioKCCIyed+M2IAuTWCKH9ZsHYHPbFdbxCAY676CAPH20Ih6+wvutT/zEFJT+7W8M7456x9yhusBc7n8SWjnr3snA4eP4YxrIhmZCy7u8MkiQN1/w5QxqxD8lDnnNbntL7qnKSLs8M0YpmIec1xCL+ppYbN7i/Q+SRyX9pqQDn6SZ8yPWAYxUmCHFto/0hbNCSQo749a+fmbGIXNqfwxJSZCasP7rUiIJihow6rTDJK8ssinZ5w2+v19eZwFhuYoHvREf09u6KtqQDnqXX7ERbA/trWvnvpdI/f/4GC2NIFXu1blyGGZ7w== 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=cFVlLB0GBlktuCXYWRL/VlNWdh4Luw9BhB+qEW0/XPM=; b=T2AuS15QqZFKVTV2Ll+82nJy6y9YyHgesxJ8aYEOWj/rZmH4V84jlbhmcan4yigngguQRDEle6Bhhk8pOv9IBCs2TYRLM8OeCBqOjzBVUifN+sE2SNhSesYpIBsrCj61NxCxfD3sMhmNbIrU3VY9A0H60DA57cNCXXYPak9hlfLos2+FZam/KedGBEzVUHmg7bnaMXFIb6e1hv+8xLXLrZr84iebuvX3zxtQA5ESO2cdIEpYVBN/T9DegUP76OZSJD18mSLkQeMj+z/+PJbVWu/Ws3xG32JCNr5htrPZYRDWmiD7rcqBnx13orJuh3nLJRFL+L52gx56/YJq2WeJ5Q== 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=cFVlLB0GBlktuCXYWRL/VlNWdh4Luw9BhB+qEW0/XPM=; b=MUNW1W7HWThqxYdkjqo9SqlgIjgZCNRlhb+knwQ7KnTGakZs5vRW7Ct1VGqkQkc4d76Yw7YkEWYhNFYv6JnH+8wwu7PcUs9JRCt8pxU/ynNSA0L0CLrBrSTieicA/WXDMQ0WbCIH1tuRTjH2UZ2SHx1ldEJKcU3inaYEd/fTvF8= Received: from MW4PR03CA0192.namprd03.prod.outlook.com (2603:10b6:303:b8::17) by PH0PR12MB8151.namprd12.prod.outlook.com (2603:10b6:510:299::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Tue, 23 May 2023 23:23:36 +0000 Received: from CO1NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::ad) by MW4PR03CA0192.outlook.office365.com (2603:10b6:303:b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:23:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT082.mail.protection.outlook.com (10.13.175.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:23:35 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:23:32 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 03/23] cxl: Rename member @dport of struct cxl_dport to @dev Date: Tue, 23 May 2023 18:21:54 -0500 Message-ID: <20230523232214.55282-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT082:EE_|PH0PR12MB8151:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e23b901-285f-4b5f-10e8-08db5be4bb6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KfZ6Tq7h2JelfWPwF7fzgdo/HFzmu617xQhWJAJf9XLWkB77GGfg5p69uGGFD3OcKquLSDXRDttrnKlGvLXhL1a+o8qVUO/ERb84tcT/YQqh9h7Me3zVTaktARuWa967rGG6KJmJjh3xSEoQXhTrKN/uZLc/MJ9csfD+q77Peyh/e5jYQjzKiv8maXPya50zjgK2Hr1P7VtM2d0x0vGu2ZIZ6ti8Guc1/AFZF0nM1mieDWvhGeDsZta2iYqfjBk/ufOoG/qNZNYKdeYqpZUcod+WSwwJgZ1poDfkPbjsXWhULSGxB2dAmO5s7swR27h/0KwcI+G7bQk12aO8VFyKkvESCYDWgn6mTPrlIeLI8y9QXNtw0pZVYTZT3z7UYb0H5LiQpjA10T55xyl+bDvPqd+F9uEgKqPAYc/eGcChUOoibHoqbBTPyTatWxpibRJl5FnVLYVWIbEIualN+NMbzOVaDPQWS1VFXzRS6Uok8hVvjUJbFbavCVkoCKmol30jApSZ3J9TMdhOd3tib0ggWqiggNoVu7TFU/jYsCcnDXRB5BbVQ1X9gPGCj3+p5g8ElxBeqaS7r+3zImL5t4ApJnrfrAcLuXr7ILRbMmco01RxZC6ebuRlRvxeu4sJYyGSGfzwGbpPdiur67QLdjK89k77e03KE6ZnLOzepxJ6G0cpwz9bSzvB6txeVT22VAhkjfCnTosy4Pz/+kjAtkENf8UzHMchLoXL6Zi7ehn9sUN3Ri86Tg7dvGLB5DsJptwJH5acaN+G3GgRqyK4G8UHpQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199021)(36840700001)(46966006)(40470700004)(2906002)(54906003)(47076005)(82310400005)(36860700001)(7416002)(5660300002)(8936002)(8676002)(44832011)(336012)(40460700003)(41300700001)(40480700001)(70586007)(110136005)(70206006)(478600001)(316002)(4326008)(7696005)(6666004)(36756003)(26005)(1076003)(81166007)(86362001)(2616005)(83380400001)(186003)(16526019)(426003)(82740400003)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:23:35.6612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e23b901-285f-4b5f-10e8-08db5be4bb6a 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: CO1NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8151 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Reading code like dport->dport does not immediately suggest that this points to the corresponding device structure of the dport. Rename struct member @dport to @dev. While at it, also rename @new argument of add_dport() to @dport. This better describes the variable as a dport (e.g. new->dport becomes to dport->dev). Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 20 ++++++++++---------- drivers/cxl/core/region.c | 4 ++-- drivers/cxl/cxl.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 618865ca6a9f..66f567480238 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -605,7 +605,7 @@ static int devm_cxl_link_parent_dport(struct device *host, if (!parent_dport) return 0; - rc = sysfs_create_link(&port->dev.kobj, &parent_dport->dport->kobj, + rc = sysfs_create_link(&port->dev.kobj, &parent_dport->dev->kobj, "parent_dport"); if (rc) return rc; @@ -658,7 +658,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, if (iter->host_bridge) port->host_bridge = iter->host_bridge; else if (parent_dport->rch) - port->host_bridge = parent_dport->dport; + port->host_bridge = parent_dport->dev; else port->host_bridge = iter->uport; dev_dbg(uport, "host-bridge: %s\n", dev_name(port->host_bridge)); @@ -847,22 +847,22 @@ static struct cxl_dport *find_dport(struct cxl_port *port, int id) return NULL; } -static int add_dport(struct cxl_port *port, struct cxl_dport *new) +static int add_dport(struct cxl_port *port, struct cxl_dport *dport) { struct cxl_dport *dup; int rc; device_lock_assert(&port->dev); - dup = find_dport(port, new->port_id); + dup = find_dport(port, dport->port_id); if (dup) { dev_err(&port->dev, "unable to add dport%d-%s non-unique port id (%s)\n", - new->port_id, dev_name(new->dport), - dev_name(dup->dport)); + dport->port_id, dev_name(dport->dev), + dev_name(dup->dev)); return -EBUSY; } - rc = xa_insert(&port->dports, (unsigned long)new->dport, new, + rc = xa_insert(&port->dports, (unsigned long)dport->dev, dport, GFP_KERNEL); if (rc) return rc; @@ -895,8 +895,8 @@ static void cxl_dport_remove(void *data) struct cxl_dport *dport = data; struct cxl_port *port = dport->port; - xa_erase(&port->dports, (unsigned long) dport->dport); - put_device(dport->dport); + xa_erase(&port->dports, (unsigned long) dport->dev); + put_device(dport->dev); } static void cxl_dport_unlink(void *data) @@ -954,7 +954,7 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dev_dbg(dport_dev, "Component Registers found for dport: %pa\n", &component_reg_phys); - dport->dport = dport_dev; + dport->dev = dport_dev; dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index f822de44bee0..8886c6201998 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1162,7 +1162,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, dev_dbg(&cxlr->dev, "%s:%s: %s expected %s at %d\n", dev_name(port->uport), dev_name(&port->dev), dev_name(&cxlsd->cxld.dev), - dev_name(ep->dport->dport), + dev_name(ep->dport->dev), cxl_rr->nr_targets_set); return -ENXIO; } @@ -1173,7 +1173,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, cxl_rr->nr_targets_set += inc; dev_dbg(&cxlr->dev, "%s:%s target[%d] = %s for %s:%s @ %d\n", dev_name(port->uport), dev_name(&port->dev), - cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport), + cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos); return 0; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 29e0bd2b8f2a..a8bda2c74a85 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -594,7 +594,7 @@ struct cxl_rcrb_info { /** * struct cxl_dport - CXL downstream port - * @dport: PCI bridge or firmware device representing the downstream link + * @dev: PCI bridge or firmware device representing the downstream link * @port: reference to cxl_port that contains this downstream port * @port_id: unique hardware identifier for dport in decoder target list * @component_reg_phys: downstream port component registers @@ -602,7 +602,7 @@ struct cxl_rcrb_info { * @rcrb: Data about the Root Complex Register Block layout */ struct cxl_dport { - struct device *dport; + struct device *dev; struct cxl_port *port; int port_id; resource_size_t component_reg_phys; From patchwork Tue May 23 23:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253108 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 C2ECDC7EE26 for ; Tue, 23 May 2023 23:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbjEWXYP (ORCPT ); Tue, 23 May 2023 19:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238685AbjEWXYM (ORCPT ); Tue, 23 May 2023 19:24:12 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2089.outbound.protection.outlook.com [40.107.96.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74D1011A; Tue, 23 May 2023 16:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=maKWMi9AzCxojNAIEXXngzoM+KXvN41ns5NSXyYQz99qOaTy4Bn1c5cbKXBIkXqTRDnsHGhD4Zg9qlCDHZrMt6SlwcuH1pzTeXAMO2gIYrLZlD28JMVKlBk2zw1FsiomlRT9HJFoeZP4wA/M+Su466KisEq+HoHzp8M7IT2sGaKRgQL7lSjD9Uqn7vZMdswe9ZGbUEJhqX+HdGp98sw0CM13Xmav18n302KsDkVBHAxEd12Kw66ZcUmd9s27g3nKDwxm8EHHl28+HyBnEdmDk3cK+svECc1E3z1aWOu0g7K3tqSeds5V4E7CKWTfyV2iUO7Do4VT9rvdzOX9dvRLAg== 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=HCYuAh2oY+yIgsTZ3UVFgv/sZuysfs/IETLX8lmb0pE=; b=QkSvD5yCIZ94xzvknYDun8p8gNa4o+ujs6KHV2aV1vr9k3KEmALyM4ccK2Wc+fjt2kaPeEaKEppzQYNM3ENWLkDyW5eqs3G4eB6JfR+TEht3HF28cx35RsFlwaCeq5Vk9qX4+B90rpQ7pPkxh+XkBSe9ULrxrgH93JDlEgWM18oRPqFiXbNi1nHNayw85vDwayA4VVdp8roBkIv2mFIGyc/YFqUjkrNe5WQh+O5S0970nO7VMfNb5j9uu0I5KFgkoraAewL9tEZFdL5eML5ih3B9OKNnH7MBKtN6MDiXm5wVI9JKg00+K8Aw68zCeo5Dgq1J6HnZYX+0M1ROdkhObg== 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=HCYuAh2oY+yIgsTZ3UVFgv/sZuysfs/IETLX8lmb0pE=; b=5M1qm29fkeWIJ/Y4QFkMkK83hXY/DcdYaU04Un5GlDQFPyUwdVmd3GsLak+IdhmnzavQHb1f/nEdLDXyWPMdLQFDcJjuFuVoRfAvWlJvmr2lIhgG/ofE2SD7BxUlK16ocTuSsPMP3bUVQK+cU7y0wY8A923fIaa43nYPLRr9kEg= Received: from MW4PR04CA0262.namprd04.prod.outlook.com (2603:10b6:303:88::27) by CY8PR12MB8242.namprd12.prod.outlook.com (2603:10b6:930:77::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:23:48 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::1f) by MW4PR04CA0262.outlook.office365.com (2603:10b6:303:88::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:23:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:23:47 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:23:43 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 04/23] cxl/core/regs: Add @dev to cxl_register_map Date: Tue, 23 May 2023 18:21:55 -0500 Message-ID: <20230523232214.55282-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT051:EE_|CY8PR12MB8242:EE_ X-MS-Office365-Filtering-Correlation-Id: 334c4346-7aff-4948-aeda-08db5be4c299 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R/t6Nh3jEHx9AiTodL78PvtlyAcFdm0LvAo37O7pI5AApEUg0jRT6Lv6scbK9EkdM478bf4WbVmxvV3nfwUWKEMIrWtpn2CK0X+25BBHc0bLuKweNChjTnlvYdyG20iWqKVxxMqqbu+jG0IGyANNpH5KDRQ0/MltaLjT16O1z1n2TimRUBjJC4TyfR7rPTnEHtW7J0CuZsAcCkXh0DPgFUJcGmPjEHfBuO9Z7MR8v9r9J5lBi5bKvR+L/2h1vIz+pJiC2qsTqRZfOGnkit7IqfR3W4ZXYu8v0AGXzqiGhVmTiJomJAAqp+yk27QAqKRiBDghxSsK8hrSOadjtiOKxrDNVjuWwUSKkMDW8UOqVz/MmLZSNZ1H2GQ/nbratx4JM0ODIgEwPvyA5w4vvcNMnb1VUqldaMaXBmiTHccFhivFeDYX1TIknZkSQEEUEWe666mX8UZgrC9gDxzOntezwMshYxvbMzoW66MU6Ah1194248VF5/2RLOZSlliHb1CAztM78Hssvc/iR0qMPU9zpOT9zfdgFPiZoJrw1DbLjVTEdrNmYBL2k/Rf5rPY6fWxY10kEnCgaA5RjkQRIDA4faO0QCpxvMKEnKvCTPkOKgXM9II3quZfYXBTO33LzFTUBJpCwZdt6oMtYM+3PszuxfKFoyzct6LEAgmcTzMnKpXUQ2vsx+Zc7SfiHK6SBQRyo6luSagRmlPZ1tvu8MmV/AtqEQhLRtjeFnwKc6YD2XiO7yHfQGDlWCpGpenks9TvDhmPAT2/HkffO2XBr2oClg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199021)(46966006)(40470700004)(36840700001)(2906002)(44832011)(7416002)(5660300002)(83380400001)(82310400005)(8936002)(8676002)(40460700003)(70206006)(4326008)(36756003)(70586007)(110136005)(54906003)(316002)(41300700001)(478600001)(6666004)(7696005)(40480700001)(426003)(336012)(26005)(2616005)(81166007)(356005)(82740400003)(86362001)(36860700001)(47076005)(186003)(16526019)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:23:47.7017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 334c4346-7aff-4948-aeda-08db5be4c299 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8242 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The corresponding device of a register mapping is used for devm operations and logging. For operations with struct cxl_register_map the device needs to be kept track separately. To simpify the involved function interfaces, add @dev to cxl_register_map. While at it also reorder function arguments of cxl_map_device_regs() and cxl_map_component_regs() to have the object @cxl_register_map first. In a result a bunch of functions are available to be used with a @cxl_register_map object. This patch is in preparation of reworking the component register setup code. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman --- drivers/cxl/core/hdm.c | 4 ++-- drivers/cxl/core/regs.c | 22 ++++++++++++--------- drivers/cxl/cxl.h | 10 ++++++---- drivers/cxl/pci.c | 42 ++++++++++++++++++++--------------------- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 7889ff203a34..5abfa9276dac 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -85,6 +85,7 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, struct cxl_component_regs *regs) { struct cxl_register_map map = { + .dev = &port->dev, .resource = port->component_reg_phys, .base = crb, .max_size = CXL_COMPONENT_REG_BLOCK_SIZE, @@ -97,8 +98,7 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, return -ENODEV; } - return cxl_map_component_regs(&port->dev, regs, &map, - BIT(CXL_CM_CAP_CAP_ID_HDM)); + return cxl_map_component_regs(&map, regs, BIT(CXL_CM_CAP_CAP_ID_HDM)); } static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 08da4c917f99..9888bdf43e55 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -199,8 +199,9 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, return ret_val; } -int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, - struct cxl_register_map *map, unsigned long map_mask) +int cxl_map_component_regs(struct cxl_register_map *map, + struct cxl_component_regs *regs, + unsigned long map_mask) { struct mapinfo { struct cxl_reg_map *rmap; @@ -213,16 +214,16 @@ int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, for (i = 0; i < ARRAY_SIZE(mapinfo); i++) { struct mapinfo *mi = &mapinfo[i]; - resource_size_t phys_addr; + resource_size_t addr; resource_size_t length; if (!mi->rmap->valid) continue; if (!test_bit(mi->rmap->id, &map_mask)) continue; - phys_addr = map->resource + mi->rmap->offset; + addr = map->resource + mi->rmap->offset; length = mi->rmap->size; - *(mi->addr) = devm_cxl_iomap_block(dev, phys_addr, length); + *(mi->addr) = devm_cxl_iomap_block(map->dev, addr, length); if (!*(mi->addr)) return -ENOMEM; } @@ -231,9 +232,8 @@ int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, } EXPORT_SYMBOL_NS_GPL(cxl_map_component_regs, CXL); -int cxl_map_device_regs(struct device *dev, - struct cxl_device_regs *regs, - struct cxl_register_map *map) +int cxl_map_device_regs(struct cxl_register_map *map, + struct cxl_device_regs *regs) { resource_size_t phys_addr = map->resource; struct mapinfo { @@ -256,7 +256,7 @@ int cxl_map_device_regs(struct device *dev, addr = phys_addr + mi->rmap->offset; length = mi->rmap->size; - *(mi->addr) = devm_cxl_iomap_block(dev, addr, length); + *(mi->addr) = devm_cxl_iomap_block(map->dev, addr, length); if (!*(mi->addr)) return -ENOMEM; } @@ -302,7 +302,10 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, u32 regloc_size, regblocks; int regloc, i; + memset(map, 0, sizeof(*map)); + map->dev = &pdev->dev; map->resource = CXL_RESOURCE_NONE; + regloc = pci_find_dvsec_capability(pdev, PCI_DVSEC_VENDOR_ID_CXL, CXL_DVSEC_REG_LOCATOR); if (!regloc) @@ -328,6 +331,7 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } map->resource = CXL_RESOURCE_NONE; + return -ENODEV; } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a8bda2c74a85..095b767c21e9 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -231,6 +231,7 @@ struct cxl_device_reg_map { /** * struct cxl_register_map - DVSEC harvested register block mapping parameters + * @dev: device for devm operations and logging * @base: virtual base of the register-block-BAR + @block_offset * @resource: physical resource base of the register block * @max_size: maximum mapping size to perform register search @@ -239,6 +240,7 @@ struct cxl_device_reg_map { * @device_map: cxl_reg_maps for device registers */ struct cxl_register_map { + struct device *dev; void __iomem *base; resource_size_t resource; resource_size_t max_size; @@ -253,11 +255,11 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map); void cxl_probe_device_regs(struct device *dev, void __iomem *base, struct cxl_device_reg_map *map); -int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, - struct cxl_register_map *map, +int cxl_map_component_regs(struct cxl_register_map *map, + struct cxl_component_regs *regs, unsigned long map_mask); -int cxl_map_device_regs(struct device *dev, struct cxl_device_regs *regs, - struct cxl_register_map *map); +int cxl_map_device_regs(struct cxl_register_map *map, + struct cxl_device_regs *regs); enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 0872f2233ed0..2a9f65be148b 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,61 +274,59 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } -static int cxl_map_regblock(struct pci_dev *pdev, struct cxl_register_map *map) +static int cxl_map_regblock(struct cxl_register_map *map) { - struct device *dev = &pdev->dev; - map->base = ioremap(map->resource, map->max_size); if (!map->base) { - dev_err(dev, "failed to map registers\n"); + dev_err(map->dev, "failed to map registers\n"); return -ENOMEM; } - dev_dbg(dev, "Mapped CXL Memory Device resource %pa\n", &map->resource); + dev_dbg(map->dev, "Mapped CXL Memory Device resource %pa\n", + &map->resource); + return 0; } -static void cxl_unmap_regblock(struct pci_dev *pdev, - struct cxl_register_map *map) +static void cxl_unmap_regblock(struct cxl_register_map *map) { iounmap(map->base); map->base = NULL; } -static int cxl_probe_regs(struct pci_dev *pdev, struct cxl_register_map *map) +static int cxl_probe_regs(struct cxl_register_map *map) { struct cxl_component_reg_map *comp_map; struct cxl_device_reg_map *dev_map; - struct device *dev = &pdev->dev; void __iomem *base = map->base; switch (map->reg_type) { case CXL_REGLOC_RBI_COMPONENT: comp_map = &map->component_map; - cxl_probe_component_regs(dev, base, comp_map); + cxl_probe_component_regs(map->dev, base, comp_map); if (!comp_map->hdm_decoder.valid) { - dev_err(dev, "HDM decoder registers not found\n"); + dev_err(map->dev, "HDM decoder registers not found\n"); return -ENXIO; } if (!comp_map->ras.valid) - dev_dbg(dev, "RAS registers not found\n"); + dev_dbg(map->dev, "RAS registers not found\n"); - dev_dbg(dev, "Set up component registers\n"); + dev_dbg(map->dev, "Set up component registers\n"); break; case CXL_REGLOC_RBI_MEMDEV: dev_map = &map->device_map; - cxl_probe_device_regs(dev, base, dev_map); + cxl_probe_device_regs(map->dev, base, dev_map); if (!dev_map->status.valid || !dev_map->mbox.valid || !dev_map->memdev.valid) { - dev_err(dev, "registers not found: %s%s%s\n", + dev_err(map->dev, "registers not found: %s%s%s\n", !dev_map->status.valid ? "status " : "", !dev_map->mbox.valid ? "mbox " : "", !dev_map->memdev.valid ? "memdev " : ""); return -ENXIO; } - dev_dbg(dev, "Probing device registers...\n"); + dev_dbg(map->dev, "Probing device registers...\n"); break; default: break; @@ -346,12 +344,12 @@ static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, if (rc) return rc; - rc = cxl_map_regblock(pdev, map); + rc = cxl_map_regblock(map); if (rc) return rc; - rc = cxl_probe_regs(pdev, map); - cxl_unmap_regblock(pdev, map); + rc = cxl_probe_regs(map); + cxl_unmap_regblock(map); return rc; } @@ -688,7 +686,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (rc) return rc; - rc = cxl_map_device_regs(&pdev->dev, &cxlds->regs.device_regs, &map); + rc = cxl_map_device_regs(&map, &cxlds->regs.device_regs); if (rc) return rc; @@ -703,8 +701,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) cxlds->component_reg_phys = map.resource; - rc = cxl_map_component_regs(&pdev->dev, &cxlds->regs.component, - &map, BIT(CXL_CM_CAP_CAP_ID_RAS)); + rc = cxl_map_component_regs(&map, &cxlds->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); From patchwork Tue May 23 23:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253109 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 3ACA7C7EE2E for ; Tue, 23 May 2023 23:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238683AbjEWXYX (ORCPT ); Tue, 23 May 2023 19:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238688AbjEWXYW (ORCPT ); Tue, 23 May 2023 19:24:22 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2064.outbound.protection.outlook.com [40.107.243.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B2AE53; Tue, 23 May 2023 16:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkoXaAMpTycWSOuk66+dy6CiQTvfnXlaKxfBrClv5fSq7YfhuA1AfodnV3xaROYRcmg8EhRCGa2DKSSPl2GQmJutcpk4uedkjoxSTnmYcPLiPDGDxzqFHpfMhdHgbPTsvAysMUUSNCK9ej5xuTCMjavt8GzOdP/t2b3uPs3GgG3CxvjUWwKrKc22K2b/TQi9LTnopv8ClJbsKoO0deIqB6YG1LRLEQ8eaMd+Mf+NVXjOfnd4FAIXwSGexFWgkeCz/iUacnOE7l6q+fQXklL/GGziA9t/Ciia5WYw++w+dOaqRClo3o20YOX5LYGs51PXk9+4eL3jq9dAWKQTvKARyA== 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=QuKQHo+wgt3bi9z1sdkiYszjcMSyPmtLrW0tH0dGwPs=; b=MF4OVvB4thRwdaK6Sl2g32zXocDyDT5Bj4mo4G2NEriX3T1xznSotGirpAPiYps96CwFdcy360N9W29HqzOk9a70sIeMJr9p2usBIUwxj7YqtMMdk04daGsZ1AHzxEPFkptyBt/cokij3dByvEF8zsn4OO9QQ80c6j3Z9tp39PFNNhRkT2FEebN8gK/3+EaZ8uXrAC90YyJ4x2PMre6kpV8R2eDciyIs5uwkYAIov/jTh3whFo2HLZGFOGrI+OwpVKOnmPoTuVWVX+BJA8kP8OpmEjElHLVlwxtEq4Rj1kyRkco60poVrWFiM49ZypE7ELOw5/W2LfWDOx/poRhn8g== 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=QuKQHo+wgt3bi9z1sdkiYszjcMSyPmtLrW0tH0dGwPs=; b=TwSFZ5fVFoqUCYVZNwF/S/rNdypMxSKV47oBSDebtS4zNXQP1gAH87u+YsMwHLwz7C+1+LRQ5H75MoF4kP/K83sSy6C58mS8o8l9YJTnfyjohCIOV7jjR5lvUTqJ7YtMtrhDxgZn860wFD6VY7bVmwbneNNywu76Uf0jORiqKu8= Received: from MW4PR04CA0100.namprd04.prod.outlook.com (2603:10b6:303:83::15) by CH2PR12MB4167.namprd12.prod.outlook.com (2603:10b6:610:7a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29; Tue, 23 May 2023 23:23:55 +0000 Received: from CO1NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::41) by MW4PR04CA0100.outlook.office365.com (2603:10b6:303:83::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:23:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT039.mail.protection.outlook.com (10.13.174.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:23:55 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:23:54 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 05/23] cxl/pci: Refactor component register discovery for reuse Date: Tue, 23 May 2023 18:21:56 -0500 Message-ID: <20230523232214.55282-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT039:EE_|CH2PR12MB4167:EE_ X-MS-Office365-Filtering-Correlation-Id: ca6974c2-8fbf-4157-9599-08db5be4c720 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bUbROVVl7CbegAPvKSJu3f9a2ao0WXyvk6NYrPISM9yfpv+zsmjS05QaggOK/8+eeo7vDxL92QSDiIYTJDScPuaT48HI15HI3P46Ar7bz24LeyWfZXDIWfrFkLYkE/FhZxofhLhAo9Ex0rhH0KZ9x5FmL/0sXe5PlM/j6aB+zQEnWGFq6LrW65oofroDQwgCgeOFpLBqd9bdibFmEuSMYOveyk8X6rv3o/TaHFxC2h42uhsP8tTO/pY/BZ1w8fFqdBEBvTmRgzHctCVlpZj74Th7F2UsAa6WGUEjvgnrWHrSMK3H06nzc9oeWeNCDlv4JiJfVyXjNKxPV6S2sLLQsRrWS3Rw6+3nPCnRmNhTlg/gXWK27KBhPTqsUpK98/sG7toD5A8F8Q0AA0+lGo3vTMtsAJ4gj8JXyKgIPyVztIuNlNOvj3qd34aTsENA9vGOjtn+14+DnwsQzxMz1zWkGO64iTuJukhmAyjC8DNPJ6IDfbwvbmQYgQVyu727l4hVqWWN5bo80o8f967Aa7tJpw+VLbvDtSwULHM5ZOP3IITzss/iJ4wuXSUG9f6TDJ49iEKjVMrJN7STDOihiBhMUmUf1jbKhqW2aPI8eoIf1qq1KTMrH+YnZns5MDMP3jcdMrxAK4xS7f7Gs2NwHNcCC+Rz7w/96T+aGSvRmOK4TyjgrkynfJG6tKW/MV5P4ejzhPHpZXhHNMek1vP0LYcana44yh/VAVLabmuo8WssqCbx5BMGJdXGoQiZAMoHiPcyKxSAgG2bojXeb2EsEIbpyQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(82740400003)(40460700003)(16526019)(26005)(356005)(186003)(81166007)(1076003)(7416002)(44832011)(2616005)(47076005)(36860700001)(36756003)(336012)(83380400001)(426003)(2906002)(40480700001)(41300700001)(7696005)(316002)(54906003)(110136005)(82310400005)(478600001)(70206006)(70586007)(4326008)(86362001)(8936002)(8676002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:23:55.3123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca6974c2-8fbf-4157-9599-08db5be4c720 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: CO1NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4167 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The endpoint implements component register setup code. Refactor it for reuse with RCRB, downstream port, and upstream port setup. Move PCI specifics from cxl_setup_regs() into cxl_pci_setup_regs(). Move cxl_setup_regs() into cxl/core/regs.c and export it. This also includes supporting static functions cxl_map_registerblock(), cxl_unmap_register_block() and cxl_probe_regs(). Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/regs.c | 76 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 1 + drivers/cxl/pci.c | 78 +++-------------------------------------- 3 files changed, 82 insertions(+), 73 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 9888bdf43e55..cb2a5b1c6db5 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -336,6 +336,82 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); +static int cxl_map_regblock(struct cxl_register_map *map) +{ + map->base = ioremap(map->resource, map->max_size); + if (!map->base) { + dev_err(map->dev, "failed to map registers\n"); + return -ENOMEM; + } + + dev_dbg(map->dev, "Mapped CXL Memory Device resource %pa\n", + &map->resource); + + return 0; +} + +static void cxl_unmap_regblock(struct cxl_register_map *map) +{ + iounmap(map->base); + map->base = NULL; +} + +static int cxl_probe_regs(struct cxl_register_map *map) +{ + struct cxl_component_reg_map *comp_map; + struct cxl_device_reg_map *dev_map; + void __iomem *base = map->base; + + switch (map->reg_type) { + case CXL_REGLOC_RBI_COMPONENT: + comp_map = &map->component_map; + cxl_probe_component_regs(map->dev, base, comp_map); + if (!comp_map->hdm_decoder.valid) { + dev_err(map->dev, "HDM decoder registers not found\n"); + return -ENXIO; + } + + if (!comp_map->ras.valid) + dev_dbg(map->dev, "RAS registers not found\n"); + + dev_dbg(map->dev, "Set up component registers\n"); + break; + case CXL_REGLOC_RBI_MEMDEV: + dev_map = &map->device_map; + cxl_probe_device_regs(map->dev, base, dev_map); + if (!dev_map->status.valid || !dev_map->mbox.valid || + !dev_map->memdev.valid) { + dev_err(map->dev, "registers not found: %s%s%s\n", + !dev_map->status.valid ? "status " : "", + !dev_map->mbox.valid ? "mbox " : "", + !dev_map->memdev.valid ? "memdev " : ""); + return -ENXIO; + } + + dev_dbg(map->dev, "Probing device registers...\n"); + break; + default: + break; + } + + return 0; +} + +int cxl_setup_regs(struct cxl_register_map *map) +{ + int rc; + + rc = cxl_map_regblock(map); + if (rc) + return rc; + + rc = cxl_probe_regs(map); + cxl_unmap_regblock(map); + + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_setup_regs, CXL); + resource_size_t cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, struct cxl_rcrb_info *ri, enum cxl_rcrb which) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 095b767c21e9..1c6fe53e9dc7 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -264,6 +264,7 @@ int cxl_map_device_regs(struct cxl_register_map *map, enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); +int cxl_setup_regs(struct cxl_register_map *map); enum cxl_rcrb { CXL_RCRB_DOWNSTREAM, diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 2a9f65be148b..ac17bc0430dc 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,69 +274,8 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } -static int cxl_map_regblock(struct cxl_register_map *map) -{ - map->base = ioremap(map->resource, map->max_size); - if (!map->base) { - dev_err(map->dev, "failed to map registers\n"); - return -ENOMEM; - } - - dev_dbg(map->dev, "Mapped CXL Memory Device resource %pa\n", - &map->resource); - - return 0; -} - -static void cxl_unmap_regblock(struct cxl_register_map *map) -{ - iounmap(map->base); - map->base = NULL; -} - -static int cxl_probe_regs(struct cxl_register_map *map) -{ - struct cxl_component_reg_map *comp_map; - struct cxl_device_reg_map *dev_map; - void __iomem *base = map->base; - - switch (map->reg_type) { - case CXL_REGLOC_RBI_COMPONENT: - comp_map = &map->component_map; - cxl_probe_component_regs(map->dev, base, comp_map); - if (!comp_map->hdm_decoder.valid) { - dev_err(map->dev, "HDM decoder registers not found\n"); - return -ENXIO; - } - - if (!comp_map->ras.valid) - dev_dbg(map->dev, "RAS registers not found\n"); - - dev_dbg(map->dev, "Set up component registers\n"); - break; - case CXL_REGLOC_RBI_MEMDEV: - dev_map = &map->device_map; - cxl_probe_device_regs(map->dev, base, dev_map); - if (!dev_map->status.valid || !dev_map->mbox.valid || - !dev_map->memdev.valid) { - dev_err(map->dev, "registers not found: %s%s%s\n", - !dev_map->status.valid ? "status " : "", - !dev_map->mbox.valid ? "mbox " : "", - !dev_map->memdev.valid ? "memdev " : ""); - return -ENXIO; - } - - dev_dbg(map->dev, "Probing device registers...\n"); - break; - default: - break; - } - - return 0; -} - -static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, - struct cxl_register_map *map) +static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, + struct cxl_register_map *map) { int rc; @@ -344,14 +283,7 @@ static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, if (rc) return rc; - rc = cxl_map_regblock(map); - if (rc) - return rc; - - rc = cxl_probe_regs(map); - cxl_unmap_regblock(map); - - return rc; + return cxl_setup_regs(map); } /* @@ -682,7 +614,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_warn(&pdev->dev, "Device DVSEC not present, skip CXL.mem init\n"); - rc = cxl_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); if (rc) return rc; @@ -695,7 +627,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) * still be useful for management functions so don't return an error. */ cxlds->component_reg_phys = CXL_RESOURCE_NONE; - rc = cxl_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); From patchwork Tue May 23 23:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253110 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 59BA8C7EE26 for ; Tue, 23 May 2023 23:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238676AbjEWXYg (ORCPT ); Tue, 23 May 2023 19:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjEWXYf (ORCPT ); Tue, 23 May 2023 19:24:35 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC5DE5B; Tue, 23 May 2023 16:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SGn6fKMlG1Q5/FAa0pK6AIDuAu8eDt5Zu63ACkRHJpsQqXVCOT+EWjtmp7YbiAV2KTWM4tAr0Skex0zAd1LLOsXYJ8t6FU5k+dSpJRdYu/ztUSQ1LbHTGdYiQUn8qa5uq9myWDQcO6ieV6wxqwCg3IndKAw7vZLmH50mR71RtV0QSMI3qmm2LOv5LWSW5WiBPdc9ha6SW7POeq6j4K2jUtnLmybtUjPJwHRwvUDyETSdvwgXjVVXFI7ZgTPtdAPCxED3nmjgQTztUjlzIBA+YvYYpIyjMn0oO/mn7+MYkk15kGj5I6COH7JIrl5HEX0KhiYVmGvbThXbVAIOu2ApdA== 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=It65MVk32CP51aKCK1dag4V5Hqyq9UBcxOX4uzKEYrw=; b=gk7I/ZFNH24HpP2R2OVLoTFpTnsJPH6ayGyp2Tsu6vgwlIMRbuy4CdzB8RsMXdBm45l2gbD06IUPHu6aUwyR4JdsghMXQKqVHcSPfvgO83nUc+iGGFa24UqWIGoz5aKuieH9sQFolbpJKj8cjNX3oCqFwgnd2JtFwqarxe2yN68u5Ek2R4DBih42kYlYRea+CE+UUGUctBnODux8g/VRcopdQz0caSsGksC76kom06zIabCvUYTDq3P//kFk2wKaGgiMSf1b+2zcBokn4rJTczk6UvnT5wjMLAyxgEus3DGvwtTlLeJeIJTzrBuNNHpY2KYzlgyL4tYn6wQ37KhiYg== 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=It65MVk32CP51aKCK1dag4V5Hqyq9UBcxOX4uzKEYrw=; b=iPqhlBx+lJBT+OoJ4IQ9OJERYhZlM5j7RawNe/Uv4sKtT9dLgsNRCQpr9HT1TVlsZvw+D1bdwNxHHS+xzCIYAhYcM6Jk/2Yb4iGyKZHbR+eRHRdUMsnOJ/w6yVLUoWQnrJK78mIamdkwnXa+hAJtliaH5uDfZxBpDM3QrCUtVPg= Received: from MW4PR03CA0165.namprd03.prod.outlook.com (2603:10b6:303:8d::20) by CH2PR12MB4293.namprd12.prod.outlook.com (2603:10b6:610:7e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14; Tue, 23 May 2023 23:24:09 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::2b) by MW4PR03CA0165.outlook.office365.com (2603:10b6:303:8d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:24:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:24:09 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:24:06 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 06/23] cxl/acpi: Moving add_host_bridge_uport() around Date: Tue, 23 May 2023 18:21:57 -0500 Message-ID: <20230523232214.55282-7-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT017:EE_|CH2PR12MB4293:EE_ X-MS-Office365-Filtering-Correlation-Id: d273a5fc-299f-40db-a135-08db5be4cfac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SVwhXb8Zl3vWEydgnyQvkSh368ya8M97sGQbXOBA01M8kXBgXKP0vhX0cUHcL9j03wmj3jkR06lJnOZs4nBcl8KCAvlushlLNIS2ukfT+kXUdcGLjnHA7AnE3cvXqAaNUJX4H5lhUKRAc6Kkh86iLfsCK12CL0WKC44gQn0MZjbf6jhAZJsbQ9+vLTVDj9gDUMyXIeeHuYGkUUfS4DWMPakwnqxyPWbDRMe0tQuX0VENCcEpttLLrEclg1ud4FMZB175pf5I3gtA6/2QzqHsvbvFSdqC+usYXsJOsYL/JLFKItptvDrlEkTnksH7lLMQpI0VM++rWsIhSXzXbVKOxICxck5DxUHHqaKGU4i+GdAGTjcihO531utGcZYnIic63UbkzO/Y/aXEhpQIK19qAMcg3nN/C720ckN7k9mxZHnf3rWUy6oOWkhMQ+fOZtn1vuiUVbN19smpDPSuSYVrQOJsUutpiMtIlfY88LUrL8x0qMaGLkH+R+w8QLXvg7Djj9A6vnl+v9wLxhcT0KTmEkmBjse0EFtdU02n6tutZNMgVBH2RAp608CpsHKIoXVCNwEDXS6cWZq4HsxRnk0OAJD+XH9nT6Im38w223LYFBaCXu3lEhY0VjqDOqFpHZXE3V+AaJ+K6bOFH12cFhenEt09MgzAvXrh9IpOgZSLCAJtaObxOQswq3SZxyFdI68fsgszY8FRi+zf5HDNyIKuGWMcpst34qY8IKWYCnnSqc9Hl7Bd4JqDMD+kFgDKaFuZxbcL2V+LVXL7ivQCMWSo0w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199021)(36840700001)(40470700004)(46966006)(8676002)(8936002)(47076005)(44832011)(5660300002)(7416002)(36860700001)(82310400005)(336012)(83380400001)(186003)(426003)(16526019)(26005)(1076003)(86362001)(81166007)(2616005)(82740400003)(356005)(40460700003)(41300700001)(40480700001)(6666004)(7696005)(70586007)(70206006)(4326008)(316002)(36756003)(478600001)(110136005)(54906003)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:24:09.6519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d273a5fc-299f-40db-a135-08db5be4cfac 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: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4293 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Just moving code to reorder functions to later share cxl_get_chbs() with add_host_bridge_uport(). This makes changes in the next patch visible. No other changes at all. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 90 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 39227070da9b..4fd9fe32f830 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -327,51 +327,6 @@ __mock struct acpi_device *to_cxl_host_bridge(struct device *host, return NULL; } -/* - * A host bridge is a dport to a CFMWS decode and it is a uport to the - * dport (PCIe Root Ports) in the host bridge. - */ -static int add_host_bridge_uport(struct device *match, void *arg) -{ - struct cxl_port *root_port = arg; - struct device *host = root_port->dev.parent; - struct acpi_device *hb = to_cxl_host_bridge(host, match); - struct acpi_pci_root *pci_root; - struct cxl_dport *dport; - struct cxl_port *port; - struct device *bridge; - int rc; - - if (!hb) - return 0; - - pci_root = acpi_pci_find_root(hb->handle); - bridge = pci_root->bus->bridge; - dport = cxl_find_dport_by_dev(root_port, bridge); - if (!dport) { - dev_dbg(host, "host bridge expected and not found\n"); - return 0; - } - - if (dport->rch) { - dev_info(bridge, "host supports CXL (restricted)\n"); - return 0; - } - - rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); - if (rc) - return rc; - - port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, - dport); - if (IS_ERR(port)) - return PTR_ERR(port); - - dev_info(bridge, "host supports CXL\n"); - - return 0; -} - struct cxl_chbs_context { unsigned long long uid; resource_size_t base; @@ -464,6 +419,51 @@ static int add_host_bridge_dport(struct device *match, void *arg) return 0; } +/* + * A host bridge is a dport to a CFMWS decode and it is a uport to the + * dport (PCIe Root Ports) in the host bridge. + */ +static int add_host_bridge_uport(struct device *match, void *arg) +{ + struct cxl_port *root_port = arg; + struct device *host = root_port->dev.parent; + struct acpi_device *hb = to_cxl_host_bridge(host, match); + struct acpi_pci_root *pci_root; + struct cxl_dport *dport; + struct cxl_port *port; + struct device *bridge; + int rc; + + if (!hb) + return 0; + + pci_root = acpi_pci_find_root(hb->handle); + bridge = pci_root->bus->bridge; + dport = cxl_find_dport_by_dev(root_port, bridge); + if (!dport) { + dev_dbg(host, "host bridge expected and not found\n"); + return 0; + } + + if (dport->rch) { + dev_info(bridge, "host supports CXL (restricted)\n"); + return 0; + } + + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); + if (rc) + return rc; + + port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, + dport); + if (IS_ERR(port)) + return PTR_ERR(port); + + dev_info(bridge, "host supports CXL\n"); + + return 0; +} + static int add_root_nvdimm_bridge(struct device *match, void *data) { struct cxl_decoder *cxld; From patchwork Tue May 23 23:21:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253113 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 8C88CC7EE26 for ; Tue, 23 May 2023 23:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235614AbjEWXYy (ORCPT ); Tue, 23 May 2023 19:24:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238718AbjEWXYv (ORCPT ); Tue, 23 May 2023 19:24:51 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF003184; Tue, 23 May 2023 16:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dVI6L3Q+5VLGi5UdC+q+kmN8BBwCfpSkSTqqdWKILgj3nTTqS581vwxw5ri3mbaItPZYE4e6RU/uQuLhnTss0qEJafAlBSGFVlJUnxmREkZwo0l3ckDYPv4gn8xaBGDiFdqugy/BNg3RJ91AnXN+WQZDLpP75jLJ1nw9v7klN5iAnvDPrj/ZwPVOq0S3FwWm+ZRe82FYxfAsYpjqK/B3oo3wwgYLRShnEA7opaq4J96qDIPLfqRdrzXc66MEc06Yghnr38x9SQxTYznhuj8aLZHJ3GuAK/+j2WUiQ4HoOo8h/AuStp6sp1TIZBJKW6qcaS3o4G+Ai4OQ9ye9mRcUAg== 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=g8ZHaV2lEJshBMFNLkBFdton5/MRV4L5HGfPj8fCoPg=; b=YtGCauRQEcx0ql7a3LtA0+7K6QFtU8Zbdx/DS3jWOOa2ZUz9D6WCyJR7x+8sPllf7t5ewMMLzB5zrZ3wPni3JOeczrX2S4YDlGtzRs+0MmoOnfU6GQ2VvKLLUCf+B8EIVxh5cQwaNlCygmOba6SmOYYNWOPT2zwXSO9VqLrf8mrkwQlC+MFWVri/OsQSyWi91iJGmfmyQ1i1TeVh3lLsMcZM2BT2NnP0mkN5L/8wI02GTpz6Qdb8Q5h+5k/uAfDqPEUvx/fifIaR+lXlVBVzAjYsXH7vpSv7VIXM/gG3dyn6HBPnWtlhxCZnTpFAGd4sEnDTByQBkBkFoFaXhbcfNQ== 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=g8ZHaV2lEJshBMFNLkBFdton5/MRV4L5HGfPj8fCoPg=; b=byNB6/ITDygwmPO3QR+1Ftf/aJRBc3Lqt7qVgZU1r3yhxFkJ/RqXWvW/qqvTLO4zYU84pkZmionZO3GqvpCnac20gvLfE/Yx8SaIsit2CI12CuoOUV8R6BT+WfLtlORJij/ZbrQWWIeOdRHa2TaVXx+eytq7AiLt29/17x57s7w= Received: from MW4PR03CA0354.namprd03.prod.outlook.com (2603:10b6:303:dc::29) by DS0PR12MB6533.namprd12.prod.outlook.com (2603:10b6:8:c2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:24:22 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::92) by MW4PR03CA0354.outlook.office365.com (2603:10b6:303:dc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:24:21 +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 CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:24:21 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:24:17 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 07/23] cxl/acpi: Directly bind the CEDT detected CHBCR to the Host Bridge's port Date: Tue, 23 May 2023 18:21:58 -0500 Message-ID: <20230523232214.55282-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT008:EE_|DS0PR12MB6533:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bc9cda2-10de-4b02-53e0-08db5be4d6ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TbQpJz7KZRBua2m9slYYTazlw0pKvfdyov5tCb9sHj4GCqIjE3feqexdvW1TFOghrtKUFQuTUH8GKd9HLSRyurTFG6rb6va1m+T7uHoY60VqCoRwqia38eRltz5PMSufd0OwaC7a538jUFMnTOjWfjYHbjIjjUWM5eoVTfXjN1jgHu9jPGY4HYb44wotR8WLFZmoJZd5DT6KHBNbVRwwv0tMLnF5SxBj1/krKIPTbDtOX3egY9CgGtcwNz7iqNKJZCquJzgBesUHsTL5eUHp9uxDEpdVnjivlw7em8mi+LSd5h7SxWy9YKs7FxG/928VBR8nUmcxvrPoKkjNWrRA2c6OR5PXlbxzCU66kk5hpqtegUMF3XqE+N6FRKJbiTgFaS/YwEZ4X3j4H0VLtnDLe8TX/YkFDSVrpjHNU5Yselb+kpLQRUFva8BepLSKJnI+MEHkw/awzpmly6A8a8NeGY6YaoYKpIFJxdJ0tkTSlnB3sX0Y1wjGD5rMDrYlSfjyVd1rC+LBS0FxctibD7J8rl2oqtKL9/FXM3drmHTySSiCmI1LsWZQz/FYFTPxn5bDolNXXQpsVyZu5xKRR1zxvieffSb2Z+FNv6Cg4EpZ32W1WKGY9ltg5IX8DYjauhlU9zw5ExoMlAzNNRVeRAkZQkqjQH0vszOcMfb+Z/SrebKUB8VMFhdijrcNCTKqxVApKEwH992ftisFlZUwqMK9zVO6vtdK42xtP3iWuNjmxoBpaFnfAVGN0TSKJttghWN8GZW7yjDda/6+gpvQrSBh8w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199021)(40470700004)(36840700001)(46966006)(82310400005)(2906002)(7696005)(6666004)(82740400003)(70586007)(70206006)(110136005)(41300700001)(478600001)(54906003)(426003)(47076005)(2616005)(81166007)(40480700001)(356005)(86362001)(7416002)(8936002)(8676002)(40460700003)(316002)(44832011)(4326008)(36756003)(83380400001)(186003)(26005)(1076003)(336012)(36860700001)(5660300002)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:24:21.4071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc9cda2-10de-4b02-53e0-08db5be4d6ae 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: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6533 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter During a Host Bridge's downstream port enumeration the CHBS entries in the CEDT table are parsed, its Component Register base address extracted and then stored in struct cxl_dport. The CHBS may contain either the RCRB (RCH mode) or the Host Bridge's Component Registers (CHBCR, VH mode). The RCRB further contains the CXL downstream port register base address, while in VH mode the CXL Downstream Switch Ports are visible in the PCI hierarchy and the DP's component regs are disovered using the CXL DVSEC register locator capability. The Component Registers derived from the CHBS for both modes are different and thus also must be treated differently. That is, in RCH mode, the component regs base should be bound to the dport, but in VH mode to the CXL host bridge's port object. The current implementation stores the CHBCR in addition in struct cxl_dport and copies it later from there to struct cxl_port. As a result, the dport contains the wrong Component Registers base address and, e.g. the RAS capability of a CXL Root Port cannot be detected. To fix the CHBCR binding, attach it directly to the Host Bridge's @cxl_port structure. Do this during port creation of the Host Bridge in add_host_bridge_uport(). Factor out CHBS parsing code in add_host_bridge_dport() and use it in both functions. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/acpi.c | 65 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 4fd9fe32f830..78a24b2ca923 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -333,8 +333,8 @@ struct cxl_chbs_context { u32 cxl_version; }; -static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, - const unsigned long end) +static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg, + const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; @@ -362,6 +362,22 @@ static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, return 0; } +static int cxl_get_chbs(struct acpi_device *hb, struct cxl_chbs_context *ctx) +{ + unsigned long long uid; + int rc; + + rc = acpi_evaluate_integer(hb->handle, METHOD_NAME__UID, NULL, &uid); + if (rc != AE_OK) + return -ENOENT; + + memset(ctx, 0, sizeof(*ctx)); + ctx->uid = uid; + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs_iter, ctx); + + return 0; +} + static int add_host_bridge_dport(struct device *match, void *arg) { acpi_status rc; @@ -377,19 +393,15 @@ static int add_host_bridge_dport(struct device *match, void *arg) if (!hb) return 0; - rc = acpi_evaluate_integer(hb->handle, METHOD_NAME__UID, NULL, &uid); - if (rc != AE_OK) { + rc = cxl_get_chbs(hb, &ctx); + if (rc == -ENOENT) dev_err(match, "unable to retrieve _UID\n"); - return -ENODEV; - } + if (rc) + return rc; + uid = ctx.uid; dev_dbg(match, "UID found: %lld\n", uid); - ctx = (struct cxl_chbs_context) { - .uid = uid, - }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); - if (!ctx.base) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); @@ -405,12 +417,17 @@ static int add_host_bridge_dport(struct device *match, void *arg) pci_root = acpi_pci_find_root(hb->handle); bridge = pci_root->bus->bridge; + /* + * In RCH mode, bind the component regs base to the dport. In + * VH mode it will be bound to the CXL host bridge's port + * object later in add_host_bridge_uport(). + */ if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) { dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.base); dport = devm_cxl_add_rch_dport(root_port, bridge, uid, ctx.base); } else { - dev_dbg(match, "CHBCR found for UID %lld: %pa\n", uid, &ctx.base); - dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.base); + dport = devm_cxl_add_dport(root_port, bridge, uid, + CXL_RESOURCE_NONE); } if (IS_ERR(dport)) @@ -432,6 +449,8 @@ static int add_host_bridge_uport(struct device *match, void *arg) struct cxl_dport *dport; struct cxl_port *port; struct device *bridge; + struct cxl_chbs_context ctx; + resource_size_t component_reg_phys; int rc; if (!hb) @@ -450,12 +469,28 @@ static int add_host_bridge_uport(struct device *match, void *arg) return 0; } + rc = cxl_get_chbs(hb, &ctx); + if (rc) + return rc; + + if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) + /* RCH mode, should never happen */ + return 0; + + if (ctx.base) + component_reg_phys = ctx.base; + else + component_reg_phys = CXL_RESOURCE_NONE; + + if (component_reg_phys != CXL_RESOURCE_NONE) + dev_dbg(match, "CHBCR found for UID %lld: %pa\n", + ctx.uid, &component_reg_phys); + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); if (rc) return rc; - port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, - dport); + port = devm_cxl_add_port(host, bridge, component_reg_phys, dport); if (IS_ERR(port)) return PTR_ERR(port); From patchwork Tue May 23 23:21:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253114 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 9CF74C7EE26 for ; Tue, 23 May 2023 23:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238724AbjEWXZG (ORCPT ); Tue, 23 May 2023 19:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238738AbjEWXZD (ORCPT ); Tue, 23 May 2023 19:25:03 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2047.outbound.protection.outlook.com [40.107.223.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270F41BB; Tue, 23 May 2023 16:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WeDl2hSzfjyz167QKLsrrdPw+M5QLRNCVzKJ37hi8Bps6tbLaixyh8ImTr+znCQ5+Vq+R6Cv9AcY5jAmDln+0lz5hANxafNfHdxHiNAmE3Oel6t1YRG77QNHukdEUhNqJ77EIwbGHzoQBWJS04IzTvWP6V7lxY9nUxJzugmZpB0xvr1SKLaYI1pRtrL1xyq3I1B+1GsJVSfg5QVKPlV3/+ojxUTDWXp+RJZANlt65VuQb68jskcseJcEQIzztoGeHgjcPzcZghCFrHP0bOi/fJH+pYyUM6aHV1QT7V4bu1iX4VV4l7es15mza9yRs897rzd9/ynE5mTKX1F+obZ8qA== 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=99kSSiBZtnkXkhLJGyNHL2ZH8gyGsNcAyDN/jiM3uYI=; b=HiboZdzzMLhDKqHPzqcngo778YvfemZmI2ExfY9dF5N4im0Z547DMkD/rIGwhlRCM987pVxw4GjFayxS+szz52gLlLRDHyqC6yrUnb/v2n8TAxCjD5EoyVdO6bBZgv29CUw+X8BpU7ZdFFuz7h/sNkWXpLvn27E+J3H0irhbias+riYD/WaAr8ioEyzOIE2KL3WkFPKbHRBjoCncgfVpfkCrGYpya3Bno8zX0wrOUmJu3tCCVhvNWpszcDdRE9NnWZtXAuWMo94VOtFC3oA2QcGLOierIaWnB7X3SeR/2dWB82BnlXfMDZR6Pj4/Ea0OYG3Ho1ZRRLt6llzqUzOY9g== 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=99kSSiBZtnkXkhLJGyNHL2ZH8gyGsNcAyDN/jiM3uYI=; b=jfzpgmdgXI7StwipwiA98WF4Fyzzigraqwk0tYo77hVk1jl00iNjGgec+aSJ5EnWFGcxyQcbHL29btRRdx5TOgRaXNAggZBHSvwTwn5NhtVB/PfWZwilulANBjvS4grz/2Myrmm6aDOpXNWst2S1IF0d5T9r9QI/JCfPudhDyEA= Received: from MW4PR04CA0104.namprd04.prod.outlook.com (2603:10b6:303:83::19) by SJ2PR12MB7941.namprd12.prod.outlook.com (2603:10b6:a03:4d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:24:31 +0000 Received: from CO1NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::a5) by MW4PR04CA0104.outlook.office365.com (2603:10b6:303:83::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23: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 CO1NAM11FT110.mail.protection.outlook.com (10.13.175.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:24:29 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:24:28 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 08/23] cxl/regs: Remove early capability checks in Component Register setup Date: Tue, 23 May 2023 18:21:59 -0500 Message-ID: <20230523232214.55282-9-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT110:EE_|SJ2PR12MB7941:EE_ X-MS-Office365-Filtering-Correlation-Id: ae444948-3dd2-45de-1a6b-08db5be4db85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VHo8P2heal+Eyr50ZDm9LAkA8+EviGwulsF2J6BDQb3TR2qtVfuyvS1dGYjhamu9/D/Az+Ph1SAenr2X6DThcap4WW+UfOudJcfPJ9py5atbDDpgPQLvieBwSs9rEqlqS052PkxlWKD70/FSeqeneocaKL0pZIyXFgdkIeaNXrXRMQbba7eOKDwWVF9UmbN2JLbL/ox5EyCWp0nyzErg5/jJVW8XZwEKIK8RCJNga7g/pyhNcwPjS3eRkrGiPWySAepOPjkMEwyDslg1xDsFle7DcAjca8/3ZGIzIazCeyN1ARTt0xrWxm9KHFx3Vvq7cRks2osoQR4rjvxAQsxe1rMfogXZRVLqcM+bYAnthVa05CIlj5089H3on0emfDnXZouGkzeZUQQPaqKrEkBH7F1eTBLW9nb4m1MpkOSPJzoyp7k+qQk38WjxxIKPr9mFkcfM+u5yAe+bvAp6odtEgl0OfQGEeSiVBcyLmj3dxvteMZZkpv4V+0+KMOPXxemFWz8mMiwEVgmBsLMc/wQ3UQ73XTkyu2JoMjimE0ZAU2Ei28OFs2h7tYO+81x5GF1XftPvXQvAzB81a3xQd+02OapuQQo4SqQQEM0xPXuCXyDWcX3r1A7LxnNHzPI7wM5CZTbzsoXwHKRuZXJsMEenOwpmAmJf4xqkUMjCwAxJzuWeAYKXKEDd00qxr89dgVjrVWQYT8fi13LuONSWo15hN1w+oYFQB+57XvsniuobTEpMBqQdJpvrupTPQV0NgvMvIjptx37EK4mgJEPozB1ZjQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(70206006)(70586007)(4326008)(7696005)(41300700001)(110136005)(6666004)(316002)(54906003)(5660300002)(8936002)(8676002)(478600001)(86362001)(44832011)(81166007)(82740400003)(356005)(1076003)(7416002)(26005)(186003)(16526019)(40460700003)(426003)(336012)(83380400001)(40480700001)(2906002)(2616005)(36756003)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:24:29.5255 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae444948-3dd2-45de-1a6b-08db5be4db85 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: CO1NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7941 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter When probing the Component Registers in function cxl_probe_regs() there are also checks for the existence of the HDM and RAS capabilities. The checks may fail for components that do not implement the HDM capability causing the Component Registers setup to fail too. Remove the checks for a generalized use of cxl_probe_regs() and check them directly before mapping the RAS or HDM capabilities. This allows it to setup other Component Registers esp. of an RCH Downstream Port, which will be implemented in a follow-on patch. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/regs.c | 8 -------- drivers/cxl/pci.c | 2 ++ drivers/cxl/port.c | 5 ++++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index cb2a5b1c6db5..7e56ddf509c0 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -366,14 +366,6 @@ static int cxl_probe_regs(struct cxl_register_map *map) case CXL_REGLOC_RBI_COMPONENT: comp_map = &map->component_map; cxl_probe_component_regs(map->dev, base, comp_map); - if (!comp_map->hdm_decoder.valid) { - dev_err(map->dev, "HDM decoder registers not found\n"); - return -ENXIO; - } - - if (!comp_map->ras.valid) - dev_dbg(map->dev, "RAS registers not found\n"); - dev_dbg(map->dev, "Set up component registers\n"); break; case CXL_REGLOC_RBI_MEMDEV: diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index ac17bc0430dc..945ca0304d68 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -630,6 +630,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); + else if (!map.component_map.ras.valid) + dev_dbg(&pdev->dev, "RAS registers not found\n"); cxlds->component_reg_phys = map.resource; diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index c23b6164e1c0..e1c7efa9232e 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -102,8 +102,11 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) return rc; cxlhdm = devm_cxl_setup_hdm(port, &info); - if (IS_ERR(cxlhdm)) + if (IS_ERR(cxlhdm)) { + if (PTR_ERR(cxlhdm) == -ENODEV) + dev_err(&port->dev, "HDM decoder registers not found\n"); return PTR_ERR(cxlhdm); + } /* Cache the data early to ensure is_visible() works */ read_cdat_data(port); From patchwork Tue May 23 23:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253115 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 D172AC7EE26 for ; Tue, 23 May 2023 23:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238740AbjEWXZR (ORCPT ); Tue, 23 May 2023 19:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238761AbjEWXZP (ORCPT ); Tue, 23 May 2023 19:25:15 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C95FE68; Tue, 23 May 2023 16:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HpwIqkVRM6B21xvkMy0jFGEFpb+K5ykF0uZ+0I38zCq/GiE5U/oW4/IFzmzNQMvE0EywsDByMNeOxSa0ncoEf3NGrMpM66f8c3+bDKZoMtoyStHc6k/B0M5dWNLnChJpTl1xvJQ4l9ua6sxzcb767SCtWxEU9GvyV60TGk1QVximHng7DZdYQ/SB/lReMfVVlpDvnvLRM2njAtAPuyBVEWglkeDDAGDWzehebGjT83awtuNV3AiwAwPYKgQrQADqkK4b2VIhWXzRmktFttxEvvCpGZBTxKGsXYIgqIxCKysUR0rZ2/3BLdqxrX+PUohAEjNwybaHUNMHVfxZYg9ykw== 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=mG+C/yH6FeEcl+1Yz1DOiJHYp6GBxwEEi/e75p4qm3A=; b=I2YcgLQpCGCoZWSraCiwB12wpJhIETOlp8nonVEDl3B5cngtHfS+2py1jhvR60FjNMsKQ9yM1gTSXzytrDp5MZRjl9R1dCrUEJcRvOAGepSmFT1h3uqxbzfsKYwwvbcAR34Klp/nhcfYRKA/lZ5mLENs94BnHJWJAiX7j4Kk9zdmBc12SzPMzNRSgO+PhVtrayr4HbMsmK0bCoP9BgXeyu61aNi4O4V/DG/oYV7Y3UgZbKlM4rvNx8X/n89Tt5bEGggBAi923ObiIT5kc4IdSWUB2MYxIExi3ALjx3vfWnTKRL+L+zNYhuGXiCT1fVV3X565MejYzUD978fOFxIPSQ== 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=mG+C/yH6FeEcl+1Yz1DOiJHYp6GBxwEEi/e75p4qm3A=; b=Rj2hhKKYj+OWUTyzRGKwKVmn7Y6qlZSI6jYWezNqdxc9BDXVqoLEliRtq1ZgPjofBKTcfIHXpwk8DcKduLTR1/n8co8VLXM3Nil964kRRkJ3MtGOfBZWLsTgSg9Y5iS3qhw5fkEKg/+joR7Yf8poq1ktrBGj60j+ZnelTwW0ifY= Received: from MW4PR04CA0282.namprd04.prod.outlook.com (2603:10b6:303:89::17) by CH3PR12MB8457.namprd12.prod.outlook.com (2603:10b6:610:154::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:24:44 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::bc) by MW4PR04CA0282.outlook.office365.com (2603:10b6:303:89::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:24:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:24:43 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:24:39 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 09/23] cxl/pci: Early setup RCH dport component registers from RCRB Date: Tue, 23 May 2023 18:22:00 -0500 Message-ID: <20230523232214.55282-10-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT011:EE_|CH3PR12MB8457:EE_ X-MS-Office365-Filtering-Correlation-Id: 39418d08-762b-4c38-9af6-08db5be4e3ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ss+Mtddbxearu9ke2LGLADJhAWSjXtvQqRIFN7oZ/iKM4R4hBlWHwMlv1nNKv6f2XniJIVPkfy64at5RlLCK/OsFTumtrbMT7GtOcNedJBVeryUPmgykcJUyWB46W1bgzQSUQFrGSf/E5LE8iEKZWf+nxGRCc/tZqGC3xDOmLl1/V9xFuYrSjM5DxD2YSPqQ+dP1016AsuHR7i9F5Qlzi64eypWb7avHJnvVamMNKGu7UzlmBFexaONidgTwsptAbHJpCFejmTioTBqipjdRDyDEU51mAKwTqVeAwo5jRNMMEd/WJ03GmP/NmUKmZZBdNF0KAa2S9qfuk7jI2FS5fPQGJ769hmJDjUv54Z9rDRCUZ9AuC/xKGFok9tS+RGwpVud+Ck2MHrCs/oCsGE4wG8u0a0gYnVFQbkfu59I25U+CiVwnL/djAASDghME3PhjnB3sVM3P3mUxpNYg2mjZJyZvqqYwety0Thu4D4PS/AYgztWOYGeR1HqC82nLyur6N/rwSfCby/f24g3AFFwuwiDiGZtA7CcEMcLdoHXvUzVWpWxuWSyvzkrIPGM3Tug/wxIBJha4a83G4A62OxYecI7i4DaclPy28RA/ua35n1B0iaoBkkKUQVc22eNjynlLGPJp47J0/eH0dFF/ESXXzhJ8olHp7jA5S+Psqn0CKxm/rDvcb5JPwgm2FGoy7OWqtUvrZH4ESiIlqV9I6qDTTrd8taVkUl+UhWge16882DvIzFAvEvdnzYXMCMpkYIdXijcg9YyhDwEajN5h6VoFKA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(110136005)(82310400005)(82740400003)(86362001)(70206006)(70586007)(478600001)(54906003)(81166007)(356005)(36860700001)(83380400001)(2906002)(47076005)(7696005)(2616005)(36756003)(6666004)(336012)(426003)(316002)(4326008)(1076003)(7416002)(8676002)(8936002)(40480700001)(26005)(186003)(40460700003)(5660300002)(41300700001)(16526019)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:24:43.6296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39418d08-762b-4c38-9af6-08db5be4e3ef 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: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8457 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter CXL RAS capabilities must be enabled and accessible as soon as the CXL endpoint is detected in the PCI hierarchy and bound to the cxl_pci driver. This needs to be independent of other modules such as cxl_port or cxl_mem. CXL RAS capabilities reside in the Component Registers. For an RCH this is determined by probing RCRB which is implemented very late once the CXL Memory Device is created. Change this by moving the RCRB probe to the cxl_pci driver. Do this by using a new introduced function cxl_pci_find_port() similar to cxl_mem_find_port() to determine the involved dport by the endpoint's PCI handle. Plug this into the existing cxl_pci_setup_regs() function to setup Component Registers. Probe the RCRB in case the Component Registers cannot be located through the CXL Register Locator capability. This unifies code and early sets up the Component Registers at the same time for both, VH and RCH mode. Only the cxl_pci driver is involved for this. This allows an early mapping of the CXL RAS capability registers. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 7 +++++++ drivers/cxl/cxl.h | 2 ++ drivers/cxl/mem.c | 12 ------------ drivers/cxl/pci.c | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 66f567480238..eff91f141fde 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1477,6 +1477,13 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) } EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); +struct cxl_port *cxl_pci_find_port(struct pci_dev *pdev, + struct cxl_dport **dport) +{ + return find_cxl_port(pdev->dev.parent, dport); +} +EXPORT_SYMBOL_NS_GPL(cxl_pci_find_port, CXL); + struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 1c6fe53e9dc7..e5ae5f4e6669 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -670,6 +670,8 @@ struct cxl_port *find_cxl_root(struct cxl_port *port); int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd); void cxl_bus_rescan(void); void cxl_bus_drain(void); +struct cxl_port *cxl_pci_find_port(struct pci_dev *pdev, + struct cxl_dport **dport); struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport); bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd); diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 7ecdaa7f9315..0643852444f3 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -65,18 +65,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep->next = down; } - /* - * The component registers for an RCD might come from the - * host-bridge RCRB if they are not already mapped via the - * typical register locator mechanism. - */ - if (parent_dport->rch && - cxlds->component_reg_phys == CXL_RESOURCE_NONE) { - cxlds->component_reg_phys = - cxl_probe_rcrb(&cxlmd->dev, parent_dport->rcrb.base, - NULL, CXL_RCRB_UPSTREAM); - } - endpoint = devm_cxl_add_port(host, &cxlmd->dev, cxlds->component_reg_phys, parent_dport); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 945ca0304d68..54c486cd65dd 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,13 +274,48 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } +/* Extract RCRB, use same function interface as cxl_find_regblock(). */ +static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, + enum cxl_regloc_type type, + struct cxl_register_map *map) +{ + struct cxl_dport *dport; + resource_size_t component_reg_phys; + + memset(map, 0, sizeof(*map)); + map->dev = &pdev->dev; + map->resource = CXL_RESOURCE_NONE; + + if (type != CXL_REGLOC_RBI_COMPONENT) + return -ENODEV; + + if (!cxl_pci_find_port(pdev, &dport) || !dport->rch) + return -ENXIO; + + component_reg_phys = cxl_probe_rcrb(&pdev->dev, dport->rcrb.base, + NULL, CXL_RCRB_UPSTREAM); + if (component_reg_phys == CXL_RESOURCE_NONE) + return -ENXIO; + + map->resource = component_reg_phys; + map->reg_type = type; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + + return 0; +} + static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map) { int rc; + /* + * If the Register Locator DVSEC does not contain the + * Component Registers, try to extract them from the RCRB if + * it is an RCH. + */ rc = cxl_find_regblock(pdev, type, map); - if (rc) + if (rc && cxl_rcrb_get_comp_regs(pdev, type, map)) return rc; return cxl_setup_regs(map); From patchwork Tue May 23 23:22:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253116 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 6C715C7EE26 for ; Tue, 23 May 2023 23:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238825AbjEWXZp (ORCPT ); Tue, 23 May 2023 19:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238786AbjEWXZg (ORCPT ); Tue, 23 May 2023 19:25:36 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E149E1AE; Tue, 23 May 2023 16:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEAsfUkUA6cvASq7GrCsW2CflNRwq4Q6vvGloSRlIpAnHHS/PnC67ElDuwNYKUbjsTFNXOF+Gqm/FMixeyhd3MqBFlZKn0WBXqNTqt47k+eXfj7nAur1SdWGqNdHhWOjTBLZm/PPdtbcXbzAb1MdapJ7uQHNJfVZhdamgKTP1fywPM7Bwsf1ar/mitdtJE9DtxgJpBrwpUHP2OdSyItXc43GN4EF2NniUFY9TjmViNhfoYg4dE1ZHHnUi2wvtWvpXgIgVY9Ea2mncNQfXXpkGbfR3uunugCZh7iIRABpmyJGGXiNt0DnnnUWcQvRBXsmZM1Y7Yy8is6i1edeqqZtDw== 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=Cnl+zAtd9pm6BxzOP/0cGIt0UtoAVtgJAnzduopQCp4=; b=TeKpA7r04xBXcFlkPxP9OQq/4XeqfcUJynA8BLP7KoOSTj/5N2MJnp8a+6feZf7VQdcinuNFonlNlhP7BlwE0HZpvrrdD1Z9AG5y8VaDVXyj2l4c1d05nHt3d6dJzQ2GVIANoj7LS/VqmIRpSMXoBH5+PhQwHcyzTEsyV/Q7ifn4rJM8dN6EH7dAVCCQABYpA8kUo5OPj7HPofDWHvVilTIY+ClXOkOC8aBC4ZTlUAcfFQHe/lfJPWeQWZuS0X5uGxQPcbnc8dzdkz25jdJKbx+KJkrkI0Czkt+jR54MWCMKPDLxi5Ktmt+dHASPTaK2OH6Z0aunPUajZZL0I6N3gA== 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=Cnl+zAtd9pm6BxzOP/0cGIt0UtoAVtgJAnzduopQCp4=; b=YtUxkYxea2y+R7sTPfDHVl9P97caezI6CyyQ/fvJmUVcJGuYRa3nl2XAl4vqbAcG674+KLxz/maD7qAlvFPF/F0UXcq3Kp5o4W74sI0qiTjH0hd8xc0M0KVpe/UiLIs15wl+brpC7h3Lq9Pkne0aysTJ2QUJhTWT1fJoDKQckGM= Received: from MW4P221CA0021.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::26) by SA1PR12MB6678.namprd12.prod.outlook.com (2603:10b6:806:251::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Tue, 23 May 2023 23:24:52 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::18) by MW4P221CA0021.outlook.office365.com (2603:10b6:303:8b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:24:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:24:51 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:24:50 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 10/23] cxl/port: Store the port's Component Register mappings in struct cxl_port Date: Tue, 23 May 2023 18:22:01 -0500 Message-ID: <20230523232214.55282-11-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|SA1PR12MB6678:EE_ X-MS-Office365-Filtering-Correlation-Id: 2936b461-c6da-4e11-4890-08db5be4e868 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OwaRER3DDaRx/I4YAL3MG5R6w789arn8eZiN5wAAyCjF1syxXgrEt4C/llAMTqCsAYzDW8bBMxWn27n76+f7P8XOy04LPWSV2pYqxw4OpGhm24qLn/Qe6YgNGKOKQSHxVro+0V58gwZekSPl5za8z0LuB9zD/HFsWNVFZNdwXDVtJDeV4aPB8I+ql2hyMuEjUyMUO4RUpI5PKgjqblQBnvCVmhDjF3nFgoSp1SUGBGhOzUwbtxn7QxOVpEuLzyB3p7qXo6pVoKHH4MsrfGb+hyJO7ivxo9DS/a79zQ11CSk+nuv1okRUQCL3ZV9sIepsYSxRz/gTcZMQPsuBYPrbZCJdFVa+Ulnz4ttEMKqCaOXKjVnT4CWGYRpv3jsP3E7xiGaxGRoiGsUfTbLLl3OH185oBwdHJHGzW1F6YA/SWkSZTDjN6lg/4yghK91cJkIHDO/GLnGEMHCMz0KrA+8aIk+SkgfNiTVTqJd6SoNYo1jccTcb9XIxTT2LXiWgirY0sHkgmSyVnPNQc3hPHXGQvKnqKB4pHj0LqGcgcjp5P3jVbxZZvOSTvdI2XHKqzzZHoKt8P9bm9sfXaZO/nM34omg97U/aCt1d+B+WtDkMdMIzPH2VsEm0y5exKv5yQicH/aDxD2JSH4K2IfR/9S2ZbzUukZhXkqBll8xIebB7nJs+hDxLAAFDE/xCxaCC/yfGWfNpsN+0YXDEapoXpLGNhhGeH4xvnjMbF0u5UatyZ9vXaZpHwOpaEb2jDaDZUV/PEuhUNztUD5kMc8Ek0/5QEg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199021)(40470700004)(36840700001)(46966006)(54906003)(41300700001)(7696005)(110136005)(82310400005)(316002)(70206006)(4326008)(6666004)(70586007)(8676002)(8936002)(5660300002)(478600001)(86362001)(44832011)(16526019)(81166007)(356005)(82740400003)(26005)(40460700003)(7416002)(1076003)(186003)(40480700001)(2906002)(2616005)(36756003)(83380400001)(36860700001)(336012)(426003)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:24:51.1470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2936b461-c6da-4e11-4890-08db5be4e868 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6678 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter CXL capabilities are stored in the Component Registers. To use them, the specific I/O ranges of the capabilities must be determined by probing the registers. For this, the whole Component Register range needs to be mapped temporarily to detect the offset and length of a capability range. In order to use more than one capability of a component (e.g. RAS and HDM) the Component Register are probed and its mappings created multiple times. This also causes overlapping I/O ranges as the whole Component Register range must be mapped again while a capability's I/O range is already mapped. Different capabilities cannot be setup at the same time. E.g. the RAS capability must be made available as soon as the PCI driver is bound, the HDM decoder is setup later during port enumeration. Moreover, during early setup it is still unknown if a certain capability is needed. A central capability setup is therefore not possible, capabilities must be individually enabled once needed during initialization. To avoid a duplicate register probe and overlapping I/O mappings, only probe the Component Registers one time and store the Component Register mapping in struct port. The stored mappings can be used later to iomap the capability register range when enabling the capability, which will be implemented in a follow-on patch. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman --- drivers/cxl/core/port.c | 26 ++++++++++++++++++++++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index eff91f141fde..34e929f1723b 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -686,6 +686,28 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, return ERR_PTR(rc); } +static int cxl_setup_comp_regs(struct device *dev, struct cxl_register_map *map, + resource_size_t component_reg_phys) +{ + if (component_reg_phys == CXL_RESOURCE_NONE) + return -ENODEV; + + memset(map, 0, sizeof(*map)); + map->dev = dev; + map->reg_type = CXL_REGLOC_RBI_COMPONENT; + map->resource = component_reg_phys; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + + return cxl_setup_regs(map); +} + +static inline int cxl_port_setup_regs(struct cxl_port *port, + resource_size_t component_reg_phys) +{ + return cxl_setup_comp_regs(&port->dev, &port->comp_map, + component_reg_phys); +} + static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *uport, resource_size_t component_reg_phys, @@ -709,6 +731,10 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, if (rc) goto err; + rc = cxl_port_setup_regs(port, component_reg_phys); + if (rc && rc != -ENODEV) + goto err; + rc = device_add(dev); if (rc) goto err; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index e5ae5f4e6669..c76e1f84ba61 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -552,6 +552,7 @@ struct cxl_dax_region { * @regions: cxl_region_ref instances, regions mapped by this port * @parent_dport: dport that points to this port in the parent * @decoder_ida: allocator for decoder ids + * @comp_map: component register capability mappings * @nr_dports: number of entries in @dports * @hdm_end: track last allocated HDM decoder instance for allocation ordering * @commit_end: cursor to track highest committed decoder for commit ordering @@ -571,6 +572,7 @@ struct cxl_port { struct xarray regions; struct cxl_dport *parent_dport; struct ida decoder_ida; + struct cxl_register_map comp_map; int nr_dports; int hdm_end; int commit_end; From patchwork Tue May 23 23:22:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253118 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 5E32EC7EE26 for ; Tue, 23 May 2023 23:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238724AbjEWX0U (ORCPT ); Tue, 23 May 2023 19:26:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjEWX0T (ORCPT ); Tue, 23 May 2023 19:26:19 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20624.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::624]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E9DE45; Tue, 23 May 2023 16:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FkgT92ZR8fz/onD2j3I3kNEzCrfKOq0/QHcJ8zQ4pipOCnx5olYlESdJ8SUjrJCERTCK1DyE3hiphtB903QhRbWNLK4/6+53+LFWFBFgMt25OBiAiNfL2rIdYYLcfQJu+yrvouRMAURkmCQCojxnafMFNiGwYEHQTl4YM3n+SlktDzV57n6Bh7shZWgrCoNisvfP18Vsr7eRXRoQGg9x1/G0W0LrQIyaXsQKv8ObQNWaScQzm2fTmEtWMFsE0iPEgCIhv2b4h9eezesaare02lNzKImCDZeCgltbGAEZ2JL6KjsesnC3zpIKdowx/TrrXMlaNWD6T9ZDWeZ2ceV1OA== 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=t86lYdGjut2Bu5lLYRt419rT7a/Rrxw0c6IAPNR8Q6k=; b=JciuEIrorxdsYp/B6zcsun48YXG5vs0370iXBuvyu/1FTPqiYFgp0WrcliLmrR+/W3PlJgZ95OQrrvUBq35s9auMnzux9ALUpI5iPeaXK5LOUJhehpFIiXF1M1URShLfHR3O8O8eNm/O6bLpoaOFMTgzG46imRpg2ZQULX7lne2OiPg7agmgWFsk4SRZGbH+MAUdV5G/ZKQnc6u40wR2tZvA4jp28rU9N5qhxqQVA3qu+EVJTFQFKW7cA1TV4OQRSA3bDiQ54z6YZWvycTHMeOHalxaBOSSQCu5iVxndo5RxoXmAIBRcsXJ3EwdcawvJ/EFzlzGxQQAdlAnAVj2qFw== 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=t86lYdGjut2Bu5lLYRt419rT7a/Rrxw0c6IAPNR8Q6k=; b=N8HRTxpOZH/f4gOyW4SlDtpOIdfzV4hCUPiyN4peL1uuPx6s6rWW+tR1Tnmg2i3xSsr2hqBPWULWTQrpGR/YoBn3NUf8c7E//5/f0pq8vbfy8wPzFaAp/KINJDzy9WnliRrahL/sdKaCrhX8QVqK2XrFgaVjlgELP0ugqxikIEY= Received: from MW4PR04CA0322.namprd04.prod.outlook.com (2603:10b6:303:82::27) by MW4PR12MB7335.namprd12.prod.outlook.com (2603:10b6:303:22b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:03 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::fa) by MW4PR04CA0322.outlook.office365.com (2603:10b6:303:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:02 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:00 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 11/23] cxl/port: Store the downstream port's Component Register mappings in struct cxl_dport Date: Tue, 23 May 2023 18:22:02 -0500 Message-ID: <20230523232214.55282-12-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT066:EE_|MW4PR12MB7335:EE_ X-MS-Office365-Filtering-Correlation-Id: faaab463-f16f-49ed-d39f-08db5be4ef6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ZRKXlMNGIZQWnT2GwjBKHMJTp2vCKPDo7XE1jyLHxRnnugySfsUotOUairKbsWZT3oT3s/aciCtLWLvTWVwdqag76kpzLqNiLzUeK3ysgiL4xgxazYoBhAIWknu15thEdNG6i9IAmmrE7e6TDfKAqXG7xsqNFOCf4gErRbp9GvTsTdV8N1cq2DQ3ssYpd+7ZhsInXgy3k1NvEkeAvyLanH9OOM9fMpb6aQxG/fl7bkTC5vhCeOBEaM0lMV83EZPJOD/bQpXX2pyCtg4v32YcTBH/QUxAjcdo4s9GJHOqTG6QczuI85mTSJLGbWNAKrsR99IHgoIRHlzQ27GafFcWalC1NA2HNx3JQc5juZ3dvo7pQjkzRZyEhTcAomdd7GLDlp2nlQ8kcG/+CrbbmG2Mv3yXlF0DDv/LLOykTLwepQv4hfvYTZyJQpGGKMi/csZmI90p00TZyAyOH3XKSID+J6+HGiYdtzUNdU+TbJCnTXddcgiKqahqxwzV2eRBBIapbCFRTmpd2gkfDHrKesl/9l3vDPDtkUzLyMjcuyjV08ZlwGkNMmcMxtlRUcuD+otX5HS5oL/HGUuNvLpilWdS71WvWVXR53BWXT5Q3J3AmmWsl4CWRghyPN7fUGG3lW0B4ntGX5fRRLe+tVOJgRfhXIDMCcjCWJGe0ZQoZTF8MH0Sb8Zh0KOYPiKXXFDHBhUvNP4sjq04Eo7e2sMUDeo3k10WozLRBR6NUl5STCQfFKM2NdC2fijr+IsEKCtI35930t1rUDGVtituUqC9HnDbA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(396003)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(70586007)(70206006)(478600001)(41300700001)(7696005)(110136005)(54906003)(316002)(4326008)(86362001)(8676002)(5660300002)(8936002)(7416002)(44832011)(356005)(26005)(16526019)(81166007)(186003)(1076003)(82740400003)(40460700003)(426003)(83380400001)(2906002)(40480700001)(336012)(2616005)(36756003)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:02.9405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: faaab463-f16f-49ed-d39f-08db5be4ef6f 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: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7335 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Same as for ports, also store the downstream port's Component Register mappings, use struct cxl_dport for that. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 11 +++++++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 34e929f1723b..db2ba0c886e2 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -708,6 +708,13 @@ static inline int cxl_port_setup_regs(struct cxl_port *port, component_reg_phys); } +static inline int cxl_dport_setup_regs(struct cxl_dport *dport, + resource_size_t component_reg_phys) +{ + return cxl_setup_comp_regs(dport->dev, &dport->comp_map, + component_reg_phys); +} + static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *uport, resource_size_t component_reg_phys, @@ -986,6 +993,10 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->port = port; dport->rcrb.base = rcrb; + rc = cxl_dport_setup_regs(dport, component_reg_phys); + if (rc && rc != -ENODEV) + return ERR_PTR(rc); + cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index c76e1f84ba61..dc83c1d0396e 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -601,6 +601,7 @@ struct cxl_rcrb_info { * struct cxl_dport - CXL downstream port * @dev: PCI bridge or firmware device representing the downstream link * @port: reference to cxl_port that contains this downstream port + * @comp_map: component register capability mappings * @port_id: unique hardware identifier for dport in decoder target list * @component_reg_phys: downstream port component registers * @rch: Indicate whether this dport was enumerated in RCH or VH mode @@ -609,6 +610,7 @@ struct cxl_rcrb_info { struct cxl_dport { struct device *dev; struct cxl_port *port; + struct cxl_register_map comp_map; int port_id; resource_size_t component_reg_phys; bool rch; From patchwork Tue May 23 23:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253123 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 A6715C7EE26 for ; Tue, 23 May 2023 23:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238836AbjEWX2Q (ORCPT ); Tue, 23 May 2023 19:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238822AbjEWX2P (ORCPT ); Tue, 23 May 2023 19:28:15 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2083.outbound.protection.outlook.com [40.107.94.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6120FE7C; Tue, 23 May 2023 16:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DuL4gIElr2RUrrUd7p3ChrVedrFsbyr8hN82Zd64z7b07shpwUAParMOSIwsH9iigOaccCTQeoT9FlEtuUnVVtfnTFc8SzamlugRVeSwQWMdYBzfBvWBUHZgWDc+1z9MLCFgGa4uN9x4z/nam9S1UTUHMSH8ja+XF8/Qzo9evRC+GO8/gStNMSbob+/FbjozY+k3Uc/bTEROa9XFDguB9nzDG4rvW4AaBPcNeoZto1F/0dlaBKI35AedYFYePZuDawOgCZ0DXRT9XqCX5CqzEFPI/qHSz7w+/CojLtaPAljRRcdsh1D6z5317iHWh/9urS9QVOAuu4ieCmG/95SeDQ== 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=apyQxvK48qB48cPBYxODFdsmX5VUAYHhqfdrve25qSU=; b=CelP5i3SR1/QHN9tQXPtqir+BYJaJSPukdoj3PXDCYQrJfUU69/sFaB4vvbEIk0YTAP5liRuALWCGo3iaPxjEo0HhOhSB1TEnmALBmJAI41kZgbw0smZZ1IiO/TpnK2qegyeeGHjz6fMcojh0e+KsxjdpiUPDK9Vkmzo/BECn2X+BTs4R/tHalbH+UPWW+KpghFHjZQDbFt3T+d16kS49CBqXIqdrDu3xWx28iVIbuRGxkAFPR51rehnwc03dY1DvcQUdCTdP+5yNfmsG8GoaYKh8Dkz3whYRSdVBj0CfuXEQ3AvbWiTyJUnlwAcPBY/pGltm1v8bjuS0wvtlJP6kw== 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=apyQxvK48qB48cPBYxODFdsmX5VUAYHhqfdrve25qSU=; b=iHiWlcm42+JK1MPCXP9NJ21sc71AaxK/EDvL8ysv2Al7bCx1FNAyyR+QYGUK+zLyZi5f9+tPtaTYv3TOTjshYN2JVeFyH4CCJ/v4nN5GPPE8IkUYd6cPRCc/+c5uJXNOT7FB4Jce81i9JC0eErI1SANyXzYJoqX1EtRau8EZdBw= Received: from MW4PR03CA0172.namprd03.prod.outlook.com (2603:10b6:303:8d::27) by SN7PR12MB8025.namprd12.prod.outlook.com (2603:10b6:806:340::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:16 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::90) by MW4PR03CA0172.outlook.office365.com (2603:10b6:303:8d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:25:15 +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 CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:25:15 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:11 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 12/23] cxl/pci: Store the endpoint's Component Register mappings in struct cxl_dev_state Date: Tue, 23 May 2023 18:22:03 -0500 Message-ID: <20230523232214.55282-13-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT034:EE_|SN7PR12MB8025:EE_ X-MS-Office365-Filtering-Correlation-Id: 5deaa73e-796e-4a53-407e-08db5be4f6eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 81Y76GhgrolYU1cAvubNoQ32lNycmQlbL/oAS+FYxFhpOS/V9MQpJa/rfVF9TTnTR3i/l4RAeA92xx4lgF0zQfELE0tJ+y4soHY/F6t9nZoUTFuTzfkQx98tmTK1YJY/vZr0tRvJ14EaHXxkwOuEwx9DzcxwMgHGnfkQtwE8NCS0PK7T9a9GPJP7/qSrUxGVhTjHZ2rJcIuAFw2fGDtmMTjM/0v5P1L29w/a8El+GOtDWDpJajtu3c2QQfFkCWjChSnYTHkhi1rEYlu1ycM6BvQeZmeUw3jYVAGQb/aTsVuOf5q+6FLz0oRoM6nXums/0PfNA7yVfcRoq7bFaGPx6Q65ptKKbygS1dMj0xT4S5rxa+TTGEW8WZkryoqIPyFV9wv/jRwA2GcYv5kcYvT7GW/FFxokYx+RbWeBr1ZbKtfasGfwbobUYiOXn7qitEN7LziPzemkjQPVxqLgZUnzUmAIiZ83/Ilmf7O8EeStHzf0Hr1EWIzVqDXx+iPPXG0ah7Y6HX6OxMpElU8L1GLd+bg8QCyFBLfEmksHta+aBQb+PfnGrpS28EVSPQ6YivQBTY8Zw+d0OYlqp8fscFO0eoEHUWf6Al39ReXdqUj6R0sGazw1+NRg742M9xQg1sN2lFfp9NI3nQnwTPSpBVJHD5cizlRgBbl35AOQtyclMJN0yjSGiQ/YQdXo69hGjpXzmMiVvjtYEhdLhuZKKusXQkZrT0KLAoAD3DEqj4SEB+vl2zirXeva/igClo3iM3+nw5Om0hRKig3xLHGYOk01/Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(110136005)(54906003)(41300700001)(7696005)(82310400005)(316002)(4326008)(356005)(6666004)(70206006)(70586007)(81166007)(5660300002)(82740400003)(8676002)(8936002)(86362001)(478600001)(44832011)(7416002)(83380400001)(47076005)(26005)(1076003)(2906002)(40460700003)(16526019)(186003)(36860700001)(36756003)(2616005)(40480700001)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:15.4934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5deaa73e-796e-4a53-407e-08db5be4f6eb 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: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8025 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Same as for ports and dports, also store the endpoint's Component Register mappings, use struct cxl_dev_state for that. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/cxlmem.h | 3 ++- drivers/cxl/pci.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index a2845a7a69d8..2823c5aaf3db 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -263,6 +263,7 @@ struct cxl_poison_state { * * @dev: The device associated with this CXL state * @cxlmd: The device representing the CXL.mem capabilities of @dev + * @comp_map: component register capability mappings * @regs: Parsed register blocks * @cxl_dvsec: Offset to the PCIe device DVSEC * @rcd: operating in RCD mode (CXL 3.0 9.11.8 CXL Devices Attached to an RCH) @@ -299,7 +300,7 @@ struct cxl_poison_state { struct cxl_dev_state { struct device *dev; struct cxl_memdev *cxlmd; - + struct cxl_register_map comp_map; struct cxl_regs regs; int cxl_dvsec; diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 54c486cd65dd..00983770ea7b 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -662,15 +662,16 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) * still be useful for management functions so don't return an error. */ cxlds->component_reg_phys = CXL_RESOURCE_NONE; - rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, + &cxlds->comp_map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); - else if (!map.component_map.ras.valid) + else if (!cxlds->comp_map.component_map.ras.valid) dev_dbg(&pdev->dev, "RAS registers not found\n"); - cxlds->component_reg_phys = map.resource; + cxlds->component_reg_phys = cxlds->comp_map.resource; - rc = cxl_map_component_regs(&map, &cxlds->regs.component, + rc = cxl_map_component_regs(&cxlds->comp_map, &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); From patchwork Tue May 23 23:22:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253117 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 5767AC7EE26 for ; Tue, 23 May 2023 23:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238713AbjEWX0N (ORCPT ); Tue, 23 May 2023 19:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjEWX0M (ORCPT ); Tue, 23 May 2023 19:26:12 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e83::625]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50F2186; Tue, 23 May 2023 16:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0/p2UqSV4vd4Lnhdq/0hytq1IO99CaIX1zFvj4gXtw3G3hIwN2T/+PmyflqO2BeCXt2htRaOdNvKsvpTALDyhbzQxzfHInN6wJvTAaFmj9I81tbnPVYaWi2R+cZADvEkIb+BPzsXtzxNcYzrOUEdK0rzCb/xyouApwbJQoXeDY6TYMwQ4Luu0NyElRzrHixJ8ZZcC3o/SnOOaoN3etIHCdm5pvOp/++7UEKhjUCtKfzaabMHMadRmhH56frzO33Qaa6FkEE4DzhDVAVK9ES5DabuJ4aTQcESaxnyXW6xtMXTT41YuSO0iM+PNdfrBjV4LO3xsZ37sHvmVwlCu0Oaw== 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=l0KWUDvo8knqFxY5epU4v/oEjuSH4pRUOlFsM3aaVh4=; b=X+yz+kMZI7o0ewpNurYPKNjD+N38ka57+fZb26vXwupo/yqXGQz//1DlH1jMGJg9UvCZeSvCDPYArZ0vWCU3RNXTAwe89NZC83mwy0Ive4nYv/YmN0f+lNwT50XhRSW68ixVxoJ46dprx4KWwpYAmFOAzthfjbvXYyZsK2BJEPzp3gl+yQWsPWu2UliPekvuNHamS6SN3RYQa2erZJ8pGUkL4Efoy88JXjw1WNk2rJO8I96nqhRTzkg/HJCNcYdH1WS9sf8Q+msM5L4st7AuYWex00oyJJv9DEUhISIoDCzNQXsybMdajRxzqJ1qZ6axv/1u9UgsazIyU/Qvzk9OYQ== 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=l0KWUDvo8knqFxY5epU4v/oEjuSH4pRUOlFsM3aaVh4=; b=hOnuqfN0j9E7ihyd4UznVWFEUw+VlWUKyQ8fQ8J69cae81IRRODJBR1UNyTmtCZRpRXWTv6iHGfIII47K46EwNcvQkYwtXTHat7z1dwsScyUw0+jSowkqSLazdqUXnGRP8d4jLOltggNDCnAG7I1jmiVM9zZdQocrIEuGy5PzTU= Received: from MW4PR03CA0313.namprd03.prod.outlook.com (2603:10b6:303:dd::18) by SA1PR12MB8985.namprd12.prod.outlook.com (2603:10b6:806:377::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:24 +0000 Received: from CO1NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::2a) by MW4PR03CA0313.outlook.office365.com (2603:10b6:303:dd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:24 +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 CO1NAM11FT023.mail.protection.outlook.com (10.13.175.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:24 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:22 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 13/23] cxl/hdm: Use stored Component Register mappings to map HDM decoder capability Date: Tue, 23 May 2023 18:22:04 -0500 Message-ID: <20230523232214.55282-14-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT023:EE_|SA1PR12MB8985:EE_ X-MS-Office365-Filtering-Correlation-Id: db8bfbd1-10a9-417c-82ac-08db5be4fbff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UUFNTq0v9R8y+hPYQNUnWfiLvK6gLfZzA2kDYKoIQQ81EhlSx9Zxjmv1DGwqfPu7s2z8a2YjEEX97A80ALsxmebh2YpQUlQLg5bTLiyeTU563cDwrAUg9Bi/XyIOWMjAqRABFwIUtk4iPO0CvI0KJT4sD9PFx5miE6ChdKUIvYBhDs6A7WQZRPrlOydtw5JFzPSb6Gszo+OAW+Wjuh6ePRII6Aa1Cstyn0FUY969Njlv/qYOF0+dGmNqwXtnLM1fvQKKQOIsW9D+ufbVJuypU19Ode5SlviWVdg/IEzkwOLBUzFzzUY1/ng0N7OFsmhQdGSpnlWa6NKWWX8vwvl3ajLu53Of1iObiF8zZYvKUYpd7imA2f2mENqyinQxubuF9TBlScvolYrKb6wqPtfbWme5V198ZS6EpcDcdP7HvGoBqUIqWxr6L0xJT6QHbd2OCKF+wSttyeIMUHf1tceNVS4dcsB+wtZxedK4FUBFMNwEMHXxRLedtZfKsLjP9sPq/OVVOO4KK1P75/xWO3QcjX8IPSAmCfu4A4km/YMcXctRnwZZ+K/Q4ymCEqBX4sQz9Zi/0yoj95W7lAn7R8oOqzaJvNYQh9JIeVqF0JKBafv+qHCuiL5eMoDxrl7ztQeZIylFdJMzeTdhvZXWFbeACasqKUw7UWqyPClG/EpQioNbrbz5/yQfNe39C1jCnKP3RM+wM8ALTpXFaPJc7btUXdqgM8LN7vzWLqgGhXI6XMDi1UIJPHHZ6tnCAKPv9dkTK7hCH0BQ+/i5sss4kDllxQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(41300700001)(44832011)(7696005)(26005)(1076003)(6666004)(316002)(40480700001)(82740400003)(81166007)(356005)(8676002)(5660300002)(7416002)(8936002)(36756003)(40460700003)(4326008)(86362001)(478600001)(82310400005)(2616005)(36860700001)(83380400001)(110136005)(54906003)(426003)(336012)(47076005)(2906002)(70206006)(16526019)(186003)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:24.0148 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db8bfbd1-10a9-417c-82ac-08db5be4fbff 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: CO1NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8985 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Now, that the Component Register mappings are stored, use them to enable and map the HDM decoder capabilities. The Component Registers do not need to be probed again for this, remove probing code. The HDM capability applies to Endpoints, USPs and VH Host Bridges. The Endpoint's component register mappings are located in the cxlds and else in the port's structure. Provide a helper function cxl_port_get_comp_map() to locate the mappings depending on the component's type. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/hdm.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 5abfa9276dac..55b5cb4842ae 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -81,26 +81,6 @@ static void parse_hdm_decoder_caps(struct cxl_hdm *cxlhdm) cxlhdm->interleave_mask |= GENMASK(14, 12); } -static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, - struct cxl_component_regs *regs) -{ - struct cxl_register_map map = { - .dev = &port->dev, - .resource = port->component_reg_phys, - .base = crb, - .max_size = CXL_COMPONENT_REG_BLOCK_SIZE, - }; - - cxl_probe_component_regs(&port->dev, crb, &map.component_map); - if (!map.component_map.hdm_decoder.valid) { - dev_dbg(&port->dev, "HDM decoder registers not implemented\n"); - /* unique error code to indicate no HDM decoder capability */ - return -ENODEV; - } - - return cxl_map_component_regs(&map, regs, BIT(CXL_CM_CAP_CAP_ID_HDM)); -} - static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) { struct cxl_hdm *cxlhdm; @@ -145,6 +125,22 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) return true; } +struct cxl_register_map *cxl_port_get_comp_map(struct cxl_port *port) +{ + /* + * HDM capability applies to Endpoints, USPs and VH Host + * Bridges. The Endpoint's component register mappings are + * located in the cxlds. + */ + if (is_cxl_endpoint(port)) { + struct cxl_memdev *memdev = to_cxl_memdev(port->uport); + + return &memdev->cxlds->comp_map; + } + + return &port->comp_map; +} + /** * devm_cxl_setup_hdm - map HDM decoder component registers * @port: cxl_port to map @@ -155,7 +151,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, { struct device *dev = &port->dev; struct cxl_hdm *cxlhdm; - void __iomem *crb; + struct cxl_register_map *comp_map; int rc; cxlhdm = devm_kzalloc(dev, sizeof(*cxlhdm), GFP_KERNEL); @@ -164,19 +160,24 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, cxlhdm->port = port; dev_set_drvdata(dev, cxlhdm); - crb = ioremap(port->component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE); - if (!crb && info && info->mem_enabled) { - cxlhdm->decoder_count = info->ranges; - return cxlhdm; - } else if (!crb) { + comp_map = cxl_port_get_comp_map(port); + + if (!comp_map->component_map.hdm_decoder.valid) { + dev_dbg(&port->dev, "HDM decoder registers not found\n"); + if (info && info->mem_enabled) { + cxlhdm->decoder_count = info->ranges; + return cxlhdm; + } dev_err(dev, "No component registers mapped\n"); return ERR_PTR(-ENXIO); } - rc = map_hdm_decoder_regs(port, crb, &cxlhdm->regs); - iounmap(crb); - if (rc) + rc = cxl_map_component_regs(comp_map, &cxlhdm->regs, + BIT(CXL_CM_CAP_CAP_ID_HDM)); + if (rc) { + dev_dbg(dev, "Failed to map HDM capability.\n"); return ERR_PTR(rc); + } parse_hdm_decoder_caps(cxlhdm); if (cxlhdm->decoder_count == 0) { From patchwork Tue May 23 23:22:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253120 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 3771AC77B75 for ; Tue, 23 May 2023 23:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238797AbjEWX1i (ORCPT ); Tue, 23 May 2023 19:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238772AbjEWX1h (ORCPT ); Tue, 23 May 2023 19:27:37 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82B2E43; Tue, 23 May 2023 16:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bBP6BsFJqld7FtzmaAWt0+2Isi4K2Q2FC+0pyArXzUAofMHcl9Z9jlGh8T/aXD0Bee5/5Ws5+yHm4VpQAl+vqt/nGhyPoTmLZ4Gl+bSzkQGcbI/qncjfX+fDlhft76HjwQ2Gp2plXYKpwIPK8ZY2KFSJ3fvXvI3SUVlGA+/oic3xMP7/iiSye8wUeI0XIlrh2g0bD2mq5WRCTSWIX9qnk1WqReFosZ2EH0fa3nGoki+VViM7/UpLum2EOaOIeiRRh0JcKjSJAT1NPg3wwIuSBXQIC4L1rQ9gK9uDcsTzDiGnvk/RB1hm1eC4LJ8pUcmjNCM5qmb/OQgAy1zhhYb6OQ== 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=YFCJvoWQOBJgfaFONxx5e0Zj4K02ZJPnBpZNxXR3g44=; b=G7DDVWB+QvnC4QAFYnD02KdwyHLWWSAsvy/JPM1+vopLfw8AWr6Sr4ZSZ/So3cEJ8ZwXIWTdu+/HiTEx8MOJF1slPVJ8IalPk4YlB1v+rpueX4GgdH3tdwLwXDg6c7ROG9dSfi8gS6EyeAxfeIkyLgC6ETCW+SDP1nOz9rbEA+PzvN6wmtQedXaART1AZfXpoODd49O8YxK1HjNw3JRu6tyDjn0BPVMzfnViuEB/k/jhMgxfgB1O32k4py/P9FDRem8SoENulggRkP7610drp1esRpmJAX1/3qha4+yuqL+5o6IqWHzlJliQvReC6fkZvFD5bp0AS0ywu4KaB9GZ2A== 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=YFCJvoWQOBJgfaFONxx5e0Zj4K02ZJPnBpZNxXR3g44=; b=sr97LWWfqCuGnoIgfIx7fV+We4/sF9B2THX3utBN2Ipv+ss9dadlDS/4kTTyirsaW6Q+DnzgxFSUC/ukA76QrhOnnZW/guE/Yy8au74YesxlaysGhheQKAqvATi0fzOq1R5f7MeJwt79TTl+HYeb2BN9I2lXkqSPBrWMO4nUwDY= Received: from MW4PR03CA0164.namprd03.prod.outlook.com (2603:10b6:303:8d::19) by PH0PR12MB5629.namprd12.prod.outlook.com (2603:10b6:510:141::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:37 +0000 Received: from CO1NAM11FT108.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::ba) by MW4PR03CA0164.outlook.office365.com (2603:10b6:303:8d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:36 +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 CO1NAM11FT108.mail.protection.outlook.com (10.13.175.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:25:35 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:33 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 14/23] cxl/port: Remove Component Register base address from struct cxl_port Date: Tue, 23 May 2023 18:22:05 -0500 Message-ID: <20230523232214.55282-15-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT108:EE_|PH0PR12MB5629:EE_ X-MS-Office365-Filtering-Correlation-Id: 112863d9-ecdb-47db-3853-08db5be50324 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2btIc88zL8Uds4uVFdY1NOO++2PATW7HKyQ+SmSon9cBIOxq2raYYswHfCn69+6n5aHYT5Ox6Eo/OSNdoeh0zltC9JmK335QoRq82FVd0AuFl2D8DtZzujHbUK4+imutf0EKQg7igzBDp3ffg0voxEdsJXf4m2WvvSqZy6BRSiN8eed4F9H9ALprReu0BI10zmxlv/XhrHg84YoSZPEOaZricKtr1kwts5PAR6VFAiWFfGOpANZg6iZmn26HNYAxZcsZq4rx3doSI0BBt9g0phSjPFNcZqEgciJwCkxil6iandXBsJW6Kc00T/5a5/mwstBXAUPfS7SB9taix/FcmtTLEDzaEsIutll+c17hcwe81uaKUfcmmzNA04Bz05bLmnHq8w1V8ty7srJq9NMlf1OtPRANbtB+orcfynItultE72azM/VO8jFIaO3WLPCWjhsCkPFSjsi7T6Nfj7RY717YWcNHQpUXZQSvTXN36cICp2ENrmiWH0T95l9muOmmbrRksfbdzvBMB54yaagxQbZlVyT47RnkzSUSiPWhNfre1E5Xiw1QPAwrye1Y6+QEAHwp61n1Alm/QRiTYpsWiIGJtd69/uh++skCEGrczyevAUlNoG4K68jN+VM7YNnIv5VYZqB4dEFRB7S38RhHXfQ27IoiAFOAGsLtQE6yueYv3/i2DqDqdw/HOg+NpUDy7+h3QIPq5tISo/LjeLqGvX/n9Muow8rUb6i9bvGeQ0v8+GAab76VeXArHBBvXqZNfQEtbhqznCRRjtUoZZKoMA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(396003)(346002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(47076005)(8676002)(8936002)(5660300002)(7416002)(82310400005)(44832011)(36860700001)(16526019)(186003)(81166007)(336012)(86362001)(2616005)(26005)(1076003)(82740400003)(356005)(426003)(83380400001)(40460700003)(6666004)(41300700001)(7696005)(40480700001)(70206006)(70586007)(316002)(478600001)(36756003)(4326008)(54906003)(110136005)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:35.9994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 112863d9-ecdb-47db-3853-08db5be50324 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: CO1NAM11FT108.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5629 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 4 +--- drivers/cxl/cxl.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index db2ba0c886e2..183f9f8548e2 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -615,7 +615,6 @@ static int devm_cxl_link_parent_dport(struct device *host, static struct lock_class_key cxl_port_key; static struct cxl_port *cxl_port_alloc(struct device *uport, - resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { struct cxl_port *port; @@ -665,7 +664,6 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, } else dev->parent = uport; - port->component_reg_phys = component_reg_phys; ida_init(&port->decoder_ida); port->hdm_end = -1; port->commit_end = -1; @@ -724,7 +722,7 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *dev; int rc; - port = cxl_port_alloc(uport, component_reg_phys, parent_dport); + port = cxl_port_alloc(uport, parent_dport); if (IS_ERR(port)) return port; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index dc83c1d0396e..4365d46606df 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -556,7 +556,6 @@ struct cxl_dax_region { * @nr_dports: number of entries in @dports * @hdm_end: track last allocated HDM decoder instance for allocation ordering * @commit_end: cursor to track highest committed decoder for commit ordering - * @component_reg_phys: component register capability base address (optional) * @dead: last ep has been removed, force port re-creation * @depth: How deep this port is relative to the root. depth 0 is the root. * @cdat: Cached CDAT data @@ -576,7 +575,6 @@ struct cxl_port { int nr_dports; int hdm_end; int commit_end; - resource_size_t component_reg_phys; bool dead; unsigned int depth; struct cxl_cdat { From patchwork Tue May 23 23:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253122 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 22C5CC7EE26 for ; Tue, 23 May 2023 23:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238826AbjEWX2L (ORCPT ); Tue, 23 May 2023 19:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238822AbjEWX2H (ORCPT ); Tue, 23 May 2023 19:28:07 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::61a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 953D11AC; Tue, 23 May 2023 16:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ARA/zJBYfkRrUAvgHYPRa7D8DNXZ4HALr4Foa0YBRLwjX6x2sVBXmtPgfkkjO+x4jn84sm19kYnPcjte3qDkp2ezTqTKGGRi50nPskXYrFNOytgLxlst/1lmwt6ByfMZ28tkuhGBTrd7DvJdl//LBkRvcq3Hpr0pVrdFTt5+cwIQbFDeXAQUYP4J0st4111NjFYBlor8BgJzY+ql4eSYaZ2yHOiI8GgMpy9l8ZlSf6tiWMP+3r2H3alvpojzfGEbZMU3F/yw38+29UksuDteMd2k29BLKS+o7wSQEqy1+kHgXKhzcKjrXDI8DgYpYh9+9++mPysOrtQ2kZNi46M1Og== 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=EL810x2wZZL+OP8fLWiOe4/g4sok4UI7ItBAzJMy2Ig=; b=krAH8/Nx8wX5Abas4ixGUa4D0bef2YoJOIa2oNVf1RSWYEtbEcgriLj/vPH7qAA+RSI7/My621rMSXNzsSYq/HPCK/iO7+Cj5Iz/QylDtJ/hk12vxMtlz2r4W9vlv0vAxJYQ9NzsBejNDbY5PrYEq5zB1yk018UYSnmXvdt3GmAbwqtgvtKwsKCfXvzbJQA1oofukpr4C7czlJRb3Mxe5+Fc/kCt0LYgKoO2cjMEwHAtlrlOTNBDm7FzkOMAMz1PcV1gh7XD82t0ItsjDxmws7RO8xjT2b3c20KfU4tDBpAsfg0NP+/WHys8GOtqTglB/l1tMtbnK1thKsBdI9yr0Q== 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=EL810x2wZZL+OP8fLWiOe4/g4sok4UI7ItBAzJMy2Ig=; b=Ew0luMocbnvmskhsTKohnW4vjIVxTLybxCG7o6N9pOE6IzfvVJ5pxsDknAAauJ7X/smt9IB3ZvrKauhLvfm0havolpSjCEbX6ZawvrICJsNsv7/edqUtqiZnpF9BmXyqoYjddHcFScZfMjTxgAb2XUQ6J0+ZoXFIiezzw9PXjLw= Received: from MW4PR03CA0067.namprd03.prod.outlook.com (2603:10b6:303:b6::12) by DS0PR12MB8765.namprd12.prod.outlook.com (2603:10b6:8:14e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:46 +0000 Received: from CO1NAM11FT099.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::64) by MW4PR03CA0067.outlook.office365.com (2603:10b6:303:b6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:25:46 +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 CO1NAM11FT099.mail.protection.outlook.com (10.13.175.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:25:45 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:44 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 15/23] cxl/port: Remove Component Register base address from struct cxl_dport Date: Tue, 23 May 2023 18:22:06 -0500 Message-ID: <20230523232214.55282-16-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT099:EE_|DS0PR12MB8765:EE_ X-MS-Office365-Filtering-Correlation-Id: 226e3edf-2479-4bbc-649f-08db5be50910 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LVRh+ASfsfKbCqx8ZhM3Fa+/SremA1fkYe35PGUh6GGPJehVlv+uuvSxv4P+c7YK7UrNtBl3D6LH1J8Q/UoBMD1Vx/ESBcH+ERO1iCF39qp2kp6PHAShl+LhVOpAUK6vI5Hja/3Eo7nAFzDHWiGvYd4to7GGos14l8ut20yrFWlKmXlO1gtHC/YW5vHw6lvB5nIljWbX50lqibq30J1j+1SNguaRoo+WkdYt6n5yzmu6c8GYQs2Hp4yLMSDc0Bq3/ODbwxlzfHrtHtcMoGafzyMrAQ+1XEJEjybHAgaaj8ii2vAaOFeMXpig6uC5flLvtj07nPPDGheBBzxwieqplUtgJpWll77hMVA6jH/XzbkDH9h2YD4oB6vAo/aDgAGECp5TPbAmxJnhpKm2J+znAdwQpbXADV+WuIHkK8y/sdVDjGiTlZqKe1GZKa8vbEIwI+M4WcF7o9T9i+BaodBmbj8LSRYXNdrK0K70IUK1Z2YL3P6hOlLGa1612zfZedT6O/p/dROBAV600HerE2CBvb6gLMytD4y03Hja9OXBuem/xQFg0EFfrdOugLWnMs/awhngaUJ3u3kmu+qbR6uW/7cn94gaPi8bGzxjQII6uhnx/1ts9l7njl/YFoI2DCwRi8hsV6X53pve+kMjSwo55ReFKUpwv8Rzow+5kHkOIoDnIK0SoblcZKASRfakpLe2CcSyptJN6ymQ20MaOjC7mf5VtZq3kXFjMNaw55o2I2kzfobNlr0Dqa+H6HL+Bo960187eJCzL5QchETKW/reUg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(110136005)(4326008)(70586007)(70206006)(478600001)(86362001)(54906003)(6666004)(41300700001)(7696005)(316002)(5660300002)(8936002)(8676002)(44832011)(1076003)(26005)(40460700003)(186003)(81166007)(356005)(82740400003)(7416002)(40480700001)(2906002)(16526019)(36756003)(36860700001)(426003)(336012)(83380400001)(2616005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:45.9358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 226e3edf-2479-4bbc-649f-08db5be50910 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: CO1NAM11FT099.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8765 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 1 - drivers/cxl/cxl.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 183f9f8548e2..d147f08780d0 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -987,7 +987,6 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->dev = dport_dev; dport->port_id = port_id; - dport->component_reg_phys = component_reg_phys; dport->port = port; dport->rcrb.base = rcrb; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 4365d46606df..6134644b51f8 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -601,7 +601,6 @@ struct cxl_rcrb_info { * @port: reference to cxl_port that contains this downstream port * @comp_map: component register capability mappings * @port_id: unique hardware identifier for dport in decoder target list - * @component_reg_phys: downstream port component registers * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @rcrb: Data about the Root Complex Register Block layout */ @@ -610,7 +609,6 @@ struct cxl_dport { struct cxl_port *port; struct cxl_register_map comp_map; int port_id; - resource_size_t component_reg_phys; bool rch; struct cxl_rcrb_info rcrb; }; From patchwork Tue May 23 23:22:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253128 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 2E582C77B75 for ; Tue, 23 May 2023 23:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238857AbjEWX24 (ORCPT ); Tue, 23 May 2023 19:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238875AbjEWX2w (ORCPT ); Tue, 23 May 2023 19:28:52 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2056.outbound.protection.outlook.com [40.107.93.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B7010D9; Tue, 23 May 2023 16:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RKApgVmbXNauorBr9wReHAn7ZnpQ8RHclFSWdeF2EEXXL+RyyjWswEnEpx4PRYkPdkcnonn1+TIc5mazX+xRIuT0FlHyFj1h8nBPd86QYEeA4bdeaHs+bcmeZYESttOt0vwa4t6gU3bQtNA3qV9PdweWFmqtB83RDLD94Btp1Cw7N4Oq6gzl5QfuEJjn4H9TO3nxASJxlyjg27nHeKEDcFe6CX+v9X7vanwKQhWwNhC4JluOt7fWKmtXCbQLP6OBYuzR6U8BjR/UCjjKedYjqG188ChvfKxnp2pBbfJt2gjov8T76+eqg1rbRKrOtq/xgJkyaPEMxBc4Ib/218qc/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=HTHGmIllFdtym0JWtvf2gcuLrQ/DaTCeEw9z18jtVkM=; b=cT5JQ9LZU6RJAwwX1o2ZhzmG2I1gUIe5qvdB69YySyIRJrB5M7fwUW5BXYS9eNjMmdqQftQl5Rn6chroKxK3Q8RqwdbdNJ8k7ZYS5kIjBE2n98yp3kHf32bw9ADM6ydHpXSqLKsPwN7MY0xMFMRqyL8Xd2owYvJ9XtWR38/AG2vYdxvxQQE7n2335QL6Issq49hRgyX8fmkFS/H2Wz8frGwVPojZn6RgxZVlXiH9bVNmqDgSfewxKc2iur5plBVg6+fyW0al5AhKkRyakb67/aOZ2UptJWQXO0PSMx5LfExh1FNoyjnC6SwPViH9cT/hAiJtqnmZTl3CZjwDFF3BVg== 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=HTHGmIllFdtym0JWtvf2gcuLrQ/DaTCeEw9z18jtVkM=; b=MvUgEgbrTSOLtfN8AB8fCDTIKSmexC9qiqafeywzF1nI6NSimL2UySqm9qq9Y/5N2VWj+pjmeoRabb4NQpMD5kS/AxbmvAi6Hl6gBbWh6JOo+dx4xXc90DUk9lrR6AuG8hXGHWB3H03PYk8E5LPR1B4eySMEnLjpPYf/0qfCg9U= Received: from MW4PR03CA0273.namprd03.prod.outlook.com (2603:10b6:303:b5::8) by MN2PR12MB4584.namprd12.prod.outlook.com (2603:10b6:208:24e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:25:57 +0000 Received: from CO1NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::39) by MW4PR03CA0273.outlook.office365.com (2603:10b6:303:b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:25:57 +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 CO1NAM11FT070.mail.protection.outlook.com (10.13.175.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:25:56 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:25:55 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 16/23] cxl/pci: Remove Component Register base address from struct cxl_dev_state Date: Tue, 23 May 2023 18:22:07 -0500 Message-ID: <20230523232214.55282-17-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT070:EE_|MN2PR12MB4584:EE_ X-MS-Office365-Filtering-Correlation-Id: a575c9f5-fe6e-4adf-5805-08db5be50fa6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OGtJCcz8cwQqBP3iLvE/+NTlonhDnHWGRnYLufSEOJEhKq4MHeUNZVzLs/tDdhEZXQEekTkbKvsGSgEqY7KvegqPRJbI1q4rwZ2wChyD7WE5NnLcFg95diW4VuDAbOQWtGdqIC8Ey9aHJRoESzh5bUuomgcg8+94PnUY+YgsTD3KAzDWgr9dfrEN6bsmOdz7SxByskj+OqwI+ZUn4SnXsd8nofSqY8YbM5HX5gPGpeSVu9Ta54a8XxasqhmMVo1vXAgIJy4jj6ajR+xje/mMXrOvlOjYSN08bWczxWPF+dtBx5tzmVSpO08BnYbtTNZncSCYlFcC1pRQnwHq+oWBB9pzfivLiznETczqYH3byasV+ZuhGgp3oLv7e9fKTMSt2BxCxc7lRQe254CVhR226VxjSKiP1MxXZ+Qy3lA0qKu3mOQilJPnkuLl3CIK4Z1+LnZTSuN7+yTFbwGTGT5f2ebeH1nfojca1IoIokIi4gV2UI+05jyIikJ7WVRGEmcW8UteSp8ntRBcG83hBQ1zlWS2M8XO/PjkWxlxh+t1u/3+IFC3znwviRSfl9vfMmPyEIHQ7N6NSZW3G9mFAJrIddz4+bXeeJC25y+B/AqlLAvlxmuRggvb74X2c1DH1L4BeBmB4YTD5OP7m5QRU402exnRcS1VPp92XKVN4LxQ6q/9ri/dr+bj3n831akfpfHfEsBNxddS0Vj6R7jC8mntqwbEK0jkLc7i20o+XZTp+fAAITQX+xGS2LRdFkUOJBpD2Xj/EcIKGhYkZejBirpjcg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(36840700001)(40470700004)(46966006)(356005)(82740400003)(7416002)(1076003)(26005)(16526019)(40460700003)(186003)(81166007)(44832011)(2616005)(36860700001)(47076005)(36756003)(83380400001)(426003)(336012)(2906002)(40480700001)(7696005)(41300700001)(110136005)(316002)(54906003)(6666004)(82310400005)(70586007)(70206006)(4326008)(86362001)(8936002)(5660300002)(478600001)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:25:56.9849 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a575c9f5-fe6e-4adf-5805-08db5be50fa6 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: CO1NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4584 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/cxlmem.h | 2 -- drivers/cxl/mem.c | 4 ++-- drivers/cxl/pci.c | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 2823c5aaf3db..7b5b2d3187bf 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -287,7 +287,6 @@ struct cxl_poison_state { * @active_persistent_bytes: sum of hard + soft persistent * @next_volatile_bytes: volatile capacity change pending device reset * @next_persistent_bytes: persistent capacity change pending device reset - * @component_reg_phys: register base of component registers * @info: Cached DVSEC information about the device. * @serial: PCIe Device Serial Number * @event: event log driver state @@ -326,7 +325,6 @@ struct cxl_dev_state { u64 next_volatile_bytes; u64 next_persistent_bytes; - resource_size_t component_reg_phys; u64 serial; struct cxl_event_state event; diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 0643852444f3..618e839919eb 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -49,7 +49,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, struct cxl_dport *parent_dport) { struct cxl_port *parent_port = parent_dport->port; - struct cxl_dev_state *cxlds = cxlmd->cxlds; struct cxl_port *endpoint, *iter, *down; int rc; @@ -65,8 +64,9 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep->next = down; } + /* The Endpoint's component regs are located in cxlds. */ endpoint = devm_cxl_add_port(host, &cxlmd->dev, - cxlds->component_reg_phys, + CXL_RESOURCE_NONE, parent_dport); if (IS_ERR(endpoint)) return PTR_ERR(endpoint); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 00983770ea7b..0db71493db5d 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -661,7 +661,6 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) * If the component registers can't be found, the cxl_pci driver may * still be useful for management functions so don't return an error. */ - cxlds->component_reg_phys = CXL_RESOURCE_NONE; rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &cxlds->comp_map); if (rc) @@ -669,8 +668,6 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) else if (!cxlds->comp_map.component_map.ras.valid) dev_dbg(&pdev->dev, "RAS registers not found\n"); - cxlds->component_reg_phys = cxlds->comp_map.resource; - rc = cxl_map_component_regs(&cxlds->comp_map, &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) From patchwork Tue May 23 23:22:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253129 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 A83E8C77B75 for ; Tue, 23 May 2023 23:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbjEWXcv (ORCPT ); Tue, 23 May 2023 19:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234317AbjEWXct (ORCPT ); Tue, 23 May 2023 19:32:49 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::60f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89EA1E7E; Tue, 23 May 2023 16:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N/1zUfzmdIQouD5ivcbTUzF9Vdu0tprIqQac6NAnMtK14BYdfkNkQDOIA6Ic6HArvoiJSGCLr2Bz0a7zuv6+KiNjKlluasFLD9c2x6lw1i5Xk/U/YK3rYC/AG9oai9OipM3hNGhiCmYiPdCSaF/yv9WNJT9fDYLbFP1YUJAFiiGr1xVJ7NJOPE7SFd0QJe1IfPSEdWpZsD3u0JSA7dJA391D5N1zyo+/3JDRJPWmgV67aVEu9drk90mgstsQ8p6WtoO+YYxygAnF1CqRo/0wikY9vpXEDoKBECQOVAZ6BfHAHs3Ouz1udfQiHH5ZiZ/DDnEOLTWnRmFC6YzwBRBbhg== 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=Up9PnbYq90TTuHUgklfiOWrK0S2RBA+NFGGLVwspxHQ=; b=BsKem7ANFP3pWnSL7RmHgXrvvv/+P5lWjwj34PTyFBx1mhygmU7yZItMkP4L2ABge6p4tI15hE+vQqzSGzXpJEJBa4pn41o4Hqh13K8SnjVgagtEjDeB7lL7QZ5MTf1KaksRJ5NVrSeUguRzgwNQdkFwRjiV8grK1obOGA5sM6enhRiHF7/8PCNpAARgJlvsAZRTPE+focFJH2bDcYlWfl9ooJ4+VuWcW17gS6BcT9e3bhJbmegUFjXpNlQ/4b5OT+b92EVcPeLjqT7oHlFgUsHnOM7fh3Nu5HJJDANWCPD3JJ8egGxdRJpa5YFFBpVcZToKHtsYK+LZ8vVoDoWsHg== 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=Up9PnbYq90TTuHUgklfiOWrK0S2RBA+NFGGLVwspxHQ=; b=c8IhaXBFBqvrNFRH6557O6ZHSvIXQkU9/XYpVP8zkav1bngKqlEYsgo1GI+QOsDt9iYZK01tLptaRnHLNxpVODuZJ6MI0bAhzn/VqJPaS1Cv0T9nMkXXvCSJJK2J1eZhBikOh+5Okti5K3x4Ao8YEswNxAyrH0qAajEHy4cdjos= Received: from MW4PR03CA0278.namprd03.prod.outlook.com (2603:10b6:303:b5::13) by CH3PR12MB8331.namprd12.prod.outlook.com (2603:10b6:610:12f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:26:08 +0000 Received: from CO1NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::6d) by MW4PR03CA0278.outlook.office365.com (2603:10b6:303:b5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:26: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 CO1NAM11FT070.mail.protection.outlook.com (10.13.175.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:26:08 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:26:06 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 17/23] cxl/pci: Add RCH downstream port AER register discovery Date: Tue, 23 May 2023 18:22:08 -0500 Message-ID: <20230523232214.55282-18-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT070:EE_|CH3PR12MB8331:EE_ X-MS-Office365-Filtering-Correlation-Id: a81dea59-0433-4a28-005d-08db5be51643 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5IuJ9G8p4I2ZHP2zDt1yl7bfmXHjAhrE08P01Rm1AhrkkLIX6BxifyPBLGYiBKywR16Ny37r61yZbLHsFJ3HHpy4ULk5Q2+JQlA4FTQSlf5z3mScwB14cQGOcBAiWgEHD57yt738ikCpxT1CR4kZlC+3eCfhMM3CxezvpmGuG0lHbRocr8ZhTvvfbgt+facJS2kdZreBguuTlUYKbvJ41XnxE/67a+jYBL9OhD4lrOfevj9Y2WbjGQ1SGJr7fR+WBedI2tI1jSaSPOBEmLZrrXxanyhmgy87bG7R0eod5+jezQk20pEHP0HFUv3hBjjKeMTwz5qIJ86Cg2Ns5eVvk1ZvKc70V0Y2u8ldrQtGwS0OEd54HQeUUaD7zRnWI6+CnEE+UqTtNm6C6r371I4Gv8INh0uDiZiMHGZhlUltVw3m8/XDo+w+Hg00UrKPgedGZsXO+qVgb/9I8hdKt3k9CAe0faVwryeiTzpZZCn6Grpaliu41Ab/EoB5LY7VnEbpH3kXJavIV9Qbg5x/udt1Vz9RUeWyCoLph3OdabKrCiaKkAW9khQVQ7FacVGomNlpJc1j6Mp+JOwq1OJmoXqUpW8J+pDfGbLdW+nxEF3UayDqdkGjyes7pe6DPiQV1kKmDz7buEbJm0yWCOxPhzGflnnR9qkBLNB9fvaDwTJgg7Zk6rg6QSCaOqZPtzkx9eJaoE8QEO9kYHx/X8jX0JT6ZvZk3+cWlzkpV/sKP3kcRFPH2GQNJbR53m+xjQTELzpINWlnMAxRfukDdB8Qvu/agQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199021)(40470700004)(36840700001)(46966006)(110136005)(54906003)(41300700001)(7696005)(82310400005)(316002)(4326008)(70586007)(356005)(81166007)(70206006)(82740400003)(8936002)(8676002)(86362001)(478600001)(5660300002)(44832011)(7416002)(83380400001)(47076005)(1076003)(26005)(2906002)(40460700003)(16526019)(186003)(36860700001)(36756003)(40480700001)(2616005)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:26:08.0779 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a81dea59-0433-4a28-005d-08db5be51643 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: CO1NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8331 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Restricted CXL host (RCH) downstream port AER information is not currently logged while in the error state. One problem preventing the error logging is the AER and RAS registers are not accessible. The CXL driver requires changes to find RCH downstream port AER and RAS registers for purpose of error logging. RCH downstream ports are not enumerated during a PCI bus scan and are instead discovered using system firmware, ACPI in this case.[1] The downstream port is implemented as a Root Complex Register Block (RCRB). The RCRB is a 4k memory block containing PCIe registers based on the PCIe root port.[2] The RCRB includes AER extended capability registers used for reporting errors. Note, the RCH's AER Capability is located in the RCRB memory space instead of PCI configuration space, thus its register access is different. Existing kernel PCIe AER functions can not be used to manage the downstream port AER capabilities and RAS registers because the port was not enumerated during PCI scan and the registers are not PCI config accessible. Discover RCH downstream port AER extended capability registers. Use MMIO accesses to search for extended AER capability in RCRB register space. [1] CXL 3.0 Spec, 9.11.2 - System Firmware View of CXL 1.1 Hierarchy [2] CXL 3.0 Spec, 8.2.1.1 - RCH Downstream Port RCRB Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Jonathan Cameron --- drivers/cxl/core/regs.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 7e56ddf509c0..045abc11add8 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -404,6 +404,54 @@ int cxl_setup_regs(struct cxl_register_map *map) } EXPORT_SYMBOL_NS_GPL(cxl_setup_regs, CXL); +static void __iomem *cxl_map_reg(struct device *dev, resource_size_t addr, + resource_size_t length) +{ + struct resource *res; + + if (WARN_ON_ONCE(addr == CXL_RESOURCE_NONE)) + return NULL; + + res = request_mem_region(addr, length, dev_name(dev)); + if (!res) + return NULL; + + return ioremap(addr, length); +} + +static void cxl_unmap_reg(void __iomem *base, resource_size_t addr, + resource_size_t length) +{ + iounmap(base); + release_mem_region(addr, length); +} + +static u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb) +{ + void __iomem *addr; + u16 offset = 0; + u32 cap_hdr; + + addr = cxl_map_reg(dev, rcrb, SZ_4K); + if (!addr) + return 0; + + cap_hdr = readl(addr + offset); + while (PCI_EXT_CAP_ID(cap_hdr) != PCI_EXT_CAP_ID_ERR) { + offset = PCI_EXT_CAP_NEXT(cap_hdr); + if (!offset) + break; + cap_hdr = readl(addr + offset); + } + + if (offset) + dev_dbg(dev, "found AER extended capability (0x%x)\n", offset); + + cxl_unmap_reg(addr, rcrb, SZ_4K); + + return offset; +} + resource_size_t cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, struct cxl_rcrb_info *ri, enum cxl_rcrb which) { @@ -467,6 +515,9 @@ resource_size_t cxl_probe_rcrb(struct device *dev, resource_size_t rcrb, if (!IS_ALIGNED(component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE)) return CXL_RESOURCE_NONE; + if (ri) + ri->aer_cap = cxl_rcrb_to_aer(dev, ri->base); + return component_reg_phys; } EXPORT_SYMBOL_NS_GPL(cxl_probe_rcrb, CXL); From patchwork Tue May 23 23:22:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253124 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 90FBFC77B75 for ; Tue, 23 May 2023 23:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238838AbjEWX2b (ORCPT ); Tue, 23 May 2023 19:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238829AbjEWX22 (ORCPT ); Tue, 23 May 2023 19:28:28 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8DDE5D; Tue, 23 May 2023 16:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GbqyjC5km4NSnergWzOMe8b1Ks2nwll4nUzrGhSyMT4JcA74b13GZcht91N9WVsr4ZsXBO533SqDNMhBmQRnkT3vou21EsUzgkWe6I+Jwgx1mWTdcJjPIerOSX+oNUt3AC86EO0Yl7bjPHvc/MpoaYwGzIA0wKSzRhbXfcBfhLzaQjxvf59xeSArAKRMLMqQB9n3GfNCyX81DFTto9ribiTwb6vy3jvfe4wZ607ggIOj28YNuuTea/4+4C+Jhq08fp8KIeh5iAfpBhJ2xnnQHBZ5aH+od1ttRw0U4+qVuQX29zqw8GutcXXLI1GW/S+Rq/9aZGP0N/CbSwmwz5QoMA== 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=ZzzK9z2IsxftQgvUnj09M15zyKC2/T1SH4s3PelW8vQ=; b=loj5z/mYO6PiPe6aMXq7BQZ4qiuIPtz8rnKyXHdgXuSkNdxVDvAUOVVlUjLb1/pSxQ3a5QbY+djSQQUsjlsL7iGIgUzR9RiOLUa+qkuZ7cOm3L1qXDTw4e4hoCPgNc+39RcyHHs2oOXcQeyGTts8wGd4zmrg1ddhsPWiSGsdOXLtWdfyIMj8GcZb94tVsK5xDF+bMAEeFMKpgzOboDH5AMPIr56WSYIM01tDYoBhDCwiPJVfmLy6t/RsDBwqA0/uRVi9rgkpvC4qbEkFBb01WladCTxoVg3iqj0dl4lqsuzOmWD4mvR2MuSLEx8hIw+16Tp0Zq+1ZE5cTVIy0NSlhw== 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=ZzzK9z2IsxftQgvUnj09M15zyKC2/T1SH4s3PelW8vQ=; b=CMN/GTbzXbny6S9NLBHWuZrB5NCP5E7gW1YvBfi2smibvVBU5dxl/Sl8efCSBUICxyMlj5b6HWSqdI/zCKw+PsMMdYWPPJjg9wEQsdipngNi6dHWzJi9LcbuzYi7x7ZT61W/VFYSGW7ax7rddGIaFGZPH5rAQMFhpehPnI0PkLg= Received: from MW4PR04CA0294.namprd04.prod.outlook.com (2603:10b6:303:89::29) by DM6PR12MB4484.namprd12.prod.outlook.com (2603:10b6:5:28f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29; Tue, 23 May 2023 23:26:19 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::50) by MW4PR04CA0294.outlook.office365.com (2603:10b6:303:89::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:26:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:26:18 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:26:17 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Mahesh J Salgaonkar , Oliver O'Halloran , Subject: [PATCH v4 18/23] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Date: Tue, 23 May 2023 18:22:09 -0500 Message-ID: <20230523232214.55282-19-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT041:EE_|DM6PR12MB4484:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e79a52b-f7fb-44d0-fbbd-08db5be51cba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9XkvoLi3K7Uu2GKoKmmWqEfkTC4snVPFCKEtybYGljckK8oli4lFOWOPmx6FGw/TKIpGViL0iCwxrc1A3ckFBSoDeMVw3FZUvh7383oi/x1n1NQNKyghT1hNE+7CF7T4bxroU2Alc5DdBpAX6479zb/JYpz+FTWYbNfcoKD45eCbtQ6nY5y/r2lQ9vuAzDqa3O7o9Pj1dRt9TImJZtkbBOA6+WtBCkL4or1FsVPsuAqILpfeCut7+SERiGH791pxctAr2R8tyuI/Jp+rRYCtmSTLFrVX3AkxrWQyV3YWprKvN7tn4Z169fOX3r3kT3WUws+Q7JxJ/EWpdG/p/MN5y5bCC3dO0fnmXdOmxOZycfGiDyKZaUiIXman59cSWZZhxrY58zVMad10ZSPX+Q3QX8smHN0MzRF28vyrE8eBj4Z4LelykQqZ9pRq+oJUQVhWMr8B/RgLd2YW1/IyBCQTRsXv3AzE90kKbDogC+QOLe4K7tuvRXChejcUBCt21CoKiFN27Ds+B2iib0yz2VSL0FjBDDEHbCRcnnrh6Ye/DNe2qNKmwKKs0XupXr6oqNurg5XpdAZ/hrvu7VSkXvbQg4mFN0y5HNWvUOJUcCVGrcxaW0iEHadqayPD4sflh6Y7W4iehpJZLCBqEKNfBn8BzWw7kR/K0Qw65xw/6+s8eB08veTGbj472VR8mdfv1nEEN53m2Trb1w3PtVsOgrOuFaNwlH8NREUByh52kHEnDR0cruZq+pat0JkZVh4/u2lXnzwhjKMbeBfk3EPXAS86FA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(110136005)(4326008)(70586007)(70206006)(478600001)(86362001)(54906003)(6666004)(41300700001)(7696005)(316002)(5660300002)(8936002)(8676002)(44832011)(1076003)(26005)(40460700003)(186003)(81166007)(356005)(82740400003)(7416002)(40480700001)(2906002)(16526019)(36756003)(36860700001)(426003)(336012)(83380400001)(2616005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:26:18.9305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e79a52b-f7fb-44d0-fbbd-08db5be51cba X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4484 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The CXL driver plans to use cper_print_aer() for logging restricted CXL host (RCH) AER errors. cper_print_aer() is not currently exported and therefore not usable by the CXL driver built as a loadable module. Export the cper_print_aer() function making it available. The CONFIG_ACPI_APEI_PCIEAER kernel config is currently used to enable cper_print_aer(). cper_print_aer() logs the AER registers and is useful in PCIE AER logging outside of APEI. Remove the CONFIG_ACPI_APEI_PCIEAER dependency to enable cper_print_aer(). The cper_print_aer() function name implies CPER specific use but is useful in non-CPER cases as well. Rename cper_print_aer() to pci_print_aer(). Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Cc: Mahesh J Salgaonkar Cc: "Oliver O'Halloran" Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Reviewed-by: Jonathan Cameron Acked-by: Bjorn Helgaas --- drivers/pci/pcie/aer.c | 9 +++++---- include/linux/aer.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index f6c24ded134c..d3344fcf1f79 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -771,9 +771,10 @@ int cper_severity_to_aer(int cper_severity) } } EXPORT_SYMBOL_GPL(cper_severity_to_aer); +#endif -void cper_print_aer(struct pci_dev *dev, int aer_severity, - struct aer_capability_regs *aer) +void pci_print_aer(struct pci_dev *dev, int aer_severity, + struct aer_capability_regs *aer) { int layer, agent, tlp_header_valid = 0; u32 status, mask; @@ -812,7 +813,7 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity, trace_aer_event(dev_name(&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); } -#endif +EXPORT_SYMBOL_NS_GPL(pci_print_aer, CXL); /** * add_error_device - list device to be handled @@ -1009,7 +1010,7 @@ static void aer_recover_work_func(struct work_struct *work) PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn)); continue; } - cper_print_aer(pdev, entry.severity, entry.regs); + pci_print_aer(pdev, entry.severity, entry.regs); if (entry.severity == AER_NONFATAL) pcie_do_recovery(pdev, pci_channel_io_normal, aer_root_reset); diff --git a/include/linux/aer.h b/include/linux/aer.h index 97f64ba1b34a..8f124b904314 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -64,7 +64,7 @@ static inline void pci_save_aer_state(struct pci_dev *dev) {} static inline void pci_restore_aer_state(struct pci_dev *dev) {} #endif -void cper_print_aer(struct pci_dev *dev, int aer_severity, +void pci_print_aer(struct pci_dev *dev, int aer_severity, struct aer_capability_regs *aer); int cper_severity_to_aer(int cper_severity); void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn, From patchwork Tue May 23 23:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253119 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 46382C7EE26 for ; Tue, 23 May 2023 23:27:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238740AbjEWX1g (ORCPT ); Tue, 23 May 2023 19:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234494AbjEWX1f (ORCPT ); Tue, 23 May 2023 19:27:35 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20622.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::622]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DA05E53; Tue, 23 May 2023 16:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IKKsBEQ0uFgg2nFBiSBqjy/aU+psMhrRd4TNZjSmnUF+NyXZBWK1QPTFChUZG42YDoEuDk3NO8VPaVqGKCnrTDB4QzhbLKHP1bq2o2kFkkReUdhtxNOGGRMl6Dq2NV7FYnkCeVerAVfhGtmlMuxK+K+WeBPc877+W+Fm2wg+h1ghFEyWJfNZaSluL1iswoqw/u2Tv4nxKlyhC/RTVdfTXzorA2wnDW/WvApyBRpDOkmAQAfazSHH8efucWuj5iucxF83LCAo3Y7iF48GM5k/R2lpk3TEQXGZGeDwJq3q/ErHg0vM5nre/i1nasA8cMcUIPimRigGJV8G07BfZl+Xmg== 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=eKMM2M96bjur82uovdQnO9JYdUwZ8brAhS32zYO5mkw=; b=OxPlxzW7iFox2Yv8jp9OI6QcU29ESB67DLcskpG3PHOO7ByRwZnh2H+ZG/0pJcWBBv0m0BgcwWViLxYxwg+OY2wOtubIMb5Ed28i6PDk9S1sJrMcJoppo8ztID2n6BR11GCOMw2m7Q7NP/aj7YmUR6ZecoG3y2plLEoouBB6FEk42woyiOKnSeCH4o9ysq/EVmwJFuu7x9AznQAWRLOOPC0xHN4L7Cjogj22/j0p6puVNJ67vZ1blXKYcT0uNyGO+HwE6RVmlKw1bqiIoyey+KG6Egkjts3abQfE/QNeqXql63nzqldupWOEfxsdtVzJkCO+q0bi2k6T2leO+hrWUQ== 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=eKMM2M96bjur82uovdQnO9JYdUwZ8brAhS32zYO5mkw=; b=fLKqPP23uFZEhhb/PRw2FEA6HNAD6uveyDl+prhdsdsvJH84ssKh7aZVJvRUUslyUVJcT7i7KJ3CazOLg82kR1y06N6wYXGf/oF1O0lsivEXXN5SNSMyCmwGg6bGhPx7rGM8K2qqiPw6gDuImt7gdxeVd/inpDVWwt5hWe5ueNk= Received: from MW4PR03CA0245.namprd03.prod.outlook.com (2603:10b6:303:b4::10) by SN7PR12MB6671.namprd12.prod.outlook.com (2603:10b6:806:26d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Tue, 23 May 2023 23:26:29 +0000 Received: from CO1NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::ec) by MW4PR03CA0245.outlook.office365.com (2603:10b6:303:b4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:26:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT082.mail.protection.outlook.com (10.13.175.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:26:29 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:26:28 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 19/23] cxl/pci: Update CXL error logging to use RAS register address Date: Tue, 23 May 2023 18:22:10 -0500 Message-ID: <20230523232214.55282-20-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT082:EE_|SN7PR12MB6671:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f98c121-765d-40a4-9bf5-08db5be5231a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BTGydbdNqmjodR4t4jEbSvUzQc3ZJEKmbdHxhtUe36N0n0+2Glct3GkgAJjj/hU3hXGLUunLZiPsS763pT0PTc/Mx57W9fi7tpxzRohXrdu7ma+1OBbg2oTysSUOIdxZGarb5BS2VfGz6/kikS/hRMU91skp3OhcYKEXUwF13c3YqOYmvCqMmK9EULEYh8pQ16pCZWHw0XURNWYcU5FpUTPCfnCKrrNJqMmBEhByN6FqEVIBqOmg03Cw8ML9Snf8I2Q4kavIfTCR4Vy9s3918RvLnCwkjPNiLc++350n+ZLNG/JqJZ/Likl/8X+qYE0Za4CG6S+m1aiDprUe4rBsj3yU4k316if0Anuc/Mjtx2rGW9JzeqSMxNgzM3XiF0aXZusfICMWF/us5vCvkp5GxCC9bju3Qh2wtYsjb8kiFji5oejM/WW6CB4qQxr6y3T6SXgYr3KYUXjR9qtveuUKpZxIimE3+Bd5BCgmth+UfqKjTOgUU4wWWa5UjQQFTCk7JqtvkjVbp9LVA4CzQu9lWpCvQm7BgC99wK+/lmWEIuA5r3gJbrCNTscEXEf5OTfsZqkt+uXqSaKjdvsJ6QgOPiH3rKCPfVcJTC1+dUrB+CjB2hWm49ZCVxOuHtkeexXSwNkVYrk46cFd0BDFyl+MFQxUCQ41gR6Jw6/hpxdPTUY+zlQYxSXrX90hrs33QwLe2brJ7kPC+3sYSLAR6l398RFuzPLK1Bgz5kWsLS8Vtp7tnzc4XvIuu3hkdCL064xvazjTVInQV3Ui93+tfQEnHg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(82740400003)(40460700003)(16526019)(81166007)(26005)(356005)(1076003)(186003)(7416002)(44832011)(15650500001)(2616005)(36860700001)(47076005)(36756003)(83380400001)(426003)(2906002)(336012)(40480700001)(41300700001)(7696005)(316002)(110136005)(6666004)(54906003)(82310400005)(478600001)(70586007)(70206006)(4326008)(86362001)(8936002)(8676002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:26:29.6235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f98c121-765d-40a4-9bf5-08db5be5231a 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: CO1NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6671 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The CXL error handler currently only logs endpoint RAS status. The CXL topology includes several components providing RAS details to be logged during error handling.[1] Update the current handler's RAS logging to use a RAS register address. This will allow for adding support to log other CXL component's RAS details in the future. [1] CXL3.0 Table 8-22 CXL_Capability_ID Assignment Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/pci.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 67f4ab6daa34..def6ee5ab4f5 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -665,32 +665,36 @@ void read_cdat_data(struct cxl_port *port) } EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL); -void cxl_cor_error_detected(struct pci_dev *pdev) +static void __cxl_log_correctable_ras(struct cxl_dev_state *cxlds, + void __iomem *ras_base) { - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); void __iomem *addr; u32 status; - if (!cxlds->regs.ras) + if (!ras_base) return; - addr = cxlds->regs.ras + CXL_RAS_CORRECTABLE_STATUS_OFFSET; + addr = ras_base + CXL_RAS_CORRECTABLE_STATUS_OFFSET; status = readl(addr); if (status & CXL_RAS_CORRECTABLE_STATUS_MASK) { writel(status & CXL_RAS_CORRECTABLE_STATUS_MASK, addr); trace_cxl_aer_correctable_error(cxlds->cxlmd, status); } } -EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); + +static void cxl_log_correctable_ras_endpoint(struct cxl_dev_state *cxlds) +{ + return __cxl_log_correctable_ras(cxlds, cxlds->regs.ras); +} /* CXL spec rev3.0 8.2.4.16.1 */ -static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log) +static void header_log_copy(void __iomem *ras_base, u32 *log) { void __iomem *addr; u32 *log_addr; int i, log_u32_size = CXL_HEADERLOG_SIZE / sizeof(u32); - addr = cxlds->regs.ras + CXL_RAS_HEADER_LOG_OFFSET; + addr = ras_base + CXL_RAS_HEADER_LOG_OFFSET; log_addr = log; for (i = 0; i < log_u32_size; i++) { @@ -704,17 +708,18 @@ static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log) * Log the state of the RAS status registers and prepare them to log the * next error status. Return 1 if reset needed. */ -static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) +static bool __cxl_report_and_clear(struct cxl_dev_state *cxlds, + void __iomem *ras_base) { u32 hl[CXL_HEADERLOG_SIZE_U32]; void __iomem *addr; u32 status; u32 fe; - if (!cxlds->regs.ras) + if (!ras_base) return false; - addr = cxlds->regs.ras + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET; + addr = ras_base + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET; status = readl(addr); if (!(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK)) return false; @@ -722,7 +727,7 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) /* If multiple errors, log header points to first error from ctrl reg */ if (hweight32(status) > 1) { void __iomem *rcc_addr = - cxlds->regs.ras + CXL_RAS_CAP_CONTROL_OFFSET; + ras_base + CXL_RAS_CAP_CONTROL_OFFSET; fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK, readl(rcc_addr))); @@ -730,13 +735,26 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) fe = status; } - header_log_copy(cxlds, hl); + header_log_copy(ras_base, hl); trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe, hl); writel(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK, addr); return true; } +static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) +{ + return __cxl_report_and_clear(cxlds, cxlds->regs.ras); +} + +void cxl_cor_error_detected(struct pci_dev *pdev) +{ + struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); + + cxl_log_correctable_ras_endpoint(cxlds); +} +EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); + pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { From patchwork Tue May 23 23:22:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253121 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 E7DD3C7EE26 for ; Tue, 23 May 2023 23:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238811AbjEWX1w (ORCPT ); Tue, 23 May 2023 19:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238808AbjEWX1v (ORCPT ); Tue, 23 May 2023 19:27:51 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::61c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B76BE4C; Tue, 23 May 2023 16:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mud3zGYNeCwoauo5OEi99cnYP9p0TE9JGaNGQ2jGMJ0oH4vuhEZQFwOymYHOanJC+EXWUhNcuJkqBAa1lTdh1RNw2LoczDOH4tbj3Zd8fw6bxyhifMD0cGEI+RS08AppIDb/mG7IHGCix2xPsTRMChmVQ6gn1/agWBDD4iZiy0LLizQywp+BJzTkpiZVoHQ9jYsYhQu5X7s+0gcWMxixAQ5k4fjcEIY16NoIVvkVIkN7SEKe9rB1B0yi4UNrmpLJ1K7dM5h1TZt9Jf560EUxjWnMlkbNSyK2u11mOyUVuBTPsAkWxGUAMA4cSravCjir2Z6BLhjvn1I0QMihysMaOw== 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=nAqq3iXHd2I7qAZR/a5UvjK88TLWG22R0HI+vDe8HSU=; b=IN7wHDbALa+zXruPCWzUt8Z43loFeEhUN1SiIkYgf4c+aHEpjVMHh+KMqD3AxE4gbkiIdOwW4mUKT9DXfzzYAGoOpe9NtJ+Yn5SHkOWCA3/gspG8L8D/Gl93RCeLwUT9xDDXV6K7ny9GTEN6kW4qi8OV5yhGKxnSNKCi/ZnM2qR+uhv0AFS/3if+fybaOKKu6EGSf+ihkGeSy9z3I9RnVA8RlgMvmme0Ts62K+IQTUQMft8DlVSpPUshwnxtEeGmQOXHzKybkXFit1s9brVvG26X+EQuUndzQyAqesbvoVLbZgWIFWT6ezdRNvzKmWzWu4btgh2yEsPKhJAXgZ/o+g== 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=nAqq3iXHd2I7qAZR/a5UvjK88TLWG22R0HI+vDe8HSU=; b=Hg7xwdnaIPyosgruoQnxeWyXcJvYEVeYaCGxtUd1sGFQgrS5cbgcDo0oOV4fZky52OmUisUVilCibzbdbA5nqh3tclmDbLM/s7Se5AcFgHjLyoGTajwn+vOnuP8W2mZx0eiZqWU7ERBQAbMDrnCPoP+5xesK9pnCGHhP2fO39xQ= Received: from MW4PR03CA0047.namprd03.prod.outlook.com (2603:10b6:303:8e::22) by BL1PR12MB5045.namprd12.prod.outlook.com (2603:10b6:208:310::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14; Tue, 23 May 2023 23:26:41 +0000 Received: from CO1NAM11FT071.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::a4) by MW4PR03CA0047.outlook.office365.com (2603:10b6:303:8e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:26:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT071.mail.protection.outlook.com (10.13.175.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:26:40 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:26:39 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 20/23] cxl/pci: Prepare for logging RCH downstream port protocol errors Date: Tue, 23 May 2023 18:22:11 -0500 Message-ID: <20230523232214.55282-21-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT071:EE_|BL1PR12MB5045:EE_ X-MS-Office365-Filtering-Correlation-Id: 782adad0-6b3c-41cb-bce1-08db5be529c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G5PkcTSKK7mB3vqLqZ0mZ6ey+RQ47ooSaBTKvN8MVqw87AwiZ1NE7tU9DkVEgs4xHnst9fs1VusdhASyuX54tTU8X/a0AyoBOa0g2T1i1aENytyqBA8fKsBmuZ/LRrMiT8x30pN0IgFPJJqZ2VKCZWdqMvDwFOJ6UuGTFtFFxMhRkKK1gL8v0jSbQMcTkjJZ1VqvkiZIuZn7+lS3sSO0W4Wgu85vVVrvpW7Tck5lc6fI2CXwopUvlU51mM1IjbLXputLIBj3niXS9VJLsQQXlpaa2R76dldQ0/t9QzmDxJsQEJ6Cs5qi7XzSS5eW3hNj57MQq0ENiy8cbiOStCIGWsUoi31yjkdEmFoUcmuJZjSDwusVcmgYXn/UtQM21cHOSlRN0936uWw+sWxAbxTFIDieKkKdShHGv8URrSLU/GSVjAaERaaOduIbF1QLQvlbpKrKdNw1ywJaXz7vmlC8JkYDswB5N4jMfv3l1Q/KYMewAb0zkJkSSFQi5IX1j5ymMab07AEEmBUN8K5HXkngVYqh2wSXzKAKHVJlqWDW9lleWZUjQeXcyzzQAT0Xk8ZGp849BtPdvJ6LknEgcfGnReNMxb4lO8LehZwzxIEiI/kUf9/zEv78b+pmW7VKoJ2tgvwtxt9EdBnbBFhi6h4KdzJ9UOs7Vn2zAvA0xvNkfRWdy7JhwoNhm1cGEiOL7FhOMVjHhUIy9lBVrB/3w62vLaoM4J7RE+GNaaf28nHWyrwIC3RBUtlMA9rioANl6+Z63r+6LE+SI74CWIdBlkp4tA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(39860400002)(376002)(136003)(451199021)(36840700001)(40470700004)(46966006)(2906002)(44832011)(7416002)(5660300002)(82310400005)(8936002)(8676002)(83380400001)(40460700003)(41300700001)(36756003)(4326008)(54906003)(110136005)(316002)(70206006)(7696005)(70586007)(478600001)(40480700001)(6666004)(426003)(336012)(2616005)(26005)(81166007)(356005)(1076003)(82740400003)(86362001)(36860700001)(47076005)(186003)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:26:40.8376 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 782adad0-6b3c-41cb-bce1-08db5be529c9 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: CO1NAM11FT071.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5045 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The restricted CXL host (RCH) error handler will log protocol errors using AER and RAS status registers. The AER and RAS registers need to be virtually memory mapped before enabling interrupts. Update __devm_cxl_add_dport() to include RCH RAS and AER mapping. Add 'struct cxl_regs' to 'struct cxl_dport' for saving a unique copy of the RCH downstream port's mapped registers. The RCH contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupt generation. [1] CXL3.0 - 12.2.1.1 RCH Downstream Port-detected Errors Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman --- drivers/cxl/core/port.c | 64 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/regs.c | 1 + drivers/cxl/cxl.h | 11 +++++++ 3 files changed, 76 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index d147f08780d0..80c643254b86 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -940,6 +941,63 @@ static void cxl_dport_unlink(void *data) sysfs_remove_link(&port->dev.kobj, link_name); } +static void cxl_disable_rch_root_ints(struct cxl_dport *dport) +{ + void __iomem *aer_base = dport->regs.dport_aer; + u32 aer_cmd_mask, aer_cmd; + + if (!dport->rch || !aer_base) + return; + + /* + * Disable RCH root port command interrupts. + * CXL3.0 12.2.1.1 - RCH Downstream Port-detected Errors + * + * This sequnce may not be necessary. CXL spec states disabling + * the root cmd register's interrupts is required. But, PCI spec + * shows these are disabled by default on reset. + */ + aer_cmd_mask = (PCI_ERR_ROOT_CMD_COR_EN | + PCI_ERR_ROOT_CMD_NONFATAL_EN | + PCI_ERR_ROOT_CMD_FATAL_EN); + aer_cmd = readl(aer_base + PCI_ERR_ROOT_COMMAND); + aer_cmd &= ~aer_cmd_mask; + writel(aer_cmd, aer_base + PCI_ERR_ROOT_COMMAND); +} + +static int cxl_dport_map_rch_aer(struct cxl_dport *dport) +{ + struct cxl_rcrb_info *ri = &dport->rcrb; + resource_size_t aer_phys; + void __iomem *dport_aer; + + if (!dport->rch || !ri->aer_cap) + return -ENODEV; + + aer_phys = ri->aer_cap + ri->base; + dport_aer = devm_cxl_iomap_block(dport->dev, aer_phys, + sizeof(struct aer_capability_regs)); + if (!dport_aer) + return -ENOMEM; + + dport->regs.dport_aer = dport_aer; + + return 0; +} + +static int cxl_dport_map_regs(struct cxl_dport *dport) +{ + struct cxl_register_map *map = &dport->comp_map; + + if (!map->component_map.ras.valid) + dev_dbg(map->dev, "RAS registers not found\n"); + else if (cxl_map_component_regs(map, &dport->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS))) + dev_dbg(dport->dev, "Failed to map RAS capability.\n"); + + return cxl_dport_map_rch_aer(dport); +} + 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, @@ -994,6 +1052,12 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, if (rc && rc != -ENODEV) return ERR_PTR(rc); + rc = cxl_dport_map_regs(dport); + if (rc && rc != -ENODEV) + return ERR_PTR(rc); + + cxl_disable_rch_root_ints(dport); + cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 045abc11add8..b34f9e04cae4 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -198,6 +198,7 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, return ret_val; } +EXPORT_SYMBOL_NS_GPL(devm_cxl_iomap_block, CXL); int cxl_map_component_regs(struct cxl_register_map *map, struct cxl_component_regs *regs, diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 6134644b51f8..0e0bcbefefaf 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -209,6 +209,13 @@ struct cxl_regs { struct_group_tagged(cxl_device_regs, device_regs, void __iomem *status, *mbox, *memdev; ); + /* + * RCH downstream port specific RAS register + * @aer: CXL 3.0 8.2.1.1 RCH Downstream Port RCRB + */ + struct_group_tagged(cxl_rch_regs, rch_regs, + void __iomem *dport_aer; + ); }; struct cxl_reg_map { @@ -255,6 +262,8 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map); void cxl_probe_device_regs(struct device *dev, void __iomem *base, struct cxl_device_reg_map *map); +void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, + resource_size_t length); int cxl_map_component_regs(struct cxl_register_map *map, struct cxl_component_regs *regs, unsigned long map_mask); @@ -603,6 +612,7 @@ struct cxl_rcrb_info { * @port_id: unique hardware identifier for dport in decoder target list * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @rcrb: Data about the Root Complex Register Block layout + * @regs: Dport parsed register blocks */ struct cxl_dport { struct device *dev; @@ -611,6 +621,7 @@ struct cxl_dport { int port_id; bool rch; struct cxl_rcrb_info rcrb; + struct cxl_regs regs; }; /** From patchwork Tue May 23 23:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253125 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 E79C0C77B75 for ; Tue, 23 May 2023 23:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238852AbjEWX2k (ORCPT ); Tue, 23 May 2023 19:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238846AbjEWX2f (ORCPT ); Tue, 23 May 2023 19:28:35 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2089.outbound.protection.outlook.com [40.107.95.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2437BE5F; Tue, 23 May 2023 16:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DoKsM2X5eqeNKEpyPA76l7Pmvars9LbIBbNmIaLV1vCWAOxMDYs8bYibEO8W+YeJ+x3EqxX5kEoN73uNN2FrJ8HRXYAxNQzFc73V/Evp75hm5YxFcKBT1h3tdNl0oZcYWjTbzgwuhWkrORdMg7U2BRx/kod6ZF8cZaWgXEmJJGHGXiWA6jDLrodCfAdx2g+L2FiD2KjcL8p3lanJN9hQH0FG4Ogi8kj/DVKxx3rGatAPdT41Gq62iXEpI9Aa6wyUCyXR6K5pJCIxRPW+DhSwYJzIeVX78GNlUFggZ+j06E/tX0M3kF355WXhKq+tqjDqcMkqpAkgTNzMl4hsXPnmOw== 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=ru4BkiU5cPsAD4arfiZPyON6tBIvUzVPdxT2kisKG/s=; b=LJ4uj4WViBibNsBBskKoLC5pg7yIcbI4B3XwQPv1Z8QuJWNolA+VenSKYW/tH+s3I/t/1fQQOiuvNvUi0biRyHTU+zbS6oX/BSBnZlujvf/Wu0kQOS59woa8aWz+z2T1BE5QE8wYskfD5lWHQkVqeDuuyW9Eznmz3pjuYE0QpEY+p2tqre6Z8/UbSqduoP6/RzyXDdQJIxQXO65735qxp3V0YW1oKDNhuk04i4MfQ3mV6qOXDLMEGyuAFZrDY+w83CpJ1XbBVNd5fWFG8Yt/K9aYuf820v48ZERZCrIgsHBEmpGtZXfv1YmRBvgds7PLvUNQYgI3pTFO/k8EJEV6Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=temperror 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=ru4BkiU5cPsAD4arfiZPyON6tBIvUzVPdxT2kisKG/s=; b=X7e57O4yvN1ZQPkzJaqtP0dvAwpIbyH0ZZ7sE70R8TyKmALZfN75VRfyJbfYIae4rqIYvlexMW0cKqeyfVk4A9l+r/EW4p7bjTsEwq6yv+FmEjf30471EB5qUKVii/4PWvDTl8ZQcZVWxHUFmkvbfZ6vUHBtM3/9cqwRoynp54Q= Received: from MW3PR06CA0022.namprd06.prod.outlook.com (2603:10b6:303:2a::27) by SA1PR12MB6994.namprd12.prod.outlook.com (2603:10b6:806:24d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.27; Tue, 23 May 2023 23:26:53 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::d4) by MW3PR06CA0022.outlook.office365.com (2603:10b6:303:2a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 23:26:53 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:26:51 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:26:50 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 21/23] cxl/pci: Add RCH downstream port error logging Date: Tue, 23 May 2023 18:22:12 -0500 Message-ID: <20230523232214.55282-22-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT038:EE_|SA1PR12MB6994:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f7d45fb-55e9-452d-6c98-08db5be53052 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvTSsD+kTxcZGtDMGjHsND7snPqmr6YiAUNttivJVKwsF2woUIm6Vy77N4yY16rsm2Weoe5j+rQCnC3GpZmT5FiHc1I8Rvkl5hWY4qL1gPMvHblM+vJ1Oxtf0xz2hKuWbqAN0zm46+3jOj549rGAVMLrVId48WOmxzCTkGTf69lOTLW4AzOEY0IWzP06ho2TeMbNVc6mQYEyiH28r9ba4I/U7lGkDO5nU3imlxsLyv54dacC7EdVcIIgwPf3PfGiIt3x6EPiREAKMoWxnTgl5nur7yg7InnTlUC+oUgMn5r07edXptfHAaLzWCEIgx3Yk7EMcfEsapxxzN8MjCipF3m77IvI+WMmBYEpUYl6YU3i//wVO8IMu33+A9zVSbnAzHDpogXTPChBoPSq4Rc4pauz8oCT6vpdeAOgHoVNFi4sCRBdMnDNzyhuN8FMsAAp1ZJE4aTbBF+G7GyVuLPViclLHyRhwWqM8MhHzUwkUPHMmI9emkpGioFtFxGt0xlg6VhtQ9e38Irc5a46ZUAqCGWiqPQYtitDdO0SMIGsUodFr+GXjvmGiLt3Ya8L6ixLg5QnpkoJ6y2A104gzDddl/P7CQejGGeoyeuXYzDMLNFKbOXlGk7z1KdrCZPx0abM/mtmdhBkRuY1GGv09/S2lQjx2+QxjNlRiR0z3RRHhJpzvwCWFCFBdvcUfSGbJ25ltzQGjGJ+8XQmM78yBrWZcGO4HwVWjrLyKQ3TZhUfLzejI56bhwYODARyIH2N6r7MMAeviNDc1DetMqxEmnJ5+g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199021)(36840700001)(40470700004)(46966006)(5660300002)(8936002)(8676002)(40460700003)(86362001)(2906002)(1076003)(26005)(426003)(47076005)(36756003)(83380400001)(63350400001)(2616005)(63370400001)(336012)(16526019)(36860700001)(186003)(40480700001)(7416002)(44832011)(4326008)(70586007)(356005)(82740400003)(81166007)(70206006)(316002)(110136005)(54906003)(478600001)(7696005)(41300700001)(6666004)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:26:51.7997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f7d45fb-55e9-452d-6c98-08db5be53052 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: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6994 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org RCH downstream port error logging is missing in the current CXL driver. The missing AER and RAS error logging is needed for communicating driver error details to userspace. Update the driver to include PCIe AER and CXL RAS error logging. Add RCH downstream port error handling into the existing RCiEP handler. The downstream port error handler is added to the RCiEP error handler because the downstream port is implemented in a RCRB, is not PCI enumerable, and as a result is not directly accessible to the PCI AER root port driver. The AER root port driver calls the RCiEP handler for handling RCD errors and RCH downstream port protocol errors. Update existing RCiEP correctable and uncorrectable handlers to also call the RCH handler. The RCH handler will read the RCH AER registers, check for error severity, and if an error exists will log using an existing kernel AER trace routine. The RCH handler will also log downstream port RAS errors if they exist. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/pci.c | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index def6ee5ab4f5..97886aacc64a 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -747,10 +748,105 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) return __cxl_report_and_clear(cxlds, cxlds->regs.ras); } +#ifdef CONFIG_PCIEAER_CXL + +static void cxl_log_correctable_ras_dport(struct cxl_dev_state *cxlds, + struct cxl_dport *dport) +{ + return __cxl_log_correctable_ras(cxlds, dport->regs.ras); +} + +static bool cxl_report_and_clear_dport(struct cxl_dev_state *cxlds, + struct cxl_dport *dport) +{ + return __cxl_report_and_clear(cxlds, dport->regs.ras); +} + +/* + * Copy the AER capability registers using 32 bit read accesses. + * This is necessary because RCRB AER capability is MMIO mapped. Clear the + * status after copying. + * + * @aer_base: base address of AER capability block in RCRB + * @aer_regs: destination for copying AER capability + */ +static bool cxl_rch_get_aer_info(void __iomem *aer_base, + struct aer_capability_regs *aer_regs) +{ + int read_cnt = sizeof(struct aer_capability_regs) / sizeof(u32); + u32 *aer_regs_buf = (u32 *)aer_regs; + int n; + + if (!aer_base) + return false; + + /* Use readl() to guarantee 32-bit accesses */ + for (n = 0; n < read_cnt; n++) + aer_regs_buf[n] = readl(aer_base + n * sizeof(u32)); + + writel(aer_regs->uncor_status, aer_base + PCI_ERR_UNCOR_STATUS); + writel(aer_regs->cor_status, aer_base + PCI_ERR_COR_STATUS); + + return true; +} + +/* Get AER severity. Return false if there is no error. */ +static bool cxl_rch_get_aer_severity(struct aer_capability_regs *aer_regs, + int *severity) +{ + if (aer_regs->uncor_status & ~aer_regs->uncor_mask) { + if (aer_regs->uncor_status & PCI_ERR_ROOT_FATAL_RCV) + *severity = AER_FATAL; + else + *severity = AER_NONFATAL; + return true; + } + + if (aer_regs->cor_status & ~aer_regs->cor_mask) { + *severity = AER_CORRECTABLE; + return true; + } + + return false; +} + +static void cxl_handle_rch_dport_errors(struct cxl_dev_state *cxlds) +{ + struct pci_dev *pdev = to_pci_dev(cxlds->dev); + struct aer_capability_regs aer_regs; + struct cxl_dport *dport; + int severity; + + if (!cxlds->rcd) + return; + + if (!cxl_pci_find_port(pdev, &dport) || !dport->rch) + return; + + if (!cxl_rch_get_aer_info(dport->regs.dport_aer, &aer_regs)) + return; + + if (!cxl_rch_get_aer_severity(&aer_regs, &severity)) + return; + + pci_print_aer(pdev, severity, &aer_regs); + + if (severity == AER_CORRECTABLE) + cxl_log_correctable_ras_dport(cxlds, dport); + else + cxl_report_and_clear_dport(cxlds, dport); +} + +#else +static void cxl_handle_rch_dport_errors(struct cxl_dev_state *cxlds) { } +#endif + void cxl_cor_error_detected(struct pci_dev *pdev) { struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); + cxl_handle_rch_dport_errors(cxlds); + cxl_log_correctable_ras_endpoint(cxlds); } EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); @@ -763,6 +859,8 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, struct device *dev = &cxlmd->dev; bool ue; + cxl_handle_rch_dport_errors(cxlds); + /* * A frozen channel indicates an impending reset which is fatal to * CXL.mem operation, and will likely crash the system. On the off From patchwork Tue May 23 23:22:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253126 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 E3261C7EE26 for ; Tue, 23 May 2023 23:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238855AbjEWX2q (ORCPT ); Tue, 23 May 2023 19:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjEWX2m (ORCPT ); Tue, 23 May 2023 19:28:42 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 948011AC; Tue, 23 May 2023 16:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NdOUD/Rsjhjmj/RTos1JPl/blYc7dY0HnBE9AdpabscgF2AynEgRrQp9dv1B6smcqnNPkDfCzgqb2kr9F0mKmZAR8agE7+sBG9qtPuq4N1xraX0BsJGm8YJ20DZEEGHEJx9LAivxGDCdpSzVPExTjwsvgQgIWgOAMFkIyIZsSMhFPNK3i77OT02/roffR86rTjkv2se9bkZdTlAKPEh/yNihPThlmj8sevWMM7eox7rcDaBKouSup9clxhwLu79nSwzIEqHoeC2CfjH824eCPF5ofC3YaCvpis0FRaXYCG2mFVgadNK5aYFcWJx53Fiw/XJAkagVZrz8MwktEZ3J1g== 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=lxbkcOVfHB2LztSBZUUwpyQrS2VM9I0+YxE7oslWjy0=; b=fPCXUbhfqrDp51EaswNhe5K+xocbm/kd+vz9uSPS+bb7dC7huCjNyevujrTlpCj56A0O/erncf72HKZXOEoSBVqXNJ0HkW1Hr8fdbJUdBeXXkIS5kBRgdxobbpIZhbugOdrIkwgHKcHnJC7CTZSpvEaMsk5tjfm59dzJHUdbCM4MiMKvnW26PjDNFuc29Lg5nvMEmqsylsT42v5HeyZ9lWA+JgQbsnpn6QDZopIbTqXI5uOCo5N7s8uT0DY0pOCgA9cOzPTfvL4ZqSJIvYxPUfjHbpJIFxjIvmIdneDziBU4PYngGZXsE1KDbBxAXhyJYY6qVT8bvyNABbKA98Om6Q== 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=lxbkcOVfHB2LztSBZUUwpyQrS2VM9I0+YxE7oslWjy0=; b=OKQpCeMgNxhsXHoLXho8CHVCx0M1AS+Q5ROQHhtw8sYcBrdO0ccQw7+G+hn9XoZLa6E6XLLu3Ha8TiJCFbep2M3f5eSMmDhtsPUOkRg/3/7PX6q12dVfLjuCmroSvqWZaiMZYz02E54IrCVwgmC7SdOnoWfT3Qba8LJ4Dmyz4PA= Received: from MW2PR16CA0024.namprd16.prod.outlook.com (2603:10b6:907::37) by SJ2PR12MB8925.namprd12.prod.outlook.com (2603:10b6:a03:542::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 23:27:03 +0000 Received: from CO1NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::b3) by MW2PR16CA0024.outlook.office365.com (2603:10b6:907::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:27: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 CO1NAM11FT092.mail.protection.outlook.com (10.13.175.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 23:27:02 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:27:01 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Oliver O'Halloran , , Subject: [PATCH v4 22/23] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Date: Tue, 23 May 2023 18:22:13 -0500 Message-ID: <20230523232214.55282-23-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT092:EE_|SJ2PR12MB8925:EE_ X-MS-Office365-Filtering-Correlation-Id: c759278c-070e-45db-3222-08db5be536d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QlWryOlJuCe/PQwmpwJqhqVUjUgCiAFbeioG2iG0JXunjy4yDosz48MrRp5cENcZjgeVXRPvdGenh0Z0SqNeUR1z+8Pi3EFrnLrjQ19e4k12b7b1Y6oh5tfCkHt9FhVrQTt7VGbE1njkhwTLls99cYD0BWVVtl+TgrI6xKTzCmMWrIjE5VEa4AgFYwYeJo8zr4sZoo86hIedFzkeWE/IM/p6RBJLBNRNlOTsw6y2RPsjWyv2ybbAcJ+6q+r1Yxrv75omZP7yRIQDVtF4CPKpxQBe/Sd2gumNnONykbbk5AHItUmQAF4a4Q/8cnFBCLMBATlCLgf5ATMNz9aJf0HqoEO+wNvOUEPEaFCx4vkqfRsrl3IjWkfHYZ6hZnXXGmMycxhjkw67KJ0jSk1ie05p7g9BVzMbOMnMaRuER7ZBTBocFLh19fTWxz/9e1IkUq/DtKUmX7fZeGWNCiISm6bAWU3PTrE+nijdM8U4tPD/tFfnDe0kuyL25Rk4u+u0O4eJtdfccG8fVC9OhQrAtRu8T7lBaHyaVt8AFOvg4w2juaOD6uzaQ+t+D54QGLTfYulFxCKaUV0m/A5peztzk4n1l3BvBSYp2l2ZnuXmnL6cnajJX0xxoVUfhHWNA+O1c76g/99mwz65x8EfYmlVUJQPqVx3jVkj438jnyfRJuKxpt0jinjbVX9Ru5Nqu6eIAyOuw8/mMlOq3pvvJ5Q35nDioQV+tpyGzQRxoZHyTbjYy9mCiutEWM0//9KjEceeLIQrp60Tp0A4iB6ZP+USxwF2Ug== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199021)(40470700004)(46966006)(36840700001)(7696005)(41300700001)(40460700003)(36860700001)(6666004)(8936002)(81166007)(8676002)(186003)(16526019)(356005)(26005)(5660300002)(1076003)(44832011)(7416002)(36756003)(82740400003)(40480700001)(2906002)(966005)(2616005)(86362001)(82310400005)(70586007)(70206006)(426003)(54906003)(47076005)(110136005)(336012)(478600001)(316002)(83380400001)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:27:02.7362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c759278c-070e-45db-3222-08db5be536d7 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: CO1NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8925 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. Protocol and link errors are sent to an RCEC. Restricted CXL host (RCH) downstream port-detected errors are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE). The error source is the id of the RCEC. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [1] Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [2]. The error handling is limited to currently supported devices with the Memory Device class code set (PCI_CLASS_MEMORY_CXL, 502h), where the handler can be implemented in the existing cxl_pci driver. Support of CXL devices (e.g. a CXL.cache device) can be enabled later. In addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port that is connected to the device. Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch. The reason for choosing this implementation is that a CXL RCEC device is bound to the AER port driver, but the driver does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler. [1] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors [2] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Cc: "Oliver O'Halloran" Cc: Bjorn Helgaas Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-pci@vger.kernel.org Acked-by: Bjorn Helgaas Reviewed-by: Jonathan Cameron --- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 100 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 228652a59f27..4f0e70fafe2d 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)" + default y + depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC # diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index d3344fcf1f79..2e3f00b6a5bd 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -946,14 +946,104 @@ static bool find_source_device(struct pci_dev *parent, return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev(struct pci_dev *dev) +{ + /* + * The capability, status, and control fields in Device 0, + * Function 0 DVSEC control the CXL functionality of the + * entire device (CXL 3.0, 8.1.3). + */ + if (dev->devfn != PCI_DEVFN(0, 0)) + return false; + + /* + * CXL Memory Devices must have the 502h class code set (CXL + * 3.0, 8.1.12.1). + */ + if ((dev->class >> 8) != PCI_CLASS_MEMORY_CXL) + return false; + + return true; +} + +static bool cxl_error_is_native(struct pci_dev *dev) +{ + struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); + + if (pcie_ports_native) + return true; + + return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error(struct aer_err_info *info) +{ + if (info->severity == AER_CORRECTABLE) + return info->status & PCI_ERR_COR_INTERNAL; + + return info->status & PCI_ERR_UNC_INTN; +} + +static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data) +{ + struct aer_err_info *info = (struct aer_err_info *)data; + const struct pci_error_handlers *err_handler; + + if (!is_cxl_mem_dev(dev) || !cxl_error_is_native(dev)) + return 0; + + /* protect dev->driver */ + device_lock(&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler : NULL; + if (!err_handler) + goto out; + + if (info->severity == AER_CORRECTABLE) { + if (err_handler->cor_error_detected) + err_handler->cor_error_detected(dev); + } else if (err_handler->error_detected) { + if (info->severity == AER_NONFATAL) + err_handler->error_detected(dev, pci_channel_io_normal); + else if (info->severity == AER_FATAL) + err_handler->error_detected(dev, pci_channel_io_frozen); + } +out: + device_unlock(&dev->dev); + return 0; +} + +static void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) +{ + /* + * CXL downstream ports of a CXL host that is operating in RCD + * mode (RCH) signal errors as RCEC internal errors. Forward + * them to all CXL devices below the RCEC. + * + * See CXL 3.0: + * 9.11.8 CXL Devices Attached to an RCH + * 12.2.1.1 RCH Downstream Port-detected Errors + */ + if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC && + is_internal_error(info)) + pcie_walk_rcec(dev, cxl_rch_handle_error_iter, info); +} + +#else +static inline void cxl_rch_handle_error(struct pci_dev *dev, + struct aer_err_info *info) { } +#endif + /** - * handle_error_source - handle logging error into an event log + * pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device * @info: comprehensive error information * * Invoked when an error being detected by Root Port. */ -static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) +static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) { int aer = dev->aer_cap; @@ -977,6 +1067,12 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset); else if (info->severity == AER_FATAL) pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset); +} + +static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) +{ + cxl_rch_handle_error(dev, info); + pci_aer_handle_error(dev, info); pci_dev_put(dev); } From patchwork Tue May 23 23:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13253127 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 4AC58C7EE26 for ; Tue, 23 May 2023 23:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238858AbjEWX2y (ORCPT ); Tue, 23 May 2023 19:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238868AbjEWX2u (ORCPT ); Tue, 23 May 2023 19:28:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2087.outbound.protection.outlook.com [40.107.92.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3878F10CE; Tue, 23 May 2023 16:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gunv5cjmhuGr6U/iUnAzsQBfkPJ78XMFI+UgGT0V/WALLDtKhOzjXA0nR5JzHs2QhsLsJs0sY7BYz5ULoaTlUsc1MDQkqvQ4Bs45bKpGjcMORYNbkUKpSn8q4fm/n3kW6JuoNursLU8eAkX+/pNAG2Gin6H4UxyssMv2QlAoqshFlniqnIswiP1TKBhgOsfKDBw6d4xFKOKAfHFb6dgigHoyUVuzIoOosq5l4ejYjsjWRKgC2qnYXUlWybotHZg8hYbrKBjkd62U88SXh7CLxow69GTPqtmyuAmN0Fo2+/PvMXOr9R152mfEGh79w4rzZVo9hmp1pzMoVzuWM8NBJA== 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=aJQwyTThQNqOz8HKMjNSNM8Yqza7Cao2DLD2ujZhYDU=; b=hEY4J8ShxI3kOXZtKYMB/8WQJYENJG6vd/uzWYbyUENwCSMIOZ4xAwHGooHHOkHLMdtaW9J83KE10suK4VdgWb2jnm4I+DnuIGaqKB+HNfok1Ms/8VNnVHRRd//yPHL1gv1PYwRk4DVYB7tvC08meES2McU3mK1AXJs8It//EUHJYJkU4SVK3x0juwBGJwbp6M6tlQbxnkrRZkt8uaosdjNJeCG6aRaB+tuNG8f+nqJOhMhct4hMjqmix+6FvaPdi4INea3tx+L78Nn/boJQO5Rd5fblbOFOPdl0HAwFOwIOSxid3akuB8/Qn4xqqEZWp9rr9ZdJZjm3wLsfaZAm3Q== 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=aJQwyTThQNqOz8HKMjNSNM8Yqza7Cao2DLD2ujZhYDU=; b=uDEoiuDP+gC+7YBbd8fV+crWrRGgEqCqy2tPGePH12WuiJaApTwJUvJqhdMHNEsaQryy7mqwdyc8nI9bNDArRYL579VpwSNF47p8SXZRci90VnpIO16LKutZUxUGvzSP1OdSSJwkW49NsvB+ZoICIKIJaw0BlHfgO2Okg0u21yM= Received: from MW4PR03CA0148.namprd03.prod.outlook.com (2603:10b6:303:8c::33) by MW6PR12MB8705.namprd12.prod.outlook.com (2603:10b6:303:24c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29; Tue, 23 May 2023 23:27:14 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::da) by MW4PR03CA0148.outlook.office365.com (2603:10b6:303:8c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 23:27: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 CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 23:27:13 +0000 Received: from ethanolx7ea3host.amd.com (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.34; Tue, 23 May 2023 18:27:12 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v4 23/23] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling Date: Tue, 23 May 2023 18:22:14 -0500 Message-ID: <20230523232214.55282-24-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523232214.55282-1-terry.bowman@amd.com> References: <20230523232214.55282-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT008:EE_|MW6PR12MB8705:EE_ X-MS-Office365-Filtering-Correlation-Id: 10981dd8-2125-48a5-b1c3-08db5be53d7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l4CVby1S23vrC99wPUGp0we0MyBJ6APzSXK5A6+gMzNZMgmJg71UWDnOGQihoWjkyDMsedEC0cNzsNErxUHgbQJ545V/KWtWATX+0gbQmvlhgtXrMbSe2kmLaCokOd9G3ezcspBm882/FdH+fCWDYxGGfqma7dAxzZsScPZSHYFs+9fZFbwHWvEtIxq+EYvv+UIthimJWt+flKAhNXhkUiWr0gCN+1+DBo6+xkDIQIHyy5XBTa74pAKKuKFaaH+ROGKdjRxylBIYQzNMjYAJFLwcDl2KAEdzGXMMz4s7xJqm584pcYhj2gZxxB7MWtqX9pnLkpsG2Fco3UcCMfpHM79463gs0O2WpVRE+B+pRea6ZV1C87tC6mZFJdMNli8h3yq0l6cjNrBT2TVQhj/6qNs5Y5AK01u6+r8Az6pw7hcyVHbxaRbYKKpUAYE7OD6DXmyxGZGcdymWF1jXH+D6x5axHYcYyGJBP3KMBoZpD/lY4QizQEVDpuU4zlb2VYHxwjUwTvakzlfr2xgF1bsdHVRLfYZAATkGRP9loy9E9MPyuvaxiiQ70qlcKInPn85C79B44huERy9CsJK8XmwytX5U8HmqOwG/xtPnb0F9xgQA9GSNPcfwfdlsX0lD2UUOcOWMvue5snq4+13/aGIddvLTm6XShG5PH7sJ5q0RiQYfuck9KfoL1CoCNxZZz2oxjp6ZmU3a6qQMo9rsg0noNLA4/jrKFIefKahL8tFC3ZSOR/GaMYx60S2hZkMxYDRtclIdR9NtWKZfp8hU96m93RTGtDhGikB8BTgFinS1Q48= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(478600001)(70206006)(70586007)(4326008)(7696005)(41300700001)(110136005)(316002)(54906003)(5660300002)(8936002)(8676002)(86362001)(44832011)(81166007)(26005)(356005)(82740400003)(1076003)(7416002)(40460700003)(16526019)(186003)(426003)(336012)(83380400001)(40480700001)(2906002)(2616005)(36756003)(36860700001)(47076005)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 23:27:13.8806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10981dd8-2125-48a5-b1c3-08db5be53d7b 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: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8705 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter AER corrected and uncorrectable internal errors (CIE/UIE) are masked in their corresponding mask registers per default once in power-up state. [1][2] Enable internal errors for RCECs to receive CXL downstream port errors of Restricted CXL Hosts (RCHs). [1] CXL 3.0 Spec, 12.2.1.1 - RCH Downstream Port Detected Errors [2] PCIe Base Spec 6.0, 7.8.4.3 Uncorrectable Error Mask Register, 7.8.4.6 Correctable Error Mask Register Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter --- drivers/pci/pcie/aer.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 2e3f00b6a5bd..c5076ae4eb58 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -948,6 +948,32 @@ static bool find_source_device(struct pci_dev *parent, #ifdef CONFIG_PCIEAER_CXL +static int pci_aer_unmask_internal_errors(struct pci_dev *dev) +{ + int aer, rc; + u32 mask; + + if (!pcie_aer_is_native(dev)) + return -EIO; + + aer = dev->aer_cap; + rc = pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, &mask); + if (rc) + return rc; + mask &= ~PCI_ERR_UNC_INTN; + rc = pci_write_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, mask); + if (rc) + return rc; + + rc = pci_read_config_dword(dev, aer + PCI_ERR_COR_MASK, &mask); + if (rc) + return rc; + mask &= ~PCI_ERR_COR_INTERNAL; + rc = pci_write_config_dword(dev, aer + PCI_ERR_COR_MASK, mask); + + return rc; +} + static bool is_cxl_mem_dev(struct pci_dev *dev) { /* @@ -1031,7 +1057,44 @@ static void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) pcie_walk_rcec(dev, cxl_rch_handle_error_iter, info); } +static int handles_cxl_error_iter(struct pci_dev *dev, void *data) +{ + int *handles_cxl = data; + + *handles_cxl = is_cxl_mem_dev(dev) && cxl_error_is_native(dev); + + return *handles_cxl; +} + +static bool handles_cxl_errors(struct pci_dev *rcec) +{ + int handles_cxl = 0; + + if (pci_pcie_type(rcec) == PCI_EXP_TYPE_RC_EC && + pcie_aer_is_native(rcec)) + pcie_walk_rcec(rcec, handles_cxl_error_iter, &handles_cxl); + + return !!handles_cxl; +} + +static void cxl_rch_enable_rcec(struct pci_dev *rcec) +{ + if (!handles_cxl_errors(rcec)) + return; + + /* + * Internal errors are masked by default, unmask RCEC's here + * PCI6.0 7.8.4.3 Uncorrectable Error Mask Register (Offset 08h) + * PCI6.0 7.8.4.6 Correctable Error Mask Register (Offset 14h) + */ + if (pci_aer_unmask_internal_errors(rcec)) + pci_err(rcec, "CXL: Failed to unmask internal errors"); + else + pci_info(rcec, "CXL: Internal errors unmasked"); +} + #else +static inline void cxl_rch_enable_rcec(struct pci_dev *dev) { } static inline void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) { } #endif @@ -1432,6 +1495,7 @@ static int aer_probe(struct pcie_device *dev) return status; } + cxl_rch_enable_rcec(port); aer_enable_rootport(rpc); pci_info(port, "enabled with IRQ %d\n", dev->irq); return 0;