Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2750080pxk; Sun, 27 Sep 2020 21:12:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3Juo3rCiNjgtbYM3SYxXOEdMhPqbgXPLn/toSycjHb3qMOJ8y3IYNfWrkE6z67tgz6ScA X-Received: by 2002:a17:906:874f:: with SMTP id hj15mr14399279ejb.539.1601266332792; Sun, 27 Sep 2020 21:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601266332; cv=none; d=google.com; s=arc-20160816; b=ANry7zqGNCiiyhVg1P5z6VA+h269MykqozObW7Ok8/srVeROLsB7HL3thFd5nwBpXq NJWFT9v73/xNfTQlx90nie9COICWTc59uYyGMAchd1kaMN5feo8n/sdjZQS0+oASHG+t qlQCL23ZV6MX3xxQK/OCE84NuhS2xU6GmU7o7w6BWNfZCb7FJKOCiU1/qh469PXLp5Xv E82LIl6KhkpteczF3A5p6/VBoTN6cLRfVSX8woDJ888ODVV7K6uI2TTbRgRcl77C8rbd rFPM0X/V+KbCuSCz8TtPF2F1yd7zaxrKXkyLjzPd8odC5yJmgW5bFuPbTC4LA/O3gRyi D13A== 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=QuOpo0EwD+25Aw/Qk6gV4TkVu/gsIFvJj6CAf/TQ5EU=; b=wkizxWhTt9ccZBSXmhC/xrnKpvRSM/pdCM9glVu7x9vZ0w0TTzIqys63YpBVqeh4Sb 4S7ZnOOi26apXGaFvw0ieZf2M7T5/tHYz9wKzojXmuE29Mg/LdAA3LcOkPxV9UEO5m5n /KvwmJmKhsNL2Pn9XwAxmxt+pk1X/VBMi9hF199YkVRb3kNxbEE2FDVc2Y4GT7K3Krkr iGggVP6nc2MVViWFPh5HiDz4dIgaYofPk3RHZwHcTvfx6LKJBcyPfc6bh+41HOjMUhrk hwx4XzuVuNfgeDDf4gfxxVf68ehrh4LJgJEiLQfUDZOh4Af7gCzvKQtrp/TsosXeVGNO WImQ== 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 u20si7595433edy.509.2020.09.27.21.11.50; Sun, 27 Sep 2020 21:12:12 -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 S1726588AbgI1EIi (ORCPT + 99 others); Mon, 28 Sep 2020 00:08:38 -0400 Received: from mga18.intel.com ([134.134.136.126]:30286 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbgI1EIi (ORCPT ); Mon, 28 Sep 2020 00:08:38 -0400 IronPort-SDR: Us+/FGGfc9McV50xrfUIfAyEh9NanlfZRBmZ/aDFZX8JQEw3wHtaWl8lciNvARMHolmGES2pnh 4raSQJYv595w== X-IronPort-AV: E=McAfee;i="6000,8403,9757"; a="149710897" X-IronPort-AV: E=Sophos;i="5.77,312,1596524400"; d="scan'208";a="149710897" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2020 21:08:37 -0700 IronPort-SDR: EcRkVaXMgGIfAc6eIQxhEJ3PGHrW6OFtiEQXTTZtuV9zOZI79S+1NKoeZM5/7fla2gyLuQFmeu DJV1KfFTBtZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,312,1596524400"; d="scan'208";a="311628167" Received: from shskylake.sh.intel.com ([10.239.48.137]) by orsmga006.jf.intel.com with ESMTP; 27 Sep 2020 21:08:34 -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 V4] PCI: only return true when dev io state is really changed Date: Mon, 28 Sep 2020 00:06:50 -0400 Message-Id: <20200928040651.24937-5-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200928040651.24937-1-haifeng.zhao@intel.com> References: <20200928040651.24937-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: Alexandru Gagniuc --- Changnes: V2: revise description and code according to suggestion from Andy. V3: change code to simpler. V4: no change. V5: no change. 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