diff mbox series

[v5,13/13] drm/ast: Automatically clean up poll helper

Message ID 20240320093738.6341-14-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/ast: Detect connector status for VGA and SIL164 | expand

Commit Message

Thomas Zimmermann March 20, 2024, 9:34 a.m. UTC
Automatically clean up the conncetor-poll thread as part of the DRM
device release. The new helper drmm_kms_helper_poll_init() provides
a shared implementation for all drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_mode.c     |  4 +++-
 drivers/gpu/drm/drm_probe_helper.c | 27 +++++++++++++++++++++++++++
 include/drm/drm_probe_helper.h     |  2 ++
 3 files changed, 32 insertions(+), 1 deletion(-)

Comments

kernel test robot March 21, 2024, 8:22 a.m. UTC | #1
Hi Thomas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.8 next-20240320]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-ast-Include-linux-of-h-where-necessary/20240320-174013
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240320093738.6341-14-tzimmermann%40suse.de
patch subject: [PATCH v5 13/13] drm/ast: Automatically clean up poll helper
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20240321/202403211604.aM8tDovD-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240321/202403211604.aM8tDovD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403211604.aM8tDovD-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_probe_helper.c:965: warning: expecting prototype for devm_drm_kms_helper_poll_init(). Prototype was for drmm_kms_helper_poll_init() instead


vim +965 drivers/gpu/drm/drm_probe_helper.c

   950	
   951	/**
   952	 * devm_drm_kms_helper_poll_init - initialize and enable output polling
   953	 * @dev: drm_device
   954	 *
   955	 * This function initializes and then also enables output polling support for
   956	 * @dev similar to drm_kms_helper_poll_init(). Polling will automatically be
   957	 * cleaned up when the DRM device goes away.
   958	 *
   959	 * See drm_kms_helper_poll_init() for more information.
   960	 *
   961	 * Returns:
   962	 * 0 on success, or a negative errno code otherwise.
   963	 */
   964	int drmm_kms_helper_poll_init(struct drm_device *dev)
 > 965	{
   966		drm_kms_helper_poll_init(dev);
   967	
   968		return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
   969	}
   970	EXPORT_SYMBOL(drmm_kms_helper_poll_init);
   971
Sui Jingfeng March 21, 2024, 9 a.m. UTC | #2
Hi,


On 2024/3/20 17:34, Thomas Zimmermann wrote:
> Automatically clean up the conncetor-poll thread as part of the DRM
> device release. The new helper drmm_kms_helper_poll_init() provides
> a shared implementation for all drivers.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>


Nice feature!

It seems that drm/loongson forget to calldrm_kms_helper_poll_fini() on driver leave, Opps.


Acked-by: Sui Jingfeng <sui.jingfeng@linux.dev>



> ---
>   drivers/gpu/drm/ast/ast_mode.c     |  4 +++-
>   drivers/gpu/drm/drm_probe_helper.c | 27 +++++++++++++++++++++++++++
>   include/drm/drm_probe_helper.h     |  2 ++
>   3 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index a42a0956c51de..7e56a77bed635 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1905,7 +1905,9 @@ int ast_mode_config_init(struct ast_device *ast)
>   
>   	drm_mode_config_reset(dev);
>   
> -	drm_kms_helper_poll_init(dev);
> +	ret = drmm_kms_helper_poll_init(dev);
> +	if (ret)
> +		return ret;
>   
>   	return 0;
>   }
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index b06dcc6c614e8..a39c98ceac68a 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -37,6 +37,7 @@
>   #include <drm/drm_crtc.h>
>   #include <drm/drm_edid.h>
>   #include <drm/drm_fourcc.h>
> +#include <drm/drm_managed.h>
>   #include <drm/drm_modeset_helper_vtables.h>
>   #include <drm/drm_print.h>
>   #include <drm/drm_probe_helper.h>
> @@ -944,6 +945,32 @@ void drm_kms_helper_poll_fini(struct drm_device *dev)
>   }
>   EXPORT_SYMBOL(drm_kms_helper_poll_fini);
>   
> +static void drm_kms_helper_poll_init_release(struct drm_device *dev, void *res)
> +{
> +	drm_kms_helper_poll_fini(dev);
> +}
> +
> +/**
> + * devm_drm_kms_helper_poll_init - initialize and enable output polling
> + * @dev: drm_device
> + *
> + * This function initializes and then also enables output polling support for
> + * @dev similar to drm_kms_helper_poll_init(). Polling will automatically be
> + * cleaned up when the DRM device goes away.
> + *
> + * See drm_kms_helper_poll_init() for more information.
> + *
> + * Returns:
> + * 0 on success, or a negative errno code otherwise.
> + */
> +int drmm_kms_helper_poll_init(struct drm_device *dev)
> +{
> +	drm_kms_helper_poll_init(dev);
> +
> +	return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
> +}
> +EXPORT_SYMBOL(drmm_kms_helper_poll_init);
> +
>   static bool check_connector_changed(struct drm_connector *connector)
>   {
>   	struct drm_device *dev = connector->dev;
> diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h
> index 031b044528c89..9925cff749296 100644
> --- a/include/drm/drm_probe_helper.h
> +++ b/include/drm/drm_probe_helper.h
> @@ -16,6 +16,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector
>   int drm_helper_probe_detect(struct drm_connector *connector,
>   			    struct drm_modeset_acquire_ctx *ctx,
>   			    bool force);
> +
> +int drmm_kms_helper_poll_init(struct drm_device *dev);
>   void drm_kms_helper_poll_init(struct drm_device *dev);
>   void drm_kms_helper_poll_fini(struct drm_device *dev);
>   bool drm_helper_hpd_irq_event(struct drm_device *dev);
Thomas Zimmermann March 21, 2024, 9:57 a.m. UTC | #3
Hi

Am 21.03.24 um 10:00 schrieb Sui Jingfeng:
> Hi,
>
>
> On 2024/3/20 17:34, Thomas Zimmermann wrote:
>> Automatically clean up the conncetor-poll thread as part of the DRM
>> device release. The new helper drmm_kms_helper_poll_init() provides
>> a shared implementation for all drivers.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>
>
> Nice feature!
>
> It seems that drm/loongson forget to calldrm_kms_helper_poll_fini() on 
> driver leave, Opps.

Indeed. I'm surprised that this never blew up with ast. Without _fini(), 
the polling thread would likely run on a stale DRM device. We only 
release the device during shutdown and I guess it doesn't make 
difference then.

Best regards
Thomas

>
>
> Acked-by: Sui Jingfeng <sui.jingfeng@linux.dev>
>
>
>
>> ---
>>   drivers/gpu/drm/ast/ast_mode.c     |  4 +++-
>>   drivers/gpu/drm/drm_probe_helper.c | 27 +++++++++++++++++++++++++++
>>   include/drm/drm_probe_helper.h     |  2 ++
>>   3 files changed, 32 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ast/ast_mode.c 
>> b/drivers/gpu/drm/ast/ast_mode.c
>> index a42a0956c51de..7e56a77bed635 100644
>> --- a/drivers/gpu/drm/ast/ast_mode.c
>> +++ b/drivers/gpu/drm/ast/ast_mode.c
>> @@ -1905,7 +1905,9 @@ int ast_mode_config_init(struct ast_device *ast)
>>         drm_mode_config_reset(dev);
>>   -    drm_kms_helper_poll_init(dev);
>> +    ret = drmm_kms_helper_poll_init(dev);
>> +    if (ret)
>> +        return ret;
>>         return 0;
>>   }
>> diff --git a/drivers/gpu/drm/drm_probe_helper.c 
>> b/drivers/gpu/drm/drm_probe_helper.c
>> index b06dcc6c614e8..a39c98ceac68a 100644
>> --- a/drivers/gpu/drm/drm_probe_helper.c
>> +++ b/drivers/gpu/drm/drm_probe_helper.c
>> @@ -37,6 +37,7 @@
>>   #include <drm/drm_crtc.h>
>>   #include <drm/drm_edid.h>
>>   #include <drm/drm_fourcc.h>
>> +#include <drm/drm_managed.h>
>>   #include <drm/drm_modeset_helper_vtables.h>
>>   #include <drm/drm_print.h>
>>   #include <drm/drm_probe_helper.h>
>> @@ -944,6 +945,32 @@ void drm_kms_helper_poll_fini(struct drm_device 
>> *dev)
>>   }
>>   EXPORT_SYMBOL(drm_kms_helper_poll_fini);
>>   +static void drm_kms_helper_poll_init_release(struct drm_device 
>> *dev, void *res)
>> +{
>> +    drm_kms_helper_poll_fini(dev);
>> +}
>> +
>> +/**
>> + * devm_drm_kms_helper_poll_init - initialize and enable output polling
>> + * @dev: drm_device
>> + *
>> + * This function initializes and then also enables output polling 
>> support for
>> + * @dev similar to drm_kms_helper_poll_init(). Polling will 
>> automatically be
>> + * cleaned up when the DRM device goes away.
>> + *
>> + * See drm_kms_helper_poll_init() for more information.
>> + *
>> + * Returns:
>> + * 0 on success, or a negative errno code otherwise.
>> + */
>> +int drmm_kms_helper_poll_init(struct drm_device *dev)
>> +{
>> +    drm_kms_helper_poll_init(dev);
>> +
>> +    return drmm_add_action_or_reset(dev, 
>> drm_kms_helper_poll_init_release, dev);
>> +}
>> +EXPORT_SYMBOL(drmm_kms_helper_poll_init);
>> +
>>   static bool check_connector_changed(struct drm_connector *connector)
>>   {
>>       struct drm_device *dev = connector->dev;
>> diff --git a/include/drm/drm_probe_helper.h 
>> b/include/drm/drm_probe_helper.h
>> index 031b044528c89..9925cff749296 100644
>> --- a/include/drm/drm_probe_helper.h
>> +++ b/include/drm/drm_probe_helper.h
>> @@ -16,6 +16,8 @@ int drm_helper_probe_single_connector_modes(struct 
>> drm_connector
>>   int drm_helper_probe_detect(struct drm_connector *connector,
>>                   struct drm_modeset_acquire_ctx *ctx,
>>                   bool force);
>> +
>> +int drmm_kms_helper_poll_init(struct drm_device *dev);
>>   void drm_kms_helper_poll_init(struct drm_device *dev);
>>   void drm_kms_helper_poll_fini(struct drm_device *dev);
>>   bool drm_helper_hpd_irq_event(struct drm_device *dev);
>
Sui Jingfeng March 21, 2024, 8:57 p.m. UTC | #4
Hi,


On 2024/3/20 17:34, Thomas Zimmermann wrote:



> +
> +/**
> + * devm_drm_kms_helper_poll_init - initialize and enable output polling

Should be drmm_kms_helper_poll_init() here.

> + * @dev: drm_device
> + *
> + * This function initializes and then also enables output polling support for
> + * @dev similar to drm_kms_helper_poll_init(). Polling will automatically be
> + * cleaned up when the DRM device goes away.
> + *
> + * See drm_kms_helper_poll_init() for more information.
> + *
> + * Returns:
> + * 0 on success, or a negative errno code otherwise.
> + */
> +int drmm_kms_helper_poll_init(struct drm_device *dev)
> +{
> +	drm_kms_helper_poll_init(dev);
> +
> +	return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
> +}
> +EXPORT_SYMBOL(drmm_kms_helper_poll_init);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index a42a0956c51de..7e56a77bed635 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1905,7 +1905,9 @@  int ast_mode_config_init(struct ast_device *ast)
 
 	drm_mode_config_reset(dev);
 
-	drm_kms_helper_poll_init(dev);
+	ret = drmm_kms_helper_poll_init(dev);
+	if (ret)
+		return ret;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index b06dcc6c614e8..a39c98ceac68a 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -37,6 +37,7 @@ 
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_fourcc.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
@@ -944,6 +945,32 @@  void drm_kms_helper_poll_fini(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_kms_helper_poll_fini);
 
+static void drm_kms_helper_poll_init_release(struct drm_device *dev, void *res)
+{
+	drm_kms_helper_poll_fini(dev);
+}
+
+/**
+ * devm_drm_kms_helper_poll_init - initialize and enable output polling
+ * @dev: drm_device
+ *
+ * This function initializes and then also enables output polling support for
+ * @dev similar to drm_kms_helper_poll_init(). Polling will automatically be
+ * cleaned up when the DRM device goes away.
+ *
+ * See drm_kms_helper_poll_init() for more information.
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise.
+ */
+int drmm_kms_helper_poll_init(struct drm_device *dev)
+{
+	drm_kms_helper_poll_init(dev);
+
+	return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
+}
+EXPORT_SYMBOL(drmm_kms_helper_poll_init);
+
 static bool check_connector_changed(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h
index 031b044528c89..9925cff749296 100644
--- a/include/drm/drm_probe_helper.h
+++ b/include/drm/drm_probe_helper.h
@@ -16,6 +16,8 @@  int drm_helper_probe_single_connector_modes(struct drm_connector
 int drm_helper_probe_detect(struct drm_connector *connector,
 			    struct drm_modeset_acquire_ctx *ctx,
 			    bool force);
+
+int drmm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_fini(struct drm_device *dev);
 bool drm_helper_hpd_irq_event(struct drm_device *dev);