From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C630670 for ; Mon, 9 Aug 2021 09:07:33 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id n12so10344648wrr.2 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=BTZwM4ntLgBxc8+FYE38NTizHUi5fk37CcvZKcBH1NTkWKkKEWepmMpoXpuajVM0Qz NHKld5LoarZ5Ij5GM/ddCoefM1hc5UaGo0VbJB2S17wF8a21QfWSj8DJRabRzfOJ3PCl cQPAYDxcKo1OIX7KKlh1tKeLplbX44bJZuCg0rAGEuiuZHMJXVRINtXjBSxYUhIUkwjL xix72xJPzx7mRyQcFEEE2JVclj5fRwA+kqzMN5o44Pjx5Q1cbk/TfCkgnQF7Gq+gzmUe eaFoPaXBGuLcfrWgih9TnMG6dwXL/w9eoSuXr7UwW8lPbNUap5sQV4uYjCYevhGwqgIr 0Nyg== X-Gm-Message-State: AOAM530YgIA5Alk3URMECEjNCNQk2TCev4XHRDGrbO4wAyX9BLdgMEXA k7VBrleFVXXR8iUR4KznV7F0MQ== X-Google-Smtp-Source: ABdhPJyLRv8OWaU2rJjJ7UBftQqOajWt7JIwvnGbG61bADURpPUKgdSk4u6IhZ36haGe/OcsoLIAnw== 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> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6859503f7e3e6cd706bf01ef06f1cae8c0b0970b.1628449004.git.leonro@nvidia.com> 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