From patchwork Tue Sep 1 15:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 310324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAF61C433E2 for ; Tue, 1 Sep 2020 16:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 891312098B for ; Tue, 1 Sep 2020 16:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598977805; bh=wqiPS/njTifRp78ETs4+N3VbYQwZ1mRSJAWeWRnEt0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dya5TsSnYzf2DiQpsntuqK/BOmXXfLm74/p8ZmvOkz98EmlKLwh6Xuq4MKAz5BILS xNsVMORQTGtUONFN8M8s7/lNbSkinya5txc4oSIuDAgxDt7p4pup8SfcjX+U9mOvbj Kr+RS2qdVSNjBKnBLogV5/3OK9ev6/KQhkFqlUf8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730733AbgIAQaA (ORCPT ); Tue, 1 Sep 2020 12:30:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730803AbgIAPbz (ORCPT ); Tue, 1 Sep 2020 11:31:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6DD820866; Tue, 1 Sep 2020 15:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974315; bh=wqiPS/njTifRp78ETs4+N3VbYQwZ1mRSJAWeWRnEt0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8dfLBFd/q+VzDGIpRkFZcKQP1POg+m7Pll+vxEMEkypLIjrgBqueNaOI02EA5j5h Hr6qfsITFUC8Mq9SQ6iFbiB78hSSN3rmp/EAK8ejvK64S17ivsFk+m30UHj97w/Cdn 5u13QuiOn28K1pduQ90ZUzBjI80xQK3/8HLblcuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 098/214] media: gpio-ir-tx: improve precision of transmitted signal due to scheduling Date: Tue, 1 Sep 2020 17:09:38 +0200 Message-Id: <20200901150957.692445334@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sean Young [ 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 Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/rc/gpio-ir-tx.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/rc/gpio-ir-tx.c b/drivers/media/rc/gpio-ir-tx.c index 18ca12d78314c..66703989ae185 100644 --- a/drivers/media/rc/gpio-ir-tx.c +++ b/drivers/media/rc/gpio-ir-tx.c @@ -79,13 +79,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]);