|
@@ -178,7 +178,7 @@ static void perf_copy_callback(void *data)
|
|
|
atomic_dec(&pctx->dma_sync);
|
|
|
}
|
|
|
|
|
|
-static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
|
|
|
+static ssize_t perf_copy(struct pthr_ctx *pctx, char __iomem *dst,
|
|
|
char *src, size_t size)
|
|
|
{
|
|
|
struct perf_ctx *perf = pctx->perf;
|
|
@@ -189,7 +189,8 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
|
|
|
dma_cookie_t cookie;
|
|
|
size_t src_off, dst_off;
|
|
|
struct perf_mw *mw = &perf->mw;
|
|
|
- u64 vbase, dst_vaddr;
|
|
|
+ void __iomem *vbase;
|
|
|
+ void __iomem *dst_vaddr;
|
|
|
dma_addr_t dst_phys;
|
|
|
int retries = 0;
|
|
|
|
|
@@ -204,14 +205,14 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
|
|
|
}
|
|
|
|
|
|
device = chan->device;
|
|
|
- src_off = (size_t)src & ~PAGE_MASK;
|
|
|
- dst_off = (size_t)dst & ~PAGE_MASK;
|
|
|
+ src_off = (uintptr_t)src & ~PAGE_MASK;
|
|
|
+ dst_off = (uintptr_t __force)dst & ~PAGE_MASK;
|
|
|
|
|
|
if (!is_dma_copy_aligned(device, src_off, dst_off, size))
|
|
|
return -ENODEV;
|
|
|
|
|
|
- vbase = (u64)(u64 *)mw->vbase;
|
|
|
- dst_vaddr = (u64)(u64 *)dst;
|
|
|
+ vbase = mw->vbase;
|
|
|
+ dst_vaddr = dst;
|
|
|
dst_phys = mw->phys_addr + (dst_vaddr - vbase);
|
|
|
|
|
|
unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOWAIT);
|
|
@@ -261,13 +262,13 @@ err_get_unmap:
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int perf_move_data(struct pthr_ctx *pctx, char *dst, char *src,
|
|
|
+static int perf_move_data(struct pthr_ctx *pctx, char __iomem *dst, char *src,
|
|
|
u64 buf_size, u64 win_size, u64 total)
|
|
|
{
|
|
|
int chunks, total_chunks, i;
|
|
|
int copied_chunks = 0;
|
|
|
u64 copied = 0, result;
|
|
|
- char *tmp = dst;
|
|
|
+ char __iomem *tmp = dst;
|
|
|
u64 perf, diff_us;
|
|
|
ktime_t kstart, kstop, kdiff;
|
|
|
|
|
@@ -324,7 +325,7 @@ static int ntb_perf_thread(void *data)
|
|
|
struct perf_ctx *perf = pctx->perf;
|
|
|
struct pci_dev *pdev = perf->ntb->pdev;
|
|
|
struct perf_mw *mw = &perf->mw;
|
|
|
- char *dst;
|
|
|
+ char __iomem *dst;
|
|
|
u64 win_size, buf_size, total;
|
|
|
void *src;
|
|
|
int rc, node, i;
|
|
@@ -364,7 +365,7 @@ static int ntb_perf_thread(void *data)
|
|
|
if (buf_size > MAX_TEST_SIZE)
|
|
|
buf_size = MAX_TEST_SIZE;
|
|
|
|
|
|
- dst = (char *)mw->vbase;
|
|
|
+ dst = (char __iomem *)mw->vbase;
|
|
|
|
|
|
atomic_inc(&perf->tsync);
|
|
|
while (atomic_read(&perf->tsync) != perf->perf_threads)
|
|
@@ -424,6 +425,7 @@ static int perf_set_mw(struct perf_ctx *perf, resource_size_t size)
|
|
|
{
|
|
|
struct perf_mw *mw = &perf->mw;
|
|
|
size_t xlat_size, buf_size;
|
|
|
+ int rc;
|
|
|
|
|
|
if (!size)
|
|
|
return -EINVAL;
|
|
@@ -447,6 +449,13 @@ static int perf_set_mw(struct perf_ctx *perf, resource_size_t size)
|
|
|
mw->buf_size = 0;
|
|
|
}
|
|
|
|
|
|
+ rc = ntb_mw_set_trans(perf->ntb, 0, mw->dma_addr, mw->xlat_size);
|
|
|
+ if (rc) {
|
|
|
+ dev_err(&perf->ntb->dev, "Unable to set mw0 translation\n");
|
|
|
+ perf_free_mw(perf);
|
|
|
+ return -EIO;
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -541,6 +550,8 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
|
|
|
return 0;
|
|
|
|
|
|
buf = kmalloc(64, GFP_KERNEL);
|
|
|
+ if (!buf)
|
|
|
+ return -ENOMEM;
|
|
|
out_offset = snprintf(buf, 64, "%d\n", perf->run);
|
|
|
ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
|
|
|
kfree(buf);
|
|
@@ -548,6 +559,21 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+static void threads_cleanup(struct perf_ctx *perf)
|
|
|
+{
|
|
|
+ struct pthr_ctx *pctx;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ perf->run = false;
|
|
|
+ for (i = 0; i < MAX_THREADS; i++) {
|
|
|
+ pctx = &perf->pthr_ctx[i];
|
|
|
+ if (pctx->thread) {
|
|
|
+ kthread_stop(pctx->thread);
|
|
|
+ pctx->thread = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
|
|
size_t count, loff_t *offp)
|
|
|
{
|
|
@@ -563,17 +589,9 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
|
|
if (atomic_read(&perf->tsync) == 0)
|
|
|
perf->run = false;
|
|
|
|
|
|
- if (perf->run) {
|
|
|
- /* lets stop the threads */
|
|
|
- perf->run = false;
|
|
|
- for (i = 0; i < MAX_THREADS; i++) {
|
|
|
- if (perf->pthr_ctx[i].thread) {
|
|
|
- kthread_stop(perf->pthr_ctx[i].thread);
|
|
|
- perf->pthr_ctx[i].thread = NULL;
|
|
|
- } else
|
|
|
- break;
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (perf->run)
|
|
|
+ threads_cleanup(perf);
|
|
|
+ else {
|
|
|
perf->run = true;
|
|
|
|
|
|
if (perf->perf_threads > MAX_THREADS) {
|
|
@@ -604,17 +622,11 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
|
|
kthread_create_on_node(ntb_perf_thread,
|
|
|
(void *)pctx,
|
|
|
node, "ntb_perf %d", i);
|
|
|
- if (pctx->thread)
|
|
|
+ if (IS_ERR(pctx->thread)) {
|
|
|
+ pctx->thread = NULL;
|
|
|
+ goto err;
|
|
|
+ } else
|
|
|
wake_up_process(pctx->thread);
|
|
|
- else {
|
|
|
- perf->run = false;
|
|
|
- for (i = 0; i < MAX_THREADS; i++) {
|
|
|
- if (pctx->thread) {
|
|
|
- kthread_stop(pctx->thread);
|
|
|
- pctx->thread = NULL;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
if (perf->run == false)
|
|
|
return -ENXIO;
|
|
@@ -623,6 +635,10 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
|
|
}
|
|
|
|
|
|
return count;
|
|
|
+
|
|
|
+err:
|
|
|
+ threads_cleanup(perf);
|
|
|
+ return -ENXIO;
|
|
|
}
|
|
|
|
|
|
static const struct file_operations ntb_perf_debugfs_run = {
|