All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
@ 2021-11-03 12:32 ` Javier Martinez Canillas
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2021-11-03 12:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pekka Paalanen, Thomas Zimmermann, Peter Robinson, Daniel Vetter,
	Neal Gompa, Michel Dänzer, David Airlie, Maarten Lankhorst,
	Maxime Ripard, dri-devel, Javier Martinez Canillas

DRM drivers can use this to determine whether they can be enabled or not.

For now it's just a wrapper around drm_modeset_disabled() but having the
indirection level will allow to add other conditions besides "nomodeset".

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
 include/drm/drm_drv.h     |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 8214a0b1ab7f..70ef08941e06 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
 }
 EXPORT_SYMBOL(drm_dev_set_unique);
 
+/**
+ * drm_drv_enabled - Checks if a DRM driver can be enabled
+ * @driver: DRM driver to check
+ *
+ * Checks whether a DRM driver can be enabled or not. This may be the case
+ * if the "nomodeset" kernel command line parameter is used.
+ *
+ * Returns:
+ * True if the DRM driver is enabled and false otherwise.
+ */
+bool drm_drv_enabled(const struct drm_driver *driver)
+{
+	if (drm_modeset_disabled()) {
+		DRM_INFO("%s driver is disabled\n", driver->name);
+		return false;
+	}
+
+	return true;
+}
+EXPORT_SYMBOL(drm_drv_enabled);
+
 /*
  * DRM Core
  * The DRM core module initializes all global DRM objects and makes them
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 0cd95953cdf5..48f2b6eec012 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
 
 int drm_dev_set_unique(struct drm_device *dev, const char *name);
 
+bool drm_drv_enabled(const struct drm_driver *driver);
 
 #endif
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
@ 2021-11-03 12:32 ` Javier Martinez Canillas
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2021-11-03 12:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pekka Paalanen, dri-devel, David Airlie, Daniel Vetter,
	Michel Dänzer, Javier Martinez Canillas, Peter Robinson,
	Thomas Zimmermann, Neal Gompa

DRM drivers can use this to determine whether they can be enabled or not.

For now it's just a wrapper around drm_modeset_disabled() but having the
indirection level will allow to add other conditions besides "nomodeset".

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
 include/drm/drm_drv.h     |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 8214a0b1ab7f..70ef08941e06 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
 }
 EXPORT_SYMBOL(drm_dev_set_unique);
 
+/**
+ * drm_drv_enabled - Checks if a DRM driver can be enabled
+ * @driver: DRM driver to check
+ *
+ * Checks whether a DRM driver can be enabled or not. This may be the case
+ * if the "nomodeset" kernel command line parameter is used.
+ *
+ * Returns:
+ * True if the DRM driver is enabled and false otherwise.
+ */
+bool drm_drv_enabled(const struct drm_driver *driver)
+{
+	if (drm_modeset_disabled()) {
+		DRM_INFO("%s driver is disabled\n", driver->name);
+		return false;
+	}
+
+	return true;
+}
+EXPORT_SYMBOL(drm_drv_enabled);
+
 /*
  * DRM Core
  * The DRM core module initializes all global DRM objects and makes them
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 0cd95953cdf5..48f2b6eec012 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
 
 int drm_dev_set_unique(struct drm_device *dev, const char *name);
 
+bool drm_drv_enabled(const struct drm_driver *driver);
 
 #endif
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
  2021-11-03 12:32 ` Javier Martinez Canillas
@ 2021-11-03 13:41   ` Jani Nikula
  -1 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2021-11-03 13:41 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Pekka Paalanen, dri-devel, David Airlie, Daniel Vetter,
	Michel Dänzer, Javier Martinez Canillas, Peter Robinson,
	Thomas Zimmermann, Neal Gompa

On Wed, 03 Nov 2021, Javier Martinez Canillas <javierm@redhat.com> wrote:
> DRM drivers can use this to determine whether they can be enabled or not.
>
> For now it's just a wrapper around drm_modeset_disabled() but having the
> indirection level will allow to add other conditions besides "nomodeset".
>
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Can't see i915 trivially using this due to the drm_driver
parameter. Please let's not merge helpers like this without actual
users.

BR,
Jani.


> ---
>
>  drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
>  include/drm/drm_drv.h     |  1 +
>  2 files changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 8214a0b1ab7f..70ef08941e06 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
>  }
>  EXPORT_SYMBOL(drm_dev_set_unique);
>  
> +/**
> + * drm_drv_enabled - Checks if a DRM driver can be enabled
> + * @driver: DRM driver to check
> + *
> + * Checks whether a DRM driver can be enabled or not. This may be the case
> + * if the "nomodeset" kernel command line parameter is used.
> + *
> + * Returns:
> + * True if the DRM driver is enabled and false otherwise.
> + */
> +bool drm_drv_enabled(const struct drm_driver *driver)
> +{
> +	if (drm_modeset_disabled()) {
> +		DRM_INFO("%s driver is disabled\n", driver->name);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +EXPORT_SYMBOL(drm_drv_enabled);
> +
>  /*
>   * DRM Core
>   * The DRM core module initializes all global DRM objects and makes them
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 0cd95953cdf5..48f2b6eec012 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
>  
>  int drm_dev_set_unique(struct drm_device *dev, const char *name);
>  
> +bool drm_drv_enabled(const struct drm_driver *driver);
>  
>  #endif

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
@ 2021-11-03 13:41   ` Jani Nikula
  0 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2021-11-03 13:41 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Pekka Paalanen, David Airlie, Daniel Vetter, Michel Dänzer,
	Javier Martinez Canillas, dri-devel, Peter Robinson,
	Thomas Zimmermann, Neal Gompa

On Wed, 03 Nov 2021, Javier Martinez Canillas <javierm@redhat.com> wrote:
> DRM drivers can use this to determine whether they can be enabled or not.
>
> For now it's just a wrapper around drm_modeset_disabled() but having the
> indirection level will allow to add other conditions besides "nomodeset".
>
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Can't see i915 trivially using this due to the drm_driver
parameter. Please let's not merge helpers like this without actual
users.

BR,
Jani.


> ---
>
>  drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
>  include/drm/drm_drv.h     |  1 +
>  2 files changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 8214a0b1ab7f..70ef08941e06 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
>  }
>  EXPORT_SYMBOL(drm_dev_set_unique);
>  
> +/**
> + * drm_drv_enabled - Checks if a DRM driver can be enabled
> + * @driver: DRM driver to check
> + *
> + * Checks whether a DRM driver can be enabled or not. This may be the case
> + * if the "nomodeset" kernel command line parameter is used.
> + *
> + * Returns:
> + * True if the DRM driver is enabled and false otherwise.
> + */
> +bool drm_drv_enabled(const struct drm_driver *driver)
> +{
> +	if (drm_modeset_disabled()) {
> +		DRM_INFO("%s driver is disabled\n", driver->name);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +EXPORT_SYMBOL(drm_drv_enabled);
> +
>  /*
>   * DRM Core
>   * The DRM core module initializes all global DRM objects and makes them
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 0cd95953cdf5..48f2b6eec012 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
>  
>  int drm_dev_set_unique(struct drm_device *dev, const char *name);
>  
> +bool drm_drv_enabled(const struct drm_driver *driver);
>  
>  #endif

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
  2021-11-03 13:41   ` Jani Nikula
  (?)
@ 2021-11-03 13:53   ` Thomas Zimmermann
  2021-11-04 11:10     ` Jani Nikula
  -1 siblings, 1 reply; 7+ messages in thread
From: Thomas Zimmermann @ 2021-11-03 13:53 UTC (permalink / raw)
  To: Jani Nikula, Javier Martinez Canillas, linux-kernel
  Cc: Pekka Paalanen, David Airlie, Daniel Vetter, Michel Dänzer,
	dri-devel, Peter Robinson, Neal Gompa


[-- Attachment #1.1: Type: text/plain, Size: 2710 bytes --]

Hi

Am 03.11.21 um 14:41 schrieb Jani Nikula:
> On Wed, 03 Nov 2021, Javier Martinez Canillas <javierm@redhat.com> wrote:
>> DRM drivers can use this to determine whether they can be enabled or not.
>>
>> For now it's just a wrapper around drm_modeset_disabled() but having the
>> indirection level will allow to add other conditions besides "nomodeset".
>>
>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Can't see i915 trivially using this due to the drm_driver
> parameter. Please let's not merge helpers like this without actual
> users.

Can you explain?

This would be called on the top of the PCI probe function. The parameter 
would allow to decide on a per-driver base (e.g., to ignore generic 
drivers).

Best regards
Thomas

> 
> BR,
> Jani.
> 
> 
>> ---
>>
>>   drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
>>   include/drm/drm_drv.h     |  1 +
>>   2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>> index 8214a0b1ab7f..70ef08941e06 100644
>> --- a/drivers/gpu/drm/drm_drv.c
>> +++ b/drivers/gpu/drm/drm_drv.c
>> @@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
>>   }
>>   EXPORT_SYMBOL(drm_dev_set_unique);
>>   
>> +/**
>> + * drm_drv_enabled - Checks if a DRM driver can be enabled
>> + * @driver: DRM driver to check
>> + *
>> + * Checks whether a DRM driver can be enabled or not. This may be the case
>> + * if the "nomodeset" kernel command line parameter is used.
>> + *
>> + * Returns:
>> + * True if the DRM driver is enabled and false otherwise.
>> + */
>> +bool drm_drv_enabled(const struct drm_driver *driver)
>> +{
>> +	if (drm_modeset_disabled()) {
>> +		DRM_INFO("%s driver is disabled\n", driver->name);
>> +		return false;
>> +	}
>> +
>> +	return true;
>> +}
>> +EXPORT_SYMBOL(drm_drv_enabled);
>> +
>>   /*
>>    * DRM Core
>>    * The DRM core module initializes all global DRM objects and makes them
>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>> index 0cd95953cdf5..48f2b6eec012 100644
>> --- a/include/drm/drm_drv.h
>> +++ b/include/drm/drm_drv.h
>> @@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
>>   
>>   int drm_dev_set_unique(struct drm_device *dev, const char *name);
>>   
>> +bool drm_drv_enabled(const struct drm_driver *driver);
>>   
>>   #endif
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
  2021-11-03 13:53   ` Thomas Zimmermann
@ 2021-11-04 11:10     ` Jani Nikula
  2021-11-04 12:11       ` Javier Martinez Canillas
  0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2021-11-04 11:10 UTC (permalink / raw)
  To: Thomas Zimmermann, Javier Martinez Canillas, linux-kernel
  Cc: Pekka Paalanen, David Airlie, Daniel Vetter, Michel Dänzer,
	dri-devel, Peter Robinson, Neal Gompa

On Wed, 03 Nov 2021, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Hi
>
> Am 03.11.21 um 14:41 schrieb Jani Nikula:
>> On Wed, 03 Nov 2021, Javier Martinez Canillas <javierm@redhat.com> wrote:
>>> DRM drivers can use this to determine whether they can be enabled or not.
>>>
>>> For now it's just a wrapper around drm_modeset_disabled() but having the
>>> indirection level will allow to add other conditions besides "nomodeset".
>>>
>>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
>> 
>> Can't see i915 trivially using this due to the drm_driver
>> parameter. Please let's not merge helpers like this without actual
>> users.
>
> Can you explain?
>
> This would be called on the top of the PCI probe function. The parameter 
> would allow to decide on a per-driver base (e.g., to ignore generic 
> drivers).

Where and how exactly? This is why we need to see the patch using the
function. A patch is worth a thousand words. ;)

See current vgacon_text_force() usage in i915/i915_module.c. It happens
way before anything related to pci or drm driver. Why bother with the
complicated setup and teardown of stuff if you can bail out earlier?


BR,
Jani.

>
> Best regards
> Thomas
>
>> 
>> BR,
>> Jani.
>> 
>> 
>>> ---
>>>
>>>   drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
>>>   include/drm/drm_drv.h     |  1 +
>>>   2 files changed, 22 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 8214a0b1ab7f..70ef08941e06 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
>>>   }
>>>   EXPORT_SYMBOL(drm_dev_set_unique);
>>>   
>>> +/**
>>> + * drm_drv_enabled - Checks if a DRM driver can be enabled
>>> + * @driver: DRM driver to check
>>> + *
>>> + * Checks whether a DRM driver can be enabled or not. This may be the case
>>> + * if the "nomodeset" kernel command line parameter is used.
>>> + *
>>> + * Returns:
>>> + * True if the DRM driver is enabled and false otherwise.
>>> + */
>>> +bool drm_drv_enabled(const struct drm_driver *driver)
>>> +{
>>> +	if (drm_modeset_disabled()) {
>>> +		DRM_INFO("%s driver is disabled\n", driver->name);
>>> +		return false;
>>> +	}
>>> +
>>> +	return true;
>>> +}
>>> +EXPORT_SYMBOL(drm_drv_enabled);
>>> +
>>>   /*
>>>    * DRM Core
>>>    * The DRM core module initializes all global DRM objects and makes them
>>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>>> index 0cd95953cdf5..48f2b6eec012 100644
>>> --- a/include/drm/drm_drv.h
>>> +++ b/include/drm/drm_drv.h
>>> @@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
>>>   
>>>   int drm_dev_set_unique(struct drm_device *dev, const char *name);
>>>   
>>> +bool drm_drv_enabled(const struct drm_driver *driver);
>>>   
>>>   #endif
>> 

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function
  2021-11-04 11:10     ` Jani Nikula
@ 2021-11-04 12:11       ` Javier Martinez Canillas
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2021-11-04 12:11 UTC (permalink / raw)
  To: Jani Nikula, Thomas Zimmermann, linux-kernel
  Cc: Pekka Paalanen, David Airlie, Daniel Vetter, Michel Dänzer,
	dri-devel, Peter Robinson, Neal Gompa

Hello Jani,

On 11/4/21 12:10, Jani Nikula wrote:
> On Wed, 03 Nov 2021, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Hi
>>
>> Am 03.11.21 um 14:41 schrieb Jani Nikula:
>>> On Wed, 03 Nov 2021, Javier Martinez Canillas <javierm@redhat.com> wrote:
>>>> DRM drivers can use this to determine whether they can be enabled or not.
>>>>
>>>> For now it's just a wrapper around drm_modeset_disabled() but having the
>>>> indirection level will allow to add other conditions besides "nomodeset".
>>>>
>>>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>>>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
>>>
>>> Can't see i915 trivially using this due to the drm_driver
>>> parameter. Please let's not merge helpers like this without actual
>>> users.
>>
>> Can you explain?
>>
>> This would be called on the top of the PCI probe function. The parameter 
>> would allow to decide on a per-driver base (e.g., to ignore generic 
>> drivers).
> 
> Where and how exactly? This is why we need to see the patch using the
> function. A patch is worth a thousand words. ;)
>

Thomas suggested to squash patches #4 and #5 so I'll do that when posting v2.
 
> See current vgacon_text_force() usage in i915/i915_module.c. It happens
> way before anything related to pci or drm driver. Why bother with the
> complicated setup and teardown of stuff if you can bail out earlier?
>

Yes, most drivers use vgacon_text_force() in their module init callback.

The ones that do in their probe function are drivers that don't have a
module init/exit but just use the module_platform_driver() macro.

I won't modify that and will keep the bail in the same place that the
drivers already do. I hope to have time and post a new revision today.

> 
> BR,
> Jani.
> 
Best regards,
-- 
Javier Martinez Canillas
Linux Engineering
Red Hat


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-04 12:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 12:32 [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function Javier Martinez Canillas
2021-11-03 12:32 ` Javier Martinez Canillas
2021-11-03 13:41 ` Jani Nikula
2021-11-03 13:41   ` Jani Nikula
2021-11-03 13:53   ` Thomas Zimmermann
2021-11-04 11:10     ` Jani Nikula
2021-11-04 12:11       ` Javier Martinez Canillas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.