Mailing List Archive

Remote keys repeating way too fast
Hi All,
Apologies for the earlier incomplete post, I hit the send key
by accident.

I just did an apt-upgrade of my ubuntu 20.10 mythtv 0.31 server and
suddenly my hard won lircd setup has started repeating keys when I
use my generic Microsoft Media Center remote.

The update updated mythtv to 31.0+fixes.202103051941.6c7c8b0351 and
the kernel version to 5.8.0-45-generic #51 so I'm not sure if the
problem was due to mythtv, the kernel or some other package update.
Lirc was not updated and remains at 0.10.1[1087].

I wanted to take lircd out of the equation and see if the problem
lies with the kernel's dev-input layer, so I shutdown lircd and
ran evtest to see if the remote's keys generated the repeats.

root@lisa:~# systemctl stop lircd
root@lisa:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Power Button
... lines omitted for brevity
/dev/input/event16: Media Center Ed. eHome Infrared Remote Transceiver (0471:060c)
Select the device event number [0-16]: 16
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x471 product 0x60c version 0x101
Input device name: "Media Center Ed. eHome Infrared Remote Transceiver (0471:060c)"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 2 (KEY_1)
Event code 3 (KEY_2)
Event code 4 (KEY_3)
... lines omitted for brevity
Key repeat handling:
Repeat type 20 (EV_REP)
Repeat code 0 (REP_DELAY)
Value 500
Repeat code 1 (REP_PERIOD)
Value 125
Properties:
Property type 5 (INPUT_PROP_POINTING_STICK)
Testing ... (interrupt to exit)
Event: time 1618540114.824036, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
Event: time 1618540114.824036, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
Event: time 1618540114.824036, -------------- SYN_REPORT ------------
Event: time 1618540114.931034, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
Event: time 1618540114.931034, -------------- SYN_REPORT ------------
Event: time 1618540115.037033, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
Event: time 1618540115.037033, -------------- SYN_REPORT ------------
Event: time 1618540115.143035, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
Event: time 1618540115.143035, -------------- SYN_REPORT ------------
Event: time 1618540115.338814, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
Event: time 1618540115.338814, -------------- SYN_REPORT ------------
Event: time 1618540115.474815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
Event: time 1618540115.474815, -------------- SYN_REPORT ------------
Event: time 1618540115.606815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
Event: time 1618540115.606815, -------------- SYN_REPORT ------------
Event: time 1618540115.738815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
... repeating lines omitted for brevity ...
Event: time 1618540127.938815, -------------- SYN_REPORT ------------
Event: time 1618540127.938815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 0
Event: time 1618540127.938815, -------------- SYN_REPORT ------------

One key press of the right arrow key on the remote generated
around 96 KEY_DOWN events.

I tried playing with ir-keytable's -D and -P options but this just slowed down the
repeats and I still got around ~96 repeats. It doesn't matter which key I hit either.

If I start up lircd, irw reports the same issue as I understand it simply reading
from the kernel input layer.

I even upgraded the kernel from 5.8.0-45-generic #51 to 5.8.0-50 #56 in the hope
that the problem in the input layer might already have been fixed... but no joy.

Any thoughts hugely appreciated.

Cheers,

Doug
--
"The big print giveth and the small print taketh away."


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remote keys repeating way too fast [ In reply to ]
On Fri, 16 Apr 2021 02:44:12 +0000, you wrote:

>Hi All,
> Apologies for the earlier incomplete post, I hit the send key
> by accident.
>
> I just did an apt-upgrade of my ubuntu 20.10 mythtv 0.31 server and
> suddenly my hard won lircd setup has started repeating keys when I
> use my generic Microsoft Media Center remote.
>
> The update updated mythtv to 31.0+fixes.202103051941.6c7c8b0351 and
> the kernel version to 5.8.0-45-generic #51 so I'm not sure if the
> problem was due to mythtv, the kernel or some other package update.
> Lirc was not updated and remains at 0.10.1[1087].
>
> I wanted to take lircd out of the equation and see if the problem
> lies with the kernel's dev-input layer, so I shutdown lircd and
> ran evtest to see if the remote's keys generated the repeats.
>
> root@lisa:~# systemctl stop lircd
> root@lisa:~# evtest
> No device specified, trying to scan all of /dev/input/event*
> Available devices:
> /dev/input/event0: Power Button
> ... lines omitted for brevity
> /dev/input/event16: Media Center Ed. eHome Infrared Remote Transceiver (0471:060c)
> Select the device event number [0-16]: 16
> Input driver version is 1.0.1
> Input device ID: bus 0x3 vendor 0x471 product 0x60c version 0x101
> Input device name: "Media Center Ed. eHome Infrared Remote Transceiver (0471:060c)"
> Supported events:
> Event type 0 (EV_SYN)
> Event type 1 (EV_KEY)
> Event code 2 (KEY_1)
> Event code 3 (KEY_2)
> Event code 4 (KEY_3)
> ... lines omitted for brevity
> Key repeat handling:
> Repeat type 20 (EV_REP)
> Repeat code 0 (REP_DELAY)
> Value 500
> Repeat code 1 (REP_PERIOD)
> Value 125
> Properties:
> Property type 5 (INPUT_PROP_POINTING_STICK)
> Testing ... (interrupt to exit)
> Event: time 1618540114.824036, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
> Event: time 1618540114.824036, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
> Event: time 1618540114.824036, -------------- SYN_REPORT ------------
> Event: time 1618540114.931034, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
> Event: time 1618540114.931034, -------------- SYN_REPORT ------------
> Event: time 1618540115.037033, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
> Event: time 1618540115.037033, -------------- SYN_REPORT ------------
> Event: time 1618540115.143035, type 4 (EV_MSC), code 4 (MSC_SCAN), value 800f0421
> Event: time 1618540115.143035, -------------- SYN_REPORT ------------
> Event: time 1618540115.338814, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
> Event: time 1618540115.338814, -------------- SYN_REPORT ------------
> Event: time 1618540115.474815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
> Event: time 1618540115.474815, -------------- SYN_REPORT ------------
> Event: time 1618540115.606815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
> Event: time 1618540115.606815, -------------- SYN_REPORT ------------
> Event: time 1618540115.738815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 2
> ... repeating lines omitted for brevity ...
> Event: time 1618540127.938815, -------------- SYN_REPORT ------------
> Event: time 1618540127.938815, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 0
> Event: time 1618540127.938815, -------------- SYN_REPORT ------------
>
> One key press of the right arrow key on the remote generated
> around 96 KEY_DOWN events.
>
> I tried playing with ir-keytable's -D and -P options but this just slowed down the
> repeats and I still got around ~96 repeats. It doesn't matter which key I hit either.
>
> If I start up lircd, irw reports the same issue as I understand it simply reading
> from the kernel input layer.
>
> I even upgraded the kernel from 5.8.0-45-generic #51 to 5.8.0-50 #56 in the hope
> that the problem in the input layer might already have been fixed... but no joy.
>
> Any thoughts hugely appreciated.
>
>Cheers,
>
>Doug

It looks like a kernel devinput driver problem, so I think the obvious
fix is to go back to the last kernel that worked, if you can.

I have a Ubuntu 20.04 box that has a tuner with IR receiver on it that
is running a 5.8.0-49 HWE kernel, but not a working copy of MythTV.
When I press any button on its Hauppauge remote (RC-5 instead of RC-6
for MCE remotes), I get infinite repeats of the button press. That
box still has a 5.4.0-72 non-HWE kernel on it, so I rebooted to that
and the repeats problem did not happen there. I rebooted back to
5.8.0-49 and did the waiting upgrade to 5.8.0-50 and tried that, but
it had the problem too.

If you do a bug report (recommended), you may want to do a kernel
bisect to see where the problem first started. At the moment, it
could be anywhere between 5.4.0-49 and 5.8.0-45.

And it looks like anyone using MythTV with an IR remote needs to not
upgrade to a 5.8 kernel until this is fixed. Which is a pain as my
test PC with MythTV Master on it has already been upgraded to 5.8 - it
is just that I have not tried Master with a real tuner and IR remote
yet, just SAT>IP network tuners.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remote keys repeating way too fast [ In reply to ]
Hi Stephen,

> It looks like a kernel devinput driver problem, so I think the
> obvious fix is to go back to the last kernel that worked, if you
> can.

Okay, I had managed to confuse myself over the kernel version that
caused the IR key repeat problem. In my previous email I said that
I thought it was 5.8.0-45-generic that caused the problem but now I
realise it was actually 5.8.0-49-generic that caused my grief...

* 2021-03-16 06:09:00 Install: linux-image-5.8.0-45-generic:amd64
* 2021-04-14 06:48:02 Install: linux-image-5.8.0-49-generic:amd64

I reverted back to 5.8.0-45 and the IR key repeat problem was
resolved.

> If you do a bug report (recommended), you may want to do a kernel
> bisect to see where the problem first started. At the moment, it
> could be anywhere between 5.4.0-49 and 5.8.0-45.

It's a long, long time since I compiled a kernel let alone
embarked on a bug hunt but I think I manage to narrow things down a
little (I've never even used git bisect before).

Anyway, I think we can say that the problem may have been
re-introduced by 5.8.0-49 and, unfortunately, 5.8.0-50 carries it
forward.

Looking at the diffs between 5.8.0-45 and 5.8.0-49:

root@lisa:/mnt/store1/src/groovy/drivers/media/rc# git diff Ubuntu-5.8.0-45.51..Ubuntu-5.8.0-49.55 .

I found the following suspicious Jan 5 2021 commit:

root@lisa:/mnt/store1/src/groovy/drivers/media/rc# git show c592cca3691db

It looks like there's been an effort to harmonize infrared
durations from nanosconds (one billionth of a second) to microseconds
(one millionth of a second).

The commit changed the drivers/media/rc/ir-mce_kbd-decoder.c and
the drivers/media/rc/rc-main.c files specifically the rc_repeat()
function in the latter file.

The commit comment is:

media: rc: fix timeout handling after switch to microsecond durations
BugLink: https://bugs.launchpad.net/bugs/1918516
commit 06b831588b639ad9d94e4789b0250562228722c2 upstream.

Commit 528222d853f92 ("media: rc: harmonize infrared durations to
microseconds") missed to switch some timeout calculations from
nanoseconds to microseconds. This resulted in spurious key_up+key_down
events at the last scancode if the rc device uses a long timeout
(eg 100ms on nuvoton-cir) as the device timeout wasn't properly
accounted for in the keyup timeout calculation.

Fix this by applying the proper conversion functions.

I'm not sure if this is the culprit at all but it seems to be in the
right area. I note that the kernel HEAD is still using the same
code. There have been no changes to rc-main.c since the above.

root@lisa:/mnt/store1/src/groovy/drivers/media/rc# git diff Ubuntu-5.8.0-49.55..HEAD rc-main.c
root@lisa:/mnt/store1/src/groovy/drivers/media/rc#

I'll try installing the latest kernel source, revert these two files
and see if I can figure out how to recompile and install to see if it
fixes the latest kernel.

Many thanks for responding... it gave me the confidence to dig a bit
Deeper.

Cheers,

Doug


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Remote keys repeating way too fast [ In reply to ]
Hi Stephen et al,

Success!!!

I tried reverting the problem c592cca3691db commit against 5.8.0-50.56
and was rewarded with a working remote. Although, by mistake, I only
reverted two of the three impacted files:

* drivers/media/rc/ir-mce_kbd-decoder.c
* drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c

I totally missed that this file was involved as well:

* drivers/media/rc/serial_ir.c

Reverting the two files seems to have been enough to fix my
MCE remote spurious repeats. I guess I'll now have to see
how I go about reporting this as a kernel bug.

For anyone wondering what the changes in the commit actually
were. I include them here:

root@lisa:/mnt/store1/src/groovy# PAGER= git show c592cca3691db
commit c592cca3691dbfefa2a7177bd42fc9eee50b7108
Author: Matthias Reichl <hias@horus.com>
Date: Tue Jan 5 10:30:23 2021 +0100

media: rc: fix timeout handling after switch to microsecond durations

BugLink: https://bugs.launchpad.net/bugs/1918516

commit 06b831588b639ad9d94e4789b0250562228722c2 upstream.

Commit 528222d853f92 ("media: rc: harmonize infrared durations to
microseconds") missed to switch some timeout calculations from
nanoseconds to microseconds. This resulted in spurious key_up+key_down
events at the last scancode if the rc device uses a long timeout
(eg 100ms on nuvoton-cir) as the device timeout wasn't properly
accounted for in the keyup timeout calculation.

Fix this by applying the proper conversion functions.

Cc: stable@vger.kernel.org
Fixes: 528222d853f92 ("media: rc: harmonize infrared durations to microseconds")
Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>

diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index cfe837f773c1..5f51bad53772 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -320,7 +320,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
data->body);
spin_lock(&data->keylock);
if (scancode) {
- delay = nsecs_to_jiffies(dev->timeout) +
+ delay = usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(100);
mod_timer(&data->rx_timeout, jiffies + delay);
} else {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 38aa0c2de243..b86e16897444 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -737,7 +737,7 @@ static unsigned int repeat_period(int protocol)
void rc_repeat(struct rc_dev *dev)
{
unsigned long flags;
- unsigned int timeout = nsecs_to_jiffies(dev->timeout) +
+ unsigned int timeout = usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(repeat_period(dev->last_protocol));
struct lirc_scancode sc = {
.scancode = dev->last_scancode, .rc_proto = dev->last_protocol,
@@ -855,7 +855,7 @@ void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u64 scancode,
ir_do_keydown(dev, protocol, scancode, keycode, toggle);

if (dev->keypressed) {
- dev->keyup_jiffies = jiffies + nsecs_to_jiffies(dev->timeout) +
+ dev->keyup_jiffies = jiffies + usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(repeat_period(protocol));
mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
}
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index d77507ba0fb5..ce5b1fd1e3f4 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -385,7 +385,7 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah)
} while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */

mod_timer(&serial_ir.timeout_timer,
- jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout));
+ jiffies + usecs_to_jiffies(serial_ir.rcdev->timeout));

ir_raw_event_handle(serial_ir.rcdev);

Of course, I still don't really understand the context for the change from
nanoseconds to microseconds but at least I have a working remote
under the latest groovy 5.8.0-50.56 kernel. Hooray!!!

Cheers,

Doug

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Remote keys repeating way too fast [ In reply to ]
This is affecting me on Ubuntu 20.04.  New bug report created:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1926030

Ted
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org