From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751115AbeECHaQ (ORCPT ); Thu, 3 May 2018 03:30:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47266 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750781AbeECHaL (ORCPT ); Thu, 3 May 2018 03:30:11 -0400 Subject: Re: [RFC] virtio: support VIRTIO_F_IO_BARRIER To: Tiwei Bie , mst@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: dan.daly@intel.com, cunming.liang@intel.com, zhihong.wang@intel.com References: <20180503025955.28816-1-tiwei.bie@intel.com> From: Jason Wang Message-ID: Date: Thu, 3 May 2018 15:30:03 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180503025955.28816-1-tiwei.bie@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年05月03日 10:59, Tiwei Bie wrote: > This patch introduces the support for VIRTIO_F_IO_BARRIER. > When this feature is negotiated, driver will use the barriers > suitable for hardware devices. > > Signed-off-by: Tiwei Bie > --- > drivers/virtio/virtio_ring.c | 5 +++++ > include/uapi/linux/virtio_config.h | 8 +++++++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 21d464a29cf8..edb565643bf4 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -996,6 +996,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, > !context; > vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX); > > + if (virtio_has_feature(vdev, VIRTIO_F_IO_BARRIER)) > + vq->weak_barriers = false; > + > /* No callback? Tell other side not to bother us. */ > if (!callback) { > vq->avail_flags_shadow |= VRING_AVAIL_F_NO_INTERRUPT; > @@ -1164,6 +1167,8 @@ void vring_transport_features(struct virtio_device *vdev) > break; > case VIRTIO_F_IOMMU_PLATFORM: > break; > + case VIRTIO_F_IO_BARRIER: > + break; > default: > /* We don't understand this bit. */ > __virtio_clear_bit(vdev, i); > diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h > index 308e2096291f..6ca8d24bf468 100644 > --- a/include/uapi/linux/virtio_config.h > +++ b/include/uapi/linux/virtio_config.h > @@ -49,7 +49,7 @@ > * transport being used (eg. virtio_ring), the rest are per-device feature > * bits. */ > #define VIRTIO_TRANSPORT_F_START 28 > -#define VIRTIO_TRANSPORT_F_END 34 > +#define VIRTIO_TRANSPORT_F_END 38 > > #ifndef VIRTIO_CONFIG_NO_LEGACY > /* Do we get callbacks when the ring is completely used, even if we've > @@ -71,4 +71,10 @@ > * this is for compatibility with legacy systems. > */ > #define VIRTIO_F_IOMMU_PLATFORM 33 > + > +/* > + * If clear - driver may use barriers suitable for CPU cores. > + * If set - driver must use barriers suitable for hardware devices. > + */ > +#define VIRTIO_F_IO_BARRIER 37 > #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ Hi: I believe this depends on Michael's patch of "[PATCH] virtio_ring: switch to dma_XX barriers for rpmsg" ? Thanks