Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2928417rwb; Mon, 15 Aug 2022 14:14:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR7v+75+DUq+hJ2EQjPP7Ug37OYXAqtTJyEFOK/vlubsNTJ6HalDGP293hRlyqM9j2j9m7zp X-Received: by 2002:a63:2021:0:b0:41b:c2e5:f4ab with SMTP id g33-20020a632021000000b0041bc2e5f4abmr15432621pgg.496.1660598041544; Mon, 15 Aug 2022 14:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598041; cv=none; d=google.com; s=arc-20160816; b=OcramYVX+zWQF8I+l9xHlYvAwjajCGrNIKgW63QKXkU/bbogynSwtbWenPk1zY5qZo 0cG0jKTQal2LRqu1PibUO1WFSVJ3EtAQDMNrj+c306X6q6yeEHuU3SSfjbKe7+IC1834 UCUZieXvIomjvX54yEge0md0Nqh/9Ar0YWUMjmW2YanIxk6YaXpACP9Q3nYzs9n1zr/9 6KjcIM243LPlUENKdm6M/tVwys4g3O+yCaBmdR/cNTFmTz63sHNwu78sXtGpYwqIRBb3 Eu91qPNohK6agB2MHboi+g/qXdsSi3WzTao+dFPBNLQ80LNeWXNdP2OyIBmRj/T1Musg v7Gg== 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=zpAdKQl0fnqrwzPCzjhlbcp8wVMCIHsPil0tsln7430=; b=kxgKsoHrsPLwoqiRns0BbUpCtf5EgzcA2U4KR9QcsSigKaIotnUwEQuQnIEQZbIPGO qRRVggOANDjQFpcJUBMqKuVbmM4ECSqcPngYThrTX6jY5mLexzG+1d38toPNZ62mBGW/ cWGC4B9fFx9PU3kPmHcaHxMxuWMIdeo4vYKyemgNxJI8Cl6k8im1pIpOFGmvQV2g9qUv zKffXYwEgOOcERqf7y7tEjEa4fUZjbTu3LB7zulXUiWfH2YOKmEG3IqjsS+PDztfbvGf CCgNotfoxR2KvOHHh15d9gPlnYkmq6jRyAicn9j0UEzMnSKvAv8zVaWNzpTSzrR36dlz t5ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KQ0A8LBV; 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 o24-20020a637e58000000b003fc137079c2si11432591pgn.60.2022.08.15.14.13.50; Mon, 15 Aug 2022 14:14:01 -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=KQ0A8LBV; 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 S1345880AbiHOUyt (ORCPT + 99 others); Mon, 15 Aug 2022 16:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346078AbiHOUyF (ORCPT ); Mon, 15 Aug 2022 16:54:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7891ABD113; Mon, 15 Aug 2022 12:10:43 -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 2877360693; Mon, 15 Aug 2022 19:10:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32209C433C1; Mon, 15 Aug 2022 19:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590635; bh=mEJcYFqxbaLpd70A3pl4J4Nih1wGRQcFljgUuJNShsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KQ0A8LBV5ZefFQzipieclZ3vMHqkZ5orn0ednu917IeaiY30aPUeAIo05JDUXOWVC JKT0ObauP88vvIFOBL4Bx4S9Eq9Fhs+EgngMiB3kSbcyo/1ROadqK1x7LSmOXsuwof f2uE50WJpTzpXauTa6lpojuu3hWqQYY4uEqhm7OQ= 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.18 0322/1095] drm/mediatek: Separate poweron/poweroff from enable/disable and define new funcs Date: Mon, 15 Aug 2022 19:55:21 +0200 Message-Id: <20220815180443.115017259@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 7a98ae100c06..3a6ee6e9ad2c 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