From patchwork Thu Oct 17 16:52:00 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: 13840380 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) (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 417F81E131A; Thu, 17 Oct 2024 16:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184002; cv=fail; b=mM8nwJFLKPDNjw4crqi1/8+5pNUhOhV5g4VMBFhjqqDEZtgs4utmWeH6gFTxuQ5+PFnZenwmVClIccEqfVBKIy5zb3cCdg3IiXqNGWKAVA3iAz2fAhlEbC4E9ES6xddK6iLj3t8aMHHr5977naOD0LJGOm4T2FV4WrHIuOzS1+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184002; c=relaxed/simple; bh=V/PeqmFiMmzbax7tFMVcbjBmog3YEMi+9S/ChOxKmhw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MDrfP/GM1VVKoLzIatA+z5pzelz5C6vLeSEtGL0PW04PxiujVg/hnufuvwnoOMk3iW7EchPcy3qkil70gkHQmsHBeehoKf5j30AJlyArUKNYQFXbuWab2Ps+yLDTRF8GgrvuiZYCD7J1PwHdJXSnJJ5pKKP/00DeT1zL/lL4GA4= 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=s6cjukYd; arc=fail smtp.client-ip=40.107.243.43 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="s6cjukYd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kK7P1+oDXQMyoM9O4WOvDIN0pmCD26adLI9Oyaktpm/FHczp6nFe9EByD/amaDSaE6vg1moma5W1spa7jSS4VFDzoVNkTtDWS65tPzyy/m21qc2H0Z2T9e2fTMMygBGEsf2uNOyvuXs4r2eVUSby6qGlhD/2nFmkUmyCuyOZTglSGhj0hX24pNpYb83OErLDdKe8NAgPYHDINfIzYExBi5R1gn20G84iDIDQQzri6CC9d/lMoxw57BAygnSh2jYOJyETaOvoSe85EK3wXEDMQcJToAu9ASOlwRHMn9kwYM3MsFzdOjagvyCOcSlb1AC01Ne1PRe8AUnlvg/5+6BuhQ== 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=MzDWL/w2eap2Q+V6WABC483T75Xvgk6PNG5ctedIeEA=; b=EVoCNcmJCRIjYaUvpVL+6CMRSYM/uRQpXESVea1AWEzPYqAm+0d3TGK4JFdKF3b14Nwg0QV2J20BGP9+C7mjAlzAwASLEX/FB1yk8TKRXiaGhHL9fmul9wn8KcX8RfBFZSIgPw3c508lkVp65HwnmqJWffpYAq3be4XDjIsTQ+z50nuVl8KyXcr1+WFE37pwRyYL0AYpetGE+TxNHh7AULWjHyqZ5+B/Klu98d+QpWn6lyw63jcgQX3Cs3y4DnBYnvfe0NHkDBS6CsObv5PxlZ/dH4xlGMvBNdjR3B6AcVh6fK/yyM+HX4m4otFcyL7pAvCVCVLXLx+opWoddJzb7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=MzDWL/w2eap2Q+V6WABC483T75Xvgk6PNG5ctedIeEA=; b=s6cjukYdo+GZmKz/wA+LTBNSr1nxtNxrKgmm38QN0+ZNbCGv2EYlwPtirqUaH49r4kIqyc2AytbT16Q4znP/u6howUfcpikOnorRx2XgyqKzVtNfOXnwrWeiJVkGzHZePg32Ufl87qAiDjofhCV9Y9Pp46gl4rw9tgrNq8jJ4IA= Received: from MN2PR16CA0034.namprd16.prod.outlook.com (2603:10b6:208:134::47) by PH7PR12MB6657.namprd12.prod.outlook.com (2603:10b6:510:1fe::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Thu, 17 Oct 2024 16:53:12 +0000 Received: from BL6PEPF00020E62.namprd04.prod.outlook.com (2603:10b6:208:134:cafe::9c) by MN2PR16CA0034.outlook.office365.com (2603:10b6:208:134::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.24 via Frontend Transport; Thu, 17 Oct 2024 16:53:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E62.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:12 +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; Thu, 17 Oct 2024 11:53:11 -0500 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; Thu, 17 Oct 2024 11:53:11 -0500 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; Thu, 17 Oct 2024 11:53:10 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 01/26] cxl: add type2 device basic support Date: Thu, 17 Oct 2024 17:52:00 +0100 Message-ID: <20241017165225.21206-2-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E62:EE_|PH7PR12MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: 2198d29e-fed3-4dab-6543-08dceecc2fdd 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: bglZ6HwMGglzS8IdPPOVE75lFX2G6WHVNEKymBYs0qQV4/zGSBalePSoRgEwvVnpHdNx1mOTmtfJoR+KKEwo+JJbDAuTrAxX1drytz8tUMiPpl/FLxWgot0DeyIArk97Wdhx96u5pFlahAjB5GsJH22oIG105NDoPYaZJrmJ0znmPHBgUt3OMArq7+tskn+6IwsKv/a+je/EQG28YR+AXf2plefm/A0hFSZXlv8csxHGOZyXroJkBbECWZszxGR77BGjlYCAW5nvcWFRy/ScY8B/bxXYpO3WAvsBQBknlN8t/itrAKaneYc4TC4fYaPOLqyRQs+a5pjG32+zUSE4cBx1PBkCFTGEWoFUhuhrMPFwVexiU1EYAuHOSZGUteEW6DH6GkzBzrNqEVvJEOs5uxzmyWOF0QKSdAYYDacByI//+25Jq5eLgm09Ovw7H6NBRSKSLq+tJxrMwm1qTn9lOgP7p9OdtqM5Z2lKqXcv7J6nC+IxSk6/UrOWce109198zZG2edy107ybiTTbbvAK28Zhzjw/hyyHPK7YVkbuwliNjGwLL0VelB4QcmJnYZ74VW2yeFllMNv4eE/asFOlu2+TnRe95rPJToHLebbe3XrTQbW2UmaqlnRALWQdBzD/s8gy3pPzL4kC3TFrMYcF4CCTnbwP5i7EKONDzYgcDhcZ1whOg8Y1sFvZVuLwOmmOTa2becVlSw34lImk6fz4fB6LTajU1kTQdFYKsIMOJsyo8prOY9TMF4ThAZgrktLbqsGxDcT3m4iPj6i2C6USrABdL8JpGrIb8d3Gf5Dty4NxT5+EJWy6+9PXvIsMubN2odG1qG2HF/zYBI1Mr3ofd5Jdwd6N/dte01GvJ5od178geGFvlAW2gnZLNX8n49eDlBM2HmN6ocNQy93neUMwyzmsP664uIB9Gdd7LEvwKuW+jgvVYTQ+Wd1REsZ3Q0DV+TG3sXbRwzkx7Vsa4CwUDiQBzKl+IsKuPUfxc5zqijlgQnHyXvY40tkH3E/Jd5H2cCJzf7vO1kAyj6Whw+6O+UMzN8032TdohGrnGtwavakXcbHvOuvg5dV0Var19MS3HBqEuhzbO2z4LNRe2gXv/AUOh5I9dNglQVvFh+CQM3lSORxCCcYb8vWbGdLQP0ufA0cv2NHOuCckPdnni6Fkq2jCqWtE8GhzkUV6f1Ozd+tp+tNithH92sdPAEVqQC+fwsisqD2C2d2SfL22LA3oAZ9+cBXXGeNgv4zcfs+hOVXo476/WOIrcnPpu5lwPdbJFSJ3NHlACcI6PffOZg1CD/hNETskmHe1RaeATSgErOCNMeg4JKG4dgutI48TvXO8iEDFCEwr+YU26IeXwqCBtzD6oRujD8CAOZGIx/Pwl8oERSQ6n56XTeqpGwui4MJo8JBUzNJJgfCP1HAp6pBqmg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:12.2920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2198d29e-fed3-4dab-6543-08dceecc2fdd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6657 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 --- drivers/cxl/core/memdev.c | 52 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/pci.c | 1 + drivers/cxl/cxlpci.h | 16 ------------ drivers/cxl/pci.c | 13 +++++++--- include/linux/cxl/cxl.h | 21 ++++++++++++++++ include/linux/cxl/pci.h | 23 +++++++++++++++++ 6 files changed, 106 insertions(+), 20 deletions(-) create mode 100644 include/linux/cxl/cxl.h create mode 100644 include/linux/cxl/pci.h diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 0277726afd04..94b8a7b53c92 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 @@ -615,6 +616,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) { @@ -692,6 +712,38 @@ 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; + } + + dev_err(cxlds->dev, "unknown resource type (%u)\n", type); + 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 51132a575b27..3d6564dbda57 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -7,6 +7,7 @@ #include #include #include +#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 4be35dc22202..246930932ea6 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -795,6 +797,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 @@ -815,13 +818,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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h new file mode 100644 index 000000000000..c06ca750168f --- /dev/null +++ b/include/linux/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/linux/cxl/pci.h b/include/linux/cxl/pci.h new file mode 100644 index 000000000000..ad63560caa2c --- /dev/null +++ b/include/linux/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 Thu Oct 17 16:52:01 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: 13840382 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (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 8473B1E1C05; Thu, 17 Oct 2024 16:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184003; cv=fail; b=FdRqgSA5BkMHqzaGXa2yPrX72H+iPt0R7+NcpCKW8SrWVBUSVIEGxMUoc1wQweU0tWU4OK8zCwRUOuiL4wwP2H927LYeUAL/EDHJ/OpVn4P3FsWz8Q/E8eYim2GJHeAGamKA4rDLb05ZswDhghj79z4TDFq6Xbp39ZRwBcOg3/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184003; c=relaxed/simple; bh=LsAZ3ReHLQo02uRYNZzVZ0SkWQys4lQuIaEOkoi16HM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cglw4xdrtO2+D44sy0jlUS8Ij/utJo5s5aRqh6KjQXpdiKxt23gwmoLtQxH1VfAXc0dMPxNLzi/zigTHM3GgoRsT/E87OlEyoHIuFAmb00E6qsyQiMcEFq5KclvHCO8kEue9kXdyR40jhL8UdFh+PpRxX+F+sHBEp1VuHxa+6rY= 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=Hk5995lU; arc=fail smtp.client-ip=40.107.237.51 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="Hk5995lU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rHedz/HCez8noD4oWx1KdC34unHJw+CfCf8jvSC/DpjRbmdsapli/WVMZn9zZUMzgr6AyYhmoZNRz8x0l0mWvz5nC+7/mpU1SkE2P8m4qY2X/+OHUM4LLLOtXbxvRJ2/nPQunW3U0iKpYP1DR3KdaOyeLxgg4fq77mTXl5KzWIME53OI9V0vYmcKRtmezbQejEbw1HFXEYOr2rJiDgDTUR63GrIFr+pHXdg+50HC6vF5Gwcdj4tKmuqhR2WpAv9P/Z1GlNlRP3hnOkog/t6+xy3ufC+WohfCtlsNWg+Bx3HP3NxW0ctOnvQ42diikw8Si6Tz8QLnm7zWEkAUDH3uAQ== 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=PF7bNIO8pk8MbwyJVRMhC8ITbfwjc1nvzSpCtco35gE=; b=NytM/5lSFrmXbr70i+KHBODieY5pL7vpR9S/UDQd2lMnusSE91pU0tiPlH5LeljIy4+2E1GZ9HTj8tfl+KXkyt9w6AZNa4F8LgYPmWHLwFxtM3CeRP+1SoDMd9D5+OXJHnLWCefYNwZDlyz3/dFpSwHzMAsoiJTKozaU3skQna6WMBW2FGglnxyfmbFqHxs+6EHe5RMrSvwvJVJw8qncCxVKRjLUVo1ImAfE3O849cdHI5boEXdf9Egq/M4NoEfsd5Iem+MSPn7+aqXJeeKba9RKU/iDxUuxikYbScUkGQuLaSaGlvTpS7N1wL3iHVNqAKztgtHX350H9YYeCKmP0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=PF7bNIO8pk8MbwyJVRMhC8ITbfwjc1nvzSpCtco35gE=; b=Hk5995lUS0CaZsbFQ/TtsNiZtmL2WjastqLgnsD4UyQX2bpjqG3yYsWnkGwGZq0stri5EF/57xtNSaN5fU900SzTT2j5Ilk2vwfv4DSWAeuVRESHLhLOr/6tvokqrXzHsCk5PwHTt5ql/1FezdnzKqZDonUcVtRvloq/3Hc9Fpw= Received: from BN9PR03CA0909.namprd03.prod.outlook.com (2603:10b6:408:107::14) by SA1PR12MB7343.namprd12.prod.outlook.com (2603:10b6:806:2b5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 16:53:15 +0000 Received: from BN1PEPF0000467F.namprd03.prod.outlook.com (2603:10b6:408:107:cafe::20) by BN9PR03CA0909.outlook.office365.com (2603:10b6:408:107::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN1PEPF0000467F.mail.protection.outlook.com (10.167.243.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:15 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:14 -0500 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; Thu, 17 Oct 2024 11:53:13 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 02/26] sfc: add cxl support using new CXL API Date: Thu, 17 Oct 2024 17:52:01 +0100 Message-ID: <20241017165225.21206-3-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000467F:EE_|SA1PR12MB7343:EE_ X-MS-Office365-Filtering-Correlation-Id: 41609d36-921d-4755-9a2d-08dceecc31aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: yIU3ExmY6YJZfQqquRscMWfGULYJp577AiLyPZDGsKmRvTAg/HRiRDGJnwQYBZRNTR+rqP7lSmRACOqCVVQENR147FugeBUBV7CX4SBe+5cFO9QP72sRj7zHFvdPb/ngYwNj6Gs6nqNQgaRT3pU3/3N+wZdUawj8SXAKXUY+BciRv1u3bnMcf9wH1njrstnAmLNuYJ0F59BfT2D7gm82K8idTOz8ik+5wKMWm5J/t8lwCY9Ey2xOdWNK/Lp+4e+GZEpxWAPSYZddTyW1MDliXi48plzEnK63kWAhH3SKdAOMMdA8PXPpWNjmTa1JPWpY8ZuXfroL0JQ/PbqQ85y2oSa8pub5C/Un1SGUrJnqL/Pk+FRvlR9u7kVhk6MCMo4FO9qm4k7Zb5NG0AD7OmtAuSY5r1356nRzwGpTDsYsRdwHvpXAFrd2c5nza7LieM9rxwjQv+QtRsWr4R8D+mywx/CON2UHikOowAj+QcduFawW52Rvrib40fqxr6PavHMcPGzYW2M4ksOviD65iU3nAzc/Mfj0AUwwXolDXyxpR6fELgieqmzBPxI44BxhqW4fkQz/1ddW+/5wlOMdUiTaNzS15VXtD5FUxYEiuqHuJZ5jX8vfRfBlEcg5xrb7Mt56q3gBL8zlvepTzcDsR043/PSv4csnxlIrI1IOrProwd0PjF8acLvaEs8REz9bT2O0E0UhrUsfVv085doOGgF9Lw8uuvKQivg++XQ1lo4nBT8H5QknCPXWalxht5b4Y4SAPqef2Klk0FWxM7eGTk40xRiKNqu5eUOOy2uBNKHXxSmgrByc98ykfd+dDyXAS6Jm+niajMNECpmjjpcdFrfUXBFv++npJtuLtppAPdUwvML84cvWp1as7892R7s0+FKlfd0C7a6LqTcd413rqp31WjG6QJpWGDuTbRVy5+cqSYPxW3/iqnGACr/KCwkvexJk1ZyqHO8x+0gizsH95vx6eWqytkNIw5LihRES+KvDVxAFLgmUdpwi0cjOuxZvJjNEA5SkQ3A7nySTYK1qtQiMgIAJvtI3uDmPKNs0oRgq80fWOK4n/WsHfXUYFQddwbn+HNUynFUdjR9+Yq9TLCDvOo0WXKi5h2/B+7vKP9cJImShbQmQJq0nbb5WWNU8flE0TpuDdpQkuyVekfR6lnHd9chtJQrZZmPL8BXJM+ZmFCvaVrNos3081GGZIuCUIdFLcIbE4K0588InGOyKRv8djOeL5XaaR5fQUaSMIfuzVwsORusjEKXOEa3Fr2FC/oxE43LE/fIAUbwshhTAhiGKhYKfTag/IxE98vZMKY/0vQpX03itOFjnTjsHyH+p8PBYssG56HpvPr9Lxnhoi4upXX2MzmSADMPgIPwJB1ZeY3JVsibEpxL1MKe7XmEVMsWmF+k/Dv02GrquH4qVPp7ZUg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:15.3146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41609d36-921d-4755-9a2d-08dceecc31aa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF0000467F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7343 X-Patchwork-Delegate: kuba@kernel.org 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 | 1 + drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/efx.c | 16 +++++ drivers/net/ethernet/sfc/efx_cxl.c | 92 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_cxl.h | 29 +++++++++ drivers/net/ethernet/sfc/net_driver.h | 6 ++ 6 files changed, 145 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..b308a6f674b2 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -20,6 +20,7 @@ config SFC tristate "Solarflare SFC9100/EF100-family support" depends on PCI depends on PTP_1588_CLOCK_OPTIONAL + depends on CXL_BUS && CXL_BUS=m && m select MDIO select CRC32 select NET_DEVLINK diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 8f446b9bd5ee..e80c713c3b0c 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -7,7 +7,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ mcdi_functions.o mcdi_filters.o mcdi_mon.o \ ef100.o ef100_nic.o ef100_netdev.o \ ef100_ethtool.o ef100_rx.o ef100_tx.o \ - efx_devlink.o + efx_devlink.o efx_cxl.o sfc-$(CONFIG_SFC_MTD) += mtd.o 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 \ diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 6f1a01ded7d4..cc7cdaccc5ed 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -33,6 +33,7 @@ #include "selftest.h" #include "sriov.h" #include "efx_devlink.h" +#include "efx_cxl.h" #include "mcdi_port_common.h" #include "mcdi_pcol.h" @@ -899,6 +900,9 @@ static void efx_pci_remove(struct pci_dev *pci_dev) efx_pci_remove_main(efx); efx_fini_io(efx); + + efx_cxl_exit(efx); + pci_dbg(efx->pci_dev, "shutdown successful\n"); efx_fini_devlink_and_unlock(efx); @@ -1109,6 +1113,15 @@ static int efx_pci_probe(struct pci_dev *pci_dev, if (rc) goto fail2; + /* 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(efx); + if (rc) + pci_err(pci_dev, "CXL initialization failed with error %d\n", rc); + rc = efx_pci_probe_post_io(efx); if (rc) { /* On failure, retry once immediately. @@ -1380,3 +1393,6 @@ MODULE_AUTHOR("Solarflare Communications and " MODULE_DESCRIPTION("Solarflare network driver"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, efx_pci_table); +#if IS_ENABLED(CONFIG_CXL_BUS) +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..fb3eef339b34 --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -0,0 +1,92 @@ +// 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_nic *efx) +{ +#if IS_ENABLED(CONFIG_CXL_BUS) + struct pci_dev *pci_dev = efx->pci_dev; + struct efx_cxl *cxl; + struct resource res; + u16 dvsec; + int rc; + + efx->efx_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; + } + + efx->cxl = cxl; +#endif + + return 0; + +#if IS_ENABLED(CONFIG_CXL_BUS) +err2: + kfree(cxl->cxlds); +err1: + kfree(cxl); + return rc; + +#endif +} + +void efx_cxl_exit(struct efx_nic *efx) +{ +#if IS_ENABLED(CONFIG_CXL_BUS) + if (efx->cxl) { + kfree(efx->cxl->cxlds); + kfree(efx->cxl); + } +#endif +} + +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..f57fb2afd124 --- /dev/null +++ b/drivers/net/ethernet/sfc/efx_cxl.h @@ -0,0 +1,29 @@ +/* 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 cxl_dev_state; + +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_nic *efx); +void efx_cxl_exit(struct efx_nic *efx); +#endif diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index b85c51cbe7f9..77261de65e63 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -817,6 +817,8 @@ enum efx_xdp_tx_queues_mode { struct efx_mae; +struct efx_cxl; + /** * struct efx_nic - an Efx NIC * @name: Device name (net device name or bus id before net device registered) @@ -963,6 +965,8 @@ struct efx_mae; * @tc: state for TC offload (EF100). * @devlink: reference to devlink structure owned by this device * @dl_port: devlink port associated with the PF + * @cxl: details of related cxl objects + * @efx_cxl_pio_initialised: clx initialization outcome. * @mem_bar: The BAR that is mapped into membase. * @reg_base: Offset from the start of the bar to the function control window. * @monitor_work: Hardware monitor workitem @@ -1148,6 +1152,8 @@ struct efx_nic { struct devlink *devlink; struct devlink_port *dl_port; + struct efx_cxl *cxl; + bool efx_cxl_pio_initialised; unsigned int mem_bar; u32 reg_base; From patchwork Thu Oct 17 16:52:02 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: 13840381 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2068.outbound.protection.outlook.com [40.107.236.68]) (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 8B6EC1E1C0D; Thu, 17 Oct 2024 16:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184002; cv=fail; b=Z5PZ2qADWf/LoYXuApW7W5BNIupLyI/mCrYpDPqYy6N7xp7bshxuoRbAcWyU6u0ywWv9rRCSnyUhHY/8NfX9Ibqgb2BLjOQSTLvDNQsVt5J6byM8Smj1vCy9vAeRZDojtA3TjfwWa7C7ZjijCMQxk8MGeoKpo6RzEOB1CN94wss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184002; c=relaxed/simple; bh=dwTBywesV/6UiHEGDeeGtq4cd77AZsxACt4ssmcUJpg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m8MRzyANlVdmX+JuoJ6/kx1NV+sFTbJC7+9memEifsIN2Iqc9jxspXFRD59SbDt5ulu+yNPK4/oijBM46DD6u7fVqaXGm2l6k7zdH99g4xtwcriEBsSqH3KwP+IoMctEXuA1PsFwmcQGL8/X3F369d4O6uG6vmNujHqkoDFLTLI= 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=n2cPw+4d; arc=fail smtp.client-ip=40.107.236.68 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="n2cPw+4d" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lqN7e8IKA8wzRokoIckw6sfbWZn93yZ6gfsI9QHI/CFcmQfNLxQrSON+r9IGcjSwhCIe6RfI3GWXAorr1CK6zoMx9Y2OD4WjAEHF/s+yMG1NBBOT2Djysy4pgUJAats/T5j1N/c8Fjk9YDFIUYSx2DMFeb4RLgy7NHsIFVyDkOQl/V+PTn0gg8WItR4QFy84ZgtAnPzHBygZSNV/pjh0nFRISbtCmLexHPvuhhBZb+KqU0eaOowXwT76swmD2PUaILZgsc7dou3wziiy5+S0DweQfwKrf3k7Wse22SnS4InXpX4Il+0pciTQkD1d6uvctImQZzmvXNGQDSEkUrM03Q== 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=7OQZVZe0uMVuVeyDjpRscgUEhmMmdLSKpY3YAULadh0=; b=zPFkLwR0Lk2EGxx7iRUbSF2JYSEIrGjYHe4erG/eTrX8/HKzJ8pihAa2z5lBWxnByfQ8GiBt7U090fx/VEK0rjEUby+A6IaBknI214JND2migcXJSEhRpmd+cyoUPOMgZFatVzYrjBn/xbFtPmtTKK4w227O03ghT1pzyPPthXkjjp9s7mRTvxlHY76NhBDIaxCz8BMIFWyM43H8RMMNjriEk6A7RLunIxVGEzJffkIOD38AxoaR76EjwPtIb8EuC+hVkxXexBoKtI8t14KOWuNZcKKSl2zN8byfYqTTo3uzpl0tf/DixArGGQhowthiOvEkkRdERG7Lzb69LtnIag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=7OQZVZe0uMVuVeyDjpRscgUEhmMmdLSKpY3YAULadh0=; b=n2cPw+4dc0kug47Ozj5yTImHqlr0iV4cCmvJrzFEyEx1afwbxvyIj4LXpJWcGdNPGUWrnm3+JKwOpdJERnpSAz7utKaBFqjziEca6pV4z7k7EAXGHAc6YkSX1oNlqkAp6+vbH/AKYxRs7DF1mTKjdBN8Yv8Y2ng6PJbZIbmDAlc= Received: from MN0P223CA0023.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:52b::10) by IA0PR12MB8375.namprd12.prod.outlook.com (2603:10b6:208:3dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Thu, 17 Oct 2024 16:53:16 +0000 Received: from BL6PEPF00020E60.namprd04.prod.outlook.com (2603:10b6:208:52b:cafe::aa) by MN0P223CA0023.outlook.office365.com (2603:10b6:208:52b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Thu, 17 Oct 2024 16:53:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E60.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53: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; Thu, 17 Oct 2024 11:53:16 -0500 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; Thu, 17 Oct 2024 11:53:14 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 03/26] cxl: add capabilities field to cxl_dev_state and cxl_port Date: Thu, 17 Oct 2024 17:52:02 +0100 Message-ID: <20241017165225.21206-4-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E60:EE_|IA0PR12MB8375:EE_ X-MS-Office365-Filtering-Correlation-Id: 833cc8d7-607a-4dfe-dcd8-08dceecc3290 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: TOZx0M/9B2VsajGcmRQrICv3BBuuzvSChhA3gzG7Uy47R3tGHMO4yAJLfVIQsC4MYavFDU8tDwC/DkOWOvmFViLYhpztbgw+394wgnktmIgP/TZXJLLA9P+uzaz7o9+nOfNmBC/Cn3M7YmtBweXG6Va00xMuRqZcd7CWbM3z3ts3As2EnmS3gpcp7CN5vNniZEbliOWYMnCdw3+n7f9JpxV1uqGYAjrk0hUNP1uWqlY5U4XSWJiOBZGIWKNCNG+SdShmv8w1/f3fbUL7WSNEeZ6BGHBtT1E/fZY81UtKjOaM3fUte72JKKJdbgYMZPSemIaE231XUDkPFbKeo33rc6LSeGNCb9QLaVE035BjpMgRPdx8MicrEPXyCaZPgv2zgrG/L7Q7gEY9dH+JX29BgBbCmDVTdZu+ME8ZLLlT6wTDkUB3s3oHInG7m1jqDeowrT2kt2sswPxjH5pSbXaJsb1SmLIPtf7f0YIfjjOuFncdenH8crJDrOjI4NJ+BayNl2OtCKfQX/6EIEGhowhjPxi0lJIqUYEbF6Gi8eulXxAGrwvpCojoUBEOPGppyyPzntsnMEi5LAVKCWETj3XclebYz60SddjpEPUDQ3ZD6PM8I/grhqaV2y/oAmYVkb+a1SaCtGcFhgI4NR0UB+xaqDXVl0PElbUZ/7NCyVYE6jhspHdtrz7pBfWZSExYFpktnAlA7Fv9H1F5FoVwbK3UpzTqjWRp7bG7dIQEO36/aC2cUKobMQaW+UKU8P7wkGlTqFQRlWWFF9W26MGLku1fYHUwc26yMDYGJnc6DXc/SvVchL09C4r82+n2H45eLkwJ0GmNYlWfMSg+X7utANgtJJJV/aYoozTz7iLUgYelJ8VzsYDCjxtFNo8odbeyvO9Lq8/ZQocZ3r9Kdg6QQWPxEowu7ulCTj8RE5p6BwL1k+u/lDjR95jqbE1rfRWlqi+uod3dSpTO+p8VkQh7bz2Ne8kgWuuwISsrStlFz3iCJ4NziWJj416CVJ0lVYFR8MVlCmBLMZU5pP7RpxOgaGH8qUNgv3Jw1+QSyz8fANpNedBpdgzvzQPUIOvkG/oK9qjMJRCmYLeMReY7eWBOGXcITOC8koSju9x7Czl7mAfK4VeXXXMz79NMvnS0km8yvnVEdRrIRgL0s73A1cyheKRAt8GyhABKvJa5HtYWDLrBEFQyiAQbLI5LrNyViDIY7CGTMXAsdEcLVKAatmKr9YJxtkpcA2D0Kdi5uh1iPHlGzkmk0Hok1egCsFoR4w9oDY6IQrKL+aDqpCb6O63Cqj+ptgIjNGV6NpuSndqey5O3tVVfTlIRxfthP9EOjc6EAG4qnN0ldkXKUf3gKJCPFq8WZDQ76hAMW1sdaQ6H+aEU4rWEUGFegB2LkWAXJ/LW2UK2H5TzEjOHO9u74YrwsWEcQQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:16.8236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 833cc8d7-607a-4dfe-dcd8-08dceecc3290 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E60.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8375 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 --- 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/linux/cxl/cxl.h | 31 +++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 1d5007e3795a..7b859b79d59d 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; } @@ -858,6 +859,8 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, 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..9d63a2adfd42 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2020 Intel Corporation. */ #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 9afb407d438f..a7c242a19b62 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -8,6 +8,7 @@ #include #include #include +#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 afb53d058d62..68d28eab3696 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -424,6 +424,7 @@ struct cxl_dpa_perf { * @ram_res: Active Volatile memory capacity configuration * @serial: PCIe Device Serial Number * @type: Generic Memory Class device or Vendor Specific Memory device + * @capabilities: those capabilities as defined in device mapped registers */ struct cxl_dev_state { struct device *dev; @@ -438,6 +439,7 @@ struct cxl_dev_state { struct resource ram_res; u64 serial; enum cxl_devtype type; + DECLARE_BITMAP(capabilities, CXL_MAX_CAPS); }; /** diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 246930932ea6..6cd7ab117f80 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -503,7 +503,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; @@ -520,7 +521,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) @@ -827,7 +828,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; @@ -840,7 +842,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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index c06ca750168f..4a4f75a86018 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/cxl/cxl.h @@ -12,6 +12,37 @@ enum cxl_resource { CXL_RES_PMEM, }; +/* Capabilities as defined for: + * + * Component Registers (Table 8-22 CXL 3.0 specification) + * Device Registers (8.2.8.2.1 CXL 3.0 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_MAILBOX_SECONDARY, + CXL_DEV_CAP_MEMDEV, + CXL_MAX_CAPS, +}; + struct cxl_dev_state *cxl_accel_state_create(struct device *dev); void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec); From patchwork Thu Oct 17 16:52:03 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: 13840383 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 B1D0B1E1317; Thu, 17 Oct 2024 16:53:23 +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=1729184008; cv=fail; b=EriB5onZ3s8JBabnxsTVa5uTV/ZWpjklpiMVVhmupo/hWE/ROPeaxYmh/zZGVUwxWwikUIVruKyqi9r5cHhWmvXOb752P6Q4ehKt6+eCQbEUrQ3lVx4JlA3unf/tcIid7xLYGTs0FYscjlkw30g68XlLYlUuK2ZKW6jYMmS46y4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184008; c=relaxed/simple; bh=7ml1znhRgWXjj9iwaD1vA9IOjwrFIB2nNTyr6CskMhM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A4OgFtPkIxB1dxBSrPWXFF8iIDoelon3GXhBr0DWgekgy1s7cc5MHDOVEbaRmcFWq2v0YVrcYN3GrsNN2Akgof9XTpGNMVTVZs/qW6nmJKZzvaBTkLFdSjYmwP2xyekZuDAFPQFF+B9a6jEt0UGnr1BAz2tjNowdndGbI2Nyfkg= 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=SzRPbhel; 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="SzRPbhel" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YgsxVLfl66YujyoKADsxTKGpDeLi1DZG91us3IeLJrAW2CXUL/vblqLL415j1vGtRFuhTnyGWp7PrnpX2eyvQj4FN91+bZjTGJd023ONiUOqdpm7EtnT/N9TdbR+I+pvDFmzw45/OzXfn2MBdLJDeYFqmGU7dAZ6EwpegMv3hJZc5w94CkSoDXH4mJDmy931iWBmUI86lUA+BrNGsu3JHxMSyjThRzXPdPk5QCrbOu76FCZuGJMqLO+38aAn9XrBjda4Xy+G0r2w5X9gTfnPg+/P+SfVMy8B0PjNbDqV0gbDKP1yaENasa3Pw/egxp+JpFSQmxGqqqJWvAfc76uzHg== 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=AfWDMQR8JLxM+JaXy5/3W28XJKfjGRzlGf6w/z9YP24=; b=OKyLeRolhWtMqjIJJ94Rp7cDiyioZiYe8HpiR4XdMZVubPR79nYPqLk49wM4c5K4PB4zwYn1FhJFjtuKBx4vwhbrbkm4qptqMxx8oFESPp+BSr7iNGtamZzcoiBQQjGrkJQVapZdav57GBLF7kV9WVBG96uebo4Tf9oQl84bH0YJJm2/zaWyotvMjsgoAwKjFsKulykOhzqSfqbq1zmOVG5Yslf1xdqDGAvOz7SWXG/GlljjdiYK5BDYFJdirb26Jsk22+DozM+HwcG6B9c2q/kv8BDCaA+VeHR3qVx/Rb54nee66dgLkDOjN4VchYdoCoBeaeiYFivYvDHsV9Yneg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=AfWDMQR8JLxM+JaXy5/3W28XJKfjGRzlGf6w/z9YP24=; b=SzRPbhelPfEyLWIO/fFbvL/n7nmoePVR4+0AiFCIykj4ruGNlJwUjUOxe87j59eocm4nTFwIhYbs49BgsfZywwKuA2Avf21HspLIoe9jWIpBK+kCqOIQLmvrQQM6Hu4J3H2k1Z9kkT6crfb3OegBGmYxIMXXTnyepz1Flu2RCh0= Received: from BN0PR04CA0166.namprd04.prod.outlook.com (2603:10b6:408:eb::21) by DM4PR12MB6615.namprd12.prod.outlook.com (2603:10b6:8:8d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:18 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:eb:cafe::50) by BN0PR04CA0166.outlook.office365.com (2603:10b6:408:eb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 16:53:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:18 +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; Thu, 17 Oct 2024 11:53:18 -0500 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; Thu, 17 Oct 2024 11:53:17 -0500 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; Thu, 17 Oct 2024 11:53:16 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 04/26] cxl/pci: add check for validating capabilities Date: Thu, 17 Oct 2024 17:52:03 +0100 Message-ID: <20241017165225.21206-5-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E66:EE_|DM4PR12MB6615:EE_ X-MS-Office365-Filtering-Correlation-Id: e79ac55a-7bfb-495f-046e-08dceecc338a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: n3wKSLLIvP8MQ4KSSj4LsSq64VPPIobjPyBr5iLBG1iMzmQYPY8sHBnYoMODwNbGICHGHGC69X0vEGildZhA+fsVsdEo3u2dwVEUkFdjSIT8R/O0s+t7bCocl+6lyHeVJNLk78gjWlCEBJ7t7irp4HVQb3M3LOJuVuFt2XuO68ccLbviLZ5wpDr4A12YWCJZlVFTbnrlDR25bnw7joCwxiYfk4HWDiEqq/sqmQ1h6WEqVz2Ll/UbzH6ChitAfPa62rT3NoJRCtxUZNoZH+uhKrVDmxPGJByGlFIvIHuqZd11063XrFcF0APVgrbxtjHSwWze8Dm2UtYJiH+s42LmtcXDl7xLTCWMqLM6xVc3+LMGd9RrB42J+9Wv5fiZFrPuSaHG92+q0xvWUV7/sdofSInangLFFT4NgdBudtcI7JvfZyPSo6Z2T8+TkJiPhJzIK8RshpbKJxgZDLNrcThcpQajywyHz0qoedcO9kKY5a6FETzxYCNSihxUMFJ1j4cXYfa9NCBtS33kwoN0pqYmiqsBVeNb31hbT0GvXvVz6kW0QeueZUENtvKaQZA8W3PqJ5QpobB5mY994Tp46JeGcm1GPMXa61XG6PVz+MyA+eoYLd8mT+bsFOz8H7MaNj5wkZtenM2Gtix7bFeickvONDDo2Wdrr5sFPPagSEFO7yMQhnPk9zeEHvcsEb6upaGriAtGSisJ1AN3EI9KW2oXCwa3PB2AtZp0uBKuK1HW0VkPsMpDJdZtIqOKgDOrvPf/Bn4VkXpfEa1bENA7g8T8iW+PMZt6sF99NSwp2zD9yxvhKGK3+rHGx5hE0cH4XibwBlpx7yyefW+l/eLTSHtUXEyN1Qb0hCGfZDMGw/Nx3sKbnGJUvQBucLeBECsZbGN3IA0SMrQfuQc5IZAJl08rcPQDhneOy43QqlKs2h4hEQBIZoymvxjUD4vQMkfLR35Xwf4eIH40eTStGxJXtdGlhBw3lvNwjEppRfJPzFs47NLbqQCbgalm8F4GI9z8SlzqP774b9NaoANzAC67chziiNs91tufiAZ1F/IJncU5B7vkfQrC1vgkzT7GcrVMSmJ835LsLHpMSv8FpyaXMOUIP1NrDfQLcijcrJIwykXCmLh9lxq8vDMPgrhqFpa412yOmdAGr7xoKHd+pEN74evob0Kxe5te8PnfWzCT9GNfdJkYk6yXcqS0/vwXAYUA5j2s8k+pNhJUNzxsgr+kOtzGPB14QxAlLYdLciFqh39BnhjpemWs1sEHryL5eax81JwlmBqAnd6cN5wS34+HfJH/UGAcr4rXfdhMBCnw6SgPJCHUka3dd1FffeQEn2LEYbaQWVaA3mztnUolVczQOFYLKHxnbww0gahU9c6HdqXTzz7E5NuzNcl2tybSWIFYjnsa5vR12WWxHj1t0AW7yodGxw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:18.4565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e79ac55a-7bfb-495f-046e-08dceecc338a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6615 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. Rely on this function for validating capabilities instead of when CXL regs are probed. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/pci.c | 14 ++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 17 +++++++++++++++++ include/linux/cxl/cxl.h | 3 +++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 3d6564dbda57..fa2a5e216dc3 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1077,3 +1078,16 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port) __cxl_endpoint_decoder_reset_detected); } EXPORT_SYMBOL_NS_GPL(cxl_endpoint_decoder_reset_detected, CXL); + +bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, + unsigned long *current_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); + + 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 9d63a2adfd42..6fbc5c57149e 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 6cd7ab117f80..89c8ac1a61fd 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -792,6 +792,8 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge, 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; @@ -853,6 +855,21 @@ 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, BITS_PER_TYPE(unsigned long)); + + /* These are the mandatory capabilities for a Type3 device */ + 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); + + if (!cxl_pci_check_caps(cxlds, expected, found)) { + dev_err(&pdev->dev, + "Expected capabilities not matching with found capabilities: (%08lx - %08lx)\n", + *expected, *found); + return -ENXIO; + } + rc = cxl_await_media_ready(cxlds); if (rc == 0) cxlds->media_ready = true; diff --git a/include/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 4a4f75a86018..78653fa4daa0 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/cxl/cxl.h @@ -49,4 +49,7 @@ 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); #endif From patchwork Thu Oct 17 16:52:04 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: 13840386 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.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 C2BD71E0DDD; Thu, 17 Oct 2024 16:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184011; cv=fail; b=sH6fvuERtVC/7bFUrWj5ihuFtqoentt2unWCrhYBR17JWaP1FrPhcpCiffrlzqtXVm5YW1OWKzTR6X22PM8d9moIyKKus8qwo85uf9MpmmT2155MANG9bSXx6rZzhFOxp4dWpaVHt5C1GPAA3wI1cFsjG00pc9/qX+rMq6n41dk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184011; c=relaxed/simple; bh=6OlpLnttcrF7j37dtrBqQLHk98Es5Nts6eZaeLVS05Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mOECruQZTePjXSFcBXNWvcWzRr6G10yN90ZQxqGVU8MxelqIYQeIDmwQOcQ+ocTdLFlNJRs3HJzjcVPJe6jwE9Y6ZX1inTfHO6fXwk5WCb0i88/xAqBUUY9v+N51yVbqCxk5lWP5hAAJZ/6VAF1Qn7FIW6v+UzUEASVDVhQsST4= 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=ioY7Vunw; arc=fail smtp.client-ip=40.107.243.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="ioY7Vunw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z953D86KEK5XskH7YgW6Jn2G2TM8OYTmyXecoZqCga4UKdhuHpY6eMg1GDCQUo6D8Ed35rsOUCxBalGzDCbAPpr/m2jpCWgsV1sgvnxEAuJGUtP9Bb9uUWfccHOdJslTcGirUZusWXSW5Inwq5tlxeB9z/R9IGge5R6KkFKk4bB4lmknhbU3ajGCNJJocyOdogBcyHkNFXAaVXEz8k9xbeBwCo50lPhzv/QNIhz85D8isjDZ7f9Lc1dXY5SJPQc7GtCM5fyPqHh6J4t2b/oBeOeQfj48Z41SY+45Q0OjCmWnXMbjAEk/l8S0AyqqdxlrZLaaAiuR+JLkZHFqtwmP2g== 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=oltp956Ct+SEFySljHfdJ4/G7ijETooxzrM3WcNNhx8=; b=TuDbVEC/PnveLbChb6U6snRYAkMSAC3JbPdnjHU81rl4jJf5Vl3flPMEVjmOTHK7h+HLFm2dw4FGNqWBNw20jfmMXvp1NbKxx2tjHIfsxoolM/Fdfg33Jp6nJkAOjyL3xMMsaFfL+XYG7cjtp08SfdOOMS0u43Qo5jdYf0Iy6win1qNW2REt0yhNH5nQc+l+PdyUjH22cGmjlg4h5KOdRHXg23c85BdTbvTwesinaGOvx1xmxx0VSJIsPUOXnUB+sPodLiWqN2TblDXj1VZcdXQlsFrUZlkDPzizfI9mMkQyKGNYIV/Cfhg4mC7JCf5LLF4lZRs/laVQ7/DsywpUdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=oltp956Ct+SEFySljHfdJ4/G7ijETooxzrM3WcNNhx8=; b=ioY7VunwbWiE0pWgLLpUyY1PYpf4ZmKt6XDHtHsu1aGkur4f95VkqWyJtz9OJNBuoT+6E1HXZ3DWpgmL9RIyJhWVuGcD97P6X+ah/oD3zxWVyLYsPAuGrxvgex3Foua1aHHcTQ/aCb+rF8wbdZnfq9hOV2ZQDbVkkGPNslYCNis= Received: from SN4PR0501CA0131.namprd05.prod.outlook.com (2603:10b6:803:42::48) by CH3PR12MB8877.namprd12.prod.outlook.com (2603:10b6:610:170::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 17 Oct 2024 16:53:20 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:803:42:cafe::5) by SN4PR0501CA0131.outlook.office365.com (2603:10b6:803:42::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.22 via Frontend Transport; Thu, 17 Oct 2024 16:53:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:19 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:19 -0500 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; Thu, 17 Oct 2024 11:53:17 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 05/26] cxl: move pci generic code Date: Thu, 17 Oct 2024 17:52:04 +0100 Message-ID: <20241017165225.21206-6-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|CH3PR12MB8877:EE_ X-MS-Office365-Filtering-Correlation-Id: d21cd61c-ad96-4e08-ac88-08dceecc3462 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: PZzZUTOHEXxvNQ0wY8VMuJHVeOjzYCa6BeRRQTl0zOqJOu9bKppxEGxmQEAHz6xZ5gvwOzlb2CkAkyJiw4fp/NMe1jneXJtH6w4mUVo8qVfutTDkLxttqNgLSTz6t2m5XHcl3ULhbFd10OFfc6ChcV84OW9zRz53PYhPGq/HEEXGrsxNC41CZwm0lA3sGeebXYRE6dlQ+X9ej267eESOdKz30bnEiGsOHZQDl+N21jBFdZLPtrvwEphE7f/ziXZyk21xF4LeP8CiYRTX8HRQ1/MgRqOKVMlOxrBIrncDhz/ZG65VX02+pcsmsXdtq+7cIB4PPBNPXxvvq/0MmSPsmiHn331Lf83Lzj2+AI7zHEebLtRrcwWGM60hS8nv17zyIw7/zOQzzvvUytoNm39JBSiK7+HgOhZblKM8YPQKgz6zYZuWhjCgAqH1+ylmyBF25jyOpC6XPGtllU9aolyhrE0+d+lqgMheIsqZJxAkiVABJBj22jURhBe7+8Ev1ncBxcxk4cTJNwjvnlH6KdUoME1issyzWt9r2h6tV6wYZ0PGFBOQS/WJ4PEhSU093v33uCdJaIFGGTj2w3zQlRXYtZvHRWbwqFFjywKxyfZx1r6dFQB2CSJ0DIWDbx+I9/T+QGBNflpHznZVMTodo+mJdSnxwywLdV3MFzCdODkiOkYXLx5pU67CJQn84/R8QS9GE9jdGY3MevKccilk7XF38A5kCOcu8zlWX4y6OP15bPJHTVshRm52E+jV8Xo+BCDBAT0H5bI5DrT01LIII1TV4psRpekABKUFMQw/IuhQjsZG4LfN+6/KfxStkq75ctkN9MIXz29Q6W33dyTYo6Q5Cazisu/t/QzI4hGRcRODYGJXlMtr3sFY6pDWtFLCmpNbTEP37251DXw8IpjHZSLa42AN/C8uD36IP+fwhrXwyNO/AbdEhzlB3agrroh8xxfm1JWFWEGIXe0lg2Cc8sOsUhHy0NdE+USsXco7VEtZBPTUEnGR3ixJYM6k0LnHWjSkyVdO5spdTMBKUIK+yySJJnD8zEGIt6b0F9uIOpG+7tgaPuO66dkTXXGIR1+C8ZcUG7HyH8X/lbZmU+byYe9OxcQuxPInik+73uu82UBTx38GH1f5gUs/FxM/X4EZuX2IgbBlhIk1m4g5ay6cj8RQj8bBlY3wlRYvywwQfmWryIMN5Zgy5J+Fo+uUtlS3aIMuLvhReagDUEonrrczvAc8QkKgocYlNHghcJZ5/S812NtN0TF5cZIud6xCx/3+b9DW4MF7k8vqCB92I2LJcKaWUJE0IxNsPKn4IZsq1Pk5SFyb2QFTjgvT2qTs4743I677k975foA0jPhchpJ/Fr7gV/bJ8TVSXIpm8E12fWZv2eA33UvUi1bYA++oNXIdmpXINL0V5uvJ344Ou+PzQuxUFQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:19.8607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d21cd61c-ad96-4e08-ac88-08dceecc3462 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8877 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/pci/pci.c in order to be exported and shared with CXL Type2 device initialization. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/pci.c | 62 ++++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlpci.h | 3 ++ drivers/cxl/pci.c | 61 ----------------------------------------- 3 files changed, 65 insertions(+), 61 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index fa2a5e216dc3..99acc258722d 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1079,6 +1079,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); + bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, unsigned long *current_caps) { 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 89c8ac1a61fd..e9333211e18f 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -463,67 +463,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_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; -} - -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 Thu Oct 17 16:52:05 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: 13840384 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.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 675AE1EABC3; Thu, 17 Oct 2024 16:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184010; cv=fail; b=Qkzx5w0RpiEIp2VVohe2kZXLpoWmzB/uwK0rGlwCKrtgZb7WQegqRE/unwKQi13kZMl9w/O9G0G1C1MYRQ/PoCFB1R9XO+SI3y4pGN/cUvnXtKv4rrEYdOusPTRme0U84tRQhR7d3xKlQNCXOvso6D9cUSVBTuvEoPZz4BxecFM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184010; c=relaxed/simple; bh=MwbNfIWoHzBKaci0YSM1FimPnKYeqVjeoJHYRXAjYNg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RVwmDAOlpSk0NIQQKds0lMHJGmkQMfNfPIYbVLNi3v7EBBe+pcd3ZSQbkhb6/vOjkAD4EzJ8OVhRO/VUdr3+UeZZosStYWfGiz7Pdn17lZoZe+g6M0dOqTeav/WR9u7YxLdLqt4pMLKilfEsX2EGp4fxhAK6ZugxYTqSawGY/XU= 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=gqMUj6Jr; arc=fail smtp.client-ip=40.107.92.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="gqMUj6Jr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jKtQGiQ4xCWAAPFJyN2379Py0ZlgsLzRzUWe4sItpbHHDaPgvAuseP2aD+K2HH9HNRK+IIjpWaQeU9V+XmWxaWxx8+xkcb8xH+e3vnHiKBa6p2aixnO8+GEkcIS6YKqtp4qM0awrt2G1E/mv4SMcUQ4LxdOfkZwO4HYHsCxxh9j7mR7ib5XYHwXwYyO1Q7gkjyLCFdpvqnrTf6WUfn3lYp6p5JTysEhOoI3Ki66kizSgMKdkKzSOd/eRqG/nMmnUehU+6Mxg+ULBU/N/wEx56hXzixnIowyZGxB/S9sZrZrgYgdxBPogsx6Z5lDzlyiZRkypE1AIeZ4+HbqAypisPw== 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=B1SSu4lG3DlnDayGi7lAAABeQ4zGlIIl5BlkpqVst/U=; b=tYScfyfD3mHcVRXunF+odCoZKUZz2AynczWO9UoxD09yfndES6AWDwsbU+FFdZbj6pQm3xDPHoHLdhr3ocbfvRu5e1lzYzsAXAtR+J7Vk8jE691b+UhuREMKrBg4qJdH8erJ1MryPye0TTtNzKqQ0/bYkWdaEFL84fZxt7U9bxam3Ehhsj7wuum741YbrUWJP2NNSitVrWKDi7HWDUFq65tJ3NSWsikIJxrg0lxKNBV5W1z71bkPX2YhFdbDlwwfv2YfyfFVLd7lzeierCTdkG+PqO2ms6qb6rZdgNnEFEI3fAGZR9VnCPvO1KffkDMX5ckswjeeSRtwM8wBHr22gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=B1SSu4lG3DlnDayGi7lAAABeQ4zGlIIl5BlkpqVst/U=; b=gqMUj6JrDylHcc0LRuN//iBJV1w0ObS2YGq0zvNLt6Av4MU61KKW1UDe5iRr2a8dtwZ8HByscYcIkJvdozjRFTHwiBVtzy9FiF2l4S0vBmDEWRSnE7WtzfOlr4yikjdRKxOUkZtiV3LDxhwriKZezLZKYXA2LRLUHzYckaTyjt4= Received: from SN4PR0501CA0102.namprd05.prod.outlook.com (2603:10b6:803:42::19) by IA1PR12MB6163.namprd12.prod.outlook.com (2603:10b6:208:3e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:21 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:803:42:cafe::ec) by SN4PR0501CA0102.outlook.office365.com (2603:10b6:803:42::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:21 +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; Thu, 17 Oct 2024 11:53:20 -0500 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; Thu, 17 Oct 2024 11:53:20 -0500 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; Thu, 17 Oct 2024 11:53:19 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 06/26] cxl: add function for type2 cxl regs setup Date: Thu, 17 Oct 2024 17:52:05 +0100 Message-ID: <20241017165225.21206-7-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|IA1PR12MB6163:EE_ X-MS-Office365-Filtering-Correlation-Id: c547786d-829c-4d0d-40a6-08dceecc3539 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: 4B8P/TzHtrv3rTYkrRUIwblm2tUqxKPYlKIqjvg7GgASja0oyLMdDoOLSWmvZBt6xNu+m4/2TvPcbkCBHrgT4PuhJHXSQAGkZtlQqn86ozZqZ0sxfgDTnH4TyaFNLZALRkzlizHNRaXKA4XNgvX+9mh/6L5W5gvLwoRh7WlqL/q15VKDJxQGQR4kC6f0PqpnSDyftCIPtz97nLBS65qkfSfT7vBshlC4+EOVkct6hrOhPa6BeEWnrhyMVaQkCPHaMgtbUXailrwCsXYa9NJc9gaZ/E7ec1qak1UjXiOkAcL6Vx0KzQzsoHpMellXMu81tnbB7cW6RTWOxi/EHVuouIdCA2gb0Ae2++7Rf6EYV2U9R+ZuDXLcw4fQf27DPAyzILnuLS/4vW5chKgj8tN26I80h+btukzH9tegWpVnbaUQAFMSQdyfCwNGykOSNB899tU0ogjNdwXYUuGHToF7ejsMQaHEDsWTTt8I6vwqpHuc/2SLPQdhoH5SM02fAk4ZRgXSiqgGGUsKDhkMvNoETX85TO/Qi6vNZVjStIp6gras2IZrjYlu5H5YfQN4AR8NxfyCe3Zv/TFf/7KpewXnlsw0PBndnbcbPKgE7Scl08AYo+5BFTlFajWt1whe750SFnGa5S/ueDrIYOtpmSAeShFchB1rbOfAF406x8W8gWx33jaguCKA3FFpVw9Ir4pLsgiYq15s26O6TzB7xUNqU5dbKuS0cgc2Ww3gUkj0OGPRktJUNcff0lst6t/cycSN6MrlPXzyuihR9bzUl7KjHacsI2NTC31jaW+zdyKTTSsFfvbEAHyqX1PYvy9D0df7/66K7m2nM4xvIE0rKoU8BOpjvM6mhPMDdVbEDbtDJitdUtPQuOcOzPQj7lkz7hUvfAm6idhIsN8VRJKeSkV5nhyNGnBxVz4ycJOm4Edv7yitpWg/QheUi5xRWga8tNVHIJZVz6yr7LVShMdbfqkKHp2BK9dwDNxCKcQXZFyXpzraV1TnuX6J07mUihHOpNmKE/YBOkFzacaSaA0cttqzveCYagthTqYGg9Ut/MlzQbMc8HfOmntvie+s4j3CDWWlFSlVq+1ke06RvDZazd2lvA+kW8jFxS3Huabjiaz0fL8HC9Nm9ejXuFvKOLL7Lrzy5pZDctGTcRSn3p3raLaZeOi8XsoFWJaQ7DNYJiDrP9VZE+3eeW+BcX2HzfSLmkwymcKlujZUIh6yXajuMs3xVlimI8ZXJaZTV6QmWq7AJJs8IkpgPcnCIk7nFTRw69IJ+x08W5pMNoMTDgwLtG2blV7klK+zzZbQ+ZD8b/LeUE9vFdTVqkfF7CsKiI3uc6PhOdYc85MlJLY8fwXNH2cYOpbnzgl1H3mo14tDJ/i4PZ+tPQzfCoJCe9lyw8vXJ6I+qVHKI7GVXdYS0F0d5kcwcQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:21.2670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c547786d-829c-4d0d-40a6-08dceecc3539 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6163 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 --- drivers/cxl/core/pci.c | 47 +++++++++++++++++++++++++++++++++++++++++ include/linux/cxl/cxl.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 99acc258722d..f0f7e8bd4499 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1141,6 +1141,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); + bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, unsigned long *current_caps) { diff --git a/include/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 78653fa4daa0..2f48ee591259 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/cxl/cxl.h @@ -5,6 +5,7 @@ #define __CXL_H #include +#include enum cxl_resource { CXL_RES_DPA, @@ -52,4 +53,5 @@ int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, unsigned long *current_caps); +int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds); #endif From patchwork Thu Oct 17 16:52:06 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: 13840385 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2070.outbound.protection.outlook.com [40.107.243.70]) (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 A2C501E0B61; Thu, 17 Oct 2024 16:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184010; cv=fail; b=SFUOQJQGipZIQn0UXv03TQcqvynV3vVtMXvqiRr/Z4juqIZB+az+n/i7C+CMD6pYDUCt0ExoHCY/uwTBG2pCtaerL0JhPMP4Nv+OGH323lITIOXGzUBUWzZS3qdEBDusSnGmnCmInbF6G+kAUzkqFZvV0aVOGbJxPn/2OpnDlds= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184010; c=relaxed/simple; bh=32+FTR8e7P6rxlvWPqvp0bmnw0i0I2BlpMPc/QWrxc4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p0VbX8fp8vne5KK9fY0konPZsDAxZbIE2eV3PO2wBsHw325i7FldLrtr/YZ4paV43Sx2lDa8appkS0KESHdrlggL8RyGemA2KjpZwjr5U5sKSYV8cZnHh6hBkWOzVbYTHx1msTHfLOagKWnoqu4v22rnp277pmkb0I4pu9TlWDc= 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=oligiGor; arc=fail smtp.client-ip=40.107.243.70 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="oligiGor" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R/9kJQHjYdVY0eL/gn+uoYdJpyq/vZXS3pWlTKrjJ6BnVlzD1I6gxq2B1tpbBi3ptr2UFy2sXVBeD76d9JXxVamEFG8kwGPxkTov9eHKUH5fMDEyHyvr9slbAdiPsGGrld75W/Nl5XZjy4E2aT8tTb9SPYM7KxqupRc8HC89nUJXAJcgufUl0Oae3Oz1Xp6lWZRKzJ6yHbqcUwcOEEgKmoBLu+KNFiZrHxRrloTViaKAwMbL31S3LkdJwEqDx9hZxow48gCy67UvGDVgm3l/vIj3Co2QAlrpTnZTE8p5rI96aRGGazDYXCxFDkPFBS8DXBY96ZFcjZkt13D5xy2NAA== 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=+jqc/Yl4Rljn1gTC6MPfbh7nvnnOV+97BQj9ElzGccw=; b=IgR4q459QiBAU7FCAuEbbgxpVs9nvjvuHY9fkdqFLXHyxBKEYZFQIg5r6uP5JctyGGRCPEgpe6fJfD+CcjUaQVch8WVitBE+lEFRy1PSuN3mnOdXbwddOjRB9mf15w8OTlC6riOlmbgwU4Ng905S9KJhvlpdQybKPI2g/ZQab/5FW6V0b4sg+YucyzL8FVzm4DYneIzoOCcJlcMguIWIOPP/HU56y8P1IZ/E3I9j4fPl1M5w2T2pQApOEm3o0vfieEZwIwlDOFDBH0VWZVF77dWPxNxDl4+qAK6lrTHeHaEXFCFyj+InGsLumlo0R0jKihj+mHkecGBNjBXCPwIRSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=+jqc/Yl4Rljn1gTC6MPfbh7nvnnOV+97BQj9ElzGccw=; b=oligiGorXzinMa0OBhEMKYQcUuJZ9pFC5uLPAkfO5kCr783CJn/tsKWQCpCkE2pABJpOa0dAYOQyCgqxv5y98/lLnf1KEPjXm/uxMg9iFwHBSILpVGKFSSY1ai1CDJL6Hehss+DYp7zwRZzkJkPRwf+BEhZH3Rwpm7w6eNRruuM= Received: from MN2PR20CA0026.namprd20.prod.outlook.com (2603:10b6:208:e8::39) by CH3PR12MB9432.namprd12.prod.outlook.com (2603:10b6:610:1c7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:23 +0000 Received: from BL6PEPF00020E61.namprd04.prod.outlook.com (2603:10b6:208:e8:cafe::8f) by MN2PR20CA0026.outlook.office365.com (2603:10b6:208:e8::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Thu, 17 Oct 2024 16:53:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E61.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53: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; Thu, 17 Oct 2024 11:53:21 -0500 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; Thu, 17 Oct 2024 11:53:20 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 07/26] sfc: use cxl api for regs setup and checking Date: Thu, 17 Oct 2024 17:52:06 +0100 Message-ID: <20241017165225.21206-8-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E61:EE_|CH3PR12MB9432:EE_ X-MS-Office365-Filtering-Correlation-Id: 20791f42-b2e2-4899-c276-08dceecc3675 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: zaQeva03krOsWbhFke7dR3N5fjRB0NeH038ZgQ7y0X3gUBTkjdOrns8BXviQeUJGCWq2inprHlxE+fKWFk0sp6mGw83kmVRgI2bPqR4pJ0pqq96+/FftMfV2i1O9Y3Nnez1GjIMKqPC4S5ZFz5Yo0yDD7fgwe5CbVxn1jf+9Ou3qD1zYC+TB2n0Ld4AJzDzQyL8/gux4zK7duRfz8u0SDIUgm8j95FSuNviwgPGq0CI3ZRFdCQXyL05t0oWKAJzHDBgoVIsC7HTUwZG5W/5WNwoDq34mN2UgiG9udeUAtePXtbj2ZzJMSp4IDnuvhORUiqv52ogfHSlGWPLnxt9Sn5TXw+8SAFbqvbZYrSLwlTh5dbdhIiKjoSErNxvr2KmnyBp4TZhJXy+V0mg8EsxhPUe4gr7m/gjknbYSgL305MvQyx2rhlXAkwhSE05O+M4inGZiZbryK7BZ0Oa9PoXzP2UF6EgbyRvlJw+72GRZQ59cUY34RRqDquesR4MVMxJmEtZeAIf+qEpjmVy6spPDJvpY5YWt118AeCDK6rGXG+eUOLVL9BS9pAcgUdw2XW97kZKNmbocO9uA8i5RxInJD4dacvkUhv0xClEmR124n76YD+KkcKFbJqjzdnyPdRX3Cduye2GnRYyCw8bdf2Nf7Su7q/xZCQuWCfSx+pmFKNm8GA3Mtoh89tJq3/l2NGK6qzJDjlmE/4e1v1GOeQWpQo872kCd4DGgZu8IH2r89OCJ2wKvdmilP2ZN1GxrWDoJ5PPOtwlSfKQoxiP7RtSbeIAv9WPMWmDAXBVKo+c7ZvVw13k/MgKdJc03oEt3XTD5jeOdHkXv9pADzWLPGkjqMYA/IZzHCY8MkBE3ZbZswWf5uZQ9yc1t14nxaENn5iodUJ1Hb5NMF42tj0e9OGmpe2nTON+nTaajnj5yjGtk5huwhelpXBWXr2MOAaBNocpYRsePifKGF/EC0Em57QIik3efyzYkEo2vDvTiNgl0aUbqU9YXC0CRiAR7UZZfjx7PmTRgp84isKHlXR+LUHdrtVelvnkrugHf0ICqEGifoIxmitJ5M4aGgHo3iZpXxPlls2dRAh4wkqiGyQblLgY92m4Z3ARSeX2UfmsY9Xb52eY7gEC7X0AyhGYkf3qKqBk7F5aMgNaLKUOzLG18QrahEug1tu4QuECupMZaHHrzio1o7r/dDz0SAFf7f6Aiy0/p5SkTBvz0W0HJazF+xl0l5bCJDW3+LD1UZZ/FtlwU5A7VhHIWvvV6cbeqoCQJ04ePgdIT+EP+n8UOJCl5h/HkFZPs+OuE12AVkRcETst3ADmQlRVnOzZwZKP7+pX0CXrUU33bFLtfmZu85Fo2SXi8xEfPyMcAymEY/qIcNLrgwgFdPW26pIxubFmBqxHTHBKyfUxUn7sxuGl9OHmuWtNgiQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:23.3569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20791f42-b2e2-4899-c276-08dceecc3675 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9432 X-Patchwork-Delegate: kuba@kernel.org 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 fb3eef339b34..749aa97683fd 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -22,6 +22,8 @@ int efx_cxl_init(struct efx_nic *efx) { #if IS_ENABLED(CONFIG_CXL_BUS) struct pci_dev *pci_dev = efx->pci_dev; + DECLARE_BITMAP(expected, CXL_MAX_CAPS); + DECLARE_BITMAP(found, CXL_MAX_CAPS); struct efx_cxl *cxl; struct resource res; u16 dvsec; @@ -64,6 +66,23 @@ int efx_cxl_init(struct efx_nic *efx) 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, BITS_PER_TYPE(unsigned long)); + 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)) { + pci_err(pci_dev, + "CXL device capabilities found(%08lx) not as expected(%08lx)", + *found, *expected); + goto err2; + } + efx->cxl = cxl; #endif From patchwork Thu Oct 17 16:52:07 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: 13840387 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.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 547271EABD4; Thu, 17 Oct 2024 16:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184015; cv=fail; b=XOr8zHTJeuRcWCvrLmR4Cwk37C9kwzRRg73ytdZoaCLuuxVJvkl6JeXWtyEz/w1yJ12exC7FgNfuIwnp0ucrsaQ9ATUxSk3ZMHmA/xlt8hdvsZPKaSPZaJh77sI7dIL/5lMqUiZ31BWnum0eUy5egYTuVDhkLsDN3t5vevquiMI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184015; c=relaxed/simple; bh=mTinsQRly/KjhHddG0CxgSuyJWoTr50MQpw2pJFF2Ng=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dhvY5psIg88xXCS7GDUgTE2vaJCS+hya2g2DeCv9cXd4n7eg7gqBW7CH5sSOhMucKKmOyRV3LYnCgfxgGm/OLPyiQLp9oJS+t38CqTdiP+O/TE4zWJQeUi8/fTikj5AeE7CjNGUwGAuKouBz4XEGcx5irPLzAAd/6FJQc9eTrNw= 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=mpNHy4Ik; arc=fail smtp.client-ip=40.107.244.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="mpNHy4Ik" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AnYMnHTU+DhOO3g0H5ABtPgwBsyNeTb4KS8HIzGDPfQ+7J+WaWHqFNwDKGJs7jfK/anGXzUtHn3047RnVHo9EAmrVCv3vshvUBzgrM2AAQ32pN0mLtbK8lKmcLrjcE4UPwVxMLEwytj4iXLlm19z696j8ELScZXn1/bD4e7iz0LTU4gVn+R7FfEnvA1DkXmqYjQM7LAbD2vp5ybsv2Ut7X3fPWjzDBBV6HrDDzBUwnXqHAKTXYr+2trKau81vgixRGGeQuQrax4mKzvRTKS/dl5B9oQd/8HZZwdz1D4V6z8OQ0eeylT23IoKmEmd12r2pF7dl0793bvC1fQBUfxcjg== 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=oqb+Ftuywvd2uVIlKEOQUkRNgrlCowKkNXO2KgCWLlo=; b=UsFczDyHMVcdK8KSnfD3hihDXl5Mr6msirnfVA3hB0el4q91S87LgDTZ0m5vftBkcvUVJcdtThKb9cyoB4XW55p42cJ+cmqmXwHYfBK9SnbG4+YUhpMBGnM9WwKW8ije6z0KdZdWtFMsbNxcrKliWetMQOsn9SgmrRCsjAmyX2/bdXvu2qfP+tfEEBItOsk1N5dJ+GyZbvMzYyUm4+mbhIEnGiaSZZMoQOgachBE7lNCKElVvOLYveDVtsRNJ8SIXRkb+7qktxEJYbOtsmT7u6Mtkc73jLBME6FxNNJrhBOOcKnLKlzmM/yJxiei9jtyiz1qv0R8bwc80331pYlcFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=oqb+Ftuywvd2uVIlKEOQUkRNgrlCowKkNXO2KgCWLlo=; b=mpNHy4IkeZIcPAGY9h3lrS2kH7datqTFaTXCPvUiEP7o1ulHdteBVZREKXbuQfMz9squveSLqU2lcD1jSAm5g7y1ODaDGg0MYH7Li/1DEUowetossQg7eM2dahZsHIyzQ5DeE7gCxFcjTH8YOsseBwiJdX/7+ZaiccP99iN1XtQ= Received: from SA0PR11CA0011.namprd11.prod.outlook.com (2603:10b6:806:d3::16) by MN2PR12MB4407.namprd12.prod.outlook.com (2603:10b6:208:260::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20; Thu, 17 Oct 2024 16:53:26 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:d3:cafe::8b) by SA0PR11CA0011.outlook.office365.com (2603:10b6:806:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:24 +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; Thu, 17 Oct 2024 11:53:23 -0500 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; Thu, 17 Oct 2024 11:53:23 -0500 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; Thu, 17 Oct 2024 11:53:22 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 08/26] cxl: add functions for resource request/release by a driver Date: Thu, 17 Oct 2024 17:52:07 +0100 Message-ID: <20241017165225.21206-9-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|MN2PR12MB4407:EE_ X-MS-Office365-Filtering-Correlation-Id: f1f609db-1b3c-4097-9590-08dceecc3716 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: qRXhiEQdzmYrEJl4Tvazdwfud5HqD63ULUnxFbxp453/8NV16TkbkVJiNcsNAqy2vhXDdOODWm5CSE/KBy3VKCVU47EAuwvYoLVyKq6lnhHC1aScIKMZj8yAZklqc6MFOxXMtkijxBsWUY9RCLhk0pUaVdtP2fRuFnN41KkSJhJqK6e4jlVU/ecxKxSZY6AIhhiCeSAEqcLRWfTSv9pqGFI/KWIF+6cHfin+Q7G/iFFqF1sCFtCEyTSSlsE0JAF9rHL1+7fM/hLOQhdd0pBJzK3b5eZ4FkOU42SFP4wjkJD3et6uIf8ZRTqPBHPKkDXXJ3ryAlqtZJ1G7PAuTA5vZQ6v3fLj0dJYF1tIcHHJw0Y0P3EHqYhDsczQlST+dUKgrAyFfrfTjOXKoz4PxJ+JSy1Y0xteilB9HUxPHTDeeHFIFlOYY2aJacJfWEyHGeKLtTvL+ETTR6QFhrVf1cPDeqZ2WvGNc3zykhwKT43lCfCqp7isquXQJUskS8ISv3iVZ3dvIFee7mdUGrUPcOth0xdqj/vKIyRn9ALLUjN2zE1ydDkPB6eruIPKyM2xh1x+kwQdzMof+7Nr3KYACLoJnjbKhcjPGVYwEmYh7GB2VcPZjoWNmjla3vpvpfLMBMMYRw/reYcOVRLGg7LSsfIyWY3M+mb1mPxytQH7SMs8Az6D9j6Pu/3A5jaSi7TAUTp1tsFoJeIqOoFXJvvtC/zTK78upOaTnuHS14Wqj6MOc5jbMWQv0Dzmjcjz9jiNCbsMUFjkrI8wxNBEAOa6xcxIZkGksfkM3n926BnTkIMH/XlpU+cfESovAJ7Oy1wDFAZZAApFFYQF+CiO392xZjEoHX9l1YwlDin9kEGowAx3NFFPdSGzW/QN6z4nT2iE6peMkR2WqD6atoLrDU50zpiBLn4hgrGgLFqIwK6wVJuohBNSlR4YNBOJ+qaXCTXqY4Hfxk2rMtVbV6tBeBAGMDXk3qx2NT52wxBUGlAjgzq811IIR8yG9V/XfnbeQcTd949Uo9Y9wO8BCJdqXMl+JqdrwFoRlFImk8CGjLWOOYJwymu2Na+TfdL6Dtw6MK9Fi8owNqB/AezMO1kXSakSBV79D9kV447kzo7So1ndcgUhAcGtG0i1FB9qtkLNEWOk5O6b2C5w2gN5IS00Nv0fVPB9nVCJ2dFHJSkWybZIYC8u/9bvCvY+yuxuoU4QKolA/Jp7tMBiR/0rr62TM5uWlv2+/UPLGqI+17GmCcBve5/G1VZNlN6mALQCQmlsKGiJGKeL3uBVDd70FpXle/Lb8Wkm9YTGhUwIDVz67SqC5MuJkTyCxMxp2iZaS+jhQCpkmjEI9z7OX5Wfk8sQkvsBfULBDcuSGugkxXYlOLmDLhQlfiD6Vt330yFwKOPZvtgbFUTQMGukFGmkYmP6XhJo6izeOw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:24.3796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1f609db-1b3c-4097-9590-08dceecc3716 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4407 From: Alejandro Lucero Create accessors for an accel driver requesting and releasing a resource. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/memdev.c | 51 +++++++++++++++++++++++++++++++++++++++ include/linux/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 94b8a7b53c92..4b2641f20128 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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 2f48ee591259..6c6d27721067 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/cxl/cxl.h @@ -54,4 +54,6 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *expected_caps, unsigned long *current_caps); 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 Thu Oct 17 16:52: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: 13840389 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2068.outbound.protection.outlook.com [40.107.223.68]) (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 1847E1EABBB; Thu, 17 Oct 2024 16:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184016; cv=fail; b=j+eJwomB2J5bpOxp3KlEIqjrn46XNAIx3ySCF/CA3i1200vTTzZSSrKgVYyr5RM5YVGmsHTX89AshjTeTtFLJCR4BhnWxERZcF7DTmKpCBrxE0JG2xPqTEnwI67uKtwg3d9uinl7zANOf2y9JzPENIEVtO18x7SgZg0mkvFSVBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184016; c=relaxed/simple; bh=xtGge27fT0tsPA8RKFjD5rgZ8ZiAEADRKmU1vA7IOJg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BXtKP0dMYS/VQPMseYB6te7j5vH7i5DgP7BjCSl5Gpkj4DcBs+62nUDg87u5eoT80lAS+4tlLNUPpwsyO98DIHEufb+1HV0s6YL7mByE0FGLTMnl9KNMDp6h2tS8y+Ovl/SCRYqh7g094ZkW0tjf3C4Vp1nvyvsgxmsLrF+/RJo= 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=xOVIowqZ; arc=fail smtp.client-ip=40.107.223.68 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="xOVIowqZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g/WnskRdF1NtyOKLslQOmmjXo8Esg0ZR9an+QHpGWVMS9dQIKlUleT93Q1K29NRBf6P9LcthFkYrcYYFvj93i/pSVg2G+9jQyeP4rQHQpQX/8BFypawc5zLbmgR9rglSHhO2fTLUCFWlxwX6BaeksDD9WxF2wc5DQkDVAs45iu8z5HWOYwj0VpzAGAUxGEM0LvOs97XMGbesyIy34JVlTDSPz7YQg2o9y05mOPnBrNCP/UdgLcKSpiaIQRRQD4sGZHCQj1uNST3jYPzxyOWv9egL/DN2vx2UxktUvMrzSmogloWX4LSlL9TY7YsZtw/DRcBqEPidFJ+bDO15XBYosw== 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=lYUMz6EzjGbSZdsfNBoV9zb1KXfMhXT1uZBMMqgtjTU=; b=x7JrdWYun8x4VNm00Xj4EthbDz02xQtlsJ3iUtBRF1Fxoa5zuiqIfRTeygwJsmA+j8e6a0twOHp8k/EXrM3TvsBDbw9vIXaQ6ALFrlYMY+2QKJqwWA1qinzwXcKEJCr2pxyxcHgetCgW/0kgFcpfUIfdcUybMlFLLfrbCWGrdLvxixldGNrpnkw+ge6s3EbeQ+2iuVRFZ8SLr0v6MBuvaKaC3TJwoEnAfOyUjGyDgQc47WCaxW4KJ0ndzbYKtwzYycT53fiTavvAKTAZTawRUF1/L1OTjXKrIfCoNopuXG1WceMQDl4ksRAwSn228i7nX7dlcC45KN0dKAlxUvrqAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=lYUMz6EzjGbSZdsfNBoV9zb1KXfMhXT1uZBMMqgtjTU=; b=xOVIowqZcMAje4ksqC5TYuvhxfyzqXC5yoArrsThITS1jg5fU8rMrkNGaljx8/J6NiobVtZ16/Tguapchs4Te+uUB8W6IsNxzzY2YnFXcUqUVwEStwORXW9M3mafW5Cq72woM5gWX4+eItMAxCjMxmmvXdD2cgyjHt3/MwZt64k= Received: from BN9PR03CA0201.namprd03.prod.outlook.com (2603:10b6:408:f9::26) by MW4PR12MB8610.namprd12.prod.outlook.com (2603:10b6:303:1ef::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:27 +0000 Received: from BL6PEPF00020E5F.namprd04.prod.outlook.com (2603:10b6:408:f9:cafe::7) by BN9PR03CA0201.outlook.office365.com (2603:10b6:408:f9::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E5F.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:26 +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; Thu, 17 Oct 2024 11:53:25 -0500 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; Thu, 17 Oct 2024 11:53:24 -0500 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; Thu, 17 Oct 2024 11:53:23 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 09/26] sfc: request cxl ram resource Date: Thu, 17 Oct 2024 17:52:08 +0100 Message-ID: <20241017165225.21206-10-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E5F:EE_|MW4PR12MB8610:EE_ X-MS-Office365-Filtering-Correlation-Id: f968750a-6088-4e29-e84a-08dceecc3844 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: xiUf8p7c3iXGh6+NeuNrbHd6JaE3oTat8UZhrk6DpK9/2u6Wj88s3vpsZk5bHOczEAdjCYchZOgRUuaKoUS7fvWX0/iBkFxLaiYsPYbnh4hJVHXWejopNO0dLI/6/GCaNWwUwszM4UKke7nshJn/FKvs114LENGFLjVv7ohvJutE7NiYsyY9bxuFqw61T7YhPsbgrdjawoJflX8Mx+kCRsiojgyIWuz4mhYC8diangolngt44Rvj0zA+Df/X+I4zuHqViScAFEnGoTnY7MXqC9kRZU13CXykBn3ijN7NK8jkCLHe7SRqVEX0r981h3r38XMIJyj8nfGyXXRasbZnQ9hbAouVEf3AieQxkTT5TV2yhsreA4ZpfjRQG3/vlcAcF8n7+gpoBhaiezr3zGSIUO3aPqQxax/JmIo1Jp/ot/G2GaI3C1GO5Ttvydp9tgkF5jTxTE8wjKqTb4YWkrFygyuLOVpYfJSDLw7awNKVoqZ+LYEtcsl+BUMEYdyHjjl7nqxxmeQzldx+bleRNMGhDHTb2q76HJ04FARmA2v6FTquKW1UDZYJNY7zyx8TK+Io4oulA9r+3eRq4oHNFx2R0YfCOmLYTSEJUJOsjDBu/uKEYUzuKyDYAp0AwZa+W7GYkX468VTd6eXQWLcwyfF8TBikJazE5MUp6Xl4YPX3j/QxQVzthu1W3/0biEtcyADtlewyMsQ6WRbHAA5i//E3HHTBYdfglLliVEa6S7F1WI6aOeBhmzMaWKykm65gTYjQF+JedQzwNZ3jSD0jsEBLUY3alqZRyelUAvUdpGSj7Ff9SfrFklY3+2ItdLt7FkCOI10meAaVDlyoOB4lre/VjgE2H+7xZ4zzZpeRB0GMR3NfEEKbMfB0r5u5iQ/8hlhMnmhXE3Rc86IiL15MS1fSEfbk06caS2/M+4ZONvHMhvQT2aPihCq+bMW7VEjawhQxPGcqrFkLsFI5DLULXUuNQFgozUbCfkw8dSj/eO2tyjuCiMUeA/AH3CPI2k+3ZPUjkq3cbueM9LR4WRYGP1zD+dKtOCgjg9EbfEOkPnJOPk+De93tXx26uTE4NA/T/1si/HXwzwxP6Xd0YWhYccGyiMJoe4XkYij4JIrLf3fsmKcrkjCOt1SzC25jmO63hEGsJVWNlR78mCIUVTZ2crMFfYegrYYdzIJNgboHwVf5vl4Xw6YWtjy63kxEO+c6Xyp2INybY1w2xl4felIw22xF5viKLYnckwE7pJgM0QhaePIoO2aR3/JvGiEBlek/sqE03eMYnFQKA8h5iDRw51kSxXCnisI9mBPotmPsgbTZgWuyeVhik6UAAx3Y7RGreyOhFS/nTmQIDmRXaMjiy0txvnOdeJNWsrA5FrnJvW9KpsiAStlvlLlh6Rni9MspJui3S7NzoB3Dvn2bYFz85m/HWA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:26.3921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f968750a-6088-4e29-e84a-08dceecc3844 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E5F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB8610 X-Patchwork-Delegate: kuba@kernel.org 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 749aa97683fd..d47f8e91eaef 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -83,6 +83,12 @@ int efx_cxl_init(struct efx_nic *efx) goto err2; } + rc = cxl_request_resource(cxl->cxlds, CXL_RES_RAM); + if (rc) { + pci_err(pci_dev, "CXL request resource failed"); + goto err2; + } + efx->cxl = cxl; #endif @@ -102,6 +108,7 @@ void efx_cxl_exit(struct efx_nic *efx) { #if IS_ENABLED(CONFIG_CXL_BUS) if (efx->cxl) { + cxl_release_resource(efx->cxl->cxlds, CXL_RES_RAM); kfree(efx->cxl->cxlds); kfree(efx->cxl); } From patchwork Thu Oct 17 16:52: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: 13840388 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) (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 17B001EF089; Thu, 17 Oct 2024 16:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184016; cv=fail; b=FwcM3v2QKXUwfgu0P5LUdTtShXSgsh9NfAlTtIZAd81GzZMBnMqDHRcalfTLp/3luLofETWe4j2PmzDriD26vzoyJDEc988mYBPie8hKjHwsZqCmuquvBc8Xql0omy69LkXCI9ZtZB+CaZSNC8z1230Qno0lOJ64axtHC4nUBOg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184016; c=relaxed/simple; bh=SV4Zjdj0KPA5SjYzgPKGrkx31xOcLf3oz5OgfcRBmak=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ghCRawYCg4tXE47xlokOObOAfokHsNlDF2GKC7c7+S5JSgYF8oKBiulCYF8xdG65Ta6olSkNTARoe/FapL5tGb5L3YRNSXaHdWPb61bAyvxdJ7vNZCZNSDhtpWnCqt+TpYxDdzhz4oGijopYuHLxF0S5WpYT1RIztTTH+g3HFH0= 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=GM/UHyON; arc=fail smtp.client-ip=40.107.220.74 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="GM/UHyON" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ap7H72maYh0um05gdfTr5OVFxwuuU7apZpyKDaKQU7aXmU3lEQ1UQroAbO1zVYG9jbWdlKWk/9yBBObm3ZcPhebOzrRvS5jBSOIohOHKG0VPgNgyv0PvolK0jQmqxXOW0RJRgltgHEWA2+H0OkqeH70L7A5nNXhzXvGBHq+/4l4Vb0ikYc0KbB92+nmp5u2ZnvlixFb0wCHrlcTFzi1jCP60i+G/HPRTifP8pXtp9fB8+3uTWhdII+EirJDyYFn6bGTt+N8mWodzdwhxcvNp/+X4qXlu2jdjUz4oWnQZAAUzYnhWQw+PqQzK3axvvut0MuTjUJ01DN6+BpLLdzAROw== 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=njQ7BXy4iW6uNUbFtkWXU0HRWbecwV+JEE7FTixF8X4=; b=emW0bLam4QFKhW43ZiQCGEe45EvXZ9kxyYblQhXCx8FXfjLtJ6zG5sbKOsM+B44BTz/Za7m/AUbvbm3cdu1cUmRzXQ5vd8qpNpGVBkhZrLjz5QOHjMe6Y1gwppsuP4+4s4pgOGu1cYumbWNEPvsasatpXpa47EfiOtyc2N2+6yRc5BkwxuKdRvqad53f1qSmTSqapTbqGmv730CVY95M5U95ZQbpwtowiskDgLRv6MZl9geCCQhxnwb++hRiSGRTEufBDjrcI3JA6SdEGeIokNd5JGKhdaVsqcvUcdkzan44vhFU6SJYKU5ZZNoEoHjk9QA2pVispWtdLWPOQtSUgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=njQ7BXy4iW6uNUbFtkWXU0HRWbecwV+JEE7FTixF8X4=; b=GM/UHyONElSJDhYEZiI/KdvMVpLq+J+fR4hhoNy14T6XBbUjmsHJri3VJkyZEfvNDXQEvqazpfFy39SrAwUffrYF8a+Nr6TNuyGfDC43qR4G9ipEmzrrLDvNFgZ1X5kOa2fmfw109iXX2v2eQuMASQdKtn2gaelxneXKGfCst6I= Received: from SA0PR11CA0012.namprd11.prod.outlook.com (2603:10b6:806:d3::17) by CH3PR12MB8481.namprd12.prod.outlook.com (2603:10b6:610:157::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:29 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:d3:cafe::b8) by SA0PR11CA0012.outlook.office365.com (2603:10b6:806:d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 16:53:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:28 +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; Thu, 17 Oct 2024 11:53:26 -0500 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; Thu, 17 Oct 2024 11:53:26 -0500 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; Thu, 17 Oct 2024 11:53:25 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 10/26] cxl: harden resource_contains checks to handle zero size resources Date: Thu, 17 Oct 2024 17:52:09 +0100 Message-ID: <20241017165225.21206-11-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|CH3PR12MB8481:EE_ X-MS-Office365-Filtering-Correlation-Id: 40d0ea5b-0400-49f8-ede0-08dceecc39b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: pxeeXN8Ye8039tHX5N3yZtLJbtLSA4VPQh/F3vZl90TDCKvh5ChU96+AcE+djhVrIwydg7B4ufqHKiskRk1QaV7zufTpAf1wseMKar5htQFIljHaH/+EKLPhTGZui0UO0afYNM3nUfhyweWwj54eswAhKI+XRew2yITojb7TuBxcixIN6iynBJPI2T8/NnlFav3gwa22LeFw6G7qWuUrFAADuU7bf6xZnQUHhlt7GB27sJcp4CtlPVgSo9TtL3PuKe1cjPKv5MAUN/K/nQUJyKQWNKIWeS+qfazZbAb0ZYlHjejweg3j9JBoE8SlZUJFLh9ggPdrYeN7B51UHy3Q5arsdNkQMWZM4BF7FhZt5LJw/1i9GN7qPQxGWL3gCQ6m4qQwoKyDm3F0KFL9g0aEPHDzBU99OZBem49oH2FCEEfd00Sa89s9q1GoDFHwG6qVjbmjtD2PL8gFkdvhvZIUit3/B26TJG5G7bMuzEjz5eJoZc9rOwe+fdF2V6ORQzpksqKxd19cc56jyvehcJ4B2rI5UDotuTi7qTJoYhRx8HJcB4Q10qRV+xECfNZMB2ZviHqH9UXjAV088ZIsJdIVfl5Dbod6AIJ1dFsC9/OV8HLUMkTwQSYDkQSqKbAFSZtCnmS/HXhReTDXEiHGKEIG2ROs1Y0thWiZ+bXazZskDVQun8QABJTXoD11RAYcCATZnyLUR3DDLOWY4TuBZrY/hVFqkxw6o8HTgMponvW+k2cuXS6kNdC/3+/xJUsccZcdG0txRZylwlOZjog8dFxmts10yQBfJG+Es/LirW1fyJnNgAAbrFPb7LJ2vnCBbIA4liCnnxF24XV2+n8KbwglLcb3tLFXgm+vwVU5Z/POS3UW0MJ+pCUgBY4KeptDzbLPT1zK8eGle17YnEwcd5bcEOltyHc09vuXNJ/8zVEdmUf33WoRiu0DE4dzkHpBca/nuIi6cUctjHDBShjBP91FmaTAsK+rDpciT1HZspwwvvgNq/w3rmPO5oSq/bavn3inOYug8QBPEUcuGnJPtz9gd+XE/CKBfGYK6Wi2fMUTJskbAAQsGtdcUnFE/dyoPcLgMNPwvD4Z5lJCP5a3t4C3K/p1VBlBXcnmD1poKGLSOneWT3py10hLU8/xcLU/dgrV5Sixs3SHzNSHU21SdO4uIw9XS+7BuVnDDbaw5ri4vGd4JSXZvetx7VZauojB8AcubioPe3/pWpTD7d6uXQwiT/LsAxyf9rray0rqgXnKt351n98l2jCI0hoQAwDWkXsiEvnGqO8UmqY/PgHrA/4DC3QQwZWqhABozWbTbMD8ZCSP7l/nM4tKwUrJtq0aw1be4cnbcBRlKn5+gSDd89ben9Lc9lJdHiYSs26tY5Q+jxmRNgabkbQe2Iq3sJHWudGWxTtRCDG+NWUWK2GQUN1EFQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:28.8015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40d0ea5b-0400-49f8-ede0-08dceecc39b6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8481 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 --- 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 3df10517a327..c729541bb7e1 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 Thu Oct 17 16:52: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: 13840390 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) (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 7C9871EF09B; Thu, 17 Oct 2024 16:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184020; cv=fail; b=GdCEKmsRaP0GMDyAZTevGMXV9+Phqb0GAKmXbANeOGnhgjkRXPdFSNkvJ1IZMrC8f04qSXhdIDYanL9hBpg6hNCpAfbBT4d30TahGQCsbzmpec2yyrrtBDN64XIJ6MhoqQCoZ0uvufTIILueS1JV4fB1Whtu7VZHsqifdaUZVJc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184020; c=relaxed/simple; bh=uLdGuW6yVMudT004wdaexhblbBXHDhKXktqTQeI/nO4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BOtnQXPSLo4nx+iq8zD0iKPlxLIHyoLpEckUvDqMOb4NgPSL3u17DQWjCvUnmFabZ/j9jNba00/gNMEfCn8US0UHC27fBFJ7bezVKKXLgFLLqQeza4YSdelghcfhDBvBLLzMdNbYKDrj2jFmMsM+YjPceUEn7OdCor2jAKAqF1Q= 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=ZUlqHVJV; arc=fail smtp.client-ip=40.107.92.51 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="ZUlqHVJV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uSj+xerV1LY5XChp1sFADEFhbRIRQUpd0DiB8quG1bdPDwmRE8zeEUOCuXIPkDEF9prJTSk3c4YEfalOufA3rQ1g7CmzYimonOnGBjRFDZFTN4e0fzBMEHufS+dXH/p4plAFCCanFssiEKAtOSCZV8uZlpbOWfvmJu9hmQwnoWTLEnOcUFwEBGL45kx2VNMchvKikj9jMbWNDmv2R8Ti+xpXB0AY9xkcxbiKufxiDPMFmp3sFM6TgFbmYINcH0LD4j9GL/XC/yeVCP2kLC4ntM30Qq1eCyyNILXoA8/ev5Tj1eHX/iWTfDTHsOqWjFY9vznSEH+i/fENC10zMcWjYA== 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=FSG85V5DmsDnjekrHnduOWMtZCsqAB0em3ecH5WQ8O8=; b=AecMIvBfiPZxfkH1oP0l6QCEI+XHRrgvNgg+hiEUU0HqvyGRfLt79+99eyV6nywfu75+B47MCsguRVYzfpzfIlLTyQeMTUDj4gVz6om1qWUGwayJ+i3Z2MdHcldQRJn5W9EE6cDqPH4IJhKayyc4ETBGfzkGNxNgyvRVO1zLWBcYVj0QNd5xN+i/JpHBWXDyy1Iwc8BevsSl3AW+mU12MNY843k9WW+D/VDOrgvZBey6CH2zpjOabIUh6vwpsTov19sxMBj0uJEd5Z3+tkW1r5P868f3qXt9HOaJgm7rR8OkPrNkRd3+avHmlS0t0TtJM+3Bh3zstdwRXqNJV0om1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=FSG85V5DmsDnjekrHnduOWMtZCsqAB0em3ecH5WQ8O8=; b=ZUlqHVJVVMhhB362wAMiku2l0+9uAEQwADgfGiLeTA7pMTOyFP9QAQKhzUalxuxqJoysRnCPT/SCxrv0Xor45wVJxSbanoCAQejVjrm6Z3wYVVa9GgcEUl23N+Q/BIw6nka3EdYetLQl4z8A1kTAg2wF0UA1RNMWy8iI46Qmt1c= Received: from SA0PR11CA0026.namprd11.prod.outlook.com (2603:10b6:806:d3::31) by SJ2PR12MB7943.namprd12.prod.outlook.com (2603:10b6:a03:4c8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:29 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:d3:cafe::c5) by SA0PR11CA0026.outlook.office365.com (2603:10b6:806:d3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 16:53:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:29 +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; Thu, 17 Oct 2024 11:53:28 -0500 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; Thu, 17 Oct 2024 11:53:27 -0500 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; Thu, 17 Oct 2024 11:53:26 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 11/26] cxl: add function for setting media ready by a driver Date: Thu, 17 Oct 2024 17:52:10 +0100 Message-ID: <20241017165225.21206-12-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|SJ2PR12MB7943:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a427185-204f-433e-5ee6-08dceecc3a29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: BuZ0UfeJvG9PiIhjc6ZkCbzDlws213cB6O42wlOlkQ0geVq2Ca1ScMmjvQCJedGKsjzKlb6ZIBCuRJ8ZHVRUqPPZiaCpvEjn9DKqmwML+R4hmagBsUxH0qDiDxgEVqlc17NVXymqR4iVUn1hGRnPOrPHnk6ctw5EBHUNIbsgdzI61qPXYoq4rR5h4EMiVQI/ZRR757wRB12XiVozGKZ/IlNw/OmsoLTqBFEIzElP8ydicrjMAY+nxMGYcN88lOwvv2/9eSs3DtGcaTA2gXYlr98Mo7s6efUpfQs5U648+/BYNXYnFC0EiZRut0IBcepVLe2Q3nnffa0so7lI9By0qTZdwFgr58SbiQwanTn1w7qRLSKC7yIapEDRcn+pwO2CtA6MqDJUMZOvIG+cMt7LE35cA5woGutTR2jtxTNoVXX3ywyiG2Dkd2nP4wsUqn4g20vySEUmyDmf8jw53g1cQoL9GZior+BbSXZYbXTbTQwyofkFWhfnimF004SRW68oBwgDRp6LuE+3FJUYw7HveSwV+7++115/jDcr/CtRFJxr0vjrp/jD1cNHkmMC0vdhLlcFBw/TjQ6/vVRqw69Pvmp/vKYwzFdJtf11+CCNFB3mGMukdinV+elrUP1LomR8ZJGjGIg4PcRRARRcbHHFN8iAYb7PaZZVWOXvfzA0lFH5MC/57h+pyXUd9nqo8V8bc5qfO3YKVYIiiOzuYSTjg960l+DE33LugB1IWQ9cc+PIUsxz/VP1y7xtQEEt+1oFsbeTuPuUt1kHDOWz904KlljyApOxPiE/V+giN+b/BzaLKC7k8OociIv4l92P6m+vXA2jZJ8xls43jxGPUoK86DTf2YVBmcKTYbGZUCFQaupjjKd+FBdkXptZ/cnQ1xZDOpQOcDWnYEcte4l5uWJsYtMnGU4w6MYVIql0DjpxWjBHUR7OICQxknEk5mym2OZ7y5n1EHvG0xPyn3CHzFtDWAJdYtrPdzh7z14GbthYO8TNmOmId5/XVAWfUppWT/MbGJsR9+yBjjA/wnVqUGCS8MVEVrV0Znwjcoe0YDpezDMY8USvYx4Ia17Cs4+KcSL3aLKvtyHohJfKgcrurH5y7b1GO97fw535Z7U5ZQ+LroHog+HZTt4elVHlKqKlkHTki/dX9dVjzuaJIPMXmVC+oio+TYKqarhBE7ikjwP3oo5+YiZHkboMFEE6h2PcIzGcR+/3CcMmKlYbibXmUwxAPhmwZMcE6C6JxkLOv55alveHjLZ4jRQQn9Nl+Y7u4dltxQWEuxaq2kTg7qrNxNdEB68aRPNlQPOnVCAGchxPnICKcxKu4eTSq7FmEwRVzUbDB6nowMgPoBj2qEKvAbWv7y38HdGS5ooDO6qqGiQSOdZIOu4b5YsnqGzONT/6cUJ/E6HnsE/RXk9zc+lzsdx0bQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:29.5515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a427185-204f-433e-5ee6-08dceecc3a29 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7943 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 --- drivers/cxl/core/memdev.c | 6 ++++++ include/linux/cxl/cxl.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 4b2641f20128..56fddb0d6a85 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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 6c6d27721067..b8ee42b38f68 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/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 Thu Oct 17 16:52: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: 13840393 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2087.outbound.protection.outlook.com [40.107.236.87]) (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 528D81E0DDD; Thu, 17 Oct 2024 16:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184022; cv=fail; b=qTzjHXSon1otkb0tB+sdAdEYqvDm7wFf5jpcMTHcLa1BJwTGOX/NM/UAXmlPMWIKrk8muGDFelTdYhmBq7MyW2t0GDFlmPZ0t33mRzX8Vfp8d+FYj2Kl674ODnhkYZC+CMdOHFwp7cukYbcdikIuptco/21bNq4HfBSkoKb6LoU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184022; c=relaxed/simple; bh=uoTeAru+AULjKEYjEAA7d793qX9lt1QmaPyMc/SMhHY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SDflwDeksaNKSQ6FCRZDFSFjQA29nNTIbTXsXcxhiHtGeBn/5Qvu5TgHBgSfRMT9sjMdKA1UgYSwRhD35aGs0yPd1Mm/0lIKeqnnRYxTYwQhzEgCHWZSjstOVa+YMrnE4KJGFWSsPQQCvwia3V1acVKea3jYvhF4oAOzv/pcXNo= 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=31jJ/S81; arc=fail smtp.client-ip=40.107.236.87 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="31jJ/S81" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gy7BPm5n576Ly/YHc4wLVUb7Dldi5s21ExfwiQ073ILguYryq1feCDkTGZVdJPPMZVyYse7x5FYkfm9UKjAIBbeiwJEoOIV5TUmRGcw2gJ9zauIgYMCA3ZH0NES3FKFjDaa+KqmVFBbld4xgb0HEDaOdkrhlirtZyYOZIVK2Qwe/cC2Vs2ceS4m6GElH8OQc/sUI1Ggj7S+Hj+Xs+3+jBn4tcf6nSSbxPIq2nNvijDRClpyMhS/JJALKys+EYfa8qQN/uSiUVSeGMauVtW/FL1T214yGtq+2mh1hTsaPKeKkzCXuZd3hFZ5nLop0sShBqNxxGZTtitBoiTlquX7Bsw== 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=XJJc5TT2L8CBAwMHksOa16CHm7CWZpl0lX+059LDFuc=; b=dq8M2XW7RU0aepkXtAPFghAsXS78xWyILxkbsU03hx5nfAnUsymJIFGAZJNTAoeinezmi5OfhZ/URBIGL5y5l960xErOTKdQHocCDH21ThuKB9XTI7YpkC9B3or9cCCnorjNq89t5QVoie3dRQ8TnFIjv8Scye8upoPvhqmp8MlXMHSM2T4FVqEdFSWarli6SAuHmye/ZBj8Hwyz/hgGArAsyYkVpZoZ3TZrvm48Y8XG2mgvlW/DuMYFY8iLQ/sHBuX8zU97ThbetvZAw6bixGeFW1jOXwhgw1vrGxuC5J8l/Y0XIgVbQopCVzFlTwcN0Oac1VMib3/1YdRxEbYf7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=XJJc5TT2L8CBAwMHksOa16CHm7CWZpl0lX+059LDFuc=; b=31jJ/S81+oqsSUjbgKFmH7VqyIuzIF3W6qL5pJc3TtSO1F4yYit2OF3qWSn4+gn+RDqPQpZ73q8dh1pLK3ukKOzEm3EUJGUXQwaUkHfmYem+f5WphRUNgNlPPEQWLDJ7RDa2dZkOFHjOUlHMKpEN7xDyTF+eVS0KT63aIJjk/4M= Received: from BN0PR04CA0158.namprd04.prod.outlook.com (2603:10b6:408:eb::13) by DS0PR12MB7534.namprd12.prod.outlook.com (2603:10b6:8:139::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.31; Thu, 17 Oct 2024 16:53:30 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:eb:cafe::2a) by BN0PR04CA0158.outlook.office365.com (2603:10b6:408:eb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 16:53:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:29 +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; Thu, 17 Oct 2024 11:53:29 -0500 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; Thu, 17 Oct 2024 11:53:28 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 12/26] sfc: set cxl media ready Date: Thu, 17 Oct 2024 17:52:11 +0100 Message-ID: <20241017165225.21206-13-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E66:EE_|DS0PR12MB7534:EE_ X-MS-Office365-Filtering-Correlation-Id: 186ab2a4-3031-4f89-0252-08dceecc3a41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 8G3Kl8/BC2KYQSXRktFEmsH2vSfB6P+Mz9Hy0ZySvEUSisVus93GzNDd+uiEzEKmrPDdJhRKR02+bK+KfaI4yO/hoqq+yaUsnju+ay3jhSGu08IFaJbgAmNpvkGNR9u9ujRNkQmfMWkQktSLpQhpjnTmmJLtrvoSVBIjNwV3CRS2kZxg36M2xFcpgmJ9nircwwVDBs51Pbr82TuOu323ssjTfgmOu7+1y+dCXeVIbUTbZdVMRl9ax8DThmNygJkSUfFNvvlzGrAAx/WdCsN9sjDpJOWdsTCZowCCzdYgt6a7BMjOQOfDMplbLzhOB7OOVcisU7g+mTOcXlWr+nCGiO8DeVsnJzq+gGIXXVov6gERXcZJOU7G6gnJvu0q9Osj2WhytnXw+BXlx7p7d8TdXyMDPv/30nLJQq/6ll3Rlqs72IW5QxxjisA7WE8dNHky4nWPfpcQKY2LF0WMrmesXqtypPoJ+XOEKyJdR5M3W8SRnnEBoJ+VQmEJG2vICtln21OYaWEo1l2SeJU7Myzf9bnafCvIWmAiO2/WMAu0aA4AKYqa6143X6iB3AwWDn4cAaLH+IUqrrMHNmtvr+kZZ6NNgJKV1hBoJ2yLJJ4OAL59OzlUS45qsl78AyXnwFjiRx+bQ3jF3VT8uZGJru94wZ4nubv2VGfJkikvxN0ZoLV0cbitXkKYoeEdfP659Tel81572oQRLCkHO/NpLvmlmLXkkaEHGCp4Gf1Rv7guv6RD8TQlG9ekTTwggOqmjDYsT0tC0+uK+hmlgu2/jRbpKuH0ZRr8+AcW4whl5KVUuFmuv8oYIsrOunC8/6ZM1ivI8Yljs7blqOKWc6tGqLrmAwYMFMIENFpLJGfLWNCSrN4cYWPnEDIHLdY+bgImEuHnh6jSNNNa37qEiCKr+BNmOTxvuAjSoVtMgjuP8YFkxKJbm20bvkdVfICb1Qc0Hlun17XRc1hab2IR5e4eCDymCpl/5xVdRU28Z2FtfruWCUh9Hm5O3w7z7uf5aAvBkxs+XWNIj+YLlMh+L2vdH8cIBpToFGNCcAGXN78DMFmmPb857Gtt/09NNxsEnoY41z6IxbiWzWk/MCudAYV12YT3OaFGR6nTvFT7w5qOKEkMEe2eHiuJC7cVRXsH/Y+5s3LX/nAFj0zexPGS9NAPBLVb2BY7IbwocfY1zahwHyMEXGeJxnGYQuwa+hkDNXdFcncZ03s5IJ/ZDNUnbPzxxFHlP3mOAkhXW44rEVcWnJFGPHnlnsf76sgd+wICn+1l8FG3L4GG+V2qjfLHo7pKHZ9qMOnTTZBmgLuGYYYkEz74QWAVg+zQ/7Loqyx4u5WXjkfwlbhe6hQcZyFsc+u5ZNIDTMXUdGjEOi5bPCzjSXVACBg22uNqELQxxCHz0gF9HJI6U8sqxSkoBtosyDBTYXvn8w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:29.7064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 186ab2a4-3031-4f89-0252-08dceecc3a41 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7534 X-Patchwork-Delegate: kuba@kernel.org 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 d47f8e91eaef..419cf9fb6bd0 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -89,6 +89,11 @@ int efx_cxl_init(struct efx_nic *efx) goto err2; } + /* We do not have the register about media status. Hardware design + * implies it is ready. + */ + cxl_set_media_ready(cxl->cxlds); + efx->cxl = cxl; #endif From patchwork Thu Oct 17 16:52: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: 13840392 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) (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 E78581DF98C; Thu, 17 Oct 2024 16:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184021; cv=fail; b=p0k3+kHQZ+rnPcZnsKOX3IPhqHOXFUJFt/sR6ySyerG9/F5wxDQAf1NwKdPGBKyj33gqpR8BQ0qJERJf2TfnIiHPf1YcFYCzTx2u9KOqJLH37OAO+NDNaEIRqu+V0SPrJWztuUPzON/G9zOODKYfzhLEJje9SVJyUGWGGmYxf0g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184021; c=relaxed/simple; bh=n63jYcAcPl3haDTyWUzShLbuGZxMLhaviQUNbbzrGYU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LWHC6xQ7U2qoi+Az1riOnzU5PMdN0BdPKAn84ZBEZbgtayc96N9e7FA7yuGipUTOqu4D4RxAv4pBkEa5ac1LSGJCX9iyt9vxMHXDZVY6bFak42CwEKgPYMt6JwZLJsqBp31sqpQFobRKQ66x4dHSdhY84jM9gOvik6nMGRiqGok= 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=DFxJPfTA; arc=fail smtp.client-ip=40.107.223.54 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="DFxJPfTA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ufe5DT+VsNGHACPLgC6QjsMlR3VukDJPzd+nCo/5aEovibGbSI715E7N/jMXRg1akRXS9cTpu2Ci6X2gCIJoSjMNix/CCAMyUV1hOUAx5oT/vMRxfhTiwMNT9iNsXbGQugX/nL75g3s8FpSb2yRXjJQbSOMPG2Tue+kJcOY3VTI8V8FYhmKtW5lPhYGugVBexnWK4ynsECY45vAsbaSSqeINpZ8ZMxCzIfL1R3jPEvxdcKGlK9J5w5pqTuGZlDEhYSrye4T4yc+a5CUQhEyhtnmSm33uHC9kShtJQ0QPQKV/sUDfm9hMqtrKohw/6tA+s4Q/ImMBmMJi/Vd7bRnN3A== 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=O/l+j8pFtpZMccxBH6H/bJUnHjbDwjXk3POT6PqYYPA=; b=uou0ma3x+bQwTkEyzAutNpQGGuOCsHLFHsK3QBAgY3qij3ctPlo+u4cNwMIAR037/PqE/w7EVBE7YLNYNyKB9wQc/OHL7ymh3VfBGZtI8YU66QqbeAIiij+kSvakf3+Bw0XxgGz7qBmzl4vh1+j2DFjwo3fj98PBRgYI08nLc01xpzFH070aL+AypI1AGzNVfwkaQwFE6khC/hZIjf5DD5SUUHHWg24O1egtqU5aMJzRO6BjksGS3mqvKaWEi/3xiXkiILf/o9r7BYVYhsozvE+exI3kwGwf96ZD6YFtw5ZiV59qCJcd954stqtYJdB4igUsFayWfwxy/sltf9TUkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=O/l+j8pFtpZMccxBH6H/bJUnHjbDwjXk3POT6PqYYPA=; b=DFxJPfTAknwwz9wL4eh8qWYTjEpki4AFejyzkkpQSFiO8CNklGboJ0gM/T+f6KC5GxNZ8J7OdLuFuvoabvcR0n5PH1/JCWScHnnfd/w4fRjqZcnAJzv04mKEG1a+HEQ0GSh+3ooORZ/HJVyH1EQZFVmQINeGPaV4WzmTGhrBJ8Y= Received: from SA9PR13CA0099.namprd13.prod.outlook.com (2603:10b6:806:24::14) by LV3PR12MB9331.namprd12.prod.outlook.com (2603:10b6:408:219::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 16:53:31 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:24:cafe::f2) by SA9PR13CA0099.outlook.office365.com (2603:10b6:806:24::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:31 +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; Thu, 17 Oct 2024 11:53:30 -0500 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; Thu, 17 Oct 2024 11:53:30 -0500 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; Thu, 17 Oct 2024 11:53:29 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 13/26] cxl: prepare memdev creation for type2 Date: Thu, 17 Oct 2024 17:52:12 +0100 Message-ID: <20241017165225.21206-14-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: SN1PEPF0002636E:EE_|LV3PR12MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: f8a31cd7-44c5-482d-d356-08dceecc3b4d 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: XGGSTtUiw21/FW4aY8D1w38N1R3DHpZmkH1KgpDWtdhtvXcEkt3hDHz+gyrjib1nxRPf0dPAuQbvZDhjguaWXcAC+jRKQGF4E7ugGrFsjyQ+wRbHN613cEqovgvsweYHNPhtannPBeuE/Ih3KjEHUQGoWUmUBnuklFR1PZVEgl7DdbbyeKSjDAlxA/Dkh+lvzMBwBgXeWtDj/ypP46fgH4YPKcUuSZyak+aZQ8e6tDkzu85ohwBVjz1GcK9w+2b9Gtd+AiMCMbSWjuydyBcZxxz+UowvVSe88wQImCtH4BIIbK8/FhVjhA0sMxzh6iafIgz/NMNWgCqn6IbYvbGl/F0VisUzE0RXEaaHWqKMbcHZs3XPGur4LC2DdVgTYDyF2LoMoezimZ+xMxX1uZeS6+ZzjWbfEPgxfsUYo83RbNa4k3QcD1mQgcLL7AP3qWZc7qQZUgK77nB1v9iksjxM3ZSxrjv1g/yQn7pEgyPlzjGJLcYG3mHKcK+sDC+Ke/gk7VNmKGKwOIX9XqK2nZAlM05uSBaYV0WHucJC0f0w5gBnnEw3woLGUN+7NG9ujoVNDDsUR/+M2BrJbFruqDH9tBZKVeUp4lPcCVmc3EZE9nbGWq7hD0pRVrmCEjQkdF5vmUMVuubS051wEd8UsOba9xosLv3u+WLB/lgdTDrO6soLRZAXQSneyZZnxQW+jyTPJzx1w3z8bromgaXCE5h100F3pGMZ4kyO5kwXPabzT6EV23SaNszRfZrLfUdQyFjYMA8AGa7CkcEDE87m7ZYr1rYMZxUfHKZI8XfxaZqKrLprZ8EiCiDpKtdd0NNdjEMkhEUU1+d7dPMO8uFL/7YHm5wKatY3rr9s7m+d6b+pU8CcA5QHs/42L3SxB1/zuj4hHCSpsuXtBqqWYACWtX2I/uGydwxHlFRmoc6dljVleBa8jLR2oqqOj9i5XCjYSPUMu8XBDuD9qsi6BBlLxgE6umIVv23CAN1BgmjbsUmLNn3TUsc9YHSLE7LEcElCQIctJ27WkBbhyKj/REB8/gwLOy7QtWX4PDQvNqo1RaptaE6LCUsW9z0RqCCNO3aoGvNlzzLN6ZQptd/em9oHM72XHTHnvxAf8KhQhWBcsa7ucwdLWqmP9+4EiRWgHU4AHXuBIyjD4cPWeyXX+B0hDw9TjHPnz7tSfuKqfWjVOjuCVv3Y2MkQCZE2lIrr/uYaWGSSQyzVj+gH5jPpDYA8FaQQxVxsMlvHXt0tGGISF5m2zTEa9NsUQVG3YbsJNhVy7kQRCzQdQ3KUBT1ngRRl+tkejIqGEkdx0loW7xNuYvI1YWQP5GIqQoEpaMXz/HC7NdT32k41hImbVlDTKFK0tH52hsdDUN5Kp9Gh8+XIASVo24B9pNmWlKBEE2FyNftT1Jymv/dpBRWmcOYuFiYa3q3nvQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:31.4525 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8a31cd7-44c5-482d-d356-08dceecc3b4d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9331 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/memdev.c | 15 +++++++++++++-- drivers/cxl/core/region.c | 3 ++- drivers/cxl/mem.c | 25 +++++++++++++++++++------ include/linux/cxl/cxl.h | 2 ++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index 56fddb0d6a85..f168cd42f8a5 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -546,9 +546,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); @@ -659,7 +667,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 21ad5f242875..7e7761ff9fc4 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1941,7 +1941,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 7de232eaeb17..3a250ddeef35 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -131,12 +131,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) @@ -222,6 +228,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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index b8ee42b38f68..bbbcf6574246 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/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 Thu Oct 17 16:52: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: 13840391 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) (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 98F721EF934; Thu, 17 Oct 2024 16:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184020; cv=fail; b=lgg/SfmhRjtyBnbXPKy1EQGOtZdCZOoZKEfmgxCsJR50O3Tty4LsNcmEOoknNGlJN36Droyo6zW5zzCbPmofCJ7p8wAh//bOCcFbzbrYguYHMC5n0ho++nq6WZB+YsUZjdJGriaWIaX2zUtlrQVWjCtUzMHGCmllzyNemAYuSdM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184020; c=relaxed/simple; bh=FIK2Iqk/Ulpr935Sk9UH/f/JCSUT5O6j7t/vkwGhE+w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mV2S75h2sINaUozKqVrRLb7j8e59eGeOyV+x1+oqMGZsSJNGbyZnnU5198sEXMLYkkXo6yabinIkYutv1IWr1tytRf9dlvQyXEsAwWVt2Redo5xcVqVcu/YEIbNf3sXm8GMFLFkkMbLdW70AUpahWZXmjogCzhQ/Z3yNwaaaspA= 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=gWzN/tDt; arc=fail smtp.client-ip=40.107.94.87 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="gWzN/tDt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PIzjeTyOJZ6rM/4eIe/0LinQvp2A6kdtkX0eNCavrqAcMvUQ94T2mu24uOFXfDD1hk69I6u1B+sXUYkpmXTNJGYgO506MTMZbOhJ0DIzIpZ6Pe9ug3/sB3+6Dq7ougbUmCrBFjvF76p60RJuDSTFqfjJrxCVpYrpA+cVMMw2XeveDjmWwjt1kiRy2rCZG7W2z9A0zkIJhpfJmFVZ9gSYrwL2Is2yHhKTMVg5WOcmiEx3zcXuXpoqYDUBBuApYQoEP1VVXWPHWghiqhOu051dy6TiCXN8sdM1DNsyHCkn+lTJOs8cIfyCs7lojQ9BRuDwVPKb2khjwq+PvyMuGwGauQ== 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=lFcAd0gy0NO/qxSnBh+rf/nBw50U2cKicFOWCm+Ta3M=; b=bjyJ2CP9TgJW6KoBK2R0rT0XKbBSQp8efPTxfh51bp1YmAqzoPwHwSOKw9vxQxKYiXFp1LgpAGKNhwrWkn3kpuRF5jX6wBK6Km/F65uzZhTuBPUPfTOo6uieRQpcIc9E89diB7kbnV0s5ZcRmNuXvyYu5A0jc6suoTCxhyUOiGSWxjW9bSatri/xO+LbQwBMWweOedqpc4hNLz5VQPaNNEBZezShYoJH4fYAWek44/XtZEETb8esPBfl6uuKoOknEIn7Tf/gFbejv2CnYMhOS5EzNvseHtl+fRetrwmEk4z0tGQVZdU2J4k+tz0IXVpN4Y5YwJofj45KSQaZFH8gYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=temperror 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=lFcAd0gy0NO/qxSnBh+rf/nBw50U2cKicFOWCm+Ta3M=; b=gWzN/tDtF0ta4qQB4fYDHreeJ7kS9LatbtieviOZHEwGbN+yfmGBPKNAgr36E4rq/wPUtXIW0qzqf1L2E+M+DGzAiRwRhLOBGxX7S1WGw7c4eelqwAoPftQ/QxZacY/0F4cqYr7NyQdqo5T74iNuXIIVp4uK39MfUDeo8PAGw0c= Received: from SN7PR18CA0021.namprd18.prod.outlook.com (2603:10b6:806:f3::12) by CH3PR12MB7738.namprd12.prod.outlook.com (2603:10b6:610:14e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21; Thu, 17 Oct 2024 16:53:34 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:f3:cafe::ed) by SN7PR18CA0021.outlook.office365.com (2603:10b6:806:f3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:33 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:33 +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; Thu, 17 Oct 2024 11:53:32 -0500 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; Thu, 17 Oct 2024 11:53:32 -0500 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; Thu, 17 Oct 2024 11:53:30 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 14/26] sfc: create type2 cxl memdev Date: Thu, 17 Oct 2024 17:52:13 +0100 Message-ID: <20241017165225.21206-15-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|CH3PR12MB7738:EE_ X-MS-Office365-Filtering-Correlation-Id: d65687f9-c84a-4728-99b3-08dceecc3c4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: mEEept8PRm417fA5kObUQICyF6gzhQwRko5BWEaRav8v3n/M14W1mHh7ZpBTsaBynw/xsC8JUfzQoAvHU8ZkOCjhL+AdD8TTEaK6QmWVgZgHAtBooHsuzCsFq0Mo7YaWGvfLpeRVGUiVHMcrXFsxKn18f+9zDaxqaQXapcjiltfXwfFxvhhvCkXs3K+xe/X1e2rSvy2aBVXmmnV4uhbmulOKxiuDPlZfoDQ38nIzlbVGJzcTk9gZMKrDD8V1HJOBHp+BMlkpHEVrXsUvwGic48/lry1C0QjCq9VHlczTuqz5H43gyPpHbNakfjZXmVv4bn8isPKtTk1SYJZSAGgFicbnexv39KJgV84vRdsUXHRNHCXKRWNVi1xeg+xRi1hluXIsXoQjA8KBI4ifFTEpNYHTPVfZnDlWOPi+8lTLxMLt5gOzijJHuqwMuFIqhVcEUaf4Eipsa/VKE5j5RB7XZs4KSKQyTT9QcbsT22dqME0MHUmfrZZxbhHMebMDWfafdITwfkEViTJ3REyOS0iZU7682kv2p5lSjoTGsvwwF+u2KLVdgrE7vZi0R2Ud07yybFBQRF+rwCCWywb1ti++sp09kEtWFIBQE6wYloyXE/TJKD/KFwhqZ1LUXyz/Jxet0/gGDmxl5NMZJsRLxY5xY4UoCkFZy6+jLOT372f84ZNG9NvBiPQXjXC8hxsGv7wpfpbnYd/4GgqzaTPG8vdG64eGKBOj56Lea22MgjoiUPICuYvHT9E5rJVHg+gIOKDsMbjukiw/bQGwDoHxbGpe3DodsTgE1+c9JSNzvFhhDf6Ixbf1kNOwqnu32HyEs5ZbJ5Byekq3FkHGDT5q8vCE+XqVLrwOtkr3BAKw8BX8pW4lcIrA/kPNNwiWfPgYWrdm54llk72zsbnZEjD8bdvycSKstU/d1ZLfEmYt3CROVLgkvq7o/G1KuI0y/FzAiG85I/v6oQTK7E/VpiQ1C3wqQs7Yc3VbJDLLWPb3bBTO4sVA1SvMDcIm81DRo3+7kycdbseJT7EGWcxyxEIisT1E3ioV4eW8w2B+dRZq8eQT9HKpA2AwoKkdkqu3F1KHSX+UkNxBAU+tEz4K6pwtb7HWJ4szSSltJh6li7rU7h/oMvWb07pv+i70BSoM4FFlAYngXqfnab04PdTzjPm9rbrrpj19O+EqVCFZPbYgBx4n4WcJOOiJkX92hzX+CnJgBcoEquBFl7l3Is+5YLQ1K/EEK8FP+XVCodaC710x5IWN18QaQs96C5nu8ztf3GgdUrCM772B343FIbsD+bI2vYux7v9lcP/tj/WXcUxTIEg0UW2jiapC2xHzd7s5qgVAXnCQxXxjcHhKLQh8ZdxcZ+M0L9sF1/b2kbW1NLD1JPjrbNcNTYcRJNXMnGHCm5q4pYQ32sI+OyldYhorYb1th2cwwg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:33.1247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d65687f9-c84a-4728-99b3-08dceecc3c4a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7738 X-Patchwork-Delegate: kuba@kernel.org 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 419cf9fb6bd0..452421d71fbf 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -94,12 +94,21 @@ int efx_cxl_init(struct efx_nic *efx) */ 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; + } + efx->cxl = cxl; #endif return 0; #if IS_ENABLED(CONFIG_CXL_BUS) +err3: + cxl_release_resource(cxl->cxlds, CXL_RES_RAM); err2: kfree(cxl->cxlds); err1: From patchwork Thu Oct 17 16:52: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: 13840397 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2088.outbound.protection.outlook.com [40.107.236.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 587C41DF990; Thu, 17 Oct 2024 16:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; cv=fail; b=L3wcRp4HhmJrRWkudfKxM8HJddhf114Awi7ET1ie9xIkzdf4Nf74QpiBX1r+GDGSHBa7xHmgCycnJepF89iFZwjmpcwrz3fsNbqqmuYNTNhtiKmDaUMc8LFMMXqk6Gx5xbK+mnQRmhex7tDQne5solVNPQC0k5CXibv2F4Omqwg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; c=relaxed/simple; bh=u0Ax7XKvvEpgeO9/qOE+KJkt7GHrGBg5PuePvdlA5fI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ICA1DTMS1gMdoCUgTMRAjE4NB04EbszcBsd++DUkQ+yHRAEgGQhdIIXf6oNDqRQYN/ueq3YT/0FMfhQAfwTcUBpBJMZGbuemHmacqINJ9SGJvnFyuqCLK+mrGJIx/4w753Syw2PCld1eQW/px68roEQSotz9rgmWMxlsFHqZ5Ow= 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=O96ri26i; arc=fail smtp.client-ip=40.107.236.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="O96ri26i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=myUx1uGpJAwfGvNhSYWm2//jDZ0/uUmiDgm7P90WY+wEiP7KB+rQc9LPUdthokJ5kW0KwhruQWFhcF1zOS0TRtb2nj/7Kac0EZIwYWx3K4bMG88xtMPgaZYjmhgPdPq59teduuI+1ZHYDnzBqz0QWGUB3HDiuF9QlUGveXK7a7NFC5T2lvk2X00D8VZ50N8a4W7EFEbrX1/BPSoRw4WTU850cksUKrDYpTKhLsnsRLCBY+eWP8y7h40+woh1vuXwWi7pieJifYN+ZOkDGQ7W1LxU3Cimsp5YmZX/+7N3mRwva1sVnvYWrxe8JTtCH9NJwP5rZ6Rmzdqv2tIJ03gCqw== 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=M3H5DFia5RQBHwrK8BRzxh6+4UcndMsB9HFXJgQXCZ4=; b=sTL9dT4cXBc9tmqtm+EcpNvg6rFx2HhdcyKRGXAjDOEvCUyC9OMEyflDTNKCToz0BAt1AI3vS4zxmkJGB2C1vF2Zqna/LSpwoyuNu6N4ymGY1yvB5IAv+FXHztCpLV31V8akgTlVAzjmyzQWG/W3/w6erSniZ0sHd6guOqdfrn/OtKRPex4g3vF3KF8ACEw+Q5l5yHSIluswP5OIFqDD1Zg78lB5euOL3advACOHjMoymOmjqjTRm1JY7GLC5JiVxpYALIZk6V+92ldWUuAHHmHrupwdyFS7jJsw1h0x7+9blPmWFQwCI+EGqMgp1CMMTJKo9pA4pLWyrg4CE8QvQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=M3H5DFia5RQBHwrK8BRzxh6+4UcndMsB9HFXJgQXCZ4=; b=O96ri26iSL8BplY2MEBu7ICeKMXystEDirhatDw+ESkDH9Bi1eKOSckYQa+gVva/ZBL5pi8l7SzIGH0L4CKzAFg71W1PHm9zcaZQKxeC4oci14YST3qxSYBRmxOJLPEg1lFXnn6qvqi649Z3pnWx7/l1tnp9bXRminMNQB4TaxI= Received: from BN0PR04CA0160.namprd04.prod.outlook.com (2603:10b6:408:eb::15) by IA0PR12MB8352.namprd12.prod.outlook.com (2603:10b6:208:3dd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Thu, 17 Oct 2024 16:53:34 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:eb:cafe::f5) by BN0PR04CA0160.outlook.office365.com (2603:10b6:408:eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 16:53:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:34 +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; Thu, 17 Oct 2024 11:53:34 -0500 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; Thu, 17 Oct 2024 11:53:33 -0500 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; Thu, 17 Oct 2024 11:53:32 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 15/26] cxl: define a driver interface for HPA free space enumeration Date: Thu, 17 Oct 2024 17:52:14 +0100 Message-ID: <20241017165225.21206-16-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E66:EE_|IA0PR12MB8352:EE_ X-MS-Office365-Filtering-Correlation-Id: 4772c3f9-5af4-436e-f3c8-08dceecc3d1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: Mz1ucRUU3bov/Q5Kz/ZeUTGmK6IVZjH4XinLA96rCWSAk4cNGiZJN5ijXsEPUgvlt+ljoWIUECEYgisaIU8ku/pjQcTXpWCkUi9A/h3E6UXcYoA8twLN1RHDlbW1EDQSLgN9DFaDpGIadpVB7TSF2RUyb5w90aLZuP6gsF9Lmdbt7gOkjxFi6cZ6tXOr353zkvOMa0yu5HaS15CyX4pzVz/XG12yFRwhMHg9irevVaydP6yBz04Uar+mBxlcoaJaOZz5lBJWuJkdgnYN7Ceg2I1pddkV+aAF0H9c/icmctPdlbq+gdj01AKSonPboVCAu41WQ0EA5RvIErTtEiJz5lbtDqRWxTsFYzAHBnbgY06lqfvCef2n5pImP1O9242CkNTMQVKQ6DFybgjzQneg2nnHqUNRoedF2EGiixM+/87nCt39YEPXcTZuQgQFXdoh0oh/HM4hsaD+GktTGV4vVdaJ4ZimI399yvR1ohkbkt20NGjKrcn2QJb2MdcrlG1ayZsCHkZcQII0cxiL0gnav8CSNfTjbWynJy27ZvMncCIidG2eIuHc51rpjqu2Y1SsxrfPC/ZcmHB2RrkP7z59V4Feiz7Y+sFIqNr9pUxAndztsQh05R5uQAHeL3YgxG5AgSjGhNgR91nLZWRrA2BAh34WrbQ2w1393cLvpfPQ3WbwFhpLm9AxVgu/WF8DSITt/UoB6AxTLsYPruyerJJHT962KHn4YdbNsyBGhkjlVVYuEconKIEJ/nAQ4N2sCGtBqGtT7dRefpmy6xsauGHZPugqCz3XTdAl4q5R+sgQw3ge+yUHdGWEfSVaxn8eF5xC+cW4S7EDB5LM25ZBIV8Aqfvdnz20poD55XIh6Ko4QEHTSkpcuUBrj5FFiRuWs7kbrjqzVP/wQbZVwVFF5ogDuYIOlmrpBf2XzOvhwsHswZICm5zQsD1zTfzYFIEw3PlEujNqb2DZLX5v7ZtszJ4pr6g3RlRTpuINbv6MjVD3u18tS6rm9f00YSh2Ymx76/x5KOXbg0EYLY9Fvep+GwcReTe5zyZmbRwm5Upwi+m83SK36+5Hk0DwkkWj4SllmeSkieqdw2Fba9oN6GIoydj99mUbWBxs8hWCUklL3x/BSrw6AJK+CVNoQmcuKCLpN2CbHI27QNR/3Uexcek6LEZNa4Wgn7IzqbSWv2phSIpiZIno+EdZblxi0+Rjp8nYPqLEbknZgKbFhHcLssa2z2CNKKEnVAm4A/ZI1kerOQk2VIvS3bqTgd8jUfCXXnbkye/6aLc8OXzDkvE15b4bT0B0QpXDJI2tysHVseg12B8fXAYe5lk1Ymx1F/nEiEy7GxwUpu2X2l6q7Ge9s7q/ZH7BTu0EVCjKity+lR8HfE3L+XRNYwnKWUwEOHr6iAFnwn8uim0956WpMmT9Dje20SBkgQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:34.5033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4772c3f9-5af4-436e-f3c8-08dceecc3d1c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8352 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/linux/cxl/cxl.h | 8 +++ 3 files changed, 152 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 7e7761ff9fc4..3d5f40507df9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -703,6 +703,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 a7c242a19b62..2ea180f05acd 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -773,6 +773,9 @@ static inline void cxl_setup_parent_dport(struct device *host, 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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index bbbcf6574246..46381bbda5f4 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/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 Thu Oct 17 16:52: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: 13840394 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.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 826531F12F4; Thu, 17 Oct 2024 16:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184024; cv=fail; b=FW69nnidddyZGeKmUzLjugM/B3k2pF/tu9i5dSTMd6wKiDpT3HpHylx5KkDqzcoCqrcH6ZtARJLGC8822JJgwcQYgxUJCe+rjmioe+G8LPFTlLampWysUjL9xGeVOlIOmoiz2gneWO+aNFRhog9Kge7aksp9Me2YMo6CbIr9d6c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184024; c=relaxed/simple; bh=icdkL5S7Ol6GZtJcALdOn//EepSKgBuN65jITM/uoH0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U07Z5jfwdWkCfZaXwsHnGz/OTXpWnyGaS3yczRcg1nW1jOqz9ZSn7bUR27VKjllgXxoSQVk2fJoLXPzbVH8kFUc67exIqZ96+cuBvGVRkHjCYeS9aixOalb5WdizNUL0mna9sZWOJToZ4ZPHFJFpahwU7IBI0OeuShsOuhbqUpQ= 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=C3g/dXmY; arc=fail smtp.client-ip=40.107.237.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="C3g/dXmY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sGR034lGe7GZ/3qrfsUVcTXzuNWXvUx/HEu3xbUv5WNGfg/+48qhuOJ0HxKFXeurQSlskk8BMTs9/sXV70Gm5C3cJy6U8za2glPnvFIV99EoeyegiC3hPK3OZRfBgU71UDq6WW/Eg6wT/zXnQEdwoxB2BMz/2bhny3J+0vVH6cd6agF7jwGZpeZNY7Fuhr3GT8TeIr+9X6GckinnZm3xM+vQrURFB7lmyRoR+I3T4N9YSeWobUyJFuqu8BIf+tj1L/hLLDP+rtAvPTy06eWd2Zf1+ejm+NkDzMv4bH+4cqTQ5rgVF5NrIqiXPfVBFFwKGtzbbjLPb+KKMjVOLk1GLw== 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=Vs8MMfq6AO7+EmA0ZbDDxUFyexk2QUOhkTot+s0DIHA=; b=tedPiky4mReWO2OYNnUm3/0l/mSzsf/C/9GcAPA+EdWMxIsGYVJsRnpVOJ+iKNVTOY4sx9lWPyI5rDmwzyK69xe8vf72hc2Uc5v9gCQ9hgnBVN57pCHgkAohshjSdgq27+tZ5QVaQBfCyCLm/vrbT7qzN90BqZ7En58YYMzXQtugY0iUGzNKfH/HAxsuBugBJgMHtsdRrFpHqtPawrUpRbjjuWN8BwntNLG1IlPSqD0lb0XXg1Dp0uW1qaRhZz7zaCUfvWa/lMggn4HrGpSWQti0ujftCyEt0EM/1CFBjf8hCJyUaJFaLYdBOeE3fe3uZcTrr0ufT+x6Wp2kHsKNHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=Vs8MMfq6AO7+EmA0ZbDDxUFyexk2QUOhkTot+s0DIHA=; b=C3g/dXmYv7fPIwa1jmbKoggCUaLanStRYPNnFgR7TjOXtuinavJXzM3dAcyUqP2WWRtxsHZyhO67vUZkZXaaqqBVEP8QR/1fojBs8lPvuSs+SksuqZlQSEQhmbYMH0IQVb8kFccAeFeXmnBNmDD9Sx03i53YB4+4MBgCp7QJa/g= Received: from MN2PR07CA0023.namprd07.prod.outlook.com (2603:10b6:208:1a0::33) by DS0PR12MB8343.namprd12.prod.outlook.com (2603:10b6:8:fd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Thu, 17 Oct 2024 16:53:37 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:1a0:cafe::37) by MN2PR07CA0023.outlook.office365.com (2603:10b6:208:1a0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 16:53:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:35 +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; Thu, 17 Oct 2024 11:53:35 -0500 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; Thu, 17 Oct 2024 11:53:34 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 16/26] sfc: obtain root decoder with enough HPA free space Date: Thu, 17 Oct 2024 17:52:15 +0100 Message-ID: <20241017165225.21206-17-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E64:EE_|DS0PR12MB8343:EE_ X-MS-Office365-Filtering-Correlation-Id: 487df862-a7da-4fc2-46db-08dceecc3dd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: NBIWSW5GbD80caHIrOKCLsGPRZd6PME0kA835N1GjdNiCr4jKxMivpzXFP7i4190C5evrocgFZPL9/G+3hzSqgIoEHfztHQmekkq6yldqtB2M9OGYi/U2gnbRu9+96tjoW6oYRxemTbSm7nYVXkGGbQm+NZzM6TDSJEd7uO87EZU+Aac4Xx99x6OFRK/KVk9eAHsFFkOBp5RwS84VeeFJOZDLL8+anDGWWnwX7Hx8cjcIuDSABDIZUp/m0adV8qwbxS4qEkXmitaTTj4iQIJDWrYrD9mbwMtx4LDUxPdQkRF5iYaS3daRS8u4OpU2OIIRRpl5NxjRjxQCOQd47aCD0Oa0KydaEMyFkR9H7jSm8VMD3FsoIUp5/H6u6mnUDT8bM0LCwuLov2JkO+PCvSuuoFiuq2NXu1k+XEphYz6JYeySIYkVivaylsnX2yanCagfLkqbiTmh80cKlQpQjAabDMcVORmfoAR5zpy5/LlRSIUZ8PQP0K/JL+/jJpbl8SSJutgujRq7KGVn4H8gFeZU2Gbybirv0gmvQm2Fwpw9wY72KRK9SrTkNcUGehF0U4SFY5eWHb+k1k7Wlb25yuB2NKGhB/BhfwNDmNRUGaE1/j7TTic4j9NjgX72jxFSUdB1+e8XIYfXp8xcEfIYpHG8p1PPsYOkKyTgif2/9ZluTlEO6TTAr5ETPxMk5PLUd9rrqoF9Ombx4i+B2ngeTtljEGfM63NQ5OYHxpmsl8v7nXELAJFnZu+VrBXK00V05K+PRGUhwWoQpX0jbYPB0qCHLb/R3ZUWl8bSY/VquA46Eubrr0pcXm1V205BHLtjza2vxctFc0RoHU/Kg/h5qw2TbPF9GvCwy36zqdB4MGc5df01u8mYnqAtOFf0N5bZlmPH8F26hT1HS71WMyjwlp1nJUcgooi4XByk0bQ8qHXEq0DA0kXKTnJvh4epK0pmrCw4HGRWlp77NKd+Un/OhIBCJAB1ti55qtCXfJ3ssi1snRZ0ZQBE6PHuuKpQS/9uPXImyyHbELbPjMhIXol97Cdy6w4FVgAWjo+7GXQyrT3SOiqCu0RBXHhqiDY3Zw4qUSjUWsHlDU2e//mUaajXWRavCI6Tde1sbuRsVr5IPl/8CPAmj1zKrQd2fjxSAccZ7iKupmRTy6LOjJSvksDQPn0sLWwsrpXbGBnav7jsJoItficmnTKnUpUaS85UETEAuNGZlqkRKxLJXddHYCGczIZDp4tG8LW8SN2UVIqzv4daM+kElhUxhuo6Cb6oszfV/KMsg1mi185ndFkTzLRXBYkYMPZMGAs95kuZWMjh9DzGnERS7FzH0FROPI8NBtr12WyhY8ND9dCRk2pVAd35cjfxb6ssPg1pfDR22Mj6s7/jZktg3vtg8YD28EUwdYvne1T+t3CEOR5x+TNOFYWlRBx5Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:35.7244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 487df862-a7da-4fc2-46db-08dceecc3dd7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8343 X-Patchwork-Delegate: kuba@kernel.org 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 452421d71fbf..399bd60f2e40 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_nic *efx) DECLARE_BITMAP(found, CXL_MAX_CAPS); struct efx_cxl *cxl; struct resource res; + resource_size_t max; u16 dvsec; int rc; @@ -101,6 +102,23 @@ int efx_cxl_init(struct efx_nic *efx) 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; + } + efx->cxl = cxl; #endif From patchwork Thu Oct 17 16:52: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: 13840396 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2080.outbound.protection.outlook.com [40.107.220.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 CB4041EF953; Thu, 17 Oct 2024 16:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; cv=fail; b=t1zbmoZw1qJrhgYRzHiI3ZHgpkGxcLNPfSb5+U+Kmf9RtP43yIZ4+5QOR77BNf1Ju5MTCAh98gD5VNh+zDiqri4GlOrdvmvHRfuVLR8imsWIIjqWtfJKfyPGVERnJITt6tjNh14fBqO2klz/hySvlbtPhfOXm0Sw4MTfru8PChE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; c=relaxed/simple; bh=RnRHpAZ/605EWO+M7Rpf+8MKsYPCVKvSaYGAuDXvfuI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cYHNmWAaXCcwjpJOtRuehY0K27MzRi0JQvyY/ccn2N+9cSfDwUccUo8j12vncTZBtwt3AHRhLN+HcYPQ7d90bm+GqGqOcP11FDLQrFGpuU8rVOJs/WRF0cKEgdWLyzJZ5Qe5hASYRDCZrNGpTly8oFWyO0Y6H8VJ8Kn4Mu59kso= 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=3hUNtUAJ; arc=fail smtp.client-ip=40.107.220.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="3hUNtUAJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jcTHblQ8q1FTW3Ne2wrVEWyWjKkwFxr/AaXOigLsI2i03Aj2IdaDEQgfJ29ixI6J3vmAe4kUXfQUoY5vxp3iQQYIvecW9LqAFNCwQY2SkGDXzhP1Eebds5gFZuqnRE5KhpYYOCcZOFZFB8XSR6F6X5fQKgijKWxLvbtud3Wh/tJxqMa5n/Rh6GRQu0O9Q/mXJ429fmR0f2v8by3VPM8xpD7FBpYOuZHf+07NJRH/KCefA49quZApQfweJeWYj/dIhnSNiltPJnO23Aiku+kPEa/a/NRsXF7j90BuQF1ry8pl3EkXjFB9UetKlNZKDZiW8iY2L5/OEoVtJA5mjvzsXQ== 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=7rMEUtAu0d5VeqlvUN1s5A9zbcufJPS8L5rTPtHIOMA=; b=upFuuY3xVWvXyL9WocEiNGk0BzzmTdI2FD+MtqzFLNsuxu0kJ05hdaIrR8KB3ch9p/8s1ar8JZssjac+3fOIrozwRayQigtK2w3It/yPBBXzuReCau2RljrXWT9d5xM6q5abOqZGmaBZM6/AyVJEp3qp4CL6axihmMg6NI29fyyKHgK0RKUf8jhBVhnGEtj7RkfWhnFI0iPbOhiZ6Gw0Et6pW5Eu98vzea3dSh5eqhQ9n8g/+LgHjqxldBEaMirHfTAQ6auw2v1vv5pZM81dLmncPBBvoVt4lcnIZqtrFep31PmDlebRJOIFNyciswuTfRqOpnfXzim+eHl1zphVBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=7rMEUtAu0d5VeqlvUN1s5A9zbcufJPS8L5rTPtHIOMA=; b=3hUNtUAJ7BGKM6c6A3SCOX2sjR6BpQaSyc6qh9GqRa3e4tryhJSrL2NQhi/389bp9C9uwRwMwedxJMcY47lz9R+EM79+t/z85RaLK/A5FWAwT1y6jN0z8jY2mocKGs5vR4L9US2m4zAUUdzbMjorhdD/SsCvEE8urTEfnQjHbQk= Received: from SN7PR04CA0156.namprd04.prod.outlook.com (2603:10b6:806:125::11) by MN2PR12MB4336.namprd12.prod.outlook.com (2603:10b6:208:1df::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21; Thu, 17 Oct 2024 16:53:37 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:125:cafe::e3) by SN7PR04CA0156.outlook.office365.com (2603:10b6:806:125::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 16:53:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:37 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:36 -0500 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; Thu, 17 Oct 2024 11:53:35 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 17/26] cxl: define a driver interface for DPA allocation Date: Thu, 17 Oct 2024 17:52:16 +0100 Message-ID: <20241017165225.21206-18-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|MN2PR12MB4336:EE_ X-MS-Office365-Filtering-Correlation-Id: b1f2c607-26af-4dfb-1414-08dceecc3ec3 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: Ml55Q0N/XaFq7hec2C4Eshpwj2XzyF7hOwrNSvUB+l7gLagtoruyWXzHaeLfbtJLwN/h3a2z7czah4omqM91FNYs+K8b0gYfeM12bqJuxDOsjMi4i+faMAKw1AnA+JMw6dg+7hGPaWM2fa0ZaqQf1yN9t8VapxCNLjlwvbYvHlpmZbBQPNp+zZ2XBFYUarIgpIWCu0HV6yTR4ZWJ69BEkzye5HrzQ1+aE86utTwsMfdkOzjVvvjsd4/HBg/yGZ7BhkncJvujw1FPESNSSepCHCK15mi3dwXhh0vv/rMJKAHFzRSe/LONhb9C5VqAYnTZCrHyAt2OFPHyo6QdXCn6u1XI1uGsPWmngaFeChuwSOTnOM7v7glL4Aa/VImnmvsAxwWlTgOVmbvasfHjeOpEFoiEUtuv1/9Iq1rN6AF7HWDld9aR9wkgM7AG9Ym4Cn38OOm9gXOu41WzwTrAodCVx1lEmQgE0Zw7yEY6le+OkhM1NxtwzcLlUJ+VAAPR1rnK6TsZfihLM/PKo4q+UR+heSqhIh3KHA0UMA+MaQ9TdPbNQBlPLE9NHdtAI3aLPL1iawLqYC85cjqD6CvkOeDDiHSNa3RT/DV6L8jNHJ7Yb4v7SfrAV3gqpLKzaqKcJY4O2lxegcz57zf7aqw+tSs2QMA82zOER3/ou/rtWbeYI/MybCI4ELUiBbfSTBVUifYmuOtaE/yY1LplQnFmdLKrVyyJNkgv7vZoL2rToSI2xKd7Fh3Ss8xub0zt4GNSlK4jbtAqrOZev6eM1oFvbIsY86oEGnJDJZSUONn/LDZfiQ3tzyuBqzAM+o7LQqyrKnnBTeJ1EmBZmviWYQuAYrfMSK+n3cWWRkG1wQAFzCtffLz+cS6Ml918FIh//XfGyOZCe/n07cAdxArGqG5ol8fgqEzEMszpWCbPKHI+Sz9B3Quj5ChZCCLdFyZISDgR51GhbSd9YcLcxjk7KIu9UO2XQ4sFK81mGjimo56Vf8NvdC0z6K5Q3fex0VSVH9VM5FkEvfKiy99rjAOZdU/91j6u4t+7kwE7P9tW/7skF0FzZonvoPg2Q3nJI0j0/oxhcLW4++6LCAQ0lYxSkRYeo/rMYtjZ8FfMWRMeXG0t0HFu4afBf2rHNa+6LIehWoTrIXyOYtHEWJnrDUEcZb8EKSucHFKC0kvjIc7NamQUiNHN6OawNvZvFj4tcmMa9HcGO5OuTkfN/x6OEXFn73H0yuXZ3jhcwe5rySCrkA5Plq90UExB7xrLjVdMrSX6d9KH6Onbn/zA51p36xTCA3ZFTsydoNqQKKry0nYcxGOzvlzTLDqc+YGPrfMqFWG5OGi+d4ZGaiWTsRCWOZj+0TVhZRzZiTLBcACzNRt/tTk6DPeXSkJe23eNcJuTNlGzjwTM+V2lVyNQUSsnvFbS6w7J7fxaZQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:37.2697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1f2c607-26af-4dfb-1414-08dceecc3ec3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4336 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/linux/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 c729541bb7e1..d2afc9a1d8f6 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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 46381bbda5f4..45b6badb8048 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/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 Thu Oct 17 16:52: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: 13840395 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.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 C9ADF1F1303; Thu, 17 Oct 2024 16:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; cv=fail; b=lYdT3wYxdGUFzm/edLn/js6O/bWzBetR2qw9jOnD8Pa2RLcnyBEIanliCDkuYIgo43+Di04xCRZARGOy/I/+Gx0TpTlh2OXCKGs16g65PRuLTGymt2/Lc+TvQcIqNpUkz0OBjLqm87jtzqCCfAZfG3U0mvrTa+hoC/X8bcnLoao= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184025; c=relaxed/simple; bh=Ipqe3wA8z+L52pxyrcKKodzMlgwFyKNu5CqSFW5szRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QGNx3EErw7APrWcI6Mj+T8yiXMF3A5spsUIyY+cRBl6yJJ+iWNDzrsnqd0+j3zOhq5opbWv1mJExyLZgN6kUTEf24YLJwZwHgCgFIDCk2PW7K6GdwdGKbPEO1AgOZlsEEbFeXi8Sec8MhorxDqwFCBrXL4yb1E6yUzBcowjmTVY= 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=0dPUchpl; arc=fail smtp.client-ip=40.107.236.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="0dPUchpl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gOKPzkzwd8oCedHkgJJgN/VHqrEveW09bmtMQnSiSJ+Y9FVpXia/c7CXg/9/XI/L8idZUNaOym3z3YDi+pJyG31kupctCRuqys7vDi1Raplg0/eXdHuYTHzwK7PpAUvqwcoIXZ3URPtzZtEcO12K35UygnWA1kcy+/MBnPb4KWmsW+EL8qNtR0W5oe2RiZxFP5iRZt2YKFUq2ulPFm7kkZKXUIWUguOEdlsaSIZ6tNdBfq0YahcVAsH822+dKzQ5ieMyrcXhNJYKIlXSXFlvTamciUHp3EYVR39+T9J/X7nGYdeY3/xatbB8K24xqyaqjSJmKVgGEKSWB7lptULu0A== 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=uW86fDaMsv/Hbqo/l4r2emx1bzcUW+4uv6m2r8fczCg=; b=lPsetW4/qPsp+N1sBn/KC6JQy6DnWLB6/mO9/aUCFHeNyiKGPt6tL9cCPBkO8D29ynAkoGnrRVS2Fc/KuWpOXAzVaG2LHBNJUI4Y9D7MelREFStgswsWYwPa8rlwar5LAg/bEB2y6WEqZEVCOz/S1jXR7BeQB+W5Wy7OkqkKggoZ0HcAmFGMbbW52MwsGMuLEc0zMKkJbeEpqZEg/7H8/A7yIOosLoA5v6KKxIMRxnYMBcNNUfBDkT6adxcNh2HBJuQXN5vVbV3bUHnUOj9NdeopxKbD0ZbT082LPUO57rmNQgL1eNfIMuMwW8LF4DSC6/QkkKarnI7Wxw8qHUWtBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=uW86fDaMsv/Hbqo/l4r2emx1bzcUW+4uv6m2r8fczCg=; b=0dPUchplSxR6Ur/DhF++HmxVuqXFonQpXmieNnyJsnVki53d+SPywYkI1g96yPJZz/83tKjkDLIm2zDNG/hiehwUxAhtbzt4IN3v+BweQlAM9EKFwfM9nkeUK6GaOJvUAccHlrjI/CgGKqIBshpB/qvD6+iI9w3gOLihfRbFhz4= Received: from SA1P222CA0031.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::11) by PH7PR12MB6443.namprd12.prod.outlook.com (2603:10b6:510:1f9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:53:39 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:2d0:cafe::d3) by SA1P222CA0031.outlook.office365.com (2603:10b6:806:2d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:38 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:38 -0500 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; Thu, 17 Oct 2024 11:53:36 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 18/26] sfc: get endpoint decoder Date: Thu, 17 Oct 2024 17:52:17 +0100 Message-ID: <20241017165225.21206-19-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|PH7PR12MB6443:EE_ X-MS-Office365-Filtering-Correlation-Id: f56c3765-807d-4535-5951-08dceecc3fbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: kdiFcvNm2Ycl/U7REY2XWanQqXvFsZVKYvGuTOkIBqzv4Mgt/XvG3/SlHXukh+c6RZRF1A6yMA4QYOPAmODUAlta4fSlGZT1k2m4p/GbzGIMNqxAONSkV92GehWfkhMy1gT4ILLC9t3QVqOK/kyb+4mwI+ewcg6HFzRPtA8N5Aj8wO2jeYvq4H/rcpsaLVXLM8BfxkqwtjijQbe+fX4jxXfflnkY/SI9YeE8pAgwDdlzARFmRSidKj067WBtvLzyZzt+LMj7h4PAQZ6dHRhMRV/ZV5oForY/0xNK8MHym10oS/GfLjtnYWVGtwcY3aMHMifZiLaQay+c+cLIA5oOOda8oKOoAm8wFlXWPcIre+4SMAHRFehmVjTJjPaQXpX3PNGU0eawjpsyMJBMiVjDOAb3aBofSUFzG3eqzA/otcK8cSzIRmU+Pj8Dbf6BCJ4QUmYE6FcQ9TfLNC7WFbpSGkwrzlQimS5WVob9RbvaWUul2rLijO+MmYrFNtKjH9RH4li9r2S9WuFyRCmb5MNaFtwA59d9Qw7koN04nXruTltoN0JQK+7mViiJDIy1tvC6I6CkETSFcLLmCnQw4wCJ9kkjYygHtyJFmkMcDX6IZcnrYdnsrGBbG/83KTiJGjSCJSd2i7V3qOuSxISBa9fiHmMHq4bCHyqK/exFqIeZTsppuV2rpWjtMnEDh9GzlFK7JAN+mTIq20l5/GpnygoTc+uahY2urwGki7Ffg3/sfPqg1q5V7FapPYkOi8BzVPllrpC+Bq3H5yq1vc6/bqY5N1i3C8mPZTQ98v0do01fLhjU4eGnq3xt/sKG90e5UQJ7pe21kZohTGWQNe+M+46QPURNAy7z9YcajVFSlyf1lq4ODQUuzgPN3E53g0V2GFq7aufCh83kfr4quNw7a/vvUbzpkqhUe71zSmH/FjnyH/25BYBLBF4NxFJM+T72y1/bA/Q9bwLiwcdOGsUa3cL5PfAs/S/LEFVWs9Jz24hyyLh/LkLojjr+BKzhp8w5WCu2H7i+l40AM2WXyuoAWcxZy5m5S9xU0SD18PjN+Ii9mpJM8m/olj4gFN21UKjJvfnKbY0hqzdB3sDmKTAz1T7n9+ODMZRfJ16iJPUjVfteoyt/ug4Kelz+Dn3vmFWnkSaXQgo6B13JvBIXjRKdOsEruxrr4iyiuFX9elkj7SvkRVKv1aAP/88PZsImAb/PaJiCeROk1ZV1D06Vot5Mu/adxT9fDDzHWaIcTX+NKAZJwAc4KZQwg0jXdIywf3OS8x9IG1RD4b4uHt734AAUPRE+H0A90Hy3qQ5lsIvO5FGvpSrtjlCl9WskT4nsu5aQ6V12b+2YndYRs6Jl3JXZ8Acx+hQ2jyy4Qr9biGkGo+31DMpxKmnF2TKNhjaRKm50ybOvlMlyGmuz4VJnC55SFv9nSQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:38.9033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f56c3765-807d-4535-5951-08dceecc3fbc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6443 X-Patchwork-Delegate: kuba@kernel.org From: Alejandro Lucero Use cxl api for getting DPA (Device Phisical 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 399bd60f2e40..c0da75b2d8e1 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -119,6 +119,14 @@ int efx_cxl_init(struct efx_nic *efx) 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; + } + efx->cxl = cxl; #endif @@ -140,6 +148,7 @@ void efx_cxl_exit(struct efx_nic *efx) { #if IS_ENABLED(CONFIG_CXL_BUS) if (efx->cxl) { + cxl_dpa_free(efx->cxl->cxled); cxl_release_resource(efx->cxl->cxlds, CXL_RES_RAM); kfree(efx->cxl->cxlds); kfree(efx->cxl); From patchwork Thu Oct 17 16:52: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: 13840399 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061.outbound.protection.outlook.com [40.107.220.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 43FBA1F6660; Thu, 17 Oct 2024 16:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184031; cv=fail; b=Uw7pmY8ppmAPCd9VzqsZUY9KbW9c4SvBzzCAEKIpN7ELV43FtnZichxb5vSPliX9tVHjnmslEKHyoJxrc2lg+tY/yONh4Q7XjndN7zdzAuYgR9Vx8qZAsi/7Gg9irvB/GbIpYmU5A005Y2PKNV24Td9tiMZUwWj1PYPRB7zs0CU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184031; c=relaxed/simple; bh=kC3zwSkMiMJfJIJ80LLz+0mnFiC6EarwLCNGbjFo0f4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JjC7+J9bVOnX63V0DGI/KMTgT5HoP6ETr05b5ygzh/TF/nJ8SPBgLa5CHfcWWaKH1BwKRyu/tqCmRYu17m2v/rSus1iD2ORr/3LISP9axiBuJfKSrmya3w8Ppg4Q00FDDjGePnZZ1hZhqAvg/hYU1vzXLwVu3NMBgt1iTn2ESYg= 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=KQ0RAC6a; arc=fail smtp.client-ip=40.107.220.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="KQ0RAC6a" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cbm6tiIeuOm0clrGZWr4zuB3IkKsNzMtktKtvLWUrVmsQG+qUkgjbrXtE8f45Wq1lLPxf5rXfgVFXQkYzUsN51czP0DnnIuAc5yCfUMsqIvOUWqip1O8ygFqj/qoYY4l5akqSO/chH0h2O2/zWTOa7Fek9Fk+NCaZvwJmQ6LySntqImkwOe/24/L6d1M7vVCS9aUFVSRTdO3wdEgb97F1DlVRAzlrgTsxmd/TwwUrVsqlPnhujhYi1P85OTdoe6ct7hNyOQuEP9rIcpdghS0DSITzlIKmLFkGlBm7WLqzMFgd9+tukkoIWoacIACYO5soiyToLw7pXZkNh2/1gCAXg== 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=IVVa3CcH2ioehlzDdkrdCMVmsuz9Zsn3xryGAoKlF/I=; b=R8EICJTvo1l6WsyxuYAA+v57+Kjl6gaZrkUk6MeZBDclGb3T/YLT5iaivNnOwh48wxkFUpBa0TVVO67hMKcEtTuGdGHlZrqq7Q5+J85O5icUaOd128nYP+HCCuUoShIq9gmZtZgs24DBYeIUCA0Gcj1O4wQDGpJNF5JTxnI0g1hrC5c2+BQnwf0loraPETpn41xibjRjWxwKJ/DcjU/uMfCvtfgup1UxIrFdCHeSHpj+EtDaQLqfANJgJZLC1WOwY9X5ChVbhtWZhKwvSAs2b1WrEbbe8JlJyc1RkAehcqTjXVLJ8SJtnF2taru94oArfMe3xK6JW0jAFkGYR5daXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=IVVa3CcH2ioehlzDdkrdCMVmsuz9Zsn3xryGAoKlF/I=; b=KQ0RAC6aBjugdx8zWy766owTIJ7MirvDx/PBr8wMHnl4vX5q6xW6kDNyOqgnBIJ8NOZoOWLBv8x/A+s7tiz9ONFR9RhwvHAWtq6HkK1I/dB2S58Oc4sp71m3Hq4dvF2gjog9YE5RwbuKsLjlxXTIdQh2htwtMK9ty3rjPIXCjow= Received: from SN7PR04CA0109.namprd04.prod.outlook.com (2603:10b6:806:122::24) by LV2PR12MB5990.namprd12.prod.outlook.com (2603:10b6:408:170::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:40 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::e1) by SN7PR04CA0109.outlook.office365.com (2603:10b6:806:122::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Thu, 17 Oct 2024 16:53:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:40 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:39 -0500 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; Thu, 17 Oct 2024 11:53:38 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 19/26] cxl: make region type based on endpoint type Date: Thu, 17 Oct 2024 17:52:18 +0100 Message-ID: <20241017165225.21206-20-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|LV2PR12MB5990:EE_ X-MS-Office365-Filtering-Correlation-Id: 61c95d9f-6fc4-4a3a-6b80-08dceecc408b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: YZfZZaQZK6VrzzOICea0lVG1WLZum8Xzm2kGtW7ZiIYbkuRWkVmARtUpyR87Q05YH0bdTJ1kwnkAlWAwG2NqaKDvcrcHpZ4ld4WWor8lKgUgiLWVIVjguuuib2nliavlBufDTNIRwBDstURt2uneTeIqHUVdFufeN+A64cx0PkzD410ZkCne2E/VS07BV5jmMarKD1yEIDagSxqRW7sht9JrdAQSpbLDvN+daDCuYwnas+iCG+0agkfLVMeJQg+rbCIhavj6KqmS+X79qgNLFwMIgxF90qvf9oZZGGKnpXAZQmxNeiMBqa5p5jCULkjMV1rXHf8ogtkhvm7NQRSFfpW12rsob2Y9qoQLu7YM/vHCoB+vDaASUgIrnARHHLBGiQzsq1J4mSBVuUraYOO6yZ2MIESNc5+hTmqj1xoBUwDV6jM1Z3NHjwrvVvcQl/UScBfcPhgL/UO45y0Xz2yHtyBCpkESCpgMLAjBwwhRCkwpWmjfVR6P3dLYAhnik5RiQlJPd2u03lFX6rUmJ/Kbg83S9dnjVvVotsWdRtRm/GxIdUSYH6KThB60aW9ZLIGmBnIISI9V2xhseK+vPtRTYdzlzTxYvYi+JFzQSQw6AXWOugmUSgdmbvFXhUviEm9mrjnPV0s3vV/Vn1GDNb2BNJViRrgcg5DDUID05GzOu1EWBvyFtaje4Z/fJKhGpp7kGax7WXIViUe9huAUDjKtG+2UJFEcekCq0MUg1FVImm328p+GjB/6jRfDp9QqRuOILGx2KzcsagcC91v+covkzi1MagQBvcl+2DPQx7mYpfPdu9eiFJc0Y9ObRXRCOqUe1HBwfgKIWYYc52SVYe94ZM//DXW82UF3u4OR0H2uIR7+48y39SUUsuPf4d1yR75QWe3d+UD9+fFZOnxqAumpJMLiPWGNNXiY20o2PyXya3OaGjsTwOpCqfWte73rfpGMcC+4Jqd598OayRdBX5fZVDiza9Ri1TR9Uf2jR0blwOFI2KJ7zuPkX46FnSnAkeD6Fd8uQyM9PZu0BKQ5FRGiYnzhT380+WJ6EScKGbqB+BpTROZkoAPXT637fYaVVDkwJp3M41YwlPC/Wchtk+ATteH81UeOm0hc91CAKIYh8mCG3tS6VJDv9oCBcJdixC43xajD7zd9z9B7wnYwqeebqnOmWTCIDgcurm2gz4eReY4RA4r11DTmJdJ5KQnGID8ipgaaQGeCwUz7zOtvHcjjxuGzUVoc9Fw+hueISCOrsba1d2xtXRT7dXfertl/YMQypRvNV0nZffWOA6kfpTNs4Q3g4PHWOl58twXKeozGY1yf8bRz1DVjyfuaP1II6GFpuuqvItR/Syf8sYCcg5KDWfE2NVwjV4jbAU8vmH8+lwkd2ULaUOjyFlJ2aSmPRbJKBE5caDAhwfKnoLDGF++fAQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:40.2448 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61c95d9f-6fc4-4a3a-6b80-08dceecc408b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5990 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 --- 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 3d5f40507df9..5c0a40fa1b10 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2665,7 +2665,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; @@ -2687,7 +2688,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, @@ -2702,7 +2703,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); @@ -2722,7 +2724,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); @@ -3382,7 +3385,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 Thu Oct 17 16:52: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: 13840398 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) (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 148581F584B; Thu, 17 Oct 2024 16:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184031; cv=fail; b=VdmS6jRyLirBmRAS9sn2MiYZwbgwJdnyYj1MkVSFQ6BN7IQ4COZI2PPn7jFAqccavr47cgVBuFRr1eg/cTg15ywG7LKqwTXcOvCLfPjg9yFobpPIaQwyWrKc/MzIiZRhIe0geZ12Cu0d1k+g4dkVuahUthWtMqr4cJvxaQT2CaU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184031; c=relaxed/simple; bh=8vM5VpB18hkW6OravpFQzAfR4Qb44dsogb8LKBkuddw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GXSOF6c8ylSbUbrCBnUlqSHj8r+unPYSgTfZa1SiG6RQE1foRMA0snQmqtFnYrrsHSTftbQxkFtI/ietBgjeqsfudw4Vag1LfXEJ6vd8ckxW5ZcirQgmmTZB7Ww9ORw4/KEdep3Mt3Shb5Cu8X2W0QtboAf0Knv64LafEDZ0KWI= 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=er4vurph; arc=fail smtp.client-ip=40.107.94.89 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="er4vurph" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tYgfDerEDBclQCwSjdX9N842aybJpYTSqRu+xNIcPZ7lECzPAQiL5fOUORJ9PvPAYkYxqisJSI3RoC2myO+YWUC1ULewdPEK6Gi5a/d2xzpQ4M1xJUxjtZnhRSVqd+NGxHFsK0+AKf74zL8Mi2weM7CTofhd9LKRN/XiPT60ZTNggwzvkbNJDGBLwhN2Dt99Xtz1ISRxkUpSe4BIzWy/aaxhPwASwdy22rlWvwA1DhAnu6wg6I3OLB1xclZyW9vvigsYQpENphsjKSQyTm/Aa2DMR6fNqHRY/86hzq4VdHWmNKNHqIXemq0YRqMpUM6heiEN4Yz9drLNSVTLipmbNQ== 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=l//icrCu7LhWsVrD6OjS2cFsu8bUGAodFWVrjIn1cZA=; b=Rr7eqfYkZr/sgbt56SFYcOIIfa9V8OWPjIO1S7FzOZCG+xsuss9hAAPz0OAisbY02hl1itXPFEVgMp9js5Xawn7cUNBB70YSDK72Eu6WACFFTe/ORMwrTZdbb1uqtWuMQcr28hNp6By9qTL/hi9HEGVGvcoIyVXfPUktlhojzFbH7718jUWxEeW8JjA1jEILwZE+FQSaRJbyqPVITyULZ8rfkpYILU5nYhmEebW3QnFwn+VxX0i1qL4yMmEk5IiliJ4esikKVnH88YQm8I5c2nLcpuqPNJmCbvRXWA4E+K+5OvSJfskMo5Vn+PGoR+P7suX7Z9Ga/vAU79GGvYCIWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=l//icrCu7LhWsVrD6OjS2cFsu8bUGAodFWVrjIn1cZA=; b=er4vurphzTxS6PTnIU2WSTImN9pMts/LE18LVNMIo49UA7gDGJFt0rGS/jSFhsNEi3dqlGaRRSLvNqd+WX+Xl8VqmqIEJ7FAsoFxgzM/40CTEOqIvqGZXUVwrBgyVEVOssU/MRpTLgfF23VGhm7bgZM/QEdfB6adAFADTY8s5Zk= Received: from SN7PR04CA0107.namprd04.prod.outlook.com (2603:10b6:806:122::22) by IA1PR12MB7541.namprd12.prod.outlook.com (2603:10b6:208:42f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 16:53:43 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::1d) by SN7PR04CA0107.outlook.office365.com (2603:10b6:806:122::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 16:53:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:41 -0500 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; Thu, 17 Oct 2024 11:53:39 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 20/26] cxl/region: factor out interleave ways setup Date: Thu, 17 Oct 2024 17:52:19 +0100 Message-ID: <20241017165225.21206-21-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|IA1PR12MB7541:EE_ X-MS-Office365-Filtering-Correlation-Id: ee1709d2-75f4-41bb-d6e9-08dceecc4179 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: JHiXkF7FwZuJ4CtDih5KfBD3v5yu7mBidtXZZydaNF/HRrmEGT35aR660hObb6VuP/sMVe85mP2zmARrQzDKtSaDDoMFcy3eZQEj6ZLJF/3y1y/MkwO9TEgxDL+wCunV5UEQ08Ad4e/xkHURjG5ZgoDxr2acrzEKFrhJa9+7Umr6ViaythcB8EQIwDlyuNVuUs8fNqSuFGqOKrq1oXtjTI6zI+omLa79HwMugikq+9ixTZVgZNsDZJS48TpE/PFX7fyPeNX6M+5LTVmxsnCaqz4q5icy2DUfF6JxIWCF2NtByYbY9BfmEPlxt/89WtL6/9xSTl15A7wVRHmrJhvT5yOlYGWNvEQuyNcATIJfiEUR0Va/56ttAFHZ8s0W3fAIiwSoxs6/lqgKDwEJGh/oqCe4xubXwrkKO5NZzpbNJSJxvKcVaHJnHqORITwuIugZzI6tyOZKXm3B4fk8ieV3ssfwyzeRVYVSg4rPS231J6Haybx8afugyoYbq0f47UCS+Vs6OXFad5JzRt4AonnvnANuYZtETQWR4GIRquJgxww0+ZEaCkGpxlACZ8pD6d1zzSnfzPP4HRbP0MtldrEc6pFuUvCSoJiz2mCPKUtiVylDYlf1lxFBaXj+UAegPoMJPG0XpubudPG4ikEEswZTGbuDXn37JWlFArkJrWoireKknd6TNZZwJiqiRWrdrfWtbpNG2Zdku1rYQJktDf5HQ/EmSKpqZ7ojq7zfz3IW9ycjVWGR1vXfO0pkKqLHkTZ85ZsYbsFEtQIsemQYHHmNr/lrF7zSMF7wu8/Xj81ZzX5EIxEiKOpcQYKPKTdP+ES0nlYczDvxlLoPQVwAQY8hrVtJ3nd1E2f2mTx4GSD6lvPp1ZwRLHz1jeBad+7vUPOOXtKzXjQ5ct3JTEZ2FZMleYp5lhhA6og1er9qrby2icqL8+Dc+0/kOiua1F26s2V0Oi8GgD6gctRu7fPViRScX7VRWTl9WOj2fEK7VJ8pox+KV79ptJZFVmDbQ/a4X2/aysoVqYGh8PZ95hCk6aCQdqNtEOskMhFaFoIR8Dtx9ZrXlYK+F6bmyXmd4r1W0zrPgYb/OBigHsZw4DeB/dPHwH84vOsU02ImPLg6ycr1hx1HuUBoCSSd/sfBB+kNNQCy0OL1TQ1VPxCkbD97l3DJI2evSvkKN7nbli+tLrJZKbKXhdtlAi5lbYpYVy12QT5f2+JAiIf0ksYy9JuI36d/JbGfUIQ0hGrIk3sS0Dp9X2YKrMVtkHQGgAYAntul5k4hapXUecAflNr4U/iiYbPYRkrSN5AhWmv5V6v2VWp8Ym54xH2M75yjrMPzToFM14NOhPksqP2e4Gymx0bgEYjSsviq2y9Tqz8PVVGSoYVDbHPVJmqaum6bFhZrmXYLDTvmLULZ4UQYGv9uDOS217BPiw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:41.8073 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee1709d2-75f4-41bb-d6e9-08dceecc4179 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7541 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 --- 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 5c0a40fa1b10..ad5818fbdeb6 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -480,22 +480,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; @@ -510,20 +502,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 Thu Oct 17 16:52: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: 13840400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) (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 515C21DF744; Thu, 17 Oct 2024 16:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184032; cv=fail; b=gdW90slkxvbhllKzpyX18aAx7p/MmFlesMLOwyAUW/Ub+9+7YSE2o1YEYSQype2gwWeDKhDbqw5Ucu6asr+xKvVTifCUg5yJTpJukc75OLuQs3QPG5jgpbqMjbsZMoVlhvBIGpIH/xDa/flPP4YEgsKpL4BmbC//yIzVZrtDBEc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184032; c=relaxed/simple; bh=eJ2d7z6xaopoHCaA2c4rgoGOZN/RaVXeAn64XMprCmU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bRBhCnvhkfo5o3R+/IAcUIJuMqua/VA/0A0Li36ngl61JUrZnBW0qb65LV7Th7AMEmyw3J9IqtB9AaoBkfLme7OVKjIcYtz3tYvkX2c5ZW83endvQBveNASw/Y7A8oPGy7CSHT7kCg+M8H9ICf1+ZEPBr3r6mY1RUCH0GQUeKY8= 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=MntAbkrL; arc=fail smtp.client-ip=40.107.243.50 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="MntAbkrL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M3wdIqRHMsYWywpIeGmjzn+Xi5/l6iJDM0TMkxVB4n1EU++ubNpHEU8m75YaSUWniwEKceZtb380s2CHA7zWsl38Tfl2FhsUziCrqrTUlOroh4s1aHI3G4H02/IpohqZqMToqgaGqwSLeYtnlwjLzAA0v2GoBxq+ySjDGwCFkyhDRkGAOKQvJKt+RyuYDWCZ0PtvaFpuDG3LAIk646IOGylOsgPVhIqOhUS10g9DQDc9/qxMWLO2qCg8PdZ3YfYCpbGkOi4lA/Y126u0KikqlJCfg7Q5Zp5m6ijA6EI9OJTFsu1af147rGkfCWy1aeuSPsLcJ2uEjh3FI7JO7VePkQ== 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=6w+qHnk01yle/9U0lXXfCFrmvkDkWu1kK4j4xiNcF10=; b=FDPcihGEf/CA8LeNd7YVscDspHUJU3Yyeac1eaFf/NskQZfczKRkw+0pD/FyTb3K7t+F6g0YNMQbXpwJlZTP3DXM4hc+DE3ncXuXapensvZzMOsUUiDDeL4UV6MTcpfG7HFJ49wrQCZvqGKIant4FGNzw8fjvPIh+eyi6/0MUJiEEuuSMb7z0xxS7FeLyytgWi2StOFGFc9Kx7GbDB/9XfGIsucqBlnOIOhY/2j5UBU99rLcs+66Gg4wE9ZfrOTb5++5MrnFqAeYw/Wqob7g00zeP6hM6y0MYPSSlVQ+mjgAbrOqTFgsg8stK0FlZBpj6Km8Ktq2894XdfD8zW/2tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=6w+qHnk01yle/9U0lXXfCFrmvkDkWu1kK4j4xiNcF10=; b=MntAbkrLzwcwPbQ5UYOLSqrUF9Nn5MV/QZEXVaQPvffOwJ3v93uTp1G08Cf0uJrS4Nbw+AspJFtlgnSP2NxCjP9NKHjOKkVewgulbQGQ8pMGIVN79zIXnrD43gLgSBlIWp4VZi0FTozMkWcJpCM8uPLf4khx5u4BDrPO66L0QTI= Received: from SN7PR04CA0106.namprd04.prod.outlook.com (2603:10b6:806:122::21) by SA3PR12MB7921.namprd12.prod.outlook.com (2603:10b6:806:320::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:44 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::c5) by SN7PR04CA0106.outlook.office365.com (2603:10b6:806:122::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 16:53:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:43 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:42 -0500 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; Thu, 17 Oct 2024 11:53:41 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 21/26] cxl/region: factor out interleave granularity setup Date: Thu, 17 Oct 2024 17:52:20 +0100 Message-ID: <20241017165225.21206-22-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|SA3PR12MB7921:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e15d71f-ce8f-4709-792a-08dceecc42c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: +xL8PwQpome6MHBjQ3nEU+urO7vCZutRuZT4WMnV0OSTKQCfYBLtUiI44ftszWTDT9lmpRKjx/OXo+09KioitQA5MXm4qdlqfbcqi2Jxj8egxpHWbxypZs9xeW5tXei6bRtF2vHKL2Z0Xiy1nhyYugo4cDCC4gP8e791DCa0Xs7AX3iON+jftdKLrcJLMmrrxaswz6BuOTna1z5P30j/yLv/sUf6BFDdCTXziu9wJm9yIUArM93Uc87M8gPQ06RFNlCutthm7cCyZA5p9WTTx+dZTfEN22PYk4rfaC3oWXVYfIlFDuqUr64KAQFLzLy2Yg2D4QPq6I28porz3MrWQ2V5JY5mE9z8mcPUkMSVx0xIzlh9AGLPWl9zvkcROIQHgqA55KMeE4v7SqxgmkRIe19rpVfeZC+rBlndyMoPYnvnP2P/5QOawgUx+ciMSpxkefbJYZ3CSdV9xXoo2/zw5OoSuQYeK15ejdVrg4kOkeLuymIwsjGYKnEUf4Q8cA/E+t11rg/YUwtQawDmhzPOlehdNuRa/dO8+aTtrAduuu2O5ZsW7wIIyU61w+qo9kADiGtYFPHzs/gCH94vp55mAaiNIw5CoFxxbuk/7oEPyb4UxlYrLRkrZV8z4ztjDU89FQ4juxlDmQAlgf5SDGnL/tgw0EwufTWecZY7F2ZHbxX/MRmnGg5ADATWQtWhlMlOvpvdF0Xl1ULSJpWoecRJ24nNeva9j2ax8fLLaGJQA5IbE2/hXamrC3/hPRmZ4/j/dLKLAV6xL0uEy6EdQE0az6LJp6uXWsW+gmbO7NwyRAbMQe3Q2GW8G/BGchvKLAccK8x0OyFC7FIxo7jCEAV1VC78ux4ck9F6sLAfouxiMGfega1rnckEG3wPy1dLB//4yv0CaCwqlknd4KYRj7AWfn3lXSaKrQOxePWWr6UYyvP1UlOlV0fnrswLdymNRQysBDq1h3cNs99FfVjJEBS0kmclo48J5kO+mfH5SP0/iOQPm7FaOWkpSEMMspNAiXxx4rOoxP+jhO03kxtRYat5CKYVdGDKblrN8VVhx6yZiXIpGECVtzQOiDNxVVqGbU+EVOkyXeELynC/G0GF7KGYdUYtiCetkqmLk9i9K2UWOYPgxlrT/SsxDI8onZiv8fO34fwxGwIq6wafahfk63wcBIcVlbbp/Ky73cPdWgv5s8YfY5395pUVWvz6nXGHWpr0Ryw5RDpe+mzxZ8+/9rpHowNIt6B47tBhFpTwX1yAe1fQ/Xa+hsL2WceotAc5i4kuGMMdLVYvbiYUfe+swcdrhVWrJ2a1dQpULRo51nkCXw2rU8WczqXsAcBbLpq8yKda3+RtIs8XPWuyEK7R6GW3mcHMj98kltlBROBG9T8W8ILLek7OB6bUXvEFgfKEI0N8PGH8wwfUMI6k12GE1+WUSg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:43.9479 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e15d71f-ce8f-4709-792a-08dceecc42c0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7921 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 --- 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 ad5818fbdeb6..d08a2a848ac9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -556,21 +556,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; @@ -586,16 +579,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 Thu Oct 17 16:52: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: 13840401 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.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 E08921DF27F; Thu, 17 Oct 2024 16:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184035; cv=fail; b=r5MTdjR97Kk7WJ9ProvFpp7Y4KV7IAM//dtMiSpPXl1R5ij0GtsL7nlw7vhB7Dqk4JT3wwavc0aznlVl8IUQ3Bv4C91M7HCu1j3qSO5Km6R/IhETxFxDoFZo1aFEsDoVbuZYOy5mLLr6EaM3iDKOktw8BA62vgZyU/aSea6yDN0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184035; c=relaxed/simple; bh=kefpFDZNlSjkemGXn19oyGi4AtDjrZ2k5knD5/E0LWQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZNEGVDLMJsA8/cm22pw6EDktziOPq8M3MUlvDrkeRd7J9jcqgwzIqC8XjV/WL57ZehfSPu7qCTRrUzVd8ld9AxxaWS+ALsixZVZwqeKAxrhMhgfdIfkhbFaYJjpoz/m8lyM/ViLsb/ZsH5ThvdLVE82Zjekp1qNy7CTHFm8cTqY= 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=FbFH00Ir; arc=fail smtp.client-ip=40.107.94.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="FbFH00Ir" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IMJOPOGyuIcwluTyfrcQudCgLjgp/QKzeIvBESQcoGg9EPB41OADNNPWbVVqMAoeUVTToOQY9WWhnKqnWPUW2pzRK6gXpKZsGE/5vXcRVqEj2aU3R8InbqERtMiTWS+DCpqw6YyHHz10L1wzeU2O68Bx0YuOUWU9CqC/mlIo51fw//5AColqsrkUI1EiKfpqccqcckQhwaa096yjpM+laEN1G1HZS5iXDvay6iY/rv9pLUEhhCwbcLw/i675scFUwbRwAhFa1ZhaUdAMjLHMvjZoKVISbJu/A55uPzIWZYY12LiVg0+9mZT4NofXa3COnFRohWidS0wCrbWsniGIMQ== 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=5tODdWFGiHG2z9NRllRcsnb6U9JgrayQp623lpzxvpc=; b=gN7+RXDHdYMlE1xkmT9iF1xVtHt29p3koelwzOsN+HCBZK2nQKYcmcNTgHnnKRDaQEQE1prFXqHE+p83KrW2NafLrh8KrEtnxarogTqo1rZozKIoWTdD4v0v9Ipqx8IH8Gk+3TS+mayofwT5RMcbwmzU16oGn0TFp5VFbgRWxVTUp6RvNFxZRt6mOvUUVJbHeLRJkt5ACRBNUmpCrmsSsS3j3TL1IWhXHopAVF0M+ROooRRXnk20Tc2XBbHDmaDJ/Ks5UE6xtOD0YNrnj58650P3jRXRRd7wqdw9704CBdKs1WQL3fX2zfRpo/hyWLwe5Q5nu9m0OjTOGc4/YPBRKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=5tODdWFGiHG2z9NRllRcsnb6U9JgrayQp623lpzxvpc=; b=FbFH00IrOLXwn1TXpbYUIJSUv1MLLNys5qPWHUr2bkmBuDR777YLXuEJxStCFudYkdNUtsgAfTasOYW5dXTsjuX1bw+KuILiszg0G9hS7A1F55S9WQaMka/P1dY2lBtNnXxzeIr66/tDJ5SMmeH105X7JDtmz3+jvrXruinr65U= Received: from SN7PR04CA0114.namprd04.prod.outlook.com (2603:10b6:806:122::29) by PH7PR12MB7210.namprd12.prod.outlook.com (2603:10b6:510:205::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 16:53:47 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::da) by SN7PR04CA0114.outlook.office365.com (2603:10b6:806:122::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:47 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 17 Oct 2024 11:53:43 -0500 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; Thu, 17 Oct 2024 11:53:42 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 22/26] cxl: allow region creation by type2 drivers Date: Thu, 17 Oct 2024 17:52:21 +0100 Message-ID: <20241017165225.21206-23-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: alejandro.lucero-palau@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|PH7PR12MB7210:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cb9c968-c06f-4976-4bb2-08dceecc44fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: Lpl/tPVfZc5Ksj8TZzdXVTkRrQNT+J9xT6pEhakNSMz82X4JTCBp2GQZfvpAnqdVZlbKUiHmaGus08xhD9TxliDEY4tUntm4L/9MHHQv7rnYsih2foQEKaxjS3kqmBOnTMA6mH3qAeLR3J8X4BvCgit8zYIeOGgwNVN1vT2dH6gjN5Mrj1xdTgcEpJ9sXNfg2TNc85RwPyjKKwpkDqw+krPrNxjpZPJXQVwoCP/EKB2w8T//K4FvRkKyhvf/K2N2JeNOhe5Mvs+n4uFJ9MznSYU2LKLr1SDdrdn6bwsmQEgRDqjFCqG4s0ddSI5RsAtmOJw57+neMMsQwUDdEu/j9Phug6GAZgRtOmRCE/V0Zx4Py9ppR91rvA3X9VZlYeAIWfZbEIgxvyyfEPdkBMpbeGakS3FY/PDZ+jP1h/8iXLbOL/LiJZXv+SRrfy5/wRZYbGzdyNchle3Dz9uJCb8DxWLiCegNIaTLpU73jMHijqGIX5jdDMD3kil43ygqUt8qBSE+oQK8KUS6Il0yxwa3geTLmsa/JiFn9Cy+PFma29YX4h9T7jrmd5AZ8D3CE5zEXkwi1WAVlHC/51m/ajivwM52DPNBpJUnXxyKW1fu/jlzfsi707z9oFCKHbYJllcZXL04KXn97TbobcXT31D/sCLexK9iK8NVL9Q8S+hz+KC3XNzUfskDRepq879ETHs2KfyC0ECgQxb5aVm8zVsG3QfKIqNv630aUPGbcNdJflFMqNSY2agYT65Eb02GIZxWmlUXMZvCEc/Y5O0fI1mX+Q2RZR5eXVN1aEFFa0DWlCyJsjv23QdzuzuscXs3yPOnENfa3+pI13EJT6YpVCek8Qwzy4fLL96yE4CHT1kO6Zd4tlnUncPelDUtevffKjG7lrKo4TV8LgpmoaYlKwiGvHWY5kmbQXzQXgFdgrUECn303+nQcZvwkPF+sT2t1wHoyhnGydIuXoJFmCpwzzu4SyMbPVAJN0uExWmYgxEU2ja8BuY3qWl8UVRxu3q9Hvjh1wnyhlUmPyO9rqzv/CIANco4AhPIkMjSc/sCeDB7Xm0BvDDFrUE/zH/oOQ/hRIR+/VwI9xI8fN7nMHFt2nPolBN/pmWSbFnROJmXBMERoGyiR/Q1pu6uyeEiDfm2k5btpJB4O4FSKo6MT7LwFLSWo04261Xn3RS0B8BxN2MU6akk9o/YzxC1rBQh+WxjEYT4WLzt+vW41/MQ4JJgDuH7BNuK9lN1nC9zemwsHMRhZxPw5s1+/CLf5iZyOwGQr8h2tQ3ykIDe1NV+bxivcro1HDr8IBgRFjJQRjovoCEmOWFno2TRv+QebJumcBOWKCkya/is0CQN2BVXZz6ltyn2Wb7Td6kWp0N01oaCc/mVgCZthJg/sT/YJLF8Hg+QNcgY2ByXSR47j20on8zGXoT9wQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:47.6979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb9c968-c06f-4976-4bb2-08dceecc44fa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7210 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 + include/linux/cxl/cxl.h | 4 ++ 3 files changed, 138 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index d08a2a848ac9..04c270a29e96 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2253,6 +2253,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); @@ -2781,6 +2793,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) @@ -3386,17 +3406,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, @@ -3405,8 +3426,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; @@ -3416,13 +3436,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); @@ -3445,6 +3485,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; @@ -3462,15 +3503,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 68d28eab3696..0f5c71909fd1 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -875,4 +875,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/include/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index 45b6badb8048..c544339c2baf 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/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 Thu Oct 17 16:52: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: 13840403 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.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 969121DF72F; Thu, 17 Oct 2024 16:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184036; cv=fail; b=GpY/h2LfSsWv/RMBznJYuCjJXtNKMgF6jLAslmz65UbzngfXqT8xzv4ws+Q0M8Dd22/T1lCcSmt39lPXrfeMoUGTzZ1Yd4QR02mCZ0xGrVE2PfHMlKJkoFcPIV04qJqCnwaGnAdfTO294lpLOEprzalMl8tHPpaPauzrgs8h9fI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184036; c=relaxed/simple; bh=dHbVp4JIrDOFYID12cNkyk4RmyYQUyN8nsS8VYSRidg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CNkVotioeee94guLf8X/XrZOr4g3jKisBjoekDBXQJzv6YSP03/USf+PNVT96o7b5THZbBFBdlFE3uuRMUnVD8huJIpC1ntbnGtEP/YC8s/fIlqkMmkJO33uDg4dx2VwNIILu3lMlmEntJYK7DmKjQ/Xw2OTP6Df4wfFm9OZZmA= 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=quftC1b8; arc=fail smtp.client-ip=40.107.237.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="quftC1b8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kH3Jx3sXpYedQusz5Uzbx6DRdcd2EXt2WLT7a9+o/rq4YU3FBzXC1cHE6qgikkA5b8X1PyRvre39qNQ/lcaRKFwS3NPT9B/+xcxXOdBXl+Qo0TlxaKtjztQsY2d8njvJ2h4QsqWtNUQklpoDzrYkPG0+3OhWOC3dLMb09ycpCVx91lJMErqUfDn4qFBnB3um10uXF+nnZy2433UWGQyohmqU85nB+EKD+p/rfKrs5W253gyC1WXNxDQfN374tRt28PPnA2VZVu8sOPa/IlwCz1JbmbGdvzpRwe+cwxpH0NyaOQrmh6qVeUkwag0WOqcmJf8rzXnuwyXWZGyd7rAPHQ== 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=SEyQrA318a1CUBce8DoYDDpKMIExBf2coSb9UkIo2jA=; b=UIeJUzh0098rT7iqfE7YK09bAv4PSF1VFI/Mwp0/ny+mCaOsf5ysqPL2TMcKYCBiADZiU3p6mTMQMq/Q3jZJAex4qPHz8gzvLFmrWpawjM17uw7tA2oOflR/b1PO/BW0ezzrckBotwhRZ82YvKIDK1jtXAHjFPILCdZb4ogOrnOyRw+t1gu9g0vPLDMzpVpob0bC8EgoAw9ZoXZagenLz33FmqEI8WzdmEOPEg3wgwOS6Cp5DjxwW8xe/JHBaOyuvwb0NwbiF9gLGaXTiBm4a8KTLUSh4KFrmJt/GZNzKHUSVPErXxH+V43WUwoOvXKKLMvnExmK3CgfIgaJbNk8/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=SEyQrA318a1CUBce8DoYDDpKMIExBf2coSb9UkIo2jA=; b=quftC1b8Yg9eOL7eHhHI5kSc7c1X6qUGO/DEM7Muakrhb8zNoQ9w1mblhVSvxgTCQGifLOtY9xcxphZFCNdeoqKzDxzBPi18JKrfRiYGFCgs5cginTUlWWF7s7Wb0/HiiqsHTJ+V3gOrho7ueU2MtDyUX435SO0/MtHEAL3qc08= Received: from SN7PR04CA0102.namprd04.prod.outlook.com (2603:10b6:806:122::17) by SJ0PR12MB6733.namprd12.prod.outlook.com (2603:10b6:a03:477::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 16:53:48 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::a4) by SN7PR04CA0102.outlook.office365.com (2603:10b6:806:122::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Thu, 17 Oct 2024 16:53:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:48 +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; Thu, 17 Oct 2024 11:53:45 -0500 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; Thu, 17 Oct 2024 11:53:45 -0500 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; Thu, 17 Oct 2024 11:53:44 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 23/26] sfc: create cxl region Date: Thu, 17 Oct 2024 17:52:22 +0100 Message-ID: <20241017165225.21206-24-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: SN1PEPF0002636B:EE_|SJ0PR12MB6733:EE_ X-MS-Office365-Filtering-Correlation-Id: be90adc6-a1a0-4960-0dbe-08dceecc453d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: EePSfriGGzNFDQ6Xp+0LGHA4bBo3c9EpbwX9xU2ObQn2HaJpnfHoraJhbmaqr6wbcqgWSsERxQNeOIC4W7xKOVC7tfkNnokkIwQoffkzWCfOjPqFiFW6nEskgkhfhs+zQ6MzJmpqkGVYZ/v4X6qvkj0GSbd/IWU6yfktIOKef9aCrAy4nk8eE2DFxcJgbpog//dG9Tygk7t39fJb+7tG1yuwC05Y3GBOE3Yy7nCgPWJTS4WON/tra3bGejGxP8bNxMzMxrFdXPPSc+P2KP5UtRa1+vV4l004HPvMjNhnpHsCyc4FRKXY6wce7l39NByY5pTtTFGixqRyEH97Hc7His+aBa35FajACjpzbxvAtv0L83YIeRXotENlUglCmCOCYIA9zmbH+DyA62F/3OaCZkVK4qSmlYHc5l+6yKgGwEAU9dxic749V889y3QyobHU74fiq1/M2ovv/7W/YR0svqhIZuxCx7OT3fcwawx0FTXfO3xg1GhRgn8ytSROe+wRcHUh62us2F0TpawBadHZz8IFENBCYyt/dV1WIuH6pbUDEF3Gnm8E+Gvm4zWEZ9Tvk13jPf0pY8Dn788Iff35mEP0lD4YH23zb5kSnYTazy9dZVYLrqNUsxGc5r0iceK8vGJIePWVXy2mQOXGdPRQ0+fpI8wFRxVPXXYbLUKo9ckoxkrmOJI3x4E4E9BK9mgneUF1QLQvYUTk4eJH3SKha8BOJrW9aNdbZRjWnOdLtzDo0iQq2vk/stnH5bmJhkGFL7wROo86h05ydZ8tMWDSmO5vh0MxZIWu0fVyjVJIr9ZFrcSBd/YqQ4zk5XLAhio518rwBrrk93jrO18OvepzRgQZn1vLKjBux68AylZ0DKYvz3UNh0NdcdyM1cleyudRZLZBBNJ+8v+mcxlzrdGkP8Thbg3US/3SgZBVaiernm8lbqyoOzjqCQCv4MeA0cgkY3KyXwXrTfZFljwjkZ1kT6Uvh+WtBB+awcmowjbAy/coVRN/24+mexTeBLolFcYlXpInW2in95acmdyyFCQSsgM4J7QhkKkWWLHKpDz386opv+a+1qGWJk5LpTwOKd1MRimU3HHoqyC2bBXMr3Q3tn/zHNRZODBqWTn+f0zm+maj8bVcTAm8fVO5bAlF9XNa/iPgi+s8Wlv0IKJlRNcteseUCI4l1DXrpZIZEY8pkXnnU7Eq67eo6S/WX7k4pi/t7DnWdtgi2FiliDdvb/1eU8l5hJxEPAFFJ8LfG8WipOPCVkRTi+CsGOKcTLZIqpjoYbspczP0Mswgg59JsuTNa5z7QgVB+3tamyy3v7UHi1s/HjKT9eckEFi/OdqspiLPLisVs7pHiq9VLPv8YT+cw6FpxvjJ3GTDau9UU0Z/wAJunVh3M6izs4Mrc4hCfD8tA/YbGxOLIOGrto8ZQUxbNw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:48.1354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be90adc6-a1a0-4960-0dbe-08dceecc453d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6733 X-Patchwork-Delegate: kuba@kernel.org 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 c0da75b2d8e1..869129635a84 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -127,12 +127,21 @@ int efx_cxl_init(struct efx_nic *efx) 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; + } + efx->cxl = cxl; #endif return 0; #if IS_ENABLED(CONFIG_CXL_BUS) +err_region: + cxl_dpa_free(cxl->cxled); err3: cxl_release_resource(cxl->cxlds, CXL_RES_RAM); err2: @@ -148,6 +157,7 @@ void efx_cxl_exit(struct efx_nic *efx) { #if IS_ENABLED(CONFIG_CXL_BUS) if (efx->cxl) { + cxl_accel_region_detach(efx->cxl->cxled); cxl_dpa_free(efx->cxl->cxled); cxl_release_resource(efx->cxl->cxlds, CXL_RES_RAM); kfree(efx->cxl->cxlds); From patchwork Thu Oct 17 16:52: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: 13840402 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB3101F76DE; Thu, 17 Oct 2024 16:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184035; cv=fail; b=BgzA0PYZPVVyUHSsWpBZV6VyGjCnq3gQpUR3Bw1JjJ34FCZwPD0jkLvo/+EBt+a9Xb2xB8zekk8zQkccotzqdSTEDo8dcCpdhDUr1fZ0b3i5jJY7LAY4xwWkpuI0CVTKwBTtQJSqWA2h3wTR523yMZJdMm+E3F1ty9RSKst9fP4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184035; c=relaxed/simple; bh=ceKHClVUL2kSDQGkcz0cpmHNDQz6EGMd5SbZAtfpd6E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HzW7MtheVrpCfLUNVmLIJv/lzTb4a3HeVlLd6D8qucN93Hs9nvxRgsY6AO+SBtk+ja6xfeoZsj9v/hGaOVEX/YbQHzFIetXEZvBaJrAT2FD9mC4Q4KdnPudCuU3vSxxksEesWoiwPjVQKinGRoaXzGeH0IDD/wknI1C5G2/DFHw= 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=WxOQfHsm; arc=fail smtp.client-ip=40.107.223.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WxOQfHsm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jydmqm/7cr1WxKlWJLXP/OOpNvmjyzQD4ZkR48G79yAazYYDiPUNxnK2ZITSZ744ALlrblRXlqNx1qfwTIUIb4GmhXaWQw/Cai2Y6KHBBfKCKhnZ2Y8pb3QPrrK0+3p13LcePHXmDqw5XZ20vCF47zhjTyLoXP7Er8zArzDiMggMQ2TpunF5eI9O4XXjuCWziShhotk/0eGTinb8hhEGlag5Wv9jaxBUwpKwIOV0wU2T2OXeRlWiWNwjsZ6ct6nUW51G5QdLVO2yMNJn90xTZiHyC9NNFKPeboRzcnFjRk7faJjSmzC8kvzOmqmljUTI/3UJLw92f4iWAxf0yAJtuw== 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=pApIhIctvycqzMqjSxabIPJ/wnKmQhjPSeu/nm3b3II=; b=Qk8OOjO1zYtbS8J9qR49IH+xjdefZRGlW2aUc0hAsxB5DNLzwaYtrkCvmmgsD1b14zLNtzaow+7eYL2jWA1rTNYCls12SCTsbSrFnUzQllDIaBSIIcLqcaXGQWX2SZbdCZiIGgMwHbym2YYIRh3G41MJqstRjAZR2LqyMBWkn58VqrBeT68RWHh+WsdtxVNnPMlIycNPIcYxQewgTSnK5rBtBaq10saiFL0mbzZULrnWVMP7u2tprU6SG0yoJuC9vymwd53+sErA4Sgb0vf6Kj0JLxDUflXj7zm9oQtu2KYMvAUM1TH20yrkLX7IaExCP362gnpCDeQ4lJ2kI9IqoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=pApIhIctvycqzMqjSxabIPJ/wnKmQhjPSeu/nm3b3II=; b=WxOQfHsmLeV36ulnLOM12Cec9SaZb0zlJa2Jr0DzbVry7oew+b+o/l8fv15x4KCciaxb1kLz4/nGyxqXVlK6NDelMFdNg7XKs6Tsp7sgtoompGaXItV/JSTbooqWnwtsch5ZLGmOy0+NElGZ0v/uuSq1BzroSs0VUHZXhbRuHO4= Received: from BN9PR03CA0936.namprd03.prod.outlook.com (2603:10b6:408:108::11) by LV3PR12MB9412.namprd12.prod.outlook.com (2603:10b6:408:211::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20; Thu, 17 Oct 2024 16:53:47 +0000 Received: from BL6PEPF00020E63.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::f0) by BN9PR03CA0936.outlook.office365.com (2603:10b6:408:108::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 16:53:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E63.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:47 +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; Thu, 17 Oct 2024 11:53:47 -0500 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; Thu, 17 Oct 2024 11:53:46 -0500 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; Thu, 17 Oct 2024 11:53:45 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 24/26] cxl: preclude device memory to be used for dax Date: Thu, 17 Oct 2024 17:52:23 +0100 Message-ID: <20241017165225.21206-25-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E63:EE_|LV3PR12MB9412:EE_ X-MS-Office365-Filtering-Correlation-Id: b7cb775e-eac5-4075-b78a-08dceecc44e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 4QoBc7czo97IU8APJGXHF99ORfdaSNIRAiCQDH8RzTOF4cJ40zwg6hXuOFiqNFOecCUNoXXpIpyNRpi3YArC+k8RlyyTsNZl+sV0M/+PFWJ6DU5w6Mt2ON+HIlY/fDchU7xiPnW9sDhJ79cC82fJ9Pp3Pdf4S6MI9XVeHwhjZf8x6oBiiR8H18PxQFL5GvzPB5gO0FywkA9cBEYcbUlnYrZD8DT9pZI6+YVirr9f5+38Qvq8k3iqKWD9vxdaB2EmmV40ruX8UvuoOU04tesqhxssP6WNeK9jc7OxuMMa9UMR7RS/07MpqSWnG2Bpmn5aYHsWGDLFRGSChpdbrDdN9Bwwg61pUiDD3o5JjqGRpE/b7M8HtgYlMtd0QYg38SQfOUGxXVs2NNDgMzmtmZB70ieztVoNuK9cMTtNs8qtHd8UjP+LRtEHgnooe5Oi19N2csgZqwvV60wrBLfZtd5RkZzZYmWS90KUrbG5czL2U8AfSR+wSeSQ0aNKCRuoZbxZ9ZYUqL386PsmMb8/mFBDebsTz04ljjNiuc/iv7GNwhcAfE8NijJ6rUNKJegUatLNi2WdEgP6JNs0BYV3SJskQ/KYtVfKj9+KEeFJfKEo4n740yIp8P8kWnPv5a+z4DEbdj6TQvzYzqJzgSsUO/IcqrXkVMgXoXTyPw4yhr/SSXgQReKnHYdTotiZ8US/ECTyVW13zdOgaIKSNB+aS0c1A/xDyI07vNbVCCGhismjbFi/qUr4babKnX1J9G+MITyqunLp/ntvLQ+vpZVNxxyfODMu363t5N+C4aAd28pOqL23+5X5kRIGCwgN32T0Op5g8ltOTCI/K/2tlybvBYnIwkWQ7+wdfxjNTvJDltKwsgQXl7slg6T+Kjb8SQA3mIw68hGtFtsJRCASQwvKQqzGlOm0w6LSwwqTrxHM27yfbSPdvcTrIYqS8uj20Y+ym4yjKNBlaASDi/F5YNY5ytOouw2GATkq/hdJIyNJv/hOEJtAr1QQtRdQ0m5sMo8G+D4emG6T4ZbFmihiVEI4Bg29HYCxZU4+AizmrP85ghQp4/6Wl/htQX/SsCgLZ030ZErPM6CRUhPZibAPVcA+m8+pTE71w99JjrS94g0sI3XA6tUG6zGl2v0ql741SlEhHMm5wfTKTEze0FJw7Oxlsvyc+UCgQHxnFVE5TsNMTFMavUAd4vusY0tWAFA7JoQpwM0ugffe4RQGJaX22jwfhO58N9vg7NNrZUxmruYYrXH20bR+76I7udp6p6alDiMzlGmzmfIk+3arHLsw3FTtSwM1L4i6jCFiIVixH3RU1lcHrYyIB/NMuCs263ilWITmzXzUdXaMS9+RZ7OK5y8X6w0bP8gTAPRqt4ALOmaYAYFiFdk+2tmW9X0hA//++eHVcdZ0t8zfLXiRnutb8VoxfpEgsw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:47.6049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7cb775e-eac5-4075-b78a-08dceecc44e9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E63.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9412 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. Signed-off-by: Alejandro Lucero --- drivers/cxl/core/region.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 04c270a29e96..7c84d8f89af6 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3703,6 +3703,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 (cxlr->type != CXL_DECODER_HOSTONLYMEM) + return 0; + /* * The region can not be manged by CXL if any portion of * it is already online as 'System RAM' From patchwork Thu Oct 17 16:52: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: 13840404 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2059.outbound.protection.outlook.com [40.107.100.59]) (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 726831F8908; Thu, 17 Oct 2024 16:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184040; cv=fail; b=tpyhO1y6Bpo95jowNRNgAb6vLN3OFk1qGsBRovsDw5Zpt4jcbZU5X9lUP8+AwnNKwPXHZlIzhkfeW5PfIhax3vR1kR/XEzc5ooG+qStcer1V06IgDa2jsnI//I55I3um2FBcO78LFLIH2GJm0lsLv1clNuHBWLmOb+A1yE3hjsE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184040; c=relaxed/simple; bh=Z8vhxf9zpg7F94r/9FLX4DWSfEr0EY/wm6BvikPvWoU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rTraQKYMHu9Ecf4yYVSOKS2qAl0bptDpCSbxbvoHlzNLmYSjq/BLJw1Y2S9sy5A05kGmoZCTgX/DUTlMnmfI3tr7gliFSKYQC7T2WLJI6nJUSeSyzxyUui6uVH1anyMfUm0obTj0gRsE2R63qrxm1flZUzmu/VxfZSktAdjJ+jQ= 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=KpkyGqeU; arc=fail smtp.client-ip=40.107.100.59 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="KpkyGqeU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ya5Mt3Pgxb7/FrR+JoH1Ybw9LF6P/KrrVwSCIzdTY3vsHCXZlHu2p/1huJ8qEuVT7QQ4wns8vA9ter488qUAa8shTHpUg5XLK6sp49zqozkT++umaMmRFVhZeYGL2FkP6KrauQsNUrqsTjNjUCoL4i8r09ICpdF0TsBvJBCsuVM7IMd39rcl+b4OE2YzOF6WgCikZFMVuncY6WiLlj4eC6ORr0aXD7IcJMclexaqK0uiRFslE/S0mGsojtd4VkL6ANMQdk7aETQjHi93lU2iO/MxJJ8WcrUVGsOzsTFValpPHVI9DMOAFIHI653mInNruPVdDB22GA+r/p5K0mWIbQ== 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=FQtSW4n+HjOVh1d0iJk8uO6RCmVe6Ol4u+aIBgnQMj4=; b=x9LFTgmJKNsE6gIhp1NmFxoygy6TDk4LUxUm3/crTbedTnbbAJhbIVvSOVzQCqtfJzfwznq/bk3oH/RahhXSGTU4n44ITMOxkaFx/W1qsDFTrrdmqAnH8OlWRHzzCYvmR4IrWnVbGnJvGrbTRLlqNpk7yY+bljVssTyMMkVgdu0ajfL6vlNC431kujeL5WSVpe3XufchAFloLMipRDch6zZ8nCJRE1S3kBLy44/LA7RZ2zxNq2pZY5HnSEn6qK7cQvOKoH5p+Tzo1t4XoI/rAK3cpbBrIbp14I+1JsUUTIaCteEHlsxIdrYMwAplT27EF/06XYM68q+xJxSGwxlXTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=FQtSW4n+HjOVh1d0iJk8uO6RCmVe6Ol4u+aIBgnQMj4=; b=KpkyGqeU1I3t2A2T3XZzP2UD+mIB7sQMtrcr8H2bluihLPEfGbsYfjhnw1rdoBDQtxUlSxx5KD9TF+ODnfK+poDCAG7CHOn+aRcdvQnw84p+RJvB4dnrEK5Q+1qGsirVJ/p61NhSkisoF9n4CAfE/Lwe/qiHiMejEowqfaiuFnE= Received: from SA9PR13CA0021.namprd13.prod.outlook.com (2603:10b6:806:21::26) by SA1PR12MB7248.namprd12.prod.outlook.com (2603:10b6:806:2be::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 16:53:51 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:21:cafe::94) by SA9PR13CA0021.outlook.office365.com (2603:10b6:806:21::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.7 via Frontend Transport; Thu, 17 Oct 2024 16:53:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:49 +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; Thu, 17 Oct 2024 11:53:48 -0500 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; Thu, 17 Oct 2024 11:53:48 -0500 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; Thu, 17 Oct 2024 11:53:47 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 25/26] cxl: add function for obtaining params from a region Date: Thu, 17 Oct 2024 17:52:24 +0100 Message-ID: <20241017165225.21206-26-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: SN1PEPF0002636C:EE_|SA1PR12MB7248:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d4721e2-c08a-4170-b6ed-08dceecc45d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: XFi8+2M5dK0I7ZVdFmZkJAOUTtj/mgUEC89M0krfXGGmoGKrHj8XaAxgU+A7i9Sh+aPe6LyLNwNzyvrAOXWkRByQCcqgHmHGYhlI65eyfHhj5q6mMCToVcfcJHogo5Ov7ABQhTKKXp6ZGU2zWStGM25I5JED+injhHtUCEiiZdaGiX8E5ivKRCUYGj5CNfBaOCibGDiQRiGU0p9q6lzBasBJGHuP5B9m8pp5e3j9b40L3JFuQu2HvwrY9J/WGedaLiOw/WseubYdMKbyL8gysgmzgUpd2FOjFrEzXnJK3l9LdFE8j/X4phfRaSfopwwz54WX+C4mwYfT8z3j7BI6zOGfElxIUJNVyqwDV8VR1eq+ntw87WAAhU3d0T5SitrUfOU0aE2uPSgU3KNPLNVJ39SMcmeKEKpr29R2lEDRy4TprLFe7WPYhpdnA/kXS+gOjRf4aXytwDPM9p4TsvPHQiNlLHcpRvyErOjgvNumsAhfxgM0MwJH5hHoIqPstEh+pWJQES7gWukWpj8b4Bg0zq7ccf4D1lhFueOs7BonJljXX3Jwa7OJNRbqpvFINP6U2AThl5DqSrG/pVC+Ctkao9xmQpGiOGkdi2nzl0x1rdCyTZKlgewg4z45gHrEgy/hWXNiFy8gQwhYCYa7TdZV3omGDhW8wLmSiCf30gW5xNy1Kw7/J0bWWivNEunFxTcaZuXR8LEAjFh/RI6tTDJqDshkc+nZbCa8WVNTbsw4d2zj26wM3VOGS3r7gOlVA+LLN/QcKJHuF3PQtlQc2Ebk5Z57aNMvGEm7mPYZnsZGC4UBuEbZgGE1dKDWyPhWexeS1ZYXrB0gnYLduc0f6/MQsX7kDKH3+s96mQjS3OSxLoafTfos/SgCbJFFQx7pfCg2UvfTTLzpKUY+hOANfhGtv3lUer2POeLjOwSTts4+QADZ5zSGWEqY0XMadc1ZgnzROcg2mpuJJqv+pzx6D0g5wTAg1MNKksZHuYHeD5odOesFqBbFqpaGLOYbzfSi+JFvUQkvtigNFCNv07BDHL8ba7H61j4fjfGLgJwbCODhsvlEN3b360ZVm511px2lFVYYkrtYA3Ktb0WiBfbp7/pGNgtivsaVje+z4tkE0MKUmw8l+9PpOxyKx/3sjUSDLuSSzEWiHYCYAx5UMiGWnk+Veqnbpd5utj6XbK/4gIbVmdl9Ux8TE66tIuem4MrS7/+eyOyE0PkQNJ9pT2fDd81YqMQ+w2zN7fl3tizflf4l8xGg29J5Ar4t4XFbldiVZae2hcM6RAMvCMmDECt4b472UsMjUBY02Br0LGiXO+9sPkLxwXfhhkEf6CJy1W1TbmYXESIh+THc6DHDKyxPJ9JRmfWxQQ2/R3f6QPx+SV8JRPMzfCK4cvam3b/XhCZ7QMmKs7aEIzig6aI0k0ji3arr1Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:49.1162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d4721e2-c08a-4170-b6ed-08dceecc45d2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7248 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/linux/cxl/cxl.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 7c84d8f89af6..60c3aa6ee404 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2674,6 +2674,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 2ea180f05acd..79fc3f6f29b2 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -904,6 +904,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/linux/cxl/cxl.h b/include/linux/cxl/cxl.h index c544339c2baf..d76f4ae60fbf 100644 --- a/include/linux/cxl/cxl.h +++ b/include/linux/cxl/cxl.h @@ -76,4 +76,6 @@ 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); +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start, + resource_size_t *end); #endif From patchwork Thu Oct 17 16:52: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: 13840405 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2081.outbound.protection.outlook.com [40.107.244.81]) (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 0E63C1F8929; Thu, 17 Oct 2024 16:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184040; cv=fail; b=hnIvIzKbwo3UuuDaOaITz2Sio4VWKJ1iaGhncTPy14Ew+2A8+b3Itq2JHkfD2eMv/15DY4XMkLWpshJ0AU6pZRQf4aEUBJMg3TggFwiuLpEBm4O6w1K773wadNPPdWd/+jghzIPwE6y5zqRAX11+A4xPMkXyCS8WnDIftFXHYT0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184040; c=relaxed/simple; bh=cR66PaxPLen+nQN6L1PDpnU1DHbrvJij9GtjBpQrZmk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TghfJEikfmv3x4XAb2z83fwsHEb4vcmKnCkvH2FO+OHaYSqZBN9c2WAI4kbt2MEyocfECBZD8h2EZUMgpDAuzCbnlif8mKv9+YqtcC4N7B0Onc/z2DZlDWU2Y0s33zz1AiGjmbmxWNz3/TFY53F/5OxGuemZlwOOB7dsgMNdf7Y= 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=Svr+qtfQ; arc=fail smtp.client-ip=40.107.244.81 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="Svr+qtfQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HE6mCl6pLH7DqSXRNWmcVG/kf7ti+mjjbod9NtqCo/abFvYm4RJVLT00u3/OuG3XVSzz0niCWregn63nePSZKOy980a6zNOjLOdNl1sqX4ejODXDIHlggrHBja1xSX39TGcrIBqCyPD704o6cvjIE56r7BcolaxkC/x17KaFIngdwFBg9DnxgCLQ2rqhCyb9Y/7314zd9jLs07MbQopKnvmts/ysCibMgtMuHJdTs3Hx2zGcPa5xn52oWJrKcWbll9SgXarffTfnOIhzKFj3pZ0LbeUTSxfFS+Eu01eHOu5zwP7/wpevYofaD0mCJB6xmHfxymaqxlVZWyRANkG56A== 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=JF5zIRxpecZyU3WnIRwoogauMBRvCnycHuW6mLLUkG8=; b=CkxEevkKPWKMD4jnYIt/1aRlQoDkHXwxhBJ7wyP2AZcPvuNzDiGMylnmNzc/jik9pcnsPkwVvjsLFT26nRPgJsEspSs8TOLX5FVm+qoN+Xkgz4ROsvtctCDWH1zimgei6iZyKhCO4WqmoEgx6FzGZumU4A4odrvq2oK94NQwSlengWf5b6wHJSIOscqCyymTkU6mU9gU90ZVQvdgaMuW8Sfw6PS+FnRUbt2l4iNyYxcLxDtvMNUG1EoumRG5LuMua1tY15ORSxQIZaus4o+fDRll2MSOwC9eUf0i7UfXMo8J4rRhT0Zv8l1vCHurkWA+AC3Ye1j0BEWLqOEW75fvzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) 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=JF5zIRxpecZyU3WnIRwoogauMBRvCnycHuW6mLLUkG8=; b=Svr+qtfQ7YsdsEpijsj0pfD1ViYXmIAeNiO3ER638hx/vPTBAZwuTrWvFnMNxeYkNvvdwHxJ87hPnVzM4tVnbxrVOi7whA3kiTzlVHzmXCkz7sLvGKgiOLeRoDD9df1N6VOkP9dUR3F+WrcUsunYAhnOcTDBNhkhv8tQ3nqaOuM= Received: from BN9PR03CA0207.namprd03.prod.outlook.com (2603:10b6:408:f9::32) by PH7PR12MB6908.namprd12.prod.outlook.com (2603:10b6:510:1ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 16:53:51 +0000 Received: from BL6PEPF00020E5F.namprd04.prod.outlook.com (2603:10b6:408:f9:cafe::ad) by BN9PR03CA0207.outlook.office365.com (2603:10b6:408:f9::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Thu, 17 Oct 2024 16:53:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E5F.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 16:53:50 +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; Thu, 17 Oct 2024 11:53:50 -0500 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; Thu, 17 Oct 2024 11:53:49 -0500 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; Thu, 17 Oct 2024 11:53:48 -0500 From: To: , , , , , , , , CC: Alejandro Lucero Subject: [PATCH v4 26/26] sfc: support pio mapping based on cxl Date: Thu, 17 Oct 2024 17:52:25 +0100 Message-ID: <20241017165225.21206-27-alejandro.lucero-palau@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> References: <20241017165225.21206-1-alejandro.lucero-palau@amd.com> Precedence: bulk X-Mailing-List: netdev@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: BL6PEPF00020E5F:EE_|PH7PR12MB6908:EE_ X-MS-Office365-Filtering-Correlation-Id: 76a63091-c804-413b-0df5-08dceecc46a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: f+Uc+7sAcuWve/bYHsnQEr/8gr0bt5O4tE4WJQJUTOTqWuvKZaiKTzY/xgls/MUChVMbfv6kRSKpzQF9PYJmd9+xRLTQy1GZe5oVru1rHM1ev4y0B+ffZ9if6ImQLSCYsAe4rF9DlZaqHXxwnL1O6bPWkTeSF8ecJNdifSq/ULLzSeICSMAES41FZtfQGGZ70uGkpR0CrtkB1eW+ja4dBxRSp+b05nHNIPbQhPkHuVD8kioSIoGg4KT50mroRXjpbNAxsgrTbvJht1QL6XxZa6rRXGe3kYgD4gM0TUxR+9apa2SQWZAT+SX4nXxw19QCLuls+ZN3mNEXXc9ulXrB+BD8TMSpM2rkwdL0Cg1opSY4YGg+meDFDmcCgSBQtdQf/gShUM56aaSjVkpIHY53E+AacLijCxx8AzIpQLT3NdkGEHFK0gp9sc6laSoKLPDHOghqDZA0w64bKS1xrWj4mpVkgx+QTWZjZ7RbRhCEugRyhuWPW4bPGlsS+XHiIn72p1LDnH/xs0KFWkFSAzbmkIgqSmNxdo1He7GkIdUOS0o62s2YEaczD8tcNetUiYMoYyYEk/ceXapOzQimKF3NqWU4wTnxP7/vl1Y7Dxe95+D4/dp3IQfAFrAb44DK46qo4o1RyiTVEns0dGdrJIsobCnnxkNGJzr7YJ0KNTEnygsUJ28Qqh7ErEP2mXvRdcSmQ4ZsWZUTacGQetyLzZQCZKUck5wIgRfvZieDxdKx+ZADk4x9mcJRtUoDhed/JJUaIrC91+0GsP0IOKsozW8JfBzfwPKAtcwSdmJU3y2syCNLT56RCU5hJFseNUugFHqeSWkJ0qm5vXRgvOzc72AmI6JfT5bgPGlM9nTvi2YKetXEbnmoktmIveosI4wb67VI+d6I1Ob9t7AuorJLC//vHVZbRu52tbRr6Gy7aJDmhaBMS6R51W3dy8tqV+gmk8uqn9wSOv7n6OMmjw1Owpjn0WnP+7Hpudf+MDQA7AotDy9mOULo4lSe2wEGzwn+W6DZ2NUcmLhtGpFQeJ0zMkaYg1u4FV7rmdOxJz1J/V1Yn0bili/zStTtQeFOhZzww8DxOV8w5fwmFzcsXcN1+m8ETBXWJiIMs9C2qvs/fgFSQuvQ2U1jTCw7zk0Qcke15bEagXx4oUfZ+Uij3Hj2/WiNWjveMKyl81vedEZQwjbti95J1c6RxZoJYxrrQqbXOJAW1anejh5lZTO4Z7ARrftqUbVbA4+F7+2kGFcsBddhvQOUTwPUi+HlyzGDlbo0ZR5uB5mQmf2/gA/2HEBN5a+4ZiDiSohvDqctOeE8DOhU7AEDLBsYoNYBvqv781rPgOCi9K8H+ImNSep5M32hT8kkKVHfpnhmt5mo1kNy8NkMrtfkza1x5LFOZFLZFDHWLUd8WwsuAd3HK6Tz/UzGwSTyXA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:53:50.5169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76a63091-c804-413b-0df5-08dceecc46a6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E5F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6908 X-Patchwork-Delegate: kuba@kernel.org 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 | 34 +++++++++++++++++++++------ drivers/net/ethernet/sfc/efx_cxl.c | 19 ++++++++++++++- drivers/net/ethernet/sfc/mcdi_pcol.h | 12 ++++++++++ drivers/net/ethernet/sfc/net_driver.h | 2 ++ drivers/net/ethernet/sfc/nic.h | 2 ++ 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 7d69302ffa0a..794574151b2f 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; } @@ -949,7 +956,7 @@ static void efx_ef10_remove(struct efx_nic *efx) efx_mcdi_rx_free_indir_table(efx); - if (nic_data->wc_membase) + if (nic_data->wc_membase && !efx->efx_cxl_pio_in_use) iounmap(nic_data->wc_membase); rc = efx_mcdi_free_vis(efx); @@ -1263,8 +1270,21 @@ 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) + return 0; + + /* Set up the WC mapping */ + + if ((nic_data->datapath_caps3 & + (1 << MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_LBN)) && + efx->efx_cxl_pio_initialised) { + /* Using PIO through CXL mapping? */ + nic_data->pio_write_base = efx->cxl->ctpio_cxl + + (pio_write_vi_base * efx->vi_stride + + ER_DZ_TX_PIOBUF - uc_mem_map_size); + efx->efx_cxl_pio_in_use = true; + } else { + /* Using legacy PIO BAR mapping */ nic_data->wc_membase = ioremap_wc(efx->membase_phys + uc_mem_map_size, wc_mem_map_size); @@ -1279,12 +1299,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 869129635a84..1629ffe3dccb 100644 --- a/drivers/net/ethernet/sfc/efx_cxl.c +++ b/drivers/net/ethernet/sfc/efx_cxl.c @@ -24,9 +24,9 @@ int efx_cxl_init(struct efx_nic *efx) struct pci_dev *pci_dev = efx->pci_dev; DECLARE_BITMAP(expected, CXL_MAX_CAPS); DECLARE_BITMAP(found, CXL_MAX_CAPS); + resource_size_t max, start, end; struct efx_cxl *cxl; struct resource res; - resource_size_t max; u16 dvsec; int rc; @@ -134,12 +134,28 @@ int efx_cxl_init(struct efx_nic *efx) 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; + } + + efx->efx_cxl_pio_initialised = true; + efx->cxl = cxl; #endif return 0; #if IS_ENABLED(CONFIG_CXL_BUS) +err_region_params: + cxl_accel_region_detach(efx->cxl->cxled); err_region: cxl_dpa_free(cxl->cxled); err3: @@ -157,6 +173,7 @@ void efx_cxl_exit(struct efx_nic *efx) { #if IS_ENABLED(CONFIG_CXL_BUS) if (efx->cxl) { + iounmap(efx->cxl->ctpio_cxl); cxl_accel_region_detach(efx->cxl->cxled); cxl_dpa_free(efx->cxl->cxled); cxl_release_resource(efx->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 77261de65e63..893e7841ffb4 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -967,6 +967,7 @@ struct efx_cxl; * @dl_port: devlink port associated with the PF * @cxl: details of related cxl objects * @efx_cxl_pio_initialised: clx initialization outcome. + * @efx_cxl_pio_in_use: PIO using CXL mapping * @mem_bar: The BAR that is mapped into membase. * @reg_base: Offset from the start of the bar to the function control window. * @monitor_work: Hardware monitor workitem @@ -1154,6 +1155,7 @@ struct efx_nic { struct devlink_port *dl_port; struct efx_cxl *cxl; bool efx_cxl_pio_initialised; + bool efx_cxl_pio_in_use; unsigned int mem_bar; u32 reg_base; diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 1db64fc6e909..b7148810acdb 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -151,6 +151,7 @@ enum { * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of * %MC_CMD_GET_CAPABILITIES response) * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of + * @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 @@ -186,6 +187,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;