From: "j.glisse" <j.glisse@gmail.com>
To: "Christian König" <deathsimple@vodafone.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 02/10] drm/radeon: add infrastructure for advanced ring synchronization
Date: Thu, 24 May 2012 11:56:21 -0400 [thread overview]
Message-ID: <20120524155620.GC3467@gmail.com> (raw)
In-Reply-To: <1337845754-3718-2-git-send-email-deathsimple@vodafone.de>
On Thu, May 24, 2012 at 09:49:06AM +0200, Christian König wrote:
> Signed-off-by: Christian König <deathsimple@vodafone.de>
Need a small improvement see below, otherwise
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
> ---
> drivers/gpu/drm/radeon/radeon.h | 23 ++++++++++-
> drivers/gpu/drm/radeon/radeon_fence.c | 73 +++++++++++++++++++++++++++++----
> 2 files changed, 85 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 5e259b4..4e232c3 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -257,8 +257,8 @@ struct radeon_fence_driver {
> uint32_t scratch_reg;
> uint64_t gpu_addr;
> volatile uint32_t *cpu_addr;
> - /* seq is protected by ring emission lock */
> - uint64_t seq;
> + /* sync_seq is protected by ring emission lock */
> + uint64_t sync_seq[RADEON_NUM_RINGS];
> atomic64_t last_seq;
> unsigned long last_activity;
> bool initialized;
> @@ -288,6 +288,25 @@ int radeon_fence_wait_any(struct radeon_device *rdev,
> struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
> void radeon_fence_unref(struct radeon_fence **fence);
> unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
> +bool radeon_fence_need_sync(struct radeon_fence *fence, int ring);
> +void radeon_fence_note_sync(struct radeon_fence *fence, int ring);
> +static inline struct radeon_fence *radeon_fence_later(struct radeon_fence *a,
> + struct radeon_fence *b)
> +{
> + if (!a) {
> + return b;
> + }
> +
> + if (!b) {
> + return a;
> + }
Please add :
BUG_ON(a->ring != b->ring);
So we can catch if someone badly use this function.
> +
> + if (a->seq > b->seq) {
> + return a;
> + } else {
> + return b;
> + }
> +}
>
> /*
> * Tiling registers
> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
> index 401d346..7b55625 100644
> --- a/drivers/gpu/drm/radeon/radeon_fence.c
> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
> @@ -72,7 +72,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
> }
> kref_init(&((*fence)->kref));
> (*fence)->rdev = rdev;
> - (*fence)->seq = ++rdev->fence_drv[ring].seq;
> + (*fence)->seq = ++rdev->fence_drv[ring].sync_seq[ring];
> (*fence)->ring = ring;
> radeon_fence_ring_emit(rdev, ring, *fence);
> trace_radeon_fence_emit(rdev->ddev, (*fence)->seq);
> @@ -449,7 +449,7 @@ int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring)
> * wait.
> */
> seq = atomic64_read(&rdev->fence_drv[ring].last_seq) + 1ULL;
> - if (seq >= rdev->fence_drv[ring].seq) {
> + if (seq >= rdev->fence_drv[ring].sync_seq[ring]) {
> /* nothing to wait for, last_seq is
> already the last emited fence */
> return -ENOENT;
> @@ -464,7 +464,7 @@ int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring)
> * activity can be scheduled so there won't be concurrent access
> * to seq value.
> */
> - return radeon_fence_wait_seq(rdev, rdev->fence_drv[ring].seq,
> + return radeon_fence_wait_seq(rdev, rdev->fence_drv[ring].sync_seq[ring],
> ring, false, false);
> }
>
> @@ -492,7 +492,8 @@ unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring)
> * but it's ok to report slightly wrong fence count here.
> */
> radeon_fence_process(rdev, ring);
> - emitted = rdev->fence_drv[ring].seq - atomic64_read(&rdev->fence_drv[ring].last_seq);
> + emitted = rdev->fence_drv[ring].sync_seq[ring]
> + - atomic64_read(&rdev->fence_drv[ring].last_seq);
> /* to avoid 32bits warp around */
> if (emitted > 0x10000000) {
> emitted = 0x10000000;
> @@ -500,6 +501,51 @@ unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring)
> return (unsigned)emitted;
> }
>
> +bool radeon_fence_need_sync(struct radeon_fence *fence, int dst_ring)
> +{
> + struct radeon_fence_driver *fdrv;
> +
> + if (!fence) {
> + return false;
> + }
> +
> + if (fence->ring == dst_ring) {
> + return false;
> + }
> +
> + /* we are protected by the ring mutex */
> + fdrv = &fence->rdev->fence_drv[dst_ring];
> + if (fence->seq <= fdrv->sync_seq[fence->ring]) {
> + return false;
> + }
> +
> + return true;
> +}
> +
> +void radeon_fence_note_sync(struct radeon_fence *fence, int dst_ring)
> +{
> + struct radeon_fence_driver *dst, *src;
> + unsigned i;
> +
> + if (!fence) {
> + return;
> + }
> +
> + if (fence->ring == dst_ring) {
> + return;
> + }
> +
> + /* we are protected by the ring mutex */
> + src = &fence->rdev->fence_drv[fence->ring];
> + dst = &fence->rdev->fence_drv[dst_ring];
> + for (i = 0; i < RADEON_NUM_RINGS; ++i) {
> + if (i == dst_ring) {
> + continue;
> + }
> + dst->sync_seq[i] = max(dst->sync_seq[i], src->sync_seq[i]);
> + }
> +}
> +
> int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
> {
> uint64_t index;
> @@ -521,7 +567,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
> }
> rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4];
> rdev->fence_drv[ring].gpu_addr = rdev->wb.gpu_addr + index;
> - radeon_fence_write(rdev, rdev->fence_drv[ring].seq, ring);
> + radeon_fence_write(rdev, rdev->fence_drv[ring].sync_seq[ring], ring);
> rdev->fence_drv[ring].initialized = true;
> dev_info(rdev->dev, "fence driver on ring %d use gpu addr 0x%016llx and cpu addr 0x%p\n",
> ring, rdev->fence_drv[ring].gpu_addr, rdev->fence_drv[ring].cpu_addr);
> @@ -530,10 +576,13 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
>
> static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
> {
> + int i;
> +
> rdev->fence_drv[ring].scratch_reg = -1;
> rdev->fence_drv[ring].cpu_addr = NULL;
> rdev->fence_drv[ring].gpu_addr = 0;
> - rdev->fence_drv[ring].seq = 0;
> + for (i = 0; i < RADEON_NUM_RINGS; ++i)
> + rdev->fence_drv[ring].sync_seq[i] = 0;
> atomic64_set(&rdev->fence_drv[ring].last_seq, 0);
> rdev->fence_drv[ring].last_activity = jiffies;
> rdev->fence_drv[ring].initialized = false;
> @@ -579,7 +628,7 @@ static int radeon_debugfs_fence_info(struct seq_file *m, void *data)
> struct drm_info_node *node = (struct drm_info_node *)m->private;
> struct drm_device *dev = node->minor->dev;
> struct radeon_device *rdev = dev->dev_private;
> - int i;
> + int i, j;
>
> for (i = 0; i < RADEON_NUM_RINGS; ++i) {
> if (!rdev->fence_drv[i].initialized)
> @@ -588,8 +637,14 @@ static int radeon_debugfs_fence_info(struct seq_file *m, void *data)
> seq_printf(m, "--- ring %d ---\n", i);
> seq_printf(m, "Last signaled fence 0x%016llx\n",
> (unsigned long long)atomic64_read(&rdev->fence_drv[i].last_seq));
> - seq_printf(m, "Last emitted 0x%016llx\n",
> - rdev->fence_drv[i].seq);
> + seq_printf(m, "Last emitted 0x%016llx\n",
> + rdev->fence_drv[i].sync_seq[i]);
> +
> + for (j = 0; j < RADEON_NUM_RINGS; ++j) {
> + if (i != j && rdev->fence_drv[j].initialized)
> + seq_printf(m, "Last sync to ring %d 0x%016llx\n",
> + j, rdev->fence_drv[i].sync_seq[j]);
> + }
> }
> return 0;
> }
> --
> 1.7.9.5
>
next prev parent reply other threads:[~2012-05-24 15:56 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 7:49 [PATCH 01/10] drm/radeon: remove radeon_fence_create Christian König
2012-05-24 7:49 ` [PATCH 02/10] drm/radeon: add infrastructure for advanced ring synchronization Christian König
2012-05-24 15:56 ` j.glisse [this message]
2012-05-24 7:49 ` [PATCH 03/10] drm/radeon: rework ring syncing code Christian König
2012-05-24 15:57 ` j.glisse
2012-05-24 7:49 ` [PATCH 04/10] drm/radeon: replace vmram_mutex with mclk_lock v2 Christian König
2012-05-24 15:57 ` j.glisse
2012-05-24 7:49 ` [PATCH 05/10] drm/radeon: remove some unneeded structure members Christian König
2012-05-24 15:58 ` j.glisse
2012-05-24 7:49 ` [PATCH 06/10] drm/radeon: fix & improve ih ring handling Christian König
2012-05-24 15:59 ` j.glisse
2012-05-24 7:49 ` [PATCH 07/10] drm/radeon: apply Murphy's law to the kms irq code Christian König
2012-05-24 15:35 ` Alex Deucher
2012-05-24 15:53 ` j.glisse
2012-05-31 18:15 ` Alex Deucher
2012-05-31 18:39 ` Jerome Glisse
2012-05-31 20:15 ` Christian König
2012-05-24 7:49 ` [PATCH 08/10] drm/radeon: replace pflip and sw_int counters with atomics Christian König
2012-05-24 11:59 ` Sylvain BERTRAND
2012-05-24 12:29 ` Koenig, Christian
2012-05-24 12:46 ` Sylvain BERTRAND
2012-05-24 12:53 ` Dave Airlie
2012-05-24 12:54 ` Dave Airlie
2012-05-24 14:23 ` Sylvain BERTRAND
2012-05-24 7:49 ` [PATCH 09/10] drm/radeon: replace cs_mutex with vm_mutex Christian König
2012-05-24 7:49 ` [PATCH 10/10] drm/radeon: work around bugs in caymans compute rings Christian König
2012-05-24 15:54 ` [PATCH 01/10] drm/radeon: remove radeon_fence_create j.glisse
-- strict thread matches above, loose matches on Subject: below --
2012-05-31 20:15 Christian König
2012-05-31 20:15 ` [PATCH 02/10] drm/radeon: add infrastructure for advanced ring synchronization Christian König
2012-05-31 21:09 ` Jerome Glisse
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=20120524155620.GC3467@gmail.com \
--to=j.glisse@gmail.com \
--cc=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
/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.