Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp7139783imm; Tue, 24 Jul 2018 09:01:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd6Pkh1HscFjiBToufUt3hIe57HPcKAeWwBus7NlZPtxfrRKRocsnL9RVtB2qCjSTAjglrd X-Received: by 2002:a63:5815:: with SMTP id m21-v6mr16524484pgb.78.1532448088586; Tue, 24 Jul 2018 09:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532448088; cv=none; d=google.com; s=arc-20160816; b=We/yHxxdxmpKvCjd7W8J79K6njQdB6TaYr8mHYDNWVDMF6X0wpcJTj6kCDka7Z4g2M Ar7M8yWOLOkGFpjXUkDZd8lpM+cCK3ZdZ1YNrMsiIek5Zw0RZajzUYjbH843CK2tu+8N LW/ST2yqrSgyw9rj2GkgTI2GWqbv1yzevBis3tGVYV2MxOh0goiwubwQ181y2LmRKSap fIosu5/X15KrKqb77QI/CR1vh4KpRl+ozZYBrmTYlYYVgQ0VO9cZ0txTVIaE71FGE9op Ycz6GRp2yx2A0GaGlGRhVxsKEGx2BVxHmUEJtSSN1K1kVp5MmBhAZ4ezYjegLIpgkWmt XcQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Bq5wHhmbmGGbbZStcNtL2N8nEdzVdUrzgal6/FwqlK0=; b=OxLEx80rovvlrsXKtMl0NICCpPfdEEYMUPeujnwGfvAcIuNkT2/nufqM3RBurZ2qMI Ya9vNCEO6eQ/gU4/0UCehKDHlpRLZuOQbF/BUVWlZx8Bl6hXNpdvLO0N5ujGVa1YMeRZ WyZ8+lHc/Ve4Z+TUMQl8HIrU2rZ5oTOr1DfJm4/nAWRSi7SWWt3udg99gXWWyr87Q0Qw mI3iIaE5ok+zU5FwIGphLjJ0GMPMU2XBspflQSDOhFFQCJU1ytnPxB+XKV3fhQZSTbUn y74Pb1UUlYXAjQxKygkcG8Evo1SUTQDU/llSatpPAWXJAI78dwtAseX/kUvIXfht0sLo wjRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OOcI+rnV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21-v6si11989858pgi.430.2018.07.24.09.01.13; Tue, 24 Jul 2018 09:01:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OOcI+rnV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388536AbeGXRGn (ORCPT + 99 others); Tue, 24 Jul 2018 13:06:43 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:34260 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388324AbeGXRGn (ORCPT ); Tue, 24 Jul 2018 13:06:43 -0400 Received: by mail-oi0-f66.google.com with SMTP id 13-v6so8430200ois.1; Tue, 24 Jul 2018 08:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Bq5wHhmbmGGbbZStcNtL2N8nEdzVdUrzgal6/FwqlK0=; b=OOcI+rnV0+cqG6t0HnpJKLPmeJ+V3tGUVOsrOImaMNI2klA/b+YLIaP8KlypaEBpPo JiiArL/L5TLA4r76v2Ve5tKDo8Y/a+W/nHwvgg8ubaslPLzhsDRueOg1MmmuCThTyFdn 0hLi5pSj/QWWUq9oXE3YnxFUE/+UOTYk+uKm8LEebW1tYQraOxcFnnOQ4l7xnBznL46X bQA2Oep3thPvDcX8asSFgqtRr2objeczdFP0d5pcnsNMj8+4WYtNvVH1tucuQdCOIFVy 3VNMp1BIwaYzbD7aj/kXPBEvBGlQofB4r3WPKxCw86CsEi83T1+PZALo+c8nI5V0iUxN 2Scw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Bq5wHhmbmGGbbZStcNtL2N8nEdzVdUrzgal6/FwqlK0=; b=QdaBq+dol/rPr2TslbNZEZt69d2qDJ2DqXBcG7ZFvEikZ8s1DSCmUas2j95Y6e8xvl BnbXkhYXCx6+gmTy26j4AS+iJraapqwhSsFmqcXqLZenNxTM41kSM7kx5cbHxZziZwnZ DJdHEW8OZn8DMpZbUfktl5aD/rIjwXE30IO/RZVyMaa1Kt4KtbhoRExLpjpJAqwNxU6e LHcxq+VS3AWKHSqUxlTfIVWSdy5QFStdCTP1Vcn7VrqONtXtRvN1QefMOHZG+I8hHdAZ IqJIQ0lMtFJHmYH0S6VUMG+RkrIP/7cq+apPcJKLdUfRTzpkomxByRxI0ShjKPTc/1JN WyEQ== X-Gm-Message-State: AOUpUlFGTJ8A+xI3KN0qx9h1aE7ME08eVU1I4pEBZ7DEu9IMiBIfFeJ/ vsc+0JR3mIAvUKM9z7koTW9IcHBlNjw= X-Received: by 2002:aca:5004:: with SMTP id e4-v6mr4020910oib.111.1532447974214; Tue, 24 Jul 2018 08:59:34 -0700 (PDT) Received: from nuclearis2-1.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id w204-v6sm14707285oif.2.2018.07.24.08.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 08:59:33 -0700 (PDT) Subject: Re: [PATCH v2] PCI/AER: Do not clear AER bits if we don't own AER To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: keith.busch@intel.com, alex_gagniuc@dellteam.com, austin_bolen@dell.com, shyam_iyer@dell.com, Frederick Lawler , Greg Kroah-Hartman , Oza Pawandeep , linux-kernel@vger.kernel.org References: <20180717153135.25925-1-mr.nuke.me@gmail.com> <20180723165251.11424-1-mr.nuke.me@gmail.com> From: "Alex G." Message-ID: <3d05f662-2c29-90cd-9c74-6456939a0e6b@gmail.com> Date: Tue, 24 Jul 2018 10:59:32 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180723165251.11424-1-mr.nuke.me@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/23/2018 11:52 AM, Alexandru Gagniuc wrote: > When we don't own AER, we shouldn't touch the AER error bits. Clearing > error bits willy-nilly might cause firmware to miss some errors. In > theory, these bits get cleared by FFS, or via ACPI _HPX method. These > mechanisms are not subject to the problem. > > This race is mostly of theoretical significance, since I can't > reasonably demonstrate this race in the lab. > > On a side-note, pcie_aer_is_kernel_first() is created to alleviate the > need for two checks: aer_cap and get_firmware_first(). > > Signed-off-by: Alexandru Gagniuc > --- > drivers/pci/pcie/aer.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index a2e88386af28..85c3e173c025 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -307,6 +307,12 @@ int pcie_aer_get_firmware_first(struct pci_dev *dev) > aer_set_firmware_first(dev); > return dev->__aer_firmware_first; > } > + > +static bool pcie_aer_is_kernel_first(struct pci_dev *dev) > +{ > + return !!dev->aer_cap && !pcie_aer_get_firmware_first(dev); > +} > + > #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ > PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) > > @@ -337,10 +343,7 @@ bool aer_acpi_firmware_first(void) > > int pci_enable_pcie_error_reporting(struct pci_dev *dev) > { > - if (pcie_aer_get_firmware_first(dev)) > - return -EIO; > - > - if (!dev->aer_cap) > + if (!pcie_aer_is_kernel_first(dev)) > return -EIO; > > return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS); > @@ -349,7 +352,7 @@ EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); > > int pci_disable_pcie_error_reporting(struct pci_dev *dev) > { > - if (pcie_aer_get_firmware_first(dev)) > + if (!pcie_aer_is_kernel_first(dev)) > return -EIO; > > return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, > @@ -383,10 +386,10 @@ int pci_cleanup_aer_error_status_regs(struct pci_dev *dev) > if (!pci_is_pcie(dev)) > return -ENODEV; > > - pos = dev->aer_cap; > - if (!pos) > + if (pcie_aer_is_kernel_first(dev)) This here is missing a '!'. It's in my local branch, so I must have exported the patch before I fixed that. I'll get that fixed next rev. > return -EIO; > > + pos = dev->aer_cap; > port_type = pci_pcie_type(dev); > if (port_type == PCI_EXP_TYPE_ROOT_PORT) { > pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status); >