Unverified Commit 54c1de28 authored by Karen Xie's avatar Karen Xie Committed by GitHub

Merge pull request #44 from X-Ryl669/fixLinux5

Fix building for Linux 5.0 and newer
parents a53ec4dd 83d50bf8
......@@ -73,6 +73,23 @@ MODULE_PARM_DESC(desc_blen_max,
#define XDMA_PERF_NUM_DESC 128
/* Kernel version adaptative code */
#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
/* 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 swait_event_interruptible_timeout_exclusive
#elif KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
#define xlx_wake_up swake_up
#define xlx_wait_event_interruptible_timeout swait_event_interruptible_timeout
#else
#define xlx_wake_up wake_up_interruptible
#define xlx_wait_event_interruptible_timeout wait_event_interruptible_timeout
#endif
/*
* xdma device management
* maintains a list of the xdma devices
......@@ -698,7 +715,10 @@ static struct xdma_transfer *engine_start(struct xdma_engine *engine)
dbg_tfr("ioread32(0x%p) (dummy read flushes writes).\n",
&engine->regs->status);
#if KERNEL_VERSION(5, 1, 0) >= LINUX_VERSION_CODE
mmiowb();
#endif
rv = engine_start_mode_config(engine);
if (rv < 0) {
......@@ -738,11 +758,7 @@ static int engine_service_shutdown(struct xdma_engine *engine)
engine->running = 0;
/* awake task on engine's shutdown wait queue */
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&engine->shutdown_wq);
#else
wake_up_interruptible(&engine->shutdown_wq);
#endif
xlx_wake_up(&engine->shutdown_wq);
return 0;
}
......@@ -762,11 +778,7 @@ static struct xdma_transfer *engine_transfer_completion(
/* synchronous I/O? */
/* awake task on transfer's wait queue */
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&transfer->wq);
#else
wake_up_interruptible(&transfer->wq);
#endif
xlx_wake_up(&transfer->wq);
/* Send completion notification for Last transfer */
if (transfer->cb && transfer->last_in_request)
......@@ -960,11 +972,7 @@ static int engine_service_perf(struct xdma_engine *engine, u32 desc_completed)
* wake any XDMA_PERF_IOCTL_STOP waiting for
* the performance run to finish
*/
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&engine->xdma_perf_wq);
#else
wake_up_interruptible(&engine->xdma_perf_wq);
#endif
xlx_wake_up(&engine->xdma_perf_wq);
dbg_perf("transfer->xdma_perf stopped\n");
}
}
......@@ -1146,22 +1154,14 @@ static int engine_service_cyclic_interrupt(struct xdma_engine *engine)
*/
xfer = &engine->cyclic_req->tfer[0];
if (enable_credit_mp) {
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&xfer->wq);
#else
wake_up_interruptible(&xfer->wq);
#endif
xlx_wake_up(&xfer->wq);
} else {
if (eop_count > 0) {
/* awake task on transfer's wait queue */
dbg_tfr("wake_up_interruptible() due to %d EOP's\n",
eop_count);
engine->eop_found = 1;
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&xfer->wq);
#else
wake_up_interruptible(&xfer->wq);
#endif
xlx_wake_up(&xfer->wq);
}
}
......@@ -1237,11 +1237,7 @@ static int engine_service_resume(struct xdma_engine *engine)
} else if (engine->shutdown & ENGINE_SHUTDOWN_REQUEST) {
engine->shutdown |= ENGINE_SHUTDOWN_IDLE;
/* awake task on engine's shutdown wait queue */
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swake_up(&engine->shutdown_wq);
#else
wake_up_interruptible(&engine->shutdown_wq);
#endif
xlx_wake_up(&engine->shutdown_wq);
} else {
dbg_tfr("no pending transfers, %s engine stays idle.\n",
engine->name);
......@@ -3576,17 +3572,10 @@ ssize_t xdma_xfer_submit(void *dev_hndl, int channel, bool write, u64 ep_addr,
}
} else {
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
swait_event_interruptible_timeout(
xlx_wait_event_interruptible_timeout(
xfer->wq,
(xfer->state != TRANSFER_STATE_SUBMITTED),
msecs_to_jiffies(timeout_ms));
#else
wait_event_interruptible_timeout(
xfer->wq,
(xfer->state != TRANSFER_STATE_SUBMITTED),
msecs_to_jiffies(timeout_ms));
#endif
}
spin_lock_irqsave(&engine->lock, flags);
......@@ -4811,34 +4800,22 @@ static int transfer_monitor_cyclic(struct xdma_engine *engine,
if (enable_credit_mp) {
dbg_tfr("%s: rx_head=%d,rx_tail=%d, wait ...\n",
engine->name, engine->rx_head, engine->rx_tail);
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
rc = swait_event_interruptible_timeout(
transfer->wq,
(engine->rx_head != engine->rx_tail ||
engine->rx_overrun),
msecs_to_jiffies(timeout_ms));
#else
rc = wait_event_interruptible_timeout(
rc = xlx_wait_event_interruptible_timeout(
transfer->wq,
(engine->rx_head != engine->rx_tail ||
engine->rx_overrun),
msecs_to_jiffies(timeout_ms));
#endif
msecs_to_jiffies(timeout_ms));
dbg_tfr("%s: wait returns %d, rx %d/%d, overrun %d.\n",
engine->name, rc, engine->rx_head,
engine->rx_tail, engine->rx_overrun);
} else {
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
rc = swait_event_interruptible_timeout(
rc = xlx_wait_event_interruptible_timeout(
transfer->wq,
engine->eop_found,
msecs_to_jiffies(timeout_ms));
#else
rc = wait_event_interruptible_timeout(
transfer->wq,
engine->eop_found,
msecs_to_jiffies(timeout_ms));
#endif
dbg_tfr("%s: wait returns %d, eop_found %d.\n",
engine->name, rc, engine->eop_found);
}
......@@ -5323,15 +5300,9 @@ static int cyclic_shutdown_interrupt(struct xdma_engine *engine)
return -EINVAL;
}
#if KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE
rc = swait_event_interruptible_timeout(engine->shutdown_wq,
!engine->running,
msecs_to_jiffies(10000));
#else
rc = wait_event_interruptible_timeout(engine->shutdown_wq,
rc = xlx_wait_event_interruptible_timeout(engine->shutdown_wq,
!engine->running,
msecs_to_jiffies(10000));
#endif
#if 0
if (rc) {
......
......@@ -24,6 +24,12 @@
#include "xdma_cdev.h"
#include "cdev_ctrl.h"
#if KERNEL_VERSION(5, 0, 0) <= LINUX_VERSION_CODE
#define xlx_access_ok(X,Y,Z) access_ok(Y,Z)
#else
#define xlx_access_ok(X,Y,Z) access_ok(X,Y,Z)
#endif
/*
* character device file operations for control bus (through control bridge)
*/
......@@ -144,10 +150,10 @@ long char_ctrl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
if (_IOC_DIR(cmd) & _IOC_READ)
result = !access_ok(VERIFY_WRITE, (void __user *)arg,
result = !xlx_access_ok(VERIFY_WRITE, (void __user *)arg,
_IOC_SIZE(cmd));
else if (_IOC_DIR(cmd) & _IOC_WRITE)
result = !access_ok(VERIFY_READ, (void __user *)arg,
result = !xlx_access_ok(VERIFY_READ, (void __user *)arg,
_IOC_SIZE(cmd));
if (result) {
......
......@@ -213,7 +213,9 @@ static long xvc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
pr_info("copy back tdo_buf failed: %d/%u.\n", rv, total_bytes);
unlock:
#if KERNEL_VERSION(5, 1, 0) >= LINUX_VERSION_CODE
mmiowb();
#endif
spin_unlock(&xcdev->lock);
cleanup:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment