Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2511274pxt; Mon, 9 Aug 2021 02:09:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Wkw0IZ4Z3QGWgN5LkB8NO2GyrKEs8OflZnLzVILaYXkTIAKIXsmqqVViB3Y7F95SfoSb X-Received: by 2002:a02:c841:: with SMTP id r1mr21780500jao.2.1628500168772; Mon, 09 Aug 2021 02:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628500168; cv=none; d=google.com; s=arc-20160816; b=N5IKWVb6caVafo14puX/xnszY8pATNWrxGllGFon7HbiQG3DRmsbuVtIZgkBBv70/I 58NOB3bp5qOiV6RYlU+eiKwkBfNGwX8FskRGjo0iAh+yLQcHmovyeMPQK4M+zC+NvIlw f8zHEbuT+KedX0fa0mkNMtVK8K0dcCZ/cGJ43dIYGbjTpx6sqJ1y5W+3pLftwPIaFHAf NrWPfostS3on6GzUMdyjbCAEwWwFqgnIUose1Q4Bxx4ETT8GK6NOoMo0kQ/PE4yosxVN b28JCHGkQ2MPhkxRY/vI2LH5MeKPx6RFGfwv2dcGRwdH+cGPF+9lS+hsngEF+Gbm+A1m +6Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/ZPOlrNFMpNUTPbgUazrf5s5awBfvFWEx4XOmYGlmFM=; b=hgsSeYaGhx5wARizhpgEjSCMsdJqQ6FcVrWhwQfRFARuYLzsa77wVIaro29uX97h1J iOdkIAEgOwYfvtvqBT18EfDyrezdDqx12LErgI1NhYtkLvPAv3+C67MGEnmx06SwKPLo 5IPE+QWuzChxV0Avsd0BuHUhxOXwcca/25L+FLO3Zw5llNfHfWX2Q6rKewimQyyL3frh S94YLJmiUws8i2cmr7elWboxUBn2GVr9WAoAdsC4xr3wpdTlZufR6b2eWB7GRy6lcDSM I79ke9gdbdN+GrdessHV47wAzGgSluCqUtkjcyeEAl1kQTnBw+irKccQTLBJPNLBvf9p HsiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=xuTbN9NL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si6528480jal.110.2021.08.09.02.09.16; Mon, 09 Aug 2021 02:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=xuTbN9NL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234062AbhHIJH5 (ORCPT + 99 others); Mon, 9 Aug 2021 05:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234172AbhHIJH4 (ORCPT ); Mon, 9 Aug 2021 05:07:56 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F3C7C061796 for ; Mon, 9 Aug 2021 02:07:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b13so20423382wrs.3 for ; Mon, 09 Aug 2021 02:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/ZPOlrNFMpNUTPbgUazrf5s5awBfvFWEx4XOmYGlmFM=; b=xuTbN9NL08Xcyq4YkCIGhzlEKVrVctUgSIIhVBnkaX8eBSEHaFOlZ6xhpHC8lMNFIe dwmLzw6HSzfSkmDyldkyO4cF/B4FSaQ+R0e3imf9Uqwu/s1kxF6cO7lgFBnp2CQiHQZb ptygmaW+KOYy2Vg86ysWX42PDO7BrZXZJ2slJRdSO2oCp1BIbrBre/fMom8tMKlqVz0H YgsuS74yevpikRF9h2yy5vlV8pLKC5hbNzRmJXeGnXWlCyldErZ0DwkZjzAc6HNz0Ks0 do7m4j3JuvYi7N6B2LzEz8XuzVlzUZp+/3EnES80Duj6XTL4TcUfvLUOpI6PI0+bVEHc haRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/ZPOlrNFMpNUTPbgUazrf5s5awBfvFWEx4XOmYGlmFM=; b=k8BHLOL9Sxk5tBnVGX7NzOXo5AcGD0YVcjPrTVxkK05qt2qTTYShxJhSia0zwI/o5n vaQ9+a0qNvnDijZLyoWxt3xRrIx9UgFuoHK3Bfj7NXW/AZ/FgMwPhC9L4GFGLvG8EpBy 9k9TzxgiG4ikiXRyJHqn/CH+0HhQ4HGvrS5JLUxDxair4NaKMzRszEbdiAJBJ8PiIfR6 pbK44t5rQlaobvEOthm40zXo6xx7TH/91jhAKX3Vy1jRPJtwhQtvsPmdn8q+IWHLPvp/ 1zaujGRtlJ+iDDxG5zshJxuJJ+d0PXbbQgnaYkSOSK3eIfmyYkfY3hp4SBKkqYwR+f76 UGGA== X-Gm-Message-State: AOAM532TJHvucKkPTu+BmFbIHJJ3K4zHFhf2rT2AzT22yfbZybpolSWJ 9OPKjL2MptgFKpxKR0s/g8pM8w== X-Received: by 2002:a05:6000:1106:: with SMTP id z6mr24270092wrw.296.1628500051979; Mon, 09 Aug 2021 02:07:31 -0700 (PDT) Received: from localhost ([86.61.181.4]) by smtp.gmail.com with ESMTPSA id v17sm18937438wrt.87.2021.08.09.02.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:07:31 -0700 (PDT) Date: Mon, 9 Aug 2021 11:07:30 +0200 From: Jiri Pirko To: Leon Romanovsky Cc: "David S . Miller" , Jakub Kicinski , Leon Romanovsky , Alexandre Belloni , Andrew Lunn , Ariel Elior , Bin Luo , Claudiu Manoil , Coiby Xu , Derek Chickles , drivers@pensando.io, Felix Manlunas , Florian Fainelli , Geetha sowjanya , Greg Kroah-Hartman , GR-everest-linux-l2@marvell.com, GR-Linux-NIC-Dev@marvell.com, hariprasad , Ido Schimmel , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-staging@lists.linux.dev, Manish Chopra , Michael Chan , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Salil Mehta , Satanand Burla , Shannon Nelson , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean , Yisen Zhuang Subject: Re: [PATCH net-next] devlink: Set device as early as possible Message-ID: References: <6859503f7e3e6cd706bf01ef06f1cae8c0b0970b.1628449004.git.leonro@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6859503f7e3e6cd706bf01ef06f1cae8c0b0970b.1628449004.git.leonro@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sun, Aug 08, 2021 at 08:57:43PM CEST, leon@kernel.org wrote: >From: Leon Romanovsky > >All kernel devlink implementations call to devlink_alloc() during >initialization routine for specific device which is used later as >a parent device for devlink_register(). > >Such late device assignment causes to the situation which requires us to >call to device_register() before setting other parameters, but that call >opens devlink to the world and makes accessible for the netlink users. > >Any attempt to move devlink_register() to be the last call generates the >following error due to access to the devlink->dev pointer. > >[ 8.758862] devlink_nl_param_fill+0x2e8/0xe50 >[ 8.760305] devlink_param_notify+0x6d/0x180 >[ 8.760435] __devlink_params_register+0x2f1/0x670 >[ 8.760558] devlink_params_register+0x1e/0x20 > >The simple change of API to set devlink device in the devlink_alloc() >instead of devlink_register() fixes all this above and ensures that >prior to call to devlink_register() everything already set. > >Signed-off-by: Leon Romanovsky Reviewed-by: Jiri Pirko