Skip to content

Commit a2a04b5

Browse files
committed
Merge tag 'drm-misc-fixes-2023-02-16' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Multiple fixes in vc4 to address issues with YUV planes, HDMI and CRTC; an invalid page access fix for fbdev, mark dynamic debug as broken, a double free and refcounting fix for vmwgfx. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20230216091905.i5wswy4dd74x4br5@houat
2 parents caa068c + a950b98 commit a2a04b5

File tree

15 files changed

+57
-29
lines changed

15 files changed

+57
-29
lines changed

drivers/gpu/drm/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ config DRM_DEBUG_MM
5353

5454
config DRM_USE_DYNAMIC_DEBUG
5555
bool "use dynamic debug to implement drm.debug"
56-
default y
56+
default n
57+
depends on BROKEN
5758
depends on DRM
5859
depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE
5960
depends on JUMP_LABEL

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct ast_private *ast)
714714
struct ast_plane *ast_primary_plane = &ast->primary_plane;
715715
struct drm_plane *primary_plane = &ast_primary_plane->base;
716716
void __iomem *vaddr = ast->vram;
717-
u64 offset = ast->vram_base;
717+
u64 offset = 0; /* with shmem, the primary plane is always at offset 0 */
718718
unsigned long cursor_size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
719719
unsigned long size = ast->vram_fb_available - cursor_size;
720720
int ret;
@@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
972972
return -ENOMEM;
973973

974974
vaddr = ast->vram + ast->vram_fb_available - size;
975-
offset = ast->vram_base + ast->vram_fb_available - size;
975+
offset = ast->vram_fb_available - size;
976976

977977
ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size,
978978
0x01, &ast_cursor_plane_funcs,

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
711711
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
712712

713713
if (vc4_encoder->type == VC4_ENCODER_TYPE_HDMI0) {
714-
vc4_state->hvs_load = max(mode->clock * mode->hdisplay / mode->htotal + 1000,
714+
vc4_state->hvs_load = max(mode->clock * mode->hdisplay / mode->htotal + 8000,
715715
mode->clock * 9 / 10) * 1000;
716716
} else {
717717
vc4_state->hvs_load = mode->clock * 1000;

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@
9797
#define VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_1_SHIFT 8
9898
#define VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_1_MASK VC4_MASK(15, 8)
9999

100+
#define VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_0_MASK VC4_MASK(7, 0)
101+
#define VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_0_SET_AVMUTE BIT(0)
102+
#define VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_0_CLEAR_AVMUTE BIT(4)
103+
100104
# define VC4_HD_M_SW_RST BIT(2)
101105
# define VC4_HD_M_ENABLE BIT(0)
102106

@@ -1306,7 +1310,6 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,
13061310
VC4_HDMI_VERTB_VBP));
13071311
unsigned long flags;
13081312
unsigned char gcp;
1309-
bool gcp_en;
13101313
u32 reg;
13111314
int idx;
13121315

@@ -1341,16 +1344,13 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,
13411344
switch (vc4_state->output_bpc) {
13421345
case 12:
13431346
gcp = 6;
1344-
gcp_en = true;
13451347
break;
13461348
case 10:
13471349
gcp = 5;
1348-
gcp_en = true;
13491350
break;
13501351
case 8:
13511352
default:
1352-
gcp = 4;
1353-
gcp_en = false;
1353+
gcp = 0;
13541354
break;
13551355
}
13561356

@@ -1359,8 +1359,7 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,
13591359
* doesn't signal in GCP.
13601360
*/
13611361
if (vc4_state->output_format == VC4_HDMI_OUTPUT_YUV422) {
1362-
gcp = 4;
1363-
gcp_en = false;
1362+
gcp = 0;
13641363
}
13651364

13661365
reg = HDMI_READ(HDMI_DEEP_COLOR_CONFIG_1);
@@ -1373,11 +1372,12 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,
13731372
reg = HDMI_READ(HDMI_GCP_WORD_1);
13741373
reg &= ~VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_1_MASK;
13751374
reg |= VC4_SET_FIELD(gcp, VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_1);
1375+
reg &= ~VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_0_MASK;
1376+
reg |= VC5_HDMI_GCP_WORD_1_GCP_SUBPACKET_BYTE_0_CLEAR_AVMUTE;
13761377
HDMI_WRITE(HDMI_GCP_WORD_1, reg);
13771378

13781379
reg = HDMI_READ(HDMI_GCP_CONFIG);
1379-
reg &= ~VC5_HDMI_GCP_CONFIG_GCP_ENABLE;
1380-
reg |= gcp_en ? VC5_HDMI_GCP_CONFIG_GCP_ENABLE : 0;
1380+
reg |= VC5_HDMI_GCP_CONFIG_GCP_ENABLE;
13811381
HDMI_WRITE(HDMI_GCP_CONFIG, reg);
13821382

13831383
reg = HDMI_READ(HDMI_MISC_CONTROL);

drivers/gpu/drm/vc4/vc4_plane.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
340340
{
341341
struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
342342
struct drm_framebuffer *fb = state->fb;
343-
struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, 0);
343+
struct drm_gem_dma_object *bo;
344344
int num_planes = fb->format->num_planes;
345345
struct drm_crtc_state *crtc_state;
346346
u32 h_subsample = fb->format->hsub;
@@ -359,8 +359,10 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
359359
if (ret)
360360
return ret;
361361

