Skip to content

Commit 1a589c0

Browse files
committed
Merge tag 'drm-fixes-for-v4.11-rc6' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "This is just mostly stuff that missed rc5, from vmwgfx and msm drivers" * tag 'drm-fixes-for-v4.11-rc6' of git://people.freedesktop.org/~airlied/linux: drm/msm: Make sure to detach the MMU during GPU cleanup drm/msm/hdmi: redefinitions of macros not required drm/msm/mdp5: Update SSPP_MAX value drm/msm/dsi: Fix bug in dsi_mgr_phy_enable drm/msm: Don't allow zero sized buffer objects drm/msm: Fix wrong pointer check in a5xx_destroy drm/msm: adreno: fix build error without debugfs drm/vmwgfx: fix integer overflow in vmw_surface_define_ioctl() drm/vmwgfx: Remove getparam error message drm/ttm: Avoid calling drm_ht_remove from atomic context drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl() drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl() drm/vmwgfx: Type-check lookups of fence objects
2 parents 08e4e0d + 130e35e commit 1a589c0

File tree

13 files changed

+112
-81
lines changed

13 files changed

+112
-81
lines changed

drivers/gpu/drm/msm/adreno/a5xx_gpu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
1+
/* Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
22
*
33
* This program is free software; you can redistribute it and/or modify
44
* it under the terms of the GNU General Public License version 2 and
@@ -534,7 +534,7 @@ static void a5xx_destroy(struct msm_gpu *gpu)
534534
}
535535

536536
if (a5xx_gpu->gpmu_bo) {
537-
if (a5xx_gpu->gpmu_bo)
537+
if (a5xx_gpu->gpmu_iova)
538538
msm_gem_put_iova(a5xx_gpu->gpmu_bo, gpu->id);
539539
drm_gem_object_unreference_unlocked(a5xx_gpu->gpmu_bo);
540540
}
@@ -860,7 +860,9 @@ static const struct adreno_gpu_funcs funcs = {
860860
.idle = a5xx_idle,
861861
.irq = a5xx_irq,
862862
.destroy = a5xx_destroy,
863+
#ifdef CONFIG_DEBUG_FS
863864
.show = a5xx_show,
865+
#endif
864866
},
865867
.get_timestamp = a5xx_get_timestamp,
866868
};

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,27 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
418418
return 0;
419419
}
420420

421-
void adreno_gpu_cleanup(struct adreno_gpu *gpu)
421+
void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
422422
{
423-
if (gpu->memptrs_bo) {
424-
if (gpu->memptrs)
425-
msm_gem_put_vaddr(gpu->memptrs_bo);
423+
struct msm_gpu *gpu = &adreno_gpu->base;
424+
425+
if (adreno_gpu->memptrs_bo) {
426+
if (adreno_gpu->memptrs)
427+
msm_gem_put_vaddr(adreno_gpu->memptrs_bo);
428+
429+
if (adreno_gpu->memptrs_iova)
430+
msm_gem_put_iova(adreno_gpu->memptrs_bo, gpu->id);
431+
432+
drm_gem_object_unreference_unlocked(adreno_gpu->memptrs_bo);
433+
}
434+
release_firmware(adreno_gpu->pm4);
435+
release_firmware(adreno_gpu->pfp);
426436

427-
if (gpu->memptrs_iova)
428-
msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
437+
msm_gpu_cleanup(gpu);
429438

430-
drm_gem_object_unreference_unlocked(gpu->memptrs_bo);
439+
if (gpu->aspace) {
440+
gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu,
441+
iommu_ports, ARRAY_SIZE(iommu_ports));
442+
msm_gem_address_space_destroy(gpu->aspace);
431443
}
432-
release_firmware(gpu->pm4);
433-
release_firmware(gpu->pfp);
434-
msm_gpu_cleanup(&gpu->base);
435444
}

drivers/gpu/drm/msm/dsi/dsi_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ dsi_mgr_phy_enable(int id,
171171
}
172172
}
173173
} else {
174-
msm_dsi_host_reset_phy(mdsi->host);
174+
msm_dsi_host_reset_phy(msm_dsi->host);
175175
ret = enable_phy(msm_dsi, src_pll_id, &shared_timings[id]);
176176
if (ret)
177177
return ret;

drivers/gpu/drm/msm/hdmi/hdmi_audio.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
#include <linux/hdmi.h>
1919
#include "hdmi.h"
2020

21-
22-
/* Supported HDMI Audio channels */
23-
#define MSM_HDMI_AUDIO_CHANNEL_2 0
24-
#define MSM_HDMI_AUDIO_CHANNEL_4 1
25-
#define MSM_HDMI_AUDIO_CHANNEL_6 2
26-
#define MSM_HDMI_AUDIO_CHANNEL_8 3
27-
2821
/* maps MSM_HDMI_AUDIO_CHANNEL_n consts used by audio driver to # of channels: */
2922
static int nchannels[] = { 2, 4, 6, 8 };
3023

drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#ifndef __MDP5_PIPE_H__
1919
#define __MDP5_PIPE_H__
2020

21-
#define SSPP_MAX (SSPP_RGB3 + 1) /* TODO: Add SSPP_MAX in mdp5.xml.h */
21+
/* TODO: Add SSPP_MAX in mdp5.xml.h */
22+
#define SSPP_MAX (SSPP_CURSOR1 + 1)
2223

2324
/* represents a hw pipe, which is dynamically assigned to a plane */
2425
struct mdp5_hw_pipe {

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,
812812

813813
size = PAGE_ALIGN(size);
814814

815+
/* Disallow zero sized objects as they make the underlying
816+
* infrastructure grumpy
817+
*/
818+
if (size == 0)
819+
return ERR_PTR(-EINVAL);
820+
815821
ret = msm_gem_new_impl(dev, size, flags, NULL, &obj);
816822
if (ret)
817823
goto fail;

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
706706
msm_ringbuffer_destroy(gpu->rb);
707707
}
708708

709-
if (gpu->aspace)
710-
msm_gem_address_space_destroy(gpu->aspace);
711-
712709
if (gpu->fctx)
713710
msm_fence_context_free(gpu->fctx);
714711
}

drivers/gpu/drm/ttm/ttm_object.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ int ttm_base_object_init(struct ttm_object_file *tfile,
179179
if (unlikely(ret != 0))
180180
goto out_err0;
181181

182-
ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL);
182+
ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, false);
183183
if (unlikely(ret != 0))
184184
goto out_err1;
185185

@@ -318,7 +318,8 @@ EXPORT_SYMBOL(ttm_ref_object_exists);
318318

319319
int ttm_ref_object_add(struct ttm_object_file *tfile,
320320
struct ttm_base_object *base,
321-
enum ttm_ref_type ref_type, bool *existed)
321+
enum ttm_ref_type ref_type, bool *existed,
322+
bool require_existed)
322323
{
323324
struct drm_open_hash *ht = &tfile->ref_hash[ref_type];
324325
struct ttm_ref_object *ref;
@@ -345,6 +346,9 @@ int ttm_ref_object_add(struct ttm_object_file *tfile,
345346
}
346347

347348
rcu_read_unlock();
349+
if (require_existed)
350+
return -EPERM;
351+
348352
ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref),
349353
false, false);
350354
if (unlikely(ret != 0))
@@ -449,10 +453,10 @@ void ttm_object_file_release(struct ttm_object_file **p_tfile)
449453
ttm_ref_object_release(&ref->kref);
450454
}
451455

456+
spin_unlock(&tfile->lock);
452457
for (i = 0; i < TTM_REF_NUM; ++i)
453458
drm_ht_remove(&tfile->ref_hash[i]);
454459

455-
spin_unlock(&tfile->lock);
456460
ttm_object_file_unref(&tfile);
457461
}
458462
EXPORT_SYMBOL(ttm_object_file_release);
@@ -529,9 +533,7 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev)
529533

530534
*p_tdev = NULL;
531535

532-
spin_lock(&tdev->object_lock);
533536
drm_ht_remove(&tdev->object_hash);
534-
spin_unlock(&tdev->object_lock);
535537

536538
kfree(tdev);
537539
}
@@ -635,7 +637,7 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile,
635637
prime = (struct ttm_prime_object *) dma_buf->priv;
636638
base = &prime->base;
637639
*handle = base->hash.key;
638-
ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL);
640+
ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, false);
639641

640642
dma_buf_put(dma_buf);
641643

drivers/gpu/drm/vmwgfx/vmwgfx_fence.c

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ int vmw_fence_create(struct vmw_fence_manager *fman,
538538
struct vmw_fence_obj **p_fence)
539539
{
540540
struct vmw_fence_obj *fence;
541-
int ret;
541+
int ret;
542542

543543
fence = kzalloc(sizeof(*fence), GFP_KERNEL);
544544
if (unlikely(fence == NULL))
@@ -701,6 +701,41 @@ void vmw_fence_fifo_up(struct vmw_fence_manager *fman)
701701
}
702702

703703

