drm/atomic: cleanup debugfs entries on un-registering the driver.
diff mbox

Message ID 20161117114129.2627-1-Liviu.Dudau@arm.com
State New
Headers show

Commit Message

Liviu Dudau Nov. 17, 2016, 11:41 a.m. UTC
Cleanup the debugfs entries created by commit 6559c901cb48 when
the driver's minor gets un-registered. Without it, DRM drivers
compiled as modules cannot be rmmod-ed and modprobed again.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
---
 drivers/gpu/drm/drm_atomic.c  | 7 +++++++
 drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
 include/drm/drm_atomic.h      | 1 +
 3 files changed, 17 insertions(+)

Comments

Liviu Dudau Nov. 17, 2016, 11:45 a.m. UTC | #1
On Thu, Nov 17, 2016 at 11:41:29AM +0000, Liviu Dudau wrote:
> Cleanup the debugfs entries created by commit 6559c901cb48 when
> the driver's minor gets un-registered. Without it, DRM drivers
> compiled as modules cannot be rmmod-ed and modprobed again.

Bah, naughty of me: should've put the commit message too:

commit 6559c901cb48:  drm/atomic: add debugfs file to dump out atomic state

Also, cc-ing Sean Paul who pulled this first into drm-misc.

Best regards,
Liviu

