[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241230214445.27602-17-alejandro.lucero-palau@amd.com>
Date: Mon, 30 Dec 2024 21:44:34 +0000
From: <alejandro.lucero-palau@....com>
To: <linux-cxl@...r.kernel.org>, <netdev@...r.kernel.org>,
<dan.j.williams@...el.com>, <edward.cree@....com>, <davem@...emloft.net>,
<kuba@...nel.org>, <pabeni@...hat.com>, <edumazet@...gle.com>,
<dave.jiang@...el.com>
CC: Alejandro Lucero <alucerop@....com>
Subject: [PATCH v9 16/27] sfc: obtain root decoder with enough HPA free space
From: Alejandro Lucero <alucerop@....com>
Asking for available 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.
Make sfc cxl build dependent on CXL region.
Signed-off-by: Alejandro Lucero <alucerop@....com>
Reviewed-by: Martin Habets <habetsm.xilinx@...il.com>
Acked-by: Edward Cree <ecree.xilinx@...il.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
---
drivers/net/ethernet/sfc/Kconfig | 2 +-
drivers/net/ethernet/sfc/efx_cxl.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index a8bc777baa95..36a7c4bec5a7 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -67,7 +67,7 @@ config SFC_MCDI_LOGGING
a sysfs file 'mcdi_logging' under the PCI device.
config SFC_CXL
bool "Solarflare SFC9100-family CXL support"
- depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m)
+ depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m) && CXL_REGION
default y
help
This enables CXL support by the driver relying on kernel support
diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
index f4bf137fd878..9413552d559d 100644
--- a/drivers/net/ethernet/sfc/efx_cxl.c
+++ b/drivers/net/ethernet/sfc/efx_cxl.c
@@ -24,6 +24,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
struct pci_dev *pci_dev = efx->pci_dev;
DECLARE_BITMAP(expected, CXL_MAX_CAPS);
DECLARE_BITMAP(found, CXL_MAX_CAPS);
+ resource_size_t max_size;
struct efx_cxl *cxl;
struct resource res;
u16 dvsec;
@@ -103,6 +104,23 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
goto err_memdev;
}
+ cxl->cxlrd = cxl_get_hpa_freespace(cxl->cxlmd,
+ CXL_DECODER_F_RAM | CXL_DECODER_F_TYPE2,
+ &max_size);
+
+ if (IS_ERR(cxl->cxlrd)) {
+ pci_err(pci_dev, "cxl_get_hpa_freespace failed\n");
+ rc = PTR_ERR(cxl->cxlrd);
+ goto err_memdev;
+ }
+
+ if (max_size < EFX_CTPIO_BUFFER_SIZE) {
+ pci_err(pci_dev, "%s: not enough free HPA space %pap < %u\n",
+ __func__, &max_size, EFX_CTPIO_BUFFER_SIZE);
+ rc = -ENOSPC;
+ goto err_memdev;
+ }
+
probe_data->cxl = cxl;
return 0;
--
2.17.1
Powered by blists - more mailing lists