Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp699452rdg; Thu, 12 Oct 2023 20:04:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcAx3jhgo3A7x0+Ku6a818pBCIFjl6OdvYyGqch06iczQARouyok0w52/rNaSuj+lZ5vVd X-Received: by 2002:a17:902:ab48:b0:1c9:bca2:d653 with SMTP id ij8-20020a170902ab4800b001c9bca2d653mr7744249plb.11.1697166245475; Thu, 12 Oct 2023 20:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697166245; cv=none; d=google.com; s=arc-20160816; b=FAY8AEmg85KIy9XF3D6tbiW9yC5oTmn8wCR/BSXlX/KP/W/X/70thoFB/yCQ66tEC4 q6Cq6iBze3odeN53oLrdLvWvp+axpFCM4mGCOnlBIsTvsMRm8qX66/2F2H4ZrgURN2Ma OHEfIfdhh37fuJKJMwo/vMEYp1kh/Bla7aNZbYPbSCBYrqG+dJB5WkE54mZ0Zs3P+ETL caxSHH9j2Mzgs5hwHPdt1W9Z8HxLad0dh5ejwhzmX03a8ufenoW0P70FQRCsJNsko1dm ljejN2/XdBAFr0QeY7JxNlRKXTPd47gwBTWKguMZc+DrIqu4l5LmQWKdFsO+L2ZzGbCZ aazg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Fh5pL38+B6R3gU+K0Col33PyIlfMXMZvWZg4AIIPXj0=; fh=mDp0NpY7pu5QEDNZnAujkyR0YB3lgZTBOIKjbR72oCc=; b=d6GQ+rB0GamVV1KOteoUupS5RHvlRzHvbdDd8Sf9Au9kd0zmO0ZuUBSN/Brp9Zl2kj muG214JhwvsooIgNOkmeTGy2f/1J+EaxwzH8bcds5vKYRO6skT9QgOcBBz+P6a/hiwYl oXcWe3HMvfTDRuATvhtsQUZiFy/oQpsmd3LdAU1NA/Sl12/zSv1g131BYt8dDXv/pg1O bVnwPrlFwo6TdCPxdNFgQUQIr78nLEwpqyzvBi5+xA87B1p3j+iycX1hwFbNB+mHzn9B MfKHyItQc20Wxmb4HRiKgSvNXlTam2y09gtPKEMzJfPzixvxLAMx9EGKE8BQ63lNonke +ufg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b+mkcRtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b3-20020a170902d30300b001c9af7debbasi3517943plc.520.2023.10.12.20.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 20:04:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b+mkcRtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BAE6681DF263; Thu, 12 Oct 2023 20:04:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjJMDD0 (ORCPT + 99 others); Thu, 12 Oct 2023 23:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjJMDDV (ORCPT ); Thu, 12 Oct 2023 23:03:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 818BF91 for ; Thu, 12 Oct 2023 20:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697166145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fh5pL38+B6R3gU+K0Col33PyIlfMXMZvWZg4AIIPXj0=; b=b+mkcRtFCtkentf7pQ/ZFPRBiVy/JWUcmnjMFlA/7vbkp5iLyq3WqUHRPbI1nbB9EoLPiD kNkKw2AkML479DWm09Z3AJvHlXRb1R+pJ/QwcyeStSzlflE4KEFlp33Q5ql/S28VnnXSK0 51wSZW/tofYYdbAkd6FmjkTnZhkoj7Y= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-umina9EYONyGIbzZK-GeyA-1; Thu, 12 Oct 2023 23:02:14 -0400 X-MC-Unique: umina9EYONyGIbzZK-GeyA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5042d5a3f13so1589768e87.2 for ; Thu, 12 Oct 2023 20:02:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697166132; x=1697770932; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fh5pL38+B6R3gU+K0Col33PyIlfMXMZvWZg4AIIPXj0=; b=NosmMzBtiSYw9XHPAdzzEaB/TPDrf5WGO7en4OSivy4aelr/l5lNF9AkUAnzMoPcyj JbAeIZ7FwGBMeXDftUPFr/UhHTzIfJrt1hu7cYxt0a8xR4+Vs5fS6n1xqdQnsP8IWnSI RQZseb0n6eMcSOaVuh2S4pTYFJYHAuxp8zV+CCv0R+YmJ/KH5LMzArFVKLGEy2NeRnc6 UtbP0R84R0U0DQH0AeZmrFHAs3NKUFPXkK0/NCmvXp5a1zUK+nIZ7zizu7DTg59gYFiE EPi9HqpPUirdUU/IqMQCRMTWquiYOX+DHuYdALLFiu4PjJpYGSYdI0AQJSUAuNweyBwm sOzw== X-Gm-Message-State: AOJu0Yz3Y0bpF/b6MNkLJ9Wodg7PLDeSB7texldAYh2pbJOrk5GVv+2l WQUppWjps7gABnpMECeTTlPXNxmX2CcZ2oGnKFSd67TcMI/S6oOaL2pE5zWN6+9ALMyu8WuTe2f F9ywNzh8Wm8Pk9cKUclHfTBmKChVRUnY0b2N6DA/m X-Received: by 2002:a05:6512:695:b0:503:28cb:c087 with SMTP id t21-20020a056512069500b0050328cbc087mr32985467lfe.29.1697166132485; Thu, 12 Oct 2023 20:02:12 -0700 (PDT) X-Received: by 2002:a05:6512:695:b0:503:28cb:c087 with SMTP id t21-20020a056512069500b0050328cbc087mr32985456lfe.29.1697166132169; Thu, 12 Oct 2023 20:02:12 -0700 (PDT) MIME-Version: 1.0 References: <1696928580-7520-1-git-send-email-si-wei.liu@oracle.com> <1696928580-7520-3-git-send-email-si-wei.liu@oracle.com> In-Reply-To: <1696928580-7520-3-git-send-email-si-wei.liu@oracle.com> From: Jason Wang Date: Fri, 13 Oct 2023 11:01:59 +0800 Message-ID: Subject: Re: [PATCH 2/4] vhost-vdpa: reset vendor specific mapping to initial state in .release To: Si-Wei Liu Cc: mst@redhat.com, eperezma@redhat.com, xuanzhuo@linux.alibaba.com, dtatulea@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 20:04:02 -0700 (PDT) On Tue, Oct 10, 2023 at 5:05=E2=80=AFPM Si-Wei Liu = wrote: > > Devices with on-chip IOMMU or vendor specific IOTLB implementation > may need to restore iotlb mapping to the initial or default state > using the .reset_map op, as it's desirable for some parent devices > to solely manipulate mappings by its own, independent of virtio device > state. For instance, device reset does not cause mapping go away on > such IOTLB model in need of persistent mapping. Before vhost-vdpa > is going away, give them a chance to reset iotlb back to the initial > state in vhost_vdpa_cleanup(). > > Signed-off-by: Si-Wei Liu > --- > drivers/vhost/vdpa.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 851535f..a3f8160 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -131,6 +131,15 @@ static struct vhost_vdpa_as *vhost_vdpa_find_alloc_a= s(struct vhost_vdpa *v, > return vhost_vdpa_alloc_as(v, asid); > } > > +static void vhost_vdpa_reset_map(struct vhost_vdpa *v, u32 asid) > +{ > + struct vdpa_device *vdpa =3D v->vdpa; > + const struct vdpa_config_ops *ops =3D vdpa->config; > + > + if (ops->reset_map) > + ops->reset_map(vdpa, asid); > +} > + > static int vhost_vdpa_remove_as(struct vhost_vdpa *v, u32 asid) > { > struct vhost_vdpa_as *as =3D asid_to_as(v, asid); > @@ -140,6 +149,13 @@ static int vhost_vdpa_remove_as(struct vhost_vdpa *v= , u32 asid) > > hlist_del(&as->hash_link); > vhost_vdpa_iotlb_unmap(v, &as->iotlb, 0ULL, 0ULL - 1, asid); > + /* > + * Devices with vendor specific IOMMU may need to restore > + * iotlb to the initial or default state which is not done > + * through device reset, as the IOTLB mapping manipulation > + * could be decoupled from the virtio device life cycle. > + */ Should we do this according to whether IOTLB_PRESIST is set? Otherwise we may break old userspace. Thanks > + vhost_vdpa_reset_map(v, asid); > kfree(as); > > return 0; > -- > 1.8.3.1 >