Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 0e2d398

Browse files
Merge remote-tracking branch 'drm-intel/drm-intel-gt-next' into drm-tip
# Conflicts: # drivers/gpu/drm/i915/gt/intel_ggtt.c # drivers/gpu/drm/i915/i915_drv.h # drivers/gpu/drm/i915/i915_vma.c
2 parents 3b4287f + bcfc713 commit 0e2d398

File tree

127 files changed

+7264
-2316
lines changed

Some content is hidden

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

127 files changed

+7264
-2316
lines changed

Documentation/gpu/drm-usage-stats.rst

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
.. _drm-client-usage-stats:
2+
3+
======================
4+
DRM client usage stats
5+
======================
6+
7+
DRM drivers can choose to export partly standardised text output via the
8+
`fops->show_fdinfo()` as part of the driver specific file operations registered
9+
in the `struct drm_driver` object registered with the DRM core.
10+
11+
One purpose of this output is to enable writing as generic as practicaly
12+
feasible `top(1)` like userspace monitoring tools.
13+
14+
Given the differences between various DRM drivers the specification of the
15+
output is split between common and driver specific parts. Having said that,
16+
wherever possible effort should still be made to standardise as much as
17+
possible.
18+
19+
File format specification
20+
=========================
21+
22+
- File shall contain one key value pair per one line of text.
23+
- Colon character (`:`) must be used to delimit keys and values.
24+
- All keys shall be prefixed with `drm-`.
25+
- Whitespace between the delimiter and first non-whitespace character shall be
26+
ignored when parsing.
27+
- Neither keys or values are allowed to contain whitespace characters.
28+
- Numerical key value pairs can end with optional unit string.
29+
- Data type of the value is fixed as defined in the specification.
30+
31+
Key types
32+
---------
33+
34+
1. Mandatory, fully standardised.
35+
2. Optional, fully standardised.
36+
3. Driver specific.
37+
38+
Data types
39+
----------
40+
41+
- <uint> - Unsigned integer without defining the maximum value.
42+
- <str> - String excluding any above defined reserved characters or whitespace.
43+
44+
Mandatory fully standardised keys
45+
---------------------------------
46+
47+
- drm-driver: <str>
48+
49+
String shall contain the name this driver registered as via the respective
50+
`struct drm_driver` data structure.
51+
52+
Optional fully standardised keys
53+
--------------------------------
54+
55+
- drm-pdev: <aaaa:bb.cc.d>
56+
57+
For PCI devices this should contain the PCI slot address of the device in
58+
question.
59+
60+
- drm-client-id: <uint>
61+
62+
Unique value relating to the open DRM file descriptor used to distinguish
63+
duplicated and shared file descriptors. Conceptually the value should map 1:1
64+
to the in kernel representation of `struct drm_file` instances.
65+
66+
Uniqueness of the value shall be either globally unique, or unique within the
67+
scope of each device, in which case `drm-pdev` shall be present as well.
68+
69+
Userspace should make sure to not double account any usage statistics by using
70+
the above described criteria in order to associate data to individual clients.
71+
72+
- drm-engine-<str>: <uint> ns
73+
74+
GPUs usually contain multiple execution engines. Each shall be given a stable
75+
and unique name (str), with possible values documented in the driver specific
76+
documentation.
77+
78+
Value shall be in specified time units which the respective GPU engine spent
79+
busy executing workloads belonging to this client.
80+
81+
Values are not required to be constantly monotonic if it makes the driver
82+
implementation easier, but are required to catch up with the previously reported
83+
larger value within a reasonable period. Upon observing a value lower than what
84+
was previously read, userspace is expected to stay with that larger previous
85+
value until a monotonic update is seen.
86+
87+
- drm-engine-capacity-<str>: <uint>
88+
89+
Engine identifier string must be the same as the one specified in the
90+
drm-engine-<str> tag and shall contain a greater than zero number in case the
91+
exported engine corresponds to a group of identical hardware engines.
92+
93+
In the absence of this tag parser shall assume capacity of one. Zero capacity
94+
is not allowed.
95+
96+
- drm-memory-<str>: <uint> [KiB|MiB]
97+
98+
Each possible memory type which can be used to store buffer objects by the
99+
GPU in question shall be given a stable and unique name to be returned as the
100+
string here.
101+
102+
Value shall reflect the amount of storage currently consumed by the buffer
103+
object belong to this client, in the respective memory region.
104+
105+
Default unit shall be bytes with optional unit specifiers of 'KiB' or 'MiB'
106+
indicating kibi- or mebi-bytes.
107+
108+
===============================
109+
Driver specific implementations
110+
===============================
111+
112+
:ref:`i915-usage-stats`

Documentation/gpu/i915.rst

+28
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
697697

