linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
@ 2023-08-15 17:26 Hamza Mahfooz
  2023-08-15 18:36 ` Mario Limonciello
  2023-08-16  5:55 ` Christian König
  0 siblings, 2 replies; 7+ messages in thread
From: Hamza Mahfooz @ 2023-08-15 17:26 UTC (permalink / raw)
  To: amd-gfx
  Cc: Hamza Mahfooz, Aurabindo Pillai, Mario Limonciello, stable,
	Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Thomas Zimmermann, Javier Martinez Canillas,
	Srinivasan Shanmugam, Guchun Chen, dri-devel, linux-kernel

fbcon requires that we implement &drm_framebuffer_funcs.dirty.
Otherwise, the framebuffer might take a while to flush (which would
manifest as noticeable lag). However, we can't enable this callback for
non-fbcon cases since it might cause too many atomic commits to be made
at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
framebuffers on devices that support atomic KMS.

Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: stable@vger.kernel.org # 6.1+
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
v2: update variable names
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26 ++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index d20dd3f852fc..d3b59f99cb7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -38,6 +38,8 @@
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_damage_helper.h>
+#include <drm/drm_drv.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
@@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 	return true;
 }
 
+static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
+			  unsigned int flags, unsigned int color,
+			  struct drm_clip_rect *clips, unsigned int num_clips)
+{
+
+	if (strcmp(fb->comm, "[fbcon]"))
+		return -ENOSYS;
+
+	return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
+					 num_clips);
+}
+
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.destroy = drm_gem_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
 };
 
