drm/amdgpu: Patch csa mc address in IB packet
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: Patch csa mc address in IB packet
the csa buffer is used by sdma engine to do context save when preemption happens. it the mc address is zero, mean the preemtpion feature(MCBP) is disabled.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 ++ drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 8 ++++++-- 4 files changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +13 -0
@@ -40,3 +40,16 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring)return NULL ; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index) +{ +struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) +return i; + +return -EINVAL ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +2 -0
@@ -26,6 +26,7 @@/* max number of IP instances */ #define AMDGPU_MAX_SDMA_INSTANCES 2 +#define AMDGPU_SDMA_CSA_SIZE (1024)enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,
@@ -96,4 +97,5 @@ struct amdgpu_buffer_funcs {struct amdgpu_sdma_instance *amdgpu_get_sdma_instance (struct amdgpu_ring *ring); +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +6 -2
@@ -424,7 +424,11 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring, bool ctx_switch) {unsigned vmid =GET_VMID (job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v3_0_ring_insert_nop (ring, (10 - (lower_32_bits (ring->wptr) &7 )) %8 );
@@ -434,8 +438,8 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +6 -2
@@ -507,7 +507,11 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring, bool ctx_switch) {unsigned vmid =GET_VMID (job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v4_0_ring_insert_nop (ring, (10 - (lower_32_bits (ring->wptr) &7 )) %8 );
@@ -517,8 +521,8 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 34 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Rex Zhu
Sent: Wednesday, October 24, 2018 2:03 PM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Patch csa mc address in IB packetthe csa buffer is used by sdma engine to do context save when preemption happens. it the mc address is zero, mean the preemtpion feature(MCBP) is disabled.
Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 ++ drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 8 ++++++-- 4 files changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +2
-0@@ -40,3 +40,16 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring) return NULL; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index) {
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c struct amdgpu_sdma_instance * · line 55
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +10
-0+struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) +return i; + +return -EINVAL ; +}
Loop for checking works, but looks not good.
If you need ring index, you can define them first as enum, and evaluate enum index to ring when ring initializing.
Regards,
David Zhou
Quoted 88 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0@@ -26,6 +26,7 @@/* max number of IP instances */ #define AMDGPU_MAX_SDMA_INSTANCES 2 +#define AMDGPU_SDMA_CSA_SIZE (1024)enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,@@ -96,4 +97,5 @@ struct amdgpu_buffer_funcs { struct
amdgpu_sdma_instance*amdgpu_get_sdma_instance(struct amdgpu_ring *ring);drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0+int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +4
-0@@ -424,7 +424,11 @@ static void sdma_v3_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +3
-2@@ -434,8 +438,8 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +4
-0@@ -507,7 +507,11 @@ static void sdma_v4_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v4_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3
-3@@ -517,8 +521,8 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); } --1.9.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sorry, Please ignore this patch.
Best Regards
Rex
________________________________
From: Zhou, David(ChunMing)
Sent: Wednesday, October 24, 2018 2:55 PM
To: Zhu, Rex; [email protected]
Cc: Zhu, Rex
Subject: RE: [PATCH v2] drm/amdgpu: Patch csa mc address in IB packet
Quoted 32 lines
-----Original Message-----
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> On Behalf Of Rex Zhu
Sent: Wednesday, October 24, 2018 2:03 PM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Patch csa mc address in IB packetthe csa buffer is used by sdma engine to do context save when preemption happens. it the mc address is zero, mean the preemtpion feature(MCBP) is disabled.
Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 ++ drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 8 ++++++-- 4 files changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +2
-0@@ -40,3 +40,16 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring) return NULL; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index) {
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c struct amdgpu_sdma_instance * · line 55
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +10
-0+struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) +return i; + +return -EINVAL ; +}
Loop for checking works, but looks not good.
If you need ring index, you can define them first as enum, and evaluate enum index to ring when ring initializing.
Regards,
David Zhou
Quoted 88 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0@@ -26,6 +26,7 @@/* max number of IP instances */ #define AMDGPU_MAX_SDMA_INSTANCES 2 +#define AMDGPU_SDMA_CSA_SIZE (1024)enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,@@ -96,4 +97,5 @@ struct amdgpu_buffer_funcs { struct
amdgpu_sdma_instance*amdgpu_get_sdma_instance(struct amdgpu_ring *ring);drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0+int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +4
-0@@ -424,7 +424,11 @@ static void sdma_v3_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +3
-2@@ -434,8 +438,8 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +4
-0@@ -507,7 +507,11 @@ static void sdma_v4_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v4_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3
-3@@ -517,8 +521,8 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); } --1.9.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thanks David.
I think we can use ring->idx.
Best Regards
Rex
________________________________
From: Zhou, David(ChunMing)
Sent: Wednesday, October 24, 2018 2:55 PM
To: Zhu, Rex; [email protected]
Cc: Zhu, Rex
Subject: RE: [PATCH v2] drm/amdgpu: Patch csa mc address in IB packet
Quoted 32 lines
-----Original Message-----
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> On Behalf Of Rex Zhu
Sent: Wednesday, October 24, 2018 2:03 PM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Patch csa mc address in IB packetthe csa buffer is used by sdma engine to do context save when preemption happens. it the mc address is zero, mean the preemtpion feature(MCBP) is disabled.
Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 2 ++ drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 8 ++++++-- 4 files changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +2
-0@@ -40,3 +40,16 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring) return NULL; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index) {
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c struct amdgpu_sdma_instance * · line 55
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +10
-0+struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) +return i; + +return -EINVAL ; +}
Loop for checking works, but looks not good.
If you need ring index, you can define them first as enum, and evaluate enum index to ring when ring initializing.
Regards,
David Zhou
Quoted 88 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0@@ -26,6 +26,7 @@/* max number of IP instances */ #define AMDGPU_MAX_SDMA_INSTANCES 2 +#define AMDGPU_SDMA_CSA_SIZE (1024)enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,@@ -96,4 +97,5 @@ struct amdgpu_buffer_funcs { struct
amdgpu_sdma_instance*amdgpu_get_sdma_instance(struct amdgpu_ring *ring);drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-0+int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +4
-0@@ -424,7 +424,11 @@ static void sdma_v3_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +3
-2@@ -434,8 +438,8 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +4
-0@@ -507,7 +507,11 @@ static void sdma_v4_0_ring_emit_ib(structamdgpu_ring *ring, bool ctx_switch) { unsigned vmid = GET_VMID(job); +uint64_t csa_mc_addr = job ? job->csa_mc_addr :0 ; +uint32_t i =0 ; +if (amdgpu_get_sdma_index (ring, &i)) +return -EINVAL ;/* IB packet must end on a 8 DW boundary */ sdma_v4_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) &7)) % 8);
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3
-3@@ -517,8 +521,8 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr) &0xffffffe0 );amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr));amdgpu_ring_write (ring, ib->length_dw); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (csa_mc_addr + i *AMDGPU_SDMA_CSA_SIZE )); +amdgpu_ring_write (ring,upper_32_bits (csa_mc_addr + i * +AMDGPU_SDMA_CSA_SIZE )); } --1.9.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx