From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 252CAC43216 for ; Tue, 3 Aug 2021 09:51:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 135B460F56 for ; Tue, 3 Aug 2021 09:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235113AbhHCJvK (ORCPT ); Tue, 3 Aug 2021 05:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235004AbhHCJvH (ORCPT ); Tue, 3 Aug 2021 05:51:07 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9962C061798 for ; Tue, 3 Aug 2021 02:50:56 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id cf5so16679731edb.2 for ; Tue, 03 Aug 2021 02:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jILE4iG7Hf5kzSZ86WpBt9OleoKnKxcD0AIYcg4CDWg=; b=UYLK3kL70/wbKlpjOzW8UaU540qw0H/BDGz2GAidxIH+0Tbdq0r3XuevQhcMlSwF58 U+YHGLL8f22QDEunPk9DqMq1eT1/Yz2ExXO9GDS/ufNbqgnesYijDgUYNyUBGpqkPBK0 jc6z0LopU31KIzZFUVhnBr86QNVcAec5ZQBL5MTDd8HrrSV4ZRwjz36IsOtuGmnH5X6A jYcjFh70UmazEs1b8oePF1wJDVsQ8glRQ/glBwJR4GBZ9yTuI1WAaizqZ05szzG1Ixmq 2ctXvL00wRUev+FoavAHzmKe4yzO/7Bj+vNrO7PmMnz9qL1uqQVTrFk5IPvZ//M0qMCj v22g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=jILE4iG7Hf5kzSZ86WpBt9OleoKnKxcD0AIYcg4CDWg=; b=k7xyCEnZxlKiKgNq2HcY/Mrn2HmLeqA9CR4+OG28OW+hGmZodXlihfyra0oGn2HK/b jYhzjt1iEtig86+I2H/DKhXJy+4vyhjciP95x25CRsc/xVfl5hEZlkx0bJYyQwwGjbrG LEZo00IQIB0Eyy5wh7Ip9/gI+qixmXmSjyqBcYSOWp5BtVAHEoAyagk/aiGmNnsmt6et 0lkwf0sAtXfZfhnksLvdJAQt4NDnC5fWwsYGt0jEi080K1Cmv+PUF+BWNCKVubD/cOCz 5RIvZ2Hjmakh/EttZby4I/cOIZNyszw0uDLhbHhENjH0b1YFRlYQs73NZVMpbgbaSY83 Czxg== X-Gm-Message-State: AOAM530Wsl4fT2/yKqrBWORq6+ho6HkFKpXBASJndlRzQRGT+vrSahWq VxDrj4G2G0IbfVPqPHzT9aRGfnTyhKjz2PV+qfIf X-Google-Smtp-Source: ABdhPJy97k/uCbx6CjOrhsXKJtmjljacfy1qGYT4R+qrgPXqN+DQqG/xN8Jl5mhRS2KKa0ZWZzj3JvoQucqDWlc+mNo= X-Received: by 2002:a05:6402:18c1:: with SMTP id x1mr24603324edy.145.1627984255528; Tue, 03 Aug 2021 02:50:55 -0700 (PDT) MIME-Version: 1.0 References: <20210729073503.187-1-xieyongji@bytedance.com> <20210729073503.187-6-xieyongji@bytedance.com> <55191de0-1a03-ff0d-1a49-afc419014bab@redhat.com> In-Reply-To: <55191de0-1a03-ff0d-1a49-afc419014bab@redhat.com> From: Yongji Xie Date: Tue, 3 Aug 2021 17:50:44 +0800 Message-ID: Subject: Re: [PATCH v10 05/17] vhost-vdpa: Fail the vhost_vdpa_set_status() on reset failure To: Jason Wang Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=C3=A4?= , Dan Carpenter , joro@8bytes.org, Greg KH , He Zhe , Liu Xiaodong , Joe Perches , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Aug 3, 2021 at 4:10 PM Jason Wang wrote: > > > =E5=9C=A8 2021/7/29 =E4=B8=8B=E5=8D=883:34, Xie Yongji =E5=86=99=E9=81=93= : > > Re-read the device status to ensure it's set to zero during > > resetting. Otherwise, fail the vhost_vdpa_set_status() after timeout. > > > > Signed-off-by: Xie Yongji > > --- > > drivers/vhost/vdpa.c | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > index b07aa161f7ad..dd05c1e1133c 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -157,7 +157,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa= *v, u8 __user *statusp) > > struct vdpa_device *vdpa =3D v->vdpa; > > const struct vdpa_config_ops *ops =3D vdpa->config; > > u8 status, status_old; > > - int nvqs =3D v->nvqs; > > + int timeout =3D 0, nvqs =3D v->nvqs; > > u16 i; > > > > if (copy_from_user(&status, statusp, sizeof(status))) > > @@ -173,6 +173,15 @@ static long vhost_vdpa_set_status(struct vhost_vdp= a *v, u8 __user *statusp) > > return -EINVAL; > > > > ops->set_status(vdpa, status); > > + if (status =3D=3D 0) { > > + while (ops->get_status(vdpa)) { > > + timeout +=3D 20; > > + if (timeout > VDPA_RESET_TIMEOUT_MS) > > + return -EIO; > > + > > + msleep(20); > > + } > > > Spec has introduced the reset a one of the basic facility. And consider > we differ reset here. > > This makes me think if it's better to introduce a dedicated vdpa ops for > reset? > Do you mean replace the ops.set_status(vdev, 0) with the ops.reset()? Then we can remove the timeout processing which is device specific stuff. Thanks, Yongji