> 
> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
> ---
>  drivers/gpu/drm/drm_atomic.c  | 7 +++++++
>  drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
>  include/drm/drm_atomic.h      | 1 +
>  3 files changed, 17 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 6773b35..dddf37a 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1681,6 +1681,13 @@ int drm_atomic_debugfs_init(struct drm_minor *minor)
>  			ARRAY_SIZE(drm_atomic_debugfs_list),
>  			minor->debugfs_root, minor);
>  }
> +
> +int drm_atomic_debugfs_cleanup(struct drm_minor *minor)
> +{
> +	return drm_debugfs_remove_files(drm_atomic_debugfs_list,
> +					ARRAY_SIZE(drm_atomic_debugfs_list),
> +					minor);
> +}
>  #endif
>  
>  /*
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index 206a4fe..2e3e46a 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -228,6 +228,7 @@ EXPORT_SYMBOL(drm_debugfs_remove_files);
>  int drm_debugfs_cleanup(struct drm_minor *minor)
>  {
>  	struct drm_device *dev = minor->dev;
> +	int ret;
>  
>  	if (!minor->debugfs_root)
>  		return 0;
> @@ -235,6 +236,14 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
>  	if (dev->driver->debugfs_cleanup)
>  		dev->driver->debugfs_cleanup(minor);
>  
> +	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
> +		ret = drm_atomic_debugfs_cleanup(minor);
> +		if (ret) {
> +			DRM_ERROR("DRM: Failed to remove atomic debugfs entries\n");
> +			return ret;
> +		}
> +	}
> +
>  	drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
>  
>  	debugfs_remove(minor->debugfs_root);
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 2409144..6400df0 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -374,6 +374,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  #ifdef CONFIG_DEBUG_FS
>  struct drm_minor;
>  int drm_atomic_debugfs_init(struct drm_minor *minor);
> +int drm_atomic_debugfs_cleanup(struct drm_minor *minor);
>  #endif
>  
>  #define for_each_connector_in_state(__state, connector, connector_state, __i) \
> -- 
> 2.10.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Brian Starkey Nov. 17, 2016, 12:26 p.m. UTC | #2
On Thu, Nov 17, 2016 at 11:41:29AM +0000, Liviu Dudau wrote:
>Cleanup the debugfs entries created by commit 6559c901cb48 when
>the driver's minor gets un-registered. Without it, DRM drivers
>compiled as modules cannot be rmmod-ed and modprobed again.
>
>Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>

Works for me,

Tested-by: Brian Starkey <brian.starkey@arm.com>

>---
> drivers/gpu/drm/drm_atomic.c  | 7 +++++++
> drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
> include/drm/drm_atomic.h      | 1 +
> 3 files changed, 17 insertions(+)
>
>diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>index 6773b35..dddf37a 100644
>--- a/drivers/gpu/drm/drm_atomic.c
>+++ b/drivers/gpu/drm/drm_atomic.c
>@@ -1681,6 +1681,13 @@ int drm_atomic_debugfs_init(struct drm_minor *minor)
> 			ARRAY_SIZE(drm_atomic_debugfs_list),
> 			minor->debugfs_root, minor);
> }
>+
>+int drm_atomic_debugfs_cleanup(struct drm_minor *minor)
>+{
>+	return drm_debugfs_remove_files(drm_atomic_debugfs_list,
>+					ARRAY_SIZE(drm_atomic_debugfs_list),
>+					minor);
>+}
> #endif
>
> /*
>diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
>index 206a4fe..2e3e46a 100644
>--- a/drivers/gpu/drm/drm_debugfs.c
>+++ b/drivers/gpu/drm/drm_debugfs.c
>@@ -228,6 +228,7 @@ EXPORT_SYMBOL(drm_debugfs_remove_files);
> int drm_debugfs_cleanup(struct drm_minor *minor)
> {
> 	struct drm_device *dev = minor->dev;
>+	int ret;
>
> 	if (!minor->debugfs_root)
> 		return 0;
>@@ -235,6 +236,14 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
> 	if (dev->driver->debugfs_cleanup)
> 		dev->driver->debugfs_cleanup(minor);
>
>+	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
>+		ret = drm_atomic_debugfs_cleanup(minor);
>+		if (ret) {
>+			DRM_ERROR("DRM: Failed to remove atomic debugfs entries\n");
>+			return ret;
>+		}
>+	}
>+
> 	drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
>
> 	debugfs_remove(minor->debugfs_root);
>diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
>index 2409144..6400df0 100644
>--- a/include/drm/drm_atomic.h
>+++ b/include/drm/drm_atomic.h
>@@ -374,6 +374,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> #ifdef CONFIG_DEBUG_FS
> struct drm_minor;
> int drm_atomic_debugfs_init(struct drm_minor *minor);
>+int drm_atomic_debugfs_cleanup(struct drm_minor *minor);
> #endif
>
> #define for_each_connector_in_state(__state, connector, connector_state, __i) \
>-- 
>2.10.0
>
Sean Paul Nov. 21, 2016, 6:23 p.m. UTC | #3
On Thu, Nov 17, 2016 at 7:26 AM, Brian Starkey <brian.starkey@arm.com> wrote:
> On Thu, Nov 17, 2016 at 11:41:29AM +0000, Liviu Dudau wrote:
>>
>> Cleanup the debugfs entries created by commit 6559c901cb48 when
>> the driver's minor gets un-registered. Without it, DRM drivers
>> compiled as modules cannot be rmmod-ed and modprobed again.
>>
>> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
>
>
> Works for me,
>
> Tested-by: Brian Starkey <brian.starkey@arm.com>
>

Applied to drm-misc

Thanks,

Sean

>
>> ---
>> drivers/gpu/drm/drm_atomic.c  | 7 +++++++
>> drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
>> include/drm/drm_atomic.h      | 1 +
>> 3 files changed, 17 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>> index 6773b35..dddf37a 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -1681,6 +1681,13 @@ int drm_atomic_debugfs_init(struct drm_minor
>> *minor)
>>                         ARRAY_SIZE(drm_atomic_debugfs_list),
>>                         minor->debugfs_root, minor);
>> }
>> +
>> +int drm_atomic_debugfs_cleanup(struct drm_minor *minor)
>> +{
>> +       return drm_debugfs_remove_files(drm_atomic_debugfs_list,
>> +
>> ARRAY_SIZE(drm_atomic_debugfs_list),
>> +                                       minor);
>> +}
>> #endif
>>
>> /*
>> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
>> index 206a4fe..2e3e46a 100644
>> --- a/drivers/gpu/drm/drm_debugfs.c
>> +++ b/drivers/gpu/drm/drm_debugfs.c
>> @@ -228,6 +228,7 @@ EXPORT_SYMBOL(drm_debugfs_remove_files);
>> int drm_debugfs_cleanup(struct drm_minor *minor)
>> {
>>         struct drm_device *dev = minor->dev;
>> +       int ret;
>>
>>         if (!minor->debugfs_root)
>>                 return 0;
>> @@ -235,6 +236,14 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
>>         if (dev->driver->debugfs_cleanup)
>>                 dev->driver->debugfs_cleanup(minor);
>>
>> +       if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
>> +               ret = drm_atomic_debugfs_cleanup(minor);
>> +               if (ret) {
>> +                       DRM_ERROR("DRM: Failed to remove atomic debugfs
>> entries\n");
>> +                       return ret;
>> +               }
>> +       }
>> +
>>         drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES,
>> minor);
>>
>>         debugfs_remove(minor->debugfs_root);
>> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
>> index 2409144..6400df0 100644
>> --- a/include/drm/drm_atomic.h
>> +++ b/include/drm/drm_atomic.h
>> @@ -374,6 +374,7 @@ void drm_state_dump(struct drm_device *dev, struct
>> drm_printer *p);
>> #ifdef CONFIG_DEBUG_FS
>> struct drm_minor;
>> int drm_atomic_debugfs_init(struct drm_minor *minor);
>> +int drm_atomic_debugfs_cleanup(struct drm_minor *minor);
>> #endif
>>
>> #define for_each_connector_in_state(__state, connector, connector_state,
>> __i) \
>> --
>> 2.10.0
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 6773b35..dddf37a 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1681,6 +1681,13 @@  int drm_atomic_debugfs_init(struct drm_minor *minor)
 			ARRAY_SIZE(drm_atomic_debugfs_list),
 			minor->debugfs_root, minor);
 }
+
+int drm_atomic_debugfs_cleanup(struct drm_minor *minor)
+{
+	return drm_debugfs_remove_files(drm_atomic_debugfs_list,
+					ARRAY_SIZE(drm_atomic_debugfs_list),
+					minor);
+}
 #endif
 
 /*
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 206a4fe..2e3e46a 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -228,6 +228,7 @@  EXPORT_SYMBOL(drm_debugfs_remove_files);
 int drm_debugfs_cleanup(struct drm_minor *minor)
 {
 	struct drm_device *dev = minor->dev;
+	int ret;
 
 	if (!minor->debugfs_root)
 		return 0;
@@ -235,6 +236,14 @@  int drm_debugfs_cleanup(struct drm_minor *minor)
 	if (dev->driver->debugfs_cleanup)
 		dev->driver->debugfs_cleanup(minor);
 
+	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
+		ret = drm_atomic_debugfs_cleanup(minor);
+		if (ret) {
+			DRM_ERROR("DRM: Failed to remove atomic debugfs entries\n");
+			return ret;
+		}
+	}
+
 	drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
 
 	debugfs_remove(minor->debugfs_root);
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 2409144..6400df0 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -374,6 +374,7 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 #ifdef CONFIG_DEBUG_FS
 struct drm_minor;
 int drm_atomic_debugfs_init(struct drm_minor *minor);
+int drm_atomic_debugfs_cleanup(struct drm_minor *minor);
 #endif
 
 #define for_each_connector_in_state(__state, connector, connector_state, __i) \