All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
To: Jonathan Kim <jonathan.kim@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Philip.Yang@amd.com, Felix.Kuehling@amd.com
Subject: Re: [PATCH] drm/amdgpu: add ih call to process until checkpoint
Date: Tue, 23 Feb 2021 17:45:15 -0500	[thread overview]
Message-ID: <c8f2c2ba-e284-7194-e04c-2a5faf53297a@amd.com> (raw)
In-Reply-To: <20210223211026.116403-1-jonathan.kim@amd.com>


On 2021-02-23 4:10 p.m., Jonathan Kim wrote:
> Add IH function to allow caller to process ring entries until the
> checkpoint write pointer.
>
> Suggested-by: Felix Kuehling <felix.kuehling@amd.com>
> Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 46 +++++++++++++++++++++++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h |  2 ++
>   2 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
> index dc852af4f3b7..cae50af9559d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
> @@ -22,7 +22,7 @@
>    */
>   
>   #include <linux/dma-mapping.h>
> -
> +#include <linux/processor.h>
>   #include "amdgpu.h"
>   #include "amdgpu_ih.h"
>   
> @@ -160,6 +160,50 @@ void amdgpu_ih_ring_write(struct amdgpu_ih_ring *ih, const uint32_t *iv,
>   	}
>   }
>   
> +/**
> + * amdgpu_ih_wait_on_checkpoint_process - wait to process IVs up to checkpoint
> + *
> + * @adev: amdgpu_device pointer
> + * @ih: ih ring to process
> + *
> + * Used to ensure ring has processed IVs up to the checkpoint write pointer.
> + */
> +int amdgpu_ih_wait_on_checkpoint_process(struct amdgpu_device *adev,
> +					struct amdgpu_ih_ring *ih)
> +{
> +	u32 prev_rptr, cur_rptr, checkpoint_wptr;
> +
> +	if (!ih->enabled || adev->shutdown)
> +		return -ENODEV;
> +
> +	cur_rptr = READ_ONCE(ih->rptr);
> +	/* Order read of current rptr with checktpoint wptr. */
> +	mb();
> +	checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
> +


Isn't rmb() enough in this case ? If I understand correctly you just 
want to confirm that
you are not reading stale checkpoint_wptr while reading fresh cur_rptr.

Andrey


> +	/* allow rptr to wrap around  */
> +	if (cur_rptr > checkpoint_wptr) {
> +		spin_begin();
> +		do {
> +			spin_cpu_relax();
> +			prev_rptr = cur_rptr;
> +			cur_rptr = READ_ONCE(ih->rptr);
> +		} while (cur_rptr >= prev_rptr);
> +		spin_end();
> +	}
> +
> +	/* wait for rptr to catch up to or pass checkpoint. */
> +	spin_begin();
> +	do {
> +		spin_cpu_relax();
> +		prev_rptr = cur_rptr;
> +		cur_rptr = READ_ONCE(ih->rptr);
> +	} while (cur_rptr >= prev_rptr && cur_rptr < checkpoint_wptr);
> +	spin_end();
> +
> +	return 0;
> +}
> +
>   /**
>    * amdgpu_ih_process - interrupt handler
>    *
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h
> index 6ed4a85fc7c3..6817f0a812d2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h
> @@ -87,6 +87,8 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih,
>   void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih);
>   void amdgpu_ih_ring_write(struct amdgpu_ih_ring *ih, const uint32_t *iv,
>   			  unsigned int num_dw);
> +int amdgpu_ih_wait_on_checkpoint_process(struct amdgpu_device *adev,
> +					struct amdgpu_ih_ring *ih);
>   int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih);
>   void amdgpu_ih_decode_iv_helper(struct amdgpu_device *adev,
>   				struct amdgpu_ih_ring *ih,
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-02-23 22:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 21:10 [PATCH] drm/amdgpu: add ih call to process until checkpoint Jonathan Kim
2021-02-23 22:45 ` Andrey Grodzovsky [this message]
2021-02-24  9:16 ` Christian König
2021-02-24 15:54   ` Kim, Jonathan
2021-02-25  3:15     ` Felix Kuehling
2021-02-25 13:53       ` Christian König
2021-02-25 15:35         ` Felix Kuehling
2021-02-25 16:48           ` Christian König
2021-02-25 18:33             ` Felix Kuehling
2021-02-25 20:05               ` Christian König

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=c8f2c2ba-e284-7194-e04c-2a5faf53297a@amd.com \
    --to=andrey.grodzovsky@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=jonathan.kim@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.