Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp95924rwb; Mon, 26 Sep 2022 09:44:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6smNMRGH4fgMBXWRzUjAYfjzkYpG6m7Uh+hybpwC9rQZVPP0ekw3yPaEn0ab0RkiJHvREI X-Received: by 2002:a62:ce07:0:b0:540:da19:bf6d with SMTP id y7-20020a62ce07000000b00540da19bf6dmr24557302pfg.31.1664210658993; Mon, 26 Sep 2022 09:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664210658; cv=none; d=google.com; s=arc-20160816; b=VR15DdkeCq1421BP5xiw84PqFLW/uNTl0Bn971eFr2HozSxyH70juq+EOLbbMKuh78 X05bWHvDxsQ1S0f4AWukBXUPG+iyRmG/tqN/fP0+O9aGjt2iMHvVP+Tita465njhruFN UBcxqFfLe9xoqiyfyRq7T6VpG8TvBkvOKvM2j/TU6GMw5IyNQ01m17xwsGB6Gi731uoo 1c+jAFQozD55yYFN5BYv5A1iRj7o5873q96v1hVY/10+nkdEh8ZhcPb5HZ0smLVdXBGa nubJV+s5CECiegCtt8qOHnV4zA18/CBxfg+JU43bBWCOB0oMkhxnRK70d/2NcNh48uEe HV0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FIFgHqPBPNy3yM204wyN2Is4H3dGTWgaSTtPRpzzBuw=; b=BofAsNo/MUVhNG5mDjOuQvwg+GEy2PYQ3too80ulpsQX3GU5EmNCFvTBJ+9+Zv1WU3 K4cvSOMdJzt4BG97Yt5bZhuxXekA9/nbWkL/jeDpulrQxotCnr7q3OUfVGfymrpnjXny +ZcEgFjcPW061f/5QK0LCoZTwKOAaxyemuRfyI5Rbs49PzD+eTVwIWEWYEl4g40e+Ud6 TxZgIqqzH8BkA7nn9qIG2nRUCkaW+S8SiXBuqr1k9ajazgeXK8SIAXlX+nzgM26FjIyC 7fjCnYmKS6Pv13BRgM8YDjTQcqluWJS6wo98PTx8GV/kQ69uqJOL3crJMLeQF4W4b3Po qMyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ty75L7GM; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj9-20020a17090b4d8900b002025f34cc78si13194485pjb.52.2022.09.26.09.43.40; Mon, 26 Sep 2022 09:44:18 -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=@collabora.com header.s=mail header.b=Ty75L7GM; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbiIZQdN (ORCPT + 99 others); Mon, 26 Sep 2022 12:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiIZQch (ORCPT ); Mon, 26 Sep 2022 12:32:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E1782D29 for ; Mon, 26 Sep 2022 08:21:23 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id C04086600371; Mon, 26 Sep 2022 16:21:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664205671; bh=CUjqHy4tnGfM2kkCAOfVdjkEold9qGI9EH5hPzPlOkI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ty75L7GMLlZIna8DWvtOYYFccyAcn3A/3yv52cjxgdoMwL7gnOa8VI7qfyKAhnlH0 CHQS/QvvIUCcQDjc2xdrCEsmDg5JrWRhQg2aZXEiSylUDdEFS2KNoZMOtfBCqz3JRX Hm13kgdPk7j7t00VSaiwfFcZDPWK5SjQnr74H0jOcEjfx5BPnxgmhRJg8chX2NLB+y x2pvUfqS70XkwwjwpvzKloLoT+G7YgEPCqqpNtvKhnNm3tq/VJZt5WpwFVSm4rKQIw JFrZSeHUxWwMuAz9gzUT5XVfjA8vWybGIhEeL4Jr1fFZTlh3JqE6ZiKJHKu478sfiF N5E72ZgF22d7w== Message-ID: Date: Mon, 26 Sep 2022 17:21:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [RESEND PATCH v3] mailbox: mtk-cmdq: fix gce timeout issue Content-Language: en-US To: Yongqiang Niu , CK Hu , Chun-Kuang Hu Cc: Jassi Brar , Matthias Brugger , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com, Hsin-Yi Wang References: <20220926090219.11871-1-yongqiang.niu@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20220926090219.11871-1-yongqiang.niu@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS 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 Il 26/09/22 11:02, Yongqiang Niu ha scritto: > 1. enable gce ddr enable(gce reigster offset 0x48, bit 16 to 18) when gce work, > and disable gce ddr enable when gce work job done > 2. split cmdq clk enable/disable api, and control gce ddr enable/disable > in clk enable/disable function to make sure it could protect when cmdq > is multiple used by display and mdp > > this is only for some SOC which has flag "control_by_sw". > for this kind of gce, there is a handshake flow between gce and ddr > hardware, > if not set ddr enable flag of gce, ddr will fall into idle mode, > then gce instructions will not process done. > we need set this flag of gce to tell ddr when gce is idle or busy > controlled by software flow. > > ddr problem is a special case. > when test suspend/resume case, gce sometimes will pull ddr, and ddr can > not go to suspend. > if we set gce register 0x48 to 0x7, will fix this gce pull ddr issue, > as you have referred [1] and [2] (8192 and 8195) > but for mt8186, the gce is more special, except setting of [1] and [2], > we need add more setting set gce register 0x48 to (0x7 << 16 | 0x7) > when gce working to make sure gce could process all instructions ok. > this case just need normal bootup, if we not set this, display cmdq > task will timeout, and chrome homescreen will always black screen. > > and with this patch, we have done these test on mt8186: > 1.suspend/resume > 2.boot up to home screen > 3.playback video with youtube. > > suspend issue is special gce hardware issue, gce client driver > command already process done, but gce still pull ddr. > > Signed-off-by: Yongqiang Niu > --- > change sinc v2: > 1. add definition GCE_CTRL_BY_SW and GCE_DDR_EN instead of magic number > --- > > --- > drivers/mailbox/mtk-cmdq-mailbox.c | 68 +++++++++++++++++++++++++++--- > 1 file changed, 63 insertions(+), 5 deletions(-) > > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c > index 9465f9081515..bd63773b05fd 100644 > --- a/drivers/mailbox/mtk-cmdq-mailbox.c > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c > @@ -38,6 +38,8 @@ > #define CMDQ_THR_PRIORITY 0x40 > > #define GCE_GCTL_VALUE 0x48 > +#define GCE_CTRL_BY_SW GENMASK(18, 16) > +#define GCE_DDR_EN GENMASK(2, 0) > > #define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200 > #define CMDQ_THR_ENABLED 0x1 > @@ -80,16 +82,60 @@ struct cmdq { > bool suspended; > u8 shift_pa; > bool control_by_sw; > + bool sw_ddr_en; > u32 gce_num; > + atomic_t usage; > + spinlock_t lock; > }; > > struct gce_plat { > u32 thread_nr; > u8 shift; > bool control_by_sw; > + bool sw_ddr_en; > u32 gce_num; > }; > > +static s32 cmdq_clk_enable(struct cmdq *cmdq) > +{ > + s32 usage, ret; > + unsigned long flags; > + > + spin_lock_irqsave(&cmdq->lock, flags); All this locking is avoidable on all SoCs where (sw_ddr_en == false), which means that this is needed only for one SoC (MT8186). You can solve that by adding a callback pointer on the gce_plat data, so that we get something like: static int cmdq_clk_swddr_enable(struct cmdq *cmdq) { lock, atomic_inc, clk_bulk_enable, writel(....); } static int cmdq_clk_enable(struct cmdq *cmdq) { return clk_bulk_enable(cmdq->gce_num, cmdq->clocks); }; static const struct gce_plat gce_plat_v7 = { ........... .clk_enable = cmdq_clk_swddr_enable, .clk_disable = cmdq_clk_swddr_disable, .......... }; Please care about older SoCs' performance. Regards, Angelo