From patchwork Fri Nov 3 12:26:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 161256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp989473vqu; Fri, 3 Nov 2023 05:26:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9e2Ft51tLt62f2p4sdx4vfd8mnh3la7ucxU89tht4l8zSes49SazaBYnoe3SzC4W+4oNB X-Received: by 2002:a17:903:2808:b0:1cc:385b:456a with SMTP id kp8-20020a170903280800b001cc385b456amr12383577plb.44.1699014416541; Fri, 03 Nov 2023 05:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014416; cv=none; d=google.com; s=arc-20160816; b=e4hNIgWMG6NNyD+Um99bY+SeC5itqKJg+Lh+zCEbqxqYWQOCUjeRuJhCWec1yZ9w4k Gj1/j3f/k4vhC9SwoboUoWPgoXB80Zgb6VxXROsvMYzM7baWiQpK9xFm9TY7DqSw/ioc s7RdhD+IAaV4dhKEwr5TUjMUJLn8fV4PwxWvx+3AzTEjV4aJN+VxyK8N6TA8LL4FQAzt 8wB0eVeA/eNSfK+xJ1B2MAFxDD8PD3LQ8puulwKa964xm884w8CW3GcOMaBj1pNLMSKt BzOQ9eXbDZidnaWYGUryL7xKQiwtPyitqhO5ttip22nsz40XqC/Ox375Irikooek/voj p8Lw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=zgHrw6VGeyWMel+aZHOfhG+ULGqf048GVY0ovi8BZ68=; fh=IOlIrXYWxiM4krkaveQsygpuC5ZH+QYNdya8+r41sT0=; b=mSP8eRhrJIoPWAIRNHeTMBrmjedY1NLNlBBtM6MieBw4T57hgXCSvTvdEreCX7gB+u xwY7kueZCgk8IHrEtImXLOgqKaRa8FXGO53K4jGT8Muwmarhx+WNxhc/fKXOfR+s8/4w tAKVWnqQr1b+2u6pMSsR4yjsdSIbexu2NOLRnGcA3Fh+hML8wQaC7YThc0MgOAo5RHwg 6nN/59v/1sbRToMsn9NX8iP2pBFr8nb98ANq6IfrVNGGpD8RszCVVUdVKEPbV78DpftG vM6/5nTp4q9y9ulRZKaaeirNz5QeohglFLM0ROqGW/+R6g96gCHsSY+fULTFFYmcRioy 8CdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=X0diECcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c4-20020a170902c1c400b001c61817e049si1420763plc.67.2023.11.03.05.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:26:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=X0diECcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5CD7282976B0; Fri, 3 Nov 2023 05:26:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346866AbjKCM0s (ORCPT + 36 others); Fri, 3 Nov 2023 08:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346442AbjKCM0q (ORCPT ); Fri, 3 Nov 2023 08:26:46 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0410123 for ; Fri, 3 Nov 2023 05:26:43 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A2NOgrf010612; Fri, 3 Nov 2023 12:26:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=corp-2023-03-30; bh=zgHrw6VGeyWMel+aZHOfhG+ULGqf048GVY0ovi8BZ68=; b=X0diECclx6eH3KP9Gq39pZ9xuHFiYx69oCscDi9jxdtWPxA+EjKA99MgkizkLJGziItB 550XC+1GWeoiwK3PqMNdXwSAiGxetQXGZN3roNisALsB+/49ct03qbKDNWmpZs7JzV4W R1fq+ylmE+vvhoY+DSFWZcV3AiLhcq+HchpYHpH81l/xOtrjctOXo7USwuZ6cybDov5+ vETsO3j+yeX/l/iSZy2U5RKdfZYbyoL+LrDRvSqqNy096Omf8I9t5PEpm0ECX8EsEoJO iYWviV5NkhOmQKhEeTfXr98uKIV2vPR5sFYozuXv6gqKbOmwguYicT4UkzChIpmZiNO1 tw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u0tuuks6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Nov 2023 12:26:34 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A3AlWk9001040; Fri, 3 Nov 2023 12:26:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u0rrab69e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Nov 2023 12:26:33 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A3CQXvT039969; Fri, 3 Nov 2023 12:26:33 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3u0rrab66c-1; Fri, 03 Nov 2023 12:26:33 +0000 From: Steve Sistare To: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Eli Cohen , Si-Wei Liu , Dragos Tatulea , Xuan Zhuo , Eugenio Perez Martin , Steve Sistare Subject: [PATCH V3] vdpa/mlx5: preserve CVQ vringh index Date: Fri, 3 Nov 2023 05:26:27 -0700 Message-Id: <1699014387-194368-1-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-03_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311030104 X-Proofpoint-GUID: oBBaOlEfpjy3wDarKlIvSnjZvFlr3MBP X-Proofpoint-ORIG-GUID: oBBaOlEfpjy3wDarKlIvSnjZvFlr3MBP X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 05:26:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545741133388773 X-GMAIL-MSGID: 1781545741133388773 mlx5_vdpa does not preserve userland's view of vring base for the control queue in the following sequence: ioctl VHOST_SET_VRING_BASE ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK mlx5_vdpa_set_status() setup_cvq_vring() vringh_init_iotlb() vringh_init_kern() vrh->last_avail_idx = 0; ioctl VHOST_GET_VRING_BASE To fix, restore the value of cvq->vring.last_avail_idx after calling vringh_init_iotlb. Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting") Signed-off-by: Steve Sistare Acked-by: Eugenio PĂ©rez Acked-by: Jason Wang --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 946488b8989f..ca972af3c89a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2795,13 +2795,18 @@ 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)) + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) { + u16 idx = cvq->vring.last_avail_idx; + 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) + cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx; + } return err; }