From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD086C4332F for ; Thu, 10 Nov 2022 09:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiKJJRU (ORCPT ); Thu, 10 Nov 2022 04:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiKJJRQ (ORCPT ); Thu, 10 Nov 2022 04:17:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C7A69DEC; Thu, 10 Nov 2022 01:17:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0DFEE60ABE; Thu, 10 Nov 2022 09:17:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0ADDC433C1; Thu, 10 Nov 2022 09:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668071834; bh=6TJNnSviLlX563oQpc85BIYcQat1cVbnGv4v0Qc+vJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nuErvBV+JiX3N5HtvK2D1LR6w1MiTqz7BX5r2A6wKtpNtZxMsDPZj7y69xuhyTrD3 BUuHNxOElpY18O+P3jV6r/vZL6mlUcfRAjl+enMvT2qbPtgbmZkiEtspmxeUt+1w7n q4uZwOiaNepckD00u0BL2SBfyOBikhzIxoi3VjYOaJgOrlyf6ktk7M8di8qVtZzIab OXbOV+mAGv40umA6nNEOja5M8uFKT8hIhlrr6pd8XGadKRJv0LVic4dCy1Q9h/nomD H/P/X+7S3skPgOh5bRAlJxAdvunajMCzS7uhQBOTp9dcUiexSdwcxlhpp/lEFb9DHM kM6oHKUX4Cm5Q== Date: Thu, 10 Nov 2022 11:17:09 +0200 From: Leon Romanovsky To: "Keller, Jacob E" Cc: ivecera , "netdev@vger.kernel.org" , "sassmann@redhat.com" , "Piotrowski, Patryk" , SlawomirX Laba , "Brandeburg, Jesse" , "Nguyen, Anthony L" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "moderated list:INTEL ETHERNET DRIVERS" , open list Subject: Re: [PATCH net] iavf: Do not restart Tx queues after reset task failure Message-ID: References: <20221108102502.2147389-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 09, 2022 at 08:11:55PM +0000, Keller, Jacob E wrote: > > > > -----Original Message----- > > From: Leon Romanovsky > > Sent: Wednesday, November 9, 2022 10:21 AM > > To: ivecera > > Cc: netdev@vger.kernel.org; sassmann@redhat.com; Keller, Jacob E > > ; Piotrowski, Patryk ; > > SlawomirX Laba ; Brandeburg, Jesse > > ; Nguyen, Anthony L > > ; David S. Miller ; Eric > > Dumazet ; Jakub Kicinski ; Paolo > > Abeni ; moderated list:INTEL ETHERNET DRIVERS > wired-lan@lists.osuosl.org>; open list > > Subject: Re: [PATCH net] iavf: Do not restart Tx queues after reset task failure > > > > On Tue, Nov 08, 2022 at 11:25:02AM +0100, Ivan Vecera wrote: > > > After commit aa626da947e9 ("iavf: Detach device during reset task") > > > the device is detached during reset task and re-attached at its end. > > > The problem occurs when reset task fails because Tx queues are > > > restarted during device re-attach and this leads later to a crash. > > > > <...> > > > > > + if (netif_running(netdev)) { > > > + /* Close device to ensure that Tx queues will not be started > > > + * during netif_device_attach() at the end of the reset task. > > > + */ > > > + rtnl_lock(); > > > + dev_close(netdev); > > > + rtnl_unlock(); > > > + } > > > > Sorry for my naive question, I see this pattern a lot (including RDMA), > > so curious. Everyone checks netif_running() outside of rtnl_lock, while > > dev_close() changes state bit __LINK_STATE_START. Shouldn't rtnl_lock() > > placed before netif_running()? > > Yes I think you're right. A ton of people check it without the lock but I think thats not strictly safe. Is dev_close safe to call when netif_running is false? Why not just remove the check and always call dev_close then. I honestly don't know. To remove any doubts, this patch is LGTM. Thanks, Reviewed-by: Leon Romanovsky