]> Git Repo - linux.git/log
linux.git
4 years agodrm/i915: give stolen system memory its own class
Matthew Auld [Fri, 5 Feb 2021 10:20:26 +0000 (10:20 +0000)]
drm/i915: give stolen system memory its own class

In some future patches we will need to also support a stolen region
carved from device local memory, on platforms like DG1. To handle this
we can simply describe each in terms of its own memory class.

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: cleanup the region class/instance encoding
Matthew Auld [Fri, 5 Feb 2021 10:20:25 +0000 (10:20 +0000)]
drm/i915: cleanup the region class/instance encoding

Get rid of the strange REGION_MAP encoding stuff and just use an
explicit class/instance pair for each region. This better matches our
future uAPI where all queryable regions are identified with a u16 class
and u16 instance.

v2: fix whitespace

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Double check heartbeat timeout before resetting
Chris Wilson [Thu, 4 Feb 2021 21:13:03 +0000 (21:13 +0000)]
drm/i915/gt: Double check heartbeat timeout before resetting

Check that we have actually passed the heartbeat interval since last
checking the request before resetting the device.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2780
Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/selftests: Restore previous heartbeat interval
Chris Wilson [Thu, 4 Feb 2021 21:13:02 +0000 (21:13 +0000)]
drm/i915/selftests: Restore previous heartbeat interval

Use the defaults we store on the engine when resetting the heartbeat as
we may have had to adjust it from the config value during initialisation.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gtt/dg1: add PTE_LM plumbing for GGTT
Matthew Auld [Wed, 3 Feb 2021 17:12:31 +0000 (17:12 +0000)]
drm/i915/gtt/dg1: add PTE_LM plumbing for GGTT

For the PTEs we get an LM bit, to signal whether the page resides in
SMEM or LMEM.

Based on a patch from Michel Thierry.

BSpec: 45015

Signed-off-by: Matthew Auld <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Signed-off-by: Daniele Ceraolo Spurio <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gtt/dg1: add PTE_LM plumbing for ppGTT
Matthew Auld [Wed, 3 Feb 2021 17:12:30 +0000 (17:12 +0000)]
drm/i915/gtt/dg1: add PTE_LM plumbing for ppGTT

For the PTEs we get an LM bit, to signal whether the page resides in
SMEM or LMEM.

BSpec: 45040

v2: just use gen8_pte_encode for dg1

Signed-off-by: Matthew Auld <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Signed-off-by: Daniele Ceraolo Spurio <[email protected]>
Signed-off-by: Niranjana Vishwanathapura <[email protected]>
Signed-off-by: Venkata Sandeep Dhanalakota <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: Distinction of memory regions
Zbigniew Kempczyński [Wed, 3 Feb 2021 17:12:29 +0000 (17:12 +0000)]
drm/i915: Distinction of memory regions

In preparation for Xe HP multi-tile architecture with multiple memory
regions, we need to be able differentiate multiple instances of device
local-memory.

Note that the region name is just to give it a human friendly
identifier, instead of using class/instance which also uniquely
identifies the region. So far the region name is only for our own
internal debugging in the kernel(like in the selftests), or debugfs
which prints the list of regions, including the regions name.

v2: add commentary for our current region name use

Signed-off-by: Zbigniew Kempczyński <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Retire unexpected starting state error dumping
Chris Wilson [Mon, 1 Feb 2021 16:42:22 +0000 (16:42 +0000)]
drm/i915/gt: Retire unexpected starting state error dumping

We have not seen an occurrence of the false restart state recenty, and if
we did see such an event from inside engine-reset, it would deadlock on
trying to suspend the tasklet to read the register state (from inside
the tasklet). Instead, we inspect the context state before submission
which will alert us to any issues prior to execution on HW.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Mika Kuoppala <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: Andi Shyti <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/selftests: Use a single copy of the mocs table
Chris Wilson [Mon, 1 Feb 2021 10:04:48 +0000 (10:04 +0000)]
drm/i915/selftests: Use a single copy of the mocs table

Instead of copying the whole table to each category (mocs, l3cc), use a
single table with a pointer to it if the category is enabled.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: Protect against request freeing during cancellation on wedging
Chris Wilson [Mon, 1 Feb 2021 08:56:22 +0000 (08:56 +0000)]
drm/i915: Protect against request freeing during cancellation on wedging

As soon as we mark a request as completed, it may be retired. So when
cancelling a request and marking it complete, make sure we first keep a
reference to the request.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: allocate cmd ring in lmem
Michel Thierry [Wed, 27 Jan 2021 13:14:17 +0000 (13:14 +0000)]
drm/i915: allocate cmd ring in lmem

Prefer allocating the cmd ring from LMEM on dgfx.

