lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 27 Oct 2015 16:59:20 +0000
From:	Ian Abbott <abbotti@....co.uk>
To:	driverdev-devel@...uxdriverproject.org
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Ian Abbott <abbotti@....co.uk>,
	H Hartley Sweeten <hsweeten@...ionengravers.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH 11/16] staging: comedi: comedi_test: make timer rate similar to scan rate

The asynchronous command handling for the analog input subdevice uses a
kernel timer which expires approximately `HZ` times a second.  However,
it only needs to do anything after each scan period.  Set the timer to
expire just after the next scan period.

Although the timer expiry function `waveform_ai_interrupt()` uses
precise time values to generate the fake waveforms used to generate the
data, those time values are constructed in a precise sequence, and do
not depend on the time the timer expiry function is actually called.  So
the timer expiry rate does not have to be very precise.

Signed-off-by: Ian Abbott <abbotti@....co.uk>
---
 drivers/staging/comedi/drivers/comedi_test.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 1b3ad7f..9655dc3 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -52,6 +52,7 @@
 
 #include <linux/timer.h>
 #include <linux/ktime.h>
+#include <linux/jiffies.h>
 
 #define N_CHANS 8
 
@@ -215,10 +216,12 @@ static void waveform_ai_interrupt(unsigned long arg)
 	if (devpriv->wf_current >= devpriv->wf_period)
 		devpriv->wf_current %= devpriv->wf_period;
 
-	if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
+	if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) {
 		async->events |= COMEDI_CB_EOA;
-	else
-		mod_timer(&devpriv->ai_timer, jiffies + 1);
+	} else {
+		mod_timer(&devpriv->ai_timer,
+			  jiffies + usecs_to_jiffies(devpriv->ai_scan_period));
+	}
 
 	comedi_handle_events(dev, s);
 }
@@ -354,7 +357,9 @@ static int waveform_ai_cmd(struct comedi_device *dev,
 	wf_current = devpriv->ai_last_scan_time;
 	devpriv->wf_current = do_div(wf_current, devpriv->wf_period);
 
-	devpriv->ai_timer.expires = jiffies + 1;
+	devpriv->ai_timer.expires =
+		jiffies + usecs_to_jiffies(devpriv->ai_scan_period);
+
 	/* mark command as active */
 	smp_mb__before_atomic();
 	set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