| 697 | } |
| 698 | |
| 699 | int |
| 700 | taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask, |
| 701 | void *uniq, int cpu, device_t dev, struct resource *irq, const char *name) |
| 702 | { |
| 703 | int i, qid, error; |
| 704 | |
| 705 | gtask->gt_uniq = uniq; |
| 706 | snprintf(gtask->gt_name, GROUPTASK_NAMELEN, "%s", name ? name : "grouptask"); |
| 707 | gtask->gt_dev = dev; |
| 708 | gtask->gt_irq = irq; |
| 709 | gtask->gt_cpu = cpu; |
| 710 | mtx_lock(&qgroup->tqg_lock); |
| 711 | for (i = 0, qid = -1; i < qgroup->tqg_cnt; i++) |
| 712 | if (qgroup->tqg_queue[i].tgc_cpu == cpu) { |
| 713 | qid = i; |
| 714 | break; |
| 715 | } |
| 716 | if (qid == -1) { |
| 717 | mtx_unlock(&qgroup->tqg_lock); |
| 718 | printf("%s: qid not found for %s cpu=%d\n", __func__, gtask->gt_name, cpu); |
| 719 | return (EINVAL); |
| 720 | } |
| 721 | qgroup->tqg_queue[qid].tgc_cnt++; |
| 722 | LIST_INSERT_HEAD(&qgroup->tqg_queue[qid].tgc_tasks, gtask, gt_list); |
| 723 | gtask->gt_taskqueue = qgroup->tqg_queue[qid].tgc_taskq; |
| 724 | cpu = qgroup->tqg_queue[qid].tgc_cpu; |
| 725 | mtx_unlock(&qgroup->tqg_lock); |
| 726 | |
| 727 | if (dev != NULL && irq != NULL) { |
| 728 | error = bus_bind_intr(dev, irq, cpu); |
| 729 | if (error) |
| 730 | printf("%s: binding interrupt failed for %s: %d\n", |
| 731 | __func__, gtask->gt_name, error); |
| 732 | } |
| 733 | return (0); |
| 734 | } |
| 735 | |
| 736 | void |
| 737 | taskqgroup_detach(struct taskqgroup *qgroup, struct grouptask *gtask) |
no test coverage detected