From patchwork Fri Mar 18 17:43:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 8622741 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F3FA9F3D1 for ; Fri, 18 Mar 2016 17:44:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5E0D20251 for ; Fri, 18 Mar 2016 17:44:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A860D2026F for ; Fri, 18 Mar 2016 17:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757570AbcCRRoH (ORCPT ); Fri, 18 Mar 2016 13:44:07 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:34511 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbcCRRoG (ORCPT ); Fri, 18 Mar 2016 13:44:06 -0400 Received: by mail-wm0-f51.google.com with SMTP id p65so78862998wmp.1 for ; Fri, 18 Mar 2016 10:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=jDuWNmGS9NMIR+6cBi1bAeRtETPYFfO+R/ndpFjb1Lk=; b=Mme3bNtvv+Gvu/QSuhU1vW/WbUeD+p7/5ui48ox7nivJ69iLnu+1wNrqKI8j+qy730 U5g10IVCaVeJlRuRrzLHgl2J3ystnCqi/4fL17XiMkbkxQMLZLgGKM4o8jKwOFC9cBTK 4aArq8K3I4Ze9cx4hWJhAoE2Bw/fhFnHh1hhJgQNBt4zyVELvTR3MNHfJzv5F610GlWS JqO52bgColxSOKsTXxgkAKwGZw0Ij8n4NAeF6EbwYBizMLc5PDUKWkml2mEAxtC+kRtl YmzKdJXXnKKw0333SVPBhOI3sZ/CNKBCwGxE1npzmvTCf05CgIRQhliCmVdgcXsZ1kbV zmwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=jDuWNmGS9NMIR+6cBi1bAeRtETPYFfO+R/ndpFjb1Lk=; b=LANdkoh0mt/3ACuF1aZ6xx/M72rtZvv3Mci5/EHXOM7JaF6R2e+srln0LVQGveMb8r RP9h0ocjWRhwyNuq3MzaF+5azMEpUxdE3wae1XTHKHyJQ/OEIJryCODtgfXi3iMLUrm9 tCptwmYHN5Idya6SOe3wNb/MonO3l7NtEYCZq69/57QKsZLYyBl7PKoso5CqTZ+5CrK4 QcUk+E67SHizY2KnEIurXkY7u2fGHF6DCJ2Bi5pb3RQwua3lUHS2ek2QJS3/JaSNlovA 0XX0NXrDqWbxR6MRdLukdFPROiobl+42nXL7JvPWn7A9m0nihXsMmpa9aZuaIz+0k/I7 JVfA== X-Gm-Message-State: AD7BkJJO02pnUCluvCnAe1Qs0tdcxc+qAKoOuu3bIgJRaqLIw/9lF/tBMcF/mpXFjKYnbA== X-Received: by 10.194.103.5 with SMTP id fs5mr17493537wjb.42.1458323044630; Fri, 18 Mar 2016 10:44:04 -0700 (PDT) Received: from ?IPv6:2003:62:5f55:ba00:d916:d1c8:b4c0:c19d? (p200300625F55BA00D916D1C8B4C0C19D.dip0.t-ipconnect.de. [2003:62:5f55:ba00:d916:d1c8:b4c0:c19d]) by smtp.googlemail.com with ESMTPSA id z127sm295532wme.5.2016.03.18.10.44.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2016 10:44:03 -0700 (PDT) To: Mauro Carvalho Chehab From: Heiner Kallweit Subject: media: rc: make raw event fifo size a module parameter Cc: linux-media@vger.kernel.org Message-ID: <56EC3E55.3090008@gmail.com> Date: Fri, 18 Mar 2016 18:43:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.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=-6.8 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. However the needed fifo size may also depend on system performance. Therefore make the fifo size a module parameter with the current value of 512 being the default. Signed-off-by: Heiner Kallweit --- drivers/media/rc/rc-core-priv.h | 2 +- drivers/media/rc/rc-ir-raw.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 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..620b036 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "rc-core-priv.h" /* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */ @@ -28,6 +29,9 @@ static DEFINE_MUTEX(ir_raw_handler_lock); static LIST_HEAD(ir_raw_handler_list); static u64 available_protocols; +/* module param */ +static unsigned int ir_raw_event_fifo_size = MAX_IR_EVENT_SIZE; + static int ir_raw_event_thread(void *data) { struct ir_raw_event ev; @@ -262,7 +266,7 @@ int ir_raw_event_register(struct rc_dev *dev) int rc; struct ir_raw_handler *handler; - if (!dev) + if (!dev || !ir_raw_event_fifo_size) return -EINVAL; dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL); @@ -271,7 +275,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, ir_raw_event_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 +286,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 +298,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 +322,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; } @@ -353,3 +363,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) mutex_unlock(&ir_raw_handler_lock); } EXPORT_SYMBOL(ir_raw_handler_unregister); + +module_param_named(fifo_size, ir_raw_event_fifo_size, uint, S_IRUGO); +MODULE_PARM_DESC(fifo_size, + "raw event fifo size, will be rounded up to next power of 2");