fb_defio: add first_io callback

A patch from »video: add support for the AUO-K190X epd controllers« in state Mainline for linux-kernel

From: Heiko Stuebner <heiko@...> Date: Fri, 30 Dec 2011 23:16:19 +0100

Commit-Message

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. Two users of defio were using kmalloc to allocate the structure. These allocations are changed to kzalloc, to prevent uninitialised .first_io members in those drivers. Signed-off-by: Heiko Stübner <heiko@...>

Patch-Comment

changes since v1: convert fb_deferred_io kmalloc calls to kzalloc drivers/video/fb_defio.c | 4 ++++ drivers/video/smscufx.c | 2 +- drivers/video/udlfb.c | 2 +- include/linux/fb.h | 1 + 4 files changed, 7 insertions(+), 2 deletions(-)

Statistics

  • 7 lines added
  • 2 lines removed

Changes

--------------------------- drivers/video/fb_defio.c ---------------------------
index c27e153..070f26f 100644
@@ -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
--------------------------- drivers/video/smscufx.c ----------------------------
index ccbfef5..9985785 100644
@@ -1083,7 +1083,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
struct fb_deferred_io *fbdefio;
- fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
+ fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
if (fbdefio) {
fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
---------------------------- drivers/video/udlfb.c -----------------------------
index a159b63..e9d43b4 100644
@@ -893,7 +893,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)
struct fb_deferred_io *fbdefio;
- fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
+ fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
if (fbdefio) {
fbdefio->delay = DL_DEFIO_WRITE_DELAY;
------------------------------ include/linux/fb.h ------------------------------
index a3229d7..ac3f1c6 100644
@@ -611,6 +611,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
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...