Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2211669pxk; Sat, 26 Sep 2020 22:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEplEntWLJPgWgvqdQxamdcLz4HjNRXqteyXK/mlKuOplOUW9poGye8234QH7aipv7SB4d X-Received: by 2002:a50:f1cf:: with SMTP id y15mr9681472edl.204.1601184853384; Sat, 26 Sep 2020 22:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601184853; cv=none; d=google.com; s=arc-20160816; b=apfEnxB2CXBp3IY5o6691KlepSXMk+Nh3BJ31pqS5TLAerE2p+jiAXHuRpKZHNmnOE rsylXYIjkuZU0gX95J6X5dpTiGACJUNCZcx3JOyu84Mqm2EIO5y6aGp0F5IwU/WAsKuC ICU7/uKoRYrykvbnmO2Igy7N3B+s1pwIQOkOC64cTNnTTN42x5LU7p+5yGr4fYVWurqm TR50YSl7X01FSaebC7UK40TCkyOBEt7PpRmRlJ96Y2EYRJA3+wchs5+8kxpJAvykXHiM RODPI8xGvVuIszR0zlIKoHaF6AEvQYqAmTdV6UQrwkswBF4TrNfmxskSJqpwMau9zz6x d5UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=8+VDTGfmPmlXHE3lsaWaSKVOTy0EqmpxmmTaVP699pU=; b=knLukcPd1VWtUbv+riH2n1P1NZog5boxtLrrsRH9Hik9wFeL9jK3BfEHuNbzHokfeY ULs3/ztMM6EydAWR8zJU2cO0cy3suKforX8HCt3esIBpNqJLa4rMWWEMVeFadk2COVuQ IwaQ+wXaauiQjrBayXmow639xgeYCjZ4g1NJxQ/acMq39x3jh3HKAqBE708mh3UtTrEZ TJFKf7XL0sWONvijkZ+WIyVaaxwi8vmYhOucO2yera/+FiqwsaRVg3BDdd4+wpK3ogMF BtZSYE3MegXvQqq6mKy9PcJm6nDCCpJ43jvWeIbXTyEDvDvVcb/u9VtJFDY3PdxBzPdY 97Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si5696177edl.154.2020.09.26.22.33.51; Sat, 26 Sep 2020 22:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730322AbgI0Fac (ORCPT + 99 others); Sun, 27 Sep 2020 01:30:32 -0400 Received: from mga07.intel.com ([134.134.136.100]:23634 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730311AbgI0Fa3 (ORCPT ); Sun, 27 Sep 2020 01:30:29 -0400 IronPort-SDR: iSwAXnDphXteXzDay/ftzkpOY9JqcWgXBwvA1PE3z2/P9zRE71KoxgEPrHw4ugSRVv6DABLroD jrS2KlKBfJwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9756"; a="225993143" X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="225993143" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2020 22:30:29 -0700 IronPort-SDR: z4V9w1T1LEzoevfb48WDI52acjviLoA++OhAR3+JBmlcV49l2+BS+kmC6bbY6I/G4wN3QFVfRI oHwxoGiXX2BQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="323909397" Received: from shskylake.sh.intel.com ([10.239.48.137]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2020 22:30:26 -0700 From: Ethan Zhao To: bhelgaas@google.com, oohall@gmail.com, ruscur@russell.cc, lukas@wunner.de, andriy.shevchenko@linux.intel.com, stuart.w.hayes@gmail.com, mr.nuke.me@gmail.com, mika.westerberg@linux.intel.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, pei.p.jia@intel.com, ashok.raj@linux.intel.com, sathyanarayanan.kuppuswamy@intel.com, Ethan Zhao Subject: [PATCH 4/5 V3] PCI: only return true when dev io state is really changed Date: Sun, 27 Sep 2020 01:28:40 -0400 Message-Id: <20200927052841.12629-5-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200927052841.12629-1-haifeng.zhao@intel.com> References: <20200927052841.12629-1-haifeng.zhao@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When uncorrectable error happens, AER driver and DPC driver interrupt handlers likely call pcie_do_recovery() ->pci_walk_bus() ->report_frozen_detected() with pci_channel_io_frozen the same time. If pci_dev_set_io_state() return true even if the original state is pci_channel_io_frozen, that will cause AER or DPC handler re-enter the error detecting and recovery procedure one after another. The result is the recovery flow mixed between AER and DPC. So simplify the pci_dev_set_io_state() function to only return true when dev->error_state is changed. Signed-off-by: Ethan Zhao Tested-by: Wen Jin Tested-by: Shanshan Zhang Reviewed-by: Andy Shevchenko Reviewed-by: Alexandru Gagniuc Reviewed-by: Joe Perches --- Changnes: V2: revise description and code according to suggestion from Andy. V3: Change code to simpler. drivers/pci/pci.h | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fa12f7cbc1a0..a2c1c7d5f494 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -359,39 +359,12 @@ struct pci_sriov { static inline bool pci_dev_set_io_state(struct pci_dev *dev, pci_channel_state_t new) { - bool changed = false; - device_lock_assert(&dev->dev); - switch (new) { - case pci_channel_io_perm_failure: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - case pci_channel_io_perm_failure: - changed = true; - break; - } - break; - case pci_channel_io_frozen: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - changed = true; - break; - } - break; - case pci_channel_io_normal: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - changed = true; - break; - } - break; - } - if (changed) - dev->error_state = new; - return changed; + if (dev->error_state == new) + return false; + + dev->error_state = new; + return true; } static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused) -- 2.18.4