Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3031564rwb; Mon, 15 Aug 2022 16:30:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NDUCWuYIIfor5f0MGGtYOMBok+VbMAXtsZim+yDiNFjWBzHBG345Z+O6Ehpi6Xg+oyfqJ X-Received: by 2002:aa7:d49a:0:b0:43c:fed4:c656 with SMTP id b26-20020aa7d49a000000b0043cfed4c656mr16070225edr.312.1660606255031; Mon, 15 Aug 2022 16:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606255; cv=none; d=google.com; s=arc-20160816; b=cioROcVHh5xWOPXHDdrvn5w+pZQFfqGin33rRSAkaxkLWjA0XvstanZMajwUdA29DE t4eucj9M5qVkodO1pTqoPFZtDtJ6Z2iu8l9CKxz0X3bvijx7JyNG7v4z3r+DlDkrJj54 TC7LltmaMxdpXQk8ohY3w4c8MLJIuR/9RQEe+spXA2BXzi0bsIZBCYzPYRF/9gIaEuHx IHMYpz27s7bKXtmRuO/886a75wqREWfpSR0ijx30Y1mUqeWjZHBemH0pvOxMjYeUrIcj Tw65rBCUnS2M5+EzgIJvxmIhWWDkFNnTinOkdbltJql3pCX40p5zrg+7yYdLlKu8FF9N uHpQ== 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=lOVdzkiyP3zdR+QUwDXuPyELdI+ZjqacS6W2wgRSquc=; b=cBSJ2CK5X3940H+DyONXuCwkdFCaP8e/Noqrap2RQFpHZ0Hh3bhJeYdxQ7Fn9s9++8 fPH5A9EtfoZnNZxJReKzuFbnBaJO1bK9sWz0F8JXmVJAd/y57jRiVcsz3PD7UqE4HSZb dYXahUJGbxeL87LqC2kvT1F06p7C6pzzJBKcuTCXR5cL7laOd78uWVbZa5k65z+/MrPy XDuxCiWvBJrN6RunuKBMnL+p9UnEUsQno3gMOFjYLz/nYD19iIxWK2HfHbwz+e2UB9Au r1e7IOZFxq5g7aHzuB4+lBqk/BkUk6DsSX/ioMqcorHzQ1MTTyQdjaXEUw4Q6RkAyu2l +ieA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AqQva6Ay; 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 z18-20020a05640240d200b0044063348cf7si10147758edb.555.2022.08.15.16.30.27; Mon, 15 Aug 2022 16:30:55 -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=AqQva6Ay; 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 S1343653AbiHOX0G (ORCPT + 99 others); Mon, 15 Aug 2022 19:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345933AbiHOXVL (ORCPT ); Mon, 15 Aug 2022 19:21:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E55D46DB9; Mon, 15 Aug 2022 13:04:34 -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 ams.source.kernel.org (Postfix) with ESMTPS id B8FB0B80EAB; Mon, 15 Aug 2022 20:04:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEB97C433D7; Mon, 15 Aug 2022 20:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593871; bh=hy90U0B6RqjC6MYvHkRk+mNS8XDwW2dA08xSUCtKBpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AqQva6AyIngN1ubRULXFdHsDrRpF4bNh3fyYVKnCK7hkH5Qhds+f46/jKe8wtpLCm DYPjxbXAZJf9+c1EEvTejGzuL+/FOpKskjAE3OZC+DQhsHb2gS0XP0gV93AKglgBzB 7GI1lXsZZ1XA5EWsBXbyj4oczTFfwWdx0B4/qk6g= 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.19 0338/1157] drm/mediatek: Separate poweron/poweroff from enable/disable and define new funcs Date: Mon, 15 Aug 2022 19:54:54 +0200 Message-Id: <20220815180453.194469064@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 6e7793f935da..966a4729bb41 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -691,16 +691,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); @@ -715,17 +705,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); @@ -739,7 +721,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; } @@ -776,13 +767,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