From patchwork Wed Sep 20 06:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13392125 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EE9E8475 for ; Wed, 20 Sep 2023 06:36:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1145C433C8; Wed, 20 Sep 2023 06:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695191762; bh=cLBLe7sysdezFUApsta72Mo5zskijgbOxtYj0dZXZec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iy9+mUIVSgJFDmbJ1UnfsEeDULR63ANI3dvfeV40G2F7JAC+NZQTOjOBkdlbffe4+ 6HcivxyGgQgmzV5k2VJjgTfK2LApZc+nOlGXxw/lO/8iGzHptsT0kplJrPOO+w9p5G /QNMlYuxJFIjaClsigIw120ZH727iV8W5u+zMekWCVZQpFZQqgpJXmbShxmSK0eHF/ PhWA7BhiGLt8SIxBfXXusQPrf9IQk2XoHIOqjwinY5sPDqI+pmImPIgKd7xI2Pq6JE 9jVxj6ITWwhXjMhoJ17GUu3eYj3UchzHcywHA6DBW1Nny7x5hhhv1Z1xlFBVdORzRn Twz/QGcEFlesQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Jiri Pirko , Shay Drory Subject: [net-next 04/15] net/mlx5: Move state lock taking into mlx5_sf_dealloc() Date: Tue, 19 Sep 2023 23:35:41 -0700 Message-ID: <20230920063552.296978-5-saeed@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920063552.296978-1-saeed@kernel.org> References: <20230920063552.296978-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Instead of taking lock and calling mlx5_sf_dealloc(), move the lock taking into mlx5_sf_dealloc(). The other caller of mlx5_sf_dealloc() does not need it now, but will need it after a follow-up patch removing the table reference counting. Signed-off-by: Jiri Pirko Reviewed-by: Shay Drory Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c index 78cdfe595a01..bed3fe8759d2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c @@ -341,6 +341,8 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink, static void mlx5_sf_dealloc(struct mlx5_sf_table *table, struct mlx5_sf *sf) { + mutex_lock(&table->sf_state_lock); + mlx5_sf_function_id_erase(table, sf); if (sf->hw_state == MLX5_VHCA_STATE_ALLOCATED) { @@ -358,6 +360,8 @@ static void mlx5_sf_dealloc(struct mlx5_sf_table *table, struct mlx5_sf *sf) mlx5_sf_hw_table_sf_deferred_free(table->dev, sf->controller, sf->id); kfree(sf); } + + mutex_unlock(&table->sf_state_lock); } int mlx5_devlink_sf_port_del(struct devlink *devlink, @@ -377,10 +381,7 @@ int mlx5_devlink_sf_port_del(struct devlink *devlink, } mlx5_eswitch_unload_sf_vport(esw, sf->hw_fn_id); - - mutex_lock(&table->sf_state_lock); mlx5_sf_dealloc(table, sf); - mutex_unlock(&table->sf_state_lock); mlx5_sf_table_put(table); return 0; }