Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1757995rdh; Tue, 26 Sep 2023 02:38:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE35UoerezL+sGQxvM9fDIWLaxRkSKHHYO49/Rhswj5+juIRsAdGHqUi+kl5eDj7DaPbK6O X-Received: by 2002:a05:6808:f8c:b0:3ae:16aa:8b9b with SMTP id o12-20020a0568080f8c00b003ae16aa8b9bmr10575786oiw.33.1695721126837; Tue, 26 Sep 2023 02:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695721126; cv=none; d=google.com; s=arc-20160816; b=q9Gyj5n+1DywGY56OxKWVhA6mqmMvMoqcxA2JfqaJXAWMh9FFCEKE3XcyVUzUzPjSQ Bl4djKJKA+WXii45y5V/v/nLDcoaoKDQoR+IppDI7f2DirJUj4huNtXPLDff9GWioS7v knD59ZokL4tjm4F2Vrl+X8ZMggkt4Y5DBzGqdBtgpS8CRzCy3vvGQBLqAgRAMxN5PKyv FxvVKNnAFDU9/vrNwOk7ScILQhe9noSpZm4bn654HvwWSajRjPKW85ejjTqRT52aL8ct RJXzCF9ME9NJuKu7LagFPOI2dwC4hArUcHwRzTiIcGVDHZP2tblc+UwW/C3vAUgOK1G7 2V2g== 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=PZAhx7MFdkeBmGFe31AVlV3iO2EqSJG4TtChPwC6CuI=; fh=dJp8FZn3+jiYGV+e7Ew7vHmAFoOpfPx8FCDDh6gjrPI=; b=WrmaxApc3J/ZMkNqIu/3/JkW295+FJb1yO2djvv2azg0JwmxQMnYlUxJu7ZrRD4cd2 zs4FGq5klW/xn1tT5EGh2xiYrTtHCBeRqm1NdCKEEUl9WuJ4VnaMyOXUzmwBhLWmR4gb 2Ht8W2SlBpMmr0x6wZVRGxsL5MAjyurekOxRbqlQV/k5U/9isHG/H1VAQ9HN+isOZ/ib mv8JWnfrtFxZLhm/RFz9xXsMag/phDW+NWpxUpUvh+NosZ4H4wre37wVkjoW1WRjSAN9 Ryxe083gNx0PvGIjuvNGLKPjGDa1PK3L5IACUYuT74/Fe5ORDwzziazptcKGQQaAv7T4 KEVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fjvsoa+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y14-20020a056a00180e00b00690d33fed3asi13184819pfa.53.2023.09.26.02.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 02:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fjvsoa+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 6C2C2825148D; Mon, 25 Sep 2023 20:30:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233591AbjIZD36 (ORCPT + 99 others); Mon, 25 Sep 2023 23:29:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233467AbjIZD3z (ORCPT ); Mon, 25 Sep 2023 23:29:55 -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 9C93D194 for ; Mon, 25 Sep 2023 20:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695698940; 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=PZAhx7MFdkeBmGFe31AVlV3iO2EqSJG4TtChPwC6CuI=; b=fjvsoa+Ml4dQ2qD5gm5vNJh4QTZwkottC8QT0OqUOWq7CjMUDkmizKLRSg0s2b3RdpdRYw Kgvj/ynQabRYCs87LoeqwphVAg/IkW8n68LhgYjloYlidLUnV2OYxy0diDHoJ1nWV2op26 sK8L+FEGvfE7lnqH01DPSIGwUJnsp1A= 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-561-yFg0sD4xPJSzjznW2i9qWw-1; Mon, 25 Sep 2023 23:28:58 -0400 X-MC-Unique: yFg0sD4xPJSzjznW2i9qWw-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-502fff967ccso10580916e87.1 for ; Mon, 25 Sep 2023 20:28:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695698937; x=1696303737; 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=PZAhx7MFdkeBmGFe31AVlV3iO2EqSJG4TtChPwC6CuI=; b=gOS21MmQeu4LK2EE04TuYfibNr4OoSrPadP2Ml6yP0CbBUfP4Lc5YW+tzMnQzAKpVV 1il1tdLl0dVkS1l5UsUPkmRQPp/QOIBRnu6xGca7LmMdROtPCyx05A1dFb0uZ27GdW3n fYJrtikibiE0TNe1/Txap0f+ZjUd8HH/lNR0djGFn1G3VoYpqcsH6laFzAuL2daBF6bs p5IEZMYl1WXrQlZ20ONVJV4kmMe3EBW5U5EM29AXi71fI85peKopjv9Ve5SiUATPGCEl Y/sXRS4tkQ+8V1UhS2EnluTQ9jUWdz/DA1GugRP9jLhe8kbBK2w8T5zU03vtZkLGkbHo AyFA== X-Gm-Message-State: AOJu0YwjT7/hHfnpuZ6i6lWkcjs4CtkS7rvIsRx6TRHj2L5qngE4VEps T8bikYb1r2gknKN+93SV+nWb0kJf+CO/RdJmFNdOkyTqPmu2KN/E/rFJNiDxsXDL/fUwroNKGk3 Cuq+8HpkYOZxev9xPIweGVLKdbpRUPPjOIXJ1/6mo X-Received: by 2002:a05:6512:401a:b0:503:2e6:685e with SMTP id br26-20020a056512401a00b0050302e6685emr9229179lfb.14.1695698937284; Mon, 25 Sep 2023 20:28:57 -0700 (PDT) X-Received: by 2002:a05:6512:401a:b0:503:2e6:685e with SMTP id br26-20020a056512401a00b0050302e6685emr9229170lfb.14.1695698936966; Mon, 25 Sep 2023 20:28:56 -0700 (PDT) MIME-Version: 1.0 References: <20230912130132.561193-1-dtatulea@nvidia.com> <20230912130132.561193-6-dtatulea@nvidia.com> In-Reply-To: <20230912130132.561193-6-dtatulea@nvidia.com> From: Jason Wang Date: Tue, 26 Sep 2023 11:28:45 +0800 Message-ID: Subject: Re: [PATCH 05/16] vdpa/mlx5: Decouple cvq iotlb handling from hw mapping code To: Dragos Tatulea Cc: =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Si-Wei Liu , "Michael S . Tsirkin" , Saeed Mahameed , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Parav Pandit , Xuan Zhuo , kvm@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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 25 Sep 2023 20:30:04 -0700 (PDT) On Tue, Sep 12, 2023 at 9:02=E2=80=AFPM Dragos Tatulea wrote: > > The handling of the cvq iotlb is currently coupled with the creation > and destruction of the hardware mkeys (mr). > > This patch moves cvq iotlb handling into its own function and shifts it > to a scope that is not related to mr handling. As cvq handling is just a > prune_iotlb + dup_iotlb cycle, put it all in the same "update" function. > Finally, the destruction path is handled by directly pruning the iotlb. > > After this move is done the ASID mr code can be collapsed into a single > function. > > Signed-off-by: Dragos Tatulea > --- > drivers/vdpa/mlx5/core/mlx5_vdpa.h | 3 ++ > drivers/vdpa/mlx5/core/mr.c | 57 +++++++++++------------------- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++-- > 3 files changed, 28 insertions(+), 39 deletions(-) > > diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/= mlx5_vdpa.h > index 3748f027cfe9..554899a80241 100644 > --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h > +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h > @@ -120,6 +120,9 @@ int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, = struct vhost_iotlb *iotlb, > unsigned int asid); > void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev); > void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev *mvdev, unsigned int= asid); > +int mlx5_vdpa_update_cvq_iotlb(struct mlx5_vdpa_dev *mvdev, > + struct vhost_iotlb *iotlb, > + unsigned int asid); > int mlx5_vdpa_create_dma_mr(struct mlx5_vdpa_dev *mvdev); > > #define mlx5_vdpa_warn(__dev, format, ...) = \ > diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c > index 7bd0883b8b25..fcb6ae32e9ed 100644 > --- a/drivers/vdpa/mlx5/core/mr.c > +++ b/drivers/vdpa/mlx5/core/mr.c > @@ -489,14 +489,6 @@ static void destroy_user_mr(struct mlx5_vdpa_dev *mv= dev, struct mlx5_vdpa_mr *mr > } > } > > -static void _mlx5_vdpa_destroy_cvq_mr(struct mlx5_vdpa_dev *mvdev, unsig= ned int asid) > -{ > - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] !=3D asid) > - return; > - > - prune_iotlb(mvdev); > -} > - > static void _mlx5_vdpa_destroy_dvq_mr(struct mlx5_vdpa_dev *mvdev, unsig= ned int asid) > { > struct mlx5_vdpa_mr *mr =3D &mvdev->mr; > @@ -522,25 +514,14 @@ void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev= *mvdev, unsigned int asid) > mutex_lock(&mr->mkey_mtx); > > _mlx5_vdpa_destroy_dvq_mr(mvdev, asid); > - _mlx5_vdpa_destroy_cvq_mr(mvdev, asid); > > mutex_unlock(&mr->mkey_mtx); > } > > void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev) > { > - mlx5_vdpa_destroy_mr_asid(mvdev, mvdev->group2asid[MLX5_VDPA_CVQ_= GROUP]); > mlx5_vdpa_destroy_mr_asid(mvdev, mvdev->group2asid[MLX5_VDPA_DATA= VQ_GROUP]); > -} > - > -static int _mlx5_vdpa_create_cvq_mr(struct mlx5_vdpa_dev *mvdev, > - struct vhost_iotlb *iotlb, > - unsigned int asid) > -{ > - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] !=3D asid) > - return 0; > - > - return dup_iotlb(mvdev, iotlb); > + prune_iotlb(mvdev); > } > > static int _mlx5_vdpa_create_dvq_mr(struct mlx5_vdpa_dev *mvdev, > @@ -572,22 +553,7 @@ static int _mlx5_vdpa_create_dvq_mr(struct mlx5_vdpa= _dev *mvdev, > static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, > struct vhost_iotlb *iotlb, unsigned int a= sid) > { > - int err; > - > - err =3D _mlx5_vdpa_create_dvq_mr(mvdev, iotlb, asid); > - if (err) > - return err; > - > - err =3D _mlx5_vdpa_create_cvq_mr(mvdev, iotlb, asid); > - if (err) > - goto out_err; > - > - return 0; > - > -out_err: > - _mlx5_vdpa_destroy_dvq_mr(mvdev, asid); > - > - return err; > + return _mlx5_vdpa_create_dvq_mr(mvdev, iotlb, asid); > } > > int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb = *iotlb, > @@ -620,7 +586,24 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *m= vdev, struct vhost_iotlb *io > return err; > } > > +int mlx5_vdpa_update_cvq_iotlb(struct mlx5_vdpa_dev *mvdev, > + struct vhost_iotlb *iotlb, > + unsigned int asid) > +{ > + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] !=3D asid) > + return 0; > + > + prune_iotlb(mvdev); > + return dup_iotlb(mvdev, iotlb); > +} > + > int mlx5_vdpa_create_dma_mr(struct mlx5_vdpa_dev *mvdev) > { > - return mlx5_vdpa_create_mr(mvdev, NULL, 0); > + int err; > + > + err =3D mlx5_vdpa_create_mr(mvdev, NULL, 0); > + if (err) > + return err; > + > + return mlx5_vdpa_update_cvq_iotlb(mvdev, NULL, 0); > } Nit: Still a little bit coupling but anyhow: Acked-by: Jason Wang Thanks > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/ml= x5_vnet.c > index d34c19b4e139..061d8f7a661a 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2884,10 +2884,13 @@ static int set_map_data(struct mlx5_vdpa_dev *mvd= ev, struct vhost_iotlb *iotlb, > return err; > } > > - if (change_map) > + if (change_map) { > err =3D mlx5_vdpa_change_map(mvdev, iotlb, asid); > + if (err) > + return err; > + } > > - return err; > + return mlx5_vdpa_update_cvq_iotlb(mvdev, iotlb, asid); > } > > static int mlx5_vdpa_set_map(struct vdpa_device *vdev, unsigned int asid= , > -- > 2.41.0 >