From patchwork Wed Nov 1 15:54:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 160592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp518961vqx; Wed, 1 Nov 2023 08:55:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxZ/qmFsSdJeMjE4W8iQjrssKStnd3Isk0N328Mq217mRfNUyuZkGbj89FsyURy2ud83Ci X-Received: by 2002:a05:6a00:1152:b0:6be:2bfa:6290 with SMTP id b18-20020a056a00115200b006be2bfa6290mr13960443pfm.8.1698854110278; Wed, 01 Nov 2023 08:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698854110; cv=none; d=google.com; s=arc-20160816; b=FAWX13YOdpbPsAQ9dWnE84akwNaTiyxvU3crpcjlR4+G138mphqh31kWaans2kiUQA +LIaOAnpaLEkcbRCcwC1s5cBce5eyL5znJzoGKP4pK6hV3dmC9f/YZOHobTvJnLEMW7+ aOVeqYrYkJJdlDVm7eddwgD/o33Gbiy6sBLmsFHk7E1r366GwQdLSYdjXA/XE8eOIvX+ WJs9SMJW+d2McqXrGJd/QEX675xomIeAv3B6DCR9C302zZXtk0CFb/JAWT/UEza7s/Jb ewdDRryM0XdwRsi4EpPVOhYE5iyimtGa52vRN603eN3cSj69Cn2azqVnvu4dJac3EKvJ tHZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=z7qKIxreV79Esql4YvSQ+NOWDmEVG9Uboz28sx478vU=; fh=IOlIrXYWxiM4krkaveQsygpuC5ZH+QYNdya8+r41sT0=; b=kA0JYh5XpbqCj2xyxhVvOux5pc9zs98+utdHnT5970gaaZkN8+uY2fX4+7dYf6y2zh 2XMXU1f3UsAcCYnb8wgQlNrM7cPWo9kvCyLu/D5nPsGgxt4wiyjB9eHhkG9GTReGfMlx kqjCN4DNlUiVAMEAeyFqPy1tjKvQTqmk6VdudO44QgohvV+Yw5xTrkfi/5RebaxVskRh DaFl7P7lWnccTPDVJ3by4UqeXZ5ALA/bKBnOwTEuoZZAJMhqVMnaw7/U0TwMvqVPT8sh tbRSuag1CMxxwwfzoLMwlBwV3zySX3nyqzp6rZerBwtvu08luxBF2fPmr72Qeue//hK5 b6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=v42C6xdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h3-20020a056a00170300b0068e256c6366si1874229pfc.352.2023.11.01.08.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 08:55:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=v42C6xdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 2CA6780C9DA9; Wed, 1 Nov 2023 08:55:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232759AbjKAPzC (ORCPT + 35 others); Wed, 1 Nov 2023 11:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbjKAPzA (ORCPT ); Wed, 1 Nov 2023 11:55:00 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5124110 for ; Wed, 1 Nov 2023 08:54:56 -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 3A1BEoIT031295; Wed, 1 Nov 2023 15:54:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2023-03-30; bh=z7qKIxreV79Esql4YvSQ+NOWDmEVG9Uboz28sx478vU=; b=v42C6xdic86zusqwEsNQaJ1K8otNUqquJ/WsiP4GJuGjJcI+AspbD8n6/OTtShigGXKw ToE9XXKa0zm8c31ODsFO3s1mBPueEeY18rZ4ISg4d7W2NWwv1Au7J+2472zQLGmQXa5+ DD7sDPeTfaa6GbyigFQTU2IZtzlfr23XwBEO/NremOAfrPv1BynArR58Ky/RAjiEnRZU +6DmE9Frw78MnRVc8syzqCVYyEn49RxAAUlB94wC8rCJdRzm7EvXbYBzRdHUKSZLfoaX D9Qk6aI/pkHF488+yjgiJPpzTGFpHodZ8qp+um+7gzDhH+OmLNY7PWxqumu40tHhp6KE wg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u0tuufnfd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Nov 2023 15:54:47 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A1FQbfE020087; Wed, 1 Nov 2023 15:54:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u0rrdf588-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Nov 2023 15:54:45 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A1FqKK2005458; Wed, 1 Nov 2023 15:54:45 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3u0rrdf572-1; Wed, 01 Nov 2023 15:54:45 +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 V2] vdpa/mlx5: preserve CVQ vringh index Date: Wed, 1 Nov 2023 08:54:43 -0700 Message-Id: <1698854083-136016-1-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 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-01_14,2023-11-01_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311010129 X-Proofpoint-GUID: mROIvOzsCUPbploxXbyOlKZPFIl9ndc6 X-Proofpoint-ORIG-GUID: mROIvOzsCUPbploxXbyOlKZPFIl9ndc6 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 01 Nov 2023 08:55:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781377647947363091 X-GMAIL-MSGID: 1781377647947363091 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. 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; }