Skip to contentSkip to conversation

drm/amdgpu: Unset context priority is now invalid

PATCH In review Luben Tuikov 2 participants 5 messages Oct 17, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: Unset context priority is now invalid

A context priority value of AMD_CTX_PRIORITY_UNSET is now invalid--instead of carrying it around and passing it to the Direct Rendering Manager--and it becomes AMD_CTX_PRIORITY_NORMAL in amdgpu_ctx_ioctl(), the gateway to context creation.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -1
index 0dc9c655c4fbdb..092962b93064fc 100644
@@ -47,7 +47,6 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
 bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
 {
 	switch (ctx_prio) {
-	case AMDGPU_CTX_PRIORITY_UNSET:
 	case AMDGPU_CTX_PRIORITY_VERY_LOW:
 	case AMDGPU_CTX_PRIORITY_LOW:
 	case AMDGPU_CTX_PRIORITY_NORMAL:
@@ -55,6 +54,7 @@ bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
 	case AMDGPU_CTX_PRIORITY_VERY_HIGH:
 		return true;
 	default:
+	case AMDGPU_CTX_PRIORITY_UNSET:
 		return false;
 	}
 }

base-commit: dc9b2e683bcba017588b9aaad80f442ad004a48f

Signature · 1 line
2.42.0
#1 lore raw

PATCH 2/2 gpu/drm: Eliminate DRM_SCHED_PRIORITY_UNSET

Eliminate DRM_SCHED_PRIORITY_UNSET, value of -2, whose only user was amdgpu. Furthermore, eliminate an index bug, in that when amdgpu boots, it calls drm_sched_entity_init() with DRM_SCHED_PRIORITY_UNSET, which uses it to index sched->sched_rq[].

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 ++-
 include/drm/gpu_scheduler.h             | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2 -1
index 092962b93064fc..aac52d9754e6da 100644
@@ -64,7 +64,8 @@ amdgpu_ctx_to_drm_sched_prio(int32_t ctx_prio)
 {
 	switch (ctx_prio) {
 	case AMDGPU_CTX_PRIORITY_UNSET:
-		return DRM_SCHED_PRIORITY_UNSET;
+		pr_warn_once("AMD-->DRM context priority value UNSET-->NORMAL");
+		return DRM_SCHED_PRIORITY_NORMAL;
 
 	case AMDGPU_CTX_PRIORITY_VERY_LOW:
 		return DRM_SCHED_PRIORITY_MIN;
include/drm/gpu_scheduler.h +1 -2
index f9544d9b670d33..ac65f0626cfc91 100644
@@ -68,8 +68,7 @@ enum drm_sched_priority {
 	DRM_SCHED_PRIORITY_HIGH,
 	DRM_SCHED_PRIORITY_KERNEL,
 
-	DRM_SCHED_PRIORITY_COUNT,
-	DRM_SCHED_PRIORITY_UNSET = -2
+	DRM_SCHED_PRIORITY_COUNT
 };
 
 /* Used to chose between FIFO and RR jobs scheduling */
Signature · 1 line
2.42.0
#2 lore raw
In reply to Luben Tuikov
Quoted 26 lines · Luben Tuikov

A context priority value of AMD_CTX_PRIORITY_UNSET is now invalid--instead of carrying it around and passing it to the Direct Rendering Manager--and it becomes AMD_CTX_PRIORITY_NORMAL in amdgpu_ctx_ioctl(), the gateway to context creation.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -1
index 0dc9c655c4fbdb..092962b93064fc 100644
@@ -47,7 +47,6 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
 bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
 {
        switch (ctx_prio) {
-       case AMDGPU_CTX_PRIORITY_UNSET:
        case AMDGPU_CTX_PRIORITY_VERY_LOW:
        case AMDGPU_CTX_PRIORITY_LOW:
        case AMDGPU_CTX_PRIORITY_NORMAL:

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio) · line 58

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -0
@@ -55,6 +54,7 @@ bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
        case AMDGPU_CTX_PRIORITY_VERY_HIGH:
                return true;
        default:
+       case AMDGPU_CTX_PRIORITY_UNSET:
                return false;

I don't recall if any userspace uses this, but this would break userspace if it does.

Alex

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
        }
 }

base-commit: dc9b2e683bcba017588b9aaad80f442ad004a48f --
2.42.0

#3 lore raw
Quoted 27 lines · Alex Deucher
Quoted 26 lines · Luben Tuikov

A context priority value of AMD_CTX_PRIORITY_UNSET is now invalid--instead of carrying it around and passing it to the Direct Rendering Manager--and it becomes AMD_CTX_PRIORITY_NORMAL in amdgpu_ctx_ioctl(), the gateway to context creation.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -1
index 0dc9c655c4fbdb..092962b93064fc 100644
@@ -47,7 +47,6 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
 bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
 {
        switch (ctx_prio) {
-       case AMDGPU_CTX_PRIORITY_UNSET:
        case AMDGPU_CTX_PRIORITY_VERY_LOW:
        case AMDGPU_CTX_PRIORITY_LOW:
        case AMDGPU_CTX_PRIORITY_NORMAL:
@@ -55,6 +54,7 @@ bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio) · line 58

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -0
        case AMDGPU_CTX_PRIORITY_VERY_HIGH:
                return true;
        default:
+       case AMDGPU_CTX_PRIORITY_UNSET:
                return false;

I don't recall if any userspace uses this, but this would break userspace if it does.

This is shielded from user space in the following manner,
1) amdgpu_ctx_priority_is_valid() is called from amdgpu_ctx_ioctl() and if amdgpu_ctx_priority_is_valid() returns false, we set the priority to NORMAL. See the 2nd patch.
2) It is also called from amdgpu_ctx_priority_permit(), which is called from amdgpu_ctx_init() which is called from amdgpu_ctx_alloc() which is called from amdgpu_ctx_ioctl(), _after_ the call described above, and thus priority is now NORMAL.

Plus I'm typing this on a running system with 6.6.0 + those two patches.

User space can send us down UNSET, but we set it to NORMAL.

Can I get an R-B?

Quoted 10 lines

Alex

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
        }
 }

base-commit: dc9b2e683bcba017588b9aaad80f442ad004a48f --
2.42.0

Signature · 2 lines
Regards,
Luben
Acked-by
#4 lore raw
Quoted 38 lines · Luben Tuikov
Quoted 27 lines · Alex Deucher
Quoted 26 lines · Luben Tuikov

A context priority value of AMD_CTX_PRIORITY_UNSET is now invalid--instead of carrying it around and passing it to the Direct Rendering Manager--and it becomes AMD_CTX_PRIORITY_NORMAL in amdgpu_ctx_ioctl(), the gateway to context creation.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -1
index 0dc9c655c4fbdb..092962b93064fc 100644
@@ -47,7 +47,6 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
 bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
 {
        switch (ctx_prio) {
-       case AMDGPU_CTX_PRIORITY_UNSET:
        case AMDGPU_CTX_PRIORITY_VERY_LOW:
        case AMDGPU_CTX_PRIORITY_LOW:
        case AMDGPU_CTX_PRIORITY_NORMAL:
@@ -55,6 +54,7 @@ bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c bool amdgpu_ctx_priority_is_valid(int32_t ctx_prio) · line 58

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -0
        case AMDGPU_CTX_PRIORITY_VERY_HIGH:
                return true;
        default:
+       case AMDGPU_CTX_PRIORITY_UNSET:
                return false;

I don't recall if any userspace uses this, but this would break userspace if it does.

Quoted 4 lines

This is shielded from user space in the following manner,
1) amdgpu_ctx_priority_is_valid() is called from amdgpu_ctx_ioctl() and if amdgpu_ctx_priority_is_valid() returns false, we set the priority to NORMAL. See the 2nd patch.

Ah, I see. Thanks. Series is:

Quoted 26 lines

2) It is also called from amdgpu_ctx_priority_permit(), which is called from amdgpu_ctx_init() which is called from amdgpu_ctx_alloc() which is called from amdgpu_ctx_ioctl(), _after_ the call described above, and thus priority is now NORMAL.

Plus I'm typing this on a running system with 6.6.0 + those two patches.

User space can send us down UNSET, but we set it to NORMAL.

Can I get an R-B?

Quoted 10 lines

Alex

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
        }
 }

base-commit: dc9b2e683bcba017588b9aaad80f442ad004a48f --
2.42.0

--
Regards,
Luben