Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2859567pxk; Mon, 28 Sep 2020 01:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ9x1bkkTI8BYtwzVXRzQEtCjeguKlhr8LqOe6GyyslEWs15nBrVGVtdzRcQktbDGd1RRX X-Received: by 2002:a05:6402:2c3:: with SMTP id b3mr519580edx.213.1601282895678; Mon, 28 Sep 2020 01:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601282895; cv=none; d=google.com; s=arc-20160816; b=HttLcWa3YdrWU3xkLIwzWbFNR2PJFG8LrA/dckuf58GPQVhYb4LTBclsghjU+QV7V8 J1RrhWcv6S3RMf27IF8uxmoOSS4wG0B4eDhc7ICS0LdeMcrDXQc2prqlc9wXAOs2WNLM G35+9LJXD1IHFEeowtQiwTrq2zU79EV+CM1FVL/5wd6AnfrD6uuBH+uR4v4h2oPIN8GQ YekfXaLA5a0X0lxAznb1dZdpJhyqD+mXtEz9Ahmvco12yeML2gxKxkHqQvjzmTDE5XT5 JLMfwOvsw3Ix27+HJ8AIxqAl7eCX/IjyIXmh3tFGx4e4jPvNIiRnD2Wn6swZpnR5+qkc 7/YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=brpxKwQZ9NEyo3kql+ZLUvVmIiQJFbmnCGpOp8iZFjQ=; b=ilJE5g177h3dR9TYNZmxNo2MbRMAXD/ABiAwlr+XsSbxM8Ij9ROxMCKPc5QKuSA99f NjlgwAfhvCrzHm7XYTI1DD9T97ZI8VY34Toxrp0EYoc3+wDwiGiN5ZAKnLpWvNj68UGg Vl9ssRzyuLuQ4TX/5k6Xz29dCM05BZRTK8OYxpoT3oiv4pkEnb6qkdIYW0ZAY2GlQHzp Bla+/dgTH9kLH/4VXy2wkTHujJkVMSGX/ukTXaPYwHlk2682oLFThBny+90Fqj2CgkHP Kl6zMoB04ExGq/dzatDFqDYtt8vZprT1shaMZoPzavugcvPlfJC93UN1ZnJfAPatgIrU ToBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gyYGGdnf; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si150936edy.478.2020.09.28.01.47.53; Mon, 28 Sep 2020 01:48:15 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gyYGGdnf; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726645AbgI1Iqq (ORCPT + 99 others); Mon, 28 Sep 2020 04:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1Iqq (ORCPT ); Mon, 28 Sep 2020 04:46:46 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86DF4C0613CE; Mon, 28 Sep 2020 01:46:46 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id e18so270403pgd.4; Mon, 28 Sep 2020 01:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=brpxKwQZ9NEyo3kql+ZLUvVmIiQJFbmnCGpOp8iZFjQ=; b=gyYGGdnfbz+QxrRGNNYeoI+2JeIwQOuoFC+gx9buN+/94EYOMnCDfuCkPltjirMcxK sRNgp+3WDPt3+yOl9vmC4+BYwG5mXkugoglOHDB4+bOWgWXImvclHB74g9dd4SlxK2AS gfHMwhc1WTnzMAjzL0wk4zBz6LDLgo3ELNHrxwsH74cg7+ZbVH2j+EfkfuGZ07ezklh1 DqdGmJN3eQsQhv12HJaD27FstRJoAUCeZQBpCVph849zjKq6r6wAS5GzKTeWKBqHg/4r Sl8Y8Upz7KhwbpHirF0BBvbuWnAafaG4X1xrnxlguRFeFY31frpEc+DxUfC5IBq2eovz a/vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=brpxKwQZ9NEyo3kql+ZLUvVmIiQJFbmnCGpOp8iZFjQ=; b=tFxTxUVFak0YVeKsfLVjM7OqQFUH6FjxKKTgurzecwA5bKRwjLW2b2mOwhsevPGGWI 8PQgUvrfUuQyiBMQLCulwNfafnXEIHsxCRk9TQPn1Dai3Kt+vJqszW/38oxFC49xr/vp cf9+scMVGred2hIeyFdEKHMEWVAGnmq4vLiuP1KLCYeIBoLDkXNCbvpjLS/htSInhJiR Odc3fo/PZQn35GKaGfEiDaIM/OQF82Er8Jw3CgRRVjR3v6AvLSxPA9H2xtXRS937S6J5 xLEm5Y3lrYIHMilXoYDHKS1FgILT2BbHcil1DxAeEqTwQQlS3h0CQMvyXf8jz8DPW30Z 7QMA== X-Gm-Message-State: AOAM5312U4VX/jtcH8EtOrIiRdGRGzShTpHAqUF6E33XOukXSV/oxfge Y+dxaKOKvKrrGXXXi8M3vXI9WiuEqlRA5hd2mvE= X-Received: by 2002:a17:902:b481:b029:d2:686a:4e1f with SMTP id y1-20020a170902b481b02900d2686a4e1fmr610560plr.17.1601282806110; Mon, 28 Sep 2020 01:46:46 -0700 (PDT) MIME-Version: 1.0 References: <20200928040651.24937-1-haifeng.zhao@intel.com> <20200928040651.24937-5-haifeng.zhao@intel.com> In-Reply-To: <20200928040651.24937-5-haifeng.zhao@intel.com> From: Andy Shevchenko Date: Mon, 28 Sep 2020 11:46:27 +0300 Message-ID: Subject: Re: [PATCH 4/5 V4] PCI: only return true when dev io state is really changed To: Ethan Zhao Cc: Bjorn Helgaas , Oliver , ruscur@russell.cc, Lukas Wunner , Andy Shevchenko , Stuart Hayes , Alexandru Gagniuc , Mika Westerberg , linux-pci , Linux Kernel Mailing List , pei.p.jia@intel.com, ashok.raj@linux.intel.com, Sathyanarayanan Kuppuswamy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 7:13 AM Ethan Zhao wrote: > > 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. > This one looks good (more or less) now. Reviewed-by: Andy Shevchenko > 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 > -- With Best Regards, Andy Shevchenko