All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wayne Lin <Wayne.Lin@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Zaeem Mohamed <zaeem.mohamed@amd.com>,
	Solomon Chiu <solomon.chiu@amd.com>,
	Daniel Wheeler <daniel.wheeler@amd.com>,
	Alex Hung <alex.hung@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 17/27] drm/amd/display: Use _free() macro for amdgpu_dm_commit_zero_streams()
Date: Tue, 25 Feb 2025 14:36:00 +0800	[thread overview]
Message-ID: <20250225063610.631461-18-Wayne.Lin@amd.com> (raw)
In-Reply-To: <20250225063610.631461-1-Wayne.Lin@amd.com>

From: Mario Limonciello <mario.limonciello@amd.com>

All cases except a failure to create a copy of the current context will
call dc_state_release() on the copied context.

Use a _free() macro to free the context and then adjust the error handling
flow to drop the unnecessary use of goto statements.

Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 24 ++++++++-----------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index fbeb3e89675b..6e218e69f039 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3083,10 +3083,11 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev,
 
 }
 
+DEFINE_FREE(state_release, struct dc_state *, if (_T) dc_state_release(_T))
+
 static enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc)
 {
-	struct dc_state *context = NULL;
-	enum dc_status res = DC_ERROR_UNEXPECTED;
+	struct dc_state *context __free(state_release) = NULL;
 	int i;
 	struct dc_stream_state *del_streams[MAX_PIPES];
 	int del_streams_count = 0;
@@ -3096,7 +3097,7 @@ static enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc)
 
 	context = dc_state_create_current_copy(dc);
 	if (context == NULL)
-		goto context_alloc_fail;
+		return DC_ERROR_UNEXPECTED;
 
 	/* First remove from context all streams */
 	for (i = 0; i < context->stream_count; i++) {
@@ -3107,25 +3108,20 @@ static enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc)
 
 	/* Remove all planes for removed streams and then remove the streams */
 	for (i = 0; i < del_streams_count; i++) {
-		if (!dc_state_rem_all_planes_for_stream(dc, del_streams[i], context)) {
-			res = DC_FAIL_DETACH_SURFACES;
-			goto fail;
-		}
+		enum dc_status res;
+
+		if (!dc_state_rem_all_planes_for_stream(dc, del_streams[i], context))
+			return DC_FAIL_DETACH_SURFACES;
 
 		res = dc_state_remove_stream(dc, context, del_streams[i]);
 		if (res != DC_OK)
-			goto fail;
+			return res;
 	}
 
 	params.streams = context->streams;
 	params.stream_count = context->stream_count;
-	res = dc_commit_streams(dc, &params);
-
-fail:
-	dc_state_release(context);
 
-context_alloc_fail:
-	return res;
+	return dc_commit_streams(dc, &params);
 }
 
 static void hpd_rx_irq_work_suspend(struct amdgpu_display_manager *dm)
-- 
2.37.3


  parent reply	other threads:[~2025-02-25  6:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  6:35 [PATCH 00/27] DC Patches Feb. 25, 2025 Wayne Lin
2025-02-25  6:35 ` [PATCH 01/27] drm/amd/display: Request HW cursor on DCN3.2 with SubVP Wayne Lin
2025-02-25  6:35 ` [PATCH 02/27] drm/amd/display: Fix p-state type when p-state is unsupported Wayne Lin
2025-02-25  6:35 ` [PATCH 03/27] drm/amd/display: Fix DMUB reset sequence for DCN401 Wayne Lin
2025-02-25  6:35 ` [PATCH 04/27] drm/amd/display: read mso dpcd caps Wayne Lin
2025-02-25  6:35 ` [PATCH 05/27] drm/amd/display: misc for dio encoder refactor Wayne Lin
2025-02-25  6:35 ` [PATCH 06/27] drm/amd/display: Skip checking FRL_MODE bit for PCON BW determination Wayne Lin
2025-02-25  6:35 ` [PATCH 07/27] drm/amd/display: Remove unused struct definition Wayne Lin
2025-02-25  6:35 ` [PATCH 08/27] drm/amd/display: Check NULL connector before it is used Wayne Lin
2025-02-25  6:35 ` [PATCH 09/27] drm/amd/display: Revert "Increase halt timeout for DMCUB to 1s" Wayne Lin
2025-02-25  6:35 ` [PATCH 10/27] drm/amd/display: Ensure DMCUB idle before reset on DCN31/DCN35 Wayne Lin
2025-02-25  6:35 ` [PATCH 11/27] drm/amd/display: Added visual confirm for DCC Wayne Lin
2025-02-25  6:35 ` [PATCH 12/27] drm/amd/display: wait for outstanding hw updates Wayne Lin
2025-02-25  6:35 ` [PATCH 13/27] drm/amd/display: Add tunneling IRQ handler Wayne Lin
2025-02-25  6:35 ` [PATCH 14/27] drm/amd/display: Change amdgpu_dm_irq_suspend() to void Wayne Lin
2025-02-25  6:35 ` [PATCH 15/27] drm/amd/display: Drop `ret` variable from dm_suspend() Wayne Lin
2025-02-25  6:35 ` [PATCH 16/27] drm/amd/display: Catch failures for amdgpu_dm_commit_zero_streams() Wayne Lin
2025-02-25  6:36 ` Wayne Lin [this message]
2025-02-25  6:36 ` [PATCH 18/27] drm/amd/display: Use drm_err() instead of DRM_ERROR in dm_resume() Wayne Lin
2025-02-25  6:36 ` [PATCH 19/27] drm/amd/display: Use scoped guard for dm_resume() Wayne Lin
2025-02-25  6:36 ` [PATCH 20/27] drm/amd/display: Change amdgpu_dm_irq_resume_*() to use drm_dbg() Wayne Lin
2025-02-25  6:36 ` [PATCH 21/27] drm/amd/display: Change amdgpu_dm_irq_resume_*() to void Wayne Lin
2025-02-25  6:36 ` [PATCH 22/27] drm/amd/display: Use _free(kfree) for dm_gpureset_commit_state() Wayne Lin
2025-02-25  6:36 ` [PATCH 23/27] drm/amd/display: Use scoped guard for amdgpu_dm_update_connector_after_detect() Wayne Lin
2025-02-25  6:36 ` [PATCH 24/27] drm/amd/display: Use _free() macro " Wayne Lin
2025-02-25  6:36 ` [PATCH 25/27] drm/amd/display: Use scoped guards for handle_hpd_irq_helper() Wayne Lin
2025-02-25  6:36 ` [PATCH 26/27] drm/amd/display: Use drm_err() " Wayne Lin
2025-02-25  6:36 ` [PATCH 27/27] drm/amd/display: Promote DAL to 3.2.323 Wayne Lin

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=20250225063610.631461-18-Wayne.Lin@amd.com \
    --to=wayne.lin@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=mario.limonciello@amd.com \
    --cc=roman.li@amd.com \
    --cc=solomon.chiu@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=zaeem.mohamed@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.