Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp782140pxk; Thu, 24 Sep 2020 19:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEfr7W7HtlhmlyiKHjSxx5oJa1HDKC2FcviFEvw6wai4H/QnKNadY/hSoL12h34oadJRYn X-Received: by 2002:a17:906:f11:: with SMTP id z17mr669175eji.88.1601001741873; Thu, 24 Sep 2020 19:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601001741; cv=none; d=google.com; s=arc-20160816; b=t6H35ewiO+Kx+vf/lI1KE2eoGiFBHObflPPPGokrKpfhwl783eSkrCnC8Ze+MigK1T zsAQ4odt34i4XlFNJ9Ea4ZB6LVRxD9hS6uyeZ1M+d2vHwprwpynUF+Xio5H//2wzz8bz rywkmbzUoyn7uKAfxwqN3QaA+JKFYZinOHQeTd3eRHwEIZxjXpy13upY4ki2isv9WkvG l+Nlk7rdZIjZNV6xp5VQek39G5GnI/u/m7J6Xw1qGOsBgq7LNHEf+vJ+FNMxJcjZtzDR 3KZHrfl53VXaCUIIRcG2b8SDK+gz5Xl/ROeuMy1pAkzYacvDVLvBVNrRm4PBcdvYYA2B Rd3w== 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=2iSJFrRYTH0npk7Ru9CIOtehwolsS3u02ECUdcmLTYQ=; b=mrxCCwugR8SeVuCnf06vQ7YP8Xf1BVfN758KcJ7fFlQOko78os3xTG8OGNwbYKv7aO 3ChHTcftuafxw/DFXDIKikI36OlpxV4DofnnIkO5pkIV8dKdEELmhbkat9T7jnZOXuR8 x+TmsBF7ucgEsXseWUMXn2CBen/HPBMYe+jVCBsA7SIC97mkX0hxS1q4qa72EgEdDiie F0BnVNemdSEvuJLGF0qpJ82Ncy/iE8Vitqeabyiu1720ypxge2oCI3ztqYA8Jf16Ms1+ qxAhC4SKFfrwb1/ftQMWqtULbRBgG35YDpAMYn2+VsiM14lq/FH2NZRcPYir/fKT+w/W mF/w== 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 us11si905925ejb.268.2020.09.24.19.41.59; Thu, 24 Sep 2020 19:42:21 -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 S1726756AbgIYCku (ORCPT + 99 others); Thu, 24 Sep 2020 22:40:50 -0400 Received: from mga17.intel.com ([192.55.52.151]:60724 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIYCku (ORCPT ); Thu, 24 Sep 2020 22:40:50 -0400 IronPort-SDR: iYjanzg5yvkkTDMkg2EMsOFOBOpOEyQ/vxriGv2afsM7qrKlfcAmEsoKVk0Tc3e9eRam+Cms2s PQuxDUxz24Cw== X-IronPort-AV: E=McAfee;i="6000,8403,9754"; a="141431845" X-IronPort-AV: E=Sophos;i="5.77,300,1596524400"; d="scan'208";a="141431845" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 19:35:58 -0700 IronPort-SDR: edQLed7J+7Et0h2PLwHieV0s0QzFTiRjxkPWU1Y571lz/hcfhCCNF4dB5mgNHCb3klmchnXBSo yLaHmH6kYifg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,300,1596524400"; d="scan'208";a="512515330" Received: from shskylake.sh.intel.com ([10.239.48.137]) by fmsmga005.fm.intel.com with ESMTP; 24 Sep 2020 19:35:55 -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, Ethan Zhao Subject: [PATCH 4/5] PCI: only return true when dev io state is really changed Date: Thu, 24 Sep 2020 22:34:22 -0400 Message-Id: <20200925023423.42675-5-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200925023423.42675-1-haifeng.zhao@intel.com> References: <20200925023423.42675-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 --- drivers/pci/pci.h | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fa12f7cbc1a0..d420bb977f3b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -362,35 +362,10 @@ 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) + if (dev->error_state != new) { dev->error_state = new; + changed = true; + } return changed; } -- 2.18.4