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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 BBD93C0032E for ; Wed, 25 Oct 2023 22:30:04 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ScRxfxyO; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SG3XC2vx3z3dKJ for ; Thu, 26 Oct 2023 09:30:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ScRxfxyO; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=helgaas@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SG3WH3YKFz30f8 for ; Thu, 26 Oct 2023 09:29:15 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 84764CE3BAC; Wed, 25 Oct 2023 22:29:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A9BBC433C8; Wed, 25 Oct 2023 22:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698272950; bh=r8HUSzqlDaMXESjFK5gUvBK0xrbNT7QU9T8BuJ2OzII=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=ScRxfxyOl3tHVsD6fcTjCUOXcJ82TGdMgHNFaT8XUzABQQmc7KAwIHjiDemvM1Ltp 3c7ntN/s0aJuOF+oHuy7Ug+81FFDjFKBZsYXfZThcn9GlltAA2YBfl83yqpwpf2IYx lniZnXD8Q6eXIDByEPPrzjdxRFo/eHlC7gdA7BbQIfZmejEo4sofUelzGjEnF2ywcy lO3qL+/XHITIDaEFdQLL2EmSW+bLzD4bTyIzstq3npT+bEsiSgm/6HQjh42TkOHhC/ S4l8V8BUosFGsXqR2VS3+TeiKiFlBRyZUQ96ZyhdxGwPnrVCjNqDkVB5qxtj9Oawqk qAwEVaHlu6gcg== Date: Wed, 25 Oct 2023 17:29:08 -0500 From: Bjorn Helgaas To: Kai-Heng Feng Subject: Re: [PATCH v6 1/3] PCI/AER: Factor out interrupt toggling into helpers Message-ID: <20231025222908.GA1770972@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230512000014.118942-1-kai.heng.feng@canonical.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sathyanarayanan.kuppuswamy@linux.intel.com, mika.westerberg@linux.intel.com, linux-pci@vger.kernel.org, Mahesh J Salgaonkar , linux-kernel@vger.kernel.org, koba.ko@canonical.com, Oliver O'Halloran , Jonathan Cameron , bhelgaas@google.com, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, May 12, 2023 at 08:00:12AM +0800, Kai-Heng Feng wrote: > There are many places that enable and disable AER interrupt, so move > them into helpers. > > Reviewed-by: Mika Westerberg > Reviewed-by: Kuppuswamy Sathyanarayanan > Reviewed-by: Jonathan Cameron > Signed-off-by: Kai-Heng Feng I applied this patch (only 1/3) to pci/aer for v6.7. I'm not clear on the others yet, so let's look at those again after v6.7-rc1. It seemed like there's still a question about disabling interrupts when we're going to D3hot. > drivers/pci/pcie/aer.c | 45 +++++++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 18 deletions(-) > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index f6c24ded134c..1420e1f27105 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -1227,6 +1227,28 @@ static irqreturn_t aer_irq(int irq, void *context) > return IRQ_WAKE_THREAD; > } > > +static void aer_enable_irq(struct pci_dev *pdev) > +{ > + int aer = pdev->aer_cap; > + u32 reg32; > + > + /* Enable Root Port's interrupt in response to error messages */ > + pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32); > + reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; > + pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32); > +} > + > +static void aer_disable_irq(struct pci_dev *pdev) > +{ > + int aer = pdev->aer_cap; > + u32 reg32; > + > + /* Disable Root's interrupt in response to error messages */ > + pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32); > + reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; > + pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32); > +} > + > /** > * aer_enable_rootport - enable Root Port's interrupts when receiving messages > * @rpc: pointer to a Root Port data structure > @@ -1256,10 +1278,7 @@ static void aer_enable_rootport(struct aer_rpc *rpc) > pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, ®32); > pci_write_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, reg32); > > - /* Enable Root Port's interrupt in response to error messages */ > - pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32); > - reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; > - pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32); > + aer_enable_irq(pdev); > } > > /** > @@ -1274,10 +1293,7 @@ static void aer_disable_rootport(struct aer_rpc *rpc) > int aer = pdev->aer_cap; > u32 reg32; > > - /* Disable Root's interrupt in response to error messages */ > - pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32); > - reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; > - pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32); > + aer_disable_irq(pdev); > > /* Clear Root's error status reg */ > pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_STATUS, ®32); > @@ -1372,12 +1388,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) > */ > aer = root ? root->aer_cap : 0; > > - if ((host->native_aer || pcie_ports_native) && aer) { > - /* Disable Root's interrupt in response to error messages */ > - pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, ®32); > - reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; > - pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32); > - } > + if ((host->native_aer || pcie_ports_native) && aer) > + aer_disable_irq(root); > > if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END) { > rc = pcie_reset_flr(dev, PCI_RESET_DO_RESET); > @@ -1396,10 +1408,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) > pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, ®32); > pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32); > > - /* Enable Root Port's interrupt in response to error messages */ > - pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, ®32); > - reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; > - pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32); > + aer_enable_irq(root); > } > > return rc ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; > -- > 2.34.1 >