Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp435817pxk; Wed, 2 Sep 2020 05:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynBU4dARFL4vaKAKvPtXEsC/DWlSp/2PtY8v1sUNkMs/kYB0lrBDwoGJsjK78uPBqyOHbQ X-Received: by 2002:a17:906:644e:: with SMTP id l14mr6015638ejn.60.1599051122851; Wed, 02 Sep 2020 05:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599051122; cv=none; d=google.com; s=arc-20160816; b=1DI4ev2dLqiQ0fOSwASdJRJdmh2ztQnVGICLKWcPWlyW/lGr2ve4L0FKXizGRZkoL0 t+iiK4zVh15YGR7XUwuen+ufZ+LwtZrK2wH4jFM1GH2gaApDxI/6FHUkHk0dm+zk7XJX RrqWTP+SPJE/LR+D/8GxrICn7IzpKGadWUs0vob2rFVdZmKApctHSgy4KhiyVRv5MhOO x0oAcniuuviotGNXCQcTTwzavXa++K0aBLMix91O6WD4Vfwa8rsgRYBWuICLcp6zJqca TRgw+vhKhG3je8vLxnF7tgMZJNpZhSDJdjRR8ecDDxbu55XXhu9BsvUDZQ/0HTerC3ex ZFow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=DM2FBmfWY1v/rXOmy+AEHj87CdncjUCOmi0RdA349F8=; b=NAbVxa/j+3ta/+RAhuAx5NqlJYw63cDSxL1p229qF+X3V0SuZRho9txEdLMsZwDbrV IEddH45EgvBOYWn12kxLlMJNqVyfMXCTq98MQmd8+Rq4GRAZxYWJqx9+TG1694gBe8/5 YKiO7vxpiIm5+JeFX9aMPeUd+Lq4X8+bQySegeSSD5x6tZoc5codch2GFuIC4RfKQjlJ 7IwT2a8p0XlYZvYpUhp5UoAnsRGQivAluFmxhGeyc0Lq6OO4fyunhdlEmg2G6GXmkcN6 8gjlcpTgAaCigkDwnNipNMa6WL2gzcWen0m2HyLCU9uXwViBCGQB5YHL9yVNpsGCDQfe SiRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jp27si2473542ejb.668.2020.09.02.05.51.38; Wed, 02 Sep 2020 05:52:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbgIBMvI (ORCPT + 99 others); Wed, 2 Sep 2020 08:51:08 -0400 Received: from gofer.mess.org ([88.97.38.141]:45889 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbgIBMvD (ORCPT ); Wed, 2 Sep 2020 08:51:03 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id AB606C649E; Wed, 2 Sep 2020 13:51:01 +0100 (BST) Date: Wed, 2 Sep 2020 13:51:01 +0100 From: Sean Young To: Pavel Machek Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Mauro Carvalho Chehab , Sasha Levin Subject: Re: [PATCH 4.19 053/125] media: gpio-ir-tx: improve precision of transmitted signal due to scheduling Message-ID: <20200902125101.GA12378@gofer.mess.org> References: <20200901150934.576210879@linuxfoundation.org> <20200901150937.150292200@linuxfoundation.org> <20200902102521.GC3765@duo.ucw.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902102521.GC3765@duo.ucw.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, On Wed, Sep 02, 2020 at 12:25:21PM +0200, Pavel Machek wrote: > Hi! > > > > [ Upstream commit ea8912b788f8144e7d32ee61e5ccba45424bef83 ] > > > > usleep_range() may take longer than the max argument due to scheduling, > > especially under load. This is causing random errors in the transmitted > > IR. Remove the usleep_range() in favour of busy-looping with udelay(). > > > > Signed-off-by: Sean Young > > I don't believe this should be in stable. > > Yes, it probably fixes someone's remote control. > > It also introduces > half a second (!) with interrupts disabled > (according to the code comments), which will break other devices on > the system. Yes, I've always been uncormfortable with this code, but nothing else I tried worked. BTW the delay has a maximum of half a second, but the point stands of course. > Less intrusive solutions should be explored, first. Like.. if that > part is time-critical, perhaps it should set itself at realtime > priority, so that scheduler has motivation to schedule it at the right > times? That is an interesting idea, I'll explore that. > Perhaps usleep_range should be delta, delta+1? I'm pretty sure I tried that and it didn't work. I'll give it another go. > Perhaps udelay makes sense to use for more than 10usec? I don't follow -- what are you suggesting here? So any other ideas here would be very welcome. I'm happy to explore options, so far under load the output is can be total garbage if you're unlucky. Thanks, Sean > > Best regards, > Pavel > > > @@ -87,13 +87,8 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf, > > // space > > edge = ktime_add_us(edge, txbuf[i]); > > delta = ktime_us_delta(edge, ktime_get()); > > - if (delta > 10) { > > - spin_unlock_irqrestore(&gpio_ir->lock, flags); > > - usleep_range(delta, delta + 10); > > - spin_lock_irqsave(&gpio_ir->lock, flags); > > - } else if (delta > 0) { > > + if (delta > 0) > > udelay(delta); > > - } > > } else { > > // pulse > > ktime_t last = ktime_add_us(edge, txbuf[i]); > > -- > > 2.25.1 > > > > > > -- > (english) http://www.livejournal.com/~pavelmachek > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html