From patchwork Sun May 22 13:43:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9130957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D943460459 for ; Sun, 22 May 2016 13:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 349212819C for ; Sun, 22 May 2016 13:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16D24281B0; Sun, 22 May 2016 13:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D5F12819C for ; Sun, 22 May 2016 13:43:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbcEVNnv (ORCPT ); Sun, 22 May 2016 09:43:51 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32985 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbcEVNnu (ORCPT ); Sun, 22 May 2016 09:43:50 -0400 Received: by mail-wm0-f65.google.com with SMTP id 67so8282714wmg.0 for ; Sun, 22 May 2016 06:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=h5h5+cjnFNXSLo6smQWjUMkr9Mkrj0ld+qH0zM6ZByk=; b=QjxvXaww3C2yabGN+ACCpii5lrHcg/fg9E4SEte1Hd0w3RS3+K7pzQ5BUUGHsUW6Y4 nSPvq1qkVMXg0eP8DTAGQnxXwScKpuiZ+GLXUmMsOIhGWGSaR3Ocz2NQ2i+Qtx6Hjxpw cstBdqsYoOUzGLE/+ExjpOyhJ17ETqVj4S7l38rDjz8Rbbp2ddaukUk/TBpTa5A3/gj+ 3vvSPy3wbiu/RrMlkYRXXiBavXL7S8QueeZHKLuBn+h9VIMM1rbfnj8oJoZXGTl5hjVg LjTzSuX/jhKKRtWIKnoh50S4nBg2YcKXNFSAHzFddObu17AJuhA+gXbaZhXVBSArDM3M ayUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=h5h5+cjnFNXSLo6smQWjUMkr9Mkrj0ld+qH0zM6ZByk=; b=KJFwNFdMMkJlSSylG9YXaFMl71Sxe8mr7jI3OPCj79QlkENHVvEzaty9TkdgKDf6wj w9EUu2Cm4NIJhSIvea+bezplnvjeu0nzCLuoJXIppa6gAwsOrIRaDGJ55e5CdhLO1O3O OZiG+UsB6GnJZD4GjBPpK0crPOaT0vRLotEWRjrqI+Ysvv+GnfWFWi0ESHPIp8MkOvb7 9geKSH7QHlR6VdbJ6UO0/BmD1J0PrK2/vU2o8CcUo/CvKGZa61Oz13jIMX20hLxpEYof alEmNCy4Qr+tIim0PKEY0+etiTWhbf056MqMRPngMTXKU5XqfgjvxOu0SncZcXKuCgye n4yw== X-Gm-Message-State: AOPr4FUU642/maEYQeCjEL/7bnGenEuFEa3dAAD4nE7zhS3nFr/4BQf0CmrBdlMd5uPuQg== X-Received: by 10.28.41.65 with SMTP id p62mr11972739wmp.15.1463924628533; Sun, 22 May 2016 06:43:48 -0700 (PDT) Received: from ?IPv6:2003:62:5f01:4400:45d:f807:eec4:198? (p200300625F014400045DF807EEC40198.dip0.t-ipconnect.de. [2003:62:5f01:4400:45d:f807:eec4:198]) by smtp.googlemail.com with ESMTPSA id r5sm29963047wjy.37.2016.05.22.06.43.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 22 May 2016 06:43:47 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH] media: rc: nuvoton: fix rx fifo overrun handling To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <313c796c-6d51-5ff3-f7aa-806fd54c9b02@gmail.com> Date: Sun, 22 May 2016 15:43:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To detect a rx fifo overrun it's checked whether the number of elements in the chip fifo exceeds the fifo size. This check can never return true and is wrong. Instead we should generate an interrupt if the fifo overruns. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 028574b..74a8de2 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -525,7 +525,7 @@ static void nvt_set_cir_iren(struct nvt_dev *nvt) { u8 iren; - iren = CIR_IREN_RTR | CIR_IREN_PE; + iren = CIR_IREN_RTR | CIR_IREN_PE | CIR_IREN_RFO; nvt_cir_reg_write(nvt, iren, CIR_IREN); } @@ -833,7 +833,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt) { u8 fifocount, val; unsigned int b_idx; - bool overrun = false; int i; /* Get count of how many bytes to read from RX FIFO */ @@ -841,11 +840,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt) /* if we get 0xff, probably means the logical dev is disabled */ if (fifocount == 0xff) return; - /* watch out for a fifo overrun condition */ - else if (fifocount > RX_BUF_LEN) { - overrun = true; - fifocount = RX_BUF_LEN; - } nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount); @@ -867,9 +861,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt) nvt_dbg("%s: pkts now %d", __func__, nvt->pkts); nvt_process_rx_ir_data(nvt); - - if (overrun) - nvt_handle_rx_fifo_overrun(nvt); } static void nvt_cir_log_irqs(u8 status, u8 iren) @@ -943,6 +934,9 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) nvt_cir_log_irqs(status, iren); + if (status & CIR_IRSTS_RFO) + nvt_handle_rx_fifo_overrun(nvt); + if (status & CIR_IRSTS_RTR) { /* FIXME: add code for study/learn mode */ /* We only do rx if not tx'ing */