Signed-off-by: Michel Thierry <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: move engine scratch to LMEM
Matthew Auld [Wed, 27 Jan 2021 13:14:16 +0000 (13:14 +0000)]
drm/i915: move engine scratch to LMEM

Prefer allocating the engine scratch from LMEM on dgfx.

v2: flatten the chain

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: allocate context from LMEM
Matthew Auld [Wed, 27 Jan 2021 13:14:15 +0000 (13:14 +0000)]
drm/i915: allocate context from LMEM

Prefer allocating the context from LMEM on dgfx.

Based on a patch from Michel Thierry.

v2: flatten the chain

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/dg1: Reserve first 1MB of local memory
Imre Deak [Wed, 27 Jan 2021 13:14:14 +0000 (13:14 +0000)]
drm/i915/dg1: Reserve first 1MB of local memory

On DG1 A0/B0 steppings the first 1MB of local memory must be reserved.
One reason for this is that the 0xA0000-0xB0000 range is not accessible
by the display, probably since this region is redirected to another
memory location for legacy VGA compatibility.

BSpec: 50586
Testcase: igt/kms_big_fb/linear-64bpp-rotate-0

v2:
- Reserve the memory on B0 as well.

v3: replace DRM_DEBUG/DRM_ERROR with drm_dbg/drm_err

v4: fix the insanity

Signed-off-by: Imre Deak <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: introduce mem->reserved
Abdiel Janulgue [Wed, 27 Jan 2021 13:14:13 +0000 (13:14 +0000)]
drm/i915: introduce mem->reserved

In the following patch we need to reserve regions unaccessible to the
driver during initialization, so add mem->reserved for collecting such
regions.

v2: turn into an actual intel_memory_region_reserve api

Cc: Imre Deak <[email protected]>
Signed-off-by: Abdiel Janulgue <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: reserve stolen for LMEM region
CQ Tang [Wed, 27 Jan 2021 13:14:12 +0000 (13:14 +0000)]
drm/i915: reserve stolen for LMEM region

The lmem region needs to remove the stolen part, which should just be a
case of snipping it off the end.

Signed-off-by: CQ Tang <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: setup the LMEM region
Matthew Auld [Wed, 27 Jan 2021 13:14:11 +0000 (13:14 +0000)]
drm/i915: setup the LMEM region

Hook up the LMEM region. Addresses will start from zero, and for CPU
access we get LMEM_BAR which is just a 1:1 mapping of said region.

Based on a patch from Michel Thierry.

v2 by Jani:
- use intel_uncore_read/intel_uncore_write
- remove trailing blank line

v3: s/drm_info/drm_dbg for info which in non-pertinent for the user

Cc: Lucas De Marchi <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Signed-off-by: Lucas De Marchi <[email protected]>
Signed-off-by: Jani Nikula <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: make local-memory probing a GT operation
Matthew Auld [Wed, 27 Jan 2021 13:14:10 +0000 (13:14 +0000)]
drm/i915: make local-memory probing a GT operation

Device local memory is very much a GT thing, therefore it should be the
responsibility of the GT to setup the device local memory region.

Suggested-by: Tvrtko Ursulin <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
[danvet: Rebase conflict.]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: use new tasklet API for execution list
Emil Renner Berthing [Tue, 26 Jan 2021 15:01:55 +0000 (16:01 +0100)]
drm/i915/gt: use new tasklet API for execution list

This converts the driver to use the new tasklet API introduced in
commit 12cc923f1ccc ("tasklet: Introduce new initialization API")

v2: Fix up selftests/execlists.

Signed-off-by: Emil Renner Berthing <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/buddy: document the unused header bits
Matthew Auld [Tue, 26 Jan 2021 10:30:19 +0000 (10:30 +0000)]
drm/i915/buddy: document the unused header bits

The largest possible order is (63-PAGE_SHIFT), given that our min chunk
size is PAGE_SIZE. With that we should only need at most 6 bits to
represent all possible orders, giving us back 4 bits for other potential
uses.  Include a simple selftest to verify this.

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Move the defer_request waiter active assertion
Chris Wilson [Mon, 25 Jan 2021 14:00:57 +0000 (14:00 +0000)]
drm/i915/gt: Move the defer_request waiter active assertion

In defer_request() we start with the request we just unsubmitted (that
should be the active request on the gpu) and then defer all of its
waiters. No waiter should be ahead of the active request, so none should
be marked as active. That assert failed.

Of particular note this machine was undergoing persistent GPU resets due
to underlying HW issues, so that may be a clue. A request is also marked
as active when it is retired, regardless of current queue status, and so
this assertion failure may be a result of the queue being completed by
the reset and then subsequently processed by the tasklet.

