From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 47817C433F5 for ; Fri, 4 Feb 2022 17:25:54 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qzbSdOXBuwVK0RjJ2ZYDFd+By2Cq80XqF1+5MlTCp7o=; b=vxMotGvoi94zml SxwNiazHye1b8ltbfRHTfzZN6ag54jNUDG7Iy7Cjl0Sd/M8vVSAzcXVjfyMaVnOnG3fmDUvDbxOEu ZtjOfpJXgBpkG/fQPNgml3NZsnwjjzCpE6ydJDwCucsTOCrBn6F34CWdCOmcCmnG2pFlO98HP6NA3 pi3V1I4OHZcJFbVd4r3B8gDTOSqapLR0svOgenCM9+Ou06gEsSil0TmeJHzArxziFL4+TDMs5BIIi 1jUtXt+yjLa7k6faA0z1h9jeyeMpXaA4dfwb86polq5yfoJInTwkCzNlJKCNDJUxOZHKQfYorAqMh 2Be0qffhxWn0fGNFbUwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG2Jj-0050Br-QU; Fri, 04 Feb 2022 17:24:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG2Jf-0050Am-LH for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 17:24:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE0811396; Fri, 4 Feb 2022 09:24:06 -0800 (PST) Received: from lpieralisi (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B108A3F774; Fri, 4 Feb 2022 09:24:05 -0800 (PST) Date: Fri, 4 Feb 2022 17:24:00 +0000 From: Lorenzo Pieralisi To: Marek =?iso-8859-1?Q?Beh=FAn?= Cc: Marc Zyngier , Bjorn Helgaas , pali@kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 02/23] PCI: aardvark: Fix reading MSI interrupt number Message-ID: <20220204172400.GA4867@lpieralisi> References: <20220110015018.26359-1-kabel@kernel.org> <20220110015018.26359-3-kabel@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220110015018.26359-3-kabel@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220204_092411_829910_0433409E X-CRM114-Status: GOOD ( 23.99 ) 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: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 10, 2022 at 02:49:57AM +0100, Marek Beh=FAn wrote: > From: Pali Roh=E1r > = > In advk_pcie_handle_msi() the authors expect that when bit i in the W1C > register PCIE_MSI_STATUS_REG is cleared, the PCIE_MSI_PAYLOAD_REG is > updated to contain the MSI number corresponding to index i. > = > Experiments show that this is not so, and instead PCIE_MSI_PAYLOAD_REG > always contains the number of the last received MSI, overall. > = > Do not read PCIE_MSI_PAYLOAD_REG register for determining MSI interrupt > number. Since Aardvark already forbids more than 32 interrupts and uses > own allocated hwirq numbers, the msi_idx already corresponds to the > received MSI number. > = > Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller dri= ver") > Signed-off-by: Pali Roh=E1r > Signed-off-by: Marek Beh=FAn > --- > drivers/pci/controller/pci-aardvark.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > = > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controll= er/pci-aardvark.c > index 62baddd2ca95..fd95ad64c887 100644 > --- a/drivers/pci/controller/pci-aardvark.c > +++ b/drivers/pci/controller/pci-aardvark.c > @@ -1393,7 +1393,6 @@ static void advk_pcie_remove_irq_domain(struct advk= _pcie *pcie) > static void advk_pcie_handle_msi(struct advk_pcie *pcie) > { > u32 msi_val, msi_mask, msi_status, msi_idx; > - u16 msi_data; > = > msi_mask =3D advk_readl(pcie, PCIE_MSI_MASK_REG); > msi_val =3D advk_readl(pcie, PCIE_MSI_STATUS_REG); > @@ -1403,13 +1402,9 @@ static void advk_pcie_handle_msi(struct advk_pcie = *pcie) > if (!(BIT(msi_idx) & msi_status)) > continue; > = > - /* > - * msi_idx contains bits [4:0] of the msi_data and msi_data > - * contains 16bit MSI interrupt number > - */ > advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG); > - msi_data =3D advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & PCIE_MSI_DATA_MA= SK; Ok, it took me a while to understand how aardvark handles MSIs. IIUC, msi_data contains the payload of the latest MSI write received. First off, I believe that using a Linux IRQ number for MSI data (payload)(I guess you rely on its truncated bits [4:0] to trigger the related MSI IRQs, which I believe is questionable - if not broken) is not a good idea. Is my understanding correct ? This patch and the following one are fixing this. Given that this is IRQ domain code if Marc can cast a look into it that would help me, to make sure I have not missed anything. Certainly replacing the MSI payload to the HW irq number makes sense to me (and this patch makes sense too, I think mainline code may miss some MSI IRQs if I understand this patch correctly). Lorenzo > - generic_handle_irq(msi_data); > + if (generic_handle_domain_irq(pcie->msi_inner_domain, msi_idx) =3D=3D = -EINVAL) > + dev_err_ratelimited(&pcie->pdev->dev, "unexpected MSI 0x%02x\n", msi_= idx); > } > = > advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING, > -- = > 2.34.1 > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel