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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44609CCA47F for ; Fri, 1 Jul 2022 09:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236385AbiGAJjw (ORCPT ); Fri, 1 Jul 2022 05:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234776AbiGAJjv (ORCPT ); Fri, 1 Jul 2022 05:39:51 -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 ESMTP id E6CE630F67 for ; Fri, 1 Jul 2022 02:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656668390; 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=1d79Stpus0q2yxaNU7MJkY6xfoyQBkCSEyRGquJaFl4=; b=Jjs7+iDfQTV9H9OOI6ArA2W59gJHqcpJNxNrK/Wn+58RDSrSaYho2TfU1w0V3iOlQT8X1j GeJbu114UDr4Dno2lmwrxyEuYDceOUn8O56S0IlDsa5PWJ6i+HZv6/fI/Zp3eQ24LCrUjA g+I6UMRkXzYstwz30XseA4eQuVa8an8= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-0KaA4s6zPBeK8gSm3VvLmA-1; Fri, 01 Jul 2022 05:39:48 -0400 X-MC-Unique: 0KaA4s6zPBeK8gSm3VvLmA-1 Received: by mail-pj1-f70.google.com with SMTP id e17-20020a17090ac21100b001ef367cb6a6so1122167pjt.8 for ; Fri, 01 Jul 2022 02:39:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=1d79Stpus0q2yxaNU7MJkY6xfoyQBkCSEyRGquJaFl4=; b=KvPERdS5rzSW1jZw7tNp6WJmGPNgb13mu1CSIXCogwpMk/TJec+Jj+RTCdT/3vPr7y lu/QSt3JeQJGaR1DWOgEfe6Am+/WZgfWVEo9ztlQG1R/1glAUxMXbW6u0CWdAgNQ48a5 5E++RpFddGD6pDNSvAw6gphCE0gOCRFta02ADpaWzxiF8UfD+OewBixh7ujMkfAtWYt0 odGyHdjhWHLNegyHPdL++a9O/ufET4pjHdKC/EGPQdkYmnC9hQNbjhYrCVd7rQaGQDgL JZTVDH+FZ2HXcUGlcjtRtmkXTcthG8gQ0nS2LvFaiYRzwsjqEmsyKeUX854Yxq7as8PU mQAA== X-Gm-Message-State: AJIora8E3W72jI3WJ1MXiEscfaC4Ugp1SDJfDlj5hNUK55AZSLEJbSUg lZc3mnboQgjhQ+Wf5qkQP3dpKIl2cQU+ViOzu4KZVGMt02/Yr5HdxDlaJF5KtJmIESZAFU9RZD2 j7Qi9ldxz3qMPC5D0P9l7q80TADwC4ZGPWw== X-Received: by 2002:a63:454a:0:b0:411:bbff:b079 with SMTP id u10-20020a63454a000000b00411bbffb079mr4669447pgk.507.1656668387165; Fri, 01 Jul 2022 02:39:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uQXl0Mg32c6PANnbBYsi+TCYur6T2X1Z6vqtoZHDXDxtmKbFKHms2mPc6lxJgdRzWP3sExWg== X-Received: by 2002:a63:454a:0:b0:411:bbff:b079 with SMTP id u10-20020a63454a000000b00411bbffb079mr4669428pgk.507.1656668386921; Fri, 01 Jul 2022 02:39:46 -0700 (PDT) Received: from [10.72.13.237] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id jy18-20020a17090b325200b001e31803540fsm6079692pjb.6.2022.07.01.02.39.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Jul 2022 02:39:46 -0700 (PDT) Message-ID: <494bcf3f-d42c-f05b-cbdb-d4ba834bd118@redhat.com> Date: Fri, 1 Jul 2022 17:39:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v11 28/40] virtio_pci: introduce helper to get/set queue reset Content-Language: en-US To: Xuan Zhuo , virtualization@lists.linux-foundation.org Cc: Richard Weinberger , Anton Ivanov , Johannes Berg , "Michael S. Tsirkin" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hans de Goede , Mark Gross , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , Cornelia Huck , Halil Pasic , Eric Farman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Vincent Whitchurch , linux-um@lists.infradead.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, bpf@vger.kernel.org, kangjie.xu@linux.alibaba.com References: <20220629065656.54420-1-xuanzhuo@linux.alibaba.com> <20220629065656.54420-29-xuanzhuo@linux.alibaba.com> From: Jason Wang In-Reply-To: <20220629065656.54420-29-xuanzhuo@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 在 2022/6/29 14:56, Xuan Zhuo 写道: > Introduce new helpers to implement queue reset and get queue reset > status. > > https://github.com/oasis-tcs/virtio-spec/issues/124 > https://github.com/oasis-tcs/virtio-spec/issues/139 > > Signed-off-by: Xuan Zhuo Acked-by: Jason Wang > --- > drivers/virtio/virtio_pci_modern_dev.c | 35 ++++++++++++++++++++++++++ > include/linux/virtio_pci_modern.h | 2 ++ > 2 files changed, 37 insertions(+) > > diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c > index fa2a9445bb18..07415654247c 100644 > --- a/drivers/virtio/virtio_pci_modern_dev.c > +++ b/drivers/virtio/virtio_pci_modern_dev.c > @@ -3,6 +3,7 @@ > #include > #include > #include > +#include > > /* > * vp_modern_map_capability - map a part of virtio pci capability > @@ -474,6 +475,40 @@ void vp_modern_set_status(struct virtio_pci_modern_device *mdev, > } > EXPORT_SYMBOL_GPL(vp_modern_set_status); > > +/* > + * vp_modern_get_queue_reset - get the queue reset status > + * @mdev: the modern virtio-pci device > + * @index: queue index > + */ > +int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) > +{ > + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; > + > + vp_iowrite16(index, &cfg->queue_select); > + return vp_ioread16(&cfg->queue_reset); > +} > +EXPORT_SYMBOL_GPL(vp_modern_get_queue_reset); > + > +/* > + * vp_modern_set_queue_reset - reset the queue > + * @mdev: the modern virtio-pci device > + * @index: queue index > + */ > +void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) > +{ > + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; > + > + vp_iowrite16(index, &cfg->queue_select); > + vp_iowrite16(1, &cfg->queue_reset); > + > + while (vp_ioread16(&cfg->queue_reset)) > + msleep(1); > + > + while (vp_ioread16(&cfg->queue_enable)) > + msleep(1); > +} > +EXPORT_SYMBOL_GPL(vp_modern_set_queue_reset); > + > /* > * vp_modern_queue_vector - set the MSIX vector for a specific virtqueue > * @mdev: the modern virtio-pci device > diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci_modern.h > index beebc7a4a31d..ded01157f864 100644 > --- a/include/linux/virtio_pci_modern.h > +++ b/include/linux/virtio_pci_modern.h > @@ -134,4 +134,6 @@ void __iomem * vp_modern_map_vq_notify(struct virtio_pci_modern_device *mdev, > u16 index, resource_size_t *pa); > int vp_modern_probe(struct virtio_pci_modern_device *mdev); > void vp_modern_remove(struct virtio_pci_modern_device *mdev); > +int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index); > +void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index); > #endif