Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp706562rdh; Tue, 22 Aug 2023 08:24:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFipZD3nil7o8cSgFZyCaT0UsPM4DmwgV8x2sjUkpFHaXM+Nn8zR3Qh7HxEHAY3x9YRxyCT X-Received: by 2002:a05:6a00:4a0d:b0:68a:6cbe:35b8 with SMTP id do13-20020a056a004a0d00b0068a6cbe35b8mr2733953pfb.6.1692717885229; Tue, 22 Aug 2023 08:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692717885; cv=none; d=google.com; s=arc-20160816; b=RV9+Q6ayK7+0tMHFEh1C1U8qH7/FvhhdUL2mDCGRVMKxn5YLhnPb+PTBBTUtnN8miz r6sQxHw/iU+DO98lvocPeIZpx8LxOAjUVWOmsAIMd2Kym4p7KtiCiVdIqL7ngi2DsVg5 40TIJXEyff6Y4LxYCzENeLPA9hu65eEnvvb+WWWetSW2ENOvuohP2l8ubnshPdN18vvp pAwKNTSM70kjtPV5snBxJjBTZ/cGC6hCwODrUf/zQn7lK1oqh2vvbrsdZFcEo+IYMH5t td2nCuEOn3tOubWVhFbb4hXkzjtUt/PfTG1oXyF1791YFMm54bcm/yJxQu84mri0svTF wy1g== 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=O7hLxMKGVWFCXb40hUpqgpoFX3Dnim9M1lx4b9UT3kw=; fh=kDjNYbNqpTt++NYpKxrianM7w81rO4mq5+oH1ITmLwE=; b=fpXtV7mrXquoJeDyYmka9r+Gxs3zqI4fJlGrUJ3kXaZB9aP+09AW7tRNEJwRSNABGE D/RLcRYmKh6+yhHMYimEHzlYfWIyFcrS/vpTJa4KfsEU92gpx/UnA3q91J0Pye2e4H3M iaQLWJMqfItuQMIeFK2AkeSHD9Wzf4EvXBg5GcimG2rMZS5t2oSgi2B21UNm/Ny2m+MV 9I78CVyTPmEFKcEqKb2XBdSFLQ7hAugNtCMHi9RNvcoWE7TNZ94y7JyCqtaH59k9KPsI L+qzLV0ajQHB14XEZ8Avg4PcVod+z6oTcpw/tqFu3YlXndsLmDeEFEt6GVzNL31qGedy sJ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mAbSmcSA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb28-20020a056a004c9c00b0068a3cb58334si5745749pfb.320.2023.08.22.08.24.32; Tue, 22 Aug 2023 08:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mAbSmcSA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S236347AbjHVOEo (ORCPT + 99 others); Tue, 22 Aug 2023 10:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236362AbjHVOEm (ORCPT ); Tue, 22 Aug 2023 10:04:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EFC10C6; Tue, 22 Aug 2023 07:04:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 95A8E6572D; Tue, 22 Aug 2023 14:04:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5863CC433CB; Tue, 22 Aug 2023 14:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692713046; bh=ZIT11GIJSJZYc0Nk4zmM2lN1LnR6J6up+poTrlxkwEE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mAbSmcSAtB0IL2oIl2XBLF8PyEKDDiTf0zaaA6Ga32HyeZ0w4yhSkB0CYf5znMN0I Xaja+9MY/z0jGyoJhVUgvmiNk59A4rq4qMPSSm0aAePihuhTprydi//vQvy1/NMZF3 KJwmVHXpsNik1D3NHQ0ua5wFNY0LcSyDzW0nOkRtPEVzvIT6aXqAh/FxU1NHnyYUlI F1HLLTIXoBfJo3wUGCqTgjWhevl4sjq1kcu+N6NH4zVFlSP4dfhq1AXLjsN/EFxtEn vOCK21l9S20rph4xnbd2tXoJOOcOCDfjtR230CZ63Sd67lApLo7DW+Mp+j+rmdQw8+ pb4cMcAsNYj6g== Date: Tue, 22 Aug 2023 17:04:03 +0300 From: Leon Romanovsky To: Petr Pavlu Cc: tariqt@nvidia.com, yishaih@nvidia.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jgg@ziepe.ca, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v3 04/11] mlx4: Replace the mlx4_interface.event callback with a notifier Message-ID: <20230822140403.GF6029@unreal> References: <20230821131225.11290-1-petr.pavlu@suse.com> <20230821131225.11290-5-petr.pavlu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230821131225.11290-5-petr.pavlu@suse.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 21, 2023 at 03:12:18PM +0200, Petr Pavlu wrote: > Use a notifier to implement mlx4_dispatch_event() in preparation to > switch mlx4_en and mlx4_ib to be an auxiliary device. > > A problem is that if the mlx4_interface.event callback was replaced with > something as mlx4_adrv.event then the implementation of > mlx4_dispatch_event() would need to acquire a lock on a given device > before executing this callback. That is necessary because otherwise > there is no guarantee that the associated driver cannot get unbound when > the callback is running. However, taking this lock is not possible > because mlx4_dispatch_event() can be invoked from the hardirq context. > Using an atomic notifier allows the driver to accurately record when it > wants to receive these events and solves this problem. > > A handler registration is done by both mlx4_en and mlx4_ib at the end of > their mlx4_interface.add callback. This matches the current situation > when mlx4_add_device() would enable events for a given device > immediately after this callback, by adding the device on the > mlx4_priv.list. > > Signed-off-by: Petr Pavlu > Tested-by: Leon Romanovsky > Acked-by: Tariq Toukan > --- > drivers/infiniband/hw/mlx4/main.c | 40 +++++++++++++------- > drivers/infiniband/hw/mlx4/mlx4_ib.h | 2 + > drivers/net/ethernet/mellanox/mlx4/en_main.c | 26 +++++++++---- > drivers/net/ethernet/mellanox/mlx4/intf.c | 24 ++++++++---- > drivers/net/ethernet/mellanox/mlx4/main.c | 2 + > drivers/net/ethernet/mellanox/mlx4/mlx4.h | 2 + > drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 2 + > include/linux/mlx4/driver.h | 8 +++- > 8 files changed, 75 insertions(+), 31 deletions(-) > Thanks, Reviewed-by: Leon Romanovsky