From patchwork Mon Nov 18 16:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878862 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) (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 254C61BDA8C; Mon, 18 Nov 2024 16:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948291; cv=fail; b=azUOPlHtszUSxtFmeBQlx4uWwV7/0qREb1lH7Ul7mTJ5ZWj+emvngMlOg5JJBxCMaMTsrTbrrWnX3GhGgX1TRJszd7UBQVl1dxpvHpIAo+R7d+s7JnajhMEPQp77KYrLg1/JRsBazr7u+4F75/61N5GFz3ceAPh2pTMqWr8i2Qc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948291; c=relaxed/simple; bh=jiV93matfl+5luOOZpVWubepIWkWlQi4HO+DxquRdL8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ULmkfU9MXQlyeYErGe6FEIbH/v9LESdSB/Sm+tqJoo91WOZn/htGmggFMLdovRxAEvdy5RWxnGcyZe6xp7DliAiYHzjvcWvW95uooUGVbhqMKV9GiqWaKLDq77niefi4KZ4GGbDy0+KvAy99at1uoRizH59/Cf+OIbz8xVzOnEU= 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=KZeXl5gW; arc=fail smtp.client-ip=40.107.93.73 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="KZeXl5gW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fqvbTGQKtNiG7BCaclEs3MTvKj04BfZ1wFrTIfRU6oZmogMHvyBjCLBBMEEGjyvN6hHwFP7RcSSegBntyAJj8buMyCFgIGMTDzmq2tBG/MVRMBtVQnYQ85qelceF5nKo81iKyRRtsqh0K4FhVZfjYck1hc261NqUcVwMlkf6HeKPIRxfybvy9DFmcp9d7998UZOyh5hSFp9cyDmokg0CrcEbVr9i5oFZv2dgLmhg/ucJfzAsmQ59brZuLQiTiKZxFPj2M8TsWpeWqNGxlPOVIOYYUIt+ER9HZW/2JyHu/6obCMjkg6/NN9p9CXORQRnbWaMH1/8uvm6qb33j7FGZng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F/1sGgI0p0Ba3uyAscDtlaUYBJMXgMq2Dm+Xd3OWci8=; b=zRJEzO26YObd1MrfRkDjdrqFtGMoeMAawGZksA17EEyR5OAVNY97M+pvNiN0DzaIl/n9kBwTpwxWf/i6yedBg1Abc8FdB69xLJh/3mfFp84ByqyOKgQp/4ug3meAABMkJdUIJ+76VcA3pKrw+0ZWWX4Ye9cZNZt7w8hCRPWcL50TQlmN2xLui9keeEmJwzEynbdbjRUB8DPrLry+WEEB9VGBUKD4yjyANL6owQB48bOLp7wgW0UTQuaCeSyAdGJ+NpCaZbussTtVxdbIVbDPzCwA9BuhbmYOzW5P8NicvVva5OR8WBmsEMCWSTKO6jVCDYXmoiTb9rOpzHXXypwbJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=F/1sGgI0p0Ba3uyAscDtlaUYBJMXgMq2Dm+Xd3OWci8=; b=KZeXl5gWmnuhLigIKjO781JoL0DlG2GO92yyuv8Pmc5HyAEHW4B5xXIuzrl+nCiWSAzO9FYYy2tzjtb1JscbbyLTHnelpLCn/8XaPJPhBzhh4QPn+/KyUGVDx1s4I672sJyRzANR13WYi7hfRdGtem5q386S+jNZznCsCxMH6ss= Received: from CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) by SN7PR12MB8130.namprd12.prod.outlook.com (2603:10b6:806:32e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:44:46 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::ec) by CH2PR10CA0029.outlook.office365.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:44:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:46 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:44:45 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:44 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 01/27] cxl: add type2 device basic support Date: Mon, 18 Nov 2024 16:44:08 +0000 Message-ID: <20241118164434.7551-2-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003441:EE_|SN7PR12MB8130:EE_ X-MS-Office365-Filtering-Correlation-Id: e1b6c13b-2748-4849-f915-08dd07f04f74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: V9RWlsvCwpApW8oGETKk4+FjynVdjyilwQSCxBZqnMO2WJOdrBxmQysZ/+Yp20baOpDTKX8a7X+eUXm4/7AulOz3i4+fQBPq/RUga576ZChtiTQPuyN+SiLk8eKsHUqlSx3OmdBKr42NGUK/ceO5gh4PEG6ISMYsnRh6hesPYj7M3fSjCGfkERWqu5qlR6T/eF/QJnbRrGerQlCL0xFVSKQVJ+o8d2Flj4/fKn5Yt0whleFKSRxuln3frEME/bvxPstyBzzWf+IWKE3CajS9a+9qJAvLsjCqXGkpleUVfPR3xErGQTnhufY8MSurJQTvXgGgTaJZEnLctXiFTx3JplIBNQRVht5/RRBneR8PTOggTZlW0JDo8wTJ2vKZx+2vdgA68Q1gQunGzoUTb2dVG6Fp/lPYPxautI/dLdGvJWH1zJPn5cc2iRuaeXk8xYaid6Fs9/xwWBSp0c6xFOzYqdA/WoiRRzpKhealn+UYBRPTFP7k0wOuc0oRdn8ONEMm7BhrtvQHxg+J2LuzdDXLx6Ual735l59a5N2IUr/4uz9/ZwR3Am0t9/NRhtKzdX6Zrcwtpu093M4AjuwMTJd69AD0eYlYZzuBYRfwQoUYLXlc8UH9D4JektDFldV6RmA9+N2fEtPIg9P/21BEIuPC12C6CV6cinYKOou5Q1mbSm+IZ1X4+peQ55tr4pEFCebE8cBAaJGR3hCngNYETK1N/EaJjZNgNnVGKbfCnVTttPwsq+J7DU4PJVhQoqZV+ilKl3aQ0eE/abSSPciTpd1kpjgzhY8ILPwTuAhWcRilEvwCuJKC0Rhy0zcMWHbekB4Tc8p74hTeEflD0Qd6x3rrqtbd0lbH4gFIoP1wRAgVpLlMqFLYPCzKLH8xIOyy0IOOXp94GF0rWITvfpHSHcKppQ938Ecl/5Qdy70GS07XXIt0lL/C7/j3rlnhm5qnn3CsrLqm8QKSklqQosg9iRSvguEi4NdMKEvnZkNOKdilCZih+Js4adOVo77a3BCA1TIontfto9DrJyAknrMycoZbDwZwlEmvJWLcZhsdCHGBTEXPXqLwsHDoFhSCDQNjxBaPzIMHH14GvdpRJJ9/wYHjG/smUxE5T0nPL3Vyy6SpzNyq8vDlRb4SDxVlOJYFbek/XqOquCf5JL84+bx6ANe3A2X+ST5RxD9tzNA8EfFiDIzxteBaGNCWqNt6tm3I9L+z/Ozji+RfkV18N9C+Q1wga56zEaJ9Yab7m/66mYhpAjh35YAFw7fe7vOTKqg96DxZRvPnKFGeqReYxJLcFDH/26UqwHaSxIuQh76tdzcOAyJOCnHJbkHSugDig5rqCd591mG7Ss5eK4INgrsJEashidllY2/4rCO8BuDsJ/0epkv7gXFiBaZQRySjYiFOQ9yKlTXr24FhQpZVsvuvf90l2g== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:46.2152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1b6c13b-2748-4849-f915-08dd07f04f74 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8130 From: Alejandro Lucero Differentiate Type3, aka memory expanders, from Type2, aka device accelerators, with a new function for initializing cxl_dev_state. Create accessors to cxl_dev_state to be used by accel drivers. Based on previous work by Dan Williams [1] Link: [1] https://lore.kernel.org/linux-cxl/168592160379.1948938.12863272903570476312.stgit@dwillia2-xfh.jf.intel.com/ Signed-off-by: Alejandro Lucero Co-developed-by: Dan Williams Reviewed-by: Dave Jiang Reviewed-by: Fan Ni --- drivers/cxl/core/memdev.c | 51 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/pci.c | 1 + drivers/cxl/cxlpci.h | 16 ------------ drivers/cxl/pci.c | 13 +++++++--- include/cxl/cxl.h | 21 ++++++++++++++++ include/cxl/pci.h | 23 ++++++++++++++++++ 6 files changed, 105 insertions(+), 20 deletions(-) create mode 100644 include/cxl/cxl.h create mode 100644 include/cxl/pci.h diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 84fefb76dafa..d083fd13a6dd 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2020 Intel Corporation. */ +#include #include #include #include @@ -616,6 +617,25 @@ static void detach_memdev(struct work_struct *work) static struct lock_class_key cxl_memdev_key; +struct cxl_dev_state *cxl_accel_state_create(struct device *dev) +{ + struct cxl_dev_state *cxlds; + + cxlds = kzalloc(sizeof(*cxlds), GFP_KERNEL); + if (!cxlds) + return ERR_PTR(-ENOMEM); + + cxlds->dev = dev; + cxlds->type = CXL_DEVTYPE_DEVMEM; + + cxlds->dpa_res = DEFINE_RES_MEM_NAMED(0, 0, "dpa"); + cxlds->ram_res = DEFINE_RES_MEM_NAMED(0, 0, "ram"); + cxlds->pmem_res = DEFINE_RES_MEM_NAMED(0, 0, "pmem"); + + return cxlds; +} +EXPORT_SYMBOL_NS_GPL(cxl_accel_state_create, CXL); + static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, const struct file_operations *fops) { @@ -693,6 +713,37 @@ static int cxl_memdev_open(struct inode *inode, struct file *file) return 0; } +void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec) +{ + cxlds->cxl_dvsec = dvsec; +} +EXPORT_SYMBOL_NS_GPL(cxl_set_dvsec, CXL); + +void cxl_set_serial(struct cxl_dev_state *cxlds, u64 serial) +{ + cxlds->serial = serial; +} +EXPORT_SYMBOL_NS_GPL(cxl_set_serial, CXL); + +int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, + enum cxl_resource type) +{ + switch (type) { + case CXL_RES_DPA: + cxlds->dpa_res = res; + return 0; + case CXL_RES_RAM: + cxlds->ram_res = res; + return 0; + case CXL_RES_PMEM: + cxlds->pmem_res = res; + return 0; + } + + return -EINVAL; +} +EXPORT_SYMBOL_NS_GPL(cxl_set_resource, CXL); + static int cxl_memdev_release_file(struct inode *inode, struct file *file) { struct cxl_memdev *cxlmd = diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 420e4be85a1f..ff266e91ea71 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2021 Intel Corporation. All rights reserved. */ +#include #include #include #include diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h index 4da07727ab9c..eb59019fe5f3 100644 --- a/drivers/cxl/cxlpci.h +++ b/drivers/cxl/cxlpci.h @@ -14,22 +14,6 @@ */ #define PCI_DVSEC_HEADER1_LENGTH_MASK GENMASK(31, 20) -/* CXL 2.0 8.1.3: PCIe DVSEC for CXL Device */ -#define CXL_DVSEC_PCIE_DEVICE 0 -#define CXL_DVSEC_CAP_OFFSET 0xA -#define CXL_DVSEC_MEM_CAPABLE BIT(2) -#define CXL_DVSEC_HDM_COUNT_MASK GENMASK(5, 4) -#define CXL_DVSEC_CTRL_OFFSET 0xC -#define CXL_DVSEC_MEM_ENABLE BIT(2) -#define CXL_DVSEC_RANGE_SIZE_HIGH(i) (0x18 + (i * 0x10)) -#define CXL_DVSEC_RANGE_SIZE_LOW(i) (0x1C + (i * 0x10)) -#define CXL_DVSEC_MEM_INFO_VALID BIT(0) -#define CXL_DVSEC_MEM_ACTIVE BIT(1) -#define CXL_DVSEC_MEM_SIZE_LOW_MASK GENMASK(31, 28) -#define CXL_DVSEC_RANGE_BASE_HIGH(i) (0x20 + (i * 0x10)) -#define CXL_DVSEC_RANGE_BASE_LOW(i) (0x24 + (i * 0x10)) -#define CXL_DVSEC_MEM_BASE_LOW_MASK GENMASK(31, 28) - #define CXL_DVSEC_RANGE_MAX 2 /* CXL 2.0 8.1.4: Non-CXL Function Map DVSEC */ diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 188412d45e0d..0b910ef52db7 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2020 Intel Corporation. All rights reserved. */ +#include +#include #include #include #include @@ -816,6 +818,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct cxl_memdev *cxlmd; int i, rc, pmu_count; bool irq_avail; + u16 dvsec; /* * Double check the anonymous union trickery in struct cxl_regs @@ -836,13 +839,15 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, cxlds); cxlds->rcd = is_cxl_restricted(pdev); - cxlds->serial = pci_get_dsn(pdev); - cxlds->cxl_dvsec = pci_find_dvsec_capability( - pdev, PCI_VENDOR_ID_CXL, CXL_DVSEC_PCIE_DEVICE); - if (!cxlds->cxl_dvsec) + cxl_set_serial(cxlds, pci_get_dsn(pdev)); + dvsec = pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_CXL, + CXL_DVSEC_PCIE_DEVICE); + if (!dvsec) dev_warn(&pdev->dev, "Device DVSEC not present, skip CXL.mem init\n"); + cxl_set_dvsec(cxlds, dvsec); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); if (rc) return rc; diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h new file mode 100644 index 000000000000..19e5d883557a --- /dev/null +++ b/include/cxl/cxl.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2024 Advanced Micro Devices, Inc. */ + +#ifndef __CXL_H +#define __CXL_H + +#include + +enum cxl_resource { + CXL_RES_DPA, + CXL_RES_RAM, + CXL_RES_PMEM, +}; + +struct cxl_dev_state *cxl_accel_state_create(struct device *dev); + +void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec); +void cxl_set_serial(struct cxl_dev_state *cxlds, u64 serial); +int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, + enum cxl_resource); +#endif diff --git a/include/cxl/pci.h b/include/cxl/pci.h new file mode 100644 index 000000000000..ad63560caa2c --- /dev/null +++ b/include/cxl/pci.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2020 Intel Corporation. All rights reserved. */ + +#ifndef __CXL_ACCEL_PCI_H +#define __CXL_ACCEL_PCI_H + +/* CXL 2.0 8.1.3: PCIe DVSEC for CXL Device */ +#define CXL_DVSEC_PCIE_DEVICE 0 +#define CXL_DVSEC_CAP_OFFSET 0xA +#define CXL_DVSEC_MEM_CAPABLE BIT(2) +#define CXL_DVSEC_HDM_COUNT_MASK GENMASK(5, 4) +#define CXL_DVSEC_CTRL_OFFSET 0xC +#define CXL_DVSEC_MEM_ENABLE BIT(2) +#define CXL_DVSEC_RANGE_SIZE_HIGH(i) (0x18 + ((i) * 0x10)) +#define CXL_DVSEC_RANGE_SIZE_LOW(i) (0x1C + ((i) * 0x10)) +#define CXL_DVSEC_MEM_INFO_VALID BIT(0) +#define CXL_DVSEC_MEM_ACTIVE BIT(1) +#define CXL_DVSEC_MEM_SIZE_LOW_MASK GENMASK(31, 28) +#define CXL_DVSEC_RANGE_BASE_HIGH(i) (0x20 + ((i) * 0x10)) +#define CXL_DVSEC_RANGE_BASE_LOW(i) (0x24 + ((i) * 0x10)) +#define CXL_DVSEC_MEM_BASE_LOW_MASK GENMASK(31, 28) + +#endif From patchwork Mon Nov 18 16:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878863 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2073.outbound.protection.outlook.com [40.107.94.73]) (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 867971B21A0; Mon, 18 Nov 2024 16:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948293; cv=fail; b=MLhYakMNu+LUG7i+l+l9GhMT5KlzflBSVqVVttM/RdKxmS832GYErqXtRbcDU1BoLvFlj7IATUJMKwTVm7BSDE/GDTozEaLoyJt2rC4bl0QD1pqUaReqRvquTFh+zoNEWaipXXkEMi1aFraQcVONjqsMFoJggL2s6Y/WK9jJ88E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948293; c=relaxed/simple; bh=0sYwz+JHrLWQ5FurmU8K7G/8MFpuLgz6QX9rmhIpZOg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kB6FEplg53ln20xuyBHb8kqEjeUkmYpKrT81iaq272cGeD3pcsgD14goYTCBdMlnCHos3b2iEswQY3QMXjP3QwiTAVMZwuWjPprh+ibm7jCX0kNdk97Ds1EUl7sxB8rxRa1OyPCIPo96CxFzu4HqR9VRuto0tzLO91k9e5k2tsc= 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=1EXggiWX; arc=fail smtp.client-ip=40.107.94.73 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="1EXggiWX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x7J7U5cSmGF0qLWARi5yxbUm5+oS+BWkK/ptzJMkiZb+obCNfy4BTY3Ph/k90PHpof7AV88f4tpkJVUhfC/Fu+mT/Iv4CEbHpOCj9A8/K/ipJr5J04S3EW/uOS1BsbzuJEtcS4VlDScFK9EChAMlDJddYp/E/E3yr9+1b4YlexAFnQRNja2Jrhm9ey7qBK2lrDgVsPO57nOgn9yvbnxq9aURVtkbi006ioHxOed4TwbecR8cnYRmhnrd7roHctWeUUSxqRJmv2BhyyzHiCirE2Io6MtzjCk5s1Sz03Z4dljCf8Hcd094fjThXj7MEK8JuPEdggo2VtG0PrZeKX6bSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Fxq/lDZXwSN9KhVcvG0CjNC7q2n51wlWjAfCmiYHtQY=; b=ogoluNQm348Dzg5dJwtkAOtGn3PxdIcX5bEK7BGjMKKxzqXKs7nYwN+oYEPibrparZdACHUQge92pey6sxJhuSAT6XH2yy+pARjmc86H7Ab+A3BR5J4nJTn+Sx57KD9dp01GI5o5RH7yuuUJP6g79Dseu5xFgPBIQrMm+LZ3DKZGapH7i9CZvJJLHDOrUnCrdyByz+/44f7m1oFCWxjqaKW4Kx3kMyqp9/aX6X0Yjl2wk4QFmlA9W0ae6A9NAASC4wSG/CN4CaaPhczIuXxyQSSBHnZEvxvVFQFsgYMThqVV8ZKHvcnz3ayteEUU/0AyyOvSCb9qXiITSgF4bwMyRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=Fxq/lDZXwSN9KhVcvG0CjNC7q2n51wlWjAfCmiYHtQY=; b=1EXggiWXxxo/d5smuq3BeeNxTzig1r4JQFKXPJlCH7rKJp4CujCIEUdRyZJXF1hcbDu2O5ZBOuEVI7B4upFZ6NXmngL0DWhubVqKfCZTtZf3a2hNWmAcYfMwsUHgz2AO/Es2p3E89/GHcyZKfF94O837C3rKX+KI3ZqbXptFndM= Received: from DM5PR08CA0040.namprd08.prod.outlook.com (2603:10b6:4:60::29) by SJ2PR12MB7866.namprd12.prod.outlook.com (2603:10b6:a03:4cc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 16:44:48 +0000 Received: from DS2PEPF00003445.namprd04.prod.outlook.com (2603:10b6:4:60::4) by DM5PR08CA0040.outlook.office365.com (2603:10b6:4:60::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:44:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003445.mail.protection.outlook.com (10.167.17.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:47 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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, 18 Nov 2024 10:44:47 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:46 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:45 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 02/27] sfc: add cxl support using new CXL API Date: Mon, 18 Nov 2024 16:44:09 +0000 Message-ID: <20241118164434.7551-3-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003445:EE_|SJ2PR12MB7866:EE_ X-MS-Office365-Filtering-Correlation-Id: bbcddcf4-920a-4573-b647-08dd07f05077 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: Z+BmOdhdfwfJt6DHqj2s0EyPqRJeEotPaE7WRXDAt9YVdh2zB5fsUgYCPNszLinrJrudxdXEX5Jnq2y4rl4Q2GVhD/HZfWGuTHUj3q5eVRD40zyAU4qHTSCR6oj3xHZO4gTXy0TnEmSXTUVoj3/SmoXcQUJlBirvr6M325cH1uv0W/mdq7humiDIGMsGUSWmwHl8AYxNxkxtelwKeatZpWnRr7BrEw0zwdnuXfSkMr4dqQf76H8AE7KoYGwLL520YAL+blF4Q5EJyVITHPwDPrX10cKrZOVtMGKqx3RshV0vksClN6GJQG72jc7OcR67WAMfvpnTVVmpnvCt6fEi6GEW0WcgHXkXXBsZOlPEUvDWMeWDJ6Rub4pyOPEIPJsXYdGdqZyb4vj0NuaL1wuwVe4BitERuzKO3WsQKIVvM0OaWvNx95X8qEZ3Qs2iMu7iU8LRhJIPyan1wNdz1PomWsoGFsgOv7N4YQ8dtne1WB8VDKSOi162e29t6+d8UVmXWGsijjgKt3gksF3YHIhcYUSaNLPasdtU+DXMaHjXrJ1zI+N6/Bc9rOL8ltQoraUzxM6sGMR/91LoqmjEDAl7FlQgaVxDogeNRGYTPWkH0jIrfU1DpxsGcnTyx6gqyz/RgExekrfF0XXFDxCxwHU3pgnPYPPKg/E1NodP3SI24H5tdQDPZWCuseJPmVv0ubcY4dwKJB/mTV5SqzGnOGndL7zxn8YgQRc77APuiji7JLsZsKOH6tExKAgnbiNvNQJPg509MNSU4bRelzKZ7hN24kquvJegj4WBok56x0pUcwki4EKwNcBA7OFXu/e1MTBwgo6b9PhPLZzbJvogoun63M3nJkBQicr+rlffWxN80I2mHsSVAp95KXpnaue61HctFpyg3ZnIBv6TikNS5C4/Jf78mLMdDJxjJUStq5r8JnbcuX+v6nEHotBdi06AoX1n8kY5dFQFrpbk+HQreRRAF7P0T6MCl8eHrxfGy9Xigx6+vjv6gaFJCGXhAppjX7ozYktdmnTIlWSSBn9FwtyZWG2hFWITQrGahItvZ6ICzi+IzAudV3sRk95hsRITvtTmq7E6qm8hHw61ICNe9KgIsW568gH9DTvS+AUcC8UsqbmbTxJss/jDkJ5z+kqGwlM1eOxsLI7/vCSTMUvjGTCJh0ReEMGB/F7eWi6EaxKN4ippvj5dahucsQoPSONqUHG+aBf3IoSujz81nphHsJf91o4LGX3TNSPUIAqoYNpN06eA+PX8HLYXSqTVVGbijCC/qQja/C0ji1W6p1w018fS+TumxAPCwu/Ab4R6/hyyLZHl+4HHU0Kve46KvhklKtSiC+Pmry7/0IjLt7m7tSa11eJJYcqWyeEbcTns8wRzMZAJDg8jKTI2TGacqLcvQwFxDAzW1IxtTpj57mMyKVn6hg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:47.8952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbcddcf4-920a-4573-b647-08dd07f05077 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003445.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7866 From: Alejandro Lucero Add CXL initialization based on new CXL API for accel drivers and make it dependable on kernel CXL configuration. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/Kconfig | 7 +++ drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/efx.c | 24 +++++++- drivers/net/ethernet/sfc/efx_cxl.c | 88 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_cxl.h | 28 +++++++++ drivers/net/ethernet/sfc/net_driver.h | 10 +++ 6 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/sfc/efx_cxl.c create mode 100644 drivers/net/ethernet/sfc/efx_cxl.h diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig index 3eb55dcfa8a6..a8bc777baa95 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -65,6 +65,13 @@ config SFC_MCDI_LOGGING Driver-Interface) commands and responses, allowing debugging of driver/firmware interaction. The tracing is actually enabled by a sysfs file 'mcdi_logging' under the PCI device. +config SFC_CXL + bool "Solarflare SFC9100-family CXL support" + depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m) + default y + help + This enables CXL support by the driver relying on kernel support + and hardware support. source "drivers/net/ethernet/sfc/falcon/Kconfig" source "drivers/net/ethernet/sfc/siena/Kconfig" diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 8f446b9bd5ee..e909cafd5908 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -13,6 +13,7 @@ sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \ mae.o tc.o tc_bindings.o tc_counters.o \ tc_encap_actions.o tc_conntrack.o +sfc-$(CONFIG_SFC_CXL) += efx_cxl.o obj-$(CONFIG_SFC) += sfc.o obj-$(CONFIG_SFC_FALCON) += falcon/ diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 36b3b57e2055..5f7c910a14a5 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -33,6 +33,9 @@ #include "selftest.h" #include "sriov.h" #include "efx_devlink.h" +#ifdef CONFIG_SFC_CXL +#include "efx_cxl.h" +#endif #include "mcdi_port_common.h" #include "mcdi_pcol.h" @@ -903,12 +906,17 @@ static void efx_pci_remove(struct pci_dev *pci_dev) efx_pci_remove_main(efx); efx_fini_io(efx); + + probe_data = container_of(efx, struct efx_probe_data, efx); +#ifdef CONFIG_SFC_CXL + efx_cxl_exit(probe_data); +#endif + pci_dbg(efx->pci_dev, "shutdown successful\n"); efx_fini_devlink_and_unlock(efx); efx_fini_struct(efx); free_netdev(efx->net_dev); - probe_data = container_of(efx, struct efx_probe_data, efx); kfree(probe_data); }; @@ -1113,6 +1121,17 @@ static int efx_pci_probe(struct pci_dev *pci_dev, if (rc) goto fail2; +#ifdef CONFIG_SFC_CXL + /* A successful cxl initialization implies a CXL region created to be + * used for PIO buffers. If there is no CXL support, or initialization + * fails, efx_cxl_pio_initialised wll be false and legacy PIO buffers + * defined at specific PCI BAR regions will be used. + */ + rc = efx_cxl_init(probe_data); + if (rc) + pci_err(pci_dev, "CXL initialization failed with error %d\n", rc); + +#endif rc = efx_pci_probe_post_io(efx); if (rc) { /* On failure, retry once immediately. @@ -1384,3 +1403,6 @@ MODULE_AUTHOR("Solarflare Communications and " MODULE_DESCRIPTION("Solarflare network driver"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, efx_pci_table); +#ifdef CONFIG_SFC_CXL +MODULE_SOFTDEP("pre: cxl_core cxl_port cxl_acpi cxl-mem"); +#endif diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c new file mode 100644 index 000000000000..99f396028639 --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * + * Driver for AMD network controllers and boards + * Copyright (C) 2024, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#include +#include +#include + +#include "net_driver.h" +#include "efx_cxl.h" + +#define EFX_CTPIO_BUFFER_SIZE SZ_256M + +int efx_cxl_init(struct efx_probe_data *probe_data) +{ + struct efx_nic *efx = &probe_data->efx; + struct pci_dev *pci_dev; + struct efx_cxl *cxl; + struct resource res; + u16 dvsec; + int rc; + + pci_dev = efx->pci_dev; + probe_data->cxl_pio_initialised = false; + + dvsec = pci_find_dvsec_capability(pci_dev, PCI_VENDOR_ID_CXL, + CXL_DVSEC_PCIE_DEVICE); + if (!dvsec) + return 0; + + pci_dbg(pci_dev, "CXL_DVSEC_PCIE_DEVICE capability found\n"); + + cxl = kzalloc(sizeof(*cxl), GFP_KERNEL); + if (!cxl) + return -ENOMEM; + + cxl->cxlds = cxl_accel_state_create(&pci_dev->dev); + if (IS_ERR(cxl->cxlds)) { + pci_err(pci_dev, "CXL accel device state failed"); + rc = -ENOMEM; + goto err1; + } + + cxl_set_dvsec(cxl->cxlds, dvsec); + cxl_set_serial(cxl->cxlds, pci_dev->dev.id); + + res = DEFINE_RES_MEM(0, EFX_CTPIO_BUFFER_SIZE); + if (cxl_set_resource(cxl->cxlds, res, CXL_RES_DPA)) { + pci_err(pci_dev, "cxl_set_resource DPA failed\n"); + rc = -EINVAL; + goto err2; + } + + res = DEFINE_RES_MEM_NAMED(0, EFX_CTPIO_BUFFER_SIZE, "ram"); + if (cxl_set_resource(cxl->cxlds, res, CXL_RES_RAM)) { + pci_err(pci_dev, "cxl_set_resource RAM failed\n"); + rc = -EINVAL; + goto err2; + } + + probe_data->cxl = cxl; + + return 0; + +err2: + kfree(cxl->cxlds); +err1: + kfree(cxl); + return rc; + +} + +void efx_cxl_exit(struct efx_probe_data *probe_data) +{ + if (probe_data->cxl) { + kfree(probe_data->cxl->cxlds); + kfree(probe_data->cxl); + } +} + +MODULE_IMPORT_NS(CXL); diff --git a/drivers/net/ethernet/sfc/efx_cxl.h b/drivers/net/ethernet/sfc/efx_cxl.h new file mode 100644 index 000000000000..90fa46bc94db --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_cxl.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for AMD network controllers and boards + * Copyright (C) 2024, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#ifndef EFX_CXL_H +#define EFX_CXL_H + +struct efx_nic; + +struct efx_cxl { + struct cxl_dev_state *cxlds; + struct cxl_memdev *cxlmd; + struct cxl_root_decoder *cxlrd; + struct cxl_port *endpoint; + struct cxl_endpoint_decoder *cxled; + struct cxl_region *efx_region; + void __iomem *ctpio_cxl; +}; + +int efx_cxl_init(struct efx_probe_data *probe_data); +void efx_cxl_exit(struct efx_probe_data *probe_data); +#endif diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index b85c51cbe7f9..efc6d90380b9 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -1160,14 +1160,24 @@ struct efx_nic { atomic_t n_rx_noskb_drops; }; +#ifdef CONFIG_SFC_CXL +struct efx_cxl; +#endif + /** * struct efx_probe_data - State after hardware probe * @pci_dev: The PCI device * @efx: Efx NIC details + * @cxl: details of related cxl objects + * @cxl_pio_initialised: cxl initialization outcome. */ struct efx_probe_data { struct pci_dev *pci_dev; struct efx_nic efx; +#ifdef CONFIG_SFC_CXL + struct efx_cxl *cxl; + bool cxl_pio_initialised; +#endif }; static inline struct efx_nic *efx_netdev_priv(struct net_device *dev) From patchwork Mon Nov 18 16:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878864 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2041.outbound.protection.outlook.com [40.107.244.41]) (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 124FA1B21A0; Mon, 18 Nov 2024 16:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948297; cv=fail; b=j5ljNcZQjnB4U8dZ2JfWxhe/G6ZkZWTqwzvwSJxHhpHtwB5jJI3vqlVuTls50NDHcWKYPotDXuSC01ADzC7hvhWTKXu/BiJJ6QSYwfqAn0WjKJJ/aRnT43b5/xQoI1/McCkSPSUrfqr+kn4c1f+qLa1GKydlawFZAT6fa9bb5Ls= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948297; c=relaxed/simple; bh=c397+EhGdBS8RubIdjXdiwD9wYDg5CZLNS4bzsq4HpY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ru823KWyyTmPzl7WgUhwQiGf2KTrL0tPpj2R2MFv1f8cpc6UFD4SK7+zQtjnPLIFO2d3P2heTqyx+ixr6Mg5Xg8R/Y61V3T3GQN7/YtWNTcSMxrdMyZkvYUj07gfwMQCaB7MRUtcljtRynAaiOXdsQ1+a1tZWm95u9zQDlTEHPU= 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=pcSZ1BoH; arc=fail smtp.client-ip=40.107.244.41 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="pcSZ1BoH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=owr+Zsqg6tYdq7k2NbyThLck3AcVNcM50bCjuEGSSBCdGUNKLIiuv1hSCQsoih16wWd9ZiiO8NI+jpaQu4ZIgg+R4tV/oYq6C15BlDOi3aXqD9W4Ck6YaQnGKl+dCUX8etJtNhFBVFqZlCdgXO6eDDadt0Jo5uwri7pQmsAGnGuXzMgh5PAMmSV5pu7WHjvzKi85ApIuEL7gJYOGo13CiysPT1UN2bdiP2E/8SA3Smz21UVEMiaSCtvD2cr+rPyR4CBvC/mfpAzh1x0tXoTZXzllNPuQI+JR8RJ9XTfRJu1+boDtI6uzrD/I6j+WO2sjRevbfet9W14SyZRt0oQHqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DVsWLhdl7emdrhRbyOLtZDspItqRqvXsYVF45eQc2B4=; b=RZkjDRrTqXo/EHf6NA6vgdPsxI+a27Cq2vlMJEuHT2XrVrVqVvV6miucA6C8UCnk6UYoipnFk/AT1yaobPLEXVyrx6sbW66qwn1qVtV6VUAlXBbfXyBi2dQpauvccxUXINIOPTfsDiqXNCbApAV7N6ElnPm1WuzbRtKkLFnnjgNXXisZbCayNSWBDy6AZNz09RaMgG9yRpJcI0QQ6T+7MD/cnXTQ40Yx0agb2uX1e3uywwzM1c4cGtqnYlShlHtjJtAhLyKQXyRxLZBrNWvRcjgHd2aL3wDCPgPLfKIwmXP3icKryLFrXSzq21FsMXakvQUmOeLO9/huw2qgAOsvsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=DVsWLhdl7emdrhRbyOLtZDspItqRqvXsYVF45eQc2B4=; b=pcSZ1BoHbvL9GyVb6u9b7HMauHgIqCaBtgAjtXVWku2aSFfRF8eboiCGIZbJaBCQQvfIrDL0YpkwT99LFqnyPWhhtbLi8DmOGCKF0HoBuUaLwsZ+pl2EC0d0N2GoNgfPQ9c1OgGMpH3dpVVlFNTa1EW4IKNqgd9zuzxPmc1nvMw= Received: from BN9P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::8) by DM6PR12MB4435.namprd12.prod.outlook.com (2603:10b6:5:2a6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:44:49 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::8a) by BN9P220CA0003.outlook.office365.com (2603:10b6:408:13e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:44:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:49 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:48 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:48 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:47 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port Date: Mon, 18 Nov 2024 16:44:10 +0000 Message-ID: <20241118164434.7551-4-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|DM6PR12MB4435:EE_ X-MS-Office365-Filtering-Correlation-Id: 8796f64b-fca8-4b52-749a-08dd07f0511f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: aYPJG4ak9kFUNFt2r43OXPgZxqJAGHmhZrGWOIB80sLB3p6p8qti0lrXXH11YsgwO39ixyW3TnBVj6M2gHJyqsREe4m6MPON5pLUlm0obnyQQdPDrlcE04beE01k0vJ4lspnyZWGftqr+lxfksonDlR9wsUaNsQfW/NbdhkUxupiQHXelmq8Kgv1NgZcbJXtpWmtJuMsqJMvAK1qddclkwIWdh+t0Pq1ScfA+hGAuUSDeSe0tqEwTENU0qaGS6VhWeHPpHdSEkGEFyskrZPv17V9Ac0tY4urQeLj8wyM8HDo2lUINbUwhT7EbchEtoxsfmPKYt7kOmOdF2sIhuiCI3aX0CbLh/5ISM8nLAqZeqYcZt7P9VDkVtx/eeAx/jwjWcV49m6rVUWIT2CX3XHf1c5ahU0Mvv/3tD3kUT8xMv2OGXTOVk9w5VuYiEQ9Y+o0tzYo3d6NzM1kIPUdwno+dtfFAGY2yMLopRcbE/8bfgTSf2Vm4CCsGRiZGKji8EfMkIgaO8FoMln68urbmZ+n6k2gXZ47JI4qpAIQsvkLvmiA463y10uT6lIU6Zjm82WCEQtTppxssZ0sq5sWMM1S+LA8zc7ToYTsCnawPbEB77idb9/6wC6lg05jA4e4A/46Fcb18qT7h9XMWZLqluvHI8vt6XroGnKJi2q5PDJw4DE/qcIKFhXxifUBL/2kZ+ddZJw/hWAK31mVStiXXcxQcSvj3hXPgy8rkATagGVWUaHE1D4LeoKpg1II77Fyj7j4GkS3WCl47GKYIHbjdpDEwZSdQONkY/DYP5ayeDLXSuptgyi+obuzUCKLC861ZM9izaho09wGRl4DR0m6M7EH84pH5EH7jgAUqRePDTC6I1PPHVzaY30IB6E3BdtH8hp3X8KoGRXPM4HfygYx2SB1p5zT7pUkCrS1kpIW2oWkOixuHOxE+YxANC2oRyRg64vlxheCzMIUYdMrjVIjK06ub5X61GLqyIxUZyAT0ENa28ZKTJfzB0qD9oZNayG0X7IdkY+NoWYHayoqzZgZfU6YhfEAyaAq8lpzrSxi0MMUDmBwyCxw8rjGyRBi4WGW+EgJAnSS9UgHDJcQUL6aaK9q5qOKwqXSYwix8aUTEgeRS7YDNTt0PsG4fZ6GhkRj3sZ/rV3+XSRn62RhzLG8t+PgsAww6jAINbxzdGtPuVgvgOrwRYWzcBMU2ins4LfSfm/YKAjNOgdmDmgvW9ry0UmSLEtof8G3+dIAUPWirS3NQg5FabSmhRS7rqp2HB3PEuDjV00pvkrhpbsaD6VaDREM1jpAODkccLntEbEyahj/ZF2PtjOkKNZBzdR6IIyho9xh//F+VGP5XBG6bdcF1HG9Maa4Jtls04FwTaRkKlz5ngJXHTsCpIjU770zMfZPmN5VgDZsV9hE8HC2s+AZIBpgMQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:49.0258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8796f64b-fca8-4b52-749a-08dd07f0511f 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4435 From: Alejandro Lucero Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements. Add a new field to cxl_dev_state for keeping device capabilities as discovered during initialization. Add same field to cxl_port as registers discovery is also used during port initialization. Signed-off-by: Alejandro Lucero Reviewed-by: Ben Cheatham --- drivers/cxl/core/port.c | 11 +++++++---- drivers/cxl/core/regs.c | 21 ++++++++++++++------- drivers/cxl/cxl.h | 9 ++++++--- drivers/cxl/cxlmem.h | 2 ++ drivers/cxl/pci.c | 10 ++++++---- include/cxl/cxl.h | 30 ++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index af92c67bc954..5bc8490a199c 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -749,7 +749,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, } static int cxl_setup_comp_regs(struct device *host, struct cxl_register_map *map, - resource_size_t component_reg_phys) + resource_size_t component_reg_phys, unsigned long *caps) { *map = (struct cxl_register_map) { .host = host, @@ -763,7 +763,7 @@ static int cxl_setup_comp_regs(struct device *host, struct cxl_register_map *map map->reg_type = CXL_REGLOC_RBI_COMPONENT; map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; - return cxl_setup_regs(map); + return cxl_setup_regs(map, caps); } static int cxl_port_setup_regs(struct cxl_port *port, @@ -772,7 +772,7 @@ static int cxl_port_setup_regs(struct cxl_port *port, if (dev_is_platform(port->uport_dev)) return 0; return cxl_setup_comp_regs(&port->dev, &port->reg_map, - component_reg_phys); + component_reg_phys, port->capabilities); } static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport, @@ -789,7 +789,8 @@ static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport, * NULL. */ rc = cxl_setup_comp_regs(dport->dport_dev, &dport->reg_map, - component_reg_phys); + component_reg_phys, + dport->port->capabilities); dport->reg_map.host = host; return rc; } @@ -851,6 +852,8 @@ static int cxl_port_add(struct cxl_port *port, port->reg_map = cxlds->reg_map; port->reg_map.host = &port->dev; cxlmd->endpoint = port; + bitmap_copy(port->capabilities, cxlds->capabilities, + CXL_MAX_CAPS); } else if (parent_dport) { rc = dev_set_name(dev, "port%d", port->id); if (rc) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index e1082e749c69..8287ec45b018 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,8 @@ * Probe for component register information and return it in map object. */ void cxl_probe_component_regs(struct device *dev, void __iomem *base, - struct cxl_component_reg_map *map) + struct cxl_component_reg_map *map, + unsigned long *caps) { int cap, cap_count; u32 cap_array; @@ -84,6 +86,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, decoder_cnt = cxl_hdm_decoder_count(hdr); length = 0x20 * decoder_cnt + 0x10; rmap = &map->hdm_decoder; + *caps |= BIT(CXL_DEV_CAP_HDM); break; } case CXL_CM_CAP_CAP_ID_RAS: @@ -91,6 +94,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, offset); length = CXL_RAS_CAPABILITY_LENGTH; rmap = &map->ras; + *caps |= BIT(CXL_DEV_CAP_RAS); break; default: dev_dbg(dev, "Unknown CM cap ID: %d (0x%x)\n", cap_id, @@ -117,7 +121,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_probe_component_regs, CXL); * Probe for device register information and return it in map object. */ void cxl_probe_device_regs(struct device *dev, void __iomem *base, - struct cxl_device_reg_map *map) + struct cxl_device_reg_map *map, unsigned long *caps) { int cap, cap_count; u64 cap_array; @@ -146,10 +150,12 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base, case CXLDEV_CAP_CAP_ID_DEVICE_STATUS: dev_dbg(dev, "found Status capability (0x%x)\n", offset); rmap = &map->status; + *caps |= BIT(CXL_DEV_CAP_DEV_STATUS); break; case CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX: dev_dbg(dev, "found Mailbox capability (0x%x)\n", offset); rmap = &map->mbox; + *caps |= BIT(CXL_DEV_CAP_MAILBOX_PRIMARY); break; case CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX: dev_dbg(dev, "found Secondary Mailbox capability (0x%x)\n", offset); @@ -157,6 +163,7 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base, case CXLDEV_CAP_CAP_ID_MEMDEV: dev_dbg(dev, "found Memory Device capability (0x%x)\n", offset); rmap = &map->memdev; + *caps |= BIT(CXL_DEV_CAP_MEMDEV); break; default: if (cap_id >= 0x8000) @@ -421,7 +428,7 @@ static void cxl_unmap_regblock(struct cxl_register_map *map) map->base = NULL; } -static int cxl_probe_regs(struct cxl_register_map *map) +static int cxl_probe_regs(struct cxl_register_map *map, unsigned long *caps) { struct cxl_component_reg_map *comp_map; struct cxl_device_reg_map *dev_map; @@ -431,12 +438,12 @@ static int cxl_probe_regs(struct cxl_register_map *map) switch (map->reg_type) { case CXL_REGLOC_RBI_COMPONENT: comp_map = &map->component_map; - cxl_probe_component_regs(host, base, comp_map); + cxl_probe_component_regs(host, base, comp_map, caps); dev_dbg(host, "Set up component registers\n"); break; case CXL_REGLOC_RBI_MEMDEV: dev_map = &map->device_map; - cxl_probe_device_regs(host, base, dev_map); + cxl_probe_device_regs(host, base, dev_map, caps); if (!dev_map->status.valid || !dev_map->mbox.valid || !dev_map->memdev.valid) { dev_err(host, "registers not found: %s%s%s\n", @@ -455,7 +462,7 @@ static int cxl_probe_regs(struct cxl_register_map *map) return 0; } -int cxl_setup_regs(struct cxl_register_map *map) +int cxl_setup_regs(struct cxl_register_map *map, unsigned long *caps) { int rc; @@ -463,7 +470,7 @@ int cxl_setup_regs(struct cxl_register_map *map) if (rc) return rc; - rc = cxl_probe_regs(map); + rc = cxl_probe_regs(map, caps); cxl_unmap_regblock(map); return rc; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a2be05fd7aa2..e5f918be6fe4 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -4,6 +4,7 @@ #ifndef __CXL_H__ #define __CXL_H__ +#include #include #include #include @@ -284,9 +285,9 @@ struct cxl_register_map { }; void cxl_probe_component_regs(struct device *dev, void __iomem *base, - struct cxl_component_reg_map *map); + struct cxl_component_reg_map *map, unsigned long *caps); void cxl_probe_device_regs(struct device *dev, void __iomem *base, - struct cxl_device_reg_map *map); + struct cxl_device_reg_map *map, unsigned long *caps); int cxl_map_component_regs(const struct cxl_register_map *map, struct cxl_component_regs *regs, unsigned long map_mask); @@ -300,7 +301,7 @@ int cxl_find_regblock_instance(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map, int index); 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); +int cxl_setup_regs(struct cxl_register_map *map, unsigned long *caps); struct cxl_dport; resource_size_t cxl_rcd_component_reg_phys(struct device *dev, struct cxl_dport *dport); @@ -600,6 +601,7 @@ struct cxl_dax_region { * @cdat: Cached CDAT data * @cdat_available: Should a CDAT attribute be available in sysfs * @pci_latency: Upstream latency in picoseconds + * @capabilities: those capabilities as defined in device mapped registers */ struct cxl_port { struct device dev; @@ -623,6 +625,7 @@ struct cxl_port { } cdat; bool cdat_available; long pci_latency; + DECLARE_BITMAP(capabilities, CXL_MAX_CAPS); }; /** diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 2a25d1957ddb..4c1c53c29544 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -428,6 +428,7 @@ struct cxl_dpa_perf { * @serial: PCIe Device Serial Number * @type: Generic Memory Class device or Vendor Specific Memory device * @cxl_mbox: CXL mailbox context + * @capabilities: those capabilities as defined in device mapped registers */ struct cxl_dev_state { struct device *dev; @@ -443,6 +444,7 @@ struct cxl_dev_state { u64 serial; enum cxl_devtype type; struct cxl_mailbox cxl_mbox; + DECLARE_BITMAP(capabilities, CXL_MAX_CAPS); }; static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox) diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 0b910ef52db7..528d4ca79fd1 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -504,7 +504,8 @@ static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, } static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, - struct cxl_register_map *map) + struct cxl_register_map *map, + unsigned long *caps) { int rc; @@ -521,7 +522,7 @@ static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, if (rc) return rc; - return cxl_setup_regs(map); + return cxl_setup_regs(map, caps); } static int cxl_pci_ras_unmask(struct pci_dev *pdev) @@ -848,7 +849,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) cxl_set_dvsec(cxlds, dvsec); - rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map, + cxlds->capabilities); if (rc) return rc; @@ -861,7 +863,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. */ rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, - &cxlds->reg_map); + &cxlds->reg_map, cxlds->capabilities); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); else if (!cxlds->reg_map.component_map.ras.valid) diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 19e5d883557a..dcc9ec8a0aec 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -12,6 +12,36 @@ enum cxl_resource { CXL_RES_PMEM, }; +/* Capabilities as defined for: + * + * Component Registers (Table 8-22 CXL 3.1 specification) + * Device Registers (8.2.8.2.1 CXL 3.1 specification) + */ + +enum cxl_dev_cap { + /* capabilities from Component Registers */ + CXL_DEV_CAP_RAS, + CXL_DEV_CAP_SEC, + CXL_DEV_CAP_LINK, + CXL_DEV_CAP_HDM, + CXL_DEV_CAP_SEC_EXT, + CXL_DEV_CAP_IDE, + CXL_DEV_CAP_SNOOP_FILTER, + CXL_DEV_CAP_TIMEOUT_AND_ISOLATION, + CXL_DEV_CAP_CACHEMEM_EXT, + CXL_DEV_CAP_BI_ROUTE_TABLE, + CXL_DEV_CAP_BI_DECODER, + CXL_DEV_CAP_CACHEID_ROUTE_TABLE, + CXL_DEV_CAP_CACHEID_DECODER, + CXL_DEV_CAP_HDM_EXT, + CXL_DEV_CAP_METADATA_EXT, + /* capabilities from Device Registers */ + CXL_DEV_CAP_DEV_STATUS, + CXL_DEV_CAP_MAILBOX_PRIMARY, + CXL_DEV_CAP_MEMDEV, + CXL_MAX_CAPS = 32 +}; + struct cxl_dev_state *cxl_accel_state_create(struct device *dev); void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec); From patchwork Mon Nov 18 16:44:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878865 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) (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 37B611BD9D0; Mon, 18 Nov 2024 16:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948297; cv=fail; b=Fs3SkTReD/rUB9jD9oPePDHJaPlBgnZPMUsq35YUkglFXoHbunpaK1QOClws1WWycZjGzlrUZK9+EsN5LdLxGAg25RC5SS+h2Tu/208KbgCkhJCx3vUUJl+c/6gMmF2SrxrIelBhta9tJuYRFoY3JIIJzG7az12gKEYparyPCMo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948297; c=relaxed/simple; bh=S/58Hr0xBVKot8uvjqN6SJjjuuOPAWvdEXKhhDbXWiA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUwzBrZqp6Qtiv2LZOsnaOlnNTUYNqP1Rrw4HT8HNrT7Uj7u3hH5E9hZMWVQiC+OLElvQKwtGZDVec/qjfS38nEzfK3J8CvhumBJM5IGP7SDL7NOiuMWAj0In7TdH4DOZ3+LTjcCrBarRyH8VhW4KQKDajkUA94+6qzin7bm/3A= 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=PfuPjvMg; arc=fail smtp.client-ip=40.107.223.77 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="PfuPjvMg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NxSsyBfUfiHCt9igesmaxBVqFtYl2P8lcpw2V6oH/7l+9xd9rH20xJYr7ohQigU6MFtbuw83JfN/rqANTfQaaNka7VVP2rpE6qFvYKfVVNFeX8HAIKJtGAPiS9ofn7gTq0B1+SpXAweXcs88vuaBLwgUBXQSAOVpKiVDbPKRFK5tZGP4Pe/gvUH5qwbF5671IehHvZP+jJWLLwLIgBfKcVZ1dNAsHbbOFTHQ4TyiL6Fgdy24vSH8Drna2C8L0aS57ITog+vybNUUgB0DIAMZbmbPN92jy2gMuMp2RwmtehgDKnRW3sNgv5M46CdaUtbyNnXrqFMvyYhlyL0S9fcsBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=W6VlfZ7IazsGr05GRcYRjRa39OQhxfMSYkTWCJfz5xo=; b=jF+r1YsIbollh1br0jtt8KoPXXuAFaLrEiLAyWfnnzHV5vwQAHP1Z5mmMDdy59jvKBJoJb3Sjug4ZfUfaG5Dt4oTP6B0LfQ2t0ZmEYqbA5Vjd3yGQ4EUfT90EgiHUfWKeHMvB3XP1MXQ4AbO59M7RtSxjsiamiJxw6OTCEiGoY+Zx5Sm1fJqmIIdyt6dKsBzNzE07OKcbNX0Sa7ORlMx3tDIhOlcgSZ7VPP7zYthVAkpj+43lHM97K8rs/fByulVcavWtD3k5JRdTJH6UabxzOHyPR25YfkRE0/5MSVKwyZzCttSXoDBGWXTrGG77DlrQN2kRxJYpZts89Ybd6MEmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=W6VlfZ7IazsGr05GRcYRjRa39OQhxfMSYkTWCJfz5xo=; b=PfuPjvMg7jIli1JQAvOwl8Nr2sB1/XmmX6jHVCPvJOvYL1jCYvqjCbXRPKT042KeBr7ofd01WsZibu7rI29tb5i0DVc6c14NW1aeHEae2fm00WeHJIASJC6dOJMjc/ia7Kpfd3aaHdJokANasPC2M5GyzefkicXPRTDEmIuaiqs= Received: from CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) by CH0PR12MB8532.namprd12.prod.outlook.com (2603:10b6:610:191::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:44:50 +0000 Received: from DS2PEPF00003447.namprd04.prod.outlook.com (2603:10b6:610:cc:cafe::b8) by CH0PR03CA0084.outlook.office365.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21 via Frontend Transport; Mon, 18 Nov 2024 16:44:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003447.mail.protection.outlook.com (10.167.17.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:50 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:44:49 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:48 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 04/27] cxl/pci: add check for validating capabilities Date: Mon, 18 Nov 2024 16:44:11 +0000 Message-ID: <20241118164434.7551-5-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003447:EE_|CH0PR12MB8532:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f70ad99-3ff7-4897-ef17-08dd07f051f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: i52Jy4ieD8m73coEaCUkT0Wn9mpSBXugNgenZQJHUW5JydQZ1vo6TngNIqRvmTY0jK8XRIa2YzzRxpezpGNGmEjgY6+bu/fp0GS2rU7N/ty1+T77YEtQcnPxyziDH1lUqZRup35tobgiSqQszZeoF0kMxpGBmuZu/Qhv2msmSwu600yLoRT2HdV1jfNDzDgRf6hl0Ie6/H1ok9zeCSnf9ncjrlWoml7c1RI5LNSjruaJbvHwcbHNZ3dn/qr+KCkJU10Y7oKVmcNeAwJjorfUUtlZ/m/oaz08tP1FIouzB3vKqz41+RFED3UdelxDbXvk8NzDuqGhZB2V/SoTdYEMt26XEVhB6OzL/XR08b4yrWs8dDAwd8gSONF2PJM/Coo4xXlsp98WCEDGmO2C5oXON59pAoSF7g20DfwOqYgFsarEkCd7danAzcgZJjte3g6ez05fLrXXJIKyuoMGPL6TyAq2Gn7T4lWaGbWJijbzZlFxTyPerqioR5Y3TICK1jUqFmiC4M62wzfvR4DqJbTufEpclVlHq4UVOLSpXKyYUKAlMwgHuGbpVUhLljNy2YGuKDM8D24MDTH/WAtZTjWMogIPHYwX3vKGhIs9CWOuYl/aXiPAkDDyHC4ri0dAYL+2RLtH/i5Dmbp41RqSx4+yqrvRUjikXeqqPOcshcQINJNpTLFedWtXJptHcozCrY2N/J1qp35+/hR3v6i3POBtDHWF2D4jNHgvpyprrOy0m1dS8CkiKF5ynUjfK6T2C6Jm7PYNtr6KNyiy1oNaI2vOky2jtOvqDXHVAeY2LL+Cb+rXTSn890Fx/wFYaQjwgXB8CNggW/ztvRpQRy/FxhFlQeI6CLEZFaskj7KzB8O2aXbIgGY9w2WkhKkez4pL2nXpVF3wt6S/sUQwggqCrZQMPqoJJkLYUiD6r6ybx03Mi07edTkYiXrwtN5qIKhNcEpnI8prwbUqQQRFcb0Loq9od1VmyNPZCmLjh3yejPuknrDULPTblREyOQy3rSYaHYy8T6ZqeClvzqW7CLpEVAvwhKAl81OFFNbLHrjjrxquU7HnRa6M7V/8S02XFCn+LncY6Fbbp2Y1ZWlN61mirTol2t+F+RdDW+7eJRQ5NsX0xiS6QwmHZ02rKKF5dZBWUruMNRqDp9aQwL/GvF9zq+9kjBR8zquKphqPAoEgG7VivEIUFBbWe5xha62dde5OdohRpuN2xRTF7jhczEuDHj/fvZVCRL6bHUj5wkW1Z4JoE4zzTlYE9mFSdNu5dnCX6X7nBF3SHTgCtdcv/Hm+5g3bNgc0k5ZtkRgO7sOfT3LzKO+ijg87phGJ2zIYfGBWnSfkc+xry37EfxDb2WlQ1orVaLOQ0776EtT2WCcrc0Hc3NhosX/+Iv3m1x418jBA4+2V/Qkmp21suh7mT/hXri44wQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:50.3740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f70ad99-3ff7-4897-ef17-08dd07f051f1 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003447.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8532 From: Alejandro Lucero During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities. Add a function for checking expected capabilities against those found during initialization. Allow those mandatory/expected capabilities to be a subset of the capabilities found. Rely on this function for validating capabilities instead of when CXL regs are probed. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/pci.c | 22 ++++++++++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 24 ++++++++++++++++++++++++ include/cxl/cxl.h | 6 +++++- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index ff266e91ea71..a1942b7be0bc 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1055,3 +1056,24 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) return 0; } + +bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, + unsigned long *current_caps, bool is_subset) +{ + DECLARE_BITMAP(subset, CXL_MAX_CAPS); + + if (current_caps) + bitmap_copy(current_caps, cxlds->capabilities, CXL_MAX_CAPS); + + dev_dbg(cxlds->dev, "Checking cxlds caps 0x%08lx vs expected caps 0x%08lx\n", + *cxlds->capabilities, *expected_caps); + + /* Checking a minimum of mandatory capabilities? */ + if (is_subset) { + bitmap_and(subset, cxlds->capabilities, expected_caps, CXL_MAX_CAPS); + return bitmap_equal(subset, expected_caps, CXL_MAX_CAPS); + } else { + return bitmap_equal(cxlds->capabilities, expected_caps, CXL_MAX_CAPS); + } +} +EXPORT_SYMBOL_NS_GPL(cxl_pci_check_caps, CXL); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 8287ec45b018..3b3965706414 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -444,15 +444,6 @@ static int cxl_probe_regs(struct cxl_register_map *map, unsigned long *caps) case CXL_REGLOC_RBI_MEMDEV: dev_map = &map->device_map; cxl_probe_device_regs(host, base, dev_map, caps); - if (!dev_map->status.valid || !dev_map->mbox.valid || - !dev_map->memdev.valid) { - dev_err(host, "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(host, "Probing device registers...\n"); break; default: diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 528d4ca79fd1..5de1473a79da 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -813,6 +813,8 @@ static int cxl_pci_type3_init_mailbox(struct cxl_dev_state *cxlds) static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct pci_host_bridge *host_bridge = pci_find_host_bridge(pdev->bus); + DECLARE_BITMAP(expected, CXL_MAX_CAPS); + DECLARE_BITMAP(found, CXL_MAX_CAPS); struct cxl_memdev_state *mds; struct cxl_dev_state *cxlds; struct cxl_register_map map; @@ -874,6 +876,28 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); + bitmap_clear(expected, 0, CXL_MAX_CAPS); + + /* + * These are the mandatory capabilities for a Type3 device. + * Only checking capabilities used by current Linux drivers. + */ + bitmap_set(expected, CXL_DEV_CAP_HDM, 1); + bitmap_set(expected, CXL_DEV_CAP_DEV_STATUS, 1); + bitmap_set(expected, CXL_DEV_CAP_MAILBOX_PRIMARY, 1); + bitmap_set(expected, CXL_DEV_CAP_DEV_STATUS, 1); + + /* + * Checking mandatory caps are there as, at least, a subset of those + * found. + */ + if (!cxl_pci_check_caps(cxlds, expected, found, true)) { + dev_err(&pdev->dev, + "Expected mandatory capabilities not found: (%08lx - %08lx)\n", + *expected, *found); + return -ENXIO; + } + rc = cxl_pci_type3_init_mailbox(cxlds); if (rc) return rc; diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index dcc9ec8a0aec..ab243ab8024f 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -39,7 +39,7 @@ enum cxl_dev_cap { CXL_DEV_CAP_DEV_STATUS, CXL_DEV_CAP_MAILBOX_PRIMARY, CXL_DEV_CAP_MEMDEV, - CXL_MAX_CAPS = 32 + CXL_MAX_CAPS = 64 }; struct cxl_dev_state *cxl_accel_state_create(struct device *dev); @@ -48,4 +48,8 @@ void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec); void cxl_set_serial(struct cxl_dev_state *cxlds, u64 serial); int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, enum cxl_resource); +bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, + unsigned long *expected_caps, + unsigned long *current_caps, + bool is_subset); #endif From patchwork Mon Nov 18 16:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878866 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2084.outbound.protection.outlook.com [40.107.244.84]) (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 D60C61BD9F9; Mon, 18 Nov 2024 16:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948298; cv=fail; b=YPj3UMZ44/Wybi/3H0QWJj8e9eMzhrh6EUBOPGHfeNpr6vGlP5gT31VU5yMER7qWD5Dv1r5tg1tTKF0p9jkCueY0rQA/Ur7D+9RzVhs6anz1mPlrSWOccG+22ZXVAkQDhcHD/rbRxExt4GJLwZelo9DABR0eK0W4FPCy8jhTPGo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948298; c=relaxed/simple; bh=NkjVDGA8AG1gfQQV1yvkZKsqKU67SCRNIk0KuMrNP94=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nl6jV/RW0UDf+gnQluSuYylxpkzAhWTgtyp/zflD2qc/1HY43mvQd2U6z9iasJJISFcF31X2jNrb8hAH3hmRBZkwbhP2SfmORWv9KquiXoTnuoW26cLGoVHkjEAteU8PfZMxMYrunDcgPfG8j4Wd7l4fZcw2telKvWQxrfulYsw= 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=HI/bq064; arc=fail smtp.client-ip=40.107.244.84 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="HI/bq064" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G7hDSbTpXYnXbnckkUZTTUBtxMNwK1ZFC3BucPcKpKesZxDK6E0bCfsBXJFIe84IfUO/CyNMF24jYh7Ld++L/M+qJDkBPwt/Q0ior43g5m8YPuSfy/dZxgqUUeaNCJnYnRbWryiHgQE/vuM33UG03pV+FpAGUiVl9feO6643d1/Pb4DfaAd0tbdWPYTA/mu4GVWWVVqQ8rJUOBlQt8gMLLrqXBm0T/YIZOBaF2vcasrm9sg/Xf0lkqLRx1TiLZSpDd1qtqm5eOq+zIgDD5A7ETizei6tJaXHgqSAsm2iU7Z6W24mQ81PSD5+9TQtvw6ssjVnlbiSHXy8yovI6AMjnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=M7+sMZ30Wzm6SufVdNgXk1hx26tcW7DQYESo92gicXA=; b=Gcol+V2tOC6fP2j3HBuVPE0s4i1MXpQepScjCD8G6E2JGLvnTdaRoJ+1D9C56YpaKqzWRB1tmjVOWAJ0A1HcHdJ1/ZNL8opXTXcyL9RPCiIDzGe0oEVWSp/4zs2yEbHJoCIoSJkbb/XBvUEKziDRz6TvUlVLWSiMSFlnAGFsQnBp0hyXx5HY/HatbkERUDRh7179DDKNO+2C5MYToBUPbWjXZquSJmjGY5x0J6AGb770LrUCb0dKDMxHy97m6L7SXPzCQc/zLnLil3+RpD8XpQAXZBwZip/rQlplmJw7fMsIcqWUlz+cy3tFuUapIIGiz52v945z+fvK27/Aff+Ksw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=M7+sMZ30Wzm6SufVdNgXk1hx26tcW7DQYESo92gicXA=; b=HI/bq064HZSw2S8j8xkRNYsHhGvKHp+42zfTNSrD9oLpizV8zvmOrEuWcTWCYA4MRJbYuZ0/9466TlVEmlnCY5wi60arnQ4y+jijRhfDB3eGsctRm6m9klLcAr7DOabLdSpDCyNomCyy2YKM5itkKBfbm3DHb9x+r3HqAR8ADy0= Received: from DS7PR03CA0266.namprd03.prod.outlook.com (2603:10b6:5:3b3::31) by DS7PR12MB6094.namprd12.prod.outlook.com (2603:10b6:8:9d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:44:53 +0000 Received: from DS2PEPF00003443.namprd04.prod.outlook.com (2603:10b6:5:3b3:cafe::ff) by DS7PR03CA0266.outlook.office365.com (2603:10b6:5:3b3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:44:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003443.mail.protection.outlook.com (10.167.17.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:51 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:44:51 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:49 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 05/27] cxl: move pci generic code Date: Mon, 18 Nov 2024 16:44:12 +0000 Message-ID: <20241118164434.7551-6-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003443:EE_|DS7PR12MB6094:EE_ X-MS-Office365-Filtering-Correlation-Id: 65f0ab9d-7b06-4ee4-3897-08dd07f052d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: SZynUcsYqdh41UHuG6SjQhYrv9iBKy9cWFep0QDY8/fPXFJtZ5UQXvRw/GfnV6HKk4mcYGQxy9UKQoibG5Y4sTZTbTsY2ZnhCVcRDA8EV2xqxk8q9fqhFseI3iCVQu8zeeszdxZsL16WI/YLjCD/Ki9OWZeFcIHJHQjZTovnJ8ms6rELTMbd5izzuuR/lYvoJ7RN2DK/IKQZ1Rc35cfG7SmDqq+iM+UsJo95rLWWF7UkY8VPaxKuHkbRpcd4bMYm4PH3r6KY6WaU8ZOAcmedgPEqU6BQB+dW4xKgDrw/B0bxW1zFu+wGhtsEDiCCOV0h5OMLuH0mM1a0LiLjnHVy/im23zIk2ocFAV6AiKdMslePp2QcBt43U8LTR+OUryC1hFyIhUwdceVurUt1uasvMF61Qh3AM7YdmnOFNu5CtMSSu/3i7Zn7jsQ+Ia71gaWIkEfClTEy8OhXfjiUUIhiOeG4MarMZ6qgJvDJgwzLYrBIRFR8Q2ZEozKk9ZLtxr0IZ1CfFe28GFY/B5dbNj3QKU0XFZQm19npT1AmgRd4CyK2QASs5j87eKeX+1O9f37J/yGvmfBPGsA4miX/nL+zACZ0Qk1aQ8mMVS/qyHeTHv4ikYBukYlhx5sBlFKm89HNkWVx9ZgNvmBT8ZcyggDFG3QcP/hrmyn68iDERzEx/RLD4nU4M1K+HUMBL17imHWJXaztWzbRAqcM1KxsYXnVBBPjQf2dI/mUIt0E2+YRTVejUNf0XAvkZqibFw57TUznaZWi64AWx2fPD/OPxpQVB8PjIO/HxnXmyW08VDeVk1TzhayxCVkXIppHTAFGzFJwM67iyjWFJ22zC4dM6s0m9/uL88YHWUN/KXFx2upKDlAc7+qHGgzysnjKqSULJSB0b2x+Y7phObMqhKEhsaX97Ae586paW7iwqROSV540B7Yyr/RWvXs/MAgTPGIp24cGwZfyIVpBowKfW+zfnF2NZd63plyKMngoFfhr2x0ZdE/qeWe51huwkQBHTa2y3eF3Tr7/2Oor7/v3LO+6RglWi49v+ZNTQ0mV70RvhLCJEWXSXFcH+ETJaKxtpOzWFpSlWbCyQnqVg7+5dBBZRcpAQ3me5vb/snX/IqHt+q1UfDoiWHrBP27UYKIVUVCs3QKTVcwkTnDzt6Du8QBIBhPsaXX9WcenWQemWb7cFPpBIBKvIR9aKuZEyMH+TQFI7JLn/qTXeLU9B2vgrFtcdkICmUyUdn7SV+BUvij0PQwYT8vu8Fzq99medkzBaiLOwHwRbA9lDKzR/eQlDgxj03fjv1fkG2Jl0SqymM825NiR53OSjYluebVXh/5Z9ZtGwM1/Z6vP58xDtR4bjSF/yRB3iOoGFojCaHgFnhm878szhAyQKKp2UhdA9sjCW7ODaRiSxWMQUFPy4kmh0cRMvSvSnA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:51.7788 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65f0ab9d-7b06-4ee4-3897-08dd07f052d4 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003443.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6094 From: Alejandro Lucero Inside cxl/core/pci.c there are helpers for CXL PCIe initialization meanwhile cxl/pci.c implements the functionality for a Type3 device initialization. Move helper functions from cxl/pci.c to cxl/core/pci.c in order to be exported and shared with CXL Type2 device initialization. Signed-off-by: Alejandro Lucero Reviewed-by: Dave Jiang Reviewed-by: Ben Cheatham --- drivers/cxl/core/pci.c | 62 ++++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlpci.h | 3 ++ drivers/cxl/pci.c | 58 --------------------------------------- 3 files changed, 65 insertions(+), 58 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index a1942b7be0bc..bfc5e96e3cb9 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1034,6 +1034,68 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port) } EXPORT_SYMBOL_NS_GPL(cxl_endpoint_decoder_reset_detected, CXL); +/* + * Assume that any RCIEP that emits the CXL memory expander class code + * is an RCD + */ +bool is_cxl_restricted(struct pci_dev *pdev) +{ + return pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END; +} +EXPORT_SYMBOL_NS_GPL(is_cxl_restricted, CXL); + +static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, + struct cxl_register_map *map) +{ + struct cxl_port *port; + struct cxl_dport *dport; + resource_size_t component_reg_phys; + + *map = (struct cxl_register_map) { + .host = &pdev->dev, + .resource = CXL_RESOURCE_NONE, + }; + + port = cxl_pci_find_port(pdev, &dport); + if (!port) + return -EPROBE_DEFER; + + component_reg_phys = cxl_rcd_component_reg_phys(&pdev->dev, dport); + + put_device(&port->dev); + + if (component_reg_phys == CXL_RESOURCE_NONE) + return -ENXIO; + + map->resource = component_reg_phys; + map->reg_type = CXL_REGLOC_RBI_COMPONENT; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + + return 0; +} + +int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, + struct cxl_register_map *map, unsigned long *caps) +{ + int rc; + + rc = cxl_find_regblock(pdev, type, map); + + /* + * If the Register Locator DVSEC does not exist, check if it + * is an RCH and try to extract the Component Registers from + * an RCRB. + */ + if (rc && type == CXL_REGLOC_RBI_COMPONENT && is_cxl_restricted(pdev)) + rc = cxl_rcrb_get_comp_regs(pdev, map); + + if (rc) + return rc; + + return cxl_setup_regs(map, caps); +} +EXPORT_SYMBOL_NS_GPL(cxl_pci_setup_regs, CXL); + int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) { int speed, bw; diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h index eb59019fe5f3..985cca3c3350 100644 --- a/drivers/cxl/cxlpci.h +++ b/drivers/cxl/cxlpci.h @@ -113,4 +113,7 @@ 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, pci_channel_state_t state); +bool is_cxl_restricted(struct pci_dev *pdev); +int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, + struct cxl_register_map *map, unsigned long *caps); #endif /* __CXL_PCI_H__ */ diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 5de1473a79da..caa7e101e063 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -467,64 +467,6 @@ static int cxl_pci_setup_mailbox(struct cxl_memdev_state *mds, bool irq_avail) return 0; } -/* - * Assume that any RCIEP that emits the CXL memory expander class code - * is an RCD - */ -static bool is_cxl_restricted(struct pci_dev *pdev) -{ - return pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END; -} - -static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, - struct cxl_register_map *map) -{ - struct cxl_dport *dport; - resource_size_t component_reg_phys; - - *map = (struct cxl_register_map) { - .host = &pdev->dev, - .resource = CXL_RESOURCE_NONE, - }; - - struct cxl_port *port __free(put_cxl_port) = - cxl_pci_find_port(pdev, &dport); - if (!port) - return -EPROBE_DEFER; - - component_reg_phys = cxl_rcd_component_reg_phys(&pdev->dev, dport); - if (component_reg_phys == CXL_RESOURCE_NONE) - return -ENXIO; - - map->resource = component_reg_phys; - map->reg_type = CXL_REGLOC_RBI_COMPONENT; - 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, - unsigned long *caps) -{ - int rc; - - rc = cxl_find_regblock(pdev, type, map); - - /* - * If the Register Locator DVSEC does not exist, check if it - * is an RCH and try to extract the Component Registers from - * an RCRB. - */ - if (rc && type == CXL_REGLOC_RBI_COMPONENT && is_cxl_restricted(pdev)) - rc = cxl_rcrb_get_comp_regs(pdev, map); - - if (rc) - return rc; - - return cxl_setup_regs(map, caps); -} - static int cxl_pci_ras_unmask(struct pci_dev *pdev) { struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); From patchwork Mon Nov 18 16:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878867 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.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 F1A6A1C1AB4; Mon, 18 Nov 2024 16:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948300; cv=fail; b=Ia2a8dK70jXDtWxqdA07S5887Ca+HNf77Cq/NFfAd7Gk8u/87yRTkGTV1dB9GSk8NYilsLkEbBPuUxHWqBW5y8gdimXfoTmWLbvzBSF9PlK8oEhV9Atp96hzRkqm5QhRGzehTsyXOAwJ1ml2D2n8oHcDK30rVR24qrhfwSo12mU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948300; c=relaxed/simple; bh=u39dTh3lLxFT3QghIkvWLEENG1Mv4piLmNw7DtlJvXg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l7AqLsswkoRLVJNsV9r+7Ujd96QTS2T081N3njOs9+T7edeKcYsaIxisOa+GEjCygDB2WNSPhei//7eXCnva8p6Yrya/6E11+0Ube4SCPsUFAuL0ILGaZ80Cx8fQzzLUUm5PQxRdNlHpC0bjm+evCOhHiOv5nXY/3mu7v24Riew= 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=migTuVa9; arc=fail smtp.client-ip=40.107.92.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="migTuVa9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PGoDcqPM+fhhqwzyBPvxClPBMKi09rvBmviCaXzkM63c9i0Gif2ci6GuwGgpK0XEdLzyJ8VGecCYu05lbYUQy0MM4mn5YPQFdCoMirNU01ZgVvfOtRNkkWOav59dROjSdKU6Q0yF+azg1u2ZojkLMnGG8kMOP8S+y3jZxIAGWqSF4bgKTZhOG2LJlDivaFRcjaxir5mwQZyMHvFOsipWZ9rHRJEVCncOvQR3zSqa530M73TS3Z0UZYffj5MbK0KR4X6ZXb8tm+QSP8SGDSYG4zHEB0jpx+Kpd+11nD6oV47U1JJgkzvAxh37UqHo7FLfQNLlSdmDvWvZEOUfhJdGFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=fV06fflleZ+l1IVhaXX/spVI/4cZTPXS0ZaLVyAdE3I=; b=ddG9KDU/QIbdJVZHLJSK+nFdp4bEhUxd1biG9uoKVSzA3FgquRk/TPEcO6lPMIhKjCcgAfu/dNsxVH3XdGyUegiCAm5Co0Asl6K/Noy2szUxX8BWVokTn+RTEEZ5U7v8ultFC/TjQWPxYHLdy1PEw4P1BDnpi7OWiZqwjgMknpZAgj0QEf+hxWTKFzM9gyy3uFIg9ePV0arnz3R8jzvBlir7N8eWxp3/k11NQeUvth9dO4qgDAxF6lDnfAIL8oF9OOnTSa/C4uCBSPywdxQISIxYl/8BJm8SOiBqMExMVCENnTLRBAWqUmBJ6vTtVmNOMYdO5PLifz4xN/7TwzpVDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=fV06fflleZ+l1IVhaXX/spVI/4cZTPXS0ZaLVyAdE3I=; b=migTuVa9eC1ZkEDv+CGH+Y2HUroxB2sXlqHaJEj6KfVjyKBImj6U5+Sxnt0WjuGlslsJmoNuuoEK8+w28Ngza6JhY2qr8sFnuq6Y8IpkWSll2d/qLZJV2PXYNOaC0dBdKn7tGr+HVMoaVSABuJO8HDxWz3nIaHXhBiBHaA8b2JQ= Received: from DS7PR03CA0261.namprd03.prod.outlook.com (2603:10b6:5:3b3::26) by DS0PR12MB8561.namprd12.prod.outlook.com (2603:10b6:8:166::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 16:44:53 +0000 Received: from DS2PEPF00003443.namprd04.prod.outlook.com (2603:10b6:5:3b3:cafe::15) by DS7PR03CA0261.outlook.office365.com (2603:10b6:5:3b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:44:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003443.mail.protection.outlook.com (10.167.17.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:53 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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, 18 Nov 2024 10:44:53 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:52 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:51 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 06/27] cxl: add function for type2 cxl regs setup Date: Mon, 18 Nov 2024 16:44:13 +0000 Message-ID: <20241118164434.7551-7-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003443:EE_|DS0PR12MB8561:EE_ X-MS-Office365-Filtering-Correlation-Id: 6789d755-b044-4b91-06a1-08dd07f053c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: 1YEeX4VLtrnGZWgBOdCAQVWG1out3ctdc2YDRwL1RjLLfNiTt91TCthfuUMvfA3sqeesyv2tsN9cDSRGsX1YMOsZggSMjWt65st02B0ZtwHRJ7VVaPSwqXSualPzxNGvh29Q/wIq3R3rk2KiE861psYJTLz9DdhRk1ycUXiSZ5MZTOoBMyCTGLuTWF1DaeSMOf5Tn5JSLkRfZi1ho+LFifbvGuIIVBfJPWH39pFqPfhBZzeH1CTQk1VcWT9iyhcE4jwX5pI1Q13l7nUaNLKxr6ZUmj8psdRJvnViJg4RJoGdmGqPfLyvL5gjbGNbDOU50cfFPmeHI1PpKUVAhr+zEmLaHrfpqpGzlGq0Ltxx0Q8pIYrqTEssp7vKfgn29re9NBDvcjNoqnQ1HEjhUQ5UZmLWDwVFaKRJ35qGLOQ6uQDf/o6l9SOxU3pybQ63YaoJpBLWMNoMarmbqODlHngEeZiqp6zqmu0y2RltT8PhczURpE9wu2l938x271Q/zRVcNlxjFBMHKzdETRGXBymsdIcaqZXCCGS37Ik5oFfK+pkj+BrE88w1iWM/uuZAnjGa+1n0KUZk7v2YUKy9wzD+dRQjkTovXaEjd2m18+fI4tBwjCzECXyGRtFreP5vSEwNW1Tp7xjknmRYZ3NOIY4xLBTFRbjGNf8VrrSxG7rfv1A5dsAOQlE4v5vWCNl1PCd59QHNB1wY/0VAFmOZogLbL3EaAJ4wHLIzWqtLNzPoOylIKEUQoZd3dIm3iNQGWUW0HHHNBzzER3/ots7w6Vc6lSjXYCfUUS8PEHFZH28pDBlyxikobxzWcx5JnI3VNBsxJ5lBNov6Fx1A8YQPq8Ak8iujjzq3NeQVEob5qzGGxLYehd7PU1FNtoWAqhSmp0z8D12ycX19w/2JVWbpdKIuFnOmc3Wifv4v3i9IowYII2JSoxBUoyiFopNM6p140kJMGz5YDkgB+plNzqeuqRAqraku+PkOvxxSsghdicJq/Slcxuh5F9RYPJsV1dG2OHnz/LXvYfQA4Hz6H+mKEQWWPT/FL2SqcQqfOv4qNeapN+NeGqVHqJwsmuMMkf74Up+jvUsL7UiYAAdOwbSiPqgjHY92H6Mz8aSyBwYDmMa9Nx8brj1JsL/2dDKtdYZcQKJmJTWl9oe3ZhMz6iEsaT8F+5c4jCAMi5owfl0+w7c2jvcambOqcugeY+9tSsjkQqiNuhuXEZknM9gEJAwTJ0nYpHivoyHmboluueV3q9qgDSFtu1/nDOx7jdMHXEMQKGV27dOD3LymDMc1UCmuamVg6OHbKZprfvJ/njx1w/LBD/SfpTFkkcpgtEStKQSOlTRNv7WtOj7hOHCgRlmLSDLcx3GjXiqE73BKKlyXiKIUMaOoPWk6VEAo9s+q6NjZ1aM/ugZ622VzAztz+ifSgDePTg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:53.4663 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6789d755-b044-4b91-06a1-08dd07f053c5 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003443.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8561 From: Alejandro Lucero Create a new function for a type2 device initialising cxl_dev_state struct regarding cxl regs setup and mapping. Signed-off-by: Alejandro Lucero Reviewed-by: Dave Jiang --- drivers/cxl/core/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index bfc5e96e3cb9..8b9aa2c578e1 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1096,6 +1096,53 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_pci_setup_regs, CXL); +static int cxl_pci_setup_memdev_regs(struct pci_dev *pdev, + struct cxl_dev_state *cxlds) +{ + struct cxl_register_map map; + int rc; + + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map, + cxlds->capabilities); + /* + * This call returning a non-zero value is not considered an error since + * these regs are not mandatory for Type2. If they do exist then mapping + * them should not fail. + */ + if (rc) + return 0; + + return cxl_map_device_regs(&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds) +{ + int rc; + + rc = cxl_pci_setup_memdev_regs(pdev, cxlds); + if (rc) + return rc; + + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, + &cxlds->reg_map, cxlds->capabilities); + if (rc) { + dev_warn(&pdev->dev, "No component registers (%d)\n", rc); + return rc; + } + + if (!test_bit(CXL_CM_CAP_CAP_ID_RAS, cxlds->capabilities)) + return rc; + + rc = cxl_map_component_regs(&cxlds->reg_map, + &cxlds->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS)); + if (rc) + dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); + + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_pci_accel_setup_regs, CXL); + int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) { int speed, bw; diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index ab243ab8024f..a88d3475e551 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -5,6 +5,7 @@ #define __CXL_H #include +#include enum cxl_resource { CXL_RES_DPA, @@ -52,4 +53,5 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, unsigned long *current_caps, bool is_subset); +int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds); #endif From patchwork Mon Nov 18 16:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878870 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (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 910051B6CFC; Mon, 18 Nov 2024 16:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948307; cv=fail; b=pUNScqxZczIjv1KCUr4pOgtDGu0IfrI0OQiLtG4xKpW8zX0sRRxukbM1DPlA40iIrxZPgc+3gzCTz2CmNamDYsMqUIqmpLPk3/vzMdtZrJ6uzsvbHSDOTMHZFwNPWxkAqVzbCIv3nxQj1fiXN+VEFJwxwJH4OXNy299jHqRPWzQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948307; c=relaxed/simple; bh=yw9zdsRjOdY4tPBebfdqBRNZ6E4cs6awh43QcZgTIVA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tODuSqqcWNnhgT1RqDPXxJWpThRc+JCYOnIPrqRIBRC5tP6mbnR6JWu3HTMok7pvNji8K0j8MEgeYyq3Hl3nB3bfuXud8LJEL/a+GC6ID45tH4RezMA+wp8JrNXIB39OiLMiEMykVhzmsew1D3loyx6jz5VZ++Z/CYLiEHRrdv0= 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=yFSkdqu0; arc=fail smtp.client-ip=40.107.94.47 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="yFSkdqu0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TYMBWCN/fTctIujrlv1J6M7YPgn57NB2R5sw3Wp551ujPr/Wr31mSFx0rwhu+D4bwOfsNjQdMMH9h+Q/zvlKvWtRIUa/HsWkW9lIMegyTkkFx02x9J+czjanHzZ16obNLI3tspz4CRlRfDw9locHVWhrEt1GZP4XLS3QMHP6EvatXrGZy6rzmebiGbbfv5BFumyTTguUB6/G5wUhRAFSzhUaewZLf/n++H4tdKtGvZFuR5jsuzfA0gSNpMptfGhkbrCRPjedMqGURNSJNQojLgZnr9bXXSU8NKwCr4M/vYqfYk1H7/KD8NEHJVRIYIt33Xs2pxuYv4dDZ+NY4m3erQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Vi+cML+UUaFcteLBcFmy5q3rPcbvNTax3KuG/FaTTUs=; b=Ij4oljlRoGxggwsLcAc9iJ7/+s0ZlrAmnVKyFptD3BqHhxdACX0LYIdTTOKflYMUUIKS0Mj4cyLaCvVHu7Jq0drvOMBDoIjrhtNYbMnhPA8KAfDQEfK05FBQmAklDTmXcq0y66Z2oxvc8SlbHsgRkzNkMBifV2XJXB596oNlqhWn9MN8eYMAYuXgeIvI6eL17eU34+X6shLdJCX7dNTXKEkjjpQcYIere1KTxnc3JKZDOQlcdSJ6G+il+92HeYiz11lE6lvKuoVVPr7NiJehn66w35pu9VStT9J93QfKr3pzpS2vzQY9XTVlwwxXDtwZT8e6STTdfHu/ieJiTYElwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=Vi+cML+UUaFcteLBcFmy5q3rPcbvNTax3KuG/FaTTUs=; b=yFSkdqu0LTIzl0kjo+jylJUvuFUI/UZA87UAxBrReZYA+bk2IwCd7jF9ij3jDDVINwzXOvpXyg+Xz5FxvlcfYoBNrrS5GRd4zXUzRl48He5HCgb65JmGC4TOc6QriZK+5VaLLmETJ2QPFL+xSCq0FuTeQFpQqbdDTf1vINac6MU= Received: from BN9P220CA0026.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::31) by PH0PR12MB7840.namprd12.prod.outlook.com (2603:10b6:510:28a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 16:45:01 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::4e) by BN9P220CA0026.outlook.office365.com (2603:10b6:408:13e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:00 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:54 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:53 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:52 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 07/27] sfc: use cxl api for regs setup and checking Date: Mon, 18 Nov 2024 16:44:14 +0000 Message-ID: <20241118164434.7551-8-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|PH0PR12MB7840:EE_ X-MS-Office365-Filtering-Correlation-Id: db6165fa-e798-456e-c4c2-08dd07f057e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: lR20ZHID1EPSqYUXmEmIX1QeTBNq6YQsHl8xy1jgA6ff1QZm0No6R24R5gVFe0b2EW29cDEKyuKwHIG33fOWQVJ31lyzdNXewxnFbbSQV+ExKh/3NB5LyO+keAZ3Yl+EV2nMl3liEIAuLZK5XGTy/k4faW3Yd9iheib8r6oUWOVKxsmypJbtfT5svifBOxR7qm3OuhuZjpa288JpXfXEoJRasOQFAToccvgYJncg7puPoOHRmdgWkrI20bpC6uBg9J4moq5XvHqmqrIrXnRYlonvMr+qF+4/LLpsTV7TL4l0HHzopCB/Q6Sv8ZZIPAK4LnKBhJpobYDfi8naQGzrnJf7SMzjDnTDrbAGUzmMUFhD4yeQ0hn1dAszviJc9B36nJfSLEUHYsWhZHkQZqevFQ3V+N6JHATMBi/yH/DgOPQFQ8tCqbgdeSp+9Ix5JLTP2eRGC2NWVJZUmxmeyL56VS665+sQZJ8+nkJQNZRvQxIRR+BPhovw+L0Qv+WX/xC+A3x4+MK470bKaIssVgFE9T55zBM4PuYstQnr7I5tMcM4ehSSIOXEOVeTJJND5ii7B8ma4ABKUfA2KoVvdzyAiYh7VXAX1y/jfljudTrRtg3FzNoQBlmlyhVdF0wPiQs4XxAftsqkFYf1oHX96HgtVtIFkF0VhSa2Tm9XBDHGNAML1dOusAufBU6WIrM4Qcq/Ln/sAqeFYF4hZVNFF+YY3py61plQISRORM0O8Ivuj/QR7kQ9CHWP88W2FYgark5pluRSJMalMJuw91I4xjwTxeDyOz2MTC26B5vRN8WllGMN1UugfUo8tZHqqDl0kbRN9Ep8v3oRtgiXNCrUkuYdICWxzLf+G1L6UiXpobrbF00I4h/h70lzVNiEpXikkQMXLBtKyOLRgv/Gp/uDDE5S/BW1O2hVdr8+BpoImcq+y3Gb6IsyEa3nIhKQSXNHsXBt3ppGk4EiZ9y8Uid4deD9oSsQCpapOEINNvzVMYO8MyfJcoVaiAtq07jlc1Ww7AviCHKtQZkkNttAzZPn0WZuZbc1g+dVQSaO6Uebe8qo+ksZmgHqyZ6L/Laiqn0rV/+/ltU1E8H/N1fp2xtDuYwHARlEK25JyHh30rscPfEXfVkGDVGZ3ZfX8iyxdX4RIEoxSy2C3SBdzAdXhLdPCptO3hgdmCaoaWEP0rXZjoAJ5JMlkD7fZtFVh789GIey4NaZC6x02WZsIh7bSYNxN198W9ouK0Ks6BEhG/4fk95c/RNx3svMG0jaNjYOO26/wbO6mTdTpXtG7QAtdmXp9KGphtngWN9o26UUdAy+c3MCMx6ufDx6yukGX32g09JvNVpDeV/aBq9IW+HWTJf67xq0eJztE2/eF6EEifuTZ0TpN3/zVWYZVy03Z+a+uXBRxERhazmojnqzGvZdRrkWi5YUPw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:00.4009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db6165fa-e798-456e-c4c2-08dd07f057e4 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7840 From: Alejandro Lucero Use cxl code for registers discovery and mapping. Validate capabilities found based on those registers against expected capabilities. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 99f396028639..d6afd1b5499f 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -21,6 +21,8 @@ int efx_cxl_init(struct efx_probe_data *probe_data) { struct efx_nic *efx = &probe_data->efx; + DECLARE_BITMAP(expected, CXL_MAX_CAPS); + DECLARE_BITMAP(found, CXL_MAX_CAPS); struct pci_dev *pci_dev; struct efx_cxl *cxl; struct resource res; @@ -65,6 +67,23 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err2; } + rc = cxl_pci_accel_setup_regs(pci_dev, cxl->cxlds); + if (rc) { + pci_err(pci_dev, "CXL accel setup regs failed"); + goto err2; + } + + bitmap_clear(expected, 0, CXL_MAX_CAPS); + bitmap_set(expected, CXL_DEV_CAP_HDM, 1); + bitmap_set(expected, CXL_DEV_CAP_RAS, 1); + + if (!cxl_pci_check_caps(cxl->cxlds, expected, found, false)) { + pci_err(pci_dev, + "CXL device capabilities found(%08lx) not as expected(%08lx)", + *found, *expected); + goto err2; + } + probe_data->cxl = cxl; return 0; From patchwork Mon Nov 18 16:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878869 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) (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 871E71C1F15; Mon, 18 Nov 2024 16:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948303; cv=fail; b=KnQceXQIk1buxT4kZU/wKj1UqXChGojlRmt+NtCdMTTImcI2dCrA7spdqqf6HrP1uYlcq+8AdipzxDYjenV9hGAdOgG9ZyAZW5mdb3HWDORKDzq35tXsB6vtGBDuPPxVW9xvCnErMNp9g/CVgWFUsDaWc1h5K7SgCHoLP+uG1l0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948303; c=relaxed/simple; bh=jvgJ+aCq0534tq8AVz1wtzIchIN5h9GODqBS95IYM8U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X4hYVOsxa0c5bB5sIBsu8Ciw9tIjKZyawySqiiZQTo1VU3zvlMhNAQlk6TolU0IXnOOAGTIkSYVRtxfT8/+OVScBrcUkM6Acg3ve2bgtT1bv+s7BWejFx33CRi+Y47xt4soMIGiEIBTAenDsGHUamDv4sLb64lG4BCkCWbp0DYU= 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=KBOt+/GY; arc=fail smtp.client-ip=40.107.223.88 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="KBOt+/GY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tFNJR8oqqDCnAWTvvu3GMO9yHKGtViGG85+FIu/lsgO1rLdNWgWRfcRKcZ4ebH4t7P0oVHKi4wMEAhTpQt+VtlGflHtHBWvg8rsQJ+i8GuK3DtK9VZQRAKKMK3WCWZV68jTVFvRFeqD+V1SlnwuCsZajT2kuGYIQs+5rlWhr91FTuqgGpSKCt84Zk8Bi5xz0JnG/LeZOmAO9J2QSLL3RX2OmnIPNTzJ8SAsmPS1iHC4RLJQJYj3rZB2UP+38c19tFkZn2vTwx1h9J7xnfAmazlam5I/2z4YznHt+LOKuiWg1E5iV2X1rZKqSTl1NBSi1rR/tDm7eZXmdvEXtAgVm3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=p8OV1HskqBWE217ug45un182EOJEVOV7jLkmeaP0yG4=; b=Q4nRgWsTtj4nbLaslVvB/pfrh1CuvtylbY4QX7H6hcLOIyLTwpGVWGbLOwQMdcUuWYQ6SGBZf/BPIBfBm1XG/dxTCYsXDXQ4CU+UwqGHD5B95MKtBQnl7wake3AjSByZ3pTOlzSriK9iwcc5LP5tK+fK8a5ROzC/3wFw2Pos4XypONUHBZjfSHo1MyCMg5m1hyOuuAFEcMY032fUYHTF4oOyeP5b8vDtldHMPWdxOphTdSLdUbLQeczqeavFYkzhUQbhSr8nG/L30o32S1495oVzACm8S8nMGfzHr7iPuRDO2hvkyq6kiYaam+wb6nuNQ77qjkWJ84MlRjleWlo5tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=p8OV1HskqBWE217ug45un182EOJEVOV7jLkmeaP0yG4=; b=KBOt+/GY885P+2fb3TIMiujhIC6vGb+S71vIRiDqmW3JYSrE3Doy0Cvel6+MUQEzedkTYo33k/vRyzULsy4nvH6hW8e6vDS60YFKNI/MyhTnmzbWIJK0e+MsdoycE3ZGctJEtSFZmUdg1uwAarlk431bJVVSVR09xHm3YIhJ1F0= Received: from CH0PR03CA0090.namprd03.prod.outlook.com (2603:10b6:610:cc::35) by SJ0PR12MB6965.namprd12.prod.outlook.com (2603:10b6:a03:448::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 16:44:57 +0000 Received: from DS2PEPF00003447.namprd04.prod.outlook.com (2603:10b6:610:cc:cafe::ce) by CH0PR03CA0090.outlook.office365.com (2603:10b6:610:cc::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:44:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003447.mail.protection.outlook.com (10.167.17.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:57 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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, 18 Nov 2024 10:44:55 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:55 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:54 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 08/27] cxl: add functions for resource request/release by a driver Date: Mon, 18 Nov 2024 16:44:15 +0000 Message-ID: <20241118164434.7551-9-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003447:EE_|SJ0PR12MB6965:EE_ X-MS-Office365-Filtering-Correlation-Id: 376b6547-d9c1-44f4-9756-08dd07f05608 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: jTBlyr73mFKbc1NqogbYkQ8u2WAJbrD1MIgNWYIrHQepRZZPfx/OxnLcGJ4OY9y0K/5Tv0iH9m52MC5dFI5xrr2TGWyEaguuG/ipoy3HI/BDvNdWGimWrP7nKOlDNUots2+GecxrMehLBDjTHQ8JA4AZPHpJULYC4MVk/SZ1RNgfHC1zGeAfz2P9R8cS7mRyJ2fjTkDYqi8kLZ0WlOnVk4nCTkXX/m1yKI+DUdIOg/bo3DQtDyWEZ/zGMxkTOHbQKqMy1SJnzlPkTwRYfAGtzY6eOjZpMQkR/E3hBmfmDZMnz09JhcwolKVrZn5QOTQxQHzTKGcKh1icGITwoYFsB8EleNNECa+VgJg+RV7MuYDxRHH0Ftx0kH/zQ/n0eRqbEps3+GLNfepeFZJy1GthRLlxzJouus6ZqsJZbFasG6Ct41X8LMQkrFWOrBJwTfToCqOBkZfYvVj38KoBhgbRNAWNZ8mOTdLtI6zyK2ZSvTEJlgC4Ch7rptJkTKaU+ZkbKDWsjtQc30tHMm/L2AEwvQML15qSPvFAKwMiDqVIBse1snUPuZrwHykeusZlmcXKk62FnrpHUYHXPy8yTi/yf8hQvX12Ia59TRUuwsG9tJjvcQcduWLPHfV9jGZsslARfI2D76SAbilEKsMY9vGmqu86sBbGb9oVlsfUc43Kfx288JjNJOIgmWgkWb/v/FbOB7+pCoNxxi7eU9Q37PPJN/zG9xl2VGWI+LxFFwQq5UOHC06JDY76yTF0/6G11ABB33H/nzM01YPbyVhC8VFVqZ4U3re1gOhA84A3u06wZgrt9GOOf3o54w1fPfoHp6KzzXWxyGdQ7j7mr9GvDtojwd4aORm0jnqZX9/wtwfNgrDtTmcKVjSkpNWRT4lIet58k8t0jNT3ZF3yOy182tb1aCMIuF2rAfa4uJQ/9m98Vg2L4xUJuSkEQPNIksZbW/UACeBYMS1b7SAkek7er/agXoOfPNurRvCEQ+Gq073nJK7Hg9R5E1Y1F+M0+b1UelsBV1qjq/aonToIjF7STa68F4VyjYLiQDymdxcSZtvKWlGGpG/PD/NA37Siz3WxT7lmL7u+ler+bnXnIPmlZriG3j814OTCVo2mbUd/7gFVniGiG1U3Bh4+NOjd10Mn5fuq+/owmHtxbY2ikNKF7GYGSk8VvAdbDWQ4ozN6K3tbSoJdF++2ZlIold8xBF7s6QNnAG9FRl0Ds85YEaHxulEca26B0q+dOEmcQYHUUgXHsnLGx8rejmBl2V+BrT3mQwrISGk2j3Wlh7kRnrTAvuLGavNoEzmbHnQyxVEW6vsDswIQY/VbCNNjtdIBh6BAYnwAN7X5quVBNmhviMODKRrF8RgArASrv+2YSPDSpK31zaRX3jxumVrsgvIqIOY5QDq3oofjk+Pcn6NXwuNmJVD6zQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:57.2333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 376b6547-d9c1-44f4-9756-08dd07f05608 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003447.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6965 From: Alejandro Lucero Create accessors for an accel driver requesting and releasing a resource. Signed-off-by: Alejandro Lucero Reviewed-by: Ben Cheatham --- drivers/cxl/core/memdev.c | 51 +++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index d083fd13a6dd..7450172c1864 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -744,6 +744,57 @@ int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, } EXPORT_SYMBOL_NS_GPL(cxl_set_resource, CXL); +int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type) +{ + int rc; + + switch (type) { + case CXL_RES_RAM: + if (!resource_size(&cxlds->ram_res)) { + dev_err(cxlds->dev, + "resource request for ram with size 0\n"); + return -EINVAL; + } + + rc = request_resource(&cxlds->dpa_res, &cxlds->ram_res); + break; + case CXL_RES_PMEM: + if (!resource_size(&cxlds->pmem_res)) { + dev_err(cxlds->dev, + "resource request for pmem with size 0\n"); + return -EINVAL; + } + rc = request_resource(&cxlds->dpa_res, &cxlds->pmem_res); + break; + default: + dev_err(cxlds->dev, "unsupported resource type (%u)\n", type); + return -EINVAL; + } + + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_request_resource, CXL); + +int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type) +{ + int rc; + + switch (type) { + case CXL_RES_RAM: + rc = release_resource(&cxlds->ram_res); + break; + case CXL_RES_PMEM: + rc = release_resource(&cxlds->pmem_res); + break; + default: + dev_err(cxlds->dev, "unknown resource type (%u)\n", type); + return -EINVAL; + } + + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_release_resource, CXL); + static int cxl_memdev_release_file(struct inode *inode, struct file *file) { struct cxl_memdev *cxlmd = diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index a88d3475e551..e0bafd066b93 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -54,4 +54,6 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *current_caps, bool is_subset); int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds); +int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); +int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); #endif From patchwork Mon Nov 18 16:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878868 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.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 7D04B1C1F14; Mon, 18 Nov 2024 16:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948302; cv=fail; b=LmKhzXjzos+0fiG+C7qtW0KHhfuVAq4Qbfm1i1XDWeQ98xVwSIM2y/Omy6tAGgIoXq4KjNQeXXurCYp8UPIfynz7Xrt4IL2YaUO1rYd3he9rsfn9YqmTaEmP6Y8V90ZmGAMcMzHtrjBk+mYSl2tBfM9XlEIKB0k8A6SjoRtkFHk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948302; c=relaxed/simple; bh=DBQiN0Ozt1FIdZD8D5UNI/q2bK8lmr6PEgu/2dYvYFY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kLw9z9GcCPP5boGlsj3FsGKO9/ZKOrYpSQ/ogUrZf7fi4T+QANtNlYurklvZroRIUsLKWD+xao2nWxirNOAtecD3SLyZse5UXF9nbB5Nu2sh64ug2/nqP94H1mtCAbpcRMqTNsVKhrEAGNqJSTlYfGlhHr/KfdiH+SR4MngE2Vc= 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=kMUaXP1R; arc=fail smtp.client-ip=40.107.220.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="kMUaXP1R" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V1CTcCOdFFonveE8MZz0Dv3Qvkgfm1YgGtxy6wXIMrozBgcct6Hyy5DMy3lAFyMThBEFi7AJYuk6aKhbQBNMPP4Mkq1D3LVaz+HEMvRLaEe8OZIlHCSdm6mkUV3BHT6NfS746EEO6+GYKDclCfKtIBcRt9CAQToAE21s+icJNFUjmB1NhQ7IjD0bO3prKLbuTS3qEaFnsMIQD2C5rCyFSpAmNVyo1BXqwbpV40YVZRBzPZPBRJ+eQKExaLfNYx/9Pwm+c7fIhKegS7U4f2nLzQalkFqArfeIURq8oT7vS+B0wNgBvkFxqFaeNenagwIfP3r2XI8TUYO6yZ/fqglJjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=rFT1kkg/Lz4XNDHEgaisrIgXSMiYCB7llULK2VDBTzI=; b=JmbzACeYEHWcNlw187FEThGQexRkLwYP9bu9OhSTtxv0nG2RV69xrSKswepmQHGHKU3wuYDuxw68HdYYwX87+aKLz+7x60GtJku2a/k7YvTkO/+1AGhMXdKRADV+NUflarLKdVEh0Vp1ccvhpmD6bPjHXcVXFk2Ukiq8ob1f7RvDEzOO+B4GCAdpdAQZiNKkJiQueEtMWXzlCDG37mYv4/pTg1pZm2iBbPhwIObCThAyWWlwiTOCzLIgt/nE7mOiWWMxfObC+mgx21hwcApposvgp2RrqtrB8Irfx+wib0UP/AWyHRH1RI/kLcDfUuIaU9zLEjYKZC3kL3tiyUOj+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=rFT1kkg/Lz4XNDHEgaisrIgXSMiYCB7llULK2VDBTzI=; b=kMUaXP1R0Jn3uLvtjCShCGvcPZT1fF3aohgJrebq42QI13UNFPWfdPnoafHlonPfAzZDklsjgOPxDReoRIRVwWDnN35RN8tQbyKVNqF0UMEN2xSvrqXLT2dstyzYgTXaLctLB297aIqO/nZPosATqdNsoUhC1MQ3uamOAx+xVHw= Received: from CH0PR03CA0082.namprd03.prod.outlook.com (2603:10b6:610:cc::27) by MN0PR12MB5955.namprd12.prod.outlook.com (2603:10b6:208:37e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:44:58 +0000 Received: from DS2PEPF00003447.namprd04.prod.outlook.com (2603:10b6:610:cc:cafe::66) by CH0PR03CA0082.outlook.office365.com (2603:10b6:610:cc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:44:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003447.mail.protection.outlook.com (10.167.17.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:44:58 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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, 18 Nov 2024 10:44:57 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:56 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:55 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 09/27] sfc: request cxl ram resource Date: Mon, 18 Nov 2024 16:44:16 +0000 Message-ID: <20241118164434.7551-10-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003447:EE_|MN0PR12MB5955:EE_ X-MS-Office365-Filtering-Correlation-Id: ed3d2328-dc36-48d4-cd20-08dd07f0567f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: TisO6aWFlAlRsgiA0VBWDtvPOUnf7dufST+/pw2juxBSIUsfCB8Bd/T/qOKQcK+BYf6nkid5kO6kwsCae56UJCKl/B82rTkyEL7vAJ2mtFVA49kUimwY3n3sSHAZoq1NvB2kTubYtwTtJbwQvuY9oTj6M89Pw+SNMSztVXilBiT6PJG2+PByyHHIiv0fES852WIdFKH4R5TdHe9KAKNfrlKgHkD4qj5bjfLKGCvDmmrd55e/Vxk83jHxFYpHjtwG/jPDgjawuz3tgjBhhqQdzGO2zTxs83GOegGdAPycexKHnTy3FSluIx75Hz88SoDrAuTsaudGitJ6Q82UfF1Y4syR8zKDbNX/PlL1YILqfaZ93x128DFD/nS5FKuD+ILSA+sTO34dec1eD1zekgbncDczqcxPt/eOv9EtYj7g8a8OfSzdvdkyZ9NoTjdutPRzRbzuXIEhycmzybNNlkVJcZY6e2WheGNkIxKUm1Q8kNW8ggvQC4ROkGNzOJS0QwhXx7dsRzhDEHGQ8FX7VEZnLCaeEbBMo5k68E6aXioyDYaoCVenTdwEHHmv3zNL5GhIBOtDAAEiXC3Cd3GeNTKnKfE8pSo8ngG02m3BqEmlmkITRN4P6Lu11NQPdDCPrW9EuNi4cKbLzN/6oo9r96mVhOjmzuAMZykeT1gUQXz/1neVTd1WhjIIZHlVhwuq+w3llmARrmveC61pDNjeoM1fk2Scmeg/XmWzyLoqFonDmlZAricbc+lpfoviTAumNRi5JOOM4ROxf4BWEn0NGuXBGJwQsP+PidbjzxI4VLn3NPfZis+GYNDWIciFi/JFJdRUQZY+ykm00tUY/rF3Fw3M5+J0tWUfgGykSbFc9WKNVB2m/q83JWNagrJQLSUFyYnFLoDPl+1Aes+4ceZBJoNlSAJWKa7I2Zejjjc5gCkm+GxWIjZL7yq/e49TNCN8a92kcjn41L9GYMofcyXxp6ydd0mso1z5BdZQYrFzKgIKG6mSHulywhvLWDZtZeXdAkVF9VP2UrD/6U2lZiql74xCeTzqPeAohJCOjm5yNZgsWmDNhr9MzsgoRkiL9nA26ZPSTFIjcVSdQ+LaVjOF0P4vnaWQB1CgvaDDlWKrUnKzAs6n4Ky6uhEfx7LGV1twV3UdBKHJUgE8DMaGsQQ6afFOwg41t3DfNK50GsdFbAeUE815vw+JYNFG4EYUyJUG4nj8AYoydpMAQAPSX54vkL8okCbPl6J0mVh3LqdL0wroZTyYCq0R4RZqr+v+Yyd7xsmLIYf1fx89j4rYokuJUVROPtqiZTyR1krjl+qIki/I+MllrzL00MaTU9ARgnIifpVvL/joE2iaYYRX8unne4U8SN8wUO//cS4Et3OY97NT4/w9i/tkBSpgDA4V5fuUko/m7Sk4HLRDM4WZpNzjMffqpA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:44:58.0146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed3d2328-dc36-48d4-cd20-08dd07f0567f 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003447.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5955 From: Alejandro Lucero Use cxl accessor for obtaining the ram resource the device advertises. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index d6afd1b5499f..06a1cc752d55 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -84,6 +84,12 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err2; } + rc = cxl_request_resource(cxl->cxlds, CXL_RES_RAM); + if (rc) { + pci_err(pci_dev, "CXL request resource failed"); + goto err2; + } + probe_data->cxl = cxl; return 0; @@ -99,6 +105,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) void efx_cxl_exit(struct efx_probe_data *probe_data) { if (probe_data->cxl) { + cxl_release_resource(probe_data->cxl->cxlds, CXL_RES_RAM); kfree(probe_data->cxl->cxlds); kfree(probe_data->cxl); } From patchwork Mon Nov 18 16:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878871 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.55]) (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 85E701C2339; Mon, 18 Nov 2024 16:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948309; cv=fail; b=PhHFCdYl1WYmf/8Irxo9HkqTtUSJKr7HGFbYvXvHA9M1SlMxxBdTeMLMZ5UVIBK6OIwEI0NnTCkr97B5fnjaaRHfH8Yi2J4qmAcLh6Bs2z/o3Qj4212XfYomW4jnx8ALWJqVHb1EteS5mSjH7rxQh2HTCN1xEjC8X0NJ+G/2/s0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948309; c=relaxed/simple; bh=tmzH4p5V7OsfPdy3Ar6TLjoP0hf2Z2za0OlT6dKdyw8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f49x+bRCYuoqhDCAlZGtreAofhjpOIJkiDb2KbMe4e6bkoGf3Vowtrcky3cTF+ZYCdPyEBdm6foJpswW7n5BDE+4b/x40PqCmRkj3lleLPiu8DU68sRrjJ8C1bT8PqHAC/PFjuUyqGka8T1b+HVE1vL12YUZTctg7JgD8mGbdmk= 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=nQFBDjRJ; arc=fail smtp.client-ip=40.107.236.55 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="nQFBDjRJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PrKkfmH/MeQbSFNSSK3XYJOnv2cAFWvQNQCf9hpcOZZgTxx6pwRCMfVNgl4UuNCGK158oWH9vKEgZ9NEMoDN4YJGXYXr8phI7Nfrh7SwmppnQAl3akoUvlpFqCv/7LzXPKJIALTnqxojen6LcY5ImRnEiRAAKYQTNdZCOrqsefnZ0WoLk2Q+vhTPHAQeJhNGFWMeH21JFKr87oB7/QWmFrJ+Ut6zDe2TTFW6v5ZnMe8pP6PmUQMIgk5urxn5xmhjvsY8Li+qmojDabc/1eWS/e2F50yzI2TZtZRJWpQiazZs0cQEXUyTpyhv20fDYNtMYHG7hRQM5oDj1EcprlxN0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3IC4GM0Rj+XiCREtClPzzW9d0fOeSS6zyRqkQ12zgCE=; b=C7hUMG5f/Tvp7WF6aq6+kpMki+mXaHd0eZANbsa+JnoyNKb6GHovIf80EuNQW9iGihS1Wo4LZkA80si/NNPka/wfs4GRhigaaqKQvi/dcCvLgS6HfXOwSZ0IQqL9VQILULRx9vpbJfGEVeZlIN8auuFYOC4I+HcZM0xLNMZG0MV0jU7jJMT7uYQZsC9Jh99qIph6uJzhGM5s/cyophcTMB7fo8Pw5reSbto/xyq298xDtjGHc4OhEBREzCOMVso4QQTSC85MnrtvZaxU6rS2yXVNalyobacR0qLxQS8dWspeUg77GTUxoJzNq8+d/HAwyT0DOmvvySvMnDhsy9lsig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=3IC4GM0Rj+XiCREtClPzzW9d0fOeSS6zyRqkQ12zgCE=; b=nQFBDjRJDX7v2DbU5X9W8fzjSfo7+QA8QDoHlA8u4mV0eRzTxxhmYTZbR/Zx8WSDpy/wGcdfVQKhKk/BIYd+RCStuzf0yJY1R2t6SvtwHDF5yW4Xp5wntu+cyJ002t9xq/LlG9RaWGqkMH75D1WixIAQ/YvyIAMQIGPKsZ1U0g0= Received: from BN9P220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::6) by MN2PR12MB4142.namprd12.prod.outlook.com (2603:10b6:208:1dd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Mon, 18 Nov 2024 16:45:03 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::8d) by BN9P220CA0001.outlook.office365.com (2603:10b6:408:13e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:03 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:58 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:58 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:56 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 10/27] cxl: harden resource_contains checks to handle zero size resources Date: Mon, 18 Nov 2024 16:44:17 +0000 Message-ID: <20241118164434.7551-11-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|MN2PR12MB4142:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fba7a6d-3d8f-42bd-398e-08dd07f059bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: UmGWdgdD1RtOiv8D0u5nssJ+jIlIGpdyhYumIOKbiYED2UZOO+UW/sl6dLLZaOKe+tgb5apYebtQBFPHLZrvgHaux6m+nzt8H4DcFtqrCLiy9icH/NkdYWvftm9PdsQbztXKFLbCBH1n9/sSTfZGErAagcmxipjistNEVWGHfkBKMRRyDIb5We/dqHT+zrlycE9QX1+NedJqGLul78Bwmj2PCaSq3GFtq9nXvfbTkzo91UWXAWhGXjqDACWuSsNNwSSeDsyRh/USdYjOZoEy1Mr1W5+teaSwVLCDSpgp0e5asQWXwD7y0EYaKuugDWbf4Yd58eYt5MWDs2+l0zb9jPhUrGrjYOsfE/OZ1zi/GbZTKYyBJzlOqZyk7vccqWBfK4BFInzclUtUUD4AF6TZrkuj1lEfEmc1W8Yaw4wOQadF4YmvAzVfwmmxk59pkK26xkaP35dg7GvVU/+l5y2PuAjjJ/pb44upYY9D4byfs3L7ZTpvGaeYNfC4H1kcqY+g/wbjoHXa0b6ZQMolX7caN+D7pn1mukJCEQTbryn2bT32iYg0GfFBtWTN7SOQFJ4On7437Uqwl9RQyjuxEyGl2PjQfsAbw6Lo9wy6XjtN0WtjPv6RSAb3dka0EN760fSJCaf8qDu0jnoNIW7LlQQm64WSueQekfatIy8Lf1WPaUIGboiW79fjUxKFiF6fCuo7KZ3nua42s1IRRu4To/w/GqoWcPy1MxGiA/ZBih0ojjfF/wTv7bLkSEl3Z2MrVwzD06hPf1IQ6ctAhDUwsE5S9GZBai0sLmFOpj6rrI3aDJzfAt5F1HvxOUfLqqNEVyap3S1e+99VkP6hrU+rMR118Y420Fig3L6c9LIcCf7AVyk4u5K7g3W1K4YpZ0wqUeYTFWv8abc4K2fdG4UfcbZr9SbNfcHL1/3mC8cy514/jV/TVzM7MHjV/sFvkaS8hlbRPnCiDBtyp/C21g9c6oznj+vNe4/qVz1lStE9Jh7SapkrLQQuG/H9clJpE3tE0sBSNxmd9BjnunoUTi+wGJix5RW/Ltp6Nc9HvnNxO9OV8Y9qXmv/BgzuOQXAYgKTIk1I3x3pDJXliRDMFZx97haQTlaDuqi5utj+S4cuba3JGynvu07xTggVUR2xuJXYsPnhkRSoSbsT78IZSKo++2Wtrb1rQFvCIU7fQs8gfNlWbwNsEXzhRh/vhwYzfWLz6Cj/NGzas0nz6eLrNu002E6JsOEDF7UB8RSGUP8hoMNPwWim7iExHtjbFVF6qsQ1TWLKygPSE+11EggmLSozU46/K6mBB2a1sQIubhWVCNZQYzXZuLK+9DEg9TNb7EcfrKBmMGuggHVQQg8u7ag+tejPHXJXYQH+ROP4dDkNb0a7Ai4DDzDd5haL491EG0XxFTCByV7R7q68hWSQGO9rsgotUQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:03.4478 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fba7a6d-3d8f-42bd-398e-08dd07f059bf 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 From: Alejandro Lucero For a resource defined with size zero, resource_contains returns always true. Add resource size check before using it. Signed-off-by: Alejandro Lucero Reviewed-by: Dave Jiang --- drivers/cxl/core/hdm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 223c273c0cd1..c58d6b8f9b58 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -327,10 +327,13 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, cxled->dpa_res = res; cxled->skip = skipped; - if (resource_contains(&cxlds->pmem_res, res)) + if (resource_size(&cxlds->pmem_res) && + resource_contains(&cxlds->pmem_res, res)) { cxled->mode = CXL_DECODER_PMEM; - else if (resource_contains(&cxlds->ram_res, res)) + } else if (resource_size(&cxlds->ram_res) && + resource_contains(&cxlds->ram_res, res)) { cxled->mode = CXL_DECODER_RAM; + } else { dev_warn(dev, "decoder%d.%d: %pr mixed mode not supported\n", port->id, cxled->cxld.id, cxled->dpa_res); From patchwork Mon Nov 18 16:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878873 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 84E7F1C2339; Mon, 18 Nov 2024 16:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; cv=fail; b=ZSWQoQ5cdLMR6i6IrTGIy557YYvIJvzgsH6rXn+QC39nTFUzUkeFwPMVIlYCfeBfa9tKCCP1BlAML6IWsGa6NwJWJxJa4gdOMiVZZjYb1X61G0ht9xdzUG7x+5z8DGzMN6IFM0419rFv2lwQ3OyVCy5stpZSk9R7bCT7DbKe+zU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; c=relaxed/simple; bh=RhVBs1yZ7D7RiIS2VzNZeuMsAV5ATjWxwR1UVwwUNmU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UcthCJUGz3Ehzu0YmlmCDw/cXRsOYwxAIHUqAcVGIZ685R2/PRpFKEFveQb3bC8PcflrfL4IKhJhKVmEJIbeK32VgwTunxI4KbqZIkF9U4tWeXzlbz5p8Ujk47WgGHDbHiebfGnSaM5bl0pNh0k1+Lyw6a9USUuFotDYpYFOSVU= 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=TSMk1+hU; arc=fail smtp.client-ip=40.107.93.48 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="TSMk1+hU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H33nJ12KV/j2cmWLJJ7XAl4ifg8GBo+Tu1ggWZWxQMmCW18L5dW/VBUpd2GCrlKWBj+6lHY2TpKSJSXicmVB3+muSypiOOTKSZR9vtqhRvDHCrMh8/yLMrU/E5PC5iojVwrGUkjN5KjbvGpXE0EVnKgDm9/PLLBeJDj2jpL1WUaAH/zMAMW3Hlm3i1UhHd8L6rdOvp+ZFXRzj3vEKhGEP+1vcqAPa9TUltB6grxP9R47c7CMmkQ4+TCVN0tlalgUVz1GAf9lfZvezx8f7JlxO5HtX8LGpI2foWF7Cg3ysGa9UIiV5slrpeoeGITHhBsF3sDh2iUjMFlsPqoFQ82Ryg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2jQDa4IFIQF+SzqQDWj4M8+JmNr96yvjH5t5terPZt8=; b=ylAdnV+G7/+/Dr5yg6LvjoDfLcvoWqgZ9vqQJ+fccj7gOz42wlcXFmf5FP6KdtFnoBeY2m+g52xg1g9fWFWEfutiGUYVRLtMLvmKIvMIxdOxVKOeJZQRx/gRhz0AYEsYdyiey2gE8znmIfSKGvDfst1TQZPVJcKGaLbRoCEu7pgJvUuLyH3uR1Z7FSoCwR0lS4+Tq3MsRHbCyjz321m3Q9XCpn6ShPTrREb3bV59ZzDUZBq0nmJVKCSUim9Q4E4ZI0dsbyrbKzzmNlqfQ14D7yCPWi1zEKguM0Ptuh3YBrjGgDbkALKPojJDy8nKYljQMQjnmicxVuv60VOOkerqNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=2jQDa4IFIQF+SzqQDWj4M8+JmNr96yvjH5t5terPZt8=; b=TSMk1+hUs0HFRq1OlozTqaC1wJN8uhIy+dR4FIrje0zkvpG2uf/NLJiIVxVgfiHFWyl4LhxS4Hqn3CN3p98Z19a5zgKxPH+a+QVmwllxq1ojebRiWFAW3rpUXofQATBoeQZ+unUObUiujMUeX+Dly195KNlC4e57ZVS1bKrD73c= Received: from BN9P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::27) by CY8PR12MB8216.namprd12.prod.outlook.com (2603:10b6:930:78::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Mon, 18 Nov 2024 16:45:04 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::ee) by BN9P220CA0022.outlook.office365.com (2603:10b6:408:13e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:45:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:03 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:59 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:44:59 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:58 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 11/27] cxl: add function for setting media ready by a driver Date: Mon, 18 Nov 2024 16:44:18 +0000 Message-ID: <20241118164434.7551-12-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|CY8PR12MB8216:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a6594eb-c17b-45d4-d45c-08dd07f059fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: pEwkPGZmteOZFblwFrkbhHw694KIqt7LAsA4hcwkvhTbSC/FhLV2JXjyb8Uwa0jEm/ZQuvF4zWM5q/YK5Ic48S+CjHxRZlbSyUb/i/4FTSyIc9DLm695L86bJqjFzSL4RCWaC0Gdk2mqTUC2vhugIRrMxOEYHsY/9mDMXEuWTijLBfud7DjOptayWcwBhQjKIjWvPuC/GEh1clOjqx808JdrJ2dCplShElznwN7YQcQNvb50MHClzcmBjR9cKiQZiIsoMN+Ta737Cup/gRjKPrSwB9F6Sc/saFEudkBOm5hdLN78VUq7DJVU7hlyouWWfraCTmhnWilA8F9r63uvdC6/yq5/P6ibZumcV4pZiHtNSgZMlAmxNhvEHnbu0/QDB6Y9PqoMaIV7h5EWS9ggGx1WXd11FGGfjJ6r0PITwIjgyg+0c6ijkr3jPOsvaxqbLERc+E62NZb5nueW8viXI2XzlsWLtlUntCoxQXTBc4iVxWrNpWr97xCNpCm+3y9yt44lH6MNa/FunbZsk5db/H82sNoLJETRGJQjARUQ51WFPUmB1cklS01jD25YeAT/X8xP+0f9S+r3DoWe2bDIN7jvdroz9cw7laMuZWMvWEq3oDC97r8A4pRgCgPZOC4kDQlztRozLVVhhmRHDxcAe9vxFZ6BsQ+3rJq8wbM+/HMapzfDX2b+J9H05jxttCQxHhhcZJkRG6s3Wq92snW68ae7e6LnM8vbqHEA8Ovnk4X8iSP5jXhkpHbuu89pO+KRq82zONcyqPpKvpdQqrrByOkmpWT+lIL5vhKKSRZpxIzYb2R9LkCsR8GmSO4wg68jaIj6e9rIf7Ydj4Ac72PPv0/J6Cy6V/ydA7nM63COhaP4pCBMyJomBgscQcGyRsbP5Af+rX9DB3qxUMM2Y8EHqmUHm/1c5bYMvICRwnHF+PrKbEpD88Xg4f7iPAOEBVrg3NuSpL1rNhabJ0Vjf6txScKebKk869q5yVR/QLSjPeXl/A6UupjmISuw99Aw4PmgQeTsqHvp3vZzPXLAtz68LOioKKJCBJpH/Zi2YnprPVeZ+3KHl1/aRjA09WMeEGPJgxHwdpO4niA8VecTwA1WnAXQjFxqa/Lpvt88lw2/DXpZc6kFxNzpl6hgLhwBBV/P9I/GZxyfcWyQvbyRGrRU/1U8G3H/Mqzt8BNGgFnxnzaD3R+OOidRExZu3O7cGO1YO5iyrD6d8JBsjGjXlqOgvlFeR+wf4N3D7i/N43CZ1RJz31gh0Sclx7ppTbNgv+IsmvJ3T1y7WABeD+ewv/5qzX3OWM/P6T9CLTsp1i4+IICUzbrPq+BPEhlHhmvGup7pprrjsyCcwSIQxQSm0YS1x85tIdajixaIXIr7ES8V0NkMLbLVzcWGE7powf2TEU7EtJIN12jBat3Kjy9Hpn6NUg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:03.8853 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a6594eb-c17b-45d4-d45c-08dd07f059fa 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8216 From: Alejandro Lucero A Type-2 driver can require to set the memory availability explicitly. Add a function to the exported CXL API for accelerator drivers. Signed-off-by: Alejandro Lucero Reviewed-by: Dave Jiang Reviewed-by: Ben Cheatham --- drivers/cxl/core/memdev.c | 6 ++++++ include/cxl/cxl.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 7450172c1864..d746c8a1021c 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -795,6 +795,12 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type) } EXPORT_SYMBOL_NS_GPL(cxl_release_resource, CXL); +void cxl_set_media_ready(struct cxl_dev_state *cxlds) +{ + cxlds->media_ready = true; +} +EXPORT_SYMBOL_NS_GPL(cxl_set_media_ready, CXL); + static int cxl_memdev_release_file(struct inode *inode, struct file *file) { struct cxl_memdev *cxlmd = diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index e0bafd066b93..6033ce84b3d3 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -56,4 +56,5 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds); int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); +void cxl_set_media_ready(struct cxl_dev_state *cxlds); #endif From patchwork Mon Nov 18 16:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878872 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) (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 4AD7A1BD4E1; Mon, 18 Nov 2024 16:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948311; cv=fail; b=BI+RuXKAoW6iZ7eKliGRzdqc2SUM71CqTvUTmwUJnSjEtV2wdwIL9dR287VbAy54E3eKL0rj6L0EXxJLiCdi90Is2wEj3viYvL3fWaIWRTtkSmdGAbpmjvCrOEEhcu0gDgT14T8DoweU2fHpZfZRZSgRDxWJKyBJSwBgfdBnojQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948311; c=relaxed/simple; bh=BlbPP/6ruWsGhS7lq7xyuWy+Tlg8H/oDopFgc80f3HY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hI71gs2nTrExSCXlwFd+yI/QpXYdEtOqBwy5wrXeS9Cdy2GcUdu7pn+3h6q3YBfX5sC/p1EiDG7ZMVzfvK8G+v7Ee20mdH3E7EHpj5crL+1+U7TI4bzsKvzEDQFTWPeX1pnxKjiKJlPq5f3+p0P1CTXXMgPUfFHCyahlI1jaSgM= 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=v4a+16pY; arc=fail smtp.client-ip=40.107.92.88 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="v4a+16pY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dz91HLjl72NSUaEb29dRI3uY5cGY0rxglMGNUZ5n2lFQH0b0HkQbPjscXYL3TkMXs5kLbyJDt2iWcBKYCaO1899+55GMZs080ESsN8kP6+flEb74gRkrhmxdRlw4ebw7E1acSsZE2X58Pd+SiOMD91Q+3Om7edh7FW7eOXSg5aE/4KyHHzEto2DEOFaSCQiE2M6IfpIcv3fCD/6oWm6GLDIu9xz94f58KIQkuI8w1Bw9i7CkxxZMoCt9xrHGjMZGCPlQXnnrpLB7FbLckDedkFBNKJQf0z/8s1XpvYBNgrLcxEQTsB8N9m2TuUENFxWUw2C8dhYfXF9p0se1ldTKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Aak2KCl1dryw5eYBlwRVzFdz5B1kvdjoNW4T7tk3eYQ=; b=DhCOFUE1nFTMZaRB752uDYgFIAUGZPH+dktxc9Vn9s1Qj1S6Sqx8iwxRv2sYrR9RcqHQTK9E0/Y1L6MlsJkr9+P70GJzyifMxBO8JxzEwBWZCrBbKDwII5sRcWrtAVUO3XzeRUDl5OPJw7rjEbSSMBr+zUA41rC7F6TwKMHff4Q9BDHp8zwh7BdD27hQcM+vS0xpGs4KtOCgdadJB66dBEwWcH1A1rtPL2e9uQ+SCXK/7+QTtBX15rHSXCCXkOYegcTbN3JjhWv+z/y6DKk9GtXU+kUb61RoVXQ5avwR2E18nC8Atu8mevJGSED/Bw/WCS6xKSGNiIa2CFgnOfBtTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=Aak2KCl1dryw5eYBlwRVzFdz5B1kvdjoNW4T7tk3eYQ=; b=v4a+16pYG0H0vBe7E8hKeoRKagnjjAFW0KWog66VHR/eJsmHpcFEdv/56UWVAK5ikgaDjhzMXRCN0zH4b9KHs7Qz66kDwMp3ByjCDwFLSITN6vCvfC+rpRa/CyqAYl4JSZsfOMxA2WdPr7jtPHhGxrLsZ19WY9kCfuHOaRe7W5U= Received: from DM5PR07CA0113.namprd07.prod.outlook.com (2603:10b6:4:ae::42) by DS0PR12MB7900.namprd12.prod.outlook.com (2603:10b6:8:14e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Mon, 18 Nov 2024 16:45:05 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:4:ae:cafe::69) by DM5PR07CA0113.outlook.office365.com (2603:10b6:4:ae::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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, 18 Nov 2024 10:45:01 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:00 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:44:59 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 12/27] sfc: set cxl media ready Date: Mon, 18 Nov 2024 16:44:19 +0000 Message-ID: <20241118164434.7551-13-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003442:EE_|DS0PR12MB7900:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f1852ed-a497-4812-5130-08dd07f05aac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: pYfRW7YC1O9k5BnZnmTCqnjOCmiL/jze8SkzOT+UAHZ51Pg37NMAMmMFsuQR5tEY9OK8JTE4+amwftMwOfA8iAf7jUzvwuuNDDXrYzRFJ3NiuK+urUklXg19WpS4CMapc9zjIFimpJc155sg1DOBBpHzkO9LfqiecZJD5A1poUHF+IJ/GrORc0Ia8YLvO455bM1Y1CrtT6jIU1LT2DADs0WkmesP4k5IPeFgbMsDltMrybrSdb/bI2VjX8ldoNepYILB9ImiSwvq1/ezEywbvO1DBm0WRYp15cxnOLzYn3JbsYXTvHixfAlBVI8OqhzX+zfq5TSw8uqPugQ+Kwzh7v8RSFRDSIbPF373Zu/SqDJDLoabfeFsCFPbGtCG7MQITJNZ3/op8ymbYCQ/rxYdYBKl2/1VEGGvJIdhoLCW94BhiUZZYFp+BrqzN0d3EraVGBWbCyFtBlDKtRNxp5DiuG4NFl0WOJiX0sXmntLdYgx03Luyo8xmGsiU/qbHV837HQrtfQuWAwsLwLaudWDMPRFU/53zolPz8zitSL7stHJuE2Z2He6jZtXkblungtNadn325/qioxHDC3sxrCo463II2XVEZXJdMfkDpMAaWj/22xRs/+0a8mcpCP0JGcDhK84SquPo38vuUKMGW3qxTiRDRJjMB6LHJrrzf7QDhyry7vWQVpzQQ+pBTrbtfgozzMVk39eQ9kpV9wFiQhDsmtAC7H56+eM2Ua3nF30yTT6lhaYP5Rq52TOqnwIJKIm7u1bKUXStfkRfUjp6xIv7y+hEsI2VdlojpkF8SkmOiohN+UAgZFZTHKy9BJhekpdlXrwUOqYdkHGSdEcBrx7eWNIa0we9cEBUkzp+xrLBpnyWehdkRVaYPUrRghgOYmx+HVuFAW59+7KOfi3v/vlvpafQEDAqlq3tzutWoP9qdFNOglStooz2I35w6veDgrJTR3iTYM0G1MxvEuQTu0HJAB2XiOildmfCYufX/yBov2fs1KqqMvqDG1TwOPTeOiKCjW8Zy8Ze+ygkDEsTf8Ib3ZK90xJhVqQBrRXjgC0XGPWfA/7Pwz/YXsXdaE2sQDt73RBKFW9t97MC1w1VA4lY8SiaM0vz1u6FejfsrkUV63YWSvLGmOwc08KuO8ak5k98K81zRISkvnEPvjviGb0DI3X2BaWVLHgPpVWfMCkbzjb+kyqw4W07/yr5p+GT9h7Cr2DlaMDXbnqxHllDQTRPVzQkxZ0rb2GPkLxCM4PJjoxUyQTGK7R0xTpq9sLHX17ooq31sUfeDjhgoAVcOnodllPPB+c+64ytvyETjTvqAOXPeIS4y0Kq73+cjCcoss0Nz7Rkp6Rl9T2GOzdHD3uafL/yEB415Bxo7ymE5SSFN1+bde4IbK2mTArO9C6otqyLhbFa4mnSXrrq3CGrtroDow== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:05.0485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f1852ed-a497-4812-5130-08dd07f05aac 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7900 From: Alejandro Lucero Use cxl api accessor for explicitly set media ready as hardware design implies it is ready and there is no device register for stating so. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 06a1cc752d55..9f862fc5ebfa 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -90,6 +90,11 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err2; } + /* We do not have the register about media status. Hardware design + * implies it is ready. + */ + cxl_set_media_ready(cxl->cxlds); + probe_data->cxl = cxl; return 0; From patchwork Mon Nov 18 16:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878877 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) (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 08BC01C2DCF; Mon, 18 Nov 2024 16:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948313; cv=fail; b=QloP0iqZllBnsmU2j4nDSmd4uSGwGrXkdrC+yKKJF6ocjpjskM5KEMuGtPJMhlzUp36qtZx2mGFHAbB1Q0XFyM65vSAd+v70QG95e+yAdR1Zigl7AH39T2oNY8vi60sAUZMEI6T8HTHHnd01gpdAsMLeUXdlnpNZp4cAVv/aB0Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948313; c=relaxed/simple; bh=xGeiuFmLrLZaVKe/5uBJmKf2dTCgm6MQ+Qpx55bz3UY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qtfHdIyMqY2IoHBdm0E/kZARhTcdfwXqjna1DcBZHSIBjv6KvguEH5pK5dZRjFcLgtEMSKsYyntX/fQhNGCWdWkP4YThgNI5XWwt/6K7wdtmsRUD5w906EUHbZIMT6IrqIKwhfYM3dX7Ha409MDO2I9nFscGCD8wlhdUG5BmyXU= 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=2qtIEVqB; arc=fail smtp.client-ip=40.107.95.85 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="2qtIEVqB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O6DbhKtDlldyu4JMKcKWBrhQTf8XNgX79vCvV+KIm0wCINZrWUYUJKJ1OtJ49DilgY4LZhveCQutl5Xv6qNNkUKejp2skaW1uHlOAE/AwwAEinHqBORtJpllUP2qkcw6XRzbXUqsGLPu31Zn/aViFgvTjT8q68Fli6PpAJfs7qXEAiopvz7kcvErtdeOQ3QfW6AABtUv7D/cWupqqDqQqrxDjy+oj0+gZsuSbb1cuQhrb4cCDASrGNct9eXzqDyJXPoK6YGQTrt1TJzO0cJG5KchRqF1AUx3UPJ/nORCsE7SXxLMT0NqMRP3i95qQbymB+LobAZQhbAB/90lwSETFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QQ6jzOoeJWGGzUOr5CYGUaAU/lwtiU1zntNhTpYDVdc=; b=y+xOOKXjNkJ7sfGB/Rc9S/paVjhavkPCkQUg8yyxmkOH/mn9gbrqbLXEnbOLAbSLd/5v9Upzw6ufIma4+yyxJ27YuHwDZAcLaqJTglgr74D/9IOXi63aT/tRyl5xxmDG+e9RMiQU3xH1BiSqUlJgm84tO+SlpVO0u9BNvExqLeXaYrYlRvnjN/RqqptZO3fXJVJc8Xtj1Eky2y9sPjUG+ka7eFkOg3BZ0YAwzfUmAya0WbNY20IwJjmEjXJplhg4+DB5jIi/2nKUY0mKTXFqgGgFjorEQDbLzyeh4ESAvZxiH2aJSHAk/+sda6m9Jnc3/z5cP+Y/bg8B/G037BKzFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=QQ6jzOoeJWGGzUOr5CYGUaAU/lwtiU1zntNhTpYDVdc=; b=2qtIEVqBCwy1sBR8U6QMeL1ZRJyJgZhmyxLoJeL2atKSkBT0D8++UiXOnKF77jK0tuCcl1Uu2arh3WBfRSKNWhU0Lb6asD7cpRyb7ACsVWlrvxg3h3AiVZM1bASZ3iCCjAv717GkAxlsGe917HVNDX8ySz1QH7ST/uLbYVlT2N4= Received: from BN9P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::15) by CY8PR12MB7265.namprd12.prod.outlook.com (2603:10b6:930:57::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:05 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::5d) by BN9P220CA0010.outlook.office365.com (2603:10b6:408:13e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:02 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:02 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:01 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 13/27] cxl: prepare memdev creation for type2 Date: Mon, 18 Nov 2024 16:44:20 +0000 Message-ID: <20241118164434.7551-14-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|CY8PR12MB7265:EE_ X-MS-Office365-Filtering-Correlation-Id: 88a0910a-b5d7-487c-7cdd-08dd07f05ac5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 6wPrTNUj7tYsIcWV6N1w42WG3COUwrGhk86Cz3gDJg+XB18J0B+RrbSY7MgisyvHY5rjzR3ziYJuoQZrbCZcIlyM17yMVkKsuW3kLwE3mDrXbC82vI40EM5AqBa0m4c9pXnavZJ4loxpgA7uA3FUWk5wDlq33RZnrhT8gsTkEXULKageXvqMUCbrn2xjvjiz3V+zANoZ9pWRh3COJrvevnLfcEJJdRpdFmmDPdi2Htf1cZ4dpgLPJQPBcCOjqJLPWJiIUWPbpcTk+HoAMWw2F3tq7JfW9W44ILlt207Sfrl/mD3x7qsdPP3H4gUk0mxhx/4sjmfbUpwKBE6benwBpJpMD5oNzJYXqsJhXmgN4a51FxFEYaLn1B5MDbucfjFlouEQG9DGuIhLWmASAVwKLSUCuYDM1IZy/lcMAvXxp0ONx5UPjTTHZS9wqwo7M18ON+eu6/o2+XMSOcrzSG/DtJkzze2IstwiY6eugYAkFIcXaPIGiwPbf2tG5trsknBRrAhsRpPCUIF9V2a/hrq5+qcPTrHcnQB7iN6UiBnz0N+4/WPOq7gF8/gbsx0IDQ73breSwb+xbV9BDkJ5rSmm11w14G/u17dLEId7juZqP24/bvE0MJEcaWn3Gyczg016QOhnErOA1O8XqR1nzuXSZYXeoiJSY8Jc6RHTS0IGAk/jPRexL9L3pn0qMORIjzPQBCgCIQ0KjyXK4xhG9odDyMUsnIw62mTdUH3FxFvfmykYymUxYTbQWiFrvjDzOuZ0M3kFD9gtaCy2LlxlVbPNiPFqksUNeHDjEn8SVT6FWlp1Lb2i0U7U99mcy92YfrLG3UKg5PDm24LiaprMZvPx1QJXQlYiskHLIaaBYMlwTE0fvbloVuAfEoA4J6ZLYd0T/GYCjZ9JUdv6IJhKjXEQ5CjjmkU1JcwmrPjnqTgowfIQln+NaUcDED8a9AcKg6Cs8Oo7+yy6owmSpl7UkA78WEhuoLOlE1MH3aLOVHVjnRTipL0NUrInKDAmOBUeAS26JZ9dqZqxwk5ZUPiY+19ytuEELgwUR4uEC0V4aGZ8zcQXWo875JpbkSGi9RzsyRY7MFtoyqZ7LCwU/+Kd7EaZFQ9I0OBG98OsMmg6X6H49yqWYx8xeUdITzUOzxz1wMNBOvZn2fLBSSDlXW+0mesOxj/riW4O7CdBtcoed+2xb/N0mkYGKTwGW7f8bMxf3zsugkkgjopQ6MG+BzVdwQ0gXQovS5jmhoED1TDTGOYZ/J15GNqcctfGlD0eA7pKnxB9WeV8OXrzKaXAx8xeOOf0zwUbrQyvNTB90F5tWi+UTUs4yVy+wtaUb9JfoRyttUegTgkxN9VPz/u0jCXW5mSRBQYste22uuxxq96vyDQa1W3FTiKLZQWYyfWnuxOwZNNlUqrmz1WlRWpn4AW4oGwT7w== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:05.2134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88a0910a-b5d7-487c-7cdd-08dd07f05ac5 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7265 From: Alejandro Lucero Current cxl core is relying on a CXL_DEVTYPE_CLASSMEM type device when creating a memdev leading to problems when obtaining cxl_memdev_state references from a CXL_DEVTYPE_DEVMEM type. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected. Create a new cxl_mem device type with no attributes for Type2. Avoid debugfs files relying on existence of clx_memdev_state. Make devm_cxl_add_memdev accesible from a accel driver. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/cdat.c | 3 +++ drivers/cxl/core/memdev.c | 15 +++++++++++++-- drivers/cxl/core/region.c | 3 ++- drivers/cxl/mem.c | 25 +++++++++++++++++++------ include/cxl/cxl.h | 2 ++ 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c index e9cd7939c407..192cff18ea25 100644 --- a/drivers/cxl/core/cdat.c +++ b/drivers/cxl/core/cdat.c @@ -577,6 +577,9 @@ static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxle struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_dpa_perf *perf; + if (!mds) + return ERR_PTR(-EINVAL); + switch (mode) { case CXL_DECODER_RAM: perf = &mds->ram_perf; diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index d746c8a1021c..df31eea0c06b 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -547,9 +547,17 @@ static const struct device_type cxl_memdev_type = { .groups = cxl_memdev_attribute_groups, }; +static const struct device_type cxl_accel_memdev_type = { + .name = "cxl_memdev", + .release = cxl_memdev_release, + .devnode = cxl_memdev_devnode, +}; + bool is_cxl_memdev(const struct device *dev) { - return dev->type == &cxl_memdev_type; + return (dev->type == &cxl_memdev_type || + dev->type == &cxl_accel_memdev_type); + } EXPORT_SYMBOL_NS_GPL(is_cxl_memdev, CXL); @@ -660,7 +668,10 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, dev->parent = cxlds->dev; dev->bus = &cxl_bus_type; dev->devt = MKDEV(cxl_mem_major, cxlmd->id); - dev->type = &cxl_memdev_type; + if (cxlds->type == CXL_DEVTYPE_DEVMEM) + dev->type = &cxl_accel_memdev_type; + else + dev->type = &cxl_memdev_type; device_set_pm_not_required(dev); INIT_WORK(&cxlmd->detach_work, detach_memdev); diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index dff618c708dc..622e3bb2e04b 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1948,7 +1948,8 @@ static int cxl_region_attach(struct cxl_region *cxlr, return -EINVAL; } - cxl_region_perf_data_calculate(cxlr, cxled); + if (cxlr->type == CXL_DECODER_HOSTONLYMEM) + cxl_region_perf_data_calculate(cxlr, cxled); if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { int i; diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index a9fd5cd5a0d2..cb771bf196cd 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -130,12 +130,18 @@ static int cxl_mem_probe(struct device *dev) dentry = cxl_debugfs_create_dir(dev_name(dev)); debugfs_create_devm_seqfile(dev, "dpamem", dentry, cxl_mem_dpa_show); - if (test_bit(CXL_POISON_ENABLED_INJECT, mds->poison.enabled_cmds)) - debugfs_create_file("inject_poison", 0200, dentry, cxlmd, - &cxl_poison_inject_fops); - if (test_bit(CXL_POISON_ENABLED_CLEAR, mds->poison.enabled_cmds)) - debugfs_create_file("clear_poison", 0200, dentry, cxlmd, - &cxl_poison_clear_fops); + /* + * Avoid poison debugfs files for Type2 devices as they rely on + * cxl_memdev_state. + */ + if (mds) { + if (test_bit(CXL_POISON_ENABLED_INJECT, mds->poison.enabled_cmds)) + debugfs_create_file("inject_poison", 0200, dentry, cxlmd, + &cxl_poison_inject_fops); + if (test_bit(CXL_POISON_ENABLED_CLEAR, mds->poison.enabled_cmds)) + debugfs_create_file("clear_poison", 0200, dentry, cxlmd, + &cxl_poison_clear_fops); + } rc = devm_add_action_or_reset(dev, remove_debugfs, dentry); if (rc) @@ -219,6 +225,13 @@ static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n) struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); + /* + * Avoid poison sysfs files for Type2 devices as they rely on + * cxl_memdev_state. + */ + if (!mds) + return 0; + if (a == &dev_attr_trigger_poison_list.attr) if (!test_bit(CXL_POISON_ENABLED_LIST, mds->poison.enabled_cmds)) diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 6033ce84b3d3..5608ed0f5f15 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -57,4 +57,6 @@ int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds); int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); void cxl_set_media_ready(struct cxl_dev_state *cxlds); +struct cxl_memdev *devm_cxl_add_memdev(struct device *host, + struct cxl_dev_state *cxlds); #endif From patchwork Mon Nov 18 16:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878874 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.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 B3E0A1C2432; Mon, 18 Nov 2024 16:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; cv=fail; b=DkLA1yCOitx39YP7bxSsfA5WaLgGqombI9tfUDAsFS1WURnpSZdfdO+6PR9MqEN5yvTzQTg3+sXXR6Kbg0ghem0r8M7klEGpOVfh3wbiwdbZeXOuumm3+yR+RbgWcPNlzJUxkm+Ff9UvCdq2gZ+8j99Uox1gZqfRMwiD9QKU0L4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; c=relaxed/simple; bh=1j6TNfg+JhX1kaacDFWTj+ov4D9cTBSIAoU/LnIHk9o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Am5Abdcl7goG/RepUlXXmE6EzbqxdD5kFz8FEqmGBroWPubjB+S09jGlsw/lKsZcujgMVkvCM5CUfsqTYbyEkShYxHhhjShg89ej4/C3ETKDdYCYEaE7c7toKf4InZ2sifKGGU4cfO5e+DcDnghbNXfXiks3dydy1o2NaPHWGAY= 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=hkFq0ShT; arc=fail smtp.client-ip=40.107.100.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="hkFq0ShT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yHQglc8WMk+cvf4U4sjy9yA4e+1NIaZkK4TCUuxh5BuKSPkR0Eyoc17M7K1rQ8Y2KDWd7liorww1GyRrCFCHdoQ9NxSrKi/5E1boxtDWp0mgR2UQagvPoIrQui1jX5pAIz3v2TAc5jgT6w9iMGyv5v2zLU47DjE96yFETb4hJiwE00bi8JqMGNf2b1JBz9E4fTUYmzfm0TVaDf6s00hfn9zRLsO4DtRfvlrpHcsMPG3PmqxI4YJb1y2MrJmg8r1O8JJaARpK3Q+dayEjxRR4HKrmL1MySSTfDqj0xp4Kh2UG2MVlO9i/IWqCBlSp3sbLiuplZDKBnmpD2wrhxgrBrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xvPgqfsB6q6ONvnvsSCAeyATNjbrTCp8brPhoXkv0HE=; b=SfgcHyeBOlAUX6JLHscaO6cSF2yIPqegeT7lvxCMMaa2bQ2NCuvpC4rGQV7e5rgKxTG0jt3+XgGhqVbzdgMrCT4v6gp7EiMCcJWFKd51rYUOb/CO6wLaRq62ifkYrRegUNXILpsyko8ayCi0hl/XP8YNAWtxtpXx/IHDihbTI+VWbUDzXflJUFYdLxc/78gr+smqPL3lK/ZBOOpvJSW3kY40TyeI9kBoF+4agOrKnmvj+w/tRqQQC//3xnugnJkBUeDvyWWHO8ywR85UIAZ9yXsQOhSmfoGyXSjNZlJJ7vosvJ9sJ8pt57J/UnGiix56M2D6q38QncTyZ34Wz2S2UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=xvPgqfsB6q6ONvnvsSCAeyATNjbrTCp8brPhoXkv0HE=; b=hkFq0ShT7gi83WBWcZkyGLvf7b95Yng/urZOiRzbnKfL5vw0WuwX//7CSlmBJdAynzqdNfzf2XjWUhXysnYtI+z+UXFAPLOuOnKuwQrSsS0IUQOw5KoDfZCgFUA6CG31uXmUPg/FiBP9xwrZ4OFU+tGM04QWi8MkrCUEE//S+Rs= Received: from BN9P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::23) by CY5PR12MB6300.namprd12.prod.outlook.com (2603:10b6:930:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19; Mon, 18 Nov 2024 16:45:06 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::8a) by BN9P220CA0018.outlook.office365.com (2603:10b6:408:13e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:05 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:03 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:03 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:02 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 14/27] sfc: create type2 cxl memdev Date: Mon, 18 Nov 2024 16:44:21 +0000 Message-ID: <20241118164434.7551-15-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|CY5PR12MB6300:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bc3c4fb-9470-4e18-1615-08dd07f05b20 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: QakN061NIQ2cd0pX4NjI7ppBQUA2/20811mmeCMZdN6/HG+xK+u36usIJa+T7pFxHqabRN82NfOpy9CyBnXHIgXhoYirrcFHO6YQPUWINyB415ZRkTZ0YPG7mBjnHYoZdoQbrZwi0EMQtjhmEZbb1NoB4l7FvRDUWpCTMCQua3v42SYOIUEZ3lGWXAvQvGp/dbSUruzHvsA5/Fk8eDoqEenbbRVEoIBTvyV75zBrQXcEyUxwZ7E0+tDd30ApwgEk1WByYm24CED0KvXRpzXYrS/+RbOWIZW9UEMqCoB2imksIO40d05KONuxxogjRSYhp5upnjW5kj+DCF6pSoz9eQxja4cCzQz6CxIepsQNzfoNF3mXzp8gKizLHfhR0YZJxhaFYTngmLUxve2Q7PUGU+x2uOvfFj1mbOHz797YicpE2ZdRtv+Vo0BOeclvFtUfHvnEOhEmKKu3pq/ArNNrB0MFLInNzYLnh+UQNZbX2pwxl74s4As/O0uv9m+8EAzjF5DNKF3l0ORH6fKKUywbfQyeE7tbiFSz+9w9yonYa2GdG9TLihHckUyAFM7FvMFiauCfYXlwzqJrhZyabMbGzJ+nmATEUisLdxpozV8lafdUDYgkjMpNJED6MdsR+pvprQaAIFNDzEIlZ3zgMCa8En7LyYLVVl909gkOHQujGQXASOlpHB/MmQ2EPtqK2QceOT4cwo/lmD+a6oqlXIWhbrj7zEi4TU4gid7RBaA3eOVp7o83AZLDgT0GBHExrD1eh9IJyGpZ/loWiQPFTlz25ALW9lCpe8gzEzKFOHR349qL69mx9TDgvN8+KBeIx8n9B9Vk8jMHqLvXfqftaDFLgaugoKoEGVVK+KdCUO2UfI9Gboe/rWbpPzTKXxwsewGxRgwO0kAHn95tTKEHJmSZU08vnCB8OZbpZtzAHZGIdSqhsrDV3nG4VNmdnhdQt3zPTuMhdsBkbDBGoiLvwbrF9mEF1uFtiZuZazBd2QqAm9xMHdhxm8K1PaQ8PhRfcZoFllRSE6PA6ummmF7BnfRH02LBhL3JGxTVw/Lm/zyu1+SjoMJsAHSmfDsXzH6+yZZ6TBIt7bOGyqKcvGBNfGxwW4bUzvKHNFpuwi9xxeIWZHBbikNCDHI/Q1nZQLqtDdt4DezIrEpIlyMVNDGpQ7OSGZTJV0is5vhObfM359f4b7JxTavzCunAseAUt72OcOTj4WJebDGg/FOVnMx+/uIfmimnzFGRv5ZIPGjgawz8R5W3Nj6O1P/7pkoP0fhtLH1EJHwkD1PCdQHzRn9FciOnfxTuPGYkQI0Wm3g/zFQbmtPoo8HL5BbWApbzgFyLF1fi7ln/MyMxnryVTnNpAFHPXXyXM/POF1qhe4hzQc64sNU1yirHOc085r1vvuGo2rDUzu/wezhOWDhgZmVzW8KCGw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:05.8072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bc3c4fb-9470-4e18-1615-08dd07f05b20 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6300 From: Alejandro Lucero Use cxl API for creating a cxl memory device using the type2 cxl_dev_state struct. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 9f862fc5ebfa..7e900fbbc28e 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -95,10 +95,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data) */ cxl_set_media_ready(cxl->cxlds); + cxl->cxlmd = devm_cxl_add_memdev(&pci_dev->dev, cxl->cxlds); + if (IS_ERR(cxl->cxlmd)) { + pci_err(pci_dev, "CXL accel memdev creation failed"); + rc = PTR_ERR(cxl->cxlmd); + goto err3; + } + probe_data->cxl = cxl; return 0; +err3: + cxl_release_resource(cxl->cxlds, CXL_RES_RAM); err2: kfree(cxl->cxlds); err1: From patchwork Mon Nov 18 16:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878875 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2061.outbound.protection.outlook.com [40.107.212.61]) (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 E7E2A1AA1FF; Mon, 18 Nov 2024 16:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; cv=fail; b=Pvpeucaqnu/6pcnkR0rKZkRw7s/9sDedn58rOP61UR8Opm2xbz5pCSikuqOG0x3Hhid8GqBG+7ngMpbz/ExVjb2zajjgD0vLex5ByhT8N4PFO7e8U/sQBInbWpHM3GwAo+sW2G942fUIwCW2xc0fVjaqBQ7tqGnR0Z/oSeXzdl8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948312; c=relaxed/simple; bh=UlWIalgg65iIEn2D/5F+OH87TeYedvng4SsufzY56Dw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S5Vge85hWmzARbv1MMvkdjVPP/HhyM723Znb2PyLB7f/GvAt339WVBs9F85aEndndIjwNRKj5pZ6Kemp2MuRDn2VI6H6fZd8tauKuMBxBGCzeXAA7TFWLsalfodYM/CxrkyRYN7XseRXuBGkmuFXksVIOAA7DWcx3VzoCJC4NKo= 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=Ow3KCoLi; arc=fail smtp.client-ip=40.107.212.61 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="Ow3KCoLi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XVN4kkejly5nmk2Pq1+Za7uH8TyQU6jR2TaYtx2FNiZCyF/6SkCu/70QLdTVQJhxsdJlLpSTbup1ef46JvTiv57MaecAs05VVDG+aNAm8MuNEeX3WGhAYHICgn0gIXoPU9XJUnnWxNpLWDfTz68QfarooIRwQgg5KPK2uTAZvnOg9rMmKTTQ0CUU7HzUg6VNp9P4UZwsUBn8r20CPAD07mUvtAc6DvmRE6FHBM6MwN040t1tf/0YPg5q2l2+ZSBTgifD0iew0d17ji2TTgifGbGILyAzuSchPE6qNOc2BJhEALDRju+aQqkkPhUF0vbM9jmsN7RXBz4feYlbQ7KVuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hZmlWyY60fGyVxcfHHIouUQ8d0SdqUhrYmlcClg91zI=; b=zPWnqKEp7vBsZGfbeg4Grd0n1EAOu5EoO0XgqLk4AIbSutNtC4dLnLmI2Xv51inJtkWMMKrEgntWuCs+iD57fl5bpYNtCIwXmYuIoPRY4/aOUoqWjkUBkZY+BKNwF8Mu5FVhvRTq6Bchj1981F33IlJMYPzzfyQZHPeLXaG4REmcMU53sf57K5nFLI5g4Rkreo+/QgbCMJFQpwO4grVbBfkJJOx5H7TcxMGIwjBcy8dYfP8lIJXOC7Vc0NqCMX4UXTDAW6qCxeFG9AZbIG8B3GQCh0NNicjBT0bEVg5LHqD+DxRUnOvF/HlqdCqkHD+e54TKuvx7urJvYCyJnkecFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=hZmlWyY60fGyVxcfHHIouUQ8d0SdqUhrYmlcClg91zI=; b=Ow3KCoLiUt/LOhshQTLANLdNqd0aeulouZjaEyVbLVHURaotYE0NDKJZ3zcH9ecofH6mrYK7hvYHV8QLn6kw4pLcKOrgqghMdIQgBTzeoZ0IOHJepXmyl22ZZTl/9+jOf+l89HAEWNh3N4FLopH0i3KgkUUu4d0sbfuIfTaUzkQ= Received: from DM5PR07CA0120.namprd07.prod.outlook.com (2603:10b6:4:ae::49) by CH2PR12MB9457.namprd12.prod.outlook.com (2603:10b6:610:27c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:07 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:4:ae:cafe::55) by DM5PR07CA0120.outlook.office365.com (2603:10b6:4:ae::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:07 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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, 18 Nov 2024 10:45:05 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:05 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:03 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 15/27] cxl: define a driver interface for HPA free space enumeration Date: Mon, 18 Nov 2024 16:44:22 +0000 Message-ID: <20241118164434.7551-16-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003442:EE_|CH2PR12MB9457:EE_ X-MS-Office365-Filtering-Correlation-Id: 03df19cd-cb30-45da-2b07-08dd07f05c2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: YoxLGH4cXgZIdSORmCOiGYCDyMsfJOwWr0C09rKquuyNefJEHTyqKQTwI6LTODUTgz+/jN21UMozQQxjfqf+nOiYu+Na6ouXNm3uYfG6dczv/pIwUyHa2RZA3ZiWuX/O095FmAESErzTqbyTdyXT6QKykBwMh/xSvi3GH5Uql0Li4uBet+r7ZnDRNIbjvrx/2GMlgDsa3u5MYQ6ZPDvVhjDoDX0UyJHIqNSUwZcyKZ7woMrLl2hmTZqfJYbN5BTcHjTQv9fI8BtTAS4U+/xZDpqxlXCmdQEtTyuZNORHk1TD1lukojea6U0bEGAi2Yh6rvqV8JcjzERYBcVvvXYXZkyvtcUD1iv6Z58OeKk9PpbuL3uEuqdRH3qhF8m6gz7pD9oD/GabgIObQuQCG15WwL/5nve2hOIcGiaaF9VbF2mkcbgiWr9iK4fDpFzL/YYxp/uCqdEh1nIe4crwxKB+1c2jaDDfAWQe62cxJ77MlG2H3v7Z6736CsEsbiM3Zhioe5zNGKVAGMdxK/lVE+aIIJJTQgGGD2GPnu5/q9wLKFPotqOTKGWOl0LnbYdxOMvZQcP+p1Ty+aYqUJ+IoIjqeFrcW9zhNWOj4OXWhl1094x1JylA5Nd0VXb6mvkQQvC0x1f0cfOjORb7URl3kbR/pqoZ+frQjXmyzguFmKoB+OcWnu31U2OTWy1fUSsFg+p35CJtB/CeyZCZTaj3l4kCa7oJ0OWdmgcq50xBSa4AqFKXd8s6SrttIPoACj2TbWeZRSLECKC0Xopx4ZtNeVspYZbs7e4WoCKl5IzwRcNSJKPqnAxvrQkthrIiTG07EMgudkU+8cnAVo5scX2rinG2ExVzVXQHbhWu8ABna4w3KVdq0AmUDQzncTHp/9xVoPLiqtDl7iJq6XXG2jAQWTmO2rRwqfs2Xee/hl+jkEskvK6Qu36SSFxTuga21GhH1wW/vRh/Rvp75cD7FHOkI4KJYnOrR9DB9BclwjwfayxnKAdw+WoT7XO3R0y31kvIHS56uLfUZqM/AzZ2NWT2QYU3lr3IKK9YxhXyrUzaX7/GF5S2PkX3PkOd7+SBafmkdGNS7rNCJ0M653CyKXshChYz5A4cbFcRYXfwuQSrvGMxF+hISovoqxhlPsyaQxPJTlj0nHJH++9jVJ/CbFMJu7TDo3FQY3N1ejimEKhxGgDeKltLRLTiQAacgF5QM4HVJSW/N0u0UajcAm8IH58JSb/3mRZEOdAFtu74K+91iSPO3K7pTEOXGvYZUYIOsWARhBPu0A2kkc3AgN+XlUtOVNJN6HWSeRprNgHASbW93xUwHNpXHqAOg1s6/1SNyKaO2uKwaxvvIIp6fN65uHuO/lmqSQgV4bIQcqb9eD9/lH1qQOxOEQ2jjgUJIf5etnMlM2rOpkvet5I1oBEWzEzr60LpXQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:07.5641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03df19cd-cb30-45da-2b07-08dd07f05c2c 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB9457 From: Alejandro Lucero CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is create equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H). Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region. Based on https://lore.kernel.org/linux-cxl/168592159290.1948938.13522227102445462976.stgit@dwillia2-xfh.jf.intel.com/ Signed-off-by: Alejandro Lucero Co-developed-by: Dan Williams --- drivers/cxl/core/region.c | 141 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 +++ 3 files changed, 152 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 622e3bb2e04b..d107cc1b4350 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -687,6 +687,147 @@ static int free_hpa(struct cxl_region *cxlr) return 0; } +struct cxlrd_max_context { + struct device *host_bridge; + unsigned long flags; + resource_size_t max_hpa; + struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa(struct device *dev, void *data) +{ + struct cxlrd_max_context *ctx = data; + struct cxl_switch_decoder *cxlsd; + struct cxl_root_decoder *cxlrd; + struct resource *res, *prev; + struct cxl_decoder *cxld; + resource_size_t max; + + if (!is_root_decoder(dev)) + return 0; + + cxlrd = to_cxl_root_decoder(dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; + if ((cxld->flags & ctx->flags) != ctx->flags) { + dev_dbg(dev, "%s, flags not matching: %08lx vs %08lx\n", + __func__, cxld->flags, ctx->flags); + return 0; + } + + /* An accelerator can not be part of an interleaved HPA range. */ + if (cxld->interleave_ways != 1) { + dev_dbg(dev, "%s, interleave_ways not matching\n", __func__); + return 0; + } + + guard(rwsem_read)(&cxl_region_rwsem); + if (ctx->host_bridge != cxlsd->target[0]->dport_dev) { + dev_dbg(dev, "%s, host bridge does not match\n", __func__); + return 0; + } + + /* + * Walk the root decoder resource range relying on cxl_region_rwsem to + * preclude sibling arrival/departure and find the largest free space + * gap. + */ + lockdep_assert_held_read(&cxl_region_rwsem); + max = 0; + res = cxlrd->res->child; + if (!res) + max = resource_size(cxlrd->res); + else + max = 0; + + for (prev = NULL; res; prev = res, res = res->sibling) { + struct resource *next = res->sibling; + resource_size_t free = 0; + + if (!prev && res->start > cxlrd->res->start) { + free = res->start - cxlrd->res->start; + max = max(free, max); + } + if (prev && res->start > prev->end + 1) { + free = res->start - prev->end + 1; + max = max(free, max); + } + if (next && res->end + 1 < next->start) { + free = next->start - res->end + 1; + max = max(free, max); + } + if (!next && res->end + 1 < cxlrd->res->end + 1) { + free = cxlrd->res->end + 1 - res->end + 1; + max = max(free, max); + } + } + + dev_dbg(CXLRD_DEV(cxlrd), "%s, found %pa bytes of free space\n", + __func__, &max); + if (max > ctx->max_hpa) { + if (ctx->cxlrd) + put_device(CXLRD_DEV(ctx->cxlrd)); + get_device(CXLRD_DEV(cxlrd)); + ctx->cxlrd = cxlrd; + ctx->max_hpa = max; + dev_dbg(CXLRD_DEV(cxlrd), "%s, found %pa bytes of free space\n", + __func__, &max); + } + return 0; +} + +/** + * cxl_get_hpa_freespace - find a root decoder with free capacity per constraints + * @endpoint: an endpoint that is mapped by the returned decoder + * @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B] + * @max_avail_contig: output parameter of max contiguous bytes available in the + * returned decoder + * + * The return tuple of a 'struct cxl_root_decoder' and 'bytes available (@max)' + * is a point in time snapshot. If by the time the caller goes to use this root + * decoder's capacity the capacity is reduced then caller needs to loop and + * retry. + * + * The returned root decoder has an elevated reference count that needs to be + * put with put_device(cxlrd_dev(cxlrd)). Locking context is with + * cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder + * does not race. + */ +struct cxl_root_decoder *cxl_get_hpa_freespace(struct cxl_memdev *cxlmd, + unsigned long flags, + resource_size_t *max_avail_contig) +{ + struct cxl_port *endpoint = cxlmd->endpoint; + struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; + struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + + if (!is_cxl_endpoint(endpoint)) { + dev_dbg(&endpoint->dev, "hpa requestor is not an endpoint\n"); + return ERR_PTR(-EINVAL); + } + + if (!root) { + dev_dbg(&endpoint->dev, "endpoint can not be related to a root port\n"); + return ERR_PTR(-ENXIO); + } + + root_port = &root->port; + down_read(&cxl_region_rwsem); + device_for_each_child(&root_port->dev, &ctx, find_max_hpa); + up_read(&cxl_region_rwsem); + + if (!ctx.cxlrd) + return ERR_PTR(-ENOMEM); + + *max_avail_contig = ctx.max_hpa; + return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_hpa_freespace, CXL); + static ssize_t size_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index e5f918be6fe4..1e0e797b9303 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -776,6 +776,9 @@ static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport, struct cxl_decoder *to_cxl_decoder(struct device *dev); struct cxl_root_decoder *to_cxl_root_decoder(struct device *dev); struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev); + +#define CXLRD_DEV(cxlrd) (&(cxlrd)->cxlsd.cxld.dev) + struct cxl_endpoint_decoder *to_cxl_endpoint_decoder(struct device *dev); bool is_root_decoder(struct device *dev); bool is_switch_decoder(struct device *dev); diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 5608ed0f5f15..4508b5c186e8 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -7,6 +7,10 @@ #include #include +#define CXL_DECODER_F_RAM BIT(0) +#define CXL_DECODER_F_PMEM BIT(1) +#define CXL_DECODER_F_TYPE2 BIT(2) + enum cxl_resource { CXL_RES_DPA, CXL_RES_RAM, @@ -59,4 +63,8 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); void cxl_set_media_ready(struct cxl_dev_state *cxlds); struct cxl_memdev *devm_cxl_add_memdev(struct device *host, struct cxl_dev_state *cxlds); +struct cxl_port; +struct cxl_root_decoder *cxl_get_hpa_freespace(struct cxl_memdev *cxlmd, + unsigned long flags, + resource_size_t *max); #endif From patchwork Mon Nov 18 16:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878876 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) (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 DD75C1C2DA4; Mon, 18 Nov 2024 16:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948313; cv=fail; b=NNtm9n+ni0VQKLjk7zb+vtevSW1QlO3sMHjnMxiS0l8KWX8a6vyxqdCeODUBWW0m69ZRn5nXl/9ylewM1j9AtA1SvoO5ForNcULUZXCKpx0JtuSnIyFj0z54VGjjNv1JmT93OpTc21dILj1vPEaumAI1N4Z0OZSa7BvU0wcAyqw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948313; c=relaxed/simple; bh=O9dOrsDGGugg4T1RmSmdZOpsWVosQUJ7maTB8/LDIrY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X9JjlKgZdu8/Q6FU3AeiYySird03R8R9YPbJUJtOkiW3LHeloVpHZHyKI6pZjnbPlPcqg6NjYXMpMadH1/vvfBx22FWqSlBo6SPEZqhCsbtnOn/+KapvOHxVPHSKpn5aGZGN/LV60MxikWVlhz1mGZlm3iXIJllE9ic/iNYBtb4= 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=JFql1dK2; arc=fail smtp.client-ip=40.107.237.40 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="JFql1dK2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aGpBcdwo+fyo4P3gLBmw6vp4q3zDTlNz4y8LFLq8ncOAbd+lpD26Gkl05VWc/UNM0lNRf4UTUFbhpaqrtrXKKApKOBkdyPclP6B58imol7kk9bWg0z3yUKtMAx02uWu0XDUAhsMtcpBwCnygle+iXsCadoLjuPKr+bMz7esDS1utJ3j/b1ZQOGB22LuLPLpM5uInYqHrS8paEQyg2gQq7tMwDu8lJ/MuqBHuLnWFzDHTEgbWwvBbCowsV38Saa9zRY1h9mTCHqUj/CqfkNn+Tt5wNBVy8mBsurgHMTxY4BtR8JOZlbTnQ2xPcEXieG1GFP6CZoYDYiowpQavFMei+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IiyQNheEWYtnZdU+UzBMgzSMrVHMJSJsRJnXqABw19k=; b=WhiVRuJfQ3f0T6p7jSRwoFqvfhCUkuoF+eBB0p9GwUcU7a5MbnD+aeymQiGQgVZRHur4rSrIgX7jpPPO72JXTQd+cQ3nyYdV4uOfHWt1wpA2cZ8jTPa/IQrLXe5In27jhxJskqqS5FNo0GNmLavnkn9KtfeMNQQqYQw8nG68UPD1+9GL7n+F2095mUh8B+fL6o5n9Q5disx0rWWJY9rrOsHklBZi0jFVPTyZhf46bTpGonmsUOZJoJPhUhUzd4Z8WhcNfg8IVJRHTc+3AekJzd2KdI3eFID8/qtYI0DMJaf3tDVypMprs7nONpaAnV8aHKZaDTXR+it8gtGVjQGdeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=IiyQNheEWYtnZdU+UzBMgzSMrVHMJSJsRJnXqABw19k=; b=JFql1dK2U3iVo2Uq4NB+R1hGJSAZHAvpOUS/ta0K4E8V2Cv9vKpYOfqCH+WIQGWzyYNgVgFIeT46klrlSQ5xi6bjkjAcqUYitu+Dd4g+cL1+w1ZkY7Ritgvci1rNtZPTHuXlFuQgfA9UVgnPcGuY9qBjcE2RiIqcZANR/dy7sjE= Received: from DM5PR08CA0047.namprd08.prod.outlook.com (2603:10b6:4:60::36) by PH7PR12MB7889.namprd12.prod.outlook.com (2603:10b6:510:27f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Mon, 18 Nov 2024 16:45:08 +0000 Received: from DS2PEPF00003445.namprd04.prod.outlook.com (2603:10b6:4:60:cafe::a2) by DM5PR08CA0047.outlook.office365.com (2603:10b6:4:60::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21 via Frontend Transport; Mon, 18 Nov 2024 16:45:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by DS2PEPF00003445.mail.protection.outlook.com (10.167.17.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:07 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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, 18 Nov 2024 10:45:06 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:06 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:05 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 16/27] sfc: obtain root decoder with enough HPA free space Date: Mon, 18 Nov 2024 16:44:23 +0000 Message-ID: <20241118164434.7551-17-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003445:EE_|PH7PR12MB7889:EE_ X-MS-Office365-Filtering-Correlation-Id: 34a506fc-bb3e-409f-c4ab-08dd07f05c71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: fQTtb7gv7oOE3uz80S6jZI7aU0q/KPW7R6HcqmYkyuc3YAeKYYis3Ky9tT/4EiHetgIEX2dAMQLCymZGFyotsmVA0aSfhChZV95u7TMEKFUj7P+a5VsWx5yJe3fOu1NsdSiuz/7N+wzWY5Jggk0DfYRMxogbzMzYlyIM8+6PwrukIIyWv60Yau41LKlGQey8xoTDMz2bvukaY6hmZ6j3eT/SaYETpUw5K6nkp21GIhXwEi8v/BF+B0aBAxH6Uxo3aonoO8d+gQdIWrN699xXu2dBfAkY/46LQMFrROzLpFi2l04QF71sSZHYdsNbxDtHKp+u7sFFQBaoGQMHc23Vn3rvIv4pMpo/owfoVSW38m57WbOFZ8Fz/+MSk6eA8+/Jb6gCT9M00omyQlTkWNswKZrd48TQuuiQ7VwBWpN6Hbg58E7XSbxtv/snKu3LxDztSfyTtHVCQI0VTvPzYWFClWPqqUCiv03gvrY/po4PEI6g+wVs6IHiIUIVmU3V5CPoTAV0HWzmPKVwBNwQ2cICUNCmQ7z5iaoCUj0gW6T1G7ZxxluPsjvMWHqH1RlT2loDwL5O9sh00s7xfKMWdxupX1xBviXuU7uX/mZVNkLidQejUJ9A/urCAhiFMyTCrRmaVvZb00CiKVl2Cxz0exxp+wQ0QtNG+8C7/k59FarC+fpqwNvL8iDfx+7r+AuOIzqgSV4R4b4c01SbTG75ry90IXbFJRgSX+2hH9RDDKEllWxZm2cfCo3fud8uwq5e3DwGXdGxIJqJzHVNf+lViW56E0svQYElgzaQqJwi46meLbe8gilbYT8Plyr7ZevrprDJbOuX8NaLy6adbL/NBGOOsgYJ1UBXU9FL3EfVcfn50P1du4E8ONCgNYli7lUTkTlHF6wpMsnnMdjdK81+XKUKhyZYce7CmPhnW4Nod7AYjcwElCs1kPZtCSBpMTU4RWliw0+J+wWVSaOP4X6mxbADiZKYd/4+yMP5aT8A5n8mh0Hn2iudDIbuLNL6bPEbMmf4dNUd8SMisJV96jHwBNRbb5HBmLgILz8agrRHlSqd0tFaLn6dvlPBcBC8ogu1j7b0S7eJPsQZo51twLHz+sj2XA5+9CV4Gd4QXO5ccBCkL7MKu3uB9yYtZgyUZ13jMV2Qj3Rdr4HV5WAG7AI7NWq/pgbYiKvQTTDeYJyYypa5VoUEzeBN86FSJxmkblh3fT/JxwpWYrZt3oBQTfE2fV12obY2Yc29g5aL3EbWSI5FyU/EN6SkMtnuWcDTpE9caG/f/bQr+SDeliBigVPjbgUz32mLfTMIrDkjoNfBfkg8psim9p9RoG1UKqJoXdHYhJ5XDVx9OcDyuLtohZUTxK6oC/y89tUrndyFL8itzl4Kci3ApbjV1Tx2K6kQqF96BWcINEUHMO+uw1I8BJXw1TrjQw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:07.9890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34a506fc-bb3e-409f-c4ab-08dd07f05c71 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003445.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7889 From: Alejandro Lucero Asking for availbale HPA space is the previous step to try to obtain an HPA range suitable to accel driver purposes. Add this call to efx cxl initialization. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 7e900fbbc28e..048500492371 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -26,6 +26,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) struct pci_dev *pci_dev; struct efx_cxl *cxl; struct resource res; + resource_size_t max; u16 dvsec; int rc; @@ -102,6 +103,23 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err3; } + cxl->cxlrd = cxl_get_hpa_freespace(cxl->cxlmd, + CXL_DECODER_F_RAM | CXL_DECODER_F_TYPE2, + &max); + + if (IS_ERR(cxl->cxlrd)) { + pci_err(pci_dev, "cxl_get_hpa_freespace failed\n"); + rc = PTR_ERR(cxl->cxlrd); + goto err3; + } + + if (max < EFX_CTPIO_BUFFER_SIZE) { + pci_err(pci_dev, "%s: no enough free HPA space %llu < %u\n", + __func__, max, EFX_CTPIO_BUFFER_SIZE); + rc = -ENOSPC; + goto err3; + } + probe_data->cxl = cxl; return 0; From patchwork Mon Nov 18 16:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878878 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) (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 908AA1BDA8C; Mon, 18 Nov 2024 16:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948318; cv=fail; b=QMacyq7crgG/kFN0t3yectmGrjLv+khvSBKlz4aAiMKYmfPWtZ6/9h6mwSohzS6MJILCndcr+fywEwXC7PVvqCuq+PrAntOnYkKU9jOi92vzp5Ttjt1CXAoxTMNbI7ihJU81hilVRJOk8t7Rwasp+TQqck07OR2TsEj2ioGeLAE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948318; c=relaxed/simple; bh=5smm4lZHvgbsybqAB2S3XrFMsH+t3r8/uhtxe9GglLA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xvlyt5BeUOxsHWxWF011rrcvD/a5zB5biijLNKy8IG0UGuGY7tt8PpnIoSXJ7tpzR+pGdryNtKsmgfgYDEqr53KkoQTw8NG2UibaMsej4t5McaZtx5fXBoJ8n7AtIeQF6vCOhSPGRzGeQLBBOUeNfe09QtCoFmRO4SKNj2Aafe8= 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=PkZXWuTO; arc=fail smtp.client-ip=40.107.93.65 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="PkZXWuTO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=an1QLWJJw8bh9Qp4JG8KE+MhQxNVXhtPPq455qHbB2LAGwZQqT8WrtilhKOTXHNAbfGawb3vFTrvm7yQismgaFPwIxQ5nEbI2o/OnVP6PEtrXxS8HoTFLE0KBsIgwhT0Ik9oe8B3LX/I8fn7Ah9nNVFcFY4ubpwja1Oc+Dggq0xb6CZ4OFefcz9tw1b0oJxCuxsv2HcJEFhTce/NvuZ8DgBWDIKbLI0B94NKCkzFDxvt6kVY5XCMYLefJ15ZO4JOanBneviPUvGdO7DJqXN9XkrtdhtPHZ/C8ou9mvR3NfuB3xNQ7P1D/l9c80gp0Bt/41GQfsGrwmzyJzdS8xvyaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kipSxJDjXLfgTNhVJvwcIFcsIkToGZWUdB1pRI6iwSg=; b=yjGChY5Mytl4UYHP67rYC7JNrv0TeE8IGzdA8tBjWimsgbYoBg474RgwdXeage06ljbaLYbILpeo9LVhMZzAkSS/0VGP32eYCTpWlkmq71B0X8eLxlXuYVJQsjVr96Dfct9eH4niZ8yDuMV5aLhvyKgHkZrn0W2GoPJtlnFF1+P7NIs+xVX80Ozk9fn+uJPuBdQxrADN5mbWz7yq4OuHIbbTTXxQc0/m9R/bqCTYVu1v2NyEIunkTiWwUPPSECBOf4YeA9XKILtWYFE4Yd+8MOGEiZszk6bFvt4uviJJqkd+J1Usx2BYxU59f2fzj3ObF6fLvx/JYA6Pbq+Pk0Wgvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=kipSxJDjXLfgTNhVJvwcIFcsIkToGZWUdB1pRI6iwSg=; b=PkZXWuTOvZN5MBmxGRWTcy/EPJ1Fq6uDEpoGnBqIFeHgZEQP4QUn0vF2O7fiEMcFQDhxnOxNl4jxnXktXConSQMT532zJ/Gyi5YXDtRNFgfg7FSI8zAZuMqqL3aUHnxhT4R+w9v+NAWuen75NWrN5qtH3WwFbgwx5QrpWXlQnfg= Received: from BY3PR10CA0020.namprd10.prod.outlook.com (2603:10b6:a03:255::25) by MW6PR12MB8735.namprd12.prod.outlook.com (2603:10b6:303:245::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:11 +0000 Received: from SJ1PEPF000023CE.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::77) by BY3PR10CA0020.outlook.office365.com (2603:10b6:a03:255::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:45:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.12) by SJ1PEPF000023CE.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:11 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:08 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 18 Nov 2024 10:45:07 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:06 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 17/27] cxl: define a driver interface for DPA allocation Date: Mon, 18 Nov 2024 16:44:24 +0000 Message-ID: <20241118164434.7551-18-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CE:EE_|MW6PR12MB8735:EE_ X-MS-Office365-Filtering-Correlation-Id: df4133fe-14fc-437a-bf96-08dd07f05e74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: G4yPeJerYT0xTQBK3abHgOP7Nb2clYekQ/LGq22TVz6D4ZwVc7TDFjwJL3kmPx5skc95LJlNHPF/NkhehxJDufw/jnpYrzI4fco8U49/Gz6EYXFPZd86LHG9BRA+68mJAsOeN5jskPXexhQ+0YBSK6uIMDpxACrk0LwBumy2g3uz9lXygZrtSMSv8BJcXd+sM2+6leUaq3hvKzE/Vg+RhappAUNrP5NzrQMvYEdcbkGqZrrX/l3ZBMD7DKnn6IsJkjc9e+Ww6YbCTIHFdq+4tExpP8ffGS2moSf1vO3iZFblv9OD7DSvimOFc8IqSdDphIkShi58pcVh4+DnXO2MYe6W8HxPlDK7l7T2Fu7y41xsLa7gPi3Ey7Ugp9WH/qt11PHmRdF2qgGlDYhmul5va/Hpe2Qum9UAuzJl3+ZL1nFSWVRTkVQCD723Y8/L0lcv5ZLOKDz3F00xEdPnwqwywKcoSZnkoTok+ER55dDM5WpC6DIMxROvUp63VMTN47qsdATArIWPTdCmntn9dF14w1NRxR6E1Q5Vc5xnbUGiiX59s3hl2sp5mVnpLunbCyMh8iQwrTCKu/Y3vPjWz3easDCVVVaXbFxXj/pO2ebrJdyrGkw/9H0Skwqo00JLqfiFQKVxvptXCIRwvWceqXniDrtRtvmDz98GqvIRpKAF1kc9m7mZcm4fHn7mO9AFrhPkfM2CZz5GSyBHsLDLuBZLF/tS9sj2eytLX8ocQxUIBrvHtSvWX/iyxCMZ7xxi4H88BSbt6+47JZ/Y0GIQpFAi58IM1vRY713h2iu4Xqd/2Ws9RueMlKRAFckXiUXDGFtk51L4eVcnFIEG7gMUtnCorA74Ao8K1SBF1cJsH60akZXzXtKYbMJ2WoOirpatY96kE5JF+rK9snxP+8Jt3OwVlwZqLE5nhRmi/hnTaYqgjL1qxtH7Y1DEh9FcuQMIUXCkBDCIBchjiXdaO7dmMHW2vQxDo5EYyMjef5YovmB5C0H4uYIuywlXLSSU+PZa1u8PlgsvE74DX2hayLvPZO+fduQ8tTa0WqwSksK08wiGuBBLbZPJZIr5nebzUixdzCtPAqQPxvWLh5tPNJzT74TA0kAvCuc6xPo9nsVHz3LXVgndqa1baG8wUgAILE+hrX/svynHk41x2IfwjvqGy82/7ryzLCtxJmP8U2b2K33a6X8XYPjUtHIupVGf2PluMpyk3tYgxj91AsiS9NQaQEn+XxjhTPpwXIpt+5ifC2C5FRPoD7GRBro/e0B7paAH9ymvEpN4TPYMLxOT3OhI+FnZYGgTmAzaaZxcWNobk4FFy1Ef7KlWV0BLxRIquDbJ6qkd6IVGAM8GgJ2rZBKA3vw9f6AuSdT2gNstGE2MezmKo3U8lWhEfcOn+vn2OBwIBVRwPsGzMcgHHyjB4QkO4t/bvw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:11.3795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df4133fe-14fc-437a-bf96-08dd07f05e74 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.12];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8735 From: Alejandro Lucero Region creation involves finding available DPA (device-physical-address) capacity to map into HPA (host-physical-address) space. Given the HPA capacity constraint, define an API, cxl_request_dpa(), that has the flexibility to map the minimum amount of memory the driver needs to operate vs the total possible that can be mapped given HPA availability. Factor out the core of cxl_dpa_alloc, that does free space scanning, into a cxl_dpa_freespace() helper, and use that to balance the capacity available to map vs the @min and @max arguments to cxl_request_dpa. Based on https://lore.kernel.org/linux-cxl/168592158743.1948938.7622563891193802610.stgit@dwillia2-xfh.jf.intel.com/ Signed-off-by: Alejandro Lucero Co-developed-by: Dan Williams --- drivers/cxl/core/hdm.c | 153 +++++++++++++++++++++++++++++++++++------ include/cxl/cxl.h | 5 ++ 2 files changed, 138 insertions(+), 20 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index c58d6b8f9b58..99c32f1a0c97 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "cxlmem.h" #include "core.h" @@ -420,6 +421,7 @@ int cxl_dpa_free(struct cxl_endpoint_decoder *cxled) up_write(&cxl_dpa_rwsem); return rc; } +EXPORT_SYMBOL_NS_GPL(cxl_dpa_free, CXL); int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, enum cxl_decoder_mode mode) @@ -467,31 +469,18 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, return rc; } -int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) +static resource_size_t cxl_dpa_freespace(struct cxl_endpoint_decoder *cxled, + resource_size_t *start_out, + resource_size_t *skip_out) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); resource_size_t free_ram_start, free_pmem_start; - struct cxl_port *port = cxled_to_port(cxled); struct cxl_dev_state *cxlds = cxlmd->cxlds; - struct device *dev = &cxled->cxld.dev; resource_size_t start, avail, skip; struct resource *p, *last; - int rc; - - down_write(&cxl_dpa_rwsem); - if (cxled->cxld.region) { - dev_dbg(dev, "decoder attached to %s\n", - dev_name(&cxled->cxld.region->dev)); - rc = -EBUSY; - goto out; - } - if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { - dev_dbg(dev, "decoder enabled\n"); - rc = -EBUSY; - goto out; - } + lockdep_assert_held(&cxl_dpa_rwsem); for (p = cxlds->ram_res.child, last = NULL; p; p = p->sibling) last = p; if (last) @@ -528,14 +517,45 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) skip_end = start - 1; skip = skip_end - skip_start + 1; } else { - dev_dbg(dev, "mode not set\n"); - rc = -EINVAL; + avail = 0; + } + + if (!avail) + return 0; + if (start_out) + *start_out = start; + if (skip_out) + *skip_out = skip; + return avail; +} + +int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) +{ + struct cxl_port *port = cxled_to_port(cxled); + struct device *dev = &cxled->cxld.dev; + resource_size_t start, avail, skip; + int rc; + + down_write(&cxl_dpa_rwsem); + if (cxled->cxld.region) { + dev_dbg(dev, "EBUSY, decoder attached to %s\n", + dev_name(&cxled->cxld.region->dev)); + rc = -EBUSY; goto out; } + if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { + dev_dbg(dev, "EBUSY, decoder enabled\n"); + rc = -EBUSY; + goto out; + } + + avail = cxl_dpa_freespace(cxled, &start, &skip); + if (size > avail) { dev_dbg(dev, "%pa exceeds available %s capacity: %pa\n", &size, - cxl_decoder_mode_name(cxled->mode), &avail); + cxled->mode == CXL_DECODER_RAM ? "ram" : "pmem", + &avail); rc = -ENOSPC; goto out; } @@ -550,6 +570,99 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); } +static int find_free_decoder(struct device *dev, void *data) +{ + struct cxl_endpoint_decoder *cxled; + struct cxl_port *port; + + if (!is_endpoint_decoder(dev)) + return 0; + + cxled = to_cxl_endpoint_decoder(dev); + port = cxled_to_port(cxled); + + if (cxled->cxld.id != port->hdm_end + 1) + return 0; + + return 1; +} + +/** + * cxl_request_dpa - search and reserve DPA given input constraints + * @endpoint: an endpoint port with available decoders + * @is_ram: DPA operation mode (ram vs pmem) + * @min: the minimum amount of capacity the call needs + * @max: extra capacity to allocate after min is satisfied + * + * Given that a region needs to allocate from limited HPA capacity it + * may be the case that a device has more mappable DPA capacity than + * available HPA. So, the expectation is that @min is a driver known + * value for how much capacity is needed, and @max is based the limit of + * how much HPA space is available for a new region. + * + * Returns a pinned cxl_decoder with at least @min bytes of capacity + * reserved, or an error pointer. The caller is also expected to own the + * lifetime of the memdev registration associated with the endpoint to + * pin the decoder registered as well. + */ +struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, + bool is_ram, + resource_size_t min, + resource_size_t max) +{ + struct cxl_port *endpoint = cxlmd->endpoint; + struct cxl_endpoint_decoder *cxled; + enum cxl_decoder_mode mode; + struct device *cxled_dev; + resource_size_t alloc; + int rc; + + if (!IS_ALIGNED(min | max, SZ_256M)) + return ERR_PTR(-EINVAL); + + down_read(&cxl_dpa_rwsem); + cxled_dev = device_find_child(&endpoint->dev, NULL, find_free_decoder); + up_read(&cxl_dpa_rwsem); + + if (!cxled_dev) + cxled = ERR_PTR(-ENXIO); + else + cxled = to_cxl_endpoint_decoder(cxled_dev); + + if (!cxled || IS_ERR(cxled)) + return cxled; + + if (is_ram) + mode = CXL_DECODER_RAM; + else + mode = CXL_DECODER_PMEM; + + rc = cxl_dpa_set_mode(cxled, mode); + if (rc) + goto err; + + down_read(&cxl_dpa_rwsem); + alloc = cxl_dpa_freespace(cxled, NULL, NULL); + up_read(&cxl_dpa_rwsem); + + if (max) + alloc = min(max, alloc); + if (alloc < min) { + rc = -ENOMEM; + goto err; + } + + rc = cxl_dpa_alloc(cxled, alloc); + if (rc) + goto err; + + return cxled; +err: + put_device(cxled_dev); + return ERR_PTR(rc); +} +EXPORT_SYMBOL_NS_GPL(cxl_request_dpa, CXL); + static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl) { u16 eig; diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 4508b5c186e8..9b5b5472a86b 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -67,4 +67,9 @@ struct cxl_port; struct cxl_root_decoder *cxl_get_hpa_freespace(struct cxl_memdev *cxlmd, unsigned long flags, resource_size_t *max); +struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, + bool is_ram, + resource_size_t min, + resource_size_t max); +int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); #endif From patchwork Mon Nov 18 16:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878879 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2078.outbound.protection.outlook.com [40.107.93.78]) (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 45BBC156236; Mon, 18 Nov 2024 16:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948319; cv=fail; b=Nqjr7jegNmPaOhQbvclY3lK8TZwK0kRzKX4UQqN5eBA2lmZGhZjNAk5AjUZAKwCTB8mWOYw0MxOdQrlR/DkmjanQvszVUhjEAl/HiBe/A1ZTzMz8aSuos0XqbxiMfRFiVsQ7LfnGeLGXi2h0xrtcZDFC5vxSv6QphyXQJb747EY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948319; c=relaxed/simple; bh=fBjYEd1zW/ncp6HVXtbN/73UOggVaflGpOi9EJV/RJ4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P6hL9rKZ4DVxkj3E9ZSYPynZK5hKAhKYc/mgXnrrEURdg+XsF09N5kE154yMYOslSHI1+aImyCmKbH4JyiKosK32TC/YmrGuP7s9sNFjN8KXMTfbIejoRNy27jzKiB5FdVpH4NThYXBAoEvMW6Nn6cIzqzE4aFH2LSspeXnmRck= 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=MhTMp6nY; arc=fail smtp.client-ip=40.107.93.78 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="MhTMp6nY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=myABw3R3gku6X9cyH0Iv3YE6JwEKN2xoBr7NJZYmBHsb1Vro8HG0dhn+wMaI9w5RTMfWXkfFc7nczQDG1PQwXzjbOauOFo9iWd7pbfBGOIj4SDGWJUGvdgxZ7B2GZuPpAev4lP64nFa7S852BKeIJpvCbU878TTBoxnYoCjUu5WmTbMmIN+VRHJiLYy5gsweeAFNVwxeinrnCPH6mHwKaXpgpVFFeko+nzRBzOpM5SUpzYszvmvRgLRX73ubbp8Pz/O+0LXuMhI7td/EMEE1p0megSA8zZGhS0Kt/Ri+95VQwxFFJYsIVMtXlzEAmwS10q/m3kTHtp80oM5Z1dWyWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=bBaGvrLd6LfODsgpTEnM1xVqVHYZeP9cWgbCw5WC4I0=; b=YWiI0grRwcstKK+sYLhxWvAmf1fXGYCsdifozMngAEbGN9xafC86KqFT+OOohICTDZwG8D/hgbyceUgdLua8FWz2OmJTclq3opHHqD6AAVZEi8aG9qQ+pG3ABZBHWwqyP265OVOMjOuB1MYfYXaCFCvWqs/cH9aWA4Q1X+KuqwPf/+nOxE7pUkxMA514BhDksowQC8dPpxBwihZtHU0PxdwW1Te95zxs6iS/47ybpmRhC5EqwJx0yz6QtZpi7Mfp2u31iMvwy4yUVqxjNPUcG/fxI6ypililoskO+AP1vtmSsE2w5LnrplAvgb0BLa2a3ZxkwHLTf14G/LpYywg87w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=bBaGvrLd6LfODsgpTEnM1xVqVHYZeP9cWgbCw5WC4I0=; b=MhTMp6nYPOCCeAPE3C7jTSnuVwXFVSDpBi9NvppEg25nqPt/8Nn9krytGGQV4Jlpa9IfJRIhi8yHoB9NocUcmDbx+mCeAQ8flJzKycWjnrDJ339bHgN2PFK0a5V9Fh5dRONKht4cNqaSino5Eew4s4mR5OCB96vZ4DlJSXdlXko= Received: from BL0PR02CA0136.namprd02.prod.outlook.com (2603:10b6:208:35::41) by DS7PR12MB8202.namprd12.prod.outlook.com (2603:10b6:8:e1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:10 +0000 Received: from BN1PEPF00005FFD.namprd05.prod.outlook.com (2603:10b6:208:35:cafe::e2) by BL0PR02CA0136.outlook.office365.com (2603:10b6:208:35::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:45:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by BN1PEPF00005FFD.mail.protection.outlook.com (10.167.243.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:10 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:09 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:08 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 18/27] sfc: get endpoint decoder Date: Mon, 18 Nov 2024 16:44:25 +0000 Message-ID: <20241118164434.7551-19-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00005FFD:EE_|DS7PR12MB8202:EE_ X-MS-Office365-Filtering-Correlation-Id: 6af5d912-1c9c-4925-d87a-08dd07f05ddf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: M5DEnwFmStW84ZhqTDiMNjQYywMRwxa/cXWuWSrwl7OIYBcclZ3STBWqJYpAhr7qDL4eCA2CBPL2sG8VTZWc+mAEG4q9k2DbUczsfJZf0BdaVPMjwDUa1N/2Cw7xxu/gcUbsvJkncA03oKIp+qI7DreJuCR5olHnvPAoxhrnmBJqYkKGIq2sbc5gKDjQJzY72QQ5I9253MwzhfmAVqwsZPF4nsO17lwCqTzWF09wLY9CuHVJEw3vzmaXbO+Wm5Mzpn4vt/uocQoPoHiqcinFsIdxT7MdNS0zOGaB7/KjjbbqZ59EQVmyXUZ+76rjAY/+AgmyG3ZKasWL3LvVvRdoDBWQD7Y1Bcc+7XkBD/zhTPx3d6M4XpyUmHi7zrR0r5IAQCVbhj38qhW4f60+vDCbb48U8jrsmGuDgZFSj9HOO2k29MYTbtMFXzdJduBzfY5oqVbTuN+rygt97cqJCxnf6+UfP3MuQ8JwSW46/F640mjGKH7/3PCfwaq2EMoTi0UVOQqatRX3JkJvSo8XI2d70aGDnZRomjsMugEp0BCc5yAjIn5gtaAecg5tCoia9/9IDnUuljem9a8Lc68RfN/nXEhFBcKrrAX374tdRsIH00qHcAm4G2AY9UXNDHvbRdkKfasiDfIQOtasSLhcbvGngux75iMDWUDk91xhYuOvRNyDKdn344oUoR6LxK7xJ/YJivTKFKcdqRaBmIyZF9nrgkHqOGtJ8EZWeIBAg3WIY/rSknCJC7sknXfV5wBh7V6Gj5qsYyVi4WMvf3/lpJOe2GIUnyLgyVooU9Dr6U1Qnyus1lX98mzvyRtMpebTv2awDMlglvE2lPgAW/b6vDW3RWXX1bD6HQqK3JtlhV/DEzBY63+p1CH9KDloUXsBduii+vqtafoiYG1vza88zjhM53g2qgWuooowXGLH4dlNKN+8MV4phYDH6KzSwDOvYyzbye3mG2XcqFCAG2/eN2cr+PDUMQvjhCSpIZKj9Jr4GUDuN6ObybnHpbhxOqPbTv/jMc6usk5LLUNw3vRtVN+DGtcJz79dnmZpbrxBI+HE+pSebcsxhiDrtU49fpnpVsKx2SdAJdPA/j+539ByptXl1VLYsQNtGYH5N3yLS2Gx11GlqPlaQ60k5KKjaP1l9yyyhQhQBKZseBzb9ZrLB/LdJ4o16ycrOh2Ng94S4Lyzg8s/Ml4dC/5snBYkZH+JJm+rQY522ceOtfHErO9Mr10IHCdz9Gr2Vp5aNMIS9OQhsGYAVjUutOfQArk69Novj5RWwfZbtLZFmbWOAlTjVFtv51h+MpaTcPsf6kxfkHmKhkb7EJKLj98/DQY8MjmIQ5opPYa4+SLiKJ3D0IttAVedmsbrU8Y6vsLivEbRq5BQWl5GRYHk2TrSlJF9T4Y0ra1QXWfjwO7ul4cDaDVZF2vs6Q== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:10.4193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6af5d912-1c9c-4925-d87a-08dd07f05ddf 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00005FFD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8202 From: Alejandro Lucero Use cxl api for getting DPA (Device Physical Address) to use through an endpoint decoder. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 048500492371..85d9632f497a 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -120,6 +120,14 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err3; } + cxl->cxled = cxl_request_dpa(cxl->cxlmd, true, EFX_CTPIO_BUFFER_SIZE, + EFX_CTPIO_BUFFER_SIZE); + if (!cxl->cxled || IS_ERR(cxl->cxled)) { + pci_err(pci_dev, "CXL accel request DPA failed"); + rc = PTR_ERR(cxl->cxlrd); + goto err3; + } + probe_data->cxl = cxl; return 0; @@ -137,6 +145,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) void efx_cxl_exit(struct efx_probe_data *probe_data) { if (probe_data->cxl) { + cxl_dpa_free(probe_data->cxl->cxled); cxl_release_resource(probe_data->cxl->cxlds, CXL_RES_RAM); kfree(probe_data->cxl->cxlds); kfree(probe_data->cxl); From patchwork Mon Nov 18 16:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878880 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) (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 94CE31C4A04; Mon, 18 Nov 2024 16:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948321; cv=fail; b=TVE7v5bh9IrnYU83eglS1HeCnVj1y8eBcfvYHqLMA2K3r0ElWOrSnAg9Ppim0t40s799d8UYdkJscNRw5OoriDeRP8CLvQtRfTVRV6qImXwL5IwImpl1O50UN9h9uf+nHeoyjQvHfZkvWJ17/NrXSXDp5FJBdc+RUXSgyeeP6xI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948321; c=relaxed/simple; bh=B0QUXCU6IbXWHz5DpjxOZQkzu5QAjfWd6lqDjhzSSJY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nR7yqH6/EIL9FKPH4kyaDRLYhmx3wzs4sRYbxqNKk9Z8OecVrXRDxC6V+l/3+faXqOvJmAFhWm2605klDXF6DCYrMI34dHj2yTHOsfwIAfEwKQY9dDoJr1ma4KqvO+992kxS8EJbhFFs9FuooKTYw7CgEkl9jGjjE0Yxd4n+zkI= 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=s3KeEBC5; arc=fail smtp.client-ip=40.107.94.66 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="s3KeEBC5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mvdzVWsujE5Ry2JbGKBNi9027n0rNro2CUqXOQT2kcRoL/OUdJC+lfYj9irqRBT6yTngeNzPvMtd5rjQ7pVAPOWrVZfFtVRGZy8CcHwRayKuRENzesTGdwqV8V3kA+OEIn/JLzQmmHADYtc3zAMUkZLTbQCdI2U8RlWA73ghJW/NsAbjhhGPRbIAuCeJdeMvrOc5hDcKsKecaxMTGazNXgBGJO6sm2AoxYnOKruw3mQnZZEEQkrqrik1gR5hWpR8A+siZiHy4RXu62l6gJhDSfLhsaUQoEwTQDp4I0oAOFxdX7h+ri6Gh2BKs2IN7NCWkXqG/f07zDCd//ykbWe1gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=yQEdRkuVV37XnlTg/2DcUX88ZW7VVdWdMJ+ESHujp+I=; b=F4bBGygBVejecv1yOhjT7Ean2i8YXqWyxUBZVe0b5IoTXUNvkHdqRO0mwai4rEp7urjCEXobZlaN6ifmkKMDfKzdLOnTg4HcCbW46FjfLai29LBncdnYe65DMIqeYELxzUAqxY4H/nH9s1OBfsYhoRGOdWXHSoHuw7fSID6zOh0czsvmcgQMUffJBlz7r7Q3W7tdp4qAaJcbTltdytGXC7DHNdYTPdV3abGH+Ttb9UoR/TNF51mV5qiZY6H7YGa36ZyNvv4gp68Wn66VMM0v7cqjtZLoKNXisYowCI2JS1/viikfyVumMmOAa4eYihh2q1eG+NCzPxOUQREDvNxZEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=yQEdRkuVV37XnlTg/2DcUX88ZW7VVdWdMJ+ESHujp+I=; b=s3KeEBC5AeRL00/yqDBbQCCeyMFApmj1wdf6xLx9rUImqCflL68hMDlvGVGydTRiS07D9ud5ePzi3Cz4u+Phhapmtu3D1pI2Quv+FMDOFaI6UQhzMdjmNlMZRemEr6NNDFw8kPv1s8peud8/IcQGrllNWJ0U5rflnmLiLvsSgz0= Received: from BYAPR06CA0042.namprd06.prod.outlook.com (2603:10b6:a03:14b::19) by DS7PR12MB8229.namprd12.prod.outlook.com (2603:10b6:8:ea::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:13 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::c1) by BYAPR06CA0042.outlook.office365.com (2603:10b6:a03:14b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19 via Frontend Transport; Mon, 18 Nov 2024 16:45:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:12 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:10 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:09 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 19/27] cxl: make region type based on endpoint type Date: Mon, 18 Nov 2024 16:44:26 +0000 Message-ID: <20241118164434.7551-20-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|DS7PR12MB8229:EE_ X-MS-Office365-Filtering-Correlation-Id: b2175669-fdbe-4490-5313-08dd07f05f7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: A381OjkLbUGqV9nuNOKMclqBmXRuneOFT4kIkPEESS+AHrsR+Pzz0KjfHoG+nnK0RB/sdFSjvupGUsFte2hvCZ8uqJVDVK2THzvQPiOmJYEWmFdXDVbznq0sAFgKONkC2ZQBxqzl1eljvbezzxZuYyRsOfjSYIM/6HUJuVd0zGLkEzwmbDO5euGfdPSQWOSxGFSrFOcK3Y2CBGBRKH684d9+4aJUVm9fYqVo5KeLMK3SDgAJyof3RzJEr+3N6oKR7+YUWXOth99Coq5dU5BlKlQF+vpDx6XhtyHBIvojEsBkekn6LAlyqeOaLEVZC7cf+L8wDaGqwV1yGhKpWfkn+33IKWrTT4ymhBfITmI4Qa327M8ULA11EqqfKsYSvKbRT5wUYNxX8kTjN5dA3DXnM5mBk5l6uJE08tGZNExQOTKutlW/3TK6J3E2OlBzftK4NhH2KmPJwLQ6CQwACKKERIvwvlBBDTnKrurGcd0M5r4htHCORAa0bPeuGxKo9K/UBWfLgLsdUm33NbBDPeLoKv3yI0mTBUbO5092KR7MugEcWxb7wuwYUvG1jzML6HXc2A/jeclU7ELDitIdI5Sy5C1Mbzcwvy4IvnjxSE1Ju4juQygvHC4zeDJ8Mel8857XXon6dDOt2YKvbWCHS2Y1ksdWDUrR3Q1pHcwTu7T76L1PdrHMCZCbGEajH5PqnKJ/0vEgogVX5r1ZRAWRAt96dftKVqPHBU2P29RI+Bnhp4GQThHmFqHTnCPYitMveTbLV2RXb+b/fX+rUQcw6DKLgwmYQb1asblNS1Cs1Klg4ccgmsSfiEeK9SAbhK7P6WUNpnKH8+pq9siaNZHiEDnyT09FkV5yICjL1EZ8mpQGt2M/UBOP5xqlS+/SMBUg0008uR2MHMO5iuRn+fw8WZlFUWSS+1UX00IXJMd35X3e06efxGo+iZ3BWmfrZKFBEaRD8HZyr0alms9aEHffzpanCTLopJry8GmxXxSaX9Zo5YHEMdqLg3k6WaHIh2n/U+7wBDavAVy+ISGsb4mSGvhxoVcpc6S3ZuwvuG9dEKxkBSIlGfTipXkzqIvPLZ/ywvG6c7ZSXgXhTfsd3+M2giUpk09zulG5Mc5JJrnemgGGh6XPAI4aatZ6776BvMcXcqeRzmXOUYXTiimgA1J8UcpZ/qHCzJEfMyE0raeBgb5YUyxUs0tMTYTfSVev9DS/Jmbp0bNSnr5VS8TjgeWtLu26QuR/mlqCh3P0wctORe//38KxGo2q0bwT5icu7lXa2WGlshgsGetOquQcO4XHearVyxtWZrvnCDMmOOJiUmzVyi2MJQnAWQ9SXxGiU48RsiwMLsKZIaPqt5CB/ypbNDuCuAPHcA3rN5LvT4Q/4Lnz0SKl14v9cOnZPqbDg2eX3u8kF37jkZMLeWDuGs3AR0auFw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:12.9532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2175669-fdbe-4490-5313-08dd07f05f7a 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8229 From: Alejandro Lucero Current code is expecting Type3 or CXL_DECODER_HOSTONLYMEM devices only. Support for Type2 implies region type needs to be based on the endpoint type instead. Signed-off-by: Alejandro Lucero Reviewed-by: Dave Jiang --- drivers/cxl/core/region.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index d107cc1b4350..8e2dbd15cfc0 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2654,7 +2654,8 @@ static ssize_t create_ram_region_show(struct device *dev, } static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd, - enum cxl_decoder_mode mode, int id) + enum cxl_decoder_mode mode, int id, + enum cxl_decoder_type target_type) { int rc; @@ -2676,7 +2677,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd, return ERR_PTR(-EBUSY); } - return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTONLYMEM); + return devm_cxl_add_region(cxlrd, id, mode, target_type); } static ssize_t create_pmem_region_store(struct device *dev, @@ -2691,7 +2692,8 @@ static ssize_t create_pmem_region_store(struct device *dev, if (rc != 1) return -EINVAL; - cxlr = __create_region(cxlrd, CXL_DECODER_PMEM, id); + cxlr = __create_region(cxlrd, CXL_DECODER_PMEM, id, + CXL_DECODER_HOSTONLYMEM); if (IS_ERR(cxlr)) return PTR_ERR(cxlr); @@ -2711,7 +2713,8 @@ static ssize_t create_ram_region_store(struct device *dev, if (rc != 1) return -EINVAL; - cxlr = __create_region(cxlrd, CXL_DECODER_RAM, id); + cxlr = __create_region(cxlrd, CXL_DECODER_RAM, id, + CXL_DECODER_HOSTONLYMEM); if (IS_ERR(cxlr)) return PTR_ERR(cxlr); @@ -3372,7 +3375,8 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, do { cxlr = __create_region(cxlrd, cxled->mode, - atomic_read(&cxlrd->region_id)); + atomic_read(&cxlrd->region_id), + cxled->cxld.target_type); } while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY); if (IS_ERR(cxlr)) { From patchwork Mon Nov 18 16:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878881 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) (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 7A6481C4A38; Mon, 18 Nov 2024 16:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948323; cv=fail; b=mga1V1UomCo6SIG5LO6D6ERr1vYUbTC0sA4ZFXfpxiCFangSBYUc47pZO/maFOm0eQR5dPUrRD1YQ6Tw3Nq9q/YAP2u816kIs8A4duGY8wGQZkX82/l2YZW6zl0YsRCWccAxchZP809f6zzXRk7FaqzdXhtwUV7cbLQwk7S+lhA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948323; c=relaxed/simple; bh=GlD7okOFYcRo0xenQY7cQCJ1AGW+seGBim86tYb17DY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FgPC1uEY6RB9gvW2R7HXcEwtWS0wiX0uMB8a/USQqcwq4WWAPFv6RKpd340fXil7S8p8d6wU2wfUgAkyRZXmgCn2oLGBwSo7tCqnSwRxMGb58+v9etEe9MOZQfS99YQtxTCJ6OnxkZdbCKXfdNC8oYugUeVK9pMu1S0isTGNoFo= 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=afoD7s7B; arc=fail smtp.client-ip=40.107.237.80 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="afoD7s7B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rPvv7moNnXjuZmLB/reqvZRBswCtmrW/q8n/71hSF56ZVcTqWfg/sLjNXYy0bUuJ3AT9pdE3Ufl+ZdM16bDuk00i+hF4TEG/jiWaBCMEFPBtzXLkgD0z5wOWzGq2c9/1Y6ZukYaVm8yctyI73xI/R1miaba6Az+6DhawlNaDkOMYltwQPmdYU1V/ehSGetyuGERO9pfT6D1rOKLSxBj9A8gPDo5u69IliS1u4Gz/c0qjtFFdBBniXHVyWi1k3PCoKMSLmJwzxQ73KHWlo61sWDjHUhdny/boN4oIWWaE30DA0FEz2GzG9ZKQxbYxp3+9Ngn/IqGkXLwKidd49+ehiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=f7w7EN51qNM93rBnB+cBz+YY8U+Wi99HtMyoVZ+LwtI=; b=Oj0gPIgmFd+lAzktOiecQ+YqUZRthmBHdi6eP8Pa9uqjd77HAgiq+iafOx7YIT8D+MAW7GeDMY7ytG20nSvBYq7HY+mptkoseWdaQP9pc2wAPYaZxSSRkWLvdibDMXD+VsMu3DxzOZ7Lfj9i/MS+4nfR6ekO3LidWO5ktajY9RUR4i/bMax4o7v1c6xhR02zAGNL5ig8VIXS7dg0t+su2hqWjxvO8pnDWRhJldQ2O/Pmb0Mp4C7uxNWNaNCT8ToWj6tltqY4mHblqtWBWxtKK5huN+a27q/NUK7PhN1gGSgnUUMi3gv+bbwAjGjQgr9whxMJvGDvmaxXddL73vZIwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=f7w7EN51qNM93rBnB+cBz+YY8U+Wi99HtMyoVZ+LwtI=; b=afoD7s7BNN2qsCXVchMWLeChOZPzPASadNHvJwHEKWQPSP4GOICedYn+U1KMQL9Q6B4oH+4S4EBffUovVZp0gvx1PiIQsOQqoUmqKVadk4JVjFcGlWqbV3VW8v/4/H9RbrtmwQNJXKzDLeV/llD2Xwpe+SPY+B+4dV4AbeJ1x1Y= Received: from BYAPR06CA0065.namprd06.prod.outlook.com (2603:10b6:a03:14b::42) by PH7PR12MB9102.namprd12.prod.outlook.com (2603:10b6:510:2f8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Mon, 18 Nov 2024 16:45:16 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::49) by BYAPR06CA0065.outlook.office365.com (2603:10b6:a03:14b::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:16 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:12 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:10 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 20/27] cxl/region: factor out interleave ways setup Date: Mon, 18 Nov 2024 16:44:27 +0000 Message-ID: <20241118164434.7551-21-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|PH7PR12MB9102:EE_ X-MS-Office365-Filtering-Correlation-Id: 4893d93c-daf8-4903-7971-08dd07f06146 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: iFqrNtwsLRJS3umRLLBDb698CFQlssmHZpzhmND8QdLQs2xuwvvna3dh5KEzOFTgtQZC1mdB6l/tn1TAvEr0bEqqDlhzhoCtVBc6/xwMUOw1rQS36t+NrHv0bFHAqPHV0uYTFHDywIysjTpiIIWS7pgqxr5KcfQ+yvd91jQLUTmROleFW6rbtNDRdqZHUSNaMXKu47Nluq9UxcGBBCbVzYOEisGQe5GOiW3Tkxgf7UEPvO+ogOZrABk2PTPzDZcIWaYuujVFcoYhLIF39FYa6sFdJYI48D/PfeaIMdZ9x8fefk6duy7JlNbTg+H8ILMda+Lnmf9y/Sp+//s2/E+oDKu4TolzgVBpH8dAqmISq0dRo27LTD0uozMvs8/u1NwPGPTpOzH1iniLDWnAAogAgwPVC5apgpNSokpsytdnlRUK2ECjrWwoJhU0ZmR3GA03CADnz2BxBZO6QovVWDzNQ3n4VmK1vQTpZyujx+X8XwbuejI0KHQ0P8b//n1A8HclCFbg8T/8rJj0wvqmgY1Ke9ytyJJx1pvw/MkJI0GAwjJa6SyQPHfX0CVNyvTq2f1kR5MWgjxiLxU8gtOMJI9Mqew+/QGqfwy5/CTmgw6ukUmmIwrX9dACp9v3esK5G3vorXC53f8WkihJppdRYgnRxXubi8sfxrso6oGQ+/jRcxZXx095ZRskc9IZcN8X6C2ATquaIqRY/YAj+lblcdyipArJo3/ErD5u/h47hWIa9CzG8QwBfezXgn2kMt/Sml43GWx3QS3l+oyxkkG64sxHown9LBXmtlvU/bLrKBr+VVGvCp7tPlTP3S//MNb3oSlyZNhuSri5g493kxmWxYXKF0TwA9mJUrYzylmZukDrsPA/KfQdgXwvprC9NevliBC6nAo1rubcuKrw5vCu8/VgtTbDY9ZkzfyemynUI6NDDd1OmRegzEpdofSF/M5+MwBiwlAecX2RuXXdZLdp5rxTF1jnt7UR7LPSOYFJvFlZNNjVDoU0sTtrU8NlMSpXqnt19gHTv/mFA0zcDQd095Vk/PIE9+Eux6Ht4RAbw5Q3fzS4WR+Ljo6xFWrsIDmbc31BXVEVRLbNnYXldRxu+UUA/16tDhscI2vqa1EyfpmvA3hH0NGySdgSzkclIpPd2+UmT33x1we3N5CqAJ3/XXmAlcovv2rDapoDVG+Di4l+Cr3GRLpK7qER9DsjhgLmBCwTt+1m7RPGHAZDGVVm+S/vYE7TfIJTci0NlUnvGmC+uskb5LT3nzwdZ0KTftJ17l/+vGe56t5BPt/IWXYIhR3wwdb6U9JreRckJAthLGEwjECZu5uG1vmdw0+C9gGYTDHp4boebN7hgWCWgt7IWNwN4TK7Wo99qXG/QN1umZKGBQCgO3Sp7vy1Mh2nCgDtb5/pxpx7R3Hob8TTPvVIIItZOg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:16.0469 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4893d93c-daf8-4903-7971-08dd07f06146 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9102 From: Alejandro Lucero In preparation for kernel driven region creation, factor out a common helper from the user-sysfs region setup for interleave ways. Signed-off-by: Alejandro Lucero Co-developed-by: Dan Williams Reviewed-by: Dave Jiang --- drivers/cxl/core/region.c | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 8e2dbd15cfc0..04f82adb763f 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -464,22 +464,14 @@ static ssize_t interleave_ways_show(struct device *dev, static const struct attribute_group *get_cxl_region_target_group(void); -static ssize_t interleave_ways_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) +static int set_interleave_ways(struct cxl_region *cxlr, int val) { - struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(dev->parent); + struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; - struct cxl_region *cxlr = to_cxl_region(dev); struct cxl_region_params *p = &cxlr->params; - unsigned int val, save; - int rc; + int save, rc; u8 iw; - rc = kstrtouint(buf, 0, &val); - if (rc) - return rc; - rc = ways_to_eiw(val, &iw); if (rc) return rc; @@ -494,20 +486,36 @@ static ssize_t interleave_ways_store(struct device *dev, return -EINVAL; } - rc = down_write_killable(&cxl_region_rwsem); - if (rc) - return rc; - if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE) { - rc = -EBUSY; - goto out; - } + lockdep_assert_held_write(&cxl_region_rwsem); + if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE) + return -EBUSY; save = p->interleave_ways; p->interleave_ways = val; rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group()); if (rc) p->interleave_ways = save; -out: + + return rc; +} + +static ssize_t interleave_ways_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct cxl_region *cxlr = to_cxl_region(dev); + unsigned int val; + int rc; + + rc = kstrtouint(buf, 0, &val); + if (rc) + return rc; + + rc = down_write_killable(&cxl_region_rwsem); + if (rc) + return rc; + + rc = set_interleave_ways(cxlr, val); up_write(&cxl_region_rwsem); if (rc) return rc; From patchwork Mon Nov 18 16:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878882 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2045.outbound.protection.outlook.com [40.107.212.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 5AF661C4A1B; Mon, 18 Nov 2024 16:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948323; cv=fail; b=KK7IjCJ3DDSfnAw3Jqy/DxXefZCsUw6LoIq+mA8oW4E2IyIfJ+qyVhlfslmQRLtw2ju1eDlEyLoEy+9CQJvRWHTQlpWtvUWgkadhBOvpYXv66oGWMyDPcSVonY8nXHy/g5bwCCK0bMzfhn5dbxKg04ManqwEbrN0WorK1X+LRwo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948323; c=relaxed/simple; bh=DKL8+YL0lnjZzV+/zM7DlbVYq/Omu/Yd6SY8k0Cx+TI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y0GIqUc2sKp5WiUY5I8A9jWnlncGWvqpWtgk02XlFtu7tsSczzfAjSQUykxr9pB1W72ifIAiaVhkXnCXjYqC4y7wgiUgnUwDFUBCWrbNwOyHc1RLswZj2IXuYSvw6j/f3H1ndfpNqM/FOBjFUiTTVuhSwYcjHIBMT9COsMUByOU= 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=Z4I4ueKr; arc=fail smtp.client-ip=40.107.212.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="Z4I4ueKr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GU+gOqmv9n88grsI60YmepSeAosLfmP2opLnBGSfMnXKOvd9XkbJRGM/IzkvSEx+EfwcJ/Uv9TCpQQhYW2MQsIw0gmSAwxi18gvXfRvJEXxZe96NCgvlWdeO7NlNevnTlDhdJHpH11Tzeqh5WodH4Twqkulo0J8TS+ORIulHBVVFq0CCt7E2uSNleZMd3wdXR3K7QqD3/CVg/8UKhWn2wIr7bcrVEzKIp+6OeuPMU5xpbyf+rpd0VnBAW/zrIYzG7wDYlLWRO+ITxrDhCgn3zc0VSwqmWC63PJSeP4BsoT+ra15Vkt0FbNIE6uGO6DyGEP4GgGCjO8s0rD8+ANXtFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=MPHKfEcxkm5tEvQ0CG+U/gqb2HSBdQzhKft+LHQvvLk=; b=vmVyqECi8e9YIgel+it/jGNwRaFt5CnwU+NAciExu4/J5B5lMCjaVUbDGH7/ABSSCFN9hMj6rSiUoNQd30Vpevp6Xy6ErcYaN+gnfglZnZS90e0Jfb4J9mj3Fe9OqYrF2p7n6Pu7jhMZWj1ZnlHF+2N/0NYV6MtXMjybSIWGweTCvrRgHO7+yaFIIPw1acGNM88PnEnUYBCNfOAtqXO5bJNj6AIjDl/Qc+en61r2gm4A5nVxOCswVJRUCAdqohmDqaiS4sEfuzQs8IdJYTQo3aM3ad6uvVDFZLDZ9gFIKOCmJbduDTH5G5PRZVsAICL+5ekaNwa31RLdws2izHtXpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=MPHKfEcxkm5tEvQ0CG+U/gqb2HSBdQzhKft+LHQvvLk=; b=Z4I4ueKreT9ncDU+nfXB/Cej6idP3BRNQHmheuj5dtwUST59+Fn8SKVEXuH16/Ua4pWS23z+vIBLEkH468N9bMIfSFZUe6RP/zd+x48ZZIFeC2zKFqncweM3A+UREyhBLZt2sf6Uscx6EaZ6grCTIkw7iZhO8WrWOwAQG2v+xKg= Received: from BYAPR06CA0057.namprd06.prod.outlook.com (2603:10b6:a03:14b::34) by CH3PR12MB9027.namprd12.prod.outlook.com (2603:10b6:610:120::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:17 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::1c) by BYAPR06CA0057.outlook.office365.com (2603:10b6:a03:14b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20 via Frontend Transport; Mon, 18 Nov 2024 16:45:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:17 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:13 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:12 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 21/27] cxl/region: factor out interleave granularity setup Date: Mon, 18 Nov 2024 16:44:28 +0000 Message-ID: <20241118164434.7551-22-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|CH3PR12MB9027:EE_ X-MS-Office365-Filtering-Correlation-Id: a27f14a9-8150-4a12-48a5-08dd07f06218 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: Z7n2fK0MhWtFoqtrOtkt6nTVbtntbb5K3WFuI09+B38YbPOHIfHd1YUTCBYHozkbwmRMCo3H0l5a/Zmp7Ij9aDaHob1mtxxa8q/5hpYxrRtDr2AaQHHvCLzucjQRSwYAKiS+cd/oiNCSINZQHpe1V8pWY2mw9GcU2SEj+9PMrEdTJqSfAdcWd5GVfQai6UY6hVhABG/a2DX23bg0cm9/b9jAZXWHqvU7vzVVB3h0rRdCcjCD7DVuw6NlLGNaPqCGGJwH76bmpma5dlaUfT9j4nMZjjdwjt0H+jCSbC1NuBuCS0cTP+6BLJvb8XCDVeDpF9wc+HlzKy5n2Fj9WfqCE8/zNrwqWs0Ns2u9PTn/p5WsmBDVCyOA32NvL1MobAEtdlC/KMVcmP9tOAEaycxAV8xDGpDucmty6EvSjBtsnGM4QiceRDWAprZ9sbPQX2mtbf0yV5/LnHL6lhFsgIUZfu0n48vtpP2zkRVBCajzka8xzlZLDfgl6S1NYeJUk2KvEEuF3tQNQzt/Fbvlm7wQxG1ZGH+xCvfemJSiVtI96jai1GFmorwxbFSeGPk7qmGthPbn7BlAVCDk37sIF78LyaQQ1bu1dlO6Cl3TbEQc9ecA0iKsU/V0xopt+VHY3hVzA/+bSwADYD1/XIck7dyDYLEShBInu+aN8A74alC93klM7PQR5e9oXIIww8S7ZLB6SK/K/qwpyhGRFw7WC0bUmcddVvdnsodZqHsFegim5Ca/Cklz4pU39ixv4PCBlXTi/3WsZKxS6SckXLvA9bm4ydpFhLlQhCo6AOu6S3wd15mVfNRR/A9PozvFkuhoaI8HmgTT7o17/A5vaZK7ONdrS0diZrQfWVBVRByEolm2v41Padenf/EAGEvdk2sEO5nUQncfOaAjP5o0gEHtcapiHWHcgfkrF+3wAbj5OcZQWELWbMpVvS7enRXX7qmDdOTtJry2yTGMgSrVLIkOmzpIvOxZUahTZpiV2I/Xadr0qcWFNufb1kkHP1Tn0srrW1bgZS5EgFe1j0KRnvo+hVeHzHVDrIyctjm/Tjc7m7+BNjrMHAIhnJqghp0JMBG40OR3X0IdTmDUnP4m3mP/28KiGXLYFs3dfwQ4XsL0m1D56WBObFN/fJXVEP5OUHcYpOTxRqcEUsV1Ps8Ye1YN1sE8f16nvfTdyZmdM1ZbmIGdDla8sjczTGWq7axeDo++nvex9TPhkUeGFTS4lg/VANPNeATCbO8KtMHcqy5h6U/cuQllhDnnar/viO/jolPbsqsdvH8kZJctcEXdhkPH2mp+gdxg37+zgOD2FZh0eqUyqoVSvcpWq6Apcd5VIQ8CsDKd3aMH8GnxYuXxdRS4BRvGvr/OExSmnitaUbU90p9KupNIPt32mNEPqHEBtEirG8f/zYnjTR8Lb+7jGPeKYYdhGQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:17.3907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a27f14a9-8150-4a12-48a5-08dd07f06218 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9027 From: Alejandro Lucero In preparation for kernel driven region creation, factor out a common helper from the user-sysfs region setup for interleave granularity. Signed-off-by: Alejandro Lucero Co-developed-by: Dan Williams Reviewed-by: Dave Jiang --- drivers/cxl/core/region.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 04f82adb763f..6652887ea396 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -540,21 +540,14 @@ static ssize_t interleave_granularity_show(struct device *dev, return rc; } -static ssize_t interleave_granularity_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) +static int set_interleave_granularity(struct cxl_region *cxlr, int val) { - struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(dev->parent); + struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; - struct cxl_region *cxlr = to_cxl_region(dev); struct cxl_region_params *p = &cxlr->params; - int rc, val; + int rc; u16 ig; - rc = kstrtoint(buf, 0, &val); - if (rc) - return rc; - rc = granularity_to_eig(val, &ig); if (rc) return rc; @@ -570,16 +563,30 @@ static ssize_t interleave_granularity_store(struct device *dev, if (cxld->interleave_ways > 1 && val != cxld->interleave_granularity) return -EINVAL; + lockdep_assert_held_write(&cxl_region_rwsem); + if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE) + return -EBUSY; + + p->interleave_granularity = val; + return 0; +} + +static ssize_t interleave_granularity_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct cxl_region *cxlr = to_cxl_region(dev); + int rc, val; + + rc = kstrtoint(buf, 0, &val); + if (rc) + return rc; + rc = down_write_killable(&cxl_region_rwsem); if (rc) return rc; - if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE) { - rc = -EBUSY; - goto out; - } - p->interleave_granularity = val; -out: + rc = set_interleave_granularity(cxlr, val); up_write(&cxl_region_rwsem); if (rc) return rc; From patchwork Mon Nov 18 16:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878884 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2041.outbound.protection.outlook.com [40.107.244.41]) (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 D0CF11C68AA; Mon, 18 Nov 2024 16:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948324; cv=fail; b=V0cuYBBHT8CsEcF55+0QzecJ/Kl01ZmKwUta1ZAaL4Un9Y5xFZN46xE/a11pPJ2HgwyqJQ1UK+v2JQYEVtxDYbCUUQel13AH7CoEwneYWb3yXskcPAlOJB1Eo8s8vabBRLrDIRlyWVP1mPunBWzqZ3dCS/aqbZb+INI/V/6yWE4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948324; c=relaxed/simple; bh=DwP6y8RWb5moHVa83bJ5+Tm4mVdXtGl1aUflHQKps+g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WwGLTR60heLMg1OAQ7n6NU8WBZBvu/0wQhr7DhvcGmcvTNOlfTDVK3Y2IYcE6DnpxOSUmtTDLY7K6MkkErA3xeeezoWY1SbcKX4uq8QCe3cqfEj2HmId5nXEhf2z/TL9G180lFLsaEDVSKCCKr9VCIQRGrcBhlnOq47flDlCTbg= 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=i/FCNJ8n; arc=fail smtp.client-ip=40.107.244.41 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="i/FCNJ8n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o4VG3yGsnKmpqia7mZ4auXLoJTBnBKiAF6se9r4WPCYrDfKqcCMuBuY+3ZsjbJxv64evqVOpmMWIjDcsTI51XLcLrPnK196zkK2JM7yxTlqpbASO/wVS6mJdxOJBv+dtyPZzc2d6Khcuh2yYPpcDwFJ9dDGIPZt6JsR7b6fyXzNRP3mT2prKjaP9k/MAb+o9cJcbJHPHdLlNeBrY67RyL2BicKmx8ti8msp44SHVvYYFh3pHlbj4XLyNtD+KPmmGEmqhEge/KJxVc+dg6H9mf7Qq8yU7YsoLrRrSYZFn5+xMcL86zTh3Y5VgIJfcjYim92YrG9j9RqSxuuj184lXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3p9lH+IX+YpnXaSaZCNqdSkfMoAIr2wwDfyW3mUehK8=; b=UTht5lg2qtFlqd6xpieqoyzNLyZa2NPhBb6//iP/E1TubTYhumK+F1WDpC/TGP7BaRWAmkIujx6edNlyzuh9/Ut5GxlB1eUk6gz/3m81WelLnSwi8hWnc9OY3/K2+AWm9tcam7K3cZZD+tG67oXjS+WPMMCR6lg8bOJ/FFulYXv2wiOBBX3n3dZoYei32bhBdcqFJkO60LSMDfBN9K47rqR8Ll79cFNB3KimXOPYuNFb/PXhYPVBagE5wNLENL+DuvGSn0lr1DolNtBthtPZn872KWBg1kDl3El+Z8A7uYfdVfyi8BXl0iU/zik6fEn5Hnf/8c9ZDUHBf/pQCcb8kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=3p9lH+IX+YpnXaSaZCNqdSkfMoAIr2wwDfyW3mUehK8=; b=i/FCNJ8n0u1GaaOv3y6snZjTCkYpvM6TRtvBMoHYC+HGyyaVsrnDvqs5VmUkKagHibXxiGvAfWPsHJlS5ecq1TfBOHuD+Ck0xQzCB1hNggXxSFQtA6Oj7/fiu2fe4sfjBgC1ZeJGaOjSYqwChBkxe3i1s/nsyehW9VtcwJICwEY= Received: from BYAPR06CA0048.namprd06.prod.outlook.com (2603:10b6:a03:14b::25) by SA1PR12MB6679.namprd12.prod.outlook.com (2603:10b6:806:252::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:18 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::96) by BYAPR06CA0048.outlook.office365.com (2603:10b6:a03:14b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:18 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:14 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:13 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 22/27] cxl: allow region creation by type2 drivers Date: Mon, 18 Nov 2024 16:44:29 +0000 Message-ID: <20241118164434.7551-23-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|SA1PR12MB6679:EE_ X-MS-Office365-Filtering-Correlation-Id: 373292f2-be67-4e67-e0cd-08dd07f06291 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: uWDdDo1XYlrUFHt4UvwktPGFkjhAAOvj4S4hETXpFh8uuyWDZC0ep0s447DUMNqg6Grh5n7RE0tIM69xuOQPPtOf3FCkiDP+Wj4ax6cFK2A9ouCM2vvU60SndP2kdjEgjl9sIaxmDzdyuJjxosObDVIS+MmKCx6fD37ZvZlFdWojTsV/zlFseHLBfHtsVEoXHtnMnp7IimhMEl3qcHzxqXD6cQE3499o917Yx/qFPIjiyYTNOsGQOazt41Ce7Nl3e4N9FCeoEachUs7VCHkD8vhGxYInsKHG16cLCWKSD7yyhCbVZgKjEDtFTQ5SCk8lxV3IKBiTqnbMW1a1Vw5jUqhKOPyip7Wa+RiiNRI4ACK2ves6W1E9kLa5rqfh55jr7FiL/xrRJqwpoN85faAm8XXGuL9UI1csg4ioz6kE+EZxmg4jNlRYOwwm1Q3+Yg1+D6KZk1Qw5EMl+Gg3yNFd19tBkft2+NastQvjtHwaI5fChPSugQNYXul3lNQnQ/X4GCa1uDDmUC4HxLqEnZpwV2idePToanrvk38vuXzIWdKEszUkv6w5JHS8TdfymEOcyo5W+ZV/niCkE4VCCjaK0Q0cu8E29/Riw8btGDBv+P43UtaBnap6IShIEqio3/xOJCM7HJCNEbd2kOvyQIn6Jq3iKjfSCCno16UxmYiBcjTYEKcQsO316dPBkghiAqP/giO1YvJBz+4+RjBZGsThHEYb8SiAhhsSONk/gDfvUUdePrUJETnaF+WahKwTDy9ynnjk6V/BHHXQQiP//77G8TZ4CCuGMzxJM9m4skMhp4E2gUpAc375/HZAVdWI0pUUWJ5cuMMQ22cw2zdFmvlFH/T8lR7T/l2+7Th1dyQQZMb/e1fFp3AMbL6rRNyreBKH5XA1/1KDQmMVaD27wrxKHpy62KZYhKxjTlOwABsvcBQGYoaZ67jxVRA9jpVrV7alDJt3/AjywVapx5qj8JJUGQgFQBhZW2yplDQUneKcQ7qNwcsYQGYQK0emsPR8IyReyiLosL9V2Ih4tQwodm9qURynpFlXHS7RwaQ8l+8C8aqvxzO2EFYBug4caVy6TyAZ+SnZxcKwiqpiAtlV04xjhaNI1P0yGEKgk+FcT2m+LS/SIjZUkwznFSoFyvO1lk19GJYyvxMcLTA9xSkLl4F+uVH+LeJp6tpOTKNrPoJC9iK/qe+PCkfCupuYoxtXD1atcOxVXqRgZgzCbe3UaG4qZDqnhDsNWqEX1m1EdtiRiF4ZEQroD+t0udKiMgm+YwB9c4bB2Q89AsyZWH849un/Dv5UnPwjKkhKQ9ZrckKtCEYPQjyb3zDem13VG9Mso/p4+N5qwh7w2flQtB2dN8NG+QEHzrqRcTMOq0Qdwc7A+HdXccLjRALMlluoN9vf2hXCVf9sK6In33wCO3lgvZWkVw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:18.1720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 373292f2-be67-4e67-e0cd-08dd07f06291 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6679 From: Alejandro Lucero Creating a CXL region requires userspace intervention through the cxl sysfs files. Type2 support should allow accelerator drivers to create such cxl region from kernel code. Adding that functionality and integrating it with current support for memory expanders. Based on https://lore.kernel.org/linux-cxl/168592159835.1948938.1647215579839222774.stgit@dwillia2-xfh.jf.intel.com/ Signed-off-by: Alejandro Lucero Signed-off-by: Dan Williams --- drivers/cxl/core/region.c | 147 ++++++++++++++++++++++++++++++++++---- drivers/cxl/cxlmem.h | 2 + drivers/cxl/port.c | 5 +- include/cxl/cxl.h | 4 ++ 4 files changed, 142 insertions(+), 16 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 6652887ea396..70549d42c2e3 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2256,6 +2256,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled) return rc; } +int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled) +{ + int rc; + + down_write(&cxl_region_rwsem); + cxled->mode = CXL_DECODER_DEAD; + rc = cxl_region_detach(cxled); + up_write(&cxl_region_rwsem); + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_accel_region_detach, CXL); + void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled) { down_write(&cxl_region_rwsem); @@ -2770,6 +2782,14 @@ cxl_find_region_by_name(struct cxl_root_decoder *cxlrd, const char *name) return to_cxl_region(region_dev); } +static void drop_region(struct cxl_region *cxlr) +{ + struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_port *port = cxlrd_to_port(cxlrd); + + devm_release_action(port->uport_dev, unregister_region, cxlr); +} + static ssize_t delete_region_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -3376,17 +3396,18 @@ static int match_region_by_range(struct device *dev, void *data) return rc; } -/* Establish an empty region covering the given HPA range */ -static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled) +static void construct_region_end(void) +{ + up_write(&cxl_region_rwsem); +} + +static struct cxl_region *construct_region_begin(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct cxl_port *port = cxlrd_to_port(cxlrd); - struct range *hpa = &cxled->cxld.hpa_range; struct cxl_region_params *p; struct cxl_region *cxlr; - struct resource *res; - int rc; + int err; do { cxlr = __create_region(cxlrd, cxled->mode, @@ -3395,8 +3416,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, } while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY); if (IS_ERR(cxlr)) { - dev_err(cxlmd->dev.parent, - "%s:%s: %s failed assign region: %ld\n", + dev_err(cxlmd->dev.parent, "%s:%s: %s failed assign region: %ld\n", dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), __func__, PTR_ERR(cxlr)); return cxlr; @@ -3406,13 +3426,33 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, p = &cxlr->params; if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE) { dev_err(cxlmd->dev.parent, - "%s:%s: %s autodiscovery interrupted\n", + "%s:%s: %s region setup interrupted\n", dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), __func__); - rc = -EBUSY; - goto err; + err = -EBUSY; + construct_region_end(); + drop_region(cxlr); + return ERR_PTR(err); } + return cxlr; +} + +/* Establish an empty region covering the given HPA range */ +static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled) +{ + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); + struct range *hpa = &cxled->cxld.hpa_range; + struct cxl_region_params *p; + struct cxl_region *cxlr; + struct resource *res; + int rc; + + cxlr = construct_region_begin(cxlrd, cxled); + if (IS_ERR(cxlr)) + return cxlr; + set_bit(CXL_REGION_F_AUTO, &cxlr->flags); res = kmalloc(sizeof(*res), GFP_KERNEL); @@ -3435,6 +3475,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, __func__, dev_name(&cxlr->dev)); } + p = &cxlr->params; p->res = res; p->interleave_ways = cxled->cxld.interleave_ways; p->interleave_granularity = cxled->cxld.interleave_granularity; @@ -3452,15 +3493,91 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, /* ...to match put_device() in cxl_add_to_region() */ get_device(&cxlr->dev); up_write(&cxl_region_rwsem); - + construct_region_end(); return cxlr; err: - up_write(&cxl_region_rwsem); - devm_release_action(port->uport_dev, unregister_region, cxlr); + construct_region_end(); + drop_region(cxlr); + return ERR_PTR(rc); +} + +static struct cxl_region * +__construct_new_region(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled) +{ + struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; + struct cxl_region_params *p; + struct cxl_region *cxlr; + int rc; + + cxlr = construct_region_begin(cxlrd, cxled); + if (IS_ERR(cxlr)) + return cxlr; + + rc = set_interleave_ways(cxlr, 1); + if (rc) + goto err; + + rc = set_interleave_granularity(cxlr, cxld->interleave_granularity); + if (rc) + goto err; + + rc = alloc_hpa(cxlr, resource_size(cxled->dpa_res)); + if (rc) + goto err; + + down_read(&cxl_dpa_rwsem); + rc = cxl_region_attach(cxlr, cxled, 0); + up_read(&cxl_dpa_rwsem); + + if (rc) + goto err; + + rc = cxl_region_decode_commit(cxlr); + if (rc) + goto err; + + p = &cxlr->params; + p->state = CXL_CONFIG_COMMIT; + + construct_region_end(); + return cxlr; +err: + construct_region_end(); + drop_region(cxlr); return ERR_PTR(rc); } +/** + * cxl_create_region - Establish a region given an endpoint decoder + * @cxlrd: root decoder to allocate HPA + * @cxled: endpoint decoder with reserved DPA capacity + * + * Returns a fully formed region in the commit state and attached to the + * cxl_region driver. + */ +struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled) +{ + struct cxl_region *cxlr; + + mutex_lock(&cxlrd->range_lock); + cxlr = __construct_new_region(cxlrd, cxled); + mutex_unlock(&cxlrd->range_lock); + + if (IS_ERR(cxlr)) + return cxlr; + + if (device_attach(&cxlr->dev) <= 0) { + dev_err(&cxlr->dev, "failed to create region\n"); + drop_region(cxlr); + return ERR_PTR(-ENODEV); + } + return cxlr; +} +EXPORT_SYMBOL_NS_GPL(cxl_create_region, CXL); + int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 4c1c53c29544..9d874f1cb3bf 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -874,4 +874,6 @@ 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); +struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled); #endif /* __CXL_MEM_H__ */ diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index acf2ac70f343..ec1f0cfb11a5 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -33,6 +33,7 @@ static void schedule_detach(void *cxlmd) static int discover_region(struct device *dev, void *root) { struct cxl_endpoint_decoder *cxled; + struct cxl_memdev *cxlmd; int rc; if (!is_endpoint_decoder(dev)) @@ -42,7 +43,9 @@ static int discover_region(struct device *dev, void *root) if ((cxled->cxld.flags & CXL_DECODER_F_ENABLE) == 0) return 0; - if (cxled->state != CXL_DECODER_STATE_AUTO) + cxlmd = cxled_to_memdev(cxled); + if (cxled->state != CXL_DECODER_STATE_AUTO || + cxlmd->cxlds->type == CXL_DEVTYPE_DEVMEM) return 0; /* diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 9b5b5472a86b..d295af4f5f9e 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -72,4 +72,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, resource_size_t min, resource_size_t max); int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); +struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled); + +int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled); #endif From patchwork Mon Nov 18 16:44:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878883 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2079.outbound.protection.outlook.com [40.107.100.79]) (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 D0D6F1C68B2; Mon, 18 Nov 2024 16:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948324; cv=fail; b=a6tt2SgoxdmEgUxc7AN9+TElGeomyafoc+9c7usWG0iZ++ewYvbR/5OO0PGQhup86aa6SSXYm5Y4Zy0dfcHuiAPAvmtV4Jj5aYD3mTzAkpgz6q2Nb3txkG3XQXxOkpTDT1Au/ZroL8nFg9QdCqD0IBWxoAQNJ6LxKsx38LO098o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948324; c=relaxed/simple; bh=6fS3IMzGQ65vbuOdU2xN8MSOoVUxo5huzSUg1BqkR4c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tn5oB0/DZKROo+jvyYow/zvdKjdVnyEanHPLPrY55PwnJ2Vrc8+U3gEsbbr19h+/KLSq4Dfn3CZf6WqQ86GKs4FUtcVfgwZKK7OxTfY9mTLJnxPH3c/hDvXBcwCZq+9BDj/xkvfXKvhV3r+0C7AZ9CvrhO2YvodzhCqtdfu1f1M= 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=TBOcH4I3; arc=fail smtp.client-ip=40.107.100.79 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="TBOcH4I3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w5FC/+/hgbm/s4e0vyqAtg++JGokxRV0VELl2BTX6sGHpwzNpsKhry8HyENI7ylwwACYyVGcemNHviv2WAImil7pnfF40w5NCwu+N8EBYOx9XFd0n5CREtQHEEqVw9PvtLvWGVjtpPnBTiCLVJKGGNUOBMcYLvaEjRQHuRmW1B7KDC3FavjcP7P/xxmqdCXl1DxLF1G2Rj/S7Ihn9Za9gIApcEiga0XuNpLz8LVy13MPForW1ncaO0AWxGezcwotAxhxY8LczRwPTBjCbMMn4QnrYwyuCDRbF4OMCCjRFZz2mRzQsZ2o+Nn6AH1VQ2L7AAw4Un4TwkEyPdsFBMKg9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/WubTte/ckcogiS9lKn4vEmspzisbu69tyjq8pCWp+s=; b=x//dTVD329qJ2HtiE+QqcgQCE+wCcr8HpuSyf4kpmM68LojEuIcDb8Q9q5D5a9OHGouRiOmdesFL2dFzv2Bhr1+vohF7sv4h6PAf2i8vrp0JvK+nhxJfJVsHcirdShsqFAzJ3Vd1S9jLjSQyHpwUDX0O/TVnrlsbKjY7sIvkPkUy2KJeFWgeVxSGwiNh3hINrfRvI+P7vjjjOuwko13NeHVn+3d00PlCv4Rw5gJ6cQ+si53cAQ8x6SgXFA2mJvDfJxENA8xAB5nhfhTls8JjL1k4tMiZLSqd/MWrFATz9ZI9xlVGPwGFvEJDXlsY37LExrArQqEk9hr6boS4EaQ8+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=/WubTte/ckcogiS9lKn4vEmspzisbu69tyjq8pCWp+s=; b=TBOcH4I3QZZfqG/uN91NULYRM01g4bntwBO8z3pA5P/nzuiP6DumWLxeabhdp6Qn6kMd8NDdead3z8mlU1gH6xsQ88Kj31kUovcUp3o/1W7gzDBlLUHIFKrsYBfbggHnnFs7DZERgMisuVM5uNlGr3VuBwsiKa98d/9AQKYsOos= Received: from BYAPR06CA0049.namprd06.prod.outlook.com (2603:10b6:a03:14b::26) by DS7PR12MB9503.namprd12.prod.outlook.com (2603:10b6:8:251::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 16:45:20 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::af) by BYAPR06CA0049.outlook.office365.com (2603:10b6:a03:14b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20 via Frontend Transport; Mon, 18 Nov 2024 16:45:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:19 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:16 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:15 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 23/27] sfc: create cxl region Date: Mon, 18 Nov 2024 16:44:30 +0000 Message-ID: <20241118164434.7551-24-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|DS7PR12MB9503:EE_ X-MS-Office365-Filtering-Correlation-Id: 66b95a20-fb83-4161-74ba-08dd07f06368 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: 4/qtAhx+77j5BV02cKpFviLH3GDdLHSGqjqYBrMLOTyj45hCeSNeTo/SvN2UJ7JHWx0rIgXJof5zID7hq3kFeQWqJ1vKc0n6Q8aK1upUvN9+ynlvS4tFGvrbP9Tp5XfKYBzJbTJtRNwYe/qz9Lht66iPfrmAUmyR+QL6+ilozz5NJf04r180HItGqjMaCAE43bS09rxXW/RqJYsr/vS4dJZc0VcTawOQT/qIF0AZl6s3iwq+pqR2P51ryTL7LwCZGpWytoLlOYAmhLkG3LENlEBaiZI1KpuZ5mhsyXu146GSwKLcQiLy5lE20Gshaw1izI9n9kVFHl3/kDxQIpXk4EWIio/y4TypdZPgy4SdgM+cMqpf20Y2H1/c9oKDNE/4ImM2oC42JRXWuVjo4KBx0z+X4NHjAHVHqQQyMSsc3OgCsmzQ2Cq0FxpCUiyUYUAclIpk0vQHwbVPffipP6Oz4B1ug5aREYOAmyx6wCYYtzF98+lG2sHY1VzGhpOEqZbGqu+eXDUd5AcToECnQ5PCbhsUGlxw2Y+VLQxgA1RP7lraJ5hz0NVo2V34MaJCUeXKuAbQUGhF6BbKUHM+e2UkNf8fV78kgmlacbcGux/BMA5k4gp4C2xADVW+F/3Fne/Sg23rc/tXbGhxucG06RXYzjjoX1I21HlwLsfk/3dWLM6fqdyI69lZ5h5NTIa2JPSIToYlMZtuCePY9Fd+d6wrhYw/FLpm0wYIetXn7mv395tr14E0ydZMhFzfV0O3He3uaLmQCyc3sOhEpCYwzRdCRL7SPfUKV0eLSB0DNeMEH5VnrIoDtaCbDxM4l/37J4y6Xg9U0lKr2It/h6mIL6yqvu0ZbCNiVan2bf3s9tMz3e8RGQSM+dbeJi1+giWGEX07E5Y1E0mDZPyET6YS2nN5cuvmwmeqL7v7gfoqO2fQntJfsJTW3VxJQuhnUpEP89wfmtc/yoYtUBrfalrwXbDhMebET8bNEk47KPOWJJImGHPfcB6aFvSaQ42XN1rwg/ny4n1n/dnRuf2EkEzGARefMg0Xj6MpudWZ0glkBv90Ne0jweHn2VzYtZ8WzOiHiZgcw+2KoHfaGydzViK22ywwixAhbqckiZemqtLWVo7gsJqpE3E83ICM5T6WTjMU1Xdx97bdM7dtECdeptLByYWPZBF9nUCLTaoU02QQnQDA7WmIJvxZYLfD3Z7OqKxbMe8MsfbW1gEBKCLuj0HPchy671L1N4Ab+R49YfHyTMZ7VAIHNw07xu9bac6/Zz/Z+E97eTHDEPW1FX7K6LJvUVHHWN4iCxjVitpmlF5NRyrr+F1k/h6/LztF/ih3lc7bQYYrauIFtCFtxIPeNxcDi4X7lexLTxNENx93fkKpBrWZj98EqJXx4fgNj9i1xugNWxOCOczvv4QyZgGBtuHNkO1XHA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:19.6251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66b95a20-fb83-4161-74ba-08dd07f06368 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB9503 From: Alejandro Lucero Use cxl api for creating a region using the endpoint decoder related to a DPA range. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index 85d9632f497a..f9f3af28690b 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -128,10 +128,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err3; } + cxl->efx_region = cxl_create_region(cxl->cxlrd, cxl->cxled); + if (!cxl->efx_region) { + pci_err(pci_dev, "CXL accel create region failed"); + rc = PTR_ERR(cxl->efx_region); + goto err_region; + } + probe_data->cxl = cxl; return 0; +err_region: + cxl_dpa_free(cxl->cxled); err3: cxl_release_resource(cxl->cxlds, CXL_RES_RAM); err2: @@ -145,6 +154,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) void efx_cxl_exit(struct efx_probe_data *probe_data) { if (probe_data->cxl) { + cxl_accel_region_detach(probe_data->cxl->cxled); cxl_dpa_free(probe_data->cxl->cxled); cxl_release_resource(probe_data->cxl->cxlds, CXL_RES_RAM); kfree(probe_data->cxl->cxlds); From patchwork Mon Nov 18 16:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878885 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (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 CFE3F1C82F4; Mon, 18 Nov 2024 16:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948327; cv=fail; b=i2+ep6I0pz0U5fuduMciZzk6cK/6FP6DhyIhCZLdTp2H+izgGuTZT1cmrUV0ANbf26tEu3/eZy9VqWN+BgrlNKW7tMyCyVXdFPkJj4BUZ2pY+id5leDCKCnt+M/R4d2WIJjMKPtc0VajH5IRlE0J8f+cC42lx+2DgiZ9SYKZ/So= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948327; c=relaxed/simple; bh=fReNXSoQIhOotVmzMP9hEsG+jVGK9sb0NysQSU1fqHc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=reAD64HQ8WMXE21EzVDnTpGSZZQMtwbJtKwQrzJBXMHhCZfBu697OpAWYmg3pAglryQlymHz3EOB8Ywo5rroiM1Mj7LacDbfupCUPjEe7pfB+RNKg4rebFmzz4OIK22z2sTdO5Np1GbPSORfOjWb8cfwnCXt6ihtn5zdFB0Vgi8= 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=BnGduYIf; arc=fail smtp.client-ip=40.107.223.83 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="BnGduYIf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lWxjCZ291WEvGGhwN+Zz6f5dnEqYtAkgwxf6czhdfNcQ6mtARqKYMCH8HLeeGdcgwAcXjZ1bQBvjPIeX+lfjnsaYrn0kccVm6T6XpvCiVe5uGMCoLasX4sOAsUtPzlDHWpyWuptY6OS3PTK734JXprUg5AxTatu+w62EIzZXLG6ptgRG8CPyw2Nq4V8LEL9LBa+OwUUS8fEcABpS6hv0+75lsMoiajZ9JxuXtSDIVGMZ53Xic2P5pgFJ68+dHmh2Ue+LIdOo/Q5TOY9JALVC6rls2p3g/5k8sIK+kYy13qIjcvUqv+rMdc18rRYcqqkAJNnzjbYtJZ/1Eat07Ow9wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TiEF7VdWg9RxbC+/oHpCvz61w1eYxsnC7HExr21FY/4=; b=OaAaaSy2uQ3AnpnFzoqsBoW6n7L/SIqvIkbqoT2ONxNM0IG0HqLzCW6+AMOdU1iBSWQZWk/8KExvbfxIpvRmAs4ZEG9wd1Jw/MssFmOfcIZPDmpuRLMPURSzoPhxs5kuJzm7qZ+DNjdSzdISQEnqJ1di2sOjCbNUcmPN/zfb8T0BLEN7dhGFbh9Tu4dwESdUGJNfLlSX5j8Sw1UVut43TDgIRlIpNMsBgFixVPHLlVGFi2Jc9CUf+PVCN1oVm/uvs0oPbrRHv0IMgMgY9Igt/2GnEnruPYz+m7ES5f5gBdaPm3iIUlWqeXwg8VrO49pn+yCxg4NZ/KvdY8Ip/y+P6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=TiEF7VdWg9RxbC+/oHpCvz61w1eYxsnC7HExr21FY/4=; b=BnGduYIfsaJBlYW0+ObIZsbTSn0APo4McYzmb9encE8+DCBj93ZpKlkyqNN82YKC4rT10ChlHvzJ/og2aRYrnzUoYrHGCC0adVJV4VaXynKTJ+qEgcgx9VtFt1FpFE+uRL8Q00PKysAPT7QTcrfUZ2fKd7ABQzdIlHUBzh5lG6E= Received: from BYAPR06CA0070.namprd06.prod.outlook.com (2603:10b6:a03:14b::47) by BL1PR12MB5900.namprd12.prod.outlook.com (2603:10b6:208:398::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:21 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::59) by BYAPR06CA0070.outlook.office365.com (2603:10b6:a03:14b::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:45:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:20 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:17 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:16 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 24/27] cxl: add region flag for precluding a device memory to be used for dax Date: Mon, 18 Nov 2024 16:44:31 +0000 Message-ID: <20241118164434.7551-25-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|BL1PR12MB5900:EE_ X-MS-Office365-Filtering-Correlation-Id: c8ec073c-84ac-44f9-0b56-08dd07f06401 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: hb1kDgzUiXGvXEWK/D6vY7KfIlWWD2CYIqiP0dCJbN+GvZHSO+LDA9JDcjP0F7W2pQKlPj2dpIJvNMf48l1rpG9ZP/eSMez+XVETRawGQ1jCAfyCNZmfomMMpxbxLffTJqXNrLsWh6AJVz53JatSdJBxVUz38icvxFyu32KuNnFjMOLPvnW0RRD/IScYNikwvsyZYknCMg4PdwDXwdoEUdQUu+1RlNiqv0MX9VNOgeZNjx3YYw0+ioQEI6uh/MOPrLykzyntNaXdoeUZyHcPS/3hKFWy01Xz+m6Kp9DXv5eXP6pulzPs6BYSzYYsnAaRwKzbKKuOjtv5zuz7GzFqtIT4Qo9NresaQ08LArObhR4whx+kj1/xcrQqmn2Kmyxe50FU8x5et8h0Co81aytB/21Oq5hya4wCKLaIIigQ8TS1dyi0/0DR9Xmmephcy+t9H4KLc6KiY89TQTcnvFykeJHMwGc7HA2ipaQsBl6bulZCF28/Re464PPNu2JOzsMjcaZC7Z/VNgS5PtcuNbJdqAE5S53UQuxNpquapihGBlUllA5l2ohS/phrdQksz6kJBfTHCYOp5wW3m3wy6IX0FtTKKx3WK5LrfpmS4cxrhCxNAxLvKw4wJrB13W5gv2CBffdNKuf1tLuFeLG321bSO2yt3WRbf5ZhDIIqZsHRmZbx0d3Ua2xmflddM4JkvTMkwAEw+5s9Rzf8FWN2jT3HagrdCbMOXqhhEOHCNRuaplUwHyE9Mmu985+PVeqPqO4NztFHQWKCeJyCoEl1WFN2rvyt9XjhaaTW1XxUMy+74QIc+OuL9kIY1nuSk10QKAoZWPNr25VIV8dF8vJZJ9EbWlNJppzQtvf02iEuEFVAmKlwSAYIFcswBMXSI9B2XEq/pwo+jtL3RC93wlQrICqosBJoOrYCczXrST/eailQpFwQdVFMM1/tC1O4p5IrhPw2Y7XH8y+PGojb25LwhghEZTDnWmA3NzXVuxKBxReymmmLgG47gDGAGgVBu0oOfUKW3WBkkfuWnOCwhWwST6ej0XhyMSkG0Gt26N59Z2zlb9qy6YbRDFPN73jw73NrjvgmQRn7iyJZcJTblM8B2S1dmM07NapgIdAquMpq+S0RmF3Xn0IxdckudFQ+z6p6cm+Oe9TdMh+wJhK74RPveCTAzxekPFfqiQyMkMwcw4IwLC1/WEB0Ew8dtDr3WATK2FbVY4HV3bhFislwcfIHIHmDm7AirWRH0rkkdIBMXaXon8eJu5cccNq+Tew6GLXqZ+ekENCe+vCwyDAbeocXCShYoGKyN5fMQPvk8vYC+hC11J4JVaoQ6XDJ3CQ/qkFhd7CzgmO4xIYa/a6ClVoTgYIefSzux2B02ldQ1aGSwCRblqx79zNAZOGEfXrIgxDFGKVlBooQnHmw4C21POppmnZhrA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:20.5938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8ec073c-84ac-44f9-0b56-08dd07f06401 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5900 From: Alejandro Lucero By definition a type2 cxl device will use the host managed memory for specific functionality, therefore it should not be available to other uses. However, a dax interface could be just good enough in some cases. Add a flag to a cxl region for specifically state to not create a dax device. Allow a Type2 driver to set that flag at region creation time. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/region.c | 10 +++++++++- drivers/cxl/cxl.h | 3 +++ drivers/cxl/cxlmem.h | 3 ++- include/cxl/cxl.h | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 70549d42c2e3..eff3ad788077 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3558,7 +3558,8 @@ __construct_new_region(struct cxl_root_decoder *cxlrd, * cxl_region driver. */ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled) + struct cxl_endpoint_decoder *cxled, + bool avoid_dax) { struct cxl_region *cxlr; @@ -3574,6 +3575,10 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, drop_region(cxlr); return ERR_PTR(-ENODEV); } + + if (avoid_dax) + set_bit(CXL_REGION_F_AVOID_DAX, &cxlr->flags); + return cxlr; } EXPORT_SYMBOL_NS_GPL(cxl_create_region, CXL); @@ -3713,6 +3718,9 @@ static int cxl_region_probe(struct device *dev) case CXL_DECODER_PMEM: return devm_cxl_add_pmem_region(cxlr); case CXL_DECODER_RAM: + if (test_bit(CXL_REGION_F_AVOID_DAX, &cxlr->flags)) + return 0; + /* * The region can not be manged by CXL if any portion of * it is already online as 'System RAM' diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 1e0e797b9303..ee3385db5663 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -512,6 +512,9 @@ struct cxl_region_params { */ #define CXL_REGION_F_NEEDS_RESET 1 +/* Allow Type2 drivers to specify if a dax region should not be created. */ +#define CXL_REGION_F_AVOID_DAX 2 + /** * struct cxl_region - CXL region * @dev: This region's device diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 9d874f1cb3bf..cc2e2a295f3d 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -875,5 +875,6 @@ 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); struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled); + struct cxl_endpoint_decoder *cxled, + bool avoid_dax); #endif /* __CXL_MEM_H__ */ diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index d295af4f5f9e..2a8ebabfc1dd 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -73,7 +73,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, resource_size_t max); int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled); + struct cxl_endpoint_decoder *cxled, + bool avoid_dax); int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled); #endif From patchwork Mon Nov 18 16:44:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878886 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2047.outbound.protection.outlook.com [40.107.93.47]) (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 73E421C8785; Mon, 18 Nov 2024 16:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948328; cv=fail; b=tf5VTm/3Z9FDchccfE5lcma4dbq+mVvGqLLEZRSR/bllqz6S9cJBolU/plWL6elJ71z4exnziQYtFz3Fn+0qT16ItfU4IchEu+eXyEqiAxqcgl91M4fwZMmbJzLsEVgloPKmxHVD6EQYgRYvn5lq3cv0M9yMJbjrixi+Y6lN34k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948328; c=relaxed/simple; bh=dc1ni5bXUxXqa1YVgtgQxEPRTbW8Pm6kR5QxMH138mE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nmbgCXixMTm9xZnoS5xHxnAIkf4rH09Oa/4xTakVIlI0E6q3b/zomDIptx4OYYNPbQIGEiZGGoY5drvnIlZsvdz3RNtA3E8VWv8BbvE8hg5zR6SVtnGiREDbtMXbhFKhlNkelAAGXs9ZF95PhYnSHsuAvAZf9hD+YO9Mj9po/Mk= 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=Fyb+/+6V; arc=fail smtp.client-ip=40.107.93.47 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="Fyb+/+6V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Jv13ZH9T/pCo1/+qbMcGLSCHN15xO8CLp8F8Y2zLZ68GVdJZRSt+4hEkUJzfEQMjQitcoXh5v3ImsiKCqwh7uQ2qJKOvk0LukTOLkMHQiYYBDJYTTmozlRtrXU9cz9S6rcCV2p5JFvGQnhr+6hV2vg1OLV1HIQoK4VQUX3O454BRDOgXkyDfcTaTmC9uc8xai/6nj2v8PKJet7tsweqK4M41Djg0W4QjJzwXTQJNHbg31RGB1lAu0VkBmMyzBtgp04kdJFJJ+ZXA0iKgczvqXYVktvFcsWPNNY2QnCXZ6z/mUFfPRsnmXooGV9nmm6JCeLzDEcQ4OI8VH8ZgBKwKgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9CprSceh0v3jYYun6qAkXMr4Ql8RLWy/fFXjmrQxC6g=; b=uQBjcts31L5OlwoVTJAC80XRupepn2AFZnxXyAt4dvofdjlMKgKYONM9JeZGz3DOqqSaycNAb+0gYRS8C2uV0eDhqcL4Ws7A7h4yjsGy9UmNWW7bONOCsBRdb+o5vD7XKgd+AAVZJBWP7WmUFlqK3AaxGi4TZ0329QfE/WIOECXLi1rAjjz6LC6tcbITUyyOiY6xRKEgmeloGdxVT6X+l8qi32uO5COiTOHubLl+AKA46Kc5sgZExqvpdSAJeoTqhBH8R1Jos/f61gtRe7Uv4tFN/p0KwOlv/AxjMztApa62ExkXyrZSs0HZNl3Hr2H4il31hR9H4asR7aUyT5zwfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=9CprSceh0v3jYYun6qAkXMr4Ql8RLWy/fFXjmrQxC6g=; b=Fyb+/+6VzIKktRjll86pInhscDX7KrfZPdUOzRgOvEP84JwOEYyttBZ/ODsmNMl329xRg8uqqoMQkcVajFnegBUMRSpHhyV02kVr6mLCBhH6uTyY/2n+bD06wsPMGB0M6ikhmp3DXERIgU93l9hCGxOnqX/lSK9xZ0w+rEc+D5E= Received: from BYAPR06CA0043.namprd06.prod.outlook.com (2603:10b6:a03:14b::20) by MW4PR12MB6730.namprd12.prod.outlook.com (2603:10b6:303:1ec::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:22 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::f9) by BYAPR06CA0043.outlook.office365.com (2603:10b6:a03:14b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:22 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:19 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:18 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 25/27] sfc: specify avoid dax when cxl region is created Date: Mon, 18 Nov 2024 16:44:32 +0000 Message-ID: <20241118164434.7551-26-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|MW4PR12MB6730:EE_ X-MS-Office365-Filtering-Correlation-Id: bb0de156-e1b2-4a7a-ec3e-08dd07f06504 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: eeY3q9lcP2nA11bWtmKgFj+55IYV5jOC1E2Od8RtqcmrQIU16CKe705KdHDUvZBJrrftho7k7vnsvg+7Xyn78R8BWgUHui/EID8YSWVHp9VnGvH1xONdzefPT6dnZ3cT8IEkQh+VOb6Z++Xtd6lIeVg2ArMQ+Yw/RN1Aoxq0jVPgjtwAkmem5DV81mpbZy93itdojkzueEC/BUV8TUrmlRYV38EKpSEc/QVy4KRyL7wme6QP0QQBGydxDKx7XONvRxzkPPFMvjuhBbVEXeTa/47zJ9AskfSjVyHcunyFcNg8zfs5s0lcQQLCIwtGKlfLNUulpR/4O8pnZrNWYBOnuTlAPi/ZLimCvgrtmr4t4u1KK2o8+9wafcsEnB9h2FDz9uU9pn5/ZjaD9D38ghGiDL4E9sZwQeUplDcXH/wCbHo23CRBHeooSqpJHMi7gtqpZkPBjfawfiCOAkQzxnvpb/3uo1vLv+qp/RnST3/z8sjxaIlEd/tubf6eOMHxIg2iskmnBLIAefHE3eSvJNnuVxXABPCEXbGrindqTcBcyRkrZV65azinolXNXPKxBFJ69YMrdhGXzsPvwpnfrs3LuUVgZIJmdIUkBHHg6Ec4LPK1Qbfbm0gpF9FBUsD899KTPH/Us7rXPFtfV4jaCNVC9X3Xm5wzbtyGDxZzIn1nVpDTPQk+h3j5k+OEU/wC6XiygcI5F6sWRRI/fbMDyoTgzGtU7rszTAaHzNCnqaYblP2k6qRQ/bCygd7/wz9JNd0/7SDdJUdnChcwqbBss+5dEb7iW1NjmrxUwWDzCIO3V9pEVwUMj6oxV4j16yGhOm0bUI2zUE4NN9VbKBe1H/HjdaENnqhlK9NHNGGASble+1+A+dOByrFfHFtOi9Zs6xgv3KmPI4jOcTnM1SptunL4oSJI7XwRvZIPz8b8nDsnt1JNym+GEZyE2plCoFLbMmbjefmtM3UB/Y/BQPzBt27X5nNfC9pASBEVpLOkxPjvcd9fRzxdu3GXSB2oimqdz78jxxlPp0HkUqjXscAORVhy7nZEAX+aTaiD54qol1cIZAztKJAR1zaINKwlAcRDHXzrpBloSPTvdcMK5hHkt7MEEcq5+j4gV1LfTwOgSrG5lNxdYIGLySFY3f3a2x8il/M/N2r9FiD18n7pdcpf4B+PuS8v04hwl29PEQglTC+8cN4mfXx8vUoKpCkNtVwstW1VfafCx3eJKoEEdrGL8Brvsndi16TMsfMx4kVxZl931NkAzHsoR96c0oFzH/iCTAZGERqyX7fVKFTvOBMw+xpmewcM/o+xVoKKT2fMwZUg7Ye8fbkrsyDceIORsLQ1E/U61fnXTEoGB4n91czD+x9gyUrHe2MhoLgGZxZBVdVa6Pb1Sd+k/e9Absr1977EXHXKE5eHTtdNRDbRzpo3NTPqUA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:22.1564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb0de156-e1b2-4a7a-ec3e-08dd07f06504 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6730 From: Alejandro Lucero The CXL memory should not be used by the host in any case except for what the driver allows. Tell the cxl core to not create a DAX device using the avoid dax at region creation time. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/efx_cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index f9f3af28690b..de8d6bca9300 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -128,7 +128,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err3; } - cxl->efx_region = cxl_create_region(cxl->cxlrd, cxl->cxled); + cxl->efx_region = cxl_create_region(cxl->cxlrd, cxl->cxled, true); if (!cxl->efx_region) { pci_err(pci_dev, "CXL accel create region failed"); rc = PTR_ERR(cxl->efx_region); From patchwork Mon Nov 18 16:44:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878887 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2057.outbound.protection.outlook.com [40.107.96.57]) (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 744A31C8787; Mon, 18 Nov 2024 16:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948329; cv=fail; b=SlmV0Zq3uqMai8XQFrZtlTvCH2PG5OiaQLpPEhple6lh+2HEPnt5WmciaS01WnaFyyt9vzvczgWBijRrLFKmJmGs3MkmFRwL/enGa3r2qXI5U/rKGFhve7pODwz0Cyiuj9HDDr//37H7lIS0QDCfv4ey+wEsTMC42gSfhPo8tn4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948329; c=relaxed/simple; bh=4jvtnNPmQRjcvhAqQx06eEXtXtNNaKnb8jPTgrFk1/w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PflQtyqot1K7GpL1qmp1FTpaiz7HE4I/N/8X93jz6/aHYWfYjgMyQQzPEySrnOME9C8UOht/wD/UWZZCSITXv74h13Y9KEHInXY9VCUr5c/8sfuvG6578F5WI0PWeYIcTLkhY1OcCTcNSAOWfLRr7ZFzeXaxhlMx3viwv81igog= 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=27XpEAnb; arc=fail smtp.client-ip=40.107.96.57 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="27XpEAnb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z/37I9hRii3frSKFskVfcAl8qtWYC6ZRLDQcddPOMn9FE0G2p4eK2rjEtB7nxWMMPER/Ddih7rrgjvtPMlpQ43x9DsQQj4rl5E8MiT7ORqo0rOJOy+uHXe+Doga7B8C8ATqk7FjuyXKMlmX6l5Rc7jcbqMqDk42IRX6l+kElN13YsZfg6hMCdEbPRUcifsFgHUclh3GT3urM+HyDepvXmNZH3J0cEhEUuJVFLM53OyvUQFols3VztMbolPVq8JLTw80DKbs5wKSuqdpS8SF8Vu32GRWG8L5gjRTjt4AXdfshX0rhfjMtgDBAjV+DE5Ea71AqCEw530SeXGj0tzdn8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=79hlLTJJd1P/6vWj5FZZHjmqyNFCQNg5tCJh8Gxe9Dk=; b=LCZDW9LuG8bx4Ny0VfwUaBjDtuphCtuFoywH08nQYQa6Mho3zNM78vHLIGAfRcYzBCs6TcrcJZ4448luY1XlFc2F6bPChFLCnIsiEYeVY6oR2eOUZjgCqic3A97XTWsyeTMYwL+XkND79zYINAkrPVPFRE06ByFHR82T6MnTXsi8lcSkW0TtFYvyDTJrPCXAoHG/NHZwk8CQ/NMoWD5sABSOfyIc48KhxtQOYwc967JsKveIRdg0OvonOgND2ibQqRL0S9+32t024gVQKtfGGqwYbE2Mya4noWnI1KiHG6Q6PJWzBGoHmMsZ39hhdEvI5GD+dSvcYfENTfVu2jLFsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=79hlLTJJd1P/6vWj5FZZHjmqyNFCQNg5tCJh8Gxe9Dk=; b=27XpEAnbpCnLBh0ygoU7VTP2j40SCwvQA1spRIIATgceegXGTPBbew01pE4BwOMVN2Kea19I7jiebI1vKFLr1kUhBSRQNAITWGUC/s3apoK6mxSpnSGQg3Jjsgg/Y9XoqQCNxLWkaPCldz+b51Ll85Uyl3rlQmmL/mjgHqYjRP4= Received: from BYAPR06CA0046.namprd06.prod.outlook.com (2603:10b6:a03:14b::23) by IA0PR12MB7507.namprd12.prod.outlook.com (2603:10b6:208:441::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:45:24 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::b6) by BYAPR06CA0046.outlook.office365.com (2603:10b6:a03:14b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:45:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:23 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:20 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:19 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 26/27] cxl: add function for obtaining params from a region Date: Mon, 18 Nov 2024 16:44:33 +0000 Message-ID: <20241118164434.7551-27-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|IA0PR12MB7507:EE_ X-MS-Office365-Filtering-Correlation-Id: 30500cb4-6d97-452e-d22e-08dd07f0658c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: H6KCvrCOuEwyiTUCgeB3n/TPjjaaKuUjBjMR6y8xq7mm0mNcd3EW6f45rsSXN5nvy11L4Ef1MX2Ln8CMh79ibGEyBSx+weBV8OM1yWF1emka+wEWezvtUP0j4p1RW8CFWWojDMF0TCwFU0cb8aptqtL4cIK695ql2mF26xHdWgpQRzMUoQmsa6aHnhxl8NZG/ruSPxRUT4qToncVMmAuAOv/63UpX0BsbgNeiDvEGyLyIdSN1oQNPSm/7qDwa//2brn2IBA+5JXMtmPxDYzj4EqgSN4UHT9pVQNS8dkZX8FJUDw7WkTfCB3gt6ebZSsuPnEMpedq3ASfh4kGLMbEPSVhSja9lXuD7XBcXqdNZsJ7dXmdUX67XrtBWP653fa5P0I583YsAAiqyjCfFW7XxVpd9FJJHxUat9SWjpKCkcNMAJM7SP7qO7m5JGfVezQPQQwV2nd7nT/oiyELzGPiWo00+qeIgXgsETIXNw1sJaCsZn6ZM+9rK64+c4WHk3uOBDA+B1q9EB+lyXo907H/526gCx6Igbzpu2cWm4Fol63FWXx/RcEuhAACoVj+hV3ztBLm4lOi+yLHhZdpUx5b/vsyg+MdlIUOpM3mBfP0oKqSejItfD1BdSrJBXMMwqbFJ3wEBxOTKrUtAAUDEKKViVMz2GLo9ZF+uTWq6egThL6061+vw29cfGlgHVOwxjP5rI5Ub1MuK2dB8+mrlQz3EQj8RsZDpPFLoQCesBc9rO+Umvuc0XjpdbzvU02uyVBaXT/zJqkWnJPAvMRr6Kgf/qiyLmzfPbeIhX9HzgcT2Si7ZQcQIMHOlf2hgk8+uNNHL4TEfm0cyBD38eTzkp0Q4nPXy8DsI2w/PqpCwC6TouItsyclAyBdVnjv0/b/JcZcrpAL7h9vGc520KjHMo6zfrmRPyiK4YxpY91WiUzQ72pDZvr9YcSK58NuBk4asAy+zWyezzSOFf/tzzMUmg1aEk6Xu7O3gvTIew3o5mYqleYRLfGsyIkZ09UJgu2C7e6R0UNRIVnLSJhesMnf51TiOsjaIxUKxcM7H0/KTauT+DTTfLeIhSHOpNtZCazBFmP1FMk2eEsjaUv5KcLsU9iZosFTQFuYzKT2JB4R+9358tt3wlvGU6Kx6/UzoZDLg1ARKOU0Sw2B72wCzrWJQKcUs+diN78W506HiXCG8/nGl48xvk94w6/GmMpuSl8JqDDJVGxq5ffM5CNCuMO8JnvjYfgA23GEc/lt12E3CL1PoNCwUEoLjFzPE3FqDa3soOj/Ct9a3Cmm6GfYNFr7hOI5KsET7PtU1UXTgh8qLGx4oRKSJj3TK+7dr5INCPKnmYHRWqU6/G/Uaq8UpgNsSxBpfhVnPatcVeUHOphLl0OLIE1YkOm+tRGgWTVuNcjwhwyonLrxnpVLOvV29gmgBt+RCA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:23.1720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30500cb4-6d97-452e-d22e-08dd07f0658c 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7507 From: Alejandro Lucero A CXL region struct contains the physical address to work with. Add a function for given a opaque cxl region struct returns the params to be used for mapping such memory range. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/region.c | 16 ++++++++++++++++ drivers/cxl/cxl.h | 2 ++ include/cxl/cxl.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index eff3ad788077..fa44a60549f7 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2663,6 +2663,22 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd, return ERR_PTR(rc); } +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start, + resource_size_t *end) +{ + if (!region) + return -ENODEV; + + if (!region->params.res) + return -ENOSPC; + + *start = region->params.res->start; + *end = region->params.res->end; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_region_params, CXL); + static ssize_t __create_region_show(struct cxl_root_decoder *cxlrd, char *buf) { return sysfs_emit(buf, "region%u\n", atomic_read(&cxlrd->region_id)); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index ee3385db5663..7b46d313e581 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -913,6 +913,8 @@ void cxl_coordinates_combine(struct access_coordinate *out, bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port); +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start, + resource_size_t *end); /* * Unit test builds overrides this to __weak, find the 'strong' version * of these symbols in tools/testing/cxl/. diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 2a8ebabfc1dd..f14a3f292ad8 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -77,4 +77,6 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, bool avoid_dax); int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled); +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start, + resource_size_t *end); #endif From patchwork Mon Nov 18 16:44:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucero Palau, Alejandro" X-Patchwork-Id: 13878888 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) (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 E9D961C173F; Mon, 18 Nov 2024 16:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948330; cv=fail; b=A9Btia5TcpXewfQb4QSQn0NnbwgDAk0fDIT5A9E+9Ia+xQ3Wz8gF9H87FGSJAK3j+AL1FCpNGXpQK3HmX89HGdenihPafdd/RReqJgjL6Eu7/C2r6rUZ6O8dQ8gAlGmVq5NzlHrG9IfbLCLfSv5YAzechoGP7WspuYDnIybAZBY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731948330; c=relaxed/simple; bh=kuuMeTAsxpcd7Q1p105WV9RAZu6NpVi611HVJBa4X+g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zg5BXeyr3SQ1x/bIHvPgfS93IaZmhXlbR6bR7MoNiE7DYh6fo6yfYPdE4swOdQVeFzqBkKnAlIHkaKjeErCk5wVoM3kYZxAm+api1ZAilJ7z2GoZPl+ZnhgrlmvOhd2FOTSlawbISaCIP8C/ABy66L3XYyqFpVM7wu7d5kyVIEM= 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=tZL3773L; arc=fail smtp.client-ip=40.107.93.73 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="tZL3773L" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mH3RdjGYCKh5TsHPcqz0BK1q93vLJbCM/U+kREpFiKL1iOMbaogkyeSHix1hmUiVQyWo9QtX+FBNV24SGYd9qO1medcUToL+SnbIyPNQPHga9z0He/c4fR5ZjpXL2bYxZh0R4azrPWHicpovYAs6ig/Q9K00n8P+IDD65ztVHdP9HQkDGLJ0wu00kTi/gNySatWZFRhNi6WOD3ppq9DpENy/Q1bn28m26PBo+WDALk4idjgaKx5yloJVp1vgV61307sLn+3BgwqNxP1CWNLoOG6juWIZw7kDl8pZdB9XU12EwIQQrhFTelWjK3p87onbs+mUEER0N52fdx/KBWg0wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NfQgc4g1di7vmY8U703jHmWsKTOzxvLARBD8MjOMLds=; b=f+TmT+veW1SQDsiTw2A1PtK5uF1BD4Dbspw3AHzoC4hyBbSAu68Ho86EmtW02LYyjP7/O7nLlg5XwrGTRNgSjhbZwT+QBQmhrbtcjmUK/lHo0WEDNNvCLwkkoVp8xTXhRJuwR1NXimBfDQvijkyQJmPKzY4vcH1NWQDWON/Fcka7VbEbWTHgVtIHcFADZ3jLWB6HsbKKTNDdvL95I1hH/PVOMtpsi3F2zoyhDPYgIafGXVWEyks7yK6hdJWdmXcFQiG3j9yHT5I37LNTkRvKM6taR3+Y0H2RriGkZrBRyik/QYce7Czcn7ZZ6Z/QLKgTMtyCo8aSjqDBVV6hphP+Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=vger.kernel.org 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=NfQgc4g1di7vmY8U703jHmWsKTOzxvLARBD8MjOMLds=; b=tZL3773LDEuJeDjon2AjUbpfOdifelvepqkjEuFfpcLdta0rkOCWVSVhnfSaMreErhAcD674W5Z4yY7lUdDMjZOcnrJJI+6VhmwX8eaamek/23gbxMuFceh3iPxRguV3GcQx7oeFvXsWk6qRod1ytT+f0UEkEx831D8i8XO0MfQ= Received: from BYAPR06CA0048.namprd06.prod.outlook.com (2603:10b6:a03:14b::25) by CH3PR12MB8583.namprd12.prod.outlook.com (2603:10b6:610:15f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 16:45:25 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::f2) by BYAPR06CA0048.outlook.office365.com (2603:10b6:a03:14b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:45:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:45:24 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 18 Nov 2024 10:45:22 -0600 Received: from xcbalucerop41x.xilinx.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.2507.39 via Frontend Transport; Mon, 18 Nov 2024 10:45:20 -0600 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v5 27/27] sfc: support pio mapping based on cxl Date: Mon, 18 Nov 2024 16:44:34 +0000 Message-ID: <20241118164434.7551-28-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> References: <20241118164434.7551-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|CH3PR12MB8583:EE_ X-MS-Office365-Filtering-Correlation-Id: fff023cb-37a6-4355-6615-08dd07f06663 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: lUAyzCsMqclKZB+Z4hmaskWnHqZNU5k6/ENj3I8S4KN7Fd/c4z2l8A9a/gfcBdmtkOxxTR8theSfOR08z4ibUgd16L+A830AKB1nhnPpdJa3Ctpmb1MLISkQxbfaSTpnplcozWsZz1QLQ2D3gp6YLaZ0R1kJc3uFnxYNkYPFpBdbLRey0Pr+6kUPJpwWo4A9vNLyQqAyEqdEYF01F1CH6oHbfuzvwt4aNupw9kqPR/VTFwOrcDd+W7FjlD7MxsEfC+br4AjawQ7GmFcDAjN0YmkAga/TCxIZ0Ljkrtpcm5COQ3zVDdFZFYMXlu/5A593vQjxHHC50vVejWMcateMlf0FYmNY0Us5+uXdrDBF5QFMm54WpSocknZNylU+xNbXwc8uNwKKasgIE31wCpZ8I56rD6n0bSHglVzaMo9L+1eK/f8YLdwvPLgXum9FWtjHiFXMUhUDrXv2x0PMKOzjEE+yZ6ikjxPENJaAa091WDrC1z7L7awmEMmSmTCa13Stay/Omgx568R0UGg0UHoOXzdsxyu51J8HdMYeZWnZ15iSwiNqkClYUNaDCpueBostXy6EXrDc0uKhzLWBAJN+lWnWld8mY9V8of3PXcX0sfTXkCg5ZuLkxi4N6jzdppVXVsljLkAGnbtnFQzQTituf4yl2tutLXJQqvrrQEVsIs4SLbIr4aSsiBHCd6UKTOVL266g7eA08WswWSauZ5Re56fNDkoAOAiARYAHfWnVUsuNKdg10cxRNcpZSWLLE/465mDCLMEJ0gqMVCW6FysQ4Fr/+t9nWtly061dzJyst9vzzMRA9+Dh5Kj3GYG0GgHxY9LiugjuKHCakv21cO34Qx1OAYEGJdTslTi9UApvVXks0RsEl7ZPc2PtuDyzdSTDLjpFt7hGv8ZYuiR9nSs5y3tVBFVbmBFe1KYvyfhBXgXHX3MUHcc9qUoLYa60NaAvm1EyNx7jOhTBfViNb9U3CyAlzLCH2FmMke7eAL1Pt9PE2B72tjtmWqMbz+Z0uaIJH6dESy/qbkGD2dK+iO0jdukmqzE9eKHJM6w41CRnnJYN4VCPoSAziRxD6YYf3xXQ+DkFoGF5DXErYxOR2oj2cXW8/mAHgmGa+6HAvSz7KupGjyoQ7Wt+glWJj51/zSRchurtg0QZCfq19y7RKUkdRNx3WHu1B43KAto47ZEzo4gZN9ljzBUQXdZWK2NT7xDIRwR1n3lrOp1hRWEaSlAsXZAj1rkPrZCXcsCULCXdPZHAuqyFOCnGBkE3HZywn/IoRKhG4R/KQPp1nrfKWgXuAeTF65kmH8lbN16m1MmrSennA3M2ExMUsj99BJn22UAZQKaIsGQa0qo1CXLDeK8LsMCdsEmDmBwVlgFXHyzoz/2oa+hAgZYsD6hoJKrft2U4MkqSe448SdX58uOm9go0Qw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:45:24.5314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fff023cb-37a6-4355-6615-08dd07f06663 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8583 From: Alejandro Lucero With a device supporting CXL and successfully initialised, use the cxl region to map the memory range and use this mapping for PIO buffers. Signed-off-by: Alejandro Lucero --- drivers/net/ethernet/sfc/ef10.c | 49 +++++++++++++++++++++++---- drivers/net/ethernet/sfc/efx_cxl.c | 18 +++++++++- drivers/net/ethernet/sfc/mcdi_pcol.h | 12 +++++++ drivers/net/ethernet/sfc/net_driver.h | 2 ++ drivers/net/ethernet/sfc/nic.h | 3 ++ 5 files changed, 77 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index de131fc5fa0b..d19e42dd8dbd 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -24,6 +24,7 @@ #include #include #include +#include "efx_cxl.h" /* Hardware control for EF10 architecture including 'Huntington'. */ @@ -177,6 +178,12 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx) efx->num_mac_stats); } + if (outlen < MC_CMD_GET_CAPABILITIES_V7_OUT_LEN) + nic_data->datapath_caps3 = 0; + else + nic_data->datapath_caps3 = MCDI_DWORD(outbuf, + GET_CAPABILITIES_V7_OUT_FLAGS3); + return 0; } @@ -919,6 +926,9 @@ static void efx_ef10_forget_old_piobufs(struct efx_nic *efx) static void efx_ef10_remove(struct efx_nic *efx) { struct efx_ef10_nic_data *nic_data = efx->nic_data; +#ifdef CONFIG_SFC_CXL + struct efx_probe_data *probe_data; +#endif int rc; #ifdef CONFIG_SFC_SRIOV @@ -949,7 +959,12 @@ static void efx_ef10_remove(struct efx_nic *efx) efx_mcdi_rx_free_indir_table(efx); +#ifdef CONFIG_SFC_CXL + probe_data = container_of(efx, struct efx_probe_data, efx); + if (nic_data->wc_membase && !probe_data->cxl_pio_in_use) +#else if (nic_data->wc_membase) +#endif iounmap(nic_data->wc_membase); rc = efx_mcdi_free_vis(efx); @@ -1140,6 +1155,9 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx) unsigned int channel_vis, pio_write_vi_base, max_vis; struct efx_ef10_nic_data *nic_data = efx->nic_data; unsigned int uc_mem_map_size, wc_mem_map_size; +#ifdef CONFIG_SFC_CXL + struct efx_probe_data *probe_data; +#endif void __iomem *membase; int rc; @@ -1263,8 +1281,27 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx) iounmap(efx->membase); efx->membase = membase; - /* Set up the WC mapping if needed */ - if (wc_mem_map_size) { + if (!wc_mem_map_size) { + netif_dbg(efx, probe, efx->net_dev, "wc_mem_map_size is 0\n"); + return 0; + } + + /* Set up the WC mapping */ + +#ifdef CONFIG_SFC_CXL + probe_data = container_of(efx, struct efx_probe_data, efx); + if ((nic_data->datapath_caps3 & + (1 << MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_LBN)) && + probe_data->cxl_pio_initialised) { + /* Using PIO through CXL mapping? */ + nic_data->pio_write_base = probe_data->cxl->ctpio_cxl + + (pio_write_vi_base * efx->vi_stride + + ER_DZ_TX_PIOBUF - uc_mem_map_size); + probe_data->cxl_pio_in_use = true; + } else +#endif + { + /* Using legacy PIO BAR mapping */ nic_data->wc_membase = ioremap_wc(efx->membase_phys + uc_mem_map_size, wc_mem_map_size); @@ -1279,12 +1316,12 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx) nic_data->wc_membase + (pio_write_vi_base * efx->vi_stride + ER_DZ_TX_PIOBUF - uc_mem_map_size); - - rc = efx_ef10_link_piobufs(efx); - if (rc) - efx_ef10_free_piobufs(efx); } + rc = efx_ef10_link_piobufs(efx); + if (rc) + efx_ef10_free_piobufs(efx); + netif_dbg(efx, probe, efx->net_dev, "memory BAR at %pa (virtual %p+%x UC, %p+%x WC)\n", &efx->membase_phys, efx->membase, uc_mem_map_size, diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c index de8d6bca9300..f727c53e287f 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -23,10 +23,10 @@ int efx_cxl_init(struct efx_probe_data *probe_data) struct efx_nic *efx = &probe_data->efx; DECLARE_BITMAP(expected, CXL_MAX_CAPS); DECLARE_BITMAP(found, CXL_MAX_CAPS); + resource_size_t max, start, end; struct pci_dev *pci_dev; struct efx_cxl *cxl; struct resource res; - resource_size_t max; u16 dvsec; int rc; @@ -135,10 +135,25 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_region; } + rc = cxl_get_region_params(cxl->efx_region, &start, &end); + if (rc) { + pci_err(pci_dev, "CXL getting regions params failed"); + goto err_region_params; + } + + cxl->ctpio_cxl = ioremap(start, end - start); + if (!cxl->ctpio_cxl) { + pci_err(pci_dev, "CXL ioremap region failed"); + goto err_region_params; + } + probe_data->cxl = cxl; + probe_data->cxl_pio_initialised = true; return 0; +err_region_params: + cxl_accel_region_detach(cxl->cxled); err_region: cxl_dpa_free(cxl->cxled); err3: @@ -154,6 +169,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data) void efx_cxl_exit(struct efx_probe_data *probe_data) { if (probe_data->cxl) { + iounmap(probe_data->cxl->ctpio_cxl); cxl_accel_region_detach(probe_data->cxl->cxled); cxl_dpa_free(probe_data->cxl->cxled); cxl_release_resource(probe_data->cxl->cxlds, CXL_RES_RAM); diff --git a/drivers/net/ethernet/sfc/mcdi_pcol.h b/drivers/net/ethernet/sfc/mcdi_pcol.h index cd297e19cddc..c158a1e8d01b 100644 --- a/drivers/net/ethernet/sfc/mcdi_pcol.h +++ b/drivers/net/ethernet/sfc/mcdi_pcol.h @@ -16799,6 +16799,9 @@ #define MC_CMD_GET_CAPABILITIES_V7_OUT_DYNAMIC_MPORT_JOURNAL_OFST 148 #define MC_CMD_GET_CAPABILITIES_V7_OUT_DYNAMIC_MPORT_JOURNAL_LBN 14 #define MC_CMD_GET_CAPABILITIES_V7_OUT_DYNAMIC_MPORT_JOURNAL_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_OFST 148 +#define MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_LBN 17 +#define MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_WIDTH 1 /* MC_CMD_GET_CAPABILITIES_V8_OUT msgresponse */ #define MC_CMD_GET_CAPABILITIES_V8_OUT_LEN 160 @@ -17303,6 +17306,9 @@ #define MC_CMD_GET_CAPABILITIES_V8_OUT_DYNAMIC_MPORT_JOURNAL_OFST 148 #define MC_CMD_GET_CAPABILITIES_V8_OUT_DYNAMIC_MPORT_JOURNAL_LBN 14 #define MC_CMD_GET_CAPABILITIES_V8_OUT_DYNAMIC_MPORT_JOURNAL_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V8_OUT_CXL_CONFIG_ENABLE_OFST 148 +#define MC_CMD_GET_CAPABILITIES_V8_OUT_CXL_CONFIG_ENABLE_LBN 17 +#define MC_CMD_GET_CAPABILITIES_V8_OUT_CXL_CONFIG_ENABLE_WIDTH 1 /* These bits are reserved for communicating test-specific capabilities to * host-side test software. All production drivers should treat this field as * opaque. @@ -17821,6 +17827,9 @@ #define MC_CMD_GET_CAPABILITIES_V9_OUT_DYNAMIC_MPORT_JOURNAL_OFST 148 #define MC_CMD_GET_CAPABILITIES_V9_OUT_DYNAMIC_MPORT_JOURNAL_LBN 14 #define MC_CMD_GET_CAPABILITIES_V9_OUT_DYNAMIC_MPORT_JOURNAL_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V9_OUT_CXL_CONFIG_ENABLE_OFST 148 +#define MC_CMD_GET_CAPABILITIES_V9_OUT_CXL_CONFIG_ENABLE_LBN 17 +#define MC_CMD_GET_CAPABILITIES_V9_OUT_CXL_CONFIG_ENABLE_WIDTH 1 /* These bits are reserved for communicating test-specific capabilities to * host-side test software. All production drivers should treat this field as * opaque. @@ -18374,6 +18383,9 @@ #define MC_CMD_GET_CAPABILITIES_V10_OUT_DYNAMIC_MPORT_JOURNAL_OFST 148 #define MC_CMD_GET_CAPABILITIES_V10_OUT_DYNAMIC_MPORT_JOURNAL_LBN 14 #define MC_CMD_GET_CAPABILITIES_V10_OUT_DYNAMIC_MPORT_JOURNAL_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V10_OUT_CXL_CONFIG_ENABLE_OFST 148 +#define MC_CMD_GET_CAPABILITIES_V10_OUT_CXL_CONFIG_ENABLE_LBN 17 +#define MC_CMD_GET_CAPABILITIES_V10_OUT_CXL_CONFIG_ENABLE_WIDTH 1 /* These bits are reserved for communicating test-specific capabilities to * host-side test software. All production drivers should treat this field as * opaque. diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index efc6d90380b9..fcf3058f64d8 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -1170,6 +1170,7 @@ struct efx_cxl; * @efx: Efx NIC details * @cxl: details of related cxl objects * @cxl_pio_initialised: cxl initialization outcome. ++ * @cxl_pio_in_use: PIO using CXL mapping */ struct efx_probe_data { struct pci_dev *pci_dev; @@ -1177,6 +1178,7 @@ struct efx_probe_data { #ifdef CONFIG_SFC_CXL struct efx_cxl *cxl; bool cxl_pio_initialised; + bool cxl_pio_in_use; #endif }; diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 9fa5c4c713ab..c87cc9214690 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -152,6 +152,8 @@ enum { * %MC_CMD_GET_CAPABILITIES response) * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of * %MC_CMD_GET_CAPABILITIES response) + * @datapath_caps3: Further Capabilities of datapath firmware (FLAGS3 field of + * %MC_CMD_GET_CAPABILITIES response) * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot @@ -186,6 +188,7 @@ struct efx_ef10_nic_data { bool must_check_datapath_caps; u32 datapath_caps; u32 datapath_caps2; + u32 datapath_caps3; unsigned int rx_dpcpu_fw_id; unsigned int tx_dpcpu_fw_id; bool must_probe_vswitching;