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.
Showing the changes to include (1 of 9 files). Show all
Unified · Split
| @@ -7,6 +7,7 @@ · 6 unmodified lines | |||
| 7 | #define __LINUX_HOST1X_H | 7 | #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 | ||
| 12 | enum host1x_class { | 13 | enum host1x_class { |
| @@ -82,12 +83,23 @@ struct host1x_client { · 69 unmodified lines | |||
| 82 | struct host1x_bo; | 83 | struct host1x_bo; |
| 83 | struct sg_table; | 84 | struct sg_table; |
| 84 | 85 | ||
| 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 | |||
| 85 | struct host1x_bo_ops { | 97 | struct 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 | ||
| 115 | static inline struct sg_table *host1x_bo_pin(struct device *dev, | 127 | static 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 | ||
| 122 | static inline void host1x_bo_unpin(struct device *dev, struct host1x_bo *bo, | 133 | static 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 | ||
| 128 | static inline void *host1x_bo_mmap(struct host1x_bo *bo) | 138 | static inline void *host1x_bo_mmap(struct host1x_bo *bo) |