Skip to content

Commit 6e85c1e

Browse files
committed
Merge tag 'drm-misc-next-2025-07-10' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-next
drm-misc-next for 6.17: UAPI Changes: Cross-subsystem Changes: Core Changes: Driver Changes: - amdgpu: debugfs improvements - ast: Improve hardware generations implementation - dma-buf heaps: - Give the CMA heap a stable name - panthor: fix UAF in debugfs - rockchip: Convert inno_hdmi to a bridge - sti: Convert to devm_drm_bridge_alloc() - vkms: Use faux_device - bridge: - Improve CEC handling code, convertions to devm_drm_bridge_alloc() Signed-off-by: Simona Vetter <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20250710-observant-elite-dingo-acfd6d@houat
2 parents 203dcde + fe69a39 commit 6e85c1e

Some content is hidden

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

67 files changed

+3762
-3170
lines changed

Documentation/userspace-api/dma-buf-heaps.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ following heaps:
1919
- The ``cma`` heap allocates physically contiguous, cacheable,
2020
buffers. Only present if a CMA region is present. Such a region is
2121
usually created either through the kernel commandline through the
22-
`cma` parameter, a memory region Device-Tree node with the
23-
`linux,cma-default` property set, or through the `CMA_SIZE_MBYTES` or
24-
`CMA_SIZE_PERCENTAGE` Kconfig options. Depending on the platform, it
25-
might be called ``reserved``, ``linux,cma``, or ``default-pool``.
22+
``cma`` parameter, a memory region Device-Tree node with the
23+
``linux,cma-default`` property set, or through the ``CMA_SIZE_MBYTES`` or
24+
``CMA_SIZE_PERCENTAGE`` Kconfig options. The heap's name in devtmpfs is
25+
``default_cma_region``. For backwards compatibility, when the
26+
``DMABUF_HEAPS_CMA_LEGACY`` Kconfig option is set, a duplicate node is
27+
created following legacy naming conventions; the legacy name might be
28+
``reserved``, ``linux,cma``, or ``default-pool``.

drivers/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ source "drivers/thunderbolt/Kconfig"
209209

210210
source "drivers/android/Kconfig"
211211

212-
source "drivers/gpu/trace/Kconfig"
213-
214212
source "drivers/nvdimm/Kconfig"
215213

216214
source "drivers/dax/Kconfig"

drivers/accel/drm_accel.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
DEFINE_XARRAY_ALLOC(accel_minors_xa);
2222

23-
static struct dentry *accel_debugfs_root;
24-
2523
static const struct device_type accel_sysfs_device_minor = {
2624
.name = "accel_minor"
2725
};
@@ -73,17 +71,6 @@ static const struct drm_info_list accel_debugfs_list[] = {
7371
};
7472
#define ACCEL_DEBUGFS_ENTRIES ARRAY_SIZE(accel_debugfs_list)
7573

76-
/**
77-
* accel_debugfs_init() - Initialize debugfs for device
78-
* @dev: Pointer to the device instance.
79-
*
80-
* This function creates a root directory for the device in debugfs.
81-
*/
82-
void accel_debugfs_init(struct drm_device *dev)
83-
{
84-
drm_debugfs_dev_init(dev, accel_debugfs_root);
85-
}
86-
8774
/**
8875
* accel_debugfs_register() - Register debugfs for device
8976
* @dev: Pointer to the device instance.
@@ -194,7 +181,6 @@ static const struct file_operations accel_stub_fops = {
194181
void accel_core_exit(void)
195182
{
196183
unregister_chrdev(ACCEL_MAJOR, "accel");
197-
debugfs_remove(accel_debugfs_root);
198184
accel_sysfs_destroy();
199185
WARN_ON(!xa_empty(&accel_minors_xa));
200186
}
@@ -209,8 +195,6 @@ int __init accel_core_init(void)
209195
goto error;
210196
}
211197

212-
accel_debugfs_root = debugfs_create_dir("accel", NULL);
213-
214198
ret = register_chrdev(ACCEL_MAJOR, "accel", &accel_stub_fops);
215199
if (ret < 0)
216200
DRM_ERROR("Cannot register ACCEL major: %d\n", ret);

drivers/dma-buf/heaps/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ config DMABUF_HEAPS_CMA
1212
Choose this option to enable dma-buf CMA heap. This heap is backed
1313
by the Contiguous Memory Allocator (CMA). If your system has these
1414
regions, you should say Y here.
15+
16+
config DMABUF_HEAPS_CMA_LEGACY
17+
bool "Legacy DMA-BUF CMA Heap"
18+
default y
19+
depends on DMABUF_HEAPS_CMA
20+
help
21+
Add a duplicate CMA-backed dma-buf heap with legacy naming derived
22+
from the CMA area's devicetree node, or "reserved" if the area is not
23+
defined in the devicetree. This uses the same underlying allocator as
24+
CONFIG_DMABUF_HEAPS_CMA.

drivers/dma-buf/heaps/cma_heap.c

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
1010
* Andrew F. Davis <[email protected]>
1111
*/
12+
13+
#define pr_fmt(fmt) "cma_heap: " fmt
14+
1215
#include <linux/cma.h>
1316
#include <linux/dma-buf.h>
1417
#include <linux/dma-heap.h>
@@ -22,6 +25,7 @@
2225
#include <linux/slab.h>
2326
#include <linux/vmalloc.h>
2427

