From patchwork Mon Jan 8 09:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenneng Li X-Patchwork-Id: 13513218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27A9EC4707B for ; Mon, 8 Jan 2024 09:46:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7185510E1E2; Mon, 8 Jan 2024 09:46:21 +0000 (UTC) X-Greylist: delayed 302 seconds by postgrey-1.36 at gabe; Mon, 08 Jan 2024 09:46:19 UTC Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by gabe.freedesktop.org (Postfix) with ESMTPS id A49BB10E1E2; Mon, 8 Jan 2024 09:46:19 +0000 (UTC) X-UUID: 0194aff85b42445fb4cd05c6b8915c12-20240108 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35, REQID:895988ca-c91d-48e2-b272-9200b13a11ca, IP:20, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:5 X-CID-INFO: VERSION:1.1.35, REQID:895988ca-c91d-48e2-b272-9200b13a11ca, IP:20, UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:5 X-CID-META: VersionHash:5d391d7, CLOUDID:b93fed2e-1ab8-4133-9780-81938111c800, B ulkID:240108174111PW07QMQM,BulkQuantity:0,Recheck:0,SF:17|19|44|66|38|24|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 0194aff85b42445fb4cd05c6b8915c12-20240108 X-User: lizhenneng@kylinos.cn Received: from localhost.localdomain [(116.128.244.171)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 286747945; Mon, 08 Jan 2024 17:41:08 +0800 From: Zhenneng Li To: Marek Olsak , Pierre-Eric Pelloux-Prayer , dri-devel , amd-gfx Subject: [PATCH libdrm 1/2] amdgpu: fix parameter of amdgpu_cs_ctx_create2 Date: Mon, 8 Jan 2024 17:40:51 +0800 Message-Id: <20240108094052.171721-1-lizhenneng@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhenneng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to pass the correct priority parameter to the kernel, we must change priority type from uint32_t to int32_t. Signed-off-by: Zhenneng Li --- amdgpu/amdgpu.h | 2 +- amdgpu/amdgpu_cs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 9bdbf366..f46753f3 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -896,7 +896,7 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle, * */ int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, - uint32_t priority, + int32_t priority, amdgpu_context_handle *context); /** * Create GPU execution Context diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 49fc16c3..eb72c638 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -49,7 +49,7 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem); * \return 0 on success otherwise POSIX Error code */ drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, - uint32_t priority, + int32_t priority, amdgpu_context_handle *context) { struct amdgpu_context *gpu_context; From patchwork Mon Jan 8 09:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenneng Li X-Patchwork-Id: 13513219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D01E5C3DA6E for ; Mon, 8 Jan 2024 09:46:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E23810E207; Mon, 8 Jan 2024 09:46:24 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by gabe.freedesktop.org (Postfix) with ESMTPS id EDD8D10E1F9; Mon, 8 Jan 2024 09:46:21 +0000 (UTC) X-UUID: 88c7ec6b451c482cb8107aa0b946676f-20240108 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35, REQID:286c5e78-a4fe-4060-8c6f-ac9c8d68c380, IP:20, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:5 X-CID-INFO: VERSION:1.1.35, REQID:286c5e78-a4fe-4060-8c6f-ac9c8d68c380, IP:20, UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:5 X-CID-META: VersionHash:5d391d7, CLOUDID:bd3fed2e-1ab8-4133-9780-81938111c800, B ulkID:240108174111OIUGN40H,BulkQuantity:0,Recheck:0,SF:38|24|17|19|44|66|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 88c7ec6b451c482cb8107aa0b946676f-20240108 X-User: lizhenneng@kylinos.cn Received: from localhost.localdomain [(116.128.244.171)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 647686786; Mon, 08 Jan 2024 17:41:08 +0800 From: Zhenneng Li To: Marek Olsak , Pierre-Eric Pelloux-Prayer , dri-devel , amd-gfx Subject: [PATCH libdrm 2/2] amdgpu: change proirity value to be consistent with kernel Date: Mon, 8 Jan 2024 17:40:52 +0800 Message-Id: <20240108094052.171721-2-lizhenneng@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240108094052.171721-1-lizhenneng@kylinos.cn> References: <20240108094052.171721-1-lizhenneng@kylinos.cn> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhenneng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In libdrm-amdgpu and amdgpu kernel driver, there are only such priority level: AMDGPU_CTX_PRIORITY_VERY_LOW, AMDGPU_CTX_PRIORITY_LOW, AMDGPU_CTX_PRIORITY_NORMAL, AMDGPU_CTX_PRIORITY_HIGH, AMDGPU_CTX_PRIORITY_VERY_HIGH If priority value is not the one of the above data, the kernel will treat it as invalid. If you set prority to HIGH or VERY_HIGH, please make sure the process have CAP_SYS_NICE capability or DRM_MASTER permission. Signed-off-by: Zhenneng Li --- amdgpu/amdgpu_cs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index eb72c638..d6d768ba 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -57,6 +57,7 @@ drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, int i, j, k; int r; char *override_priority; + int32_t override_prio; if (!dev || !context) return -EINVAL; @@ -66,9 +67,16 @@ drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, /* The priority is a signed integer. The variable type is * wrong. If parsing fails, priority is unchanged. */ - if (sscanf(override_priority, "%i", &priority) == 1) { + if (sscanf(override_priority, "%i", &override_prio) == 1) { printf("amdgpu: context priority changed to %i\n", - priority); + override_prio); + if (override_prio == 0) { + priority = AMDGPU_CTX_PRIORITY_NORMAL; + } else if (override_prio < 0) { + priority = AMDGPU_CTX_PRIORITY_HIGH; + } else { + priority = AMDGPU_CTX_PRIORITY_LOW; + } } }