Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2277132pxk; Sun, 27 Sep 2020 01:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcOE0b4PRETvycUP5sIaTSK8Zd5ZyIrpx2Bhs3uvDwTO3g2sMpDkiQquy6Yl0wUusVYJM+ X-Received: by 2002:a50:e79c:: with SMTP id b28mr10360056edn.371.1601195505949; Sun, 27 Sep 2020 01:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601195505; cv=none; d=google.com; s=arc-20160816; b=Y5TYUb6Gk6LQSoU0+na1UvdxWrDp6Puvyd9gyPw8VCwQd3wHTrZJLI02AY6bbZI1CQ kLTt54fOQB/J2fu3xDe8R83+wVeuQcO33p8nHDWqrjol40jIodGxUDFlAl97p2owziSY ufiLQqTd6dN7HROcKlEgkdvKu6wIgPDToplP7hUvGP7wVhlpp3z7u2gpqslbc0z9V9CU ZbueGr8ZUDdSjleXZ++8qPAzbKHjM8SS/1W4/cdInSsacX+l4aT1GuQLrc0yLC22F0Kk UI40o4Ap8MWnKvS88ffhTG0TDL3zQi6zG5dBNSea5Ht7B+I51hrjII6LsHPKoqr5qUtT qO2w== 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=E4eqX4Eo4Idxofk+jN7dayHXX2n22xUMFClphaTRpvk=; b=0l+rnMKucuiIQu/8bFl2R5l2V1gkfr+Gux2Slxq8eCxGo+9TSIf1202t/Gn8fSVQlK vwFDqoxtSi470jf8pu2q63CVPZcnSZJq1jY8GRGsslTBNiJZ1W/6+w1ckQuDlqx6PKkG LEH8xBp5VpiBvrTphrOZSyHl9plc1KYHNGwH4GH5zoYwqDpIRYE5WFoF6MY+gENM9DQ4 ipTjnCS2ksHm/h71n4Ryls2xr+wtl98q6y7iEro21yzXbs0/L87Hev9xh0QtwT/TWhhO OkUVOoRC0XLgxrO0XjJ1MlkZaL0HKO1bQmNTzAy5ouu9Rp2dcIg+FFzsS++QpL6UGQcN VS6A== 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 h16si5276924edr.336.2020.09.27.01.31.23; Sun, 27 Sep 2020 01:31:45 -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 S1730596AbgI0I3b (ORCPT + 99 others); Sun, 27 Sep 2020 04:29:31 -0400 Received: from mga03.intel.com ([134.134.136.65]:31482 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730548AbgI0I3a (ORCPT ); Sun, 27 Sep 2020 04:29:30 -0400 IronPort-SDR: WFSjwK8cYqQHQnJmKUlKlq68ypNWakChcE0YAFE8+VxNKmRzlGKm/oeCbHKk5AbNr0k6FEr/f4 jZA/JK/jeCEA== X-IronPort-AV: E=McAfee;i="6000,8403,9756"; a="161912202" X-IronPort-AV: E=Sophos;i="5.77,309,1596524400"; d="scan'208";a="161912202" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2020 01:29:30 -0700 IronPort-SDR: 1wAIsIchmeEmypOu/RH+O+8G4P6HKibAmlUzRWwVsjsxSupfoktZx4+jYCcQcJBJ/XV9eivWjR UxwdsByz7EPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,309,1596524400"; d="scan'208";a="456437745" Received: from shskylake.sh.intel.com ([10.239.48.137]) by orsmga004.jf.intel.com with ESMTP; 27 Sep 2020 01:29:27 -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, hch@infradead.org, joe@perches.com, Ethan Zhao Subject: [PATCH 4/5 V4] PCI: only return true when dev io state is really changed Date: Sun, 27 Sep 2020 04:27:35 -0400 Message-Id: <20200927082736.14633-5-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200927082736.14633-1-haifeng.zhao@intel.com> References: <20200927082736.14633-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. V4: 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