* [PATCH] media: rc: Fix simulated TX timer lifecycle
@ 2026-09-29 14:31 Runyu Xiao
2026-09-29 16:20 ` Sean Young
0 siblings, 1 reply; 5+ messages in thread
From: Runyu Xiao @ 2026-09-29 14:31 UTC (permalink / raw)
To: Maxim Levitsky
Cc: Sean Young, Mauro Carvalho Chehab, linux-media, linux-kernel,
stable, Runyu Xiao, Jianhao Xu
The ENE driver only initializes tx_sim_timer when TX simulation is
enabled for hardware without native TX support. However, ene_remove()
passes the timer to timer_delete_sync() unconditionally, and
ene_tx_sample() uses the global txsim parameter when deciding whether to
arm it. Thus a normal device, or a device with native TX support and
txsim enabled, can operate on an uninitialized timer.
Track whether simulation was actually enabled for each device and use
that state for timer arming and teardown. Since the simulation callback
rearms the timer, shut it down permanently before freeing the device.
Fixes: 9ea53b74df9c ("V4L/DVB: STAGING: remove lirc_ene0100 driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
drivers/media/rc/ene_ir.c | 6 ++++--
drivers/media/rc/ene_ir.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index 6f7dccc96..9d0279667 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -652,7 +652,7 @@ static void ene_tx_sample(struct ene_device *dev)
dev->tx_reg = !dev->tx_reg;
exit:
/* simulate TX done interrupt */
- if (txsim)
+ if (dev->tx_sim_enabled)
mod_timer(&dev->tx_sim_timer, jiffies + HZ / 500);
}
@@ -1032,6 +1032,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
if (!dev->hw_learning_and_tx_capable && txsim) {
dev->hw_learning_and_tx_capable = true;
+ dev->tx_sim_enabled = true;
timer_setup(&dev->tx_sim_timer, ene_tx_irqsim, 0);
pr_warn("Simulation of TX activated\n");
}
@@ -1103,7 +1104,8 @@ static void ene_remove(struct pnp_dev *pnp_dev)
unsigned long flags;
rc_unregister_device(dev->rdev);
- timer_delete_sync(&dev->tx_sim_timer);
+ if (dev->tx_sim_enabled)
+ timer_shutdown_sync(&dev->tx_sim_timer);
spin_lock_irqsave(&dev->hw_lock, flags);
ene_rx_disable(dev);
ene_rx_restore_hw_buffer(dev);
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
index c1c44e86e..f44cbc034 100644
--- a/drivers/media/rc/ene_ir.h
+++ b/drivers/media/rc/ene_ir.h
@@ -218,6 +218,7 @@ struct ene_device {
int tx_done; /* done transmitting */
/* one more sample pending*/
struct completion tx_complete; /* TX completion */
+ bool tx_sim_enabled; /* simulated TX is enabled */
struct timer_list tx_sim_timer;
/* TX settings */
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] media: rc: Fix simulated TX timer lifecycle
2026-09-29 14:31 [PATCH] media: rc: Fix simulated TX timer lifecycle Runyu Xiao
@ 2026-09-29 16:20 ` Sean Young
2026-10-04 9:45 ` Runyu Xiao
0 siblings, 1 reply; 5+ messages in thread
From: Sean Young @ 2026-09-29 16:20 UTC (permalink / raw)
To: Runyu Xiao
Cc: Maxim Levitsky, Mauro Carvalho Chehab, linux-media, linux-kernel,
stable, Jianhao Xu
On Tue, Sep 29, 2026 at 10:31:05PM +0800, Runyu Xiao wrote:
> The ENE driver only initializes tx_sim_timer when TX simulation is
> enabled for hardware without native TX support. However, ene_remove()
> passes the timer to timer_delete_sync() unconditionally, and
> ene_tx_sample() uses the global txsim parameter when deciding whether to
> arm it. Thus a normal device, or a device with native TX support and
> txsim enabled, can operate on an uninitialized timer.
>
> Track whether simulation was actually enabled for each device and use
> that state for timer arming and teardown. Since the simulation callback
> rearms the timer, shut it down permanently before freeing the device.
I think this patch is correct, but I am not sure txsim is really needed
in the source code. Maybe it's better to just remove txsim module parameter
and all the related code.
Sean
> Fixes: 9ea53b74df9c ("V4L/DVB: STAGING: remove lirc_ene0100 driver")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> drivers/media/rc/ene_ir.c | 6 ++++--
> drivers/media/rc/ene_ir.h | 1 +
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
> index 6f7dccc96..9d0279667 100644
> --- a/drivers/media/rc/ene_ir.c
> +++ b/drivers/media/rc/ene_ir.c
> @@ -652,7 +652,7 @@ static void ene_tx_sample(struct ene_device *dev)
> dev->tx_reg = !dev->tx_reg;
> exit:
> /* simulate TX done interrupt */
> - if (txsim)
> + if (dev->tx_sim_enabled)
> mod_timer(&dev->tx_sim_timer, jiffies + HZ / 500);
> }
>
> @@ -1032,6 +1032,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
>
> if (!dev->hw_learning_and_tx_capable && txsim) {
> dev->hw_learning_and_tx_capable = true;
> + dev->tx_sim_enabled = true;
> timer_setup(&dev->tx_sim_timer, ene_tx_irqsim, 0);
> pr_warn("Simulation of TX activated\n");
> }
> @@ -1103,7 +1104,8 @@ static void ene_remove(struct pnp_dev *pnp_dev)
> unsigned long flags;
>
> rc_unregister_device(dev->rdev);
> - timer_delete_sync(&dev->tx_sim_timer);
> + if (dev->tx_sim_enabled)
> + timer_shutdown_sync(&dev->tx_sim_timer);
> spin_lock_irqsave(&dev->hw_lock, flags);
> ene_rx_disable(dev);
> ene_rx_restore_hw_buffer(dev);
> diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
> index c1c44e86e..f44cbc034 100644
> --- a/drivers/media/rc/ene_ir.h
> +++ b/drivers/media/rc/ene_ir.h
> @@ -218,6 +218,7 @@ struct ene_device {
> int tx_done; /* done transmitting */
> /* one more sample pending*/
> struct completion tx_complete; /* TX completion */
> + bool tx_sim_enabled; /* simulated TX is enabled */
> struct timer_list tx_sim_timer;
>
> /* TX settings */
> --
> 2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] media: rc: Fix simulated TX timer lifecycle
2026-09-29 16:20 ` Sean Young
@ 2026-10-04 9:45 ` Runyu Xiao
2026-10-04 11:21 ` Sean Young
0 siblings, 1 reply; 5+ messages in thread
From: Runyu Xiao @ 2026-10-04 9:45 UTC (permalink / raw)
To: Sean Young
Cc: Maxim Levitsky, Mauro Carvalho Chehab, linux-media, linux-kernel,
stable, Jianhao Xu, Runyu Xiao
Hi Sean,
Thanks for the review.
On Tue, Sep 29, 2026 at 05:20:25PM +0100, Sean Young wrote:
> I think this patch is correct, but I am not sure txsim is really needed
> in the source code. Maybe it's better to just remove txsim module parameter
> and all related code.
The txsim parameter enables the driver to expose TX on hardware without
native TX support by simulating TX completion. I found no in-tree references
outside ene_ir.c and no separate documentation for txsim. Removing it would
drop that fallback. Do you consider this fallback obsolete and prefer
removing it in this change? If so, I can revise the patch to remove txsim and
its related code; otherwise, I will keep the timer-lifecycle fix separate
from that cleanup.
Thanks,
Runyu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] media: rc: Fix simulated TX timer lifecycle
2026-10-04 9:45 ` Runyu Xiao
@ 2026-10-04 11:21 ` Sean Young
2026-10-04 12:37 ` Runyu Xiao
0 siblings, 1 reply; 5+ messages in thread
From: Sean Young @ 2026-10-04 11:21 UTC (permalink / raw)
To: Runyu Xiao
Cc: Maxim Levitsky, Mauro Carvalho Chehab, linux-media, linux-kernel,
stable, Jianhao Xu
On Sun, Oct 04, 2026 at 05:45:07PM +0800, Runyu Xiao wrote:
> On Tue, Sep 29, 2026 at 05:20:25PM +0100, Sean Young wrote:
> > I think this patch is correct, but I am not sure txsim is really needed
> > in the source code. Maybe it's better to just remove txsim module parameter
> > and all related code.
>
> The txsim parameter enables the driver to expose TX on hardware without
> native TX support by simulating TX completion. I found no in-tree references
> outside ene_ir.c and no separate documentation for txsim. Removing it would
> drop that fallback. Do you consider this fallback obsolete and prefer
> removing it in this change? If so, I can revise the patch to remove txsim and
> its related code; otherwise, I will keep the timer-lifecycle fix separate
> from that cleanup.
If the hardware has no TX capability then what is the point of those code
paths other than exercises the code paths. Might as well go (unless I missed
something)
Sean
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] media: rc: Fix simulated TX timer lifecycle
2026-10-04 11:21 ` Sean Young
@ 2026-10-04 12:37 ` Runyu Xiao
0 siblings, 0 replies; 5+ messages in thread
From: Runyu Xiao @ 2026-10-04 12:37 UTC (permalink / raw)
To: Sean Young
Cc: Maxim Levitsky, Mauro Carvalho Chehab, linux-media, linux-kernel,
stable, Jianhao Xu, Runyu Xiao
On Sun, 4 Oct 2026 12:21:13 +0100, Sean Young wrote:
> If the hardware has no TX capability then what is the point of those code
> paths other than exercises the code paths. Might as well go (unless I missed
> something)
You're right that `txsim` has no clear supported use case. It enables the TX
path on hardware that reports no TX capability and uses a timer to fake TX
completion, while the samples are still written to the hardware TX output
registers. I have not found evidence that this provides reliable transmission
on such hardware.
I'll remove the `txsim` parameter and its timer-based simulation path while
keeping native TX support for hardware that reports the capability. This also
removes the timer lifecycle issue, so I will revise the patch to remove the
unsupported simulation path instead of keeping a standalone timer fix.
Thanks,
Runyu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-04 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 14:31 [PATCH] media: rc: Fix simulated TX timer lifecycle Runyu Xiao
2026-09-29 16:20 ` Sean Young
2026-10-04 9:45 ` Runyu Xiao
2026-10-04 11:21 ` Sean Young
2026-10-04 12:37 ` Runyu Xiao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®