Lines Matching defs:g2d

248 static int g2d_init_cmdlist(struct g2d_data *g2d)
250 struct device *dev = g2d->dev;
251 struct g2d_cmdlist_node *node = g2d->cmdlist_node;
252 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
257 init_dma_attrs(&g2d->cmdlist_dma_attrs);
258 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &g2d->cmdlist_dma_attrs);
260 g2d->cmdlist_pool_virt = dma_alloc_attrs(subdrv->drm_dev->dev,
262 &g2d->cmdlist_pool, GFP_KERNEL,
263 &g2d->cmdlist_dma_attrs);
264 if (!g2d->cmdlist_pool_virt) {
280 g2d->cmdlist_pool_virt + nr * G2D_CMDLIST_SIZE;
282 g2d->cmdlist_pool + nr * G2D_CMDLIST_SIZE;
288 list_add_tail(&node[nr].list, &g2d->free_cmdlist);
295 g2d->cmdlist_pool_virt,
296 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
300 static void g2d_fini_cmdlist(struct g2d_data *g2d)
302 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
304 kfree(g2d->cmdlist_node);
306 if (g2d->cmdlist_pool_virt && g2d->cmdlist_pool) {
308 g2d->cmdlist_pool_virt,
309 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
313 static struct g2d_cmdlist_node *g2d_get_cmdlist(struct g2d_data *g2d)
315 struct device *dev = g2d->dev;
318 mutex_lock(&g2d->cmdlist_mutex);
319 if (list_empty(&g2d->free_cmdlist)) {
321 mutex_unlock(&g2d->cmdlist_mutex);
325 node = list_first_entry(&g2d->free_cmdlist, struct g2d_cmdlist_node,
328 mutex_unlock(&g2d->cmdlist_mutex);
333 static void g2d_put_cmdlist(struct g2d_data *g2d, struct g2d_cmdlist_node *node)
335 mutex_lock(&g2d->cmdlist_mutex);
336 list_move_tail(&node->list, &g2d->free_cmdlist);
337 mutex_unlock(&g2d->cmdlist_mutex);
410 struct g2d_data *g2d;
423 g2d = dev_get_drvdata(g2d_priv->dev);
440 * at this moment, maybe g2d dma is accessing this
537 if (g2d->current_pool + (npages << PAGE_SHIFT) < g2d->max_pool) {
538 g2d->current_pool += npages << PAGE_SHIFT;
570 struct g2d_data *g2d,
583 g2d->current_pool = 0;
687 static int g2d_map_cmdlist_gem(struct g2d_data *g2d,
777 static void g2d_unmap_cmdlist_gem(struct g2d_data *g2d,
781 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
811 static void g2d_dma_start(struct g2d_data *g2d,
819 ret = pm_runtime_get_sync(g2d->dev);
823 writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR);
824 writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND);
827 static struct g2d_runqueue_node *g2d_get_runqueue_node(struct g2d_data *g2d)
831 if (list_empty(&g2d->runqueue))
834 runqueue_node = list_first_entry(&g2d->runqueue,
840 static void g2d_free_runqueue_node(struct g2d_data *g2d,
848 mutex_lock(&g2d->cmdlist_mutex);
854 g2d_unmap_cmdlist_gem(g2d, node, runqueue_node->filp);
855 list_splice_tail_init(&runqueue_node->run_cmdlist, &g2d->free_cmdlist);
856 mutex_unlock(&g2d->cmdlist_mutex);
858 kmem_cache_free(g2d->runqueue_slab, runqueue_node);
861 static void g2d_exec_runqueue(struct g2d_data *g2d)
863 g2d->runqueue_node = g2d_get_runqueue_node(g2d);
864 if (g2d->runqueue_node)
865 g2d_dma_start(g2d, g2d->runqueue_node);
870 struct g2d_data *g2d = container_of(work, struct g2d_data,
873 mutex_lock(&g2d->runqueue_mutex);
874 pm_runtime_put_sync(g2d->dev);
876 complete(&g2d->runqueue_node->complete);
877 if (g2d->runqueue_node->async)
878 g2d_free_runqueue_node(g2d, g2d->runqueue_node);
880 if (g2d->suspended)
881 g2d->runqueue_node = NULL;
883 g2d_exec_runqueue(g2d);
884 mutex_unlock(&g2d->runqueue_mutex);
887 static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no)
889 struct drm_device *drm_dev = g2d->subdrv.drm_dev;
890 struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node;
914 struct g2d_data *g2d = dev_id;
917 pending = readl_relaxed(g2d->regs + G2D_INTC_PEND);
919 writel_relaxed(pending, g2d->regs + G2D_INTC_PEND);
922 u32 cmdlist_no = readl_relaxed(g2d->regs + G2D_DMA_STATUS);
927 g2d_finish_event(g2d, cmdlist_no);
929 writel_relaxed(0, g2d->regs + G2D_DMA_HOLD_CMD);
932 g2d->regs + G2D_DMA_COMMAND);
937 queue_work(g2d->g2d_workq, &g2d->runqueue_work);
1051 struct g2d_data *g2d;
1061 g2d = dev_get_drvdata(dev);
1062 if (!g2d)
1078 struct g2d_data *g2d;
1095 g2d = dev_get_drvdata(dev);
1096 if (!g2d)
1099 node = g2d_get_cmdlist(g2d);
1210 ret = g2d_map_cmdlist_gem(g2d, node, drm_dev, file);
1229 g2d_unmap_cmdlist_gem(g2d, node, file);
1238 g2d_put_cmdlist(g2d, node);
1249 struct g2d_data *g2d;
1262 g2d = dev_get_drvdata(dev);
1263 if (!g2d)
1266 runqueue_node = kmem_cache_alloc(g2d->runqueue_slab, GFP_KERNEL);
1283 kmem_cache_free(g2d->runqueue_slab, runqueue_node);
1287 mutex_lock(&g2d->runqueue_mutex);
1290 list_add_tail(&runqueue_node->list, &g2d->runqueue);
1291 if (!g2d->runqueue_node)
1292 g2d_exec_runqueue(g2d);
1293 mutex_unlock(&g2d->runqueue_mutex);
1299 g2d_free_runqueue_node(g2d, runqueue_node);
1308 struct g2d_data *g2d;
1311 g2d = dev_get_drvdata(dev);
1312 if (!g2d)
1316 ret = g2d_init_cmdlist(g2d);
1328 g2d_fini_cmdlist(g2d);
1368 struct g2d_data *g2d;
1374 g2d = dev_get_drvdata(dev);
1375 if (!g2d)
1378 mutex_lock(&g2d->cmdlist_mutex);
1387 g2d_unmap_cmdlist_gem(g2d, node, file);
1388 list_move_tail(&node->list, &g2d->free_cmdlist);
1390 mutex_unlock(&g2d->cmdlist_mutex);
1393 g2d_userptr_free_all(drm_dev, g2d, file);
1402 struct g2d_data *g2d;
1406 g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL);
1407 if (!g2d)
1410 g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab",
1412 if (!g2d->runqueue_slab)
1415 g2d->dev = dev;
1417 g2d->g2d_workq = create_singlethread_workqueue("g2d");
1418 if (!g2d->g2d_workq) {
1424 INIT_WORK(&g2d->runqueue_work, g2d_runqueue_worker);
1425 INIT_LIST_HEAD(&g2d->free_cmdlist);
1426 INIT_LIST_HEAD(&g2d->runqueue);
1428 mutex_init(&g2d->cmdlist_mutex);
1429 mutex_init(&g2d->runqueue_mutex);
1431 g2d->gate_clk = devm_clk_get(dev, "fimg2d");
1432 if (IS_ERR(g2d->gate_clk)) {
1434 ret = PTR_ERR(g2d->gate_clk);
1442 g2d->regs = devm_ioremap_resource(dev, res);
1443 if (IS_ERR(g2d->regs)) {
1444 ret = PTR_ERR(g2d->regs);
1448 g2d->irq = platform_get_irq(pdev, 0);
1449 if (g2d->irq < 0) {
1451 ret = g2d->irq;
1455 ret = devm_request_irq(dev, g2d->irq, g2d_irq_handler, 0,
1456 "drm_g2d", g2d);
1462 g2d->max_pool = MAX_POOL;
1464 platform_set_drvdata(pdev, g2d);
1466 subdrv = &g2d->subdrv;
1475 dev_err(dev, "failed to register drm g2d device\n");
1479 dev_info(dev, "The exynos g2d(ver %d.%d) successfully probed\n",
1487 destroy_workqueue(g2d->g2d_workq);
1489 kmem_cache_destroy(g2d->runqueue_slab);
1495 struct g2d_data *g2d = platform_get_drvdata(pdev);
1497 cancel_work_sync(&g2d->runqueue_work);
1498 exynos_drm_subdrv_unregister(&g2d->subdrv);
1500 while (g2d->runqueue_node) {
1501 g2d_free_runqueue_node(g2d, g2d->runqueue_node);
1502 g2d->runqueue_node = g2d_get_runqueue_node(g2d);
1507 g2d_fini_cmdlist(g2d);
1508 destroy_workqueue(g2d->g2d_workq);
1509 kmem_cache_destroy(g2d->runqueue_slab);
1517 struct g2d_data *g2d = dev_get_drvdata(dev);
1519 mutex_lock(&g2d->runqueue_mutex);
1520 g2d->suspended = true;
1521 mutex_unlock(&g2d->runqueue_mutex);
1523 while (g2d->runqueue_node)
1527 flush_work(&g2d->runqueue_work);
1534 struct g2d_data *g2d = dev_get_drvdata(dev);
1536 g2d->suspended = false;
1537 g2d_exec_runqueue(g2d);
1546 struct g2d_data *g2d = dev_get_drvdata(dev);
1548 clk_disable_unprepare(g2d->gate_clk);
1555 struct g2d_data *g2d = dev_get_drvdata(dev);
1558 ret = clk_prepare_enable(g2d->gate_clk);
1572 { .compatible = "samsung,exynos5250-g2d" },
1573 { .compatible = "samsung,exynos4212-g2d" },
1582 .name = "s5p-g2d",