Received: by 10.192.165.148 with SMTP id m20csp1346426imm; Wed, 2 May 2018 19:59:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo4FQ+a09xkE80wXDGC2T2ALXyXK1AscLLB1k1cJY/HtrrowKc/HU3tJE/hrGK9LglRug1b X-Received: by 10.98.20.195 with SMTP id 186mr3957082pfu.92.1525316386411; Wed, 02 May 2018 19:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525316386; cv=none; d=google.com; s=arc-20160816; b=PPRIqvad8HGCfNEFCfdSw8+wVaFTpFxIpaauc82EHKozxO/3iAXFnoRRbV+AUbCJof 1GDwoaptguuE5Y+p2gED3V3XM0pMg1sDb2NTyQLqeckPM82fNjGO3qVTAi0JR0xpAyx9 iVddPzAxj+djnXg+zL9O9ZRh2tfhZY5y6/9XwcxVmNsU9HDYGT8bhIxvC6bex6E7jO9T oF1d0Ghzz21ePIQFiNROtARn/m0b9DQArZyatEAsroK/aVeIRQFMWP3tPK3mCq0CiLGY hEkm7qyQ3EhXyK4PicfT+Deqr+t2GZt4L/1xvl9nKk4tFDfm2TPQVTR3MALziF1/tNXM wiUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uX4IMxor2xsg7nZEILIljjLzvU5Q/JLcNba707enguk=; b=cvHZFmzmcdBn/qtUD8LJBfqYBA14AfGMrzCNUJ4D/XQuV8bwfB5uyDS/CTCBgR/lRW AEk8TcB2f2HHONGJtRtgqTPxnnYfpFCCpKbT8KMNMAjbqxL4spSGDaKYH6gEnwGeD/84 x3UPE8UuuvLtzII69jb0J6v8nTTAn/DWTMgD+Y9xCFHF6IYR1PfKUMLuzftQF52GvvAi f8xELN76xErlE+VxZpKAJbLHUfjuVxb33WHr8h/1idfnpS032QJnU6yU09yNGorxrobN yDuwmVK/YlnrUJLsXD3XNPKSoyy4yEVulppWq7/Iu3b5bT/JllHxybeE9ylf9NqLiI9n jSHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si10523259pgp.273.2018.05.02.19.59.32; Wed, 02 May 2018 19:59:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbeECC7T (ORCPT + 99 others); Wed, 2 May 2018 22:59:19 -0400 Received: from mga14.intel.com ([192.55.52.115]:63857 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbeECC7P (ORCPT ); Wed, 2 May 2018 22:59:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2018 19:59:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,356,1520924400"; d="scan'208";a="38273855" Received: from debian.sh.intel.com ([10.67.104.164]) by orsmga008.jf.intel.com with ESMTP; 02 May 2018 19:59:12 -0700 From: Tiwei Bie To: mst@redhat.com, jasowang@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 Subject: [RFC] virtio: support VIRTIO_F_IO_BARRIER Date: Thu, 3 May 2018 10:59:55 +0800 Message-Id: <20180503025955.28816-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.11.0