@@ -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
@@ -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;