Skip to content

Commit 0b73c02

Browse files
khayash1gregkh
authored andcommitted
PCI: uniphier: Serialize INTx masking/unmasking and fix the bit operation
[ Upstream commit 4caab28 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d2ff7a8 commit 0b73c02

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
@@ -171,48 +171,42 @@ static void uniphier_pcie_irq_enable(struct uniphier_pcie_priv *priv)
171171
writel(PCL_RCV_INTX_ALL_ENABLE, priv->base + PCL_RCV_INTX);
172172
}
173173

174-
static void uniphier_pcie_irq_ack(struct irq_data *d)
175-
{
176-
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
177-
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
178-
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
179-
u32 val;
180-
181-
val = readl(priv->base + PCL_RCV_INTX);
182-
val &= ~PCL_RCV_INTX_ALL_STATUS;
183-
val |= BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_STATUS_SHIFT);
184-
writel(val, priv->base + PCL_RCV_INTX);
185-
}
186-
187174
static void uniphier_pcie_irq_mask(struct irq_data *d)
188175
{
189176
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
190177
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
191178
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
179+
unsigned long flags;
192180
u32 val;
193181

182+
raw_spin_lock_irqsave(&pp->lock, flags);
183+
194184
val = readl(priv->base + PCL_RCV_INTX);
195-
val &= ~PCL_RCV_INTX_ALL_MASK;
196185
val |= BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT);
197186
writel(val, priv->base + PCL_RCV_INTX);
187+
188+
raw_spin_unlock_irqrestore(&pp->lock, flags);
198189
}
199190

200191
static void uniphier_pcie_irq_unmask(struct irq_data *d)
201192
{
202193
struct pcie_port *pp = irq_data_get_irq_chip_data(d);
203194
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
204195
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
196+
unsigned long flags;
205197
u32 val;
206198

199+
raw_spin_lock_irqsave(&pp->lock, flags);
200+
207201
val = readl(priv->base + PCL_RCV_INTX);
208-
val &= ~PCL_RCV_INTX_ALL_MASK;
209202
val &= ~BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT);
210203
writel(val, priv->base + PCL_RCV_INTX);
204+
205+
raw_spin_unlock_irqrestore(&pp->lock, flags);
211206
}
212207

213208
static struct irq_chip uniphier_pcie_irq_chip = {
214209
.name = "PCI",
215-
.irq_ack = uniphier_pcie_irq_ack,
216210
.irq_mask = uniphier_pcie_irq_mask,
217211
.irq_unmask = uniphier_pcie_irq_unmask,
218212
};

0 commit comments

Comments
 (0)