Thomas Gleixner
cd6cf06590
genirq/msi: Convert storage to xarray
...
The current linked list storage for MSI descriptors is suboptimal in
several ways:
1) Looking up a MSI desciptor requires a O(n) list walk in the worst case
2) The upcoming support of runtime expansion of MSI-X vectors would need
to do a full list walk to figure out whether a particular index is
already associated.
3) Runtime expansion of sparse allocations is even more complex as the
current implementation assumes an ordered list (increasing MSI index).
Use an xarray which solves all of the above problems nicely.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210749.280627070@linutronix.de
2021-12-16 22:22:20 +01:00
Thomas Gleixner
bf5e758f02
genirq/msi: Simplify sysfs handling
...
The sysfs handling for MSI is a convoluted maze and it is in the way of
supporting dynamic expansion of the MSI-X vectors because it only supports
a one off bulk population/free of the sysfs entries.
Change it to do:
1) Creating an empty sysfs attribute group when msi_device_data is
allocated
2) Populate the entries when the MSI descriptor is initialized
3) Free the entries when a MSI descriptor is detached from a Linux
interrupt.
4) Provide functions for the legacy non-irqdomain fallback code to
do a bulk population/free. This code won't support dynamic
expansion.
This makes the code simpler and reduces the number of allocations as the
empty attribute group can be shared.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210749.224917330@linutronix.de
2021-12-16 22:22:20 +01:00
Thomas Gleixner
ef3350c53d
genirq/msi: Add abuse prevention comment to msi header
...
Hope dies last.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210749.170847844@linutronix.de
2021-12-16 22:22:20 +01:00
Thomas Gleixner
cc9a246dbf
genirq/msi: Mop up old interfaces
...
Get rid of the old iterators, alloc/free functions and adjust the core code
accordingly.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210749.117395027@linutronix.de
2021-12-16 22:22:20 +01:00
Thomas Gleixner
ef8dd01538
genirq/msi: Make interrupt allocation less convoluted
...
There is no real reason to do several loops over the MSI descriptors
instead of just doing one loop. In case of an error everything is undone
anyway so it does not matter whether it's a partial or a full rollback.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210749.010234767@linutronix.de
2021-12-16 22:22:20 +01:00
Thomas Gleixner
645474e2ce
genirq/msi: Provide domain flags to allocate/free MSI descriptors automatically
...
Provide domain info flags which tell the core to allocate simple
descriptors or to free descriptors when the interrupts are freed and
implement the required functionality.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.928198636@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
6029052536
genirq/msi: Provide msi_alloc_msi_desc() and a simple allocator
...
Provide msi_alloc_msi_desc() which takes a template MSI descriptor for
initializing a newly allocated descriptor. This allows to simplify various
usage sites of alloc_msi_entry() and moves the storage handling into the
core code.
For simple cases where only a linear vector space is required provide
msi_add_simple_msi_descs() which just allocates a linear range of MSI
descriptors and fills msi_desc::msi_index accordingly.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.873833567@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
1046f71d72
genirq/msi: Provide a set of advanced MSI accessors and iterators
...
In preparation for dynamic handling of MSI-X interrupts provide a new set
of MSI descriptor accessor functions and iterators. They are benefitial per
se as they allow to cleanup quite some code in various MSI domain
implementations.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.818635078@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
0f62d941ac
genirq/msi: Provide msi_domain_alloc/free_irqs_descs_locked()
...
Usage sites which do allocations of the MSI descriptors before invoking
msi_domain_alloc_irqs() require to lock the MSI decriptors accross the
operation.
Provide entry points which can be called with the MSI mutex held and lock
the mutex in the existing entry points.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.765371053@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
b5f687f97d
genirq/msi: Add mutex for MSI list protection
...
For upcoming runtime extensions of MSI-X interrupts it's required to
protect the MSI descriptor list. Add a mutex to struct msi_device_data and
provide lock/unlock functions.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.708877269@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
125282cd4f
genirq/msi: Move descriptor list to struct msi_device_data
...
It's only required when MSI is in use.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211206210747.650487479@linutronix.de
2021-12-16 22:22:16 +01:00
Thomas Gleixner
cf15f43aca
genirq/msi: Provide interface to retrieve Linux interrupt number
...
This allows drivers to retrieve the Linux interrupt number instead of
fiddling with MSI descriptors.
msi_get_virq() returns the Linux interrupt number or 0 in case that there
is no entry for the given MSI index.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.780824745@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
7a823443e9
PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS
...
Provide a domain info flag which makes the core code check for a contiguous
MSI-X index on allocation. That's simpler than checking it at some other
domain callback in architecture code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211210221814.662401116@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
173ffad79d
PCI/MSI: Use msi_desc::msi_index
...
The usage of msi_desc::pci::entry_nr is confusing at best. It's the index
into the MSI[X] descriptor table.
Use msi_desc::msi_index which is shared between all MSI incarnations
instead of having a PCI specific storage for no value.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211210221814.602911509@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
0f18095871
soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index
...
Use the common msi_index member and get rid of the pointless wrapper struct.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Acked-by: Nishanth Menon <nm@ti.com >
Link: https://lore.kernel.org/r/20211210221814.540704224@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
78ee9fb4b8
bus: fsl-mc-msi: Use msi_desc::msi_index
...
Use the common msi_index member and get rid of the pointless wrapper struct.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.477386185@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
dba27c7fa3
platform-msi: Use msi_desc::msi_index
...
Use the common msi_index member and get rid of the pointless wrapper struct.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.413638645@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
20c6d424cf
genirq/msi: Consolidate MSI descriptor data
...
All non PCI/MSI usage variants have data structures in struct msi_desc with
only one member: xxx_index. PCI/MSI has a entry_nr member.
Add a common msi_index member to struct msi_desc so all implementations can
share it which allows further consolidation.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.350967317@linutronix.de
2021-12-16 22:16:40 +01:00
Thomas Gleixner
fc22e7dbcd
platform-msi: Store platform private data pointer in msi_device_data
...
Storing the platform private data in a MSI descriptor is sloppy at
best. The data belongs to the device and not to the descriptor.
Add a pointer to struct msi_device_data and store the pointer there.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.287680528@linutronix.de
2021-12-16 22:16:39 +01:00
Thomas Gleixner
9835cec6d5
platform-msi: Rename functions and clarify comments
...
It's hard to distinguish what platform_msi_domain_alloc() and
platform_msi_domain_alloc_irqs() are about. Make the distinction more
explicit and add comments which explain the use cases properly.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.228706214@linutronix.de
2021-12-16 22:16:39 +01:00
Thomas Gleixner
24cff375fd
genirq/msi: Remove the original sysfs interfaces
...
No more users. Refactor the core code accordingly and move the global
interface under CONFIG_PCI_MSI_ARCH_FALLBACKS.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221814.168362229@linutronix.de
2021-12-16 22:16:39 +01:00
Thomas Gleixner
bf6e054e0e
genirq/msi: Provide msi_device_populate/destroy_sysfs()
...
Add new allocation functions which can be activated by domain info
flags. They store the groups pointer in struct msi_device_data.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221813.988659194@linutronix.de
2021-12-16 22:16:39 +01:00
Thomas Gleixner
013bd8e543
device: Add device:: Msi_data pointer and struct msi_device_data
...
Create struct msi_device_data and add a pointer of that type to struct
dev_msi_info, which is part of struct device. Provide an allocator function
which can be invoked from the MSI interrupt allocation code pathes.
Add a properties field to the data structure as a first member so the
allocation size is not zero bytes. The field will be uses later on.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Michael Kelley <mikelley@microsoft.com >
Tested-by: Nishanth Menon <nm@ti.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/20211210221813.676660809@linutronix.de
2021-12-16 22:16:38 +01:00
Thomas Gleixner
890337624e
genirq/msi: Handle PCI/MSI allocation fail in core code
...
Get rid of yet another irqdomain callback and let the core code return the
already available information of how many descriptors could be allocated.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Acked-by: Bjorn Helgaas <bhelgaas@google.com > # PCI
Link: https://lore.kernel.org/r/20211206210225.046615302@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
57ce3a3c99
PCI/MSI: Make pci_msi_domain_check_cap() static
...
No users outside of that file.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210224.980989243@linutronix.de
2021-12-09 11:52:22 +01:00