Skip to content

Commit d2be61f

Browse files
committed
Merge tag 'amd-drm-next-6.8-2023-12-15' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-next-6.8-2023-12-15: amdgpu: - Suspend fixes - Misc code cleanups - JPEG fix - Add AMD specific color management (protected by AMD_PRIVATE_COLOR) - UHBR13.5 cable fixes - Misc display fixes - Display WB fixes - PSR fixes - XGMI fix - ACPI WBRF support for handling potential RF interference from GPU clocks - Enable tunneling on high priority compute queues - drm_edid.h include cleanup - VPE DPM support - SMU 13 fixes - Fix possible double frees in error paths - Misc fixes amdkfd: - Support import and export of dma-bufs using GEM handles - MES shader debugger fixes - SVM fixes radeon: - drm_edid.h include cleanup - Misc code cleanups - Fix possible memory leak in error path drm: - Increase max objects to accomodate new color props - Make replace_property_blob_from_id a DRM helper - Track color management changes per plane platform-x86: - Merge immutable branch from Hans for platform dependencies for WBRF to coordinate merge of WBRF feature across wifi, platform, and GPU Signed-off-by: Dave Airlie <airlied@redhat.com> # -----BEGIN PGP SIGNATURE----- # # iHUEABYKAB0WIQQgO5Idg2tXNTSZAr293/aFa7yZ2AUCZXygTgAKCRC93/aFa7yZ # 2EW1AQCILfGTtDWXzgLSpUBtt9jOooHqaSrah19Cfw0HlA3QIQD+OCohXH1LLZo1 # tYHyfsLv0LsNawI198qABzB1PwptSAI= # =M1AO # -----END PGP SIGNATURE----- # gpg: Signature made Sat 16 Dec 2023 04:51:58 AEST # gpg: using EDDSA key 203B921D836B5735349902BDBDDFF6856BBC99D8 # gpg: Can't check signature: No public key From: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231215193519.5040-1-alexander.deucher@amd.com
2 parents 48b2728 + 6690808 commit d2be61f

File tree

126 files changed

+3187
-436
lines changed

Some content is hidden

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

126 files changed

+3187
-436
lines changed

Documentation/driver-api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ available subsections can be seen below.
115115
hte/index
116116
wmi
117117
dpll
118+
wbrf
118119

119120
.. only:: subproject and html
120121

Documentation/driver-api/wbrf.rst

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
=================================
4+
WBRF - Wifi Band RFI Mitigations
5+
=================================
6+
7+
Due to electrical and mechanical constraints in certain platform designs
8+
there may be likely interference of relatively high-powered harmonics of
9+
the GPU memory clocks with local radio module frequency bands used by
10+
certain Wifi bands.
11+
12+
To mitigate possible RFI interference producers can advertise the
13+
frequencies in use and consumers can use this information to avoid using
14+
these frequencies for sensitive features.
15+
16+
When a platform is known to have this issue with any contained devices,
17+
the platform designer will advertise the availability of this feature via
18+
ACPI devices with a device specific method (_DSM).
19+
* Producers with this _DSM will be able to advertise the frequencies in use.
20+
* Consumers with this _DSM will be able to register for notifications of
21+
frequencies in use.
22+
23+
Some general terms
24+
==================
25+
26+
Producer: such component who can produce high-powered radio frequency
27+
Consumer: such component who can adjust its in-use frequency in
28+
response to the radio frequencies of other components to mitigate the
29+
possible RFI.
30+
31+
To make the mechanism function, those producers should notify active use
32+
of their particular frequencies so that other consumers can make relative
33+
internal adjustments as necessary to avoid this resonance.
34+
35+
ACPI interface
36+
==============
37+
38+
Although initially used by for wifi + dGPU use cases, the ACPI interface
39+
can be scaled to any type of device that a platform designer discovers
40+
can cause interference.
41+
42+
The GUID used for the _DSM is 7B7656CF-DC3D-4C1C-83E9-66E721DE3070.
43+
44+
3 functions are available in this _DSM:
45+
46+
* 0: discover # of functions available
47+
* 1: record RF bands in use
48+
* 2: retrieve RF bands in use
49+
50+
Driver programming interface
51+
============================
52+
53+
.. kernel-doc:: drivers/platform/x86/amd/wbrf.c
54+
55+
Sample Usage
56+
=============
57+
58+
The expected flow for the producers:
59+
1. During probe, call `acpi_amd_wbrf_supported_producer` to check if WBRF
60+
can be enabled for the device.
61+
2. On using some frequency band, call `acpi_amd_wbrf_add_remove` with 'add'
62+
param to get other consumers properly notified.
63+
3. Or on stopping using some frequency band, call
64+
`acpi_amd_wbrf_add_remove` with 'remove' param to get other consumers notified.
65+
66+
The expected flow for the consumers:
67+
1. During probe, call `acpi_amd_wbrf_supported_consumer` to check if WBRF
68+
can be enabled for the device.
69+
2. Call `amd_wbrf_register_notifier` to register for notification
70+
of frequency band change(add or remove) from other producers.
71+
3. Call the `amd_wbrf_retrieve_freq_band` initally to retrieve
72+
current active frequency bands considering some producers may broadcast
73+
such information before the consumer is up.
74+
4. On receiving a notification for frequency band change, run
75+
`amd_wbrf_retrieve_freq_band` again to retrieve the latest
76+
active frequency bands.
77+
5. During driver cleanup, call `amd_wbrf_unregister_notifier` to
78+
unregister the notifier.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ extern int amdgpu_seamless;
252252
extern int amdgpu_user_partt_mode;
253253
extern int amdgpu_agp;
254254

