Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2348506ybp; Sat, 5 Oct 2019 10:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGPIYLugyyRQqg1QfgDikWBuhUgNGRa5Hx2LTE5V5aYlN4n7JTYDkBcaYNT1wiqYitBtnF X-Received: by 2002:a17:906:52d8:: with SMTP id w24mr16992013ejn.6.1570296248631; Sat, 05 Oct 2019 10:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570296248; cv=none; d=google.com; s=arc-20160816; b=y11fcp2JS3kNvmcBY7vVhWZweoOVGeqHmr+GwkiqEC8X5B1FppbLeuVx4dRuYms7dD vj56XHz7rJ+p6DpV1aKywsroGRt6S+tbX9aDODo4PfnZvT+L5yYiRRuQuT+ML4ZlThrF 5K8rjgJzI5haPxzhy+Qh15jVZhb4QFqscd5ZR+6bpgg1onrwSISDq0wXiy+Nw4UjYvo+ TGInCKfhz5AT5hcY/wOmtjrihS9bF7JChIZ8BAxv3eOfi/8t823C9lrqnr4Uzi6h1Npi Jn6qrb45682DCgEUO+efPVlVGeNb4lCUUclkDEn6b+7K68YkzIH/4X/KjKoN2PdFvoyk qN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pxUjmIbw13CFxUgTRwyvWTjL0FCOWPTaQat66nHsxn0=; b=drsScM3tGp4ks/rDwpTOxEW8GgzRwV5TmwmVaw4yWGZDM6TzIbYMDGUTj+lo2epdBN ocl8dE490provaxapdnq1JW/j136ioXNgrQOrz1i80+IoZrQ1dxYk+9frO8OnZu124jV 7MDENaH7SJtbeJlmsow635MwYa35ufNlwk+SFKLPAuYA4c+bIHBQarSKGt9qg+q4wOBt dGgz999Y+B7/ITd0YlZGEIsDVEvEgodPxyN33RppOlfQ0OrNKiMCG0GX8ZRmVHLqVGie 8uee651yqKhdV9XGj0LrgO5BnR3IsEqYMUr7ZwdEEj2okLGBdapLTB+NXF4gqB9tY2x2 x8aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GjHYE04f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v8si6096034edi.22.2019.10.05.10.23.44; Sat, 05 Oct 2019 10:24:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GjHYE04f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729222AbfJERXI (ORCPT + 99 others); Sat, 5 Oct 2019 13:23:08 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:41723 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbfJERXH (ORCPT ); Sat, 5 Oct 2019 13:23:07 -0400 Received: by mail-io1-f68.google.com with SMTP id n26so20185538ioj.8; Sat, 05 Oct 2019 10:23:07 -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=pxUjmIbw13CFxUgTRwyvWTjL0FCOWPTaQat66nHsxn0=; b=GjHYE04fxu3DN13Mnf7fbSHz1nFx//ZjX7nE9aR/qHFSe2rn6p59OexXtYrrEraHOa cXCoRJk2iT1G5LdGA6mTi8hUidXPkXUBu+tOw+Tx2dvt0IUcjmL41mT7b4dRX8eUrTyk 607GLwODe1OC5tQeDGdWeIkX+MYfVZVXXswoWXtm70D9EHTsWqAr/FZsMS7GpIuokoPm 9/8/yAHZaDs3AstB1kp0qbEECIodqnVJfQ+l7AG/akZsUlPGpW+a1VQXF08r15qDG0UX a+JybUpzNaVL93WAYik84iCfzADKmk1AcZ4f7dLGNeuLteK+YraQ3dkxhHswE/HTi/kP Qp+w== 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=pxUjmIbw13CFxUgTRwyvWTjL0FCOWPTaQat66nHsxn0=; b=XjCDmB2QcTjEQA/14iaHdBh3qk+/njOBDrQE4CCHfZ+jCNoa15+152nFbDyBX+im4H HShQOhSB46rwuXM/QgbojnV9Xayf+fZGavlUotxL8SdjrMIZWblE9RE5pyZLuhXuwVNg DJf4+lAaEL3ckkwc5hCzXIiDQ0+NrFgGRTTbgxzDUrRx/zmy0S14bjSGgiTz3+MC+s8F +AR+zBc7LwjdHxTucL0OKNvpaUqQvqamfNe4Llpu3z3EIOYnie39SE7dGFDg1dgISb8r MbrAqx4yMF34chxNPHTO8nSCTMmKPIrNJR30xlx85s3oCJT7w4wLKqMFsKS89GWrXl/M 5nVw== X-Gm-Message-State: APjAAAWDFfeyDAfXRlfEquZ4BwtOqglIiBXO191iBlKrBbZKz8yjkXhl A1TTByoiRKBrqZeewisH3KKko3hbpWGChrws5KY= X-Received: by 2002:a6b:da06:: with SMTP id x6mr9478783iob.42.1570296186664; Sat, 05 Oct 2019 10:23:06 -0700 (PDT) MIME-Version: 1.0 References: <1570208647.1250.55.camel@oc5348122405> <20191004233052.28865.1609.stgit@localhost.localdomain> <1570241926.10511.7.camel@oc5348122405> In-Reply-To: <1570241926.10511.7.camel@oc5348122405> From: Alexander Duyck Date: Sat, 5 Oct 2019 10:22:55 -0700 Message-ID: Subject: Re: [RFC PATCH] e1000e: Use rtnl_lock to prevent race conditions between net and pci/pm To: "David Z. Dai" Cc: Netdev , LKML , intel-wired-lan , Jeff Kirsher , zdai@us.ibm.com, David Miller Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 4, 2019 at 7:18 PM David Z. Dai wrote: > > On Fri, 2019-10-04 at 16:36 -0700, Alexander Duyck wrote: > > From: Alexander Duyck > > > > This patch is meant to address possible race conditions that can exist > > between network configuration and power management. A similar issue was > > fixed for igb in commit 9474933caf21 ("igb: close/suspend race in > > netif_device_detach"). > > > > In addition it consolidates the code so that the PCI error handling code > > will essentially perform the power management freeze on the device prior to > > attempting a reset, and will thaw the device afterwards if that is what it > > is planning to do. Otherwise when we call close on the interface it should > > see it is detached and not attempt to call the logic to down the interface > > and free the IRQs again. > > > > >From what I can tell the check that was adding the check for __E1000_DOWN > > in e1000e_close was added when runtime power management was added. However > > it should not be relevant for us as we perform a call to > > pm_runtime_get_sync before we call e1000_down/free_irq so it should always > > be back up before we call into this anyway. > > > > Signed-off-by: Alexander Duyck > > --- > > > > I'm putting this out as an RFC for now. I haven't had a chance to do much > > testing yet, but I have verified no build issues, and the driver appears > > to load, link, and pass traffic without problems. > > > > This should address issues seen with either double freeing or never freeing > > IRQs that have been seen on this and similar drivers in the past. > > > > I'll submit this formally after testing it over the weekend assuming there > > are no issues. > > > > drivers/net/ethernet/intel/e1000e/netdev.c | 33 ++++++++++++++-------------- > > 1 file changed, 17 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c > > index d7d56e42a6aa..182a2c8f12d8 100644 > > --- a/drivers/net/ethernet/intel/e1000e/netdev.c > > +++ b/drivers/net/ethernet/intel/e1000e/netdev.c > > > > -#ifdef CONFIG_PM_SLEEP > > static int e1000e_pm_thaw(struct device *dev) > > { > > struct net_device *netdev = dev_get_drvdata(dev); > > struct e1000_adapter *adapter = netdev_priv(netdev); > > + int rc = 0; > > > > e1000e_set_interrupt_capability(adapter); > > - if (netif_running(netdev)) { > > - u32 err = e1000_request_irq(adapter); > > > > - if (err) > > - return err; > > + rtnl_lock(); > > + if (netif_running(netdev)) { > > + rc = e1000_request_irq(adapter); > > + if (rc) > > + goto err_irq; > > > > e1000e_up(adapter); > > } > > > > netif_device_attach(netdev); > > - > > - return 0; > > + rtnl_unlock(); > > +err_irq: > > + return rc; > > } > > > In e1000e_pm_thaw(), these 2 lines need to switch order to avoid > deadlock. > from: > + rtnl_unlock(); > +err_irq: > > to: > +err_irq: > + rtnl_unlock(); > > I will find hardware to test this patch next week. Will update the test > result later. > > Thanks! - David Thanks for spotting that. I will update my copy of the patch for when I submit the final revision. I'll probably wait to submit it for acceptance until you have had a chance to verify that it resolves the issue you were seeing. Thanks. - Alex