From patchwork Fri Aug 20 15:50:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12449681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67E71C4338F for ; Fri, 20 Aug 2021 15:52:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26863610FF for ; Fri, 20 Aug 2021 15:52:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 26863610FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=7uOY7OpnXXNTOCMDGe+mNjg3jJfYM4Q4pRU7E2EPF6M=; b=lKOBdHS4irtVxw rY1+a6ONJATuer5CS07blzCRuLwnqZ5jCA6oZqZeGhA/DErJ0/FRxOR2UnHL1uEuklAI/MFA4Jx8j 70j5XRbb4Kiwot/bZI+ZgQWmnBJntG5NecIAMzWiI6m1tcdO+U1/T8grzCpyOupOPlGx3/BLL2yTy 2SvcVHlX0HHO3vdqkjSXS09jAXcbp63jk/vYNgTXTNSSjY0rQK+HatB5mnbm8uWexoWKEBRRfgwWP NbaWOt7RCE4kO2xq9cWXvGgnDumE753vO9HhpodM2E5/zAt1PrmkUoPXOX57uv862V3JpCsbhLMKK Q3aQtbwRV6++yvR/njmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH6nA-00BYoX-Ek; Fri, 20 Aug 2021 15:50:48 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH6n4-00BYnO-6i for linux-arm-kernel@lists.infradead.org; Fri, 20 Aug 2021 15:50:45 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 356EB610FF; Fri, 20 Aug 2021 15:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629474639; bh=8CvVTyQLgyT4k1b1Kry/k0Zwq3bTzm48hEVEPj2TyQA=; h=From:To:Cc:Subject:Date:From; b=RrWyjeSbC8KF61Yxd8M5euzkXKYvhVUG9Rh0Q0CaEbPG0wjEAJ8a2hq2p7nrbHFL+ O2bBCmrc394BgCoVDLKPTvasV/tKQikzIVV6OhJvn2545N2hWRpXS2b1j7u3KNHwqW A/vDSNB9xSs7EW41z32uXmlAEioP278nPKVBFbLLffmrsTk5wNjr88Shxvijsp6g6m tjyLBSf2W5TjsV5BtHZNB7Ngfg7/R/1i62TbhGtOQ8tnLHxPWKWxrbeYlZcyRXru8V tK4l2f837YRsIUz5I7n6L2O1Xet7vt01WEGbowpuhif7fRgiFhvp872+oUKji5xG4f MZ0E+W2OLL7QA== Received: by pali.im (Postfix) id ADE627C5; Fri, 20 Aug 2021 17:50:36 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lorenzo Pieralisi , Rob Herring , Thomas Petazzoni , Bjorn Helgaas , Marc Zyngier , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI: aardvark: Fix masking and unmasking legacy INTx interrupts Date: Fri, 20 Aug 2021 17:50:20 +0200 Message-Id: <20210820155020.3000-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_085044_211664_0FF42FAE X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org irq_mask and irq_unmask callbacks need to be properly guarded by raw spin locks as masking/unmasking procedure needs atomic read-modify-write operation on hardware register. Signed-off-by: Pali Rohár Reported-by: Marc Zyngier Cc: stable@vger.kernel.org Acked-by: Marc Zyngier --- drivers/pci/controller/pci-aardvark.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index fb8060160251..a49e8bad9f4f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -234,6 +234,7 @@ struct advk_pcie { u8 wins_count; struct irq_domain *irq_domain; struct irq_chip irq_chip; + raw_spinlock_t irq_lock; struct irq_domain *msi_domain; struct irq_domain *msi_inner_domain; struct irq_chip msi_bottom_irq_chip; @@ -1087,22 +1088,28 @@ static void advk_pcie_irq_mask(struct irq_data *d) { struct advk_pcie *pcie = d->domain->host_data; irq_hw_number_t hwirq = irqd_to_hwirq(d); + unsigned long flags; u32 mask; + raw_spin_lock_irqsave(&pcie->irq_lock, flags); mask = advk_readl(pcie, PCIE_ISR1_MASK_REG); mask |= PCIE_ISR1_INTX_ASSERT(hwirq); advk_writel(pcie, mask, PCIE_ISR1_MASK_REG); + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); } static void advk_pcie_irq_unmask(struct irq_data *d) { struct advk_pcie *pcie = d->domain->host_data; irq_hw_number_t hwirq = irqd_to_hwirq(d); + unsigned long flags; u32 mask; + raw_spin_lock_irqsave(&pcie->irq_lock, flags); mask = advk_readl(pcie, PCIE_ISR1_MASK_REG); mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq); advk_writel(pcie, mask, PCIE_ISR1_MASK_REG); + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); } static int advk_pcie_irq_map(struct irq_domain *h, @@ -1186,6 +1193,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) struct irq_chip *irq_chip; int ret = 0; + raw_spin_lock_init(&pcie->irq_lock); + pcie_intc_node = of_get_next_child(node, NULL); if (!pcie_intc_node) { dev_err(dev, "No PCIe Intc node found\n");