255+
extern int amdgpu_wbrf;
256+
255257
#define AMDGPU_VM_MAX_NUM_CTX 4096
256258
#define AMDGPU_SG_THRESHOLD (256*1024*1024)
257259
#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
@@ -789,6 +791,7 @@ struct amdgpu_mqd_prop {
789791
uint64_t eop_gpu_addr;
790792
uint32_t hqd_pipe_priority;
791793
uint32_t hqd_queue_priority;
794+
bool allow_tunneling;
792795
bool hqd_active;
793796
};
794797

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
142142
{
143143
int i;
144144
int last_valid_bit;
145+
int ret;
145146

146147
amdgpu_amdkfd_gpuvm_init_mem_limits();
147148

@@ -160,6 +161,12 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
160161
.enable_mes = adev->enable_mes,
161162
};
162163

164+
ret = drm_client_init(&adev->ddev, &adev->kfd.client, "kfd", NULL);
165+
if (ret) {
166+
dev_err(adev->dev, "Failed to init DRM client: %d\n", ret);
167+
return;
168+
}
169+
163170
/* this is going to have a few of the MSBs set that we need to
164171
* clear
165172
*/
@@ -198,6 +205,10 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
198205

199206
adev->kfd.init_complete = kgd2kfd_device_init(adev->kfd.dev,
200207
&gpu_resources);
208+
if (adev->kfd.init_complete)
209+
drm_client_register(&adev->kfd.client);
210+
else
211+
drm_client_release(&adev->kfd.client);
201212

202213
amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size;
203214

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/mmu_notifier.h>
3434
#include <linux/memremap.h>
3535
#include <kgd_kfd_interface.h>
36+
#include <drm/drm_client.h>
3637
#include "amdgpu_sync.h"
3738
#include "amdgpu_vm.h"
3839
#include "amdgpu_xcp.h"
@@ -83,6 +84,7 @@ struct kgd_mem {
8384

8485
struct amdgpu_sync sync;
8586

87+
uint32_t gem_handle;
8688
bool aql_queue;
8789
bool is_imported;
8890
};
@@ -105,6 +107,9 @@ struct amdgpu_kfd_dev {
105107

106108
/* HMM page migration MEMORY_DEVICE_PRIVATE mapping */
107109
struct dev_pagemap pgmap;
110+
111+
/* Client for KFD BO GEM handle allocations */
112+
struct drm_client_dev client;
108113
};
109114

