Received: by 10.192.165.148 with SMTP id m20csp345616imm; Thu, 3 May 2018 21:59:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQWqN8oIaoI5+V++P1k1jNiiJQFMbGJ9ppR6oP7HlIH9657a+c/nm5C7ohyI7wwu16lckM X-Received: by 10.167.129.204 with SMTP id c12mr12971775pfn.169.1525409942746; Thu, 03 May 2018 21:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525409942; cv=none; d=google.com; s=arc-20160816; b=lKXsvP7wDpt62/hk9CGQ2vBfoAysWAj83z1ywmexrdoYNS14YZVD8gDMx9foIusoD6 7FZ3P08eSMqtf6jGLCLxzt9A1ciJEPfXxiBFjfcEqeBGEiB8IZyFDNwwU3TUhPtnWA7/ cmpV+2zn1axytn456SnKjZAc9q2VEg9/EBzLb64NNp/CBSIQtRhmeo+yNLy+4yBvKkxm r2NSorqv6hVlkV9QqlY5bIKLYR51PLNuEy/zaytghdDkGn5qCQ03s4nqILiWfHEOmupL GRRbxKdgy4LVJRicV/jFVcg5rgPtkt4q3EQvJTmrnO3BlTWdbIdsbX8naUJxHad23hvp B+3g== 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=fs72M3ycGP+scNmYVjy4j2Vn4v4ZaaUP6Pj9R44t69w=; b=BHU8Tk4w1aN4NzAZRgBbmuMM3hnOSbH1WJ/WoszEfN1ETV6Bi711reaBYeU+ScEjPT Lqw6ENVs2+M9E6SKwHw8hedZft6uvu+mbwRklA+lzBZBKqCLCuSnJjTzt+Lna+WOJSgd eVHcAPaDYcqDQ1XNP4jfU8sAEeKeG6WgkcOMuvaFXyQG2vfVlWwevbp/vG0ZJX0jYZTs Mctyz9CLTjl7/VM0tvzSFHn6jHJRlv/ZaKazRJN00yXSPAiZrvD4HuKjOiGLMoZkfbvw IC6hsY2ktg2BDHAyLztQDGomDdX88Zdg8oKoqiD2ZmjQpOuxQtpVM3fSizkxsOiFPGCc 8oxg== 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 c10si15735652pfn.133.2018.05.03.21.58.46; Thu, 03 May 2018 21:59:02 -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 S1751236AbeEDE6g (ORCPT + 99 others); Fri, 4 May 2018 00:58:36 -0400 Received: from mga11.intel.com ([192.55.52.93]:23548 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbeEDE6f (ORCPT ); Fri, 4 May 2018 00:58:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 21:58:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,361,1520924400"; d="scan'208";a="37355479" Received: from debian.sh.intel.com ([10.67.104.164]) by fmsmga008.fm.intel.com with ESMTP; 03 May 2018 21:58:33 -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, virtio-dev@lists.oasis-open.org Cc: dan.daly@intel.com, cunming.liang@intel.com, zhihong.wang@intel.com Subject: [PATCH v1] virtio: support VIRTIO_F_IO_BARRIER Date: Fri, 4 May 2018 12:59:15 +0800 Message-Id: <20180504045915.17693-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 --- This patch depends on below proposal for virtio-spec: https://lists.oasis-open.org/archives/virtio-dev/201805/msg00019.html This patch also depends on below patch: https://lkml.org/lkml/2018/4/19/789 RFC -> v1: - Address the changes in the proposal; 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..9fb519a9df28 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 37 #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 36 #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ -- 2.11.0