Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4445473imw; Tue, 19 Jul 2022 06:48:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sn6qNgPddVgaC7BKf4THhiQhK9HAACIu3c41Gk5vSJsKwKQW42B/BFXkKe0MFfVTXtP46o X-Received: by 2002:a17:907:2d88:b0:72f:5bb:1ee0 with SMTP id gt8-20020a1709072d8800b0072f05bb1ee0mr18796409ejc.641.1658238482773; Tue, 19 Jul 2022 06:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238482; cv=none; d=google.com; s=arc-20160816; b=zYfALXQfMhD2hCoDuXq52aQhBaR4gJqUe/JDMMB6Y39gd94hFDLoLSYNS8oEfigPOP azTSgsiWtxZ+CKqgrZWCb2ntJfeBpxjO6FvaHe25gicjIf1SyAtB5EskQODh+eweeywB 65unPnFyNye8of1Ec4O05NSvQVxqP9CaaZqqENi0ckZJhIb2bWiSeF8qB3FOpnljD1X6 BEkLI/6Kfluc3KfDHkvEDVNcUGBOq0GIHpQ3QClLnCbbGFWHiZJKiruA5Et9vvNDw1wE 8fxw3Y6AgXTiYz3wYsTtllyJ6AIGh3acLiho2X0g/jfna4UAEt5Sy1UC+bshlpuUOVWx zTbQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GKSBeYrygUES9IsAiGPwIHxtusX4PtJnnYEQH8AsJqI=; b=JehZvHKTHn7/umizsCpuqSpAhptSI8DHTbgn/JNQm2bkYJ7QZVnshM3TrIHKZhKFV9 T3S9y1h2OTN0X8HU6RY9yiTrjWc+hLTicI2p570XwuB8PfLK6hHn1vtzallRPWCnR57g u9K8kjv0xzkzsZbS1LnRyD1s2Ezc588XA9lbY2ZsDHNF4T8FY6JC7MJy826t+yno0AsY IRAeMDnQg2zc2tVnpjpv0tBsmA1D8MBpOCAGvUwgbkgDvoVdYtpbr9ASf92w/MWk6pKM qs5oyrzuzafymvQ/r1ODw40/pCfWNC+zRNjPBgPQVda2kui0REmdoQEid1eawTdbREdz QBfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1kO+/yim"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd33-20020a17090796a100b006ff09d27800si21129832ejc.536.2022.07.19.06.47.38; Tue, 19 Jul 2022 06:48:02 -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=@linuxfoundation.org header.s=korg header.b="1kO+/yim"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241341AbiGSMnK (ORCPT + 99 others); Tue, 19 Jul 2022 08:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239439AbiGSMmr (ORCPT ); Tue, 19 Jul 2022 08:42:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C25537FE6C; Tue, 19 Jul 2022 05:16:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ACF656182A; Tue, 19 Jul 2022 12:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F01EC341C6; Tue, 19 Jul 2022 12:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232981; bh=vaJUynLGbfCplRsDW60OG5aSx//g6F4tBTnT7pWjYiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kO+/yim9SL6tEQTpC0A2tXMGCm5RP/lCffGci94TV5FAKK/8iyhz+6EfXyKA7MHJ 5nrT40WFAWvfkb034MDxGkOczRciRiFrOnSUIAraRVIJnj/oXyFGFYcqUdmBEDJQqZ 95da9yVdQQ7mrIrrEai8bbPF7u4xK8qro435roWY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Cohen , "Michael S. Tsirkin" , Jason Wang , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Sasha Levin Subject: [PATCH 5.15 115/167] vdpa/mlx5: Initialize CVQ vringh only once Date: Tue, 19 Jul 2022 13:54:07 +0200 Message-Id: <20220719114707.667896153@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Eli Cohen [ Upstream commit ace9252446ec615cd79a5f77d90edb25c0b9d024 ] Currently, CVQ vringh is initialized inside setup_virtqueues() which is called every time a memory update is done. This is undesirable since it resets all the context of the vring, including the available and used indices. Move the initialization to mlx5_vdpa_set_status() when VIRTIO_CONFIG_S_DRIVER_OK is set. Signed-off-by: Eli Cohen Message-Id: <20220613075958.511064-2-elic@nvidia.com> Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Acked-by: Eugenio PĂ©rez Signed-off-by: Sasha Levin --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 467a349dc26c..e748c00789f0 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1898,7 +1898,6 @@ static int verify_driver_features(struct mlx5_vdpa_dev *mvdev, u64 features) static int setup_virtqueues(struct mlx5_vdpa_dev *mvdev) { struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); - struct mlx5_control_vq *cvq = &mvdev->cvq; int err; int i; @@ -1908,16 +1907,6 @@ static int setup_virtqueues(struct mlx5_vdpa_dev *mvdev) goto err_vq; } - if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) { - err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features, - MLX5_CVQ_MAX_ENT, false, - (struct vring_desc *)(uintptr_t)cvq->desc_addr, - (struct vring_avail *)(uintptr_t)cvq->driver_addr, - (struct vring_used *)(uintptr_t)cvq->device_addr); - if (err) - goto err_vq; - } - return 0; err_vq: @@ -2184,6 +2173,21 @@ static void clear_vqs_ready(struct mlx5_vdpa_net *ndev) ndev->mvdev.cvq.ready = false; } +static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev) +{ + struct mlx5_control_vq *cvq = &mvdev->cvq; + int err = 0; + + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) + err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features, + MLX5_CVQ_MAX_ENT, false, + (struct vring_desc *)(uintptr_t)cvq->desc_addr, + (struct vring_avail *)(uintptr_t)cvq->driver_addr, + (struct vring_used *)(uintptr_t)cvq->device_addr); + + return err; +} + static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) { struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); @@ -2194,6 +2198,11 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) if ((status ^ ndev->mvdev.status) & VIRTIO_CONFIG_S_DRIVER_OK) { if (status & VIRTIO_CONFIG_S_DRIVER_OK) { + err = setup_cvq_vring(mvdev); + if (err) { + mlx5_vdpa_warn(mvdev, "failed to setup control VQ vring\n"); + goto err_setup; + } err = setup_driver(mvdev); if (err) { mlx5_vdpa_warn(mvdev, "failed to setup driver\n"); -- 2.35.1