Lines Matching refs:kdev
43 static struct knav_device *kdev; variable
60 #define knav_queue_idx_to_inst(kdev, idx) \ argument
61 (kdev->instances + (idx << kdev->inst_shift))
66 #define for_each_instance(idx, inst, kdev) \ argument
67 for (idx = 0, inst = kdev->instances; \
68 idx < (kdev)->num_queues_in_use; \
69 idx++, inst = knav_queue_idx_to_inst(kdev, idx))
128 dev_warn(range->kdev->dev, in knav_queue_setup_irq()
193 knav_queue_match_id_to_inst(struct knav_device *kdev, unsigned id) in knav_queue_match_id_to_inst() argument
198 for_each_instance(idx, inst, kdev) { in knav_queue_match_id_to_inst()
207 if (kdev->base_id <= id && in knav_queue_find_by_id()
208 kdev->base_id + kdev->num_queues > id) { in knav_queue_find_by_id()
209 id -= kdev->base_id; in knav_queue_find_by_id()
210 return knav_queue_match_id_to_inst(kdev, id); in knav_queue_find_by_id()
222 qh = devm_kzalloc(inst->kdev->dev, sizeof(*qh), GFP_KERNEL); in __knav_queue_open()
242 devm_kfree(inst->kdev->dev, qh); in __knav_queue_open()
289 for_each_instance(idx, inst, kdev) { in knav_queue_open_by_type()
421 struct knav_device *kdev = inst->kdev; in knav_queue_debug_show_instance() local
428 kdev->base_id + inst->id, inst->name); in knav_queue_debug_show_instance()
453 dev_name(kdev->dev), kdev->base_id, in knav_queue_debug_show()
454 kdev->base_id + kdev->num_queues - 1); in knav_queue_debug_show()
455 for_each_instance(idx, inst, kdev) in knav_queue_debug_show()
559 devm_kfree(inst->kdev->dev, qh); in knav_queue_close()
580 ret = qh->inst->kdev->base_id + qh->inst->id; in knav_queue_device_control()
712 dev_dbg(pool->kdev->dev, in kdesc_empty_pool()
757 if (!kdev->dev) in knav_pool_create()
760 pool = devm_kzalloc(kdev->dev, sizeof(*pool), GFP_KERNEL); in knav_pool_create()
762 dev_err(kdev->dev, "out of memory allocating pool\n"); in knav_pool_create()
766 for_each_region(kdev, reg_itr) { in knav_pool_create()
774 dev_err(kdev->dev, "region-id(%d) not found\n", region_id); in knav_pool_create()
781 dev_err(kdev->dev, in knav_pool_create()
789 pool->kdev = kdev; in knav_pool_create()
790 pool->dev = kdev->dev; in knav_pool_create()
795 dev_err(kdev->dev, "out of descs in region(%d) for pool(%s)\n", in knav_pool_create()
822 list_add_tail(&pool->list, &kdev->pools); in knav_pool_create()
825 dev_err(kdev->dev, "pool(%s) create failed: fragmented desc pool in region(%d)\n", in knav_pool_create()
839 devm_kfree(kdev->dev, pool); in knav_pool_create()
867 devm_kfree(kdev->dev, pool); in knav_pool_destroy()
968 static void knav_queue_setup_region(struct knav_device *kdev, in knav_queue_setup_region() argument
980 dev_warn(kdev->dev, "unused region %s\n", region->name); in knav_queue_setup_region()
990 dev_warn(kdev->dev, "too few descriptors in region %s\n", in knav_queue_setup_region()
1000 dev_err(kdev->dev, "memory alloc failed for region %s\n", in knav_queue_setup_region()
1007 region->dma_start = dma_map_page(kdev->dev, page, 0, size, in knav_queue_setup_region()
1009 if (dma_mapping_error(kdev->dev, region->dma_start)) { in knav_queue_setup_region()
1010 dev_err(kdev->dev, "dma map failed for region %s\n", in knav_queue_setup_region()
1016 pool = devm_kzalloc(kdev->dev, sizeof(*pool), GFP_KERNEL); in knav_queue_setup_region()
1018 dev_err(kdev->dev, "out of memory allocating dummy pool\n"); in knav_queue_setup_region()
1025 dev_dbg(kdev->dev, in knav_queue_setup_region()
1034 for_each_qmgr(kdev, qmgr) { in knav_queue_setup_region()
1045 dma_unmap_page(kdev->dev, region->dma_start, size, in knav_queue_setup_region()
1064 static int knav_queue_setup_regions(struct knav_device *kdev, in knav_queue_setup_regions() argument
1067 struct device *dev = kdev->dev; in knav_queue_setup_regions()
1107 list_add_tail(®ion->list, &kdev->regions); in knav_queue_setup_regions()
1109 if (list_empty(&kdev->regions)) { in knav_queue_setup_regions()
1115 for_each_region(kdev, region) in knav_queue_setup_regions()
1116 knav_queue_setup_region(kdev, region); in knav_queue_setup_regions()
1121 static int knav_get_link_ram(struct knav_device *kdev, in knav_get_link_ram() argument
1125 struct platform_device *pdev = to_platform_device(kdev->dev); in knav_get_link_ram()
1154 block->virt = dmam_alloc_coherent(kdev->dev, in knav_get_link_ram()
1158 dev_err(kdev->dev, "failed to alloc linkram\n"); in knav_get_link_ram()
1168 static int knav_queue_setup_link_ram(struct knav_device *kdev) in knav_queue_setup_link_ram() argument
1173 for_each_qmgr(kdev, qmgr) { in knav_queue_setup_link_ram()
1174 block = &kdev->link_rams[0]; in knav_queue_setup_link_ram()
1175 dev_dbg(kdev->dev, "linkram0: phys:%x, virt:%p, size:%x\n", in knav_queue_setup_link_ram()
1184 dev_dbg(kdev->dev, "linkram1: phys:%x, virt:%p, size:%x\n", in knav_queue_setup_link_ram()
1192 static int knav_setup_queue_range(struct knav_device *kdev, in knav_setup_queue_range() argument
1195 struct device *dev = kdev->dev; in knav_setup_queue_range()
1207 range->kdev = kdev; in knav_setup_queue_range()
1211 range->queue_base = temp[0] - kdev->base_id; in knav_setup_queue_range()
1244 ret = knav_init_acc_range(kdev, node, range); in knav_setup_queue_range()
1254 for_each_qmgr(kdev, qmgr) { in knav_setup_queue_range()
1267 list_add_tail(&range->list, &kdev->queue_ranges); in knav_setup_queue_range()
1275 kdev->num_queues_in_use += range->num_queues; in knav_setup_queue_range()
1279 static int knav_setup_queue_pools(struct knav_device *kdev, in knav_setup_queue_pools() argument
1287 ret = knav_setup_queue_range(kdev, range); in knav_setup_queue_pools()
1293 if (list_empty(&kdev->queue_ranges)) { in knav_setup_queue_pools()
1294 dev_err(kdev->dev, "no valid queue range found\n"); in knav_setup_queue_pools()
1300 static void knav_free_queue_range(struct knav_device *kdev, in knav_free_queue_range() argument
1306 devm_kfree(kdev->dev, range); in knav_free_queue_range()
1309 static void knav_free_queue_ranges(struct knav_device *kdev) in knav_free_queue_ranges() argument
1314 range = first_queue_range(kdev); in knav_free_queue_ranges()
1317 knav_free_queue_range(kdev, range); in knav_free_queue_ranges()
1321 static void knav_queue_free_regions(struct knav_device *kdev) in knav_queue_free_regions() argument
1328 region = first_region(kdev); in knav_queue_free_regions()
1338 devm_kfree(kdev->dev, region); in knav_queue_free_regions()
1342 static void __iomem *knav_queue_map_reg(struct knav_device *kdev, in knav_queue_map_reg() argument
1351 dev_err(kdev->dev, "Can't translate of node(%s) address for index(%d)\n", in knav_queue_map_reg()
1356 regs = devm_ioremap_resource(kdev->dev, &res); in knav_queue_map_reg()
1358 dev_err(kdev->dev, "Failed to map register base for index(%d) node(%s)\n", in knav_queue_map_reg()
1363 static int knav_queue_init_qmgrs(struct knav_device *kdev, in knav_queue_init_qmgrs() argument
1366 struct device *dev = kdev->dev; in knav_queue_init_qmgrs()
1394 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1397 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1400 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1403 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1406 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1409 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1432 list_add_tail(&qmgr->list, &kdev->qmgrs); in knav_queue_init_qmgrs()
1442 static int knav_queue_init_pdsps(struct knav_device *kdev, in knav_queue_init_pdsps() argument
1445 struct device *dev = kdev->dev; in knav_queue_init_pdsps()
1457 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1460 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1463 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1466 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1485 list_add_tail(&pdsp->list, &kdev->pdsps); in knav_queue_init_pdsps()
1493 static int knav_queue_stop_pdsp(struct knav_device *kdev, in knav_queue_stop_pdsp() argument
1504 dev_err(kdev->dev, "timed out on pdsp %s stop\n", pdsp->name); in knav_queue_stop_pdsp()
1512 static int knav_queue_load_pdsp(struct knav_device *kdev, in knav_queue_load_pdsp() argument
1524 kdev->dev); in knav_queue_load_pdsp()
1533 dev_err(kdev->dev, "failed to get firmware for pdsp\n"); in knav_queue_load_pdsp()
1537 dev_info(kdev->dev, "firmware file %s downloaded for PDSP\n", in knav_queue_load_pdsp()
1551 static int knav_queue_start_pdsp(struct knav_device *kdev, in knav_queue_start_pdsp() argument
1574 dev_err(kdev->dev, in knav_queue_start_pdsp()
1582 static void knav_queue_stop_pdsps(struct knav_device *kdev) in knav_queue_stop_pdsps() argument
1587 for_each_pdsp(kdev, pdsp) in knav_queue_stop_pdsps()
1588 knav_queue_stop_pdsp(kdev, pdsp); in knav_queue_stop_pdsps()
1591 static int knav_queue_start_pdsps(struct knav_device *kdev) in knav_queue_start_pdsps() argument
1596 knav_queue_stop_pdsps(kdev); in knav_queue_start_pdsps()
1603 for_each_pdsp(kdev, pdsp) { in knav_queue_start_pdsps()
1604 ret = knav_queue_load_pdsp(kdev, pdsp); in knav_queue_start_pdsps()
1609 for_each_pdsp(kdev, pdsp) { in knav_queue_start_pdsps()
1611 ret = knav_queue_start_pdsp(kdev, pdsp); in knav_queue_start_pdsps()
1623 for_each_qmgr(kdev, qmgr) { in knav_find_qmgr()
1631 static int knav_queue_init_queue(struct knav_device *kdev, in knav_queue_init_queue() argument
1642 inst->kdev = kdev; in knav_queue_init_queue()
1655 static int knav_queue_init_queues(struct knav_device *kdev) in knav_queue_init_queues() argument
1667 kdev->inst_shift = order_base_2(size); in knav_queue_init_queues()
1668 size = (1 << kdev->inst_shift) * kdev->num_queues_in_use; in knav_queue_init_queues()
1669 kdev->instances = devm_kzalloc(kdev->dev, size, GFP_KERNEL); in knav_queue_init_queues()
1670 if (!kdev->instances) in knav_queue_init_queues()
1673 for_each_queue_range(kdev, range) { in knav_queue_init_queues()
1679 ret = knav_queue_init_queue(kdev, range, in knav_queue_init_queues()
1680 knav_queue_idx_to_inst(kdev, idx), id); in knav_queue_init_queues()
1685 knav_queue_idx_to_inst(kdev, base_idx); in knav_queue_init_queues()
1703 kdev = devm_kzalloc(dev, sizeof(struct knav_device), GFP_KERNEL); in knav_queue_probe()
1704 if (!kdev) { in knav_queue_probe()
1709 platform_set_drvdata(pdev, kdev); in knav_queue_probe()
1710 kdev->dev = dev; in knav_queue_probe()
1711 INIT_LIST_HEAD(&kdev->queue_ranges); in knav_queue_probe()
1712 INIT_LIST_HEAD(&kdev->qmgrs); in knav_queue_probe()
1713 INIT_LIST_HEAD(&kdev->pools); in knav_queue_probe()
1714 INIT_LIST_HEAD(&kdev->regions); in knav_queue_probe()
1715 INIT_LIST_HEAD(&kdev->pdsps); in knav_queue_probe()
1730 kdev->base_id = temp[0]; in knav_queue_probe()
1731 kdev->num_queues = temp[1]; in knav_queue_probe()
1740 ret = knav_queue_init_qmgrs(kdev, qmgrs); in knav_queue_probe()
1748 ret = knav_queue_init_pdsps(kdev, pdsps); in knav_queue_probe()
1752 ret = knav_queue_start_pdsps(kdev); in knav_queue_probe()
1765 ret = knav_setup_queue_pools(kdev, queue_pools); in knav_queue_probe()
1770 ret = knav_get_link_ram(kdev, "linkram0", &kdev->link_rams[0]); in knav_queue_probe()
1772 dev_err(kdev->dev, "could not setup linking ram\n"); in knav_queue_probe()
1776 ret = knav_get_link_ram(kdev, "linkram1", &kdev->link_rams[1]); in knav_queue_probe()
1784 ret = knav_queue_setup_link_ram(kdev); in knav_queue_probe()
1794 ret = knav_queue_setup_regions(kdev, regions); in knav_queue_probe()
1799 ret = knav_queue_init_queues(kdev); in knav_queue_probe()
1810 knav_queue_stop_pdsps(kdev); in knav_queue_probe()
1811 knav_queue_free_regions(kdev); in knav_queue_probe()
1812 knav_free_queue_ranges(kdev); in knav_queue_probe()