We can filter out retired requests here by doing the assertion check
after the is-ready check (active is a subset of being ready).

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2978
Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/selftests: Check for engine-reset errors in the middle of workarounds
Chris Wilson [Mon, 25 Jan 2021 14:00:56 +0000 (14:00 +0000)]
drm/i915/selftests: Check for engine-reset errors in the middle of workarounds

As we reset the engine between verifying the workarounds remain intact,
report an engine reset failure.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gem: consolidate 2big error checking for object sizes
Matthew Auld [Fri, 22 Jan 2021 18:15:14 +0000 (18:15 +0000)]
drm/i915/gem: consolidate 2big error checking for object sizes

Throw it into a simple helper, and throw a warning if we encounter an
object which has been initialised with an object size that exceeds our
limit of INT_MAX pages.

Suggested-by: Chris Wilson <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gem: don't trust the dma_buf->size
Matthew Auld [Fri, 22 Jan 2021 18:15:13 +0000 (18:15 +0000)]
drm/i915/gem: don't trust the dma_buf->size

At least for the time being, we need to limit our object sizes such that
the number of pages can fit within a 32b signed int. It looks like we
should also apply the same restriction to any imported dma-buf.

Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Replace 'return' with a fall-through
Chris Wilson [Fri, 22 Jan 2021 19:29:13 +0000 (19:29 +0000)]
drm/i915/gt: Replace 'return' with a fall-through

Checkpatch worries that the 'return' before an else clause might be
redundant. In this case, it is avoiding hitting the MISSING_CASE()
warning. Let us appease checkpatch by falling through to the end of the
function, which typically means that we then clean up the unused
wa_list.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Add a space before '('
Chris Wilson [Fri, 22 Jan 2021 19:29:12 +0000 (19:29 +0000)]
drm/i915/gt: Add a space before '('

Checkpatch noticed a while(0) and complains about the lack of space.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Replace unnecessary ',' with '; '
Chris Wilson [Fri, 22 Jan 2021 19:29:11 +0000 (19:29 +0000)]
drm/i915/gt: Replace unnecessary ',' with '; '

Checkpatch spotted a couple of commas where we can use the more common
';', and so not worry about the subtle implications of sequence points.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Insert spaces into GEN3_L3LOG_SIZE/4
Chris Wilson [Fri, 22 Jan 2021 19:29:10 +0000 (19:29 +0000)]
drm/i915/gt: Insert spaces into GEN3_L3LOG_SIZE/4

Checkpatch wants spaces, let's give it some spaces.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Wrap macro arg in ()
Chris Wilson [Fri, 22 Jan 2021 19:29:09 +0000 (19:29 +0000)]
drm/i915/gt: Wrap macro arg in ()

Checkpatch noticed that ppgtt->pd should have been (ppgtt)->pd to avoid
issues with macros.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Remove a bonus newline
Chris Wilson [Fri, 22 Jan 2021 19:29:08 +0000 (19:29 +0000)]
drm/i915/gt: Remove a bonus newline

Trailing newlines before closing the function are best forgotten, or
else checkpatch moans.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Fixup misaligned function parameters
Chris Wilson [Fri, 22 Jan 2021 19:29:07 +0000 (19:29 +0000)]
drm/i915/gt: Fixup misaligned function parameters

Remember to align parameters to the '(', thanks checkpatch

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Remove repeated words from comments
Chris Wilson [Fri, 22 Jan 2021 19:29:06 +0000 (19:29 +0000)]
drm/i915/gt: Remove repeated words from comments

Checkpatch spotted a few repeated words in the comment, genuine
mistakes.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Add some missing blank lines after declaration
Chris Wilson [Fri, 22 Jan 2021 19:29:05 +0000 (19:29 +0000)]
drm/i915/gt: Add some missing blank lines after declaration

Trivial checkpatch cleanup.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: SPDX cleanup
Chris Wilson [Fri, 22 Jan 2021 19:29:04 +0000 (19:29 +0000)]
drm/i915/gt: SPDX cleanup

Clean up the SPDX licence declarations to comply with checkpatch.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Michal Wajdeczko <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: Decrease number of subplatform bits
Tvrtko Ursulin [Thu, 21 Jan 2021 16:19:36 +0000 (16:19 +0000)]
drm/i915: Decrease number of subplatform bits

Commit 6ce1c33d6c36 ("drm/i915: Kill INTEL_SUBPLATFORM_AML") removed the
only platform which used bit 2 so could also decrease the
INTEL_SUBPLATFORM_BITS definition.

This is not a fixes material but still lets make it precise.

v2:
 * Fix assert in intel_device_info_subplatform_init by introducing
   INTEL_SUBPLATFORM_MASK. (Chris)
 * Update intel_subplatform().

Signed-off-by: Tvrtko Ursulin <[email protected]>
References: 6ce1c33d6c36 ("drm/i915: Kill INTEL_SUBPLATFORM_AML")
Cc: Chris Wilson <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/gt: Call stop_ring() from ring resume, again
Chris Wilson [Thu, 21 Jan 2021 15:49:50 +0000 (15:49 +0000)]
drm/i915/gt: Call stop_ring() from ring resume, again

For reasons I cannot explain, except to say this is Sandybridge after
all, call stop_ring() again dring ring resume in order to prevent
mysterious hard hangs.

Testcase: igt/i915_selftest/hangcheck # snb
Signed-off-by: Chris Wilson <[email protected]>
Cc: Mika Kuoppala <[email protected]>
Acked-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: Remove I915_USER_PRIORITY_SHIFT
Chris Wilson [Wed, 20 Jan 2021 12:14:39 +0000 (12:14 +0000)]
drm/i915: Remove I915_USER_PRIORITY_SHIFT

As we do not have any internal priority levels, the priority can be set
directed from the user values.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915: Strip out internal priorities
Chris Wilson [Wed, 20 Jan 2021 12:14:38 +0000 (12:14 +0000)]
drm/i915: Strip out internal priorities

Since we are not using any internal priority levels, and in the next few
patches will introduce a new index for which the optimisation is not so
lear cut, discard the small table within the priolist.

Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
4 years agodrm/i915/audio: set HDA link parameters in driver
Kai Vehmanen [Wed, 24 Mar 2021 12:37:25 +0000 (14:37 +0200)]
drm/i915/audio: set HDA link parameters in driver

Update logic to program AUD_FREQ_CNTRL register based on new guidance.
Earlier this register was configured by BIOS and driver discovered the
value at init. This is no longer recommended and instead driver should
set the values based on the hardware revision.

Add the recommended values for all supported hardware. This change applies
for all GEN12+ hardware. For TGL, some special case handling is needed
to not break existing systems.

Extend the debug print to also include values of the register as written
by BIOS. This can help debug rare cases where BIOS has configured the link
settings to incorrect values.

Bspec: 49279
Signed-off-by: Kai Vehmanen <[email protected]>
Reviewed-by: Uma Shankar <[email protected]>
Signed-off-by: Uma Shankar <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Move gt_revoke() slightly
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:52 +0000 (16:50 +0100)]
drm/i915: Move gt_revoke() slightly

We get a lockdep splat when the reset mutex is held, because it can be
taken from fence_wait. This conflicts with the mmu notifier we have,
because we recurse between reset mutex and mmap lock -> mmu notifier.

Remove this recursion by calling revoke_mmaps before taking the lock.

The reset code still needs fixing, as taking mmap locks during reset
is not allowed.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Add FIXME.]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Keep userpointer bindings if seqcount is unchanged, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:51 +0000 (16:50 +0100)]
drm/i915: Keep userpointer bindings if seqcount is unchanged, v2.

Instead of force unbinding and rebinding every time, we try to check
if our notifier seqcount is still correct when pages are bound. This
way we only rebind userptr when we need to, and prevent stalls.

Changes since v1:
- Missing mutex_unlock, reported by kbuild.

Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Maarten Lankhorst <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Finally remove obj->mm.lock.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:50 +0000 (16:50 +0100)]
drm/i915: Finally remove obj->mm.lock.

With all callers and selftests fixed to use ww locking, we can now
finally remove this lock.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare gtt tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:49 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare gtt tests for obj->mm.lock removal

We need to lock the global gtt dma_resv, use i915_vm_lock_objects
to handle this correctly. Add ww handling for this where required.

Add the object lock around unpin/put pages, and use the unlocked
versions of pin_pages and pin_map where required.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare cs engine tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:48 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare cs engine tests for obj->mm.lock removal

Same as other tests, use pin_map_unlocked.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare memory region tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:47 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare memory region tests for obj->mm.lock removal

Use the unlocked variants for pin_map and pin_pages, and add lock
around unpinning/putting pages.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare i915_request tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:46 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare i915_request tests for obj->mm.lock removal

Straightforward conversion by using unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare timeline tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:45 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare timeline tests for obj->mm.lock removal

We can no longer call intel_timeline_pin with a null argument,
so add a ww loop that locks the backing object.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare ring submission for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:44 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare ring submission for obj->mm.lock removal

Use unlocked versions when the ww lock is not held.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare mocs tests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:43 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare mocs tests for obj->mm.lock removal

Use pin_map_unlocked when we're not holding locks.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare execlists and lrc selftests for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:42 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare execlists and lrc selftests for obj->mm.lock removal

Convert normal functions to unlocked versions where needed.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare hangcheck for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:41 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare hangcheck for obj->mm.lock removal

Convert a few calls to use the unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare context selftest for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:40 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare context selftest for obj->mm.lock removal

Only needs to convert a single call to the unlocked version.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare igt_gem_utils for obj->mm.lock removal
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:39 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare igt_gem_utils for obj->mm.lock removal

igt_emit_store_dw needs to use the unlocked version, as it's not
holding a lock. This fixes igt_gpu_fill_dw() which is used by
some other selftests.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare object blit tests for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:38 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare object blit tests for obj->mm.lock removal.

Use some unlocked versions where we're not holding the ww lock.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare object tests for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:37 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare object tests for obj->mm.lock removal.

Convert a single pin_pages call to use the unlocked version.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare mman testcases for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:36 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare mman testcases for obj->mm.lock removal.

Ensure we hold the lock around put_pages, and use the unlocked wrappers
for pinning pages and mappings.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare execbuf tests for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:35 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare execbuf tests for obj->mm.lock removal.

Also quite simple, a single call needs to use the unlocked version.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare dma-buf tests for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:34 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare dma-buf tests for obj->mm.lock removal.

Use pin_pages_unlocked() where we don't have a lock.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare context tests for obj->mm.lock removal.
Maarten Lankhorst [Thu, 28 Jan 2021 16:25:53 +0000 (17:25 +0100)]
drm/i915/selftests: Prepare context tests for obj->mm.lock removal.

Straightforward conversion, just convert a bunch of calls to
unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare coherency tests for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:32 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare coherency tests for obj->mm.lock removal.

Straightforward conversion, just convert a bunch of calls to
unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare client blit for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:31 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare client blit for obj->mm.lock removal.

Straightforward conversion, just convert a bunch of calls to
unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915/selftests: Prepare huge_pages testcases for obj->mm.lock removal.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:30 +0000 (16:50 +0100)]
drm/i915/selftests: Prepare huge_pages testcases for obj->mm.lock removal.

Straightforward conversion, just convert a bunch of calls to
unlocked versions.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Use a single page table lock for each gtt.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:29 +0000 (16:50 +0100)]
drm/i915: Use a single page table lock for each gtt.

We may create page table objects on the fly, but we may need to
wait with the ww lock held. Instead of waiting on a freed obj
lock, ensure we have the same lock for each object to keep
-EDEADLK working. This ensures that i915_vma_pin_ww can lock
the page tables when required.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Fix ww locking in shmem_create_from_object
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:28 +0000 (16:50 +0100)]
drm/i915: Fix ww locking in shmem_create_from_object

Quick fix, just use the unlocked version.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add missing ww lock in intel_dsb_prepare.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:27 +0000 (16:50 +0100)]
drm/i915: Add missing ww lock in intel_dsb_prepare.

Because of the long lifetime of the mapping, we cannot wrap this in a
simple limited ww lock. Just use the unlocked version of pin_map,
because we'll likely release the mapping a lot later, in a different
thread.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add ww locking to dma-buf ops, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:26 +0000 (16:50 +0100)]
drm/i915: Add ww locking to dma-buf ops, v2.

vmap is using pin_pages, but needs to use ww locking,
add pin_pages_unlocked to correctly lock the mapping.

Also add ww locking to begin/end cpu access.

Changes since v1:
- Fix i915_gem_map_dma_buf by using pin_pages_unlocked().

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Lock ww in ucode objects correctly
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:25 +0000 (16:50 +0100)]
drm/i915: Lock ww in ucode objects correctly

In the ucode functions, the calls are done before userspace runs,
when debugging using debugfs, or when creating semi-permanent mappings;
we can safely use the unlocked versions that does the ww dance for us.

Because there is no pin_pages_unlocked yet, add it as convenience function.

This removes possible lockdep splats about missing resv lock for ucode.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Increase ww locking for perf.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:24 +0000 (16:50 +0100)]
drm/i915: Increase ww locking for perf.

We need to lock a few more objects, some temporarily,
add ww lock where needed.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add ww locking around vm_access()
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:23 +0000 (16:50 +0100)]
drm/i915: Add ww locking around vm_access()

i915_gem_object_pin_map potentially needs a ww context, so ensure we
have one we can revoke.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add igt_spinner_pin() to allow for ww locking around spinner.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:22 +0000 (16:50 +0100)]
drm/i915: Add igt_spinner_pin() to allow for ww locking around spinner.

By default, we assume that it's called inside igt_create_request
to keep existing selftests working, but allow for manual pinning
when passing a ww context.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Prepare for obj->mm.lock removal, v2.
Thomas Hellström [Tue, 23 Mar 2021 15:50:21 +0000 (16:50 +0100)]
drm/i915: Prepare for obj->mm.lock removal, v2.

