All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Jay Cornwall <jay.cornwall@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Kent Russell <kent.russell@amd.com>
Subject: Re: [PATCH v3] drm/amdgpu: Increase KIQ invalidate_tlbs timeout
Date: Wed, 2 Apr 2025 09:37:01 +0200	[thread overview]
Message-ID: <be35f643-0006-4a12-be34-2b0f02cb3a5f@gmail.com> (raw)
In-Reply-To: <20250331154456.1879064-1-jay.cornwall@amd.com>



Am 31.03.25 um 17:44 schrieb Jay Cornwall:
> KIQ invalidate_tlbs request has been seen to marginally exceed the
> configured 100 ms timeout on systems under load.
>
> All other KIQ requests in the driver use a 10 second timeout. Use a
> similar timeout implementation on the invalidate_tlbs path.
>
> v2: Poll once before msleep
> v3: Fix return value
>
> Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
> Cc: Kent Russell <kent.russell@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  1 -
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 ++++++++++++++-----
>  2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index ffca74a476da..3cdb5f8325aa 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -356,7 +356,6 @@ enum amdgpu_kiq_irq {
>  	AMDGPU_CP_KIQ_IRQ_DRIVER0 = 0,
>  	AMDGPU_CP_KIQ_IRQ_LAST
>  };
> -#define SRIOV_USEC_TIMEOUT  1200000 /* wait 12 * 100ms for SRIOV */
>  #define MAX_KIQ_REG_WAIT       5000 /* in usecs, 5ms */
>  #define MAX_KIQ_REG_BAILOUT_INTERVAL   5 /* in msecs, 5ms */
>  #define MAX_KIQ_REG_TRY 1000

Unrelated to this patch here, but defines like those *must* have an AMDGPU_ prefix.

Please fix in a follow up patch.

Regards,
Christian.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 464625282872..ecb74ccf1d90 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -699,12 +699,10 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
>  				   uint32_t flush_type, bool all_hub,
>  				   uint32_t inst)
>  {
> -	u32 usec_timeout = amdgpu_sriov_vf(adev) ? SRIOV_USEC_TIMEOUT :
> -		adev->usec_timeout;
>  	struct amdgpu_ring *ring = &adev->gfx.kiq[inst].ring;
>  	struct amdgpu_kiq *kiq = &adev->gfx.kiq[inst];
>  	unsigned int ndw;
> -	int r;
> +	int r, cnt = 0;
>  	uint32_t seq;
>  
>  	/*
> @@ -761,10 +759,21 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
>  
>  		amdgpu_ring_commit(ring);
>  		spin_unlock(&adev->gfx.kiq[inst].ring_lock);
> -		if (amdgpu_fence_wait_polling(ring, seq, usec_timeout) < 1) {
> +
> +		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
> +
> +		might_sleep();
> +		while (r < 1 && cnt++ < MAX_KIQ_REG_TRY &&
> +		       !amdgpu_reset_pending(adev->reset_domain)) {
> +			msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
> +			r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
> +		}
> +
> +		if (cnt > MAX_KIQ_REG_TRY) {
>  			dev_err(adev->dev, "timeout waiting for kiq fence\n");
>  			r = -ETIME;
> -		}
> +		} else
> +			r = 0;
>  	}
>  
>  error_unlock_reset:


  parent reply	other threads:[~2025-04-02  7:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 15:44 [PATCH v3] drm/amdgpu: Increase KIQ invalidate_tlbs timeout Jay Cornwall
2025-04-01 19:58 ` Kasiviswanathan, Harish
2025-04-02  7:37 ` Christian König [this message]
2025-04-02 16:33   ` Jay Cornwall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be35f643-0006-4a12-be34-2b0f02cb3a5f@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=jay.cornwall@amd.com \
    --cc=kent.russell@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.