From patchwork Mon May 29 07:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13258255 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 5F780C7EE23 for ; Mon, 29 May 2023 07:19:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64E8010E214; Mon, 29 May 2023 07:19:05 +0000 (UTC) Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4017410E214 for ; Mon, 29 May 2023 07:19:03 +0000 (UTC) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3X9eqYgEzMDzt3X9eq4QMn; Mon, 29 May 2023 09:19:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685344740; bh=ToQuNxvWCS00We22b4WvFzbjWsFm90sAaGVlSiXzZ6A=; h=From:To:Cc:Subject:Date; b=N0OGot8XgN/sgaRBBPtv8sAmxBbjCRQT9O8f739VgP6/PefDcz4qn4+sQQ4buhqA8 fAc/X2jePdXNNBWmTWvgbUp9Ryp8kHWEDgJmdzV8ZHE8c1YY413djR6ZWGI8tjM7GY fQLYY7JVDeWvBPzsWhh3RHmI0aLvzF0lmu23syr3EuHsiPzq+pwh17fxnJCmfsb7/j iuwSEeqSG/cl3+zCv29bZ+NSC0beKhU3a8viZBb92BUsu6ZKRr/ioSKfkXVgzCf4ft vipwGXayXPCFv1AUaJfDRHr8JmJ2AbFb3IS6GFQko1QKSbRwVykQrP2aT2+cJnfe+V vbfQ3xCVLrLbQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 29 May 2023 09:19:00 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Subject: [PATCH 1/3] drm/amd/display: Fix an erroneous sanity check in get_dmif_switch_time_us() Date: Mon, 29 May 2023 09:18:54 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe JAILLET , dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It is likely that there is a typo in the sanity check for 'v_total'. If it is 0, then 'pixels_per_frame' will also be 0, and in this case, we also return 'single_frame_time_multiplier * min_single_frame_time_us'. So test for !v_total which looks much more logical. Fixes: 4562236b3bc0 ("drm/amd/dc: Add dc display driver (v2)") Signed-off-by: Christophe JAILLET --- drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c index 4cdd4dacb761..091f0d68a045 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c @@ -683,7 +683,7 @@ static uint32_t get_dmif_switch_time_us( /*return double of frame time*/ const uint32_t single_frame_time_multiplier = 2; - if (!h_total || v_total || !pix_clk_khz) + if (!h_total || !v_total || !pix_clk_khz) return single_frame_time_multiplier * min_single_frame_time_us; /*TODO: should we use pixel format normalized pixel clock here?*/ From patchwork Mon May 29 07:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13258256 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 BF01BC77B7E for ; Mon, 29 May 2023 07:19:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D69FB10E22E; Mon, 29 May 2023 07:19:12 +0000 (UTC) Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DEB310E22E for ; Mon, 29 May 2023 07:19:10 +0000 (UTC) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3X9eqYgEzMDzt3X9oq4QNQ; Mon, 29 May 2023 09:19:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685344748; bh=E29VI58F9t8lbiMbudotJ9ysUUBZknzo+5bxInVW578=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qN2RdXC/1SfqjAN9PDebvToRpP+JJUk8Q6FA4M43mFXtgHgv0S+f9x8BrEfyJZ44v mtS4PdX+9TjiYH+BNk64ndNK/Ckh2i5e6HYPe7JvC5eyR7vhJiDCWSCrkLW6IRGsti 4SbpZPIOkkBBr7xntU7liZnyPVJiF7mWgIksIwA3ms5JM7fsRK4Z5j0IJuIuFPi4rB rfVPxOjaTrYe/94URzYk1vwNsONPBvEQ7qOSB8Ik7Tz2YlnOHjqwVnq437SS7RmZeL xBlZ05K7U4aOtAjKzaQnJdRGcfQaCyE1b6xVOIiTFfCpG6wSLH9XXT4nbw/XPv1Y+L PT7MiJgsJiDfQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 29 May 2023 09:19:08 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Subject: [PATCH 2/3] drm/amd/display: Simplify get_dmif_switch_time_us() Date: Mon, 29 May 2023 09:18:55 +0200 Message-Id: <1ab1210048a4b485247cccba6721f1885c986331.1685342739.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe JAILLET , dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Thanks to the sanity check a few lines above: if (!h_total || !v_total || !pix_clk_khz) and the computation done afterwards on these non 0 values, we know that 'pixels_per_second', 'pixels_per_frame' and 'refresh_rate' are not 0 The code can be simplified accordingly. Signed-off-by: Christophe JAILLET --- NOT compile tested. Because of some BROKEN in KConfig files. --- drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c index 091f0d68a045..eafe8561e55e 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c @@ -690,21 +690,8 @@ static uint32_t get_dmif_switch_time_us( pixels_per_second = pix_clk_khz * 1000; pixels_per_frame = h_total * v_total; - if (!pixels_per_second || !pixels_per_frame) { - /* avoid division by zero */ - ASSERT(pixels_per_frame); - ASSERT(pixels_per_second); - return single_frame_time_multiplier * min_single_frame_time_us; - } - refresh_rate = pixels_per_second / pixels_per_frame; - if (!refresh_rate) { - /* avoid division by zero*/ - ASSERT(refresh_rate); - return single_frame_time_multiplier * min_single_frame_time_us; - } - frame_time = us_in_sec / refresh_rate; if (frame_time < min_single_frame_time_us) From patchwork Mon May 29 07:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13258257 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 0D7F2C77B7A for ; Mon, 29 May 2023 07:19:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5227410E239; Mon, 29 May 2023 07:19:18 +0000 (UTC) Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C6EC10E238 for ; Mon, 29 May 2023 07:19:17 +0000 (UTC) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3X9eqYgEzMDzt3X9vq4QNv; Mon, 29 May 2023 09:19:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685344755; bh=QHA/Y0t0+ZEe+OD0y5zfwImt3ZyVK3OrMC3Z9s2pa1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W7r6xtOwhhzprrKfnZGh0T9qW6D98nODcTPYdrrsDy8UKp9fEcacSAXQkx7QVuWsz vE44t8MRi8+dK7gLek1AWrWxPl2qATJxc8HrbjAGOwLvfuSOuHMg8DP6xMcVD+Q/hF /zkkum9tvQek+TK7Z7XtphlqTNEWEXI55kvwobij7TzAVfmh+PJgyMsTYhyjUXYimY Evlsvd/Mq++SUL8fVPRhVdmAdbSLzHn0uzjvyRgyt9LioGM/9JBO4zihT7xxKHZ/If NW7ybU0zzERVByEtGA9ueYwMHYxdLYXlp9F7FUWyRqUTynkURq6ySZq3E7kKqkpFHx sSecbvRt+wSiw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 29 May 2023 09:19:15 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Subject: [PATCH 3/3] drm/amd/display: Use USEC_PER_SEC Date: Mon, 29 May 2023 09:18:56 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe JAILLET , dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use USEC_PER_SEC instead of defining an equivalent local 'us_in_sec'. Signed-off-by: Christophe JAILLET --- NOT compile tested. Because of some BROKEN in KConfig files. Some header may be missing for USEC_PER_SEC! --- drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c index eafe8561e55e..9b82ee3e06d0 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c @@ -678,7 +678,6 @@ static uint32_t get_dmif_switch_time_us( uint32_t pixels_per_second; uint32_t pixels_per_frame; uint32_t refresh_rate; - const uint32_t us_in_sec = 1000000; const uint32_t min_single_frame_time_us = 30000; /*return double of frame time*/ const uint32_t single_frame_time_multiplier = 2; @@ -691,8 +690,7 @@ static uint32_t get_dmif_switch_time_us( pixels_per_frame = h_total * v_total; refresh_rate = pixels_per_second / pixels_per_frame; - - frame_time = us_in_sec / refresh_rate; + frame_time = USEC_PER_SEC / refresh_rate; if (frame_time < min_single_frame_time_us) frame_time = min_single_frame_time_us;