Stolen objects need to lock, and we may call put_pages when
refcount drops to 0, ensure all calls are handled correctly.

Changes since v1:
- Rebase on top of upstream changes.

Idea-from: Thomas Hellström <[email protected]>
Signed-off-by: Thomas Hellström <[email protected]>
Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Matthew Auld <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Fix workarounds selftest, part 1
Maarten Lankhorst [Thu, 28 Jan 2021 16:25:40 +0000 (17:25 +0100)]
drm/i915: Fix workarounds selftest, part 1

pin_map needs the ww lock, so ensure we pin both before submission.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Again pick older version just to side-step conflicts.]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Fix pread/pwrite to work with new locking rules.
Maarten Lankhorst [Thu, 28 Jan 2021 16:25:39 +0000 (17:25 +0100)]
drm/i915: Fix pread/pwrite to work with new locking rules.

We are removing obj->mm.lock, and need to take the reservation lock
before we can pin pages. Move the pinning pages into the helper, and
merge gtt pwrite/pread preparation and cleanup paths.

The fence lock is also removed; it will conflict with fence annotations,
because of memory allocations done when pagefaulting inside copy_*_user.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Pick the older version to avoid the conflicts]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Defer pin calls in buffer pool until first use by caller.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:18 +0000 (16:50 +0100)]
drm/i915: Defer pin calls in buffer pool until first use by caller.

We need to take the obj lock to pin pages, so wait until the callers
have done so, before making the object unshrinkable.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Take obj lock around set_domain ioctl
Maarten Lankhorst [Thu, 28 Jan 2021 16:25:37 +0000 (17:25 +0100)]
drm/i915: Take obj lock around set_domain ioctl

We need to lock the object to move it to the correct domain,
add the missing lock.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Pick version from an older patch series.]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Make __engine_unpark() compatible with ww locking.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:16 +0000 (16:50 +0100)]
drm/i915: Make __engine_unpark() compatible with ww locking.

Take the ww lock around engine_unpark. Because of the
many many places where rpm is used, I chose the safest option
and used a trylock to opportunistically take this lock for
__engine_unpark.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Make lrc_init_wa_ctx compatible with ww locking, v3.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:15 +0000 (16:50 +0100)]
drm/i915: Make lrc_init_wa_ctx compatible with ww locking, v3.

Make creation separate from pinning, in order to take the lock only
once, and pin the mapping with the lock held.

Changes since v1:
- Rebase on top of upstream changes.
Changes since v2:
- Fully clear wa_ctx on error.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Take reservation lock around i915_vma_pin.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:14 +0000 (16:50 +0100)]
drm/i915: Take reservation lock around i915_vma_pin.

We previously complained when ww == NULL.

This function is now only used in selftests to pin an object,
and ww locking is now fixed.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Resolve conflict because we don't have a set-domain refactor,
see
https://lore.kernel.org/intel-gfx/20210203090205[email protected]/

The really worrying thing here is that the above patch had a change in
arguments for i915_gem_object_set_to_gtt_domain(), without any
explanation. I decided to just faithfully apply Maarten's change but
not the argument change which was in Maarten's context diff.]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Move pinning to inside engine_wa_list_verify()
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:13 +0000 (16:50 +0100)]
drm/i915: Move pinning to inside engine_wa_list_verify()

This should be done as part of the ww loop, in order to remove a
i915_vma_pin that needs ww held.

Now only i915_ggtt_pin() callers remaining.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add object locking to vm_fault_cpu
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:12 +0000 (16:50 +0100)]
drm/i915: Add object locking to vm_fault_cpu

Take a simple lock so we hold ww around (un)pin_pages as needed.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Pass ww ctx to intel_pin_to_display_plane
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:11 +0000 (16:50 +0100)]
drm/i915: Pass ww ctx to intel_pin_to_display_plane

Instead of multiple lockings, lock the object once,
and perform the ww dance around attach_phys and pin_pages.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Rework clflush to work correctly without obj->mm.lock.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:10 +0000 (16:50 +0100)]
drm/i915: Rework clflush to work correctly without obj->mm.lock.

Pin in the caller, not in the work itself. This should also
work better for dma-fence annotations.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Handle ww locking in init_status_page
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:09 +0000 (16:50 +0100)]
drm/i915: Handle ww locking in init_status_page

Try to pin to ggtt first, and use a full ww loop to handle
eviction correctly.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Make ring submission compatible with obj->mm.lock removal, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:08 +0000 (16:50 +0100)]
drm/i915: Make ring submission compatible with obj->mm.lock removal, v2.

We map the initial context during first pin.

This allows us to remove pin_map from state allocation, which saves
us a few retry loops. We won't need this until first pin anyway.

