Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2328422pxb; Sat, 25 Sep 2021 04:25:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9yvBQXWvJmAniYH3CzqsZuuUuoiKvem41NPxoicVHTUoFE+8MU6hztONEwL095qMaiUR4 X-Received: by 2002:a50:becf:: with SMTP id e15mr1552400edk.114.1632569158494; Sat, 25 Sep 2021 04:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632569158; cv=none; d=google.com; s=arc-20160816; b=VAkn9swpD+nph1eOjNzVkWKpVgYtNEeEFajiaibv+GQkDkYIrGZTSI8Rm2epGOn0kn TyZnajFZLsU+iDBeTf+VjtTFZLqGuzwOrfxIu/7sz9ehNz9YSPfHFxNO2DukMQYSbwFS aAQz6fSMkk5cKg7QKp3M/FoLJAkL3uo7BACxJua2s0j1B70Glx0/30O9SNlzVO+T9ObW 8FMGCXRrI85v3b6lfWQq9xpYTfLBYpQaHIvqmxeZdVQjIesME1NNCU2Iz7X6RvzB9Rrd pO4SxI61GQZBoanKEc8N+GRNAPKT4XR5RCCZdnbmMI497AohfGs8aRnt/Hs0/169ys92 LuYQ== 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=Xw6wDFV6z2o9Shf1V3fKBK6S8vJ74XbOMaqfrTkKBqI=; b=hHv642sY9HsCt1Z3of0WeJl55xHavvatJ4ROAVv9DvRODmHn5dU73kFkntaz33X2C1 U89tHykM48Fn7jdMoJdsw1GwgnEALp+hFXGIEc7yLMgNu6kAlLpvWinNeYvGrs8mt7p7 KpCR8BYw1vlU1FE6RNT7Ors+0v4EwIf1tZQDB67K8HrY/ZlWvDL8e+/NIv59WMdADlzd fNR40SQotufqLUu/BE4rDUrUNuBfijSNsGsQtVvw+Wjdt5A1j3TpIC5HfOJhG8Z/uTeD +WpKPah21y9NwfmgAo80y1sKGe9IrpClkVWHrnoR+V7H2UhlHterHu3FanIGPR6I0+mm ZObQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/RREPSk"; 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 bl3si2861468ejb.204.2021.09.25.04.25.34; Sat, 25 Sep 2021 04:25:58 -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="X/RREPSk"; 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 S245179AbhIYLZQ (ORCPT + 99 others); Sat, 25 Sep 2021 07:25:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:55944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244930AbhIYLZB (ORCPT ); Sat, 25 Sep 2021 07:25:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42CC86127A; Sat, 25 Sep 2021 11:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632569007; bh=1Fnka8ps90Zylh+ydNx/A5aVv/Vtl8oI7QwGTBkxA5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/RREPSk0+dMrPt2ZhjQQE6yWhqRdBVusehpcFG2nS6PEjbiY1fkQqX5oNJSMq6l5 yjJHliByFUAzg3jr1HOGac7gBEFipVghPyyQg9UeqRZ6xTZNalYQP1kQwNu/Z9fJku wz+Kh+NytJ1mpAo0fdujHFCyIeaORwISRAF3E4zwXEYSLUBkgFAZB3Pnibo5cQe+u+ IgLybrtUtt3EoigRgqXbOnGBmFH/Y9BTAnrnZ08U/ssToKdsANp9vwBxfjjrLs0KTm cYvnLTAcsp65QzrliUDhNGLpg4GHwdwUF941D188Ic+EeR3yVitlX/9vcpDTRug49/ KqJEz5/5w/lAQ== 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 07/21] octeontx2: Move devlink registration to be last devlink command Date: Sat, 25 Sep 2021 14:22:47 +0300 Message-Id: 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. This change allows us to delete call to devlink_params_publish() and impossible check during unregister flow. Signed-off-by: Leon Romanovsky --- .../ethernet/marvell/octeontx2/af/rvu_devlink.c | 10 ++-------- .../ethernet/marvell/octeontx2/nic/otx2_devlink.c | 15 +++------------ 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c index de9562acd04b..70bacd38a6d9 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c @@ -1510,7 +1510,6 @@ int rvu_register_dl(struct rvu *rvu) return -ENOMEM; } - devlink_register(dl); rvu_dl = devlink_priv(dl); rvu_dl->dl = dl; rvu_dl->rvu = rvu; @@ -1531,13 +1530,11 @@ int rvu_register_dl(struct rvu *rvu) goto err_dl_health; } - devlink_params_publish(dl); - + devlink_register(dl); return 0; err_dl_health: rvu_health_reporters_destroy(rvu); - devlink_unregister(dl); devlink_free(dl); return err; } @@ -1547,12 +1544,9 @@ void rvu_unregister_dl(struct rvu *rvu) struct rvu_devlink *rvu_dl = rvu->rvu_dl; struct devlink *dl = rvu_dl->dl; - if (!dl) - return; - + devlink_unregister(dl); devlink_params_unregister(dl, rvu_af_dl_params, ARRAY_SIZE(rvu_af_dl_params)); rvu_health_reporters_destroy(rvu); - devlink_unregister(dl); devlink_free(dl); } diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c index 3de18f9433ae..777a27047c8e 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c @@ -108,7 +108,6 @@ int otx2_register_dl(struct otx2_nic *pfvf) return -ENOMEM; } - devlink_register(dl); otx2_dl = devlink_priv(dl); otx2_dl->dl = dl; otx2_dl->pfvf = pfvf; @@ -122,12 +121,10 @@ int otx2_register_dl(struct otx2_nic *pfvf) goto err_dl; } - devlink_params_publish(dl); - + devlink_register(dl); return 0; err_dl: - devlink_unregister(dl); devlink_free(dl); return err; } @@ -135,16 +132,10 @@ int otx2_register_dl(struct otx2_nic *pfvf) void otx2_unregister_dl(struct otx2_nic *pfvf) { struct otx2_devlink *otx2_dl = pfvf->dl; - struct devlink *dl; - - if (!otx2_dl || !otx2_dl->dl) - return; - - dl = otx2_dl->dl; + struct devlink *dl = otx2_dl->dl; + devlink_unregister(dl); devlink_params_unregister(dl, otx2_dl_params, ARRAY_SIZE(otx2_dl_params)); - - devlink_unregister(dl); devlink_free(dl); } -- 2.31.1