Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2329438pxb; Sat, 25 Sep 2021 04:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDhQLlqZJxZ0TJ/m1CnHA5nAc+WsViyj6ZA1RBLS+ladlXLifaShKgrAs4IqngDN8sZgu8 X-Received: by 2002:a17:907:10c8:: with SMTP id rv8mr16366324ejb.280.1632569249453; Sat, 25 Sep 2021 04:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632569249; cv=none; d=google.com; s=arc-20160816; b=qcWAerqjr7Pb6HgdXC5YJCUoLbjVz2DirnV2bNry87kBAZuhxe2O+Ns6m16vKS/A5c gyXGE/Q9W2ijA1BMx9JItlBdt8yaryz7iwbiItLcY3uTD8EFPPnpLSm1sAcJ9RZVDWKp D9TqyH412fxeFcBEr+pZM32GU3kP4aoJrlZmUnCq0vkFVVVjLc93hQ5FE4HU1NJF8v1o x71Fv12V8yvWbTUblqtHOVUd3f19fj2mb95DmyHgEv3sxK+OdWF7CCBA9Ju+gylMCDQb BGOS/yHtv26oh9gTJj5mxDQV0eHcNwyZkm1TK7dMQne4McZdmnioSMQhV4ABEfBJVyip DcWg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RcisZbI+ARcJk53aVpyyiKE0QJbQu9B//Bimokg0VNU=; b=o6Sf999Ay0zPgdZM427bzf/Y2VbXpqN9PIggSNIE+kBiO3msHS2Ny5mZox0QiageDy cBAoK20jKT1RUz/2rsq6MaGosPUFJpQDpPzhlRrBuAoUwOGttVdwLosQqlGAHekH5kL6 HGFzab+qOoo+lzhWzq36hVJCDIRUSeRBmWhOWC/Jl9Dv+JgPvD+MK2XFJI1cDZb9V137 kPKnAavhg9OBIYJwis65OC48LhaB+L0ewk5jrI1VuZe8ulTKGza5NzA6iOoajreDdDS/ iPhVqM0lx+dkAvayoUfzW3LgwIcLkY5/6+YMiJFgyagSdUsuBZdM7Rw/uTPC8ol3x8uN 5X8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BFN1GH5Y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si13310373edj.121.2021.09.25.04.27.06; Sat, 25 Sep 2021 04:27:29 -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=@kernel.org header.s=k20201202 header.b=BFN1GH5Y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244626AbhIYL0M (ORCPT + 99 others); Sat, 25 Sep 2021 07:26:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245428AbhIYLZg (ORCPT ); Sat, 25 Sep 2021 07:25:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 002256128A; Sat, 25 Sep 2021 11:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632569041; bh=Cl3NV1NYQWAcpVSM6GygwU59q/PE56ay+2A5k8m+/J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFN1GH5Yf1Hsh8UTT6arSQ8EKwmk0uMdcSCGgM/dgkyj3ocPsN9Vib6wa5dZd1Vwz u8rLDRoYW6di1kveNeOMohk6xPKcEvcce/XHpWBXbVjOIlFhpzFhJHHK+3QOzz2Zr9 UPBq95GV2ADYPAzc6L51cg9xLwD9Le8xe4Vc4UqonE/62LqGC9UUMf9agd++VJIEnk 1BjNKGV/rp1lfPh2q4rxGAM52rDVmF/gwCAivI1rzyB7FhJa0oKEDBVXsd+6pTJ0ZD KPsnfCNXWwdH+x7un/bTHw9zKjbfqAmmcjpTdlnAKXgf/Elqbq1UnyzIKCBdF0jyOH RvSInpbsT4LUg== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: 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 Corporation , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Jonathan Lemon , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-rdma@vger.kernel.org, linux-staging@lists.linux.dev, Loic Poulain , Manish Chopra , M Chetan Kumar , Michael Chan , Michael Guralnik , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Satanand Burla , Sergey Ryazanov , Shannon Nelson , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next v1 17/21] netdevsim: Move devlink registration to be last devlink command Date: Sat, 25 Sep 2021 14:22:57 +0300 Message-Id: <87822c7b4f20182c37758a2c0b9bb84a0a3edaf8.1632565508.git.leonro@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky This change prevents from users to access device before devlink is fully configured. Signed-off-by: Leon Romanovsky --- drivers/net/netdevsim/dev.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index b2214bc9efe2..cb6645012a30 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -1470,7 +1470,6 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) if (err) goto err_devlink_free; - devlink_register(devlink); err = devlink_params_register(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); if (err) @@ -1511,9 +1510,9 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) if (err) goto err_psample_exit; - devlink_params_publish(devlink); - devlink_reload_enable(devlink); nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY; + devlink_register(devlink); + devlink_reload_enable(devlink); return 0; err_psample_exit: @@ -1534,7 +1533,6 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) devlink_params_unregister(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); err_dl_unregister: - devlink_unregister(devlink); devlink_resources_unregister(devlink, NULL); err_devlink_free: devlink_free(devlink); @@ -1569,6 +1567,7 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev) struct devlink *devlink = priv_to_devlink(nsim_dev); devlink_reload_disable(devlink); + devlink_unregister(devlink); nsim_dev_reload_destroy(nsim_dev); @@ -1576,7 +1575,6 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev) nsim_dev_debugfs_exit(nsim_dev); devlink_params_unregister(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); - devlink_unregister(devlink); devlink_resources_unregister(devlink, NULL); devlink_free(devlink); } -- 2.31.1