lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdUovU-zaPPCV0tbOMEy3GsH6heSe+21koW3Ti3S+4qD5g@mail.gmail.com>
Date:   Tue, 5 Apr 2022 15:16:07 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        stable <stable@...r.kernel.org>,
        Михаил <vrserver1@...il.com>,
        Sean Young <sean@...s.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>
Subject: Re: [PATCH 5.16 0172/1017] media: gpio-ir-tx: fix transmit with long
 spaces on Orange Pi PC

On Tue, Apr 5, 2022 at 1:33 PM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
> From: Sean Young <sean@...s.org>
>
> commit 5ad05ecad4326ddaa26a83ba2233a67be24c1aaa upstream.
>
> Calling udelay for than 1000us does not always yield the correct
> results.
>
> Cc: stable@...r.kernel.org
> Reported-by: Михаил <vrserver1@...il.com>
> Signed-off-by: Sean Young <sean@...s.org>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@...nel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>  drivers/media/rc/gpio-ir-tx.c |   28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
>
> --- a/drivers/media/rc/gpio-ir-tx.c
> +++ b/drivers/media/rc/gpio-ir-tx.c
> @@ -48,11 +48,29 @@ static int gpio_ir_tx_set_carrier(struct
>         return 0;
>  }
>
> +static void delay_until(ktime_t until)
> +{
> +       /*
> +        * delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on
> +        * m68k ndelay(s64) does not compile; so use s32 rather than s64.
> +        */
> +       s32 delta;
> +
> +       while (true) {
> +               delta = ktime_us_delta(until, ktime_get());
> +               if (delta <= 0)
> +                       return;
> +
> +               /* udelay more than 1ms may not work */
> +               delta = min(delta, 1000);
> +               udelay(delta);
> +       }

Yeah, that's why we have mdelay(), which loops around udelay() if no
arch-specific implementation is provided.

> +}
> +
>  static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
>                                    uint count)
>  {
>         ktime_t edge;
> -       s32 delta;
>         int i;
>
>         local_irq_disable();
> @@ -63,9 +81,7 @@ static void gpio_ir_tx_unmodulated(struc
>                 gpiod_set_value(gpio_ir->gpio, !(i % 2));
>
>                 edge = ktime_add_us(edge, txbuf[i]);
> -               delta = ktime_us_delta(edge, ktime_get());
> -               if (delta > 0)
> -                       udelay(delta);
> +               delay_until(edge);
>         }
>
>         gpiod_set_value(gpio_ir->gpio, 0);
> @@ -97,9 +113,7 @@ static void gpio_ir_tx_modulated(struct
>                 if (i % 2) {
>                         // space
>                         edge = ktime_add_us(edge, txbuf[i]);
> -                       delta = ktime_us_delta(edge, ktime_get());
> -                       if (delta > 0)
> -                               udelay(delta);
> +                       delay_until(edge);
>                 } else {
>                         // pulse
>                         ktime_t last = ktime_add_us(edge, txbuf[i]);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