lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2a88d198-f3b6-4684-b528-4aaaa0340d46@amd.com>
Date: Mon, 12 Aug 2024 10:06:19 -0400
From: Hamza Mahfooz <hamza.mahfooz@....com>
To: Jani Nikula <jani.nikula@...ux.intel.com>,
 Jocelyn Falempe <jfalempe@...hat.com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng
 <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
 Bjorn Roy Baron <bjorn3_gh@...tonmail.com>,
 Benno Lossin <benno.lossin@...ton.me>,
 Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl
 <aliceryhl@...gle.com>, linux-kernel@...r.kernel.org,
 dri-devel@...ts.freedesktop.org, rust-for-linux@...r.kernel.org,
 Danilo Krummrich <dakr@...hat.com>
Subject: Re: [PATCH v6 2/4] drm/rect: Add drm_rect_overlap()

On 8/12/24 09:49, Jani Nikula wrote:
> On Mon, 12 Aug 2024, Jocelyn Falempe <jfalempe@...hat.com> wrote:
>> Check if two rectangles overlap.
>> It's a bit similar to drm_rect_intersect() but this won't modify
>> the rectangle.
>> Simplifies a bit drm_panic.
> 
> Based on the name, I'd expect drm_rect_overlap() to return true for
> *any* overlap, while this one seems to mean if one rectangle is
> completely within another, with no adjacent borders.
> 
> I'd expect a drm_rect_overlap() to return true for this:
> 
>   +-------+
>   |   +---+---+
>   |   |       |
>   +---+       |
>       |       |
>       +-------+
> 
> While this seems to be required instead:
> 
>   +-------+
>   | +---+ |
>   | |   | |
>   | +---+ |
>   +-------+
> 
> 
> IOW, I find the name misleading.

Ya, maybe drm_rect_encloses() would be a better fit.

> 
> BR,
> Jani.
> 
> 
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@...hat.com>
>> ---
>>   drivers/gpu/drm/drm_panic.c |  3 +--
>>   include/drm/drm_rect.h      | 15 +++++++++++++++
>>   2 files changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
>> index 0a047152f88b8..59fba23e5fd7a 100644
>> --- a/drivers/gpu/drm/drm_panic.c
>> +++ b/drivers/gpu/drm/drm_panic.c
>> @@ -529,8 +529,7 @@ static void draw_panic_static_user(struct drm_scanout_buffer *sb)
>>   	/* Fill with the background color, and draw text on top */
>>   	drm_panic_fill(sb, &r_screen, bg_color);
>>   
>> -	if ((r_msg.x1 >= logo_width || r_msg.y1 >= logo_height) &&
>> -	    logo_width <= sb->width && logo_height <= sb->height) {
>> +	if (!drm_rect_overlap(&r_logo, &r_msg)) {
>>   		if (logo_mono)
>>   			drm_panic_blit(sb, &r_logo, logo_mono->data, DIV_ROUND_UP(logo_width, 8),
>>   				       fg_color);
>> diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h
>> index 73fcb899a01da..7bafde747d560 100644
>> --- a/include/drm/drm_rect.h
>> +++ b/include/drm/drm_rect.h
>> @@ -238,6 +238,21 @@ static inline void drm_rect_fp_to_int(struct drm_rect *dst,
>>   		      drm_rect_height(src) >> 16);
>>   }
>>   
>> +/**
>> + * drm_rect_overlap - Check if two rectangles overlap
>> + * @r1: first rectangle
>> + * @r2: second rectangle
>> + *
>> + * RETURNS:
>> + * %true if the rectangles overlap, %false otherwise.

If you do end up going with that name, the returns doc ought to be:

%true if @r2 is completely enclosed in @r1, %false otherwise.

>> + */
>> +static inline bool drm_rect_overlap(const struct drm_rect *r1,
>> +				    const struct drm_rect *r2)
>> +{
>> +	return (r1->x2 > r2->x1 && r2->x2 > r1->x1 &&
>> +		r1->y2 > r2->y1 && r2->y2 > r1->y1);
>> +}
>> +
>>   bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);
>>   bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,
>>   			  const struct drm_rect *clip);
> 
-- 
Hamza


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