How to handle PCIe MSI interupts

Would you please tell me how to handle the specific PCIe MSI vector?
The following code returns 1 to indicate the number of MSI vectors is just one.

err = pci_enable_msi_range(pdev, 1, SAP_NUM_MSI_VECTORS_REQUEST);

However, the driver code (kernel-4.4/drivers/pci/host/pci-tegra.c) seems to check the all 256 (= 8 * 32) MSI vectors. Is there any Tegra specific API function to know the MSI vector triggered?

static irqreturn_t tegra_pcie_msi_irq(int irq, void *data)
	struct tegra_pcie *pcie = data;
	struct tegra_msi *msi = &pcie->msi;
	unsigned int i, processed = 0;


	for (i = 0; i < 8; i++) {
		unsigned long reg = afi_readl(pcie, AFI_MSI_VEC0_0 + i * 4);

		while (reg) {
			unsigned int offset = find_first_bit(&reg, 32);
			unsigned int index = i * 32 + offset;
			unsigned int irq_num;

			/* check if there are any interrupts in this reg */
			if (offset == 32)

			/* clear the interrupt */
			afi_writel(pcie, 1 << offset, AFI_MSI_VEC0_0 + i * 4);

			irq_num = irq_find_mapping(msi->domain, index);
			if (irq_num) {
				if (test_bit(index, msi->used))
					dev_info(pcie->dev, "unhandled MSI\n");
			} else {
				 * that's weird who triggered this?
				 * just clear it
				dev_info(pcie->dev, "unexpected MSI\n");

			/* see if there's any more pending in this vector */
			reg = afi_readl(pcie, AFI_MSI_VEC0_0 + i * 4);


	return processed > 0 ? IRQ_HANDLED : IRQ_NONE;



I’d like to know if L4T PCIe driver can handle MSI vectors.

The return value 1 from pci_enable_msi_range(pdev, 1, SAP_NUM_MSI_VECTORS_REQUEST), means no support of MSI vectors?


If it is returning ‘1’, it means that ‘1’ MSI interrupt is already allocated. Please check the API documentation.
L4T PCIe host controller driver does support/handle MSI interrupt.
For some legacy reasons, we are not supporting more than one MSI interrupt, hence, even if more are asked, only one will be allocated. You can request MSI-X interrupts (if your end point supports) and you can get more than one (in fact how many ever you want)


Thank you.