Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8985315rwp; Wed, 19 Jul 2023 19:59:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFUVYr38phLUEsUBCmLgIzRBZu8GFvi83jONe9Mfr0gbgcaHfyqqgxXI5QbqnVBQVXgBF9W X-Received: by 2002:a17:906:7c3:b0:98e:933:28fe with SMTP id m3-20020a17090607c300b0098e093328femr1034003ejc.66.1689821981344; Wed, 19 Jul 2023 19:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689821981; cv=none; d=google.com; s=arc-20160816; b=CANSuYkmp7RQpj1GMdPxvPTAEW1+zsPqZgFivadhbf2d1WdfYPtdMLOXdSJFSlBZnb IhNSxRvmpb+HdVYCgfVxiwk7TITQDq4ziM5RrKMyeoeVNTf2XBn/w80K9UxFnmXlqdcl nV7dC54azwqsUpoOhIzsDzhEIaS8A/D9B+PvMQOTCSyG5qg7TsVB5q+KqA7yTIFD5WtP bASsKOZiDHfObK1Bx/U5RR5QEMNFa7D1NwprTg51NGZWpFJ2X1gsQ1txIVo0gc7X2BGs IHOEs0gc44/G/aNUgEYOMgGhKYRPJwa05EBfOADKyIE/1JH9rk5jxhqs3QeW5LVwF6hn FD/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from:date:subject :message-id; bh=ngi61uJ8tDdKYyBiCT9eojtTv9nm7kMikxD0B2Rc+C8=; fh=eT5imPoFdojrZ89B6X4vfpYrwtW4g3poD7H+7YuT9kw=; b=l5Pyegvb6jTkYHdrzH+z0AZzMp/hxXfIzHwuzSpzy60hL5cHN+HipXRU8JiIBhk9i0 gtx7L+tsO36NdHYHcumSbsLfWT84W0uTJEKPm9ehDfaO018LIaoThpS3YXLR3IQW5v07 MDjsB5Zl61ebQf3WveBFvHK7NEhIL5UF6qA0yKVf4ACZD+SJf3JSx8C37EQ0u+A6lnMc iI/sQ2ruDsVbg75zH4NNYNCFlBwXqMe1LTWAo5YUXlZr15CdtEcxLt/BbVGAFr1c9fBX pVXymQSjxvkuyDOwAgXxzfZPSlnc6rAUmhlfLdOaVrE+8dUEzmKfI759VcXrkaxSG7ZU xcaQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a170906941900b009886d385534si3861583ejx.950.2023.07.19.19.59.17; Wed, 19 Jul 2023 19:59:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjGTCGr (ORCPT + 99 others); Wed, 19 Jul 2023 22:06:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjGTCGq (ORCPT ); Wed, 19 Jul 2023 22:06:46 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DCA1FF9 for ; Wed, 19 Jul 2023 19:06:44 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vnnt3WB_1689818801; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0Vnnt3WB_1689818801) by smtp.aliyun-inc.com; Thu, 20 Jul 2023 10:06:42 +0800 Message-ID: <1689818793.8129647-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH v1] virtio-pci: Fix legacy device flag setting error in probe Date: Thu, 20 Jul 2023 10:06:33 +0800 From: Xuan Zhuo To: Feng Liu Cc: Jason Wang , "Michael S . Tsirkin" , Bodong Wang , Feng Liu , Parav Pandit , Jiri Pirko , , References: <20230719154550.79536-1-feliu@nvidia.com> In-Reply-To: <20230719154550.79536-1-feliu@nvidia.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 Wed, 19 Jul 2023 11:45:50 -0400, Feng Liu wrote: > The 'is_legacy' flag is used to differentiate between legacy vs modern > device. Currently, it is based on the value of vp_dev->ldev.ioaddr. > However, due to the shared memory of the union between struct > virtio_pci_legacy_device and struct virtio_pci_modern_device, when > virtio_pci_modern_probe modifies the content of struct > virtio_pci_modern_device, it affects the content of struct > virtio_pci_legacy_device, and ldev.ioaddr is no longer zero, causing > the 'is_legacy' flag to be set as true. To resolve issue, when legacy > device is probed, mark 'is_legacy' as true, when modern device is > probed, keep 'is_legacy' as false. > > Fixes: 4f0fc22534e3 ("virtio_pci: Optimize virtio_pci_device structure size") > Signed-off-by: Feng Liu > Reviewed-by: Parav Pandit > Reviewed-by: Jiri Pirko Reviewed-by: Xuan Zhuo > --- > drivers/virtio/virtio_pci_common.c | 2 -- > drivers/virtio/virtio_pci_legacy.c | 1 + > 2 files changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c > index a6c86f916dbd..c2524a7207cf 100644 > --- a/drivers/virtio/virtio_pci_common.c > +++ b/drivers/virtio/virtio_pci_common.c > @@ -557,8 +557,6 @@ static int virtio_pci_probe(struct pci_dev *pci_dev, > > pci_set_master(pci_dev); > > - vp_dev->is_legacy = vp_dev->ldev.ioaddr ? true : false; > - > rc = register_virtio_device(&vp_dev->vdev); > reg_dev = vp_dev; > if (rc) > diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c > index 2257f1b3d8ae..d9cbb02b35a1 100644 > --- a/drivers/virtio/virtio_pci_legacy.c > +++ b/drivers/virtio/virtio_pci_legacy.c > @@ -223,6 +223,7 @@ int virtio_pci_legacy_probe(struct virtio_pci_device *vp_dev) > vp_dev->config_vector = vp_config_vector; > vp_dev->setup_vq = setup_vq; > vp_dev->del_vq = del_vq; > + vp_dev->is_legacy = true; > > return 0; > } > -- > 2.37.1 (Apple Git-137.1) >