* [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings
[not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.65d15247-f1fa-4fe2-a8f9-10b1259d8649@emailsignatures365.codetwo.com>
@ 2026-01-14 10:51 ` Mike Looijmans
2026-01-14 11:24 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Mike Looijmans @ 2026-01-14 10:51 UTC (permalink / raw)
To: gregkh; +Cc: Mike Looijmans, linux-kernel
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@topic.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@topic.nl
W: www.topic.nl
Please consider the environment before printing this e-mail
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings
2026-01-14 10:51 ` [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings Mike Looijmans
@ 2026-01-14 11:24 ` Greg KH
2026-01-14 11:45 ` Mike Looijmans
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2026-01-14 11:24 UTC (permalink / raw)
To: Mike Looijmans; +Cc: linux-kernel
On Wed, Jan 14, 2026 at 11:51:49AM +0100, Mike Looijmans wrote:
> 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@topic.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
But you have no in-kernel user for this, so why add it? We really can't
take this unless there is such a user, sorry.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings
2026-01-14 11:24 ` Greg KH
@ 2026-01-14 11:45 ` Mike Looijmans
0 siblings, 0 replies; 3+ messages in thread
From: Mike Looijmans @ 2026-01-14 11:45 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On 1/14/26 12:24, Greg KH wrote:
> On Wed, Jan 14, 2026 at 11:51:49AM +0100, Mike Looijmans wrote:
>> 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@topic.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
> But you have no in-kernel user for this, so why add it? We really can't
> take this unless there is such a user, sorry.
Understandable. I was planning to add some flag to uio_pdrv_genirq, but there
don't appear to be existing bindings or interfaces to add a write-combine flag
("ramoops" seems to be the only one that does that).
>
> thanks,
>
> greg k-h
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@topic.nl
W: www.topic.nl
Please consider the environment before printing this e-mail
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-14 11:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.65d15247-f1fa-4fe2-a8f9-10b1259d8649@emailsignatures365.codetwo.com>
2026-01-14 10:51 ` [PATCH] uio: Provide UIO_MEM_PHYS_WC for write-combine mappings Mike Looijmans
2026-01-14 11:24 ` Greg KH
2026-01-14 11:45 ` Mike Looijmans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®