Re: [PATCH] incremental fix for NIU MSI-X problem

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

 



Hi Matthew,

This would be a bad news.  I'd like to request you to make a fix.

Matthew Wilcox wrote:
> @@ -442,7 +445,6 @@ static int msix_capability_init(struct pci_dev *dev,
>  	if (base == NULL)
>  		return -ENOMEM;
>  
> -	/* MSI-X Table Initialization */
>  	for (i = 0; i < nvec; i++) {
>  		entry = alloc_msi_entry(dev);
>  		if (!entry)
> @@ -455,7 +457,6 @@ static int msix_capability_init(struct pci_dev *dev,
>  		entry->msi_attrib.default_irq = dev->irq;
>  		entry->msi_attrib.pos = pos;
>  		entry->mask_base = base;
> -		msix_mask_irq(entry, 1);
>  
>  		list_add_tail(&entry->list, &dev->msi_list);
>  	}

I found that we do write to Vector Control register in msi_free_irqs()
to mask the entry.  It means that NIU will have same problem within the
pci_disable_msix(), so we need more fix (or rework of this patch) for it.

static int msi_free_irqs(struct pci_dev* dev)
{
 :
	list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
		if (entry->msi_attrib.is_msix) {
			writel(1, entry->mask_base + entry->msi_attrib.entry_nr
				  * PCI_MSIX_ENTRY_SIZE
				  + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
 :
}

And it also has preserved bits problem too.
We should use msix_mask_irq() instead of above writel.
And we should not use call msi_free_irqs() from error path around here in msix_capability_init() where the preserved bits are not saved yet.

> @@ -480,22 +481,31 @@ static int msix_capability_init(struct pci_dev *dev,
>  		return ret;
>  	}
>  
> +	/*
> +	 * Some devices require MSI-X to be enabled before we can touch the
> +	 * MSI-X registers.  We need to mask all the vectors to prevent
> +	 * interrupts coming in before they're fully set up.
> +	 */
> +	control |= PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE;
> +	pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
> +
>  	i = 0;
>  	list_for_each_entry(entry, &dev->msi_list, list) {
>  		entries[i].vector = entry->irq;
>  		set_irq_msi(entry->irq, entry);
> +		j = entries[i].entry;
> +		entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE +
> +					PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
> +		msix_mask_irq(entry, 1);
>  		i++;
>  	}
> -	/* Set MSI-X enabled bits */
> +
> +	/* Set MSI-X enabled bits and unmask the function */
>  	pci_intx_for_msi(dev, 0);
> -	msix_set_enable(dev, 1);
>  	dev->msix_enabled = 1;
>  
> -	list_for_each_entry(entry, &dev->msi_list, list) {
> -		int vector = entry->msi_attrib.entry_nr;
> -		entry->masked = readl(base + vector * PCI_MSIX_ENTRY_SIZE +
> -					PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
> -	}
> +	control &= ~PCI_MSIX_FLAGS_MASKALL;
> +	pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
>  
>  	return 0;
>  }

Thanks,
H.Seto

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux