Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp906015imm; Wed, 18 Jul 2018 12:50:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe//eq0+m7apDnMBmMhT1HhqZ5mDG1hnb9S8jiCc93WFIMjFKdvaNjIm0QFXYtXhwjZ9Hz9 X-Received: by 2002:a65:6094:: with SMTP id t20-v6mr7142684pgu.264.1531943407179; Wed, 18 Jul 2018 12:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531943407; cv=none; d=google.com; s=arc-20160816; b=Rf5n1t96w1on2FUlEJmuqWju7qaMB8/jDuYfwbMes85C6dFWtvfg2MLGNP1tpmwds2 ZyEFLZimU093GKDYH+h/YaKBhITczL5b+tbLEC2X8veurCj7jw63aT4vR2dv5ps+XEBF y6teI0Yv9cKUwC60HwH7KQpiNvTPO5OOAI5/ESecjK26phL++4j0hNHnKJP7UGUa0Dxm B524MfR5raxQ7tO2rqSsSeFtL2ru9GP/upO2zomRrSjYnEtAUajP3f/uJcyWFR8WeiCj KekQI6lBsUekAfLBnGAg6svdI05zZc51C6ofQmqIBCMvSBmmv6JGv9pl37GyJBQCrwGB 5GGQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:arc-authentication-results; bh=+eE/2NvhV3GGnw5afUwIDrW/rNVyAacnJ+CZP1t0tiM=; b=CP5qttKzc8nkEXadkn6Gjsd5W4Dcb6C63jJ6bLVaBIA1tC7grotMF2KoL3bMerj3B/ Jec8VF3vOVbSdJhSl364QWXIXORP2v7t06PBn1Ncw4VN8efI//juy/qa9/JCHRvind2T jGp0w8VDcDOvzqet0C1ZFzOGUG++5EIZJ6YfCn7k+dgX/Zybd7QXeoJUTOfeXp+1e26D AjFiDqQpiKuRpGHQaP68PZOzmXLBgPPuRRZ8pP44F2idYpjFsRH7znkgl4hBSCWvsU8W QdPkk10cbYerozTsDG89pQCMsAT246aFI+evBTiE4O2olcugRW/nwqmyb5f2vCdKlW6s jDcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D2sj1Oiz; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si3331636plr.148.2018.07.18.12.49.28; Wed, 18 Jul 2018 12:50:07 -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=@kernel.org header.s=default header.b=D2sj1Oiz; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730897AbeGRUYP (ORCPT + 99 others); Wed, 18 Jul 2018 16:24:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728912AbeGRUYP (ORCPT ); Wed, 18 Jul 2018 16:24:15 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A7BE20850; Wed, 18 Jul 2018 19:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531943092; bh=yzfMZBNt72oqa5z1kwvv4mNdihmvoBt3oEwPXq+VcVQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=D2sj1OizpMuJwp/TA3nRcyprE2iPM1rmhQazAggdxv/eLeuM1kM/rnVnJgVoeFrgS hPy1KaZ0izEWRIiBAyNk52tsXXlex3jLKjA3RoqThj45TGJoAuPUkOc4pmYTUcIts0 KoVfKVUOZjAWer8BRmLCRsp+kahBNoJCYAMOj/5M= Subject: [PATCH v3 5/7] PCI/AER: Clear device status bits during ERR_FATAL and ERR_NONFATAL From: Bjorn Helgaas To: Oza Pawandeep Cc: Philippe Ombredanne , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , Dongdong Liu , Keith Busch , Wei Zhang , Sinan Kaya , Timur Tabi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 18 Jul 2018 14:44:51 -0500 Message-ID: <153194309124.191586.12413426053649369470.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <153194245964.191586.14782253252654776509.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <153194245964.191586.14782253252654776509.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oza Pawandeep Clear the device status bits while handling both ERR_FATAL and ERR_NONFATAL cases. Signed-off-by: Oza Pawandeep [bhelgaas: rename to pci_aer_clear_device_status(), declare internal to PCI core instead of exposing it everywhere] Signed-off-by: Bjorn Helgaas --- drivers/pci/pci.h | 1 + drivers/pci/pcie/aer.c | 15 +++++++++------ drivers/pci/pcie/err.c | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 12fd2ac95843..fc4978df7caf 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -454,6 +454,7 @@ static inline int devm_of_pci_get_host_bridge_resources(struct device *dev, #ifdef CONFIG_PCIEAER void pci_aer_clear_fatal_status(struct pci_dev *dev); +void pci_aer_clear_device_status(struct pci_dev *dev); #endif #endif /* DRIVERS_PCI_H */ diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index b8972fe85043..dc67f52b002f 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -357,6 +357,14 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); +void pci_aer_clear_device_status(struct pci_dev *dev) +{ + u16 sta; + + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &sta); + pcie_capability_write_word(dev, PCI_EXP_DEVSTA, sta); +} + int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) { int pos; @@ -1356,12 +1364,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) */ static void aer_error_resume(struct pci_dev *dev) { - u16 reg16; - - /* Clean up Root device status */ - pcie_capability_read_word(dev, PCI_EXP_DEVSTA, ®16); - pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16); - + pci_aer_clear_device_status(dev); pci_cleanup_aer_uncorrect_error_status(dev); } diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 638eda5c1d79..fdbcc555860d 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -252,6 +252,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, dev->error_state = state; pci_walk_bus(dev->subordinate, cb, &result_data); if (cb == report_resume) { + pci_aer_clear_device_status(dev); pci_cleanup_aer_uncorrect_error_status(dev); dev->error_state = pci_channel_io_normal; } @@ -312,6 +313,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) * of the bridge and clear the error status of the bridge. */ pci_aer_clear_fatal_status(dev); + pci_aer_clear_device_status(dev); } if (result == PCI_ERS_RESULT_RECOVERED) {