Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9549665rwr; Thu, 11 May 2023 17:16:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4l2l4UweGGCZ11iG8VlT/Hw+10N1tc1GI6db8TzNuDh3di+3q7fWAQq9wZ9359w9nALVc4 X-Received: by 2002:a17:90a:70c2:b0:246:5fbb:43bf with SMTP id a2-20020a17090a70c200b002465fbb43bfmr23169648pjm.4.1683850585816; Thu, 11 May 2023 17:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683850585; cv=none; d=google.com; s=arc-20160816; b=MBhdXmadInT3ktZwY1jdmgGBBH6hYptlJyG3DnFXG3aeTDKPpgs/w5RKKNI0DNXwqK ImbTgsBge1MkTMm/UyZZPHMGrGzQN+51gUo2u+GPyCLUcOi85yvKm8rLnExWE6S9zbCE 0uFfgVSGDv2TVqglUMiXMc5Z/gqGllv8yeRc8w0nWn5bDGijYNOspJ+K5/z+Pmnh3DKm kM1B3lx347WXaOILxf+dsVcReZGltkeX9PMY0iXc8se3NFX1cQp5AR4gXSigk7Ee9pUs MxnPHjBGPxPOX7D4CvJGfgeikxN3sn1AfYIXa2eFka/5w1fETSchO7tLJRhTPtab5tYJ PTcw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=7Yy+TTJYxzOVEE7Li/9nXT/goYCMvcjZLz3BYtWDTGA=; b=kbz9kndQEX94Qkpj9fn3eDcsJA/jgpbxE3xuaNQa67j3zIz3xR89nyY3LSjIBlxE/m q0zRWMDV1/ncQ7tDz+PD3z37r+BEYvOEJHJEOdlfVuQ2zxXWh13Hdi//Wb978Ko3W8mL SpB045wCPwe3wIwfYZ4psEKTWvwt0cte4hJjlUADn8AJ/w4Htcc71rkGbyZ8n1svzeuu 4exzS218zV64rqCVz3Ao2ccBakfLma43iUxmTjRg1WvOmApDCv0LcS9+9Wmjjgtqe9cl l3EQJplCppuHyrMJxCut0o9mqDhW50AHEDCN6NyVn5nZm8hR5mZVVY6ax+LCv5B+FBaW 9tIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Z48p6PFL; 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=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m67-20020a633f46000000b0052f9d99941fsi7521345pga.400.2023.05.11.17.16.12; Thu, 11 May 2023 17:16:25 -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=@canonical.com header.s=20210705 header.b=Z48p6PFL; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239597AbjELAPJ (ORCPT + 99 others); Thu, 11 May 2023 20:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbjELAPG (ORCPT ); Thu, 11 May 2023 20:15:06 -0400 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27582E4A; Thu, 11 May 2023 17:15:05 -0700 (PDT) Received: from localhost.localdomain (unknown [10.101.196.174]) (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 smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 5B7C7412D7; Fri, 12 May 2023 00:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1683849664; bh=7Yy+TTJYxzOVEE7Li/9nXT/goYCMvcjZLz3BYtWDTGA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Z48p6PFLknBe5LY92s5PDYjK5gm0ulwEihq2WGg5Vq5JOeRICHYwfUBH26cXolCsc v87rcLnKBkZ//zWG4cGyJXinGqvITyUNkQQk+cV/xgINL7+mjOLD+10fY7NWChTCxd hwQeYE2nrirb/ZFKz6PuLaGigp3LWWcrHhEvVpHsbg8PeozKpE5sTPftPFnpsBgnNF aL0IGgS2FmLkxI6YKnMVJmbat5bm1Z3taFIOOwT0TEyWmN68yE3nHBtxfLwptTw+sy tkLCMfMJhQ415skVqKXk6IOuJiDU5LJ9DLtwAMwVm86GKJXXw+yvJYxF++H8ckaZ79 DeCdekzdLP82A== From: Kai-Heng Feng To: bhelgaas@google.com Cc: mika.westerberg@linux.intel.com, koba.ko@canonical.com, sathyanarayanan.kuppuswamy@linux.intel.com, Kai-Heng Feng , Jonathan Cameron , Mahesh J Salgaonkar , "Oliver O'Halloran" , linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/3] PCI/AER: Factor out interrupt toggling into helpers Date: Fri, 12 May 2023 08:00:12 +0800 Message-Id: <20230512000014.118942-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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 --- v6: - No change. v5: - Fix misspelling. v4: - No change. v3: - Correct subject. v2: - New patch. 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