Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp244038rdb; Mon, 22 Jan 2024 02:48:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcOFhL/jVo7KYrea6qu4C/ZduxUp2PJvTUCrNE745iVwApugNTByOBFNLsHPF0sA9wYkFy X-Received: by 2002:a17:906:d8c5:b0:a2e:cac9:97ca with SMTP id re5-20020a170906d8c500b00a2ecac997camr2065023ejb.85.1705920494951; Mon, 22 Jan 2024 02:48:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705920494; cv=pass; d=google.com; s=arc-20160816; b=jfmJVMvEgxH/dmGSk+LT1QZDYhgfIwDjnER4uX9nDGjeCc/X0h1+yYwfZIbTFo+yYi XW84lnkjq8nWI8V9VVb03hBuriYfXwVgM7QMLCBYr7lEe7ZjcgOZOfnHmJnJGTe/IWv0 qj39wtKt2BWR/+GX6kzjAEyBQi63fQmbsEqlyTAyke+IDU6lsAtGgK/mAp8mhIhl9xCs yYyPG2+HFJ4MpQiBOQvWumQAv4qjrNdjCDMoM35mjL/wIg44LhUQ8yizDYTHO4cFWZvL 190iyNOKR0yWWe1bxeOkEgkvQYY2puzKfxbsjQErhB6i1tTaGWJuLYgMdp6MLHFEOWXk LWSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=SAQacrX86fqUD9K4Yvf7W+7v6QcN6oGZap2bo4/kXUo=; fh=IK1PXCu2rzGoydYSkOQmRFGoIanQfdiuFm45GhLOfaE=; b=d/GuiU/KUzEiRzRQM0pvF9lG7S5oJCnXTrc4pBoJ8LEdaW8MTTz7qBV6TanGJ8OAqG +8hk2oytFKB448jQweijflQh6eGegzOumoFlKnErAgfOCEjwDHCkx1uFzhaOxn52Ojts esDYzTp6tStQzR95l8+hb3QjoA201P4BX+UMRql0AjcgveA3KTiSNJMYtr5301QZVMjY Qt0atq+Cbcmj0X2lXNLTHxtV2LHgd4XjZp+du1Wa8iO5a4mfcRCilG++VKzfCZ8iJU0E mRP7acMrqK8VBSV86JloLbH+L8wSZ9cYK+mGWmy2aTkc2wWDZDFAGCts+2bEKcQBwBvC Et6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IlnEHFP5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-32783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i8-20020a170906250800b00a2ef0f42ab5si4886209ejb.348.2024.01.22.02.48.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:48:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IlnEHFP5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-32783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B26E81F2203D for ; Mon, 22 Jan 2024 10:48:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0FAD3A1DC; Mon, 22 Jan 2024 10:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IlnEHFP5" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8CB021362 for ; Mon, 22 Jan 2024 10:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705920485; cv=none; b=m5jOptErBo/KDyZVxReeDnS/MnwqOhEOYxft/lTrNiKrHK81uePj0kzBcM3MQwQlH63s1rrtV3Ew/H69kNeEzIXHxPihdnvPXIUo2DyAV3hY0e5koD0LzYZTV366OTQpVjo1UVhd04+bMvICAcbFmSRdjzDyT80o0BFIy6jDEXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705920485; c=relaxed/simple; bh=UMEPrzsFfMwcLb6gpEQxDtl8Y3dVJdxWPuxxS76bS/E=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=C/+FAgqPb/NfOo+wLh4ibOfhZ5tKmKAcIbxphpahMRQw5nEIYR05GSX/3F/Bk+3xAgideJn27Ex2evOCUPnQON0evzKHMt3crvJ10EAHT0x43yJQqZI49jeXF/2WzyaXeFh2lkN/CNwD9tpXr3Kk0aHie0Ji5EKCqSs2KhFzSgo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IlnEHFP5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705920482; 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=SAQacrX86fqUD9K4Yvf7W+7v6QcN6oGZap2bo4/kXUo=; b=IlnEHFP5obKsWJLjfj6TjV1OmZg5Dq4lx8slAphgF8HPCWMR98o3glL5hZdNEuM/K7SlDB LLEFA95XYkpeB2JDvlDAxwV7VYttDDVwxJtWp1YtU4IdH+CsTE9v2B4u4JDHX4SPFt1Ohe AP9RhuwOcn0Gc6ZQlaMMDeI42r6N8QE= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-303-Rtdmxc_aPIiYyu3HbYW08g-1; Mon, 22 Jan 2024 05:47:59 -0500 X-MC-Unique: Rtdmxc_aPIiYyu3HbYW08g-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-5ffc7ce3343so15606737b3.1 for ; Mon, 22 Jan 2024 02:47:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705920479; x=1706525279; 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=SAQacrX86fqUD9K4Yvf7W+7v6QcN6oGZap2bo4/kXUo=; b=p6a/UsFny0u4zowilHMt/o+HueI2wSdM/F1r+GZhkMwsX9QGbmAaYOuI+A2yTCxwSN ghcNpqjA31Qmn736gT+rGxsPNiDPzSriCr0JMs+gA21iTC02AE7phYYFobrHJeENdxPL uPC+oebLmeqJ7C30Q0G/Kjw7JWjaBaTpe4BBoq+tLfsKSWuc1zlowZKVODVrk5QiivSH M3j7JGUko5lViWCpx3YV9tOk64JkSaYns9vqqMkEzmpqi1SlFXqTdDPXzNoqEEQ/BYq/ 7IBEnqLinhUPYOWdUEqdY8pR4iIK6F/1noF+imOyMLHzjJkp09ZRFOEIt++JfkhNdYcq 2xFQ== X-Gm-Message-State: AOJu0YzIaqp/9FZCqIW90yEFodSgT/SlTlv3gxEl72RJ+iRiFCaeJk0W OfouCDZqQjohmeh657HQI1aJqCUvvRwFimA6fgbraDXYJVlX0ucPAVjuywoH/wWI5VYpu5Ar+he R30heca8oFBfVMSivh4A1SVlSsFjJ3tnkf2ofLU4jK7/fuKMhMvF7712zL27o8BH77uIm7lGDsw 3exovNQQx0PZBH6jdMKsu29OY8xh9lQRt6P4SI X-Received: by 2002:a0d:dbd5:0:b0:5ff:956d:8b7f with SMTP id d204-20020a0ddbd5000000b005ff956d8b7fmr3052786ywe.10.1705920479006; Mon, 22 Jan 2024 02:47:59 -0800 (PST) X-Received: by 2002:a0d:dbd5:0:b0:5ff:956d:8b7f with SMTP id d204-20020a0ddbd5000000b005ff956d8b7fmr3052778ywe.10.1705920478772; Mon, 22 Jan 2024 02:47:58 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1705519403-255169-1-git-send-email-steven.sistare@oracle.com> In-Reply-To: From: Eugenio Perez Martin Date: Mon, 22 Jan 2024 11:47:22 +0100 Message-ID: Subject: Re: [PATCH V1] vdpa_sim: reset must not run To: Stefano Garzarella Cc: Steve Sistare , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Si-Wei Liu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 22, 2024 at 11:22=E2=80=AFAM Stefano Garzarella wrote: > > On Wed, Jan 17, 2024 at 11:23:23AM -0800, Steve Sistare wrote: > >vdpasim_do_reset sets running to true, which is wrong, as it allows > >vdpasim_kick_vq to post work requests before the device has been > >configured. To fix, do not set running until VIRTIO_CONFIG_S_FEATURES_O= K > >is set. > > > >Fixes: 0c89e2a3a9d0 ("vdpa_sim: Implement suspend vdpa op") > >Signed-off-by: Steve Sistare > >Reviewed-by: Eugenio P=C3=A9rez > >--- > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > >diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vd= pa_sim.c > >index be2925d0d283..6304cb0b4770 100644 > >--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > >+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > >@@ -160,7 +160,7 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim= , u32 flags) > > } > > } > > > >- vdpasim->running =3D true; > >+ vdpasim->running =3D false; > > spin_unlock(&vdpasim->iommu_lock); > > > > vdpasim->features =3D 0; > >@@ -483,6 +483,7 @@ static void vdpasim_set_status(struct vdpa_device *v= dpa, u8 status) > > > > mutex_lock(&vdpasim->mutex); > > vdpasim->status =3D status; > >+ vdpasim->running =3D (status & VIRTIO_CONFIG_S_FEATURES_OK) !=3D = 0; > > mutex_unlock(&vdpasim->mutex); > > Should we do something similar also in vdpasim_resume() ? > > I mean something like this: > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdp= a_sim.c > index be2925d0d283..55e4633d5442 100644 > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > @@ -520,7 +520,7 @@ static int vdpasim_resume(struct vdpa_device *vdpa) > int i; > > mutex_lock(&vdpasim->mutex); > - vdpasim->running =3D true; > + vdpasim->running =3D (vdpasim->status & VIRTIO_CONFIG_S_FEATURES_= OK) !=3D 0; > > if (vdpasim->pending_kick) { > /* Process pending descriptors */ > > Thanks, > Stefano > The suspend and resume operation should not be called before DRIVER_OK, so maybe we should add that protection at drivers/vhost/vdpa.c actually? Thanks!