Message ID | 58500052a6740806e8af199ece45e97cb5eeb1b8.1684393811.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp299755vqo; Thu, 18 May 2023 00:22:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Wgw00npdnEamWrITHi4cgLErWLCtRTns/2t/n0cNXqCKpoRAuA+UAWA4uyqjPhYLuTCMD X-Received: by 2002:a17:902:f809:b0:1ad:dd21:2691 with SMTP id ix9-20020a170902f80900b001addd212691mr1711146plb.10.1684394571212; Thu, 18 May 2023 00:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684394571; cv=none; d=google.com; s=arc-20160816; b=og+8yrMRTwY/t1SlxyYowoOWojEFG3rdBvQeFsVJmK3OSFGGaXjPdZie7pGIpv84Iw VwPgKD6c+To3OqyUyV6jQui1rsN4ayVj5j0b6LJDDq/a8cILyBiP/8ptCnPfguSjxW8I 3PPu4ZuN7Rjnu94hQV6PyY/mSJIN5UcYhj5xjgQ0Qy6nHqzP9kvX4+BtbuNd/0MJuoWL 5qNwELLlx2xsMMWfy1lWYic3Tc67so4mrHs1k54tENfGA4C8W+Q24qCl1fV0vJeS3EH0 hLzaUXXwvgj7MW2TZG29WsDp++rAjOXtPCcuA4HIlJh/6at64SAZGahyBjicOUrJUA2M N3fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=F+zInelYRTBn1Bc3nl++TZglWSkvYGCgphkwfxYXGUI=; b=UsT3sFY2HkxmTMKIIpcsrprrFLMjw6z8MmzYnNSslwPnDfoZAA4ibXayac5Ai2HGCW 7XpNW0hvUXNhfZeCbQqHgbwSWhZCbMRFx7EpFZr6KEZfxRcO6NFcrPIGgZQUoI5YHY+c hWggnNFh6KRht1cO2F7FqgYeSdN57RodLWUMcduPKNUSv6mKfI+csHUL0dH2Ms428xE6 hHJN1l5k6lwYDvIIrNFGg4ypJ4nbk/9NKrdxvt6CiN9K3k2rfuYrIL2bx9GLvS4xvZdb UJbEL/8rElLPvF0aAU9fTP979Lz6SqDLMHWQ29NdlB8/Mae0UgtRgCs/TehnpnxlHYDd /ubA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=jj5h5i+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170902ed5400b001ac311fefa3si685081plb.115.2023.05.18.00.22.38; Thu, 18 May 2023 00:22:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=jj5h5i+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjERHKx (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Thu, 18 May 2023 03:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjERHKv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 18 May 2023 03:10:51 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922CC10D9 for <linux-kernel@vger.kernel.org>; Thu, 18 May 2023 00:10:46 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id zXmapJCyDEQ0YzXmbpoAuZ; Thu, 18 May 2023 09:10:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1684393844; bh=F+zInelYRTBn1Bc3nl++TZglWSkvYGCgphkwfxYXGUI=; h=From:To:Cc:Subject:Date; b=jj5h5i+UBg8mXjxtMytCz3rOb/3ZuplCgQI7Qtmube/kc/QQnYDVSVNeRw4htK//5 JtCtXmMUqbJq96EQ2dpuiOHjg3Is7ZG3zDKWOUrK+ko4kGTcuDsrPINQ6qhP5Q0q70 yCn5VgPnQDvFvZ/NgNCMuopUozdGtPGJWiSWC+634Ft55qDtM1WNMC+fpjx/BEnGQ/ GTzk4kULOfnMzjSEIk14pCoEN08qbs9IO0TWBuIvrauEetjnYGh36xT/pXmczco7lV 6obaf4B7UzFX1Vln9AD8XW0fvSx3pgLG21OZTLdYyeIWjG0M4m4dIHHhdVnU2JUzOb AkY+DDx1mDgkA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 18 May 2023 09:10:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Pavel Pisa <pisa@cmp.felk.cvut.cz>, Ondrej Ille <ondrej.ille@gmail.com>, Wolfgang Grandegger <wg@grandegger.com>, Marc Kleine-Budde <mkl@pengutronix.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] can: ctucanfd: Remove a useless netif_napi_del() call Date: Thu, 18 May 2023 09:10:39 +0200 Message-Id: <58500052a6740806e8af199ece45e97cb5eeb1b8.1684393811.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766215721581954599?= X-GMAIL-MSGID: =?utf-8?q?1766215721581954599?= |
Series |
can: ctucanfd: Remove a useless netif_napi_del() call
|
|
Commit Message
Christophe JAILLET
May 18, 2023, 7:10 a.m. UTC
free_candev() already calls netif_napi_del(), so there is no need to call
it explicitly. It is harmless, but useless.
This makes the code mode consistent with the error handling path of
ctucan_probe_common().
While at it, remove a wrong comment about the return value of this
function.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
The comment went wrong after 45413bf75919 ("can: ctucanfd: Convert to platform remove callback returning void")
---
drivers/net/can/ctucanfd/ctucanfd_platform.c | 2 --
1 file changed, 2 deletions(-)
Comments
Dear Christophe, On Thursday 18 of May 2023 09:10:39 Christophe JAILLET wrote: > free_candev() already calls netif_napi_del(), so there is no need to call > it explicitly. It is harmless, but useless. > > This makes the code mode consistent with the error handling path of > ctucan_probe_common(). OK, but I would suggest to consider to keep sequence in sync with linux/drivers/net/can/ctucanfd/ctucanfd_pci.c where is netif_napi_del() used as well while ((priv = list_first_entry_or_null(&bdata->ndev_list_head, struct ctucan_priv, peers_on_pdev)) != NULL) { ndev = priv->can.dev; unregister_candev(ndev); netif_napi_del(&priv->napi); list_del_init(&priv->peers_on_pdev); free_candev(ndev); } On the other hand, if interrupt can be called for device between unregister_candev() and free_candev() or some other callback which is prevented by netif_napi_del() now then I would consider to keep explicit netif_napi_del() to ensure that no callback is activated to driver there. And for PCI integration it is more critical because list_del_init(&priv->peers_on_pdev); appears in between and I would prefer that no interrupt appears when instance is not on the peers list anymore. Even that would not be a problem for actual CTU CAN FD implementation, peers are accessed only during physical device remove, but I have worked on other controllers in past, which required to coordinate with peers in interrupt handling... So I would be happy for some feedback what is actual guarantee when device is stopped. May it be that it would be even more robust to run removal with two loop where the first one calls unregister_candev() and netif_napi_del() and only the second one removes from peers and call free_candev()... But I am not sure there and it is not problem in actual driver because peers are not used in any other place... > While at it, remove a wrong comment about the return value of this > function. OK, this has been caused probably by prototype change. > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > The comment went wrong after 45413bf75919 ("can: ctucanfd: Convert to > platform remove callback returning void") --- > drivers/net/can/ctucanfd/ctucanfd_platform.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/net/can/ctucanfd/ctucanfd_platform.c > b/drivers/net/can/ctucanfd/ctucanfd_platform.c index > 55bb10b157b4..8fe224b8dac0 100644 > --- a/drivers/net/can/ctucanfd/ctucanfd_platform.c > +++ b/drivers/net/can/ctucanfd/ctucanfd_platform.c > @@ -84,7 +84,6 @@ static int ctucan_platform_probe(struct platform_device > *pdev) * @pdev: Handle to the platform device structure > * > * This function frees all the resources allocated to the device. > - * Return: 0 always > */ > static void ctucan_platform_remove(struct platform_device *pdev) > { > @@ -95,7 +94,6 @@ static void ctucan_platform_remove(struct platform_device > *pdev) > > unregister_candev(ndev); > pm_runtime_disable(&pdev->dev); > - netif_napi_del(&priv->napi); > free_candev(ndev); > } Best wishes, Pavel Pisa phone: +420 603531357 e-mail: pisa@cmp.felk.cvut.cz Department of Control Engineering FEE CVUT Karlovo namesti 13, 121 35, Prague 2 university: http://control.fel.cvut.cz/ personal: http://cmp.felk.cvut.cz/~pisa projects: https://www.openhub.net/accounts/ppisa CAN related:http://canbus.pages.fel.cvut.cz/ RISC-V education: https://comparch.edu.cvut.cz/ Open Technologies Research Education and Exchange Services https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home
On 18.05.2023 09:32:38, Pavel Pisa wrote: > Dear Christophe, > > On Thursday 18 of May 2023 09:10:39 Christophe JAILLET wrote: > > free_candev() already calls netif_napi_del(), so there is no need to call > > it explicitly. It is harmless, but useless. > > > > This makes the code mode consistent with the error handling path of > > ctucan_probe_common(). > > OK, but I would suggest to consider to keep sequence in sync with > > linux/drivers/net/can/ctucanfd/ctucanfd_pci.c > > where is netif_napi_del() used as well > > while ((priv = list_first_entry_or_null(&bdata->ndev_list_head, struct ctucan_priv, > peers_on_pdev)) != NULL) { > ndev = priv->can.dev; > > unregister_candev(ndev); > > netif_napi_del(&priv->napi); > > list_del_init(&priv->peers_on_pdev); > free_candev(ndev); > } > > On the other hand, if interrupt can be called for device between > unregister_candev() and free_candev() At least the case of an "interrupt during ctucan_pci_remove()" is a bug, as there is no IRQ handler registered. The IRQ handler is registered in ctucan_open() and freed in ctucan_close(). > or some other callback > which is prevented by netif_napi_del() now then I would consider > to keep explicit netif_napi_del() to ensure that no callback > is activated to driver there. Napi itself is shut down, too, as there is a call to napi_disable() in ctucan_close(). > And for PCI integration it is more > critical because list_del_init(&priv->peers_on_pdev); appears in > between and I would prefer that no interrupt appears when instance > is not on the peers list anymore. Even that would not be a problem > for actual CTU CAN FD implementation, peers are accessed only during > physical device remove, but I have worked on other controllers > in past, which required to coordinate with peers in interrupt > handling... > > So I would be happy for some feedback what is actual guarantee > when device is stopped. After a ifup; ifdown;, which corresponds to ctucan_open(), ctucan_close() in the driver, the device should be shut down, no interrupts active. You might even power down the device, although things get a little more complicated with HW timestamping or even PTP enabled. > May it be that it would be even more robust to run removal > with two loop where the first one calls unregister_candev() > and netif_napi_del() and only the second one removes from peers > and call free_candev()... But I am not sure there and it is not > problem in actual driver because peers are not used in any > other place... regards, Marc
Hi Christophe,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mkl-can-next/testing]
[also build test WARNING on linus/master v6.4-rc2 next-20230518]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christophe-JAILLET/can-ctucanfd-Remove-a-useless-netif_napi_del-call/20230518-151217
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
patch link: https://lore.kernel.org/r/58500052a6740806e8af199ece45e97cb5eeb1b8.1684393811.git.christophe.jaillet%40wanadoo.fr
patch subject: [PATCH] can: ctucanfd: Remove a useless netif_napi_del() call
config: x86_64-allmodconfig
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/aaed91df00cf16ff7783fa535c29228072d41554
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christophe-JAILLET/can-ctucanfd-Remove-a-useless-netif_napi_del-call/20230518-151217
git checkout aaed91df00cf16ff7783fa535c29228072d41554
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202305181949.ywS3ECIq-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/net/can/ctucanfd/ctucanfd_platform.c: In function 'ctucan_platform_remove':
>> drivers/net/can/ctucanfd/ctucanfd_platform.c:91:29: warning: unused variable 'priv' [-Wunused-variable]
91 | struct ctucan_priv *priv = netdev_priv(ndev);
| ^~~~
vim +/priv +91 drivers/net/can/ctucanfd/ctucanfd_platform.c
e8f0c23a2415fa Pavel Pisa 2022-03-22 81
e8f0c23a2415fa Pavel Pisa 2022-03-22 82 /**
e8f0c23a2415fa Pavel Pisa 2022-03-22 83 * ctucan_platform_remove - Unregister the device after releasing the resources
e8f0c23a2415fa Pavel Pisa 2022-03-22 84 * @pdev: Handle to the platform device structure
e8f0c23a2415fa Pavel Pisa 2022-03-22 85 *
e8f0c23a2415fa Pavel Pisa 2022-03-22 86 * This function frees all the resources allocated to the device.
e8f0c23a2415fa Pavel Pisa 2022-03-22 87 */
45413bf759193d Uwe Kleine-König 2023-05-12 88 static void ctucan_platform_remove(struct platform_device *pdev)
e8f0c23a2415fa Pavel Pisa 2022-03-22 89 {
e8f0c23a2415fa Pavel Pisa 2022-03-22 90 struct net_device *ndev = platform_get_drvdata(pdev);
e8f0c23a2415fa Pavel Pisa 2022-03-22 @91 struct ctucan_priv *priv = netdev_priv(ndev);
e8f0c23a2415fa Pavel Pisa 2022-03-22 92
e8f0c23a2415fa Pavel Pisa 2022-03-22 93 netdev_dbg(ndev, "ctucan_remove");
e8f0c23a2415fa Pavel Pisa 2022-03-22 94
e8f0c23a2415fa Pavel Pisa 2022-03-22 95 unregister_candev(ndev);
e8f0c23a2415fa Pavel Pisa 2022-03-22 96 pm_runtime_disable(&pdev->dev);
e8f0c23a2415fa Pavel Pisa 2022-03-22 97 free_candev(ndev);
e8f0c23a2415fa Pavel Pisa 2022-03-22 98 }
e8f0c23a2415fa Pavel Pisa 2022-03-22 99
diff --git a/drivers/net/can/ctucanfd/ctucanfd_platform.c b/drivers/net/can/ctucanfd/ctucanfd_platform.c index 55bb10b157b4..8fe224b8dac0 100644 --- a/drivers/net/can/ctucanfd/ctucanfd_platform.c +++ b/drivers/net/can/ctucanfd/ctucanfd_platform.c @@ -84,7 +84,6 @@ static int ctucan_platform_probe(struct platform_device *pdev) * @pdev: Handle to the platform device structure * * This function frees all the resources allocated to the device. - * Return: 0 always */ static void ctucan_platform_remove(struct platform_device *pdev) { @@ -95,7 +94,6 @@ static void ctucan_platform_remove(struct platform_device *pdev) unregister_candev(ndev); pm_runtime_disable(&pdev->dev); - netif_napi_del(&priv->napi); free_candev(ndev); }