All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Kevin Baradon <kevin.baradon@gmail.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jarod Wilson <jarod@wilsonet.com>
Subject: Re: [PATCH 1/2] media/rc/imon.c: make send_packet() delay configurable
Date: Thu, 14 Mar 2013 12:01:53 -0300	[thread overview]
Message-ID: <20130314120153.7bb71ad8@redhat.com> (raw)
In-Reply-To: <1361737170-4687-2-git-send-email-kevin.baradon@gmail.com>

Em Sun, 24 Feb 2013 21:19:29 +0100
Kevin Baradon <kevin.baradon@gmail.com> escreveu:

> Some imon devices (like 15c2:0036) need a higher delay between send_packet calls.
> Default value is still 5ms to avoid regressions on already working hardware.
> 
> Also use interruptible wait to avoid load average going too high (and let caller handle signals).
> 
> Signed-off-by: Kevin Baradon <kevin.baradon@gmail.com>
> ---
>  drivers/media/rc/imon.c |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
> index 78d109b..a3e66a0 100644
> --- a/drivers/media/rc/imon.c
> +++ b/drivers/media/rc/imon.c
> @@ -347,6 +347,11 @@ module_param(pad_stabilize, int, S_IRUGO | S_IWUSR);
>  MODULE_PARM_DESC(pad_stabilize, "Apply stabilization algorithm to iMON PAD "
>  		 "presses in arrow key mode. 0=disable, 1=enable (default).");
>  
> +static unsigned int send_packet_delay = 5;
> +module_param(send_packet_delay, uint, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(send_packet_delay, "Minimum delay between send_packet() calls "
> +		 "(default 5ms)");
> +

Users will find a hard time discovering what delay is needed for each device.

If this is a per-device type property, then it should, instead, be associated
with the device's USB ID.

The better would be to encapsulate it at the USB device table, like adding a
NEED_(extra)_DELAY flag, like:

	{ USB_DEVICE(0x15c2, 0x0036),  .driver_info = NEED_10MS_DELAY },

If such flag is zero (like on all devices where .driver_info is not filled, as
Kernel zeroes the memory on all static vars), then it will keep using 5ms.

Another alternative would be to use .driver_info for the device type, and
add a logic to handle different types with different logic. This is what
mceusb.c does, for example.

>  /*
>   * In certain use cases, mouse mode isn't really helpful, and could actually
>   * cause confusion, so allow disabling it when the IR device is open.
> @@ -535,12 +540,15 @@ static int send_packet(struct imon_context *ictx)
>  	kfree(control_req);
>  
>  	/*
> -	 * Induce a mandatory 5ms delay before returning, as otherwise,
> +	 * Induce a mandatory delay before returning, as otherwise,
>  	 * send_packet can get called so rapidly as to overwhelm the device,
>  	 * particularly on faster systems and/or those with quirky usb.
> +	 * Do not use TASK_UNINTERRUPTIBLE as this routine is called quite often
> +	 * and doing so will increase load average slightly. Caller will handle
> +	 * signals itself.
>  	 */
> -	timeout = msecs_to_jiffies(5);
> -	set_current_state(TASK_UNINTERRUPTIBLE);
> +	timeout = msecs_to_jiffies(send_packet_delay);
> +	set_current_state(TASK_INTERRUPTIBLE);
>  	schedule_timeout(timeout);
>  
>  	return retval;

Regards,
Mauro

  reply	other threads:[~2013-03-14 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-24 20:19 [PATCH 0/2] Improve imon LCD/VFD driver to better support 15c2:0036 Kevin Baradon
2013-02-24 20:19 ` [PATCH 1/2] media/rc/imon.c: make send_packet() delay configurable Kevin Baradon
2013-03-14 15:01   ` Mauro Carvalho Chehab [this message]
2013-03-17 15:06     ` Kevin Baradon
2013-02-24 20:19 ` [PATCH 2/2] media/rc/imon.c: avoid flooding syslog with "unknown keypress" when keypad is pressed Kevin Baradon
2013-03-14 15:18   ` Mauro Carvalho Chehab
2013-03-14 15:18   ` Mauro Carvalho Chehab
2013-03-17 15:09     ` Kevin Baradon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130314120153.7bb71ad8@redhat.com \
    --to=mchehab@redhat.com \
    --cc=jarod@wilsonet.com \
    --cc=kevin.baradon@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.