Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp176088imn; Wed, 27 Jul 2022 03:17:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v56ReJLCu3WlXQlssyURCPi7kD4hBz6qqXK862eEZ1k8NTfizjBgbY64sw6ICqDQHFaxnk X-Received: by 2002:a05:6402:254b:b0:43b:d6c3:dd96 with SMTP id l11-20020a056402254b00b0043bd6c3dd96mr21680101edb.406.1658917067596; Wed, 27 Jul 2022 03:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658917067; cv=none; d=google.com; s=arc-20160816; b=dAHaSSGoc8XhUb3hGbGzHDZ26NMlrT8zPdFW1Od9WetdsxwzW2PpiT1/wDy+Wpb20E ELvjwilGzV3q/JgV01IVdEss3IDy6fQOdrHWRjSn70D0I1LgY9KyH6o7I/6HokX/QBnE SLa5c+DN2NYzvSBj14hnjtXWlP6+UV3AcoI1lPxZq2t29+9Cx8RkzlZlW3p/deG8HptV ruPyblTaOBjRdZyEx1XgrYsqzzkjA5OvkeWxQXhVCsl+1DS+hoqf/I+OBj+6SNtNTnuM NldZr9uixvNyNnAPJkLQ6GO4OZfrIEEfMxiI/cOih/m/BZASiv8ZpFgWjeNspmtdPG0/ yMPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=vJn+MLWCsk+ei9hsjhMzOKCAi7lwMqHzERz4ilhjRd8=; b=O0fsyxSwZcOH0HdEGlRUSY6maGQ4g2aL63rTpUmw2pv2ndRPuYNlUs0BqbW6eYehey vcmlqoefVTsJuP/K9DWuxhfDNbl/qf/f4M58bS0dF7zhewk/0JB0dXMkt7yv968q9s2c F98rl2jWeJlkaZUkIm7Jbg1QGYOpgg/SmpGse/Ub2WwIYNEr0acvGiJMLB00P9Aul5KB jbi5QeONiCWToFYCxTWF0kk6YPUPtCtNnSaz/Fc6or2AkGqjHy9VPvBXu5LnCBktF5Up tEgzyz9kCge1qvXGxDHwI6j5Pr/CX/tvLRcP8neCWRYA3jiRA/JbaF1ZgaCamrAyWVPe JYBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=BAhli0xR; 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 r22-20020a1709067fd600b007136091f459si15992568ejs.302.2022.07.27.03.17.22; Wed, 27 Jul 2022 03:17:47 -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=BAhli0xR; 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 S231545AbiG0Jhi (ORCPT + 99 others); Wed, 27 Jul 2022 05:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbiG0Jhd (ORCPT ); Wed, 27 Jul 2022 05:37:33 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B053C2A94E for ; Wed, 27 Jul 2022 02:37:32 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id c139so15652161pfc.2 for ; Wed, 27 Jul 2022 02:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=vJn+MLWCsk+ei9hsjhMzOKCAi7lwMqHzERz4ilhjRd8=; b=BAhli0xR/K813sba6mxZ6qzpHkBuQ4XWkwcm3SYX26nlD7jupj4lyIm8AZWeSTrPTU uaNdRXX43CRPYE0tkW/2ileR6tI0bBEP3hf1Gb2uTf1dQGypO3EBgYByss0gfOR3mUZv P5/YmzgTICq86WARnnbyd6/1midmJWjkxayGrnR7TaNtYE87DBcqeKyXVMrzn5zQRc9q OoQMm93hby7hlcUQ/FBMFOnGABtmX17n4C4lArmjtRL6pgvbiKX5+vJbaIivq7YiUuHs WAo3aG1YsmNpvTQ7yZ/TmvahbK4tE5hDB+ARbVgHPrPYTVCXpkGHQ3usbGHYgP6NyQRt nDJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=vJn+MLWCsk+ei9hsjhMzOKCAi7lwMqHzERz4ilhjRd8=; b=YuUOENTtnxhd9yxEDNCmDv6/JbRoPD20ch0lhFRgwU3wBqtzoLuasTL1cG9yL6xQEQ eFwZRpIrMfAt/HcdUECMNvNFCOB0BW7xhUHwa+65dzGB7VbBS03dCgVq+obIuXVDWx+r qR+N/Fwoh9eyfgxYgouyiS2M2BMZJY4wZpUnpRBMTGIG9UfYeSO5mw0jKzUyuU1uyd5q UW+ZBVb+TfZLL/cGeSJPJBtkw8f+Hr1QtQDIUfMKP7zItsG+kGsVhcgoOhcse5ZTQ0ia JOar7yBE6CflyvqEXbsboogu9fFcqBtmfdDTgcaFL9QU81tHK5cwYu8PjHaOLxXyjo9w em/w== X-Gm-Message-State: AJIora8PNUUC+3dhWgNRSZOKRpYMYaZoFHrnUuWYNcLRl3M05wpwoO0V gdyW4J8YpxmonZ4LmUnH0r2gNMHZn9PUMqfH X-Received: by 2002:a65:6398:0:b0:415:7d00:c1de with SMTP id h24-20020a656398000000b004157d00c1demr18665628pgv.610.1658914652147; Wed, 27 Jul 2022 02:37:32 -0700 (PDT) Received: from [10.2.192.95] ([61.120.150.78]) by smtp.gmail.com with ESMTPSA id i128-20020a636d86000000b0041a4df3d3e2sm11591867pgc.68.2022.07.27.02.37.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Jul 2022 02:37:31 -0700 (PDT) Message-ID: Date: Wed, 27 Jul 2022 17:37:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v3] PCI/ERR: Use pcie_aer_is_native() to judge whether OS owns AER Content-Language: en-US From: Zhuo Chen To: Sathyanarayanan Kuppuswamy Cc: ruscur@russell.cc, oohall@gmail.com, bhelgaas@google.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, chenzhuo.1@bytedance.com References: <20220727035334.9997-1-chenzhuo.1@bytedance.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,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 On 7/26/22 1:35 PM, Zhuo Chen wrote: > > On 7/26/22 9:02 PM, Sathyanarayanan Kuppuswamy wrote: >> >> >> On 7/26/22 8:53 PM, Zhuo Chen wrote: >>> Use pcie_aer_is_native() in place of "host->native_aer || >>> pcie_ports_native" to judge whether OS has native control of AER >>> in 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 >>> --- >> >> Patch looks better now. It looks like following two changes >> can also be replaced with pcie_aer_is_native() check. >> >> drivers/pci/pcie/aer.c:1407:    if ((host->native_aer || >> pcie_ports_native) && aer) { >> drivers/pci/pcie/aer.c:1426:    if ((host->native_aer || >> pcie_ports_native) && aer) { > > Good advice. But I wonder is there a scenario that dev->rcec ("root") is > NULL meanwhile dev->aer_cap is not NULL? If so, replace > "(host->native_aer || pcie_ports_native) && aer" with > pcie_aer_is_native() will change original function. > Do you mean changing "if ((host->native_aer || pcie_ports_native) && aer)" into "if (pcie_aer_is_native(dev) && aer)" ? I thought changing into "if (pcie_aer_is_native(dev))" before. One another doubt. Not every pci device support aer. When dev->aer_cap is NULL and root->aer_cap is not NULL in aer_root_reset(), pcie_aer_is_native() will return false and OS cannot operate root register. It's different from just using "(host->native_aer || pcie_ports_native)". Or we can change "if ((host->native_aer || pcie_ports_native) && aer)" into "if (pcie_aer_is_native(root))". But in this way, argument NULL pointer check should be added in pcie_aer_is_native(). >> >> >> >>> Changelog: >>> 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/err.c          | 3 +-- >>>   drivers/pci/pcie/portdrv_core.c | 3 +-- >>>   2 files changed, 2 insertions(+), 4 deletions(-) >>> >>> 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; >>>           /* >> > > Thanks, > Zhuo Chen -- Thanks, Zhuo Chen