From patchwork Wed May 18 20:29:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9122091 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F397FBF29F for ; Wed, 18 May 2016 20:30:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14AF4202AE for ; Wed, 18 May 2016 20:30:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 245FE20340 for ; Wed, 18 May 2016 20:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753855AbcERUaU (ORCPT ); Wed, 18 May 2016 16:30:20 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35194 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753840AbcERUaT (ORCPT ); Wed, 18 May 2016 16:30:19 -0400 Received: by mail-wm0-f65.google.com with SMTP id s63so1204279wme.2 for ; Wed, 18 May 2016 13:30:18 -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=CI/QLfXa3swQH70YJfkF+stE4QrN+FlPMSXNCVcbKtY=; b=X39oh7r++MO+SNpNo240rQYaF9hDOI26uzSq92RNbnpRIoHLjUmMZA23RWZL9rFpA/ PT451qZWWPEgz665hEWXG0EbcZO1jYWAGrsCax47fxqtxRbD6ED+RtGW7YCL/X+rLQOH zal6yCF/rDHuGXLHSnbzMN5J9CptIgybt1AnjeH4Jf50D9Ui9+44upTFW0Fzg4ArUQtu 9Os/5CSD8s4HbOYYfnLlYLrluLvTudVpnxLzeXX2WGiEVTVW9k9etdkRsVkxaPNB2H5a EEHOlBIUhk+BdHJtxmVeDP5QF94xUnMaYXtK/Qq/eozxkh4s2IwOy+m5gIi3RWjtCdIO OZFQ== 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=CI/QLfXa3swQH70YJfkF+stE4QrN+FlPMSXNCVcbKtY=; b=AF1Y3iZ1HjwBxr4T/7k68CRiqJPYQgyGm1RuytWr0sab+g3LMPcbKz9qGv+PreFRss liIwCK6/ke5C7LvBppXnbVcK26LTQD4XWB5ZIY78c4Jf7dmkbAwz6rJnEPnCjFuBOA8G e2KhVZd+1YGjUaKCWPF5w3gT6rmjJz2YjD6OLHlQSnaBLlm7+HgjOj51WTEjMLTzTyBb 7Fypa2F9BNINn1EQ29BsM8sBj25gv9fXm7OvjoQqTlANxvGWACSU6CG4OZMEMkO+9S/g qE8baVEZGEzF6HlL5ySrXdzz1WFC7S5jNk9n+JUEcA81wTxW4ZPfp1hO3AmozwZ3pw2/ 9xwQ== X-Gm-Message-State: AOPr4FUWyn2SLqdgkSUGQPMV/g8Sandcq+w9lt8TCf5ZXApeyRNe/9O/pW4H7cdiQvw1xw== X-Received: by 10.28.230.137 with SMTP id e9mr31963684wmi.90.1463603417175; Wed, 18 May 2016 13:30:17 -0700 (PDT) Received: from ?IPv6:2003:62:5f01:4400:211c:e7c3:54e4:3e5b? (p200300625F014400211CE7C354E43E5B.dip0.t-ipconnect.de. [2003:62:5f01:4400:211c:e7c3:54e4:3e5b]) by smtp.googlemail.com with ESMTPSA id b124sm32434039wmb.1.2016.05.18.13.30.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2016 13:30:16 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH] media: rc: make fifo size for raw events configurable via rc_dev To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <1122490c-9700-e99e-338c-cde8a959fc5f@gmail.com> Date: Wed, 18 May 2016 22:29:07 +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-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the fifo size is 512 elements. After a recent patch the size of struct ir_raw_event is down to 8 bytes, so the fifo still consumes 4KB. In most cases a much smaller fifo is sufficient, e.g. nuvoton-cir triggers event processing after 24 events latest. This patch introduces an element raw_fifo_size to struct rc_dev to allow configuring the fifo size. If not set the current default MAX_IR_EVENT_SIZE is used. Signed-off-by: Heiner Kallweit --- drivers/media/rc/rc-core-priv.h | 2 +- drivers/media/rc/rc-ir-raw.c | 11 +++++++++-- include/media/rc-core.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 585d5e5..ae6f81e 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -39,7 +39,7 @@ struct ir_raw_event_ctrl { struct task_struct *thread; spinlock_t lock; /* fifo for the pulse/space durations */ - DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE); + DECLARE_KFIFO_PTR(kfifo, struct ir_raw_event); ktime_t last_event; /* when last event occurred */ enum raw_event_type last_type; /* last event type */ struct rc_dev *dev; /* pointer to the parent rc_dev */ diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 144304c..96270f1 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -261,6 +261,7 @@ int ir_raw_event_register(struct rc_dev *dev) { int rc; struct ir_raw_handler *handler; + unsigned fifo_size = dev->raw_fifo_size ?: MAX_IR_EVENT_SIZE; if (!dev) return -EINVAL; @@ -271,7 +272,10 @@ int ir_raw_event_register(struct rc_dev *dev) dev->raw->dev = dev; dev->change_protocol = change_protocol; - INIT_KFIFO(dev->raw->kfifo); + + rc = kfifo_alloc(&dev->raw->kfifo, fifo_size, GFP_KERNEL); + if (rc) + goto out; spin_lock_init(&dev->raw->lock); dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw, @@ -279,7 +283,7 @@ int ir_raw_event_register(struct rc_dev *dev) if (IS_ERR(dev->raw->thread)) { rc = PTR_ERR(dev->raw->thread); - goto out; + goto out_kfifo; } mutex_lock(&ir_raw_handler_lock); @@ -291,6 +295,8 @@ int ir_raw_event_register(struct rc_dev *dev) return 0; +out_kfifo: + kfifo_free(&dev->raw->kfifo); out: kfree(dev->raw); dev->raw = NULL; @@ -313,6 +319,7 @@ void ir_raw_event_unregister(struct rc_dev *dev) handler->raw_unregister(dev); mutex_unlock(&ir_raw_handler_lock); + kfifo_free(&dev->raw->kfifo); kfree(dev->raw); dev->raw = NULL; } diff --git a/include/media/rc-core.h b/include/media/rc-core.h index f6f55b7..07e096b 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -72,6 +72,7 @@ enum rc_filter_type { * anyone can call show_protocols or store_protocols * @minor: unique minor remote control device number * @raw: additional data for raw pulse/space devices + * @raw_fifo_size: size of fifo for raw events * @input_dev: the input child device used to communicate events to userspace * @driver_type: specifies if protocol decoding is done in hardware or software * @idle: used to keep track of RX state @@ -133,6 +134,7 @@ struct rc_dev { struct mutex lock; unsigned int minor; struct ir_raw_event_ctrl *raw; + unsigned raw_fifo_size; struct input_dev *input_dev; enum rc_driver_type driver_type; bool idle;