Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5291582rwl; Tue, 11 Apr 2023 03:22:43 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqgVkyD5XKTzf3/38ty788m/jYbzbFzOb1innSgJ190Ms/AGBddQoreG8hZto6iHyAq53o X-Received: by 2002:a17:906:c1d8:b0:8a0:7158:15dc with SMTP id bw24-20020a170906c1d800b008a0715815dcmr9644907ejb.74.1681208563121; Tue, 11 Apr 2023 03:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681208563; cv=none; d=google.com; s=arc-20160816; b=dEX0TopACLoTNPa38jXx5eDRHpxYa++34hdD+8OnfjXjlrOjuS+FuqguP6du6LfNvn oJ2JkxLvIRRX3ZjuyeVO3G/CsB8ldoXS2PRX41DFxoObxb0o9rjGOW98HN1glC0hl68V Pnhd5yG+xO/wWgXC05TtSn9RYQ+64FuxNrR4A0eXGZv2j8hsaUR8txtr6h0jXpzoUq9w QiSSU9nlRZumlc04l2pqF1eFFACpNUBHcH2DNW0hYMvM+MMue5aRGBbzBKlg9yRjtQM+ dzhMVLwpttN3cdMtrxM44QqtLCaZSc3O5ZuC+d2SJxXx37VB+j9YL7ltoUp2F+vaoLlk D/XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KP9DSVci9yH230xXuxpWDJ94bVH6AIL4+Sc2quvSh70=; b=ZWpFowmxTcM9VKHvh8sUWFaO5sTKwsyHdOfUE7nPQgfNd5zd5m/xP/M8umY/6mrHFz s6D0xuRet8alKL7eYckU8Ihphy8WeFUC8Vhb3cWlEF2+cDvJ5qfgncrkwNLepgOCtdAg Wk9zXGMEXRmSTlx3vAvQ/8+22zaNAvNj65qYLORr9/rTenxjl1G51Ip+EirKkVjZE0PY RPsbqYCbN6JwM69HiE43HqMyDqOwLwFBtQHWJP/TZE5KWdygeqpdOGL2KKi1b60x8CLp yROsQ/f0T2ub207E0hYDyTyudLKR2H+vm40T5cimSXgpycC3xT/WW5J0VrmE0MIWD772 us2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=be4PBgOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk27-20020a170906d9db00b0094a834a770asi4331108ejb.889.2023.04.11.03.22.19; Tue, 11 Apr 2023 03:22:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=be4PBgOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjDKKQm (ORCPT + 99 others); Tue, 11 Apr 2023 06:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjDKKQk (ORCPT ); Tue, 11 Apr 2023 06:16:40 -0400 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 0DE67C9 for ; Tue, 11 Apr 2023 03:15:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681208154; 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=KP9DSVci9yH230xXuxpWDJ94bVH6AIL4+Sc2quvSh70=; b=be4PBgOO7hktru7BOEwl+XLc2nKfaE+6c+NJ+9M3BaEFrJYOShAS4qiCq/IXkxZFjUyPIe XdSY0bNIvIv1a5ZhGmABmMMK+L0lCTzrAh+3q//2xWN60xTKuMdOR/9zw8axB0NsdP83Pk H//DlUip+TjQV+PWIsQs5zY2wivAiV4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-eL8fKPqBPnKMuRB28Ab8Ww-1; Tue, 11 Apr 2023 06:15:53 -0400 X-MC-Unique: eL8fKPqBPnKMuRB28Ab8Ww-1 Received: by mail-wm1-f72.google.com with SMTP id h8-20020a05600c314800b003ef649aa8c7so1173702wmo.6 for ; Tue, 11 Apr 2023 03:15:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681208152; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KP9DSVci9yH230xXuxpWDJ94bVH6AIL4+Sc2quvSh70=; b=8GYbteq26Kav5m3NlQ9LoXxamQHZB1ahhQTMr3dGHq6rVvwsm+7dg8fSa7jLNuTq0r //C1MNd/PeF0ad1yXIBnDBcS/oVm4cG9PuCyv8WN6CZqbrQ0ZwMNvnU71Dg2QApsw6U8 AZvkVkBKE0sip4HpQ7+LOUgt6yJ3o6zrGev8yyAgBSx8pNT1xbIjuJ9AlB7uUzuzeNKX 6nSCTiR+2JTrfybwZeGz/IWxZqMV/1wA0qToFS6sd0V3IuVqtO1/kX4cnJTUlWcOBGmI QlCHLiEmaTsT6wM/H3Eeig9N8dAla/Dp7VOo6R6/COTVtrLZy0Y1gy9rWTbvdsiR9E/C gQBw== X-Gm-Message-State: AAQBX9c2IoBUb1Kf8dU0huOY4G/4ukQCRvqnwfK79BJNNpeg/5ZmpQLH OmU2BR5Qf0pZt4AK8mygIz/vzZJEm3Frt9Nx9tT9JDH7ik/8uiXQRwxSQwAf+iNHhbi23g6SK6s jNrb6cCm+1PT8NvjJDHk7OFpA X-Received: by 2002:a7b:c302:0:b0:3ea:d620:570a with SMTP id k2-20020a7bc302000000b003ead620570amr9708229wmj.38.1681208151998; Tue, 11 Apr 2023 03:15:51 -0700 (PDT) X-Received: by 2002:a7b:c302:0:b0:3ea:d620:570a with SMTP id k2-20020a7bc302000000b003ead620570amr9708214wmj.38.1681208151687; Tue, 11 Apr 2023 03:15:51 -0700 (PDT) Received: from redhat.com ([2.52.10.80]) by smtp.gmail.com with ESMTPSA id u11-20020a05600c19cb00b003ede3f5c81fsm20746541wmq.41.2023.04.11.03.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 03:15:51 -0700 (PDT) Date: Tue, 11 Apr 2023 06:15:48 -0400 From: "Michael S. Tsirkin" To: Angus Chen Cc: Jason Wang , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset Message-ID: <20230411061409-mutt-send-email-mst@kernel.org> References: <20230411013833.1305-1-angus.chen@jaguarmicro.com> <20230411024459-mutt-send-email-mst@kernel.org> <20230411025335-mutt-send-email-mst@kernel.org> <20230411032014-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 11, 2023 at 07:30:48AM +0000, Angus Chen wrote: > > > > -----Original Message----- > > From: Michael S. Tsirkin > > Sent: Tuesday, April 11, 2023 3:21 PM > > To: Angus Chen > > Cc: Jason Wang ; > > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org > > Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset > > > > On Tue, Apr 11, 2023 at 07:17:14AM +0000, Angus Chen wrote: > > > > > > > > > > -----Original Message----- > > > > From: Michael S. Tsirkin > > > > Sent: Tuesday, April 11, 2023 2:56 PM > > > > To: Angus Chen > > > > Cc: Jason Wang ; > > > > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org > > > > Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset > > > > > > > > On Tue, Apr 11, 2023 at 06:49:03AM +0000, Angus Chen wrote: > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Michael S. Tsirkin > > > > > > Sent: Tuesday, April 11, 2023 2:47 PM > > > > > > To: Angus Chen > > > > > > Cc: Jason Wang ; > > > > > > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org > > > > > > Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset > > > > > > > > > > > > On Tue, Apr 11, 2023 at 06:36:39AM +0000, Angus Chen wrote: > > > > > > > Hi. > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Jason Wang > > > > > > > > Sent: Tuesday, April 11, 2023 1:24 PM > > > > > > > > To: Angus Chen > > > > > > > > Cc: mst@redhat.com; virtualization@lists.linux-foundation.org; > > > > > > > > linux-kernel@vger.kernel.org > > > > > > > > Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset > > > > > > > > > > > > > > > > On Tue, Apr 11, 2023 at 9:39 AM Angus Chen > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > We read the status of device after reset, > > > > > > > > > It is not guaranteed that the device be reseted successfully. > > > > > > > > > We can use a while loop to make sure that,like the modern device > > did. > > > > > > > > > The spec is not request it ,but it work. > > > > > > > > > > > > > > > > The only concern is if it's too late to do this. > > > > > > > > > > > > > > > > Btw, any reason you want to have a legacy hardware implementation. > > It > > > > > > > > will be very tricky to work correctly. > > > > > > > En,I found this in the real production environment some times about > > > > one > > > > > > year ago. > > > > > > > and I fix this out of tree.our virtio card had been sold about thousands . > > > > > > > > > > > > > > Now,we created a new card, it support virtio 0.95,1.0,1.1 etc. > > > > > > > > > > > > I am not 100% sure what does this mean. > > > > > > So it's a transitional device then? > > > > > Hi mst,it is a real card in the In cloud computing ,not transitional device. > > > > > > > > yes, a real card. But you said it supports 0.95, 1.0 and 1.1 guests, > > > > so this is what the virtio spec calls a transitional device, right? > > > > > > > > To simplify transition from these earlier draft interfaces, > > > > a device MAY implement: > > > > > > > > \begin{description} > > > > \item[Transitional Device] > > > > a device supporting both drivers conforming to this > > > > specification, and allowing legacy drivers. > > > > \end{description} > > > > > > > > or did I misunderstand? > > > > > > > Yes, I'm not sure whether I make myself clear. > > > We support the vritio spec 0.95, 1.0 and 1.1 in the same card. > > > And the numer of devices is 1k per one card. > > > > > > Btw, thanks a lot for the work of redhat, we just Implement the virtio protocol > > by hardware. > > > > Yes, not very clear still. What are the device and vendor ID of the > > card? Does it have the virtio capabilities? > > Thanks > It's have the virtio capabilities. > When it is used in bare metal , > it just use PCI_VENDOR_ID_REDHAT_QUMRANET. > When it use in vm, > It is just like : > { PCI_DEVICE_SUB(PCI_VENDOR_ID_REDHAT_QUMRANET, > VIRTIO_TRANS_ID_NET, > PCI_VENDOR_ID_JAGUARMICRO, > VIRTIO_ID_NET) }, > { PCI_DEVICE_SUB(PCI_VENDOR_ID_REDHAT_QUMRANET, > VIRTIO_TRANS_ID_BLOCK, > PCI_VENDOR_ID_JAGUARMICRO, > VIRTIO_ID_BLOCK) }, > Okay. So it's a transitional device. The question, then, is how come you end up with drivers/virtio/virtio_pci_legacy.c with a modern linux at all? Did you by chance set force_legacy = true ? > > > > > > > > > > > > > > > > > > > > > > > > > And we use this host vdpa+ legacy virtio in vm to hot migration,we > > > > found > > > > > > that the > > > > > > > Legacy model often get the middle state value after reset and probe > > > > again. > > > > > > > The Soc is Simulated by fpga which is run slower than the host,so the > > > > same > > > > > > bug > > > > > > > Is found more frequently when the host use the other kernel like > > > > ubuntu or > > > > > > centos8. > > > > > > > > > > > > > > So we hope we can fix this by upstream . > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: Angus Chen > > > > > > > > > --- > > > > > > > > > drivers/virtio/virtio_pci_legacy.c | 4 +++- > > > > > > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > > > > > diff --git a/drivers/virtio/virtio_pci_legacy.c > > > > > > b/drivers/virtio/virtio_pci_legacy.c > > > > > > > > > index 2257f1b3d8ae..f2d241563e4f 100644 > > > > > > > > > --- a/drivers/virtio/virtio_pci_legacy.c > > > > > > > > > +++ b/drivers/virtio/virtio_pci_legacy.c > > > > > > > > > @@ -14,6 +14,7 @@ > > > > > > > > > * Michael S. Tsirkin > > > > > > > > > */ > > > > > > > > > > > > > > > > > > +#include > > > > > > > > > #include "linux/virtio_pci_legacy.h" > > > > > > > > > #include "virtio_pci_common.h" > > > > > > > > > > > > > > > > > > @@ -97,7 +98,8 @@ static void vp_reset(struct virtio_device > > *vdev) > > > > > > > > > vp_legacy_set_status(&vp_dev->ldev, 0); > > > > > > > > > /* Flush out the status write, and flush in device writes, > > > > > > > > > * including MSi-X interrupts, if any. */ > > > > > > > > > - vp_legacy_get_status(&vp_dev->ldev); > > > > > > > > > + while (vp_legacy_get_status(&vp_dev->ldev)) > > > > > > > > > + msleep(1); > > > > > > > > > /* Flush pending VQ/configuration callbacks. */ > > > > > > > > > vp_synchronize_vectors(vdev); > > > > > > > > > } > > > > > > > > > -- > > > > > > > > > 2.25.1 > > > > > > > > > > > > > > > > > > > > > > > > >