Commit 112e43e9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Revert "Merge tag 'irq-msi-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip"



This reverts commit 36f5f026, reversing
changes made to 43a7eec0.

Thomas says:
 "I just noticed that for some incomprehensible reason, probably sheer
  incompetemce when trying to utilize b4, I managed to merge an outdated
  _and_ buggy version of that series.

  Can you please revert that merge completely?"

Done.

Requested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent acb4f337
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -106,10 +106,10 @@ int ntb_msi_setup_mws(struct ntb_dev *ntb)
	if (!ntb->msi)
		return -EINVAL;

	scoped_guard (msi_descs_lock, &ntb->pdev->dev) {
	msi_lock_descs(&ntb->pdev->dev);
	desc = msi_first_desc(&ntb->pdev->dev, MSI_DESC_ASSOCIATED);
	addr = desc->msg.address_lo + ((uint64_t)desc->msg.address_hi << 32);
	}
	msi_unlock_descs(&ntb->pdev->dev);

	for (peer = 0; peer < ntb_peer_port_count(ntb); peer++) {
		peer_widx = ntb_peer_highest_mw_idx(ntb, peer);
@@ -289,7 +289,7 @@ int ntbm_msi_request_threaded_irq(struct ntb_dev *ntb, irq_handler_t handler,
	if (!ntb->msi)
		return -EINVAL;

	guard(msi_descs_lock)(dev);
	msi_lock_descs(dev);
	msi_for_each_desc(entry, dev, MSI_DESC_ASSOCIATED) {
		if (irq_has_action(entry->irq))
			continue;
@@ -307,11 +307,17 @@ int ntbm_msi_request_threaded_irq(struct ntb_dev *ntb, irq_handler_t handler,
		ret = ntbm_msi_setup_callback(ntb, entry, msi_desc);
		if (ret) {
			devm_free_irq(&ntb->dev, entry->irq, dev_id);
			return ret;
			goto unlock;
		}
		return entry->irq;

		ret = entry->irq;
		goto unlock;
	}
	return -ENODEV;
	ret = -ENODEV;

unlock:
	msi_unlock_descs(dev);
	return ret;
}
EXPORT_SYMBOL(ntbm_msi_request_threaded_irq);

+10 −4
Original line number Diff line number Diff line
@@ -3975,18 +3975,24 @@ static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg)
{
	struct irq_data *irq_data;
	struct msi_desc *entry;
	int ret = 0;

	if (!pdev->msi_enabled && !pdev->msix_enabled)
		return 0;

	guard(msi_descs_lock)(&pdev->dev);
	msi_lock_descs(&pdev->dev);
	msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
		irq_data = irq_get_irq_data(entry->irq);
		if (WARN_ON_ONCE(!irq_data))
			return -EINVAL;
		if (WARN_ON_ONCE(!irq_data)) {
			ret = -EINVAL;
			break;
		}

		hv_compose_msi_msg(irq_data, &entry->msg);
	}
	return 0;
	msi_unlock_descs(&pdev->dev);

	return ret;
}

/*
+4 −2
Original line number Diff line number Diff line
@@ -53,9 +53,10 @@ void pci_disable_msi(struct pci_dev *dev)
	if (!pci_msi_enabled() || !dev || !dev->msi_enabled)
		return;

	guard(msi_descs_lock)(&dev->dev);
	msi_lock_descs(&dev->dev);
	pci_msi_shutdown(dev);
	pci_free_msi_irqs(dev);
	msi_unlock_descs(&dev->dev);
}
EXPORT_SYMBOL(pci_disable_msi);

@@ -195,9 +196,10 @@ void pci_disable_msix(struct pci_dev *dev)
	if (!pci_msi_enabled() || !dev || !dev->msix_enabled)
		return;

	guard(msi_descs_lock)(&dev->dev);
	msi_lock_descs(&dev->dev);
	pci_msix_shutdown(dev);
	pci_free_msi_irqs(dev);
	msi_unlock_descs(&dev->dev);
}
EXPORT_SYMBOL(pci_disable_msix);

+60 −107
Original line number Diff line number Diff line
@@ -335,11 +335,41 @@ static int msi_verify_entries(struct pci_dev *dev)
	return !entry ? 0 : -EIO;
}

static int __msi_capability_init(struct pci_dev *dev, int nvec, struct irq_affinity_desc *masks)
/**
 * msi_capability_init - configure device's MSI capability structure
 * @dev: pointer to the pci_dev data structure of MSI device function
 * @nvec: number of interrupts to allocate
 * @affd: description of automatic IRQ affinity assignments (may be %NULL)
 *
 * Setup the MSI capability structure of the device with the requested
 * number of interrupts.  A return value of zero indicates the successful
 * setup of an entry with the new MSI IRQ.  A negative return value indicates
 * an error, and a positive return value indicates the number of interrupts
 * which could have been allocated.
 */
