All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] devlink: Remove duplicated registration check
@ 2021-07-25 12:24 Leon Romanovsky
  2021-07-25 15:58 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-07-25 12:24 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Jiri Pirko
  Cc: Leon Romanovsky, linux-kernel, netdev

From: Leon Romanovsky <leonro@nvidia.com>

Both registered flag and devlink pointer are set at the same time
and indicate the same thing - devlink/devlink_port are ready. Instead
of checking ->registered use devlink pointer as an indication.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 include/net/devlink.h |  4 +---
 net/core/devlink.c    | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 57b738b78073..e48a62320407 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -55,8 +55,7 @@ struct devlink {
 			    * port, sb, dpipe, resource, params, region, traps and more.
 			    */
 	u8 reload_failed:1,
-	   reload_enabled:1,
-	   registered:1;
+	   reload_enabled:1;
 	char priv[0] __aligned(NETDEV_ALIGN);
 };
 
@@ -158,7 +157,6 @@ struct devlink_port {
 	struct list_head region_list;
 	struct devlink *devlink;
 	unsigned int index;
-	bool registered;
 	spinlock_t type_lock; /* Protects type and type_dev
 			       * pointer consistency.
 			       */
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 8fdd04f00fd7..b596a971b473 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -115,7 +115,7 @@ static void __devlink_net_set(struct devlink *devlink, struct net *net)
 
 void devlink_net_set(struct devlink *devlink, struct net *net)
 {
-	if (WARN_ON(devlink->registered))
+	if (WARN_ON(devlink->dev))
 		return;
 	__devlink_net_set(devlink, net);
 }
@@ -1043,7 +1043,7 @@ static void devlink_port_notify(struct devlink_port *devlink_port,
 	struct sk_buff *msg;
 	int err;
 
-	if (!devlink_port->registered)
+	if (!devlink_port->devlink)
 		return;
 
 	WARN_ON(cmd != DEVLINK_CMD_PORT_NEW && cmd != DEVLINK_CMD_PORT_DEL);
@@ -8817,8 +8817,8 @@ EXPORT_SYMBOL_GPL(devlink_alloc);
  */
 int devlink_register(struct devlink *devlink, struct device *dev)
 {
+	WARN_ON(devlink->dev);
 	devlink->dev = dev;
-	devlink->registered = true;
 	mutex_lock(&devlink_mutex);
 	list_add_tail(&devlink->list, &devlink_list);
 	devlink_notify(devlink, DEVLINK_CMD_NEW);
@@ -8960,9 +8960,10 @@ int devlink_port_register(struct devlink *devlink,
 		mutex_unlock(&devlink->lock);
 		return -EEXIST;
 	}
+
+	WARN_ON(devlink_port->devlink);
 	devlink_port->devlink = devlink;
 	devlink_port->index = port_index;
-	devlink_port->registered = true;
 	spin_lock_init(&devlink_port->type_lock);
 	INIT_LIST_HEAD(&devlink_port->reporter_list);
 	mutex_init(&devlink_port->reporters_lock);
@@ -9001,7 +9002,7 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
 				    enum devlink_port_type type,
 				    void *type_dev)
 {
-	if (WARN_ON(!devlink_port->registered))
+	if (WARN_ON(!devlink_port->devlink))
 		return;
 	devlink_port_type_warn_cancel(devlink_port);
 	spin_lock_bh(&devlink_port->type_lock);
@@ -9121,7 +9122,7 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
 {
 	int ret;
 
-	if (WARN_ON(devlink_port->registered))
+	if (WARN_ON(devlink_port->devlink))
 		return;
 	devlink_port->attrs = *attrs;
 	ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);
@@ -9145,7 +9146,7 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
 	int ret;
 
-	if (WARN_ON(devlink_port->registered))
+	if (WARN_ON(devlink_port->devlink))
 		return;
 	ret = __devlink_port_attrs_set(devlink_port,
 				       DEVLINK_PORT_FLAVOUR_PCI_PF);
@@ -9172,7 +9173,7 @@ void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
 	int ret;
 
-	if (WARN_ON(devlink_port->registered))
+	if (WARN_ON(devlink_port->devlink))
 		return;
 	ret = __devlink_port_attrs_set(devlink_port,
 				       DEVLINK_PORT_FLAVOUR_PCI_VF);
@@ -9200,7 +9201,7 @@ void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port, u32 contro
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
 	int ret;
 
-	if (WARN_ON(devlink_port->registered))
+	if (WARN_ON(devlink_port->devlink))
 		return;
 	ret = __devlink_port_attrs_set(devlink_port,
 				       DEVLINK_PORT_FLAVOUR_PCI_SF);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] devlink: Remove duplicated registration check
  2021-07-25 12:24 [PATCH net-next] devlink: Remove duplicated registration check Leon Romanovsky
@ 2021-07-25 15:58 ` kernel test robot
  2021-07-25 18:37 ` Leon Romanovsky
  2021-07-25 19:23 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-07-25 15:58 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3283 bytes --]

Hi Leon,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Leon-Romanovsky/devlink-Remove-duplicated-registration-check/20210725-202618
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cc19862ffe454a5b632ca202e5a51bfec9f89fd2
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/2e93956fb49369674f9230f43f27c140fe4d277a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Leon-Romanovsky/devlink-Remove-duplicated-registration-check/20210725-202618
        git checkout 2e93956fb49369674f9230f43f27c140fe4d277a
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c: In function 'mlx5e_devlink_port_unregister':
>> drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c:58:13: error: 'struct devlink_port' has no member named 'registered'
      58 |  if (dl_port->registered)
         |             ^~
   drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c: In function 'mlx5e_get_devlink_port':
   drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c:70:10: error: 'struct devlink_port' has no member named 'registered'
      70 |  if (port->registered)
         |          ^~
--
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_nic_init':
>> drivers/net/ethernet/mellanox/mlx5/core/en_main.c:4954:13: error: 'struct devlink_port' has no member named 'registered'
    4954 |  if (dl_port->registered)
         |             ^~
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_nic_cleanup':
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c:4964:13: error: 'struct devlink_port' has no member named 'registered'
    4964 |  if (dl_port->registered)
         |             ^~


vim +58 drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c

c6acd629eec754 Vladyslav Tarasiuk 2019-11-13  53  
162add8cbae463 Parav Pandit       2020-03-03  54  void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv)
c6acd629eec754 Vladyslav Tarasiuk 2019-11-13  55  {
c27971d08abecc Roi Dayan          2020-10-28  56  	struct devlink_port *dl_port = mlx5e_devlink_get_dl_port(priv);
c27971d08abecc Roi Dayan          2020-10-28  57  
6a5689ba0259ac Vladyslav Tarasiuk 2021-04-13 @58  	if (dl_port->registered)
c27971d08abecc Roi Dayan          2020-10-28  59  		devlink_port_unregister(dl_port);
c6acd629eec754 Vladyslav Tarasiuk 2019-11-13  60  }
c6acd629eec754 Vladyslav Tarasiuk 2019-11-13  61  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 68211 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] devlink: Remove duplicated registration check
  2021-07-25 12:24 [PATCH net-next] devlink: Remove duplicated registration check Leon Romanovsky
  2021-07-25 15:58 ` kernel test robot
@ 2021-07-25 18:37 ` Leon Romanovsky
  2021-07-25 19:23 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-07-25 18:37 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Jiri Pirko; +Cc: linux-kernel, netdev

