Skip to content

Commit 9e2c5c6

Browse files
committed
Merge tag 'drm-misc-fixes-2022-11-24' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v6.1-rc7: - Another amdgpu gang submit fix. - Use dma_fence_unwrap_for_each when importing sync files. - Fix race in dma_heap_add(). - Fix use of uninitialized memory in logo. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents eb70814 + a6a00d7 commit 9e2c5c6

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/slab.h>
1616
#include <linux/dma-buf.h>
1717
#include <linux/dma-fence.h>
18+
#include <linux/dma-fence-unwrap.h>
1819
#include <linux/anon_inodes.h>
1920
#include <linux/export.h>
2021
#include <linux/debugfs.h>
@@ -391,8 +392,10 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf,
391392
const void __user *user_data)
392393
{
393394
struct dma_buf_import_sync_file arg;
394-
struct dma_fence *fence;
395+
struct dma_fence *fence, *f;
395396
enum dma_resv_usage usage;
397+
struct dma_fence_unwrap iter;
398+
unsigned int num_fences;
396399
int ret = 0;
397400

398401
if (copy_from_user(&arg, user_data, sizeof(arg)))
@@ -411,13 +414,21 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf,
411414
usage = (arg.flags & DMA_BUF_SYNC_WRITE) ? DMA_RESV_USAGE_WRITE :
412415
DMA_RESV_USAGE_READ;
413416

414-
dma_resv_lock(dmabuf->resv, NULL);
417+
num_fences = 0;
418+
dma_fence_unwrap_for_each(f, &iter, fence)
419+
++num_fences;
415420

416-
ret = dma_resv_reserve_fences(dmabuf->resv, 1);
417-
if (!ret)
418-
dma_resv_add_fence(dmabuf->resv, fence, usage);
421+
if (num_fences > 0) {
422+
dma_resv_lock(dmabuf->resv, NULL);
419423

420-
dma_resv_unlock(dmabuf->resv);
424+
ret = dma_resv_reserve_fences(dmabuf->resv, num_fences);
425+
if (!ret) {
426+
dma_fence_unwrap_for_each(f, &iter, fence)
427+
dma_resv_add_fence(dmabuf->resv, f, usage);
428+
}
429+
430+
dma_resv_unlock(dmabuf->resv);
431+
}
421432

422433
dma_fence_put(fence);
423434

drivers/dma-buf/dma-heap.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
233233
return ERR_PTR(-EINVAL);
234234
}
235235

236-
/* check the name is unique */
237-
mutex_lock(&heap_list_lock);
238-
list_for_each_entry(h, &heap_list, list) {
239-
if (!strcmp(h->name, exp_info->name)) {
240-
mutex_unlock(&heap_list_lock);
241-
pr_err("dma_heap: Already registered heap named %s\n",
242-
exp_info->name);
243-
return ERR_PTR(-EINVAL);
244-
}
245-
}
246-
mutex_unlock(&heap_list_lock);
247-
248236
heap = kzalloc(sizeof(*heap), GFP_KERNEL);
249237
if (!heap)
250238
return ERR_PTR(-ENOMEM);
@@ -283,13 +271,27 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
283271
err_ret = ERR_CAST(dev_ret);
284272
goto err2;
285273
}
286-
/* Add heap to the list */
274+
287275
mutex_lock(&heap_list_lock);
276+
/* check the name is unique */
277+
list_for_each_entry(h, &heap_list, list) {
278+
if (!strcmp(h->name, exp_info->name)) {
279+
mutex_unlock(&heap_list_lock);
280+
pr_err("dma_heap: Already registered heap named %s\n",
281+
exp_info->name);
282+
err_ret = ERR_PTR(-EINVAL);
283+
goto err3;
284+
}
285+
}
286+
287+
/* Add heap to the list */
288288
list_add(&heap->list, &heap_list);
289289
mutex_unlock(&heap_list_lock);
290290

291291
return heap;
292292

293+
err3:
294+
device_destroy(dma_heap_class, heap->heap_devt);
293295
err2:
294296
cdev_del(&heap->heap_cdev);
295297
err1:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ static struct dma_fence *amdgpu_job_dependency(struct drm_sched_job *sched_job,
254254
DRM_ERROR("Error adding fence (%d)\n", r);
255255
}
256256

257+
if (!fence && job->gang_submit)
258+
fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
259+
257260
while (fence == NULL && vm && !job->vmid) {
258261
r = amdgpu_vmid_grab(vm, ring, &job->sync,
259262
&job->base.s_fence->finished,
@@ -264,9 +267,6 @@ static struct dma_fence *amdgpu_job_dependency(struct drm_sched_job *sched_job,
264267
fence = amdgpu_sync_get_fence(&job->sync);
265268
}
266269

267-
if (!fence && job->gang_submit)
268-
fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
269-
270270
return fence;
271271
}
272272

drivers/video/fbdev/core/fbcon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
577577
if (scr_readw(r) != vc->vc_video_erase_char)
578578
break;
579579
if (r != q && new_rows >= rows + logo_lines) {
580-
save = kmalloc(array3_size(logo_lines, new_cols, 2),
580+
save = kzalloc(array3_size(logo_lines, new_cols, 2),
581581
GFP_KERNEL);
582582
if (save) {
583583
int i = min(cols, new_cols);

0 commit comments

Comments
 (0)