698698
.. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
699699
:doc: The i915 register macro definition style guide
700+
701+
.. _i915-usage-stats:
702+
703+
i915 DRM client usage stats implementation
704+
==========================================
705+
706+
The drm/i915 driver implements the DRM client usage stats specification as
707+
documented in :ref:`drm-client-usage-stats`.
708+
709+
Example of the output showing the implemented key value pairs and entirety of
710+
the currently possible format options:
711+
712+
::
713+
714+
pos: 0
715+
flags: 0100002
716+
mnt_id: 21
717+
drm-driver: i915
718+
drm-pdev: 0000:00:02.0
719+
drm-client-id: 7
720+
drm-engine-render: 9288864723 ns
721+
drm-engine-copy: 2035071108 ns
722+
drm-engine-video: 0 ns
723+
drm-engine-capacity-video: 2
724+
drm-engine-video-enhance: 0 ns
725+
726+
Possible `drm-engine-` key names are: `render`, `copy`, `video` and
727+
`video-enhance`.

Documentation/gpu/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Linux GPU Driver Developer's Guide
1010
drm-kms
1111
drm-kms-helpers
1212
drm-uapi
13+
drm-usage-stats
1314
driver-uapi
1415
drm-client
1516
drivers

drivers/gpu/drm/i915/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config DRM_I915
44
depends on DRM
55
depends on X86 && PCI
66
depends on !PREEMPT_RT
7-
select INTEL_GTT
7+
select INTEL_GTT if X86
88
select INTERVAL_TREE
99
# we need shmfs for the swappable backing store, and in particular
1010
# the shmem_readpage() which depends upon tmpfs

drivers/gpu/drm/i915/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ subdir-ccflags-y += -I$(srctree)/$(src)
3333

3434
# core driver code
3535
i915-y += i915_driver.o \
36+
i915_drm_client.o \
3637
i915_config.o \
3738
i915_getparam.o \
3839
i915_ioctl.o \
@@ -106,6 +107,8 @@ gt-y += \
106107
gt/intel_gt_pm_debugfs.o \
107108
gt/intel_gt_pm_irq.o \
108109
gt/intel_gt_requests.o \
110+
gt/intel_gt_sysfs.o \
111+
gt/intel_gt_sysfs_pm.o \
109112
gt/intel_gtt.o \
110113
gt/intel_llc.o \
111114
gt/intel_lrc.o \
@@ -125,6 +128,8 @@ gt-y += \
125128
gt/intel_workarounds.o \
126129
gt/shmem_utils.o \
127130
gt/sysfs_engines.o
131+
# x86 intel-gtt module support
132+
gt-$(CONFIG_X86) += gt/intel_gt_gmch.o
128133
# autogenerated null render state
129134
gt-y += \
130135
gt/gen6_renderstate.o \
@@ -185,9 +190,11 @@ i915-y += gt/uc/intel_uc.o \
185190
gt/uc/intel_uc_fw.o \
186191
gt/uc/intel_guc.o \
187192
gt/uc/intel_guc_ads.o \
193+
gt/uc/intel_guc_capture.o \
188194
gt/uc/intel_guc_ct.o \
189195
gt/uc/intel_guc_debugfs.o \
190196
gt/uc/intel_guc_fw.o \
197+
gt/uc/intel_guc_hwconfig.o \
191198
gt/uc/intel_guc_log.o \
192199
gt/uc/intel_guc_log_debugfs.o \
193200
gt/uc/intel_guc_rc.o \

drivers/gpu/drm/i915/display/intel_dpt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,5 +300,5 @@ void intel_dpt_destroy(struct i915_address_space *vm)
300300
{
301301
struct i915_dpt *dpt = i915_vm_to_dpt(vm);
302302

303-
i915_vm_close(&dpt->vm);
303+
i915_vm_put(&dpt->vm);
304304
}

drivers/gpu/drm/i915/display/intel_fb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
20292029

