Skip to content

Commit 9a181e1

Browse files
Bharat Kumar Gogadabjorn-helgaas
Bharat Kumar Gogada
authored andcommitted
PCI: xilinx-nwl: Modify IRQ chip for legacy interrupts
- Add spinlock for protecting legacy mask register - Few wifi end points which only support legacy interrupts, performs hardware reset functionalities after disabling interrupts by invoking disable_irq() and then re-enable using enable_irq(), they enable hardware interrupts first and then virtual IRQ line later. - The legacy IRQ line goes low only after DEASSERT_INTx is received. As the legacy IRQ line is high immediately after hardware interrupts are enabled but virq of EP is still in disabled state and EP handler is never executed resulting no DEASSERT_INTx. If dummy IRQ chip is used, interrupts are not masked and system hangs with CPU stall. - Add IRQ chip functions instead of dummy IRQ chip for legacy interrupts. - Legacy interrupts are level sensitive, so using handle_level_irq() is more appropriate as it is masks interrupts until Endpoint handles interrupts and unmasks interrupts after Endpoint handler is executed. - Legacy interrupts are level triggered, virtual IRQ line of EndPoint shows as edge in /proc/interrupts. - Set IRQ flags of virtual IRQ line of EP to level triggered at the time of mapping. Signed-off-by: Bharat Kumar Gogada <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 769b461 commit 9a181e1

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

drivers/pci/host/pcie-xilinx-nwl.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ struct nwl_pcie {
172172
u8 root_busno;
173173
struct nwl_msi msi;
174174
struct irq_domain *legacy_irq_domain;
175+
raw_spinlock_t leg_mask_lock;
175176
};
176177

177178
static inline u32 nwl_bridge_readl(struct nwl_pcie *pcie, u32 off)
@@ -383,11 +384,52 @@ static void nwl_pcie_msi_handler_low(struct irq_desc *desc)
383384
chained_irq_exit(chip, desc);
384385
}
385386

387+
static void nwl_mask_leg_irq(struct irq_data *data)
388+
{
389+
struct irq_desc *desc = irq_to_desc(data->irq);
390+
struct nwl_pcie *pcie;
391+
unsigned long flags;
392+
u32 mask;
393+
u32 val;
394+
395+
pcie = irq_desc_get_chip_data(desc);
396+
mask = 1 << (data->hwirq - 1);
397+
raw_spin_lock_irqsave(&pcie->leg_mask_lock, flags);
398+
val = nwl_bridge_readl(pcie, MSGF_LEG_MASK);
399+
nwl_bridge_writel(pcie, (val & (~mask)), MSGF_LEG_MASK);
400+
raw_spin_unlock_irqrestore(&pcie->leg_mask_lock, flags);
401+
}
402+
403+
static void nwl_unmask_leg_irq(struct irq_data *data)
404+
{
405+
struct irq_desc *desc = irq_to_desc(data->irq);
406+
struct nwl_pcie *pcie;
407+
unsigned long flags;
408+
u32 mask;
409+
u32 val;
410+
411+
pcie = irq_desc_get_chip_data(desc);
412+
mask = 1 << (data->hwirq - 1);
413+
raw_spin_lock_irqsave(&pcie->leg_mask_lock, flags);
414+
val = nwl_bridge_readl(pcie, MSGF_LEG_MASK);
415+
nwl_bridge_writel(pcie, (val | mask), MSGF_LEG_MASK);
416+
raw_spin_unlock_irqrestore(&pcie->leg_mask_lock, flags);
417+
}
418+
419+
static struct irq_chip nwl_leg_irq_chip = {
420+
.name = "nwl_pcie:legacy",
421+
.irq_enable = nwl_unmask_leg_irq,
422+
.irq_disable = nwl_mask_leg_irq,
423+
.irq_mask = nwl_mask_leg_irq,
424+
.irq_unmask = nwl_unmask_leg_irq,
425+
};
426+
386427
static int nwl_legacy_map(struct irq_domain *domain, unsigned int irq,
387428
irq_hw_number_t hwirq)
388429
{
389-
irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
430+
irq_set_chip_and_handler(irq, &nwl_leg_irq_chip, handle_level_irq);
390431
irq_set_chip_data(irq, domain->host_data);
432+
irq_set_status_flags(irq, IRQ_LEVEL);
391433

392434
return 0;
393435
}
@@ -526,6 +568,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
526568
return -ENOMEM;
527569
}
528570

571+
raw_spin_lock_init(&pcie->leg_mask_lock);
529572
nwl_pcie_init_msi_irq_domain(pcie);
530573
return 0;
531574
}

0 commit comments

Comments
 (0)