Skip to content

Commit

Permalink
drm/amdgpu: update the handle ptr in wait_for_idle
Browse files Browse the repository at this point in the history
Update the *handle to amdgpu_ip_block ptr for all
functions pointers of wait_for_idle.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Sunil Khatri authored and Alex Deucher committed Oct 7, 2024
1 parent ded57e4 commit 82ae661
Show file tree
Hide file tree
Showing 79 changed files with 219 additions and 157 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ static bool acp_is_idle(void *handle)
return true;
}

static int acp_wait_for_idle(void *handle)
static int acp_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev,
if (!adev->ip_blocks[i].status.valid)
continue;
if (adev->ip_blocks[i].version->type == block_type) {
r = adev->ip_blocks[i].version->funcs->wait_for_idle((void *)adev);
r = adev->ip_blocks[i].version->funcs->wait_for_idle(&adev->ip_blocks[i]);
if (r)
return r;
break;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static bool isp_is_idle(void *handle)
return true;
}

static int isp_wait_for_idle(void *handle)
static int isp_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static bool amdgpu_vkms_is_idle(void *handle)
return true;
}

static int amdgpu_vkms_wait_for_idle(void *handle)
static int amdgpu_vkms_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/cik.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ static bool cik_common_is_idle(void *handle)
return true;
}

static int cik_common_wait_for_idle(void *handle)
static int cik_common_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/cik_ih.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ static bool cik_ih_is_idle(void *handle)
return true;
}

static int cik_ih_wait_for_idle(void *handle)
static int cik_ih_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/cik_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,11 @@ static bool cik_sdma_is_idle(void *handle)
return true;
}

static int cik_sdma_wait_for_idle(void *handle)
static int cik_sdma_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
tmp = RREG32(mmSRBM_STATUS2) & (SRBM_STATUS2__SDMA_BUSY_MASK |
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/cz_ih.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ static bool cz_ih_is_idle(void *handle)
return true;
}

static int cz_ih_wait_for_idle(void *handle)
static int cz_ih_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ static bool dce_v10_0_is_idle(void *handle)
return true;
}

static int dce_v10_0_wait_for_idle(void *handle)
static int dce_v10_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,7 @@ static bool dce_v11_0_is_idle(void *handle)
return true;
}

static int dce_v11_0_wait_for_idle(void *handle)
static int dce_v11_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ static bool dce_v6_0_is_idle(void *handle)
return true;
}

static int dce_v6_0_wait_for_idle(void *handle)
static int dce_v6_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,7 @@ static bool dce_v8_0_is_idle(void *handle)
return true;
}

static int dce_v8_0_wait_for_idle(void *handle)
static int dce_v8_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -7477,11 +7477,11 @@ static bool gfx_v10_0_is_idle(void *handle)
return true;
}

static int gfx_v10_0_wait_for_idle(void *handle)
static int gfx_v10_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned int i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4726,11 +4726,11 @@ static bool gfx_v11_0_is_idle(void *handle)
return true;
}

static int gfx_v11_0_wait_for_idle(void *handle)
static int gfx_v11_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -3664,11 +3664,11 @@ static bool gfx_v12_0_is_idle(void *handle)
return true;
}

static int gfx_v12_0_wait_for_idle(void *handle)
static int gfx_v12_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -3177,13 +3177,13 @@ static bool gfx_v6_0_is_idle(void *handle)
return true;
}

static int gfx_v6_0_wait_for_idle(void *handle)
static int gfx_v6_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
if (gfx_v6_0_is_idle(handle))
if (gfx_v6_0_is_idle(adev))
return 0;
udelay(1);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4523,11 +4523,11 @@ static bool gfx_v7_0_is_idle(void *handle)
return true;
}

static int gfx_v7_0_wait_for_idle(void *handle)
static int gfx_v7_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
u32 tmp;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
/* read MC_STATUS */
Expand Down
14 changes: 10 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4865,13 +4865,13 @@ static int gfx_v8_0_wait_for_rlc_idle(void *handle)
return -ETIMEDOUT;
}

static int gfx_v8_0_wait_for_idle(void *handle)
static int gfx_v8_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned int i;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
if (gfx_v8_0_is_idle(handle))
if (gfx_v8_0_is_idle(adev))
return 0;

udelay(1);
Expand All @@ -4882,6 +4882,7 @@ static int gfx_v8_0_wait_for_idle(void *handle)
static int gfx_v8_0_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_ip_block *ip_block;

amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);
amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);
Expand All @@ -4897,8 +4898,13 @@ static int gfx_v8_0_hw_fini(void *handle)
pr_debug("For SRIOV client, shouldn't do anything.\n");
return 0;
}

ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
if (!ip_block)
return -EINVAL;

amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
if (!gfx_v8_0_wait_for_idle(adev))
if (!gfx_v8_0_wait_for_idle(ip_block))
gfx_v8_0_cp_enable(adev, false);
else
pr_err("cp is busy, skip halt cp\n");
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4095,13 +4095,13 @@ static bool gfx_v9_0_is_idle(void *handle)
return true;
}

