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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1907C433F5 for ; Fri, 19 Nov 2021 00:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C587161ABD for ; Fri, 19 Nov 2021 00:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbhKSAFB (ORCPT ); Thu, 18 Nov 2021 19:05:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:57954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbhKSAFA (ORCPT ); Thu, 18 Nov 2021 19:05:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DFFD61AD0 for ; Fri, 19 Nov 2021 00:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637280119; bh=AoNZd47gCGaimK9v5NfigphGWhTSDsXfAmbFC4BIlz4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Lmq7eHFQfyyikTZkqVB4YTGA+sw+e7PKhSPSxzUx9AAn0X6/GyE6UcqLyYm4BmD24 +xCYcoK+WvTm0LWxHMNIPZ4ALkoGI1YTyzsZCONyYdXjiDe+KS6/H0ELH+UMwSMOam BGN627Tvg879jCfHGN8vVIQNeBjxpb7TqfiZMVqHvPbF2zeq/NUEmTCQUdSizO7CXc 1KecLoH2ubW8vlFF3DB+0dPkwjiveEp1kL/Y2zihwpysKNT1dhoXlcDdrytZIDgPz2 Gh4Peu3R30ixCYiGCfTB5d+bxidTRRWTsgLXKa6R67N0INmd8oUpRng7z1QzvwLmzU cOgsFYbpdvifg== Received: by mail-ed1-f47.google.com with SMTP id b15so34701087edd.7 for ; Thu, 18 Nov 2021 16:01:59 -0800 (PST) X-Gm-Message-State: AOAM531nBuJWujOhiS5JLY95FKHVYz03pOTowsfhqceHzkZWQ69i1LW1 NHQFmQGe1xSrMcoGrz3u+uRvVXEkn3gyq5I55Q== X-Google-Smtp-Source: ABdhPJzJ+m25jkKAHUC8dqOXn/CxWb6mvvVoe7NwAcoZoKeWFquNa7VfncVxf9FsAbU+dFfNaujeGSmcwQHUHnIoiD0= X-Received: by 2002:a50:e608:: with SMTP id y8mr16990077edm.39.1637280117833; Thu, 18 Nov 2021 16:01:57 -0800 (PST) MIME-Version: 1.0 References: <20211117064158.27451-1-jason-jh.lin@mediatek.com> <20211117064158.27451-3-jason-jh.lin@mediatek.com> In-Reply-To: <20211117064158.27451-3-jason-jh.lin@mediatek.com> From: Chun-Kuang Hu Date: Fri, 19 Nov 2021 08:01:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] mailbox: add cmdq_mbox_flush to clear all task before suspend To: "jason-jh.lin" Cc: Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , Jassi Brar , David Airlie , Daniel Vetter , DRI Development , "moderated list:ARM/Mediatek SoC support" , Linux ARM , linux-kernel , Hsin-Yi Wang , Fei Shao , tzungbi@google.com, Nancy Lin , singo.chang@mediatek.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jason: jason-jh.lin =E6=96=BC 2021=E5=B9=B411=E6=9C=88= 17=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=882:42=E5=AF=AB=E9=81=93=EF= =BC=9A > > CMDQ driver will occupy GCE clock to execute the task in GCE thread. > > So call cmdq_mbox_flush to clear all task in GCE thread before > CMDQ suspend. > > Signed-off-by: jason-jh.lin > --- > drivers/mailbox/mtk-cmdq-mailbox.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmd= q-mailbox.c > index 03f9ed4c5131..28cadfc0091b 100644 > --- a/drivers/mailbox/mtk-cmdq-mailbox.c > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c > @@ -484,21 +484,18 @@ static int cmdq_suspend(struct device *dev) > struct cmdq *cmdq =3D dev_get_drvdata(dev); > struct cmdq_thread *thread; > int i; > - bool task_running =3D false; > > cmdq->suspended =3D true; > > for (i =3D 0; i < cmdq->thread_nr; i++) { > thread =3D &cmdq->thread[i]; > if (!list_empty(&thread->task_busy_list)) { > - task_running =3D true; > - break; > + /* try to clear all task in this thread */ > + cmdq_mbox_flush(thread->chan, 2000); I would like the normal control flow rather than error handling. So the normal control flow is: 1. Client driver suspend: Flush command. 2. CMDQ driver suspend: There is no command to flush. If there are command, show error message and debug the client driver. The error handling flow: 1. Client driver suspend: Does not flush command. 2. CMDQ driver suspend: Flush command and callback to client driver. Client driver process these callback as error handling. The client driver may integrate multiple driver. In the suspend flow, it may need to stop these driver in a sequence such as. 1. Stop driver 1 2. Stop driver 2 3. Stop driver 3 (cmdq) 4. Stop driver 4 5. Stop driver 5. In the normal flow, client driver could control the stop flow. In the error handling flow, it does not match the stop flow. Regards, Chun-Kuang. > + dev_warn(dev, "thread[%d] exist running task(s) i= n suspend\n", i); > } > } > > - if (task_running) > - dev_warn(dev, "exist running task(s) in suspend\n"); > - > clk_bulk_unprepare(cmdq->gce_num, cmdq->clocks); > > return 0; > -- > 2.18.0 >