Skip to content

Commit dcad98b

Browse files
committed
Merge tag 'drm-misc-fixes-2023-10-12' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Short summary of fixes pull: * atomic-helper: Relax checks for unregistered connectors * dma-buf: Work around race condition when retrieving fence timestamp * gem: Avoid OOB access in BO memory range * panel: * boe-tv101wun-ml6: Fix flickering * simpledrm: Fix error output * vwmgfx: * Fix size calculation in texture-state code * Ref GEM BOs in surfaces Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20231012111638.GA25037@linux-uq9g
2 parents 94f6f05 + c1165df commit dcad98b

19 files changed

+115
-76
lines changed

drivers/dma-buf/dma-fence-unwrap.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,11 @@ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,
7676
dma_fence_unwrap_for_each(tmp, &iter[i], fences[i]) {
7777
if (!dma_fence_is_signaled(tmp)) {
7878
++count;
79-
} else if (test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT,
80-
&tmp->flags)) {
81-
if (ktime_after(tmp->timestamp, timestamp))
82-
timestamp = tmp->timestamp;
8379
} else {
84-
/*
85-
* Use the current time if the fence is
86-
* currently signaling.
87-
*/
88-
timestamp = ktime_get();
80+
ktime_t t = dma_fence_timestamp(tmp);
81+
82+
if (ktime_after(t, timestamp))
83+
timestamp = t;
8984
}
9085
}
9186
}

drivers/dma-buf/sync_file.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,10 @@ static int sync_fill_fence_info(struct dma_fence *fence,
268268
sizeof(info->driver_name));
269269

270270
info->status = dma_fence_get_status(fence);
271-
while (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) &&
272-
!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags))
273-
cpu_relax();
274271
info->timestamp_ns =
275-
test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags) ?
276-
ktime_to_ns(fence->timestamp) :
277-
ktime_set(0, 0);
272+
dma_fence_is_signaled(fence) ?
273+
ktime_to_ns(dma_fence_timestamp(fence)) :
274+
ktime_set(0, 0);
278275

279276
return info->status;
280277
}

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ static int
290290
update_connector_routing(struct drm_atomic_state *state,
291291
struct drm_connector *connector,
292292
struct drm_connector_state *old_connector_state,
293-
struct drm_connector_state *new_connector_state)
293+
struct drm_connector_state *new_connector_state,
294+
bool added_by_user)
294295
{
295296
const struct drm_connector_helper_funcs *funcs;
296297
struct drm_encoder *new_encoder;
@@ -339,9 +340,13 @@ update_connector_routing(struct drm_atomic_state *state,
339340
* there's a chance the connector may have been destroyed during the
340341
* process, but it's better to ignore that then cause
341342
* drm_atomic_helper_resume() to fail.
343+
*
344+
* Last, we want to ignore connector registration when the connector
345+
* was not pulled in the atomic state by user-space (ie, was pulled
346+
* in by the driver, e.g. when updating a DP-MST stream).
342347
*/
343348
if (!state->duplicated && drm_connector_is_unregistered(connector) &&
344-
crtc_state->active) {
349+
added_by_user && crtc_state->active) {
345350
drm_dbg_atomic(connector->dev,
346351
"[CONNECTOR:%d:%s] is not registered\n",
347352
connector->base.id, connector->name);
@@ -620,7 +625,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
620625
struct drm_connector *connector;
621626
struct drm_connector_state *old_connector_state, *new_connector_state;
622627
int i, ret;
623-
unsigned int connectors_mask = 0;
628+
unsigned int connectors_mask = 0, user_connectors_mask = 0;
629+
630+
for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i)
631+
user_connectors_mask |= BIT(i);
624632

625633
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
626634
bool has_connectors =
@@ -685,7 +693,8 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
685693
*/
686694
ret = update_connector_routing(state, connector,
687695
old_connector_state,
688-
new_connector_state);
696+
new_connector_state,
697+
BIT(i) & user_connectors_mask);
689698
if (ret)
690699
return ret;
691700
if (old_connector_state->crtc) {

drivers/gpu/drm/drm_gem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
540540
struct page **pages;
541541
struct folio *folio;
542542
struct folio_batch fbatch;
543-
int i, j, npages;
543+
long i, j, npages;
544544

545545
if (WARN_ON(!obj->filp))
546546
return ERR_PTR(-EINVAL);
@@ -564,11 +564,13 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
564564

565565
i = 0;
566566
while (i < npages) {
567+
long nr;
567568
folio = shmem_read_folio_gfp(mapping, i,
568569
mapping_gfp_mask(mapping));
569570
if (IS_ERR(folio))
570571
goto fail;
571-
for (j = 0; j < folio_nr_pages(folio); j++, i++)
572+
nr = min(npages - i, folio_nr_pages(folio));
573+
for (j = 0; j < nr; j++, i++)
572574
pages[i] = folio_file_page(folio, i);
573575

574576
/* Make sure shmem keeps __GFP_DMA32 allocated pages in the

drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,7 @@ static const struct panel_init_cmd starry_himax83102_j02_init_cmd[] = {
13421342
_INIT_DCS_CMD(0xB1, 0x01, 0xBF, 0x11),
13431343
_INIT_DCS_CMD(0xCB, 0x86),
13441344
_INIT_DCS_CMD(0xD2, 0x3C, 0xFA),
1345-
_INIT_DCS_CMD(0xE9, 0xC5),
1346-
_INIT_DCS_CMD(0xD3, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0C, 0x01),
1347-
_INIT_DCS_CMD(0xE9, 0x3F),
1345+
_INIT_DCS_CMD(0xD3, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0C, 0x01),
13481346
_INIT_DCS_CMD(0xE7, 0x02, 0x00, 0x28, 0x01, 0x7E, 0x0F, 0x7E, 0x10, 0xA0, 0x00, 0x00, 0x20, 0x40, 0x50, 0x40),
13491347
_INIT_DCS_CMD(0xBD, 0x02),
13501348
_INIT_DCS_CMD(0xD8, 0xFF, 0xFF, 0xBF, 0xFE, 0xAA, 0xA0, 0xFF, 0xFF, 0xBF, 0xFE, 0xAA, 0xA0),

drivers/gpu/drm/scheduler/sched_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
929929

930930
if (next) {
931931
next->s_fence->scheduled.timestamp =
932-
job->s_fence->finished.timestamp;
932+
dma_fence_timestamp(&job->s_fence->finished);
933933
/* start TO timer for next job */
934934
drm_sched_start_timeout(sched);
935935
}

drivers/gpu/drm/tiny/simpledrm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
745745

746746
ret = devm_aperture_acquire_from_firmware(dev, res->start, resource_size(res));
747747
if (ret) {
748-
drm_err(dev, "could not acquire memory range %pr: %d\n", &res, ret);
748+
drm_err(dev, "could not acquire memory range %pr: %d\n", res, ret);
749749
return ERR_PTR(ret);
750750
}
751751

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
static void vmw_bo_release(struct vmw_bo *vbo)
3636
{
37+
WARN_ON(vbo->tbo.base.funcs &&
38+
kref_read(&vbo->tbo.base.refcount) != 0);
3739
vmw_bo_unmap(vbo);
3840
drm_gem_object_release(&vbo->tbo.base);
3941
}
@@ -497,7 +499,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,
497499
if (!(flags & drm_vmw_synccpu_allow_cs)) {
498500
atomic_dec(&vmw_bo->cpu_writers);
499501
}
500-
vmw_user_bo_unref(vmw_bo);
502+
vmw_user_bo_unref(&vmw_bo);
501503
}
502504

503505
return ret;
@@ -539,7 +541,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
539541
return ret;
540542

541543
ret = vmw_user_bo_synccpu_grab(vbo, arg->flags);
542-
vmw_user_bo_unref(vbo);
544+
vmw_user_bo_unref(&vbo);
543545
if (unlikely(ret != 0)) {
544546
if (ret == -ERESTARTSYS || ret == -EBUSY)
545547
return -EBUSY;
@@ -612,7 +614,6 @@ int vmw_user_bo_lookup(struct drm_file *filp,
612614
}
613615

614616
*out = to_vmw_bo(gobj);
615-
ttm_bo_get(&(*out)->tbo);
616617

617618
return 0;
618619
}

drivers/gpu/drm/vmwgfx/vmwgfx_bo.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,19 @@ static inline struct vmw_bo *vmw_bo_reference(struct vmw_bo *buf)
195195
return buf;
196196
}
197197

