Skip to content

Commit 79384e4

Browse files
Ian Munsiempe
authored andcommitted
cxl: Add kernel APIs to get & set the max irqs per context
These APIs will be used by the Mellanox CX4 support. While they function standalone to configure existing behaviour, their primary purpose is to allow the Mellanox driver to inform the cxl driver of a hardware limitation, which will be used in a future patch. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 317f5ef commit 79384e4

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎drivers/misc/cxl/api.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,30 @@ ssize_t cxl_read_adapter_vpd(struct pci_dev *dev, void *buf, size_t count)
447447
return cxl_ops->read_adapter_vpd(afu->adapter, buf, count);
448448
}
449449
EXPORT_SYMBOL_GPL(cxl_read_adapter_vpd);
450+
451+
int cxl_set_max_irqs_per_process(struct pci_dev *dev, int irqs)
452+
{
453+
struct cxl_afu *afu = cxl_pci_to_afu(dev);
454+
if (IS_ERR(afu))
455+
return -ENODEV;
456+
457+
if (irqs > afu->adapter->user_irqs)
458+
return -EINVAL;
459+
460+
/* Limit user_irqs to prevent the user increasing this via sysfs */
461+
afu->adapter->user_irqs = irqs;
462+
afu->irqs_max = irqs;
463+
464+
return 0;
465+
}
466+
EXPORT_SYMBOL_GPL(cxl_set_max_irqs_per_process);
467+
468+
int cxl_get_max_irqs_per_process(struct pci_dev *dev)
469+
{
470+
struct cxl_afu *afu = cxl_pci_to_afu(dev);
471+
if (IS_ERR(afu))
472+
return -ENODEV;
473+
474+
return afu->irqs_max;
475+
}
476+
EXPORT_SYMBOL_GPL(cxl_get_max_irqs_per_process);

‎include/misc/cxl.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ void cxl_psa_unmap(void __iomem *addr);
166166
/* Get the process element for this context */
167167
int cxl_process_element(struct cxl_context *ctx);
168168

169+
/*
170+
* Limit the number of interrupts that a single context can allocate via
171+
* cxl_start_work. If using the api with a real phb, this may be used to
172+
* request that additional default contexts be created when allocating
173+
* interrupts via pci_enable_msix_range. These will be set to the same running
174+
* state as the default context, and if that is running it will reuse the
175+
* parameters previously passed to cxl_start_context for the default context.
176+
*/
177+
int cxl_set_max_irqs_per_process(struct pci_dev *dev, int irqs);
178+
int cxl_get_max_irqs_per_process(struct pci_dev *dev);
169179

170180
/*
171181
* These calls allow drivers to create their own file descriptors and make them

0 commit comments

Comments
 (0)