Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp39276rdh; Wed, 25 Oct 2023 15:29:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKb8ifPcVbpdjDPcAs1XKtKiJh+IgnQUJOqcbls8MslOSHTR8sVh09o4/TZfg1rE+piKzg X-Received: by 2002:a25:b9c2:0:b0:d7e:9eeb:998e with SMTP id y2-20020a25b9c2000000b00d7e9eeb998emr15263330ybj.4.1698272965670; Wed, 25 Oct 2023 15:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698272965; cv=none; d=google.com; s=arc-20160816; b=ESXV8HXPWH9cZrizESHw5mq/UaZJ7lasNDzcI5L8hhukN8drJ4bs9bckSb06B9ioaf Dql09HUiMYqT52agPgJSbH0s0dYpFq9WJ/2Q4doCl3J0nrAtQ2WslLJu7iNLJBLE/+y8 +uA18wPerJs8yawqac3Fe684vQjvu/NzFs+nPgI4bcgNS0O/GXpjjAs9E/6/kJQAMcJL F6UOnTfee9RPqGYE4FQdmN/jYGaFKkZGDSI2AhcG6vJI+Mg7NU/tuMtSKzgNS2XUfVDT 2AK9SZfHLQ2Pf02HJqw8kTZepsdOLyAreimcqqpR54eUuZ3t2nQy4erUee5tMbny+aNC +6Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=wHuQFZrsyEYyofAnismfPI/UEFEmW2qAOxi99HkeZ9k=; fh=BbMQHvFq18E6wXPP4vukEGdVWdIwcMb6W6poYGImK1M=; b=qN3xeb3QZXPW/DsfBXM8MN44P0n2bIEZPRonNG/3JJopKoX5yuysQVbc768tXyexRn mH+p6BQQ7As0cmEXhKmH+Esy4eIqan10gRhJ4eFsnQSUf3Gmr5G2MKUVVsY8sq+VGe8d +HPp+x2x6nJTyqcdYaeLJkLFDj+RBLdoT9JDmDo8JUPVBwgbqWnK0qEP+Yzo9cJQdxt1 ruJA4z0dK+gARXkT1htKnrIy6oWZ9TgaeoPaXjqOQHmX7rgKHENVYwz8VbdDGDYNDhCo vDpXyWZW3QybQjYLA1qcl7zRNHfSfZMnzAxSXvDSa38dRD/SowNmFoAqiLLnkT7a1l3c XzwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ScRxfxyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id f31-20020a25b09f000000b00da072547af3si3719359ybj.224.2023.10.25.15.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 15:29:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ScRxfxyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 57A5E81829F8; Wed, 25 Oct 2023 15:29:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbjJYW3O (ORCPT + 99 others); Wed, 25 Oct 2023 18:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjJYW3N (ORCPT ); Wed, 25 Oct 2023 18:29:13 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D7148F; Wed, 25 Oct 2023 15:29:11 -0700 (PDT) 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 Cc: bhelgaas@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, Mahesh J Salgaonkar , linux-kernel@vger.kernel.org, koba.ko@canonical.com, Oliver O'Halloran , Jonathan Cameron , mika.westerberg@linux.intel.com 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 15:29:22 -0700 (PDT) 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 >