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: 13288008 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 D6C22EB64DC 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=FrvVrq43Jup/jmjoBFeHcNYh1vcxT1WhpdBlL+/2O18=; b=efrn4+FnsLVtFlTAif+T9o62+l E+Iy9wItusD9k5z7F70ubvMju6cU4pqG2oOKjVoOfIa6Lkv1oUZ6DdjiR/2awYvPJuD6OVGw2YAHB WFNrs7H15vEdff1mUWcX5GalLzfY2WnvVulCIQjbU/YGH8YD8jrWcxWj73B681AAd6A3uoGFQ/8uE /LTPSseS0gcXsz3aNC9aVrIyI+/jd94EuY4kvj2X+YUbp9YuJxq25N5AfHya+7IUmZEOV4oigotJ8 hxbPqGr6oahkte0MATSfu820rlBctMpr65TdFK2iKMM6WU/caLlP/wbCsNn2VrqE8k8ZHbvrs32/L R+lSlTlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OD-00FvF5-3D; Wed, 21 Jun 2023 22:33:26 +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 1qC6O8-00FvA6-2g for linux-arm-kernel@lists.infradead.org; Wed, 21 Jun 2023 22:33:23 +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+gicqUMciYzh1qKi2jKGewsMwfYub88+tjr/7DeBSIAqmDYOrSVMRrAZycIsc0TY71XMeoP5GGdp81bZAV/ybGRSYL1wVq0xKYYR4C0cJ1lolSyNlzLyxtNjRMHw== 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_153321_408888_5BA29B19 X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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: 13288009 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 2C811EB64D7 for ; Wed, 21 Jun 2023 22:33:50 +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=1hwcWXBv6UttWr1laqEWMw36KdSzocI6ztBL8UdDy/Q=; b=vc6DuzWIP993KNt4PBR/I22kc3 FdqUF5Ob4fuESxcvoed83979RHt9Orf0SHAH259a+5bY4m6rloYLNsRIDweaXCWayu0D9lx1d4+A7 plRQqLW2KFIvF5f6XwTlfJ0zwIe/HLlDfr+Rg21kpq+wbJLDcXEbHwOo9XksOxpWEBvv+54tsP9qz MRo1aO/uAs73k7GOi3TAWfIab68Pxf8uCpGgOxiqesFHWh7EL6R8MAOehwBsNW8BHQkEIcmjUTnqL Yjllx3CAB2N4CAcyFcNunyT9rId16q99fQ4IYBzlVV0/pTU138wP9GyLk0nrdBsFedanJRaI969b9 PbQHjehA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OD-00FvEP-0v; Wed, 21 Jun 2023 22:33:25 +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 1qC6O8-00FvA1-2W for linux-arm-kernel@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/N8pAF5a9hBPnC8XNJBaYIDCfuUuuWEK4B0qxGqt4f05EEKcLgsMy7edDt9U0jM++n89RGFJVilxQNETIrJyk4awAhWKlTufAemFiH8dvc7iQmGiikny1ajsgY1HIvr1J93Ke3QnMqqfIYwaL6Jj8XEsfhw== 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_402536_0A75B396 X-CRM114-Status: GOOD ( 11.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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: 13288013 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 162D4EB64DC for ; Wed, 21 Jun 2023 22:34:09 +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=Qwis9PM8gtiVZI98dHfRxHdmk+XB5PlJT94M91HaLl0=; b=f+sQ69jPiAQh8zl1KfXAHRk01k G16CuVhLK0Rar172GBR+3clRrKnhaxeIndrc0V3r8kHDxKFy9hFzxNz8E9oswc8SzWECklFfTyzD4 QoYP22w+kZaoWGkh6SimOJjMO8F/WNw3RxTkgiRYdPitKFoyvjsqF6jt92WuoJ5EU8EEPlUQ0VmpV tofvqhPiudVA+QQK1gNZXyCRjWbDWQkQCWTvw7d1UZgKKG1NvQDuPF8Lef6z3IsYUGcZ4F++BJNZ5 byJn5zyJvbt1f1dO2F25GI/MMpTLW/Opz5I6RDxVuFduC8wR3yEkcrMxlSP/C5FSQAyzngsORVFQM 8SKiRPSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6OZ-00FvSQ-1L; Wed, 21 Jun 2023 22:33:47 +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 1qC6OA-00FvBC-2a for linux-arm-kernel@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=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/VKEfNKLQZiqi2umm+dqbriEYRDImwY7HEZ51OgylcG39fUr/zBOUk52Ep1qOflYQL2wXTa2Imx5IU9iXaZ9oVR2AGhwRiPe8jDGZb4Dd2ndbd7q4OMxijV/w== 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_153322_991018_6BD1F0DA X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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: 13288012 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 BDC73EB64D7 for ; Wed, 21 Jun 2023 22:34:08 +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=+LBH8LeWP1qot0mN4vjAc8aPffCneSISHmgVowutLwg=; b=XfWdIq8a1Z5llLNn1U8pbmLHbr Eq9cu285MLg4E1mEgzIheQMK9H4sT0ia5m2257Qhw/mrrualFrOmyE7q58N/d63OO7jh68sb1YFwo Npr8C9Oy6R0Y3y15B44HRR0gCkSIT5TNVcrtDp67l4gF2gcxWz3SNwt68BdXm4TXrgdYxESig7Rjn GScIOR1f5mxA0Q60QFKJ2ik++ol1PpUHXj/5KuId5XuXm1RbxsYpLOQuyx8P8S3zL9Lxt3ELqJbrw iAj39xAQ2fJZRiT0z4opsuiJMxGc4SJeAsuCY1F35e2K+TEkVV/ihsiWowzkESGDJmzDUH3dkCeSJ +3uU+ohw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6Oa-00FvT5-0H; Wed, 21 Jun 2023 22:33:48 +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 1qC6OB-00FvC5-2v for linux-arm-kernel@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=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/sE9PLBlsEjGZQtSKXi5i3SEO3cdYyc94fzi8P/ZYuy8DUcIuJUjl5i020ENksPcwCs6aq/6bDeWUx2IwnM5saKkJQjimntqR2d8IWAMLxhJPHCLauMd+TZBcQ== 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_153324_084863_DB142D6A X-CRM114-Status: GOOD ( 12.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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: 13288011 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 BE981EB64D8 for ; Wed, 21 Jun 2023 22:34:06 +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=b6kudr81wF9R7xgmoS6Nwk42NlDh2MMpypKwFwadTQM=; b=QShXSpHnsXWhsfnU/nnXdHYTTn jRGY7k2CzYMZ7g6n5dfn7/Pt/Zmg+4Q51XcDuuEGA2F+6Z4iauoGBX+HgEl871Ge0LYTX3fdkJA4w /AQPgCNa+pDi0JxwcSp98LkRT528XdnxropMbBe+ATSj/eWfDC+j8RFFu6UjE8p5i+Debv+OK82ci 2wkmz4pPswT6NGVKRdsRRyDgInEjjEV67J3dybIQ8z6tVEgAN0XCwJEOTSRAn4fKdcfgWno1gWWZG h+9h/CoukIdEXMZxi8/Wt5VBg2vTHLGZjlPpUAwYTzFY6qBjlAPh/VsnePqdYh44f80PGoPb29plx DRSmaepw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC6Oa-00FvTe-2U; Wed, 21 Jun 2023 22:33:48 +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 1qC6OC-00FvCo-0W for linux-arm-kernel@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=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/vfUnHx3mUyDKgumjHDaRQIPiL31NJ2du6oz01DwPK8KoRoBpmLYyy0WPk79Cbsu101l84dCjvPY43LcPCtu2HcyMXH/XRIMrgeiFewZTt6rT2AWpg7ta+BEPOTrcMknNzejAeVKoBDP7hKltDU7Sq0IdGxIJdCEqJF+tA+goZwvjMfldtHCUG6kiwz4w== 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_153324_279565_2D822083 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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,