Skip to contentSkip to conversation

dma-buf/heaps: Correct the types of fd_flags and heap_flags

PATCH In review Barry Song 4 participants 4 messages Jun 6, 2024 – Jun 19, 2024

Subsystems (3)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 dma-buf/heaps: Correct the types of fd_flags and heap_flags

From: Barry Song <[email protected]>

dma_heap_allocation_data defines the UAPI as follows:

 struct dma_heap_allocation_data {
        __u64 len;
        __u32 fd;
        __u32 fd_flags;
        __u64 heap_flags;

};

But dma heaps are casting both fd_flags and heap_flags into unsigned long. This patch makes dma heaps - cma heap and system heap have consistent types with UAPI.

---
 drivers/dma-buf/heaps/cma_heap.c    | 4 ++--
 drivers/dma-buf/heaps/system_heap.c | 4 ++--
 include/linux/dma-heap.h            | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/dma-buf/heaps/cma_heap.c +2 -2
index 4a63567e93ba..c384004b918e 100644
@@ -274,8 +274,8 @@ static const struct dma_buf_ops cma_heap_buf_ops = {
 
 static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
 					 unsigned long len,
-					 unsigned long fd_flags,
-					 unsigned long heap_flags)
+					 u32 fd_flags,
+					 u64 heap_flags)
 {
 	struct cma_heap *cma_heap = dma_heap_get_drvdata(heap);
 	struct cma_heap_buffer *buffer;
drivers/dma-buf/heaps/system_heap.c +2 -2
index 9076d47ed2ef..d78cdb9d01e5 100644
@@ -333,8 +333,8 @@ static struct page *alloc_largest_available(unsigned long size,
 
 static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
 					    unsigned long len,
-					    unsigned long fd_flags,
-					    unsigned long heap_flags)
+					    u32 fd_flags,
+					    u64 heap_flags)
 {
 	struct system_heap_buffer *buffer;
 	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
include/linux/dma-heap.h +2 -2
index 0c05561cad6e..064bad725061 100644
@@ -23,8 +23,8 @@ struct dma_heap;
 struct dma_heap_ops {
 	struct dma_buf *(*allocate)(struct dma_heap *heap,
 				    unsigned long len,
-				    unsigned long fd_flags,
-				    unsigned long heap_flags);
+				    u32 fd_flags,
+				    u64 heap_flags);
 };
 
 /**
Signature · 1 line
2.34.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Barry Song

From: Barry Song <[email protected]>

dma_heap_allocation_data defines the UAPI as follows:

 struct dma_heap_allocation_data {
        __u64 len;
        __u32 fd;
        __u32 fd_flags;
        __u64 heap_flags;
Quoted 7 lines

};

But dma heaps are casting both fd_flags and heap_flags into unsigned long. This patch makes dma heaps - cma heap and system heap have consistent types with UAPI.

Thanks for submitting this additional cleanup!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Barry Song
Quoted 9 lines · Barry Song

From: Barry Song <[email protected]>

dma_heap_allocation_data defines the UAPI as follows:

 struct dma_heap_allocation_data {
        __u64 len;
        __u32 fd;
        __u32 fd_flags;
        __u64 heap_flags;
Quoted 8 lines

};

But dma heaps are casting both fd_flags and heap_flags into unsigned long. This patch makes dma heaps - cma heap and system heap have consistent types with UAPI.

---

Looks good to me, thanks!

maintainer
#3 lore raw

Hi Barry,

Quoted 13 lines · Carlos Llamas
Quoted 11 lines · Barry Song

From: Barry Song <[email protected]>

dma_heap_allocation_data defines the UAPI as follows:

 struct dma_heap_allocation_data {
        __u64 len;
        __u32 fd;
        __u32 fd_flags;
        __u64 heap_flags;

};

Quoted 5 lines
Quoted 5 lines

But dma heaps are casting both fd_flags and heap_flags into unsigned long. This patch makes dma heaps - cma heap and system heap have consistent types with UAPI.

Thanks for this cleanup; pushed to drm-misc-next.

Quoted 5 lines
Quoted 1 line

---

Looks good to me, thanks!

Best,
Sumit.