[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260114105149.1725098-1-mike.looijmans@topic.nl>
Date: Wed, 14 Jan 2026 11:51:49 +0100
From: Mike Looijmans <mike.looijmans@...ic.nl>
To: gregkh@...uxfoundation.org
CC: Mike Looijmans <mike.looijmans@...ic.nl>,
linux-kernel@...r.kernel.org
Subject: [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings
Introduce UIO_MEM_PHYS_WC which is identical to UIO_MEM_PHYS except
that the mapping will enable write-combining. This allows the system to
coalesce writes and greatly improves performance if the underlying
hardware allows that. Typically used for video buffers, but also very
well suited for filling FPGA (block)RAMs with reference data.
Signed-off-by: Mike Looijmans <mike.looijmans@...ic.nl>
---
drivers/uio/uio.c | 3 +++
include/linux/uio_driver.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index fa0d4e6aee16..c33db04d2004 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -757,6 +757,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
vma->vm_ops = &uio_physical_vm_ops;
if (idev->info->mem[mi].memtype == UIO_MEM_PHYS)
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ else if (idev->info->mem[mi].memtype == UIO_MEM_PHYS_WC)
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
/*
* We cannot use the vm_iomap_memory() helper here,
@@ -858,6 +860,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
switch (idev->info->mem[mi].memtype) {
case UIO_MEM_IOVA:
case UIO_MEM_PHYS:
+ case UIO_MEM_PHYS_WC:
ret = uio_mmap_physical(vma);
break;
case UIO_MEM_LOGICAL:
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 334641e20fb1..b925b8c17214 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -171,6 +171,7 @@ extern int __must_check
* Do not use in new drivers.
*/
#define UIO_MEM_DMA_COHERENT 5
+#define UIO_MEM_PHYS_WC 6
/* defines for uio_port->porttype */
#define UIO_PORT_NONE 0
--
2.34.1
Met vriendelijke groet / kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@...ic.nl
W: www.topic.nl
Please consider the environment before printing this e-mail
Powered by blists - more mailing lists