diff options
author | Sean Paul <seanpaul@chromium.org> | 2017-07-17 11:43:05 -0400 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2017-07-17 11:56:07 -0400 |
commit | ef434a0c2ce765ad33026375db7d23aebd5e9532 (patch) | |
tree | 4bdac59f0bac3a6508741e6bd62da6e770fc3bc1 /drivers/dma-buf | |
parent | 76250f2b743b72cb685cc51ac0cdabb32957180b (diff) | |
parent | 1ed134e6526b1b513a14fba938f6d96aa1c7f3dd (diff) |
Merge branch 'drm-misc-next-fixes' into drm-misc-fixes
Pick up
1ed134e6526b drm/vc4: Fix VBLANK handling in crtc->enable() path
From drm-misc-next-fixes, it was applied after the last pull request
was sent from that branch. We'll send it through drm-fixes instead.
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r-- | drivers/dma-buf/dma-buf.c | 8 | ||||
-rw-r--r-- | drivers/dma-buf/dma-fence.c | 5 | ||||
-rw-r--r-- | drivers/dma-buf/sync_debug.c | 10 | ||||
-rw-r--r-- | drivers/dma-buf/sync_file.c | 52 |
4 files changed, 48 insertions, 27 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 512bdbc23bbb..4a038dcf5361 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c | |||
@@ -558,8 +558,8 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, | |||
558 | if (WARN_ON(!dmabuf || !dev)) | 558 | if (WARN_ON(!dmabuf || !dev)) |
559 | return ERR_PTR(-EINVAL); | 559 | return ERR_PTR(-EINVAL); |
560 | 560 | ||
561 | attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL); | 561 | attach = kzalloc(sizeof(*attach), GFP_KERNEL); |
562 | if (attach == NULL) | 562 | if (!attach) |
563 | return ERR_PTR(-ENOMEM); | 563 | return ERR_PTR(-ENOMEM); |
564 | 564 | ||
565 | attach->dev = dev; | 565 | attach->dev = dev; |
@@ -1122,9 +1122,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) | |||
1122 | attach_count = 0; | 1122 | attach_count = 0; |
1123 | 1123 | ||
1124 | list_for_each_entry(attach_obj, &buf_obj->attachments, node) { | 1124 | list_for_each_entry(attach_obj, &buf_obj->attachments, node) { |
1125 | seq_puts(s, "\t"); | 1125 | seq_printf(s, "\t%s\n", dev_name(attach_obj->dev)); |
1126 | |||
1127 | seq_printf(s, "%s\n", dev_name(attach_obj->dev)); | ||
1128 | attach_count++; | 1126 | attach_count++; |
1129 | } | 1127 | } |
1130 | 1128 | ||
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 13556fdda2a5..56e0a0e1b600 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c | |||
@@ -397,6 +397,11 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) | |||
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | if (!timeout) { | ||
401 | ret = 0; | ||
402 | goto out; | ||
403 | } | ||
404 | |||
400 | cb.base.func = dma_fence_default_wait_cb; | 405 | cb.base.func = dma_fence_default_wait_cb; |
401 | cb.task = current; | 406 | cb.task = current; |
402 | list_add(&cb.base.node, &fence->cb_list); | 407 | list_add(&cb.base.node, &fence->cb_list); |
diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c index bfead12390f2..59a3b2f8ee91 100644 --- a/drivers/dma-buf/sync_debug.c +++ b/drivers/dma-buf/sync_debug.c | |||
@@ -110,7 +110,7 @@ static void sync_print_fence(struct seq_file *s, | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | seq_puts(s, "\n"); | 113 | seq_putc(s, '\n'); |
114 | } | 114 | } |
115 | 115 | ||
116 | static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) | 116 | static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) |
@@ -132,9 +132,11 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) | |||
132 | static void sync_print_sync_file(struct seq_file *s, | 132 | static void sync_print_sync_file(struct seq_file *s, |
133 | struct sync_file *sync_file) | 133 | struct sync_file *sync_file) |
134 | { | 134 | { |
135 | char buf[128]; | ||
135 | int i; | 136 | int i; |
136 | 137 | ||
137 | seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name, | 138 | seq_printf(s, "[%p] %s: %s\n", sync_file, |
139 | sync_file_get_name(sync_file, buf, sizeof(buf)), | ||
138 | sync_status_str(dma_fence_get_status(sync_file->fence))); | 140 | sync_status_str(dma_fence_get_status(sync_file->fence))); |
139 | 141 | ||
140 | if (dma_fence_is_array(sync_file->fence)) { | 142 | if (dma_fence_is_array(sync_file->fence)) { |
@@ -161,7 +163,7 @@ static int sync_debugfs_show(struct seq_file *s, void *unused) | |||
161 | sync_timeline_list); | 163 | sync_timeline_list); |
162 | 164 | ||
163 | sync_print_obj(s, obj); | 165 | sync_print_obj(s, obj); |
164 | seq_puts(s, "\n"); | 166 | seq_putc(s, '\n'); |
165 | } | 167 | } |
166 | spin_unlock_irqrestore(&sync_timeline_list_lock, flags); | 168 | spin_unlock_irqrestore(&sync_timeline_list_lock, flags); |
167 | 169 | ||
@@ -173,7 +175,7 @@ static int sync_debugfs_show(struct seq_file *s, void *unused) | |||
173 | container_of(pos, struct sync_file, sync_file_list); | 175 | container_of(pos, struct sync_file, sync_file_list); |
174 | 176 | ||
175 | sync_print_sync_file(s, sync_file); | 177 | sync_print_sync_file(s, sync_file); |
176 | seq_puts(s, "\n"); | 178 | seq_putc(s, '\n'); |
177 | } | 179 | } |
178 | spin_unlock_irqrestore(&sync_file_list_lock, flags); | 180 | spin_unlock_irqrestore(&sync_file_list_lock, flags); |
179 | return 0; | 181 | return 0; |
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index 95f259b719fc..d7e219d2669d 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c | |||
@@ -41,8 +41,6 @@ static struct sync_file *sync_file_alloc(void) | |||
41 | if (IS_ERR(sync_file->file)) | 41 | if (IS_ERR(sync_file->file)) |
42 | goto err; | 42 | goto err; |
43 | 43 | ||
44 | kref_init(&sync_file->kref); | ||
45 | |||
46 | init_waitqueue_head(&sync_file->wq); | 44 | init_waitqueue_head(&sync_file->wq); |
47 | 45 | ||
48 | INIT_LIST_HEAD(&sync_file->cb.node); | 46 | INIT_LIST_HEAD(&sync_file->cb.node); |
@@ -82,11 +80,6 @@ struct sync_file *sync_file_create(struct dma_fence *fence) | |||
82 | 80 | ||
83 | sync_file->fence = dma_fence_get(fence); | 81 | sync_file->fence = dma_fence_get(fence); |
84 | 82 | ||
85 | snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%llu-%d", | ||
86 | fence->ops->get_driver_name(fence), | ||
87 | fence->ops->get_timeline_name(fence), fence->context, | ||
88 | fence->seqno); | ||
89 | |||
90 | return sync_file; | 83 | return sync_file; |
91 | } | 84 | } |
92 | EXPORT_SYMBOL(sync_file_create); | 85 | EXPORT_SYMBOL(sync_file_create); |
@@ -131,6 +124,36 @@ struct dma_fence *sync_file_get_fence(int fd) | |||
131 | } | 124 | } |
132 | EXPORT_SYMBOL(sync_file_get_fence); | 125 | EXPORT_SYMBOL(sync_file_get_fence); |
133 | 126 | ||
127 | /** | ||
128 | * sync_file_get_name - get the name of the sync_file | ||
129 | * @sync_file: sync_file to get the fence from | ||
130 | * @buf: destination buffer to copy sync_file name into | ||
131 | * @len: available size of destination buffer. | ||
132 | * | ||
133 | * Each sync_file may have a name assigned either by the user (when merging | ||
134 | * sync_files together) or created from the fence it contains. In the latter | ||
135 | * case construction of the name is deferred until use, and so requires | ||
136 | * sync_file_get_name(). | ||
137 | * | ||
138 | * Returns: a string representing the name. | ||
139 | */ | ||
140 | char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len) | ||
141 | { | ||
142 | if (sync_file->user_name[0]) { | ||
143 | strlcpy(buf, sync_file->user_name, len); | ||
144 | } else { | ||
145 | struct dma_fence *fence = sync_file->fence; | ||
146 | |||
147 | snprintf(buf, len, "%s-%s%llu-%d", | ||
148 | fence->ops->get_driver_name(fence), | ||
149 | fence->ops->get_timeline_name(fence), | ||
150 | fence->context, | ||
151 | fence->seqno); | ||
152 | } | ||
153 | |||
154 | return buf; | ||
155 | } | ||
156 | |||
134 | static int sync_file_set_fence(struct sync_file *sync_file, | 157 | static int sync_file_set_fence(struct sync_file *sync_file, |
135 | struct dma_fence **fences, int num_fences) | 158 | struct dma_fence **fences, int num_fences) |
136 | { | 159 | { |
@@ -268,7 +291,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, | |||
268 | goto err; | 291 | goto err; |
269 | } | 292 | } |
270 | 293 | ||
271 | strlcpy(sync_file->name, name, sizeof(sync_file->name)); | 294 | strlcpy(sync_file->user_name, name, sizeof(sync_file->user_name)); |
272 | return sync_file; | 295 | return sync_file; |
273 | 296 | ||
274 | err: | 297 | err: |
@@ -277,22 +300,15 @@ err: | |||
277 | 300 | ||
278 | } | 301 | } |
279 | 302 | ||
280 | static void sync_file_free(struct kref *kref) | 303 | static int sync_file_release(struct inode *inode, struct file *file) |
281 | { | 304 | { |
282 | struct sync_file *sync_file = container_of(kref, struct sync_file, | 305 | struct sync_file *sync_file = file->private_data; |
283 | kref); | ||
284 | 306 | ||
285 | if (test_bit(POLL_ENABLED, &sync_file->fence->flags)) | 307 | if (test_bit(POLL_ENABLED, &sync_file->fence->flags)) |
286 | dma_fence_remove_callback(sync_file->fence, &sync_file->cb); | 308 | dma_fence_remove_callback(sync_file->fence, &sync_file->cb); |
287 | dma_fence_put(sync_file->fence); | 309 | dma_fence_put(sync_file->fence); |
288 | kfree(sync_file); | 310 | kfree(sync_file); |
289 | } | ||
290 | |||
291 | static int sync_file_release(struct inode *inode, struct file *file) | ||
292 | { | ||
293 | struct sync_file *sync_file = file->private_data; | ||
294 | 311 | ||
295 | kref_put(&sync_file->kref, sync_file_free); | ||
296 | return 0; | 312 | return 0; |
297 | } | 313 | } |
298 | 314 | ||
@@ -428,7 +444,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file, | |||
428 | } | 444 | } |
429 | 445 | ||
430 | no_fences: | 446 | no_fences: |
431 | strlcpy(info.name, sync_file->name, sizeof(info.name)); | 447 | sync_file_get_name(sync_file, info.name, sizeof(info.name)); |
432 | info.status = dma_fence_is_signaled(sync_file->fence); | 448 | info.status = dma_fence_is_signaled(sync_file->fence); |
433 | info.num_fences = num_fences; | 449 | info.num_fences = num_fences; |
434 | 450 | ||