From: jsg Date: Mon, 9 Sep 2024 09:30:22 +0000 (+0000) Subject: drm/amdgpu: Fix the warning division or modulo by zero X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f926a68b5c7b450eb425177d879d399faf8535c2;p=openbsd drm/amdgpu: Fix the warning division or modulo by zero From Jesse Zhang d116bb921e8b104f45d1f30a473ea99ef4262b9a in linux-6.6.y/6.6.50 1a00f2ac82d6bc6689388c7edcd2a4bd82664f3c in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/aqua_vanjaram.c b/sys/dev/pci/drm/amd/amdgpu/aqua_vanjaram.c index 0284c9198a0..6c6f9d9b5d8 100644 --- a/sys/dev/pci/drm/amd/amdgpu/aqua_vanjaram.c +++ b/sys/dev/pci/drm/amd/amdgpu/aqua_vanjaram.c @@ -500,6 +500,12 @@ static int aqua_vanjaram_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, if (mode == AMDGPU_AUTO_COMPUTE_PARTITION_MODE) { mode = __aqua_vanjaram_get_auto_mode(xcp_mgr); + if (mode == AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE) { + dev_err(adev->dev, + "Invalid config, no compatible compute partition mode found, available memory partitions: %d", + adev->gmc.num_mem_partitions); + return -EINVAL; + } } else if (!__aqua_vanjaram_is_valid_mode(xcp_mgr, mode)) { dev_err(adev->dev, "Invalid compute partition mode requested, requested: %s, available memory partitions: %d",