public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: si2168: increase cmd execution timeout value
@ 2025-03-31  7:58 Christian Hewitt
  2025-03-31  8:06 ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Hewitt @ 2025-03-31  7:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Peter Rosin, Thomas Zimmermann,
	Uwe Kleine-König, Heiner Kallweit, Wolfram Sang, linux-media,
	linux-kernel

Testing with a MyGica T230C v2 USB device (0572:c68a) shows occasional
cmd timeouts that cause Tvheadend services to fail:

Jan 28 12:23:46.788180 LibreELEC kernel: si2168 1-0060: cmd execution took 0 ms
Jan 28 12:23:46.790799 LibreELEC kernel: si2168 1-0060: cmd execution took 0 ms
Jan 28 12:23:46.878158 LibreELEC kernel: si2168 1-0060: cmd execution took 80 ms
Jan 28 12:23:46.879158 LibreELEC kernel: si2168 1-0060: failed=-110
Jan 28 12:23:46.879908 LibreELEC kernel: si2168 1-0060: failed=-110
Jan 28 12:23:46.948234 LibreELEC kernel: si2168 1-0060: cmd execution took 60 ms
Jan 28 12:23:46.949121 LibreELEC kernel: si2168 1-0060: cmd execution took 0 ms
Jan 28 12:23:46.949940 LibreELEC kernel: si2168 1-0060: cmd execution took 10 ms
..
Jan 28 12:23:57.457216 LibreELEC tvheadend[3126]: subscription: 009B: service instance is bad, reason: No input detected
Jan 28 12:23:57.457392 LibreELEC tvheadend[3126]: linuxdvb: Silicon Labs Si2168 #0 : DVB-T #0 - stopping 778MHz in DVB-T Network
..
Jan 28 12:23:57.457584 LibreELEC tvheadend[3126]: subscription: 009B: No input source available for subscription "127.0.0.1 [ | Kodi Media Center ]" to channel "XXXXXXX"

The original timeout of 50ms was extended to 70ms in commit 551c33e729f6
("[media] Si2168: increase timeout to fix firmware loading") but testing
shows there are other demux commands that take longer. The largest value
observed from user reports/logs is 150ms so increase timeout to 200ms.

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
 drivers/media/dvb-frontends/si2168.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index d6b6b8bc7d4e..557e6228ffe8 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -40,7 +40,7 @@ static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd)
 
 	if (cmd->rlen) {
 		/* wait cmd execution terminate */
-		#define TIMEOUT 70
+		#define TIMEOUT 200
 		timeout = jiffies + msecs_to_jiffies(TIMEOUT);
 		while (!time_after(jiffies, timeout)) {
 			ret = i2c_master_recv(client, cmd->args, cmd->rlen);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: si2168: increase cmd execution timeout value
  2025-03-31  7:58 [PATCH] media: si2168: increase cmd execution timeout value Christian Hewitt
@ 2025-03-31  8:06 ` Wolfram Sang
  2025-03-31  8:31   ` Christian Hewitt
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2025-03-31  8:06 UTC (permalink / raw)
  To: Christian Hewitt
  Cc: Mauro Carvalho Chehab, Peter Rosin, Thomas Zimmermann,
	Uwe Kleine-König, Heiner Kallweit, linux-media, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]


>  	if (cmd->rlen) {
>  		/* wait cmd execution terminate */
> -		#define TIMEOUT 70
> +		#define TIMEOUT 200

While we are here, can we rename it to CMD_TIMEOUT and put it next to
the #includes?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: si2168: increase cmd execution timeout value
  2025-03-31  8:06 ` Wolfram Sang
@ 2025-03-31  8:31   ` Christian Hewitt
  2025-03-31  8:34     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Hewitt @ 2025-03-31  8:31 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Mauro Carvalho Chehab, Peter Rosin, Thomas Zimmermann,
	Uwe Kleine-König, Heiner Kallweit, linux-media, linux-kernel

> On 31 Mar 2025, at 12:06 pm, Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> 
> 
>> if (cmd->rlen) {
>> /* wait cmd execution terminate */
>> - #define TIMEOUT 70
>> + #define TIMEOUT 200
> 
> While we are here, can we rename it to CMD_TIMEOUT and put it next to
> the #includes?

I’m at the novice end of kernel contributors, so like this?

--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -9,6 +9,8 @@
 
 #include "si2168_priv.h"
 
+#define CMD_TIMEOUT 200
+
 static const struct dvb_frontend_ops si2168_ops;
 
 static void cmd_init(struct si2168_cmd *cmd, const u8 *buf, int wlen, int rlen)
@@ -40,8 +42,7 @@ static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd)
 
        if (cmd->rlen) {
                /* wait cmd execution terminate */
-               #define TIMEOUT 200
-               timeout = jiffies + msecs_to_jiffies(TIMEOUT);
+               timeout = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
                while (!time_after(jiffies, timeout)) {
                        ret = i2c_master_recv(client, cmd->args, cmd->rlen);
                        if (ret < 0) {
@@ -58,7 +59,7 @@ static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd)
 
                dev_dbg(&client->dev, "cmd execution took %d ms\n",
                                jiffies_to_msecs(jiffies) -
-                               (jiffies_to_msecs(timeout) - TIMEOUT));
+                               (jiffies_to_msecs(timeout) - CMD_TIMEOUT));
 
                /* error bit set? */
                if ((cmd->args[0] >> 6) & 0x01) {

Christian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: si2168: increase cmd execution timeout value
  2025-03-31  8:31   ` Christian Hewitt
@ 2025-03-31  8:34     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2025-03-31  8:34 UTC (permalink / raw)
  To: Christian Hewitt
  Cc: Mauro Carvalho Chehab, Peter Rosin, Thomas Zimmermann,
	Uwe Kleine-König, Heiner Kallweit, linux-media, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Mon, Mar 31, 2025 at 12:31:48PM +0400, Christian Hewitt wrote:
> > On 31 Mar 2025, at 12:06 pm, Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> > 
> > 
> >> if (cmd->rlen) {
> >> /* wait cmd execution terminate */
> >> - #define TIMEOUT 70
> >> + #define TIMEOUT 200
> > 
> > While we are here, can we rename it to CMD_TIMEOUT and put it next to
> > the #includes?
> 
> I’m at the novice end of kernel contributors, so like this?

Exactly! Thank you. If you send v2 of this patch, you can already add:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-31  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31  7:58 [PATCH] media: si2168: increase cmd execution timeout value Christian Hewitt
2025-03-31  8:06 ` Wolfram Sang
2025-03-31  8:31   ` Christian Hewitt
2025-03-31  8:34     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox