Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l: vsp1: Fix Suspend-to-RAM

Fix Suspend-to-RAM so that VSP1 driver continues to work after resuming.

In detail,
- Fix the judgment of ref count in resuming.
- Add stopping VSP1 during suspend.

[Refactor the suspend and resume code to lower suspend delay]

Signed-off-by: Sei Fumizono <sei.fumizono.jw@hitachi-solutions.com>
Signed-off-by: Yoshifumi Hosoya <yoshifumi.hosoya.wj@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Sei Fumizono and committed by
Mauro Carvalho Chehab
139c9286 45008ee9

+83 -5
+10 -3
drivers/media/platform/vsp1/vsp1_drv.c
··· 1 1 /* 2 2 * vsp1_drv.c -- R-Car VSP1 Driver 3 3 * 4 - * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 + * Copyright (C) 2013-2015 Renesas Electronics Corporation 5 5 * 6 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 7 7 * ··· 403 403 if (vsp1->ref_count == 0) 404 404 return 0; 405 405 406 + vsp1_pipelines_suspend(vsp1); 407 + 406 408 clk_disable_unprepare(vsp1->clock); 409 + 407 410 return 0; 408 411 } 409 412 ··· 416 413 417 414 WARN_ON(mutex_is_locked(&vsp1->lock)); 418 415 419 - if (vsp1->ref_count) 416 + if (vsp1->ref_count == 0) 420 417 return 0; 421 418 422 - return clk_prepare_enable(vsp1->clock); 419 + clk_prepare_enable(vsp1->clock); 420 + 421 + vsp1_pipelines_resume(vsp1); 422 + 423 + return 0; 423 424 } 424 425 #endif 425 426
+69 -1
drivers/media/platform/vsp1/vsp1_video.c
··· 1 1 /* 2 2 * vsp1_video.c -- R-Car VSP1 Video Node 3 3 * 4 - * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 + * Copyright (C) 2013-2015 Renesas Electronics Corporation 5 5 * 6 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 7 7 * ··· 700 700 701 701 pad = &entity->pads[entity->source_pad]; 702 702 pad = media_entity_remote_pad(pad); 703 + } 704 + } 705 + 706 + void vsp1_pipelines_suspend(struct vsp1_device *vsp1) 707 + { 708 + unsigned long flags; 709 + unsigned int i; 710 + int ret; 711 + 712 + /* To avoid increasing the system suspend time needlessly, loop over the 713 + * pipelines twice, first to set them all to the stopping state, and then 714 + * to wait for the stop to complete. 715 + */ 716 + for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 717 + struct vsp1_rwpf *wpf = vsp1->wpf[i]; 718 + struct vsp1_pipeline *pipe; 719 + 720 + if (wpf == NULL) 721 + continue; 722 + 723 + pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); 724 + if (pipe == NULL) 725 + continue; 726 + 727 + spin_lock_irqsave(&pipe->irqlock, flags); 728 + if (pipe->state == VSP1_PIPELINE_RUNNING) 729 + pipe->state = VSP1_PIPELINE_STOPPING; 730 + spin_unlock_irqrestore(&pipe->irqlock, flags); 731 + } 732 + 733 + for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 734 + struct vsp1_rwpf *wpf = vsp1->wpf[i]; 735 + struct vsp1_pipeline *pipe; 736 + 737 + if (wpf == NULL) 738 + continue; 739 + 740 + pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); 741 + if (pipe == NULL) 742 + continue; 743 + 744 + ret = wait_event_timeout(pipe->wq, 745 + pipe->state == VSP1_PIPELINE_STOPPED, 746 + msecs_to_jiffies(500)); 747 + if (ret == 0) 748 + dev_warn(vsp1->dev, "pipeline %u stop timeout\n", 749 + wpf->entity.index); 750 + } 751 + } 752 + 753 + void vsp1_pipelines_resume(struct vsp1_device *vsp1) 754 + { 755 + unsigned int i; 756 + 757 + /* Resume pipeline all running pipelines. */ 758 + for (i = 0; i < vsp1->pdata.wpf_count; ++i) { 759 + struct vsp1_rwpf *wpf = vsp1->wpf[i]; 760 + struct vsp1_pipeline *pipe; 761 + 762 + if (wpf == NULL) 763 + continue; 764 + 765 + pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); 766 + if (pipe == NULL) 767 + continue; 768 + 769 + if (vsp1_pipeline_ready(pipe)) 770 + vsp1_pipeline_run(pipe); 703 771 } 704 772 } 705 773
+4 -1
drivers/media/platform/vsp1/vsp1_video.h
··· 1 1 /* 2 2 * vsp1_video.h -- R-Car VSP1 Video Node 3 3 * 4 - * Copyright (C) 2013-2014 Renesas Electronics Corporation 4 + * Copyright (C) 2013-2015 Renesas Electronics Corporation 5 5 * 6 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 7 7 * ··· 148 148 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, 149 149 struct vsp1_entity *input, 150 150 unsigned int alpha); 151 + 152 + void vsp1_pipelines_suspend(struct vsp1_device *vsp1); 153 + void vsp1_pipelines_resume(struct vsp1_device *vsp1); 151 154 152 155 #endif /* __VSP1_VIDEO_H__ */