Skip to content

Commit e81df5b

Browse files
committed
Merge tag 'drm-misc-next-fixes-2021-02-25' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next tasty fixes for v5.12: - Cherry pick of drm-misc-fixes pull: "here's this week's PR for drm-misc-fixes. One of the patches is a memory leak; the rest is for hardware issues." - Fix dt bindings for dp connector. - Fix build error in atyfb. - Improve error handling for dma-buf heaps. - Make vblank timestamp more correct, by recording timestamp to be set when signaling. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/0f60a68c-d562-7266-0815-ea75ff680b17@linux.intel.com
2 parents 12458e3 + d922d58 commit e81df5b

14 files changed

Lines changed: 197 additions & 62 deletions

File tree

Documentation/devicetree/bindings/display/connector/dp-connector.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ properties:
2626

2727
dp-pwr-supply:
2828
description: Power supply for the DP_PWR pin
29-
maxItems: 1
3029

3130
port:
3231
$ref: /schemas/graph.yaml#/properties/port

drivers/dma-buf/dma-fence.c

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,22 +312,25 @@ void __dma_fence_might_wait(void)
312312

313313

314314
/**
315-
* dma_fence_signal_locked - signal completion of a fence
315+
* dma_fence_signal_timestamp_locked - signal completion of a fence
316316
* @fence: the fence to signal
317+
* @timestamp: fence signal timestamp in kernel's CLOCK_MONOTONIC time domain
317318
*
318319
* Signal completion for software callbacks on a fence, this will unblock
319320
* dma_fence_wait() calls and run all the callbacks added with
320321
* dma_fence_add_callback(). Can be called multiple times, but since a fence
321322
* can only go from the unsignaled to the signaled state and not back, it will
322-
* only be effective the first time.
323+
* only be effective the first time. Set the timestamp provided as the fence
324+
* signal timestamp.
323325
*
324-
* Unlike dma_fence_signal(), this function must be called with &dma_fence.lock
325-
* held.
326+
* Unlike dma_fence_signal_timestamp(), this function must be called with
327+
* &dma_fence.lock held.
326328
*
327329
* Returns 0 on success and a negative error value when @fence has been
328330
* signalled already.
329331
*/
330-
int dma_fence_signal_locked(struct dma_fence *fence)
332+
int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
333+
ktime_t timestamp)
331334
{
332335
struct dma_fence_cb *cur, *tmp;
333336
struct list_head cb_list;
@@ -341,7 +344,7 @@ int dma_fence_signal_locked(struct dma_fence *fence)
341344
/* Stash the cb_list before replacing it with the timestamp */
342345
list_replace(&fence->cb_list, &cb_list);
343346

344-
fence->timestamp = ktime_get();
347+
fence->timestamp = timestamp;
345348
set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
346349
trace_dma_fence_signaled(fence);
347350

@@ -352,6 +355,59 @@ int dma_fence_signal_locked(struct dma_fence *fence)
352355

353356
return 0;
354357
}
358+
EXPORT_SYMBOL(dma_fence_signal_timestamp_locked);
359+
360+
/**
361+
* dma_fence_signal_timestamp - signal completion of a fence
362+
* @fence: the fence to signal
363+
* @timestamp: fence signal timestamp in kernel's CLOCK_MONOTONIC time domain
364+
*
365+
* Signal completion for software callbacks on a fence, this will unblock
366+
* dma_fence_wait() calls and run all the callbacks added with
367+
* dma_fence_add_callback(). Can be called multiple times, but since a fence
368+
* can only go from the unsignaled to the signaled state and not back, it will
369+
* only be effective the first time. Set the timestamp provided as the fence
370+
* signal timestamp.
371+
*
372+
* Returns 0 on success and a negative error value when @fence has been
373+
* signalled already.
374+
*/
375+
int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp)
376+
{
377+
unsigned long flags;
378+
int ret;
379+
380+
if (!fence)
381+
return -EINVAL;
382+
383+
spin_lock_irqsave(fence->lock, flags);
384+
ret = dma_fence_signal_timestamp_locked(fence, timestamp);
385+
spin_unlock_irqrestore(fence->lock, flags);
386+
387+
return ret;
388+
}
389+
EXPORT_SYMBOL(dma_fence_signal_timestamp);
390+
391+
/**
392+
* dma_fence_signal_locked - signal completion of a fence
393+
* @fence: the fence to signal
394+
*
395+
* Signal completion for software callbacks on a fence, this will unblock
396+
* dma_fence_wait() calls and run all the callbacks added with
397+
* dma_fence_add_callback(). Can be called multiple times, but since a fence
398+
* can only go from the unsignaled to the signaled state and not back, it will
399+
* only be effective the first time.
400+
*
401+
* Unlike dma_fence_signal(), this function must be called with &dma_fence.lock
402+
* held.
403+
*
404+
* Returns 0 on success and a negative error value when @fence has been
405+
* signalled already.
406+
*/
407+
int dma_fence_signal_locked(struct dma_fence *fence)
408+
{
409+
return dma_fence_signal_timestamp_locked(fence, ktime_get());
410+
}
355411
EXPORT_SYMBOL(dma_fence_signal_locked);
356412

