Skip to content

Commit 47271a0

Browse files
committed
Merge tag 'amd-drm-fixes-6.15-2025-04-09' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
amd-drm-fixes-6.15-2025-04-09: amdgpu: - MES FW version caching fixes - Only use GTT as a fallback if we already have a backing store - dma_buf fix - IP discovery fix - Replay and PSR with VRR fix - DC FP fixes - eDP fixes - KIQ TLB invalidate fix - Enable dmem groups support - Allow pinning VRAM dma bufs if imports can do P2P - Workload profile fixes - Prevent possible division by 0 in fan handling amdkfd: - Queue reset fixes Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://lore.kernel.org/r/20250409165238.1180153-1-alexander.deucher@amd.com
2 parents 9afaa16 + 34779e1 commit 47271a0

20 files changed

+187
-36
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ enum amdgpu_kiq_irq {
353353
AMDGPU_CP_KIQ_IRQ_DRIVER0 = 0,
354354
AMDGPU_CP_KIQ_IRQ_LAST
355355
};
356-
#define SRIOV_USEC_TIMEOUT 1200000 /* wait 12 * 100ms for SRIOV */
357356
#define MAX_KIQ_REG_WAIT 5000 /* in usecs, 5ms */
358357
#define MAX_KIQ_REG_BAILOUT_INTERVAL 5 /* in msecs, 5ms */
359358
#define MAX_KIQ_REG_TRY 1000

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,6 +3643,13 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
36433643
adev, adev->ip_blocks[i].version->type))
36443644
continue;
36453645

3646+
/* Since we skip suspend for S0i3, we need to cancel the delayed
3647+
* idle work here as the suspend callback never gets called.
3648+
*/
3649+
if (adev->in_s0ix &&
3650+
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GFX &&
3651+
amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(10, 0, 0))
3652+
cancel_delayed_work_sync(&adev->gfx.idle_work);
36463653
/* skip suspend of gfx/mes and psp for S0ix
36473654
* gfx is in gfxoff state, so on resume it will exit gfxoff just
36483655
* like at runtime. PSP is also part of the always on hardware

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ MODULE_FIRMWARE("amdgpu/vega20_ip_discovery.bin");
120120
MODULE_FIRMWARE("amdgpu/raven_ip_discovery.bin");
121121
MODULE_FIRMWARE("amdgpu/raven2_ip_discovery.bin");
122122
MODULE_FIRMWARE("amdgpu/picasso_ip_discovery.bin");
123+
MODULE_FIRMWARE("amdgpu/arcturus_ip_discovery.bin");
124+
MODULE_FIRMWARE("amdgpu/aldebaran_ip_discovery.bin");
123125

124126
#define mmIP_DISCOVERY_VERSION 0x16A00
125127
#define mmRCC_CONFIG_MEMSIZE 0xde3

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,25 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
7575
*/
7676
static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach)
7777
{
78-
struct drm_gem_object *obj = attach->dmabuf->priv;
79-
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
78+
struct dma_buf *dmabuf = attach->dmabuf;
79+
struct amdgpu_bo *bo = gem_to_amdgpu_bo(dmabuf->priv);
80+
u32 domains = bo->preferred_domains;
8081

81-
/* pin buffer into GTT */
82-
return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
82+
dma_resv_assert_held(dmabuf->resv);
83+
84+
/*
85+
* Try pinning into VRAM to allow P2P with RDMA NICs without ODP
86+
* support if all attachments can do P2P. If any attachment can't do
87+
* P2P just pin into GTT instead.
88+
*/
89+
list_for_each_entry(attach, &dmabuf->attachments, node)
90+
if (!attach->peer2peer)
91+
domains &= ~AMDGPU_GEM_DOMAIN_VRAM;
92+
93+
if (domains & AMDGPU_GEM_DOMAIN_VRAM)
94+
bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
95+
96+
return amdgpu_bo_pin(bo, domains);
8397
}
8498

8599
/**
@@ -134,9 +148,6 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach,
134148
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
135149
if (r)
136150
return ERR_PTR(r);
137-
138-
} else if (bo->tbo.resource->mem_type != TTM_PL_TT) {
139-
return ERR_PTR(-EBUSY);
140151
}
141152

142153
switch (bo->tbo.resource->mem_type) {
@@ -184,7 +195,7 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach,
184195
struct sg_table *sgt,
185196
enum dma_data_direction dir)
186197
{
187-
if (sgt->sgl->page_link) {
198+
if (sg_page(sgt->sgl)) {
188199
dma_unmap_sgtable(attach->dev, sgt, dir, 0);
189200
sg_free_table(sgt);
190201
kfree(sgt);

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,10 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
699699
uint32_t flush_type, bool all_hub,
700700
uint32_t inst)
701701
{
702-
u32 usec_timeout = amdgpu_sriov_vf(adev) ? SRIOV_USEC_TIMEOUT :
703-
adev->usec_timeout;
704702
struct amdgpu_ring *ring = &adev->gfx.kiq[inst].ring;
705703
struct amdgpu_kiq *kiq = &adev->gfx.kiq[inst];
706704
unsigned int ndw;
707-
int r;
705+
int r, cnt = 0;
708706
uint32_t seq;
709707

710708
/*
@@ -761,10 +759,21 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
761759

762760
amdgpu_ring_commit(ring);
763761
spin_unlock(&adev->gfx.kiq[inst].ring_lock);
764-
if (amdgpu_fence_wait_polling(ring, seq, usec_timeout) < 1) {
762+
763+
r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
764+
765+
might_sleep();
766+
while (r < 1 && cnt++ < MAX_KIQ_REG_TRY &&
767+
!amdgpu_reset_pending(adev->reset_domain)) {
768+
msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
769+
r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
770+
}
771+
772+
if (cnt > MAX_KIQ_REG_TRY) {
765773
dev_err(adev->dev, "timeout waiting for kiq fence\n");
766774
r = -ETIME;
767-
}
775+
} else
776+
r = 0;
768777
}
769778

770779
error_unlock_reset:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
163163
* When GTT is just an alternative to VRAM make sure that we
164164
* only use it as fallback and still try to fill up VRAM first.
165165
*/
166-
if (domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM &&
167-
!(adev->flags & AMD_IS_APU))
166+
if (abo->tbo.resource && !(adev->flags & AMD_IS_APU) &&
167+
domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)
168168
places[c].flags |= TTM_PL_FLAG_FALLBACK;
169169
c++;
170170
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <linux/dma-mapping.h>
2626
#include <drm/ttm/ttm_range_manager.h>
27+
#include <drm/drm_drv.h>
2728

2829
#include "amdgpu.h"
2930
#include "amdgpu_vm.h"
@@ -907,6 +908,9 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
907908
struct ttm_resource_manager *man = &mgr->manager;
908909
int err;
909910

911+
man->cg = drmm_cgroup_register_region(adev_to_drm(adev), "vram", adev->gmc.real_vram_size);
912+
if (IS_ERR(man->cg))
913+
return PTR_ERR(man->cg);
910914
ttm_resource_manager_init(man, &adev->mman.bdev,
911915
adev->gmc.real_vram_size);
912916

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,10 @@ static void mes_v11_0_get_fw_version(struct amdgpu_device *adev)
894894
{
895895
int pipe;
896896

897+
/* return early if we have already fetched these */
898+
if (adev->mes.sched_version && adev->mes.kiq_version)
899+
return;
900+
897901
/* get MES scheduler/KIQ versions */
898902
mutex_lock(&adev->srbm_mutex);
899903

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,20 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
13921392
mes_v12_0_queue_init_register(ring);
13931393
}
13941394

1395-
/* get MES scheduler/KIQ versions */
1396-
mutex_lock(&adev->srbm_mutex);
1397-
soc21_grbm_select(adev, 3, pipe, 0, 0);
1395+
if (((pipe == AMDGPU_MES_SCHED_PIPE) && !adev->mes.sched_version) ||
1396+
((pipe == AMDGPU_MES_KIQ_PIPE) && !adev->mes.kiq_version)) {
1397+
/* get MES scheduler/KIQ versions */
1398+
mutex_lock(&adev->srbm_mutex);
1399+
soc21_grbm_select(adev, 3, pipe, 0, 0);
13981400

1399-
if (pipe == AMDGPU_MES_SCHED_PIPE)
1400-
adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
1401-
else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
1402-
adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
1401+
if (pipe == AMDGPU_MES_SCHED_PIPE)
1402+
adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
1403+
else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
1404+
adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
14031405

1404-
soc21_grbm_select(adev, 0, 0, 0, 0);
1405-
mutex_unlock(&adev->srbm_mutex);
1406+
soc21_grbm_select(adev, 0, 0, 0, 0);
1407+
mutex_unlock(&adev->srbm_mutex);
1408+
}
14061409

14071410
return 0;
14081411
}

drivers/gpu/drm/amd/amdkfd/kfd_topology.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,9 +1983,6 @@ static void kfd_topology_set_capabilities(struct kfd_topology_device *dev)
19831983
if (kfd_dbg_has_ttmps_always_setup(dev->gpu))
19841984
dev->node_props.debug_prop |= HSA_DBG_DISPATCH_INFO_ALWAYS_VALID;
19851985

1986-
if (dev->gpu->adev->sdma.supported_reset & AMDGPU_RESET_TYPE_PER_QUEUE)
1987-
dev->node_props.capability2 |= HSA_CAP2_PER_SDMA_QUEUE_RESET_SUPPORTED;
1988-
19891986
if (KFD_GC_VERSION(dev->gpu) < IP_VERSION(10, 0, 0)) {
19901987
if (KFD_GC_VERSION(dev->gpu) == IP_VERSION(9, 4, 3) ||
19911988
KFD_GC_VERSION(dev->gpu) == IP_VERSION(9, 4, 4))
@@ -2001,7 +1998,11 @@ static void kfd_topology_set_capabilities(struct kfd_topology_device *dev)
20011998
dev->node_props.capability |=
20021999
HSA_CAP_TRAP_DEBUG_PRECISE_MEMORY_OPERATIONS_SUPPORTED;
20032000

2004-
dev->node_props.capability |= HSA_CAP_PER_QUEUE_RESET_SUPPORTED;
2001+
if (!amdgpu_sriov_vf(dev->gpu->adev))
2002+
dev->node_props.capability |= HSA_CAP_PER_QUEUE_RESET_SUPPORTED;
2003+
2004+
if (dev->gpu->adev->sdma.supported_reset & AMDGPU_RESET_TYPE_PER_QUEUE)
2005+
dev->node_props.capability2 |= HSA_CAP2_PER_SDMA_QUEUE_RESET_SUPPORTED;
20052006
} else {
20062007
dev->node_props.debug_prop |= HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX10 |
20072008
HSA_DBG_WATCH_ADDR_MASK_HI_BIT;

0 commit comments

Comments
 (0)