+static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
+	.destroy = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.dirty = amdgpu_dirtyfb
+};
+
 uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
 					  uint64_t bo_flags)
 {
@@ -1139,7 +1159,11 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
 	if (ret)
 		goto err;
 
-	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
+	if (drm_drv_uses_atomic_modeset(dev))
+		ret = drm_framebuffer_init(dev, &rfb->base,
+					   &amdgpu_fb_funcs_atomic);
+	else
+		ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
 
 	if (ret)
 		goto err;
-- 
2.41.0


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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-15 17:26 [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon Hamza Mahfooz
@ 2023-08-15 18:36 ` Mario Limonciello
  2023-08-16  5:55 ` Christian König
  1 sibling, 0 replies; 7+ messages in thread
From: Mario Limonciello @ 2023-08-15 18:36 UTC (permalink / raw)
  To: Hamza Mahfooz, amd-gfx
  Cc: Aurabindo Pillai, stable, Alex Deucher, Christian König,
	Pan, Xinhui, David Airlie, Daniel Vetter, Thomas Zimmermann,
	Javier Martinez Canillas, Srinivasan Shanmugam, Guchun Chen,
	dri-devel, linux-kernel

On 8/15/2023 12:26, Hamza Mahfooz wrote:
> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
> Otherwise, the framebuffer might take a while to flush (which would
> manifest as noticeable lag). However, we can't enable this callback for
> non-fbcon cases since it might cause too many atomic commits to be made
> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
> framebuffers on devices that support atomic KMS.
> 
> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: stable@vger.kernel.org # 6.1+

This is safe specifically because other things like FB_DAMAGE_CLIPS have 
come back to 6.1.y as well via f1edb2f58adb ("drm/amd/display: add 
FB_DAMAGE_CLIPS support") and fixups to that.

> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

> ---
> v2: update variable names
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26 ++++++++++++++++++++-
>   1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index d20dd3f852fc..d3b59f99cb7c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -38,6 +38,8 @@
>   #include <linux/pci.h>
>   #include <linux/pm_runtime.h>
>   #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_damage_helper.h>
> +#include <drm/drm_drv.h>
>   #include <drm/drm_edid.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_gem_framebuffer_helper.h>
> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>   	return true;
>   }
>   
> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
> +			  unsigned int flags, unsigned int color,
> +			  struct drm_clip_rect *clips, unsigned int num_clips)
> +{
> +
> +	if (strcmp(fb->comm, "[fbcon]"))
> +		return -ENOSYS;
> +
> +	return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
> +					 num_clips);
> +}
> +
>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>   	.destroy = drm_gem_fb_destroy,
>   	.create_handle = drm_gem_fb_create_handle,
>   };
>   
> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
> +	.destroy = drm_gem_fb_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.dirty = amdgpu_dirtyfb
> +};
> +
>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>   					  uint64_t bo_flags)
>   {
> @@ -1139,7 +1159,11 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
>   	if (ret)
>   		goto err;
>   
> -	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
> +	if (drm_drv_uses_atomic_modeset(dev))
> +		ret = drm_framebuffer_init(dev, &rfb->base,
> +					   &amdgpu_fb_funcs_atomic);
> +	else
> +		ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>   
>   	if (ret)
>   		goto err;


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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-15 17:26 [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon Hamza Mahfooz
  2023-08-15 18:36 ` Mario Limonciello
@ 2023-08-16  5:55 ` Christian König
  2023-08-16 13:41   ` Hamza Mahfooz
  1 sibling, 1 reply; 7+ messages in thread
From: Christian König @ 2023-08-16  5:55 UTC (permalink / raw)
  To: Hamza Mahfooz, amd-gfx
  Cc: Srinivasan Shanmugam, Thomas Zimmermann, Guchun Chen, dri-devel,
	Pan, Xinhui, Javier Martinez Canillas, stable, linux-kernel,
	Aurabindo Pillai, Daniel Vetter, Alex Deucher, David Airlie,
	Christian König, Mario Limonciello



Am 15.08.23 um 19:26 schrieb Hamza Mahfooz:
> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
> Otherwise, the framebuffer might take a while to flush (which would
> manifest as noticeable lag). However, we can't enable this callback for
> non-fbcon cases since it might cause too many atomic commits to be made
> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
> framebuffers on devices that support atomic KMS.
>
> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: stable@vger.kernel.org # 6.1+
> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> ---
> v2: update variable names
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26 ++++++++++++++++++++-
>   1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index d20dd3f852fc..d3b59f99cb7c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -38,6 +38,8 @@
>   #include <linux/pci.h>
>   #include <linux/pm_runtime.h>
>   #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_damage_helper.h>
> +#include <drm/drm_drv.h>
>   #include <drm/drm_edid.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_gem_framebuffer_helper.h>
> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>   	return true;
>   }
>   
> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
> +			  unsigned int flags, unsigned int color,
> +			  struct drm_clip_rect *clips, unsigned int num_clips)
> +{
> +
> +	if (strcmp(fb->comm, "[fbcon]"))
> +		return -ENOSYS;

Once more to the v2 of this patch: Tests like those are a pretty big 
NO-GO for upstreaming.

Regards,
Christian.

> +
> +	return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
> +					 num_clips);
> +}
> +
>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>   	.destroy = drm_gem_fb_destroy,
>   	.create_handle = drm_gem_fb_create_handle,
>   };
>   
> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
> +	.destroy = drm_gem_fb_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.dirty = amdgpu_dirtyfb
> +};
> +
>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>   					  uint64_t bo_flags)
>   {
> @@ -1139,7 +1159,11 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
>   	if (ret)
>   		goto err;
>   
> -	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
> +	if (drm_drv_uses_atomic_modeset(dev))
> +		ret = drm_framebuffer_init(dev, &rfb->base,
> +					   &amdgpu_fb_funcs_atomic);
> +	else
> +		ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>   
>   	if (ret)
>   		goto err;


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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-16  5:55 ` Christian König
@ 2023-08-16 13:41   ` Hamza Mahfooz
  2023-08-16 14:17     ` Christian König
  0 siblings, 1 reply; 7+ messages in thread
From: Hamza Mahfooz @ 2023-08-16 13:41 UTC (permalink / raw)
  To: Christian König, amd-gfx
  Cc: Srinivasan Shanmugam, Thomas Zimmermann, Guchun Chen, dri-devel,
	Pan, Xinhui, Javier Martinez Canillas, stable, linux-kernel,
	Aurabindo Pillai, Daniel Vetter, Alex Deucher, David Airlie,
	Christian König, Mario Limonciello


On 8/16/23 01:55, Christian König wrote:
> 
> 
> Am 15.08.23 um 19:26 schrieb Hamza Mahfooz:
>> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
>> Otherwise, the framebuffer might take a while to flush (which would
>> manifest as noticeable lag). However, we can't enable this callback for
>> non-fbcon cases since it might cause too many atomic commits to be made
>> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
>> framebuffers on devices that support atomic KMS.
>>
>> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
>> Cc: Mario Limonciello <mario.limonciello@amd.com>
>> Cc: stable@vger.kernel.org # 6.1+
>> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>> ---
>> v2: update variable names
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26 ++++++++++++++++++++-
>>   1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> index d20dd3f852fc..d3b59f99cb7c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> @@ -38,6 +38,8 @@
>>   #include <linux/pci.h>
>>   #include <linux/pm_runtime.h>
>>   #include <drm/drm_crtc_helper.h>
>> +#include <drm/drm_damage_helper.h>
>> +#include <drm/drm_drv.h>
>>   #include <drm/drm_edid.h>
>>   #include <drm/drm_fb_helper.h>
>>   #include <drm/drm_gem_framebuffer_helper.h>
>> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct 
>> amdgpu_connector *amdgpu_connector,
>>       return true;
>>   }
>> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file 
>> *file,
>> +              unsigned int flags, unsigned int color,
>> +              struct drm_clip_rect *clips, unsigned int num_clips)
>> +{
>> +
>> +    if (strcmp(fb->comm, "[fbcon]"))
>> +        return -ENOSYS;
> 
> Once more to the v2 of this patch: Tests like those are a pretty big 
> NO-GO for upstreaming.

On closer inspection it is actually sufficient to check if `file` is
NULL here (since it means that the request isn't from userspace). So, do
you think that would be palatable for upstream?

> 
> Regards,
> Christian.
> 
>> +
>> +    return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
>> +                     num_clips);
>> +}
>> +
>>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>>       .destroy = drm_gem_fb_destroy,
>>       .create_handle = drm_gem_fb_create_handle,
>>   };
>> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
>> +    .destroy = drm_gem_fb_destroy,
>> +    .create_handle = drm_gem_fb_create_handle,
>> +    .dirty = amdgpu_dirtyfb
>> +};
>> +
>>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>>                         uint64_t bo_flags)
>>   {
>> @@ -1139,7 +1159,11 @@ static int 
>> amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
>>       if (ret)
>>           goto err;
>> -    ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>> +    if (drm_drv_uses_atomic_modeset(dev))
>> +        ret = drm_framebuffer_init(dev, &rfb->base,
>> +                       &amdgpu_fb_funcs_atomic);
>> +    else
>> +        ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>>       if (ret)
>>           goto err;
> 
-- 
Hamza


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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-16 13:41   ` Hamza Mahfooz
@ 2023-08-16 14:17     ` Christian König
  2023-08-23 20:51       ` Alex Deucher
  0 siblings, 1 reply; 7+ messages in thread
From: Christian König @ 2023-08-16 14:17 UTC (permalink / raw)
  To: Hamza Mahfooz, amd-gfx
  Cc: Srinivasan Shanmugam, Thomas Zimmermann, Guchun Chen, dri-devel,
	Pan, Xinhui, Javier Martinez Canillas, stable, linux-kernel,
	Aurabindo Pillai, Daniel Vetter, Alex Deucher, David Airlie,
	Christian König, Mario Limonciello

Am 16.08.23 um 15:41 schrieb Hamza Mahfooz:
>
> On 8/16/23 01:55, Christian König wrote:
>>
>>
>> Am 15.08.23 um 19:26 schrieb Hamza Mahfooz:
>>> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
>>> Otherwise, the framebuffer might take a while to flush (which would
>>> manifest as noticeable lag). However, we can't enable this callback for
>>> non-fbcon cases since it might cause too many atomic commits to be made
>>> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
>>> framebuffers on devices that support atomic KMS.
>>>
>>> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
>>> Cc: Mario Limonciello <mario.limonciello@amd.com>
>>> Cc: stable@vger.kernel.org # 6.1+
>>> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
>>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>>> ---
>>> v2: update variable names
>>> ---
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26 
>>> ++++++++++++++++++++-
>>>   1 file changed, 25 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>> index d20dd3f852fc..d3b59f99cb7c 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>> @@ -38,6 +38,8 @@
>>>   #include <linux/pci.h>
>>>   #include <linux/pm_runtime.h>
>>>   #include <drm/drm_crtc_helper.h>
>>> +#include <drm/drm_damage_helper.h>
>>> +#include <drm/drm_drv.h>
>>>   #include <drm/drm_edid.h>
>>>   #include <drm/drm_fb_helper.h>
>>>   #include <drm/drm_gem_framebuffer_helper.h>
>>> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct 
>>> amdgpu_connector *amdgpu_connector,
>>>       return true;
>>>   }
>>> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct 
>>> drm_file *file,
>>> +              unsigned int flags, unsigned int color,
>>> +              struct drm_clip_rect *clips, unsigned int num_clips)
>>> +{
>>> +
>>> +    if (strcmp(fb->comm, "[fbcon]"))
>>> +        return -ENOSYS;
>>
>> Once more to the v2 of this patch: Tests like those are a pretty big 
>> NO-GO for upstreaming.
>
> On closer inspection it is actually sufficient to check if `file` is
> NULL here (since it means that the request isn't from userspace). So, do
> you think that would be palatable for upstream?

That's certainly better than doing a string compare, but I'm not sure if 
that's sufficient.

In general drivers shouldn't have any special handling for fdcon.

You should probably have Thomas Zimmermann <tzimmermann@suse.de> take a 
look at this.

Regards,
Christian.

>
>>
>> Regards,
>> Christian.
>>
>>> +
>>> +    return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
>>> +                     num_clips);
>>> +}
>>> +
>>>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>>>       .destroy = drm_gem_fb_destroy,
>>>       .create_handle = drm_gem_fb_create_handle,
>>>   };
>>> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
>>> +    .destroy = drm_gem_fb_destroy,
>>> +    .create_handle = drm_gem_fb_create_handle,
>>> +    .dirty = amdgpu_dirtyfb
>>> +};
>>> +
>>>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>>>                         uint64_t bo_flags)
>>>   {
>>> @@ -1139,7 +1159,11 @@ static int 
>>> amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
>>>       if (ret)
>>>           goto err;
>>> -    ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>>> +    if (drm_drv_uses_atomic_modeset(dev))
>>> +        ret = drm_framebuffer_init(dev, &rfb->base,
>>> +                       &amdgpu_fb_funcs_atomic);
>>> +    else
>>> +        ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>>>       if (ret)
>>>           goto err;
>>


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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-16 14:17     ` Christian König
@ 2023-08-23 20:51       ` Alex Deucher
  2023-08-23 21:02         ` Hamza Mahfooz
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Deucher @ 2023-08-23 20:51 UTC (permalink / raw)
  To: Christian König, Mahfooz, Hamza
  Cc: amd-gfx, Srinivasan Shanmugam, Guchun Chen, Pan, Xinhui,
	Javier Martinez Canillas, dri-devel, linux-kernel,
	Aurabindo Pillai, stable, Thomas Zimmermann, Alex Deucher,
	Mario Limonciello

@Mahfooz, Hamza
 can you respin with the NULL check?

Alex

On Wed, Aug 16, 2023 at 10:25 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 16.08.23 um 15:41 schrieb Hamza Mahfooz:
> >
> > On 8/16/23 01:55, Christian König wrote:
> >>
> >>
> >> Am 15.08.23 um 19:26 schrieb Hamza Mahfooz:
> >>> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
> >>> Otherwise, the framebuffer might take a while to flush (which would
> >>> manifest as noticeable lag). However, we can't enable this callback for
> >>> non-fbcon cases since it might cause too many atomic commits to be made
> >>> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
> >>> framebuffers on devices that support atomic KMS.
> >>>
> >>> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> >>> Cc: Mario Limonciello <mario.limonciello@amd.com>
> >>> Cc: stable@vger.kernel.org # 6.1+
> >>> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
> >>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> >>> ---
> >>> v2: update variable names
> >>> ---
> >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26
> >>> ++++++++++++++++++++-
> >>>   1 file changed, 25 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >>> index d20dd3f852fc..d3b59f99cb7c 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >>> @@ -38,6 +38,8 @@
> >>>   #include <linux/pci.h>
> >>>   #include <linux/pm_runtime.h>
> >>>   #include <drm/drm_crtc_helper.h>
> >>> +#include <drm/drm_damage_helper.h>
> >>> +#include <drm/drm_drv.h>
> >>>   #include <drm/drm_edid.h>
> >>>   #include <drm/drm_fb_helper.h>
> >>>   #include <drm/drm_gem_framebuffer_helper.h>
> >>> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct
> >>> amdgpu_connector *amdgpu_connector,
> >>>       return true;
> >>>   }
> >>> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct
> >>> drm_file *file,
> >>> +              unsigned int flags, unsigned int color,
> >>> +              struct drm_clip_rect *clips, unsigned int num_clips)
> >>> +{
> >>> +
> >>> +    if (strcmp(fb->comm, "[fbcon]"))
> >>> +        return -ENOSYS;
> >>
> >> Once more to the v2 of this patch: Tests like those are a pretty big
> >> NO-GO for upstreaming.
> >
> > On closer inspection it is actually sufficient to check if `file` is
> > NULL here (since it means that the request isn't from userspace). So, do
> > you think that would be palatable for upstream?
>
> That's certainly better than doing a string compare, but I'm not sure if
> that's sufficient.
>
> In general drivers shouldn't have any special handling for fdcon.
>
> You should probably have Thomas Zimmermann <tzimmermann@suse.de> take a
> look at this.
>
> Regards,
> Christian.
>
> >
> >>
> >> Regards,
> >> Christian.
> >>
> >>> +
> >>> +    return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
> >>> +                     num_clips);
> >>> +}
> >>> +
> >>>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
> >>>       .destroy = drm_gem_fb_destroy,
> >>>       .create_handle = drm_gem_fb_create_handle,
> >>>   };
> >>> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
> >>> +    .destroy = drm_gem_fb_destroy,
> >>> +    .create_handle = drm_gem_fb_create_handle,
> >>> +    .dirty = amdgpu_dirtyfb
> >>> +};
> >>> +
> >>>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
> >>>                         uint64_t bo_flags)
> >>>   {
> >>> @@ -1139,7 +1159,11 @@ static int
> >>> amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
> >>>       if (ret)
> >>>           goto err;
> >>> -    ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
> >>> +    if (drm_drv_uses_atomic_modeset(dev))
> >>> +        ret = drm_framebuffer_init(dev, &rfb->base,
> >>> +                       &amdgpu_fb_funcs_atomic);
> >>> +    else
> >>> +        ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
> >>>       if (ret)
> >>>           goto err;
> >>
>

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

* Re: [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon
  2023-08-23 20:51       ` Alex Deucher
@ 2023-08-23 21:02         ` Hamza Mahfooz
  0 siblings, 0 replies; 7+ messages in thread
From: Hamza Mahfooz @ 2023-08-23 21:02 UTC (permalink / raw)
  To: Alex Deucher, Christian König
  Cc: amd-gfx, Srinivasan Shanmugam, Guchun Chen, Pan, Xinhui,
	Javier Martinez Canillas, dri-devel, linux-kernel,
	Aurabindo Pillai, stable, Thomas Zimmermann, Alex Deucher,
	Mario Limonciello

On 8/23/23 16:51, Alex Deucher wrote:
> @Mahfooz, Hamza
>   can you respin with the NULL check?

sure.

> 
> Alex
> 
> On Wed, Aug 16, 2023 at 10:25 AM Christian König
> <christian.koenig@amd.com> wrote:
>>
>> Am 16.08.23 um 15:41 schrieb Hamza Mahfooz:
>>>
>>> On 8/16/23 01:55, Christian König wrote:
>>>>
>>>>
>>>> Am 15.08.23 um 19:26 schrieb Hamza Mahfooz:
>>>>> fbcon requires that we implement &drm_framebuffer_funcs.dirty.
>>>>> Otherwise, the framebuffer might take a while to flush (which would
>>>>> manifest as noticeable lag). However, we can't enable this callback for
>>>>> non-fbcon cases since it might cause too many atomic commits to be made
>>>>> at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon
>>>>> framebuffers on devices that support atomic KMS.
>>>>>
>>>>> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
>>>>> Cc: Mario Limonciello <mario.limonciello@amd.com>
>>>>> Cc: stable@vger.kernel.org # 6.1+
>>>>> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519
>>>>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>>>>> ---
>>>>> v2: update variable names
>>>>> ---
>>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 26
>>>>> ++++++++++++++++++++-
>>>>>    1 file changed, 25 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>>>> index d20dd3f852fc..d3b59f99cb7c 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>>>>> @@ -38,6 +38,8 @@
>>>>>    #include <linux/pci.h>
>>>>>    #include <linux/pm_runtime.h>
>>>>>    #include <drm/drm_crtc_helper.h>
>>>>> +#include <drm/drm_damage_helper.h>
>>>>> +#include <drm/drm_drv.h>
>>>>>    #include <drm/drm_edid.h>
>>>>>    #include <drm/drm_fb_helper.h>
>>>>>    #include <drm/drm_gem_framebuffer_helper.h>
>>>>> @@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct
>>>>> amdgpu_connector *amdgpu_connector,
>>>>>        return true;
>>>>>    }
>>>>> +static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct
>>>>> drm_file *file,
>>>>> +              unsigned int flags, unsigned int color,
>>>>> +              struct drm_clip_rect *clips, unsigned int num_clips)
>>>>> +{
>>>>> +
>>>>> +    if (strcmp(fb->comm, "[fbcon]"))
>>>>> +        return -ENOSYS;
>>>>
>>>> Once more to the v2 of this patch: Tests like those are a pretty big
>>>> NO-GO for upstreaming.
>>>
>>> On closer inspection it is actually sufficient to check if `file` is
>>> NULL here (since it means that the request isn't from userspace). So, do
>>> you think that would be palatable for upstream?
>>
>> That's certainly better than doing a string compare, but I'm not sure if
>> that's sufficient.
>>
>> In general drivers shouldn't have any special handling for fdcon.
>>
>> You should probably have Thomas Zimmermann <tzimmermann@suse.de> take a
>> look at this.
>>
>> Regards,
>> Christian.
>>
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>>> +
>>>>> +    return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
>>>>> +                     num_clips);
>>>>> +}
>>>>> +
>>>>>    static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>>>>>        .destroy = drm_gem_fb_destroy,
>>>>>        .create_handle = drm_gem_fb_create_handle,
>>>>>    };
>>>>> +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
>>>>> +    .destroy = drm_gem_fb_destroy,
>>>>> +    .create_handle = drm_gem_fb_create_handle,
>>>>> +    .dirty = amdgpu_dirtyfb
>>>>> +};
>>>>> +
>>>>>    uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>>>>>                          uint64_t bo_flags)
>>>>>    {
>>>>> @@ -1139,7 +1159,11 @@ static int
>>>>> amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
>>>>>        if (ret)
>>>>>            goto err;
>>>>> -    ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>>>>> +    if (drm_drv_uses_atomic_modeset(dev))
>>>>> +        ret = drm_framebuffer_init(dev, &rfb->base,
>>>>> +                       &amdgpu_fb_funcs_atomic);
>>>>> +    else
>>>>> +        ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
>>>>>        if (ret)
>>>>>            goto err;
>>>>
>>
-- 
Hamza


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

end of thread, other threads:[~2023-08-23 21:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 17:26 [PATCH v2] drm/amdgpu: register a dirty framebuffer callback for fbcon Hamza Mahfooz
2023-08-15 18:36 ` Mario Limonciello
2023-08-16  5:55 ` Christian König
2023-08-16 13:41   ` Hamza Mahfooz
2023-08-16 14:17     ` Christian König
2023-08-23 20:51       ` Alex Deucher
2023-08-23 21:02         ` Hamza Mahfooz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).