* [PATCH] drm/amdkfd: fix the wrong no space return while acquires packet buffer
@ 2020-03-19 10:51 Huang Rui
2020-03-19 11:42 ` Pan, Xinhui
0 siblings, 1 reply; 3+ messages in thread
From: Huang Rui @ 2020-03-19 10:51 UTC (permalink / raw)
To: amd-gfx; +Cc: Felix Kuehling, Huang Rui
The queue buffer index starts from position 0, so the available buffer size
which starts from position 0 to rptr should be "rptr" index value. While the
packet_size_in_dwords == rptr, the available buffer is just good enough.
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index bae7064..4667c8f 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
/* make sure after rolling back to position 0, there is
* still enough space.
*/
- if (packet_size_in_dwords >= rptr)
+ if (packet_size_in_dwords > rptr)
goto err_no_space;
/* fill nops, roll back and start at position 0 */
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: fix the wrong no space return while acquires packet buffer
2020-03-19 10:51 [PATCH] drm/amdkfd: fix the wrong no space return while acquires packet buffer Huang Rui
@ 2020-03-19 11:42 ` Pan, Xinhui
2020-03-19 13:40 ` Huang Rui
0 siblings, 1 reply; 3+ messages in thread
From: Pan, Xinhui @ 2020-03-19 11:42 UTC (permalink / raw)
To: Huang, Ray; +Cc: Kuehling, Felix, Pan, Xinhui, amd-gfx
> 2020年3月19日 18:51,Huang Rui <ray.huang@amd.com> 写道:
>
> The queue buffer index starts from position 0, so the available buffer size
> which starts from position 0 to rptr should be "rptr" index value. While the
> packet_size_in_dwords == rptr, the available buffer is just good enough.
>
> Signed-off-by: Huang Rui <ray.huang@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> index bae7064..4667c8f 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> @@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
> /* make sure after rolling back to position 0, there is
> * still enough space.
> */
> - if (packet_size_in_dwords >= rptr)
> + if (packet_size_in_dwords > rptr)
rptr should always be > wptr unless ring is empty.
say, rptr is 4, packet_size_in_dwords is 4. Then wptr changes from 0 to 4, that is illegal.
> goto err_no_space;
>
> /* fill nops, roll back and start at position 0 */
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cxinhui.pan%40amd.com%7Cdb98cfd84b764e77d20e08d7cbf38dff%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637202119950119907&sdata=mqrl2uooQ95Dns4l6CtmmOBCm%2FqZyw1pX48VA20mlZY%3D&reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: fix the wrong no space return while acquires packet buffer
2020-03-19 11:42 ` Pan, Xinhui
@ 2020-03-19 13:40 ` Huang Rui
0 siblings, 0 replies; 3+ messages in thread
From: Huang Rui @ 2020-03-19 13:40 UTC (permalink / raw)
To: Pan, Xinhui; +Cc: Kuehling, Felix, amd-gfx
On Thu, Mar 19, 2020 at 07:42:04PM +0800, Pan, Xinhui wrote:
>
>
> > 2020年3月19日 18:51,Huang Rui <ray.huang@amd.com> 写道:
> >
> > The queue buffer index starts from position 0, so the available buffer size
> > which starts from position 0 to rptr should be "rptr" index value. While the
> > packet_size_in_dwords == rptr, the available buffer is just good enough.
> >
> > Signed-off-by: Huang Rui <ray.huang@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> > index bae7064..4667c8f 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> > @@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
> > /* make sure after rolling back to position 0, there is
> > * still enough space.
> > */
> > - if (packet_size_in_dwords >= rptr)
> > + if (packet_size_in_dwords > rptr)
>
> rptr should always be > wptr unless ring is empty.
>
> say, rptr is 4, packet_size_in_dwords is 4. Then wptr changes from 0 to 4, that is illegal.
>
Hey, xinhui, yes. :-)
See the comment "we can only use up to queue_size_dword - 1 dwords", that
we cannot use the whole packet slots in the queue, it's to differentiate
empty and full cases.
Thanks,
Ray
>
> > goto err_no_space;
> >
> > /* fill nops, roll back and start at position 0 */
> > --
> > 2.7.4
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cxinhui.pan%40amd.com%7Cdb98cfd84b764e77d20e08d7cbf38dff%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637202119950119907&sdata=mqrl2uooQ95Dns4l6CtmmOBCm%2FqZyw1pX48VA20mlZY%3D&reserved=0
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-19 13:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 10:51 [PATCH] drm/amdkfd: fix the wrong no space return while acquires packet buffer Huang Rui
2020-03-19 11:42 ` Pan, Xinhui
2020-03-19 13:40 ` Huang Rui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).