198-
static inline void vmw_user_bo_unref(struct vmw_bo *vbo)
198+
static inline struct vmw_bo *vmw_user_bo_ref(struct vmw_bo *vbo)
199199
{
200-
if (vbo) {
201-
ttm_bo_put(&vbo->tbo);
202-
drm_gem_object_put(&vbo->tbo.base);
203-
}
200+
drm_gem_object_get(&vbo->tbo.base);
201+
return vbo;
202+
}
203+
204+
static inline void vmw_user_bo_unref(struct vmw_bo **buf)
205+
{
206+
struct vmw_bo *tmp_buf = *buf;
207+
208+
*buf = NULL;
209+
if (tmp_buf)
210+
drm_gem_object_put(&tmp_buf->tbo.base);
204211
}
205212

206213
static inline struct vmw_bo *to_vmw_bo(struct drm_gem_object *gobj)

drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
432432
* for the new COTable. Initially pin the buffer object to make sure
433433
* we can use tryreserve without failure.
434434
*/
435-
ret = vmw_bo_create(dev_priv, &bo_params, &buf);
435+
ret = vmw_gem_object_create(dev_priv, &bo_params, &buf);
436436
if (ret) {
437437
DRM_ERROR("Failed initializing new cotable MOB.\n");
438438
goto out_done;
@@ -502,7 +502,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
502502

503503
vmw_resource_mob_attach(res);
504504
/* Let go of the old mob. */
505-
vmw_bo_unreference(&old_buf);
505+
vmw_user_bo_unref(&old_buf);
506506
res->id = vcotbl->type;
507507

508508
ret = dma_resv_reserve_fences(bo->base.resv, 1);
@@ -521,7 +521,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
521521
out_wait:
522522
ttm_bo_unpin(bo);
523523
ttm_bo_unreserve(bo);
524-
vmw_bo_unreference(&buf);
524+
vmw_user_bo_unref(&buf);
525525

526526
out_done:
527527
MKS_STAT_TIME_POP(MKSSTAT_KERN_COTABLE_RESIZE);

0 commit comments

Comments
 (0)