Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp20307pxh; Thu, 7 Apr 2022 12:42:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzijyETJalSAT5KgORShjbuf27Js8VA9t/I6spQrLaXnJAF8wr02HeSYmS31EyIlTExEkg4 X-Received: by 2002:a05:6a00:4293:b0:4fa:e005:7e99 with SMTP id bx19-20020a056a00429300b004fae0057e99mr15798804pfb.20.1649360569589; Thu, 07 Apr 2022 12:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649360569; cv=none; d=google.com; s=arc-20160816; b=wQQp7g/GNFtDQZtDVI2np2i14w0htif0iI7xidme8vM3ItHzADbastPA+pn6VPzNG6 2741tjDJ8/NqLG4m/kFWzrWSmS8Uvt3v1jqgjalq7sZoJYIYNapAAX5XO6CPOcPzz9dp 9dOOa8GP8uh5xVVXkdRpteqi1A64xzVyFK8DfPtcLJtmJz/So8dpSn48yVUWBQ2U3yNa QVf4OaaAQtVrJQzHx39eBvf6ziyXPtUzekrp7B6Hu2PQ4scSI7FwUTLmVofZezQZp6Wa PuKGHZ3+QJdJpwZYlOv6f/1rqiYKzK6g7HiKOGIoIe6mOHvQ887s0j+lzi9SeDybN/ei JhYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QtLGQzteAZT9kcf3gmumtL3u+12YimdOugCApg4gsE4=; b=Z8+5lv4fhrwtdPR+h1v9TGsODg1QSxq1rxOm+wghkNfPw1ltJti3ZpZhVoLItbe2n/ QVanRxllsYzYBI2h3CZV3Qxsy7DiZavPT0MELQtS96/q002bamwl6kVicRo9z6Be0KhA QEk8mKtq9/TbVhVWc7E6ODZSoRiZx3535L5chfxUPIDR6D1DrMQdslDij6LL9V7zZ9V/ 09yVQbFXn0QSulR6VA3VWT/G86v8JSJlSXiOMYeUKMevFZtvc3E0EbHD5V1ODh0Km1qn ApBRFkkmKeeZkqcpcT1VfAIuPhA6qDZyB4/1LzDwe+zGAzvhQPvWCYray217H8CiZn20 ySSg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k19-20020a056a00135300b004fa3a8dff81si20860984pfu.56.2022.04.07.12.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 12:42:49 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 231EA216FA9; Thu, 7 Apr 2022 12:18:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243157AbiDGIgo (ORCPT + 99 others); Thu, 7 Apr 2022 04:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243158AbiDGIgj (ORCPT ); Thu, 7 Apr 2022 04:36:39 -0400 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A08A24A121; Thu, 7 Apr 2022 01:34:40 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id BF869101C60; Thu, 7 Apr 2022 08:34:37 +0000 (UTC) Date: Thu, 7 Apr 2022 09:34:37 +0100 From: Sean Young To: Geert Uytterhoeven Cc: Greg Kroah-Hartman , Linux Kernel Mailing List , stable , =?utf-8?B?0JzQuNGF0LDQuNC7?= , Mauro Carvalho Chehab Subject: Re: [PATCH 5.16 0172/1017] media: gpio-ir-tx: fix transmit with long spaces on Orange Pi PC Message-ID: References: <20220405070354.155796697@linuxfoundation.org> <20220405070359.334460978@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 05, 2022 at 03:16:07PM +0200, Geert Uytterhoeven wrote: > On Tue, Apr 5, 2022 at 1:33 PM Greg Kroah-Hartman > wrote: > > From: Sean Young > > > > commit 5ad05ecad4326ddaa26a83ba2233a67be24c1aaa upstream. > > > > Calling udelay for than 1000us does not always yield the correct > > results. > > > > Cc: stable@vger.kernel.org > > Reported-by: Михаил > > Signed-off-by: Sean Young > > Signed-off-by: Mauro Carvalho Chehab > > Signed-off-by: Greg Kroah-Hartman > > --- > > 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. That is a good point. That doesn't make this patch incorrect, just a bit ugly. Can this patch be merged as-is please, and I'll write an patch upstream that simplifies the code. Thanks Sean > > > +} > > + > > 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@linux-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