Message ID | 79c92cfa-cf5a-4a23-8a93-11c1af7432fc@ancud.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3540870dyb; Wed, 28 Feb 2024 10:46:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3BqJpn8CsC/0sYORnJiArlwnpm72ma/aTFJ0jTcIWUDw4keooVS43R3GFOQxPuL25y96YYgJZ5SsVXev1MdjmSwgsDg== X-Google-Smtp-Source: AGHT+IE4Njzd+iie5nftpKOoIZUpnvlkjuR0tTT7X/236Ha+M0pNT/aM0EFKaeoEgK7/J9Jt0qK+ X-Received: by 2002:a05:6a00:198d:b0:6e4:7762:624d with SMTP id d13-20020a056a00198d00b006e47762624dmr3644pfl.10.1709145971118; Wed, 28 Feb 2024 10:46:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709145971; cv=pass; d=google.com; s=arc-20160816; b=PdeMq53CasPU/hXF8L77tEt2YAQlsudHRs+aKfZLwlbrtngfTxiicWgjnsQDWPDL5u +qF5Ds1VUP2cG5ggCmSjVemkRyapkB/u98gR4hoIG9NHKZkbFAz0vAjmJFaS9ycaMNM3 dvydqehsPZOFoKgIGJEBnylYsu3QitkABmzOcV5bgdDYQ8sGCLJtFbVss7O0KB7JjlTh 8sOJ1dDGpG4DFyTRQewiqv3d9he5f1BpBq2TvbwkzMDSkPMkOFddE9Xc9PEHodldaLXr BYsbfNSOtU2XcE/EnQ30E++QjV75bH8rfAIn/Lbwbeipiddla3TA0ZjVyzrUX7YwntIi cJAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:cc:to:content-language :references:reply-to:subject:from:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=x9EGP0VfHwgtE+zhdEbqEGMyyEUW6NqX1LNB4JCeEfk=; fh=W3bCfKXBSeIuabwxGBI1D8VX5JIdo0RjVS3KibIPlB8=; b=EYlnGo5NKWCpXA7IhwoIL9j+n6cAYAbXPSXbOpBPzMRbAyvIkq1aq4Wtk+RpkjLnwN VZdQH0fUBEwo72nL06/+XOrEfwslS/F7JabsLOTtTQlTmqtVsMM0pjL+POObRJ3Ayrm1 KGH1+hq1vhPWXwtRH7EgHhfIo/4gQQuwMpfp3wc3n0MydGRBv4ju/J3QmbakW0Mdguqg POpS5h8kFI4ZJ9ZaowG60cfbpQ+/o2TF4c/jJ7u3v4rq6vJNs2Jr8HLRT0Ghz2FiA1qa FG6ZfA0phkyYd9F42FxtPPnRLM6Vs9DlkrQwXKo70XMQsxkTqVotODRDx9lyGqceTtXg iAmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m135-20020a633f8d000000b005cee03a1bf9si80075pga.448.2024.02.28.10.46.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 10:46:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85541-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 379ED28BE22 for <ouuuleilei@gmail.com>; Wed, 28 Feb 2024 18:38:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2D4871EC7; Wed, 28 Feb 2024 18:38:43 +0000 (UTC) Received: from relay161.nicmail.ru (relay161.nicmail.ru [91.189.117.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE15279B79 for <linux-kernel@vger.kernel.org>; Wed, 28 Feb 2024 18:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.189.117.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709145522; cv=none; b=St0U6VfDpMkL4WWjyTpiQ6+fQgZDV6Jq7lV9ZhDdt4NK5zOCm5iOpd7RpWuRrM9XjROtILVafBNuvPuVbUqwJyL3Jk4fgiGv0Ccz/5usU6IzBqTYyUMyBl8uGvmTyisJI9aUX3Du6F4EpmTGfo5U4XLpQZt95cww/FpuKxTu4sQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709145522; c=relaxed/simple; bh=MsJjh7TXS8JgWzGdB0v4jRwOparhSbtOtRlvrf4J/gU=; h=Message-ID:Date:MIME-Version:From:Subject:References:To:Cc: In-Reply-To:Content-Type; b=A2LGTywGplfT0AX8CmV0yTt9tEFv+uSUod+qkAIjo1tWu3miBF+6C3oOqGZq4BnMYHIabkIHLlTcXWG26rWMefMFM5Wix9qhEvZJz6I2A10vgJydg3Xiq9tOZXO0uavHF+Jvhl6kRgG35v0GF8OcGz9DHbT4L6NWqiYuGhdnj3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru; spf=pass smtp.mailfrom=ancud.ru; arc=none smtp.client-ip=91.189.117.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ancud.ru Received: from [10.28.138.149] (port=32378 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from <kiryushin@ancud.ru>) id 1rfOja-00034v-6A; Wed, 28 Feb 2024 21:32:51 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1102.mail.hosting.nic.ru (Exim 5.55) with id 1rfOja-000Yz9-2h; Wed, 28 Feb 2024 21:32:50 +0300 Message-ID: <79c92cfa-cf5a-4a23-8a93-11c1af7432fc@ancud.ru> Date: Wed, 28 Feb 2024 21:32:47 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Nikita Kiryushin <kiryushin@ancud.ru> Subject: [PATCH] drm/i915: Remove unneeded double drm_rect_visible call in check_overlay_dst Reply-To: Nikita Kiryushin <kiryushin@ancud.ru> References: <> Content-Language: en-US To: Jani Nikula <jani.nikula@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Manasi Navare <manasi.d.navare@intel.com>, =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= <ville.syrjala@linux.intel.com>, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, project@linuxtesting.org In-Reply-To: <> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MS-Exchange-Organization-SCL: -1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792169445574088163 X-GMAIL-MSGID: 1792169445574088163 |
Series |
drm/i915: Remove unneeded double drm_rect_visible call in check_overlay_dst
|
|
Commit Message
Nikita Kiryushin
Feb. 28, 2024, 6:32 p.m. UTC
check_overlay_dst for clipped is called 2 times: in drm_rect_intersect
and than directly. Change second call for check of drm_rect_intersect
result to save some time (in locked code section).
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 8d8b2dd3995f ("drm/i915: Make the PIPESRC rect relative to the
entire bigjoiner area")
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
---
drivers/gpu/drm/i915/display/intel_overlay.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On Wed, Feb 28, 2024 at 09:32:47PM +0300, Nikita Kiryushin wrote: > > check_overlay_dst for clipped is called 2 times: in drm_rect_intersect > and than directly. Change second call for check of drm_rect_intersect > result to save some time (in locked code section). > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 8d8b2dd3995f ("drm/i915: Make the PIPESRC rect relative to the > entire bigjoiner area") > Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru> > --- > drivers/gpu/drm/i915/display/intel_overlay.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c > b/drivers/gpu/drm/i915/display/intel_overlay.c > index 2b1392d5a902..1cda1c163a92 100644 > --- a/drivers/gpu/drm/i915/display/intel_overlay.c > +++ b/drivers/gpu/drm/i915/display/intel_overlay.c > @@ -972,9 +972,8 @@ static int check_overlay_dst(struct intel_overlay > *overlay, > rec->dst_width, rec->dst_height); > clipped = req; > - drm_rect_intersect(&clipped, &crtc_state->pipe_src); > - if (!drm_rect_visible(&clipped) || > + if (!drm_rect_intersect(&clipped, &crtc_state->pipe_src) || I prefer the current way where we have no side effects in the if statement. > !drm_rect_equals(&clipped, &req)) > return -EINVAL; > -- 2.34.1
On 2/29/24 15:30, Ville Syrjälä wrote: > I prefer the current way where we have no side effects in > the if statement. > This seem like a valid concern from readability and maintainability standpoint. My patch was aimed mostly at performance and maintainability using tools: some more pedantic analyzers are sensitive to non-checked return values (as of now, drm_rect_intersect is ignored). Would it be a better idea to make an update to the patch with second drm_rect_visible call changed to an appropriately named state flag set with drm_rect_intersect result? BTW, the original patch somehow got mangled while it made its way to the patchwork: source list line in patch got broken, which permits the patch from being applied (the original version did not have that line break). Any ideas how to prevent this happening with the second version of patch (in case the idea is viable)?
On Fri, Mar 01, 2024 at 09:56:41PM +0300, Nikita Kiryushin wrote: > On 2/29/24 15:30, Ville Syrjälä wrote: > > I prefer the current way where we have no side effects in > > the if statement. > > > > This seem like a valid concern from readability and maintainability > standpoint. My patch was aimed mostly at performance and maintainability > using tools: some more pedantic analyzers are sensitive to non-checked > return values (as of now, drm_rect_intersect is ignored). > > Would it be a better idea to make an update to the patch with second > drm_rect_visible call changed to an appropriately named state flag set > with drm_rect_intersect result? I was thinking of maybe removing that drm_rect_visible() from drm_rect_intersect() entirely, but looks like it's used fairly extensively, so would require a bunch of work. But now that I though about this I recalled that there was an earlier patch trying to do exactly what you suggested in this patch. And looks like there was a second version posted which I completely missed: https://patchwork.freedesktop.org/series/115605/ While that does still have drm_rect_intersect() with its side effects inside the if() I don't find it quite as objectionable since it's the only thing in there. So it's a bit more obvious what is happening. I've gone and merged that one. Thanks for the patch regardless. At least I reminded me to look at the earlier attempt ;) > > BTW, the original patch somehow got mangled while it made its way to the > patchwork: source list line in patch got broken, which permits the patch > from being applied (the original version did not have that line break). > Any ideas how to prevent this happening with the second version of patch > (in case the idea is viable)?
diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c b/drivers/gpu/drm/i915/display/intel_overlay.c index 2b1392d5a902..1cda1c163a92 100644 --- a/drivers/gpu/drm/i915/display/intel_overlay.c +++ b/drivers/gpu/drm/i915/display/intel_overlay.c @@ -972,9 +972,8 @@ static int check_overlay_dst(struct intel_overlay *overlay, rec->dst_width, rec->dst_height); clipped = req; - drm_rect_intersect(&clipped, &crtc_state->pipe_src); - if (!drm_rect_visible(&clipped) || + if (!drm_rect_intersect(&clipped, &crtc_state->pipe_src) || !drm_rect_equals(&clipped, &req)) return -EINVAL; -- 2.34.1