20302030
/* object is backed with LMEM for discrete */
20312031
i915 = to_i915(obj->base.dev);
2032-
if (HAS_LMEM(i915) && !i915_gem_object_can_migrate(obj, INTEL_REGION_LMEM)) {
2032+
if (HAS_LMEM(i915) && !i915_gem_object_can_migrate(obj, INTEL_REGION_LMEM_0)) {
20332033
/* object is "remote", not in local memory */
20342034
i915_gem_object_put(obj);
20352035
return ERR_PTR(-EREMOTE);

drivers/gpu/drm/i915/display/intel_fb_pin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
140140
if (!ret && phys_cursor)
141141
ret = i915_gem_object_attach_phys(obj, alignment);
142142
else if (!ret && HAS_LMEM(dev_priv))
143-
ret = i915_gem_object_migrate(obj, &ww, INTEL_REGION_LMEM);
143+
ret = i915_gem_object_migrate(obj, &ww, INTEL_REGION_LMEM_0);
144144
/* TODO: Do we need to sync when migration becomes async? */
145145
if (!ret)
146146
ret = i915_gem_object_pin_pages(obj);

drivers/gpu/drm/i915/display/intel_fbdev.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
279279
/* Our framebuffer is the entirety of fbdev's system memory */
280280
info->fix.smem_start =
281281
(unsigned long)(ggtt->gmadr.start + vma->node.start);
282-
info->fix.smem_len = vma->node.size;
282+
info->fix.smem_len = vma->size;
283283
}
284284

285285
vaddr = i915_vma_pin_iomap(vma);
@@ -290,7 +290,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
290290
goto out_unpin;
291291
}
292292
info->screen_base = vaddr;
293-
info->screen_size = vma->node.size;
293+
info->screen_size = vma->size;
294294

295295
drm_fb_helper_fill_info(info, &ifbdev->helper, sizes);
296296

drivers/gpu/drm/i915/display/intel_plane_initial.c

+50-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © 2021 Intel Corporation
44
*/
55

6+
#include "gem/i915_gem_region.h"
67
#include "i915_drv.h"
78
#include "intel_atomic_plane.h"
89
#include "intel_display.h"
@@ -46,16 +47,55 @@ static struct i915_vma *
4647
initial_plane_vma(struct drm_i915_private *i915,
4748
struct intel_initial_plane_config *plane_config)
4849
{
49-
struct intel_memory_region *mem = i915->mm.stolen_region;
50+
struct intel_memory_region *mem;
5051
struct drm_i915_gem_object *obj;
5152
struct i915_vma *vma;
53+
resource_size_t phys_base;
5254
u32 base, size;
55+
u64 pinctl;
5356

54-
if (!mem || plane_config->size == 0)
57+
if (plane_config->size == 0)
58+
return NULL;
59+
60+
base = round_down(plane_config->base, I915_GTT_MIN_ALIGNMENT);
61+
if (IS_DGFX(i915)) {
62+
gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm;
63+
gen8_pte_t pte;
64+
65+
gte += base / I915_GTT_PAGE_SIZE;
66+
67+
pte = ioread64(gte);
68+
if (!(pte & GEN12_GGTT_PTE_LM)) {
69+
drm_err(&i915->drm,
70+
"Initial plane programming missing PTE_LM bit\n");
71+
return NULL;
72+
}
73+
74+
phys_base = pte & I915_GTT_PAGE_MASK;
75+
mem = i915->mm.regions[INTEL_REGION_LMEM_0];
76+
77+
/*
78+
* We don't currently expect this to ever be placed in the
79+
* stolen portion.
80+
*/
81+
if (phys_base >= resource_size(&mem->region)) {
82+
drm_err(&i915->drm,
83+
"Initial plane programming using invalid range, phys_base=%pa\n",
84+
&phys_base);
85+
return NULL;
86+
}
87+
88+
drm_dbg(&i915->drm,
89+
"Using phys_base=%pa, based on initial plane programming\n",
90+
&phys_base);
91+
} else {
92+
phys_base = base;
93+
mem = i915->mm.stolen_region;
94+
}
95+
96+
if (!mem)
5597
return NULL;
5698

57-
base = round_down(plane_config->base,
58-
I915_GTT_MIN_ALIGNMENT);
5999
size = round_up(plane_config->base + plane_config->size,
60100
mem->min_page_size);
61101
size -= base;
@@ -66,10 +106,11 @@ initial_plane_vma(struct drm_i915_private *i915,
66106
* features.
67107
*/
68108
if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) &&
109+
mem == i915->mm.stolen_region &&
69110
size * 2 > i915->stolen_usable_size)
70111
return NULL;
71112

72-
obj = i915_gem_object_create_stolen_for_preallocated(i915, base, size);
113+
obj = i915_gem_object_create_region_at(mem, phys_base, size, 0);
73114
if (IS_ERR(obj))
74115
return NULL;
75116

@@ -99,7 +140,10 @@ initial_plane_vma(struct drm_i915_private *i915,
99140
if (IS_ERR(vma))
100141
goto err_obj;
101142

102-
if (i915_ggtt_pin(vma, NULL, 0, PIN_MAPPABLE | PIN_OFFSET_FIXED | base))
143+
pinctl = PIN_GLOBAL | PIN_OFFSET_FIXED | base;
144+
if (HAS_GMCH(i915))
145+
pinctl |= PIN_MAPPABLE;
146+
if (i915_vma_pin(vma, 0, 0, pinctl))
103147
goto err_obj;
104148

105149
if (i915_gem_object_is_tiled(obj) &&

0 commit comments

Comments
 (0)