Convert fence to use 64bits sequence
Subsystems (2)
So this patchset convert the fence to use 64bits sequence and simplify the fence code (dropping fence lock). I am still convinced that the best solution is to have the various helper code deals with fence cleanup/processing. The last patch show an example of what can be done to improve sa allocator taking advantage of u64 fence.
Cheers,
Jerome
PATCH 1/4 drm/radeon: allow to allocate adjacent scratch reg
From: Jerome Glisse <[email protected]>
This add the number of adjacent scratch reg you want to allocate or free to the scratch alloc/free function.
--- drivers/gpu/drm/radeon/r100.c | 12 ++++++------ drivers/gpu/drm/radeon/r420.c | 4 ++-- drivers/gpu/drm/radeon/r600.c | 12 ++++++------ drivers/gpu/drm/radeon/radeon.h | 4 ++-- drivers/gpu/drm/radeon/radeon_device.c | 31 +++++++++++++++++++++++-------- drivers/gpu/drm/radeon/radeon_fence.c | 6 +++--- 6 files changed, 42 insertions(+), 27 deletions(-)
drivers/gpu/drm/radeon/r100.c +6 -6
@@ -3636,7 +3636,7 @@ int r100_ring_test(struct radeon_device *rdev, struct radeon_ring *ring)unsigned i;int r; - r =radeon_scratch_get (rdev, &scratch); + r =radeon_scratch_get (rdev, &scratch,1 );if (r) {DRM_ERROR ("radeon: cp failed to get scratch reg (%d).\n" , r);return r;
@@ -3645,7 +3645,7 @@ int r100_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) r =radeon_ring_lock (rdev, ring,2 );if (r) {DRM_ERROR ("radeon: cp failed to lock ring (%d).\n" , r); -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );return r; }radeon_ring_write (ring,PACKET0 (scratch,0 ));
@@ -3665,7 +3665,7 @@ int r100_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );return r; }
@@ -3686,7 +3686,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)unsigned i;int r; - r =radeon_scratch_get (rdev, &scratch); + r =radeon_scratch_get (rdev, &scratch,1 );if (r) {DRM_ERROR ("radeon: failed to get scratch reg (%d).\n" , r);return r;
@@ -3707,7 +3707,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib->length_dw =8 ; r =radeon_ib_schedule (rdev, ib);if (r) { -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );radeon_ib_free (rdev, &ib);return r; }
@@ -3729,7 +3729,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );radeon_ib_free (rdev, &ib);return r; }
drivers/gpu/drm/radeon/r420.c +2 -2
@@ -207,7 +207,7 @@ static void r420_cp_errata_init(struct radeon_device *rdev)* The proper workaround is to queue a RESYNC at the beginning * of the CP init, apparently. */ -radeon_scratch_get (rdev, &rdev->config.r300.resync_scratch); +radeon_scratch_get (rdev, &rdev->config.r300.resync_scratch,1 );radeon_ring_lock (rdev, ring,8 );radeon_ring_write (ring,PACKET0 (R300_CP_RESYNC_ADDR ,1 ));radeon_ring_write (ring, rdev->config.r300.resync_scratch);
@@ -226,7 +226,7 @@ static void r420_cp_errata_fini(struct radeon_device *rdev)radeon_ring_write (ring,PACKET0 (R300_RB3D_DSTCACHE_CTLSTAT ,0 ));radeon_ring_write (ring,R300_RB3D_DC_FINISH );radeon_ring_unlock_commit (rdev, ring); -radeon_scratch_free (rdev, rdev->config.r300.resync_scratch); +radeon_scratch_free (rdev, rdev->config.r300.resync_scratch,1 ); }static int r420_startup (struct radeon_device *rdev)
drivers/gpu/drm/radeon/r600.c +6 -6
@@ -2261,7 +2261,7 @@ int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *ring)unsigned i, ridx =radeon_ring_index (rdev, ring);int r; - r =radeon_scratch_get (rdev, &scratch); + r =radeon_scratch_get (rdev, &scratch,1 );if (r) {DRM_ERROR ("radeon: cp failed to get scratch reg (%d).\n" , r);return r;
@@ -2270,7 +2270,7 @@ int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) r =radeon_ring_lock (rdev, ring,3 );if (r) {DRM_ERROR ("radeon: cp failed to lock ring %d (%d).\n" , ridx, r); -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );return r; }radeon_ring_write (ring,PACKET3 (PACKET3_SET_CONFIG_REG ,1 ));
@@ -2290,7 +2290,7 @@ int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) ridx, scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );return r; }
@@ -2693,7 +2693,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)int r;int ring_index =radeon_ring_index (rdev, ring); - r =radeon_scratch_get (rdev, &scratch); + r =radeon_scratch_get (rdev, &scratch,1 );if (r) {DRM_ERROR ("radeon: failed to get scratch reg (%d).\n" , r);return r;
@@ -2710,7 +2710,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib->length_dw =3 ; r =radeon_ib_schedule (rdev, ib);if (r) { -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );radeon_ib_free (rdev, &ib);DRM_ERROR ("radeon: failed to schedule ib (%d).\n" , r);return r;
@@ -2733,7 +2733,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +radeon_scratch_free (rdev, scratch,1 );radeon_ib_free (rdev, &ib);return r; }
drivers/gpu/drm/radeon/radeon.h +2 -2
@@ -533,8 +533,8 @@ struct radeon_scratch {uint32_t reg[32 ]; }; -int radeon_scratch_get (struct radeon_device *rdev,uint32_t *reg); -void radeon_scratch_free (struct radeon_device *rdev,uint32_t reg); +int radeon_scratch_get (struct radeon_device *rdev,uint32_t *reg,unsigned n); +void radeon_scratch_free (struct radeon_device *rdev,uint32_t reg,unsigned n);/*
drivers/gpu/drm/radeon/radeon_device.c +23 -8
@@ -136,13 +136,26 @@ void radeon_scratch_init(struct radeon_device *rdev) } } -int radeon_scratch_get (struct radeon_device *rdev,uint32_t *reg) +int radeon_scratch_get (struct radeon_device *rdev,uint32_t *reg,unsigned n) { -int i; +unsigned i, j, c; -for (i =0 ; i < rdev->scratch.num_reg; i++) { -if (rdev->scratch.free[i]) { - rdev->scratch.free[i] = false; +if (n >= rdev->scratch.num_reg) { +dump_stack (); +dev_err (rdev->dev,"trying to allocate %d scratch reg out of %d\n" , + n, rdev->scratch.num_reg); +return -EINVAL ; + } +for (i =0 ; i < rdev->scratch.num_reg - n; i++) { +for (j =0 , c =0 ; j < n; j++) { +if (rdev->scratch.free[i+j]) { + c++; + } + } +if (c == n) { +for (j =0 ; j < n; j++) { + rdev->scratch.free[i+j] = false; + } *reg = rdev->scratch.reg[i];return 0 ; }
@@ -150,13 +163,15 @@ int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg)return -EINVAL ; } -void radeon_scratch_free (struct radeon_device *rdev,uint32_t reg) +void radeon_scratch_free (struct radeon_device *rdev,uint32_t reg,unsigned n) { -int i; +unsigned i, j;for (i =0 ; i < rdev->scratch.num_reg; i++) {if (rdev->scratch.reg[i] == reg) { - rdev->scratch.free[i] = true; +for (j =0 ; j < n; j++) { + rdev->scratch.free[i+j] = true; + }return ; } }
drivers/gpu/drm/radeon/radeon_fence.c +3 -3
@@ -371,12 +371,12 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)int r;write_lock_irqsave (&rdev->fence_lock, irq_flags); -radeon_scratch_free (rdev, rdev->fence_drv[ring].scratch_reg); +radeon_scratch_free (rdev, rdev->fence_drv[ring].scratch_reg,1 );if (rdev->wb.use_event) { rdev->fence_drv[ring].scratch_reg =0 ; index =R600_WB_EVENT_OFFSET + ring *4 ; }else { - r =radeon_scratch_get (rdev, &rdev->fence_drv[ring].scratch_reg); + r =radeon_scratch_get (rdev, &rdev->fence_drv[ring].scratch_reg,1 );if (r) {dev_err (rdev->dev,"fence failed to get scratch register\n" );write_unlock_irqrestore (&rdev->fence_lock, irq_flags);
@@ -435,7 +435,7 @@ void radeon_fence_driver_fini(struct radeon_device *rdev)radeon_fence_wait_empty (rdev, ring);wake_up_all (&rdev->fence_drv[ring].queue);write_lock_irqsave (&rdev->fence_lock, irq_flags); -radeon_scratch_free (rdev, rdev->fence_drv[ring].scratch_reg); +radeon_scratch_free (rdev, rdev->fence_drv[ring].scratch_reg,1 );write_unlock_irqrestore (&rdev->fence_lock, irq_flags); rdev->fence_drv[ring].initialized = false; }
Signature · 1 line
1.7.7.6
PATCH 2/4 drm/radeon: convert fence to uint64_t
In reply to [email protected]From: Jerome Glisse <[email protected]>
This convert fence to use uint64_t sequence number intention is to use the fact that uin64_t is big enough that we don't need to care about wrap around.
Tested with and without writeback using 0xFFFFF000 as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.
--- drivers/gpu/drm/radeon/ni.c | 6 ++-- drivers/gpu/drm/radeon/r100.c | 5 ++- drivers/gpu/drm/radeon/r300.c | 5 ++- drivers/gpu/drm/radeon/r600.c | 11 ++++---- drivers/gpu/drm/radeon/radeon.h | 20 +++++++------- drivers/gpu/drm/radeon/radeon_fence.c | 43 +++++++++++++++++---------------- drivers/gpu/drm/radeon/si.c | 6 ++-- 7 files changed, 50 insertions(+), 46 deletions(-)
drivers/gpu/drm/radeon/ni.c +3 -3
@@ -1120,9 +1120,9 @@ void cayman_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring,PACKET3 (PACKET3_EVENT_WRITE_EOP ,4 ));radeon_ring_write (ring,EVENT_TYPE (CACHE_FLUSH_AND_INV_EVENT_TS ) |EVENT_INDEX (5 ));radeon_ring_write (ring, addr &0xffffffff ); -radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (1 ) |INT_SEL (2 )); -radeon_ring_write (ring, fence->seq); -radeon_ring_write (ring,0 ); +radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (2 ) |INT_SEL (2 )); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq)); }void cayman_ring_ib_execute (struct radeon_device *rdev,struct radeon_ib *ib)
drivers/gpu/drm/radeon/r100.c +3 -2
@@ -864,8 +864,9 @@ void r100_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring,PACKET0 (RADEON_HOST_PATH_CNTL ,0 ));radeon_ring_write (ring, rdev->config.r100.hdp_cntl);/* Emit fence sequence & fire IRQ */ -radeon_ring_write (ring,PACKET0 (rdev->fence_drv[fence->ring].scratch_reg,0 )); -radeon_ring_write (ring, fence->seq); +radeon_ring_write (ring,PACKET0 (rdev->fence_drv[fence->ring].scratch_reg,1 )); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq));radeon_ring_write (ring,PACKET0 (RADEON_GEN_INT_STATUS ,0 ));radeon_ring_write (ring,RADEON_SW_INT_FIRE ); }
drivers/gpu/drm/radeon/r300.c +3 -2
@@ -200,8 +200,9 @@ void r300_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring,PACKET0 (RADEON_HOST_PATH_CNTL ,0 ));radeon_ring_write (ring, rdev->config.r300.hdp_cntl);/* Emit fence sequence & fire IRQ */ -radeon_ring_write (ring,PACKET0 (rdev->fence_drv[fence->ring].scratch_reg,0 )); -radeon_ring_write (ring, fence->seq); +radeon_ring_write (ring,PACKET0 (rdev->fence_drv[fence->ring].scratch_reg,1 )); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq));radeon_ring_write (ring,PACKET0 (RADEON_GEN_INT_STATUS ,0 ));radeon_ring_write (ring,RADEON_SW_INT_FIRE ); }
drivers/gpu/drm/radeon/r600.c +6 -5
@@ -2313,9 +2313,9 @@ void r600_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring,PACKET3 (PACKET3_EVENT_WRITE_EOP ,4 ));radeon_ring_write (ring,EVENT_TYPE (CACHE_FLUSH_AND_INV_EVENT_TS ) |EVENT_INDEX (5 ));radeon_ring_write (ring, addr &0xffffffff ); -radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (1 ) |INT_SEL (2 )); -radeon_ring_write (ring, fence->seq); -radeon_ring_write (ring,0 ); +radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (2 ) |INT_SEL (2 )); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq)); }else {/* flush read cache over gart */ radeon_ring_write (ring,PACKET3 (PACKET3_SURFACE_SYNC ,3 ));
@@ -2332,9 +2332,10 @@ void r600_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring, (WAIT_UNTIL -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );radeon_ring_write (ring, WAIT_3D_IDLE_bit | WAIT_3D_IDLECLEAN_bit);/* Emit fence sequence & fire IRQ */ -radeon_ring_write (ring,PACKET3 (PACKET3_SET_CONFIG_REG ,1 )); +radeon_ring_write (ring,PACKET3 (PACKET3_SET_CONFIG_REG ,2 ));radeon_ring_write (ring, ((rdev->fence_drv[fence->ring].scratch_reg -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 )); -radeon_ring_write (ring, fence->seq); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq));/* CP_INTERRUPT packet 3 no longer exists, use packet 0 */ radeon_ring_write (ring,PACKET0 (CP_INT_STATUS ,0 ));radeon_ring_write (ring,RB_INT_STAT );
drivers/gpu/drm/radeon/radeon.h +10 -10
@@ -281,9 +281,9 @@ void radeon_semaphore_free(struct radeon_device *rdev,struct radeon_fence_driver {uint32_t scratch_reg;uint64_t gpu_addr; -volatile uint32_t *cpu_addr; -atomic_t seq; -uint32_t last_seq; +volatile uint64_t *cpu_addr; +atomic64_t seq; +uint64_t last_seq;unsigned long last_activity;wait_queue_head_t queue;struct list_head emitted;
@@ -296,7 +296,7 @@ struct radeon_fence {struct kref kref;struct list_head list;/* protected by radeon_fence.lock */ -uint32_t seq; +uint64_t seq;bool emitted;bool signaled;/* RB, DMA, etc. */
@@ -884,12 +884,12 @@ struct radeon_wb {bool use_event; }; -#define RADEON_WB_SCRATCH_OFFSET 0 -#define RADEON_WB_CP_RPTR_OFFSET 1024 -#define RADEON_WB_CP1_RPTR_OFFSET 1280 -#define RADEON_WB_CP2_RPTR_OFFSET 1536 -#define R600_WB_IH_WPTR_OFFSET 2048 -#define R600_WB_EVENT_OFFSET 3072 +#define RADEON_WB_SCRATCH_OFFSET 0 +#define RADEON_WB_CP_RPTR_OFFSET 1024 +#define RADEON_WB_CP1_RPTR_OFFSET 1280 +#define RADEON_WB_CP2_RPTR_OFFSET 1536 +#define R600_WB_IH_WPTR_OFFSET 2048 +#define R600_WB_EVENT_OFFSET 3072/** * struct radeon_pm - power management datas
drivers/gpu/drm/radeon/radeon_fence.c +22 -21
121 lines not on this page · raw message
drivers/gpu/drm/radeon/si.c +3 -3
@@ -1905,9 +1905,9 @@ void si_fence_ring_emit(struct radeon_device *rdev,radeon_ring_write (ring,PACKET3 (PACKET3_EVENT_WRITE_EOP ,4 ));radeon_ring_write (ring,EVENT_TYPE (CACHE_FLUSH_AND_INV_TS_EVENT ) |EVENT_INDEX (5 ));radeon_ring_write (ring, addr &0xffffffff ); -radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (1 ) |INT_SEL (2 )); -radeon_ring_write (ring, fence->seq); -radeon_ring_write (ring,0 ); +radeon_ring_write (ring, (upper_32_bits (addr) &0xff ) |DATA_SEL (2 ) |INT_SEL (2 )); +radeon_ring_write (ring,lower_32_bits (fence->seq)); +radeon_ring_write (ring,upper_32_bits (fence->seq)); }/*
Signature · 1 line
1.7.7.6
Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 11 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse <[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse <[email protected]>
[...]
drivers/gpu/drm/radeon/radeon_fence.c int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) · line 391
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_fence.c +1
-1@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) rdev->fence_drv[ring].scratch_reg - rdev->scratch.reg_base; } - rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4 ]; + rdev->fence_drv[ring].cpu_addr = (u64 *)&rdev->wb.wb[index/4 ];
Might want to ensure cpu_addr is 64 bit aligned, or there might be trouble on some architectures.
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 28 lines · Michel Dänzer
Quoted 11 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
drivers/gpu/drm/radeon/radeon_fence.c int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) · line 391
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_fence.c +1
-1@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) rdev->fence_drv[ring].scratch_reg - rdev->scratch.reg_base; } - rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4 ]; + rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.
Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the emit_fence callback to properly handle it and then you have to fix the radeon_fence_read which can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
http://people.freedesktop.org/~glisse/reset3/
Cheers,
Jerome
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 57 lines · Jerome Glisse
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.
Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Alex
Quoted 8 lines
http://people.freedesktop.org/~glisse/reset3/
Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 62 lines · Alex Deucher
Quoted 57 lines · Jerome Glisse
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
Quoted 6 lines
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Alex
That's what my v2 does, just drop scratch reg for cayman and newer.
Cheers,
Jerome
Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 60 lines · Jerome Glisse
Quoted 59 lines · Alex Deucher
Quoted 51 lines · Jerome Glisse
Quoted 35 lines · Christian König
Quoted 30 lines · Michel Dänzer
Quoted 11 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
drivers/gpu/drm/radeon/radeon_fence.c int radeon_fence_driver_start_ring(struct · line 392
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1
-1@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) rdev->fence_drv[ring].scratch_reg - rdev->scratch.reg_base; } - rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4 ]; + rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Quoted 7 lines
Quoted 2 lines
Alex
That's what my v2 does, just drop scratch reg for cayman and newer.
Cheers,
Jerome
I actually always wanted to change that in a way that scratch regs are only allocated if wb is really disabled, just never had time to do so (sigh).
Cheers,
Christian.
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
In reply to Jerome GlisseQuoted 67 lines · Jerome Glisse
Quoted 66 lines · Alex Deucher
Quoted 57 lines · Jerome Glisse
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Quoted 7 lines
Quoted 2 lines
Alex
That's what my v2 does, just drop scratch reg for cayman and newer.
Cheers,
Jerome
Btw uploaded a v3 with some more thing like warnononce for extra safety, better comment and trying to mitigate race btw cpu reading and gpu writing fence.
http://people.freedesktop.org/~glisse/reset3/
Cheers,
Jerome
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
Quoted 73 lines · Jerome Glisse
Quoted 72 lines · Jerome Glisse
Quoted 62 lines · Alex Deucher
Quoted 57 lines · Jerome Glisse
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
Quoted 6 lines
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Alex
That's what my v2 does, just drop scratch reg for cayman and newer.
Quoted 7 lines
Quoted 2 lines
Cheers,
JeromeBtw uploaded a v3 with some more thing like warnononce for extra safety, better comment and trying to mitigate race btw cpu reading and gpu writing fence.
http://people.freedesktop.org/~glisse/reset3/
You can drop this hunk:
+ if (rdev->family >= CHIP_CAYMAN) {
+ /* because there is so many ring on newer GPU we can't use
+ * scratch reg thus we need to use event, on those GPU there
+ * is no AGP version and writting to system ram have always
+ * been reliable so far
+ */
+ rdev->wb.enabled = true;
+ rdev->wb.use_event = true;
+ }
As the code right below it does the exact same thing. It could probably be extended to APUs as well since they will never have AGP support. I'll send out a patch.
Alex
Quoted 3 lines
Cheers,
Jerome
PATCH 1/1 drm/radeon: clarify and extend wb setup on APUs and NI+ asics
From: Alex Deucher <[email protected]>
Use family rather than DCE check for clarity, also always use wb on APUs, there will never be AGP variants.
--- drivers/gpu/drm/radeon/radeon_device.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +2 -2
@@ -241,8 +241,8 @@ int radeon_wb_init(struct radeon_device *rdev) rdev->wb.use_event = true; } } -/* always use writeback/events on NI */ -if (ASIC_IS_DCE5 (rdev)) { +/* always use writeback/events on NI, APUs */ +if (rdev->family >=CHIP_PALM ) { rdev->wb.enabled = true; rdev->wb.use_event = true; }
Signature · 1 line
1.7.7.5
Re: [PATCH] drm/radeon: clarify and extend wb setup on APUs and NI+ asics
Quoted 6 lines · On Don, 2012-05-03 at 17:06 -0400, [email protected] wrote:
From: Alex Deucher <[email protected]>
Use family rather than DCE check for clarity, also always use wb on APUs, there will never be AGP variants.
Signed-off-by Alex Deucher <[email protected]>
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: Re: [PATCH 2/4] drm/radeon: convert fence to uint64_t
In reply to Alex DeucherQuoted 96 lines · Alex Deucher
Quoted 73 lines · Jerome Glisse
Quoted 72 lines · Jerome Glisse
Quoted 62 lines · Alex Deucher
Quoted 57 lines · Jerome Glisse
Quoted 40 lines · Christian König
Quoted 34 lines · Michel Dänzer
Quoted 12 lines · On Mit, 2012-05-02 at 16:20 -0400, [email protected] wrote:
From: Jerome Glisse<[email protected]>
This convert fence to use
uint64_tsequence number intention is to use the fact thatuin64_tis big enough that we don't need to care about wrap around.Tested with and without writeback using
0xFFFFF000as initial fence sequence and thus allowing to test the wrap around from 32bits to 64bits.Signed-off-by Jerome Glisse<[email protected]>[...]
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +0
-0@@ -386,9 +388,9 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)Quoted 5 lines
rdev->fence_drv[ring].scratch_reg -
rdev->scratch.reg_base;
}
- rdev->fence_drv[ring].cpu_addr =rdev->wb.wb[index/4];
+ rdev->fence_drv[ring].cpu_addr =u64*)&rdev->wb.wb[index/4];Might want to ensure
cpu_addris 64 bit aligned, or there might be trouble on some architectures.Quoted 3 lines
With this change, Cayman cards will already use six scratch registers for the rings. It won't be possible to extend this scheme for even one additional ring, will it?
Quoted 7 lines
That won't work anyway, since not all rings can deal with 64 bit fences, so we need to still use 32 bit signaling and extend them to 64 bit while processing the fence value.
Already working on that.
Christian.
This patch is fine with ring that can't emit directly 64bits, all you have to do is fix the
emit_fencecallback to properly handle it and then you have to fix theradeon_fence_readwhich can be move to a ring specific callback. Anyway point is that patchset works and is fine on current set of ring we have and it can work as easily for ring without easy 64bits value emitting. So please explain further why those patch can't work because as i just explained i don't see why.Quoted 3 lines
I have updated some v2 version of those patchset to handle the cayman and newer possibly running out of scratch reg and i also fix the alignment issue to be 64bits
Quoted 6 lines
FWIW, we don't actually use scratch regs any more on r6xx+ (non-AGP at least), it's just memory writes so we could make the scratch pool bigger.
Alex
That's what my v2 does, just drop scratch reg for cayman and newer.
Quoted 7 lines
Quoted 2 lines
Cheers,
JeromeBtw uploaded a v3 with some more thing like warnononce for extra safety, better comment and trying to mitigate race btw cpu reading and gpu writing fence.
http://people.freedesktop.org/~glisse/reset3/You can drop this hunk:
+ if (rdev->family>=CHIP_CAYMAN) {
+ /* because there is so many ring on newer GPU we can't use
+ * scratch reg thus we need to use event, on those GPU there
+ * is no AGP version and writting to system ram have always
+ * been reliable so far
+ */
+rdev->wb.enabled= true;
+rdev->wb.use_event= true;
+ }
Quoted 6 lines
As the code right below it does the exact same thing. It could probably be extended to APUs as well since they will never have AGP support. I'll send out a patch.
Alex
Good catch updated patch
http://people.freedesktop.org/~glisse/reset3/
Cheers,
Jerome
PATCH 3/4 drm/radeon: rework fence handling, drop fence list
In reply to [email protected]From: Jerome Glisse <[email protected]>
Using 64bits fence sequence we can directly compare sequence number to know if a fence is signaled or not. Thus the fence list became useless, so does the fence lock that mainly protected the fence list.
Things like ring.ready are no longer behind a lock, this should be ok as ring.ready is initialized once and will only change when facing lockup. Worst case is that we return an -EBUSY just after a successfull GPU reset, or we go into wait state instead of returning -EBUSY (thus delaying reporting -EBUSY to fence wait caller).
--- drivers/gpu/drm/radeon/radeon.h | 6 +- drivers/gpu/drm/radeon/radeon_device.c | 1 - drivers/gpu/drm/radeon/radeon_fence.c | 278 ++++++++++++-------------------- 3 files changed, 102 insertions(+), 183 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -5
@@ -286,15 +286,12 @@ struct radeon_fence_driver {uint64_t last_seq;unsigned long last_activity;wait_queue_head_t queue; -struct list_head emitted; -struct list_head signaled;bool initialized; };struct radeon_fence {struct radeon_device *rdev;struct kref kref; -struct list_head list;/* protected by radeon_fence.lock */ uint64_t seq;bool emitted;
@@ -316,7 +313,7 @@ int radeon_fence_wait_next(struct radeon_device *rdev, int ring);int radeon_fence_wait_empty (struct radeon_device *rdev,int ring);struct radeon_fence *radeon_fence_ref (struct radeon_fence *fence);void radeon_fence_unref (struct radeon_fence **fence); -int radeon_fence_count_emitted (struct radeon_device *rdev,int ring); +unsigned radeon_fence_count_emitted (struct radeon_device *rdev,int ring);/* * Tiling registers
@@ -1488,7 +1485,6 @@ struct radeon_device {struct radeon_mode_info mode_info;struct radeon_scratch scratch;struct radeon_mman mman; -rwlock_t fence_lock;struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS ];struct radeon_ring ring[RADEON_NUM_RINGS ];bool ib_pool_ready;
drivers/gpu/drm/radeon/radeon_device.c +0 -1
@@ -746,7 +746,6 @@ int radeon_device_init(struct radeon_device *rdev,mutex_init (&rdev->gem.mutex);mutex_init (&rdev->pm.mutex);mutex_init (&rdev->vram_mutex); -rwlock_init (&rdev->fence_lock);INIT_LIST_HEAD (&rdev->gem.objects);init_waitqueue_head (&rdev->irq.vblank_queue);init_waitqueue_head (&rdev->irq.idle_queue);
drivers/gpu/drm/radeon/radeon_fence.c +101 -177
453 lines not on this page · raw message
Signature · 1 line
1.7.7.6
Re: [PATCH 3/4] drm/radeon: rework fence handling, drop fence list
drivers/gpu/drm/radeon/radeon_fence.c static u64 radeon_fence_read(struct radeon_device *rdev, int ring) · line 74
Quoted 3 lines · On 5/2/12 4:20 PM, [email protected] wrote:
drivers/gpu/drm/radeon/radeon_fence.c +3
-0+/* there is small chance that we overwritte a bigger last_emited +* value, but in normal usage this +*/
Seems unfinished. Also "overwrite".
- ajax
PATCH 4/4 drm/radeon: improve sa allocator to agressivly free idle bo
In reply to [email protected]From: Jerome Glisse <[email protected]>
With fence rework it's now easier to agressivly free idle bo when there is no hole to satisfy current allocation request. The hit of some cs ioctl to have to go through the sa bo list and free them is minimal, it happens once in while and avoid some fence waiting.
--- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_fence.c | 2 +- drivers/gpu/drm/radeon/radeon_sa.c | 51 +++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -314,6 +314,7 @@ int radeon_fence_wait_empty(struct radeon_device *rdev, int ring);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_poll (struct radeon_device *rdev,int ring);/* * Tiling registers
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
@@ -78,7 +78,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)return 0 ; } -static bool radeon_fence_poll (struct radeon_device *rdev,int ring) +bool radeon_fence_poll (struct radeon_device *rdev,int ring) {uint64_t seq;
drivers/gpu/drm/radeon/radeon_sa.c +46 -5
81 lines not on this page · raw message
Signature · 1 line
1.7.7.6