linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Noralf Trønnes" <noralf@tronnes.org>,
	daniel@ffwll.ch, airlied@linux.ie, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, drawat.floss@gmail.com,
	airlied@redhat.com, kraxel@redhat.com, david@lechnology.com,
	sam@ravnborg.org, javierm@redhat.com, kernel@amanoeldawod.com,
	dirty.ice.hu@gmail.com, michael+lkml@stapelberg.ch, aros@gmx.com,
	joshua@stroblindustries.com, arnd@arndb.de
Cc: dri-devel@lists.freedesktop.org, linux-hyperv@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2 7/9] drm/simpledrm: Enable FB_DAMAGE_CLIPS property
Date: Tue, 9 Nov 2021 10:43:50 +0100	[thread overview]
Message-ID: <177b124b-96bb-a05f-a22b-90e238209187@suse.de> (raw)
In-Reply-To: <6cf78eae-796d-f5a2-e93f-624599af4944@tronnes.org>


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

Hi

Am 08.11.21 um 19:57 schrieb Noralf Trønnes:
> 
> 
> Den 01.11.2021 15.15, skrev Thomas Zimmermann:
>> Enable the FB_DAMAGE_CLIPS property to reduce display-update
>> overhead. Also fixes a warning in the kernel log.
>>
>>    simple-framebuffer simple-framebuffer.0: [drm] drm_plane_enable_fb_damage_clips() not called
>>
>> Fix the computation of the blit rectangle. This wasn't an issue so
>> far, as simpledrm always blitted the full framebuffer. The code now
>> supports damage clipping and virtual screen sizes.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   drivers/gpu/drm/tiny/simpledrm.c | 30 ++++++++++++++++++++++--------
>>   1 file changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
>> index 571f716ff427..e872121e9fb0 100644
>> --- a/drivers/gpu/drm/tiny/simpledrm.c
>> +++ b/drivers/gpu/drm/tiny/simpledrm.c
>> @@ -642,7 +642,7 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
>>   	void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */
>>   	struct drm_device *dev = &sdev->dev;
>>   	void __iomem *dst = sdev->screen_base;
>> -	struct drm_rect clip;
>> +	struct drm_rect src_clip, dst_clip;
>>   	int idx;
>>   
>>   	if (!fb)
>> @@ -651,10 +651,14 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
>>   	if (!drm_dev_enter(dev, &idx))
>>   		return;
>>   
>> -	drm_rect_init(&clip, 0, 0, fb->width, fb->height);
>> +	drm_rect_fp_to_int(&src_clip, &plane_state->src);
>>   
>> -	dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &clip);
>> -	drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &clip);
>> +	dst_clip = plane_state->dst;
>> +	if (!drm_rect_intersect(&dst_clip, &src_clip))
>> +		return;
> 
> You're inside drm_dev_enter here so can't just return. Move
> drm_dev_enter after this like you do in update().

Right. Will be fixed.

> 
>> +
>> +	dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip);
>> +	drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &src_clip);
>>   
>>   	drm_dev_exit(idx);
>>   }
>> @@ -686,20 +690,28 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
>>   	struct drm_framebuffer *fb = plane_state->fb;
>>   	struct drm_device *dev = &sdev->dev;
>>   	void __iomem *dst = sdev->screen_base;
>> -	struct drm_rect clip;
>> +	struct drm_rect damage_clip, src_clip, dst_clip;
>>   	int idx;
>>   
>>   	if (!fb)
>>   		return;
>>   
>> -	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &clip))
>> +	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &damage_clip))
>> +		return;
>> +
> 
> The following check, isn't that the same check that has just happened in
> drm_atomic_helper_damage_iter_next()?

Oh, indeed. It takes the plane's src rectangle [1] and clips against it. 
[2] The bounding box of all damage clips is the final rectangle. [3] It 
can never by outside of plane_state->src. So the extra test here and the 
damage_clip variable can be removed.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_damage_helper.c#L235
[2] 
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_damage_helper.c#L280
[3] 
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_damage_helper.c#L320

> 
> Noralf.
> 
>> +	drm_rect_fp_to_int(&src_clip, &plane_state->src);
>> +	if (!drm_rect_intersect(&src_clip, &damage_clip))
>> +		return;
>> +
>> +	dst_clip = plane_state->dst;
>> +	if (!drm_rect_intersect(&dst_clip, &src_clip))
>>   		return;
>>   
>>   	if (!drm_dev_enter(dev, &idx))
>>   		return;
>>   
>> -	dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &clip);
>> -	drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &clip);
>> +	dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip);
>> +	drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &src_clip);
>>   
>>   	drm_dev_exit(idx);
>>   }
>> @@ -794,6 +806,8 @@ static int simpledrm_device_init_modeset(struct simpledrm_device *sdev)
>>   	if (ret)
>>   		return ret;
>>   
>> +	drm_plane_enable_fb_damage_clips(&pipe->plane);
>> +
>>   	drm_mode_config_reset(dev);
>>   
>>   	return 0;
>>

-- 
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 --]

  reply	other threads:[~2021-11-09  9:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 14:15 [PATCH v2 0/9] drm/simpledrm: Enable damage clips and virtual screens Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 1/9] drm/format-helper: Export drm_fb_clip_offset() Thomas Zimmermann
2021-11-05 20:48   ` Noralf Trønnes
2021-11-08  8:50     ` Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 2/9] drm/format-helper: Rework format-helper memcpy functions Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 3/9] drm/format-helper: Add destination-buffer pitch to drm_fb_swab() Thomas Zimmermann
2021-11-08 18:57   ` Amanoel Dawod
2021-11-10  9:17     ` Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 4/9] drm/format-helper: Rework format-helper conversion functions Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 5/9] drm/format-helper: Streamline blit-helper interface Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 6/9] drm/fb-helper: Allocate shadow buffer of surface height Thomas Zimmermann
2021-11-01 14:15 ` [PATCH v2 7/9] drm/simpledrm: Enable FB_DAMAGE_CLIPS property Thomas Zimmermann
2021-11-08 18:57   ` Noralf Trønnes
2021-11-09  9:43     ` Thomas Zimmermann [this message]
2021-11-08 20:55   ` Noralf Trønnes
2021-11-09 12:38     ` Thomas Zimmermann
2021-11-09 13:04       ` Noralf Trønnes
2021-11-09 14:56         ` Thomas Zimmermann
2021-11-09 15:52           ` Noralf Trønnes
2021-11-01 14:15 ` [PATCH v2 8/9] drm/simpledrm: Support virtual screen sizes Thomas Zimmermann
2021-11-08 21:01   ` Noralf Trønnes
2021-11-09  9:06     ` Thomas Zimmermann
2021-11-09 13:05       ` Noralf Trønnes
2021-11-01 14:15 ` [PATCH v2 9/9] drm: Clarify semantics of struct drm_mode_config.{min,max}_{width,height} Thomas Zimmermann
2021-11-08 21:02   ` Noralf Trønnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=177b124b-96bb-a05f-a22b-90e238209187@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=arnd@arndb.de \
    --cc=aros@gmx.com \
    --cc=daniel@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dirty.ice.hu@gmail.com \
    --cc=drawat.floss@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=joshua@stroblindustries.com \
    --cc=kernel@amanoeldawod.com \
    --cc=kraxel@redhat.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michael+lkml@stapelberg.ch \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).