intel_ring_submission_setup() is also reworked slightly to do all
pinning in a single ww loop.

Changes since v1:
- Handle -EDEADLK backoff in intel_ring_submission_setup() better.
- Handle smatch errors reported by Dan and testbot.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Populate logical context during first pin.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:07 +0000 (16:50 +0100)]
drm/i915: Populate logical context during first pin.

This allows us to remove pin_map from state allocation, which saves
us a few retry loops. We won't need this until first pin, anyway.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Resolve context conflict because we don't have the
i915_scheduler.c extraction from the below patches set:
https://lore.kernel.org/intel-gfx/20210203165259[email protected]/]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Flatten obj->mm.lock
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:06 +0000 (16:50 +0100)]
drm/i915: Flatten obj->mm.lock

With userptr fixed, there is no need for all separate lockdep classes
now, and we can remove all lockdep tricks used. A trylock in the
shrinker is all we need now to flatten the locking hierarchy.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: Resolve conflict because we don't have the patch from Chris
to rebrand i915_gem_shrinker_taints_mutex to fs_reclaim_taints_mutex.
It's not a bad idea, but if we do it, it should be moved to the right
header. See
https://lore.kernel.org/intel-gfx/20210202154318[email protected]/]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Fix userptr so we do not have to worry about obj->mm.lock, v7.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:05 +0000 (16:50 +0100)]
drm/i915: Fix userptr so we do not have to worry about obj->mm.lock, v7.

Instead of doing what we do currently, which will never work with
PROVE_LOCKING, do the same as AMD does, and something similar to
relocation slowpath. When all locks are dropped, we acquire the
pages for pinning. When the locks are taken, we transfer those
pages in .get_pages() to the bo. As a final check before installing
the fences, we ensure that the mmu notifier was not called; if it is,
we return -EAGAIN to userspace to signal it has to start over.

Changes since v1:
- Unbinding is done in submit_init only. submit_begin() removed.
- MMU_NOTFIER -> MMU_NOTIFIER
Changes since v2:
- Make i915->mm.notifier a spinlock.
Changes since v3:
- Add WARN_ON if there are any page references left, should have been 0.
- Return 0 on success in submit_init(), bug from spinlock conversion.
- Release pvec outside of notifier_lock (Thomas).
Changes since v4:
- Mention why we're clearing eb->[i + 1].vma in the code. (Thomas)
- Actually check all invalidations in eb_move_to_gpu. (Thomas)
- Do not wait when process is exiting to fix gem_ctx_persistence.userptr.
Changes since v5:
- Clarify why check on PF_EXITING is (temporarily) required.
Changes since v6:
- Ensure userptr validity is checked in set_domain through a special path.

Signed-off-by: Maarten Lankhorst <[email protected]>
Acked-by: Dave Airlie <[email protected]>
[danvet: s/kfree/kvfree/ in i915_gem_object_userptr_drop_ref in the
previous review round, but which got lost. The other open questions
around page refcount are imo better discussed in a separate series,
with amdgpu folks involved].
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Make compilation of userptr code depend on MMU_NOTIFIER.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:04 +0000 (16:50 +0100)]
drm/i915: Make compilation of userptr code depend on MMU_NOTIFIER.

Now that unsynchronized mappings are removed, the only time userptr
works is when the MMU notifier is enabled. Put all of the userptr
code behind a mmu notifier ifdef.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Reject UNSYNCHRONIZED for userptr, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:03 +0000 (16:50 +0100)]
drm/i915: Reject UNSYNCHRONIZED for userptr, v2.

We should not allow this any more, as it will break with the new userptr
implementation, it could still be made to work, but there's no point in
doing so.

Inspection of the beignet opencl driver shows that it's only used
when normal userptr is not available, which means for new kernels
you will need CONFIG_I915_USERPTR.

Signed-off-by: Maarten Lankhorst <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Reject more ioctls for userptr, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:02 +0000 (16:50 +0100)]
drm/i915: Reject more ioctls for userptr, v2.

There are a couple of ioctl's related to tiling and cache placement,
that make no sense for userptr, reject those:
- i915_gem_set_tiling_ioctl()
    Tiling should always be linear for userptr. Changing placement will
    fail with -ENXIO.
- i915_gem_set_caching_ioctl()
    Userptr memory should always be cached. Changing caching mode will
    fail with -ENXIO.
- i915_gem_set_domain_ioctl()
    Still temporarily allowed to work as intended, it's used to check
    userptr validity. With the reworked userptr code, it will keep
    working for this usecase.

This plus the previous changes have been tested against beignet
by using its own unit tests, and intel-video-compute by using
piglit's opencl tests.