704+
/**
705+
* vmw_fence_obj_lookup - Look up a user-space fence object
706+
*
707+
* @tfile: A struct ttm_object_file identifying the caller.
708+
* @handle: A handle identifying the fence object.
709+
* @return: A struct vmw_user_fence base ttm object on success or
710+
* an error pointer on failure.
711+
*
712+
* The fence object is looked up and type-checked. The caller needs
713+
* to have opened the fence object first, but since that happens on
714+
* creation and fence objects aren't shareable, that's not an
715+
* issue currently.
716+
*/
717+
static struct ttm_base_object *
718+
vmw_fence_obj_lookup(struct ttm_object_file *tfile, u32 handle)
719+
{
720+
struct ttm_base_object *base = ttm_base_object_lookup(tfile, handle);
721+
722+
if (!base) {
723+
pr_err("Invalid fence object handle 0x%08lx.\n",
724+
(unsigned long)handle);
725+
return ERR_PTR(-EINVAL);
726+
}
727+
728+
if (base->refcount_release != vmw_user_fence_base_release) {
729+
pr_err("Invalid fence object handle 0x%08lx.\n",
730+
(unsigned long)handle);
731+
ttm_base_object_unref(&base);
732+
return ERR_PTR(-EINVAL);
733+
}
734+
735+
return base;
736+
}
737+
738+
704739
int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
705740
struct drm_file *file_priv)
706741
{
@@ -726,13 +761,9 @@ int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
726761
arg->kernel_cookie = jiffies + wait_timeout;
727762
}
728763

729-
base = ttm_base_object_lookup(tfile, arg->handle);
730-
if (unlikely(base == NULL)) {
731-
printk(KERN_ERR "Wait invalid fence object handle "
732-
"0x%08lx.\n",
733-
(unsigned long)arg->handle);
734-
return -EINVAL;
735-
}
764+
base = vmw_fence_obj_lookup(tfile, arg->handle);
765+
if (IS_ERR(base))
766+
return PTR_ERR(base);
736767

737768
fence = &(container_of(base, struct vmw_user_fence, base)->fence);
738769

@@ -771,13 +802,9 @@ int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
771802
struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
772803
struct vmw_private *dev_priv = vmw_priv(dev);
773804

774-
base = ttm_base_object_lookup(tfile, arg->handle);
775-
if (unlikely(base == NULL)) {
776-
printk(KERN_ERR "Fence signaled invalid fence object handle "
777-
"0x%08lx.\n",
778-
(unsigned long)arg->handle);
779-
return -EINVAL;
780-
}
805+
base = vmw_fence_obj_lookup(tfile, arg->handle);
806+
if (IS_ERR(base))
807+
return PTR_ERR(base);
781808

782809
fence = &(container_of(base, struct vmw_user_fence, base)->fence);
783810
fman = fman_from_fence(fence);
@@ -1024,6 +1051,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
10241051
(struct drm_vmw_fence_event_arg *) data;
10251052
struct vmw_fence_obj *fence = NULL;
10261053
struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
1054+
struct ttm_object_file *tfile = vmw_fp->tfile;
10271055
struct drm_vmw_fence_rep __user *user_fence_rep =
10281056
(struct drm_vmw_fence_rep __user *)(unsigned long)
10291057
arg->fence_rep;
@@ -1037,24 +1065,18 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
10371065
*/
10381066
if (arg->handle) {
10391067
struct ttm_base_object *base =
1040-
ttm_base_object_lookup_for_ref(dev_priv->tdev,
1041-
arg->handle);
1042-
1043-
if (unlikely(base == NULL)) {
1044-
DRM_ERROR("Fence event invalid fence object handle "
1045-
"0x%08lx.\n",
1046-
(unsigned long)arg->handle);
1047-
return -EINVAL;
1048-
}
1068+
vmw_fence_obj_lookup(tfile, arg->handle);
1069+
1070+
if (IS_ERR(base))
1071+
return PTR_ERR(base);
1072+
10491073
fence = &(container_of(base, struct vmw_user_fence,
10501074
base)->fence);
10511075
(void) vmw_fence_obj_reference(fence);
10521076

10531077
if (user_fence_rep != NULL) {
1054-
bool existed;
1055-
10561078
ret = ttm_ref_object_add(vmw_fp->tfile, base,
1057-
TTM_REF_USAGE, &existed);
1079+
TTM_REF_USAGE, NULL, false);
10581080
if (unlikely(ret != 0)) {
10591081
DRM_ERROR("Failed to reference a fence "
10601082
"object.\n");
@@ -1097,8 +1119,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
10971119
return 0;
10981120
out_no_create:
10991121
if (user_fence_rep != NULL)
1100-
ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
1101-
handle, TTM_REF_USAGE);
1122+
ttm_ref_object_base_unref(tfile, handle, TTM_REF_USAGE);
11021123
out_no_ref_obj:
11031124
vmw_fence_obj_unreference(&fence);
11041125
return ret;

drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
114114
param->value = dev_priv->has_dx;
115115
break;
116116
default:
117-
DRM_ERROR("Illegal vmwgfx get param request: %d\n",
118-
param->param);
119117
return -EINVAL;
120118
}
121119

@@ -186,7 +184,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
186184
bool gb_objects = !!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS);
187185
struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
188186

189-
if (unlikely(arg->pad64 != 0)) {
187+
if (unlikely(arg->pad64 != 0 || arg->max_size == 0)) {
190188
DRM_ERROR("Illegal GET_3D_CAP argument.\n");
191189
return -EINVAL;
192190
}

0 commit comments

Comments
 (0)