Skip to content

Commit 4caab28

Browse files
khayash1Lorenzo Pieralisi
authored andcommitted
PCI: uniphier: Serialize INTx masking/unmasking and fix the bit operation
The condition register PCI_RCV_INTX is used in irq_mask() and irq_unmask() callbacks. Accesses to register can occur at the same time without a lock. Add a lock into each callback to prevent the issue. And INTX mask and unmask fields in PCL_RCV_INTX register should only be set/reset for each bit. Clearing by PCL_RCV_INTX_ALL_MASK should be removed. INTX status fields in PCL_RCV_INTX register only indicates each INTX interrupt status, so the handler can't clear by writing 1 to the field. The status is expected to be cleared by the interrupt origin. The ack function has no meaning, so should remove it. Suggested-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/1631924579-24567-1-git-send-email-hayashi.kunihiko@socionext.com Fixes: 7e6d5cd ("PCI: uniphier: Add UniPhier PCIe host controller support") Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Pali Rohár <pali@kernel.org> Acked-by: Marc Zyngier <maz@kernel.org>
1 parent 7e91967 commit 4caab28

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

‎drivers/pci/controller/dwc/pcie-uniphier.c‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,48 +168,42 @@ static void uniphier_pcie_irq_enable(struct uniphier_pcie_priv *priv)
168168
writel(PCL_RCV_INTX_ALL_ENABLE, priv->base + PCL_RCV_INTX);
169169
}
170170

171-
static void uniphier_pcie_irq_ack(struct irq_data *d)
172-
{
173-
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
174-
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
175-
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
176-
u32 val;
177-
178-
val = readl(priv->base + PCL_RCV_INTX);
179-
val &= ~PCL_RCV_INTX_ALL_STATUS;
180-
val |= BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_STATUS_SHIFT);
181-
writel(val, priv->base + PCL_RCV_INTX);
182-
}
183-
184171
static void uniphier_pcie_irq_mask(struct irq_data *d)
185172
{
186173
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
187174
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
188175
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
176+
unsigned long flags;
189177
u32 val;
190178

179+
raw_spin_lock_irqsave(&pp->lock, flags);
180+
191181
val = readl(priv->base + PCL_RCV_INTX);
192-
val &= ~PCL_RCV_INTX_ALL_MASK;
193182
val |= BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT);
194183
writel(val, priv->base + PCL_RCV_INTX);
184+
185+
raw_spin_unlock_irqrestore(&pp->lock, flags);
195186
}
196187

197188
static void uniphier_pcie_irq_unmask(struct irq_data *d)
198189
{
199190
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
200191
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
201192
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
193+
unsigned long flags;
202194
u32 val;
203195

196+
raw_spin_lock_irqsave(&pp->lock, flags);
197+
204198
val = readl(priv->base + PCL_RCV_INTX);
205-
val &= ~PCL_RCV_INTX_ALL_MASK;
206199
val &= ~BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT);
207200
writel(val, priv->base + PCL_RCV_INTX);
201+
202+
raw_spin_unlock_irqrestore(&pp->lock, flags);
208203
}
209204

210205
static struct irq_chip uniphier_pcie_irq_chip = {
211206
.name = "PCI",
212-
.irq_ack = uniphier_pcie_irq_ack,
213207
.irq_mask = uniphier_pcie_irq_mask,
214208
.irq_unmask = uniphier_pcie_irq_unmask,
215209
};

0 commit comments

Comments
 (0)