[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch V2 21/36] x86/apic/msi: Use device MSI properties



On Mon, Dec 06, 2021 at 11:39:29PM +0100, Thomas Gleixner wrote:
> instead of fiddling with MSI descriptors.
> 
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> ---
>  arch/x86/kernel/apic/msi.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> --- a/arch/x86/kernel/apic/msi.c
> +++ b/arch/x86/kernel/apic/msi.c
> @@ -160,11 +160,8 @@ static struct irq_chip pci_msi_controlle
>  int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec,
>                   msi_alloc_info_t *arg)
>  {
> -     struct pci_dev *pdev = to_pci_dev(dev);
> -     struct msi_desc *desc = first_pci_msi_entry(pdev);
> -
>       init_irq_alloc_info(arg, NULL);
> -     if (desc->pci.msi_attrib.is_msix) {
> +     if (msi_device_has_property(dev, MSI_PROP_PCI_MSIX)) {
>               arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSIX;
>       } else {
>               arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSI;
>

Just thought for future

It looks like the only use of this is to link to the irq_remapping
which is only using it to get back to the physical device:

        case X86_IRQ_ALLOC_TYPE_PCI_MSI:
        case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
                set_msi_sid(irte,
                            pci_real_dma_dev(msi_desc_to_pci_dev(info->desc)));

        case X86_IRQ_ALLOC_TYPE_PCI_MSI:
        case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
                return get_device_id(msi_desc_to_dev(info->desc));

And this is super confusing:

static inline int get_device_id(struct device *dev)
{
        int devid;

        if (dev_is_pci(dev))
                devid = get_pci_device_id(dev);
        else
                devid = get_acpihid_device_id(dev, NULL);

        return devid;
}

How does an ACPI device have a *PCI* MSI or MSI-X ??

IMHO this makes more sense written as:

  struct device *origin_device = msi_desc_get_origin_dev(info->desc);

  if (dev_is_pci(origin_device)
      devid = get_pci_device_id(origin_device);
  else if (dev_is_acpi(origin_device))
      devid = get_acpihid_device_id(dev, NULL);

And similar in all places touching X86_IRQ_ALLOC_TYPE_PCI_MSI/X

Like this oddball thing in AMD too:

        } else if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI ||
                   info->type == X86_IRQ_ALLOC_TYPE_PCI_MSIX) {
                bool align = (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI);

                index = alloc_irq_index(devid, nr_irqs, align,
                                        msi_desc_to_pci_dev(info->desc));
        } else {
                index = alloc_irq_index(devid, nr_irqs, false, NULL);

This should just use a dev and inside alloc_irq_table do the dev_is_pci()
thing to guard the pci_for_each_dma_alias()

Then just call it X86_IRQ_ALLOC_TYPE_DEVICE (ie allocated for a struct device)

Jason



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.