From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C48E310F3DE2 for ; Sat, 28 Mar 2026 14:52:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D6D610E121; Sat, 28 Mar 2026 14:52:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="J5eulvBn"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CE4F10E121; Sat, 28 Mar 2026 14:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774709569; x=1806245569; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Nj65AVXv5ECweY6QhlEAy95vOjFQHw5ampBzfKUX14U=; b=J5eulvBnlCDFP7gSk2BnHCDBb4vgQCpConIMoW/vV046mlxb3EjSTt/6 2CmO3lmctjdTVZt0W4Pj6h+b/W/ip1ZqhzqRD+gaPx2D/M+pQoKqUPbss mz4jOQb3GA4yACvbd+KfGP35OdURHGEkiAbOntR1uZorcZ83vZ6/DlE71 R/C0Q1LHJGrMeJINw13QjABRpTOhMuZcxl+vobUodHXvL61JKoLVuac9W TmLxNIU6YrvXFzLNfvaiSJEPO1agjndgh2P646Ed7J8ZjrG5iE7CTU6LY 920ObZDd2ayGqsP2MwbcvP2lcoMMnXWowtuxJWtAO2fp2DExCAvDyKqLI Q==; X-CSE-ConnectionGUID: Lh47a2c3R/yz6RqehZKbkA== X-CSE-MsgGUID: 03a4PFGTQVCs7Lok2ciA8Q== X-IronPort-AV: E=McAfee;i="6800,10657,11742"; a="63313563" X-IronPort-AV: E=Sophos;i="6.23,146,1770624000"; d="scan'208";a="63313563" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2026 07:52:49 -0700 X-CSE-ConnectionGUID: gcM6p9VkQWukIJrcicJHDw== X-CSE-MsgGUID: FDupMcLjTjSTkAtZMBWK/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,146,1770624000"; d="scan'208";a="222267462" Received: from administrator-system-product-name.igk.intel.com ([10.91.214.181]) by fmviesa007.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2026 07:52:47 -0700 Date: Sat, 28 Mar 2026 15:52:45 +0100 (CET) From: =?ISO-8859-2?Q?Micha=B3_Grzelak?= To: =?ISO-8859-15?Q?Ville_Syrj=E4l=E4?= cc: =?ISO-8859-2?Q?Micha=B3_Grzelak?= , intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Nemesa Garg Subject: Re: [PATCH 4/9] drm/i915/casf: Extract scaler_has_casf() In-Reply-To: Message-ID: References: <20260326223139.19116-1-ville.syrjala@linux.intel.com> <20260326223139.19116-5-ville.syrjala@linux.intel.com> <5312c2aa-a724-9b98-aa95-e4a4fffe3e91@intel.com> <7de76a02-bf3e-49e0-52c0-14ef65c879c3@intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-635784336-1774709568=:601923" X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-635784336-1774709568=:601923 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Fri, 27 Mar 2026, Ville Syrjälä wrote: > On Fri, Mar 27, 2026 at 11:06:18AM +0100, Michał Grzelak wrote: >> On Fri, 27 Mar 2026, Michał Grzelak wrote: >>> On Thu, 26 Mar 2026, Ville Syrjala wrote: >>>> From: Ville Syrjälä >>>> >>>> Extract a small helper to determine if the scaler supports >>>> the sharpness filter or not. >>>> >>>> Cc: Nemesa Garg >>>> Signed-off-by: Ville Syrjälä >>>> --- >>>> drivers/gpu/drm/i915/display/skl_scaler.c | 12 ++++++++---- >>>> 1 file changed, 8 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c >>>> b/drivers/gpu/drm/i915/display/skl_scaler.c >>>> index e9fe5c0bf6ff..525afd736195 100644 >>>> --- a/drivers/gpu/drm/i915/display/skl_scaler.c >>>> +++ b/drivers/gpu/drm/i915/display/skl_scaler.c >>>> @@ -323,19 +323,24 @@ int skl_update_scaler_plane(struct intel_crtc_state >>>> *crtc_state, >>>> need_scaler); >>>> } >>>> >>>> +static bool scaler_has_casf(struct intel_display *display, int scaler_id) >>>> +{ >>>> + return HAS_CASF(display) && scaler_id == 1; >>>> +} >>>> + >>>> static int intel_allocate_scaler(struct intel_crtc_scaler_state >>>> *scaler_state, >>>> struct intel_crtc *crtc, >>>> struct intel_plane_state *plane_state, >>>> bool casf_scaler) >>>> { >>>> + struct intel_display *display = to_intel_display(crtc); >>>> int i; >>>> >>>> for (i = 0; i < crtc->num_scalers; i++) { >>>> if (scaler_state->scalers[i].in_use) >>>> continue; >>>> >>>> - /* CASF needs second scaler */ >>>> - if (!plane_state && casf_scaler && i != 1) >>>> + if (casf_scaler && !scaler_has_casf(display, i)) >>>> continue; >>>> >>>> scaler_state->scalers[i].in_use = true; >>>> @@ -982,8 +987,7 @@ void skl_scaler_get_config(struct intel_crtc_state >>>> *crtc_state) >>>> >>>> id = i; >>>> >>>> - /* Read CASF regs for second scaler */ >>>> - if (HAS_CASF(display) && id == 1) >>>> + if (scaler_has_casf(display, i)) >>> >>> With that being changed I am wondering if we need int id at all. The >>> only user of it is outside the loop. Since id is set to i on every >>> loop's pass, I guess we can replace it with last value of i. And if >>> crtc->num_scalers == -1, we wouldn't enter the loop anyway, so the id >>> is still set to -1. The only scenario I see where it can break is e.g. >>> when crtc->num_scalers == -2, but I have no clue if it is even possible. >>> >>> To be precise, I am wondering about such change (diff without your change >>> being applied): >>> >>> diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c >>> b/drivers/gpu/drm/i915/display/skl_scaler.c >>> index 4c4deac7f9c8..78852267e60b 100644 >>> --- a/drivers/gpu/drm/i915/display/skl_scaler.c >>> +++ b/drivers/gpu/drm/i915/display/skl_scaler.c >>> @@ -969,7 +969,6 @@ void skl_scaler_get_config(struct intel_crtc_state >>> *crtc_state) >>> struct intel_display *display = to_intel_display(crtc_state); >>> struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); >>> struct intel_crtc_scaler_state *scaler_state = >>> &crtc_state->scaler_state; >>> - int id = -1; >>> int i; >>> >>> /* find scaler attached to this pipe */ >>> @@ -980,8 +979,6 @@ void skl_scaler_get_config(struct intel_crtc_state >>> *crtc_state) >>> if ((ctl & (PS_SCALER_EN | PS_BINDING_MASK)) != (PS_SCALER_EN >>> | PS_BINDING_PIPE)) >>> continue; >>> >>> - id = i; >>> - >>> /* Read CASF regs for second scaler */ >>> if (HAS_CASF(display) && id == 1) >>> intel_casf_sharpness_get_config(crtc_state); >>> @@ -1003,8 +1000,8 @@ void skl_scaler_get_config(struct intel_crtc_state >>> *crtc_state) >>> break; >>> } >>> >>> - scaler_state->scaler_id = id; >>> - if (id >= 0) >>> + scaler_state->scaler_id = crtc->num_scalers; >>> + if (scaler_state->scaler_id >= 0) >>> scaler_state->scaler_users |= (1 << SKL_CRTC_INDEX); >>> else >>> scaler_state->scaler_users &= ~(1 << SKL_CRTC_INDEX); >>> >>> But I don't know if the reasoning above makes any sense. >> >> Now I see that I missed the continue-break magic, so please disregard >> the whole comment. > > I think the correct thing is to s/i/scaler_id/ and just move the > scaler_state->scaler_id and caler_state->scaler_users assignment into > the loop. > > Or even better something like this: > > skl_pipe_scaler_get_hw_state() > { > for (scaler_id) { > ctl = ... > if (ctl...) > return scaler_id; > } > > return -1; > } > > skl_scaler_get_config() > { > scaler_id = skl_pipe_scaler_get_hw_state(); > if (scaler_id < 0) > return; > > // do the scaler readout > } > > Feel free to go at it. > Now it makes sense, thanks. :) I've added you to couple of Suggested-by:, please correct me if I mishandled it. BR, Michał >>> >>> Reviewed-by: Michał Grzelak >>> >>>> intel_casf_sharpness_get_config(crtc_state); >>>> >>>> if (!crtc_state->pch_pfit.casf.enable) >>>> -- >>>> 2.52.0 >>>> >>>> >>> > > > -- > Ville Syrjälä > Intel > --8323329-635784336-1774709568=:601923--