diff mbox series

[i-g-t,v4,3/5] lib/gem_engine_topology: Fix premature break from primary find loop

Message ID 20240718085912.15434-10-janusz.krzysztofik@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series tests/gem_ctx_exec: Fix failing preempt timeout updates | expand

Commit Message

Janusz Krzysztofik July 18, 2024, 8:55 a.m. UTC
When looking for a primary counterpart of a render device, we try to open
each primary minor.  When one fails, we should continue rather then break,
since contiguity of minor numbers assigned to devices is not guaranteed.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 lib/i915/gem_engine_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kamil Konieczny July 18, 2024, 12:11 p.m. UTC | #1
Hi Janusz,
On 2024-07-18 at 10:55:14 +0200, Janusz Krzysztofik wrote:
> When looking for a primary counterpart of a render device, we try to open
> each primary minor.  When one fails, we should continue rather then break,
> since contiguity of minor numbers assigned to devices is not guaranteed.
> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
>  lib/i915/gem_engine_topology.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
> index c878e95f08..8589af5c1a 100644
> --- a/lib/i915/gem_engine_topology.c
> +++ b/lib/i915/gem_engine_topology.c
> @@ -479,7 +479,7 @@ static int __open_primary(int dir)
>  		sprintf(buf, "/sys/dev/char/%d:%d", major, minor);
>  		dir = openat(fd, buf, O_RDONLY);
>  		if (dir < 0)
> -			break;
> +			continue;

Good catch!

Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

>  
>  		if (readlinkat(dir, "device", device, sizeof(device)) > 0 &&
>  		    !strcmp(device, target))
> -- 
> 2.45.2
>
diff mbox series

Patch

diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index c878e95f08..8589af5c1a 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -479,7 +479,7 @@  static int __open_primary(int dir)
 		sprintf(buf, "/sys/dev/char/%d:%d", major, minor);
 		dir = openat(fd, buf, O_RDONLY);
 		if (dir < 0)
-			break;
+			continue;
 
 		if (readlinkat(dir, "device", device, sizeof(device)) > 0 &&
 		    !strcmp(device, target))