Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2952025pxx; Sun, 1 Nov 2020 16:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXsq9Yo/NyiIasrGz6bwVVIOld8n3aGgvVqhFr9nlLi+pmjB/pwsk4Eh6HqpCH8xMHLO2F X-Received: by 2002:a17:906:2b8d:: with SMTP id m13mr9194115ejg.536.1604278066868; Sun, 01 Nov 2020 16:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604278066; cv=none; d=google.com; s=arc-20160816; b=JowwqN868r9EFk+2g1lsAKidDvT9U1zOXDulmbFNudD/0wVTI0slFTwrnQ+zM1kG5u fupZO6yEW8SVu/gFdpqpORr0dhr2EUa7WbEeanxOAqLkG+iYqJ24hXuN9bcxRIDkW0fs UpVYEh05dcBgB5FBQhv8YOzzLg0cE3TZx8Cm9mjslFoziycP4D2sphy+kgW97aenSgso cUZeL89vA5foT/WqqSGfOUwZcPDzvjjVmKZ0NMBV/MRiqtWY42Ni0coiCGMJVDzoNIdz 8ryaB1FRlKKLOrEtMtH3y3rEvPrKVEL8WaPUCcOhWlZtCzt4Ybj2IqcC3KqYmx7wqKgh Kbig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pwGvK8xD4zeGCATA8Oiza5SKhDa94HhIEsaZbO7ExRg=; b=h6rMBFZDis5ORwRlegeb2X7cv9FwSeewqjYRinVospkVQHHEDiK10yy5V3Wmu6c3Px 8mk/G5ZE0DjUA/FTUTjpc7X8lcUYn75icwTJGyJi7ilvmRK2COMz5nijjomteyaOANgb Nj6ZBkJp5apBoTg41ahgGaMtjkfle3kzihzXi1y3yPWUYtkDuVafDzNqKU9qbReXADl4 cYefXm+RSkq3PkPbQtFXB90otq4mewOYAHRchcvKnNaQft/G3vl2vg0GkRyRzd4aAAUQ OhqZnSLKXDf1KQhBCekDcMy7fifyDX/1LbQijXKeFxJ8rGesy29kh/XHnu65XJCcxd0V FIBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GQx/7dTf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si10499592ejb.125.2020.11.01.16.47.08; Sun, 01 Nov 2020 16:47:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GQx/7dTf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbgKBAob (ORCPT + 99 others); Sun, 1 Nov 2020 19:44:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:43552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbgKBAoa (ORCPT ); Sun, 1 Nov 2020 19:44:30 -0500 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C973222273 for ; Mon, 2 Nov 2020 00:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604277870; bh=KaiRQcVGa2tJ5Os4qhu+MrURan2Yqg+O/vf3Vf6r8s8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GQx/7dTfbZIc7nbb5piys34SR6dIcocJeeXnq/6g5wzMj/K3PpuW14+vOeY8VJ5FG oKaLG9iLzD4xpKKNwjhfxWeNAiDxuRTMalNKpajsfEXBU9uGd6azINpR+Bgcon6SKX M8BB9dNf8CbxP/Hu8Zf0WbRO4Z54dPS9HBt5pEOg= Received: by mail-ej1-f46.google.com with SMTP id w13so3112794eju.13 for ; Sun, 01 Nov 2020 16:44:29 -0800 (PST) X-Gm-Message-State: AOAM532Zfc118Koxoh175r+EUObbyzKs/G9IqOidf9rfL0pnhSIixWIX LYTjDDFBEGtEsg/TpQy2jPJZ/aKu5eYYHpzzpw== X-Received: by 2002:a17:906:3e49:: with SMTP id t9mr3688121eji.75.1604277868412; Sun, 01 Nov 2020 16:44:28 -0800 (PST) MIME-Version: 1.0 References: <20201022094152.17662-1-houlong.wei@mediatek.com> In-Reply-To: <20201022094152.17662-1-houlong.wei@mediatek.com> From: Chun-Kuang Hu Date: Mon, 2 Nov 2020 08:44:16 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] soc: mediatek: cmdq: fixup possible timeout issue To: Houlong Wei Cc: Matthias Brugger , Jassi Brar , Nicolas Boichat , Yongqiang Niu , srv_heupstream , Daoyuan Huang , linux-kernel , Dennis-YC Hsieh , "moderated list:ARM/Mediatek SoC support" , Bibby Hsieh , CK HU , Linux ARM , ginny.chen@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, Houlong: Houlong Wei =E6=96=BC 2020=E5=B9=B410=E6=9C=8822= =E6=97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=885:55=E5=AF=AB=E9=81=93=EF=BC= =9A > > Fixes: 576f1b4bc802 ("soc: mediatek: Add Mediatek CMDQ helper") > > There may be possible timeout issue when lots of cmdq packets are > flushed to the same cmdq client. The necessary modifications are as > below. > 1.Adjust the timer timeout period as client->timeout_ms * client->pkt_cnt= . > 2.Optimize the time to start the timer. > > Signed-off-by: Houlong Wei > --- > drivers/soc/mediatek/mtk-cmdq-helper.c | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediate= k/mtk-cmdq-helper.c > index dc644cfb6419..31142c193527 100644 > --- a/drivers/soc/mediatek/mtk-cmdq-helper.c > +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c > @@ -350,7 +350,8 @@ static void cmdq_pkt_flush_async_cb(struct cmdq_cb_da= ta data) > del_timer(&client->timer); > else > mod_timer(&client->timer, jiffies + > - msecs_to_jiffies(client->timeout_ms)); > + msecs_to_jiffies(client->timeout_ms * > + client->pkt_cnt)); > spin_unlock_irqrestore(&client->lock, flags); > } > > @@ -379,9 +380,7 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_a= sync_flush_cb cb, > > if (client->timeout_ms !=3D CMDQ_NO_TIMEOUT) { > spin_lock_irqsave(&client->lock, flags); > - if (client->pkt_cnt++ =3D=3D 0) > - mod_timer(&client->timer, jiffies + > - msecs_to_jiffies(client->timeout_ms)); > + client->pkt_cnt++; > spin_unlock_irqrestore(&client->lock, flags); > } > > @@ -391,6 +390,21 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_= async_flush_cb cb, > /* We can send next packet immediately, so just call txdone. */ > mbox_client_txdone(client->chan, 0); > > + if (client->timeout_ms !=3D CMDQ_NO_TIMEOUT) { > + spin_lock_irqsave(&client->lock, flags); > + /* > + * GCE HW maybe execute too quickly and the callback func= tion > + * may be invoked earlier. If this happens, pkt_cnt is re= duced > + * by 1 in cmdq_pkt_flush_async_cb(). The timer is set on= ly if > + * pkt_cnt is greater than 0. > + */ > + if (client->pkt_cnt > 0) > + mod_timer(&client->timer, jiffies + > + msecs_to_jiffies(client->timeout_ms * > + client->pkt_cnt)); I think for some client, it care about execution time of one packet, but some client care about total execution time of all packets, so we should let client driver implement its own timeout handler and remove handler in cmdq helper [1]. [1] https://patchwork.kernel.org/project/linux-mediatek/patch/2020110200043= 8.29225-1-chunkuang.hu@kernel.org/ Regards, Chun-Kuang. > + spin_unlock_irqrestore(&client->lock, flags); > + } > + > return 0; > } > EXPORT_SYMBOL(cmdq_pkt_flush_async); > -- > 2.18.0 > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek