Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D744606A322 for ; Fri, 4 Dec 2026 03:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=d9Ld21im Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AADD10E3F5; Fri, 4 Dec 2026 03:35:01 +0000 (UTC) Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011044.outbound.protection.outlook.com [52.101.52.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47C1110E3F5 for ; Fri, 4 Dec 2026 03:34:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xl/8RKA8W1n+2n5vJ6qQjqRqBAeEtXqOoVmIbaqD/a5JOZcUnan3dhJnz43etfXLF+tQXBlnEnMiPHdB0yxxvzZFkb0a3jp7nSiy8eX5uNNJ584AhJkbo1tVbmmqTpThZ0/OAEDA+qq+G/nCawwlwdLy0KUJBBN+yUqufi7Yhw+CR7oJ5nkY49PpKG5b9dU3eTCyyKdatdsdkFEc8te0q0eNlvcRjZtURxILh7KOW89LThbarHL3kuxtCyg5zbEa5JsY4ofPvpb0Qx3d6B7BJ3bVUeOYGFSMdnWi70BB+uEWdsRlHxOoSLvB8cYjpgDhOkFrvlqCi8DIOEZ8jYLFCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pdDGPOvgtnhxTznp0/HNza1vCdiHZhuK9vLsy1yxruI=; b=tOKBczU9R/q3M3IhFOyLoOxaUdzHt6MdG1sY8qeAozgY2CGByj5PR1JPUHScmVo3XT0FShaXJ1p+UE20DlpE+MNLOXnIxiWCUm8uLryGC3/PVBmVWXBTwEDU/L9ZSN9zcpYu2/Ix3g804TpLi09j+FqFh55TNOLYBlaetFDeqWTqO7qzoIPVjFriygZNayKqpfos/75d8VHs1arj71EOH9AwC5Km1Tu242sNOsmHlpQaIro9rjWYNGnvbOwKJqn+dFpiniWcfwvgDWo/s9PGh6cnOHzg6ZDA5dWSw4uqK8PdNovyQGiaLjIzsygJpAueblmt4WYBXRL7qGVrj+Bl4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pdDGPOvgtnhxTznp0/HNza1vCdiHZhuK9vLsy1yxruI=; b=d9Ld21im+T+Le1XUaOypjI52d97/J31C6tfHir3QXA3NdAy2kWEtJooMJIHo+fb5FqKJRBV1u4j9cMdxTiiOUnd2U9oyCz/vKPrqLtHQqzMq4lY0MSHHHf38RgkB0jzK2O1dkwrls+NDV4pLaHnAdO+bIR/8NU4MsZA5cpdMOnI= Received: from CH0PR03CA0396.namprd03.prod.outlook.com (2603:10b6:610:11b::16) by SA0PR12MB7463.namprd12.prod.outlook.com (2603:10b6:806:24b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 03:34:48 +0000 Received: from BN3PEPF0000B374.namprd21.prod.outlook.com (2603:10b6:610:11b:cafe::32) by CH0PR03CA0396.outlook.office365.com (2603:10b6:610:11b::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 03:34:47 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BN3PEPF0000B374.mail.protection.outlook.com (10.167.243.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.0 via Frontend Transport; Fri, 4 Dec 2026 03:34:47 +0000 Received: from mukjoshi-dev.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 21:34:45 -0600 From: Mukul Joshi To: CC: , , , Mukul Joshi Subject: [PATCHv2 2/2] drm/amdkfd: remove all queues of a process with a single MES call Date: Thu, 3 Dec 2026 22:33:58 -0500 Message-ID: <20261204033433.939162-2-mukul.joshi@amd.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261204033433.939162-1-mukul.joshi@amd.com> References: <20261204033433.939162-1-mukul.joshi@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B374:EE_|SA0PR12MB7463:EE_ X-MS-Office365-Filtering-Correlation-Id: c694ac57-61c1-47fa-71fb-08df51b78bdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700016|376014|23010399003|82310400026|18002099003|22082099003|10067099003|56012099006|261026121527099003|261026140227099003|261022105027099003|261022075727099003|261028144727099003|261021123027099003|261021121427099003|261102123227099003|261009223027099003|11063799006; X-Microsoft-Antispam-Message-Info: gwhzzO6DY46K2gHw7rQp4HaffL3XxJ2JQlDgRCNBKgUDJhEHv3iz0A/tEj3/5ARzvKPlPAX272O+ex47UQzsodujzz8ecTD0Lrgj1iiH73iHwCqi87IFAvO4weWiBPn7/Xy+HqoPDogrCFovlPprd4fFssCdkhspxSgSGD6DZyTGmrT2gpD8seVUp2HPB0eEeA3PTNANpDB/XwmSsydTq0F3betNTeIwR8CzltyFu7C0Ba6sVfP6p9RLJ9AuKDm3cMj4v0p+Nz9miANWx7i+qr06MYHRWiqoUazAbgslgLV/NLGxdRZJ/IBboAWb96BrukniSDNnIGsM9gn2C1xCZh0kG+h+U6MzPl+NB+SGYFGlABxrGbgJOBpVtfclbixDuLq3T/BEjspSMWPs5CkeEfY4R3nqEwo4Pxbc7L1LoC7MJvKO1auz+yb3O32qUNCcuZ2cj2vJb381tTT7oYDfRmpcMuY5HrnXzQczTC9mj4Ka0sV9uyqTvbcVR4jJy5LNsCgJAbkCqpth6OEB3amN8TCBZg8VAdvpLOy7TnFQNRsTWF/3jhUZN1/JU1cYaE8oGZUfXtSLmusvjM28DRxfIbnOeEiEC5pFLqfwZBiyn9ehjzveD4XdHTS2aD1URYm/f5A3xifjuI20pZC/AaMpMIvqiLX4g1IPBdPP9IDSMw6pilg3nJja5MreVuA8P9zPuviHmTkQg6NiFbs2ugCgLQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700016)(376014)(23010399003)(82310400026)(18002099003)(22082099003)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261022105027099003)(261022075727099003)(261028144727099003)(261021123027099003)(261021121427099003)(261102123227099003)(261009223027099003)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pTNYBdz+c/l9cUXb9oOpQIdfN+RfBZ2MQ8ldod2okjUAEfKB/LjB0CWXguXqDkaAZMWPyj9dGvpfnW+gBnHI8PBkn/jqChuQeOnUYxE6srlSF3u7vf4mMlaT8NHTEY3Jbzl17BnDHOKPLssLKtCWeuYEUMNa/BuQLCi6LfsWIkN+1lQRl0GXidikhDysl+PL2KQmdLKmFSUZ+izodGJwvW1jK62T1Q+o9ikcu3q15/G2lfKsMsAyzyVX/C/rBZcJHtx6GCmXPJmwcSR1uy26q4rcjionuM77ekXiYX/JNl7/6Eqt0rnLnYtQDXRWoi8HS7zfAGILDU7UJ+Jir6IMa3UCojsD2MQPgKFc0jsAxjzFS5yS9rQbkf4GHPtY8maXzt+WK7CVLhRUI7n7u2xV0LzbybaR9MVhuPOQvFsfvdIegOH8VSDBcX5cDOIN1+r/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 03:34:47.7016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c694ac57-61c1-47fa-71fb-08df51b78bdf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B374.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7463 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On process eviction, termination and scheduler halt/stop, KFD sends one MES REMOVE_QUEUE per active queue. If MES supports it, remove all queues of a process, by PASID, with a single request instead. remove_queue_mes() sends this request when called with a NULL queue. On failure, the same request is passed to the MES queue reset path, which sends it again if no hung queue is found. If hung queues were reset instead, the other queues of the process are resumed, so send the request once more. Signed-off-by: Mukul Joshi --- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 139 ++++++++++++++---- 1 file changed, 113 insertions(+), 26 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 58c7da599752..35d7aef68f62 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -79,7 +79,10 @@ static struct queue *find_queue_by_doorbell_offset(struct device_queue_manager * u32 doorbell_offset); static void set_queue_as_reset(struct device_queue_manager *dqm, struct queue *q, struct qcm_process_device *qpd, bool verbose); -static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q); +static int reset_queues_mes(struct device_queue_manager *dqm, + struct kfd_process_device *pdd, + struct mes_remove_queue_input *queue_input, + unsigned int *hung_queue_count); static inline enum KFD_MQD_TYPE get_mqd_type_from_queue_type(enum kfd_queue_type type) @@ -299,17 +302,35 @@ static int add_queue_mes(struct device_queue_manager *dqm, struct queue *q, return r; } +/* A queue that is active and not reset is still in MES */ +static bool qpd_has_mes_queue(struct qcm_process_device *qpd) +{ + struct queue *q; + + list_for_each_entry(q, &qpd->queues_list, list) + if (q->properties.is_active && !q->properties.is_reset) + return true; + + return false; +} + +/* + * Remove queue q from MES. If q is NULL, remove all queues of the process + * with a single request, see amdgpu_mes_remove_all_process_queues_supported(). + * This must be done while the queues are still marked active. + */ static int remove_queue_mes_on_reset_option(struct device_queue_manager *dqm, struct queue *q, struct qcm_process_device *qpd, bool is_for_reset, bool flush_mes_queue) { struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev; + unsigned int num_hung = 0; int r; struct mes_remove_queue_input queue_input; - /* queue was already removed during reset */ - if (q->properties.is_reset) + /* queue(s) already removed during reset */ + if (q ? q->properties.is_reset : !qpd_has_mes_queue(qpd)) return 0; if (!dqm->sched_running || dqm->sched_halt) @@ -318,12 +339,17 @@ static int remove_queue_mes_on_reset_option(struct device_queue_manager *dqm, st return -EIO; memset(&queue_input, 0x0, sizeof(struct mes_remove_queue_input)); - queue_input.doorbell_offset = q->properties.doorbell_off; - queue_input.gang_context_addr = q->gang_ctx_gpu_addr; - queue_input.queue_type = convert_to_amdgpu_ring_type(q->properties.type); - queue_input.remove_queue_after_reset = flush_mes_queue; + if (q) { + queue_input.doorbell_offset = q->properties.doorbell_off; + queue_input.gang_context_addr = q->gang_ctx_gpu_addr; + queue_input.queue_type = convert_to_amdgpu_ring_type(q->properties.type); + queue_input.remove_queue_after_reset = flush_mes_queue; + queue_input.gang_context_array_index = q->gang_ctx_array_index; + } else { + queue_input.remove_all_process_queues = true; + queue_input.pasid = qpd_to_pdd(qpd)->pasid; + } queue_input.xcc_id = ffs(dqm->dev->xcc_mask) - 1; - queue_input.gang_context_array_index = q->gang_ctx_array_index; amdgpu_mes_lock(&adev->mes); r = adev->mes.funcs->remove_hw_queue(&adev->mes, &queue_input); @@ -335,10 +361,26 @@ static int remove_queue_mes_on_reset_option(struct device_queue_manager *dqm, st return r; /* remove_hw_queue failure indicates a queue hang. reset the queue */ - r = reset_queues_mes(dqm, q); + queue_input.remove_queue_after_reset = false; + r = reset_queues_mes(dqm, qpd_to_pdd(qpd), &queue_input, &num_hung); + + /* hung queues were reset and removed; remove the rest of the process */ + if (!r && !q && num_hung && qpd_has_mes_queue(qpd)) { + if (!down_read_trylock(&adev->reset_domain->sem)) + return -EIO; + amdgpu_mes_lock(&adev->mes); + r = adev->mes.funcs->remove_hw_queue(&adev->mes, &queue_input); + amdgpu_mes_unlock(&adev->mes); + up_read(&adev->reset_domain->sem); + } + if (r && amdgpu_gpu_recovery) { - dev_err(adev->dev, "failed to remove queue from MES, doorbell=0x%x\n", - q->properties.doorbell_off); + if (q) + dev_err(adev->dev, "failed to remove queue from MES, doorbell=0x%x\n", + q->properties.doorbell_off); + else + dev_err(adev->dev, "failed to remove queues of pasid 0x%x from MES\n", + queue_input.pasid); dev_err(adev->dev, "MES might be in unrecoverable state, issue a GPU reset\n"); kfd_hws_hang(dqm); } @@ -363,6 +405,8 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q, static int remove_all_kfd_queues_mes(struct device_queue_manager *dqm) { + struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev; + bool remove_all = amdgpu_mes_remove_all_process_queues_supported(adev); struct device_process_node *cur; struct device *dev = dqm->dev->adev->dev; struct qcm_process_device *qpd; @@ -371,6 +415,16 @@ static int remove_all_kfd_queues_mes(struct device_queue_manager *dqm) list_for_each_entry(cur, &dqm->queues, list) { qpd = cur->qpd; + if (remove_all) { + retval = remove_queue_mes(dqm, NULL, qpd); + if (retval) { + dev_err(dev, "%s: Failed to remove queues of pasid 0x%x for dev %d", + __func__, qpd_to_pdd(qpd)->pasid, dqm->dev->id); + return retval; + } + continue; + } + list_for_each_entry(q, &qpd->queues_list, list) { if (q->properties.is_active) { retval = remove_queue_mes(dqm, q, qpd); @@ -452,15 +506,21 @@ int kfd_reset_queue_mes(struct device_queue_manager *dqm, int queue_type, return reset_queue_mes(dqm, q, queue_type, pipe, queue, db); } -static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) +/* + * queue_input is the remove request for the bad queue(s). If MES doesn't + * detect a hung queue, it is sent again before the queues are resumed. + * hung_queue_count (optional) returns the number of hung queues. + */ +static int reset_queues_mes(struct device_queue_manager *dqm, + struct kfd_process_device *pdd, + struct mes_remove_queue_input *queue_input, + unsigned int *hung_queue_count) { struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev; struct drm_wedge_task_info *info = NULL; struct amdgpu_task_info *ti = NULL; - struct kfd_process_device *pdd; unsigned int num_hung = 0; int r = 0; - struct mes_remove_queue_input queue_input; if (!amdgpu_mes_queue_reset_by_mes_supported(adev)) { r = -ENOTRECOVERABLE; @@ -471,18 +531,13 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) if (WARN_ON(dqm->detect_hang_count > 0)) return 0; - memset(&queue_input, 0x0, sizeof(struct mes_remove_queue_input)); - queue_input.doorbell_offset = q->properties.doorbell_off; - queue_input.gang_context_addr = q->gang_ctx_gpu_addr; - queue_input.gang_context_array_index = q->gang_ctx_array_index; - queue_input.queue_type = convert_to_amdgpu_ring_type(q->properties.type); - queue_input.remove_queue_after_reset = false; - queue_input.xcc_id = ffs(dqm->dev->xcc_mask) - 1; /* pass the known bad queue info to the reset function */ - r = amdgpu_gfx_reset_mes_compute(adev, dqm->dev->xcp, NULL, NULL, NULL, &num_hung, &queue_input); + r = amdgpu_gfx_reset_mes_compute(adev, dqm->dev->xcp, NULL, NULL, NULL, &num_hung, + queue_input); if (r) goto fail; - pdd = kfd_get_process_device_data(q->device, q->process); + if (hung_queue_count) + *hung_queue_count = num_hung; if (pdd) { ti = amdgpu_vm_get_task_info_pasid(adev, pdd->pasid); if (ti) { @@ -1493,6 +1548,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, struct queue *q; struct device *dev = dqm->dev->adev->dev; struct kfd_process_device *pdd; + bool remove_all; int retval = 0; dqm_lock(dqm); @@ -1514,6 +1570,17 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, if (dqm->dev->kfd->shared_resources.enable_mes) pdd->last_evict_timestamp = get_jiffies_64(); + remove_all = dqm->dev->kfd->shared_resources.enable_mes && + amdgpu_mes_remove_all_process_queues_supported(dqm->dev->adev); + if (remove_all) { + retval = remove_queue_mes(dqm, NULL, qpd); + if (retval) { + dev_err(dev, "Failed to evict queues of pasid 0x%x\n", + pdd->pasid); + goto out; + } + } + /* Mark all queues as evicted. Deactivate all active queues on * the qpd. */ @@ -1525,7 +1592,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, q->properties.is_active = false; decrement_queue_count(dqm, qpd, q); - if (dqm->dev->kfd->shared_resources.enable_mes) { + if (dqm->dev->kfd->shared_resources.enable_mes && !remove_all) { retval = remove_queue_mes(dqm, q, qpd); if (retval) { dev_err(dev, "Failed to evict queue %d\n", @@ -3286,6 +3353,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm, enum kfd_unmap_queues_filter filter = KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES; bool found = false; + bool remove_all; dqm_lock(dqm); @@ -3298,6 +3366,15 @@ static int process_termination_cpsch(struct device_queue_manager *dqm, filter = KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES; } + remove_all = dqm->dev->kfd->shared_resources.enable_mes && + amdgpu_mes_remove_all_process_queues_supported(dqm->dev->adev); + if (remove_all) { + retval = remove_queue_mes(dqm, NULL, qpd); + if (retval) + dev_err(dev, "Failed to remove queues of pasid 0x%x\n", + qpd_to_pdd(qpd)->pasid); + } + /* Clear all user mode queues */ list_for_each_entry(q, &qpd->queues_list, list) { if (q->properties.type == KFD_QUEUE_TYPE_SDMA) @@ -3308,7 +3385,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm, if (q->properties.is_active) { decrement_queue_count(dqm, qpd, q); - if (dqm->dev->kfd->shared_resources.enable_mes) { + if (dqm->dev->kfd->shared_resources.enable_mes && !remove_all) { retval = remove_queue_mes(dqm, q, qpd); if (retval) dev_err(dev, "Failed to remove queue %d\n", @@ -3610,7 +3687,17 @@ int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbel list_for_each_entry(q, &qpd->queues_list, list) { if (q->doorbell_id == doorbell_id && q->properties.is_active) { - if (reset_queues_mes(dqm, q)) + struct mes_remove_queue_input queue_input; + + memset(&queue_input, 0x0, sizeof(struct mes_remove_queue_input)); + queue_input.doorbell_offset = q->properties.doorbell_off; + queue_input.gang_context_addr = q->gang_ctx_gpu_addr; + queue_input.gang_context_array_index = q->gang_ctx_array_index; + queue_input.queue_type = + convert_to_amdgpu_ring_type(q->properties.type); + queue_input.xcc_id = ffs(dqm->dev->xcc_mask) - 1; + + if (reset_queues_mes(dqm, pdd, &queue_input, NULL)) dev_dbg(knode->adev->dev, "Fail to remove bad queue. doorbell_id 0x%x\n", q->doorbell_id); q->properties.is_evicted = true; -- 2.56.0