From d4fe5b33c50ccc02c4e3099166b877c3ffe52957 Mon Sep 17 00:00:00 2001 From: zsq Date: Tue, 4 Mar 2014 21:06:53 +0800 Subject: [PATCH] fix rga driver crash bug --- drivers/video/rockchip/rga/rga_drv.c | 42 +++++++++++++------------- drivers/video/rockchip/rga2/rga2_drv.c | 28 +++++++---------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/drivers/video/rockchip/rga/rga_drv.c b/drivers/video/rockchip/rga/rga_drv.c index 53f685b823d7..44b5bb809767 100755 --- a/drivers/video/rockchip/rga/rga_drv.c +++ b/drivers/video/rockchip/rga/rga_drv.c @@ -259,9 +259,9 @@ static void rga_power_on(void) if (rga_service.enable) return; - clk_enable(drvdata->aclk_rga); - clk_enable(drvdata->hclk_rga); - clk_enable(drvdata->pd_rga); + clk_prepare_enable(drvdata->aclk_rga); + clk_prepare_enable(drvdata->hclk_rga); + //clk_prepare_enable(drvdata->pd_rga); wake_lock(&drvdata->wake_lock); rga_service.enable = true; } @@ -283,9 +283,9 @@ static void rga_power_off(void) rga_dump(); } - clk_disable(drvdata->pd_rga); - clk_disable(drvdata->aclk_rga); - clk_disable(drvdata->hclk_rga); + //clk_disable_unprepare(drvdata->pd_rga); + clk_disable_unprepare(drvdata->aclk_rga); + clk_disable_unprepare(drvdata->hclk_rga); wake_unlock(&drvdata->wake_lock); rga_service.enable = false; } @@ -1123,11 +1123,12 @@ static struct miscdevice rga_dev ={ }; - -static const struct of_device_id rockchip_rga_of_match[] = { - { .compatible = "rockchip,rga", .data = NULL, }, +#if defined(CONFIG_OF) +static const struct of_device_id rockchip_rga_dt_ids[] = { + { .compatible = "rockchip,rga", }, {}, }; +#endif static int rga_drv_probe(struct platform_device *pdev) { @@ -1136,10 +1137,6 @@ static int rga_drv_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; int ret = 0; - INIT_LIST_HEAD(&rga_service.waiting); - INIT_LIST_HEAD(&rga_service.running); - INIT_LIST_HEAD(&rga_service.done); - INIT_LIST_HEAD(&rga_service.session); mutex_init(&rga_service.lock); mutex_init(&rga_service.mutex); atomic_set(&rga_service.total_running, 0); @@ -1160,9 +1157,6 @@ static int rga_drv_probe(struct platform_device *pdev) data->aclk_rga = devm_clk_get(&pdev->dev, "aclk_rga"); data->hclk_rga = devm_clk_get(&pdev->dev, "hclk_rga"); - clk_prepare_enable(data->aclk_rga); - clk_prepare_enable(data->hclk_rga); - /* map the registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->rga_base = devm_ioremap_resource(&pdev->dev, res); @@ -1224,12 +1218,9 @@ static int rga_drv_remove(struct platform_device *pdev) free_irq(data->irq, &data->miscdev); iounmap((void __iomem *)(data->rga_base)); - clk_disable_unprepare(data->aclk_rga); - clk_disable_unprepare(data->hclk_rga); - //clk_put(data->pd_rga); - clk_put(data->aclk_rga); - clk_put(data->hclk_rga); + devm_clk_put(&pdev->dev, data->aclk_rga); + devm_clk_put(&pdev->dev, data->hclk_rga); //kfree(data); return 0; @@ -1241,6 +1232,7 @@ static struct platform_driver rga_driver = { .driver = { .owner = THIS_MODULE, .name = "rga", + .of_match_table = of_match_ptr(rockchip_rga_dt_ids), }, }; @@ -1290,6 +1282,12 @@ static int __init rga_init(void) INIT_LIST_HEAD(&rga_session_global.waiting); INIT_LIST_HEAD(&rga_session_global.running); INIT_LIST_HEAD(&rga_session_global.list_session); + + INIT_LIST_HEAD(&rga_service.waiting); + INIT_LIST_HEAD(&rga_service.running); + INIT_LIST_HEAD(&rga_service.done); + INIT_LIST_HEAD(&rga_service.session); + init_waitqueue_head(&rga_session_global.wait); //mutex_lock(&rga_service.lock); list_add_tail(&rga_session_global.list_session, &rga_service.session); @@ -1298,6 +1296,8 @@ static int __init rga_init(void) atomic_set(&rga_session_global.num_done, 0); } + + #if RGA_TEST_CASE rga_test_0(); #endif diff --git a/drivers/video/rockchip/rga2/rga2_drv.c b/drivers/video/rockchip/rga2/rga2_drv.c index c6a6046f3091..0f622fd70f20 100644 --- a/drivers/video/rockchip/rga2/rga2_drv.c +++ b/drivers/video/rockchip/rga2/rga2_drv.c @@ -253,8 +253,8 @@ static void rga2_power_on(void) return; //clk_enable(rga2_drvdata->rga2); - clk_enable(rga2_drvdata->aclk_rga2); - clk_enable(rga2_drvdata->hclk_rga2); + clk_prepare_enable(rga2_drvdata->aclk_rga2); + clk_prepare_enable(rga2_drvdata->hclk_rga2); //clk_enable(rga2_drvdata->pd_rga2); wake_lock(&rga2_drvdata->wake_lock); rga2_service.enable = true; @@ -279,8 +279,8 @@ static void rga2_power_off(void) //clk_disable(rga2_drvdata->pd_rga2); //clk_disable(rga2_drvdata->rga2); - clk_disable(rga2_drvdata->aclk_rga2); - clk_disable(rga2_drvdata->hclk_rga2); + clk_disable_unprepare(rga2_drvdata->aclk_rga2); + clk_disable_unprepare(rga2_drvdata->hclk_rga2); wake_unlock(&rga2_drvdata->wake_lock); rga2_service.enable = false; } @@ -1007,10 +1007,6 @@ static int __devinit rga2_drv_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; int ret = 0; - INIT_LIST_HEAD(&rga2_service.waiting); - INIT_LIST_HEAD(&rga2_service.running); - INIT_LIST_HEAD(&rga2_service.done); - INIT_LIST_HEAD(&rga2_service.session); mutex_init(&rga2_service.lock); mutex_init(&rga2_service.mutex); atomic_set(&rga2_service.total_running, 0); @@ -1033,9 +1029,6 @@ static int __devinit rga2_drv_probe(struct platform_device *pdev) data->aclk_rga = devm_clk_get(&pdev->dev, "aclk_rga"); data->hclk_rga = devm_clk_get(&pdev->dev, "hclk_rga"); - clk_prepare_enable(data->aclk_rga); - clk_prepare_enable(data->hclk_rga); - /* map the registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->rga_base = devm_ioremap_resource(&pdev->dev, res); @@ -1096,14 +1089,10 @@ static int rga2_drv_remove(struct platform_device *pdev) free_irq(data->irq, &data->miscdev); iounmap((void __iomem *)(data->rga_base)); - clk_disable_unprepare(data->aclk_rga); - clk_disable_unprepare(data->hclk_rga); - //clk_put(data->pd_rga2); //clk_put(data->rga2); - clk_put(data->aclk_rga2); - clk_put(data->hclk_rga2); - + devm_clk_put(&pdev->dev, data->aclk_rga2); + devm_clk_put(&pdev->dev, data->hclk_rga2); kfree(data); return 0; @@ -1145,6 +1134,11 @@ static int __init rga2_init(void) INIT_LIST_HEAD(&rga2_session_global.waiting); INIT_LIST_HEAD(&rga2_session_global.running); INIT_LIST_HEAD(&rga2_session_global.list_session); + + INIT_LIST_HEAD(&rga2_service.waiting); + INIT_LIST_HEAD(&rga2_service.running); + INIT_LIST_HEAD(&rga2_service.done); + INIT_LIST_HEAD(&rga2_service.session); init_waitqueue_head(&rga2_session_global.wait); //mutex_lock(&rga_service.lock); list_add_tail(&rga2_session_global.list_session, &rga2_service.session); -- 2.34.1