* [PATCH] dmatest: make dmatest threads freezable
@ 2011-08-18 14:50 Guennadi Liakhovetski
2011-08-25 14:27 ` Koul, Vinod
0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2011-08-18 14:50 UTC (permalink / raw)
To: linux-kernel; +Cc: Dan Williams, Vinod Koul
Making dmatest threads freezable allows its use for system PM testing.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/dma/dmatest.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 765f5ff..fc0ea6c 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
+#include <linux/freezer.h>
#include <linux/init.h>
#include <linux/kthread.h>
#include <linux/module.h>
@@ -251,6 +252,7 @@ static int dmatest_func(void *data)
int i;
thread_name = current->comm;
+ set_freezable_with_signal();
ret = -ENOMEM;
@@ -305,7 +307,8 @@ static int dmatest_func(void *data)
dma_addr_t dma_srcs[src_cnt];
dma_addr_t dma_dsts[dst_cnt];
struct completion cmp;
- unsigned long tmo = msecs_to_jiffies(timeout);
+ unsigned long start, tmo, end = 0 /* compiler... */;
+ bool reload = true;
u8 align = 0;
total_tests++;
@@ -404,7 +407,17 @@ static int dmatest_func(void *data)
}
dma_async_issue_pending(chan);
- tmo = wait_for_completion_timeout(&cmp, tmo);
+ do {
+ start = jiffies;
+ if (reload)
+ end = start + msecs_to_jiffies(timeout);
+ else if (end <= start)
+ end = start + 1;
+ tmo = wait_for_completion_interruptible_timeout(&cmp,
+ end - start);
+ reload = try_to_freeze();
+ } while (tmo == -ERESTARTSYS);
+
status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
if (tmo == 0) {
--
1.7.2.5
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] dmatest: make dmatest threads freezable
2011-08-18 14:50 [PATCH] dmatest: make dmatest threads freezable Guennadi Liakhovetski
@ 2011-08-25 14:27 ` Koul, Vinod
2011-08-25 22:42 ` Dan Williams
0 siblings, 1 reply; 4+ messages in thread
From: Koul, Vinod @ 2011-08-25 14:27 UTC (permalink / raw)
To: Guennadi Liakhovetski, Dan Williams; +Cc: linux-kernel
On Thu, 2011-08-18 at 16:50 +0200, Guennadi Liakhovetski wrote:
> Making dmatest threads freezable allows its use for system PM testing.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Looks good to me, Dan if you give me your ack, I will carry this in my
tree
--
~Vinod
> ---
> drivers/dma/dmatest.c | 17 +++++++++++++++--
> 1 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 765f5ff..fc0ea6c 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -10,6 +10,7 @@
> #include <linux/delay.h>
> #include <linux/dma-mapping.h>
> #include <linux/dmaengine.h>
> +#include <linux/freezer.h>
> #include <linux/init.h>
> #include <linux/kthread.h>
> #include <linux/module.h>
> @@ -251,6 +252,7 @@ static int dmatest_func(void *data)
> int i;
>
> thread_name = current->comm;
> + set_freezable_with_signal();
>
> ret = -ENOMEM;
>
> @@ -305,7 +307,8 @@ static int dmatest_func(void *data)
> dma_addr_t dma_srcs[src_cnt];
> dma_addr_t dma_dsts[dst_cnt];
> struct completion cmp;
> - unsigned long tmo = msecs_to_jiffies(timeout);
> + unsigned long start, tmo, end = 0 /* compiler... */;
> + bool reload = true;
> u8 align = 0;
>
> total_tests++;
> @@ -404,7 +407,17 @@ static int dmatest_func(void *data)
> }
> dma_async_issue_pending(chan);
>
> - tmo = wait_for_completion_timeout(&cmp, tmo);
> + do {
> + start = jiffies;
> + if (reload)
> + end = start + msecs_to_jiffies(timeout);
> + else if (end <= start)
> + end = start + 1;
> + tmo = wait_for_completion_interruptible_timeout(&cmp,
> + end - start);
> + reload = try_to_freeze();
> + } while (tmo == -ERESTARTSYS);
> +
> status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
>
> if (tmo == 0) {
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] dmatest: make dmatest threads freezable
2011-08-25 14:27 ` Koul, Vinod
@ 2011-08-25 22:42 ` Dan Williams
2011-08-29 12:13 ` Vinod Koul
0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2011-08-25 22:42 UTC (permalink / raw)
To: Koul, Vinod; +Cc: Guennadi Liakhovetski, linux-kernel
On Thu, Aug 25, 2011 at 7:27 AM, Koul, Vinod <vinod.koul@intel.com> wrote:
> On Thu, 2011-08-18 at 16:50 +0200, Guennadi Liakhovetski wrote:
>> Making dmatest threads freezable allows its use for system PM testing.
>>
>> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Looks good to me, Dan if you give me your ack, I will carry this in my
> tree
Acked-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dmatest: make dmatest threads freezable
2011-08-25 22:42 ` Dan Williams
@ 2011-08-29 12:13 ` Vinod Koul
0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2011-08-29 12:13 UTC (permalink / raw)
To: Dan Williams; +Cc: Guennadi Liakhovetski, linux-kernel
On Thu, 2011-08-25 at 15:42 -0700, Dan Williams wrote:
> On Thu, Aug 25, 2011 at 7:27 AM, Koul, Vinod <vinod.koul@intel.com> wrote:
> > On Thu, 2011-08-18 at 16:50 +0200, Guennadi Liakhovetski wrote:
> >> Making dmatest threads freezable allows its use for system PM testing.
> >>
> >> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > Looks good to me, Dan if you give me your ack, I will carry this in my
> > tree
>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
Applied, Thanks
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-29 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 14:50 [PATCH] dmatest: make dmatest threads freezable Guennadi Liakhovetski
2011-08-25 14:27 ` Koul, Vinod
2011-08-25 22:42 ` Dan Williams
2011-08-29 12:13 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®