Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp585731imu; Wed, 23 Jan 2019 01:55:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN5dJQnIGTzUTpTIUvkYEO/3q9qPVWKPRlYAbFwQOshSrOO0ZvkY15CSKUWlCdzjSmaAU6Ln X-Received: by 2002:a62:c101:: with SMTP id i1mr1474537pfg.80.1548237314888; Wed, 23 Jan 2019 01:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548237314; cv=none; d=google.com; s=arc-20160816; b=BtrdaMgf+GgCo4o8cFHjToOlisNfVFuspBug2YgEch+a/lUh+h8XbILFNczZLg5fqR RVOTWFqFkTiT0MnWABbYQyODsY2xEeIzm6r8pPcsljYq9CWCS5xoB5Lt/KNdtARn5aTo B9KFi8GQUFsTiaKajMHlukfMcDO1I09ygJNpLP8Sc2I52/7kRWXuw0vzCacelKr98gjW F9zXrxvdg8rUzN2AB9hooyWYBX71dv0FU576NSJMLSREtgPe6D8UraYRFo0dV4uXNDlW grh6u9ZIee31JIib0P4oemb2QIQuMETjUgwSPvPnQlBUgWEe+jfTuwcLA5QRrQd7cFuh C1TA== 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:to:from; bh=pMqRT7bsVmcpVzjD1+XqZPiaJGC4jYXnAX5Uya7ZqwA=; b=e65GQHcu+Q1glkiL7p+bhv8vBg+qJp9U+Gx5Y82eL9aPc18x4ttHJhYgkvbZNcYUJ8 1TZgbRHbmhHw5NwpL9Y3eh2hO21FlzJyLiIbItzpbP64L0UbDqf7Kw8VhfpxLftJPWyQ s1ehetBUHfLFmGgAKCleR2z9EHdIlHzzOlGHTZTGJYtviFhlR3uN9is/5ot1UFGO52Nc iImH+sUGjTm4+7GsofW2DWIVe81uFUGR4yRL3ADIWy8QZHyFgT6qB9ZA2CfXe6rDi5rO s8Nnu5PdUzq3zZpRVwwwfg7lMszAxSTBBtZah6iB9hy9y2KjAZ1zm4S7WnZD07VGgYl5 KCtw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si15966874pgo.483.2019.01.23.01.54.59; Wed, 23 Jan 2019 01:55:14 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbfAWJxB (ORCPT + 99 others); Wed, 23 Jan 2019 04:53:01 -0500 Received: from mga07.intel.com ([134.134.136.100]:43150 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727075AbfAWJxB (ORCPT ); Wed, 23 Jan 2019 04:53:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2019 01:53:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,510,1539673200"; d="scan'208";a="128190241" Received: from unknown (HELO dpdk-tbie.sh.intel.com) ([10.67.104.173]) by orsmga002.jf.intel.com with ESMTP; 23 Jan 2019 01:52:59 -0800 From: Tiwei Bie To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, virtio-dev@lists.oasis-open.org Subject: [PATCH v2] virtio: support VIRTIO_F_ORDER_PLATFORM Date: Wed, 23 Jan 2019 17:50:26 +0800 Message-Id: <20190123095026.8387-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 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_ORDER_PLATFORM. If this feature is negotiated, the driver must use the barriers suitable for hardware devices. Otherwise, the device and driver are assumed to be implemented in software, that is they can be assumed to run on identical CPUs in an SMP configuration. Thus a weaker form of memory barriers is sufficient to yield better performance. It is recommended that an add-in card based PCI device offers this feature for portability. The device will fail to operate further or will operate in a slower emulation mode if this feature is offered but not accepted. Signed-off-by: Tiwei Bie --- v2: - Add more explanations in commit log (MST); drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index cd7e755484e3..27d3f057493e 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX); + if (virtio_has_feature(vdev, VIRTIO_F_ORDER_PLATFORM)) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr; @@ -2079,6 +2082,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_ORDER_PLATFORM)) + vq->weak_barriers = false; + vq->split.queue_dma_addr = 0; vq->split.queue_size_in_bytes = 0; @@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev) break; case VIRTIO_F_RING_PACKED: break; + case VIRTIO_F_ORDER_PLATFORM: + 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 1196e1c1d4f6..ff8e7dc9d4dd 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h @@ -78,6 +78,12 @@ /* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* + * This feature indicates that memory accesses by the driver and the + * device are ordered in a way described by the platform. + */ +#define VIRTIO_F_ORDER_PLATFORM 36 + /* * Does the device support Single Root I/O Virtualization? */ -- 2.17.1