From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next 09/11] devlink: convert occ_get op to separate registration Date: Tue, 3 Apr 2018 08:33:11 -0600 Message-ID: References: <20180329203334.25575-1-idosch@mellanox.com> <20180329203334.25575-10-idosch@mellanox.com> <5f2dc834-0d8a-77ef-3d33-2228e7bd530c@gmail.com> <20180403073212.GI3313@nanopsycho> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Ido Schimmel , netdev@vger.kernel.org, davem@davemloft.net, jiri@mellanox.com, petrm@mellanox.com, mlxsw@mellanox.com To: Jiri Pirko Return-path: Received: from mail-pl0-f49.google.com ([209.85.160.49]:33662 "EHLO mail-pl0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178AbeDCOdS (ORCPT ); Tue, 3 Apr 2018 10:33:18 -0400 Received: by mail-pl0-f49.google.com with SMTP id s10-v6so7069292plp.0 for ; Tue, 03 Apr 2018 07:33:18 -0700 (PDT) In-Reply-To: <20180403073212.GI3313@nanopsycho> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 4/3/18 1:32 AM, Jiri Pirko wrote: > Fri, Mar 30, 2018 at 04:45:50PM CEST, dsahern@gmail.com wrote: >> On 3/29/18 2:33 PM, Ido Schimmel wrote: >>> From: Jiri Pirko >>> >>> This resolves race during initialization where the resources with >>> ops are registered before driver and the structures used by occ_get >>> op is initialized. So keep occ_get callbacks registered only when >>> all structs are initialized. >> >> Why can't the occ_get handler look at some flag in an mlxsw struct to >> know if the system has initialized? >> >> Separate registration here is awkward. You register a resource and then >> register its op later. > > The separation is exactly why this patch is made. Note that devlink > resouce is registered by core way before the initialization is done and > the driver is actually able to perform the op. Also consider "reload" That's how you have chose to code it. I hit this problem adding devlink to netdevsim; the solution was to fix the init order. > case, when the resource is still registered and the driver unloads and > loads again. For that makes perfect sense to have that separated. > Flag would just make things odd. Also, the priv could not be used in > that case. > I am not aware of any other API where you invoked the register function at point A and then later add the operations at point B. In every API that comes to mind the ops are part of the register. I am sure there are options for you to fix the init order of mlxsw without making the devlink API awkward.