spi: spi-pci1xxxx: Fix Probe failure with Dual SPI instance with INTx interrupts
PATCH 1/1 spi: spi-pci1xxxx: Fix Probe failure with Dual SPI instance with INTx interrupts
Fixes a probe failure that occurs when dual SPI controllers are enabled and INTx interrupts are used. Reduces the minimum required number of interrupt vectors to 1 and registers a shared ISR when the allocated vectors are fewer than the number of controllers. This change ensures that the probe succeeds even with limited vectors, restoring INTx functionality when multiple SPI controllers are present.
--- drivers/spi/spi-pci1xxxx.c | 48 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-)
drivers/spi/spi-pci1xxxx.c +34 -14
@@ -688,6 +688,17 @@ static irqreturn_t pci1xxxx_spi_isr(int irq, void *dev)return pci1xxxx_spi_isr_io (irq, dev); } +static irqreturn_t pci1xxxx_spi_shared_isr (int irq,void *dev) +{ +struct pci1xxxx_spi *par = dev; +u8 i =0 ; + +for (i =0 ; i < par->total_hw_instances; i++) +pci1xxxx_spi_isr (irq, par->spi_int[i]); + +return IRQ_HANDLED ; +} +static bool pci1xxxx_spi_can_dma (struct spi_controller *host,struct spi_device *spi,struct spi_transfer *xfer)
@@ -705,6 +716,7 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *struct device *dev = &pdev->dev;struct pci1xxxx_spi *spi_bus;struct spi_controller *spi_host; +int num_vector =0 ;u32 regval;int ret;
@@ -752,9 +764,9 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *if (!spi_bus->reg_base)return -EINVAL ; - ret =pci_alloc_irq_vectors (pdev, hw_inst_cnt, hw_inst_cnt, -PCI_IRQ_ALL_TYPES ); -if (ret <0 ) { + num_vector =pci_alloc_irq_vectors (pdev,1 , hw_inst_cnt, +PCI_IRQ_ALL_TYPES ); +if (num_vector <0 ) {dev_err (&pdev->dev,"Error allocating MSI vectors\n" );return ret; }
@@ -768,9 +780,15 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id * SPI_MST_EVENT_MASK_REG_OFFSET(spi_sub_ptr->hw_inst)); spi_sub_ptr->irq =pci_irq_vector (pdev,0 ); - ret =devm_request_irq (&pdev->dev, spi_sub_ptr->irq, - pci1xxxx_spi_isr,PCI1XXXX_IRQ_FLAGS , -pci_name (pdev), spi_sub_ptr); +if (num_vector >= hw_inst_cnt) + ret =devm_request_irq (&pdev->dev, spi_sub_ptr->irq, + pci1xxxx_spi_isr,PCI1XXXX_IRQ_FLAGS , +pci_name (pdev), spi_sub_ptr); +else + ret =devm_request_irq (&pdev->dev, spi_sub_ptr->irq, + pci1xxxx_spi_shared_isr, +PCI1XXXX_IRQ_FLAGS |IRQF_SHARED , +pci_name (pdev), spi_bus);if (ret <0 ) {dev_err (&pdev->dev,"Unable to request irq : %d" , spi_sub_ptr->irq);
@@ -801,14 +819,16 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id * regval &= ~SPI_INTR ;writel (regval, spi_bus->reg_base +SPI_MST_EVENT_MASK_REG_OFFSET (spi_sub_ptr->hw_inst)); - spi_sub_ptr->irq =pci_irq_vector (pdev, iter); - ret =devm_request_irq (&pdev->dev, spi_sub_ptr->irq, - pci1xxxx_spi_isr,PCI1XXXX_IRQ_FLAGS , -pci_name (pdev), spi_sub_ptr); -if (ret <0 ) { -dev_err (&pdev->dev,"Unable to request irq : %d" , - spi_sub_ptr->irq); -return -ENODEV ; +if (num_vector >= hw_inst_cnt) { + spi_sub_ptr->irq =pci_irq_vector (pdev, iter); + ret =devm_request_irq (&pdev->dev, spi_sub_ptr->irq, + pci1xxxx_spi_isr,PCI1XXXX_IRQ_FLAGS , +pci_name (pdev), spi_sub_ptr); +if (ret <0 ) { +dev_err (&pdev->dev,"Unable to request irq : %d" , + spi_sub_ptr->irq); +return -ENODEV ; + } } }
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Thangaraj Samynathan
Fixes a probe failure that occurs when dual SPI controllers are enabled and INTx interrupts are used. Reduces the minimum required number of interrupt vectors to 1 and registers a shared ISR when the allocated vectors are fewer than the number of controllers. This change ensures that the probe succeeds even with limited vectors, restoring INTx functionality when multiple SPI controllers are present.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-pci1xxxx: Fix Probe failure with Dual SPI instance with INTx interrupts
commit: b4608e944177531334a79f3df2cd14275b47808c
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark