From 7a1ad311838a1074ab5b09cede25e595b090ecc4 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Wed, 4 Oct 2017 14:18:53 +0900 Subject: [PATCH] HFI: call hfi1_map_device_addresses() at initialization time Conflicts: kernel/syscall.c --- kernel/file_ops.c | 5 +---- kernel/syscall.c | 21 ++++++++++++++++++--- kernel/user_exp_rcv.c | 6 ------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/kernel/file_ops.c b/kernel/file_ops.c index ce65e2d1..4be82f59 100644 --- a/kernel/file_ops.c +++ b/kernel/file_ops.c @@ -571,6 +571,7 @@ long hfi1_file_ioctl(void *private_data, unsigned int cmd, else return -EPERM; #endif + ret = -ENODEV; dkprintf("%s: HFI1_IOCTL_SET_PKEY \n", __FUNCTION__); break; @@ -687,10 +688,6 @@ ssize_t hfi1_aio_write(void *private_data, const struct iovec *iovec, unsigned l if (!dim) return -EINVAL; - if (hfi1_map_device_addresses(fd) < 0) { - return -EINVAL; - } - hfi1_cdbg(SDMA, "SDMA request from %u:%u (%lu)", fd->uctxt->ctxt, fd->subctxt, dim); diff --git a/kernel/syscall.c b/kernel/syscall.c index a57f08e5..14917c09 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -3146,6 +3146,7 @@ SYSCALL_DECLARE(ioctl) long irqstate; void *private_data = proc->fd_priv_table[fd]; unsigned long t_s = rdtsc(); + int sub_rc = 0; irqstate = ihk_mc_spinlock_lock(&proc->mckfd_lock); for(fdp = proc->mckfd; fdp; fdp = fdp->next) @@ -3163,20 +3164,34 @@ SYSCALL_DECLARE(ioctl) ihk_mc_syscall_arg1(ctx), ihk_mc_syscall_arg2(ctx), t_s); - /* continue forwarding iff hfi1 didn't handle it */ + + /* Continue forwarding iff hfi1 didn't handle it */ // TODO: improve heuristics? - if (rc != -ENOTSUPP) + if (rc != -ENOTSUPP && rc != -ENODEV) return rc; + + if (rc == -ENODEV) { + sub_rc = rc; + } } if (fdp && fdp->ioctl_cb) { - //kprintf("ioctl: found system fd %d\n", fd); rc = fdp->ioctl_cb(fdp, ctx); } else { rc = syscall_generic_forwarding(__NR_ioctl, ctx); } + if (private_data && sub_rc == -ENODEV) { + extern int hfi1_map_device_addresses(void *fd); + + if (hfi1_map_device_addresses(private_data) < 0) { + kprintf("%s: Could not map hfi1 device addresses\n", + __FUNCTION__); + return -EINVAL; + } + } + return rc; } diff --git a/kernel/user_exp_rcv.c b/kernel/user_exp_rcv.c index bb18b29e..63f5caa5 100644 --- a/kernel/user_exp_rcv.c +++ b/kernel/user_exp_rcv.c @@ -100,12 +100,6 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, struct hfi1_tid_info *tinf return -EINVAL; } - if (hfi1_map_device_addresses(fd) < 0) { - kprintf("%s: Could not map hfi1 device addresses\n", - __FUNCTION__); - return -EINVAL; - } - tidlist = kmalloc_cache_alloc(&tidlist_cache, //sizeof(*tidlist) * uctxt->expected_count); sizeof(*tidlist) * 1024);