From nobody Tue Dec 2 02:31:04 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 6A55C32B9A6 for ; Wed, 19 Nov 2025 22:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; cv=none; b=msnHuKAgBnr5WTLFRPNFnalp5czD5NNMkpmbeDhafv3QLxi6AXyFW/NaPw4ASK6oCkPwXZ6ezEYHpvS1D+hZlqxLx1Rmpnejoi6tcRrWQ9YOsKrWgtDqWMmEDD2Or9JX1N+VFuBlvNY1Ulhfk7yu8/DL+tOF4loRe8FOxOnLVSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592166; c=relaxed/simple; bh=xCLv9FusCE6yLnQm5DohNUGPMWTDyVxGTMHgjF2cXEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vvgk0KaxiHQfqksTpvUgqBN1LDvf7CwKeR8A0dPXmTHWpmCDXNArWiuD2YuDmpBdHj+bsdnoPd37EV06KsPfbGAJ6s5bjs7aB7kjtHaknI+Vu25rI+TLyyYz5BRdYzYHkSnEcCPKKLsMpUHNhlgb8PIHVEuz/Y1K6Oe2WhFS8z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mDlHjQLr; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mDlHjQLr" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsl-006yoa-LL; Wed, 19 Nov 2025 23:42:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=KZaeZLqE5bpE2oI7JueUUAQfCDTGIs3rJJZPcaqXWlw=; b=mDlHjQLr3ylsbhaToLWMaW21yW 3UVy21XkacH0+aMXmbQJGgcaEEUcpaPdkWRfbeLgpnQWeuE5UazmtfWFCAxw4PAywzYxbWcWRE5wi yydZf/9QgusRj2ZIM70TwSLTYD0H8U34DcCttEXjGzQbWV1vIw2D5mA1dbb/AfJUSZxy0gC0UxGzm 3mhsqOossZ8FbtNoL7e/1hiK5mJJTtkE/SebrhXQF2cSm2NHVTf/4d9Tp7280RfRfVkSEXjg0swpr Gkjt72YT776jjIc8yqIXhdAFDxwNP31J3hEXpaDULau580GcJrDs4cTQLlPfzOIXGaBPL2mH0NWnz RW6tI2CQ==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsk-00005F-RE; Wed, 19 Nov 2025 23:42:35 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsd-00Fos6-R9; Wed, 19 Nov 2025 23:42:27 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Harry Wentland , Leo Li , Simona Vetter , David Laight Subject: [PATCH 19/44] drivers/gpu/drm/amd: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:15 +0000 Message-Id: <20251119224140.8616-20-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. min_t(u8, a, b) is particularly likely to be problematic In this case I think the values are small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c b/drivers/gpu= /drm/amd/amdgpu/amdgpu_doorbell_mgr.c index 3040437d99c2..1eb88327a18b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c @@ -211,8 +211,8 @@ int amdgpu_doorbell_init(struct amdgpu_device *adev) adev->doorbell.size =3D pci_resource_len(adev->pdev, 2); =20 adev->doorbell.num_kernel_doorbells =3D - min_t(u32, adev->doorbell.size / sizeof(u32), - adev->doorbell_index.max_assignment + 1); + min(adev->doorbell.size / sizeof(u32), + adev->doorbell_index.max_assignment + 1); if (adev->doorbell.num_kernel_doorbells =3D=3D 0) return -EINVAL; =20 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/a= mdgpu/amdgpu_vm.c index c1a801203949..124ce3e7310e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2388,7 +2388,7 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev= , uint32_t min_vm_size, if (amdgpu_vm_block_size !=3D -1) tmp >>=3D amdgpu_vm_block_size - 9; tmp =3D DIV_ROUND_UP(fls64(tmp) - 1, 9) - 1; - adev->vm_manager.num_level =3D min_t(unsigned int, max_level, tmp); + adev->vm_manager.num_level =3D min(max_level, tmp); switch (adev->vm_manager.num_level) { case 3: adev->vm_manager.root_level =3D AMDGPU_VM_PDB2; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gp= u/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 91c0188a29b2..0180675e76a4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6257,7 +6257,7 @@ convert_color_depth_from_display_info(const struct dr= m_connector *connector, * or if this was called outside of atomic check, so it * can't be used directly. */ - bpc =3D min_t(u8, bpc, requested_bpc); + bpc =3D umin(bpc, requested_bpc); =20 /* Round down to the nearest even number. */ bpc =3D bpc - (bpc & 1); --=20 2.39.5