Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2166785pxk; Sat, 26 Sep 2020 20:34:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Tqd2Ro/0hUOmZOJjUfFbWccM6IRmgSeY4tFiqQ/QimX7jhI5GsD3EilojzyIAy0YA86S X-Received: by 2002:a17:906:6b95:: with SMTP id l21mr9388435ejr.317.1601177671907; Sat, 26 Sep 2020 20:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601177671; cv=none; d=google.com; s=arc-20160816; b=f8GuYEc/K56OQCMdhSgmy/V0xMTOwqteTzHnBD4ZItowGmp0mtCgKv8hul7O0LPG+I Uxnv9S8KRUIPxlc7EPnIuVRfUl5SSEejoCpWd73mMrt10LHkcKXshdDDbE0C8Jb5s42p RBE6DKX4/4v9rs0+k0AMTzyP1/9CxzjgvXSbRAhnLOW+QGiQLubw7eDq0PgY19KoCyO/ EgqUxVt6iXt9oNxSU3OwnSz+59DgAI53ljuAUxt7KBf9Y56vWcae+I4giVN9eK5HeuQX rUEqBxR9rx5Envq9NYbXZSsmvqSF1TP7K7nJhPHZ3M5iHt+6BG3Efb0tcB6KZz5iS2zS GREw== 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=ngHRWfrTD60jh5a+gscHQZcr7ssHcVgdAxQbeNiPHc4=; b=yxlMqFzP2hQ9c6eUMN5daWughaYCyrrOQA6duWu4GImXDiqVZfcrCvJkUMWrxKSSN/ Nw5P7qRpCV/UH6f6O4d7Yo1j2W3USli2CwV1XLBKkxLWUVV/TVxmPxcUUgdcRuXCnObX eAFB8UlaYLPj9du5jj6u1vv6rbtzSUR10/646RTYAIw9ALOroGidLG/jKHXpB+pGxcjd twce8HVJVPQraduyXuHLenDpbSGukxQZUODYU+dreXGXbH7ysd5mZSxv9dj7YwNNG+AL 1Eyf0S4bkr4GVJEYsJql9u1KE0Busi/bpSodWNv2bw1K84Q7tHrNs7cx6klLGouGDtA5 o91Q== 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 n23si5351376edw.337.2020.09.26.20.34.07; Sat, 26 Sep 2020 20:34:31 -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 S1730256AbgI0DaN (ORCPT + 99 others); Sat, 26 Sep 2020 23:30:13 -0400 Received: from mga12.intel.com ([192.55.52.136]:65386 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730250AbgI0DaN (ORCPT ); Sat, 26 Sep 2020 23:30:13 -0400 IronPort-SDR: NxTuNn9+vb+x2PaDySmV0JOT6jJbvwlVXQwCIZ+WjPmm4qi24g3gT6PxcNqwH3mdMK8qgqLIf7 l9UM12bnhMXA== X-IronPort-AV: E=McAfee;i="6000,8403,9756"; a="141242670" X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="141242670" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2020 20:30:12 -0700 IronPort-SDR: k7kuHZOWuM6IQrSnGRUR3zYbRDGCMufzqKZhok+pDtbmKePH/qNPUOJY5HucATi1ycN9zgk3KE 870H3MnH+aJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="337697538" Received: from shskylake.sh.intel.com ([10.239.48.137]) by fmsmga004.fm.intel.com with ESMTP; 26 Sep 2020 20:30:09 -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 V2] PCI: only return true when dev io state is really changed Date: Sat, 26 Sep 2020 23:28:28 -0400 Message-Id: <20200927032829.11321-5-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200927032829.11321-1-haifeng.zhao@intel.com> References: <20200927032829.11321-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 --- Changes: V2: revise doc and code flow according to Andy's suggestion. drivers/pci/pci.h | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fa12f7cbc1a0..387f891ce6a1 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -362,35 +362,11 @@ static inline bool pci_dev_set_io_state(struct pci_dev *dev, 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; + if (dev->error_state == new) + return changed; + + dev->error_state = new; + changed = true; return changed; } -- 2.18.4