diff mbox series

[24/33] PCI/MSI: Provide prepare_desc() MSI domain op

Message ID 20221111135206.632756918@linutronix.de
State New
Headers show
Series genirq, PCI/MSI: Support for per device MSI and PCI/IMS - Part 3 implementation | expand

Commit Message

Thomas Gleixner Nov. 11, 2022, 1:58 p.m. UTC
Dynamic MSI-X vector allocation post MSI-X allows to allocate vectors at a
given index or at any free index in the available table range. The latter
requires that the core code selects the index at descriptor allocation time.

This requires that the PCI/MSI-X specific setup of the MSI-X descriptor,
which is partially depending on the chosen index happens after allocation.

Implement the prepare_desc() op in the PCI/MSI-X specific msi_domain_ops
which is invoked before the core interrupt descriptor and the associated
Linux interrupt number is allocated. That callback is also provided for the
upcoming PCI/IMS implementations so the implementation specific interrupt
domain can do their domain specific initialization of the MSI descriptors.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/pci/msi/irqdomain.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jason Gunthorpe Nov. 16, 2022, 7:40 p.m. UTC | #1
On Fri, Nov 11, 2022 at 02:58:49PM +0100, Thomas Gleixner wrote:
> Dynamic MSI-X vector allocation post MSI-X allows to allocate vectors at a
> given index or at any free index in the available table range. The latter
> requires that the core code selects the index at descriptor allocation time.
> 
> This requires that the PCI/MSI-X specific setup of the MSI-X descriptor,
> which is partially depending on the chosen index happens after allocation.
> 
> Implement the prepare_desc() op in the PCI/MSI-X specific msi_domain_ops
> which is invoked before the core interrupt descriptor and the associated
> Linux interrupt number is allocated. That callback is also provided for the
> upcoming PCI/IMS implementations so the implementation specific interrupt
> domain can do their domain specific initialization of the MSI descriptors.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  drivers/pci/msi/irqdomain.c |    9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason
Bjorn Helgaas Nov. 16, 2022, 8:26 p.m. UTC | #2
On Fri, Nov 11, 2022 at 02:58:49PM +0100, Thomas Gleixner wrote:
> Dynamic MSI-X vector allocation post MSI-X allows to allocate vectors at a
> given index or at any free index in the available table range.

Is "post MSI-X" missing something?  "post MSI-X enablement" or
something?

> The latter
> requires that the core code selects the index at descriptor allocation time.
> 
> This requires that the PCI/MSI-X specific setup of the MSI-X descriptor,
> which is partially depending on the chosen index happens after allocation.

Is there a comma missing after "index"?  I.e., setup of the descriptor
partially depends on the chosen index?  And the above requires that
setup happens after allocation?

> Implement the prepare_desc() op in the PCI/MSI-X specific msi_domain_ops
> which is invoked before the core interrupt descriptor and the associated
> Linux interrupt number is allocated. That callback is also provided for the
> upcoming PCI/IMS implementations so the implementation specific interrupt
> domain can do their domain specific initialization of the MSI descriptors.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/msi/irqdomain.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> --- a/drivers/pci/msi/irqdomain.c
> +++ b/drivers/pci/msi/irqdomain.c
> @@ -202,6 +202,14 @@ static void pci_unmask_msix(struct irq_d
>  	pci_msix_unmask(irq_data_get_msi_desc(data));
>  }
>  
> +static void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg,
> +				  struct msi_desc *desc)
> +{
> +	/* Don't fiddle with preallocated MSI descriptors */
> +	if (!desc->pci.mask_base)
> +		msix_prepare_msi_desc(to_pci_dev(desc->dev), desc);
> +}
> +
>  static struct msi_domain_template pci_msix_template = {
>  	.chip = {
>  		.name			= "PCI-MSIX",
> @@ -212,6 +220,7 @@ static struct msi_domain_template pci_ms
>  	},
>  
>  	.ops = {
> +		.prepare_desc		= pci_msix_prepare_desc,
>  		.set_desc		= pci_device_domain_set_desc,
>  	},
>  
>
Thomas Gleixner Nov. 16, 2022, 10:42 p.m. UTC | #3
On Wed, Nov 16 2022 at 14:26, Bjorn Helgaas wrote:
> On Fri, Nov 11, 2022 at 02:58:49PM +0100, Thomas Gleixner wrote:
>> Dynamic MSI-X vector allocation post MSI-X allows to allocate vectors at a
>> given index or at any free index in the available table range.
>
> Is "post MSI-X" missing something?  "post MSI-X enablement" or
> something?

Yes. That was the plan.

>> The latter
>> requires that the core code selects the index at descriptor allocation time.
>> 
>> This requires that the PCI/MSI-X specific setup of the MSI-X descriptor,
>> which is partially depending on the chosen index happens after allocation.
>
> Is there a comma missing after "index"?  I.e., setup of the descriptor
> partially depends on the chosen index?  And the above requires that
> setup happens after allocation?

Yes.

Thanks,

        tglx
diff mbox series

Patch

--- a/drivers/pci/msi/irqdomain.c
+++ b/drivers/pci/msi/irqdomain.c
@@ -202,6 +202,14 @@  static void pci_unmask_msix(struct irq_d
 	pci_msix_unmask(irq_data_get_msi_desc(data));
 }
 
+static void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg,
+				  struct msi_desc *desc)
+{
+	/* Don't fiddle with preallocated MSI descriptors */
+	if (!desc->pci.mask_base)
+		msix_prepare_msi_desc(to_pci_dev(desc->dev), desc);
+}
+
 static struct msi_domain_template pci_msix_template = {
 	.chip = {
 		.name			= "PCI-MSIX",
@@ -212,6 +220,7 @@  static struct msi_domain_template pci_ms
 	},
 
 	.ops = {
+		.prepare_desc		= pci_msix_prepare_desc,
 		.set_desc		= pci_device_domain_set_desc,
 	},