[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC v1 6/7] virtio: use io_tlb_high_mem if it is active
- To: iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, x86@xxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
- From: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
- Date: Wed, 8 Jun 2022 17:55:52 -0700
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fg5JBE/9uMN3vIcpEYAyJ0dIp33/fBmQIiC1iTsr1WI=; b=fKLmA99xmJ0FTMfqsHuuH6sqfvQWQSLdbwiWtD1L+k9GKCP0OGwz0gEGIhcSGXTBBIuByTXArZg+cVyU+CxGQbXFriu+izrIb5xsItvafXQ2CarzDQPPAmopm7aCyNfSN423dLpQ3v5uS3/H3jZEqPyclLXKfqm2PWnQfHfCuW9Dsee6oOnk/QkWWzgH0eYyoDhJapegEnk3MG0p4zXwoGT6V7mCyttgWq7jfvv9Kg7fE1iA4NF4DVuhR3QfZSC1st/HpJfDfYnZ/sq8+osdxDSU4acsOwNC9eORu+yc7bJhT80vEH8njAiRRj9VQ0F7dSKcdqDmWYsGVdfbS/qF1w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UaxlOS4FSWP+dY8KXuHtKJoZaZ0sy2JK0zEgDdp9/+1ipm/bPO3EQE5KEaHVAGeu5ICjvdNXVmm2w1gwcSRZgjduXewAOvQRhoNHFtLzpKupGdRgfruQskk5qhKKWM0Pj393MvVFWL2fL174lbIuYquGEKBZyqsfjSkWxfnM2KrrphzJ9QXlNRv8uKH4/GwQ6N6/0GYFkMLosxGVEfELcaQsP7Ia0LZE3n6tqVMSb3VBsseoChQenPSL0RLbKot3W2lG64/Cxefj+9fEA/hV3VPi/wJSHwB+c5FMbHS3wYFc3JYaO1InDbi7ncPjZQevSwcj7UNW1m+THaqmlIxyhA==
- Cc: linux-kernel@xxxxxxxxxxxxxxx, hch@xxxxxxxxxxxxx, m.szyprowski@xxxxxxxxxxx, jgross@xxxxxxxx, tglx@xxxxxxxxxxxxx, mingo@xxxxxxxxxx, bp@xxxxxxxxx, dave.hansen@xxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, mpe@xxxxxxxxxxxxxx, konrad.wilk@xxxxxxxxxx, mst@xxxxxxxxxx, jasowang@xxxxxxxxxx, joe.jin@xxxxxxxxxx
- Delivery-date: Thu, 09 Jun 2022 00:59:43 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
When the swiotlb is enforced (e.g., when amd sev is involved), the virito
driver will not be able to use 4+ GB memory. Therefore, the virtio driver
uses 'io_tlb_high_mem' as swiotlb.
Cc: Konrad Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Joe Jin <joe.jin@xxxxxxxxxx>
Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
---
drivers/virtio/virtio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index ef04a96942bf..d9ebe3940e2d 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -5,6 +5,8 @@
#include <linux/module.h>
#include <linux/idr.h>
#include <linux/of.h>
+#include <linux/swiotlb.h>
+#include <linux/dma-mapping.h>
#include <uapi/linux/virtio_ids.h>
/* Unique numbering for virtio devices. */
@@ -241,6 +243,12 @@ static int virtio_dev_probe(struct device *_d)
u64 device_features;
u64 driver_features;
u64 driver_features_legacy;
+ struct device *parent = dev->dev.parent;
+ u64 dma_mask = min_not_zero(*parent->dma_mask,
+ parent->bus_dma_limit);
+
+ if (dma_mask == DMA_BIT_MASK(64))
+ swiotlb_use_high(parent);
/* We have a driver! */
virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
--
2.17.1
|