362-
for (i = 0; i < num_planes; i++)
362+
for (i = 0; i < num_planes; i++) {
363+
bo = drm_fb_dma_get_gem_obj(fb, i);
363364
vc4_state->offsets[i] = bo->dma_addr + fb->offsets[i];
365+
}
364366

365367
/*
366368
* We don't support subpixel source positioning for scaling,

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ int vmw_bo_create(struct vmw_private *vmw,
462462
return -ENOMEM;
463463
}
464464

465+
/*
466+
* vmw_bo_init will delete the *p_bo object if it fails
467+
*/
465468
ret = vmw_bo_init(vmw, *p_bo, size,
466469
placement, interruptible, pin,
467470
bo_free);
@@ -470,7 +473,6 @@ int vmw_bo_create(struct vmw_private *vmw,
470473

471474
return ret;
472475
out_error:
473-
kfree(*p_bo);
474476
*p_bo = NULL;
475477
return ret;
476478
}
@@ -596,6 +598,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,
596598
ttm_bo_put(&vmw_bo->base);
597599
}
598600

601+
drm_gem_object_put(&vmw_bo->base.base);
599602
return ret;
600603
}
601604

@@ -636,6 +639,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
636639

637640
ret = vmw_user_bo_synccpu_grab(vbo, arg->flags);
638641
vmw_bo_unreference(&vbo);
642+
drm_gem_object_put(&vbo->base.base);
639643
if (unlikely(ret != 0)) {
640644
if (ret == -ERESTARTSYS || ret == -EBUSY)
641645
return -EBUSY;
@@ -693,7 +697,7 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,
693697
* struct vmw_buffer_object should be placed.
694698
* Return: Zero on success, Negative error code on error.
695699
*
696-
* The vmw buffer object pointer will be refcounted.
700+
* The vmw buffer object pointer will be refcounted (both ttm and gem)
697701
*/
698702
int vmw_user_bo_lookup(struct drm_file *filp,
699703
uint32_t handle,
@@ -710,7 +714,6 @@ int vmw_user_bo_lookup(struct drm_file *filp,
710714

711715
*out = gem_to_vmw_bo(gobj);
712716
ttm_bo_get(&(*out)->base);
713-
drm_gem_object_put(gobj);
714717

715718
return 0;
716719
}
@@ -791,7 +794,8 @@ int vmw_dumb_create(struct drm_file *file_priv,
791794
ret = vmw_gem_object_create_with_handle(dev_priv, file_priv,
792795
args->size, &args->handle,
793796
&vbo);
794-
797+
/* drop reference from allocate - handle holds it now */
798+
drm_gem_object_put(&vbo->base.base);
795799
return ret;
796800
}
797801

drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
11601160
}
11611161
ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, true, false);
11621162
ttm_bo_put(&vmw_bo->base);
1163+
drm_gem_object_put(&vmw_bo->base.base);
11631164
if (unlikely(ret != 0))
11641165
return ret;
11651166

@@ -1214,6 +1215,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,
12141215
}
12151216
ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, false, false);
12161217
ttm_bo_put(&vmw_bo->base);
1218+
drm_gem_object_put(&vmw_bo->base.base);
12171219
if (unlikely(ret != 0))
12181220
return ret;
12191221

drivers/gpu/drm/vmwgfx/vmwgfx_gem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,12 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,
146146
&vmw_sys_placement :
147147
&vmw_vram_sys_placement,
148148
true, false, &vmw_gem_destroy, p_vbo);
149-
150-
(*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;
151149
if (ret != 0)
152150
goto out_no_bo;
153151

152+
(*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;
153+
154154
ret = drm_gem_handle_create(filp, &(*p_vbo)->base.base, handle);
155-
/* drop reference from allocate - handle holds it now */
156-
drm_gem_object_put(&(*p_vbo)->base.base);
157155
out_no_bo:
158156
return ret;
159157
}
@@ -180,6 +178,8 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,
180178
rep->map_handle = drm_vma_node_offset_addr(&vbo->base.base.vma_node);
181179
rep->cur_gmr_id = handle;
182180
rep->cur_gmr_offset = 0;
181+
/* drop reference from allocate - handle holds it now */
182+
drm_gem_object_put(&vbo->base.base);
183183
out_no_bo:
184184
return ret;
185185
}

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,8 +1815,10 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
18151815

18161816
err_out:
18171817
/* vmw_user_lookup_handle takes one ref so does new_fb */
1818-
if (bo)
1818+
if (bo) {
18191819
vmw_bo_unreference(&bo);
1820+
drm_gem_object_put(&bo->base.base);
1821+
}
18201822
if (surface)
18211823
vmw_surface_unreference(&surface);
18221824

drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data,
458458
ret = vmw_overlay_update_stream(dev_priv, buf, arg, true);
459459

460460
vmw_bo_unreference(&buf);
461+
drm_gem_object_put(&buf->base.base);
461462

462463
out_unlock:
463464
mutex_unlock(&overlay->mutex);

0 commit comments

Comments
 (0)