Skip to content

Commit

Permalink
Merge tag 'drm-fixes-2022-04-08' of git://anongit.freedesktop.org/drm…
Browse files Browse the repository at this point in the history
…/drm

Pull drm fixes from Dave Airlie:
 "Main set of fixes for rc2, mostly amdgpu, but some dma-fence fixups as
  well, along with some other misc ones.

  dma-fence:
   - fix warning about fence containers
   - fix logic error in new fence merge code
   - handle empty dma_fence_arrays gracefully

  bridge:
   - Try all possible cases for bridge/panel detection.

  bindings:
   - Don't require input port for MIPI-DSI, and make width/height mandatory.

  fbdev:
   - Fix unregistering of framebuffers without device.

  nouveau:
   - Fix a crash when booting with nouveau on tegra.

  amdgpu:
   - GFX 10.3.7 fixes
   - noretry updates
   - VCN fixes
   - TMDS fix
   - zstate fix for freesync video
   - DCN 3.1.5 fix
   - Display stack size fix
   - Audio fix
   - DCN 3.1 pstate fix
   - TMZ VCN fix
   - APU passthrough fix
   - Misc other fixes
   - VCN 3.0 fixes
   - Misc display fixes
   - GC 10.3 golden register fix
   - Suspend fix
   - SMU 10 fix

  amdkfd:
   - Error handling fix
   - xgmi p2p fix
   - HWS VMIDs fix
   - Event fix

  panel:
   - ili9341: Fix optional regulator handling

  imx:
   - Catch an EDID allocation failure in imx-ldb
   - fix a leaked drm display mode on DT parsing error in parallel-display
   - properly remove the dw_hdmi bridge in case the component_add fails in dw_hdmi-imx
   - fix the IPU clock frequency debug printout in ipu-di"

* tag 'drm-fixes-2022-04-08' of git://anongit.freedesktop.org/drm/drm: (61 commits)
  dt-bindings: display: panel: mipi-dbi-spi: Make width-mm/height-mm mandatory
  fbdev: Fix unregistering of framebuffers without device
  drm/amdgpu/smu10: fix SoC/fclk units in auto mode
  drm/amd/display: update dcn315 clock table read
  drm/amdgpu/display: change pipe policy for DCN 2.1
  drm/amd/display: Add configuration options for AUX wake work around.
  drm/amd/display: remove assert for odm transition case
  drm/amdgpu: don't use BACO for reset in S3
  drm/amd/display: Fix by adding FPU protection for dcn30_internal_validate_bw
  drm/amdkfd: Create file descriptor after client is added to smi_clients list
  drm/amdgpu: Sync up header and implementation to use the same parameter names
  drm/amdgpu: fix incorrect GCR_GENERAL_CNTL address
  amd/display: set backlight only if required
  drm/amd/display: Fix allocate_mst_payload assert on resume
  drm/amd/display: Revert FEC check in validation
  drm/amd/display: Add work around for AUX failure on wake.
  drm/amd/display: Clear optc false state when disable otg
  drm/amd/display: Enable power gating before init_pipes
  drm/amd/display: Remove redundant dsc power gating from init_hw
  drm/amd/display: Correct Slice reset calculation
  ...
  • Loading branch information
torvalds committed Apr 8, 2022
2 parents 5a5dcfd + 88711fa commit 1831fed
Show file tree
Hide file tree
Showing 72 changed files with 1,031 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ properties:
Video port for MIPI DPI output (panel or connector).

required:
- port@0
- port@1

required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ properties:
Video port for MIPI DPI output (panel or connector).

required:
- port@0
- port@1

required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ properties:
required:
- compatible
- reg
- width-mm
- height-mm
- panel-timing

unevaluatedProperties: false
Expand Down
6 changes: 6 additions & 0 deletions Documentation/driver-api/dma-buf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ DMA Fence Chain
.. kernel-doc:: include/linux/dma-fence-chain.h
:internal:

DMA Fence unwrap
~~~~~~~~~~~~~~~~

.. kernel-doc:: include/linux/dma-fence-unwrap.h
:internal:

DMA Fence uABI/Sync File
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions drivers/dma-buf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dmabuf_selftests-y := \
selftest.o \
st-dma-fence.o \
st-dma-fence-chain.o \
st-dma-fence-unwrap.o \
st-dma-resv.o

obj-$(CONFIG_DMABUF_SELFTESTS) += dmabuf_selftests.o
32 changes: 32 additions & 0 deletions drivers/dma-buf/dma-fence-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
struct dma_fence_array *array;
size_t size = sizeof(*array);

WARN_ON(!num_fences || !fences);

/* Allocate the callback structures behind the array. */
size += num_fences * sizeof(struct dma_fence_array_cb);
array = kzalloc(size, GFP_KERNEL);
Expand Down Expand Up @@ -219,3 +221,33 @@ bool dma_fence_match_context(struct dma_fence *fence, u64 context)
return true;
}
EXPORT_SYMBOL(dma_fence_match_context);

struct dma_fence *dma_fence_array_first(struct dma_fence *head)
{
struct dma_fence_array *array;

if (!head)
return NULL;

array = to_dma_fence_array(head);
if (!array)
return head;

if (!array->num_fences)
return NULL;

return array->fences[0];
}
EXPORT_SYMBOL(dma_fence_array_first);

struct dma_fence *dma_fence_array_next(struct dma_fence *head,
unsigned int index)
{
struct dma_fence_array *array = to_dma_fence_array(head);

if (!array || index >= array->num_fences)
return NULL;

return array->fences[index];
}
EXPORT_SYMBOL(dma_fence_array_next);
1 change: 1 addition & 0 deletions drivers/dma-buf/selftests.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
selftest(sanitycheck, __sanitycheck__) /* keep first (igt selfcheck) */
selftest(dma_fence, dma_fence)
selftest(dma_fence_chain, dma_fence_chain)
selftest(dma_fence_unwrap, dma_fence_unwrap)
selftest(dma_resv, dma_resv)
261 changes: 261 additions & 0 deletions drivers/dma-buf/st-dma-fence-unwrap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
// SPDX-License-Identifier: MIT

/*
* Copyright (C) 2022 Advanced Micro Devices, Inc.
*/

#include <linux/dma-fence-unwrap.h>
#if 0
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/random.h>
#endif

#include "selftest.h"

#define CHAIN_SZ (4 << 10)

static inline struct mock_fence {
struct dma_fence base;
spinlock_t lock;
} *to_mock_fence(struct dma_fence *f) {
return container_of(f, struct mock_fence, base);
}

static const char *mock_name(struct dma_fence *f)
{
return "mock";
}

static const struct dma_fence_ops mock_ops = {
.get_driver_name = mock_name,
.get_timeline_name = mock_name,
};

static struct dma_fence *mock_fence(void)
{
struct mock_fence *f;

f = kmalloc(sizeof(*f), GFP_KERNEL);
if (!f)
return NULL;

spin_lock_init(&f->lock);
dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);

return &f->base;
}

static struct dma_fence *mock_array(unsigned int num_fences, ...)
{
struct dma_fence_array *array;
struct dma_fence **fences;
va_list valist;
int i;

fences = kcalloc(num_fences, sizeof(*fences), GFP_KERNEL);
if (!fences)
return NULL;

va_start(valist, num_fences);
for (i = 0; i < num_fences; ++i)
fences[i] = va_arg(valist, typeof(*fences));
va_end(valist);

array = dma_fence_array_create(num_fences, fences,
dma_fence_context_alloc(1),
1, false);
if (!array)
goto cleanup;
return &array->base;

cleanup:
for (i = 0; i < num_fences; ++i)
dma_fence_put(fences[i]);
kfree(fences);
return NULL;
}

