From patchwork Mon Jul 1 17:47:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13718500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ACEC16F0E3; Mon, 1 Jul 2024 17:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856106; cv=fail; b=kYmeJ8sOL8KdgxwVmBRhmMHZVP0lVEU1XBb7BNBuXj2JxiETVOIFnod3x0a5StwrRoEhCe7XeDPI5ng2dapEiay4OasUoK5bAFkrOGjW8aE6tspo62jMh2x8Y+/8XkSLR5eJz3IrM1Ey7Tw7WH6a1Ol4vq3v/aCcf9UN5dV+6XM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856106; c=relaxed/simple; bh=vxi2BveKx2d72IInQNT4V8klhjcRw+VnsVtOaZTJ/mc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BJS8uj4bWPjMqOaeMNgsbr3WrVa8D7qrqf7e5y82DwMug6HysS8DNzD3v1l8Pyq4WsfWKrgRIOAgGLQtZEmC8xJjJ7VaIDdF4lHqSELF1k6LK2w9cvm9meitu9Azdq6aUJs0kh1AWu1r8zdD+9A3ufN3VEbKvo7GHoGMNdFWwpY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Gf7DvPQn; arc=fail smtp.client-ip=40.107.95.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Gf7DvPQn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hcjpj8LuGfB93yIc/x2YZPSFf7LWATyCiYEhiSUTW4hGQLLiIxR9fjaIDteNXlQP9134Biu0De1KY40D5DMlSvwkPAWe8dA9IvRYDVWr1jwC9i/MG8ReTZAE0PcXnciPwIr9RxTnKvSE4aB2PBxoztMT7hcJdNxmDpVfs99FCRpa51NREBfWDui0I+Y9gDmqDsJ1xVkktYuXLwmQoVHsfYptppDS8x/fHT6Drcq/jl3kIfX7zDSDmcESITkJP5hES67moUs+FgdIyrr31S95I7cZr9YDxwTM/7xnwFIR5BHNzZzrszqJVtwleV5ZVuC4Gt9f676q5E2jgcGdqzmJFQ== 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=NPrE16HyJfyTGkyDchmZus+YzDNBhVyxLDSXdh1TC3s=; b=HImLsiXGxByYW9m8YWX+dVjPaBdrDCQixJx9bY44NPYTsv7I+/ztEpz/WKvZCBrOj0gjqEhTZEQHLQf7nEV592BDccwID/gJ66uhk42Ah+ZY7srfomjHbUc9zMYuy1xw0jGAtxx/pR+lojE0/UjgtQIGbt6UlbZ8UQ06WTSOlF+uE7mwSkbncAzMTTwYpJJ2za/MCQAnuPWTsuIWbiyK+NoX02ss4xlS3uNwoy0gvuK+F2N8e2HLfhAjJJ6P46DSQ5BIWZUMghkVfv+xeC8j0PMZo1pT2PDTEBhAhyATGcYvkORawuknroKfH02KftKq3KR0VM9i291pNdoED+PBJw== 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 (0) 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=NPrE16HyJfyTGkyDchmZus+YzDNBhVyxLDSXdh1TC3s=; b=Gf7DvPQn5VCZMAFCUwH83LNZ+9YzCg8e5vAo8Ro/9bWiJ6ihkU0lUEVSN5jJ6j0I3D/w/FDhSTAAWn32zwG6VX4ZtFhSiA8vrTmAarQgSBMxpEWVIi8IKoX0uS1ag6c5p0ZIPAjzH+355UH+8Gcz2oRnb29XnGTl2RgG/sBhJrg= Received: from PH7P220CA0144.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::6) by DM4PR12MB7575.namprd12.prod.outlook.com (2603:10b6:8:10d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33; Mon, 1 Jul 2024 17:48:21 +0000 Received: from SN1PEPF000397B0.namprd05.prod.outlook.com (2603:10b6:510:327:cafe::3c) by PH7P220CA0144.outlook.office365.com (2603:10b6:510:327::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32 via Frontend Transport; Mon, 1 Jul 2024 17:48: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 SN1PEPF000397B0.mail.protection.outlook.com (10.167.248.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Mon, 1 Jul 2024 17:48:21 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 12:48:18 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , "Robert Richter" Subject: [PATCH v2 1/5] cxl/hdm: Moving HDM specific code to core/hdm.c. Date: Mon, 1 Jul 2024 19:47:49 +0200 Message-ID: <20240701174754.967954-2-rrichter@amd.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240701174754.967954-1-rrichter@amd.com> References: <20240701174754.967954-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SN1PEPF000397B0:EE_|DM4PR12MB7575:EE_ X-MS-Office365-Filtering-Correlation-Id: af5a58b3-7290-4e25-621f-08dc99f5ff85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: C/AQRUhq2Dikh4twLWd5Dmwx2zOas57I6I4lIZ1RJ2Bo3fEWzqtQQEcQrhlM4b7mFJXtRJIPzjCrtl1ut7BwkCfKYdGUEWAqjx+WyTF9+BSzB9UVw24va0DXcV/VCjlc1ZlBJVFGgZush3DPNDfG6DiWDEoMkF6Wid1wjnVq1w7yXKXOWgh73XwyTf+ArNDhosnqGxcSDbfjRwapSWf41cQdUXrkuo6+Rs+g/7fo7fK7vJ3ETA9lBMfM34V/LvkKVIYbBMdydiAykjLB196GtKDFPHKIYVKi6TgzdiwZeMU9mjhsCWqXJN1zf7cRJXBshoWMQ7n1Ji0P5Ak0Is6lcVkOvH3zg/NejgHQQv8PEuBkYi3Vqb/FxoXMbNN8w3kMaGgxZuEWBrgBoy3K2e+CLr/R47C4B5P/kcW3/cAScjSybJ83APQXrdCse/3UVwr4TAUFpIdHjPve7SF8P53EsExPSMM6XKFFDTkY1PXKrPijHZgI11uKhv9JPbtGMSDPwUf0Gb6p3a/K4B9Zzj7g1RKlGkXAn9Xu8BAi7mfsyzqYp9exhBZTVm3uH1Jx2q3o8k5TmugkYvTYItCvBqWYb/yFkGT8UT+3arjENjMHEnWP6O5fkg+ym4Hh4MZ+QPEzPJ+H0/yDGBxdNbQUU303MpoK/k4Wbm6Sjbo4vcq4kqKmc9Ir5Oze5nrN++K7/0u7PSAzoDEiH4VzlX0OReXBYLrgX9SNan+HvREtDXEPAxRr0s895FxlB5RhKU3PYSc14vYxdv+ZCtNlcmjFa98LLO4hEF3aBlZmDndov8/xK/sQjHUE8legQ2ksSOIEAconCr7byGteagf+fcxD9amBqOi5K/4gsIOH8VKMWQIiWvnnVI5w2/FgADxvYL5FeGhuNuhw3dL7W4I0VzlakUEf12hdNJCNV75GY5YwKVPr6aVKObapmm67TbGQpBTJB8nXY6Pw454gK9XusxlN61pQ/solWIu3fZTt9zaBT0C/XmwX3P2W37a+XF1j/fH1e3uzAMzE5obUZkckuaTcTsaMMiR9ZDSizd3Q6iBXXjF54b49qFx0RCDFIFw/BQR7hTtFCTFXtFnptOchYdcQIu7lAoyCv9g1bVZurzzmHhlmlpVz0XgqchDyYPic24yQYWvxRXY5e01xSUQewQ/PyIB5phKBo6XsN1trpMSAaQ2p1vexUWZk1ersbc6Xy3laS4wripYi1snHdnPcbM4rx2ZYe5zGlsoVhT9LJz1FIj+rSdWmumuqnzPc1kYu3g1LjwQ6vlTeVb3+y9TcfyUbDhlpXhG9+YhAEgX08b2Y/0NhtXhuDKy+WjxsS6Zaihrlj5aOGBVG9VTj5MI1253oc+jiB8ibYkXTud9vR1QIrWxQTuDGUoT8+ctjEDlhD7BJEdTHNubeHge8oubJcWwpPUz8bKBG/KV/wZ0zjimlWAOrWaBT6fvxYWPtIn1mC1W0Fxil 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:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2024 17:48:21.1799 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af5a58b3-7290-4e25-621f-08dc99f5ff85 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: SN1PEPF000397B0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7575 Code to handle HDM specifics is implemented in core/pci.c and core/hdm.c. In both files helper functions will be needed for address translation. To simplify the introduction of static helper functions, move all HDM code to core/hdm.c. The function devm_cxl_enable_mem() is no longer static and is shared now within the core module. No functional changes otherwise. Signed-off-by: Robert Richter Reviewed-by: Dan Williams --- drivers/cxl/core/core.h | 2 + drivers/cxl/core/hdm.c | 117 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/pci.c | 119 +--------------------------------------- drivers/cxl/cxlmem.h | 3 + drivers/cxl/cxlpci.h | 3 - 5 files changed, 123 insertions(+), 121 deletions(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 625394486459..d8c3c27ce100 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -70,6 +70,8 @@ int cxl_query_cmd(struct cxl_memdev *cxlmd, int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s); void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, resource_size_t length); +struct cxl_dev_state; +int devm_cxl_enable_mem(struct device *host, struct cxl_dev_state *cxlds); struct dentry *cxl_debugfs_create_dir(const char *dir); int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 784843fa2a22..605da9a55d89 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -1027,3 +1027,120 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, return 0; } EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_decoders, CXL); + +/* require dvsec ranges to be covered by a locked platform window */ +static int dvsec_range_allowed(struct device *dev, void *arg) +{ + struct range *dev_range = arg; + struct cxl_decoder *cxld; + + if (!is_root_decoder(dev)) + return 0; + + cxld = to_cxl_decoder(dev); + + if (!(cxld->flags & CXL_DECODER_F_RAM)) + return 0; + + return range_contains(&cxld->hpa_range, dev_range); +} + +static void disable_hdm(void *_cxlhdm) +{ + u32 global_ctrl; + struct cxl_hdm *cxlhdm = _cxlhdm; + void __iomem *hdm = cxlhdm->regs.hdm_decoder; + + global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); + writel(global_ctrl & ~CXL_HDM_DECODER_ENABLE, + hdm + CXL_HDM_DECODER_CTRL_OFFSET); +} + +static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) +{ + void __iomem *hdm = cxlhdm->regs.hdm_decoder; + u32 global_ctrl; + + global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); + writel(global_ctrl | CXL_HDM_DECODER_ENABLE, + hdm + CXL_HDM_DECODER_CTRL_OFFSET); + + return devm_add_action_or_reset(host, disable_hdm, cxlhdm); +} + +/** + * cxl_hdm_decode_init() - Setup HDM decoding for the endpoint + * @cxlds: Device state + * @cxlhdm: Mapped HDM decoder Capability + * @info: Cached DVSEC range registers info + * + * Try to enable the endpoint's HDM Decoder Capability + */ +int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, + struct cxl_endpoint_dvsec_info *info) +{ + void __iomem *hdm = cxlhdm->regs.hdm_decoder; + struct cxl_port *port = cxlhdm->port; + struct device *dev = cxlds->dev; + struct cxl_port *root; + int i, rc, allowed; + u32 global_ctrl = 0; + + if (hdm) + global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); + + /* + * If the HDM Decoder Capability is already enabled then assume + * that some other agent like platform firmware set it up. + */ + if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled)) + return devm_cxl_enable_mem(&port->dev, cxlds); + else if (!hdm) + return -ENODEV; + + root = to_cxl_port(port->dev.parent); + while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) + root = to_cxl_port(root->dev.parent); + if (!is_cxl_root(root)) { + dev_err(dev, "Failed to acquire root port for HDM enable\n"); + return -ENODEV; + } + + for (i = 0, allowed = 0; info->mem_enabled && i < info->ranges; i++) { + struct device *cxld_dev; + + cxld_dev = device_find_child(&root->dev, &info->dvsec_range[i], + dvsec_range_allowed); + if (!cxld_dev) { + dev_dbg(dev, "DVSEC Range%d denied by platform\n", i); + continue; + } + dev_dbg(dev, "DVSEC Range%d allowed by platform\n", i); + put_device(cxld_dev); + allowed++; + } + + if (!allowed && info->mem_enabled) { + dev_err(dev, "Range register decodes outside platform defined CXL ranges.\n"); + return -ENXIO; + } + + /* + * Per CXL 2.0 Section 8.1.3.8.3 and 8.1.3.8.4 DVSEC CXL Range 1 Base + * [High,Low] when HDM operation is enabled the range register values + * are ignored by the device, but the spec also recommends matching the + * DVSEC Range 1,2 to HDM Decoder Range 0,1. So, non-zero info->ranges + * are expected even though Linux does not require or maintain that + * match. If at least one DVSEC range is enabled and allowed, skip HDM + * Decoder Capability Enable. + */ + if (info->mem_enabled) + return 0; + + rc = devm_cxl_enable_hdm(&port->dev, cxlhdm); + if (rc) + return rc; + + return devm_cxl_enable_mem(&port->dev, cxlds); +} +EXPORT_SYMBOL_NS_GPL(cxl_hdm_decode_init, CXL); diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 8567dd11eaac..4f67e3ae7a05 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -270,7 +270,7 @@ static void clear_mem_enable(void *cxlds) cxl_set_mem_enable(cxlds, 0); } -static int devm_cxl_enable_mem(struct device *host, struct cxl_dev_state *cxlds) +int devm_cxl_enable_mem(struct device *host, struct cxl_dev_state *cxlds) { int rc; @@ -282,46 +282,6 @@ static int devm_cxl_enable_mem(struct device *host, struct cxl_dev_state *cxlds) return devm_add_action_or_reset(host, clear_mem_enable, cxlds); } -/* require dvsec ranges to be covered by a locked platform window */ -static int dvsec_range_allowed(struct device *dev, void *arg) -{ - struct range *dev_range = arg; - struct cxl_decoder *cxld; - - if (!is_root_decoder(dev)) - return 0; - - cxld = to_cxl_decoder(dev); - - if (!(cxld->flags & CXL_DECODER_F_RAM)) - return 0; - - return range_contains(&cxld->hpa_range, dev_range); -} - -static void disable_hdm(void *_cxlhdm) -{ - u32 global_ctrl; - struct cxl_hdm *cxlhdm = _cxlhdm; - void __iomem *hdm = cxlhdm->regs.hdm_decoder; - - global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); - writel(global_ctrl & ~CXL_HDM_DECODER_ENABLE, - hdm + CXL_HDM_DECODER_CTRL_OFFSET); -} - -static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) -{ - void __iomem *hdm = cxlhdm->regs.hdm_decoder; - u32 global_ctrl; - - global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); - writel(global_ctrl | CXL_HDM_DECODER_ENABLE, - hdm + CXL_HDM_DECODER_CTRL_OFFSET); - - return devm_add_action_or_reset(host, disable_hdm, cxlhdm); -} - int cxl_dvsec_rr_decode(struct device *dev, int d, struct cxl_endpoint_dvsec_info *info) { @@ -425,83 +385,6 @@ int cxl_dvsec_rr_decode(struct device *dev, int d, } EXPORT_SYMBOL_NS_GPL(cxl_dvsec_rr_decode, CXL); -/** - * cxl_hdm_decode_init() - Setup HDM decoding for the endpoint - * @cxlds: Device state - * @cxlhdm: Mapped HDM decoder Capability - * @info: Cached DVSEC range registers info - * - * Try to enable the endpoint's HDM Decoder Capability - */ -int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, - struct cxl_endpoint_dvsec_info *info) -{ - void __iomem *hdm = cxlhdm->regs.hdm_decoder; - struct cxl_port *port = cxlhdm->port; - struct device *dev = cxlds->dev; - struct cxl_port *root; - int i, rc, allowed; - u32 global_ctrl = 0; - - if (hdm) - global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET); - - /* - * If the HDM Decoder Capability is already enabled then assume - * that some other agent like platform firmware set it up. - */ - if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled)) - return devm_cxl_enable_mem(&port->dev, cxlds); - else if (!hdm) - return -ENODEV; - - root = to_cxl_port(port->dev.parent); - while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) - root = to_cxl_port(root->dev.parent); - if (!is_cxl_root(root)) { - dev_err(dev, "Failed to acquire root port for HDM enable\n"); - return -ENODEV; - } - - for (i = 0, allowed = 0; info->mem_enabled && i < info->ranges; i++) { - struct device *cxld_dev; - - cxld_dev = device_find_child(&root->dev, &info->dvsec_range[i], - dvsec_range_allowed); - if (!cxld_dev) { - dev_dbg(dev, "DVSEC Range%d denied by platform\n", i); - continue; - } - dev_dbg(dev, "DVSEC Range%d allowed by platform\n", i); - put_device(cxld_dev); - allowed++; - } - - if (!allowed && info->mem_enabled) { - dev_err(dev, "Range register decodes outside platform defined CXL ranges.\n"); - return -ENXIO; - } - - /* - * Per CXL 2.0 Section 8.1.3.8.3 and 8.1.3.8.4 DVSEC CXL Range 1 Base - * [High,Low] when HDM operation is enabled the range register values - * are ignored by the device, but the spec also recommends matching the - * DVSEC Range 1,2 to HDM Decoder Range 0,1. So, non-zero info->ranges - * are expected even though Linux does not require or maintain that - * match. If at least one DVSEC range is enabled and allowed, skip HDM - * Decoder Capability Enable. - */ - if (info->mem_enabled) - return 0; - - rc = devm_cxl_enable_hdm(&port->dev, cxlhdm); - if (rc) - return rc; - - return devm_cxl_enable_mem(&port->dev, cxlds); -} -EXPORT_SYMBOL_NS_GPL(cxl_hdm_decode_init, CXL); - #define CXL_DOE_TABLE_ACCESS_REQ_CODE 0x000000ff #define CXL_DOE_TABLE_ACCESS_REQ_CODE_READ 0 #define CXL_DOE_TABLE_ACCESS_TABLE_TYPE 0x0000ff00 diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 19aba81cdf13..61d9f4e00921 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -862,4 +862,7 @@ struct cxl_hdm { struct seq_file; struct dentry *cxl_debugfs_create_dir(const char *dir); void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); +int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, + struct cxl_endpoint_dvsec_info *info); + #endif /* __CXL_MEM_H__ */ diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h index 4da07727ab9c..fe01793af1cb 100644 --- a/drivers/cxl/cxlpci.h +++ b/drivers/cxl/cxlpci.h @@ -122,9 +122,6 @@ static inline bool cxl_pci_flit_256(struct pci_dev *pdev) } int devm_cxl_port_enumerate_dports(struct cxl_port *port); -struct cxl_dev_state; -int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, - struct cxl_endpoint_dvsec_info *info); void read_cdat_data(struct cxl_port *port); void cxl_cor_error_detected(struct pci_dev *pdev); pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, From patchwork Mon Jul 1 17:47:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13718501 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECE6A16EC11; Mon, 1 Jul 2024 17:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856114; cv=fail; b=rTev4L+/dwOz8epRnOljTiJ675ZVXGajeE0D37vZIHpNhMF3DdYdGhc8DPtyV5rzKHjmzUEuAGsmFKlZ6VUJ922okIlQKlPVnuQ1EkWctnQfACdrWiTyle8GpqJ982kQhIxMIvq4AA2APSRcoV6DdEbqnhkZ+BuoaNvoEudB8CE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856114; c=relaxed/simple; bh=kfBgx1cN9MGxCeqW04wWSTxZ31ki+m1SrHTU6OvWjJY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KoE9xfaOxy8uCNrDmvjcZToF6PT09IIyKjgZP5/OSxLE1oJIWyud1zhjDlJrjNHj9g1nQ2Q1LXFmKHnG2Silkwnri2YZjxIdLVTqp3o/wUby6ifqepF6X11kYqfH6KU5TiMv1nwcwVLDPd5u+q7h//6uSAcRnBiz474haXeZ8IE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=aGl39xsk; arc=fail smtp.client-ip=40.107.223.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="aGl39xsk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvQRhJ4kx9lXA8oEZxauHoJVU51iMgjjk08tclh2H6Sn41mnQaUMuaQXrpv+IRZerjcQu18WVJHe8rrdarzgx1CjNiBokbikx8la7v94Tpmw9fdx74wWiLnIoOhiQryZWGUfmOlW2B/qrO6ru6hdMZxcFJ75gGpVZXjO8c1G2UXb9CEJkHPQI08/hzpBRREv0bVaxyLU/t76kOqx3IBHS31XtZzVyoK401k4751dvNPIyJn8zfEr6LJ6KFA7laODIOAYKZ+bU0bNMOUDR7T3T40Yts6o+u+SLxz5t++r4O7zNuDvFYN5EmRw9Tp8D9S600kfjFMWc3eHbU9VkFozmQ== 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=YjP5YshW8yxPb5hSTf2Cu12fdT4c3VRWLRHit/0vJJA=; b=hnTdNyUSxrJzGv+L4kOhD2d0Wb0lbO1aNHA0AB1+B3KLOS9wHO0yeX+fWLBPAg2KX4BpJssCtZ/iTf2vX040C+1zhlfoVmPt7Kp3cgPVXakvwbxsRIPMP3MH12myJSwHAhiE614j4s6qiKw6WFexvjkRjGTjjCRZ4zGwq9KxcyBBYTfYzmA2Mw/QCGf67TS17wBs3oXi8GDtqEKH3hNsOKvNiKg7bDwp96X7Q74mVORCLHgRuBdtBTKaXBtqRQ5gECNKTmg88Z9w/Vi/XXYdVXYPPmLGQ2oOrxUFhzUVLkCZpS9vMC/Mgz5qEk3Lo5QJ+odZJgS94tOAqZ4NnNj3hw== 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 (0) 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=YjP5YshW8yxPb5hSTf2Cu12fdT4c3VRWLRHit/0vJJA=; b=aGl39xskrQYOQ+Vz79IsYvXUlY1Y/Yjs2MUzq8RsEFauqVlGH+6kLAknQkDlcXQgi+1rdu5Es2t8hMBu2UfdmCRy21N5Tzel8D1g9+5KUWymYAfyYvw/FuSe9fdetL9Nb0Olk5lcliTPzzlqq2IDv/YLeXl6Dtandzz40W542sY= Received: from PH7PR10CA0012.namprd10.prod.outlook.com (2603:10b6:510:23d::26) by SA1PR12MB7200.namprd12.prod.outlook.com (2603:10b6:806:2bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Mon, 1 Jul 2024 17:48:25 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2603:10b6:510:23d:cafe::fb) by PH7PR10CA0012.outlook.office365.com (2603:10b6:510:23d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32 via Frontend Transport; Mon, 1 Jul 2024 17:48:25 +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 SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Mon, 1 Jul 2024 17:48:24 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 12:48:22 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , "Robert Richter" Subject: [PATCH v2 2/5] cxl/hdm: Implement address translation for HDM decoding Date: Mon, 1 Jul 2024 19:47:50 +0200 Message-ID: <20240701174754.967954-3-rrichter@amd.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240701174754.967954-1-rrichter@amd.com> References: <20240701174754.967954-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SN1PEPF000397B2:EE_|SA1PR12MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: cc62cb5b-1305-4437-5698-08dc99f601b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: pC6eQmyj4yC4nNK00U2DZal2kg9MxEoZtOE8WxBFqFl+ZIbEQcva44ey5pfCW51Yg6TQwu//88GSsOgG2vy/ASwAsXFRqFsr50p+mVgoiEKqVJXanYrU7Kosb16iNoKPISOliiAv94sDOf2HHKWJJocTapKrA3ylJnZoIjftWf5pbXWDstU9VjlqK5+GfaL5hdC/ULsqBQjWRYfyA7JahXbXQNQsnYecNDYLinlWfoyt/cBgGDaQo0fAWc6xqHDI33kF6AglSL0THcy166QoSDAxxe3a/TV3PlWgsvv6f1T4Ao7f77nxWnAyLDGhU8n4rBq79tFg+c2xORMLy4eO3UAchP5i5xU/JyIpSZKG7KqQTZDWZ1Rcr+nvSHPvy7ycMPTW5Gs0YLQ5oOTU/5MQbOPpSCAfgKrGm3bJ+8e8bVnmwwhL4kpvIA8VIHIGscImAvOCxXN3KrE63u2+7GeclmTMsJFB/3/LJHeE2IlbCZpsGt4hEVWXcfUpgBjYf41GveFuXhdcnjiIQ/QVvuLJONNRudon9ZfLO8Wr0bhNFvGsI0MVd76bTcuMMXvmayjBehRUrrqsqqQCBHYc62oUL1mcS2vYW9C2Q4DxJxe1SGxPFVfmtscGuZujjPuccpOPeq6ka4KwWd7w4e1sYIoBayIRZ4OayqhItgvPhIf0+5q7gFOMHAbMU7HKiEQOsCPgEOM40NgvbyZ1wZ+UPMADPpTee3FPfMe5aoeCqVqWPD2eNUgkZXkzHbjAprOI7Y9wRhGqlIKRcIk/uTqMNwNSxnz7/U/26jAbkE7gxGstkQu1Sw5KBPIdkHZ1c9qbxcad9iPYens8keXhIWlJ01alX4eu8PuONyPLxztbRZ8a82tUw8B8FBpNbJhZiVPiaOw/NC7ATRLYWxY2SyOdW5Czok1S2mlSrySSxFJjHh5VMb6VPNMk/+xo/y2r4r2lgVXcorxrjEerpqPQR7HKZ2ZfKxwefEGNnHsxcXIkwXk2svJcXY4e2s68qEHhkPsnn+AiOstOblDja7/HESDvO+16iwvsgqLcaGOECgYb5inzaT64X+X8voP3uUpvizmxa00BJdTHuw8mjYvPcFvKMUrkn752GGCFsPLHjCEu4GPE70EGJlDLKc7lmlSOd3ZYZWyuo5pcF+5U+j80D9BOARaWJ3LqMOosD0Pgsgxo0HHPOH7qs50tsbuO6DlaBQ0+1g7HK2oBKWv5e794MqMvD9KO3MMDCY422yJjefoqucaWF8aWilPT7HcNaTM/kkF9NIr9Ya0pk/kcf9qkxQ1POWHiEZYij4Y+rf+0R0Sw1TpPT/ZSbh8TjK8q4P3LZu6pBlS6dqx5gbS+sfrjG1Bq72Z4aegoReqTCGmRp0hvJLWid4wHynltk3+o0ZKHy8u/Eo/StrEr6HdtRbevQC+14Y2KgQ== 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:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2024 17:48:24.8783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc62cb5b-1305-4437-5698-08dc99f601b7 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7200 Default expectation of Linux is that HPA == SPA, which means that hardware addresses in the decoders are the same as the kernel sees them. However, there are platforms where this is not the case and an address translation between decoder's (HPA) and the system's physical addresses (SPA) is needed. The CXL driver stores all internal hardware address ranges as SPA. When accessing the HDM decoder's registers, hardware addresses must be translated back and forth. This is needed for the base addresses in the CXL Range Registers of the PCIe DVSEC for CXL Devices (CXL_DVSEC_RANGE_BASE*) or the CXL HDM Decoder Capability Structure (CXL_HDM_DECODER0_BASE*). To handle address translation the kernel needs to keep track of the system's base HPA the decoder bases on. The base can be different between memory domains, each port may have its own domain. Thus, the HPA base cannot be shared between CXL ports and its decoders, instead the base HPA must be stored per port. Each port has its own struct cxl_hdm to handle the sets of decoders and targets, that struct can also be used for storing the base. Add @base_hpa to struct cxl_hdm. Also Introduce helper functions for the translation and use them to convert the HDM decoder base addresses to or from an SPA. While at this, rename len to size for the common base/size naming used with ranges. Link: https://lore.kernel.org/all/65c6b8c9a42e4_d2d4294f1@dwillia2-xfh.jf.intel.com.notmuch/ Suggested-by: Dan Williams Signed-off-by: Robert Richter --- drivers/cxl/core/hdm.c | 69 ++++++++++++++++++++++++++++++++++-------- drivers/cxl/cxlmem.h | 1 + 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 605da9a55d89..50078013f4e3 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -125,6 +125,17 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) return true; } +static void setup_base_hpa(struct cxl_hdm *cxlhdm) +{ + /* + * Address translation is not needed on platforms with HPA == + * SPA. HDM decoder addresses all base on system addresses, + * there is no offset and the base is zero (cxlhdm->base_hpa + * == 0). Nothing to do here as it is already pre-initialized + * zero. + */ +} + /** * devm_cxl_setup_hdm - map HDM decoder component registers * @port: cxl_port to map @@ -144,6 +155,8 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, cxlhdm->port = port; dev_set_drvdata(dev, cxlhdm); + setup_base_hpa(cxlhdm); + /* Memory devices can configure device HDM using DVSEC range regs. */ if (reg_map->resource == CXL_RESOURCE_NONE) { if (!info || !info->mem_enabled) { @@ -611,6 +624,23 @@ static int cxld_await_commit(void __iomem *hdm, int id) return -ETIMEDOUT; } +/* + * Default expectation is that decoder base addresses match + * HPA resource values (that is cxlhdm->base_hpa == 0). + */ + +static inline resource_size_t cxl_xlat_to_hpa(resource_size_t base, + struct cxl_hdm *cxlhdm) +{ + return cxlhdm->base_hpa + base; +} + +static inline resource_size_t cxl_xlat_to_base(resource_size_t hpa, + struct cxl_hdm *cxlhdm) +{ + return hpa - cxlhdm->base_hpa; +} + static int cxl_decoder_commit(struct cxl_decoder *cxld) { struct cxl_port *port = to_cxl_port(cxld->dev.parent); @@ -655,7 +685,7 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld) ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(cxld->id)); cxld_set_interleave(cxld, &ctrl); cxld_set_type(cxld, &ctrl); - base = cxld->hpa_range.start; + base = cxl_xlat_to_base(cxld->hpa_range.start, cxlhdm); size = range_len(&cxld->hpa_range); writel(upper_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(id)); @@ -746,22 +776,27 @@ static int cxl_setup_hdm_decoder_from_dvsec( struct cxl_port *port, struct cxl_decoder *cxld, u64 *dpa_base, int which, struct cxl_endpoint_dvsec_info *info) { + struct cxl_hdm *cxlhdm = dev_get_drvdata(&port->dev); struct cxl_endpoint_decoder *cxled; - u64 len; + u64 base, size; int rc; if (!is_cxl_endpoint(port)) return -EOPNOTSUPP; cxled = to_cxl_endpoint_decoder(&cxld->dev); - len = range_len(&info->dvsec_range[which]); - if (!len) + size = range_len(&info->dvsec_range[which]); + if (!size) return -ENOENT; + base = cxl_xlat_to_hpa(info->dvsec_range[which].start, cxlhdm); cxld->target_type = CXL_DECODER_HOSTONLYMEM; cxld->commit = NULL; cxld->reset = NULL; - cxld->hpa_range = info->dvsec_range[which]; + cxld->hpa_range = (struct range) { + .start = base, + .end = base + size -1, + }; /* * Set the emulated decoder as locked pending additional support to @@ -770,14 +805,14 @@ static int cxl_setup_hdm_decoder_from_dvsec( cxld->flags |= CXL_DECODER_F_ENABLE | CXL_DECODER_F_LOCK; port->commit_end = cxld->id; - rc = devm_cxl_dpa_reserve(cxled, *dpa_base, len, 0); + rc = devm_cxl_dpa_reserve(cxled, *dpa_base, size, 0); if (rc) { dev_err(&port->dev, "decoder%d.%d: Failed to reserve DPA range %#llx - %#llx\n (%d)", - port->id, cxld->id, *dpa_base, *dpa_base + len - 1, rc); + port->id, cxld->id, *dpa_base, *dpa_base + size - 1, rc); return rc; } - *dpa_base += len; + *dpa_base += size; cxled->state = CXL_DECODER_STATE_AUTO; return 0; @@ -787,6 +822,7 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, int *target_map, void __iomem *hdm, int which, u64 *dpa_base, struct cxl_endpoint_dvsec_info *info) { + struct cxl_hdm *cxlhdm = dev_get_drvdata(&port->dev); struct cxl_endpoint_decoder *cxled = NULL; u64 size, base, skip, dpa_size, lo, hi; bool committed; @@ -823,6 +859,9 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, if (info) cxled = to_cxl_endpoint_decoder(&cxld->dev); + + base = cxl_xlat_to_hpa(base, cxlhdm); + cxld->hpa_range = (struct range) { .start = base, .end = base + size - 1, @@ -1107,16 +1146,20 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, } for (i = 0, allowed = 0; info->mem_enabled && i < info->ranges; i++) { - struct device *cxld_dev; - - cxld_dev = device_find_child(&root->dev, &info->dvsec_range[i], - dvsec_range_allowed); + u64 base = cxl_xlat_to_hpa(info->dvsec_range[i].start, cxlhdm); + u64 size = range_len(&info->dvsec_range[i]); + struct range hpa_range = { + .start = base, + .end = base + size -1, + }; + struct device *cxld_dev __free(put_device) = + cxld_dev = device_find_child(&root->dev, &hpa_range, + dvsec_range_allowed); if (!cxld_dev) { dev_dbg(dev, "DVSEC Range%d denied by platform\n", i); continue; } dev_dbg(dev, "DVSEC Range%d allowed by platform\n", i); - put_device(cxld_dev); allowed++; } diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 61d9f4e00921..849ea97385c9 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -856,6 +856,7 @@ struct cxl_hdm { unsigned int decoder_count; unsigned int target_count; unsigned int interleave_mask; + u64 base_hpa; struct cxl_port *port; }; From patchwork Mon Jul 1 17:47:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13718502 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFAFC16EC0E; Mon, 1 Jul 2024 17:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856115; cv=fail; b=UWYUfm/2jmkvxvGqK2Xocet+DtwnLpV1OMjq1YKopCrRV7hYzq8J2VZxMjEwvqEN8o8GOaF0rpz9S+PR5J2gDCmvv+j1Fg2L+3F3poEiEaphMucHg4LQW5cv6wNBOaGcMuzZVHDbbBatiTV20sPsX8pd/coSPqBUNCw2RH382n8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856115; c=relaxed/simple; bh=CSUBmafGC/wwdSnalGy7Y+ViTsiZtqFnkD3xzP8Vx6c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EOWpvYjP1anpStAHcmUCM7PTfcYRD5bbLlNPNjx88/nBnSdpa/bx5PtVGVt8lUYFMw0btriMz9VYr2wDoJsy4jm5vxzig4PV6nXvAusIQjFl1yZGREAB3H57Wp82Ur7dqwJDmfgq0hXYfqiduF7LhS+MbDOSkIT1R/JQ8vvqjck= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5IQ1jVNG; arc=fail smtp.client-ip=40.107.223.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5IQ1jVNG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0dJcKHa8FqX8/ZsHDkvJTL7Js4Wk0BqrFYO4BDN9P8JhQdtm5/Tk/S60lT37Oqb5P0oNl6PwdOVZ54erZX6E+/wrFl0tXs3M80lUGJX1KD7Ihhk5ZkRmWhf6535GpLjOMnSAelXsf5f1ORvtQoUnkK4hPZfA9XrNOvTHDVoodavQcN5olO8bjAjiBWSVKugiXqMI76Um2hQDcJpOVdFsp8azb1JLO2ZRpaZyFArKXyDw9qKTfURtHMBokN9KFdRnxvnZw83Z/KtBhDeGBaQzPoi0A1Hd4afTtnbKMNG1hl4dcp1sYYEZwSa0fSjbTRkjNWBQnYc0thitAlv5PZs8w== 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=XvTHDYS5g3rvFskiyopebg68RQxdzwYWGUVzm2Z7aB8=; b=PeKdAan3+sZn+XDIBWG7d6oChql24CSN/KTLXBmT6bERjjSCdaRu1LaVKT564Fbsmgqsd+1SzHA9yiYtjN4AwvJ14O1Rh9wPOEaz2cap3CQ16F1408hPdfRMsPUPfjlYmROnZJVB1Rg6f9q9ZKMQwWfJKz3OqgkPMfpqe6lJXoy4PNCCcNkoYbxyNFLuiuF363BDOndU9wgL78lewkhElO8n/z2f/fkkRa0kh4LZciqRXwYfvqcyhPPVw2im0mIXvgx4Wum9TuegauacinMaOF3qPxj4eTt49uoZHEirsI3MUXggcxI7olpIy2K6YZNQCmseCmDvj4SaAXvR5D/uPg== 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 (0) 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=XvTHDYS5g3rvFskiyopebg68RQxdzwYWGUVzm2Z7aB8=; b=5IQ1jVNGojE8/YEv9mFtRMydxiag6VPsgLE84kfXKdj+FVr7tMFdgWn/b9v5KBFS0J0O2QdGuMrdyn05EZCQ9i8FYZJcD5iClZ8PXOlkDaV0LBL/bGOTt08HMd77yoS/D4CROdDr7aOE4qvX3rPocEkjBlICC2FyjsRKgkLNlEE= Received: from SA1P222CA0023.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::15) by BY5PR12MB4211.namprd12.prod.outlook.com (2603:10b6:a03:20f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32; Mon, 1 Jul 2024 17:48:28 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:806:22c:cafe::a6) by SA1P222CA0023.outlook.office365.com (2603:10b6:806:22c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33 via Frontend Transport; Mon, 1 Jul 2024 17:48:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Mon, 1 Jul 2024 17:48:28 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 12:48:25 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , "Robert Richter" Subject: [PATCH v2 3/5] cxl/acpi: Add platform flag for HPA address translation Date: Mon, 1 Jul 2024 19:47:51 +0200 Message-ID: <20240701174754.967954-4-rrichter@amd.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240701174754.967954-1-rrichter@amd.com> References: <20240701174754.967954-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SN1PEPF000397B1:EE_|BY5PR12MB4211:EE_ X-MS-Office365-Filtering-Correlation-Id: 739c98c4-4f18-48e3-c057-08dc99f603bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: jXRG2Gmh0rGf7dbZS2fCK94dSrleT71TJ3VOfFwR6d0c+nD24FXRG9xmAQTxVB3ZmbUrzlioYF4NO3SVylFXZwax3CWVDcaoXel+2iKOYTxMQD+H/13OM85bi/2s3zHBTZvg8O4gGoNlfwPAbSZj3KoHKQ5vbSzQpqe+cuYqt2fjOJeQPW8JokLK9H/XvmGbU1VJiedDqIm3U8THWL/3B38WHAREymfp1qWQzNmf2hXOuB3LAz9jhGLioWUZ43VjMt9vacFiiuaIsw+rB1QmGoZrQqptoouYSBmumod/NFKzosu5y5WygFXOUubrWaSmA6rQGfxI3GQZHSqQeeDbg9YTpiE4beXzEZl05RZwFhVtXdkfmyIyj4jlUgP8bBBoWDkuOgBxzMsbKGZ9iAkLbLeqgKarCatMQsq0sFu9RV7shKSv7kkGStmuschHnypr/6To+CKVte5eeK2g/2SJ7HeZ8UzqgJcf07nbSuCOUXlKtos9s7GngLqn30uVR8Z6jgWhf34YYl2gFK13upCVoCSEzpqJ/C/V9cUpk/++qwIepowUX1dYoSsoYL7e7+sjnlyXUnNSoyXSJYDmT0ajadTELjXoYFnCdvSVgeouR/QoUCoLsc1GNz1f55B+/4QLl1bCf0gx/lu647xCy7izd0faFlaS3jwGgWKt1XU4Jn3LvnFS9ZbYz/C43/4P7Rg2ib4B6L2jm18B+Dabbr7nT0vwNZ1HlGO2nU9PDVEMRCiklD5Kt1VY4RW+sRR225vdbdqT1GVonYPHZzAhp1MBM49RV7xHbTSsQ+uteu0obmddR6Pm8DZh11N9r2Iu8YJXWv3KXGCxHS9u0qwmArK+cjZD0J0MG2uIYgex3LEt1xcHn+ViAIG5Sk4DGLCl4GrpSw1c2AJilLFLhIjdxZGxXFBvpL3VJGcEdnGXJe/UERYFK85/IHcw9aHwT73gqEl+6IwF2MSV5PzKKXQX/dlNwvTxEBtPZMRg84LO+zSmTwfafA60Hq4GIN/IthBbF2J+kC8yenllg9zkjiMNf+ABkJjMTOgQJ4pFpUU8diBgw0UYbFhwY714ULXPOcSbK0hIdk4VxrtkBOuqzY0cx0Pg3+NvyTgcXHNAqRt+g8jvPbORbnYo9ieD+ScQDlHUgzTjLZiwt5dT8xkjAmbmbqeGqDOOW2w7rX/1PjdkJ+FX83vpv3pKdYlziPJ41GUuYvvex+thJ78LXZYDrO6So5ZBaVnDDyUuJC1SonlQYldhN6onbz5dJJAWCZa+6vWCywWEAQjTOJrD/EVjRTW47foHNbq2sBfIL+r4/0vATX1E7aC3omd9NAMCs0IvtXw2p8cH8LGEyJqUQPsvwhOda6H6lb6fQA36ty/1WjxDtBW4ypxcAhx/vdhKN1AAKqd+3QQTgLtBhPUdhC874Ym2uNcCbw== 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:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2024 17:48:28.2627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 739c98c4-4f18-48e3-c057-08dc99f603bb 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4211 Adding an early check to detect platform specifics to (later) enable HPA address translation. The cxl_root structure is used to store that information. Note: The platform check will be added later when enabling address translation. Link: https://lore.kernel.org/all/65c68969903b1_afa429460@dwillia2-xfh.jf.intel.com.notmuch/ Cc: Dan Williams Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 7 +++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 571069863c62..67f73a831bd3 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -536,6 +536,11 @@ static int cxl_get_chbs(struct device *dev, struct acpi_device *hb, return 0; } +static void setup_platform_quirks(struct cxl_root *root) +{ + root->hpa_xlat_enable = 0; +} + static int get_genport_coordinates(struct device *dev, struct cxl_dport *dport) { struct acpi_device *hb = to_cxl_host_bridge(NULL, dev); @@ -838,6 +843,8 @@ static int cxl_acpi_probe(struct platform_device *pdev) return PTR_ERR(cxl_root); root_port = &cxl_root->port; + setup_platform_quirks(cxl_root); + rc = bus_for_each_dev(adev->dev.bus, NULL, root_port, add_host_bridge_dport); if (rc < 0) diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 603c0120cff8..95d054dc1af0 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -627,10 +627,12 @@ struct cxl_port { * * @port: cxl_port member * @ops: cxl root operations + * @hpa_xlat_enable: enable HPA translation */ struct cxl_root { struct cxl_port port; const struct cxl_root_ops *ops; + bool hpa_xlat_enable; }; static inline struct cxl_root * From patchwork Mon Jul 1 17:47:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13718503 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2052.outbound.protection.outlook.com [40.107.93.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2E0416EC19; Mon, 1 Jul 2024 17:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856117; cv=fail; b=UbLouoT1d8ie8QXLHKgIAXb0DTVD/KF2CGLWJRqjWyHJpZOSC2m8LnxcTPxq9zJ22cIOkFxfb3SRq3ngzDcCd0JTjCGHIK0zHzQldHwCjeaPPF3IJ+RAM1HRyXN+XlThTvpFPVzTiXKeIrKnnsyyRYJWe8dBbwlM5X7RkW2dWsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856117; c=relaxed/simple; bh=i1Isd+rAPjpLFj73cHX5Iy78ewxgsubyerpMCUB8Exg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZirtSsnmGsupHT39nH0r1bmSlvPxkuB9qYOh6mbgSZomKjZGSPGAntlrJkQ9apsXiGG98jOC5FawBDjBL+pnWfHqKl9RvZ29jcbE5HGWRahAaiDtiq41gv9Clu0TfWm1L8pSrIdNZfyiwfpeFCsccD7LO+pS5pFU5gQdSj0LKaE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wi3L4vSj; arc=fail smtp.client-ip=40.107.93.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wi3L4vSj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2SO3ziq3KL2n7Of7HLWjwszAPkBvYLI03nqrjzGhZHRQa4Lksc3EyYu4kP0Vt8GlNhH1sQVeYEmIaLf2817ISCBStb82gRy/Gz1i831d+UOcRpt1XVa15luSxd2nyLvPbHWXDiW7qfOYdMjCeilo2ajUzzbvpVLxKi/7cb74wg9anptd+nCqqsj9HV0JZXWo3EznAGV/fYXMINwNJfqPsl2qX2JmheKas3nfuGoiTYe9SvT9eZnlp0vn98vn7PNSKHOQMyZ/i+ln8xcKp7/JF1Wr06gRGEXKXF68EFQphwTvcDe2ikhLsAFdEEDb/1eDg4KiYHJXfs5JJ9PFJjlAA== 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=Xgrn84JS7zg+8EfybpCUjXN8siRMFlFrd5niEZIv09s=; b=m3fP99Xcfe8QQFsf7fwOBB3owo6tGsKGOXt0V+UODXHYN4SS/eyzUIjqlgg8xyQj4ajH41xVdEpzJ9HGFVI/tlS8hgkornsZw0TTMfH/URseqsNLcaJNy6XLCHT8y/4GLEVGLxyG2vVu4G9r1HAxXF6o1503P3j1wKVkqycVKc3EsUE4+ED8VhIBKKshyVISBDg+rFnJTJjmqzKCAIt1fySGW87BSx9UihhHTl1M63mkStkI2m1UJ3YmDebBBpgYnnoWPVLW5hdA/GG4VV1+nQ4lq3AJCSkcHakBTnpm+wZbQh4psURPbJzQa5qSLnFeWI9HhTPXkhIhD+B5w2aavQ== 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 (0) 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=Xgrn84JS7zg+8EfybpCUjXN8siRMFlFrd5niEZIv09s=; b=wi3L4vSjVM/B074EAEx928eb6vHO1iJRN3YSsnJjYU97hhjnHp8iHcNqAuFmBHYhJWnbmOk/oRVzvjITOGFgGlNhUOwQnsX99UwlGhBnXMIVF3vIuYaSYEexAwWAnikA+RHxo0N4roSCtTDCtPkls53IF0TvBs5co/W0COgseRo= Received: from SA1P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::24) by SN7PR12MB8817.namprd12.prod.outlook.com (2603:10b6:806:347::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Mon, 1 Jul 2024 17:48:33 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:806:22c:cafe::89) by SA1P222CA0029.outlook.office365.com (2603:10b6:806:22c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.33 via Frontend Transport; Mon, 1 Jul 2024 17:48:33 +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 SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Mon, 1 Jul 2024 17:48:32 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 12:48:28 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , "Robert Richter" Subject: [PATCH v2 4/5] cxl/hdm: Setup HPA base for address translation using the HPA window in CFMWS Date: Mon, 1 Jul 2024 19:47:52 +0200 Message-ID: <20240701174754.967954-5-rrichter@amd.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240701174754.967954-1-rrichter@amd.com> References: <20240701174754.967954-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SN1PEPF000397B1:EE_|SN7PR12MB8817:EE_ X-MS-Office365-Filtering-Correlation-Id: fd4a8632-51cc-4b16-191c-08dc99f6067b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: pTdL0kt00QjL6G2HPW4gavFqFbWhCX3hVqQO/Jxm6qdlGN40JmCYDXvqLXHto1xs5xJVssephvFLTxX8YgRK33fccIfzqsguEtm9RB55Li8Ug8g7v/gazoJdxA02JAUTnKNzYaEc0aUy/8fVjal+85Ig2jP2yz6dDS7pSGEbYufyOjz0FZ2QPX9VtAeQNVXdK4HKNF0fADJL1LwmOUOkI5VHPyONtK8jF3hY4q7Xpax1vj1OhlB5AIca0c+xHTRjq0EOKULNXOdUBUfCccxDWWurM8uPpnK18uWhWHxH3i7ogcmTpYxFOY3GVv5CYRcn9oMSuAJPlLvnK/TxEVZ4tvJezYfzez2QNj2r99JuOb/1HdpYUYuvaPNuyaOVwrc1iOzxk4ESPYE6OHnLs3+DVeHI3e/0sGwt4h5SH8Aa/LoSknJaA3RCAJBqfQbiCf62UfepJVk8HJSjsPFnHkOPhFkyqoNn8tuqAlrR3aXsuRqNIMhJ17GdD2GoBzDhKca2wCEtUhL9NUG+h+k1VYH0r0AhGx0fkCDSLXG/sfw7Em3CeQW49xovz1jnE+NKUgeJgbedhcmtafb1OysI6qbZcmBmA+P89JKE17p2mE1nigNbJOtL2zs6Rsws2m5p88TL7ff7zG+Pz60XMyOk3Zm9ElOkhROywvVl54522mhMXWmDuiJDl7KzLZUoDW48BfmVkFiedN9AhSSvnxiXMsdnezISXXebgtzTIYEwHPwHBCY0P01xPCutyhfLO7AvMx6ig0f7ImzR/rVbdfbELrJB7mUVxKSDZU85anpcnTWqTNgzD2m0Wu/rje0w9CutshhnhPWjpZqMX1JJ8KY7cIiL1MBFBF1z1jZCj7eOl7shR98L4mIVWs/B8GypD0LZ3kXtL74nHE1gYkl+NFmfW5E0GF9x+KfXeohwMGFu4ER1OkbZMKDxsYw5xl14jeKH4hR8T5+43mTYtYNTmm+fKTEiDcJB85QMA8I7p6N3pOGddQhmmeNE4BIJxofPfdZTXFQg/mKhTG10C0nmy7N65zUhDCpq83xSUrF+yI6C8lb/fZlnoip0Z75AdSpgQyrRUkcgXqfmh6O550zKxnuVnom9SfLg401xDkS2VgMlsBpOG5izj5WzOK7dBMwdfYV70FSN6T/CEpbJ5UzXIRLNO4uhxuGiMEGN4p+SPZbmPxOWz8Xa3xPL0dfL4LeNjTeJMGPSU/p40pi8hhasphcnTuCrTcPsMvgkr9xAYOlQSm+P2mcVkOyifODvpxuaVXkci/zZGjoPQMbWZIg6zyMBWsZNapGraZdgKL/lQmqjQxCLKky9ypKyvXcv2UoMjY6UO5YputrbNxXvYkrB/oMdEzYx2vR69AGpgGIkp6YYcXhFomRW6KY+NzrxO0w77YONN5m2jlT2w4QTsqSVZJ0edulSQ1w9DivViSPuV8C1dwY8MiEdPu8wb/LeJdGG4qTk+5sJ 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:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2024 17:48:32.8721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd4a8632-51cc-4b16-191c-08dc99f6067b 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8817 There are platforms where an address translation between decoder's (HPA) and the system's physical addresses (SPA) is needed. The HPA window in the CFMWS can be used to determine the address offset for the translation. Each CXL endpoint or switch is uniquely attached to a CXL host bridge. The host bridge is assigned a unique HPA window in an CFMWS entry of the CEDT (host bridge is in target list). The hardware base addresses of a CFMWS is an SPA. With that, the offset can be determined using the HDM decoder's base address from the registers and the HPA window in the CFMWS entry of the corresponding CXL host bridge. The CFMWS entries are parsed during host bridge enablement and set up in the CXL root decoder during CXL decoder enumeration before a CXL endpoint is enabled. That is, the endpoint's host bridge's root decoder can be determined. The HPA range of it marks the beginning of the HDM decoder's base address and the offset between both can be used for later address translation. Setup HPA base address (@base_hpa) of a struct cxl_hdm by determining the offset as described. Use the port's host bridge and CXL root port to find the corresponding CXL root decoder containing the HPA window in the bridge's CFMWS entry. Only enable this for platforms with the @hpa_xlat_enable flag set. Signed-off-by: Robert Richter --- drivers/cxl/core/hdm.c | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 50078013f4e3..5164ff807537 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -125,8 +125,73 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) return true; } +static int match_root_decoder(struct device *dev, void *dport_dev) +{ + struct cxl_switch_decoder *cxlsd; + + if (!is_switch_decoder(dev)) + return 0; + + cxlsd = to_cxl_switch_decoder(dev); + + guard(rwsem_read)(&cxl_region_rwsem); + + for (int i = 0; i < cxlsd->nr_targets; i++) { + if (dport_dev == cxlsd->target[i]->dport_dev) + return 1; + } + + return 0; +} + +static struct cxl_decoder *find_root_decoder(struct cxl_port *port, + struct device *dport_dev) +{ + struct device *dev; + + dev = device_find_child(&port->dev, dport_dev, match_root_decoder); + + return dev ? to_cxl_decoder(dev) : NULL; +} + +static void setup_base_hpa_cfmws(struct cxl_hdm *cxlhdm, + struct cxl_root *cxl_root) +{ + struct cxl_port *port = cxlhdm->port; + struct cxl_decoder *cxld; + u64 base; + + if (!port->host_bridge) { + dev_dbg(&port->dev, "No host bridge found for port.\n"); + return; + } + + cxld = find_root_decoder(&cxl_root->port, port->host_bridge); + if (!cxld) { + dev_dbg(&port->dev, + "CFMWS missing for host bridge %s, HPA range not found.\n", + dev_name(port->host_bridge)); + return; + } + + base = cxld->hpa_range.start; + dev_dbg(&port->dev, + "HPA translation for decoders enabled, base 0x%08llx\n", + base); + put_device(&cxld->dev); + + cxlhdm->base_hpa = base; +} + static void setup_base_hpa(struct cxl_hdm *cxlhdm) { + struct cxl_port *port = cxlhdm->port; + + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); + + if (!cxl_root) + return; + /* * Address translation is not needed on platforms with HPA == * SPA. HDM decoder addresses all base on system addresses, @@ -134,6 +199,10 @@ static void setup_base_hpa(struct cxl_hdm *cxlhdm) * == 0). Nothing to do here as it is already pre-initialized * zero. */ + if (!cxl_root->hpa_xlat_enable) + return; + + setup_base_hpa_cfmws(cxlhdm, cxl_root); } /** From patchwork Mon Jul 1 17:47:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13718504 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EC9816F0D8; Mon, 1 Jul 2024 17:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856125; cv=fail; b=E5mRXSb7OaIwEa/bR8559h1KRLrzw1CMju03+TgMDfhMSfcGrsejPkEcjmj/oOvt32S7fpA3XPLGHM2kUgpRtVOrKCUpRaucAQD6/jeD+E5idQb+Fa79n8HaFCtKY9r/p3SliDWvuc1mlQFjonJ20bWqK922w/15WM9IR8ND2Nk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719856125; c=relaxed/simple; bh=CpM7Vs/2nA21lLEDS5zFQlDltZxLar1+tK60xO2Z7UM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ThkaeS6c+L+zY/Pr4LXtG3qII87PD/7ftjEUfy/BMa7H8b61sC+iGEFzFT7sM5FP6moltC2FObR1dJn3uHA4CjYsyO/UBpv13UeMpyCgBuyMhJArS4rfgt9BMJFJuX8MGNjmsjeiKfI6GIXHTSPNZFIJUf+lDBDCYyoL74gj774= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=cIRl8WZ8; arc=fail smtp.client-ip=40.107.223.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cIRl8WZ8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mECA10oX69ZoVg6sp6fX9Ii8h+5hJrJlNhIUAKZcQpn7nhoIEf2cOoBT9W+e93bv+6bSrkpexQsW5nkxklvU+87X2DwG6ab+1yhOaBsDpjqd8D241FAdoUKQJ8UqhuihlNoZMHpHNw4pnLSVNYvYUtlvLK5fGigdd9T9TINL18bnTKT1IOvh7Itlvpbpgt7YHPXBrN/pLHJ3Fqq4Lt8mV11VGs4+qOOaqAZY8CJUQI0OWnoPG7pfQ/X76Gv85fk+ijxiLcVHQM/0aU+aXoAfpsprcSuDG7rv/o5WpzJvH8cXevh0enTqAf/XCEaRP+DFxHQkDkRoIiHhCvWKWCHakg== 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=OwPOFx61JWJuphJdc/uphWuP+jljOvmMztOko9/5wN8=; b=gwV9iYVkSbYyEHkbXFu+LJxlpo4NwA3025+Kctb/pJbZoiIKRTFpJSMiZ19ra78GQklysXSQYJdf665y/riSvvfJZdIaq8u9XYQW/VtmJXLRTzES6Jfny2c5hGqs0wTPcv8rvaDgjZVB47jzQD2FojT1NGwO8k2bUsE86pwuivMrM1rCQNv6UqvGTJIcjElOoGqCnYSoHqOmL/rqa8H3kInADaACARgpSgKdPknUlC8Fzmi16+TfUvOiAYjumPDmoHvIcQnq6oo1BJG1ULq99JVRTefF34eGyZ5QfG1jvBREX9UM5VUybuXVgtw2Fd+0IRoA+vEe8xE8Myel6fgWsg== 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 (0) 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=OwPOFx61JWJuphJdc/uphWuP+jljOvmMztOko9/5wN8=; b=cIRl8WZ8w0i3WUvA+iOv/7c3eYmMCMXIqY00ZInZwd1oAeF0Qqt+kq8MrqABIVKgqVGi5UifZR2CGMfEV/vtyODdXRpUBOB88hZZRXLkGp9WT/uaAd4NLboJXHG1UK/HCKSL73ZWPUj1zz19lwP26Chf8EqQxf+2PcrdaH9ABjI= Received: from SA1P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::9) by PH7PR12MB7139.namprd12.prod.outlook.com (2603:10b6:510:1ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Mon, 1 Jul 2024 17:48:36 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:806:22c:cafe::62) by SA1P222CA0002.outlook.office365.com (2603:10b6:806:22c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32 via Frontend Transport; Mon, 1 Jul 2024 17:48:34 +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 SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.18 via Frontend Transport; Mon, 1 Jul 2024 17:48:34 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 12:48:31 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , "Robert Richter" Subject: [PATCH v2 5/5] cxl/acpi: Enable address translation for Zen4 platforms Date: Mon, 1 Jul 2024 19:47:53 +0200 Message-ID: <20240701174754.967954-6-rrichter@amd.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240701174754.967954-1-rrichter@amd.com> References: <20240701174754.967954-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SN1PEPF000397B1:EE_|PH7PR12MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f1de2f4-4636-4d60-ac68-08dc99f60770 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: z2a566AnEd7FNnNDOLXe/K2bODuV3UyWi5ng+5LVsz2RNWTMhzQ9bNoHhipSJh5WSDEFSEd4/e0z4+a+HpMpzfhsj1lmw/Oicvq3Lz3ax2mLjj2wMG2+hbn8Yk+7zgWU1ZbbHS01AYoWv8+GCc7a10GAX4JDZ8sVzm+BZpyk/g3F2I3sbnAuhJXTUvFuGghGoRKwGuKTyDyqRmFZnNzmqTXD5RXgOhqDl9ekzkBFSGT9z1zATfQVU1/BE4l4SPNzd8QWFSj3HGH0UFTMD/9hYm75ZISKHWbJizitsbwfFF71Ktl28BGOLjDAGD7lDT8jJLWpBu6QxRbUNZu1NWBaGDakvELH6OCPCsBe20Ds+/jgHCmKclQLKCei1lZwu6Z4t5SU0XySl1Y2zkYnmF48Zjki+0sL1FI3hgND5cPq2qo0EU+JYlsBRjNLnWvkJvCgQhqdaU0z5qfM6R+RjGSF1ma4YhDLFV8ejLsuElmnwEbpK4kuHeEEQZQl+Y8AAbfCD0HuA7SUZoeKpEEz2m65JtAgpf4qcDyOjCdAAIEM/RswS2IK7ND5yr/UBqXM748ZMmlT8bNLOelJqs6OcQQ3RUqnXpEhf6UmpO5gQLEqFINXG2I/yssuWXrv08pgLwrTKqhUKM5rtrP+ogR2vFUiYc0Q3I9RjpqzBXeEivyMg7YyyLSLKPTdtkvAcJyyrsZvaqWKVP0hpvU6Aya0MFDTOXnqQSlf5nIvYLbOWswXlgW9/nRSSyQJlNNU73cu6HURbwTtNaFoLhcqbIHPg/7PeX35Chc8/4Z8YNuWc4XzfNRzJgRhXJNz5g6ORSS+HHEctIfMm28WWe4Ljizakot73WWKjONrR1FttepvSTsnXvPxzIIfALh18eAVvBv0A7W50Tj0QWlhGdmMzajqXWMVWUu5S8jNMrIrDzATw56+PqH96f/FZRwnmPBtBd6BAqE2Cqm6zsf9VJ0CwbBkKqB6zBYgAoVq4ARESmtmeR8Wc+OXPYaw4n78xeB2opkiF15/snIVVRKPdN0tPKsokGNErMhZ7yKG5Ga1wHmbW9huPlL/glkfbCGjKABhG4RD+mykGxbbvpN4FDVSricJyTKPKMhN888VwGDck7s85+cBsTk6ErSHZnmmBlPuGbguRHGTLIF9NzFeKW3xGtpFzPKWXq8fb7TUWDODnjPUl2oYF+6JMIt5bQlk4x9VlZomnAHCdYUGh5UUX4w/U0hmwO2PTyZT+H0xWH60JzkcbfBK2/GC7rtdfsLC18W1zNvmZeGGaU3eEtjCp1xAsiE4AQrbtvvw4vDo01CJsEGg626KDzzg9R8HbMEelq3w7GGhLsgBwISlHlMqWJRpvfz5vm0Jg3bSbLLOQ68v3mTlcZoABHLEozxWkJ2CdmHnW6gGeU5BEuraIPr9gXOeZ3DX/s+rlw== 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:(13230040)(36860700013)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2024 17:48:34.4659 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f1de2f4-4636-4d60-ac68-08dc99f60770 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7139 Enable address translation for Zen4 platforms. Link: https://lore.kernel.org/all/65c68969903b1_afa429460@dwillia2-xfh.jf.intel.com.notmuch/ Cc: Dan Williams Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 67f73a831bd3..70fdb806016e 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -11,6 +11,10 @@ #include "cxlpci.h" #include "cxl.h" +#ifdef CONFIG_X86 +#include +#endif + #define CXL_RCRB_SIZE SZ_8K struct cxl_cxims_data { @@ -538,7 +542,12 @@ static int cxl_get_chbs(struct device *dev, struct acpi_device *hb, static void setup_platform_quirks(struct cxl_root *root) { - root->hpa_xlat_enable = 0; +#ifdef CONFIG_X86_64 + bool is_amd_zen4 = boot_cpu_has(X86_FEATURE_ZEN4); +#else + bool is_amd_zen4 = false; +#endif + root->hpa_xlat_enable = is_amd_zen4; } static int get_genport_coordinates(struct device *dev, struct cxl_dport *dport)