110115
enum kgd_engine_type {
@@ -309,11 +314,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info,
309314
struct dma_fence **ef);
310315
int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
311316
struct kfd_vm_fault_info *info);
312-
int amdgpu_amdkfd_gpuvm_import_dmabuf(struct amdgpu_device *adev,
313-
struct dma_buf *dmabuf,
314-
uint64_t va, void *drm_priv,
315-
struct kgd_mem **mem, uint64_t *size,
316-
uint64_t *mmap_offset);
317+
int amdgpu_amdkfd_gpuvm_import_dmabuf_fd(struct amdgpu_device *adev, int fd,
318+
uint64_t va, void *drm_priv,
319+
struct kgd_mem **mem, uint64_t *size,
320+
uint64_t *mmap_offset);
317321
int amdgpu_amdkfd_gpuvm_export_dmabuf(struct kgd_mem *mem,
318322
struct dma_buf **dmabuf);
319323
void amdgpu_amdkfd_debug_mem_fence(struct amdgpu_device *adev);

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

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/pagemap.h>
2626
#include <linux/sched/mm.h>
2727
#include <linux/sched/task.h>
28+
#include <linux/fdtable.h>
2829
#include <drm/ttm/ttm_tt.h>
2930

3031
#include <drm/drm_exec.h>
@@ -806,13 +807,22 @@ kfd_mem_dmaunmap_attachment(struct kgd_mem *mem,
806807
static int kfd_mem_export_dmabuf(struct kgd_mem *mem)
807808
{
808809
if (!mem->dmabuf) {
809-
struct dma_buf *ret = amdgpu_gem_prime_export(
810-
&mem->bo->tbo.base,
810+
struct amdgpu_device *bo_adev;
811+
struct dma_buf *dmabuf;
812+
int r, fd;
813+
814+
bo_adev = amdgpu_ttm_adev(mem->bo->tbo.bdev);
815+
r = drm_gem_prime_handle_to_fd(&bo_adev->ddev, bo_adev->kfd.client.file,
816+
mem->gem_handle,
811817
mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
812-
DRM_RDWR : 0);
813-
if (IS_ERR(ret))
814-
return PTR_ERR(ret);
815-
mem->dmabuf = ret;
818+
DRM_RDWR : 0, &fd);
819+
if (r)
820+
return r;
821+
dmabuf = dma_buf_get(fd);
822+
close_fd(fd);
823+
if (WARN_ON_ONCE(IS_ERR(dmabuf)))
824+
return PTR_ERR(dmabuf);
825+
mem->dmabuf = dmabuf;
816826
}
817827

818828
return 0;
@@ -1778,6 +1788,9 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
17781788
pr_debug("Failed to allow vma node access. ret %d\n", ret);
17791789
goto err_node_allow;
17801790
}
1791+
ret = drm_gem_handle_create(adev->kfd.client.file, gobj, &(*mem)->gem_handle);
1792+
if (ret)
1793+
goto err_gem_handle_create;
17811794
bo = gem_to_amdgpu_bo(gobj);
17821795
if (bo_type == ttm_bo_type_sg) {
17831796
bo->tbo.sg = sg;
@@ -1829,6 +1842,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
18291842
err_pin_bo:
18301843
err_validate_bo:
18311844
remove_kgd_mem_from_kfd_bo_list(*mem, avm->process_info);
1845+
drm_gem_handle_delete(adev->kfd.client.file, (*mem)->gem_handle);
1846+
err_gem_handle_create:
18321847
drm_vma_node_revoke(&gobj->vma_node, drm_priv);
18331848
err_node_allow:
18341849
/* Don't unreserve system mem limit twice */
@@ -1941,8 +1956,11 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
19411956

19421957
/* Free the BO*/
19431958
drm_vma_node_revoke(&mem->bo->tbo.base.vma_node, drm_priv);
1944-
if (mem->dmabuf)
1959+
drm_gem_handle_delete(adev->kfd.client.file, mem->gem_handle);
1960+
if (mem->dmabuf) {
19451961
dma_buf_put(mem->dmabuf);
1962+
mem->dmabuf = NULL;
1963+
}
19461964
mutex_destroy(&mem->lock);
19471965

19481966
/* If this releases the last reference, it will end up calling
@@ -2294,34 +2312,26 @@ int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
22942312
return 0;
22952313
}
22962314

2297-
int amdgpu_amdkfd_gpuvm_import_dmabuf(struct amdgpu_device *adev,
2298-
struct dma_buf *dma_buf,
2299-
uint64_t va, void *drm_priv,
2300-
struct kgd_mem **mem, uint64_t *size,
2301-
uint64_t *mmap_offset)
2315+
static int import_obj_create(struct amdgpu_device *adev,
2316+
struct dma_buf *dma_buf,
2317+
struct drm_gem_object *obj,
2318+
uint64_t va, void *drm_priv,
2319+
struct kgd_mem **mem, uint64_t *size,
2320+
uint64_t *mmap_offset)
23022321
{
23032322
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
2304-
struct drm_gem_object *obj;
23052323
struct amdgpu_bo *bo;
23062324
int ret;
23072325

2308-
obj = amdgpu_gem_prime_import(adev_to_drm(adev), dma_buf);
2309-
if (IS_ERR(obj))
2310-
return PTR_ERR(obj);
2311-
23122326
bo = gem_to_amdgpu_bo(obj);
23132327
if (!(bo->preferred_domains & (AMDGPU_GEM_DOMAIN_VRAM |
2314-
AMDGPU_GEM_DOMAIN_GTT))) {
2328+
AMDGPU_GEM_DOMAIN_GTT)))
23152329
/* Only VRAM and GTT BOs are supported */
2316-
ret = -EINVAL;
2317-
goto err_put_obj;
2318-
}
2330+
return -EINVAL;
23192331

23202332
*mem = kzalloc(sizeof(struct kgd_mem), GFP_KERNEL);
2321-
if (!*mem) {
2322-
ret = -ENOMEM;
2323-
goto err_put_obj;
2324-
}
2333+
if (!*mem)
2334+
return -ENOMEM;
23252335

23262336
ret = drm_vma_node_allow(&obj->vma_node, drm_priv);
23272337
if (ret)
@@ -2371,8 +2381,41 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct amdgpu_device *adev,
23712381
drm_vma_node_revoke(&obj->vma_node, drm_priv);
23722382
err_free_mem:
23732383
kfree(*mem);
2384+
return ret;
2385+
}
2386+
2387+
int amdgpu_amdkfd_gpuvm_import_dmabuf_fd(struct amdgpu_device *adev, int fd,
2388+
uint64_t va, void *drm_priv,
2389+
struct kgd_mem **mem, uint64_t *size,
2390+
uint64_t *mmap_offset)
2391+
{
2392+
struct drm_gem_object *obj;
2393+
uint32_t handle;
2394+
int ret;
2395+
2396+
ret = drm_gem_prime_fd_to_handle(&adev->ddev, adev->kfd.client.file, fd,
2397+
&handle);
2398+
if (ret)
2399+
return ret;
2400+
obj = drm_gem_object_lookup(adev->kfd.client.file, handle);
2401+
if (!obj) {
2402+
ret = -EINVAL;
2403+
goto err_release_handle;
2404+
}
2405+
2406+
ret = import_obj_create(adev, obj->dma_buf, obj, va, drm_priv, mem, size,
2407+
mmap_offset);
2408+
if (ret)
2409+
goto err_put_obj;
2410+
2411+
(*mem)->gem_handle = handle;
2412+
2413+
return 0;
2414+
23742415
err_put_obj:
23752416
drm_gem_object_put(obj);
2417+
err_release_handle:
2418+
drm_gem_handle_delete(adev->kfd.client.file, handle);
23762419
return ret;
23772420
}
23782421

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
755755
int r;
756756

