linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] fb_defio: add first_io callback
@ 2012-03-28 17:33 Heiko Stübner
  2012-03-31 23:38 ` Florian Tobias Schandinat
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Stübner @ 2012-03-28 17:33 UTC (permalink / raw)
  To: linux-fbdev

With this optional callback the driver is notified when the first page
is entered into the pagelist and a new deferred_io call is scheduled.

A possible use-case for this is runtime-pm. In the first_io call
	pm_runtime_get()
could be called, which starts an asynchronous runtime_resume of the
device. In the deferred_io callback a call to
	pm_runtime_barrier()
makes the sure, the device is resumed by then and a
	pm_runtime_put()
may put the device back to sleep.

Also, some SoCs may use the runtime-pm system to determine if they
are able to enter deeper idle states. Therefore it is necessary to
keep the use-count from the first written page until the conclusion
of the screen update, to prevent the system from going to sleep before
completing the pending update.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/video/fb_defio.c |    4 ++++
 include/linux/fb.h       |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index c27e153..070f26f 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -107,6 +107,10 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
 
+	/* first write in this cycle, notify the driver */
+	if (fbdefio->first_io && list_empty(&fbdefio->pagelist))
+		fbdefio->first_io(info);
+
 	/*
 	 * We want the page to remain locked from ->page_mkwrite until
 	 * the PTE is marked dirty to avoid page_mkclean() being called
diff --git a/include/linux/fb.h b/include/linux/fb.h
index d31cb68..c10e71e 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -607,6 +607,7 @@ struct fb_deferred_io {
 	struct mutex lock; /* mutex that protects the page list */
 	struct list_head pagelist; /* list of touched pages */
 	/* callback */
+	void (*first_io)(struct fb_info *info);
 	void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
 };
 #endif
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/4] fb_defio: add first_io callback
  2012-03-28 17:33 [PATCH 1/4] fb_defio: add first_io callback Heiko Stübner
@ 2012-03-31 23:38 ` Florian Tobias Schandinat
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Tobias Schandinat @ 2012-03-31 23:38 UTC (permalink / raw)
  To: linux-fbdev

Hi Heiko,

On 03/28/2012 05:33 PM, Heiko Stübner wrote:
> With this optional callback the driver is notified when the first page
> is entered into the pagelist and a new deferred_io call is scheduled.
> 
> A possible use-case for this is runtime-pm. In the first_io call
> 	pm_runtime_get()
> could be called, which starts an asynchronous runtime_resume of the
> device. In the deferred_io callback a call to
> 	pm_runtime_barrier()
> makes the sure, the device is resumed by then and a
> 	pm_runtime_put()
> may put the device back to sleep.
> 
> Also, some SoCs may use the runtime-pm system to determine if they
> are able to enter deeper idle states. Therefore it is necessary to
> keep the use-count from the first written page until the conclusion
> of the screen update, to prevent the system from going to sleep before
> completing the pending update.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Special characters are allowed in sign-offs. And your other patches are
encoded as quoted-printable anyway (although I'd prefer an encoding my
git takes directly like UTF-8).

> ---
>  drivers/video/fb_defio.c |    4 ++++
>  include/linux/fb.h       |    1 +
>  2 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
> index c27e153..070f26f 100644
> --- a/drivers/video/fb_defio.c
> +++ b/drivers/video/fb_defio.c
> @@ -107,6 +107,10 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
>  	/* protect against the workqueue changing the page list */
>  	mutex_lock(&fbdefio->lock);
>  
> +	/* first write in this cycle, notify the driver */
> +	if (fbdefio->first_io && list_empty(&fbdefio->pagelist))
> +		fbdefio->first_io(info);
> +
>  	/*
>  	 * We want the page to remain locked from ->page_mkwrite until
>  	 * the PTE is marked dirty to avoid page_mkclean() being called
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index d31cb68..c10e71e 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -607,6 +607,7 @@ struct fb_deferred_io {

There are some drivers (smscufx & udlfb) that kmalloc this struct. I
think you have to fix (kzalloc) them to avoid breaking them?

>  	struct mutex lock; /* mutex that protects the page list */
>  	struct list_head pagelist; /* list of touched pages */
>  	/* callback */
> +	void (*first_io)(struct fb_info *info);
>  	void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
>  };
>  #endif

Thanks,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-31 23:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-28 17:33 [PATCH 1/4] fb_defio: add first_io callback Heiko Stübner
2012-03-31 23:38 ` Florian Tobias Schandinat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).