Skip to content

Commit 3baca39

Browse files
committed
Merge branch 'devel'
2 parents f86407a + 5cbc0be commit 3baca39

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

switchtec.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int max_devices = 16;
3636
module_param(max_devices, int, 0644);
3737
MODULE_PARM_DESC(max_devices, "max number of switchtec device instances");
3838

39-
static bool use_dma_mrpc = 1;
39+
static bool use_dma_mrpc = true;
4040
module_param(use_dma_mrpc, bool, 0644);
4141
MODULE_PARM_DESC(use_dma_mrpc,
4242
"Enable the use of the DMA MRPC feature");
@@ -60,10 +60,11 @@ struct switchtec_user {
6060

6161
enum mrpc_state state;
6262

63-
struct completion comp;
63+
wait_queue_head_t cmd_comp;
6464
struct kref kref;
6565
struct list_head list;
6666

67+
bool cmd_done;
6768
u32 cmd;
6869
u32 status;
6970
u32 return_code;
@@ -92,7 +93,7 @@ static struct switchtec_user *stuser_create(struct switchtec_dev *stdev)
9293
stuser->stdev = stdev;
9394
kref_init(&stuser->kref);
9495
INIT_LIST_HEAD(&stuser->list);
95-
init_completion(&stuser->comp);
96+
init_waitqueue_head(&stuser->cmd_comp);
9697
stuser->event_cnt = atomic_read(&stdev->event_cnt);
9798

9899
dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser);
@@ -187,7 +188,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)
187188
kref_get(&stuser->kref);
188189
stuser->read_len = sizeof(stuser->data);
189190
stuser_set_state(stuser, MRPC_QUEUED);
190-
init_completion(&stuser->comp);
191+
stuser->cmd_done = false;
191192
list_add_tail(&stuser->list, &stdev->mrpc_queue);
192193

193194
mrpc_cmd_submit(stdev);
@@ -201,7 +202,8 @@ static void mrpc_cleanup_cmd(struct switchtec_dev *stdev)
201202
struct switchtec_user *stuser = list_entry(stdev->mrpc_queue.next,
202203
struct switchtec_user, list);
203204

204-
complete_all(&stuser->comp);
205+
stuser->cmd_done = true;
206+
wake_up_interruptible(&stuser->cmd_comp);
205207
list_del_init(&stuser->list);
206208
stuser_put(stuser);
207209
stdev->mrpc_busy = 0;
@@ -572,10 +574,11 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
572574
mutex_unlock(&stdev->mrpc_mutex);
573575

574576
if (filp->f_flags & O_NONBLOCK) {
575-
if (!try_wait_for_completion(&stuser->comp))
577+
if (!stuser->cmd_done)
576578
return -EAGAIN;
577579
} else {
578-
rc = wait_for_completion_interruptible(&stuser->comp);
580+
rc = wait_event_interruptible(stuser->cmd_comp,
581+
stuser->cmd_done);
579582
if (rc < 0)
580583
return rc;
581584
}
@@ -629,15 +632,15 @@ static __poll_t switchtec_dev_poll(struct file *filp, poll_table *wait)
629632
struct switchtec_dev *stdev = stuser->stdev;
630633
__poll_t ret = 0;
631634

632-
poll_wait(filp, &stuser->comp.wait, wait);
635+
poll_wait(filp, &stuser->cmd_comp, wait);
633636
poll_wait(filp, &stdev->event_wq, wait);
634637

635638
if (lock_mutex_and_test_alive(stdev))
636639
return EPOLLIN | EPOLLRDHUP | EPOLLOUT | EPOLLERR | EPOLLHUP;
637640

638641
mutex_unlock(&stdev->mrpc_mutex);
639642

640-
if (try_wait_for_completion(&stuser->comp))
643+
if (stuser->cmd_done)
641644
ret |= EPOLLIN | EPOLLRDNORM;
642645

643646
if (stuser->event_cnt != atomic_read(&stdev->event_cnt))
@@ -985,18 +988,18 @@ static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev,
985988
size_t off;
986989

987990
if (event_id < 0 || event_id >= SWITCHTEC_IOCTL_MAX_EVENTS)
988-
return ERR_PTR(-EINVAL);
991+
return (u32 __iomem *)ERR_PTR(-EINVAL);
989992

990993
off = event_regs[event_id].offset;
991994

992995
if (event_regs[event_id].map_reg == part_ev_reg) {
993996
if (index == SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX)
994997
index = stdev->partition;
995998
else if (index < 0 || index >= stdev->partition_count)
996-
return ERR_PTR(-EINVAL);
999+
return (u32 __iomem *)ERR_PTR(-EINVAL);
9971000
} else if (event_regs[event_id].map_reg == pff_ev_reg) {
9981001
if (index < 0 || index >= stdev->pff_csr_count)
999-
return ERR_PTR(-EINVAL);
1002+
return (u32 __iomem *)ERR_PTR(-EINVAL);
10001003
}
10011004

10021005
return event_regs[event_id].map_reg(stdev, off, index);
@@ -1105,11 +1108,11 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
11051108
}
11061109

11071110
static int ioctl_pff_to_port(struct switchtec_dev *stdev,
1108-
struct switchtec_ioctl_pff_port *up)
1111+
struct switchtec_ioctl_pff_port __user *up)
11091112
{
11101113
int i, part;
11111114
u32 reg;
1112-
struct part_cfg_regs *pcfg;
1115+
struct part_cfg_regs __iomem *pcfg;
11131116
struct switchtec_ioctl_pff_port p;
11141117

11151118
if (copy_from_user(&p, up, sizeof(p)))
@@ -1152,10 +1155,10 @@ static int ioctl_pff_to_port(struct switchtec_dev *stdev,
11521155
}
11531156

11541157
static int ioctl_port_to_pff(struct switchtec_dev *stdev,
1155-
struct switchtec_ioctl_pff_port *up)
1158+
struct switchtec_ioctl_pff_port __user *up)
11561159
{
11571160
struct switchtec_ioctl_pff_port p;
1158-
struct part_cfg_regs *pcfg;
1161+
struct part_cfg_regs __iomem *pcfg;
11591162

11601163
if (copy_from_user(&p, up, sizeof(p)))
11611164
return -EFAULT;
@@ -1323,7 +1326,8 @@ static void stdev_kill(struct switchtec_dev *stdev)
13231326

13241327
/* Wake up and kill any users waiting on an MRPC request */
13251328
list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) {
1326-
complete_all(&stuser->comp);
1329+
stuser->cmd_done = true;
1330+
wake_up_interruptible(&stuser->cmd_comp);
13271331
list_del_init(&stuser->list);
13281332
stuser_put(stuser);
13291333
}
@@ -1493,7 +1497,7 @@ static int switchtec_init_isr(struct switchtec_dev *stdev)
14931497
if (nvecs < 0)
14941498
return nvecs;
14951499

1496-
event_irq = ioread32(&stdev->mmio_part_cfg->vep_vector_number);
1500+
event_irq = ioread16(&stdev->mmio_part_cfg->vep_vector_number);
14971501
if (event_irq < 0 || event_irq >= nvecs)
14981502
return -EFAULT;
14991503

@@ -1530,7 +1534,7 @@ static void init_pff(struct switchtec_dev *stdev)
15301534
{
15311535
int i;
15321536
u32 reg;
1533-
struct part_cfg_regs *pcfg = stdev->mmio_part_cfg;
1537+
struct part_cfg_regs __iomem *pcfg = stdev->mmio_part_cfg;
15341538

15351539
for (i = 0; i < SWITCHTEC_MAX_PFF_CSR; i++) {
15361540
reg = ioread16(&stdev->mmio_pff_csr[i].vendor_id);

0 commit comments

Comments
 (0)