]> git.ipfire.org Git - people/ms/linux.git/commitdiff
drm/amdgpu: simplify nv and soc21 read_register functions
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 5 May 2022 03:24:00 +0000 (23:24 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 May 2022 20:56:57 +0000 (16:56 -0400)
Check of the base offset for the IP exists rather than
explicitly checking for how many instances of a particular
IP there are.  This is what soc15.c already does.  Expand
this to nv.c and soc21.c.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/soc21.c

index 8ecfd66c4cee6847ca86d0d44741a14e82da9702..d016e3c3e221f80eb00e048173bac592dc4f61ca 100644 (file)
@@ -392,9 +392,9 @@ static int nv_read_register(struct amdgpu_device *adev, u32 se_num,
        *value = 0;
        for (i = 0; i < ARRAY_SIZE(nv_allowed_read_registers); i++) {
                en = &nv_allowed_read_registers[i];
-               if ((i == 7 && (adev->sdma.num_instances == 1)) || /* some asics don't have SDMA1 */
-                   reg_offset !=
-                   (adev->reg_offset[en->hwip][en->inst][en->seg] + en->reg_offset))
+               if (adev->reg_offset[en->hwip][en->inst] &&
+                   reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+                                  + en->reg_offset))
                        continue;
 
                *value = nv_get_register_value(adev,
index cfe5d12b180beb041e8ffa7f7e2d0598c1dcb807..741ed3ba84d645270f4672a5a3a9b3b4453c9b03 100644 (file)
@@ -252,9 +252,9 @@ static int soc21_read_register(struct amdgpu_device *adev, u32 se_num,
        *value = 0;
        for (i = 0; i < ARRAY_SIZE(soc21_allowed_read_registers); i++) {
                en = &soc21_allowed_read_registers[i];
-               if ((i == 7 && (adev->sdma.num_instances == 1)) || /* some asics don't have SDMA1 */
-                       reg_offset !=
-                       (adev->reg_offset[en->hwip][en->inst][en->seg] + en->reg_offset))
+               if (adev->reg_offset[en->hwip][en->inst] &&
+                   reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+                                  + en->reg_offset))
                        continue;
 
                *value = soc21_get_register_value(adev,