28+
#define DEFAULT_CMA_NAME "default_cma_region"
2529

2630
struct cma_heap {
2731
struct dma_heap *heap;
@@ -366,17 +370,17 @@ static const struct dma_heap_ops cma_heap_ops = {
366370
.allocate = cma_heap_allocate,
367371
};
368372

369-
static int __init __add_cma_heap(struct cma *cma, void *data)
373+
static int __init __add_cma_heap(struct cma *cma, const char *name)
370374
{
371-
struct cma_heap *cma_heap;
372375
struct dma_heap_export_info exp_info;
376+
struct cma_heap *cma_heap;
373377

374378
cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL);
375379
if (!cma_heap)
376380
return -ENOMEM;
377381
cma_heap->cma = cma;
378382

379-
exp_info.name = cma_get_name(cma);
383+
exp_info.name = name;
380384
exp_info.ops = &cma_heap_ops;
381385
exp_info.priv = cma_heap;
382386

@@ -394,12 +398,30 @@ static int __init __add_cma_heap(struct cma *cma, void *data)
394398
static int __init add_default_cma_heap(void)
395399
{
396400
struct cma *default_cma = dev_get_cma_area(NULL);
397-
int ret = 0;
401+
const char *legacy_cma_name;
402+
int ret;
398403

399-
if (default_cma)
400-
ret = __add_cma_heap(default_cma, NULL);
404+
if (!default_cma)
405+
return 0;
401406

402-
return ret;
407+
ret = __add_cma_heap(default_cma, DEFAULT_CMA_NAME);
408+
if (ret)
409+
return ret;
410+
411+
if (IS_ENABLED(CONFIG_DMABUF_HEAPS_CMA_LEGACY)) {
412+
legacy_cma_name = cma_get_name(default_cma);
413+
if (!strcmp(legacy_cma_name, DEFAULT_CMA_NAME)) {
414+
pr_warn("legacy name and default name are the same, skipping legacy heap\n");
415+
return 0;
416+
}
417+
418+
ret = __add_cma_heap(default_cma, legacy_cma_name);
419+
if (ret)
420+
pr_warn("failed to add legacy heap: %pe\n",
421+
ERR_PTR(ret));
422+
}
423+
424+
return 0;
403425
}
404426
module_init(add_default_cma_heap);
405427
MODULE_DESCRIPTION("DMA-BUF CMA Heap");

drivers/dma-buf/heaps/system_heap.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct system_heap_buffer {
3333

3434
struct dma_heap_attachment {
3535
struct device *dev;
36-
struct sg_table *table;
36+
struct sg_table table;
3737
struct list_head list;
3838
bool mapped;
3939
};
@@ -52,49 +52,41 @@ static gfp_t order_flags[] = {HIGH_ORDER_GFP, HIGH_ORDER_GFP, LOW_ORDER_GFP};
5252
static const unsigned int orders[] = {8, 4, 0};
5353
#define NUM_ORDERS ARRAY_SIZE(orders)
5454

55-
static struct sg_table *dup_sg_table(struct sg_table *table)
55+
static int dup_sg_table(struct sg_table *from, struct sg_table *to)
5656
{
57-
struct sg_table *new_table;
58-
int ret, i;
5957
struct scatterlist *sg, *new_sg;
58+
int ret, i;
6059

61-
new_table = kzalloc(sizeof(*new_table), GFP_KERNEL);
62-
if (!new_table)
63-
return ERR_PTR(-ENOMEM);
64-
65-
ret = sg_alloc_table(new_table, table->orig_nents, GFP_KERNEL);
66-
if (ret) {
67-
kfree(new_table);
68-
return ERR_PTR(-ENOMEM);
69-
}
60+
ret = sg_alloc_table(to, from->orig_nents, GFP_KERNEL);
61+
if (ret)
62+
return ret;
7063

71-
new_sg = new_table->sgl;
72-
for_each_sgtable_sg(table, sg, i) {
64+
new_sg = to->sgl;
65+
for_each_sgtable_sg(from, sg, i) {
7366
sg_set_page(new_sg, sg_page(sg), sg->length, sg->offset);
7467
new_sg = sg_next(new_sg);
7568
}
7669

77-
return new_table;
70+
return 0;
7871
}
7972

8073
static int system_heap_attach(struct dma_buf *dmabuf,
8174
struct dma_buf_attachment *attachment)
8275
{
8376
struct system_heap_buffer *buffer = dmabuf->priv;
8477
struct dma_heap_attachment *a;
85-
struct sg_table *table;
78+
int ret;
8679

8780
a = kzalloc(sizeof(*a), GFP_KERNEL);
8881
if (!a)
8982
return -ENOMEM;
9083

91-
table = dup_sg_table(&buffer->sg_table);
92-
if (IS_ERR(table)) {
84+
ret = dup_sg_table(&buffer->sg_table, &a->table);
85+
if (ret) {
9386
kfree(a);
94-
return -ENOMEM;
87+
return ret;
9588
}
9689

97-
a->table = table;
9890
a->dev = attachment->dev;
9991
INIT_LIST_HEAD(&a->list);
10092
a->mapped = false;
@@ -118,16 +110,15 @@ static void system_heap_detach(struct dma_buf *dmabuf,
118110
list_del(&a->list);
119111
mutex_unlock(&buffer->lock);
120112

121-
sg_free_table(a->table);
122-
kfree(a->table);
113+
sg_free_table(&a->table);
123114
kfree(a);
124115
}
125116

126117
static struct sg_table *system_heap_map_dma_buf(struct dma_buf_attachment *attachment,
127118
enum dma_data_direction direction)
128119
{
129120
struct dma_heap_attachment *a = attachment->priv;
130-
struct sg_table *table = a->table;
121+
struct sg_table *table = &a->table;
131122
int ret;
132123

133124
ret = dma_map_sgtable(attachment->dev, table, direction, 0);
@@ -162,7 +153,7 @@ static int system_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
162153
list_for_each_entry(a, &buffer->attachments, list) {
163154
if (!a->mapped)
164155
continue;
165-
dma_sync_sgtable_for_cpu(a->dev, a->table, direction);
156+
dma_sync_sgtable_for_cpu(a->dev, &a->table, direction);
166157
}
167158
mutex_unlock(&buffer->lock);
168159

@@ -183,7 +174,7 @@ static int system_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
183174
list_for_each_entry(a, &buffer->attachments, list) {
184175
if (!a->mapped)
185176
continue;
186-
dma_sync_sgtable_for_device(a->dev, a->table, direction);
177+
dma_sync_sgtable_for_device(a->dev, &a->table, direction);
187178
}
188179
mutex_unlock(&buffer->lock);
189180

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,55 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
21312131
return 0;
21322132
}
21332133

2134+
static int amdgpu_pt_info_read(struct seq_file *m, void *unused)
2135+
{
2136+
struct drm_file *file;
2137+
struct amdgpu_fpriv *fpriv;
2138+
struct amdgpu_bo *root_bo;
2139+
int r;
2140+
2141+
file = m->private;
2142+
if (!file)
2143+
return -EINVAL;
2144+
2145+
fpriv = file->driver_priv;
2146+
if (!fpriv || !fpriv->vm.root.bo)
2147+
return -ENODEV;
2148+
2149+
root_bo = amdgpu_bo_ref(fpriv->vm.root.bo);
2150+
r = amdgpu_bo_reserve(root_bo, true);
2151+
if (r) {
2152+
amdgpu_bo_unref(&root_bo);
2153+
return -EINVAL;
2154+
}
2155+
2156+
seq_printf(m, "gpu_address: 0x%llx\n", amdgpu_bo_gpu_offset(fpriv->vm.root.bo));
2157+
2158+
amdgpu_bo_unreserve(root_bo);
2159+
amdgpu_bo_unref(&root_bo);
2160+
2161+
return 0;
2162+
}
2163+
2164+
static int amdgpu_pt_info_open(struct inode *inode, struct file *file)
2165+
{
2166+
return single_open(file, amdgpu_pt_info_read, inode->i_private);
2167+
}
2168+
2169+
static const struct file_operations amdgpu_pt_info_fops = {
2170+
.owner = THIS_MODULE,
2171+
.open = amdgpu_pt_info_open,
2172+
.read = seq_read,
2173+
.llseek = seq_lseek,
2174+
.release = single_release,
2175+
};
2176+
2177+
void amdgpu_debugfs_vm_init(struct drm_file *file)
2178+
{
2179+
debugfs_create_file("vm_pagetable_info", 0444, file->debugfs_client, file,
2180+
&amdgpu_pt_info_fops);
2181+
}
2182+
21342183
#else
21352184
int amdgpu_debugfs_init(struct amdgpu_device *adev)
21362185
{
@@ -2140,4 +2189,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
21402189
{
21412190
return 0;
21422191
}
2192+
void amdgpu_debugfs_vm_init(struct drm_file *file)
2193+
{
2194+
}
21432195
#endif

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ void amdgpu_debugfs_fence_init(struct amdgpu_device *adev);
3333
void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev);
3434
void amdgpu_debugfs_gem_init(struct amdgpu_device *adev);
3535
void amdgpu_debugfs_mes_event_log_init(struct amdgpu_device *adev);
36+
void amdgpu_debugfs_vm_init(struct drm_file *file);
3637

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
13951395
if (r)
13961396
goto error_pasid;
13971397

1398+
amdgpu_debugfs_vm_init(file_priv);
1399+
13981400
r = amdgpu_vm_init(adev, &fpriv->vm, fpriv->xcp_id);
13991401
if (r)
14001402
goto error_pasid;

0 commit comments

Comments
 (0)