Lines Matching refs:cmd
206 void __iomem *ptr = dev->cmd.dbell_map; in mthca_cmd_post_dbell()
207 u16 *offs = dev->cmd.dbell_offsets; in mthca_cmd_post_dbell()
286 mutex_lock(&dev->cmd.hcr_mutex); in mthca_cmd_post()
288 if (event && dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS && fw_cmd_doorbell) in mthca_cmd_post()
295 mutex_unlock(&dev->cmd.hcr_mutex); in mthca_cmd_post()
344 down(&dev->cmd.poll_sem); in mthca_cmd_poll()
383 up(&dev->cmd.poll_sem); in mthca_cmd_poll()
393 &dev->cmd.context[token & dev->cmd.token_mask]; in mthca_cmd_event()
418 down(&dev->cmd.event_sem); in mthca_cmd_wait()
420 spin_lock(&dev->cmd.context_lock); in mthca_cmd_wait()
421 BUG_ON(dev->cmd.free_head < 0); in mthca_cmd_wait()
422 context = &dev->cmd.context[dev->cmd.free_head]; in mthca_cmd_wait()
423 context->token += dev->cmd.token_mask + 1; in mthca_cmd_wait()
424 dev->cmd.free_head = context->next; in mthca_cmd_wait()
425 spin_unlock(&dev->cmd.context_lock); in mthca_cmd_wait()
459 spin_lock(&dev->cmd.context_lock); in mthca_cmd_wait()
460 context->next = dev->cmd.free_head; in mthca_cmd_wait()
461 dev->cmd.free_head = context - dev->cmd.context; in mthca_cmd_wait()
462 spin_unlock(&dev->cmd.context_lock); in mthca_cmd_wait()
464 up(&dev->cmd.event_sem); in mthca_cmd_wait()
477 if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS) in mthca_cmd_box()
512 if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS) in mthca_cmd_imm()
524 mutex_init(&dev->cmd.hcr_mutex); in mthca_cmd_init()
525 sema_init(&dev->cmd.poll_sem, 1); in mthca_cmd_init()
526 dev->cmd.flags = 0; in mthca_cmd_init()
535 dev->cmd.pool = dma_pool_create("mthca_cmd", &dev->pdev->dev, in mthca_cmd_init()
538 if (!dev->cmd.pool) { in mthca_cmd_init()
548 dma_pool_destroy(dev->cmd.pool); in mthca_cmd_cleanup()
550 if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS) in mthca_cmd_cleanup()
551 iounmap(dev->cmd.dbell_map); in mthca_cmd_cleanup()
562 dev->cmd.context = kmalloc_array(dev->cmd.max_cmds, in mthca_cmd_use_events()
565 if (!dev->cmd.context) in mthca_cmd_use_events()
568 for (i = 0; i < dev->cmd.max_cmds; ++i) { in mthca_cmd_use_events()
569 dev->cmd.context[i].token = i; in mthca_cmd_use_events()
570 dev->cmd.context[i].next = i + 1; in mthca_cmd_use_events()
573 dev->cmd.context[dev->cmd.max_cmds - 1].next = -1; in mthca_cmd_use_events()
574 dev->cmd.free_head = 0; in mthca_cmd_use_events()
576 sema_init(&dev->cmd.event_sem, dev->cmd.max_cmds); in mthca_cmd_use_events()
577 spin_lock_init(&dev->cmd.context_lock); in mthca_cmd_use_events()
579 for (dev->cmd.token_mask = 1; in mthca_cmd_use_events()
580 dev->cmd.token_mask < dev->cmd.max_cmds; in mthca_cmd_use_events()
581 dev->cmd.token_mask <<= 1) in mthca_cmd_use_events()
583 --dev->cmd.token_mask; in mthca_cmd_use_events()
585 dev->cmd.flags |= MTHCA_CMD_USE_EVENTS; in mthca_cmd_use_events()
587 down(&dev->cmd.poll_sem); in mthca_cmd_use_events()
599 dev->cmd.flags &= ~MTHCA_CMD_USE_EVENTS; in mthca_cmd_use_polling()
601 for (i = 0; i < dev->cmd.max_cmds; ++i) in mthca_cmd_use_polling()
602 down(&dev->cmd.event_sem); in mthca_cmd_use_polling()
604 kfree(dev->cmd.context); in mthca_cmd_use_polling()
606 up(&dev->cmd.poll_sem); in mthca_cmd_use_polling()
618 mailbox->buf = dma_pool_alloc(dev->cmd.pool, gfp_mask, &mailbox->dma); in mthca_alloc_mailbox()
632 dma_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma); in mthca_free_mailbox()
758 max_off = max(max_off, dev->cmd.dbell_offsets[i]); in mthca_setup_cmd_doorbells()
769 dev->cmd.dbell_map = ioremap(addr, max_off + sizeof(u32)); in mthca_setup_cmd_doorbells()
770 if (!dev->cmd.dbell_map) in mthca_setup_cmd_doorbells()
773 dev->cmd.flags |= MTHCA_CMD_POST_DOORBELLS; in mthca_setup_cmd_doorbells()
826 dev->cmd.max_cmds = 1 << lg; in mthca_QUERY_FW()
829 (unsigned long long) dev->fw_ver, dev->cmd.max_cmds); in mthca_QUERY_FW()
843 MTHCA_GET(dev->cmd.dbell_offsets[i], outbox, in mthca_QUERY_FW()