From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 934A7C56202 for ; Tue, 27 Oct 2020 16:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D678208B8 for ; Tue, 27 Oct 2020 16:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603814797; bh=yXqeFP9waseVng23oKDHhwTymLtY0AP+P7lpYFpfHfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pzF0Mq6bUVik99yWx96tWthP3KCWe1A8mWhTFr7lSF2N56yT1TN8297YsJ+qtkzLK j0sSno+drjLw0PxKAeG6a8LuupjiUcRKpcazk6Qte84cNszQ5ckg08A3y2v5tVZgfl 5+crJJMDAUeSO2AXd3CqR+2v7liLH1Z8kxX+oNiw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1806088AbgJ0QFn (ORCPT ); Tue, 27 Oct 2020 12:05:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:44108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1802366AbgJ0Pqx (ORCPT ); Tue, 27 Oct 2020 11:46:53 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D12F22202; Tue, 27 Oct 2020 15:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813611; bh=yXqeFP9waseVng23oKDHhwTymLtY0AP+P7lpYFpfHfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SLOhYJDUafF6AC8Fu72DtxwsX1D5p8AdRRD6SKkZ7NUoaiZOVFyG+zeD+6uw9FXSO OEh2D8MoVE6nHpFljWFbX2VIPDKGDepTI9GwjUscdyCHlo3HCyDB5LxQkfuDWhOZh8 vvNj44EgpPBNzdBiGT2mm2wMjNSUpSC/O32YkgS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Cohen , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 5.9 579/757] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK Date: Tue, 27 Oct 2020 14:53:49 +0100 Message-Id: <20201027135517.678689514@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eli Cohen [ Upstream commit 1897f0b618b0af0eb9dca709ab6bdf9ef1969ef7 ] set_map() is used by mlx5 vdpa to create a memory region based on the address map passed by the iotlb argument. If we get successive calls, we will destroy the current memory region and build another one based on the new address mapping. We also need to setup the hardware resources since they depend on the memory region. If these calls happen before DRIVER_OK, It means that driver VQs may also not been setup and we may not create them yet. In this case we want to avoid setting up the other resources and defer this till we get DRIVER OK. Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") Signed-off-by: Eli Cohen Link: https://lore.kernel.org/r/20200908123346.GA169007@mtl-vdi-166.wap.labs.mlnx Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 5ca309473c03d..1fa6fcac82992 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1658,6 +1658,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net *ndev, struct vhost_iotlb * if (err) goto err_mr; + if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) + return 0; + restore_channels_info(ndev); err = setup_driver(ndev); if (err) -- 2.25.1