From patchwork Wed Jun 21 22:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13287997 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 4141CEB64DC for ; Wed, 21 Jun 2023 22:33:39 +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=vK4Btp5SbmvevpNeQdtFhYcNAgLTi8jr8ibcN4olIBM=; b=IQzm6li1OhxMN+vT4BwGqqC4oq +mUdqRiBgT5xRYkEvi90eFvWLaNoq4414l7/Q9qXB8fxmqn+ZIwfKUipthZI2uMQOJNSvebXsotFL vLSRoen+Np6zGpRuFzbZxADrHKOyYW8YEtyEamvEcpj5teWsfo1aS2sLI5X7MFfTgxtrMvVO5iIL8 zlezcYcExiZGkiqSpMwnjOUT5EtgJrmN9clkVKgxtuksTyiMV5O0wkfEuIsShjwbFF+pZdJ+ie/6w Pcos8YkqohuA01iNAnnZaICyoHYxg/NP9gY/nNNZl6YheG5bBG8ceMuwFra+ZGb1+4BmJRfm9HdRk ASQDJc3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OF-00FvG4-07; Wed, 21 Jun 2023 22:33:27 +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 1qC6OA-00FvBB-2P for linux-rockchip@lists.infradead.org; Wed, 21 Jun 2023 22:33:24 +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=W99jR6zQr9o9HH0LFWjkqVeyLEmhww0LQ1TODMrD+JU=; b=lgYVrVqzL5xtT/wvZAyliCCJFvkwGuTcAcJfKQdzdxZC6nLMwUo9oDusU22C1uWycY8I p34S3bqatApfjKJTD6B4eqk7llOn5/Xibjn/59rFvUNYJpcXcORsPCo/1q8lBzu49gqfjB 5PDLZaTyULgvju+D0MFe6J6rsx8c/hdQbcyDzjbI6MDJnr3FbvWFMIIF/X0/Gt/wgODH29 AMiYWHdlvJEungau2LBFg6UBFDagsmxX5TqNHt+ZoboL6wu8V4cakUrMw9jhJCfkqgkEj3 F40YikYplgk68+/3que0WX9V4L4kVAXHsY7Sm/jyaWEFZ3bd0BYwBi10ZNkv5yNA== Received: by filterdrecv-84b96456cb-hrvlt with SMTP id filterdrecv-84b96456cb-hrvlt-1-64937AAC-29 2023-06-21 22:33:16.784398642 +0000 UTC m=+3624881.780498603 Received: from bionic.localdomain (unknown) by geopod-ismtpd-0 (SG) with ESMTP id q2JBcGBES7ak8zO87bOzoQ Wed, 21 Jun 2023 22:33:16.341 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 1/5] drm/rockchip: vop: Fix reset of state in duplicate state crtc funcs Date: Wed, 21 Jun 2023 22:33:17 +0000 (UTC) Message-ID: <20230621223311.2239547-2-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621223311.2239547-1-jonas@kwiboo.se> References: <20230621223311.2239547-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h4IxyhjudaBMscryWyil2MxaaDxax+ugZQXodSqRHYB6mo1lanwr1jqtEi9avORGicVCxu+gicqUMciYzh1qKi0rKAAZsg36a46UzsyNeYvAelFe/L5MeEgpWHSX6qgeZuSn/rbILQujCX+o+T3Up+mu4zx/DdYQ0uZHRIKOJURd1a0LTlj2c6hV6WggcPO0cw== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Mark Yao Cc: Maarten Lankhorst , 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-20230621_153322_922577_C06A5A98 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 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 --- v2: - Collect r-b tag 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 Wed Jun 21 22:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13287996 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 8C332EB64DC for ; Wed, 21 Jun 2023 22:33:33 +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=GAg6cSglgmq09Ax05EWbbtnLQu4dLaZ8J45KiFP9RNM=; b=obrAS0fbj1838h+95OFj7wcBsc Nt7CI0UxmDHpHXqNen2CLuDPK/EFZZtd0wJMAip0N54T+uLvOKedw66CJtr39Vga2hKuNObOly/lX 88OilfkbTYK/8ToeNduVhvbYZ+AyDqHNDThg7x/Pb2ysUXCWvWSqAK81ALozlfYAeR5za41hKfqDG iZ5vxulxIoeXqkDui6x2Oxle85u5x4DeaJ9k/4Yv8IuACa2n3pvYpARp6O8UCiPAa3sOlES/HLa7h Kiien/3KWLG+LWcllW67SzzgRaPNRz86xBzVyR7WG68RVXtzciaHzW5UYAGBhGPtzXBPxERXxxgN7 3vokfSrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OC-00FvE0-2f; Wed, 21 Jun 2023 22:33:24 +0000 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qC6O8-00FvA5-26 for linux-rockchip@lists.infradead.org; Wed, 21 Jun 2023 22:33:22 +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=EBeEmyxPHZsV8uwK86Vd5rWpL+TZ9Rlo5l7W7Yh2uhw=; b=aMHyRWqwoobd2f1d7rESpCk+lcJj5Z9C/apkwSupwwykIXNOJP/NLA+9jeCE1UEXhTcC qnOqSRtq7pT6VYAlN7+GV+nQmVthZwMzFxpuWcGUh7fHsaROlYE21qNesmJYShwqF6J1P8 y8eoe9MvDB8jfrZsWvy1QOPxjzLErndwQHhP8UXcbWLXdcDiaN1osR0cFiOfKB+ZtWKDp1 8nsc0PVm8QsGmfsf7fIdeyoyDdmVfOsbbm4EAxAnLkZSM16po4xEc6BAVg8nBz7qlk323j AacmXij6fSU1hOKpMp5Nd73t5H3RvphjtczNKwKYrqnKzT3mDwyxmQhIJsMhYv8w== Received: by filterdrecv-65f68489c8-k2rl8 with SMTP id filterdrecv-65f68489c8-k2rl8-1-64937AAE-5 2023-06-21 22:33:18.193802383 +0000 UTC m=+1463593.463557322 Received: from bionic.localdomain (unknown) by geopod-ismtpd-0 (SG) with ESMTP id -sFQmpmXTsaEvCoAmpELPQ Wed, 21 Jun 2023 22:33:17.910 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 2/5] drm/rockchip: vop: Use cleanup helper directly as destroy funcs Date: Wed, 21 Jun 2023 22:33:18 +0000 (UTC) Message-ID: <20230621223311.2239547-3-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621223311.2239547-1-jonas@kwiboo.se> References: <20230621223311.2239547-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0hx33UZE3akeZPDZ+mBfd1ZvpDkt9enAwukw495j/N8pAF5a9hBPnC8XNJBaYIDCfuUuuWEK4B0qxGqt4f05EEKcXNP3wOakN7M/9NS4t6FkuZpoiazBiF5oXJc2AyrbqMOJg10kAAZlFoIl/cdaVg9qEsnalBLLeYFtxV4Xs8bqeoWiufg3akSzJC/7n+Tt+dA== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter Cc: Mark Yao , Maarten Lankhorst , 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-20230621_153321_401073_7F49AC85 X-CRM114-Status: GOOD ( 10.19 ) 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 --- v2: - Collect r-b tag 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 Wed Jun 21 22:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13287998 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 A6310EB64D7 for ; Wed, 21 Jun 2023 22:33:45 +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=cyAJNdNXszA1OZlkL0CkOWM9wCHN8GQ46mivjAB+j/A=; b=UNs3ujcJQZTwrAaRLNLtTFPuKx bsfZ7k2MVNp8lNDEDMWX0pFz5SajD0XCLoCMAaXZg8gDOl8qG/KFDeVvBcFnQIrFed2FbYPDBHE4o QX/RnHHxJKcatRBCw2yUtvBksL0ZdETWtjkFT375NMwmYLScRzhmzS/XNKAUnt+56xddFSXQgHpGy OQw/AaA/ZdK53ipqFMov5qY+9xMkZ2sw63K5tH+PqM3VGmB1xa7uhU+88uuhCCXq3w4y7N8VMN0T4 ZPLES9EYuSg6LCzGXWylian3OgSh3ZIdybhM+0x/b8lB20nCD/FZgk3c+/u6n75CjCxk2iC6W97cX 8uwiLu7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OT-00FvPa-2V; Wed, 21 Jun 2023 22:33:41 +0000 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OB-00FvBX-1c for linux-rockchip@lists.infradead.org; Wed, 21 Jun 2023 22:33:25 +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=N3/rzRG3o23sD+ICspFZR3Hn+pKFLqALOJeNlqnKgj4=; b=odo6I7Jt7vJMGUnTiX003h/h8HEQt1HFOUB00tQROehfkL77cpEvY37AZmQGVQkAjjO1 +vExX5bMazjGKH1Kak0ROyBhP7gG4VQ4mKNf2kOPWts/wX01JJiYLvcURr4p8QRHMzLVYw enwvkMPNRdMtVo4za6tO8B/xk8FvH+GsScKALqG3YwK6BTRHLkek1QpTfgR+pADi1KPTW7 OtcUXI9ClAufLMKUWkoD1BYAoFBYNZogpZL4+Snt4P+unpFxwqsEqTxsbH+ieJc5kc8O09 H4x4ZykiaZS9cfKtysqt4m0I+DQuF6WWklCLiG9IMOeCUl+TZ4KK4iU2RBcOeFQA== Received: by filterdrecv-84b96456cb-hq7z7 with SMTP id filterdrecv-84b96456cb-hq7z7-1-64937AAF-22 2023-06-21 22:33:19.939834959 +0000 UTC m=+3624888.194376328 Received: from bionic.localdomain (unknown) by geopod-ismtpd-0 (SG) with ESMTP id ZVQYkneORxuup128izvcVw Wed, 21 Jun 2023 22:33:19.491 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 3/5] drm/rockchip: vop: Fix call to crtc reset helper Date: Wed, 21 Jun 2023 22:33:20 +0000 (UTC) Message-ID: <20230621223311.2239547-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621223311.2239547-1-jonas@kwiboo.se> References: <20230621223311.2239547-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h8LrEgJzY5ktvBu14zmHPK0tdeaF/rED9ytrdgA/Zcc/ZBkGuBtyyJesjdWC3QvDOV0X9yW1R/VKEfNKLQZiqi09BM4YEAP+O8MhuTX8IUJxNQ1hDLN5d06OhhlyKV3DKYYg9Au2l/OMSP+tVShDs6Czt8AVcVqfxbTS8zTc+Gt6uLuYIn+3Z8yCSQU/NI2Kmw== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Maarten Lankhorst 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-20230621_153323_671853_CA717809 X-CRM114-Status: GOOD ( 11.36 ) 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 Allocation of crtc_state may fail in vop_crtc_reset, causing an invalid pointer to be passed to __drm_atomic_helper_crtc_reset. Fix this by adding a NULL check of crtc_state, similar to other drivers. Fixes: 01e2eaf40c9d ("drm/rockchip: Convert to using __drm_atomic_helper_crtc_reset() for reset.") Signed-off-by: Jonas Karlman Reviewed-by: Sascha Hauer --- v2: - New patch drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 25c873d4ff53..23bc79064e78 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1630,7 +1630,10 @@ static void vop_crtc_reset(struct drm_crtc *crtc) if (crtc->state) vop_crtc_destroy_state(crtc, crtc->state); - __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base); + if (crtc_state) + __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base); + else + __drm_atomic_helper_crtc_reset(crtc, NULL); } #ifdef CONFIG_DRM_ANALOGIX_DP From patchwork Wed Jun 21 22:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13287999 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 D9853EB64D8 for ; Wed, 21 Jun 2023 22:33:54 +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=ylxxbePCiE8X/AJkmYmkysD3hKY2CCJwwCgUaGIuCmE=; b=Nj6e0LPwb5nCydXPswJz6pilQb yRX2D+bXoOVkyDWFDIelFnH/wx0TNNUXMVxiZG5Zr+nzrM0AiBZ8L6eXXxh2+Tx+h2FBgU2b0cuPB SmNbxXJtRDQd6AiNQzIFu3bIL6bs0dWUAv1eIgFFvCNhHemEl7x4n1FIhTCkd6tBTbFS/4vbtBbkZ 8IE93xE1E/GmzLn9Zsc6Z3jDQXOb0+vZvJ203wS8V33zNXbJSeFar8pUWI5eMOmoPKARc7xEhsUUV 5iFQfOViEWlbTZ9yQcqXQo8gPL7QFfz4U8Xi0QtDyaUogyb+t26NspLnP74wkt7rysz41IVTQ3mj3 gnhaTCNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6Ob-00FvUN-1U; Wed, 21 Jun 2023 22:33:49 +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 1qC6OD-00FvEC-1v for linux-rockchip@lists.infradead.org; Wed, 21 Jun 2023 22:33:26 +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=v14Q72PruEDwmH4o+T8D3FApv9VBvr48LzkZegCo/u4=; b=rBdphp+s6nKgaYVQW7kNM0FgEY82p1wXQvzHlIC5PkiJlWolj396r9VbEcECshqqISme K1/Rm9vjIM5834etPzzojd16lF/NBRZp2BaCqg7Ib29s3myOI4lx50490qsayrRlZLWXvP dsaZzA04HgTxD3CFwzFXHIAvcVLhImJWFygnSp5/HxQhih5r7U04aCO7JZOIEBZJHfOd4j 7NfTIYvPAfycoU0VMdh6VtgzIok7APy8agt8yV2/9iWI00Rw9J5qLpRZgTlId6sS74OXJd 2TWR+V3/4RkVOIhQ2gW42NRU0Vqr4D7+zJyoFw/SUKhcKTmCa2UmxfYZOROn1Zhg== Received: by filterdrecv-84b96456cb-hq7z7 with SMTP id filterdrecv-84b96456cb-hq7z7-1-64937AB1-C 2023-06-21 22:33:21.44628361 +0000 UTC m=+3624889.700825056 Received: from bionic.localdomain (unknown) by geopod-ismtpd-0 (SG) with ESMTP id vZirRyg8Rfmll8Z_NYscQw Wed, 21 Jun 2023 22:33:21.131 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 4/5] drm/rockchip: vop2: Don't crash for invalid duplicate_state Date: Wed, 21 Jun 2023 22:33:21 +0000 (UTC) Message-ID: <20230621223311.2239547-5-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621223311.2239547-1-jonas@kwiboo.se> References: <20230621223311.2239547-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h32UvfMM/7Im2hDMck0YtrNlBiYhIMIchAeUrU5n0sre8GH0aHkc25Kjc5HCoIUZZ7FARoKQ/sE9PLBlsEjGZQs7vTcjzfr29hrXhjC8S9Sso0YHD9EabPjIenPzNkUoHeQR6g8qt/AfpEyKd+CmvUnrLklGGawcf6TTxFUpDNA9eiuM0MURnYZDLlz2T351dw== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Andy Yan , Rob Herring , Sascha Hauer Cc: Mark Yao , Maarten Lankhorst , 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-20230621_153325_781952_E07FD7D5 X-CRM114-Status: GOOD ( 11.50 ) 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 --- v2: - Collect r-b tag 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 Wed Jun 21 22:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13288000 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 50444EB64D8 for ; Wed, 21 Jun 2023 22:33:58 +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=OWPOtyJvIWNkqngV89iI2yzSd5yxXhS2TV2T+uWjYlk=; b=3DrWK7fi+tgeC+/MKsHlWcaA0h TU2h/nolIKG+o8Imn1LuK/osnusHy/BcoyZ3Xdbowff26UpGRPTiZ+sDh9Npry06EsICQ8I3oRijU 45Q8ieQSuLxpamQu4c+KgDs8SrlwqFPex8gViGNUF9uRw3zmsdrjIAkiiwWiAJoPhfOyN/OZ/9hL6 Fig2rCJM2FKEokKjpFokHdiBMhLTJGSI94lvTCpbYGCHZyQJ5RjrCDpxFpE6f75gEQsgIuAWOAKGA MkOP8aD/o8sWdkIRMdFZzuqkkIKlCOrNP5f5Wv5Nj13+16SBMKLM9H7+wcjAf0NrLoY9lFvU760kT q2ovDtMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6Oc-00FvUy-1C; Wed, 21 Jun 2023 22:33:50 +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 1qC6OE-00FvFD-1q for linux-rockchip@lists.infradead.org; Wed, 21 Jun 2023 22:33:27 +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=gpt4shW9Az8HQBaGBESfhw3ZJgloP+jLONDW/keDorI=; b=A8qHE49+Rg910ao7nsxF5wejLhadp5zf4H3oduW0IvhB6JgcqzK642zeQKPYN3xd6Kz+ bZnriW/wigqdWrwPerUr09sTPqBJt1oeH+WKLmj6f4fuLH+uXvBViFsnAkB5KmwqIV7FXf DOJdKVGEcwKWyiwnz5XFki6bDwuRZxiFpFMO2mdKfZ8kK5OZkZaaqS7RiotSwKZ7ZHQP5W QiOanLgQtVB5gyhNfl4RX6hS3/sHP8wvXV1jWLkCu4lJ3rLePPLxPizm/1ir69yz97MbZC umfuwRmM0t1fB2ftWFwruJmeMlIXXqNMVbpPcCJ3qaB0IA3OcRvKyEfhubPU/Mcw== Received: by filterdrecv-65f68489c8-k2rl8 with SMTP id filterdrecv-65f68489c8-k2rl8-1-64937AB2-32 2023-06-21 22:33:23.019043275 +0000 UTC m=+1463598.288798320 Received: from bionic.localdomain (unknown) by geopod-ismtpd-0 (SG) with ESMTP id W7fz8D3QRnife75m7ND9CA Wed, 21 Jun 2023 22:33:22.815 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 5/5] drm/rockchip: vop2: Add missing call to crtc reset helper Date: Wed, 21 Jun 2023 22:33:23 +0000 (UTC) Message-ID: <20230621223311.2239547-6-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621223311.2239547-1-jonas@kwiboo.se> References: <20230621223311.2239547-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0hz78e/vfUnHx3mUyDKgumjHDaRQIPiL31NJ2du6oz01DwPK8KoRoBpmLYyy0WPk79Cbsu101l84dCjvPY43LcPCZ0102sxyBVTJAlRnTwVHK5FGXLdIfbRXkZ0cE8gE/UO2Zao9MlDedQBLQ58pY8P2QjpvLmZzZNXwKkWlodowJtTUAGwS3HSdapCdxi83VsA== To: Sandy Huang , Heiko Stuebner , David Airlie , Daniel Vetter , Sascha Hauer , Andy Yan , Rob Herring Cc: Mark Yao , Maarten Lankhorst , 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-20230621_153326_726471_E4017B51 X-CRM114-Status: GOOD ( 10.50 ) 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 Reviewed-by: Sascha Hauer --- v2: - Add check for allocation failure (Sascha) drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 31 +++++++++----------- 1 file changed, 14 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..5ba83121a1b9 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,20 @@ 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); + + if (vcstate) + __drm_atomic_helper_crtc_reset(crtc, &vcstate->base); + else + __drm_atomic_helper_crtc_reset(crtc, NULL); +} + static const struct drm_crtc_funcs vop2_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip,