All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: alyssa.rosenzweig@collabora.com, dri-devel@lists.freedesktop.org
Cc: airlied@linux.ie, tomeu.vizoso@collabora.com
Subject: Re: [PATCH 3/4] drm/panfrost: Add permon acquire/release helpers
Date: Wed, 2 Jun 2021 12:50:28 +0100	[thread overview]
Message-ID: <5d00a41d-b79c-14af-485b-e689f926ae2c@arm.com> (raw)
In-Reply-To: <20210527203804.12914-4-alyssa.rosenzweig@collabora.com>

On 27/05/2021 21:38, alyssa.rosenzweig@collabora.com wrote:
> From: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
> 
> Wrap the underlying CYCLE_COUNT_START/STOP commands in a safe interface
> that ensures the commands are only issued where required by guarding
> behind an atomic counter. In particular, we need to be careful about
> races between multiple in-flight jobs, where only some require cycle
> counts.
> 
> Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
> ---
>  drivers/gpu/drm/panfrost/panfrost_device.h |  3 +++
>  drivers/gpu/drm/panfrost/panfrost_gpu.c    | 20 ++++++++++++++++++++
>  drivers/gpu/drm/panfrost/panfrost_gpu.h    |  3 +++
>  3 files changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
> index 597cf1459..8a89aa274 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.h
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.h
> @@ -117,6 +117,9 @@ struct panfrost_device {
>  	struct shrinker shrinker;
>  
>  	struct panfrost_devfreq pfdevfreq;
> +
> +	/* Number of active jobs requiring performance monitoring */
> +	atomic_t permon_pending;

If the JD_REQ name is going to be changed then this should be renamed to
be consistent.

>  };
>  
>  struct panfrost_mmu {
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c
> index 2aae636f1..acacceb15 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gpu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c
> @@ -399,3 +399,23 @@ u32 panfrost_gpu_get_latest_flush_id(struct panfrost_device *pfdev)
>  
>  	return 0;
>  }
> +
> +void panfrost_acquire_permon(struct panfrost_device *pfdev)
> +{
> +	/* If another in-flight job enabled permon, we don't have to */
> +	if (atomic_inc_return(&pfdev->permon_pending) > 1)
> +		return;
> +
> +	/* Otherwise, we're the first user */
> +	gpu_write(pfdev, GPU_CMD, GPU_CMD_CYCLE_COUNT_START);
> +}

NIT: The check of atomic_inc_return() is usually of the style '== 1', i.e.:

	/* Only enable permon, if we're the first user */
	if (atomic_inc_return(&pfdev->permon_pending) == 1)
		gpu_write(pfdev, GPU_CMD, GPU_CMD_CYCLE_COUNT_START);

> +
> +void panfrost_release_permon(struct panfrost_device *pfdev)
> +{
> +	/* If another in-flight job needs permon, keep it active */
> +	if (atomic_dec_return(&pfdev->permon_pending) > 0)
> +		return;
> +
> +	/* Otherwise, we're the last user */
> +	gpu_write(pfdev, GPU_CMD, GPU_CMD_CYCLE_COUNT_STOP);
> +}

NIT: Similarly for disabling the usual style is '== 0'

Thanks,

Steve

> diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.h b/drivers/gpu/drm/panfrost/panfrost_gpu.h
> index 468c51e7e..01a91af09 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gpu.h
> +++ b/drivers/gpu/drm/panfrost/panfrost_gpu.h
> @@ -18,4 +18,7 @@ void panfrost_gpu_power_off(struct panfrost_device *pfdev);
>  
>  void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev);
>  
> +void panfrost_acquire_permon(struct panfrost_device *pfdev);
> +void panfrost_release_permon(struct panfrost_device *pfdev);
> +
>  #endif
> 


  reply	other threads:[~2021-06-02 11:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 20:38 [PATCH 0/4] drm/panfrost: Plumb cycle counters to userspace alyssa.rosenzweig
2021-05-27 20:38 ` [PATCH 1/4] drm/panfrost: Add cycle counter job requirement alyssa.rosenzweig
2021-06-02 11:50   ` Steven Price
2021-05-27 20:38 ` [PATCH 2/4] drm/panfrost: Add CYCLE_COUNT_START/STOP commands alyssa.rosenzweig
2021-06-02 11:50   ` Steven Price
2021-05-27 20:38 ` [PATCH 3/4] drm/panfrost: Add permon acquire/release helpers alyssa.rosenzweig
2021-06-02 11:50   ` Steven Price [this message]
2021-05-27 20:38 ` [PATCH 4/4] drm/panfrost: Handle PANFROST_JD_REQ_PERMON alyssa.rosenzweig
2021-06-02 11:50   ` Steven Price
2021-05-27 21:14 ` [PATCH 0/4] drm/panfrost: Plumb cycle counters to userspace Alyssa Rosenzweig
2021-05-28  6:07 ` Tomeu Vizoso
2021-05-28 13:31   ` Alyssa Rosenzweig

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=5d00a41d-b79c-14af-485b-e689f926ae2c@arm.com \
    --to=steven.price@arm.com \
    --cc=airlied@linux.ie \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomeu.vizoso@collabora.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.