drm/amdgpu: Fix the warning division or modulo by zero
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:30:22 +0000 (09:30 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:30:22 +0000 (09:30 +0000)
From Jesse Zhang
d116bb921e8b104f45d1f30a473ea99ef4262b9a in linux-6.6.y/6.6.50
1a00f2ac82d6bc6689388c7edcd2a4bd82664f3c in mainline linux

sys/dev/pci/drm/amd/amdgpu/aqua_vanjaram.c

index 0284c91..6c6f9d9 100644 (file)
@@ -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",