Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6244680iob; Tue, 10 May 2022 13:49:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU68+Qjlz1D4PlUD9M+vqwYFjaX1lgPCJ+/kjHolCfAvvZXYOQkbNJhcHkV1DT8pYFdAku X-Received: by 2002:a17:907:62a9:b0:6da:7953:4df0 with SMTP id nd41-20020a17090762a900b006da79534df0mr21536959ejc.316.1652215756081; Tue, 10 May 2022 13:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652215756; cv=none; d=google.com; s=arc-20160816; b=TExR12oYfdxQ9f0VRm1S4lrg6QtbA3a8uTzVRNlSpsHGG0iP32xubtSiDI1pd0IoCe iymQ98arJ5PHFmtMjn4/IzHRsrBbpFrOTpKSCQOC8acFW8DkjoHiX1brNG1rCXCHlMmq BaR5nMnJA5glYL8i7fMsLpVa/YRN9gclHl5vNbuFO0KlR58uumO8p1rloCpmw4rqBQk9 R/rvULtJ99GmnzQdyI8x5o1FepNFKD/4JRbiNJ77S5k+xvf+rxOHTsE/qv9qjZrEsLky xab7071ZywKOej5x35DGtxtqCiVtpQmounPNo7hC4To3MtaUg3xEfGzcK8ff4D41BEit 4A4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=47EZJv2lnHrwxLG7/apvNbn6+4KFe6t0iXIOm79tN+g=; b=uHiT1TyifFPAx9A8InxWVxNjmFziaDRYxBy80AaErhhsBqE7gek0/fJz9VrevL/Izy nN7KlhfMgPrbQahahINtr9xBZOpD09MYGHzzEKvF2UMGvk87yHPjbCdFwDL05PjCgC8S Qz06l3vZFBsqYNxWhJC/scmV5J0pw8cAO/vjdHqgD+ihzafBRc2TIXQsUEQydM64PXpa tX8ZjnMKxv9SeidtXPExFSa5hUgzCjjigLHhYdtdbZoF+D1Rv2h+XKjV/1JM4PLvdw4l VcjxDp1lzXzK0j0eVDL2Ux5NChI56ytd5nRWjSkWdJms9VHgqWskT7Hq1dW6KTqP05zB rG+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hv/6NYQ1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020a508a8c000000b00427f46f080bsi184564edj.624.2022.05.10.13.48.52; Tue, 10 May 2022 13:49:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hv/6NYQ1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243116AbiEJOfw (ORCPT + 99 others); Tue, 10 May 2022 10:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244853AbiEJOIP (ORCPT ); Tue, 10 May 2022 10:08:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F4382716CD; Tue, 10 May 2022 06:42:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C0F661931; Tue, 10 May 2022 13:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4950C385A6; Tue, 10 May 2022 13:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652190142; bh=3BROekrajQ8eZtFfapC/03jcVX2gHLm08MrUKeGjcLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hv/6NYQ1XExGXFp9g1I2CPdt89WrzMhHW+RrVsygrShI+OvQOguOvUBa2vNejFILl 6Rz6KOJX1FMDq9VNncaRpn6aKtaochPXiZda4HQg1hr08VhudLT3AVZ7RSkHKUO6x9 MhqziZCsrQ1CT4qE5GkypJ7/doAWGOahhuAwUJIY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, pali@kernel.org, =?UTF-8?q?Marek=20Beh=FAn?= , Lorenzo Pieralisi Subject: [PATCH 5.17 129/140] PCI: aardvark: Add support for masking MSI interrupts Date: Tue, 10 May 2022 15:08:39 +0200 Message-Id: <20220510130745.281245324@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130741.600270947@linuxfoundation.org> References: <20220510130741.600270947@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Roh?r commit e77d9c90691071769cd2b86ef097f7d07167dc3b upstream. We should not unmask MSIs at setup, but only when kernel asks for them to be unmasked. At setup, mask all MSIs, and implement IRQ chip callbacks for masking and unmasking particular MSIs. Link: https://lore.kernel.org/r/20220110015018.26359-11-kabel@kernel.org Signed-off-by: Pali Roh?r Signed-off-by: Marek Beh?n Signed-off-by: Lorenzo Pieralisi Signed-off-by: Marek Beh?n Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-aardvark.c | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -274,6 +274,7 @@ struct advk_pcie { raw_spinlock_t irq_lock; struct irq_domain *msi_domain; struct irq_domain *msi_inner_domain; + raw_spinlock_t msi_irq_lock; DECLARE_BITMAP(msi_used, MSI_IRQ_NUM); struct mutex msi_used_lock; u16 msi_msg; @@ -570,12 +571,10 @@ static void advk_pcie_setup_hw(struct ad advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_REG); advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG); - /* Disable All ISR0/1 Sources */ + /* Disable All ISR0/1 and MSI Sources */ advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_MASK_REG); advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG); - - /* Unmask all MSIs */ - advk_writel(pcie, ~(u32)PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); + advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); /* Unmask summary MSI interrupt */ reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); @@ -1191,10 +1190,52 @@ static int advk_msi_set_affinity(struct return -EINVAL; } +static void advk_msi_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->msi_irq_lock, flags); + mask = advk_readl(pcie, PCIE_MSI_MASK_REG); + mask |= BIT(hwirq); + advk_writel(pcie, mask, PCIE_MSI_MASK_REG); + raw_spin_unlock_irqrestore(&pcie->msi_irq_lock, flags); +} + +static void advk_msi_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->msi_irq_lock, flags); + mask = advk_readl(pcie, PCIE_MSI_MASK_REG); + mask &= ~BIT(hwirq); + advk_writel(pcie, mask, PCIE_MSI_MASK_REG); + raw_spin_unlock_irqrestore(&pcie->msi_irq_lock, flags); +} + +static void advk_msi_top_irq_mask(struct irq_data *d) +{ + pci_msi_mask_irq(d); + irq_chip_mask_parent(d); +} + +static void advk_msi_top_irq_unmask(struct irq_data *d) +{ + pci_msi_unmask_irq(d); + irq_chip_unmask_parent(d); +} + static struct irq_chip advk_msi_bottom_irq_chip = { .name = "MSI", .irq_compose_msi_msg = advk_msi_irq_compose_msi_msg, .irq_set_affinity = advk_msi_set_affinity, + .irq_mask = advk_msi_irq_mask, + .irq_unmask = advk_msi_irq_unmask, }; static int advk_msi_irq_domain_alloc(struct irq_domain *domain, @@ -1284,7 +1325,9 @@ static const struct irq_domain_ops advk_ }; static struct irq_chip advk_msi_irq_chip = { - .name = "advk-MSI", + .name = "advk-MSI", + .irq_mask = advk_msi_top_irq_mask, + .irq_unmask = advk_msi_top_irq_unmask, }; static struct msi_domain_info advk_msi_domain_info = { @@ -1298,6 +1341,7 @@ static int advk_pcie_init_msi_irq_domain struct device *dev = &pcie->pdev->dev; phys_addr_t msi_msg_phys; + raw_spin_lock_init(&pcie->msi_irq_lock); mutex_init(&pcie->msi_used_lock); msi_msg_phys = virt_to_phys(&pcie->msi_msg);