From patchwork Thu Oct 26 07:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 15914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp483378vqb; Thu, 26 Oct 2023 00:18:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEm+kruonXR6FYFZcVTMQHvFAXX9sw5JN0q9KQYv2/sdHFU6OZR5/0Po+pqlje3lTgmT2bV X-Received: by 2002:a81:8356:0:b0:5a7:bfbf:1bbb with SMTP id t83-20020a818356000000b005a7bfbf1bbbmr19943154ywf.17.1698304714017; Thu, 26 Oct 2023 00:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698304714; cv=none; d=google.com; s=arc-20160816; b=Efa38cGyNxWAzOnYn/LghAmABAWPGwd5NI2QWECiLrc8TvIKUq99vAw7m6yZVXz1Qa yfK7Pt4jY85lXszJuiuZr3Zz5BJFKLuGFG5a4j/qDZIYzXlwlhnOOE4I/eUoP8+qGRVo 1Ec3oDOzsbs4K1Q8Ko4noytlqccVauIBsxDwsSQynR1JqVbB5RN7ISrlOSv7zDfoEcx9 s7DNEaBP3uHke6bVpfZuAh20+qfBNb8+RruWGBOl6gD3x91ueTDBYzqQ9gQzWjqa9c98 aQ8stnF+2j+0trkIPKBvAeXVQh0rznm9LTCV4CqC7sZ92rcndfkw0L/tE44ZGN+8DwzK 5MBA== 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=X3a3iMFmYQw/CMdUXMYbinGUijqCuBut6pJA3oZ9q40=; fh=ozy2CkLebIOzbpPF40kmeuF6jbAmH8vZa/HD/EKOE2c=; b=dR45mUkiDVOHuVeq9BZTAVfvn4pRlmFRUr11mF4eHEImvMMFxuk5SKmXMgiHFtwvFJ BMYmY6IJaK8UUfwrEBKj+IjHY53vkJLbty8QIjJj3uUrjcMg1SupO0+PjQpGpmspuRbt P1StlX5amVv40e1JhDk+ZXFiAfaU+zfNrRPrsYp3u4hThOL6EUNpP8rr4GDwAQGfiE5X JQJ2fDL6/MRWkIH7cXMrhTnJqyGmfN4uhZHCWlKgD5rNB8fSfCJmhk5W/G3HiU5+DmM7 jP+onwUvakL+AmyJsMS1+eX3gAQj53ougK1J659ir1eeCac643annVJGE3bdQa5FVvxz aaxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=dtiBETwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a135-20020a0dd88d000000b005a7afbfc65csi14496474ywe.126.2023.10.26.00.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 00:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=dtiBETwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 0736382696D3; Thu, 26 Oct 2023 00:18:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344111AbjJZHRd (ORCPT + 26 others); Thu, 26 Oct 2023 03:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJZHRc (ORCPT ); Thu, 26 Oct 2023 03:17:32 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 633E7129 for ; Thu, 26 Oct 2023 00:17:30 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39Q3TVX3026203; Thu, 26 Oct 2023 07:17:26 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=X3a3iMFmYQw/CMdUXMYbinGUijqCuBut6pJA3oZ9q40=; b=dtiBETwYeqenKYB3667NRLSJibQtUKO2SmxLXMuzkC4GzWTS9iNMrShenwsaw+LWVsHL YhGJWG+Kx+DPW2yRhmpLoBCggkQsr7oC/Kuh36dRmhhK4YxL/cI9DgCDhSAfx0Yv1VAC 3fWHTMoy5O3sQezUTYgw6EEl+zzF+BnkYGzCPcNvummZEbB+Xxs8Nl2tsKXzgXYLC3Ao RiXToDrIvXkq79MPuWBLgMK/0Ic+IxBnpTNkiEvHo30DuwfJmJ9EPeieA5rqVLLvO/Kq FcRwzyP7rUPprxuXnvn2flA5TLl6dj61wek71Ad2iQ1FXNEV+sZ5FI5ZG+2DXltlnG/F Yw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tv52e2bvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Oct 2023 07:17:26 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39Q6tbAE015200; Thu, 26 Oct 2023 07:17:25 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3tv537t53r-1; Thu, 26 Oct 2023 07:17:24 +0000 From: Si-Wei Liu To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, dtatulea@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/7] vdpa: decouple reset of iotlb mapping from device reset Date: Thu, 26 Oct 2023 00:14:33 -0700 Message-Id: <1698304480-18463-1-git-send-email-si-wei.liu@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.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-26_04,2023-10-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310260060 X-Proofpoint-ORIG-GUID: qJzScXUnYZ5ovVfehxHlTl8PaF3d8GsY X-Proofpoint-GUID: qJzScXUnYZ5ovVfehxHlTl8PaF3d8GsY 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 00:18:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780801564025196090 X-GMAIL-MSGID: 1780801564025196090 In order to reduce needlessly high setup and teardown cost of iotlb mapping during live migration, it's crucial to decouple the vhost-vdpa iotlb abstraction from the virtio device life cycle, i.e. iotlb mappings should be left intact across virtio device reset [1]. For it to work, the on-chip IOMMU parent device could implement a separate .reset_map() operation callback to restore 1:1 DMA mapping without having to resort to the .reset() callback, the latter of which is mainly used to reset virtio device state. This new .reset_map() callback will be invoked only before the vhost-vdpa driver is to be removed and detached from the vdpa bus, such that other vdpa bus drivers, e.g. virtio-vdpa, can start with 1:1 DMA mapping when they are attached. For the context, those on-chip IOMMU parent devices, create the 1:1 DMA mapping at vdpa device creation, and they would implicitly destroy the 1:1 mapping when the first .set_map or .dma_map callback is invoked. This patchset is rebased on top of the latest vhost tree. [1] Reducing vdpa migration downtime because of memory pin / maps https://www.mail-archive.com/qemu-devel@nongnu.org/msg953755.html --- v5: - Squashed two fixups to the clean map patch v4: - Rework compatibility using new .compat_reset driver op v3: - add .reset_map support to vdpa_sim - introduce module parameter to provide bug-for-bug compatibility with older userspace v2: - improved commit message to clarify the intended csope of .reset_map API - improved commit messages to clarify no breakage on older userspace v1: - rewrote commit messages to include more detailed description and background - reword to vendor specific IOMMU implementation from on-chip IOMMU - include parent device backend feautres to persistent iotlb precondition - reimplement mlx5_vdpa patch on top of descriptor group series RFC v3: - fix missing return due to merge error in patch #4 RFC v2: - rebased on top of the "[PATCH RFC v2 0/3] vdpa: dedicated descriptor table group" series: https://lore.kernel.org/virtualization/1694248959-13369-1-git-send-email-si-wei.liu@oracle.com/ --- Si-Wei Liu (7): vdpa: introduce .reset_map operation callback vhost-vdpa: reset vendor specific mapping to initial state in .release vhost-vdpa: introduce IOTLB_PERSIST backend feature bit vdpa: introduce .compat_reset operation callback vhost-vdpa: clean iotlb map during reset for older userspace vdpa/mlx5: implement .reset_map driver op vdpa_sim: implement .reset_map support drivers/vdpa/mlx5/core/mlx5_vdpa.h | 1 + drivers/vdpa/mlx5/core/mr.c | 17 ++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 27 ++++++++++++++-- drivers/vdpa/vdpa_sim/vdpa_sim.c | 52 ++++++++++++++++++++++++------ drivers/vhost/vdpa.c | 52 +++++++++++++++++++++++++++--- drivers/virtio/virtio_vdpa.c | 2 +- include/linux/vdpa.h | 30 +++++++++++++++-- include/uapi/linux/vhost_types.h | 2 ++ 8 files changed, 164 insertions(+), 19 deletions(-)