drm/lima: add suspend/resume support
Subsystems (3)
Qiang Yu
maintainerv2 cover drm/lima: add suspend/resume support
Suspend need to wait running jobs finish and put hardware in poweroff state. Resume need to re-init hardware.
v2:
1. add misc patches to prepare enable runtime pm
2. fix pmu command wait time out on mali400 gpu
3. do power and clock gating when suspend
4. do runtime pm
Qiang Yu (10):
drm/lima: use module_platform_driver helper drm/lima: print process name and pid when task error drm/lima: check vm != NULL in lima_vm_put drm/lima: always set page directory when switch vm drm/lima: add lima_devfreq_resume/suspend drm/lima: power down ip blocks when pmu exit drm/lima: add resume/suspend callback for each ip drm/lima: seperate clk/regulator enable/disable function drm/lima: add pm resume/suspend ops
drm/lima: enable runtime pm
drivers/gpu/drm/lima/lima_bcast.c | 25 +++- drivers/gpu/drm/lima/lima_bcast.h | 2 + drivers/gpu/drm/lima/lima_devfreq.c | 24 ++++ drivers/gpu/drm/lima/lima_devfreq.h | 3 + drivers/gpu/drm/lima/lima_device.c | 199 ++++++++++++++++++++++----- drivers/gpu/drm/lima/lima_device.h | 5 + drivers/gpu/drm/lima/lima_dlbu.c | 17 ++- drivers/gpu/drm/lima/lima_dlbu.h | 2 + drivers/gpu/drm/lima/lima_drv.c | 40 +++--- drivers/gpu/drm/lima/lima_gp.c | 21 ++- drivers/gpu/drm/lima/lima_gp.h | 2 + drivers/gpu/drm/lima/lima_l2_cache.c | 37 +++-- drivers/gpu/drm/lima/lima_l2_cache.h | 2 + drivers/gpu/drm/lima/lima_mmu.c | 48 +++++-- drivers/gpu/drm/lima/lima_mmu.h | 2 + drivers/gpu/drm/lima/lima_pmu.c | 77 ++++++++++- drivers/gpu/drm/lima/lima_pmu.h | 2 + drivers/gpu/drm/lima/lima_pp.c | 31 ++++- drivers/gpu/drm/lima/lima_pp.h | 4 + drivers/gpu/drm/lima/lima_sched.c | 63 ++++++--- drivers/gpu/drm/lima/lima_vm.h | 3 +- 21 files changed, 496 insertions(+), 113 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 1/10 drm/lima: use module_platform_driver helper
Simplify module init/exit with module_platform_driver.
--- drivers/gpu/drm/lima/lima_drv.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +1 -11
@@ -461,17 +461,7 @@ static struct platform_driver lima_platform_driver = { }, }; -static int __init lima_init (void ) -{ -return platform_driver_register (&lima_platform_driver); -} -module_init (lima_init); - -static void __exit lima_exit(void) -{ -platform_driver_unregister (&lima_platform_driver); -} -module_exit (lima_exit); +module_platform_driver (lima_platform_driver);MODULE_AUTHOR ("Lima Project Developers" );MODULE_DESCRIPTION ("Lima DRM Driver" );
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 2/10 drm/lima: print process name and pid when task error
In reply to Qiang YuWhen error task list is full, print the process info where the error task come from for debug usage.
--- drivers/gpu/drm/lima/lima_sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_sched.c +2 -1
@@ -285,7 +285,8 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task)mutex_lock (&dev->error_task_list_lock);if (dev->dump.num_tasks >= lima_max_error_tasks) { -dev_info (dev->dev,"fail to save task state: error task list is full\n" ); +dev_info (dev->dev,"fail to save task state from %s pid %d: " +"error task list is full\n" , ctx->pname, ctx->pid); goto out; }
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 3/10 drm/lima: check vm != NULL in lima_vm_put
In reply to Qiang YuNo need to handle this check before calling lima_vm_put.
--- drivers/gpu/drm/lima/lima_sched.c | 7 ++----- drivers/gpu/drm/lima/lima_vm.h | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/lima/lima_sched.c +2 -5
@@ -252,8 +252,7 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job)lima_mmu_switch_vm (pipe->mmu[i], vm); } -if (last_vm) -lima_vm_put (last_vm); +lima_vm_put (last_vm);trace_lima_task_run (task);
@@ -416,9 +415,7 @@ static void lima_sched_timedout_job(struct drm_sched_job *job)lima_mmu_page_fault_resume (pipe->mmu[i]); } -if (pipe->current_vm) -lima_vm_put (pipe->current_vm); - +lima_vm_put (pipe->current_vm); pipe->current_vm =NULL ; pipe->current_task =NULL ;
drivers/gpu/drm/lima/lima_vm.h +2 -1
@@ -54,7 +54,8 @@ static inline struct lima_vm *lima_vm_get(struct lima_vm *vm)static inline void lima_vm_put (struct lima_vm *vm) { -kref_put (&vm->refcount, lima_vm_release); +if (vm) +kref_put (&vm->refcount, lima_vm_release); }void lima_vm_print (struct lima_vm *vm);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 4/10 drm/lima: always set page directory when switch vm
In reply to Qiang YuWe need to flush TLB anyway before every task start, and the page directory will be set to empty vm after suspend/resume, so always set it to the task vm even no ctx switch happens.
--- drivers/gpu/drm/lima/lima_mmu.c | 3 +-- drivers/gpu/drm/lima/lima_sched.c | 14 ++++---------- 2 files changed, 5 insertions(+), 12 deletions(-)
drivers/gpu/drm/lima/lima_mmu.c +1 -2
@@ -113,8 +113,7 @@ void lima_mmu_switch_vm(struct lima_ip *ip, struct lima_vm *vm)LIMA_MMU_STATUS , v, v & LIMA_MMU_STATUS_STALL_ACTIVE); -if (vm) -mmu_write (LIMA_MMU_DTE_ADDR , vm->pd.dma); +mmu_write (LIMA_MMU_DTE_ADDR , vm->pd.dma);/* flush the TLB */ mmu_write (LIMA_MMU_COMMAND ,LIMA_MMU_COMMAND_ZAP_CACHE );
drivers/gpu/drm/lima/lima_sched.c +4 -10
@@ -200,7 +200,6 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job)struct lima_sched_pipe *pipe =to_lima_pipe (job->sched);struct lima_fence *fence;struct dma_fence *ret; -struct lima_vm *vm =NULL , *last_vm =NULL ;int i;/* after GPU reset */
@@ -239,21 +238,16 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job)for (i =0 ; i < pipe->num_l2_cache; i++)lima_l2_cache_flush (pipe->l2_cache[i]); -if (task->vm != pipe->current_vm) { - vm =lima_vm_get (task->vm); - last_vm = pipe->current_vm; - pipe->current_vm = task->vm; - } +lima_vm_put (pipe->current_vm); + pipe->current_vm =lima_vm_get (task->vm);if (pipe->bcast_mmu) -lima_mmu_switch_vm (pipe->bcast_mmu, vm); +lima_mmu_switch_vm (pipe->bcast_mmu, pipe->current_vm);else {for (i =0 ; i < pipe->num_mmu; i++) -lima_mmu_switch_vm (pipe->mmu[i], vm); +lima_mmu_switch_vm (pipe->mmu[i], pipe->current_vm); } -lima_vm_put (last_vm); -trace_lima_task_run (task); pipe->error = false;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 5/10 drm/lima: add lima_devfreq_resume/suspend
In reply to Qiang YuUsed for device resume/suspend in the following commits.
--- drivers/gpu/drm/lima/lima_devfreq.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_devfreq.h | 3 +++ 2 files changed, 27 insertions(+)
drivers/gpu/drm/lima/lima_devfreq.c +24 -0
@@ -232,3 +232,27 @@ void lima_devfreq_record_idle(struct lima_devfreq *devfreq)spin_unlock_irqrestore (&devfreq->lock, irqflags); } + +int lima_devfreq_resume (struct lima_devfreq *devfreq) +{ +unsigned long irqflags; + +if (!devfreq->devfreq) +return 0 ; + +spin_lock_irqsave (&devfreq->lock, irqflags); + +lima_devfreq_reset (devfreq); + +spin_unlock_irqrestore (&devfreq->lock, irqflags); + +return devfreq_resume_device (devfreq->devfreq); +} + +int lima_devfreq_suspend (struct lima_devfreq *devfreq) +{ +if (!devfreq->devfreq) +return 0 ; + +return devfreq_suspend_device (devfreq->devfreq); +}
drivers/gpu/drm/lima/lima_devfreq.h +3 -0
@@ -38,4 +38,7 @@ void lima_devfreq_fini(struct lima_device *ldev);void lima_devfreq_record_busy (struct lima_devfreq *devfreq);void lima_devfreq_record_idle (struct lima_devfreq *devfreq); +int lima_devfreq_resume (struct lima_devfreq *devfreq); +int lima_devfreq_suspend (struct lima_devfreq *devfreq); +#endif
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 6/10 drm/lima: power down ip blocks when pmu exit
In reply to Qiang YuPrepare resume/suspend PM.
v2:
Fix lima_pmu_wait_cmd timeout when mali400 case.
--- drivers/gpu/drm/lima/lima_device.h | 2 ++ drivers/gpu/drm/lima/lima_pmu.c | 53 +++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_device.h +2 -0
@@ -64,6 +64,8 @@ struct lima_ip {bool async_reset;/* l2 cache */ spinlock_t lock; +/* pmu */ +u32 mask; } data; };
drivers/gpu/drm/lima/lima_pmu.c +52 -1
70 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 7/10 drm/lima: add resume/suspend callback for each ip
In reply to Qiang YuFor called when PM do resume/suspend.
--- drivers/gpu/drm/lima/lima_bcast.c | 25 ++++++++++++---- drivers/gpu/drm/lima/lima_bcast.h | 2 ++ drivers/gpu/drm/lima/lima_device.c | 4 +++ drivers/gpu/drm/lima/lima_device.h | 2 +- drivers/gpu/drm/lima/lima_dlbu.c | 17 ++++++++++- drivers/gpu/drm/lima/lima_dlbu.h | 2 ++ drivers/gpu/drm/lima/lima_gp.c | 21 +++++++++++-- drivers/gpu/drm/lima/lima_gp.h | 2 ++ drivers/gpu/drm/lima/lima_l2_cache.c | 37 ++++++++++++++++------- drivers/gpu/drm/lima/lima_l2_cache.h | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 45 ++++++++++++++++++++-------- drivers/gpu/drm/lima/lima_mmu.h | 2 ++ drivers/gpu/drm/lima/lima_pmu.c | 24 +++++++++++++-- drivers/gpu/drm/lima/lima_pmu.h | 2 ++ drivers/gpu/drm/lima/lima_pp.c | 31 +++++++++++++++++-- drivers/gpu/drm/lima/lima_pp.h | 4 +++ 16 files changed, 185 insertions(+), 37 deletions(-)
drivers/gpu/drm/lima/lima_bcast.c +20 -5
@@ -26,18 +26,33 @@ void lima_bcast_enable(struct lima_device *dev, int num_pp)bcast_write (LIMA_BCAST_BROADCAST_MASK , mask); } +static int lima_bcast_hw_init (struct lima_ip *ip) +{ +bcast_write (LIMA_BCAST_BROADCAST_MASK , ip->data.mask <<16 ); +bcast_write (LIMA_BCAST_INTERRUPT_MASK , ip->data.mask); +return 0 ; +} + +int lima_bcast_resume (struct lima_ip *ip) +{ +return lima_bcast_hw_init (ip); +} + +void lima_bcast_suspend (struct lima_ip *ip) +{ + +} +int lima_bcast_init (struct lima_ip *ip) { -int i, mask =0 ; +int i;for (i = lima_ip_pp0; i <= lima_ip_pp7; i++) {if (ip->dev->ip[i].present) - mask |=1 << (i - lima_ip_pp0); + ip->data.mask |=1 << (i - lima_ip_pp0); } -bcast_write (LIMA_BCAST_BROADCAST_MASK , mask <<16 ); -bcast_write (LIMA_BCAST_INTERRUPT_MASK , mask); -return 0 ; +return lima_bcast_hw_init (ip); }void lima_bcast_fini (struct lima_ip *ip)
drivers/gpu/drm/lima/lima_bcast.h +2 -0
@@ -6,6 +6,8 @@struct lima_ip ; +int lima_bcast_resume (struct lima_ip *ip); +void lima_bcast_suspend (struct lima_ip *ip);int lima_bcast_init (struct lima_ip *ip);void lima_bcast_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_device.c +4 -0
@@ -25,6 +25,8 @@ struct lima_ip_desc {int (*init)(struct lima_ip *ip);void (*fini)(struct lima_ip *ip); +int (*resume)(struct lima_ip *ip); +void (*suspend)(struct lima_ip *ip); };#define LIMA_IP_DESC (ipname, mst0, mst1, off0, off1, func, irq) \
@@ -41,6 +43,8 @@ struct lima_ip_desc { }, \ .init = lima_##func##_init, \ .fini = lima_##func##_fini, \ + .resume = lima_##func##_resume, \ + .suspend = lima_##func##_suspend, \ }static struct lima_ip_desc lima_ip_desc[lima_ip_num] = {
drivers/gpu/drm/lima/lima_device.h +1 -1
@@ -64,7 +64,7 @@ struct lima_ip {bool async_reset;/* l2 cache */ spinlock_t lock; -/* pmu */ +/* pmu/bcast */ u32 mask; } data; };
drivers/gpu/drm/lima/lima_dlbu.c +16 -1
@@ -42,7 +42,7 @@ void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg)dlbu_write (LIMA_DLBU_START_TILE_POS , reg[3 ]); } -int lima_dlbu_init (struct lima_ip *ip) +static int lima_dlbu_hw_init (struct lima_ip *ip) {struct lima_device *dev = ip->dev;
@@ -52,6 +52,21 @@ int lima_dlbu_init(struct lima_ip *ip)return 0 ; } +int lima_dlbu_resume (struct lima_ip *ip) +{ +return lima_dlbu_hw_init (ip); +} + +void lima_dlbu_suspend (struct lima_ip *ip) +{ + +} + +int lima_dlbu_init (struct lima_ip *ip) +{ +return lima_dlbu_hw_init (ip); +} +void lima_dlbu_fini (struct lima_ip *ip) {
drivers/gpu/drm/lima/lima_dlbu.h +2 -0
@@ -12,6 +12,8 @@ void lima_dlbu_disable(struct lima_device *dev);void lima_dlbu_set_reg (struct lima_ip *ip,u32 *reg); +int lima_dlbu_resume (struct lima_ip *ip); +void lima_dlbu_suspend (struct lima_ip *ip);int lima_dlbu_init (struct lima_ip *ip);void lima_dlbu_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_gp.c +18 -3
@@ -274,6 +274,23 @@ static void lima_gp_print_version(struct lima_ip *ip)static struct kmem_cache *lima_gp_task_slab;static int lima_gp_task_slab_refcnt; +static int lima_gp_hw_init (struct lima_ip *ip) +{ + ip->data.async_reset = false; +lima_gp_soft_reset_async (ip); +return lima_gp_soft_reset_async_wait (ip); +} + +int lima_gp_resume (struct lima_ip *ip) +{ +return lima_gp_hw_init (ip); +} + +void lima_gp_suspend (struct lima_ip *ip) +{ + +} +int lima_gp_init (struct lima_ip *ip) {struct lima_device *dev = ip->dev;
@@ -281,9 +298,7 @@ int lima_gp_init(struct lima_ip *ip)lima_gp_print_version (ip); - ip->data.async_reset = false; -lima_gp_soft_reset_async (ip); - err =lima_gp_soft_reset_async_wait (ip); + err =lima_gp_hw_init (ip);if (err)return err;
drivers/gpu/drm/lima/lima_gp.h +2 -0
@@ -7,6 +7,8 @@struct lima_ip ;struct lima_device ; +int lima_gp_resume (struct lima_ip *ip); +void lima_gp_suspend (struct lima_ip *ip);int lima_gp_init (struct lima_ip *ip);void lima_gp_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_l2_cache.c +27 -10
@@ -38,9 +38,34 @@ int lima_l2_cache_flush(struct lima_ip *ip)return ret; } +static int lima_l2_cache_hw_init (struct lima_ip *ip) +{ +int err; + + err =lima_l2_cache_flush (ip); +if (err) +return err; + +l2_cache_write (LIMA_L2_CACHE_ENABLE , +LIMA_L2_CACHE_ENABLE_ACCESS |LIMA_L2_CACHE_ENABLE_READ_ALLOCATE ); +l2_cache_write (LIMA_L2_CACHE_MAX_READS ,0x1c ); + +return 0 ; +} + +int lima_l2_cache_resume (struct lima_ip *ip) +{ +return lima_l2_cache_hw_init (ip); +} + +void lima_l2_cache_suspend (struct lima_ip *ip) +{ + +} +int lima_l2_cache_init (struct lima_ip *ip) { -int i, err; +int i;u32 size;struct lima_device *dev = ip->dev;
@@ -63,15 +88,7 @@ int lima_l2_cache_init(struct lima_ip *ip)1 << (size &0xff ), 1 << ((size >> 24) & 0xff)); - err =lima_l2_cache_flush (ip); -if (err) -return err; - -l2_cache_write (LIMA_L2_CACHE_ENABLE , -LIMA_L2_CACHE_ENABLE_ACCESS |LIMA_L2_CACHE_ENABLE_READ_ALLOCATE ); -l2_cache_write (LIMA_L2_CACHE_MAX_READS ,0x1c ); - -return 0 ; +return lima_l2_cache_hw_init (ip); }void lima_l2_cache_fini (struct lima_ip *ip)
drivers/gpu/drm/lima/lima_l2_cache.h +2 -0
@@ -6,6 +6,8 @@struct lima_ip ; +int lima_l2_cache_resume (struct lima_ip *ip); +void lima_l2_cache_suspend (struct lima_ip *ip);int lima_l2_cache_init (struct lima_ip *ip);void lima_l2_cache_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_mmu.c +33 -12
68 lines not on this page · raw message
drivers/gpu/drm/lima/lima_mmu.h +2 -0
@@ -7,6 +7,8 @@struct lima_ip ;struct lima_vm ; +int lima_mmu_resume (struct lima_ip *ip); +void lima_mmu_suspend (struct lima_ip *ip);int lima_mmu_init (struct lima_ip *ip);void lima_mmu_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_pmu.c +22 -2
@@ -63,7 +63,7 @@ static u32 lima_pmu_get_ip_mask(struct lima_ip *ip)return ret; } -int lima_pmu_init (struct lima_ip *ip) +static int lima_pmu_hw_init (struct lima_ip *ip) {int err;u32 stat;
@@ -88,7 +88,7 @@ int lima_pmu_init(struct lima_ip *ip)return 0 ; } -void lima_pmu_fini (struct lima_ip *ip) +static void lima_pmu_hw_fini (struct lima_ip *ip) {u32 stat;
@@ -109,3 +109,23 @@ void lima_pmu_fini(struct lima_ip *ip)lima_pmu_wait_cmd (ip); } } + +int lima_pmu_resume (struct lima_ip *ip) +{ +return lima_pmu_hw_init (ip); +} + +void lima_pmu_suspend (struct lima_ip *ip) +{ +lima_pmu_hw_fini (ip); +} + +int lima_pmu_init (struct lima_ip *ip) +{ +return lima_pmu_hw_init (ip); +} + +void lima_pmu_fini (struct lima_ip *ip) +{ +lima_pmu_hw_fini (ip); +}
drivers/gpu/drm/lima/lima_pmu.h +2 -0
@@ -6,6 +6,8 @@struct lima_ip ; +int lima_pmu_resume (struct lima_ip *ip); +void lima_pmu_suspend (struct lima_ip *ip);int lima_pmu_init (struct lima_ip *ip);void lima_pmu_fini (struct lima_ip *ip);
drivers/gpu/drm/lima/lima_pp.c +28 -3
@@ -223,6 +223,23 @@ static void lima_pp_print_version(struct lima_ip *ip) lima_ip_name(ip), name, major, minor); } +static int lima_pp_hw_init (struct lima_ip *ip) +{ + ip->data.async_reset = false; +lima_pp_soft_reset_async (ip); +return lima_pp_soft_reset_async_wait (ip); +} + +int lima_pp_resume (struct lima_ip *ip) +{ +return lima_pp_hw_init (ip); +} + +void lima_pp_suspend (struct lima_ip *ip) +{ + +} +int lima_pp_init (struct lima_ip *ip) {struct lima_device *dev = ip->dev;
@@ -230,9 +247,7 @@ int lima_pp_init(struct lima_ip *ip)lima_pp_print_version (ip); - ip->data.async_reset = false; -lima_pp_soft_reset_async (ip); - err =lima_pp_soft_reset_async_wait (ip); + err =lima_pp_hw_init (ip);if (err)return err;
@@ -254,6 +269,16 @@ void lima_pp_fini(struct lima_ip *ip) } +int lima_pp_bcast_resume (struct lima_ip *ip) +{ +return 0 ; +} + +void lima_pp_bcast_suspend (struct lima_ip *ip) +{ + +} +int lima_pp_bcast_init (struct lima_ip *ip) {struct lima_device *dev = ip->dev;
drivers/gpu/drm/lima/lima_pp.h +4 -0
@@ -7,9 +7,13 @@struct lima_ip ;struct lima_device ; +int lima_pp_resume (struct lima_ip *ip); +void lima_pp_suspend (struct lima_ip *ip);int lima_pp_init (struct lima_ip *ip);void lima_pp_fini (struct lima_ip *ip); +int lima_pp_bcast_resume (struct lima_ip *ip); +void lima_pp_bcast_suspend (struct lima_ip *ip);int lima_pp_bcast_init (struct lima_ip *ip);void lima_pp_bcast_fini (struct lima_ip *ip);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 8/10 drm/lima: seperate clk/regulator enable/disable function
In reply to Qiang YuFor being used by both device init/fini and suspend/resume.
--- drivers/gpu/drm/lima/lima_device.c | 105 +++++++++++++++++++---------- 1 file changed, 68 insertions(+), 37 deletions(-)
drivers/gpu/drm/lima/lima_device.c +68 -37
@@ -81,26 +81,10 @@ const char *lima_ip_name(struct lima_ip *ip)return lima_ip_desc[ip->id].name; } -static int lima_clk_init (struct lima_device *dev) +static int lima_clk_enable (struct lima_device *dev) {int err; - dev->clk_bus =devm_clk_get (dev->dev,"bus" ); -if (IS_ERR (dev->clk_bus)) { - err =PTR_ERR (dev->clk_bus); -if (err != -EPROBE_DEFER ) -dev_err (dev->dev,"get bus clk failed %d\n" , err); -return err; - } - - dev->clk_gpu =devm_clk_get (dev->dev,"core" ); -if (IS_ERR (dev->clk_gpu)) { - err =PTR_ERR (dev->clk_gpu); -if (err != -EPROBE_DEFER ) -dev_err (dev->dev,"get core clk failed %d\n" , err); -return err; - } - err =clk_prepare_enable (dev->clk_bus);if (err)return err;
@@ -109,15 +93,7 @@ static int lima_clk_init(struct lima_device *dev)if (err) goto error_out0; - dev->reset =devm_reset_control_array_get_optional_shared (dev->dev); - -if (IS_ERR (dev->reset)) { - err =PTR_ERR (dev->reset); -if (err != -EPROBE_DEFER ) -dev_err (dev->dev,"get reset controller failed %d\n" , - err); - goto error_out1; - }else if (dev->reset !=NULL ) { +if (dev->reset) { err =reset_control_deassert (dev->reset);if (err) { dev_err(dev->dev,
@@ -135,14 +111,76 @@ static int lima_clk_init(struct lima_device *dev)return err; } -static void lima_clk_fini (struct lima_device *dev) +static void lima_clk_disable (struct lima_device *dev) { -if (dev->reset !=NULL ) +if (dev->reset)reset_control_assert (dev->reset);clk_disable_unprepare (dev->clk_gpu);clk_disable_unprepare (dev->clk_bus); } +static int lima_clk_init (struct lima_device *dev) +{ +int err; + + dev->clk_bus =devm_clk_get (dev->dev,"bus" ); +if (IS_ERR (dev->clk_bus)) { + err =PTR_ERR (dev->clk_bus); +if (err != -EPROBE_DEFER ) +dev_err (dev->dev,"get bus clk failed %d\n" , err); + dev->clk_bus =NULL ; +return err; + } + + dev->clk_gpu =devm_clk_get (dev->dev,"core" ); +if (IS_ERR (dev->clk_gpu)) { + err =PTR_ERR (dev->clk_gpu); +if (err != -EPROBE_DEFER ) +dev_err (dev->dev,"get core clk failed %d\n" , err); + dev->clk_gpu =NULL ; +return err; + } + + dev->reset =devm_reset_control_array_get_optional_shared (dev->dev); +if (IS_ERR (dev->reset)) { + err =PTR_ERR (dev->reset); +if (err != -EPROBE_DEFER ) +dev_err (dev->dev,"get reset controller failed %d\n" , + err); + dev->reset =NULL ; +return err; + } + +return lima_clk_enable (dev); +} + +static void lima_clk_fini (struct lima_device *dev) +{ +lima_clk_disable (dev); +} + +static int lima_regulator_enable (struct lima_device *dev) +{ +int ret; + +if (!dev->regulator) +return 0 ; + + ret =regulator_enable (dev->regulator); +if (ret <0 ) { +dev_err (dev->dev,"failed to enable regulator: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static void lima_regulator_disable (struct lima_device *dev) +{ +if (dev->regulator) +regulator_disable (dev->regulator); +} +static int lima_regulator_init (struct lima_device *dev) {int ret;
@@ -158,19 +196,12 @@ static int lima_regulator_init(struct lima_device *dev)return ret; } - ret =regulator_enable (dev->regulator); -if (ret <0 ) { -dev_err (dev->dev,"failed to enable regulator: %d\n" , ret); -return ret; - } - -return 0 ; +return lima_regulator_enable (dev); }static void lima_regulator_fini (struct lima_device *dev) { -if (dev->regulator) -regulator_disable (dev->regulator); +lima_regulator_disable (dev); }static int lima_init_ip (struct lima_device *dev,int index)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 9/10 drm/lima: add pm resume/suspend ops
In reply to Qiang YuAdd driver pm system and runtime hardware resume/suspend ops. Note this won't enable runtime pm of the device yet.
v2:
Do clock and power gating when suspend/resume.
--- drivers/gpu/drm/lima/lima_device.c | 90 ++++++++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_device.h | 3 + drivers/gpu/drm/lima/lima_drv.c | 7 +++ 3 files changed, 100 insertions(+)
drivers/gpu/drm/lima/lima_device.c +90 -0
@@ -244,6 +244,27 @@ static void lima_fini_ip(struct lima_device *ldev, int index) desc->fini (ip); } +static int lima_resume_ip (struct lima_device *ldev,int index) +{ +struct lima_ip_desc *desc = lima_ip_desc + index; +struct lima_ip *ip = ldev->ip + index; +int ret =0 ; + +if (ip->present) + ret = desc->resume (ip); + +return ret; +} + +static void lima_suspend_ip (struct lima_device *ldev,int index) +{ +struct lima_ip_desc *desc = lima_ip_desc + index; +struct lima_ip *ip = ldev->ip + index; + +if (ip->present) + desc->suspend (ip); +} +static int lima_init_gp_pipe (struct lima_device *dev) {struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_gp;
@@ -439,3 +460,72 @@ void lima_device_fini(struct lima_device *ldev)lima_clk_fini (ldev); } + +int lima_device_resume (struct device *dev) +{ +struct lima_device *ldev =dev_get_drvdata (dev); +int i, err; + + err =lima_clk_enable (ldev); +if (err) { +dev_err (dev,"resume clk fail %d\n" , err); +return err; + } + + err =lima_regulator_enable (ldev); +if (err) { +dev_err (dev,"resume regulator fail %d\n" , err); + goto err_out0; + } + +for (i =0 ; i < lima_ip_num; i++) { + err =lima_resume_ip (ldev, i); +if (err) { +dev_err (dev,"resume ip %d fail\n" , i); + goto err_out1; + } + } + + err =lima_devfreq_resume (&ldev->devfreq); +if (err) { +dev_err (dev,"devfreq resume fail\n" ); + goto err_out1; + } + +return 0 ; + +err_out1: +while (--i >=0 ) +lima_suspend_ip (ldev, i); +lima_regulator_disable (ldev); +err_out0: +lima_clk_disable (ldev); +return err; +} + +int lima_device_suspend (struct device *dev) +{ +struct lima_device *ldev =dev_get_drvdata (dev); +int i, err; + +/* check any task running */ +for (i =0 ; i < lima_pipe_num; i++) { +if (atomic_read (&ldev->pipe[i].base.hw_rq_count)) +return -EBUSY ; + } + + err =lima_devfreq_suspend (&ldev->devfreq); +if (err) { +dev_err (dev,"devfreq suspend fail\n" ); +return err; + } + +for (i = lima_ip_num -1 ; i >=0 ; i--) +lima_suspend_ip (ldev, i); + +lima_regulator_disable (ldev); + +lima_clk_disable (ldev); + +return 0 ; +}
drivers/gpu/drm/lima/lima_device.h +3 -0
@@ -141,4 +141,7 @@ static inline int lima_poll_timeout(struct lima_ip *ip, lima_poll_func_t func, return 0; } +int lima_device_suspend (struct device *dev); +int lima_device_resume (struct device *dev); +#endif
drivers/gpu/drm/lima/lima_drv.c +7 -0
@@ -5,6 +5,7 @@#include <linux/of_platform.h> #include <linux/uaccess.h> #include <linux/slab.h> +#include <linux/pm_runtime.h> #include <drm/drm_ioctl.h> #include <drm/drm_drv.h> #include <drm/drm_prime.h>
@@ -452,11 +453,17 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +static const struct dev_pm_ops lima_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) +SET_RUNTIME_PM_OPS (lima_device_suspend, lima_device_resume,NULL ) +}; +static struct platform_driver lima_platform_driver = { .probe = lima_pdev_probe, .remove = lima_pdev_remove, .driver = { .name ="lima" , + .pm = &lima_pm_ops, .of_match_table = dt_match, }, };
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 10/10 drm/lima: enable runtime pm
In reply to Qiang YuEnable runtime pm by default so GPU suspend when idle for 200ms. This value can be changed by autosuspend_delay_ms in device's power sysfs dir.
On Allwinner H3 lima_device_resume takes ~40us and lima_device_suspend takes ~20us.
--- drivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++---- drivers/gpu/drm/lima/lima_sched.c | 41 +++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +16 -5
@@ -405,6 +405,12 @@ static int lima_pdev_probe(struct platform_device *pdev) goto err_out2; } +pm_runtime_set_active (ldev->dev); +pm_runtime_mark_last_busy (ldev->dev); +pm_runtime_set_autosuspend_delay (ldev->dev,200 ); +pm_runtime_use_autosuspend (ldev->dev); +pm_runtime_enable (ldev->dev); +/* * Register the DRM device with the core and the connectors with * sysfs.
@@ -413,17 +419,16 @@ static int lima_pdev_probe(struct platform_device *pdev)if (err <0 ) goto err_out3; -platform_set_drvdata (pdev, ldev); -if (sysfs_create_bin_file (&ldev->dev->kobj, &lima_error_state_attr))dev_warn (ldev->dev,"fail to create error state sysfs\n" );return 0 ; err_out3: -lima_device_fini (ldev); -err_out2: +pm_runtime_disable (ldev->dev);lima_devfreq_fini (ldev); +err_out2: +lima_device_fini (ldev); err_out1:drm_dev_put (ddev); err_out0:
@@ -437,10 +442,16 @@ static int lima_pdev_remove(struct platform_device *pdev)struct drm_device *ddev = ldev->ddev;sysfs_remove_bin_file (&ldev->dev->kobj, &lima_error_state_attr); -platform_set_drvdata (pdev,NULL ); +drm_dev_unregister (ddev); + +/* stop autosuspend to make sure device is in active state */ +pm_runtime_set_autosuspend_delay (ldev->dev,-1 ); +pm_runtime_disable (ldev->dev); +lima_devfreq_fini (ldev);lima_device_fini (ldev); +drm_dev_put (ddev);lima_sched_slab_fini ();return 0 ;
drivers/gpu/drm/lima/lima_sched.c +36 -5
94 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Qiang Yu
Suspend need to wait running jobs finish and put hardware in poweroff state. Resume need to re-init hardware.
v2:
1. add misc patches to prepare enable runtime pm
2. fix pmu command wait time out on mali400 gpu
3. do power and clock gating when suspend
4. do runtime pm
Quoted 9 lines
Qiang Yu (10):
drm/lima: usemodule_platform_driverhelper drm/lima: print process name and pid when task error drm/lima: check vm != NULL inlima_vm_putdrm/lima: always set page directory when switch vm drm/lima: add lima_devfreq_resume/suspend drm/lima: power down ip blocks when pmu exit drm/lima: add resume/suspend callback for each ip drm/lima: seperate clk/regulator enable/disable function
s/seperate/separate
I guess you can fix it before merging into drm-misc-next, no need to respin whole patchset
Quoted 2 lines
drm/lima: add pm resume/suspend ops
drm/lima: enable runtime pm
Besides that, series is:
Quoted 23 lines
drivers/gpu/drm/lima/lima_bcast.c | 25 +++- drivers/gpu/drm/lima/lima_bcast.h | 2 + drivers/gpu/drm/lima/lima_devfreq.c | 24 ++++ drivers/gpu/drm/lima/lima_devfreq.h | 3 + drivers/gpu/drm/lima/lima_device.c | 199 ++++++++++++++++++++++----- drivers/gpu/drm/lima/lima_device.h | 5 + drivers/gpu/drm/lima/lima_dlbu.c | 17 ++- drivers/gpu/drm/lima/lima_dlbu.h | 2 + drivers/gpu/drm/lima/lima_drv.c | 40 +++--- drivers/gpu/drm/lima/lima_gp.c | 21 ++- drivers/gpu/drm/lima/lima_gp.h | 2 + drivers/gpu/drm/lima/lima_l2_cache.c | 37 +++-- drivers/gpu/drm/lima/lima_l2_cache.h | 2 + drivers/gpu/drm/lima/lima_mmu.c | 48 +++++-- drivers/gpu/drm/lima/lima_mmu.h | 2 + drivers/gpu/drm/lima/lima_pmu.c | 77 ++++++++++- drivers/gpu/drm/lima/lima_pmu.h | 2 + drivers/gpu/drm/lima/lima_pp.c | 31 ++++- drivers/gpu/drm/lima/lima_pp.h | 4 + drivers/gpu/drm/lima/lima_sched.c | 63 ++++++--- drivers/gpu/drm/lima/lima_vm.h | 3 +- 21 files changed, 496 insertions(+), 113 deletions(-)
Quoted 3 lines
--
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerThanks, fix and applied to drm-misc-next.
Regards,
Qiang
Quoted 27 lines · Vasily Khoruzhick
Quoted 10 lines · Qiang Yu
Suspend need to wait running jobs finish and put hardware in poweroff state. Resume need to re-init hardware.
v2:
1. add misc patches to prepare enable runtime pm
2. fix pmu command wait time out on mali400 gpu
3. do power and clock gating when suspend
4. do runtime pmQuoted 9 lines
Qiang Yu (10):
drm/lima: usemodule_platform_driverhelper drm/lima: print process name and pid when task error drm/lima: check vm != NULL inlima_vm_putdrm/lima: always set page directory when switch vm drm/lima: add lima_devfreq_resume/suspend drm/lima: power down ip blocks when pmu exit drm/lima: add resume/suspend callback for each ip drm/lima: seperate clk/regulator enable/disable functions/seperate/separate
I guess you can fix it before merging into drm-misc-next, no need to respin whole patchset
Quoted 33 lines
Quoted 2 lines
drm/lima: add pm resume/suspend ops
drm/lima: enable runtime pmBesides that, series is:
Reviewed-by Vasily Khoruzhick <[email protected]>Quoted 26 lines
drivers/gpu/drm/lima/lima_bcast.c | 25 +++- drivers/gpu/drm/lima/lima_bcast.h | 2 + drivers/gpu/drm/lima/lima_devfreq.c | 24 ++++ drivers/gpu/drm/lima/lima_devfreq.h | 3 + drivers/gpu/drm/lima/lima_device.c | 199 ++++++++++++++++++++++----- drivers/gpu/drm/lima/lima_device.h | 5 + drivers/gpu/drm/lima/lima_dlbu.c | 17 ++- drivers/gpu/drm/lima/lima_dlbu.h | 2 + drivers/gpu/drm/lima/lima_drv.c | 40 +++--- drivers/gpu/drm/lima/lima_gp.c | 21 ++- drivers/gpu/drm/lima/lima_gp.h | 2 + drivers/gpu/drm/lima/lima_l2_cache.c | 37 +++-- drivers/gpu/drm/lima/lima_l2_cache.h | 2 + drivers/gpu/drm/lima/lima_mmu.c | 48 +++++-- drivers/gpu/drm/lima/lima_mmu.h | 2 + drivers/gpu/drm/lima/lima_pmu.c | 77 ++++++++++- drivers/gpu/drm/lima/lima_pmu.h | 2 + drivers/gpu/drm/lima/lima_pp.c | 31 ++++- drivers/gpu/drm/lima/lima_pp.h | 4 + drivers/gpu/drm/lima/lima_sched.c | 63 ++++++--- drivers/gpu/drm/lima/lima_vm.h | 3 +- 21 files changed, 496 insertions(+), 113 deletions(-)--
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel