Commit f0ec5b99 authored by Ben Goz's avatar Ben Goz Committed by Oded Gabbay

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

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: default avatarBen Goz <ben.goz@amd.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6898f0a5
...@@ -191,12 +191,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, ...@@ -191,12 +191,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm,
static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q) static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
{ {
bool set; bool set;
int pipe, bit; int pipe, bit, i;
set = false; set = false;
for (pipe = dqm->next_pipe_to_allocate; pipe < 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)) { pipe = ((pipe + 1) % get_pipes_num(dqm)), ++i) {
if (dqm->allocated_queues[pipe] != 0) { if (dqm->allocated_queues[pipe] != 0) {
bit = find_first_bit( bit = find_first_bit(
(unsigned long *)&dqm->allocated_queues[pipe], (unsigned long *)&dqm->allocated_queues[pipe],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment