History

drm/tegra: Implement correct DMA-BUF semantics

DMA-BUF requires that each device that accesses a DMA-BUF attaches to it separately. To do so the host1x_bo_pin() and host1x_bo_unpin() functions need to be reimplemented so that they can return a mapping, which either represents an attachment or a map of the driver's own GEM object.

Thierry Reding committed 5 years ago

Commit c6aeaf51 parent 7a567839 files · +268 −288Browse files

Showing the changes to include (1 of 9 files). Show all

Unified · Split

include/linux/host1x.h+20−10
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #define __LINUX_HOST1X_H
88
99 #include <linux/device.h>
10+#include <linux/dma-direction.h>
1011 #include <linux/types.h>
1112
1213 enum host1x_class {
@@ -82,12 +83,23 @@ struct host1x_client { · 69 unmodified lines
8283 struct host1x_bo;
8384 struct sg_table;
8485
86+struct host1x_bo_mapping {
87+ struct dma_buf_attachment *attach;
88+ enum dma_data_direction direction;
89+ struct host1x_bo *bo;
90+ struct sg_table *sgt;
91+ unsigned int chunks;
92+ struct device *dev;
93+ dma_addr_t phys;
94+ size_t size;
95+};
96+
8597 struct host1x_bo_ops {
8698 struct host1x_bo *(*get)(struct host1x_bo *bo);
8799 void (*put)(struct host1x_bo *bo);
88− struct sg_table *(*pin)(struct device *dev, struct host1x_bo *bo,
89− dma_addr_t *phys);
90− void (*unpin)(struct device *dev, struct sg_table *sgt);
100+ struct host1x_bo_mapping *(*pin)(struct device *dev, struct host1x_bo *bo,
101+ enum dma_data_direction dir);
102+ void (*unpin)(struct host1x_bo_mapping *map);
91103 void *(*mmap)(struct host1x_bo *bo);
92104 void (*munmap)(struct host1x_bo *bo, void *addr);
93105 };
@@ -112,17 +124,15 @@ static inline void host1x_bo_put(struct host1x_bo *bo) · 18 unmodified lines
112124 bo->ops->put(bo);
113125 }
114126
115−static inline struct sg_table *host1x_bo_pin(struct device *dev,
116− struct host1x_bo *bo,
117− dma_addr_t *phys)
127+static inline struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo,
128+ enum dma_data_direction dir)
118129 {
119− return bo->ops->pin(dev, bo, phys);
130+ return bo->ops->pin(dev, bo, dir);
120131 }
121132
122−static inline void host1x_bo_unpin(struct device *dev, struct host1x_bo *bo,
123− struct sg_table *sgt)
133+static inline void host1x_bo_unpin(struct host1x_bo_mapping *map)
124134 {
125− bo->ops->unpin(dev, sgt);
135+ map->bo->ops->unpin(map);
126136 }
127137
128138 static inline void *host1x_bo_mmap(struct host1x_bo *bo)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t