357413
/**
@@ -379,7 +435,7 @@ int dma_fence_signal(struct dma_fence *fence)
379435
tmp = dma_fence_begin_signalling();
380436

381437
spin_lock_irqsave(fence->lock, flags);
382-
ret = dma_fence_signal_locked(fence);
438+
ret = dma_fence_signal_timestamp_locked(fence, ktime_get());
383439
spin_unlock_irqrestore(fence->lock, flags);
384440

385441
dma_fence_end_signalling(tmp);

drivers/dma-buf/dma-heap.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
5252
unsigned int fd_flags,
5353
unsigned int heap_flags)
5454
{
55+
struct dma_buf *dmabuf;
56+
int fd;
57+
5558
/*
5659
* Allocations from all heaps have to begin
5760
* and end on page boundaries.
@@ -60,7 +63,16 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
6063
if (!len)
6164
return -EINVAL;
6265

63-
return heap->ops->allocate(heap, len, fd_flags, heap_flags);
66+
dmabuf = heap->ops->allocate(heap, len, fd_flags, heap_flags);
67+
if (IS_ERR(dmabuf))
68+
return PTR_ERR(dmabuf);
69+
70+
fd = dma_buf_fd(dmabuf, fd_flags);
71+
if (fd < 0) {
72+
dma_buf_put(dmabuf);
73+
/* just return, as put will call release and that will free */
74+
}
75+
return fd;
6476
}
6577

6678
static int dma_heap_open(struct inode *inode, struct file *file)

drivers/dma-buf/heaps/cma_heap.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ static const struct dma_buf_ops cma_heap_buf_ops = {
271271
.release = cma_heap_dma_buf_release,
272272
};
273273

