Skip to content

Commit a9062ec

Browse files
committed
Merge tag 'amd-drm-fixes-6.16-2025-06-05' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-fixes-6.16-2025-06-05: amdgpu: - IP discovery fix - Cleaner shader fix for GC 10.1.x - OD fix - UserQ fixes - Non-OLED panel fix - Misc display fixes - Brightness fixes amdkfd: - Enable CONFIG_HSA_AMD on RISCV Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2 parents 4f577be + 8b5f3a2 commit a9062ec

File tree

17 files changed

+205
-51
lines changed

17 files changed

+205
-51
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,10 @@ static int amdgpu_discovery_read_binary_from_sysmem(struct amdgpu_device *adev,
270270
static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
271271
uint8_t *binary)
272272
{
273+
bool sz_valid = true;
273274
uint64_t vram_size;
274-
u32 msg;
275275
int i, ret = 0;
276+
u32 msg;
276277

277278
if (!amdgpu_sriov_vf(adev)) {
278279
/* It can take up to a second for IFWI init to complete on some dGPUs,
@@ -291,16 +292,25 @@ static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
291292
}
292293
}
293294

294-
vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
295+
vram_size = RREG32(mmRCC_CONFIG_MEMSIZE);
296+
if (!vram_size || vram_size == U32_MAX)
297+
sz_valid = false;
298+
else
299+
vram_size <<= 20;
295300

296-
if (vram_size) {
301+
if (sz_valid) {
297302
uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
298303
amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
299304
adev->mman.discovery_tmr_size, false);
300305
} else {
301306
ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary);
302307
}
303308

309+
if (ret)
310+
dev_err(adev->dev,
311+
"failed to read discovery info from memory, vram size read: %llx",
312+
vram_size);
313+
304314
return ret;
305315
}
306316

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ amdgpu_gem_add_input_fence(struct drm_file *filp,
5858
return 0;
5959

6060
syncobj_handles = memdup_user(u64_to_user_ptr(syncobj_handles_array),
61-
sizeof(uint32_t) * num_syncobj_handles);
61+
size_mul(sizeof(uint32_t), num_syncobj_handles));
6262
if (IS_ERR(syncobj_handles))
6363
return PTR_ERR(syncobj_handles);
6464

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,9 @@ void amdgpu_gfx_profile_ring_begin_use(struct amdgpu_ring *ring)
22282228
enum PP_SMC_POWER_PROFILE profile;
22292229
int r;
22302230

2231+
if (amdgpu_dpm_is_overdrive_enabled(adev))
2232+
return;
2233+
22312234
if (adev->gfx.num_gfx_rings)
22322235
profile = PP_SMC_POWER_PROFILE_FULLSCREEN3D;
22332236
else
@@ -2258,6 +2261,11 @@ void amdgpu_gfx_profile_ring_begin_use(struct amdgpu_ring *ring)
22582261

22592262
void amdgpu_gfx_profile_ring_end_use(struct amdgpu_ring *ring)
22602263
{
2264+
struct amdgpu_device *adev = ring->adev;
2265+
2266+
if (amdgpu_dpm_is_overdrive_enabled(adev))
2267+
return;
2268+
22612269
atomic_dec(&ring->adev->gfx.total_submission_cnt);
22622270

22632271
schedule_delayed_work(&ring->adev->gfx.idle_work, GFX_PROFILE_IDLE_TIMEOUT);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
430430

431431
num_syncobj_handles = args->num_syncobj_handles;
432432
syncobj_handles = memdup_user(u64_to_user_ptr(args->syncobj_handles),
433-
sizeof(u32) * num_syncobj_handles);
433+
size_mul(sizeof(u32), num_syncobj_handles));
434434
if (IS_ERR(syncobj_handles))
435435
return PTR_ERR(syncobj_handles);
436436

@@ -612,21 +612,21 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
612612

613613
num_read_bo_handles = wait_info->num_bo_read_handles;
614614
bo_handles_read = memdup_user(u64_to_user_ptr(wait_info->bo_read_handles),
615-
sizeof(u32) * num_read_bo_handles);
615+
size_mul(sizeof(u32), num_read_bo_handles));
616616
if (IS_ERR(bo_handles_read))
617617
return PTR_ERR(bo_handles_read);
618618

619619
num_write_bo_handles = wait_info->num_bo_write_handles;
620620
bo_handles_write = memdup_user(u64_to_user_ptr(wait_info->bo_write_handles),
621-
sizeof(u32) * num_write_bo_handles);
621+
size_mul(sizeof(u32), num_write_bo_handles));
622622
if (IS_ERR(bo_handles_write)) {
623623
r = PTR_ERR(bo_handles_write);
624624
goto free_bo_handles_read;
625625
}
626626

627627
num_syncobj = wait_info->num_syncobj_handles;
628628
syncobj_handles = memdup_user(u64_to_user_ptr(wait_info->syncobj_handles),
629-
sizeof(u32) * num_syncobj);
629+
size_mul(sizeof(u32), num_syncobj));
630630
if (IS_ERR(syncobj_handles)) {
631631
r = PTR_ERR(syncobj_handles);
632632
goto free_bo_handles_write;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ static const u32 gfx_10_1_10_cleaner_shader_hex[] = {
4343
0xd70f6a01, 0x000202ff,
4444
0x00000400, 0x80828102,
4545
0xbf84fff7, 0xbefc03ff,
46-
0x00000068, 0xbe803080,
47-
0xbe813080, 0xbe823080,
48-
0xbe833080, 0x80fc847c,
46+
0x00000068, 0xbe803000,
47+
0xbe813000, 0xbe823000,
48+
0xbe833000, 0x80fc847c,
4949
0xbf84fffa, 0xbeea0480,
5050
0xbeec0480, 0xbeee0480,
5151
0xbef00480, 0xbef20480,

drivers/gpu/drm/amd/amdgpu/gfx_v10_1_10_cleaner_shader.asm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ shader main
4040
type(CS)
4141
wave_size(32)
4242
// Note: original source code from SQ team
43-
4443
//
4544
// Create 32 waves in a threadgroup (CS waves)
4645
// Each allocates 64 VGPRs
@@ -71,8 +70,8 @@ label_0005:
7170
s_sub_u32 s2, s2, 8
7271
s_cbranch_scc0 label_0005
7372
//
74-
s_mov_b32 s2, 0x80000000 // Bit31 is first_wave
75-
s_and_b32 s2, s2, s0 // sgpr0 has tg_size (first_wave) term as in ucode only COMPUTE_PGM_RSRC2.tg_size_en is set
73+
s_mov_b32 s2, 0x80000000 // Bit31 is first_wave
74+
s_and_b32 s2, s2, s1 // sgpr0 has tg_size (first_wave) term as in ucode only COMPUTE_PGM_RSRC2.tg_size_en is set
7675
s_cbranch_scc0 label_0023 // Clean LDS if its first wave of ThreadGroup/WorkGroup
7776
// CLEAR LDS
7877
//
@@ -99,10 +98,10 @@ label_001F:
9998
label_0023:
10099
s_mov_b32 m0, 0x00000068 // Loop 108/4=27 times (loop unrolled for performance)
101100
label_sgpr_loop:
102-
s_movreld_b32 s0, 0
103-
s_movreld_b32 s1, 0
104-
s_movreld_b32 s2, 0
105-
s_movreld_b32 s3, 0
101+
s_movreld_b32 s0, s0
102+
s_movreld_b32 s1, s0
103+
s_movreld_b32 s2, s0
104+
s_movreld_b32 s3, s0
106105
s_sub_u32 m0, m0, 4
107106
s_cbranch_scc0 label_sgpr_loop
108107

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "gc/gc_12_0_0_offset.h"
3737
#include "gc/gc_12_0_0_sh_mask.h"
3838
#include "soc24_enum.h"
39-
#include "ivsrcid/gfx/irqsrcs_gfx_11_0_0.h"
39+
#include "ivsrcid/gfx/irqsrcs_gfx_12_0_0.h"
4040

4141
#include "soc15.h"
4242
#include "clearstate_gfx12.h"
@@ -1453,28 +1453,28 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
14531453

14541454
/* EOP Event */
14551455
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1456-
GFX_11_0_0__SRCID__CP_EOP_INTERRUPT,
1456+
GFX_12_0_0__SRCID__CP_EOP_INTERRUPT,
14571457
&adev->gfx.eop_irq);
14581458
if (r)
14591459
return r;
14601460

14611461
/* Bad opcode Event */
14621462
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1463-
GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR,
1463+
GFX_12_0_0__SRCID__CP_BAD_OPCODE_ERROR,
14641464
&adev->gfx.bad_op_irq);
14651465
if (r)
14661466
return r;
14671467

14681468
/* Privileged reg */
14691469
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1470-
GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,
1470+
GFX_12_0_0__SRCID__CP_PRIV_REG_FAULT,
14711471
&adev->gfx.priv_reg_irq);
14721472
if (r)
14731473
return r;
14741474

14751475
/* Privileged inst */
14761476
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1477-
GFX_11_0_0__SRCID__CP_PRIV_INSTR_FAULT,
1477+
GFX_12_0_0__SRCID__CP_PRIV_INSTR_FAULT,
14781478
&adev->gfx.priv_inst_irq);
14791479
if (r)
14801480
return r;

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

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "gc/gc_12_0_0_offset.h"
3434
#include "gc/gc_12_0_0_sh_mask.h"
3535
#include "hdp/hdp_6_0_0_offset.h"
36-
#include "ivsrcid/gfx/irqsrcs_gfx_11_0_0.h"
36+
#include "ivsrcid/gfx/irqsrcs_gfx_12_0_0.h"
3737

3838
#include "soc15_common.h"
3939
#include "soc15.h"
@@ -43,6 +43,7 @@
4343
#include "sdma_v7_0.h"
4444
#include "v12_structs.h"
4545
#include "mes_userqueue.h"
46+
#include "amdgpu_userq_fence.h"
4647

4748
MODULE_FIRMWARE("amdgpu/sdma_7_0_0.bin");
4849
MODULE_FIRMWARE("amdgpu/sdma_7_0_1.bin");
@@ -910,6 +911,9 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd,
910911
m->sdmax_rlcx_csa_addr_lo = lower_32_bits(prop->csa_addr);
911912
m->sdmax_rlcx_csa_addr_hi = upper_32_bits(prop->csa_addr);
912913

914+
m->sdmax_rlcx_mcu_dbg0 = lower_32_bits(prop->fence_address);
915+
m->sdmax_rlcx_mcu_dbg1 = upper_32_bits(prop->fence_address);
916+
913917
return 0;
914918
}
915919

@@ -1296,11 +1300,18 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block)
12961300

12971301
/* SDMA trap event */
12981302
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
1299-
GFX_11_0_0__SRCID__SDMA_TRAP,
1303+
GFX_12_0_0__SRCID__SDMA_TRAP,
13001304
&adev->sdma.trap_irq);
13011305
if (r)
13021306
return r;
13031307

1308+
/* SDMA user fence event */
1309+
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
1310+
GFX_12_0_0__SRCID__SDMA_FENCE,
1311+
&adev->sdma.fence_irq);
1312+
if (r)
1313+
return r;
1314+
13041315
for (i = 0; i < adev->sdma.num_instances; i++) {
13051316
ring = &adev->sdma.instance[i].ring;
13061317
ring->ring_obj = NULL;
@@ -1526,25 +1537,9 @@ static int sdma_v7_0_process_trap_irq(struct amdgpu_device *adev,
15261537
struct amdgpu_iv_entry *entry)
15271538
{
15281539
int instances, queue;
1529-
uint32_t mes_queue_id = entry->src_data[0];
15301540

15311541
DRM_DEBUG("IH: SDMA trap\n");
15321542

1533-
if (adev->enable_mes && (mes_queue_id & AMDGPU_FENCE_MES_QUEUE_FLAG)) {
1534-
struct amdgpu_mes_queue *queue;
1535-
1536-
mes_queue_id &= AMDGPU_FENCE_MES_QUEUE_ID_MASK;
1537-
1538-
spin_lock(&adev->mes.queue_id_lock);
1539-
queue = idr_find(&adev->mes.queue_id_idr, mes_queue_id);
1540-
if (queue) {
1541-
DRM_DEBUG("process smda queue id = %d\n", mes_queue_id);
1542-
amdgpu_fence_process(queue->ring);
1543-
}
1544-
spin_unlock(&adev->mes.queue_id_lock);
1545-
return 0;
1546-
}
1547-
15481543
queue = entry->ring_id & 0xf;
15491544
instances = (entry->ring_id & 0xf0) >> 4;
15501545
if (instances > 1) {
@@ -1566,6 +1561,29 @@ static int sdma_v7_0_process_trap_irq(struct amdgpu_device *adev,
15661561
return 0;
15671562
}
15681563

1564+
static int sdma_v7_0_process_fence_irq(struct amdgpu_device *adev,
1565+
struct amdgpu_irq_src *source,
1566+
struct amdgpu_iv_entry *entry)
1567+
{
1568+
u32 doorbell_offset = entry->src_data[0];
1569+
1570+
if (adev->enable_mes && doorbell_offset) {
1571+
struct amdgpu_userq_fence_driver *fence_drv = NULL;
1572+
struct xarray *xa = &adev->userq_xa;
1573+
unsigned long flags;
1574+
1575+
doorbell_offset >>= SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT;
1576+
1577+
xa_lock_irqsave(xa, flags);
1578+
fence_drv = xa_load(xa, doorbell_offset);
1579+
if (fence_drv)
1580+
amdgpu_userq_fence_driver_process(fence_drv);
1581+
xa_unlock_irqrestore(xa, flags);
1582+
}
1583+
1584+
return 0;
1585+
}
1586+
15691587
static int sdma_v7_0_process_illegal_inst_irq(struct amdgpu_device *adev,
15701588
struct amdgpu_irq_src *source,
15711589
struct amdgpu_iv_entry *entry)
@@ -1703,6 +1721,10 @@ static const struct amdgpu_irq_src_funcs sdma_v7_0_trap_irq_funcs = {
17031721
.process = sdma_v7_0_process_trap_irq,
17041722
};
17051723

1724+
static const struct amdgpu_irq_src_funcs sdma_v7_0_fence_irq_funcs = {
1725+
.process = sdma_v7_0_process_fence_irq,
1726+
};
1727+
17061728
static const struct amdgpu_irq_src_funcs sdma_v7_0_illegal_inst_irq_funcs = {
17071729
.process = sdma_v7_0_process_illegal_inst_irq,
17081730
};
@@ -1712,6 +1734,7 @@ static void sdma_v7_0_set_irq_funcs(struct amdgpu_device *adev)
17121734
adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_INSTANCE0 +
17131735
adev->sdma.num_instances;
17141736
adev->sdma.trap_irq.funcs = &sdma_v7_0_trap_irq_funcs;
1737+
adev->sdma.fence_irq.funcs = &sdma_v7_0_fence_irq_funcs;
17151738
adev->sdma.illegal_inst_irq.funcs = &sdma_v7_0_illegal_inst_irq_funcs;
17161739
}
17171740

drivers/gpu/drm/amd/amdkfd/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
config HSA_AMD
77
bool "HSA kernel driver for AMD GPU devices"
8-
depends on DRM_AMDGPU && (X86_64 || ARM64 || PPC64)
8+
depends on DRM_AMDGPU && (X86_64 || ARM64 || PPC64 || (RISCV && 64BIT))
99
select HMM_MIRROR
1010
select MMU_NOTIFIER
1111
select DRM_AMDGPU_USERPTR

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4910,6 +4910,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49104910
struct backlight_properties props = { 0 };
49114911
struct amdgpu_dm_backlight_caps caps = { 0 };
49124912
char bl_name[16];
4913+
int min, max;
49134914

49144915
if (aconnector->bl_idx == -1)
49154916
return;
@@ -4922,11 +4923,15 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49224923
}
49234924

49244925
amdgpu_acpi_get_backlight_caps(&caps);
4925-
if (caps.caps_valid) {
4926+
if (caps.caps_valid && get_brightness_range(&caps, &min, &max)) {
49264927
if (power_supply_is_system_supplied() > 0)
4927-
props.brightness = caps.ac_level;
4928+
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps.ac_level, 100);
49284929
else
4929-
props.brightness = caps.dc_level;
4930+
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps.dc_level, 100);
4931+
/* min is zero, so max needs to be adjusted */
4932+
props.max_brightness = max - min;
4933+
drm_dbg(drm, "Backlight caps: min: %d, max: %d, ac %d, dc %d\n", min, max,
4934+
caps.ac_level, caps.dc_level);
49304935
} else
49314936
props.brightness = AMDGPU_MAX_BL_LEVEL;
49324937

0 commit comments

Comments
 (0)