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
7#define __LINUX_HOST1X_H7#define __LINUX_HOST1X_H
8 8
9#include <linux/device.h>9#include <linux/device.h>
10#include <linux/dma-direction.h>
10#include <linux/types.h>11#include <linux/types.h>
11 12
12enum host1x_class {13enum host1x_class {
@@ -82,12 +83,23 @@ struct host1x_client { · 69 unmodified lines
82struct host1x_bo;83struct host1x_bo;
83struct sg_table;84struct sg_table;
84 85
86struct 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
85struct host1x_bo_ops {97struct host1x_bo_ops {
86 struct host1x_bo *(*get)(struct host1x_bo *bo);98 struct host1x_bo *(*get)(struct host1x_bo *bo);
87 void (*put)(struct host1x_bo *bo);99 void (*put)(struct host1x_bo *bo);
88 struct sg_table *(*pin)(struct device *dev, struct host1x_bo *bo,100 struct host1x_bo_mapping *(*pin)(struct device *dev, struct host1x_bo *bo,
89 dma_addr_t *phys);101 enum dma_data_direction dir);
90 void (*unpin)(struct device *dev, struct sg_table *sgt);102 void (*unpin)(struct host1x_bo_mapping *map);
91 void *(*mmap)(struct host1x_bo *bo);103 void *(*mmap)(struct host1x_bo *bo);
92 void (*munmap)(struct host1x_bo *bo, void *addr);104 void (*munmap)(struct host1x_bo *bo, void *addr);
93};105};
@@ -112,17 +124,15 @@ static inline void host1x_bo_put(struct host1x_bo *bo) · 18 unmodified lines
112 bo->ops->put(bo);124 bo->ops->put(bo);
113}125}
114 126
115static inline struct sg_table *host1x_bo_pin(struct device *dev,127static inline struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo,
116 struct host1x_bo *bo,128 enum dma_data_direction dir)
117 dma_addr_t *phys)
118{129{
119 return bo->ops->pin(dev, bo, phys);130 return bo->ops->pin(dev, bo, dir);
120}131}
121 132
122static inline void host1x_bo_unpin(struct device *dev, struct host1x_bo *bo,133static inline void host1x_bo_unpin(struct host1x_bo_mapping *map)
123 struct sg_table *sgt)
124{134{
125 bo->ops->unpin(dev, sgt);135 map->bo->ops->unpin(map);
126}136}
127 137
128static inline void *host1x_bo_mmap(struct host1x_bo *bo)138static 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