Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 73658191F93 for ; Sat, 12 Sep 2026 14:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224123; cv=none; b=liXMf1+d+pftEShV8TR4LcLmd1I5taza0cFaLUzMgYyztNo0s8VusE2A60dOllE3jbavZWvOj+h1loCNf1YFvhg4S7Vxr1H13jsBD3Ws3ueoo+vTgRpj694gMhyJ3nEPNxe/eqkRmjSCpCt99f8gyhweTEsvTPVsypcqLl5ZaHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224123; c=relaxed/simple; bh=a7IZfIHGr3vFTvIdxAws+ryoZlq87jxysoMferfbWfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PEhCSl8/rc42Zxb5Zsd59vckzu+Wb1L9byARdC5+cQFaPjxKYkfolZydz31/4n+TSllF4/0wkTYUXNoY8YEeHCmibx5aJuxGidIfP9tXS1FAgNyEEboPjLOC0L9sVwreDdAnUL48TCw7vU/+4M/4yNtN92UEaohj3gBpkP2Wpak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Undm9dh0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Undm9dh0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B82D1F000FF; Sat, 12 Sep 2026 14:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789224122; bh=PTWDdiZc+qUX892OUbIxUHea70Qb9nFYXz2iNTZnf8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Undm9dh0c+lkAAJFESKfQ4rj0bWSzLVfor0Zkkz5fCM1iJ8wGF1mOTFLhnNN08r+I xSUQREAhEw2/rqR0gxZtUTjlqO/q/qbPdeyt0SDsoIgRDgc96oj6g7AGqz2zubfYAN TmcEbbIHZT+9FNgNs3bfEpUF7B+1OdL6I/MoTIxAV7L6AigwDeUtJITDzFRsbqHyap 4kcpZkXayufUxYhcT38gW6R3xsYxKrd+FsDbL4SkDyN0o67bp/p+nWcrSPkQp4HYrZ gRIflX6QdQ1grA/sBVHN7X7DHTRxIvrhxzihAmXoRHsz/8AW1PvyCYe09SFDJECQog wUsl27Ud4/pMw== From: Sasha Levin To: stable@vger.kernel.org Cc: Thomas Zimmermann , Yongbang Shi , Rongrong Zou , Sean Paul , Xinliang Liu , Dmitry Baryshkov , Baihan Li , Sasha Levin Subject: [PATCH 5.15.y] drm/hibmc: Use drm_atomic_helper_check_plane_state() Date: Sat, 12 Sep 2026 10:41:59 -0400 Message-ID: <20260912144159.2988791-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026090902-sequester-penpal-1d95@gregkh> References: <2026090902-sequester-penpal-1d95@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Thomas Zimmermann [ Upstream commit 715c5db68bdbd4a524b79ebf20fb61e880fffea0 ] Call drm_atomic_helper_check_plane_state() from the primary plane's atomic-check helper and replace the custom implementation. All plane's implementations of atomic_check should call the shared _check_plane_state() helper first. It adjusts the plane state for correct positioning, rotation and scaling of the plane. Do this even if the plane's CRTC has been disabled by setting the parameter can_update_disabled. The original code returned early in this case, but it's safe to so and cleaner to have all plane state initialized. As we don't set can_position, drm_atomic_helper_check_plane_state()'s visibility check tests if the plane covers all of the CRTC. This is a small change from the original code, which tested if the plane is exactly the size of the CRTC. With the new test, the plane still has to cover all of the CRTC, but can be larger than the CRTC's size. A later patch can fully implement this feature in hibmc. If the plane is disabled, the helper clears the visibility flag in the plane state. On errors or if the plane is not visible, the atomic-check helper can return early. Implement all this in hibmc and drop the custom code that does some of it. v2: - extend the commit description (Yongbang) Signed-off-by: Thomas Zimmermann Fixes: da52605eea8f ("drm/hisilicon/hibmc: Add support for display engine") Reviewed-by: Yongbang Shi Cc: Rongrong Zou Cc: Sean Paul Cc: Xinliang Liu Cc: Dmitry Baryshkov Cc: Baihan Li Cc: Yongbang Shi Cc: # v4.10+ Link: https://patch.msgid.link/20260618123142.92298-2-tzimmermann@suse.de [ adapted to 5.15’s drm_atomic_state signature and DRM_PLANE_HELPER_NO_SCALING constant from drm_plane_helper.h. ] Signed-off-by: Sasha Levin --- .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 47 ++++++------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c index db7fce4e8cc34..0b619ad8741ae 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "hibmc_drm_drv.h" @@ -72,46 +73,28 @@ static int hibmc_get_best_clock_idx(const struct drm_display_mode *mode) static int hibmc_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, - plane); - struct drm_framebuffer *fb = new_plane_state->fb; - struct drm_crtc *crtc = new_plane_state->crtc; - struct drm_crtc_state *crtc_state; - u32 src_w = new_plane_state->src_w >> 16; - u32 src_h = new_plane_state->src_h >> 16; - - if (!crtc || !fb) - return 0; + struct drm_plane_state *new_plane_state = + drm_atomic_get_new_plane_state(state, plane); + struct drm_crtc_state *new_crtc_state = NULL; + int ret; - crtc_state = drm_atomic_get_crtc_state(state, crtc); - if (IS_ERR(crtc_state)) - return PTR_ERR(crtc_state); + if (new_plane_state->crtc) + new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_state->crtc); - if (src_w != new_plane_state->crtc_w || src_h != new_plane_state->crtc_h) { - drm_dbg_atomic(plane->dev, "scale not support\n"); - return -EINVAL; - } - - if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) { - drm_dbg_atomic(plane->dev, "crtc_x/y of drm_plane state is invalid\n"); - return -EINVAL; - } - - if (!crtc_state->enable) + ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, true); + if (ret) + return ret; + else if (!new_plane_state->visible) return 0; - if (new_plane_state->crtc_x + new_plane_state->crtc_w > - crtc_state->adjusted_mode.hdisplay || - new_plane_state->crtc_y + new_plane_state->crtc_h > - crtc_state->adjusted_mode.vdisplay) { - drm_dbg_atomic(plane->dev, "visible portion of plane is invalid\n"); - return -EINVAL; - } - if (new_plane_state->fb->pitches[0] % 128 != 0) { drm_dbg_atomic(plane->dev, "wrong stride with 128-byte aligned\n"); return -EINVAL; } + return 0; } -- 2.53.0