From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BAE35CB7B; Wed, 3 Dec 2025 16:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779185; cv=none; b=IkIdu+ukCkWEbXVrFL+ngrNesIV5Kj2bvhtDIj+BXYKp4stA/k//55+/iYF8s++MHxw0wGZayJSVl6jVOWnfPhvYXS0ib7tIxGi0olemGmLzJCeq+JyMsh7/KHfe2vevsAHqgjf79SfHRESbD6zEWw1E++BzRBiXhQ80dYPcEvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779185; c=relaxed/simple; bh=hzMQjUgDTuR+S9mPa3ywKhiKGB1o8L7Xb1NyF7g7vHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E8cq0a5wGYYGtcDGZqydb+j4Ax5/sUbxD+HsLADYk0HwDFMSzgzsmI7T3nKVJw2eLWXpgqcOZHv5fLRXM6IuhHCJroD5FiLCDHnJEX3tY95xVPlL+oeRFxep69TZg+yV2aSO7UqLH2vQvigTkQ1mTDdIg0Htts5A72AKeYZVMD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D44tXBu9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="D44tXBu9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4841C4CEF5; Wed, 3 Dec 2025 16:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764779185; bh=hzMQjUgDTuR+S9mPa3ywKhiKGB1o8L7Xb1NyF7g7vHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D44tXBu9lD939zCJC+fiuzmfsISCdQrtRruaFEtL4cHepj7vqdcZA9Ih5D33odRbT 0hkUxUTHkBg6m9hlohy0Gv+rUyXcd4vSztPPpP9Mg3Kspj7UMROltFCevqzufwBtcp MX56rjrX/lOT4Fb+K2FAdyHAg7l2E3/L/HsI+WeI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Amber Lin , Harish Kasiviswanathan , Alex Deucher , Sasha Levin Subject: [PATCH 6.1 173/568] drm/amdkfd: Tie UNMAP_LATENCY to queue_preemption Date: Wed, 3 Dec 2025 16:22:55 +0100 Message-ID: <20251203152447.068715407@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152440.645416925@linuxfoundation.org> References: <20251203152440.645416925@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amber Lin [ Upstream commit f3820e9d356132e18405cd7606e22dc87ccfa6d1 ] When KFD asks CP to preempt queues, other than preempt CP queues, CP also requests SDMA to preempt SDMA queues with UNMAP_LATENCY timeout. Currently queue_preemption_timeout_ms is 9000 ms by default but can be configured via module parameter. KFD_UNMAP_LATENCY_MS is hard coded as 4000 ms though. This patch ties KFD_UNMAP_LATENCY_MS to queue_preemption_timeout_ms so in a slow system such as emulator, both CP and SDMA slowness are taken into account. Signed-off-by: Amber Lin Reviewed-by: Harish Kasiviswanathan Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 3c7d267f2a07b..d1ebae9519d6c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -111,7 +111,14 @@ #define KFD_KERNEL_QUEUE_SIZE 2048 -#define KFD_UNMAP_LATENCY_MS (4000) +/* KFD_UNMAP_LATENCY_MS is the timeout CP waiting for SDMA preemption. One XCC + * can be associated to 2 SDMA engines. queue_preemption_timeout_ms is the time + * driver waiting for CP returning the UNMAP_QUEUE fence. Thus the math is + * queue_preemption_timeout_ms = sdma_preemption_time * 2 + cp workload + * The format here makes CP workload 10% of total timeout + */ +#define KFD_UNMAP_LATENCY_MS \ + ((queue_preemption_timeout_ms - queue_preemption_timeout_ms / 10) >> 1) /* * 512 = 0x200 -- 2.51.0