From patchwork Fri Aug 24 19:51:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 179896 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9BC822C00FD for ; Sat, 25 Aug 2012 05:51:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760136Ab2HXTvO (ORCPT ); Fri, 24 Aug 2012 15:51:14 -0400 Received: from webmail.solarflare.com ([12.187.104.25]:56751 "EHLO ocex02.SolarFlarecom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758130Ab2HXTvN (ORCPT ); Fri, 24 Aug 2012 15:51:13 -0400 Received: from [10.17.20.137] (10.17.20.137) by ocex02.SolarFlarecom.com (10.20.40.31) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 24 Aug 2012 12:51:12 -0700 Message-ID: <1345837870.2694.29.camel@bwh-desktop.uk.solarflarecom.com> Subject: [PATCH net-next 07/16] sfc: Hold the RTNL lock for more of the suspend/resume cycle From: Ben Hutchings To: David Miller CC: , Date: Fri, 24 Aug 2012 20:51:10 +0100 In-Reply-To: <1345837574.2694.22.camel@bwh-desktop.uk.solarflarecom.com> References: <1345837574.2694.22.camel@bwh-desktop.uk.solarflarecom.com> Organization: Solarflare Communications X-Mailer: Evolution 3.2.3 (3.2.3-3.fc16) MIME-Version: 1.0 X-Originating-IP: [10.17.20.137] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I don't think these PM functions can race with userland net device operations, but it's much easier to reason about locking if state is consistently guarded by the same lock. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 9f88ad8..e5f3a17 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -2727,6 +2727,8 @@ static int efx_pm_freeze(struct device *dev) { struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); + rtnl_lock(); + efx->state = STATE_UNINIT; netif_device_detach(efx->net_dev); @@ -2734,6 +2736,8 @@ static int efx_pm_freeze(struct device *dev) efx_stop_all(efx); efx_stop_interrupts(efx, false); + rtnl_unlock(); + return 0; } @@ -2741,6 +2745,8 @@ static int efx_pm_thaw(struct device *dev) { struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); + rtnl_lock(); + efx_start_interrupts(efx, false); mutex_lock(&efx->mac_lock); @@ -2755,6 +2761,8 @@ static int efx_pm_thaw(struct device *dev) efx->type->resume_wol(efx); + rtnl_unlock(); + /* Reschedule any quenched resets scheduled during efx_pm_freeze() */ queue_work(reset_workqueue, &efx->reset_work);