274-
static int cma_heap_allocate(struct dma_heap *heap,
275-
unsigned long len,
276-
unsigned long fd_flags,
277-
unsigned long heap_flags)
274+
static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
275+
unsigned long len,
276+
unsigned long fd_flags,
277+
unsigned long heap_flags)
278278
{
279279
struct cma_heap *cma_heap = dma_heap_get_drvdata(heap);
280280
struct cma_heap_buffer *buffer;
@@ -289,7 +289,7 @@ static int cma_heap_allocate(struct dma_heap *heap,
289289

290290
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
291291
if (!buffer)
292-
return -ENOMEM;
292+
return ERR_PTR(-ENOMEM);
293293

294294
INIT_LIST_HEAD(&buffer->attachments);
295295
mutex_init(&buffer->lock);
@@ -348,15 +348,7 @@ static int cma_heap_allocate(struct dma_heap *heap,
348348
ret = PTR_ERR(dmabuf);
349349
goto free_pages;
350350
}
351-
352-
ret = dma_buf_fd(dmabuf, fd_flags);
353-
if (ret < 0) {
354-
dma_buf_put(dmabuf);
355-
/* just return, as put will call release and that will free */
356-
return ret;
357-
}
358-
359-
return ret;
351+
return dmabuf;
360352

361353
free_pages:
362354
kfree(buffer->pages);
@@ -365,7 +357,7 @@ static int cma_heap_allocate(struct dma_heap *heap,
365357
free_buffer:
366358
kfree(buffer);
367359

368-
return ret;
360+
return ERR_PTR(ret);
369361
}
370362

371363
static const struct dma_heap_ops cma_heap_ops = {

drivers/dma-buf/heaps/system_heap.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ static struct page *alloc_largest_available(unsigned long size,
331331
return NULL;
332332
}
333333

334-
static int system_heap_allocate(struct dma_heap *heap,
335-
unsigned long len,
336-
unsigned long fd_flags,
337-
unsigned long heap_flags)
334+
static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
335+
unsigned long len,
336+
unsigned long fd_flags,
337+
unsigned long heap_flags)
338338
{
339339
struct system_heap_buffer *buffer;
340340
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
@@ -349,7 +349,7 @@ static int system_heap_allocate(struct dma_heap *heap,
349349

350350
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
351351
if (!buffer)
352-
return -ENOMEM;
352+
return ERR_PTR(-ENOMEM);
353353

354354
INIT_LIST_HEAD(&buffer->attachments);
355355
mutex_init(&buffer->lock);
@@ -363,8 +363,10 @@ static int system_heap_allocate(struct dma_heap *heap,
363363
* Avoid trying to allocate memory if the process
364364
* has been killed by SIGKILL
365365
*/
366-
if (fatal_signal_pending(current))
366+
if (fatal_signal_pending(current)) {
367+
ret = -EINTR;
367368
goto free_buffer;
369+
}
368370

369371
page = alloc_largest_available(size_remaining, max_order);
370372
if (!page)
@@ -397,14 +399,7 @@ static int system_heap_allocate(struct dma_heap *heap,
397399
ret = PTR_ERR(dmabuf);
398400
goto free_pages;
399401
}
400-
401-
ret = dma_buf_fd(dmabuf, fd_flags);
402-
if (ret < 0) {
403-
dma_buf_put(dmabuf);
404-
/* just return, as put will call release and that will free */
405-
return ret;
406-
}
407-
return ret;
402+
return dmabuf;
408403

409404
free_pages:
410405
for_each_sgtable_sg(table, sg, i) {
@@ -418,7 +413,7 @@ static int system_heap_allocate(struct dma_heap *heap,
418413
__free_pages(page, compound_order(page));
419414
kfree(buffer);
420415

421-
return ret;
416+
return ERR_PTR(ret);
422417
}
423418

424419
static const struct dma_heap_ops system_heap_ops = {

drivers/gpu/drm/drm_file.c

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -775,20 +775,19 @@ void drm_event_cancel_free(struct drm_device *dev,
775775
EXPORT_SYMBOL(drm_event_cancel_free);
776776

777777
/**
778-
* drm_send_event_locked - send DRM event to file descriptor
778+
* drm_send_event_helper - send DRM event to file descriptor
779779
* @dev: DRM device
780780
* @e: DRM event to deliver
781+
* @timestamp: timestamp to set for the fence event in kernel's CLOCK_MONOTONIC
782+
* time domain
781783
*
782-
* This function sends the event @e, initialized with drm_event_reserve_init(),
783-
* to its associated userspace DRM file. Callers must already hold
784-
* &drm_device.event_lock, see drm_send_event() for the unlocked version.
785-
*
786-
* Note that the core will take care of unlinking and disarming events when the
787-
* corresponding DRM file is closed. Drivers need not worry about whether the
788-
* DRM file for this event still exists and can call this function upon
789-
* completion of the asynchronous work unconditionally.
784+
* This helper function sends the event @e, initialized with
785+
* drm_event_reserve_init(), to its associated userspace DRM file.
786+
* The timestamp variant of dma_fence_signal is used when the caller
787+
* sends a valid timestamp.
790788
*/
791-
void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
789+
void drm_send_event_helper(struct drm_device *dev,
790+
struct drm_pending_event *e, ktime_t timestamp)
792791
{
793792
assert_spin_locked(&dev->event_lock);
794793

@@ -799,7 +798,10 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
799798
}
800799

801800
if (e->fence) {
802-
dma_fence_signal(e->fence);
801+
if (timestamp)
802+
dma_fence_signal_timestamp(e->fence, timestamp);
803+
else
804+
dma_fence_signal(e->fence);
803805
dma_fence_put(e->fence);
804806
}
805807

@@ -814,6 +816,48 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
814816
wake_up_interruptible_poll(&e->file_priv->event_wait,
815817
EPOLLIN | EPOLLRDNORM);
816818
}
819+
820+
/**
821+
* drm_send_event_timestamp_locked - send DRM event to file descriptor
822+
* @dev: DRM device
823+
* @e: DRM event to deliver
824+
* @timestamp: timestamp to set for the fence event in kernel's CLOCK_MONOTONIC
825+
* time domain
826+
*
827+
* This function sends the event @e, initialized with drm_event_reserve_init(),
828+
* to its associated userspace DRM file. Callers must already hold
829+
* &drm_device.event_lock.
830+
*
831+
* Note that the core will take care of unlinking and disarming events when the
832+
* corresponding DRM file is closed. Drivers need not worry about whether the
833+
* DRM file for this event still exists and can call this function upon
834+
* completion of the asynchronous work unconditionally.
835+
*/
836+
void drm_send_event_timestamp_locked(struct drm_device *dev,
837+
struct drm_pending_event *e, ktime_t timestamp)
838+
{
839+
drm_send_event_helper(dev, e, timestamp);
840+
}
841+
EXPORT_SYMBOL(drm_send_event_timestamp_locked);
842+
843+
/**
844+
* drm_send_event_locked - send DRM event to file descriptor
845+
* @dev: DRM device
846+
* @e: DRM event to deliver
847+
*
848+
* This function sends the event @e, initialized with drm_event_reserve_init(),
849+
* to its associated userspace DRM file. Callers must already hold
850+
* &drm_device.event_lock, see drm_send_event() for the unlocked version.
851+
*
852+
* Note that the core will take care of unlinking and disarming events when the
853+
* corresponding DRM file is closed. Drivers need not worry about whether the
854+
* DRM file for this event still exists and can call this function upon
855+
* completion of the asynchronous work unconditionally.
856+
*/
857+
void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
858+
{
859+
drm_send_event_helper(dev, e, 0);
860+
}
817861
EXPORT_SYMBOL(drm_send_event_locked);
818862

819863
/**
@@ -836,7 +880,7 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
836880
unsigned long irqflags;
837881

838882
spin_lock_irqsave(&dev->event_lock, irqflags);
839-
drm_send_event_locked(dev, e);
883+
drm_send_event_helper(dev, e, 0);
840884
spin_unlock_irqrestore(&dev->event_lock, irqflags);
841885
}
842886
EXPORT_SYMBOL(drm_send_event);

drivers/gpu/drm/drm_vblank.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,14 @@ static void send_vblank_event(struct drm_device *dev,
10061006
break;
10071007
}
10081008
trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe, seq);
1009-
drm_send_event_locked(dev, &e->base);
1009+
/*
1010+
* Use the same timestamp for any associated fence signal to avoid
1011+
* mismatch in timestamps for vsync & fence events triggered by the
1012+
* same HW event. Frameworks like SurfaceFlinger in Android expects the
1013+
* retire-fence timestamp to match exactly with HW vsync as it uses it
1014+
* for its software vsync modeling.
1015+
*/
1016+
drm_send_event_timestamp_locked(dev, &e->base, now);
10101017
}
10111018

10121019
/**

drivers/gpu/drm/panel/panel-elida-kd35t133.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static int kd35t133_probe(struct mipi_dsi_device *dsi)
265265
dsi->lanes = 1;
266266
dsi->format = MIPI_DSI_FMT_RGB888;
267267
dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
268-
MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET;
268+
MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET |
269+
MIPI_DSI_CLOCK_NON_CONTINUOUS;
269270

270271
drm_panel_init(&ctx->panel, &dsi->dev, &kd35t133_funcs,
271272
DRM_MODE_CONNECTOR_DSI);

0 commit comments

Comments
 (0)