On Sun, Jul 25, 2021 at 03:24:41PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Both registered flag and devlink pointer are set at the same time
> and indicate the same thing - devlink/devlink_port are ready. Instead
> of checking ->registered use devlink pointer as an indication.
> 
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  include/net/devlink.h |  4 +---
>  net/core/devlink.c    | 19 ++++++++++---------
>  2 files changed, 11 insertions(+), 12 deletions(-)

Sorry, please drop this patch for now, I'll need to resubmit it after will
fix completely bogus 6a5689ba0259 ("net/mlx5e: Fix possible non-initialized struct usage").

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] devlink: Remove duplicated registration check
  2021-07-25 12:24 [PATCH net-next] devlink: Remove duplicated registration check Leon Romanovsky
  2021-07-25 15:58 ` kernel test robot
  2021-07-25 18:37 ` Leon Romanovsky
@ 2021-07-25 19:23 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-07-25 19:23 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2975 bytes --]

Hi Leon,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Leon-Romanovsky/devlink-Remove-duplicated-registration-check/20210725-202618
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cc19862ffe454a5b632ca202e5a51bfec9f89fd2
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/2e93956fb49369674f9230f43f27c140fe4d277a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Leon-Romanovsky/devlink-Remove-duplicated-registration-check/20210725-202618
        git checkout 2e93956fb49369674f9230f43f27c140fe4d277a
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/ti/am65-cpsw-nuss.c: In function 'am65_cpsw_unregister_devlink_ports':
>> drivers/net/ethernet/ti/am65-cpsw-nuss.c:2411:14: error: 'struct devlink_port' has no member named 'registered'
    2411 |   if (dl_port->registered)
         |              ^~


vim +2411 drivers/net/ethernet/ti/am65-cpsw-nuss.c

58356eb31d60dd Vignesh Raghavendra 2021-02-11  2400  
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2401  static void am65_cpsw_unregister_devlink_ports(struct am65_cpsw_common *common)
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2402  {
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2403  	struct devlink_port *dl_port;
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2404  	struct am65_cpsw_port *port;
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2405  	int i;
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2406  
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2407  	for (i = 1; i <= common->port_num; i++) {
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2408  		port = am65_common_get_port(common, i);
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2409  		dl_port = &port->devlink_port;
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2410  
58356eb31d60dd Vignesh Raghavendra 2021-02-11 @2411  		if (dl_port->registered)
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2412  			devlink_port_unregister(dl_port);
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2413  	}
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2414  }
58356eb31d60dd Vignesh Raghavendra 2021-02-11  2415  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 77926 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-25 19:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-25 12:24 [PATCH net-next] devlink: Remove duplicated registration check Leon Romanovsky
2021-07-25 15:58 ` kernel test robot
2021-07-25 18:37 ` Leon Romanovsky
2021-07-25 19:23 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.