Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2335599imn; Mon, 1 Aug 2022 21:41:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5OpwTDlaK9hTI1DZY7FnY7FLXxvQubhnki9IjLnxMwm7sQ9p4P345UPU7UbsnyAKzbkOGT X-Received: by 2002:a17:902:778a:b0:16c:a1c9:7b14 with SMTP id o10-20020a170902778a00b0016ca1c97b14mr19865924pll.116.1659415275146; Mon, 01 Aug 2022 21:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659415275; cv=none; d=google.com; s=arc-20160816; b=n1Ygzs05OqzrVdzkGId3GQzhGgbwZCYkwRUCpaWq4eS6cAK/TDGgDqciUA68ieielH ZxsYjMWxBiioHF9Liai9+8wyjMLmfYKmVlUmWq/QVqxAWwj8kb1gGbj5OeMgUjB+LbTt 7Hg5CY9lYpJ3MjW9IMEybZVJty8Xk80072liCKwX7gquGmSaelI+YM0L9sJubxfyOXe9 jXzLkGX8uAWQZ1C/S8j9pOZmHTIFd2POZXAxv0qeinM/4bFFTOC0ODzPNx3KF48RCmkx qmr55J7HgYNSEIk/43ASAU9oq5t1J3bqlscjND0iFFIntsjdlomFOFjl2G64SPLauA/M 2z6g== 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=qt2lrz7hBi6/NHKhZYMSJYVUWY56n9uxWwwqraR3638=; b=BFHavJw9QHeTfNQg+2WXrarqfs67Jd24HWd+87ILmKmhuY+FVmIa9/uFn7tw5WV8Kp +9KFsxslRgMziUIKTWj+eZ0WNrfwYdpJj7ZkQ9CX5WLouSLr6Rptjec1y2Drm39D2P2t lCesHcgH7H2Bz0B8aPFgR8sux3fhFjpkC9o2eyKGGofZHMNWucldidjczvnv5NRPR1q0 r3d9GCeKm0IZCoDGEhu2FOo1tZgG/VGJaCadQUKVf6iDxaQK2KzpDWvs2qIG9dACaDJt xO9Sy+oaDaGcXnJHIQHPmcPKQLxYusYJvqexItYB8tZiwsVckqwqmCbVhO0BYD7I0Zid jGZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rpCpGLlL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k71-20020a63844a000000b0041bc89f17e1si8685333pgd.142.2022.08.01.21.40.35; Mon, 01 Aug 2022 21:41:15 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rpCpGLlL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232999AbiHBEIm (ORCPT + 99 others); Tue, 2 Aug 2022 00:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbiHBEIl (ORCPT ); Tue, 2 Aug 2022 00:08:41 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0714B1B7B0 for ; Mon, 1 Aug 2022 21:08:40 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id m2so5550667pls.4 for ; Mon, 01 Aug 2022 21:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=qt2lrz7hBi6/NHKhZYMSJYVUWY56n9uxWwwqraR3638=; b=rpCpGLlLp7TBtQ479cZ7kwRr9lCjE+DaLznlPfNFZu01VkPz1WwcASUTwlw1Bweluo jXkYKLsDxBsWEDMBp73X7qDXF1L60OJeyvIuShjF/k1o1KeTPFOxyxlNd3PquLOKnJkH +5ymXZtQ9nLxD0+xsUB3xAHJXC/8116SdFPoQOeOcpBZjPGsokL66mz3v+M9IJ07peAL CQRZfNAU5xFYMCWJldyjxal32EFt0rOJWA8XHb/NY6E0OToq1QINeBh9zcJpZD1DWQHw LdIe1ckvpddfm5pqA18mn0Ti5O9Ri29pmza/EvlfqtfdRHicttKir5eRMXZpz55MXpdJ ybjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=qt2lrz7hBi6/NHKhZYMSJYVUWY56n9uxWwwqraR3638=; b=jbC09Q9LrFh8y5yPsrzxP5uKQqmKKX1/cTIIlLme1xLknJ+zRdtq4tqTegDGZDfe5X dFWwpInPPszaOkUKIagcoQsadcBN5I+taVQo0JNuPHD2e1qdTww0Oh3OsJLLNbRlILa5 mTBTwm3DIz9wJU32UbaAjNb5oZfxpnieVcwVr/xhfHZuG4YHYQ/SNcHT0D84L4EHk+Gn lhBeExgPc+2w2AphT6xyXfaa/6yMQQpl1KOHtfs8N4PdDU+DAsZAIsY9HraQBxRvqWmq p3NQBChiMpaQoWuuzcw94uxvC7r/r8c6Te2SIT6dRLdGt0aAxdc9CQIxufm+kdVrkZuK PnTQ== X-Gm-Message-State: ACgBeo1Xz8UmM9YX+QV5BQX951pDqsWm2Are7Wu4GNl8TLGuspemyrGn SyPtRa+W6KDlZdkDZ6VtXwyuYg== X-Received: by 2002:a17:902:e5c3:b0:16e:d968:634e with SMTP id u3-20020a170902e5c300b0016ed968634emr11974551plf.80.1659413319426; Mon, 01 Aug 2022 21:08:39 -0700 (PDT) Received: from C02F63J9MD6R.bytedance.net ([61.120.150.78]) by smtp.gmail.com with ESMTPSA id m18-20020a63f612000000b003fba1a97c49sm8238014pgh.61.2022.08.01.21.08.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Aug 2022 21:08:39 -0700 (PDT) From: Zhuo Chen To: ruscur@russell.cc, oohall@gmail.com, bhelgaas@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Cc: chenzhuo.1@bytedance.com, lukas@wunner.de, jan.kiszka@siemens.com, stuart.w.hayes@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] PCI/ERR: Use pcie_aer_is_native() to judge whether OS owns AER Date: Tue, 2 Aug 2022 12:08:30 +0800 Message-Id: <20220802040830.28514-1-chenzhuo.1@bytedance.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Use pcie_aer_is_native() in place of "host->native_aer || pcie_ports_native" to judge whether OS has native control of AER in aer_root_reset() and pcie_do_recovery(). Replace "dev->aer_cap && (pcie_ports_native || host->native_aer)" in get_port_device_capability() with pcie_aer_is_native(), which has no functional changes. Signed-off-by: Zhuo Chen --- Changelog: v4: - Use pcie_aer_is_native() instead in aer_root_reset(). v3: - Simplify why we use pcie_aer_is_native(). - Revert modification of pci_aer_clear_nonfatal_status() and comments. v2: - Add details and note in commit log. --- drivers/pci/pcie/aer.c | 5 ++--- drivers/pci/pcie/err.c | 3 +-- drivers/pci/pcie/portdrv_core.c | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 7952e5efd6cf..796810c49008 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1383,7 +1383,6 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) int type = pci_pcie_type(dev); struct pci_dev *root; int aer; - struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); u32 reg32; int rc; @@ -1404,7 +1403,7 @@ 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) { + if (pcie_aer_is_native(dev) && 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; @@ -1423,7 +1422,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) pci_is_root_bus(dev->bus) ? "Root" : "Downstream", rc); } - if ((host->native_aer || pcie_ports_native) && aer) { + if (pcie_aer_is_native(dev) && aer) { /* Clear Root Error Status */ pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, ®32); pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32); diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 0c5a143025af..121a53338e44 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -184,7 +184,6 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, int type = pci_pcie_type(dev); struct pci_dev *bridge; pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER; - struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); /* * If the error was detected by a Root Port, Downstream Port, RCEC, @@ -243,7 +242,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, * it is responsible for clearing this status. In that case, the * signaling device may not even be visible to the OS. */ - if (host->native_aer || pcie_ports_native) { + if (pcie_aer_is_native(dev)) { pcie_clear_device_status(dev); pci_aer_clear_nonfatal_status(dev); } diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 604feeb84ee4..98c18f4a01b2 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev) } #ifdef CONFIG_PCIEAER - if (dev->aer_cap && pci_aer_available() && - (pcie_ports_native || host->native_aer)) { + if (pcie_aer_is_native(dev) && pci_aer_available()) { services |= PCIE_PORT_SERVICE_AER; /* -- 2.30.1 (Apple Git-130)