Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle ERESTARTSYS for both wait_ and swait_*, with and without timeout #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions XDMA/linux-kernel/xdma/libxdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,54 @@ MODULE_PARM_DESC(desc_blen_max,

#define XDMA_PERF_NUM_DESC 128

/* Functions:
* wait_event_interruptible_timeout
* swait_event_interruptible_timeout_exclusive
* wait_event_interruptible
* swait_event_interruptible_exclusive
could return prematurely (-ERESTARTSYS) if interrupted by a signal, this case must be handled by kernel module */
#define xlx_wait_event_interruptible_timeout(wq, condition, timeout) \
({\
int __ret = 0; \
unsigned long expire = timeout + jiffies; \
do { \
__ret = _xlx_wait_event_interruptible_timeout(wq, condition, \
timeout); \
} while ((__ret < 0) && (jiffies < expire)); \
__ret; \
})

#define xlx_wait_event_interruptible(wq, condition) \
({\
int __ret = 0; \
do { \
__ret = _xlx_wait_event_interruptible(wq, condition); \
} while (__ret < 0); \
__ret; \
})

/* Kernel version adaptative code */
#if HAS_SWAKE_UP_ONE
/* since 4.18, using simple wait queues is not recommended
* except for realtime constraint (see swait.h comments)
* and will likely be removed in future kernel versions
*/
#define xlx_wake_up swake_up_one
#define xlx_wait_event_interruptible_timeout \
#define _xlx_wait_event_interruptible_timeout \
swait_event_interruptible_timeout_exclusive
#define xlx_wait_event_interruptible \
#define _xlx_wait_event_interruptible \
swait_event_interruptible_exclusive
#elif HAS_SWAKE_UP
#define xlx_wake_up swake_up
#define xlx_wait_event_interruptible_timeout \
#define _xlx_wait_event_interruptible_timeout \
swait_event_interruptible_timeout
#define xlx_wait_event_interruptible \
#define _xlx_wait_event_interruptible \
swait_event_interruptible
#else
#define xlx_wake_up wake_up_interruptible
/* wait_event_interruptible_timeout() could return prematurely (-ERESTARTSYS)
* if it is interrupted by a signal */
#define xlx_wait_event_interruptible_timeout(wq, condition, timeout) \
({\
int __ret = 0; \
unsigned long expire = timeout + jiffies; \
do { \
__ret = wait_event_interruptible_timeout(wq, condition, \
timeout); \
} while ((__ret < 0) && (jiffies < expire)); \
__ret; \
})
#define xlx_wait_event_interruptible \
#define _xlx_wait_event_interruptible_timeout \
wait_event_interruptible_timeout
#define _xlx_wait_event_interruptible \
wait_event_interruptible
#endif

Expand Down