Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 423CFC636CC for ; Thu, 16 Feb 2023 04:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjBPEtx (ORCPT ); Wed, 15 Feb 2023 23:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjBPEtu (ORCPT ); Wed, 15 Feb 2023 23:49:50 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1477F30EA6 for ; Wed, 15 Feb 2023 20:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676522942; 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: in-reply-to:in-reply-to:references:references; bh=NlDKmPgYGuj2vp+iCLyrQRKv19uw3gvLOjVZhG1ou+Q=; b=PNVKDaTW8yNG0XsC0np7/4yDUd/JWrwvcCMVk3QbAoYHbYVgq5RExsornDBqDsNGGYjnpX /l7jbaL7roVwHkgxUatT80ajFI2VtS6hMH/cK+5R+ZbxfP0hYIJ4RQFWRtsxA6+Xo7eY1D H0ktdsD8BAK3N5ElbJ5q48E+jZiJur4= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-88-71hlEWRxP8iyB14xaKlf0Q-1; Wed, 15 Feb 2023 23:49:00 -0500 X-MC-Unique: 71hlEWRxP8iyB14xaKlf0Q-1 Received: by mail-oo1-f72.google.com with SMTP id s20-20020a4adb94000000b0051f988b6656so176561oou.14 for ; Wed, 15 Feb 2023 20:49:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=NlDKmPgYGuj2vp+iCLyrQRKv19uw3gvLOjVZhG1ou+Q=; b=tLKtEaQ8KBBC+PpZCeIPXLMGB0rV6yBr+8mxvQXx2LGksLnlNBJkOfbAfFQ/+iUd41 6xv742TpHdHR93gnCuhGLAyEG4ETodE44cZzvfM9RlqFzccAVvAOTgDFcr7mJK2zMNyV tnzTH7YYrOzDdbLyYDQeGQv7v31JC6htfA5/VngzPz8LZZWGjghyyanMb8QsKT7KmvFd 3Hi5ly6JbNKF/ZQbZdstrLp5gCHWcirbAeiKZiAt6Ma6ysfnuA2/5tsS0ijclqXokmgG n39nSRpY0OHDe0yAyZYH9u2c8NV8DpQDvLYA4Sywc77+Fesq8bO+N8N9X4mnKgdYjq7G knKw== X-Gm-Message-State: AO0yUKWvurU0msIqpKw6E126jSZUvGkK4uOUNaC/QOihY+j45VgNY6yJ 9SiVPgDTQipO6E0oHYPhqQihbwK8l23WYlnXpPqN+/mp2Y7p6oN3GJN6pSVfcjLF6OzxOHNoQle oMqXRQPlMB2lq+JjBae/z4w4kQ5DYVSRpUg+bp4zf X-Received: by 2002:a05:6808:3186:b0:37d:5d77:e444 with SMTP id cd6-20020a056808318600b0037d5d77e444mr59820oib.35.1676522940042; Wed, 15 Feb 2023 20:49:00 -0800 (PST) X-Google-Smtp-Source: AK7set/penI+mI8fHaWiIdLRXLv5ATb6NdjbtjsVWvqsvhX3hGUAZ5SRLsbEAlIOAgsLajHHCClQY8yHruiDl9lWezI= X-Received: by 2002:a05:6808:3186:b0:37d:5d77:e444 with SMTP id cd6-20020a056808318600b0037d5d77e444mr59814oib.35.1676522939846; Wed, 15 Feb 2023 20:48:59 -0800 (PST) MIME-Version: 1.0 References: <1676424640-11673-1-git-send-email-si-wei.liu@oracle.com> In-Reply-To: <1676424640-11673-1-git-send-email-si-wei.liu@oracle.com> From: Jason Wang Date: Thu, 16 Feb 2023 12:48:48 +0800 Message-ID: Subject: Re: [PATCH v3] vdpa/mlx5: should not activate virtq object when suspended To: Si-Wei Liu Cc: mst@redhat.com, elic@nvidia.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, eperezma@redhat.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 15, 2023 at 9:31 AM Si-Wei Liu wrote: > > Otherwise the virtqueue object to instate could point to invalid address > that was unmapped from the MTT: > > mlx5_core 0000:41:04.2: mlx5_cmd_out_err:782:(pid 8321): > CREATE_GENERAL_OBJECT(0xa00) op_mod(0xd) failed, status > bad parameter(0x3), syndrome (0x5fa1c), err(-22) > > Fixes: cae15c2ed8e6 ("vdpa/mlx5: Implement susupend virtqueue callback") > Cc: Eli Cohen > Signed-off-by: Si-Wei Liu > Reviewed-by: Eli Cohen > > --- > v3: move suspended to struct mlx5_vdpa_dev > v2: removed the change for improving warning message > --- > drivers/vdpa/mlx5/core/mlx5_vdpa.h | 1 + > drivers/vdpa/mlx5/net/mlx5_vnet.c | 6 +++++- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/mlx5_vdpa.h > index 058fbe2..25fc412 100644 > --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h > +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h > @@ -96,6 +96,7 @@ struct mlx5_vdpa_dev { > struct mlx5_control_vq cvq; > struct workqueue_struct *wq; > unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS]; > + bool suspended; > }; > > int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid); > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 3a6dbbc6..daac3ab 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2411,7 +2411,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, > if (err) > goto err_mr; > > - if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) > + if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK) || mvdev->suspended) One more thought, Does this mean set_map() is forbidden during suspending? I'm not sure this is correct or at least we need restrict in in the vDPA core. Thanks > goto err_mr; > > restore_channels_info(ndev); > @@ -2579,6 +2579,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev) > clear_vqs_ready(ndev); > mlx5_vdpa_destroy_mr(&ndev->mvdev); > ndev->mvdev.status = 0; > + ndev->mvdev.suspended = false; > ndev->cur_num_vqs = 0; > ndev->mvdev.cvq.received_desc = 0; > ndev->mvdev.cvq.completed_desc = 0; > @@ -2815,6 +2816,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) > struct mlx5_vdpa_virtqueue *mvq; > int i; > > + mlx5_vdpa_info(mvdev, "suspending device\n"); > + > down_write(&ndev->reslock); > ndev->nb_registered = false; > mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); > @@ -2824,6 +2827,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) > suspend_vq(ndev, mvq); > } > mlx5_vdpa_cvq_suspend(mvdev); > + mvdev->suspended = true; > up_write(&ndev->reslock); > return 0; > } > -- > 1.8.3.1 >