serial/pci_16550: make sure that interrupts are disabled during init
Make sure that interrups are disabled during initialization. This is a proper fix for an unexpected MSI interrupt for PCI serial driver. Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
parent
f76c2ed83b
commit
545774eb88
@ -546,6 +546,7 @@ static int pci_u16550_initialize(FAR struct pci_u16550_priv_s *priv,
|
|||||||
bool mmio)
|
bool mmio)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int offset;
|
||||||
|
|
||||||
/* Configure UART PCI */
|
/* Configure UART PCI */
|
||||||
|
|
||||||
@ -563,6 +564,14 @@ static int pci_u16550_initialize(FAR struct pci_u16550_priv_s *priv,
|
|||||||
priv->common.regincr = type->regincr;
|
priv->common.regincr = type->regincr;
|
||||||
priv->pcidev = dev;
|
priv->pcidev = dev;
|
||||||
|
|
||||||
|
/* Make sure that all interrupts are disabled otherwise spurious MSI
|
||||||
|
* interrupt can happen just after we connect MSI.
|
||||||
|
*/
|
||||||
|
|
||||||
|
offset = (priv->common.regincr * sizeof(uart_datawidth_t) *
|
||||||
|
UART_IER_OFFSET);
|
||||||
|
priv->common.ops->putreg(&priv->common, offset, 0);
|
||||||
|
|
||||||
/* Allocate and connect MSI if supported */
|
/* Allocate and connect MSI if supported */
|
||||||
|
|
||||||
ret = pci_alloc_irq(dev, &priv->common.irq, 1);
|
ret = pci_alloc_irq(dev, &priv->common.irq, 1);
|
||||||
@ -586,14 +595,6 @@ legacy_irq:
|
|||||||
|
|
||||||
priv->common.irq = pci_get_irq(dev);
|
priv->common.irq = pci_get_irq(dev);
|
||||||
|
|
||||||
/* Attach interrupts early to prevent unexpected isr fault */
|
|
||||||
|
|
||||||
ret = irq_attach(priv->common.irq, priv->common.ops->isr, dev);
|
|
||||||
if (ret != OK)
|
|
||||||
{
|
|
||||||
pcierr("Failed to attach irq %d\n", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user