All of lore.kernel.org
 help / color / mirror / Atom feed
From: Houlong Wei <houlong.wei@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	Jassi Brar <jassisinghbrar@gmail.com>
Cc: Daniel Kurtz <djkurtz@chromium.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	<srv_heupstream@mediatek.com>,
	Nicolas Boichat <drinkcat@chromium.org>,
	CK HU <ck.hu@mediatek.com>,
	Bibby Hsieh <bibby.hsieh@mediatek.com>,
	Daoyuan Huang <daoyuan.huang@mediatek.com>,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	Houlong Wei <houlong.wei@mediatek.com>, <ginny.chen@mediatek.com>,
	<yongqiang.niu@mediatek.com>
Subject: [PATCH] soc: mediatek: cmdq: fixup possible timeout issue
Date: Thu, 22 Oct 2020 17:41:53 +0800	[thread overview]
Message-ID: <20201022094152.17662-1-houlong.wei@mediatek.com> (raw)

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 <houlong.wei@mediatek.com>
---
 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/mediatek/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_data 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_async_flush_cb cb,
 
 	if (client->timeout_ms != CMDQ_NO_TIMEOUT) {
 		spin_lock_irqsave(&client->lock, flags);
-		if (client->pkt_cnt++ == 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 != CMDQ_NO_TIMEOUT) {
+		spin_lock_irqsave(&client->lock, flags);
+		/*
+		 * GCE HW maybe execute too quickly and the callback function
+		 * may be invoked earlier. If this happens, pkt_cnt is reduced
+		 * by 1 in cmdq_pkt_flush_async_cb(). The timer is set only 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));
+		spin_unlock_irqrestore(&client->lock, flags);
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(cmdq_pkt_flush_async);
-- 
2.18.0

WARNING: multiple messages have this Message-ID (diff)
From: Houlong Wei <houlong.wei@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	Jassi Brar <jassisinghbrar@gmail.com>
Cc: Nicolas Boichat <drinkcat@chromium.org>,
	yongqiang.niu@mediatek.com, srv_heupstream@mediatek.com,
	Daoyuan Huang <daoyuan.huang@mediatek.com>,
	linux-kernel@vger.kernel.org,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Houlong Wei <houlong.wei@mediatek.com>,
	Bibby Hsieh <bibby.hsieh@mediatek.com>,
	CK HU <ck.hu@mediatek.com>,
	linux-arm-kernel@lists.infradead.org, ginny.chen@mediatek.com
Subject: [PATCH] soc: mediatek: cmdq: fixup possible timeout issue
Date: Thu, 22 Oct 2020 17:41:53 +0800	[thread overview]
Message-ID: <20201022094152.17662-1-houlong.wei@mediatek.com> (raw)

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 <houlong.wei@mediatek.com>
---
 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/mediatek/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_data 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_async_flush_cb cb,
 
 	if (client->timeout_ms != CMDQ_NO_TIMEOUT) {
 		spin_lock_irqsave(&client->lock, flags);
-		if (client->pkt_cnt++ == 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 != CMDQ_NO_TIMEOUT) {
+		spin_lock_irqsave(&client->lock, flags);
+		/*
+		 * GCE HW maybe execute too quickly and the callback function
+		 * may be invoked earlier. If this happens, pkt_cnt is reduced
+		 * by 1 in cmdq_pkt_flush_async_cb(). The timer is set only 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));
+		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

WARNING: multiple messages have this Message-ID (diff)
From: Houlong Wei <houlong.wei@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	Jassi Brar <jassisinghbrar@gmail.com>
Cc: Nicolas Boichat <drinkcat@chromium.org>,
	yongqiang.niu@mediatek.com, srv_heupstream@mediatek.com,
	Daoyuan Huang <daoyuan.huang@mediatek.com>,
	linux-kernel@vger.kernel.org, Daniel Kurtz <djkurtz@chromium.org>,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Houlong Wei <houlong.wei@mediatek.com>,
	Bibby Hsieh <bibby.hsieh@mediatek.com>,
	CK HU <ck.hu@mediatek.com>,
	linux-arm-kernel@lists.infradead.org, ginny.chen@mediatek.com
Subject: [PATCH] soc: mediatek: cmdq: fixup possible timeout issue
Date: Thu, 22 Oct 2020 17:41:53 +0800	[thread overview]
Message-ID: <20201022094152.17662-1-houlong.wei@mediatek.com> (raw)

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 <houlong.wei@mediatek.com>
---
 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/mediatek/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_data 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_async_flush_cb cb,
 
 	if (client->timeout_ms != CMDQ_NO_TIMEOUT) {
 		spin_lock_irqsave(&client->lock, flags);
-		if (client->pkt_cnt++ == 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 != CMDQ_NO_TIMEOUT) {
+		spin_lock_irqsave(&client->lock, flags);
+		/*
+		 * GCE HW maybe execute too quickly and the callback function
+		 * may be invoked earlier. If this happens, pkt_cnt is reduced
+		 * by 1 in cmdq_pkt_flush_async_cb(). The timer is set only 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));
+		spin_unlock_irqrestore(&client->lock, flags);
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(cmdq_pkt_flush_async);
-- 
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2020-10-22  9:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22  9:41 Houlong Wei [this message]
2020-10-22  9:41 ` [PATCH] soc: mediatek: cmdq: fixup possible timeout issue Houlong Wei
2020-10-22  9:41 ` Houlong Wei
2020-10-31  1:49 ` Nicolas Boichat
2020-10-31  1:49   ` Nicolas Boichat
2020-10-31  1:49   ` Nicolas Boichat
2020-11-02  0:44 ` Chun-Kuang Hu
2020-11-02  0:44   ` Chun-Kuang Hu
2020-11-02  0:44   ` Chun-Kuang Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201022094152.17662-1-houlong.wei@mediatek.com \
    --to=houlong.wei@mediatek.com \
    --cc=bibby.hsieh@mediatek.com \
    --cc=ck.hu@mediatek.com \
    --cc=daoyuan.huang@mediatek.com \
    --cc=dennis-yc.hsieh@mediatek.com \
    --cc=djkurtz@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=ginny.chen@mediatek.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=srv_heupstream@mediatek.com \
    --cc=yongqiang.niu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.