Thomas Gleixner
d558285413
PCI/MSI: Unbreak pci_irq_get_affinity()
...
The recent cleanup of pci_irq_get_affinity() broke the function for
PCI/MSI-X and indices > 0. Only the MSI descriptor for PCI/MSI has more
than one affinity mask which can be retrieved via the MSI index.
PCI/MSI-X has one descriptor per vector and each has a single affinity
mask.
Use index 0 when accessing the affinity mask in the MSI descriptor when
MSI-X is enabled.
Fixes: f482359001 ("PCI/MSI: Simplify pci_irq_get_affinity()")
Reported-by: Nathan Chancellor <nathan@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Nathan Chancellor <nathan@kernel.org >
Link: https://lore.kernel.org/r/87v8zm9pmd.ffs@tglx
2021-12-18 20:33:21 +01:00
Thomas Gleixner
ae24e28fef
PCI/MSI: Use msi_on_each_desc()
...
Use the new iterator functions which pave the way for dynamically extending
MSI-X vectors.
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 >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210748.142603657@linutronix.de
2021-12-16 22:22:18 +01:00
Thomas Gleixner
9fb9eb4b59
PCI/MSI: Let core code free MSI descriptors
...
Set the domain info flag which tells the core code to free the MSI
descriptors from msi_domain_free_irqs() and add an explicit call to the
core function into the legacy code.
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 >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210748.089085131@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
71020a3c0d
PCI/MSI: Use msi_add_msi_desc()
...
Simplify the allocation of MSI descriptors by using msi_add_msi_desc()
which moves the storage handling to core code and prepares for dynamic
extension of the MSI-X vector space.
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 >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210748.035348646@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
5512c5eaf5
PCI/MSI: Protect MSI operations
...
To prepare for dynamic extension of MSI-X vectors, protect the MSI
operations for MSI and MSI-X. This requires to move the invocation of
irq_create_affinity_masks() out of the descriptor lock section to avoid
reverse lock ordering vs. CPU hotplug lock as some callers of the PCI/MSI
allocation interfaces already hold it.
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 >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210747.982292705@linutronix.de
2021-12-16 22:22:17 +01:00
Thomas Gleixner
f482359001
PCI/MSI: Simplify pci_irq_get_affinity()
...
Replace open coded MSI descriptor chasing and use the proper accessor
functions instead.
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.900929381@linutronix.de
2021-12-16 22:16:41 +01:00
Thomas Gleixner
82ff8e6b78
PCI/MSI: Use msi_get_virq() in pci_get_vector()
...
Use msi_get_vector() and handle the return value to be compatible.
No functional change intended.
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.841243231@linutronix.de
2021-12-16 22:16:41 +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
ffd84485e6
PCI/MSI: Let the irq code handle sysfs groups
...
Set the domain info flag which makes the core code handle sysfs groups and
put an explicit invocation into the legacy code.
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.048612053@linutronix.de
2021-12-16 22:16:39 +01:00
Thomas Gleixner
93296cd132
PCI/MSI: Allocate MSI device data on first use
...
Allocate MSI device data on first use, i.e. when a PCI driver invokes one
of the PCI/MSI enablement functions.
Add a wrapper function to ensure that the ordering vs. pcim_msi_release()
is correct.
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 >
Link: https://lore.kernel.org/r/87r1adrdje.ffs@tglx
2021-12-16 22:16:38 +01:00
Thomas Gleixner
3f35d2cf9f
PCI/MSI: Decouple MSI[-X] disable from pcim_release()
...
The MSI core will introduce runtime allocation of MSI related data. This
data will be devres managed and has to be set up before enabling
PCI/MSI[-X]. This would introduce an ordering issue vs. pcim_release().
The setup order is:
pcim_enable_device()
devres_alloc(pcim_release...);
...
pci_irq_alloc()
msi_setup_device_data()
devres_alloc(msi_device_data_release, ...)
and once the device is released these release functions are invoked in the
opposite order:
msi_device_data_release()
...
pcim_release()
pci_disable_msi[x]()
which is obviously wrong, because pci_disable_msi[x]() requires the MSI
data to be available to tear down the MSI[-X] interrupts.
Remove the MSI[-X] teardown from pcim_release() and add an explicit action
to be installed on the attempt of enabling PCI/MSI[-X].
This allows the MSI core data allocation to be ordered correctly in a
subsequent step.
Reported-by: Nishanth Menon <nm@ti.com >
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 >
Link: https://lore.kernel.org/r/87tuf9rdoj.ffs@tglx
2021-12-16 22:16:38 +01:00
Thomas Gleixner
c7ecb95ca6
PCI/MSI: Set pci_dev::msi[x]_enabled early
...
There are quite some places which retrieve the first MSI descriptor to
evaluate whether the setup is for MSI or MSI-X. That's required because
pci_dev::msi[x]_enabled is only set when the setup completed successfully.
There is no real reason why msi[x]_enabled can't be set at the beginning of
the setup sequence and cleared in case of a failure.
Implement that so the MSI descriptor evaluations can be converted to simple
property queries.
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/20211210221813.250049810@linutronix.de
2021-12-16 22:16:37 +01:00
Thomas Gleixner
09eb3ad55f
Merge branch 'irq/urgent' into irq/msi
...
to pick up the PCI/MSI-x fixes.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
2021-12-14 13:30:34 +01:00
Thomas Gleixner
60bf9b33c8
PCI/MSI: Move descriptor counting on allocation fail to the legacy code
...
The irqdomain code already returns the information. Move the loop to the
legacy code.
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 >
Link: https://lore.kernel.org/r/20211206210225.101336873@linutronix.de
2021-12-09 11:52:23 +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
Thomas Gleixner
cd119b09a8
PCI/MSI: Move msi_lock to struct pci_dev
...
It's only required for PCI/MSI. So no point in having it in every struct
device.
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/20211206210224.925241961@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
85aa607e79
PCI/MSI: Sanitize MSI-X table map handling
...
Unmapping the MSI-X base mapping in the loops which allocate/free MSI
descriptors is daft and in the way of allowing runtime expansion of MSI-X
descriptors.
Store the mapping in struct pci_dev and free it after freeing the MSI-X
descriptors.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210224.871651518@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
aa423ac422
PCI/MSI: Split out irqdomain code
...
Move the irqdomain specific code into its own 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.817754783@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
a01e09ef12
PCI/MSI: Split out !IRQDOMAIN code
...
Split out the non irqdomain code into its own 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.763574089@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
54324c2f3d
PCI/MSI: Split out CONFIG_PCI_MSI independent part
...
These functions are required even when CONFIG_PCI_MSI is not set. Move them
to their own 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.710137730@linutronix.de
2021-12-09 11:52:22 +01:00
Thomas Gleixner
288c81ce4b
PCI/MSI: Move code into a separate directory
...
msi.c is getting larger and really could do with a splitup. Move it into
its own directory to prepare for that.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com >
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Link: https://lore.kernel.org/r/20211206210224.655043033@linutronix.de
2021-12-09 11:52:22 +01:00