static struct dma_fence *mock_chain(struct dma_fence *prev,
struct dma_fence *fence)
{
struct dma_fence_chain *f;

f = dma_fence_chain_alloc();
if (!f) {
dma_fence_put(prev);
dma_fence_put(fence);
return NULL;
}

dma_fence_chain_init(f, prev, fence, 1);
return &f->base;
}

static int sanitycheck(void *arg)
{
struct dma_fence *f, *chain, *array;
int err = 0;

f = mock_fence();
if (!f)
return -ENOMEM;

array = mock_array(1, f);
if (!array)
return -ENOMEM;

chain = mock_chain(NULL, array);
if (!chain)
return -ENOMEM;

dma_fence_signal(f);
dma_fence_put(chain);
return err;
}

static int unwrap_array(void *arg)
{
struct dma_fence *fence, *f1, *f2, *array;
struct dma_fence_unwrap iter;
int err = 0;

f1 = mock_fence();
if (!f1)
return -ENOMEM;

f2 = mock_fence();
if (!f2) {
dma_fence_put(f1);
return -ENOMEM;
}

array = mock_array(2, f1, f2);
if (!array)
return -ENOMEM;

dma_fence_unwrap_for_each(fence, &iter, array) {
if (fence == f1) {
f1 = NULL;
} else if (fence == f2) {
f2 = NULL;
} else {
pr_err("Unexpected fence!\n");
err = -EINVAL;
}
}

if (f1 || f2) {
pr_err("Not all fences seen!\n");
err = -EINVAL;
}

dma_fence_signal(f1);
dma_fence_signal(f2);
dma_fence_put(array);
return 0;
}

static int unwrap_chain(void *arg)
{
struct dma_fence *fence, *f1, *f2, *chain;
struct dma_fence_unwrap iter;
int err = 0;

f1 = mock_fence();
if (!f1)
return -ENOMEM;

f2 = mock_fence();
if (!f2) {
dma_fence_put(f1);
return -ENOMEM;
}

chain = mock_chain(f1, f2);
if (!chain)
return -ENOMEM;

dma_fence_unwrap_for_each(fence, &iter, chain) {
if (fence == f1) {
f1 = NULL;
} else if (fence == f2) {
f2 = NULL;
} else {
pr_err("Unexpected fence!\n");
err = -EINVAL;
}
}

if (f1 || f2) {
pr_err("Not all fences seen!\n");
err = -EINVAL;
}

dma_fence_signal(f1);
dma_fence_signal(f2);
dma_fence_put(chain);
return 0;
}

static int unwrap_chain_array(void *arg)
{
struct dma_fence *fence, *f1, *f2, *array, *chain;
struct dma_fence_unwrap iter;
int err = 0;

f1 = mock_fence();
if (!f1)
return -ENOMEM;

f2 = mock_fence();
if (!f2) {
dma_fence_put(f1);
return -ENOMEM;
}

array = mock_array(2, f1, f2);
if (!array)
return -ENOMEM;

chain = mock_chain(NULL, array);
if (!chain)
return -ENOMEM;

dma_fence_unwrap_for_each(fence, &iter, chain) {
if (fence == f1) {
f1 = NULL;
} else if (fence == f2) {
f2 = NULL;
} else {
pr_err("Unexpected fence!\n");
err = -EINVAL;
}
}

if (f1 || f2) {
pr_err("Not all fences seen!\n");
err = -EINVAL;
}

dma_fence_signal(f1);
dma_fence_signal(f2);
dma_fence_put(chain);
return 0;
}

int dma_fence_unwrap(void)
{
static const struct subtest tests[] = {
SUBTEST(sanitycheck),
SUBTEST(unwrap_array),
SUBTEST(unwrap_chain),
SUBTEST(unwrap_chain_array),
};

return subtests(tests, NULL);
}
Loading

0 comments on commit 1831fed

Please sign in to comment.