Skip to content

Commit 2a7005c

Browse files
committed
Merge tag 'drm-intel-gt-next-2021-06-10' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
UAPI Changes: - Disable mmap ioctl for gen12+ (excl. TGL-LP) - Start enabling HuC loading by default for upcoming Gen12+ platforms (excludes TGL and RKL) Core Changes: - Backmerge of drm-next Driver Changes: - Revert "i915: use io_mapping_map_user" (Eero, Matt A) - Initialize the TTM device and memory managers (Thomas) - Major rework to the GuC submission backend to prepare for enabling on new platforms (Michal Wa., Daniele, Matt B, Rodrigo) - Fix i915_sg_page_sizes to record dma segments rather than physical pages (Thomas) - Locking rework to prep for TTM conversion (Thomas) - Replace IS_GEN and friends with GRAPHICS_VER (Lucas) - Use DEVICE_ATTR_RO macro (Yue) - Static code checker fixes (Zhihao) Signed-off-by: Dave Airlie <[email protected]> From: Joonas Lahtinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 0666cba + 47c65b3 commit 2a7005c

File tree

108 files changed

+1897
-2723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1897
-2723
lines changed

drivers/gpu/drm/i915/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ config DRM_I915
2020
select INPUT if ACPI
2121
select ACPI_VIDEO if ACPI
2222
select ACPI_BUTTON if ACPI
23-
select IO_MAPPING
2423
select SYNC_FILE
2524
select IOSF_MBI
2625
select CRC32
2726
select SND_HDA_I915 if SND_HDA_CORE
2827
select CEC_CORE if CEC_NOTIFIER
2928
select VMAP_PFN
29+
select DRM_TTM
3030
help
3131
Choose this option if you have a system that has "Intel Graphics
3232
Media Accelerator" or "HD Graphics" integrated graphics,

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ i915-y += i915_drv.o \
5050
intel_memory_region.o \
5151
intel_pch.o \
5252
intel_pm.o \
53+
intel_region_ttm.o \
5354
intel_runtime_pm.o \
5455
intel_sideband.o \
5556
intel_step.o \
@@ -160,7 +161,6 @@ gem-y += \
160161
i915-y += \
161162
$(gem-y) \
162163
i915_active.o \
163-
i915_buddy.o \
164164
i915_cmd_parser.o \
165165
i915_gem_evict.o \
166166
i915_gem_gtt.o \

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static void set_ppgtt_barrier(void *data)
11901190
{
11911191
struct i915_address_space *old = data;
11921192

1193-
if (INTEL_GEN(old->i915) < 8)
1193+
if (GRAPHICS_VER(old->i915) < 8)
11941194
gen6_ppgtt_unpin_all(i915_vm_to_ppgtt(old));
11951195

11961196
i915_vm_close(old);
@@ -1436,7 +1436,7 @@ i915_gem_user_to_context_sseu(struct intel_gt *gt,
14361436
context->max_eus_per_subslice = user->max_eus_per_subslice;
14371437

14381438
/* Part specific restrictions. */
1439-
if (IS_GEN(i915, 11)) {
1439+
if (GRAPHICS_VER(i915) == 11) {
14401440
unsigned int hw_s = hweight8(device->slice_mask);
14411441
unsigned int hw_ss_per_s = hweight8(device->subslice_mask[0]);
14421442
unsigned int req_s = hweight8(context->slice_mask);
@@ -1503,7 +1503,7 @@ static int set_sseu(struct i915_gem_context *ctx,
15031503
if (args->size < sizeof(user_sseu))
15041504
return -EINVAL;
15051505

1506-
if (!IS_GEN(i915, 11))
1506+
if (GRAPHICS_VER(i915) != 11)
15071507
return -ENODEV;
15081508

15091509
if (copy_from_user(&user_sseu, u64_to_user_ptr(args->value),

drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int i915_gem_object_get_pages_dmabuf(struct drm_i915_gem_object *obj)
209209
if (IS_ERR(pages))
210210
return PTR_ERR(pages);
211211

212-
sg_page_sizes = i915_sg_page_sizes(pages->sgl);
212+
sg_page_sizes = i915_sg_dma_sizes(pages->sgl);
213213

214214
__i915_gem_object_set_pages(obj, pages, sg_page_sizes);
215215

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ eb_validate_vma(struct i915_execbuffer *eb,
500500
* also covers all platforms with local memory.
501501
*/
502502
if (entry->relocation_count &&
503-
INTEL_GEN(eb->i915) >= 12 && !IS_TIGERLAKE(eb->i915))
503+
GRAPHICS_VER(eb->i915) >= 12 && !IS_TIGERLAKE(eb->i915))
504504
return -EINVAL;
505505

506506
if (unlikely(entry->flags & eb->invalid_flags))
@@ -1439,7 +1439,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
14391439

14401440
static bool reloc_can_use_engine(const struct intel_engine_cs *engine)
14411441
{
1442-
return engine->class != VIDEO_DECODE_CLASS || !IS_GEN(engine->i915, 6);
1442+
return engine->class != VIDEO_DECODE_CLASS || GRAPHICS_VER(engine->i915) != 6;
14431443
}
14441444

14451445
static u32 *reloc_gpu(struct i915_execbuffer *eb,
@@ -1671,7 +1671,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,
16711671
* batchbuffers.
16721672
*/
16731673
if (reloc->write_domain == I915_GEM_DOMAIN_INSTRUCTION &&
1674-
IS_GEN(eb->i915, 6)) {
1674+
GRAPHICS_VER(eb->i915) == 6) {
16751675
err = i915_vma_bind(target->vma,
16761676
target->vma->obj->cache_level,
16771677
PIN_GLOBAL, NULL);
@@ -2332,7 +2332,7 @@ static int i915_reset_gen7_sol_offsets(struct i915_request *rq)
23322332
u32 *cs;
23332333
int i;
23342334

2335-
if (!IS_GEN(rq->engine->i915, 7) || rq->engine->id != RCS0) {
2335+
if (GRAPHICS_VER(rq->engine->i915) != 7 || rq->engine->id != RCS0) {
23362336
drm_dbg(&rq->engine->i915->drm, "sol reset is gen7/rcs only\n");
23372337
return -EINVAL;
23382338
}
@@ -3375,7 +3375,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
33753375

33763376
eb.batch_flags = 0;
33773377
if (args->flags & I915_EXEC_SECURE) {
3378-
if (INTEL_GEN(i915) >= 11)
3378+
if (GRAPHICS_VER(i915) >= 11)
33793379
return -ENODEV;
33803380

33813381
/* Return -EPERM to trigger fallback code on old binaries. */

drivers/gpu/drm/i915/gem/i915_gem_lmem.c

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,71 @@
44
*/
55

66
#include "intel_memory_region.h"
7+
#include "intel_region_ttm.h"
78
#include "gem/i915_gem_region.h"
89
#include "gem/i915_gem_lmem.h"
910
#include "i915_drv.h"
1011

12+
static void lmem_put_pages(struct drm_i915_gem_object *obj,
13+
struct sg_table *pages)
14+
{
15+
intel_region_ttm_node_free(obj->mm.region, obj->mm.st_mm_node);
16+
obj->mm.dirty = false;
17+
sg_free_table(pages);
18+
kfree(pages);
19+
}
20+
21+
static int lmem_get_pages(struct drm_i915_gem_object *obj)
22+
{
23+
unsigned int flags;
24+
struct sg_table *pages;
25+
26+
flags = I915_ALLOC_MIN_PAGE_SIZE;
27+
if (obj->flags & I915_BO_ALLOC_CONTIGUOUS)
28+
flags |= I915_ALLOC_CONTIGUOUS;
29+
30+
obj->mm.st_mm_node = intel_region_ttm_node_alloc(obj->mm.region,
31+
obj->base.size,
32+
flags);
33+
if (IS_ERR(obj->mm.st_mm_node))
34+
return PTR_ERR(obj->mm.st_mm_node);
35+
36+
/* Range manager is always contigous */
37+
if (obj->mm.region->is_range_manager)
38+
obj->flags |= I915_BO_ALLOC_CONTIGUOUS;
39+
pages = intel_region_ttm_node_to_st(obj->mm.region, obj->mm.st_mm_node);
40+
if (IS_ERR(pages)) {
41+
intel_region_ttm_node_free(obj->mm.region, obj->mm.st_mm_node);
42+
return PTR_ERR(pages);
43+
}
44+
45+
__i915_gem_object_set_pages(obj, pages, i915_sg_dma_sizes(pages->sgl));
46+
47+
if (obj->flags & I915_BO_ALLOC_CPU_CLEAR) {
48+
void __iomem *vaddr =
49+
i915_gem_object_lmem_io_map(obj, 0, obj->base.size);
50+
51+
if (!vaddr) {
52+
struct sg_table *pages =
53+
__i915_gem_object_unset_pages(obj);
54+
55+
if (!IS_ERR_OR_NULL(pages))
56+
lmem_put_pages(obj, pages);
57+
}
58+
59+
memset_io(vaddr, 0, obj->base.size);
60+
io_mapping_unmap(vaddr);
61+
}
62+
63+
return 0;
64+
}
65+
1166
const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
1267
.name = "i915_gem_object_lmem",
1368
.flags = I915_GEM_OBJECT_HAS_IOMEM,
1469

15-
.get_pages = i915_gem_object_get_pages_buddy,
16-
.put_pages = i915_gem_object_put_pages_buddy,
70+
.get_pages = lmem_get_pages,
71+
.put_pages = lmem_put_pages,
1772
.release = i915_gem_object_release_memory_region,
1873
};
1974

drivers/gpu/drm/i915/gem/i915_gem_mman.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@ int
5656
i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
5757
struct drm_file *file)
5858
{
59+
struct drm_i915_private *i915 = to_i915(dev);
5960
struct drm_i915_gem_mmap *args = data;
6061
struct drm_i915_gem_object *obj;
6162
unsigned long addr;
6263

64+
/* mmap ioctl is disallowed for all platforms after TGL-LP. This also
65+
* covers all platforms with local memory.
66+
*/
67+
if (GRAPHICS_VER(i915) >= 12 && !IS_TIGERLAKE(i915))
68+
return -EOPNOTSUPP;
69+
6370
if (args->flags & ~(I915_MMAP_WC))
6471
return -EINVAL;
6572

@@ -367,10 +374,11 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
367374
goto err_unpin;
368375

369376
/* Finally, remap it using the new GTT offset */
370-
ret = io_mapping_map_user(&ggtt->iomap, area, area->vm_start +
371-
(vma->ggtt_view.partial.offset << PAGE_SHIFT),
372-
(ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT,
373-
min_t(u64, vma->size, area->vm_end - area->vm_start));
377+
ret = remap_io_mapping(area,
378+
area->vm_start + (vma->ggtt_view.partial.offset << PAGE_SHIFT),
379+
(ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT,
380+
min_t(u64, vma->size, area->vm_end - area->vm_start),
381+
&ggtt->iomap);
374382
if (ret)
375383
goto err_fence;
376384

drivers/gpu/drm/i915/gem/i915_gem_object.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
6262
const struct drm_i915_gem_object_ops *ops,
6363
struct lock_class_key *key, unsigned flags)
6464
{
65+
/*
66+
* A gem object is embedded both in a struct ttm_buffer_object :/ and
67+
* in a drm_i915_gem_object. Make sure they are aliased.
68+
*/
69+
BUILD_BUG_ON(offsetof(typeof(*obj), base) !=
70+
offsetof(typeof(*obj), __do_not_access.base));
71+
6572
spin_lock_init(&obj->vma.lock);
6673
INIT_LIST_HEAD(&obj->vma.list);
6774

@@ -252,6 +259,9 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
252259
if (obj->mm.n_placements > 1)
253260
kfree(obj->mm.placements);
254261

262+
if (obj->shares_resv_from)
263+
i915_vm_resv_put(obj->shares_resv_from);
264+
255265
/* But keep the pointer alive for RCU-protected lookups */
256266
call_rcu(&obj->rcu, __i915_gem_free_object_rcu);
257267
cond_resched();

drivers/gpu/drm/i915/gem/i915_gem_object_blt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce,
7272

7373
GEM_BUG_ON(size >> PAGE_SHIFT > S16_MAX);
7474

75-
if (INTEL_GEN(i915) >= 8) {
75+
if (GRAPHICS_VER(i915) >= 8) {
7676
*cmd++ = XY_COLOR_BLT_CMD | BLT_WRITE_RGBA | (7 - 2);
7777
*cmd++ = BLT_DEPTH_32 | BLT_ROP_COLOR_COPY | PAGE_SIZE;
7878
*cmd++ = 0;
@@ -232,7 +232,7 @@ static bool wa_1209644611_applies(struct drm_i915_private *i915, u32 size)
232232
{
233233
u32 height = size >> PAGE_SHIFT;
234234

235-
if (!IS_GEN(i915, 11))
235+
if (GRAPHICS_VER(i915) != 11)
236236
return false;
237237

238238
return height % 4 == 3 && height <= 8;
@@ -297,7 +297,7 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce,
297297
size = min_t(u64, rem, block_size);
298298
GEM_BUG_ON(size >> PAGE_SHIFT > S16_MAX);
299299

300-
if (INTEL_GEN(i915) >= 9 &&
300+
if (GRAPHICS_VER(i915) >= 9 &&
301301
!wa_1209644611_applies(i915, size)) {
302302
*cmd++ = GEN9_XY_FAST_COPY_BLT_CMD | (10 - 2);
303303
*cmd++ = BLT_DEPTH_32 | PAGE_SIZE;
@@ -309,7 +309,7 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce,
309309
*cmd++ = PAGE_SIZE;
310310
*cmd++ = lower_32_bits(src_offset);
311311
*cmd++ = upper_32_bits(src_offset);
312-
} else if (INTEL_GEN(i915) >= 8) {
312+
} else if (GRAPHICS_VER(i915) >= 8) {
313313
*cmd++ = XY_SRC_COPY_BLT_CMD | BLT_WRITE_RGBA | (10 - 2);
314314
*cmd++ = BLT_DEPTH_32 | BLT_ROP_SRC_COPY | PAGE_SIZE;
315315
*cmd++ = 0;

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/mmu_notifier.h>
1111

1212
#include <drm/drm_gem.h>
13+
#include <drm/ttm/ttm_bo_api.h>
1314
#include <uapi/drm/i915_drm.h>
1415

1516
#include "i915_active.h"
@@ -99,7 +100,16 @@ struct i915_gem_object_page_iter {
99100
};
100101

101102
struct drm_i915_gem_object {
102-
struct drm_gem_object base;
103+
/*
104+
* We might have reason to revisit the below since it wastes
105+
* a lot of space for non-ttm gem objects.
106+
* In any case, always use the accessors for the ttm_buffer_object
107+
* when accessing it.
108+
*/
109+
union {
110+
struct drm_gem_object base;
111+
struct ttm_buffer_object __do_not_access;
112+
};
103113

104114
const struct drm_i915_gem_object_ops *ops;
105115

@@ -149,6 +159,10 @@ struct drm_i915_gem_object {
149159
* when i915_gem_ww_ctx_backoff() or i915_gem_ww_ctx_fini() are called.
150160
*/
151161
struct list_head obj_link;
162+
/**
163+
* @shared_resv_from: The object shares the resv from this vm.
164+
*/
165+
struct i915_address_space *shares_resv_from;
152166

153167
union {
154168
struct rcu_head rcu;
@@ -231,10 +245,12 @@ struct drm_i915_gem_object {
231245
* Memory region for this object.
232246
*/
233247
struct intel_memory_region *region;
248+
234249
/**
235-
* List of memory region blocks allocated for this object.
250+
* Memory manager node allocated for this object.
236251
*/
237-
struct list_head blocks;
252+
void *st_mm_node;
253+
238254
/**
239255
* Element within memory_region->objects or region->purgeable
240256
* if the object is marked as DONTNEED. Access is protected by

0 commit comments

Comments
 (0)