diff mbox

drm/amdkfd: Fix for-loop when allocating HQD (non-HWS)

Message ID 1421141272-18444-1-git-send-email-oded.gabbay@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oded Gabbay Jan. 13, 2015, 9:27 a.m. UTC
From: Ben Goz <ben.goz@amd.com>

This patch fixes a minor bug in allocate_hqd(), where the loop run from the
next-to-allocate pipe until the number of pipes.

This is wrong because we need to consider the possibility where
next-to-allocate pipe is not 0, and thus, the for-loop only checks part of the
pipes and doesn't wrap-around, as it supposed to do.

Therefore, we add another counting variable to make sure we go over all the
pipes, regardless of where we start to look at the first iteration of the loop.

This bug only affected non-HWS mode. In HWS mode, the CP fw is responsible for
allocating the HQD.

Signed-off-by: Ben Goz <ben.goz@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Deucher Jan. 13, 2015, 2:47 p.m. UTC | #1
On Tue, Jan 13, 2015 at 4:27 AM, Oded Gabbay <oded.gabbay@amd.com> wrote:
> From: Ben Goz <ben.goz@amd.com>
>
> This patch fixes a minor bug in allocate_hqd(), where the loop run from the
> next-to-allocate pipe until the number of pipes.
>
> This is wrong because we need to consider the possibility where
> next-to-allocate pipe is not 0, and thus, the for-loop only checks part of the
> pipes and doesn't wrap-around, as it supposed to do.
>
> Therefore, we add another counting variable to make sure we go over all the
> pipes, regardless of where we start to look at the first iteration of the loop.
>
> This bug only affected non-HWS mode. In HWS mode, the CP fw is responsible for
> allocating the HQD.
>
> Signed-off-by: Ben Goz <ben.goz@amd.com>
> Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 30c8fda..102aaba 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -214,12 +214,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm,
>  static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
>  {
>         bool set;
> -       int pipe, bit;
> +       int pipe, bit, i;
>
>         set = false;
>
> -       for (pipe = dqm->next_pipe_to_allocate; pipe < get_pipes_num(dqm);
> -                       pipe = (pipe + 1) % get_pipes_num(dqm)) {
> +       for (pipe = dqm->next_pipe_to_allocate, i = 0; i < get_pipes_num(dqm);
> +                       pipe = ((pipe + 1) % get_pipes_num(dqm)), ++i) {
>                 if (dqm->allocated_queues[pipe] != 0) {
>                         bit = find_first_bit(
>                                 (unsigned long *)&dqm->allocated_queues[pipe],
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 30c8fda..102aaba 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -214,12 +214,12 @@  static int create_queue_nocpsch(struct device_queue_manager *dqm,
 static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
 {
 	bool set;
-	int pipe, bit;
+	int pipe, bit, i;
 
 	set = false;
 
-	for (pipe = dqm->next_pipe_to_allocate; pipe < get_pipes_num(dqm);
-			pipe = (pipe + 1) % get_pipes_num(dqm)) {
+	for (pipe = dqm->next_pipe_to_allocate, i = 0; i < get_pipes_num(dqm);
+			pipe = ((pipe + 1) % get_pipes_num(dqm)), ++i) {
 		if (dqm->allocated_queues[pipe] != 0) {
 			bit = find_first_bit(
 				(unsigned long *)&dqm->allocated_queues[pipe],