Lines Matching refs:kdev

26 static struct knav_device *kdev;  variable
54 #define knav_queue_idx_to_inst(kdev, idx) \ argument
55 (kdev->instances + (idx << kdev->inst_shift))
61 #define for_each_instance(idx, inst, kdev) \ argument
62 for (idx = 0, inst = kdev->instances; \
63 idx < (kdev)->num_queues_in_use; \
64 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()
256 devm_kfree(inst->kdev->dev, qh); in __knav_queue_open()
299 for_each_instance(idx, inst, kdev) { in knav_queue_open_by_type()
431 struct knav_device *kdev = inst->kdev; in knav_queue_debug_show_instance() local
444 kdev->base_id + inst->id, inst->name); in knav_queue_debug_show_instance()
472 dev_name(kdev->dev), kdev->base_id, in knav_queue_debug_show()
473 kdev->base_id + kdev->num_queues - 1); in knav_queue_debug_show()
474 for_each_instance(idx, inst, kdev) in knav_queue_debug_show()
569 devm_kfree(inst->kdev->dev, qh); in knav_queue_close()
590 ret = qh->inst->kdev->base_id + qh->inst->id; in knav_queue_device_control()
722 dev_dbg(pool->kdev->dev, in kdesc_empty_pool()
767 if (!kdev) in knav_pool_create()
770 if (!kdev->dev) in knav_pool_create()
773 pool = devm_kzalloc(kdev->dev, sizeof(*pool), GFP_KERNEL); in knav_pool_create()
775 dev_err(kdev->dev, "out of memory allocating pool\n"); in knav_pool_create()
779 for_each_region(kdev, reg_itr) { in knav_pool_create()
787 dev_err(kdev->dev, "region-id(%d) not found\n", region_id); in knav_pool_create()
794 dev_err(kdev->dev, in knav_pool_create()
802 pool->kdev = kdev; in knav_pool_create()
803 pool->dev = kdev->dev; in knav_pool_create()
808 dev_err(kdev->dev, "out of descs in region(%d) for pool(%s)\n", in knav_pool_create()
835 list_add_tail(&pool->list, &kdev->pools); in knav_pool_create()
838 dev_err(kdev->dev, "pool(%s) create failed: fragmented desc pool in region(%d)\n", in knav_pool_create()
852 devm_kfree(kdev->dev, pool); in knav_pool_create()
880 devm_kfree(kdev->dev, pool); in knav_pool_destroy()
982 static void knav_queue_setup_region(struct knav_device *kdev, in knav_queue_setup_region() argument
994 dev_warn(kdev->dev, "unused region %s\n", region->name); in knav_queue_setup_region()
1004 dev_warn(kdev->dev, "too few descriptors in region %s\n", in knav_queue_setup_region()
1014 dev_err(kdev->dev, "memory alloc failed for region %s\n", in knav_queue_setup_region()
1021 region->dma_start = dma_map_page(kdev->dev, page, 0, size, in knav_queue_setup_region()
1023 if (dma_mapping_error(kdev->dev, region->dma_start)) { in knav_queue_setup_region()
1024 dev_err(kdev->dev, "dma map failed for region %s\n", in knav_queue_setup_region()
1030 pool = devm_kzalloc(kdev->dev, sizeof(*pool), GFP_KERNEL); in knav_queue_setup_region()
1032 dev_err(kdev->dev, "out of memory allocating dummy pool\n"); in knav_queue_setup_region()
1039 dev_dbg(kdev->dev, in knav_queue_setup_region()
1048 for_each_qmgr(kdev, qmgr) { in knav_queue_setup_region()
1059 dma_unmap_page(kdev->dev, region->dma_start, size, in knav_queue_setup_region()
1078 static int knav_queue_setup_regions(struct knav_device *kdev, in knav_queue_setup_regions() argument
1081 struct device *dev = kdev->dev; in knav_queue_setup_regions()
1122 list_add_tail(&region->list, &kdev->regions); in knav_queue_setup_regions()
1124 if (list_empty(&kdev->regions)) { in knav_queue_setup_regions()
1130 for_each_region(kdev, region) in knav_queue_setup_regions()
1131 knav_queue_setup_region(kdev, region); in knav_queue_setup_regions()
1136 static int knav_get_link_ram(struct knav_device *kdev, in knav_get_link_ram() argument
1140 struct platform_device *pdev = to_platform_device(kdev->dev); in knav_get_link_ram()
1169 block->virt = dmam_alloc_coherent(kdev->dev, in knav_get_link_ram()
1173 dev_err(kdev->dev, "failed to alloc linkram\n"); in knav_get_link_ram()
1183 static int knav_queue_setup_link_ram(struct knav_device *kdev) in knav_queue_setup_link_ram() argument
1188 for_each_qmgr(kdev, qmgr) { in knav_queue_setup_link_ram()
1189 block = &kdev->link_rams[0]; in knav_queue_setup_link_ram()
1190 dev_dbg(kdev->dev, "linkram0: dma:%pad, virt:%p, size:%x\n", in knav_queue_setup_link_ram()
1193 if (kdev->version == QMSS_66AK2G) in knav_queue_setup_link_ram()
1203 dev_dbg(kdev->dev, "linkram1: dma:%pad, virt:%p, size:%x\n", in knav_queue_setup_link_ram()
1211 static int knav_setup_queue_range(struct knav_device *kdev, in knav_setup_queue_range() argument
1214 struct device *dev = kdev->dev; in knav_setup_queue_range()
1226 range->kdev = kdev; in knav_setup_queue_range()
1230 range->queue_base = temp[0] - kdev->base_id; in knav_setup_queue_range()
1273 ret = knav_init_acc_range(kdev, node, range); in knav_setup_queue_range()
1283 for_each_qmgr(kdev, qmgr) { in knav_setup_queue_range()
1296 list_add_tail(&range->list, &kdev->queue_ranges); in knav_setup_queue_range()
1304 kdev->num_queues_in_use += range->num_queues; in knav_setup_queue_range()
1308 static int knav_setup_queue_pools(struct knav_device *kdev, in knav_setup_queue_pools() argument
1316 knav_setup_queue_range(kdev, range); in knav_setup_queue_pools()
1321 if (list_empty(&kdev->queue_ranges)) { in knav_setup_queue_pools()
1322 dev_err(kdev->dev, "no valid queue range found\n"); in knav_setup_queue_pools()
1328 static void knav_free_queue_range(struct knav_device *kdev, in knav_free_queue_range() argument
1334 devm_kfree(kdev->dev, range); in knav_free_queue_range()
1337 static void knav_free_queue_ranges(struct knav_device *kdev) in knav_free_queue_ranges() argument
1342 range = first_queue_range(kdev); in knav_free_queue_ranges()
1345 knav_free_queue_range(kdev, range); in knav_free_queue_ranges()
1349 static void knav_queue_free_regions(struct knav_device *kdev) in knav_queue_free_regions() argument
1356 region = first_region(kdev); in knav_queue_free_regions()
1366 devm_kfree(kdev->dev, region); in knav_queue_free_regions()
1370 static void __iomem *knav_queue_map_reg(struct knav_device *kdev, in knav_queue_map_reg() argument
1379 dev_err(kdev->dev, "Can't translate of node(%pOFn) address for index(%d)\n", in knav_queue_map_reg()
1384 regs = devm_ioremap_resource(kdev->dev, &res); in knav_queue_map_reg()
1386 dev_err(kdev->dev, "Failed to map register base for index(%d) node(%pOFn)\n", in knav_queue_map_reg()
1391 static int knav_queue_init_qmgrs(struct knav_device *kdev, in knav_queue_init_qmgrs() argument
1394 struct device *dev = kdev->dev; in knav_queue_init_qmgrs()
1423 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1426 if (kdev->version == QMSS) { in knav_queue_init_qmgrs()
1428 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1433 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1434 (kdev->version == QMSS_66AK2G) ? in knav_queue_init_qmgrs()
1438 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1439 (kdev->version == QMSS_66AK2G) ? in knav_queue_init_qmgrs()
1444 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1445 (kdev->version == QMSS_66AK2G) ? in knav_queue_init_qmgrs()
1449 if (kdev->version == QMSS) { in knav_queue_init_qmgrs()
1451 knav_queue_map_reg(kdev, child, in knav_queue_init_qmgrs()
1456 ((kdev->version == QMSS) && in knav_queue_init_qmgrs()
1461 if (kdev->version == QMSS) { in knav_queue_init_qmgrs()
1480 if (kdev->version == QMSS_66AK2G) in knav_queue_init_qmgrs()
1483 list_add_tail(&qmgr->list, &kdev->qmgrs); in knav_queue_init_qmgrs()
1493 static int knav_queue_init_pdsps(struct knav_device *kdev, in knav_queue_init_pdsps() argument
1496 struct device *dev = kdev->dev; in knav_queue_init_pdsps()
1509 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1512 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1515 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1518 knav_queue_map_reg(kdev, child, in knav_queue_init_pdsps()
1537 list_add_tail(&pdsp->list, &kdev->pdsps); in knav_queue_init_pdsps()
1545 static int knav_queue_stop_pdsp(struct knav_device *kdev, in knav_queue_stop_pdsp() argument
1556 dev_err(kdev->dev, "timed out on pdsp %s stop\n", pdsp->name); in knav_queue_stop_pdsp()
1564 static int knav_queue_load_pdsp(struct knav_device *kdev, in knav_queue_load_pdsp() argument
1576 kdev->dev); in knav_queue_load_pdsp()
1585 dev_err(kdev->dev, "failed to get firmware for pdsp\n"); in knav_queue_load_pdsp()
1589 dev_info(kdev->dev, "firmware file %s downloaded for PDSP\n", in knav_queue_load_pdsp()
1603 static int knav_queue_start_pdsp(struct knav_device *kdev, in knav_queue_start_pdsp() argument
1626 dev_err(kdev->dev, in knav_queue_start_pdsp()
1634 static void knav_queue_stop_pdsps(struct knav_device *kdev) in knav_queue_stop_pdsps() argument
1639 for_each_pdsp(kdev, pdsp) in knav_queue_stop_pdsps()
1640 knav_queue_stop_pdsp(kdev, pdsp); in knav_queue_stop_pdsps()
1643 static int knav_queue_start_pdsps(struct knav_device *kdev) in knav_queue_start_pdsps() argument
1648 knav_queue_stop_pdsps(kdev); in knav_queue_start_pdsps()
1655 for_each_pdsp(kdev, pdsp) { in knav_queue_start_pdsps()
1656 ret = knav_queue_load_pdsp(kdev, pdsp); in knav_queue_start_pdsps()
1661 for_each_pdsp(kdev, pdsp) { in knav_queue_start_pdsps()
1663 ret = knav_queue_start_pdsp(kdev, pdsp); in knav_queue_start_pdsps()
1675 for_each_qmgr(kdev, qmgr) { in knav_find_qmgr()
1683 static int knav_queue_init_queue(struct knav_device *kdev, in knav_queue_init_queue() argument
1694 inst->kdev = kdev; in knav_queue_init_queue()
1707 static int knav_queue_init_queues(struct knav_device *kdev) in knav_queue_init_queues() argument
1719 kdev->inst_shift = order_base_2(size); in knav_queue_init_queues()
1720 size = (1 << kdev->inst_shift) * kdev->num_queues_in_use; in knav_queue_init_queues()
1721 kdev->instances = devm_kzalloc(kdev->dev, size, GFP_KERNEL); in knav_queue_init_queues()
1722 if (!kdev->instances) in knav_queue_init_queues()
1725 for_each_queue_range(kdev, range) { in knav_queue_init_queues()
1731 ret = knav_queue_init_queue(kdev, range, in knav_queue_init_queues()
1732 knav_queue_idx_to_inst(kdev, idx), id); in knav_queue_init_queues()
1737 knav_queue_idx_to_inst(kdev, base_idx); in knav_queue_init_queues()
1769 kdev = devm_kzalloc(dev, sizeof(struct knav_device), GFP_KERNEL); in knav_queue_probe()
1770 if (!kdev) { in knav_queue_probe()
1777 kdev->version = QMSS_66AK2G; in knav_queue_probe()
1779 platform_set_drvdata(pdev, kdev); in knav_queue_probe()
1780 kdev->dev = dev; in knav_queue_probe()
1781 INIT_LIST_HEAD(&kdev->queue_ranges); in knav_queue_probe()
1782 INIT_LIST_HEAD(&kdev->qmgrs); in knav_queue_probe()
1783 INIT_LIST_HEAD(&kdev->pools); in knav_queue_probe()
1784 INIT_LIST_HEAD(&kdev->regions); in knav_queue_probe()
1785 INIT_LIST_HEAD(&kdev->pdsps); in knav_queue_probe()
1800 kdev->base_id = temp[0]; in knav_queue_probe()
1801 kdev->num_queues = temp[1]; in knav_queue_probe()
1810 ret = knav_queue_init_qmgrs(kdev, qmgrs); in knav_queue_probe()
1818 ret = knav_queue_init_pdsps(kdev, pdsps); in knav_queue_probe()
1822 ret = knav_queue_start_pdsps(kdev); in knav_queue_probe()
1835 ret = knav_setup_queue_pools(kdev, queue_pools); in knav_queue_probe()
1840 ret = knav_get_link_ram(kdev, "linkram0", &kdev->link_rams[0]); in knav_queue_probe()
1842 dev_err(kdev->dev, "could not setup linking ram\n"); in knav_queue_probe()
1846 ret = knav_get_link_ram(kdev, "linkram1", &kdev->link_rams[1]); in knav_queue_probe()
1854 ret = knav_queue_setup_link_ram(kdev); in knav_queue_probe()
1864 ret = knav_queue_setup_regions(kdev, regions); in knav_queue_probe()
1869 ret = knav_queue_init_queues(kdev); in knav_queue_probe()
1881 knav_queue_stop_pdsps(kdev); in knav_queue_probe()
1882 knav_queue_free_regions(kdev); in knav_queue_probe()
1883 knav_free_queue_ranges(kdev); in knav_queue_probe()