Skip to contentSkip to conversation

drm/amd/amdgpu: cleanup coding style a bit

PATCH In review Bernard Zhao 4 participants 5 messages May 7, 2020 – May 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd/amdgpu: cleanup coding style a bit

There is DEVICE_ATTR mechanism in separate attribute define. So this change is to use attr array, also use sysfs_create_files in init function & sysfs_remove_files in fini function.
This maybe make the code a bit readable.

Changes since V1:
*Use DEVICE_ATTR mechanism

Link for V1:
*https://lore.kernel.org/patchwork/patch/1228076/

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++--------------
 1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +13 -30
index 82a3299e53c0..57bbc70662ff 100644
@@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used, S_IRUGO,
 static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
 		   amdgpu_mem_info_vram_vendor, NULL);
 
+static struct attribute *amdgpu_vram_mgr_attributes[] = {
+	&dev_attr_mem_info_vram_total.attr,
+	&dev_attr_mem_info_vis_vram_total.attr,
+	&dev_attr_mem_info_vram_used.attr,
+	&dev_attr_mem_info_vis_vram_used.attr,
+	&dev_attr_mem_info_vram_vendor.attr,
+	NULL
+};
+
 /**
  * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
  *
@@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
 	man->priv = mgr;
 
 	/* Add the two VRAM-related sysfs files */
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
-		return ret;
-	}
+	ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
+	if (ret)
+		DRM_ERROR("Failed to register sysfs\n");
 
 	return 0;
 }
@@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
 	spin_unlock(&mgr->lock);
 	kfree(mgr);
 	man->priv = NULL;
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_vendor);
+	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
 	return 0;
 }
 
Signature · 1 line
2.26.2
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 07.05.20 um 11:13 schrieb Bernard Zhao:

Quoted 7 lines

There is DEVICE_ATTR mechanism in separate attribute define. So this change is to use attr array, also use sysfs_create_files in init function & sysfs_remove_files in fini function.
This maybe make the code a bit readable.

Quoted 68 lines

Changes since V1:
*Use DEVICE_ATTR mechanism

Link for V1:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1228076%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7C073b9043be5346b3c90c08d7f266e6fb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637244396096735223&sdata=PjFsYvmw2pvVisZ6TzMqOyoSr0m3DsFN%2F0q%2B%2FfBxACg%3D&reserved=0

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++--------------
  1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +12 -25
index 82a3299e53c0..57bbc70662ff 100644
@@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used, S_IRUGO,
  static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
  		   amdgpu_mem_info_vram_vendor, NULL);
 
+static struct attribute *amdgpu_vram_mgr_attributes[] = {
+	&dev_attr_mem_info_vram_total.attr,
+	&dev_attr_mem_info_vis_vram_total.attr,
+	&dev_attr_mem_info_vram_used.attr,
+	&dev_attr_mem_info_vis_vram_used.attr,
+	&dev_attr_mem_info_vram_vendor.attr,
+	NULL
+};
+
  /**
   * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
   *
@@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
  	man->priv = mgr;
 
  	/* Add the two VRAM-related sysfs files */
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
-	if (ret) {
-		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
-		return ret;
-	}
+	ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
+	if (ret)
+		DRM_ERROR("Failed to register sysfs\n");
 
  	return 0;
  }
@@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
  	spin_unlock(&mgr->lock);
  	kfree(mgr);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man) · line 212

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -5
  	man->priv = NULL;
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_vendor);
+	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
  	return 0;
  }
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
Quoted 8 lines · Christian König

Am 07.05.20 um 11:13 schrieb Bernard Zhao:

Quoted 6 lines

There is DEVICE_ATTR mechanism in separate attribute define. So this change is to use attr array, also use sysfs_create_files in init function & sysfs_remove_files in fini function.
This maybe make the code a bit readable.

Quoted 4 lines
Quoted 1 line

Applied with a minor change to make the array const to fix the build.

Alex

Quoted 75 lines
Quoted 75 lines

Changes since V1:
*Use DEVICE_ATTR mechanism

Link for V1:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1228076%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7C073b9043be5346b3c90c08d7f266e6fb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637244396096735223&sdata=PjFsYvmw2pvVisZ6TzMqOyoSr0m3DsFN%2F0q%2B%2FfBxACg%3D&reserved=0

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++--------------
  1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +13 -30
index 82a3299e53c0..57bbc70662ff 100644
@@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used, S_IRUGO,
  static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
                 amdgpu_mem_info_vram_vendor, NULL);
 
+static struct attribute *amdgpu_vram_mgr_attributes[] = {
+     &dev_attr_mem_info_vram_total.attr,
+     &dev_attr_mem_info_vis_vram_total.attr,
+     &dev_attr_mem_info_vram_used.attr,
+     &dev_attr_mem_info_vis_vram_used.attr,
+     &dev_attr_mem_info_vram_vendor.attr,
+     NULL
+};
+
  /**
   * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
   *
@@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
      man->priv = mgr;
 
      /* Add the two VRAM-related sysfs files */
-     ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
-     if (ret) {
-             DRM_ERROR("Failed to create device file mem_info_vram_total\n");
-             return ret;
-     }
-     ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-     if (ret) {
-             DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
-             return ret;
-     }
-     ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
-     if (ret) {
-             DRM_ERROR("Failed to create device file mem_info_vram_used\n");
-             return ret;
-     }
-     ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-     if (ret) {
-             DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
-             return ret;
-     }
-     ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
-     if (ret) {
-             DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
-             return ret;
-     }
+     ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
+     if (ret)
+             DRM_ERROR("Failed to register sysfs\n");
 
      return 0;
  }
@@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
      spin_unlock(&mgr->lock);
      kfree(mgr);
      man->priv = NULL;
-     device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
-     device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
-     device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
-     device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
-     device_remove_file(adev->dev, &dev_attr_mem_info_vram_vendor);
+     sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man) · line 212

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -0
      return 0;
  }
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Acked-by on v2 1/1
#3 lore raw
In reply to Bernard Zhao
Quoted 96 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Bernard Zhao
Sent: Thursday, May 7, 2020 5:13 AM
To: Alex Deucher <[email protected]>; Christian König <[email protected]>; David (ChunMing) Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Tom St Denis <[email protected]>; Sam Ravnborg <[email protected]>; Ori Messinger <[email protected]>; Bernard Zhao <[email protected]>; [email protected]; dri- [email protected]; [email protected]
Cc: [email protected]
Subject: [PATCH v2] drm/amd/amdgpu: cleanup coding style a bit

There is DEVICE_ATTR mechanism in separate attribute define. So this change is to use attr array, also use sysfs_create_files in init function & sysfs_remove_files in fini function.
This maybe make the code a bit readable.

Changes since V1:
*Use DEVICE_ATTR mechanism

Link for V1:
*https://lore.kernel.org/patchwork/patch/1228076/
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++------------- -

1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +9 -0
index 82a3299e53c0..57bbc70662ff 100644
@@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used,
 S_IRUGO,
 static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
 		   amdgpu_mem_info_vram_vendor, NULL);
 
+static struct attribute *amdgpu_vram_mgr_attributes[] = {
+	&dev_attr_mem_info_vram_total.attr,
+	&dev_attr_mem_info_vis_vram_total.attr,
+	&dev_attr_mem_info_vram_used.attr,
+	&dev_attr_mem_info_vis_vram_used.attr,
+	&dev_attr_mem_info_vram_vendor.attr,
+	NULL
+};
+
 /**
 * amdgpu_vram_mgr_init - init VRAM manager and DRM MM

*

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -13
@@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct
 ttm_mem_type_manager *man,
 	man->priv = mgr;
 
 	/* Add the two VRAM-related sysfs files */
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file
 mem_info_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vis_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file
 mem_info_vis_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vram_used\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -3
-		return ret;
-	}
-	ret = device_create_file(adev->dev,

&dev_attr_mem_info_vis_vram_used);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -2
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vis_vram_used\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -3
-		return ret;
-	}
-	ret = device_create_file(adev->dev,

&dev_attr_mem_info_vram_vendor);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -2
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vram_vendor\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -2
-		return ret;
-	}
+	ret = sysfs_create_files(&adev->dev->kobj,

amdgpu_vram_mgr_attributes);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man, · line 186

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2 -0
+	if (ret)
+		DRM_ERROR("Failed to register sysfs\n");

This looks good to me.

I think that there is a new error macro (drm_err?) that you might want to use instead of DRM_ERROR().

Otherwise:

m

Quoted 21 lines
	return 0;
}
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -5
@@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct
 ttm_mem_type_manager *man)
 	spin_unlock(&mgr->lock);
 	kfree(mgr);
 	man->priv = NULL;
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
-	device_remove_file(adev->dev,
 &dev_attr_mem_info_vis_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
-	device_remove_file(adev->dev,
 &dev_attr_mem_info_vis_vram_used);
-	device_remove_file(adev->dev,

&dev_attr_mem_info_vram_vendor);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -0
+	sysfs_remove_files(&adev->dev->kobj,
amdgpu_vram_mgr_attributes);
	return 0;
}
Quoted 7 lines

--
2.26.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#4 lore raw

发件人:"Ruhl, Michael J" <[email protected]>
发送日期:2020-05-08 23:45:07
收件人:Bernard Zhao <[email protected]>,Alex Deucher <[email protected]>,"Christian König" <[email protected]>,"David (ChunMing) Zhou" <[email protected]>,David Airlie <[email protected]>,Daniel Vetter <[email protected]>,Tom St Denis <[email protected]>,Sam Ravnborg <[email protected]>,Ori Messinger <[email protected]>,"[email protected]" <[email protected]>,"[email protected]" <[email protected]>,"[email protected]" <[email protected]> 抄送人:"[email protected]" <[email protected]>
主题:RE: [PATCH v2] drm/amd/amdgpu: cleanup coding style a bit>>-----Original Message-----

Quoted 100 lines
Quoted 95 lines

From: dri-devel <[email protected]> On Behalf Of Bernard Zhao
Sent: Thursday, May 7, 2020 5:13 AM
To: Alex Deucher <[email protected]>; Christian König <[email protected]>; David (ChunMing) Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Tom St Denis <[email protected]>; Sam Ravnborg <[email protected]>; Ori Messinger <[email protected]>; Bernard Zhao <[email protected]>; [email protected]; dri- [email protected]; [email protected]
Cc: [email protected]
Subject: [PATCH v2] drm/amd/amdgpu: cleanup coding style a bit

There is DEVICE_ATTR mechanism in separate attribute define. So this change is to use attr array, also use sysfs_create_files in init function & sysfs_remove_files in fini function.
This maybe make the code a bit readable.

Changes since V1:
*Use DEVICE_ATTR mechanism

Link for V1:
*https://lore.kernel.org/patchwork/patch/1228076/
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++------------- -

1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +9 -0
index 82a3299e53c0..57bbc70662ff 100644
@@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used,
 S_IRUGO,
 static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
 		   amdgpu_mem_info_vram_vendor, NULL);
 
+static struct attribute *amdgpu_vram_mgr_attributes[] = {
+	&dev_attr_mem_info_vram_total.attr,
+	&dev_attr_mem_info_vis_vram_total.attr,
+	&dev_attr_mem_info_vram_used.attr,
+	&dev_attr_mem_info_vis_vram_used.attr,
+	&dev_attr_mem_info_vram_vendor.attr,
+	NULL
+};
+
 /**
 * amdgpu_vram_mgr_init - init VRAM manager and DRM MM

*

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -13
@@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct
 ttm_mem_type_manager *man,
 	man->priv = mgr;
 
 	/* Add the two VRAM-related sysfs files */
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file
 mem_info_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vis_vram_total);
-	if (ret) {
-		DRM_ERROR("Failed to create device file
 mem_info_vis_vram_total\n");
-		return ret;
-	}
-	ret = device_create_file(adev->dev,
 &dev_attr_mem_info_vram_used);
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vram_used\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -3
-		return ret;
-	}
-	ret = device_create_file(adev->dev,

&dev_attr_mem_info_vis_vram_used);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -2
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vis_vram_used\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -3
-		return ret;
-	}
-	ret = device_create_file(adev->dev,

&dev_attr_mem_info_vram_vendor);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -2
-	if (ret) {
-		DRM_ERROR("Failed to create device file

mem_info_vram_vendor\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -2
-		return ret;
-	}
+	ret = sysfs_create_files(&adev->dev->kobj,

amdgpu_vram_mgr_attributes);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man, · line 186

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2 -0
+	if (ret)
+		DRM_ERROR("Failed to register sysfs\n");

This looks good to me.

Quoted 8 lines

I think that there is a new error macro (drm_err?) that you might want to use instead of DRM_ERROR().

Otherwise:

m

Hi
Sure, I am willing to make this modification, also in GPU TODO list, there is one content:
"Convert logging to drm_* functions with drm_device paramater,For drivers which could have multiple instances, it is necessary to differentiate between which is which in the logs. Since DRM_INFO/WARN/ERROR don’t do this, drivers used dev_info/warn/err to make this differentiation. We now have drm_* variants of the drm print functions, so we can start to convert those drivers back to using drm-formatted specific log messages." From https://www.kernel.org/doc/html/v5.7-rc5/gpu/todo.html#subsystem-wide-refactorings.

But i have to say that now in the DRM/AMD modules, all are used DRM_INFO/WARNING/ERROR I'm not sure weather maintainers want to replace these.

Regards,
Bernard

Quoted 28 lines
Quoted 28 lines
	return 0;
}
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0 -5
@@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct
 ttm_mem_type_manager *man)
 	spin_unlock(&mgr->lock);
 	kfree(mgr);
 	man->priv = NULL;
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
-	device_remove_file(adev->dev,
 &dev_attr_mem_info_vis_vram_total);
-	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
-	device_remove_file(adev->dev,
 &dev_attr_mem_info_vis_vram_used);
-	device_remove_file(adev->dev,

&dev_attr_mem_info_vram_vendor);

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -0
+	sysfs_remove_files(&adev->dev->kobj,
amdgpu_vram_mgr_attributes);
	return 0;
}

--
2.26.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel