Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2868725rwb; Mon, 15 Aug 2022 12:59:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR6lR7sr3GUQhx6cefZZOGQ/XFIZSnVlebDoGdArYAQ2ZscIRUA3cq68Ly6qpic+1uL2PAP2 X-Received: by 2002:a17:906:fc6:b0:72f:d080:416 with SMTP id c6-20020a1709060fc600b0072fd0800416mr11488489ejk.1.1660593566736; Mon, 15 Aug 2022 12:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593566; cv=none; d=google.com; s=arc-20160816; b=nwV4dP8ERzeUmVGj0kZVySpCJJoSHfhX68x8ZnT8cdW2cxcJ31xgN4xWzGicxy/eqf Tf/IUiLPiV6FA7AHU1HTirVyzvkATyomE7Ss+UjkCN7+2JS4wMTl9HaRFO7Fg4+EMynb PALKabL7w/XzkR0F57aFywVd1BfqtfgsjvOOdk8zHFmpE61248Try84RLsR3spz+HtaL uxQQHJ/Cim/HXLxDNXg8rvElzvKq7lITVk1tmKtqjg+nkcf6aR0kRsktWdxRxCHV2j83 MZAgvMMIP1ACjxFyg3/81GpO1iD7uRn1QX7MQlsJX8xRfH+tOOK8ATjWf1+iwaf3pPnX kEpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bbncXdhHZgCwcl94el8W/EonnO8OPtfWZEEivbWGO3k=; b=omXDL35gqMywiOoi5XXQK4aragjNx40BsYhxssUuJfv4JQP3yNI4WyaZRNnfRFPtYW 63YPGgqStwNgvkOy2vhWzktRNU27IJKd0Lk4WfHhhexlZ3CVA/iZ98YUnKaOQwTMNsvW nqSgIGDxph/XBb4wTdq4RTcMEFlRJ5lQpB8MFlvd5xnFFzb5oVkEmQzk8nj4TBsdBzXN thQQV+GC2cXCg+J5epr/ZJ6VEUaZJRXX0YZIOnlNFJFo8kXTqyuH3hacn3HNwVKNiDEy 2tr98VXjOq10i8k9zVfY25dqf0fXv1rnmGSg/19ZKbsDGeK7DGGIoaDJuvB8Jz1jgfxC raeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c3IxYaVG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb35-20020a1709076da300b00732fa7c5058si7785897ejc.300.2022.08.15.12.59.01; Mon, 15 Aug 2022 12:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c3IxYaVG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243737AbiHOSpS (ORCPT + 99 others); Mon, 15 Aug 2022 14:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244030AbiHOSmA (ORCPT ); Mon, 15 Aug 2022 14:42:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4BA2F386; Mon, 15 Aug 2022 11:25:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 469FD60693; Mon, 15 Aug 2022 18:25:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FAF9C433C1; Mon, 15 Aug 2022 18:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587944; bh=Z/NltabhsuR4e77xbYHTWIzSHxeANw3DcDZUPjXlfVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3IxYaVG6d7HlhoHBQxS3urM4cGyuQyYd7AGeIx9IBal/P6qDv5rI7WxFrQuMf+LJ vYek66IL5DnASpvj7e7lD6NklR4F1cSRuxoLY0RmEPiaze8vPukKEwDd1LVgy43DOy jDPPXFw8w730aAyiUQaeuo9NWU5dk942MX16yGM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jitao Shi , Xinlei Lee , AngeloGioacchino Del Regno , Rex-BC Chen , Chun-Kuang Hu , Sasha Levin Subject: [PATCH 5.15 245/779] drm/mediatek: Separate poweron/poweroff from enable/disable and define new funcs Date: Mon, 15 Aug 2022 19:58:09 +0200 Message-Id: <20220815180347.793051428@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jitao Shi [ Upstream commit cde7e2e35c2866d22a3a012e72a41052dfcc255d ] In order to match the changes of "Use the drm_panel_bridge API", the poweron/poweroff of dsi is extracted from enable/disable and defined as new funcs (atomic_pre_enable/atomic_post_disable). Since dsi_poweron is moved from dsi_enable to pre_enable function, in order to avoid poweron failure, the operation of dsi register fails to cause bus hang. Therefore, the protection mechanism is added to the dsi_enable function. Fixes: 2dd8075d2185 ("drm/mediatek: mtk_dsi: Use the drm_panel_bridge API") Link: https://patchwork.kernel.org/project/linux-mediatek/patch/1653012007-11854-3-git-send-email-xinlei.lee@mediatek.com/ Signed-off-by: Jitao Shi Signed-off-by: Xinlei Lee Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Rex-BC Chen Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_dsi.c | 53 +++++++++++++++++++----------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index cfa354037bb8..c30af7ca5fad 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -679,16 +679,6 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi) if (--dsi->refcount != 0) return; - /* - * mtk_dsi_stop() and mtk_dsi_start() is asymmetric, since - * mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(), - * which needs irq for vblank, and mtk_dsi_stop() will disable irq. - * mtk_dsi_start() needs to be called in mtk_output_dsi_enable(), - * after dsi is fully set. - */ - mtk_dsi_stop(dsi); - - mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); mtk_dsi_reset_engine(dsi); mtk_dsi_lane0_ulp_mode_enter(dsi); mtk_dsi_clk_ulp_mode_enter(dsi); @@ -703,17 +693,9 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi) static void mtk_output_dsi_enable(struct mtk_dsi *dsi) { - int ret; - if (dsi->enabled) return; - ret = mtk_dsi_poweron(dsi); - if (ret < 0) { - DRM_ERROR("failed to power on dsi\n"); - return; - } - mtk_dsi_set_mode(dsi); mtk_dsi_clk_hs_mode(dsi, 1); @@ -727,7 +709,16 @@ static void mtk_output_dsi_disable(struct mtk_dsi *dsi) if (!dsi->enabled) return; - mtk_dsi_poweroff(dsi); + /* + * mtk_dsi_stop() and mtk_dsi_start() is asymmetric, since + * mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(), + * which needs irq for vblank, and mtk_dsi_stop() will disable irq. + * mtk_dsi_start() needs to be called in mtk_output_dsi_enable(), + * after dsi is fully set. + */ + mtk_dsi_stop(dsi); + + mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); dsi->enabled = false; } @@ -764,13 +755,37 @@ static void mtk_dsi_bridge_atomic_enable(struct drm_bridge *bridge, { struct mtk_dsi *dsi = bridge_to_dsi(bridge); + if (dsi->refcount == 0) + return; + mtk_output_dsi_enable(dsi); } +static void mtk_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) +{ + struct mtk_dsi *dsi = bridge_to_dsi(bridge); + int ret; + + ret = mtk_dsi_poweron(dsi); + if (ret < 0) + DRM_ERROR("failed to power on dsi\n"); +} + +static void mtk_dsi_bridge_atomic_post_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) +{ + struct mtk_dsi *dsi = bridge_to_dsi(bridge); + + mtk_dsi_poweroff(dsi); +} + static const struct drm_bridge_funcs mtk_dsi_bridge_funcs = { .attach = mtk_dsi_bridge_attach, .atomic_disable = mtk_dsi_bridge_atomic_disable, .atomic_enable = mtk_dsi_bridge_atomic_enable, + .atomic_pre_enable = mtk_dsi_bridge_atomic_pre_enable, + .atomic_post_disable = mtk_dsi_bridge_atomic_post_disable, .mode_set = mtk_dsi_bridge_mode_set, }; -- 2.35.1