From patchwork Tue Jun 20 06:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13285210 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 89F60EB64D8 for ; Tue, 20 Jun 2023 06:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jpy8P4uZA0yEZbWI6/0Xe+AoljIwK9tpaQkZziLbDgM=; b=1P8ZWhKVcV3lRGnlWSvFdbjS8q BAiRVaTnqsp6BLNP6YS4zR4cu/MuXKh3OKJhA8vJSzAmB4EwnFPQ+H4TnzO7idqS+oefSsHrfTi00 +XpTdZxMT4pxc2cFJI0HNKh8fGZ17XnA78c4ZHXH4BygD3NrBEJcPXB+H4lxsvSJEkuB9BVpBjwC0 VJsRbWsaSEz3nc9qOmQkzaIiZowURO5l3hOptFAc2syemat5PbQkfNIdZleWpVT+hhXFA63tXlawH fnQ5iZfLwHgqskJBym4rklg7cik3EQ1prVT3Hh1l1Xj3HMDoPT0x+pqnc+fJtpUpffwIz5/K36FOT dOkMLikw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9V-00AIdc-13; Tue, 20 Jun 2023 06:47:45 +0000 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9Q-00AIZX-0y for linux-rockchip@lists.infradead.org; Tue, 20 Jun 2023 06:47:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=7VAyeHaEUSj0bxluLt7sEIx5TaeytzztFbaHZjpZj8k=; b=Yaqr4eSXajGdW3zb2Vo2erptc07KneJhPCDUZVBW/po6bK5+S4DfDUx16e3mWY604Vol 42CmRW44ZDXak2Wf109cwtPdk0m1v3PspGogcKjTcOVTBfOVrA/kcYV+6tM4E108c1005O dpNlbjr+yHGZkEzmgRM5GfLRjW/p6OFlLkC4UT18QsQrc9R/RhiuG47nt/MeSBjWIaNWjr b4dVBGoSokJnz+D9hN78+vYKuVw1naEeCIjozjR5NJpS3EJP2pfeA8lERb6XKG8fLTjQn4 ALOG/ILTsSroZahOP6/u51c2PomFzTUbNCcQ8uUjysK3OUxiFxod8W27QcMt5aGw== Received: by filterdrecv-65f68489c8-knmdt with SMTP id filterdrecv-65f68489c8-knmdt-1-64914B88-8 2023-06-20 06:47:36.28238049 +0000 UTC m=+3481898.218316761 Received: from bionic.localdomain (unknown) by geopod-ismtpd-5 (SG) with ESMTP id OucGoYNtQB-78UXqJGyOIw Tue, 20 Jun 2023 06:47:36.053 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 1/4] drm/rockchip: vop: Fix reset of state in duplicate state crtc funcs Date: Tue, 20 Jun 2023 06:47:36 +0000 (UTC) Message-ID: <20230620064732.1525594-2-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620064732.1525594-1-jonas@kwiboo.se> References: <20230620064732.1525594-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0hxFAD2iWJqHQE2VFrfjH7oZLbnsxnWN5pOReYr+8l0s7F6R6sTfG3KkB8tSvbGGbhywgNax29XYxC/7RMyoEnmWQVOwBB1lSvlOkoqbU/ibnnSecm3h5PGKW3nmxbm0xNk+cCWw5hw4BdROLlDO5x0yxMqAKQxrSeTl+uAXqQZ7GNDWP25y/dwaTEGBjlbtRmA== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Mark Yao Cc: Andy Yan , Sascha Hauer , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230619_234740_418892_60EC3AC4 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org struct rockchip_crtc_state members such as output_type, output_bpc and enable_afbc is always reset to zero in the atomic_duplicate_state crtc funcs. Fix this by using kmemdup on the subclass rockchip_crtc_state struct. Fixes: 4e257d9eee23 ("drm/rockchip: get rid of rockchip_drm_crtc_mode_config") Signed-off-by: Jonas Karlman Reviewed-by: Sascha Hauer --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index a530ecc4d207..60b23636a3fe 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1614,7 +1614,8 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) if (WARN_ON(!crtc->state)) return NULL; - rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL); + rockchip_state = kmemdup(to_rockchip_crtc_state(crtc->state), + sizeof(*rockchip_state), GFP_KERNEL); if (!rockchip_state) return NULL; From patchwork Tue Jun 20 06:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13285211 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A7B4DEB64DD for ; Tue, 20 Jun 2023 06:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yr32UsUXC3vXYhUC85TGAFIzGNAhwQsocddyJCkWtxw=; b=aOVmdES2rL40MEWAgWfgmz9dGd Q3Z99w6oukdKzVNqlNo1TZT93c2SBmC7guy0m89LTytXOGQ2b5HQdYzZ/NW+ye2WeRsQQIEFxcCPX 9dq13lgHPgikOhxeUQOOmO958UP+iU0N4gTxIbsAk4xGGZ9khjZf2M0oWkG+j+kvK1jDafBXS43oE SFdC4uTWj2cTvTiGRaEXiv0naU9awY7NtUHYDqjDb/OntayKnuZL1RnyhHejNtwY5lgcjrSXxXr2P MSOnVrR8Nu94Tg0wGU+yRhz9RKGwWWwL6VKYjfCcm9zjG5rn6GwY2I+DO0BdEYrPL+WIEzcX3XSLT yGKT0lhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9a-00AIgY-2b; Tue, 20 Jun 2023 06:47:50 +0000 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9Q-00AIZV-1G for linux-rockchip@lists.infradead.org; Tue, 20 Jun 2023 06:47:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=WIftQBIpIy4TYM/w/l437zYjnaja+iEv9fSTQdcIaxc=; b=DD8iiQ3BAznRD1abNxYFKd9FHfceipbNMrV1hgdm7Tior8YDCBRjEgOXsTiSHl10CIFg c9EJnBeSFAU/kN1aAyQld2KFKR61y8VXWQExNua3TYlYNv4v7sbgDt3wWlCID2MvbIQE1H TKK/Qm0UXcDm3Wbp/tFsqOISysV8dMJjAdgjo0t4IooRVDydt9d1Sp7IVsCIGMQflMGMTJ QkvgEoQ9zQGRA4IeTiwzwWvVEv7GPpNdgtH6MrSUu1t6qaUsB4GRZfBWqXkHNnWPtd6gVS 2kmfOP2nxBtMo+eVPQndktCzKStTkBNpLQgqSMCyGoIucG8Rk+d99MUwSt+NIiDA== Received: by filterdrecv-84b96456cb-rsmc4 with SMTP id filterdrecv-84b96456cb-rsmc4-1-64914B89-1E 2023-06-20 06:47:37.498149536 +0000 UTC m=+3481757.706840986 Received: from bionic.localdomain (unknown) by geopod-ismtpd-5 (SG) with ESMTP id ZMjEKrw4Qmu6N8KSTS7lHQ Tue, 20 Jun 2023 06:47:37.177 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 2/4] drm/rockchip: vop: Use cleanup helper directly as destroy funcs Date: Tue, 20 Jun 2023 06:47:37 +0000 (UTC) Message-ID: <20230620064732.1525594-3-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620064732.1525594-1-jonas@kwiboo.se> References: <20230620064732.1525594-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h+3K61RI4BbEH1WyovFH13WxQgrm+3EFl7eTAtcTWehbd5CjXWBfBMemcOLPT8tHF4GvEfty/J9+9b1lO9STEgArffL3tM9doL3YygCvl15zgZ5dHuvbfpVEivoEqrBAPBzafYzaHSv5iNyxVzm9JYLsU3lNl5pbVgB3nyNKCtL3Kn14bRH1J01cAZVF8pBd6w== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter Cc: Mark Yao , Andy Yan , Sascha Hauer , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230619_234740_554255_7961D5CC X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org vop_plane_destroy and vop_crtc_destroy are plain wrappers around drm_plane_cleanup and drm_crtc_cleanup. Use them directly as plane and crtc funcs to closer match VOP2 driver. Signed-off-by: Jonas Karlman Reviewed-by: Sascha Hauer --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 60b23636a3fe..25c873d4ff53 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -766,11 +766,6 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, } } -static void vop_plane_destroy(struct drm_plane *plane) -{ - drm_plane_cleanup(plane); -} - static inline bool rockchip_afbc(u64 modifier) { return modifier == ROCKCHIP_AFBC_MOD; @@ -1131,7 +1126,7 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = { static const struct drm_plane_funcs vop_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = vop_plane_destroy, + .destroy = drm_plane_cleanup, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, @@ -1602,11 +1597,6 @@ static const struct drm_crtc_helper_funcs vop_crtc_helper_funcs = { .atomic_disable = vop_crtc_atomic_disable, }; -static void vop_crtc_destroy(struct drm_crtc *crtc) -{ - drm_crtc_cleanup(crtc); -} - static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) { struct rockchip_crtc_state *rockchip_state; @@ -1711,7 +1701,7 @@ vop_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name, static const struct drm_crtc_funcs vop_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip, - .destroy = vop_crtc_destroy, + .destroy = drm_crtc_cleanup, .reset = vop_crtc_reset, .atomic_duplicate_state = vop_crtc_duplicate_state, .atomic_destroy_state = vop_crtc_destroy_state, @@ -1962,7 +1952,7 @@ static void vop_destroy_crtc(struct vop *vop) */ list_for_each_entry_safe(plane, tmp, &drm_dev->mode_config.plane_list, head) - vop_plane_destroy(plane); + drm_plane_cleanup(plane); /* * Destroy CRTC after vop_plane_destroy() since vop_disable_plane() From patchwork Tue Jun 20 06:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13285213 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 550CAEB64D8 for ; Tue, 20 Jun 2023 06:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8Tvp32nOiQkFutcRJf9hCdqPcIYpYoTXti5dTKm3l/8=; b=iWsxCE7k0afc8Ef1KRaC0/ffoX 3D7xdT0UVDlQVf4QORWhkrbN4sEM8tG2pbrlOo8QGNfB2hz8GJaskS1ZTqed+hBdjsWYBfgh2St2Q QyNxiDdoJ45E3VseBnLLkUOPogfmXw7HQ5usbgNIq+mGnryAWEjXiQStgjJ4NTFkmvUJC3hPrDPKY A355n2ly3ehaqvQPjq8JjbqX09Dp6XgcpxlzCpkH0D8L6QCkAcDeEG8lFgKljOs/0gr8deeQ1+Ys2 xMz643/O+hXoxrLm8ViSzy7Ay9t31TRR26FYhZ9Rk0HIl6Wa++2WFmyGPyNJ6MVigGJpUmuqzjPZd tAb669mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9a-00AIgM-1F; Tue, 20 Jun 2023 06:47:50 +0000 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9Q-00AIZa-2L for linux-rockchip@lists.infradead.org; Tue, 20 Jun 2023 06:47:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=5pbgdWNmSy9aPDMPkbL8AbjV9U0EnRo0+ZChKli6JfM=; b=eVrS5554pcjPfv9qQqL7hGY0jyiDvsj9RT7apUoZX0grmM3rUFRKnLhEDdf4ygOm1p1Q 0r3S4yOzh2Rqg2ol1RfyIADEiNF/f+K2skcpAAZwtoT7B9cIZe9JerudoUS5PHLLWN0lBA gwj2sQZssKqPGbWx0LdzP9ZMxjP8azYEKdVZEl78Joe+ftZF0V9buBCwNynFdPHd0FiYWZ HVq50Ln69Irhwmf5ZSzV/eUAlDJKUVOzoOEqYnTBvwJ5VIktfdqbKRKuheFxvCA6akmLvf tIJxBJrfY+FMZf0GXdg3Bw4U10ByCZcH6kXilzSMw63jIncJb96Bo5tCIvgOOQrg== Received: by filterdrecv-84b96456cb-5hl7m with SMTP id filterdrecv-84b96456cb-5hl7m-1-64914B8A-11 2023-06-20 06:47:38.471885304 +0000 UTC m=+3481762.440632816 Received: from bionic.localdomain (unknown) by geopod-ismtpd-5 (SG) with ESMTP id RoZFBd_nQNK1YqBzlZ8GTA Tue, 20 Jun 2023 06:47:38.183 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 3/4] drm/rockchip: vop2: Don't crash for invalid duplicate_state Date: Tue, 20 Jun 2023 06:47:38 +0000 (UTC) Message-ID: <20230620064732.1525594-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620064732.1525594-1-jonas@kwiboo.se> References: <20230620064732.1525594-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h+eHmV8Nkxhx/pGei3g0n+d3x8Np2TBP3wBP6EHYLmaspDk9WVqgJCxMF3L9wcKO7JYi6qnKjNs2IVQjlFzRSo9BdNyixoWioyn4a99eKnBuPXlbCnUzbMH11YwLP0DwC51taHbX9wYpASN++FUl579/N27U+ahU4pTUUTpEjYKHjHc+zeSjFVIYEYd2OZZ3cw== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Andy Yan , Sascha Hauer , Rob Herring Cc: Mark Yao , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230619_234740_891776_77CD4C53 X-CRM114-Status: GOOD ( 11.27 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org It's possible for users to try to duplicate the CRTC state even when the state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other users of __drm_atomic_helper_crtc_duplicate_state()) already guard this with a WARN_ON() instead of crashing, so let's do that here too. Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver") Signed-off-by: Jonas Karlman Reviewed-by: Sascha Hauer --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index ca73b8ccc29f..f725487d02ef 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -2099,11 +2099,13 @@ static void vop2_crtc_reset(struct drm_crtc *crtc) static struct drm_crtc_state *vop2_crtc_duplicate_state(struct drm_crtc *crtc) { - struct rockchip_crtc_state *vcstate, *old_vcstate; + struct rockchip_crtc_state *vcstate; - old_vcstate = to_rockchip_crtc_state(crtc->state); + if (WARN_ON(!crtc->state)) + return NULL; - vcstate = kmemdup(old_vcstate, sizeof(*old_vcstate), GFP_KERNEL); + vcstate = kmemdup(to_rockchip_crtc_state(crtc->state), + sizeof(*vcstate), GFP_KERNEL); if (!vcstate) return NULL; From patchwork Tue Jun 20 06:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13285212 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B2E72EB64DB for ; Tue, 20 Jun 2023 06:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=obk9aw/mddclBLQx/JCQyjfYhSCopRhSGiAKZSMRNew=; b=hQM13JyH4P8L2ja3Qoa2rKf/Ev x44//MceVbY+SQytHtxlXxnDE27/UCHmGYyG4Z9JbfkAQsm4bLq2nHwI9rBEFqI+bhqypknr4r0z+ ap2UHvxLwXLoT0vs1x+415DZlCvXknx4aXnqSFV3xO0J51Zb0jLgFHggFksjeKHeuTJUgt1GyRn1L HLlzBQ6uPw94WNdIuUv8LestEDEzZibK+Y/g0oDCpEDcJkKHGgmvX0iDgk/GBkMzz7iBwCsrfNDm4 svBuOKeKM8H7NiQvxQsutQOHGBC4cRkYBLqxF75bZFBpYiGN1Fg8r+rDz+3R8QkCGzCmXv0sbLl3o SOA0shSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9c-00AIiU-2Q; Tue, 20 Jun 2023 06:47:52 +0000 Received: from s.wrqvtbkv.outbound-mail.sendgrid.net ([149.72.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBV9R-00AIaQ-0l for linux-rockchip@lists.infradead.org; Tue, 20 Jun 2023 06:47:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=DWKAFEQyu98IZ9ZgJni/kueEjxYsF0HocTjSZNu5dc0=; b=cMGNWwX+FeprtsjEHvLYOSUZ211lLDMzQXxmXdfQhxXIqJbaWseCwlohRjzI8kWuzPVL O2VB9JXBKQsD/DbNxiMXMzrmLn03KrwtiWKFhwPTDUONzAcndz3OJxTXiIAK43QzW2FAgE ZBRJwv8azP6NtTHPv24FUCskm796yXLRLWHErC/HoPfWA8IK21mKgKU19TUubA+a121BpS Ly4qAioPvfhZiYD2EEmJz8Hamf+flxBeMdXw28hgWOzvmHMFcZWbHUgXLCnEGc4DjPpMSt uZHz+RNGL0QnNHtiF32vqkQMt/KjyLSk43zlGMXPfeWilVw59ShCanwl9SXr73IA== Received: by filterdrecv-77869f68cc-wnrh7 with SMTP id filterdrecv-77869f68cc-wnrh7-1-64914B8B-15 2023-06-20 06:47:39.640836851 +0000 UTC m=+3481899.293266760 Received: from bionic.localdomain (unknown) by geopod-ismtpd-5 (SG) with ESMTP id HGVB4aOXSe-PK4Ce6TiCSw Tue, 20 Jun 2023 06:47:39.424 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 4/4] drm/rockchip: vop2: Add missing call to crtc reset helper Date: Tue, 20 Jun 2023 06:47:39 +0000 (UTC) Message-ID: <20230620064732.1525594-5-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620064732.1525594-1-jonas@kwiboo.se> References: <20230620064732.1525594-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h6Y7pOvDXJbRf1XNurdBi7Uj4gm/qSVvpHVBX1ECIzrzeDP264QZlPK8XVyx2htZ01V+Bv6v+2TFKR+yi8Clec0YVFiObQjcVcrjSTKLgtIPg/z6on3AmvrZ9dWgl0nMs7hQ0mDHCKKH4CtLHNBiHnfIS2pPhliDFmPkc6fWluY8rQZBMqgYql4icV6wlJDsYw== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Rob Herring , Andy Yan , Sascha Hauer Cc: Mark Yao , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230619_234741_350506_0C000441 X-CRM114-Status: GOOD ( 10.33 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Add missing call to crtc reset helper to properly vblank reset. Also move vop2_crtc_reset and call vop2_crtc_destroy_state to simplify and remove duplicated code. Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver") Signed-off-by: Jonas Karlman --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 28 ++++++++------------ 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index f725487d02ef..1be84fe0208f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -2080,23 +2080,6 @@ static const struct drm_crtc_helper_funcs vop2_crtc_helper_funcs = { .atomic_disable = vop2_crtc_atomic_disable, }; -static void vop2_crtc_reset(struct drm_crtc *crtc) -{ - struct rockchip_crtc_state *vcstate = to_rockchip_crtc_state(crtc->state); - - if (crtc->state) { - __drm_atomic_helper_crtc_destroy_state(crtc->state); - kfree(vcstate); - } - - vcstate = kzalloc(sizeof(*vcstate), GFP_KERNEL); - if (!vcstate) - return; - - crtc->state = &vcstate->base; - crtc->state->crtc = crtc; -} - static struct drm_crtc_state *vop2_crtc_duplicate_state(struct drm_crtc *crtc) { struct rockchip_crtc_state *vcstate; @@ -2123,6 +2106,17 @@ static void vop2_crtc_destroy_state(struct drm_crtc *crtc, kfree(vcstate); } +static void vop2_crtc_reset(struct drm_crtc *crtc) +{ + struct rockchip_crtc_state *vcstate = + kzalloc(sizeof(*vcstate), GFP_KERNEL); + + if (crtc->state) + vop2_crtc_destroy_state(crtc, crtc->state); + + __drm_atomic_helper_crtc_reset(crtc, &vcstate->base); +} + static const struct drm_crtc_funcs vop2_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip,