Skip to content

Commit aee43aa

Browse files
committed
Merge tag 'amd-drm-fixes-7.1-2026-05-20' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
amd-drm-fixes-7.1-2026-05-20: amdgpu: - Userq fixes - VPE fix - SMU 15 fix - Misc fixes - VCE fixes - DC bios parsing fixes - DC aux fix - Mode1 reset fix - RAS fixes amdkfd: - Misc fixes radeon: - CS parser fix Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://patch.msgid.link/20260520181359.28421-1-alexander.deucher@amd.com
2 parents 30afd24 + b6fe4ff commit aee43aa

27 files changed

Lines changed: 347 additions & 211 deletions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,6 @@ struct amdgpu_device {
11901190
bool apu_prefer_gtt;
11911191

11921192
bool userq_halt_for_enforce_isolation;
1193-
struct work_struct userq_reset_work;
11941193
struct amdgpu_uid *uid_info;
11951194

11961195
struct amdgpu_uma_carveout_info uma_info;

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include "amdgpu_ras.h"
3737
#include "amdgpu_umc.h"
3838
#include "amdgpu_reset.h"
39+
#if IS_ENABLED(CONFIG_HSA_AMD)
40+
#include "kfd_priv.h"
41+
#endif
3942

4043
/* Total memory size in system memory and all GPU VRAM. Used to
4144
* estimate worst case amount of memory to reserve for page tables
@@ -320,6 +323,28 @@ void amdgpu_amdkfd_gpu_reset(struct amdgpu_device *adev)
320323
(void)amdgpu_reset_domain_schedule(adev->reset_domain, &adev->kfd.reset_work);
321324
}
322325

326+
void amdgpu_amdkfd_clear_kfd_mapping(struct amdgpu_device *adev)
327+
{
328+
#if IS_ENABLED(CONFIG_HSA_AMD)
329+
struct kfd_dev *kfd = adev->kfd.dev;
330+
unsigned int i;
331+
332+
if (!kfd)
333+
return;
334+
335+
for (i = 0; i < kfd->num_nodes; i++) {
336+
struct kfd_node *node = kfd->nodes[i];
337+
338+
kfd_dev_unmap_mapping_range(KFD_MMAP_TYPE_DOORBELL |
339+
KFD_MMAP_GPU_ID(node->id),
340+
kfd_doorbell_process_slice(kfd));
341+
kfd_dev_unmap_mapping_range(KFD_MMAP_TYPE_MMIO |
342+
KFD_MMAP_GPU_ID(node->id),
343+
PAGE_SIZE);
344+
}
345+
#endif
346+
}
347+
323348
int amdgpu_amdkfd_alloc_kernel_mem(struct amdgpu_device *adev, size_t size,
324349
u32 domain, void **mem_obj, uint64_t *gpu_addr,
325350
void **cpu_ptr, bool cp_mqd_gfx9)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ int amdgpu_amdkfd_reserve_mem_limit(struct amdgpu_device *adev,
358358
uint64_t size, u32 alloc_flag, int8_t xcp_id);
359359
void amdgpu_amdkfd_unreserve_mem_limit(struct amdgpu_device *adev,
360360
uint64_t size, u32 alloc_flag, int8_t xcp_id);
361+
void amdgpu_amdkfd_clear_kfd_mapping(struct amdgpu_device *adev);
361362

362363
u64 amdgpu_amdkfd_xcp_memory_size(struct amdgpu_device *adev, int xcp_id);
363364

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
37873787
}
37883788

37893789
INIT_WORK(&adev->xgmi_reset_work, amdgpu_device_xgmi_reset_func);
3790-
INIT_WORK(&adev->userq_reset_work, amdgpu_userq_reset_work);
37913790

37923791
amdgpu_coredump_init(adev);
37933792

@@ -5478,7 +5477,7 @@ static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev)
54785477
if (!amdgpu_sriov_vf(adev))
54795478
cancel_work(&adev->reset_work);
54805479
#endif
5481-
cancel_work(&adev->userq_reset_work);
5480+
amdgpu_userq_mgr_cancel_reset_work(adev);
54825481

54835482
if (adev->kfd.dev)
54845483
cancel_work(&adev->kfd.reset_work);
@@ -5836,6 +5835,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
58365835
/* We need to lock reset domain only once both for XGMI and single device */
58375836
amdgpu_device_recovery_get_reset_lock(adev, &device_list);
58385837

5838+
/* unmap all the mappings of doorbell and framebuffer to prevent user space from
5839+
* accessing them
5840+
*/
5841+
unmap_mapping_range(adev->ddev.anon_inode->i_mapping, 0, 0, 1);
5842+
amdgpu_amdkfd_clear_kfd_mapping(adev);
5843+
58395844
amdgpu_device_halt_activities(adev, job, reset_context, &device_list,
58405845
hive, need_emergency_restart);
58415846
if (need_emergency_restart)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static int amdgpu_discovery_get_tmr_info(struct amdgpu_device *adev,
304304
adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].offset;
305305
adev->discovery.size =
306306
adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb << 10;
307-
if (!adev->discovery.offset || !adev->discovery.size)
307+
if (!adev->discovery.size)
308308
return -EINVAL;
309309
} else {
310310
goto out;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/pci.h>
3232
#include <linux/dma-buf.h>
3333
#include <linux/dma-fence-unwrap.h>
34+
#include <linux/uaccess.h>
3435

3536
#include <drm/amdgpu_drm.h>
3637
#include <drm/drm_drv.h>
@@ -508,6 +509,9 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
508509
if (offset_in_page(args->addr | args->size))
509510
return -EINVAL;
510511

512+
if (!access_ok((void __user *)(uintptr_t)args->addr, args->size))
513+
return -EFAULT;
514+
511515
/* reject unknown flag values */
512516
if (args->flags & ~(AMDGPU_GEM_USERPTR_READONLY |
513517
AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_VALIDATE |
@@ -821,7 +825,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
821825
struct drm_syncobj *timeline_syncobj = NULL;
822826
struct dma_fence_chain *timeline_chain = NULL;
823827
struct drm_exec exec;
824-
uint64_t vm_size;
828+
uint64_t vm_size, tmp;
825829
int r = 0;
826830

827831
/* Validate virtual address range against reserved regions. */
@@ -845,7 +849,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
845849

846850
vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
847851
vm_size -= AMDGPU_VA_RESERVED_TOP;
848-
if (args->va_address + args->map_size > vm_size) {
852+
if (check_add_overflow(args->va_address, args->map_size, &tmp) || tmp > vm_size) {
849853
dev_dbg(dev->dev,
850854
"va_address 0x%llx is in top reserved area 0x%llx\n",
851855
args->va_address + args->map_size, vm_size);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,18 @@ int amdgpu_gtt_mgr_alloc_entries(struct amdgpu_gtt_mgr *mgr,
199199
enum drm_mm_insert_mode mode)
200200
{
201201
struct amdgpu_device *adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
202+
u32 alignment = 0;
202203
int r;
203204

205+
/* Align to TLB L2 cache entry size to work around "V bit HW bug" */
206+
if (adev->asic_type == CHIP_TAHITI) {
207+
alignment = 32 * 1024 / AMDGPU_GPU_PAGE_SIZE;
208+
num_pages = ALIGN(num_pages, alignment);
209+
}
210+
204211
spin_lock(&mgr->lock);
205212
r = drm_mm_insert_node_in_range(&mgr->mm, mm_node, num_pages,
206-
0, GART_ENTRY_WITHOUT_BO_COLOR, 0,
213+
alignment, GART_ENTRY_WITHOUT_BO_COLOR, 0,
207214
adev->gmc.gart_size >> PAGE_SHIFT,
208215
mode);
209216
spin_unlock(&mgr->lock);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ struct amdgpu_bo_va {
9696
* if non-zero, cannot unmap from GPU because user queues may still access it
9797
*/
9898
unsigned int queue_refcount;
99-
atomic_t userq_va_mapped;
99+
/* Indicates if this buffer is mapped for any user queue. Once set, never reset. */
100+
bool userq_va_mapped;
100101
};
101102

102103
struct amdgpu_bo {

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va,
175175
{
176176
unsigned long bit_pos;
177177

178-
bit_pos = find_first_zero_bit(adev->seq64.used, adev->seq64.num_sem);
179-
if (bit_pos >= adev->seq64.num_sem)
180-
return -ENOSPC;
178+
for (;;) {
179+
bit_pos = find_first_zero_bit(adev->seq64.used, adev->seq64.num_sem);
180+
if (bit_pos >= adev->seq64.num_sem)
181+
return -ENOSPC;
181182

182-
__set_bit(bit_pos, adev->seq64.used);
183+
if (!test_and_set_bit(bit_pos, adev->seq64.used))
184+
break;
185+
}
183186

184187
*va = bit_pos * sizeof(u64) + amdgpu_seq64_get_va_base(adev);
185188

@@ -205,7 +208,7 @@ void amdgpu_seq64_free(struct amdgpu_device *adev, u64 va)
205208

206209
bit_pos = (va - amdgpu_seq64_get_va_base(adev)) / sizeof(u64);
207210
if (bit_pos < adev->seq64.num_sem)
208-
__clear_bit(bit_pos, adev->seq64.used);
211+
clear_bit(bit_pos, adev->seq64.used);
209212
}
210213

211214
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
130130
if (adev->umc.ras && adev->umc.ras->ras_block.hw_ops &&
131131
adev->umc.ras->ras_block.hw_ops->query_ras_error_address &&
132132
adev->umc.max_ras_err_cnt_per_query) {
133+
kfree(err_data->err_addr);
133134
err_data->err_addr =
134135
kzalloc_objs(struct eeprom_table_record,
135136
adev->umc.max_ras_err_cnt_per_query);
@@ -160,6 +161,7 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
160161
if (adev->umc.ras &&
161162
adev->umc.ras->ecc_info_query_ras_error_address &&
162163
adev->umc.max_ras_err_cnt_per_query) {
164+
kfree(err_data->err_addr);
163165
err_data->err_addr =
164166
kzalloc_objs(struct eeprom_table_record,
165167
adev->umc.max_ras_err_cnt_per_query);

0 commit comments

Comments
 (0)