static int msi_capability_init(struct pci_dev *dev, int nvec,
			       struct irq_affinity *affd)
{
	int ret = msi_setup_msi_desc(dev, nvec, masks);
	struct irq_affinity_desc *masks = NULL;
	struct msi_desc *entry, desc;
	int ret;

	/* Reject multi-MSI early on irq domain enabled architectures */
	if (nvec > 1 && !pci_msi_domain_supports(dev, MSI_FLAG_MULTI_PCI_MSI, ALLOW_LEGACY))
		return 1;

	/*
	 * Disable MSI during setup in the hardware, but mark it enabled
	 * so that setup code can evaluate it.
	 */
	pci_msi_set_enable(dev, 0);
	dev->msi_enabled = 1;

	if (affd)
		masks = irq_create_affinity_masks(nvec, affd);

	msi_lock_descs(&dev->dev);
	ret = msi_setup_msi_desc(dev, nvec, masks);
	if (ret)
		goto fail;

@@ -368,48 +398,19 @@ static int __msi_capability_init(struct pci_dev *dev, int nvec, struct irq_affin

	pcibios_free_irq(dev);
	dev->irq = entry->irq;
	return 0;
	goto unlock;

err:
	pci_msi_unmask(&desc, msi_multi_mask(&desc));
	pci_free_msi_irqs(dev);
fail:
	dev->msi_enabled = 0;
unlock:
	msi_unlock_descs(&dev->dev);
	kfree(masks);
	return ret;
}

/**
 * msi_capability_init - configure device's MSI capability structure
 * @dev: pointer to the pci_dev data structure of MSI device function
 * @nvec: number of interrupts to allocate
 * @affd: description of automatic IRQ affinity assignments (may be %NULL)
 *
 * Setup the MSI capability structure of the device with the requested
 * number of interrupts.  A return value of zero indicates the successful
 * setup of an entry with the new MSI IRQ.  A negative return value indicates
 * an error, and a positive return value indicates the number of interrupts
 * which could have been allocated.
 */
static int msi_capability_init(struct pci_dev *dev, int nvec,
			       struct irq_affinity *affd)
{
	/* Reject multi-MSI early on irq domain enabled architectures */
	if (nvec > 1 && !pci_msi_domain_supports(dev, MSI_FLAG_MULTI_PCI_MSI, ALLOW_LEGACY))
		return 1;

	/*
	 * Disable MSI during setup in the hardware, but mark it enabled
	 * so that setup code can evaluate it.
	 */
	pci_msi_set_enable(dev, 0);
	dev->msi_enabled = 1;

	struct irq_affinity_desc *masks __free(kfree) =
		affd ? irq_create_affinity_masks(nvec, affd) : NULL;

	guard(msi_descs_lock)(&dev->dev);
	return __msi_capability_init(dev, nvec, masks);
}

int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
			   struct irq_affinity *affd)
{
@@ -662,41 +663,40 @@ static void msix_mask_all(void __iomem *base, int tsize)
		writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
}

static int __msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
				   int nvec, struct irq_affinity_desc *masks)
