Skip to content

Commit

Permalink
PCI: xilinx-nwl: Modify IRQ chip for legacy interrupts
Browse files Browse the repository at this point in the history
- 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 <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  • Loading branch information
Bharat Kumar Gogada authored and bjorn-helgaas committed Jul 2, 2017
1 parent 769b461 commit 9a181e1
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion drivers/pci/host/pcie-xilinx-nwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ struct nwl_pcie {
u8 root_busno;
struct nwl_msi msi;
struct irq_domain *legacy_irq_domain;
raw_spinlock_t leg_mask_lock;
};

static inline u32 nwl_bridge_readl(struct nwl_pcie *pcie, u32 off)
Expand Down Expand Up @@ -383,11 +384,52 @@ static void nwl_pcie_msi_handler_low(struct irq_desc *desc)
chained_irq_exit(chip, desc);
}

static void nwl_mask_leg_irq(struct irq_data *data)
{
struct irq_desc *desc = irq_to_desc(data->irq);
struct nwl_pcie *pcie;
unsigned long flags;
u32 mask;
u32 val;

pcie = irq_desc_get_chip_data(desc);
mask = 1 << (data->hwirq - 1);
raw_spin_lock_irqsave(&pcie->leg_mask_lock, flags);
val = nwl_bridge_readl(pcie, MSGF_LEG_MASK);
nwl_bridge_writel(pcie, (val & (~mask)), MSGF_LEG_MASK);
raw_spin_unlock_irqrestore(&pcie->leg_mask_lock, flags);
}

static void nwl_unmask_leg_irq(struct irq_data *data)
{
struct irq_desc *desc = irq_to_desc(data->irq);
struct nwl_pcie *pcie;
unsigned long flags;
u32 mask;
u32 val;

pcie = irq_desc_get_chip_data(desc);
mask = 1 << (data->hwirq - 1);
raw_spin_lock_irqsave(&pcie->leg_mask_lock, flags);
val = nwl_bridge_readl(pcie, MSGF_LEG_MASK);
nwl_bridge_writel(pcie, (val | mask), MSGF_LEG_MASK);
raw_spin_unlock_irqrestore(&pcie->leg_mask_lock, flags);
}

static struct irq_chip nwl_leg_irq_chip = {
.name = "nwl_pcie:legacy",
.irq_enable = nwl_unmask_leg_irq,
.irq_disable = nwl_mask_leg_irq,
.irq_mask = nwl_mask_leg_irq,
.irq_unmask = nwl_unmask_leg_irq,
};

static int nwl_legacy_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq)
{
irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
irq_set_chip_and_handler(irq, &nwl_leg_irq_chip, handle_level_irq);
irq_set_chip_data(irq, domain->host_data);
irq_set_status_flags(irq, IRQ_LEVEL);

return 0;
}
Expand Down Expand Up @@ -526,6 +568,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
return -ENOMEM;
}

raw_spin_lock_init(&pcie->leg_mask_lock);
nwl_pcie_init_msi_irq_domain(pcie);
return 0;
}
Expand Down

0 comments on commit 9a181e1

Please sign in to comment.