Changes since v1:
- set_domain was apparently used in iris for checking userptr validity,
  keep it working as intended.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: No longer allow exporting userptr through dma-buf
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:01 +0000 (16:50 +0100)]
drm/i915: No longer allow exporting userptr through dma-buf

It doesn't make sense to export a memory address, we will prevent
allowing access this way to different address spaces when we
rework userptr handling, so best to explicitly disable it.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Disable userptr pread/pwrite support.
Maarten Lankhorst [Tue, 23 Mar 2021 15:50:00 +0000 (16:50 +0100)]
drm/i915: Disable userptr pread/pwrite support.

Userptr should not need the kernel for a userspace memcpy, userspace
needs to call memcpy directly.

Specifically, disable i915_gem_pwrite_ioctl() and i915_gem_pread_ioctl().

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/ttm: switch to per device LRU lock
Christian König [Tue, 6 Oct 2020 15:26:42 +0000 (17:26 +0200)]
drm/ttm: switch to per device LRU lock

Instead of having a global lock for potentially less contention.

Signed-off-by: Christian König <[email protected]>
Tested-by: Nirmoy Das <[email protected]>
Reviewed-by: Huang Rui <[email protected]>
Reviewed-by: Matthew Auld <[email protected]>
Link: https://patchwork.freedesktop.org/patch/424010/
4 years agodrm/ttm: remove swap LRU v3
Christian König [Tue, 6 Oct 2020 14:30:09 +0000 (16:30 +0200)]
drm/ttm: remove swap LRU v3

Instead evict round robin from each devices SYSTEM and TT domain.

v2: reorder num_pages access reported by Dan's script
v3: fix rebase fallout, num_pages should be 32bit

Signed-off-by: Christian König <[email protected]>
Tested-by: Nirmoy Das <[email protected]>
Reviewed-by: Huang Rui <[email protected]>
Reviewed-by: Matthew Auld <[email protected]>
Link: https://patchwork.freedesktop.org/patch/424009/
4 years agodrm/ttm: move swapout logic around v3
Christian König [Tue, 6 Oct 2020 11:35:32 +0000 (13:35 +0200)]
drm/ttm: move swapout logic around v3

Move the iteration of the global lru into the new function
ttm_global_swapout() and use that instead in drivers.

v2: consistently return int
v3: fix build fail

Signed-off-by: Christian König <[email protected]>
Tested-by: Nirmoy Das <[email protected]>
Reviewed-by: Huang Rui <[email protected]>
Reviewed-by: Matthew Auld <[email protected]>
Link: https://patchwork.freedesktop.org/patch/424008/
4 years agodrm/i915: make lockdep slightly happier about execbuf.
Maarten Lankhorst [Tue, 23 Mar 2021 15:49:59 +0000 (16:49 +0100)]
drm/i915: make lockdep slightly happier about execbuf.

As soon as we install fences, we should stop allocating memory
in order to prevent any potential deadlocks.

This is required later on, when we start adding support for
dma-fence annotations.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Convert i915_gem_object_attach_phys() to ww locking, v2.
Maarten Lankhorst [Tue, 23 Mar 2021 15:49:58 +0000 (16:49 +0100)]
drm/i915: Convert i915_gem_object_attach_phys() to ww locking, v2.

Simple adding of i915_gem_object_lock, we may start to pass ww to
get_pages() in the future, but that won't be the case here;
We override shmem's get_pages() handling by calling
i915_gem_object_get_pages_phys(), no ww is needed.

Changes since v1:
- Call shmem put pages directly, the callback would
  go down the phys free path.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Rework struct phys attachment handling
Maarten Lankhorst [Tue, 23 Mar 2021 15:49:57 +0000 (16:49 +0100)]
drm/i915: Rework struct phys attachment handling

Instead of creating a separate object type, we make changes to
the shmem type, to clear struct page backing. This will allow us to
ensure we never run into a race when we exchange obj->ops with other
function pointers.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Move HAS_STRUCT_PAGE to obj->flags
Maarten Lankhorst [Tue, 23 Mar 2021 15:49:56 +0000 (16:49 +0100)]
drm/i915: Move HAS_STRUCT_PAGE to obj->flags

We want to remove the changing of ops structure for attaching
phys pages, so we need to kill off HAS_STRUCT_PAGE from ops->flags,
and put it in the bo.

This will remove a potential race of dereferencing the wrong obj->ops
without ww mutex held.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
[danvet: apply with wiggle]
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
4 years agodrm/i915: Add gem object locking to madvise.
Maarten Lankhorst [Tue, 23 Mar 2021 15:49:55 +0000 (16:49 +0100)]
drm/i915: Add gem object locking to madvise.

Doesn't need the full ww lock, only checking if pages are bound.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]> #irc
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
This page took 0.112787 seconds and 4 git commands to generate.