static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
				 int nvec, struct irq_affinity *affd)
{
	int ret = msix_setup_msi_descs(dev, entries, nvec, masks);
	struct irq_affinity_desc *masks = NULL;
	int ret;

	if (affd)
		masks = irq_create_affinity_masks(nvec, affd);

	msi_lock_descs(&dev->dev);
	ret = msix_setup_msi_descs(dev, entries, nvec, masks);
	if (ret)
		goto fail;
		goto out_free;

	ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
	if (ret)
		goto fail;
		goto out_free;

	/* Check if all MSI entries honor device restrictions */
	ret = msi_verify_entries(dev);
	if (ret)
		goto fail;
		goto out_free;

	msix_update_entries(dev, entries);
	return 0;
	goto out_unlock;

fail:
out_free:
	pci_free_msi_irqs(dev);
out_unlock:
	msi_unlock_descs(&dev->dev);
	kfree(masks);
	return ret;
}

static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
				 int nvec, struct irq_affinity *affd)
{
	struct irq_affinity_desc *masks __free(kfree) =
		affd ? irq_create_affinity_masks(nvec, affd) : NULL;

	guard(msi_descs_lock)(&dev->dev);
	return __msix_setup_interrupts(dev, entries, nvec, masks);
}

/**
 * msix_capability_init - configure device's MSI-X capability
 * @dev: pointer to the pci_dev data structure of MSI-X device function
@@ -870,13 +870,13 @@ void __pci_restore_msix_state(struct pci_dev *dev)

	write_msg = arch_restore_msi_irqs(dev);

	scoped_guard (msi_descs_lock, &dev->dev) {
	msi_lock_descs(&dev->dev);
	msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
		if (write_msg)
			__pci_write_msi_msg(entry, &entry->msg);
		pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl);
	}
	}
	msi_unlock_descs(&dev->dev);

	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
}
@@ -915,53 +915,6 @@ void pci_free_msi_irqs(struct pci_dev *dev)
	}
}

#ifdef CONFIG_PCIE_TPH
/**
 * pci_msix_write_tph_tag - Update the TPH tag for a given MSI-X vector
 * @pdev:	The PCIe device to update
 * @index:	The MSI-X index to update
 * @tag:	The tag to write
 *
 * Returns: 0 on success, error code on failure
 */
int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int index, u16 tag)
{
	struct msi_desc *msi_desc;
	struct irq_desc *irq_desc;
	unsigned int virq;

	if (!pdev->msix_enabled)
		return -ENXIO;

	guard(msi_descs_lock)(&pdev->dev);
	virq = msi_get_virq(&pdev->dev, index);
	if (!virq)
		return -ENXIO;
	/*
	 * This is a horrible hack, but short of implementing a PCI
	 * specific interrupt chip callback and a huge pile of
	 * infrastructure, this is the minor nuissance. It provides the
	 * protection against concurrent operations on this entry and keeps
	 * the control word cache in sync.
	 */
	irq_desc = irq_to_desc(virq);
	if (!irq_desc)
		return -ENXIO;

	guard(raw_spinlock_irq)(&irq_desc->lock);
	msi_desc = irq_data_get_msi_desc(&irq_desc->irq_data);
	if (!msi_desc || msi_desc->pci.msi_attrib.is_virtual)
		return -ENXIO;

	msi_desc->pci.msix_ctrl &= ~PCI_MSIX_ENTRY_CTRL_ST;
	msi_desc->pci.msix_ctrl |= FIELD_PREP(PCI_MSIX_ENTRY_CTRL_ST, tag);
	pci_msix_write_vector_ctrl(msi_desc, msi_desc->pci.msix_ctrl);
	/* Flush the write */
	readl(pci_msix_desc_addr(msi_desc));
	return 0;
}
#endif

/* Misc. infrastructure */

struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc)
+0 −9
Original line number Diff line number Diff line
@@ -989,15 +989,6 @@ int pcim_request_region_exclusive(struct pci_dev *pdev, int bar,
				  const char *name);
void pcim_release_region(struct pci_dev *pdev, int bar);

#ifdef CONFIG_PCI_MSI
int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int index, u16 tag);
#else
static inline int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int index, u16 tag)
{
	return -ENODEV;
}
#endif

/*
 * Config Address for PCI Configuration Mechanism #1
 *
Loading