757757
if (!adev->smc_rreg)
758-
return -EPERM;
758+
return -EOPNOTSUPP;
759759

760760
if (size & 0x3 || *pos & 0x3)
761761
return -EINVAL;
@@ -814,7 +814,7 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *
814814
int r;
815815

816816
if (!adev->smc_wreg)
817-
return -EPERM;
817+
return -EOPNOTSUPP;
818818

819819
if (size & 0x3 || *pos & 0x3)
820820
return -EINVAL;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ bool amdgpu_device_seamless_boot_supported(struct amdgpu_device *adev)
15991599
if (adev->mman.keep_stolen_vga_memory)
16001600
return false;
16011601

1602-
return adev->ip_versions[DCE_HWIP][0] >= IP_VERSION(3, 0, 0);
1602+
return amdgpu_ip_version(adev, DCE_HWIP, 0) >= IP_VERSION(3, 0, 0);
16031603
}
16041604

16051605
/*
@@ -4589,8 +4589,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
45894589

45904590
amdgpu_ras_suspend(adev);
45914591

4592-
amdgpu_ttm_set_buffer_funcs_status(adev, false);
4593-
45944592
amdgpu_device_ip_suspend_phase1(adev);
45954593

45964594
if (!adev->in_s0ix)

0 commit comments

Comments
 (0)