Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmatest: make dmatest threads freezable

Making dmatest threads freezable allows its use for system PM testing.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Guennadi Liakhovetski and committed by
Vinod Koul
981ed70d 57001a60

+15 -2
+15 -2
drivers/dma/dmatest.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/dma-mapping.h> 12 12 #include <linux/dmaengine.h> 13 + #include <linux/freezer.h> 13 14 #include <linux/init.h> 14 15 #include <linux/kthread.h> 15 16 #include <linux/module.h> ··· 252 251 int i; 253 252 254 253 thread_name = current->comm; 254 + set_freezable_with_signal(); 255 255 256 256 ret = -ENOMEM; 257 257 ··· 307 305 dma_addr_t dma_srcs[src_cnt]; 308 306 dma_addr_t dma_dsts[dst_cnt]; 309 307 struct completion cmp; 310 - unsigned long tmo = msecs_to_jiffies(timeout); 308 + unsigned long start, tmo, end = 0 /* compiler... */; 309 + bool reload = true; 311 310 u8 align = 0; 312 311 313 312 total_tests++; ··· 407 404 } 408 405 dma_async_issue_pending(chan); 409 406 410 - tmo = wait_for_completion_timeout(&cmp, tmo); 407 + do { 408 + start = jiffies; 409 + if (reload) 410 + end = start + msecs_to_jiffies(timeout); 411 + else if (end <= start) 412 + end = start + 1; 413 + tmo = wait_for_completion_interruptible_timeout(&cmp, 414 + end - start); 415 + reload = try_to_freeze(); 416 + } while (tmo == -ERESTARTSYS); 417 + 411 418 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL); 412 419 413 420 if (tmo == 0) {