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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EC98C4338F for ; Fri, 6 Aug 2021 01:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3778D611C7 for ; Fri, 6 Aug 2021 01:26:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235464AbhHFB0p (ORCPT ); Thu, 5 Aug 2021 21:26:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:59652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhHFB0o (ORCPT ); Thu, 5 Aug 2021 21:26:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78B2F611C5; Fri, 6 Aug 2021 01:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628213189; bh=QvIgHk9TGLUizh9HoaiT/w3IVfdthAAaKnipBI+IXqU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aJyfd6vf4uGNUZ/z9XjXxkobtvILX3aPKo4R42Ju9t4tJ30ximrZFRSnOkAE85M4V y4om5owCrwWGzyldynuTAeLFkbipXJKypkUFFt/Szom14eMqSwbzmXMoQnORAH0gjA IgsPCjnX8K5EtbV8FfgDRnPYoODPWZ1tavyPS5ek5T343R52JcED2myQIlsiHwOikL 07hWjYj5K0MpaarYRttjohJynzeK4UNZp1rXUMDCiZtECI1CD0JMK6oIZ9tBR3jEU9 aBDKXMkbjDfserKT3Z0ftZkkdqnQTdWmw+kBKaEcwqOaB6XJmhIFA58kaXSUyA9h68 tp5Tp7y3nfRhw== Date: Thu, 5 Aug 2021 18:26:28 -0700 From: Jakub Kicinski To: Alex Elder Cc: davem@davemloft.net, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/6] net: ipa: don't suspend/resume modem if not up Message-ID: <20210805182628.02ebf355@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210804153626.1549001-2-elder@linaro.org> References: <20210804153626.1549001-1-elder@linaro.org> <20210804153626.1549001-2-elder@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Aug 2021 10:36:21 -0500 Alex Elder wrote: > The modem network device is set up by ipa_modem_start(). But its > TX queue is not actually started and endpoints enabled until it is > opened. > > So avoid stopping the modem network device TX queue and disabling > endpoints on suspend or stop unless the netdev is marked UP. And > skip attempting to resume unless it is UP. > > Signed-off-by: Alex Elder You said in the cover letter that in practice this fix doesn't matter. It seems trivial to test so perhaps it doesn't and we should leave the code be? Looking at dev->flags without holding rtnl_lock() seems suspicious, drivers commonly put the relevant portion of suspend/resume routines under rtnl_lock()/rtnl_unlock() (although to be completely frank IDK if it's actually possible for concurrent suspend + open/close to happen). Are there any callers of ipa_modem_stop() which don't hold rtnl_lock()? > diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c > index 4ea8287e9d237..663a610979e70 100644 > --- a/drivers/net/ipa/ipa_modem.c > +++ b/drivers/net/ipa/ipa_modem.c > @@ -178,6 +178,9 @@ void ipa_modem_suspend(struct net_device *netdev) > struct ipa_priv *priv = netdev_priv(netdev); > struct ipa *ipa = priv->ipa; > > + if (!(netdev->flags & IFF_UP)) > + return; > + > netif_stop_queue(netdev); > > ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); > @@ -194,6 +197,9 @@ void ipa_modem_resume(struct net_device *netdev) > struct ipa_priv *priv = netdev_priv(netdev); > struct ipa *ipa = priv->ipa; > > + if (!(netdev->flags & IFF_UP)) > + return; > + > ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); > ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); > > @@ -265,9 +271,11 @@ int ipa_modem_stop(struct ipa *ipa) > /* Prevent the modem from triggering a call to ipa_setup() */ > ipa_smp2p_disable(ipa); > > - /* Stop the queue and disable the endpoints if it's open */ > + /* Clean up the netdev and endpoints if it was started */ > if (netdev) { > - (void)ipa_stop(netdev); > + /* If it was opened, stop it first */ > + if (netdev->flags & IFF_UP) > + (void)ipa_stop(netdev); > ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = NULL; > ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = NULL; > ipa->modem_netdev = NULL;