static struct bman_portal *init_pcfg(struct bm_portal_config *pcfg) { struct bman_portal *p = bman_create_affine_portal(pcfg); if (!p) { dev_crit(pcfg->dev, "%s: Portal failure on cpu %d\n", __func__, pcfg->cpu); return NULL; } bman_p_irqsource_add(p, BM_PIRQ_RCRI); affine_bportals[pcfg->cpu] = p; dev_info(pcfg->dev, "Portal initialised, cpu %d\n", pcfg->cpu); return p; }
static int fsl_bman_portal_init(uint32_t idx, int is_shared) { cpu_set_t cpuset; struct bman_portal *portal; int loop, ret; struct dpaa_ioctl_irq_map irq_map; /* Verify the thread's cpu-affinity */ ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (ret) { error(0, ret, "pthread_getaffinity_np()"); return ret; } pcfg.cpu = -1; for (loop = 0; loop < CPU_SETSIZE; loop++) if (CPU_ISSET(loop, &cpuset)) { if (pcfg.cpu != -1) { pr_err("Thread is not affine to 1 cpu"); return -EINVAL; } pcfg.cpu = loop; } if (pcfg.cpu == -1) { pr_err("Bug in getaffinity handling!"); return -EINVAL; } /* Allocate and map a bman portal */ map.index = idx; ret = process_portal_map(&map); if (ret) { error(0, ret, "process_portal_map()"); return ret; } /* Make the portal's cache-[enabled|inhibited] regions */ pcfg.addr_virt[DPAA_PORTAL_CE] = map.addr.cena; pcfg.addr_virt[DPAA_PORTAL_CI] = map.addr.cinh; pcfg.is_shared = is_shared; pcfg.index = map.index; bman_depletion_fill(&pcfg.mask); fd = open(BMAN_PORTAL_IRQ_PATH, O_RDONLY); if (fd == -1) { pr_err("BMan irq init failed"); process_portal_unmap(&map.addr); return -EBUSY; } /* Use the IRQ FD as a unique IRQ number */ pcfg.irq = fd; portal = bman_create_affine_portal(&pcfg); if (!portal) { pr_err("Bman portal initialisation failed (%d)", pcfg.cpu); process_portal_unmap(&map.addr); return -EBUSY; } /* Set the IRQ number */ irq_map.type = dpaa_portal_bman; irq_map.portal_cinh = map.addr.cinh; process_portal_irq_map(fd, &irq_map); return 0; }