static int gfx_v9_0_wait_for_idle(void *handle)
static int gfx_v9_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
if (gfx_v9_0_is_idle(handle))
if (gfx_v9_0_is_idle(adev))
return 0;
udelay(1);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,13 +2410,13 @@ static bool gfx_v9_4_3_is_idle(void *handle)
return true;
}

static int gfx_v9_4_3_wait_for_idle(void *handle)
static int gfx_v9_4_3_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned i;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
if (gfx_v9_4_3_is_idle(handle))
if (gfx_v9_4_3_is_idle(adev))
return 0;
udelay(1);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ static bool gmc_v10_0_is_idle(void *handle)
return true;
}

static int gmc_v10_0_wait_for_idle(void *handle)
static int gmc_v10_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
/* There is no need to wait for MC idle in GMC v10.*/
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ static bool gmc_v11_0_is_idle(void *handle)
return true;
}

static int gmc_v11_0_wait_for_idle(void *handle)
static int gmc_v11_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
/* There is no need to wait for MC idle in GMC v11.*/
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static bool gmc_v12_0_is_idle(void *handle)
return true;
}

static int gmc_v12_0_wait_for_idle(void *handle)
static int gmc_v12_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
/* There is no need to wait for MC idle in GMC v11.*/
return 0;
Expand Down
30 changes: 22 additions & 8 deletions drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

static void gmc_v6_0_set_gmc_funcs(struct amdgpu_device *adev);
static void gmc_v6_0_set_irq_funcs(struct amdgpu_device *adev);
static int gmc_v6_0_wait_for_idle(void *handle);
static int gmc_v6_0_wait_for_idle(struct amdgpu_ip_block *ip_block);

MODULE_FIRMWARE("amdgpu/tahiti_mc.bin");
MODULE_FIRMWARE("amdgpu/pitcairn_mc.bin");
Expand All @@ -64,8 +64,13 @@ MODULE_FIRMWARE("amdgpu/si58_mc.bin");
static void gmc_v6_0_mc_stop(struct amdgpu_device *adev)
{
u32 blackout;
struct amdgpu_ip_block *ip_block;

gmc_v6_0_wait_for_idle((void *)adev);
ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
if (!ip_block)
return;

gmc_v6_0_wait_for_idle(ip_block);

blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
Expand Down Expand Up @@ -213,6 +218,8 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev,
static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
{
int i, j;
struct amdgpu_ip_block *ip_block;


/* Initialize HDP */
for (i = 0, j = 0; i < 32; i++, j += 0x6) {
Expand All @@ -224,7 +231,11 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
}
WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0);

if (gmc_v6_0_wait_for_idle((void *)adev))
ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
if (!ip_block)
return;

if (gmc_v6_0_wait_for_idle(ip_block))
dev_warn(adev->dev, "Wait for MC idle timedout !\n");

if (adev->mode_info.num_crtc) {
Expand All @@ -251,7 +262,7 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
WREG32(mmMC_VM_AGP_TOP, adev->gmc.agp_end >> 22);
WREG32(mmMC_VM_AGP_BOT, adev->gmc.agp_start >> 22);

if (gmc_v6_0_wait_for_idle((void *)adev))
if (gmc_v6_0_wait_for_idle(ip_block))
dev_warn(adev->dev, "Wait for MC idle timedout !\n");
}

Expand Down Expand Up @@ -950,6 +961,7 @@ static int gmc_v6_0_resume(void *handle)
static bool gmc_v6_0_is_idle(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

u32 tmp = RREG32(mmSRBM_STATUS);

if (tmp & (SRBM_STATUS__MCB_BUSY_MASK | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK |
Expand All @@ -959,13 +971,13 @@ static bool gmc_v6_0_is_idle(void *handle)
return true;
}

static int gmc_v6_0_wait_for_idle(void *handle)
static int gmc_v6_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
unsigned int i;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_device *adev = ip_block->adev;

for (i = 0; i < adev->usec_timeout; i++) {
if (gmc_v6_0_is_idle(handle))
if (gmc_v6_0_is_idle(adev))
return 0;
udelay(1);
}
Expand All @@ -976,6 +988,7 @@ static int gmc_v6_0_wait_for_idle(void *handle)
static int gmc_v6_0_soft_reset(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;

u32 srbm_soft_reset = 0;
u32 tmp = RREG32(mmSRBM_STATUS);

Expand All @@ -992,7 +1005,8 @@ static int gmc_v6_0_soft_reset(struct amdgpu_ip_block *ip_block)

if (srbm_soft_reset) {
gmc_v6_0_mc_stop(adev);
if (gmc_v6_0_wait_for_idle(adev))

if (gmc_v6_0_wait_for_idle(ip_block))
dev_warn(adev->dev, "Wait for GMC idle timed out !\n");

tmp = RREG32(mmSRBM_SOFT_RESET);
Expand Down
Loading

0 comments on commit 82ae661

Please sign in to comment.