Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH 1/3] video: mxsfb: fix color settings for 18bit data bus and 32bpp
From: Maxime Ripard @ 2013-07-15 15:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373902022-20439-1-git-send-email-maxime.ripard@free-electrons.com>

From: Hector Palacios <hector.palacios@digi.com>

For a combination of 18bit LCD data bus width and a color
mode of 32bpp, the driver was setting the color mapping to
rgb666, which is wrong, as the color in memory realy has an
rgb888 layout.

This patch also removes the setting of flag CTRL_DF24 that
makes the driver dimiss the upper 2 bits when handling 32/24bpp
colors in a diplay with 18bit data bus width. This flag made
true color images display wrong in such configurations.

Finally, the color mapping rgb666 has also been removed as nobody
is using it and high level applications like Qt5 cannot work
with it either.

Reference: https://lkml.org/lkml/2013/5/23/220
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Acked-by: Juergen Beisert <jbe@pengutronix.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/video/mxsfb.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 3ba3771..dc09ebe 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -239,24 +239,6 @@ static const struct fb_bitfield def_rgb565[] = {
 	}
 };
 
-static const struct fb_bitfield def_rgb666[] = {
-	[RED] = {
-		.offset = 16,
-		.length = 6,
-	},
-	[GREEN] = {
-		.offset = 8,
-		.length = 6,
-	},
-	[BLUE] = {
-		.offset = 0,
-		.length = 6,
-	},
-	[TRANSP] = {	/* no support for transparency */
-		.length = 0,
-	}
-};
-
 static const struct fb_bitfield def_rgb888[] = {
 	[RED] = {
 		.offset = 16,
@@ -309,9 +291,6 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
 			break;
 		case STMLCDIF_16BIT:
 		case STMLCDIF_18BIT:
-			/* 24 bit to 18 bit mapping */
-			rgb = def_rgb666;
-			break;
 		case STMLCDIF_24BIT:
 			/* real 24 bit */
 			rgb = def_rgb888;
@@ -453,11 +432,6 @@ static int mxsfb_set_par(struct fb_info *fb_info)
 			return -EINVAL;
 		case STMLCDIF_16BIT:
 		case STMLCDIF_18BIT:
-			/* 24 bit to 18 bit mapping */
-			ctrl |= CTRL_DF24; /* ignore the upper 2 bits in
-					    *  each colour component
-					    */
-			break;
 		case STMLCDIF_24BIT:
 			/* real 24 bit */
 			break;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 0/3] Few ignored framebuffer fixes/additions
From: Maxime Ripard @ 2013-07-15 15:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew, 

Sorry to bother you again with the framebuffer stuff but the new
maintainer doesn't appear to be responsive either.k

This is a collection of patches that have been silently ignored,
despite being pinged numerous times:
  - Patch 1 has been sent for the first time on June 7 [1], resent on
    June 18 [2], plus two pings on July, 3rd [3] and July, 12th [4]. With
    no comments whatsoever.
  - Patch 2 has been sent on June, 21st [5]. Jean Christophe commented
    on it on June, 24th [6], but every attempts at getting clear
    explanations on what was expected have been ignored ever since
    (June 25th [7], July 12th [8])
  - Patch 3 was sent on June 21st along with Patch 2 [9]. There was
    comments on it and a second version was sent on June 24th
    [10]. Without any comments so far.

Could you take a look at those patches? We already missed 3.11, and
I'd really like not to miss another merge window because of the fbdev
curse.

Thanks,
Maxime

[1]: https://lkml.org/lkml/2013/6/7/116
[2]: https://lkml.org/lkml/2013/6/18/130
[3]: https://lkml.org/lkml/2013/7/3/105
[4]: https://lkml.org/lkml/2013/7/12/177
[5]: https://lkml.org/lkml/2013/6/21/405
[6]: https://lkml.org/lkml/2013/6/24/313
[7]: https://lkml.org/lkml/2013/6/25/274
[8]: https://lkml.org/lkml/2013/7/12/103
[9]: https://lkml.org/lkml/2013/6/21/407
[10]: https://lkml.org/lkml/2013/6/24/302

Alexandre Belloni (1):
  fb: backlight: HX8357: Add HX8369 support

Hector Palacios (1):
  video: mxsfb: fix color settings for 18bit data bus and 32bpp

Maxime Ripard (1):
  video: hx8357: Make IM pins optional

 drivers/video/backlight/hx8357.c | 255 +++++++++++++++++++++++++++++++++------
 drivers/video/mxsfb.c            |  26 ----
 2 files changed, 218 insertions(+), 63 deletions(-)

-- 
1.8.3.2


^ permalink raw reply

* Re: [BUG] radeon: suspend resume
From: Michel Dänzer @ 2013-07-15 10:35 UTC (permalink / raw)
  To: kerolasa; +Cc: dri-devel
In-Reply-To: <CAG27Bk2NzdZELTeByjH5Sj_NbB+TOhYDK66aX1-9e=W_LT39Hg@mail.gmail.com>


[ The radeon driver is discussed on the dri-devel mailing list, moving
there ]

On Son, 2013-07-14 at 13:26 +0100, Sami Kerola wrote:
> 
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
> CP stall for more than 10000msec
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
> (waiting for 0x0000000000000004 last fence id 0x0000000000000002)
> Jul 14 12:51:31 kerolasa-home kernel: [drm:r600_uvd_ib_test] *ERROR*
> radeon: fence wait failed (-35).
> Jul 14 12:51:31 kerolasa-home kernel: [drm:radeon_ib_ring_tests]
> *ERROR* radeon: failed testing IB on ring 5 (-35).

Looks like the patch from
https://bugs.freedesktop.org/show_bug.cgi?idf425 might help.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer

^ permalink raw reply

* Re: [PATCH] video: remove unused variable "dev" in vga16fb_destroy()
From: Jingoo Han @ 2013-07-15  7:13 UTC (permalink / raw)
  To: 'Yijing Wang', 'Jean-Christophe Plagniol-Villard',
	'Tomi Valkeinen'
  Cc: linux-kernel, linux-fbdev, 'Hanjun Guo', jiang.liu,
	Jingoo Han
In-Reply-To: <1373869765-52572-1-git-send-email-wangyijing@huawei.com>

On Monday, July 15, 2013 3:29 PM, Yijing Wang wrote:
> 
> Delete unused variable "dev" to fix build warning in
> drivers/video/vga16fb.c
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Cc: Jingoo Han <jg1.han@samsung.com>

It looks good.
Reviewed-by: Jingoo Han <jg1.han@samsung.com>

Best regards,
Jingoo Han

> ---
>  drivers/video/vga16fb.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
> index 830ded4..2827333 100644
> --- a/drivers/video/vga16fb.c
> +++ b/drivers/video/vga16fb.c
> @@ -1265,7 +1265,6 @@ static void vga16fb_imageblit(struct fb_info *info, const struct fb_image *image
> 
>  static void vga16fb_destroy(struct fb_info *info)
>  {
> -	struct platform_device *dev = container_of(info->device, struct platform_device, dev);
>  	iounmap(info->screen_base);
>  	fb_dealloc_cmap(&info->cmap);
>  	/* XXX unshare VGA regions */
> --
> 1.7.1



^ permalink raw reply

* [PATCH] video: remove unused variable "dev" in vga16fb_destroy()
From: Yijing Wang @ 2013-07-15  6:29 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen
  Cc: linux-kernel, linux-fbdev, Hanjun Guo, jiang.liu, Yijing Wang,
	Jingoo Han

Delete unused variable "dev" to fix build warning in
drivers/video/vga16fb.c

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Cc: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/vga16fb.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 830ded4..2827333 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -1265,7 +1265,6 @@ static void vga16fb_imageblit(struct fb_info *info, const struct fb_image *image
 
 static void vga16fb_destroy(struct fb_info *info)
 {
-	struct platform_device *dev = container_of(info->device, struct platform_device, dev);
 	iounmap(info->screen_base);
 	fb_dealloc_cmap(&info->cmap);
 	/* XXX unshare VGA regions */
-- 
1.7.1



^ permalink raw reply related

* Re: [PATCH] video: nuc900fb: fix to pass correct device identity to free_irq()
From: Wan ZongShun @ 2013-07-15  2:41 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAPgLHd_mMOOeMecVJbTQjiK+xJD+-8jvgH6oAFqTHK_uSpWOJw@mail.gmail.com>

2013/7/12 Wei Yongjun <weiyj.lk@gmail.com>:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> free_irq() expects the same device identity that was passed to
> corresponding request_irq(), otherwise the IRQ is not freed.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Sorry, repost.

Hi Yongjun,

(1)  ret = request_irq(irq, nuc900fb_irqhandler, 0,
              pdev->name, fbinfo);

(2)  static irqreturn_t nuc900fb_irqhandler(int irq, void *dev_id)
{
    struct nuc900fb_info *fbi = dev_id;
    void __iomem *regs = fbi->io;

From (1) and (2), we should consider the wrong with passing 'fbinfo'
to 'nuc900fb_irqhandler', it should pass the 'fbi' instead as
following codes:

ret = request_irq(irq, nuc900fb_irqhandler, 0,
              pdev->name, fbi);

So if we fix this wrong,' free_irq(irq, fbi);' would be ok, right?

Thanks!
Vincent Wan.


> ---
>  drivers/video/nuc900fb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
> index 8c527e5..ebd5501 100644
> --- a/drivers/video/nuc900fb.c
> +++ b/drivers/video/nuc900fb.c
> @@ -661,7 +661,7 @@ release_clock:
>         clk_disable(fbi->clk);
>         clk_put(fbi->clk);
>  release_irq:
> -       free_irq(irq, fbi);
> +       free_irq(irq, fbinfo);
>  release_regs:
>         iounmap(fbi->io);
>  release_mem_region:
> @@ -702,7 +702,7 @@ static int nuc900fb_remove(struct platform_device *pdev)
>         iounmap(fbi->io);
>
>         irq = platform_get_irq(pdev, 0);
> -       free_irq(irq, fbi);
> +       free_irq(irq, fbinfo);
>
>         release_resource(fbi->mem);
>         kfree(fbi->mem);
>



--
Wan ZongShun.
www.mcuos.com

^ permalink raw reply

* Re: [BUG] radeon: suspend resume
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-07-14 20:13 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <CAG27Bk2NzdZELTeByjH5Sj_NbB+TOhYDK66aX1-9e=W_LT39Hg@mail.gmail.com>


On Jul 14, 2013, at 8:26 PM, Sami Kerola <kerolasa@iki.fi> wrote:

> Hello,
> 
> I build from Linus's tree from point
> 
> commit 9903883f1dd6e86f286b7bfa6e4b423f98c1cd9e
> 
> a kernel which has a power management suspend/resume problem.  In short I
> do not get video back at resume, and my laptop becomes completely
> unresponsive.  I have hunch the NO_HZ has something to do with issue.

You will have to bisect and found the commit that introduce the bug

as commit 9903883f1dd6e86

    Merge tag 'dm-3.11-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-dm

    Pull device-mapper changes from Alasdair G Kergon:
     "Add a device-mapper target called dm-switch to provide a multipath
      framework for storage arrays that dynamically reconfigure their
      preferred paths for different device regions.

      Fix a bug in the verity target that prevented its use with some
      specific sizes of devices.

      Improve some locking mechanisms in the device-mapper core and bufio.

      Add Mike Snitzer as a device-mapper maintainer.

      A few more clean-ups and fixes"

is a merge about device-mapper not fbdev and even Radeon drivers

Best Regards,
J.

> 
> # zgrep ^CONFIG_NO_HZ /proc/config.gz
> CONFIG_NO_HZ_COMMON=y
> CONFIG_NO_HZ_FULL=y
> CONFIG_NO_HZ=y
> 
> The NO_HZ combined with this piece of hardware results seems to be the
> issue.
> 
> 00:01.0 VGA compatible controller: Advanced Micro Devices, Inc.
> [AMD/ATI] Wrestler [Radeon HD 7310] (prog-if 00 [VGA controller])
>        Subsystem: Toshiba America Info Systems Device fb33
>        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
> ParErr- Stepping- SERR- FastB2B- DisINTx+
>        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSELúst >TAbort-
> <TAbort- <MAbort- >SERR- <PERR- INTx-
>        Latency: 0, Cache Line Size: 64 bytes
>        Interrupt: pin A routed to IRQ 49
>        Region 0: Memory at e0000000 (32-bit, prefetchable) [size%6M]
>        Region 1: I/O ports at 5000 [size%6]
>        Region 2: Memory at f0400000 (32-bit, non-prefetchable) [size%6K]
>        Expansion ROM at <unassigned> [disabled]
>        Capabilities: [50] Power Management version 3
>                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA
> PME(D0-,D1-,D2-,D3hot-,D3cold-)
>                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
>        Capabilities: [58] Express (v2) Root Complex Integrated Endpoint, MSI 00
>                DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s
> <4us, L1 unlimited
>                        ExtTag+ RBE+ FLReset-
>                DevCtl: Report errors: Correctable- Non-Fatal- Fatal-
> Unsupported-
>                        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
>                        MaxPayload 128 bytes, MaxReadReq 128 bytes
>                DevSta: CorrErr- UncorrErr+ FatalErr- UnsuppReq+
> AuxPwr- TransPend-
>                LnkCap: Port #0, Speed unknown, Width x0, ASPM
> unknown, Latency L0 <64ns, L1 <1us
>                        ClockPM- Surprise- LLActRep- BwNot-
>                LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
>                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
>                LnkSta: Speed unknown, Width x0, TrErr- Train-
> SlotClk- DLActive- BWMgmt- ABWMgmt-
>                DevCap2: Completion Timeout: Not Supported,
> TimeoutDis-, LTR-, OBFF Not Supported
>                DevCtl2: Completion Timeout: 50us to 50ms,
> TimeoutDis-, LTR-, OBFF Disabled
>                LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
>                         Transmit Margin: Normal Operating Range,
> EnterModifiedCompliance- ComplianceSOS-
>                         Compliance De-emphasis: -6dB
>                LnkSta2: Current De-emphasis Level: -6dB,
> EqualizationComplete-, EqualizationPhase1-
>                         EqualizationPhase2-, EqualizationPhase3-,
> LinkEqualizationRequest-
>        Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
>                Address: 00000000fee0300c  Data: 4152
>        Capabilities: [100 v1] Vendor Specific Information: ID\001
> Rev=1 Len\x010 <?>
>        Kernel driver in use: radeon
>        Kernel modules: radeon
> 
> 
> Here are some message from journalctl from the time suspend begun, and
> resume failed.  To me the two lines with '*ERROR* radeon' does not look
> right.  The messages are result of 'echo devices > /sys/power/pm_test'.
> 
> 
> Jul 14 12:51:12 kerolasa-home kernel: PM: Hibernation mode set to 'platform'
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
> (ffff8800d2c09010): kobject_add_internal: parent: 'vc', set: 'devices'
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
> (ffff8800d2c09010): kobject_uevent_env
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
> (ffff8800d2c09010): fill_kobj_path: path = '/devices/virtual/vc/vcs63'
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
> (ffff8800d2c08010): kobject_add_internal: parent: 'vc', set: 'devices'
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
> (ffff8800d2c08010): kobject_uevent_env
> Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
> (ffff8800d2c08010): fill_kobj_path: path > '/devices/virtual/vc/vcsa63'
> Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0x0009f000-0x000fffff]
> Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0xdf6bf000-0xdfbfefff]
> Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0xdfc00000-0xffffffff]
> Jul 14 12:51:12 kerolasa-home kernel: PM: Basic memory bitmaps created
> Jul 14 12:51:31 kerolasa-home kernel: PM: Syncing filesystems ... done.
> Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: carrier lost
> Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting host route
> to 192.168.1.2 via 127.0.0.1
> Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting route to
> 192.168.1.0/24
> Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting default
> route via 192.168.1.1
> Jul 14 12:51:31 kerolasa-home kernel: Freezing user space processes
> ... (elapsed 0.001 seconds) done.
> Jul 14 12:51:31 kerolasa-home kernel: PM: Preallocating image
> memory... done (allocated 187558 pages)
> Jul 14 12:51:31 kerolasa-home kernel: PM: Allocated 750232 kbytes in
> 0.32 seconds (2344.47 MB/s)
> Jul 14 12:51:31 kerolasa-home kernel: Freezing remaining freezable
> tasks ... (elapsed 0.001 seconds) done.
> Jul 14 12:51:31 kerolasa-home kernel: Suspending console(s) (use
> no_console_suspend to debug)
> Jul 14 12:51:31 kerolasa-home kernel: wlan0: deauthenticating from
> 20:f3:a3:39:74:56 by local choice (reason=3)
> Jul 14 12:51:31 kerolasa-home kernel: cfg80211: Calling CRDA to update
> world regulatory domain
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'regulatory.0'
> (ffff8800d98bc820): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'regulatory.0'
> (ffff8800d98bc820): fill_kobj_path: path > '/devices/platform/regulatory.0'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
> (ffff8800d8c97888): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
> (ffff8800d8c97888): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '50': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c974d8): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c974d8): auto cleanup kobject_del
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c974d8): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c974d8): kset_release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
> (ffff8800d8c97ac8): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
> (ffff8800d8c97ac8): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '49': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c97b98): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c97b98): auto cleanup kobject_del
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c97b98): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d8c97b98): kset_release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
> driver on ring 5 use gpu addr 0x0000000000177118 and cpu addr
> 0xffffc90004ab2118
> Jul 14 12:51:31 kerolasa-home kernel: PM: freeze of devices complete
> after 631.979 msecs
> Jul 14 12:51:31 kerolasa-home kernel: hibernation debug: Waiting for 5 seconds.
> Jul 14 12:51:31 kerolasa-home kernel: usb usb1: root hub lost power or was reset
> Jul 14 12:51:31 kerolasa-home kernel: usb usb2: root hub lost power or was reset
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
> (ffff880106a39dc8): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
> (ffff880106a39dc8): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '43': free name
> Jul 14 12:51:31 kerolasa-home kernel: usb usb4: root hub lost power or was reset
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
> (ffff880106a39d08): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
> (ffff880106a39d08): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '44': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
> (ffff880106a39c48): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
> (ffff880106a39c48): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '45': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39b98): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39b98): auto cleanup kobject_del
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39b98): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39b98): kset_release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
> Jul 14 12:51:31 kerolasa-home kernel: usb usb5: root hub lost power or was reset
> Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 43
> for MSI/MSI-X
> Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 44
> for MSI/MSI-X
> Jul 14 12:51:31 kerolasa-home kernel: rtlwifi: wireless switch is on
> Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 45
> for MSI/MSI-X
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d9012118): kobject_add_internal: parent: '0000:00:10.0', set:
> '<NULL>'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d9012118): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d9012118): kobject_uevent_env: filter function caused the
> event to drop!
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
> (ffff8800d90121c8): kobject_add_internal: parent: 'msi_irqs', set:
> 'msi_irqs'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
> (ffff8800d9012e88): kobject_add_internal: parent: 'msi_irqs', set:
> 'msi_irqs'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
> (ffff8800d9012c48): kobject_add_internal: parent: 'msi_irqs', set:
> 'msi_irqs'
> Jul 14 12:51:31 kerolasa-home kernel: [drm] PCIE GART of 512M enabled
> (table at 0x0000000000145000).
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: WB enabled
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
> driver on ring 0 use gpu addr 0x0000000018000c00 and cpu addr
> 0xffff8800d98a2c00
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
> driver on ring 3 use gpu addr 0x0000000018000c0c and cpu addr
> 0xffff8800d98a2c0c
> Jul 14 12:51:31 kerolasa-home kernel: snd_hda_intel 0000:00:14.2: irq
> 49 for MSI/MSI-X
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d92b5718): kobject_add_internal: parent: '0000:00:14.2', set:
> '<NULL>'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d92b5718): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff8800d92b5718): kobject_uevent_env: filter function caused the
> event to drop!
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
> (ffff8800d92b5648): kobject_add_internal: parent: 'msi_irqs', set:
> 'msi_irqs'
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
> driver on ring 5 use gpu addr 0x00000000007ca118 and cpu addr
> 0xffffc90005432118
> Jul 14 12:51:31 kerolasa-home kernel: snd_hda_intel 0000:00:01.1: irq
> 50 for MSI/MSI-X
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39658): kobject_add_internal: parent: '0000:00:01.1', set:
> '<NULL>'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39658): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
> (ffff880106a39658): kobject_uevent_env: filter function caused the
> event to drop!
> Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
> (ffff8800d9012a08): kobject_add_internal: parent: 'msi_irqs', set:
> 'msi_irqs'
> Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 0 succeeded in 1 usecs
> Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 3 succeeded in 1 usecs
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
> (ffff8800da197198): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
> (ffff8800da197198): fill_kobj_path: path > '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-LVDS-1/radeon_bl0'
> Jul 14 12:51:31 kerolasa-home kernel: ACPI: \_SB_.PCI0:
> ACPI_NOTIFY_BUS_CHECK event: unsupported
> Jul 14 12:51:31 kerolasa-home kernel: ACPI: \_SB_.PCI0: Bus check
> notify on _handle_hotplug_event_root
> Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 5 succeeded in 1 usecs
> Jul 14 12:51:31 kerolasa-home kernel: [drm] UVD initialized successfully.
> Jul 14 12:51:31 kerolasa-home kernel: [drm] ib test on ring 0
> succeeded in 0 usecs
> Jul 14 12:51:31 kerolasa-home kernel: [drm] ib test on ring 3
> succeeded in 1 usecs
> Jul 14 12:51:31 kerolasa-home kernel: usb 5-4: reset high-speed USB
> device number 3 using ehci-pci
> Jul 14 12:51:31 kerolasa-home kernel: ata1: SATA link up 3.0 Gbps
> (SStatus 123 SControl 300)
> Jul 14 12:51:31 kerolasa-home kernel: ata2: SATA link up 1.5 Gbps
> (SStatus 113 SControl 300)
> Jul 14 12:51:31 kerolasa-home kernel: ata2.00: configured for UDMA/100
> Jul 14 12:51:31 kerolasa-home kernel: ata1.00: configured for UDMA/100
> Jul 14 12:51:31 kerolasa-home kernel: sd 0:0:0:0: [sda] Starting disk
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
> CP stall for more than 10000msec
> Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
> (waiting for 0x0000000000000004 last fence id 0x0000000000000002)
> Jul 14 12:51:31 kerolasa-home kernel: [drm:r600_uvd_ib_test] *ERROR*
> radeon: fence wait failed (-35).
> Jul 14 12:51:31 kerolasa-home kernel: [drm:radeon_ib_ring_tests]
> *ERROR* radeon: failed testing IB on ring 5 (-35).
> Jul 14 12:51:31 kerolasa-home kernel: PM: restore of devices complete
> after 11949.096 msecs
> Jul 14 12:51:31 kerolasa-home kernel: PM: Image restored successfully.
> Jul 14 12:51:31 kerolasa-home kernel: Restarting tasks ... done.
> Jul 14 12:51:31 kerolasa-home kernel: PM: Basic memory bitmaps freed
> Jul 14 12:51:31 kerolasa-home kernel: video LNXVIDEO:00: Restoring
> backlight state
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
> (ffff8800da197198): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
> (ffff8800da197198): fill_kobj_path: path > '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-LVDS-1/radeon_bl0'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800db3b6010): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800db3b6010): fill_kobj_path: path > '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
> (ffff880106aba8a0): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
> (ffff880106aba8a0): auto cleanup kobject_del
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
> (ffff880106aba8a0): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800db3b6010): kobject_cleanup
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800db3b6010): calling ktype release
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0': free name
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
> (ffff8800d924d180): kobject_add_internal: parent: 'PNP0C0A:00', set:
> '(null)'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800d2c0e010): kobject_add_internal: parent: 'power_supply', set:
> 'devices'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800d2c0e010): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800d2c0e010): fill_kobj_path: path > '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800d2c0e010): kobject_uevent_env
> Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
> (ffff8800d2c0e010): fill_kobj_path: path > '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
> Jul 14 12:51:31 kerolasa-home kernel: PM: Hibernation mode set to 'platform'
> Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0x0009f000-0x000fffff]
> Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0xdf6bf000-0xdfbfefff]
> Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
> 0xdfc00000-0xffffffff]
> Jul 14 12:51:31 kerolasa-home kernel: PM: Basic memory bitmaps created
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: authenticate with 20:f3:a3:39:74:56
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: send auth to
> 20:f3:a3:39:74:56 (try 1/3)
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: authenticated
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: associate with
> 20:f3:a3:39:74:56 (try 1/3)
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: RX AssocResp from
> 20:f3:a3:39:74:56 (capab=0x411 status=0 aid=1)
> Jul 14 12:51:32 kerolasa-home kernel: wlan0: associated
> Jul 14 12:51:32 kerolasa-home dhcpcd[451]: wlan0: carrier acquired
> 
> Let me know if more debug information or output is needed.
> 
> --
> Sami Kerola
> http://www.iki.fi/kerolasa/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply

* [BUG] radeon: suspend resume
From: Sami Kerola @ 2013-07-14 12:26 UTC (permalink / raw)
  To: linux-fbdev

Hello,

I build from Linus's tree from point

commit 9903883f1dd6e86f286b7bfa6e4b423f98c1cd9e

a kernel which has a power management suspend/resume problem.  In short I
do not get video back at resume, and my laptop becomes completely
unresponsive.  I have hunch the NO_HZ has something to do with issue.

# zgrep ^CONFIG_NO_HZ /proc/config.gz
CONFIG_NO_HZ_COMMON=y
CONFIG_NO_HZ_FULL=y
CONFIG_NO_HZ=y

The NO_HZ combined with this piece of hardware results seems to be the
issue.

00:01.0 VGA compatible controller: Advanced Micro Devices, Inc.
[AMD/ATI] Wrestler [Radeon HD 7310] (prog-if 00 [VGA controller])
        Subsystem: Toshiba America Info Systems Device fb33
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSELúst >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 49
        Region 0: Memory at e0000000 (32-bit, prefetchable) [size%6M]
        Region 1: I/O ports at 5000 [size%6]
        Region 2: Memory at f0400000 (32-bit, non-prefetchable) [size%6K]
        Expansion ROM at <unassigned> [disabled]
        Capabilities: [50] Power Management version 3
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA
PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [58] Express (v2) Root Complex Integrated Endpoint, MSI 00
                DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s
<4us, L1 unlimited
                        ExtTag+ RBE+ FLReset-
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal-
Unsupported-
                        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 128 bytes, MaxReadReq 128 bytes
                DevSta: CorrErr- UncorrErr+ FatalErr- UnsuppReq+
AuxPwr- TransPend-
                LnkCap: Port #0, Speed unknown, Width x0, ASPM
unknown, Latency L0 <64ns, L1 <1us
                        ClockPM- Surprise- LLActRep- BwNot-
                LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed unknown, Width x0, TrErr- Train-
SlotClk- DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported,
TimeoutDis-, LTR-, OBFF Not Supported
                DevCtl2: Completion Timeout: 50us to 50ms,
TimeoutDis-, LTR-, OBFF Disabled
                LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
                         Transmit Margin: Normal Operating Range,
EnterModifiedCompliance- ComplianceSOS-
                         Compliance De-emphasis: -6dB
                LnkSta2: Current De-emphasis Level: -6dB,
EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-,
LinkEqualizationRequest-
        Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee0300c  Data: 4152
        Capabilities: [100 v1] Vendor Specific Information: ID\001
Rev=1 Len\x010 <?>
        Kernel driver in use: radeon
        Kernel modules: radeon


Here are some message from journalctl from the time suspend begun, and
resume failed.  To me the two lines with '*ERROR* radeon' does not look
right.  The messages are result of 'echo devices > /sys/power/pm_test'.


Jul 14 12:51:12 kerolasa-home kernel: PM: Hibernation mode set to 'platform'
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
(ffff8800d2c09010): kobject_add_internal: parent: 'vc', set: 'devices'
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
(ffff8800d2c09010): kobject_uevent_env
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcs63'
(ffff8800d2c09010): fill_kobj_path: path = '/devices/virtual/vc/vcs63'
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
(ffff8800d2c08010): kobject_add_internal: parent: 'vc', set: 'devices'
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
(ffff8800d2c08010): kobject_uevent_env
Jul 14 12:51:12 kerolasa-home kernel: kobject: 'vcsa63'
(ffff8800d2c08010): fill_kobj_path: path '/devices/virtual/vc/vcsa63'
Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
0x0009f000-0x000fffff]
Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
0xdf6bf000-0xdfbfefff]
Jul 14 12:51:12 kerolasa-home kernel: PM: Marking nosave pages: [mem
0xdfc00000-0xffffffff]
Jul 14 12:51:12 kerolasa-home kernel: PM: Basic memory bitmaps created
Jul 14 12:51:31 kerolasa-home kernel: PM: Syncing filesystems ... done.
Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: carrier lost
Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting host route
to 192.168.1.2 via 127.0.0.1
Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting route to
192.168.1.0/24
Jul 14 12:51:31 kerolasa-home dhcpcd[451]: wlan0: deleting default
route via 192.168.1.1
Jul 14 12:51:31 kerolasa-home kernel: Freezing user space processes
... (elapsed 0.001 seconds) done.
Jul 14 12:51:31 kerolasa-home kernel: PM: Preallocating image
memory... done (allocated 187558 pages)
Jul 14 12:51:31 kerolasa-home kernel: PM: Allocated 750232 kbytes in
0.32 seconds (2344.47 MB/s)
Jul 14 12:51:31 kerolasa-home kernel: Freezing remaining freezable
tasks ... (elapsed 0.001 seconds) done.
Jul 14 12:51:31 kerolasa-home kernel: Suspending console(s) (use
no_console_suspend to debug)
Jul 14 12:51:31 kerolasa-home kernel: wlan0: deauthenticating from
20:f3:a3:39:74:56 by local choice (reason=3)
Jul 14 12:51:31 kerolasa-home kernel: cfg80211: Calling CRDA to update
world regulatory domain
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'regulatory.0'
(ffff8800d98bc820): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'regulatory.0'
(ffff8800d98bc820): fill_kobj_path: path '/devices/platform/regulatory.0'
Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
(ffff8800d8c97888): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
(ffff8800d8c97888): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: '50': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c974d8): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c974d8): auto cleanup kobject_del
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c974d8): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c974d8): kset_release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
(ffff8800d8c97ac8): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
(ffff8800d8c97ac8): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: '49': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c97b98): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c97b98): auto cleanup kobject_del
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c97b98): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d8c97b98): kset_release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
driver on ring 5 use gpu addr 0x0000000000177118 and cpu addr
0xffffc90004ab2118
Jul 14 12:51:31 kerolasa-home kernel: PM: freeze of devices complete
after 631.979 msecs
Jul 14 12:51:31 kerolasa-home kernel: hibernation debug: Waiting for 5 seconds.
Jul 14 12:51:31 kerolasa-home kernel: usb usb1: root hub lost power or was reset
Jul 14 12:51:31 kerolasa-home kernel: usb usb2: root hub lost power or was reset
Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
(ffff880106a39dc8): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
(ffff880106a39dc8): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: '43': free name
Jul 14 12:51:31 kerolasa-home kernel: usb usb4: root hub lost power or was reset
Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
(ffff880106a39d08): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
(ffff880106a39d08): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: '44': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
(ffff880106a39c48): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
(ffff880106a39c48): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: '45': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39b98): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39b98): auto cleanup kobject_del
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39b98): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39b98): kset_release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs': free name
Jul 14 12:51:31 kerolasa-home kernel: usb usb5: root hub lost power or was reset
Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 43
for MSI/MSI-X
Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 44
for MSI/MSI-X
Jul 14 12:51:31 kerolasa-home kernel: rtlwifi: wireless switch is on
Jul 14 12:51:31 kerolasa-home kernel: xhci_hcd 0000:00:10.0: irq 45
for MSI/MSI-X
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d9012118): kobject_add_internal: parent: '0000:00:10.0', set:
'<NULL>'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d9012118): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d9012118): kobject_uevent_env: filter function caused the
event to drop!
Jul 14 12:51:31 kerolasa-home kernel: kobject: '43'
(ffff8800d90121c8): kobject_add_internal: parent: 'msi_irqs', set:
'msi_irqs'
Jul 14 12:51:31 kerolasa-home kernel: kobject: '44'
(ffff8800d9012e88): kobject_add_internal: parent: 'msi_irqs', set:
'msi_irqs'
Jul 14 12:51:31 kerolasa-home kernel: kobject: '45'
(ffff8800d9012c48): kobject_add_internal: parent: 'msi_irqs', set:
'msi_irqs'
Jul 14 12:51:31 kerolasa-home kernel: [drm] PCIE GART of 512M enabled
(table at 0x0000000000145000).
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: WB enabled
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
driver on ring 0 use gpu addr 0x0000000018000c00 and cpu addr
0xffff8800d98a2c00
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
driver on ring 3 use gpu addr 0x0000000018000c0c and cpu addr
0xffff8800d98a2c0c
Jul 14 12:51:31 kerolasa-home kernel: snd_hda_intel 0000:00:14.2: irq
49 for MSI/MSI-X
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d92b5718): kobject_add_internal: parent: '0000:00:14.2', set:
'<NULL>'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d92b5718): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff8800d92b5718): kobject_uevent_env: filter function caused the
event to drop!
Jul 14 12:51:31 kerolasa-home kernel: kobject: '49'
(ffff8800d92b5648): kobject_add_internal: parent: 'msi_irqs', set:
'msi_irqs'
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: fence
driver on ring 5 use gpu addr 0x00000000007ca118 and cpu addr
0xffffc90005432118
Jul 14 12:51:31 kerolasa-home kernel: snd_hda_intel 0000:00:01.1: irq
50 for MSI/MSI-X
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39658): kobject_add_internal: parent: '0000:00:01.1', set:
'<NULL>'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39658): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'msi_irqs'
(ffff880106a39658): kobject_uevent_env: filter function caused the
event to drop!
Jul 14 12:51:31 kerolasa-home kernel: kobject: '50'
(ffff8800d9012a08): kobject_add_internal: parent: 'msi_irqs', set:
'msi_irqs'
Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 0 succeeded in 1 usecs
Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 3 succeeded in 1 usecs
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
(ffff8800da197198): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
(ffff8800da197198): fill_kobj_path: path '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-LVDS-1/radeon_bl0'
Jul 14 12:51:31 kerolasa-home kernel: ACPI: \_SB_.PCI0:
ACPI_NOTIFY_BUS_CHECK event: unsupported
Jul 14 12:51:31 kerolasa-home kernel: ACPI: \_SB_.PCI0: Bus check
notify on _handle_hotplug_event_root
Jul 14 12:51:31 kerolasa-home kernel: [drm] ring test on 5 succeeded in 1 usecs
Jul 14 12:51:31 kerolasa-home kernel: [drm] UVD initialized successfully.
Jul 14 12:51:31 kerolasa-home kernel: [drm] ib test on ring 0
succeeded in 0 usecs
Jul 14 12:51:31 kerolasa-home kernel: [drm] ib test on ring 3
succeeded in 1 usecs
Jul 14 12:51:31 kerolasa-home kernel: usb 5-4: reset high-speed USB
device number 3 using ehci-pci
Jul 14 12:51:31 kerolasa-home kernel: ata1: SATA link up 3.0 Gbps
(SStatus 123 SControl 300)
Jul 14 12:51:31 kerolasa-home kernel: ata2: SATA link up 1.5 Gbps
(SStatus 113 SControl 300)
Jul 14 12:51:31 kerolasa-home kernel: ata2.00: configured for UDMA/100
Jul 14 12:51:31 kerolasa-home kernel: ata1.00: configured for UDMA/100
Jul 14 12:51:31 kerolasa-home kernel: sd 0:0:0:0: [sda] Starting disk
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
CP stall for more than 10000msec
Jul 14 12:51:31 kerolasa-home kernel: radeon 0000:00:01.0: GPU lockup
(waiting for 0x0000000000000004 last fence id 0x0000000000000002)
Jul 14 12:51:31 kerolasa-home kernel: [drm:r600_uvd_ib_test] *ERROR*
radeon: fence wait failed (-35).
Jul 14 12:51:31 kerolasa-home kernel: [drm:radeon_ib_ring_tests]
*ERROR* radeon: failed testing IB on ring 5 (-35).
Jul 14 12:51:31 kerolasa-home kernel: PM: restore of devices complete
after 11949.096 msecs
Jul 14 12:51:31 kerolasa-home kernel: PM: Image restored successfully.
Jul 14 12:51:31 kerolasa-home kernel: Restarting tasks ... done.
Jul 14 12:51:31 kerolasa-home kernel: PM: Basic memory bitmaps freed
Jul 14 12:51:31 kerolasa-home kernel: video LNXVIDEO:00: Restoring
backlight state
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
(ffff8800da197198): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'radeon_bl0'
(ffff8800da197198): fill_kobj_path: path '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-LVDS-1/radeon_bl0'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800db3b6010): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800db3b6010): fill_kobj_path: path '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
(ffff880106aba8a0): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
(ffff880106aba8a0): auto cleanup kobject_del
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
(ffff880106aba8a0): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800db3b6010): kobject_cleanup
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800db3b6010): calling ktype release
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0': free name
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'power_supply'
(ffff8800d924d180): kobject_add_internal: parent: 'PNP0C0A:00', set:
'(null)'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800d2c0e010): kobject_add_internal: parent: 'power_supply', set:
'devices'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800d2c0e010): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800d2c0e010): fill_kobj_path: path '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800d2c0e010): kobject_uevent_env
Jul 14 12:51:31 kerolasa-home kernel: kobject: 'BAT0'
(ffff8800d2c0e010): fill_kobj_path: path '/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0'
Jul 14 12:51:31 kerolasa-home kernel: PM: Hibernation mode set to 'platform'
Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
0x0009f000-0x000fffff]
Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
0xdf6bf000-0xdfbfefff]
Jul 14 12:51:31 kerolasa-home kernel: PM: Marking nosave pages: [mem
0xdfc00000-0xffffffff]
Jul 14 12:51:31 kerolasa-home kernel: PM: Basic memory bitmaps created
Jul 14 12:51:32 kerolasa-home kernel: wlan0: authenticate with 20:f3:a3:39:74:56
Jul 14 12:51:32 kerolasa-home kernel: wlan0: send auth to
20:f3:a3:39:74:56 (try 1/3)
Jul 14 12:51:32 kerolasa-home kernel: wlan0: authenticated
Jul 14 12:51:32 kerolasa-home kernel: wlan0: associate with
20:f3:a3:39:74:56 (try 1/3)
Jul 14 12:51:32 kerolasa-home kernel: wlan0: RX AssocResp from
20:f3:a3:39:74:56 (capab=0x411 status=0 aid=1)
Jul 14 12:51:32 kerolasa-home kernel: wlan0: associated
Jul 14 12:51:32 kerolasa-home dhcpcd[451]: wlan0: carrier acquired

Let me know if more debug information or output is needed.

--
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply

* Re: [V3 0/7] Enhance mmp display driver
From: jett zhou @ 2013-07-14  3:00 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20130709133918.GC18477@ns203013.ovh.net>

Hi Jean
     As I checked the for-next branch, found patch4 and patch5 are
already applied.
     As checked on my side,  only apply patch1~patch3 and
patch6~patch7 is ok, so think you can apply them except for patch4/5.
     If there is still problem, please let me know, I will check it then.
Thanks

2013/7/9 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>:
> HI,
>
>         please rebase on the for-next branch as it does not apply
>
> Best Regards,
> J.
> On 19:27 Thu 27 Jun     , Jett.Zhou wrote:
>> Changelog:
>> 1 Add more comments for the mmp_display rbswap usage
>> according to Daniel's comments;
>> 2 Add fix patch for ttc_dkb on rbswap;
>> 3 Add more comments on the pitch usage and definition;
>> 4 Combine the modification on pitch of graphic and video layer
>> in one patch.
>>
>> Guoqing Li (2):
>>   video: mmp: rb swap setting update for mmp display
>>   video: mmp: optimize some register setting code
>>
>> Jett.Zhou (1):
>>   ARM: mmp: remove the legacy rbswap setting for ttc_dkb platform
>>
>> Jing Xiang (4):
>>   video: mmp: fix graphics/video layer enable/mask issue
>>   video: mmp: fix memcpy wrong size for mmp_addr issue
>>   video: mmp: calculate pitch value when fb set win
>>   video: mmp: add pitch info in mmp_win structure
>>
>>  arch/arm/mach-mmp/ttc_dkb.c     |    4 +-
>>  drivers/video/mmp/fb/mmpfb.c    |   34 +++++++++++------
>>  drivers/video/mmp/hw/mmp_ctrl.c |   79 ++++++++++++++++++++++-----------------
>>  drivers/video/mmp/hw/mmp_ctrl.h |    5 ++
>>  include/video/mmp_disp.h        |    6 +++
>>  5 files changed, 79 insertions(+), 49 deletions(-)
>>



--

----------------------------------
Best Regards
Jett Zhou

^ permalink raw reply

* Re: [PATCH] omapfb: In omapfb_probe return -EPROBE_DEFER when display driver is not loaded yet
From: Pavel Machek @ 2013-07-13 19:56 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard, linux-omap,
	linux-fbdev, linux-kernel, Aaro Koskinen, Tony Lindgren
In-Reply-To: <20130713182733.GA25019@amd.pavel.ucw.cz>

Hi!


> One thing I'd like to know: how do you configure kernel to get output
> on qemu? I was doing CONFIG_DEBUG_LL with specific uart, but that
> needed patching the kernel, you apparently have something more
> clever.

Aha, normal console=ttyO2 option. Got it now :-).

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* Re: [PATCH] omapfb: In omapfb_probe return -EPROBE_DEFER when display driver is not loaded yet
From: Pavel Machek @ 2013-07-13 18:27 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard, linux-omap,
	linux-fbdev, linux-kernel, Aaro Koskinen, Tony Lindgren
In-Reply-To: <1373461739-10168-1-git-send-email-pali.rohar@gmail.com>

On Wed 2013-07-10 15:08:59, Pali Rohár wrote:
> * On RX-51 probing for acx565akm driver is later then for omapfb which cause that omapfb probe fail and framebuffer is not working
> * EPROBE_DEFER causing that kernel try to probe for omapfb later again which fixing this problem
> 
> * Without this patch display on Nokia RX-51 (N900) phone not working
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

Tested-by: Pavel Machek <pavel@ucw.cz>

(Actually, do we know which commit broke the ordering? We may want to
simply revert that one...)

BTW I'm currently trying to set-up automated scripts for n900/qemu
testing. I guess I'll try to run them on mainline kernel to catch such
stuff earlier.

One thing I'd like to know: how do you configure kernel to get output
on qemu? I was doing CONFIG_DEBUG_LL with specific uart, but that
needed patching the kernel, you apparently have something more clever.

I tried doing:

# CONFIG_DEBUG_LL is not set
CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"

but no output on console...

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* Re: [patch -next] fb: fix recent breakage in correct_chipset()
From: Randy Dunlap @ 2013-07-12 20:11 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <20130702062821.GC24410@elgon.mountain>

On 07/01/13 23:28, Dan Carpenter wrote:
> The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> the indexes off by one.  This patch reverts it and casts the
> ARRAY_SIZE() to int to silence the build warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Tomi,

My incorrect patch has been merged into mainline.
Please merge Dan's fix for it instead.

Thanks.

> diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> index a89c15d..9b0f12c 100644
> --- a/drivers/video/aty/atyfb_base.c
> +++ b/drivers/video/aty/atyfb_base.c
> @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
>  	const char *name;
>  	int i;
>  
> -	for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> -		if (par->pci_id = aty_chips[i - 1].pci_id)
> +	for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> +		if (par->pci_id = aty_chips[i].pci_id)
>  			break;
>  
>  	if (i < 0)
> 


-- 
~Randy

^ permalink raw reply

* [PATCH] matroxfb: replace kmalloc and memset with kzalloc.
From: Alexandru Juncu @ 2013-07-12 14:00 UTC (permalink / raw)
  To: plagnioj; +Cc: tomi.valkeinen, alexj, linux-fbdev, linux-kernel

Signed-off-by: Alexandru Juncu <alexj@rosedu.org>
---
 drivers/video/matrox/matroxfb_base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 401a56e..2456529 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -2029,10 +2029,9 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
 		return -1;
 	}
 
-	minfo = kmalloc(sizeof(*minfo), GFP_KERNEL);
+	minfo = kzalloc(sizeof(*minfo), GFP_KERNEL);
 	if (!minfo)
 		return -1;
-	memset(minfo, 0, sizeof(*minfo));
 
 	minfo->pcidev = pdev;
 	minfo->dead = 0;
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH] video: nuc900fb: fix to pass correct device identity to free_irq()
From: Wei Yongjun @ 2013-07-12 13:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

free_irq() expects the same device identity that was passed to
corresponding request_irq(), otherwise the IRQ is not freed.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/video/nuc900fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
index 8c527e5..ebd5501 100644
--- a/drivers/video/nuc900fb.c
+++ b/drivers/video/nuc900fb.c
@@ -661,7 +661,7 @@ release_clock:
 	clk_disable(fbi->clk);
 	clk_put(fbi->clk);
 release_irq:
-	free_irq(irq, fbi);
+	free_irq(irq, fbinfo);
 release_regs:
 	iounmap(fbi->io);
 release_mem_region:
@@ -702,7 +702,7 @@ static int nuc900fb_remove(struct platform_device *pdev)
 	iounmap(fbi->io);
 
 	irq = platform_get_irq(pdev, 0);
-	free_irq(irq, fbi);
+	free_irq(irq, fbinfo);
 
 	release_resource(fbi->mem);
 	kfree(fbi->mem);


^ permalink raw reply related

* [PATCH] video: sh7760fb: fix to pass correct device identity to free_irq()
From: Wei Yongjun @ 2013-07-12 13:20 UTC (permalink / raw)
  To: linux-fbdev

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

free_irq() expects the same device identity that was passed to
corresponding request_irq(), otherwise the IRQ is not freed.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/video/sh7760fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index a8c6c43..1265b25 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -567,7 +567,7 @@ static int sh7760fb_remove(struct platform_device *dev)
 	fb_dealloc_cmap(&info->cmap);
 	sh7760fb_free_mem(info);
 	if (par->irq >= 0)
-		free_irq(par->irq, par);
+		free_irq(par->irq, &par->vsync);
 	iounmap(par->base);
 	release_mem_region(par->ioarea->start, resource_size(par->ioarea));
 	framebuffer_release(info);


^ permalink raw reply related

* Re: [PATCH RESEND] video: mxsfb: fix color settings for 18bit data bus and 32bpp
From: maxime.ripard @ 2013-07-12 12:30 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20130703085505.GG2969@lukather>

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

On Wed, Jul 03, 2013 at 10:55:05AM +0200, maxime.ripard@free-electrons.com wrote:
> Hi Jean-Christophe,
> 
> On Tue, Jun 18, 2013 at 10:44:17AM +0200, Hector Palacios wrote:
> > For a combination of 18bit LCD data bus width and a color
> > mode of 32bpp, the driver was setting the color mapping to
> > rgb666, which is wrong, as the color in memory realy has an
> > rgb888 layout.
> > 
> > This patch also removes the setting of flag CTRL_DF24 that
> > makes the driver dimiss the upper 2 bits when handling 32/24bpp
> > colors in a diplay with 18bit data bus width. This flag made
> > true color images display wrong in such configurations.
> > 
> > Finally, the color mapping rgb666 has also been removed as nobody
> > is using it and high level applications like Qt5 cannot work
> > with it either.
> > 
> > Reference: https://lkml.org/lkml/2013/5/23/220
> > Signed-off-by: Hector Palacios <hector.palacios@digi.com>
> > Acked-by: Juergen Beisert <jbe@pengutronix.de>
> > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> I don't see this patch in your for-next branch.
> 
> It would be really great to have it for 3.11 if possible.
> 
> Could you take a look at this patch please?

Ping?

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] fb: backlight: HX8357: Make IM pins optionnal
From: Maxime Ripard @ 2013-07-12  9:11 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Alexandre Belloni, linux-fbdev, jimwall, brian, linux-kernel,
	Richard Purdie, Florian Tobias Schandinat
In-Reply-To: <20130625135015.GM26008@lukather>

[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]

On Tue, Jun 25, 2013 at 03:50:15PM +0200, Maxime Ripard wrote:
> > >  };
> > >  
> > >  static u8 hx8357_seq_power[] = {
> > > @@ -250,9 +251,11 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
> > >  	 * Set the interface selection pins to SPI mode, with three
> > >  	 * wires
> > >  	 */
> > > -	gpio_set_value_cansleep(lcd->im_pins[0], 1);
> > > -	gpio_set_value_cansleep(lcd->im_pins[1], 0);
> > > -	gpio_set_value_cansleep(lcd->im_pins[2], 1);
> > > +	if (lcd->use_im_pins) {
> > > +		gpio_set_value_cansleep(lcd->im_pins[0], 1);
> > > +		gpio_set_value_cansleep(lcd->im_pins[1], 0);
> > > +		gpio_set_value_cansleep(lcd->im_pins[2], 1);
> > > +	}
> > 
> > base on the dt probe you may have gpios betwee 0 to HX8357_NUM_IM_PINS
> > 
> > so this look wrong
> 
> How so?
> 
> HX8357_NUM_IM_PINS is defined to 3, the probe checks to see if we
> actually have HX8357_NUM_IM_PINS, otherwise returns an error, what is
> wrong in setting these pins here?

Ping?

I'd really like to get this merged, could you clarify what you want?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* [RFC PATCH v1 2/2] dma-buf: add lock callback for fcntl system call
From: Inki Dae @ 2013-07-12  6:12 UTC (permalink / raw)
  To: dri-devel, linux-fbdev, linux-arm-kernel, linux-media
  Cc: maarten.lankhorst, daniel, robdclark, sumit.semwal, linux,
	kyungmin.park, myungjoo.ham, yj44.cho, Inki Dae
In-Reply-To: <1373609566-10784-1-git-send-email-inki.dae@samsung.com>

This patch adds lock callback to dma buf file operations,
and this callback will be called by fcntl system call.

With this patch, fcntl system call can be used for buffer
synchronization between CPU and CPU, and CPU and DMA in user mode.

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/base/dma-buf.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 9a26981..e1b8583 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -80,9 +80,42 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
 	return dmabuf->ops->mmap(dmabuf, vma);
 }
 
+static int dma_buf_lock(struct file *file, int cmd, struct file_lock *fl)
+{
+	struct dma_buf *dmabuf;
+	unsigned int type;
+	bool wait = false;
+
+	if (!is_dma_buf_file(file))
+		return -EINVAL;
+
+	dmabuf = file->private_data;
+
+	if ((fl->fl_type & F_UNLCK) = F_UNLCK) {
+		dmabuf_sync_single_unlock(dmabuf);
+		return 0;
+	}
+
+	/* convert flock type to dmabuf sync type. */
+	if ((fl->fl_type & F_WRLCK) = F_WRLCK)
+		type = DMA_BUF_ACCESS_W;
+	else if ((fl->fl_type & F_RDLCK) = F_RDLCK)
+		type = DMA_BUF_ACCESS_R;
+	else
+		return -EINVAL;
+
+	if (fl->fl_flags & FL_SLEEP)
+		wait = true;
+
+	/* TODO. the locking to certain region should also be considered. */
+
+	return dmabuf_sync_single_lock(dmabuf, type, wait);
+}
+
 static const struct file_operations dma_buf_fops = {
 	.release	= dma_buf_release,
 	.mmap		= dma_buf_mmap_internal,
+	.lock		= dma_buf_lock,
 };
 
 /*
-- 
1.7.5.4


^ permalink raw reply related

* [RFC PATCH v5 1/2] dmabuf-sync: Introduce buffer synchronization framework
From: Inki Dae @ 2013-07-12  6:12 UTC (permalink / raw)
  To: dri-devel, linux-fbdev, linux-arm-kernel, linux-media
  Cc: maarten.lankhorst, daniel, robdclark, sumit.semwal, linux,
	kyungmin.park, myungjoo.ham, yj44.cho, Inki Dae
In-Reply-To: <1373609566-10784-1-git-send-email-inki.dae@samsung.com>

This patch adds a buffer synchronization framework based on DMA BUF[1]
and and based on ww-mutexes[2] for lock mechanism.

The purpose of this framework is to provide not only buffer access control
to CPU and DMA but also easy-to-use interfaces for device drivers and
user application. This framework can be used for all dma devices using
system memory as dma buffer, especially for most ARM based SoCs.

Changelog v5:
- Rmove a dependence on reservation_object: the reservation_object is used
  to hook up to ttm and dma-buf for easy sharing of reservations across
  devices. However, the dmabuf sync can be used for all dma devices; v4l2
  and drm based drivers, so doesn't need the reservation_object anymore.
  With regared to this, it adds 'void *sync' to dma_buf structure.
- All patches are rebased on mainline, Linux v3.10.

Changelog v4:
- Add user side interface for buffer synchronization mechanism and update
  descriptions related to the user side interface.

Changelog v3:
- remove cache operation relevant codes and update document file.

Changelog v2:
- use atomic_add_unless to avoid potential bug.
- add a macro for checking valid access type.
- code clean.

The mechanism of this framework has the following steps,
    1. Register dmabufs to a sync object - A task gets a new sync object and
    can add one or more dmabufs that the task wants to access.
    This registering should be performed when a device context or an event
    context such as a page flip event is created or before CPU accesses a shared
    buffer.

	dma_buf_sync_get(a sync object, a dmabuf);

    2. Lock a sync object - A task tries to lock all dmabufs added in its own
    sync object. Basically, the lock mechanism uses ww-mutex[1] to avoid dead
    lock issue and for race condition between CPU and CPU, CPU and DMA, and DMA
    and DMA. Taking a lock means that others cannot access all locked dmabufs
    until the task that locked the corresponding dmabufs, unlocks all the locked
    dmabufs.
    This locking should be performed before DMA or CPU accesses these dmabufs.

	dma_buf_sync_lock(a sync object);

    3. Unlock a sync object - The task unlocks all dmabufs added in its own sync
    object. The unlock means that the DMA or CPU accesses to the dmabufs have
    been completed so that others may access them.
    This unlocking should be performed after DMA or CPU has completed accesses
    to the dmabufs.

	dma_buf_sync_unlock(a sync object);

    4. Unregister one or all dmabufs from a sync object - A task unregisters
    the given dmabufs from the sync object. This means that the task dosen't
    want to lock the dmabufs.
    The unregistering should be performed after DMA or CPU has completed
    accesses to the dmabufs or when dma_buf_sync_lock() is failed.

	dma_buf_sync_put(a sync object, a dmabuf);
	dma_buf_sync_put_all(a sync object);

    The described steps may be summarized as:
	get -> lock -> CPU or DMA access to a buffer/s -> unlock -> put

This framework includes the following two features.
    1. read (shared) and write (exclusive) locks - A task is required to declare
    the access type when the task tries to register a dmabuf;
    READ, WRITE, READ DMA, or WRITE DMA.

    The below is example codes,
	struct dmabuf_sync *sync;

	sync = dmabuf_sync_init(NULL, "test sync");

	dmabuf_sync_get(sync, dmabuf, DMA_BUF_ACCESS_R);
	...

	And the below can be used as access types:
		DMA_BUF_ACCESS_R - CPU will access a buffer for read.
		DMA_BUF_ACCESS_W - CPU will access a buffer for read or write.
		DMA_BUF_ACCESS_DMA_R - DMA will access a buffer for read
		DMA_BUF_ACCESS_DMA_W - DMA will access a buffer for read or
					write.

    2. Mandatory resource releasing - a task cannot hold a lock indefinitely.
    A task may never try to unlock a buffer after taking a lock to the buffer.
    In this case, a timer handler to the corresponding sync object is called
    in five (default) seconds and then the timed-out buffer is unlocked by work
    queue handler to avoid lockups and to enforce resources of the buffer.

The below is how to use interfaces for device driver:
	1. Allocate and Initialize a sync object:
		struct dmabuf_sync *sync;

		sync = dmabuf_sync_init(NULL, "test sync");
		...

	2. Add a dmabuf to the sync object when setting up dma buffer relevant
	   registers:
		dmabuf_sync_get(sync, dmabuf, DMA_BUF_ACCESS_READ);
		...

	3. Lock all dmabufs of the sync object before DMA or CPU accesses
	   the dmabufs:
		dmabuf_sync_lock(sync);
		...

	4. Now CPU or DMA can access all dmabufs locked in step 3.

	5. Unlock all dmabufs added in a sync object after DMA or CPU access
	   to these dmabufs is completed:
		dmabuf_sync_unlock(sync);

	   And call the following functions to release all resources,
		dmabuf_sync_put_all(sync);
		dmabuf_sync_fini(sync);

	You can refer to actual example codes:
		"drm/exynos: add dmabuf sync support for g2d driver" and
		"drm/exynos: add dmabuf sync support for kms framework" from
		https://git.kernel.org/cgit/linux/kernel/git/daeinki/
		drm-exynos.git/log/?h=dmabuf-sync

And this framework includes fcntl system call[3] as interfaces exported
to user. As you know, user sees a buffer object as a dma-buf file descriptor.
So fcntl() call with the file descriptor means to lock some buffer region being
managed by the dma-buf object.

The below is how to use interfaces for user application:
	struct flock filelock;

	1. Lock a dma buf:
		filelock.l_type = F_WRLCK or F_RDLCK;

		/* lock entire region to the dma buf. */
		filelock.lwhence = SEEK_CUR;
		filelock.l_start = 0;
		filelock.l_len = 0;

		fcntl(dmabuf fd, F_SETLKW or F_SETLK, &filelock);
		...
		CPU access to the dma buf

	2. Unlock a dma buf:
		filelock.l_type = F_UNLCK;

		fcntl(dmabuf fd, F_SETLKW or F_SETLK, &filelock);

		close(dmabuf fd) call would also unlock the dma buf. And for more
		detail, please refer to [3]

References:
[1] http://lwn.net/Articles/470339/
[2] https://patchwork.kernel.org/patch/2625361/
[3] http://linux.die.net/man/2/fcntl

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/dma-buf-sync.txt |  290 +++++++++++++++++
 drivers/base/Kconfig           |    7 +
 drivers/base/Makefile          |    1 +
 drivers/base/dma-buf.c         |    4 +
 drivers/base/dmabuf-sync.c     |  674 ++++++++++++++++++++++++++++++++++++++++
 include/linux/dma-buf.h        |   16 +
 include/linux/dmabuf-sync.h    |  178 +++++++++++
 7 files changed, 1170 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/dma-buf-sync.txt
 create mode 100644 drivers/base/dmabuf-sync.c
 create mode 100644 include/linux/dmabuf-sync.h

diff --git a/Documentation/dma-buf-sync.txt b/Documentation/dma-buf-sync.txt
new file mode 100644
index 0000000..4427759
--- /dev/null
+++ b/Documentation/dma-buf-sync.txt
@@ -0,0 +1,290 @@
+                    DMA Buffer Synchronization Framework
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+                                  Inki Dae
+                      <inki dot dae at samsung dot com>
+                          <daeinki at gmail dot com>
+
+This document is a guide for device-driver writers describing the DMA buffer
+synchronization API. This document also describes how to use the API to
+use buffer synchronization mechanism between DMA and DMA, CPU and DMA, and
+CPU and CPU.
+
+The DMA Buffer synchronization API provides buffer synchronization mechanism;
+i.e., buffer access control to CPU and DMA, and easy-to-use interfaces for
+device drivers and user application. And this API can be used for all dma
+devices using system memory as dma buffer, especially for most ARM based SoCs.
+
+
+Motivation
+----------
+
+Buffer synchronization issue between DMA and DMA:
+	Sharing a buffer, a device cannot be aware of when the other device
+	will access the shared buffer: a device may access a buffer containing
+	wrong data if the device accesses the shared buffer while another
+	device is still accessing the shared buffer.
+	Therefore, a user process should have waited for the completion of DMA
+	access by another device before a device tries to access the shared
+	buffer.
+
+Buffer synchronization issue between CPU and DMA:
+	A user process should consider that when having to send a buffer, filled
+	by CPU, to a device driver for the device driver to access the buffer as
+	a input buffer while CPU and DMA are sharing the buffer.
+	This means that the user process needs to understand how the device
+	driver is worked. Hence, the conventional mechanism not only makes
+	user application complicated but also incurs performance overhead.
+
+Buffer synchronization issue between CPU and CPU:
+	In case that two processes share one buffer; shared with DMA also,
+	they may need some mechanism to allow process B to access the shared
+	buffer after the completion of CPU access by process A.
+	Therefore, process B should have waited for the completion of CPU access
+	by process A using the mechanism before trying to access the shared
+	buffer.
+
+What is the best way to solve these buffer synchronization issues?
+	We may need a common object that a device driver and a user process
+	notify the common object of when they try to access a shared buffer.
+	That way we could decide when we have to allow or not to allow for CPU
+	or DMA to access the shared buffer through the common object.
+	If so, what could become the common object? Right, that's a dma-buf[1].
+	Now we have already been using the dma-buf to share one buffer with
+	other drivers.
+
+How we can utilize multi threads for more performance?
+	DMA and CPU works individually. So CPU could perform other works while
+	DMA are performing some works, and vise versa.
+	However, in the conventional way, that is not easy to do so because
+	DMA operation is depend on CPU operation, and vice versa.
+
+	Conventional way:
+        User                                     Kernel
+        ---------------------------------------------------------------------
+        CPU writes something to src
+        send the src to driver------------------------->
+                                                 update DMA register
+        request DMA start(1)--------------------------->
+                                                 DMA start
+                <---------completion signal(2)----------
+        CPU accesses dst
+
+        (1) Request DMA start after the CPU access to src buffer is completed.
+        (2) Access dst buffer after DMA access to the dst buffer is completed.
+
+On the other hand, if there is something to control buffer access between CPU
+and DMA? The below shows that:
+
+        User(thread a)          User(thread b)            Kernel
+        ---------------------------------------------------------------------
+        send a src to driver---------------------------------->
+                                                          update DMA register
+        lock the src
+                                request DMA start(1)---------->
+        CPU acccess to src
+        unlock the src                                    lock src and dst
+                                                          DMA start
+                <-------------completion signal(2)-------------
+        lock dst                                          DMA completion
+        CPU access to dst                                 unlock src and dst
+        unlock DST
+
+        (1) Try to start DMA operation while CPU is accessing the src buffer.
+        (2) Try CPU access to dst buffer while DMA is accessing the dst buffer.
+
+	In the same way, we could reduce hand shaking overhead between
+	two processes when those processes need to share a shared buffer.
+	There may be other cases that we could reduce overhead as well.
+
+
+Basic concept
+-------------
+
+The mechanism of this framework has the following steps,
+    1. Register dmabufs to a sync object - A task gets a new sync object and
+    can add one or more dmabufs that the task wants to access.
+    This registering should be performed when a device context or an event
+    context such as a page flip event is created or before CPU accesses a shared
+    buffer.
+
+	dma_buf_sync_get(a sync object, a dmabuf);
+
+    2. Lock a sync object - A task tries to lock all dmabufs added in its own
+    sync object. Basically, the lock mechanism uses ww-mutexes[2] to avoid dead
+    lock issue and for race condition between CPU and CPU, CPU and DMA, and DMA
+    and DMA. Taking a lock means that others cannot access all locked dmabufs
+    until the task that locked the corresponding dmabufs, unlocks all the locked
+    dmabufs.
+    This locking should be performed before DMA or CPU accesses these dmabufs.
+
+	dma_buf_sync_lock(a sync object);
+
+    3. Unlock a sync object - The task unlocks all dmabufs added in its own sync
+    object. The unlock means that the DMA or CPU accesses to the dmabufs have
+    been completed so that others may access them.
+    This unlocking should be performed after DMA or CPU has completed accesses
+    to the dmabufs.
+
+	dma_buf_sync_unlock(a sync object);
+
+    4. Unregister one or all dmabufs from a sync object - A task unregisters
+    the given dmabufs from the sync object. This means that the task dosen't
+    want to lock the dmabufs.
+    The unregistering should be performed after DMA or CPU has completed
+    accesses to the dmabufs or when dma_buf_sync_lock() is failed.
+
+	dma_buf_sync_put(a sync object, a dmabuf);
+	dma_buf_sync_put_all(a sync object);
+
+    The described steps may be summarized as:
+	get -> lock -> CPU or DMA access to a buffer/s -> unlock -> put
+
+This framework includes the following two features.
+    1. read (shared) and write (exclusive) locks - A task is required to declare
+    the access type when the task tries to register a dmabuf;
+    READ, WRITE, READ DMA, or WRITE DMA.
+
+    The below is example codes,
+	struct dmabuf_sync *sync;
+
+	sync = dmabuf_sync_init(NULL, "test sync");
+
+	dmabuf_sync_get(sync, dmabuf, DMA_BUF_ACCESS_R);
+	...
+
+    2. Mandatory resource releasing - a task cannot hold a lock indefinitely.
+    A task may never try to unlock a buffer after taking a lock to the buffer.
+    In this case, a timer handler to the corresponding sync object is called
+    in five (default) seconds and then the timed-out buffer is unlocked by work
+    queue handler to avoid lockups and to enforce resources of the buffer.
+
+
+Access types
+------------
+
+DMA_BUF_ACCESS_R - CPU will access a buffer for read.
+DMA_BUF_ACCESS_W - CPU will access a buffer for read or write.
+DMA_BUF_ACCESS_DMA_R - DMA will access a buffer for read
+DMA_BUF_ACCESS_DMA_W - DMA will access a buffer for read or write.
+
+
+Generic user interfaces
+-----------------------
+
+And this framework includes fcntl system call[3] as interfaces exported
+to user. As you know, user sees a buffer object as a dma-buf file descriptor.
+So fcntl() call with the file descriptor means to lock some buffer region being
+managed by the dma-buf object.
+
+
+API set
+-------
+
+bool is_dmabuf_sync_supported(void)
+	- Check if dmabuf sync is supported or not.
+
+struct dmabuf_sync *dmabuf_sync_init(void *priv, const char *name)
+	- Allocate and initialize a new sync object. The caller can get a new
+	sync object for buffer synchronization. priv is used to set caller's
+	private data and name is the name of sync object.
+
+void dmabuf_sync_fini(struct dmabuf_sync *sync)
+	- Release all resources to the sync object.
+
+int dmabuf_sync_get(struct dmabuf_sync *sync, void *sync_buf,
+			unsigned int type)
+	- Get dmabuf sync object. Internally, this function allocates
+	a dmabuf_sync object and adds a given dmabuf to it, and also takes
+	a reference to the dmabuf. The caller can tie up multiple dmabufs
+	into one sync object by calling this function several times.
+
+void dmabuf_sync_put(struct dmabuf_sync *sync, struct dma_buf *dmabuf)
+	- Put dmabuf sync object to a given dmabuf. Internally, this function
+	removes a given dmabuf from a sync object and remove the sync object.
+	At this time, the dmabuf is putted.
+
+void dmabuf_sync_put_all(struct dmabuf_sync *sync)
+	- Put dmabuf sync object to dmabufs. Internally, this function removes
+	all dmabufs from a sync object and remove the sync object.
+	At this time, all dmabufs are putted.
+
+int dmabuf_sync_lock(struct dmabuf_sync *sync)
+	- Lock all dmabufs added in a sync object. The caller should call this
+	function prior to CPU or DMA access to the dmabufs so that others can
+	not access the dmabufs. Internally, this function avoids dead lock
+	issue with ww-mutexes.
+
+int dmabuf_sync_single_lock(struct dma_buf *dmabuf)
+	- Lock a dmabuf. The caller should call this
+	function prior to CPU or DMA access to the dmabuf so that others can
+	not access the dmabuf.
+
+int dmabuf_sync_unlock(struct dmabuf_sync *sync)
+	- Unlock all dmabufs added in a sync object. The caller should call
+	this function after CPU or DMA access to the dmabufs is completed so
+	that others can access the dmabufs.
+
+void dmabuf_sync_single_unlock(struct dma_buf *dmabuf)
+	- Unlock a dmabuf. The caller should call this function after CPU or
+	DMA access to the dmabuf is completed so that others can access
+	the dmabuf.
+
+
+Tutorial for device driver
+--------------------------
+
+1. Allocate and Initialize a sync object:
+	struct dmabuf_sync *sync;
+
+	sync = dmabuf_sync_init(NULL, "test sync");
+	...
+
+2. Add a dmabuf to the sync object when setting up dma buffer relevant registers:
+	dmabuf_sync_get(sync, dmabuf, DMA_BUF_ACCESS_READ);
+	...
+
+3. Lock all dmabufs of the sync object before DMA or CPU accesses the dmabufs:
+	dmabuf_sync_lock(sync);
+	...
+
+4. Now CPU or DMA can access all dmabufs locked in step 3.
+
+5. Unlock all dmabufs added in a sync object after DMA or CPU access to these
+   dmabufs is completed:
+	dmabuf_sync_unlock(sync);
+
+   And call the following functions to release all resources,
+	dmabuf_sync_put_all(sync);
+	dmabuf_sync_fini(sync);
+
+
+Tutorial for user application
+-----------------------------
+	struct flock filelock;
+
+1. Lock a dma buf:
+	filelock.l_type = F_WRLCK or F_RDLCK;
+
+	/* lock entire region to the dma buf. */
+	filelock.lwhence = SEEK_CUR;
+	filelock.l_start = 0;
+	filelock.l_len = 0;
+
+	fcntl(dmabuf fd, F_SETLKW or F_SETLK, &filelock);
+	...
+	CPU access to the dma buf
+
+2. Unlock a dma buf:
+	filelock.l_type = F_UNLCK;
+
+	fcntl(dmabuf fd, F_SETLKW or F_SETLK, &filelock);
+
+	close(dmabuf fd) call would also unlock the dma buf. And for more
+	detail, please refer to [3]
+
+
+References:
+[1] http://lwn.net/Articles/470339/
+[2] https://patchwork.kernel.org/patch/2625361/
+[3] http://linux.die.net/man/2/fcntl
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 5daa259..35e1518 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -200,6 +200,13 @@ config DMA_SHARED_BUFFER
 	  APIs extension; the file's descriptor can then be passed on to other
 	  driver.
 
+config DMABUF_SYNC
+	bool "DMABUF Synchronization Framework"
+	depends on DMA_SHARED_BUFFER
+	help
+	  This option enables dmabuf sync framework for buffer synchronization between
+	  DMA and DMA, CPU and DMA, and CPU and CPU.
+
 config CMA
 	bool "Contiguous Memory Allocator"
 	depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 48029aa..e06a5d7 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -11,6 +11,7 @@ obj-y			+= power/
 obj-$(CONFIG_HAS_DMA)	+= dma-mapping.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
 obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o
+obj-$(CONFIG_DMABUF_SYNC) += dmabuf-sync.o
 obj-$(CONFIG_ISA)	+= isa.o
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
 obj-$(CONFIG_NUMA)	+= node.o
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 08fe897..9a26981 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -29,6 +29,7 @@
 #include <linux/export.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
+#include <linux/dmabuf-sync.h>
 
 static inline int is_dma_buf_file(struct file *);
 
@@ -56,6 +57,8 @@ static int dma_buf_release(struct inode *inode, struct file *file)
 	list_del(&dmabuf->list_node);
 	mutex_unlock(&db_list.lock);
 
+	dmabuf_sync_reservation_fini(dmabuf);
+
 	kfree(dmabuf);
 	return 0;
 }
@@ -134,6 +137,7 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops,
 
 	file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf, flags);
 
+	dmabuf_sync_reservation_init(dmabuf);
 	dmabuf->file = file;
 
 	mutex_init(&dmabuf->lock);
diff --git a/drivers/base/dmabuf-sync.c b/drivers/base/dmabuf-sync.c
new file mode 100644
index 0000000..0b83111
--- /dev/null
+++ b/drivers/base/dmabuf-sync.c
@@ -0,0 +1,674 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics Co.Ltd
+ * Authors:
+ *	Inki Dae <inki.dae@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/debugfs.h>
+#include <linux/uaccess.h>
+
+#include <linux/dmabuf-sync.h>
+
+#define MAX_SYNC_TIMEOUT	5 /* Second. */
+
+int dmabuf_sync_enabled = 1;
+
+MODULE_PARM_DESC(enabled, "Check if dmabuf sync is supported or not");
+module_param_named(enabled, dmabuf_sync_enabled, int, 0444);
+
+DEFINE_WW_CLASS(dmabuf_sync_ww_class);
+EXPORT_SYMBOL(dmabuf_sync_ww_class);
+
+static void dmabuf_sync_timeout_worker(struct work_struct *work)
+{
+	struct dmabuf_sync *sync = container_of(work, struct dmabuf_sync, work);
+	struct dmabuf_sync_object *sobj;
+
+	mutex_lock(&sync->lock);
+
+	list_for_each_entry(sobj, &sync->syncs, head) {
+		if (WARN_ON(!sobj->robj))
+			continue;
+
+		mutex_lock(&sobj->robj->lock);
+
+		printk(KERN_WARNING "%s: timeout = 0x%x [type = %d, " \
+					"refcnt = %d, locked = %d]\n",
+					sync->name, (u32)sobj->dmabuf,
+					sobj->access_type,
+					atomic_read(&sobj->robj->shared_cnt),
+					sobj->robj->locked);
+
+		/* unlock only valid sync object. */
+		if (!sobj->robj->locked) {
+			mutex_unlock(&sobj->robj->lock);
+			continue;
+		}
+
+		if (sobj->robj->shared &&
+		    atomic_add_unless(&sobj->robj->shared_cnt, -1, 1)) {
+			mutex_unlock(&sobj->robj->lock);
+			continue;
+		}
+
+		mutex_unlock(&sobj->robj->lock);
+
+		ww_mutex_unlock(&sobj->robj->sync_lock);
+
+		mutex_lock(&sobj->robj->lock);
+
+		if (sobj->access_type & DMA_BUF_ACCESS_R)
+			printk(KERN_WARNING "%s: r-unlocked = 0x%x\n",
+					sync->name, (u32)sobj->dmabuf);
+		else
+			printk(KERN_WARNING "%s: w-unlocked = 0x%x\n",
+					sync->name, (u32)sobj->dmabuf);
+
+		mutex_unlock(&sobj->robj->lock);
+	}
+
+	sync->status = 0;
+	mutex_unlock(&sync->lock);
+
+	dmabuf_sync_put_all(sync);
+	dmabuf_sync_fini(sync);
+}
+
+static void dmabuf_sync_lock_timeout(unsigned long arg)
+{
+	struct dmabuf_sync *sync = (struct dmabuf_sync *)arg;
+
+	schedule_work(&sync->work);
+}
+
+static int dmabuf_sync_lock_objs(struct dmabuf_sync *sync,
+					struct ww_acquire_ctx *ctx)
+{
+	struct dmabuf_sync_object *contended_sobj = NULL;
+	struct dmabuf_sync_object *res_sobj = NULL;
+	struct dmabuf_sync_object *sobj = NULL;
+	int ret;
+
+	if (ctx)
+		ww_acquire_init(ctx, &dmabuf_sync_ww_class);
+
+retry:
+	list_for_each_entry(sobj, &sync->syncs, head) {
+		if (WARN_ON(!sobj->robj))
+			continue;
+
+		mutex_lock(&sobj->robj->lock);
+
+		/* Don't lock in case of read and read. */
+		if (sobj->robj->accessed_type & DMA_BUF_ACCESS_R &&
+		    sobj->access_type & DMA_BUF_ACCESS_R) {
+			atomic_inc(&sobj->robj->shared_cnt);
+			sobj->robj->shared = true;
+			mutex_unlock(&sobj->robj->lock);
+			continue;
+		}
+
+		if (sobj = res_sobj) {
+			res_sobj = NULL;
+			mutex_unlock(&sobj->robj->lock);
+			continue;
+		}
+
+		mutex_unlock(&sobj->robj->lock);
+
+		ret = ww_mutex_lock(&sobj->robj->sync_lock, ctx);
+		if (ret < 0) {
+			contended_sobj = sobj;
+
+			if (ret = -EDEADLK)
+				printk(KERN_WARNING"%s: deadlock = 0x%x\n",
+					sync->name, (u32)sobj->dmabuf);
+			goto err;
+		}
+
+		mutex_lock(&sobj->robj->lock);
+		sobj->robj->locked = true;
+
+		mutex_unlock(&sobj->robj->lock);
+	}
+
+	if (ctx)
+		ww_acquire_done(ctx);
+
+	init_timer(&sync->timer);
+
+	sync->timer.data = (unsigned long)sync;
+	sync->timer.function = dmabuf_sync_lock_timeout;
+	sync->timer.expires = jiffies + (HZ * MAX_SYNC_TIMEOUT);
+
+	add_timer(&sync->timer);
+
+	return 0;
+
+err:
+	list_for_each_entry_continue_reverse(sobj, &sync->syncs, head) {
+		mutex_lock(&sobj->robj->lock);
+
+		/* Don't need to unlock in case of read and read. */
+		if (atomic_add_unless(&sobj->robj->shared_cnt, -1, 1)) {
+			mutex_unlock(&sobj->robj->lock);
+			continue;
+		}
+
+		ww_mutex_unlock(&sobj->robj->sync_lock);
+		sobj->robj->locked = false;
+
+		mutex_unlock(&sobj->robj->lock);
+	}
+
+	if (res_sobj) {
+		mutex_lock(&res_sobj->robj->lock);
+
+		if (!atomic_add_unless(&res_sobj->robj->shared_cnt, -1, 1)) {
+			ww_mutex_unlock(&res_sobj->robj->sync_lock);
+			res_sobj->robj->locked = false;
+		}
+
+		mutex_unlock(&res_sobj->robj->lock);
+	}
+
+	if (ret = -EDEADLK) {
+		ww_mutex_lock_slow(&contended_sobj->robj->sync_lock, ctx);
+		res_sobj = contended_sobj;
+
+		goto retry;
+	}
+
+	if (ctx)
+		ww_acquire_fini(ctx);
+
+	return ret;
+}
+
+static void dmabuf_sync_unlock_objs(struct dmabuf_sync *sync,
+					struct ww_acquire_ctx *ctx)
+{
+	struct dmabuf_sync_object *sobj;
+
+	if (list_empty(&sync->syncs))
+		return;
+
+	mutex_lock(&sync->lock);
+
+	list_for_each_entry(sobj, &sync->syncs, head) {
+		mutex_lock(&sobj->robj->lock);
+
+		if (sobj->robj->shared) {
+			if (atomic_add_unless(&sobj->robj->shared_cnt, -1,
+						1)) {
+				mutex_unlock(&sobj->robj->lock);
+				continue;
+			}
+
+			mutex_unlock(&sobj->robj->lock);
+
+			ww_mutex_unlock(&sobj->robj->sync_lock);
+
+			mutex_lock(&sobj->robj->lock);
+			sobj->robj->shared = false;
+			sobj->robj->locked = false;
+		} else {
+			mutex_unlock(&sobj->robj->lock);
+
+			ww_mutex_unlock(&sobj->robj->sync_lock);
+
+			mutex_lock(&sobj->robj->lock);
+			sobj->robj->locked = false;
+		}
+
+		mutex_unlock(&sobj->robj->lock);
+	}
+
+	mutex_unlock(&sync->lock);
+
+	if (ctx)
+		ww_acquire_fini(ctx);
+
+	del_timer(&sync->timer);
+}
+
+/**
+ * is_dmabuf_sync_supported - Check if dmabuf sync is supported or not.
+ */
+bool is_dmabuf_sync_supported(void)
+{
+	return dmabuf_sync_enabled = 1;
+}
+EXPORT_SYMBOL(is_dmabuf_sync_supported);
+
+/**
+ * dmabuf_sync_init - Allocate and initialize a dmabuf sync.
+ *
+ * @priv: A device private data.
+ * @name: A sync object name.
+ *
+ * This function should be called when a device context or an event
+ * context such as a page flip event is created. And the created
+ * dmabuf_sync object should be set to the context.
+ * The caller can get a new sync object for buffer synchronization
+ * through this function.
+ */
+struct dmabuf_sync *dmabuf_sync_init(void *priv, const char *name)
+{
+	struct dmabuf_sync *sync;
+
+	sync = kzalloc(sizeof(*sync), GFP_KERNEL);
+	if (!sync)
+		return ERR_PTR(-ENOMEM);
+
+	strncpy(sync->name, name, ARRAY_SIZE(sync->name) - 1);
+
+	sync->priv = priv;
+	INIT_LIST_HEAD(&sync->syncs);
+	mutex_init(&sync->lock);
+	INIT_WORK(&sync->work, dmabuf_sync_timeout_worker);
+
+	return sync;
+}
+EXPORT_SYMBOL(dmabuf_sync_init);
+
+/**
+ * dmabuf_sync_fini - Release a given dmabuf sync.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * This function should be called if some operation is failed after
+ * dmabuf_sync_init call to release relevant resources, and after
+ * dmabuf_sync_unlock function is called.
+ */
+void dmabuf_sync_fini(struct dmabuf_sync *sync)
+{
+	if (WARN_ON(!sync))
+		return;
+
+	kfree(sync);
+}
+EXPORT_SYMBOL(dmabuf_sync_fini);
+
+/*
+ * dmabuf_sync_get_obj - Add a given object to syncs list.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ * @dmabuf: An object to dma_buf structure.
+ * @type: A access type to a dma buf.
+ *	The DMA_BUF_ACCESS_R means that this dmabuf could be accessed by
+ *	others for read access. On the other hand, the DMA_BUF_ACCESS_W
+ *	means that this dmabuf couldn't be accessed by others but would be
+ *	accessed by caller's dma exclusively. And the DMA_BUF_ACCESS_DMA can be
+ *	combined.
+ *
+ * This function creates and initializes a new dmabuf sync object and it adds
+ * the dmabuf sync object to syncs list to track and manage all dmabufs.
+ */
+static int dmabuf_sync_get_obj(struct dmabuf_sync *sync, struct dma_buf *dmabuf,
+					unsigned int type)
+{
+	struct dmabuf_sync_object *sobj;
+
+	if (!dmabuf->sync) {
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	if (!IS_VALID_DMA_BUF_ACCESS_TYPE(type))
+		return -EINVAL;
+
+	if ((type & DMA_BUF_ACCESS_RW) = DMA_BUF_ACCESS_RW)
+		type &= ~DMA_BUF_ACCESS_R;
+
+	sobj = kzalloc(sizeof(*sobj), GFP_KERNEL);
+	if (!sobj) {
+		WARN_ON(1);
+		return -ENOMEM;
+	}
+
+	sobj->dmabuf = dmabuf;
+	sobj->robj = dmabuf->sync;
+
+	mutex_lock(&sync->lock);
+	list_add_tail(&sobj->head, &sync->syncs);
+	mutex_unlock(&sync->lock);
+
+	get_dma_buf(dmabuf);
+
+	mutex_lock(&sobj->robj->lock);
+	sobj->access_type = type;
+	mutex_unlock(&sobj->robj->lock);
+
+	return 0;
+}
+
+/*
+ * dmabuf_sync_put_obj - Release a given sync object.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * This function should be called if some operation is failed after
+ * dmabuf_sync_get_obj call to release a given sync object.
+ */
+static void dmabuf_sync_put_obj(struct dmabuf_sync *sync,
+					struct dma_buf *dmabuf)
+{
+	struct dmabuf_sync_object *sobj;
+
+	mutex_lock(&sync->lock);
+
+	list_for_each_entry(sobj, &sync->syncs, head) {
+		if (sobj->dmabuf != dmabuf)
+			continue;
+
+		dma_buf_put(sobj->dmabuf);
+
+		list_del_init(&sobj->head);
+		kfree(sobj);
+		break;
+	}
+
+	if (list_empty(&sync->syncs))
+		sync->status = 0;
+
+	mutex_unlock(&sync->lock);
+}
+
+/*
+ * dmabuf_sync_put_objs - Release all sync objects of dmabuf_sync.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * This function should be called if some operation is failed after
+ * dmabuf_sync_get_obj call to release all sync objects.
+ */
+static void dmabuf_sync_put_objs(struct dmabuf_sync *sync)
+{
+	struct dmabuf_sync_object *sobj, *next;
+
+	mutex_lock(&sync->lock);
+
+	list_for_each_entry_safe(sobj, next, &sync->syncs, head) {
+		dma_buf_put(sobj->dmabuf);
+
+		list_del_init(&sobj->head);
+		kfree(sobj);
+	}
+
+	mutex_unlock(&sync->lock);
+
+	sync->status = 0;
+}
+
+/**
+ * dmabuf_sync_lock - lock all dmabufs added to syncs list.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * The caller should call this function prior to CPU or DMA access to
+ * the dmabufs so that others can not access the dmabufs.
+ * Internally, this function avoids dead lock issue with ww-mutex.
+ */
+int dmabuf_sync_lock(struct dmabuf_sync *sync)
+{
+	int ret;
+
+	if (!sync) {
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	if (list_empty(&sync->syncs))
+		return -EINVAL;
+
+	if (sync->status != DMABUF_SYNC_GOT)
+		return -EINVAL;
+
+	ret = dmabuf_sync_lock_objs(sync, &sync->ctx);
+	if (ret < 0) {
+		WARN_ON(1);
+		return ret;
+	}
+
+	sync->status = DMABUF_SYNC_LOCKED;
+
+	return ret;
+}
+EXPORT_SYMBOL(dmabuf_sync_lock);
+
+/**
+ * dmabuf_sync_unlock - unlock all objects added to syncs list.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * The caller should call this function after CPU or DMA access to
+ * the dmabufs is completed so that others can access the dmabufs.
+ */
+int dmabuf_sync_unlock(struct dmabuf_sync *sync)
+{
+	if (!sync) {
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	/* If current dmabuf sync object wasn't reserved then just return. */
+	if (sync->status != DMABUF_SYNC_LOCKED)
+		return -EAGAIN;
+
+	dmabuf_sync_unlock_objs(sync, &sync->ctx);
+
+	return 0;
+}
+EXPORT_SYMBOL(dmabuf_sync_unlock);
+
+/**
+ * dmabuf_sync_single_lock - lock a dma buf.
+ *
+ * @dmabuf: A dma buf object that tries to lock.
+ * @type: A access type to a dma buf.
+ *	The DMA_BUF_ACCESS_R means that this dmabuf could be accessed by
+ *	others for read access. On the other hand, the DMA_BUF_ACCESS_W
+ *	means that this dmabuf couldn't be accessed by others but would be
+ *	accessed by caller's dma exclusively. And the DMA_BUF_ACCESS_DMA can
+ *	be combined with other.
+ * @wait: Indicate whether caller is blocked or not.
+ *	true means that caller will be blocked, and false means that this
+ *	function will return -EAGAIN if this caller can't take the lock
+ *	right now.
+ *
+ * The caller should call this function prior to CPU or DMA access to the dmabuf
+ * so that others cannot access the dmabuf.
+ */
+int dmabuf_sync_single_lock(struct dma_buf *dmabuf, unsigned int type,
+				bool wait)
+{
+	struct dmabuf_sync_reservation *robj;
+
+	if (!dmabuf->sync) {
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	if (!IS_VALID_DMA_BUF_ACCESS_TYPE(type)) {
+		WARN_ON(1);
+		return -EINVAL;
+	}
+
+	get_dma_buf(dmabuf);
+	robj = dmabuf->sync;
+
+	mutex_lock(&robj->lock);
+
+	/* Don't lock in case of read and read. */
+	if (robj->accessed_type & DMA_BUF_ACCESS_R && type & DMA_BUF_ACCESS_R) {
+		atomic_inc(&robj->shared_cnt);
+		robj->shared = true;
+		mutex_unlock(&robj->lock);
+		return 0;
+	}
+
+	/*
+	 * In case of F_SETLK, just return -EAGAIN if this dmabuf has already
+	 * been locked.
+	 */
+	if (!wait && robj->locked) {
+		mutex_unlock(&robj->lock);
+		dma_buf_put(dmabuf);
+		return -EAGAIN;
+	}
+
+	mutex_unlock(&robj->lock);
+
+	mutex_lock(&robj->sync_lock.base);
+
+	mutex_lock(&robj->lock);
+	robj->locked = true;
+	mutex_unlock(&robj->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL(dmabuf_sync_single_lock);
+
+/**
+ * dmabuf_sync_single_unlock - unlock a dma buf.
+ *
+ * @dmabuf: A dma buf object that tries to unlock.
+ *
+ * The caller should call this function after CPU or DMA access to
+ * the dmabuf is completed so that others can access the dmabuf.
+ */
+void dmabuf_sync_single_unlock(struct dma_buf *dmabuf)
+{
+	struct dmabuf_sync_reservation *robj;
+
+	if (!dmabuf->sync) {
+		WARN_ON(1);
+		return;
+	}
+
+	robj = dmabuf->sync;
+
+	mutex_lock(&robj->lock);
+
+	if (robj->shared) {
+		if (atomic_add_unless(&robj->shared_cnt, -1 , 1)) {
+			mutex_unlock(&robj->lock);
+			return;
+		}
+
+		robj->shared = false;
+	}
+
+	mutex_unlock(&robj->lock);
+
+	mutex_unlock(&robj->sync_lock.base);
+
+	mutex_lock(&robj->lock);
+	robj->locked = false;
+	mutex_unlock(&robj->lock);
+
+	dma_buf_put(dmabuf);
+
+	return;
+}
+EXPORT_SYMBOL(dmabuf_sync_single_unlock);
+
+/**
+ * dmabuf_sync_get - Get dmabuf sync object.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ * @sync_buf: A dmabuf object to be synchronized with others.
+ * @type: A access type to a dma buf.
+ *	The DMA_BUF_ACCESS_R means that this dmabuf could be accessed by
+ *	others for read access. On the other hand, the DMA_BUF_ACCESS_W
+ *	means that this dmabuf couldn't be accessed by others but would be
+ *	accessed by caller's dma exclusively. And the DMA_BUF_ACCESS_DMA can
+ *	be combined with other.
+ *
+ * This function should be called after dmabuf_sync_init function is called.
+ * The caller can tie up multiple dmabufs into one sync object by calling this
+ * function several times. Internally, this function allocates
+ * a dmabuf_sync_object and adds a given dmabuf to it, and also takes
+ * a reference to a dmabuf.
+ */
+int dmabuf_sync_get(struct dmabuf_sync *sync, void *sync_buf, unsigned int type)
+{
+	int ret;
+
+	if (!sync || !sync_buf) {
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	ret = dmabuf_sync_get_obj(sync, sync_buf, type);
+	if (ret < 0) {
+		WARN_ON(1);
+		return ret;
+	}
+
+	sync->status = DMABUF_SYNC_GOT;
+
+	return 0;
+}
+EXPORT_SYMBOL(dmabuf_sync_get);
+
+/**
+ * dmabuf_sync_put - Put dmabuf sync object to a given dmabuf.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ * @dmabuf: An dmabuf object.
+ *
+ * This function should be called if some operation is failed after
+ * dmabuf_sync_get function is called to release the dmabuf, or
+ * dmabuf_sync_unlock function is called. Internally, this function
+ * removes a given dmabuf from a sync object and remove the sync object.
+ * At this time, the dmabuf is putted.
+ */
+void dmabuf_sync_put(struct dmabuf_sync *sync, struct dma_buf *dmabuf)
+{
+	if (!sync || !dmabuf) {
+		WARN_ON(1);
+		return;
+	}
+
+	if (list_empty(&sync->syncs))
+		return;
+
+	dmabuf_sync_put_obj(sync, dmabuf);
+}
+EXPORT_SYMBOL(dmabuf_sync_put);
+
+/**
+ * dmabuf_sync_put_all - Put dmabuf sync object to dmabufs.
+ *
+ * @sync: An object to dmabuf_sync structure.
+ *
+ * This function should be called if some operation is failed after
+ * dmabuf_sync_get function is called to release all sync objects, or
+ * dmabuf_sync_unlock function is called. Internally, this function
+ * removes dmabufs from a sync object and remove the sync object.
+ * At this time, all dmabufs are putted.
+ */
+void dmabuf_sync_put_all(struct dmabuf_sync *sync)
+{
+	if (!sync) {
+		WARN_ON(1);
+		return;
+	}
+
+	if (list_empty(&sync->syncs))
+		return;
+
+	dmabuf_sync_put_objs(sync);
+}
+EXPORT_SYMBOL(dmabuf_sync_put_all);
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index dfac5ed..0109673 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -115,6 +115,7 @@ struct dma_buf_ops {
  * @exp_name: name of the exporter; useful for debugging.
  * @list_node: node for dma_buf accounting and debugging.
  * @priv: exporter specific private data for this buffer object.
+ * @sync: sync object linked to this dma-buf
  */
 struct dma_buf {
 	size_t size;
@@ -128,6 +129,7 @@ struct dma_buf {
 	const char *exp_name;
 	struct list_head list_node;
 	void *priv;
+	void *sync;
 };
 
 /**
@@ -148,6 +150,20 @@ struct dma_buf_attachment {
 	void *priv;
 };
 
+#define	DMA_BUF_ACCESS_R	0x1
+#define DMA_BUF_ACCESS_W	0x2
+#define DMA_BUF_ACCESS_DMA	0x4
+#define DMA_BUF_ACCESS_RW	(DMA_BUF_ACCESS_R | DMA_BUF_ACCESS_W)
+#define DMA_BUF_ACCESS_DMA_R	(DMA_BUF_ACCESS_R | DMA_BUF_ACCESS_DMA)
+#define DMA_BUF_ACCESS_DMA_W	(DMA_BUF_ACCESS_W | DMA_BUF_ACCESS_DMA)
+#define DMA_BUF_ACCESS_DMA_RW	(DMA_BUF_ACCESS_DMA_R | DMA_BUF_ACCESS_DMA_W)
+#define IS_VALID_DMA_BUF_ACCESS_TYPE(t)	(t = DMA_BUF_ACCESS_R || \
+					 t = DMA_BUF_ACCESS_W || \
+					 t = DMA_BUF_ACCESS_DMA_R || \
+					 t = DMA_BUF_ACCESS_DMA_W || \
+					 t = DMA_BUF_ACCESS_RW || \
+					 t = DMA_BUF_ACCESS_DMA_RW)
+
 /**
  * get_dma_buf - convenience wrapper for get_file.
  * @dmabuf:	[in]	pointer to dma_buf
diff --git a/include/linux/dmabuf-sync.h b/include/linux/dmabuf-sync.h
new file mode 100644
index 0000000..2502ad6
--- /dev/null
+++ b/include/linux/dmabuf-sync.h
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics Co.Ltd
+ * Authors:
+ *	Inki Dae <inki.dae@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/mutex.h>
+#include <linux/sched.h>
+#include <linux/dma-buf.h>
+
+enum dmabuf_sync_status {
+	DMABUF_SYNC_GOT		= 1,
+	DMABUF_SYNC_LOCKED,
+};
+
+struct dmabuf_sync_reservation {
+	struct ww_mutex		sync_lock;
+	struct mutex		lock;
+	atomic_t		shared_cnt;
+	unsigned int		accessed_type;
+	unsigned int		shared;
+	unsigned int		locked;
+};
+
+/*
+ * A structure for dmabuf_sync_object.
+ *
+ * @head: A list head to be added to syncs list.
+ * @robj: A reservation_object object.
+ * @dma_buf: A dma_buf object.
+ * @access_type: Indicate how a current task tries to access
+ *	a given buffer.
+ */
+struct dmabuf_sync_object {
+	struct list_head		head;
+	struct dmabuf_sync_reservation	*robj;
+	struct dma_buf			*dmabuf;
+	unsigned int			access_type;
+};
+
+/*
+ * A structure for dmabuf_sync.
+ *
+ * @syncs: A list head to sync object and this is global to system.
+ * @list: A list entry used as committed list node
+ * @lock: A mutex lock to current sync object.
+ * @ctx: A current context for ww mutex.
+ * @work: A work struct to release resources at timeout.
+ * @priv: A private data.
+ * @name: A string to dmabuf sync owner.
+ * @timer: A timer list to avoid lockup and release resources.
+ * @status: Indicate current status (DMABUF_SYNC_GOT or DMABUF_SYNC_LOCKED).
+ */
+struct dmabuf_sync {
+	struct list_head	syncs;
+	struct list_head	list;
+	struct mutex		lock;
+	struct ww_acquire_ctx	ctx;
+	struct work_struct	work;
+	void			*priv;
+	char			name[64];
+	struct timer_list	timer;
+	unsigned int		status;
+};
+
+#ifdef CONFIG_DMABUF_SYNC
+
+extern struct ww_class dmabuf_sync_ww_class;
+
+static inline void dmabuf_sync_reservation_init(struct dma_buf *dmabuf)
+{
+	struct dmabuf_sync_reservation *obj;
+
+	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+	if (!obj)
+		return;
+
+	dmabuf->sync = obj;
+
+	ww_mutex_init(&obj->sync_lock, &dmabuf_sync_ww_class);
+
+	mutex_init(&obj->lock);
+	atomic_set(&obj->shared_cnt, 1);
+}
+
+static inline void dmabuf_sync_reservation_fini(struct dma_buf *dmabuf)
+{
+	struct dmabuf_sync_reservation *obj;
+
+	if (!dmabuf->sync)
+		return;
+
+	obj = dmabuf->sync;
+
+	ww_mutex_destroy(&obj->sync_lock);
+
+	kfree(obj);
+}
+
+extern bool is_dmabuf_sync_supported(void);
+
+extern struct dmabuf_sync *dmabuf_sync_init(void *priv, const char *name);
+
+extern void dmabuf_sync_fini(struct dmabuf_sync *sync);
+
+extern int dmabuf_sync_lock(struct dmabuf_sync *sync);
+
+extern int dmabuf_sync_unlock(struct dmabuf_sync *sync);
+
+int dmabuf_sync_single_lock(struct dma_buf *dmabuf, unsigned int type,
+				bool wait);
+
+void dmabuf_sync_single_unlock(struct dma_buf *dmabuf);
+
+extern int dmabuf_sync_get(struct dmabuf_sync *sync, void *sync_buf,
+				unsigned int type);
+
+extern void dmabuf_sync_put(struct dmabuf_sync *sync, struct dma_buf *dmabuf);
+
+extern void dmabuf_sync_put_all(struct dmabuf_sync *sync);
+
+#else
+
+static inline void dmabuf_sync_reservation_init(struct dma_buf *dmabuf) { }
+
+static inline void dmabuf_sync_reservation_fini(struct dma_buf *dmabuf) { }
+
+static inline bool is_dmabuf_sync_supported(void) { return false; }
+
+static inline struct dmabuf_sync *dmabuf_sync_init(void *priv,
+					const char *names)
+{
+	return ERR_PTR(0);
+}
+
+static inline void dmabuf_sync_fini(struct dmabuf_sync *sync) { }
+
+static inline int dmabuf_sync_lock(struct dmabuf_sync *sync)
+{
+	return 0;
+}
+
+static inline int dmabuf_sync_unlock(struct dmabuf_sync *sync)
+{
+	return 0;
+}
+
+static inline int dmabuf_sync_single_lock(struct dma_buf *dmabuf,
+						unsigned int type,
+						bool wait)
+{
+	return 0;
+}
+
+static inline void dmabuf_sync_single_unlock(struct dma_buf *dmabuf)
+{
+	return;
+}
+
+static inline int dmabuf_sync_get(struct dmabuf_sync *sync,
+					void *sync_buf,
+					unsigned int type)
+{
+	return 0;
+}
+
+static inline void dmabuf_sync_put(struct dmabuf_sync *sync,
+					struct dma_buf *dmabuf) { }
+
+static inline void dmabuf_sync_put_all(struct dmabuf_sync *sync) { }
+
+#endif
-- 
1.7.5.4


^ permalink raw reply related

* [RFC PATCH 0/2 v5] Introduce buffer synchronization framework
From: Inki Dae @ 2013-07-12  6:12 UTC (permalink / raw)
  To: dri-devel, linux-fbdev, linux-arm-kernel, linux-media
  Cc: maarten.lankhorst, daniel, robdclark, sumit.semwal, linux,
	kyungmin.park, myungjoo.ham, yj44.cho, Inki Dae

Hi all,

This patch set introduces a buffer synchronization framework based
on DMA BUF[1] and based on ww-mutexes[2] for lock mechanism.

The purpose of this framework is to provide not only buffer access
control to CPU and CPU, and CPU and DMA, and DMA and DMA but also
easy-to-use interfaces for device drivers and user application.
In addtion, this patch set suggests a way for enhancing performance.

For generic user mode interface, we have used fcntl system call[3].
As you know, user application sees a buffer object as a dma-buf file
descriptor. So fcntl() call with the file descriptor means to lock
some buffer region being managed by the dma-buf object.
For more detail, you can refer to the dma-buf-sync.txt in Documentation/

Moreover, we had tried to find how we could utilize limited hardware
resources more using buffer synchronization mechanism. And finally,
we have realized that it could enhance performance using multi threads
with this buffer synchronization mechanism: DMA and CPU works individually
so CPU could perform other works while DMA is performing some works,
and vise versa.

However, in the conventional way, that is not easy to do so because DMA
operation is depend on CPU operation, and vice versa.

Conventional way:
        User                                     Kernel
        ---------------------------------------------------------------------
        CPU writes something to src
        send the src to driver------------------------->
                                                 update DMA register
        request DMA start(1)--------------------------->
                                                 DMA start
                <---------completion signal(2)----------
        CPU accesses dst

        (1) Request DMA start after the CPU access to src buffer is completed.
        (2) Access dst buffer after DMA access to the dst buffer is completed.

On the other hand, if there is something to control buffer access between CPU
and DMA? The below shows that:

        User(thread a)          User(thread b)            Kernel
        ---------------------------------------------------------------------
        send a src to driver---------------------------------->
                                                          update DMA register
        lock the src
                                request DMA start(1)---------->
        CPU acccess to src
        unlock the src                                    lock src and dst
                                                          DMA start
                <-------------completion signal(2)-------------
        lock dst                                          DMA completion
        CPU access to dst                                 unlock src and dst
        unlock DST

        (1) Try to start DMA operation while CPU is accessing the src buffer.
        (2) Try CPU access to dst buffer while DMA is accessing the dst buffer.

	This means that CPU or DMA could do more works.

	In the same way, we could reduce hand shaking overhead between
	two processes when those processes need to share a shared buffer.
	There may be other cases that we could reduce overhead as well.


References:
[1] http://lwn.net/Articles/470339/
[2] https://patchwork.kernel.org/patch/2625361/
[3] http://linux.die.net/man/2/fcntl


Inki Dae (2):
  [RFC PATCH v5 1/2] dmabuf-sync: Introduce buffer synchronization framework
  [RFC PATCH v1 2/2] dma-buf: add lock callback for fcntl system call

 Documentation/dma-buf-sync.txt |  290 +++++++++++++++++
 drivers/base/Kconfig           |    7 +
 drivers/base/Makefile          |    1 +
 drivers/base/dma-buf.c         |   37 +++
 drivers/base/dmabuf-sync.c     |  674 ++++++++++++++++++++++++++++++++++++++++
 include/linux/dma-buf.h        |   16 +
 include/linux/dmabuf-sync.h    |  178 +++++++++++
 7 files changed, 1203 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/dma-buf-sync.txt
 create mode 100644 drivers/base/dmabuf-sync.c
 create mode 100644 include/linux/dmabuf-sync.h

-- 
1.7.5.4


^ permalink raw reply

* [PATCH 5/5] Documentation: DT: Add DCU framebuffer driver
From: Alison Wang @ 2013-07-12  6:07 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373609276-14566-1-git-send-email-b18965@freescale.com>

This patch adds the document for DCU framebuffer driver under
Documentation/devicetree/bindings/fb/.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
Changes in v2: New
- Add this document for DCU framebuffer driver.

 .../devicetree/bindings/fb/fsl-dcu-fb.txt          | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fb/fsl-dcu-fb.txt

diff --git a/Documentation/devicetree/bindings/fb/fsl-dcu-fb.txt b/Documentation/devicetree/bindings/fb/fsl-dcu-fb.txt
new file mode 100644
index 0000000..231bda7
--- /dev/null
+++ b/Documentation/devicetree/bindings/fb/fsl-dcu-fb.txt
@@ -0,0 +1,36 @@
+* Freescale Display Control Unit (DCU)
+
+Required properties:
+- compatible: Should be "fsl,vf610-dcu". Supported chips include
+  Vybrid VF610.
+- reg: Address and length of the register set for DCU.
+- interrupts: Should contain DCU interrupts.
+- clocks: From common clock binding: handle to DCU clock.
+- clock-names: From common clock binding: Shall be "dcu".
+- tcon-controller: The phandle of TCON controller.
+
+For the DCU initialization, we read data from TCON node.
+Required properties for TCON:
+- compatible: Should be "fsl,vf610-tcon". Supported chips include
+  Vybrid VF610.
+- reg: Address and length of the register set for TCON.
+- clocks: From common clock binding: handle to TCON clock.
+- clock-names: From common clock binding: Shall be "tcon".
+
+Examples:
+
+dcu0: dcu@40058000 {
+	compatible = "fsl,vf610-dcu";
+	reg = <0x40058000 0x1200>;
+	interrupts = <0 30 0x04>;
+	clocks = <&clks VF610_CLK_DCU0>;
+	clock-names = "dcu";
+	tcon-controller = <&tcon0>;
+};
+
+tcon0: tcon@4003d000 {
+	compatible = "fsl,vf610-tcon";
+	reg = <0x4003d000 0x1000>;
+	clocks = <&clks VF610_CLK_TCON0>;
+	clock-names = "tcon";
+};
-- 
1.8.0



^ permalink raw reply related

* [PATCH 4/5] fb: Add DCU framebuffer driver for Vybrid VF610 platform
From: Alison Wang @ 2013-07-12  6:07 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373609276-14566-1-git-send-email-b18965@freescale.com>

The Display Controller Unit (DCU) module is a system master that
fetches graphics stored in internal or external memory and displays
them on a TFT LCD panel. A wide range of panel sizes is supported
and the timing of the interface signals is highly configurable.
Graphics are read directly from memory and then blended in real-time,
which allows for dynamic content creation with minimal CPU intervention.

The features:

(1) Full RGB888 output to TFT LCD panel.
(2) For the current LCD panel, WQVGA "480x272" is tested.
(3) Blending of each pixel using up to 4 source layers dependent on size of panel.
(4) Each graphic layer can be placed with one pixel resolution in either axis.
(5) Each graphic layer support RGB565 and RGB888 direct colors without alpha channel
and BGRA8888 direct colors with an alpha channel.
(6) Each graphic layer support alpha blending with 8-bit resolution.

This driver has been tested on Vybrid VF610 TOWER board.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
Changes in v2: None

 drivers/video/Kconfig      |    9 +
 drivers/video/Makefile     |    1 +
 drivers/video/fsl-dcu-fb.c | 1091 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1101 insertions(+)
 create mode 100644 drivers/video/fsl-dcu-fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 46544d0..32dc1f8 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1978,6 +1978,15 @@ config FB_FSL_DIU
 	---help---
 	  Framebuffer driver for the Freescale SoC DIU
 
+config FB_FSL_DCU
+	tristate "Freescale DCU framebuffer support"
+	depends on FB
+	select FB_CFB_FILLRECT
+	select FB_CFB_COPYAREA
+	select FB_CFB_IMAGEBLIT
+	---help---
+	  Framebuffer driver for the Freescale SoC DCU
+
 config FB_W100
 	tristate "W100 frame buffer support"
 	depends on FB && ARCH_PXA
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e8bae8d..3707a7d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -129,6 +129,7 @@ obj-$(CONFIG_FB_IMX)              += imxfb.o
 obj-$(CONFIG_FB_S3C)		  += s3c-fb.o
 obj-$(CONFIG_FB_S3C2410)	  += s3c2410fb.o
 obj-$(CONFIG_FB_FSL_DIU)	  += fsl-diu-fb.o
+obj-$(CONFIG_FB_FSL_DCU)	  += fsl-dcu-fb.o
 obj-$(CONFIG_FB_COBALT)           += cobalt_lcdfb.o
 obj-$(CONFIG_FB_IBM_GXT4500)	  += gxt4500.o
 obj-$(CONFIG_FB_PS3)		  += ps3fb.o
diff --git a/drivers/video/fsl-dcu-fb.c b/drivers/video/fsl-dcu-fb.c
new file mode 100644
index 0000000..5571dde
--- /dev/null
+++ b/drivers/video/fsl-dcu-fb.c
@@ -0,0 +1,1091 @@
+/*
+ * Copyright 2012-2013 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU Frame Buffer device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
+#include <linux/fb.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/uaccess.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		(x << 20)
+#define DCU_MODE_RASTER_EN		(1 << 14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			(x << 16)
+#define DCU_BGND_G(x)			(x << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	(x << 16)
+#define DCU_DISP_SIZE_DELTA_X(x)	(x)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		(x << 22)
+#define DCU_HSYN_PARA_PW(x)		(x << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		(x << 22)
+#define DCU_VSYN_PARA_PW(x)		(x << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		(1 << 1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	(x << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	(x << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		(1 << 1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		(1 << 1)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		(1 << 31)
+#define DCU_UPDATE_MODE_READREG		(1 << 30)
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	(x << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	(x << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		(1 << 31)
+#define DCU_CTRLDESCLN_4_TILE_EN	(1 << 30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	(1 << 29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	(1 << 28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	(x << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		(x << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		(1 << 15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	(x << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		(1 << 2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	(x << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	(x << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	(x << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	(x << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	(x << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_TOTAL_LAYER_NUM		64
+#define DCU_LAYER_NUM_MAX		6
+#define DCU_LAYER_NUM			4
+
+#define BPP_16_RGB565			4
+#define BPP_24_RGB888			5
+#define BPP_32_ARGB8888			6
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		(1 << 29)
+
+#define MFB_SET_ALPHA		_IOW('M', 0, __u8)
+#define MFB_GET_ALPHA		_IOR('M', 0, __u8)
+#define MFB_SET_LAYER		_IOW('M', 4, struct layer_display_offset)
+#define MFB_GET_LAYER		_IOR('M', 4, struct layer_display_offset)
+
+static char *fb_mode;
+static unsigned int default_bpp = 24;
+
+static struct fb_videomode dcu_mode_db[] = {
+	{
+		.name		= "480x272",
+		.refresh	= 75,
+		.xres		= 480,
+		.yres		= 272,
+		.pixclock	= 91996,
+		.left_margin	= 2,
+		.right_margin	= 2,
+		.upper_margin	= 1,
+		.lower_margin	= 1,
+		.hsync_len	= 41,
+		.vsync_len	= 2,
+		.sync		= FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+		.vmode		= FB_VMODE_NONINTERLACED,
+	},
+};
+
+/* DCU framebuffer data structure */
+struct dcu_fb_data {
+	struct fb_info *fsl_dcu_info[DCU_LAYER_NUM];
+	void __iomem *reg_base;
+	unsigned int irq;
+	struct clk *clk;
+};
+
+struct layer_display_offset {
+	int x_layer_d;
+	int y_layer_d;
+};
+
+struct mfb_info {
+	int index;
+	char *id;
+	unsigned long pseudo_palette[16];
+	unsigned char alpha;
+	unsigned char blend;
+	unsigned int count;
+	int x_layer_d;	/* layer display x offset to physical screen */
+	int y_layer_d;	/* layer display y offset to physical screen */
+	struct dcu_fb_data *parent;
+};
+
+enum mfb_index {
+	LAYER0 = 0,
+	LAYER1,
+	LAYER2,
+	LAYER3,
+};
+
+static struct mfb_info mfb_template[] = {
+	{
+	.index = LAYER0,
+	.id = "Layer0",
+	.alpha = 0xff,
+	.blend = 0,
+	.count = 0,
+	.x_layer_d = 0,
+	.y_layer_d = 0,
+	},
+	{
+	.index = LAYER1,
+	.id = "Layer1",
+	.alpha = 0xff,
+	.blend = 0,
+	.count = 0,
+	.x_layer_d = 50,
+	.y_layer_d = 50,
+	},
+	{
+	.index = LAYER2,
+	.id = "Layer2",
+	.alpha = 0xff,
+	.blend = 0,
+	.count = 0,
+	.x_layer_d = 100,
+	.y_layer_d = 100,
+	},
+	{
+	.index = LAYER3,
+	.id = "Layer3",
+	.alpha = 0xff,
+	.blend = 0,
+	.count = 0,
+	.x_layer_d = 150,
+	.y_layer_d = 150,
+	},
+};
+
+static int enable_panel(struct fb_info *info)
+{
+	struct fb_var_screeninfo *var = &info->var;
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+	unsigned int bpp;
+
+	writel(DCU_CTRLDESCLN_1_HEIGHT(var->yres) |
+		DCU_CTRLDESCLN_1_WIDTH(var->xres),
+		dcufb->reg_base + DCU_CTRLDESCLN_1(mfbi->index));
+	writel(DCU_CTRLDESCLN_2_POSY(mfbi->y_layer_d) |
+		DCU_CTRLDESCLN_2_POSX(mfbi->x_layer_d),
+		dcufb->reg_base + DCU_CTRLDESCLN_2(mfbi->index));
+
+	writel(info->fix.smem_start,
+		dcufb->reg_base + DCU_CTRLDESCLN_3(mfbi->index));
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		bpp = BPP_16_RGB565;
+		break;
+	case 24:
+		bpp = BPP_24_RGB888;
+		break;
+	case 32:
+		bpp = BPP_32_ARGB8888;
+		break;
+	default:
+		printk(KERN_ERR "unsupported color depth: %u\n",
+			var->bits_per_pixel);
+		return -EINVAL;
+	}
+
+	writel(DCU_CTRLDESCLN_4_EN |
+		DCU_CTRLDESCLN_4_TRANS(mfbi->alpha) |
+		DCU_CTRLDESCLN_4_BPP(bpp) |
+		DCU_CTRLDESCLN_4_AB(mfbi->blend),
+		dcufb->reg_base + DCU_CTRLDESCLN_4(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_5_CKMAX_R(0xff) |
+		DCU_CTRLDESCLN_5_CKMAX_G(0xff) |
+		DCU_CTRLDESCLN_5_CKMAX_B(0xff),
+		dcufb->reg_base + DCU_CTRLDESCLN_5(mfbi->index));
+	writel(DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		DCU_CTRLDESCLN_6_CKMIN_B(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_6(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_7_TILE_VER(0) | DCU_CTRLDESCLN_7_TILE_HOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_7(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_8_FG_FCOLOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_8(mfbi->index));
+	writel(DCU_CTRLDESCLN_9_BG_BCOLOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_9(mfbi->index));
+
+	writel(DCU_UPDATE_MODE_READREG, dcufb->reg_base + DCU_UPDATE_MODE);
+	return 0;
+}
+
+static int disable_panel(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+
+	writel(DCU_CTRLDESCLN_1_HEIGHT(0) |
+		DCU_CTRLDESCLN_1_WIDTH(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_1(mfbi->index));
+	writel(DCU_CTRLDESCLN_2_POSY(0) | DCU_CTRLDESCLN_2_POSX(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_2(mfbi->index));
+
+	writel(0, dcufb->reg_base + DCU_CTRLDESCLN_3(mfbi->index));
+	writel(0, dcufb->reg_base + DCU_CTRLDESCLN_4(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_5_CKMAX_R(0) |
+		DCU_CTRLDESCLN_5_CKMAX_G(0) |
+		DCU_CTRLDESCLN_5_CKMAX_B(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_5(mfbi->index));
+	writel(DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		DCU_CTRLDESCLN_6_CKMIN_B(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_6(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_7_TILE_VER(0) | DCU_CTRLDESCLN_7_TILE_HOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_7(mfbi->index));
+
+	writel(DCU_CTRLDESCLN_8_FG_FCOLOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_8(mfbi->index));
+	writel(DCU_CTRLDESCLN_9_BG_BCOLOR(0),
+		dcufb->reg_base + DCU_CTRLDESCLN_9(mfbi->index));
+
+	writel(DCU_UPDATE_MODE_READREG, dcufb->reg_base + DCU_UPDATE_MODE);
+	return 0;
+}
+
+static void enable_controller(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+	unsigned int dcu_mode;
+
+	dcu_mode = readl(dcufb->reg_base + DCU_DCU_MODE);
+	writel(dcu_mode | DCU_MODE_DCU_MODE(DCU_MODE_NORMAL),
+		dcufb->reg_base + DCU_DCU_MODE);
+}
+
+static void disable_controller(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+
+	writel(DCU_MODE_DCU_MODE(DCU_MODE_OFF),
+		dcufb->reg_base + DCU_DCU_MODE);
+}
+
+static int fsl_dcu_check_var(struct fb_var_screeninfo *var,
+		struct fb_info *info)
+{
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
+	if (var->xoffset < 0)
+		var->xoffset = 0;
+
+	if (var->yoffset < 0)
+		var->yoffset = 0;
+
+	if (var->xoffset + info->var.xres > info->var.xres_virtual)
+		var->xoffset = info->var.xres_virtual - info->var.xres;
+
+	if (var->yoffset + info->var.yres > info->var.yres_virtual)
+		var->yoffset = info->var.yres_virtual - info->var.yres;
+
+	if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
+	    (var->bits_per_pixel != 16))
+		var->bits_per_pixel = default_bpp;
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		var->red.length = 5;
+		var->red.offset = 11;
+		var->red.msb_right = 0;
+
+		var->green.length = 6;
+		var->green.offset = 5;
+		var->green.msb_right = 0;
+
+		var->blue.length = 5;
+		var->blue.offset = 0;
+		var->blue.msb_right = 0;
+
+		var->transp.length = 0;
+		var->transp.offset = 0;
+		var->transp.msb_right = 0;
+		break;
+	case 24:
+		var->red.length = 8;
+		var->red.offset = 16;
+		var->red.msb_right = 0;
+
+		var->green.length = 8;
+		var->green.offset = 8;
+		var->green.msb_right = 0;
+
+		var->blue.length = 8;
+		var->blue.offset = 0;
+		var->blue.msb_right = 0;
+
+		var->transp.length = 0;
+		var->transp.offset = 0;
+		var->transp.msb_right = 0;
+		break;
+	case 32:
+		var->red.length = 8;
+		var->red.offset = 16;
+		var->red.msb_right = 0;
+
+		var->green.length = 8;
+		var->green.offset = 8;
+		var->green.msb_right = 0;
+
+		var->blue.length = 8;
+		var->blue.offset = 0;
+		var->blue.msb_right = 0;
+
+		var->transp.length = 8;
+		var->transp.offset = 24;
+		var->transp.msb_right = 0;
+		break;
+	default:
+		printk(KERN_ERR "unsupported color depth: %u\n",
+			var->bits_per_pixel);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int calc_div_ratio(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+	unsigned long dcu_clk;
+	unsigned long long tmp;
+
+	dcu_clk = clk_get_rate(dcufb->clk);
+	tmp = info->var.pixclock * (unsigned long long)dcu_clk;
+
+	do_div(tmp, 1000000);
+
+	if (do_div(tmp, 1000000) > 500000)
+		tmp++;
+
+	tmp = tmp - 1;
+	return tmp;
+}
+
+static void update_controller(struct fb_info *info)
+{
+	struct fb_var_screeninfo *var = &info->var;
+	struct mfb_info *mfbi = info->par;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+	unsigned int ratio;
+
+	ratio = calc_div_ratio(info);
+	writel(ratio, dcufb->reg_base + DCU_DIV_RATIO);
+
+	writel(DCU_DISP_SIZE_DELTA_Y(var->yres) |
+		DCU_DISP_SIZE_DELTA_X(var->xres / 16),
+		dcufb->reg_base + DCU_DISP_SIZE);
+
+	/* Horizontal and vertical sync parameter */
+	writel(DCU_HSYN_PARA_BP(var->left_margin) |
+		DCU_HSYN_PARA_PW(var->hsync_len) |
+		DCU_HSYN_PARA_FP(var->right_margin),
+		dcufb->reg_base + DCU_HSYN_PARA);
+
+	writel(DCU_VSYN_PARA_BP(var->upper_margin) |
+		DCU_VSYN_PARA_PW(var->vsync_len) |
+		DCU_VSYN_PARA_FP(var->lower_margin),
+		dcufb->reg_base + DCU_VSYN_PARA);
+
+	writel(DCU_SYN_POL_INV_PXCK_FALL | DCU_SYN_POL_NEG_REMAIN |
+		DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW,
+		dcufb->reg_base + DCU_SYN_POL);
+
+	writel(DCU_BGND_R(0) | DCU_BGND_G(0) | DCU_BGND_B(0),
+		dcufb->reg_base + DCU_BGND);
+
+	writel(DCU_MODE_BLEND_ITER(DCU_LAYER_NUM_MAX) | DCU_MODE_RASTER_EN,
+			dcufb->reg_base + DCU_DCU_MODE);
+
+	writel(DCU_THRESHOLD_LS_BF_VS(0x3) | DCU_THRESHOLD_OUT_BUF_HIGH(0x78) |
+		DCU_THRESHOLD_OUT_BUF_LOW(0), dcufb->reg_base + DCU_THRESHOLD);
+
+	enable_controller(info);
+}
+
+static int map_video_memory(struct fb_info *info)
+{
+	u32 smem_len = info->fix.line_length * info->var.yres_virtual;
+
+	info->fix.smem_len = smem_len;
+
+	info->screen_base = dma_alloc_coherent(info->device, info->fix.smem_len,
+		(dma_addr_t *)&info->fix.smem_start, GFP_KERNEL);
+	if (!info->screen_base) {
+		printk(KERN_ERR "unable to allocate fb memory\n");
+		return -ENOMEM;
+	}
+
+	memset(info->screen_base, 0, info->fix.smem_len);
+
+	return 0;
+}
+
+static void unmap_video_memory(struct fb_info *info)
+{
+	if (!info->screen_base)
+		return;
+
+	dma_free_coherent(info->device, info->fix.smem_len,
+		info->screen_base, info->fix.smem_start);
+
+	info->screen_base = NULL;
+	info->fix.smem_start = 0;
+	info->fix.smem_len = 0;
+}
+
+static int fsl_dcu_set_layer(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct fb_var_screeninfo *var = &info->var;
+	struct dcu_fb_data *dcufb = mfbi->parent;
+	int pixel_offset;
+	unsigned long addr;
+
+	pixel_offset = (var->yoffset * var->xres_virtual) + var->xoffset;
+	addr = info->fix.smem_start +
+		(pixel_offset * (var->bits_per_pixel >> 3));
+
+	writel(addr, dcufb->reg_base + DCU_CTRLDESCLN_3(mfbi->index));
+	writel(DCU_UPDATE_MODE_READREG, dcufb->reg_base + DCU_UPDATE_MODE);
+
+	return 0;
+}
+
+static int fsl_dcu_set_par(struct fb_info *info)
+{
+	unsigned long len;
+	struct fb_var_screeninfo *var = &info->var;
+	struct fb_fix_screeninfo *fix = &info->fix;
+	struct mfb_info *mfbi = info->par;
+
+	fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
+	fix->type = FB_TYPE_PACKED_PIXELS;
+	fix->accel = FB_ACCEL_NONE;
+	fix->visual = FB_VISUAL_TRUECOLOR;
+	fix->xpanstep = 1;
+	fix->ypanstep = 1;
+
+	len = info->var.yres_virtual * info->fix.line_length;
+	if (len != info->fix.smem_len) {
+		if (info->fix.smem_start)
+			unmap_video_memory(info);
+
+		if (map_video_memory(info)) {
+			printk(KERN_ERR "unable to allocate fb memory\n");
+			return -ENOMEM;
+		}
+	}
+
+	/* Only layer 0 could update LCD controller */
+	if (mfbi->index = LAYER0)
+		update_controller(info);
+
+	enable_panel(info);
+	return 0;
+}
+
+static inline __u32 CNVT_TOHW(__u32 val, __u32 width)
+{
+	return ((val<<width) + 0x7FFF - val) >> 16;
+}
+
+static int fsl_dcu_setcolreg(unsigned regno, unsigned red, unsigned green,
+			   unsigned blue, unsigned transp, struct fb_info *info)
+{
+	unsigned int val;
+	int ret = -EINVAL;
+
+	/*
+	 * If greyscale is true, then we convert the RGB value
+	 * to greyscale no matter what visual we are using.
+	 */
+	if (info->var.grayscale)
+		red = green = blue = (19595 * red + 38470 * green +
+				      7471 * blue) >> 16;
+	switch (info->fix.visual) {
+	case FB_VISUAL_TRUECOLOR:
+		/*
+		 * 16-bit True Colour.  We encode the RGB value
+		 * according to the RGB bitfield information.
+		 */
+		if (regno < 16) {
+			u32 *pal = info->pseudo_palette;
+
+			red = CNVT_TOHW(red, info->var.red.length);
+			green = CNVT_TOHW(green, info->var.green.length);
+			blue = CNVT_TOHW(blue, info->var.blue.length);
+			transp = CNVT_TOHW(transp, info->var.transp.length);
+
+			val = (red << info->var.red.offset) |
+			    (green << info->var.green.offset) |
+			    (blue << info->var.blue.offset) |
+			    (transp << info->var.transp.offset);
+
+			pal[regno] = val;
+			ret = 0;
+		}
+		break;
+	case FB_VISUAL_STATIC_PSEUDOCOLOR:
+	case FB_VISUAL_PSEUDOCOLOR:
+		break;
+	}
+
+	return ret;
+}
+
+static int fsl_dcu_pan_display(struct fb_var_screeninfo *var,
+			     struct fb_info *info)
+{
+	if ((info->var.xoffset = var->xoffset) &&
+	    (info->var.yoffset = var->yoffset))
+		return 0;
+
+	if (var->xoffset < 0 || var->yoffset < 0
+	    || var->xoffset + info->var.xres > info->var.xres_virtual
+	    || var->yoffset + info->var.yres > info->var.yres_virtual)
+		return -EINVAL;
+
+	info->var.xoffset = var->xoffset;
+	info->var.yoffset = var->yoffset;
+
+	if (var->vmode & FB_VMODE_YWRAP)
+		info->var.vmode |= FB_VMODE_YWRAP;
+	else
+		info->var.vmode &= ~FB_VMODE_YWRAP;
+
+	fsl_dcu_set_layer(info);
+
+	return 0;
+}
+
+static int fsl_dcu_blank(int blank_mode, struct fb_info *info)
+{
+	switch (blank_mode) {
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
+	case FB_BLANK_NORMAL:
+		disable_panel(info);
+		break;
+	case FB_BLANK_POWERDOWN:
+		disable_controller(info);
+		break;
+	case FB_BLANK_UNBLANK:
+		enable_panel(info);
+		break;
+	}
+
+	return 0;
+}
+
+static int fsl_dcu_ioctl(struct fb_info *info, unsigned int cmd,
+		unsigned long arg)
+{
+	struct mfb_info *mfbi = info->par;
+	struct layer_display_offset layer_d;
+	void __user *buf = (void __user *)arg;
+	unsigned char alpha;
+
+	switch (cmd) {
+	case MFB_SET_LAYER:
+		if (copy_from_user(&layer_d, buf, sizeof(layer_d)))
+			return -EFAULT;
+		mfbi->x_layer_d = layer_d.x_layer_d;
+		mfbi->y_layer_d = layer_d.y_layer_d;
+		fsl_dcu_set_par(info);
+		break;
+	case MFB_GET_LAYER:
+		layer_d.x_layer_d = mfbi->x_layer_d;
+		layer_d.y_layer_d = mfbi->y_layer_d;
+		if (copy_to_user(buf, &layer_d, sizeof(layer_d)))
+			return -EFAULT;
+		break;
+	case MFB_GET_ALPHA:
+		alpha = mfbi->alpha;
+		if (copy_to_user(buf, &alpha, sizeof(alpha)))
+			return -EFAULT;
+		break;
+	case MFB_SET_ALPHA:
+		if (copy_from_user(&alpha, buf, sizeof(alpha)))
+			return -EFAULT;
+		mfbi->blend = 1;
+		mfbi->alpha = alpha;
+		fsl_dcu_set_par(info);
+		break;
+	default:
+		printk(KERN_ERR "unknown ioctl command (0x%08X)\n", cmd);
+		return -ENOIOCTLCMD;
+	}
+
+	return 0;
+}
+
+static void enable_interrupts(struct dcu_fb_data *dcufb)
+{
+	u32 int_mask = readl(dcufb->reg_base + DCU_INT_MASK);
+
+	writel(int_mask & ~DCU_INT_MASK_UNDRUN, dcufb->reg_base + DCU_INT_MASK);
+}
+
+static void reset_layers(struct dcu_fb_data *dcufb)
+{
+	int i;
+
+	for (i = 1; i < DCU_TOTAL_LAYER_NUM; i++) {
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_1(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_2(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_3(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_4(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_5(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_6(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_7(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_8(i));
+		writel(0, dcufb->reg_base + DCU_CTRLDESCLN_9(i));
+	}
+	writel(DCU_UPDATE_MODE_READREG, dcufb->reg_base + DCU_UPDATE_MODE);
+}
+
+static int fsl_dcu_open(struct fb_info *info, int user)
+{
+	struct mfb_info *mfbi = info->par;
+	int ret = 0;
+
+	mfbi->index = info->node;
+
+	mfbi->count++;
+	if (mfbi->count = 1) {
+		fsl_dcu_check_var(&info->var, info);
+		ret = fsl_dcu_set_par(info);
+		if (ret < 0)
+			mfbi->count--;
+		else
+			enable_interrupts(mfbi->parent);
+	}
+
+	return ret;
+}
+
+static int fsl_dcu_release(struct fb_info *info, int user)
+{
+	struct mfb_info *mfbi = info->par;
+	int ret = 0;
+
+	mfbi->count--;
+	if (mfbi->count = 0) {
+		ret = disable_panel(info);
+		if (ret < 0)
+			mfbi->count++;
+	}
+
+	return ret;
+}
+
+static struct fb_ops fsl_dcu_ops = {
+	.owner = THIS_MODULE,
+	.fb_check_var = fsl_dcu_check_var,
+	.fb_set_par = fsl_dcu_set_par,
+	.fb_setcolreg = fsl_dcu_setcolreg,
+	.fb_blank = fsl_dcu_blank,
+	.fb_pan_display = fsl_dcu_pan_display,
+	.fb_fillrect = cfb_fillrect,
+	.fb_copyarea = cfb_copyarea,
+	.fb_imageblit = cfb_imageblit,
+	.fb_ioctl = fsl_dcu_ioctl,
+	.fb_open = fsl_dcu_open,
+	.fb_release = fsl_dcu_release,
+};
+
+static int install_framebuffer(struct fb_info *info)
+{
+	struct mfb_info *mfbi = info->par;
+	struct fb_videomode *db = dcu_mode_db;
+	unsigned int dbsize = ARRAY_SIZE(dcu_mode_db);
+	int ret;
+
+	info->var.activate = FB_ACTIVATE_NOW;
+	info->fbops = &fsl_dcu_ops;
+	info->flags = FBINFO_FLAG_DEFAULT;
+	info->pseudo_palette = &mfbi->pseudo_palette;
+
+	fb_alloc_cmap(&info->cmap, 16, 0);
+
+	ret = fb_find_mode(&info->var, info, fb_mode, db, dbsize,
+			NULL, default_bpp);
+
+	if (fsl_dcu_check_var(&info->var, info)) {
+		ret = -EINVAL;
+		goto failed_checkvar;
+	}
+
+	if (register_framebuffer(info) < 0) {
+		ret = -EINVAL;
+		goto failed_register_framebuffer;
+	}
+
+	printk(KERN_INFO "fb%d: %s fb device registered successfully.\n",
+		info->node, info->fix.id);
+	return 0;
+
+failed_checkvar:
+	fb_dealloc_cmap(&info->cmap);
+failed_register_framebuffer:
+	unmap_video_memory(info);
+	fb_dealloc_cmap(&info->cmap);
+	return ret;
+}
+
+static void uninstall_framebuffer(struct fb_info *info)
+{
+	unregister_framebuffer(info);
+	unmap_video_memory(info);
+
+	if (&info->cmap)
+		fb_dealloc_cmap(&info->cmap);
+}
+
+static irqreturn_t fsl_dcu_irq(int irq, void *dev_id)
+{
+	struct dcu_fb_data *dcufb = dev_id;
+	unsigned int status = readl(dcufb->reg_base + DCU_INT_STATUS);
+	u32 dcu_mode;
+
+	if (status) {
+		if (status & DCU_INT_STATUS_UNDRUN) {
+			dcu_mode = readl(dcufb->reg_base + DCU_DCU_MODE);
+			dcu_mode &= ~DCU_MODE_DCU_MODE_MASK;
+			writel(dcu_mode | DCU_MODE_DCU_MODE(DCU_MODE_OFF),
+				dcufb->reg_base + DCU_DCU_MODE);
+			udelay(1);
+			writel(dcu_mode | DCU_MODE_DCU_MODE(DCU_MODE_NORMAL),
+				dcufb->reg_base + DCU_DCU_MODE);
+		}
+		writel(status, dcufb->reg_base + DCU_INT_STATUS);
+		return IRQ_HANDLED;
+	}
+	return IRQ_NONE;
+}
+
+#ifdef CONFIG_PM
+static int fsl_dcu_suspend(struct platform_device *pdev,
+		pm_message_t state)
+{
+	struct dcu_fb_data *dcufb = dev_get_drvdata(&pdev->dev);
+
+	clk_disable_unprepare(dcufb->clk);
+	return 0;
+}
+
+static int fsl_dcu_resume(struct platform_device *pdev)
+{
+	struct dcu_fb_data *dcufb = dev_get_drvdata(&pdev->dev);
+
+	clk_prepare_enable(dcufb->clk);
+	return 0;
+}
+#else
+#define fsl_dcu_suspend	NULL
+#define fsl_dcu_resume	NULL
+#endif
+
+static int bypass_tcon(struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *tcon_pdev;
+	struct clk *tcon_clk;
+	void __iomem *tcon_reg;
+	int ret = 0;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	tcon_pdev = of_find_device_by_node(tcon_np);
+	if (!tcon_pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&tcon_pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk)) {
+		ret = PTR_ERR(tcon_clk);
+		goto failed_getclock;
+	}
+	clk_prepare_enable(tcon_clk);
+
+	tcon_reg = of_iomap(tcon_np, 0);
+	if (!tcon_reg) {
+		ret = -ENOMEM;
+		goto failed_ioremap;
+	}
+	writel(TCON_BYPASS_ENABLE, tcon_reg + TCON_CTRL1);
+
+	return 0;
+
+failed_ioremap:
+	clk_disable_unprepare(tcon_clk);
+failed_getclock:
+	of_node_put(tcon_np);
+	return ret;
+}
+
+static int fsl_dcu_probe(struct platform_device *pdev)
+{
+	struct dcu_fb_data *dcufb;
+	struct mfb_info *mfbi;
+	struct resource *res;
+	int ret = 0;
+	int i;
+
+	dcufb = devm_kzalloc(&pdev->dev,
+		sizeof(struct dcu_fb_data), GFP_KERNEL);
+	if (!dcufb)
+		return -ENOMEM;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "could not get memory IO resource\n");
+		return -ENODEV;
+	}
+
+	dcufb->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(dcufb->reg_base)) {
+		ret = PTR_ERR(dcufb->reg_base);
+		goto failed_ioremap;
+	}
+
+	dcufb->irq = platform_get_irq(pdev, 0);
+	if (!dcufb->irq) {
+		ret = -EINVAL;
+		goto failed_getirq;
+	}
+
+	ret = request_irq(dcufb->irq, fsl_dcu_irq, 0, DRIVER_NAME, dcufb);
+	if (ret) {
+		dev_err(&pdev->dev, "could not request irq\n");
+		goto failed_requestirq;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are passed
+	 * through TCON unchanged */
+	ret = bypass_tcon(pdev->dev.of_node);
+	if (ret) {
+		dev_err(&pdev->dev, "could not bypass TCON\n");
+		goto failed_bypasstcon;
+	}
+
+	dcufb->clk = devm_clk_get(&pdev->dev, "dcu");
+	if (IS_ERR(dcufb->clk)) {
+		dev_err(&pdev->dev, "could not get clock\n");
+		goto failed_getclock;
+	}
+	clk_prepare_enable(dcufb->clk);
+
+	for (i = 0; i < ARRAY_SIZE(dcufb->fsl_dcu_info); i++) {
+		dcufb->fsl_dcu_info[i] +			framebuffer_alloc(sizeof(struct mfb_info), &pdev->dev);
+		if (!dcufb->fsl_dcu_info[i]) {
+			ret = ENOMEM;
+			goto failed_alloc_framebuffer;
+		}
+
+		dcufb->fsl_dcu_info[i]->fix.smem_start = 0;
+
+		mfbi = dcufb->fsl_dcu_info[i]->par;
+		memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
+		mfbi->parent = dcufb;
+
+		ret = install_framebuffer(dcufb->fsl_dcu_info[i]);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"could not register framebuffer %d\n", i);
+			goto failed_register_framebuffer;
+		}
+	}
+
+	reset_layers(mfbi->parent);
+
+	dev_set_drvdata(&pdev->dev, dcufb);
+	return 0;
+
+failed_register_framebuffer:
+	for (i = 0; i < ARRAY_SIZE(dcufb->fsl_dcu_info); i++) {
+		if (dcufb->fsl_dcu_info[i])
+			framebuffer_release(dcufb->fsl_dcu_info[i]);
+	}
+failed_alloc_framebuffer:
+failed_getclock:
+failed_bypasstcon:
+	free_irq(dcufb->irq, dcufb);
+failed_requestirq:
+failed_getirq:
+	iounmap(dcufb->reg_base);
+failed_ioremap:
+	kfree(dcufb);
+	return ret;
+}
+
+static int fsl_dcu_remove(struct platform_device *pdev)
+{
+	struct dcu_fb_data *dcufb = dev_get_drvdata(&pdev->dev);
+	int i;
+
+	disable_controller(dcufb->fsl_dcu_info[0]);
+
+	clk_disable_unprepare(dcufb->clk);
+	free_irq(dcufb->irq, dcufb);
+
+	for (i = 0; i < ARRAY_SIZE(dcufb->fsl_dcu_info); i++) {
+		uninstall_framebuffer(dcufb->fsl_dcu_info[i]);
+		framebuffer_release(dcufb->fsl_dcu_info[i]);
+	}
+
+	return 0;
+}
+
+static int fsl_dcu_setup(void)
+{
+#ifndef MODULE
+	char *opt, *options = NULL;
+	unsigned long val;
+
+	if (fb_get_options("fslfb", &options))
+		return -ENODEV;
+
+	if (!options || !*options)
+		return 0;
+
+	while ((opt = strsep(&options, ",")) != NULL) {
+		if (!*opt)
+			continue;
+		if (!strncmp(opt, "bpp=", 4)) {
+			if (!strict_strtoul(opt + 4, 10, &val))
+				default_bpp = val;
+		} else {
+			fb_mode = opt;
+		}
+	}
+#endif
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_dt_ids[] = {
+	{
+		.compatible = "fsl,vf610-dcu",
+	},
+	{}
+};
+
+static struct platform_driver fsl_dcu_driver = {
+	.driver = {
+		.name = DRIVER_NAME,
+		.owner = THIS_MODULE,
+		.of_match_table = fsl_dcu_dt_ids,
+	},
+	.probe = fsl_dcu_probe,
+	.remove = fsl_dcu_remove,
+	.suspend = fsl_dcu_suspend,
+	.resume = fsl_dcu_resume,
+};
+
+static int __init fsl_dcu_init(void)
+{
+	int ret = fsl_dcu_setup();
+
+	if (ret < 0)
+		return ret;
+
+	return platform_driver_register(&fsl_dcu_driver);
+}
+
+static void __exit fsl_dcu_exit(void)
+{
+	platform_driver_unregister(&fsl_dcu_driver);
+}
+
+module_init(fsl_dcu_init);
+module_exit(fsl_dcu_exit);
+
+MODULE_AUTHOR("Alison Wang");
+MODULE_DESCRIPTION("Freescale DCU framebuffer driver");
+MODULE_LICENSE("GPL v2");
-- 
1.8.0



^ permalink raw reply related

* [PATCH 3/5] ARM: clk: vf610: Add DCU and TCON clock support
From: Alison Wang @ 2013-07-12  6:07 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373609276-14566-1-git-send-email-b18965@freescale.com>

This patch adds DCU and TCON clock support for Vybrid VF610 platform.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
Changes in v2: None

 arch/arm/mach-imx/clk-vf610.c           | 5 +++++
 include/dt-bindings/clock/vf610-clock.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-vf610.c b/arch/arm/mach-imx/clk-vf610.c
index d617c0b..c4dbe32 100644
--- a/arch/arm/mach-imx/clk-vf610.c
+++ b/arch/arm/mach-imx/clk-vf610.c
@@ -245,6 +245,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
 	clk[VF610_CLK_DCU1_DIV] = imx_clk_divider("dcu1_div", "dcu1_en", CCM_CSCDR3, 20, 3);
 	clk[VF610_CLK_DCU1] = imx_clk_gate2("dcu1", "dcu1_div", CCM_CCGR9, CCM_CCGRx_CGn(8));
 
+	clk[VF610_CLK_TCON0] = imx_clk_gate2("tcon0", "platform_bus", CCM_CCGR1, CCM_CCGRx_CGn(13));
+
 	clk[VF610_CLK_ESAI_SEL] = imx_clk_mux("esai_sel", CCM_CSCMR1, 20, 2, esai_sels, 4);
 	clk[VF610_CLK_ESAI_EN] = imx_clk_gate("esai_en", "esai_sel", CCM_CSCDR2, 30);
 	clk[VF610_CLK_ESAI_DIV] = imx_clk_divider("esai_div", "esai_en", CCM_CSCDR2, 24, 4);
@@ -311,6 +313,9 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
 	clk_set_parent(clk[VF610_CLK_SAI2_SEL], clk[VF610_CLK_AUDIO_EXT]);
 	clk_set_parent(clk[VF610_CLK_SAI3_SEL], clk[VF610_CLK_AUDIO_EXT]);
 
+	clk_set_parent(clk[VF610_CLK_DCU0_SEL], clk[VF610_CLK_PLL1_PFD2]);
+	clk_set_rate(clk[VF610_CLK_DCU0_DIV], 113200000);
+
 	/* Add the clocks to provider list */
 	clk_data.clks = clk;
 	clk_data.clk_num = ARRAY_SIZE(clk);
diff --git a/include/dt-bindings/clock/vf610-clock.h b/include/dt-bindings/clock/vf610-clock.h
index 15e997f..a2fc6d9 100644
--- a/include/dt-bindings/clock/vf610-clock.h
+++ b/include/dt-bindings/clock/vf610-clock.h
@@ -158,6 +158,7 @@
 #define VF610_CLK_GPU_SEL		145
 #define VF610_CLK_GPU_EN		146
 #define VF610_CLK_GPU2D			147
-#define VF610_CLK_END			148
+#define VF610_CLK_TCON0			148
+#define VF610_CLK_END			149
 
 #endif /* __DT_BINDINGS_CLOCK_VF610_H */
-- 
1.8.0



^ permalink raw reply related

* [PATCH 2/5] ARM: dts: vf610-twr: Enable DCU and TCON devices
From: Alison Wang @ 2013-07-12  6:07 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373609276-14566-1-git-send-email-b18965@freescale.com>

This patch enables DCU and TCON devices for Vybrid VF610 TOWER board.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
Changes in v2: None

 arch/arm/boot/dts/vf610-twr.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
index b3905f5..605fb04 100644
--- a/arch/arm/boot/dts/vf610-twr.dts
+++ b/arch/arm/boot/dts/vf610-twr.dts
@@ -36,6 +36,12 @@
 
 };
 
+&dcu0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dcu0_1>;
+	status = "okay";
+};
+
 &fec0 {
 	phy-mode = "rmii";
 	pinctrl-names = "default";
@@ -50,6 +56,10 @@
 	status = "okay";
 };
 
+&tcon0 {
+	status = "okay";
+};
+
 &uart1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart1_1>;
-- 
1.8.0



^ permalink raw reply related

* [PATCH 1/5] ARM: dts: vf610: Add DCU and TCON nodes
From: Alison Wang @ 2013-07-12  6:07 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1373609276-14566-1-git-send-email-b18965@freescale.com>

This patch adds DCU and TCON nodes in SoC level DTS for Freescale
Vybrid VF610. It also removes useless pin for DCU0 pinctrl.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
Changes in v2: None

 arch/arm/boot/dts/vf610.dtsi | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/vf610.dtsi b/arch/arm/boot/dts/vf610.dtsi
index e1eb7da..037e8f1 100644
--- a/arch/arm/boot/dts/vf610.dtsi
+++ b/arch/arm/boot/dts/vf610.dtsi
@@ -140,6 +140,14 @@
 				clock-names = "pit";
 			};
 
+			tcon0: tcon@4003d000 {
+				compatible = "fsl,vf610-tcon";
+				reg = <0x4003d000 0x1000>;
+				clocks = <&clks VF610_CLK_TCON0>;
+				clock-names = "tcon";
+				status = "disabled";
+			};
+
 			wdog@4003e000 {
 				compatible = "fsl,vf610-wdt", "fsl,imx21-wdt";
 				reg = <0x4003e000 0x1000>;
@@ -169,7 +177,6 @@
 				dcu0 {
 					pinctrl_dcu0_1: dcu0grp_1 {
 						fsl,pins = <
-						VF610_PAD_PTB8__GPIO_30		0x42
 						VF610_PAD_PTE0__DCU0_HSYNC	0x42
 						VF610_PAD_PTE1__DCU0_VSYNC	0x42
 						VF610_PAD_PTE2__DCU0_PCLK	0x42
@@ -395,6 +402,16 @@
 				reg = <0x40050000 0x1000>;
 			};
 
+			dcu0: dcu@40058000 {
+				compatible = "fsl,vf610-dcu";
+				reg = <0x40058000 0x1200>;
+				interrupts = <0 30 0x04>;
+				clocks = <&clks VF610_CLK_DCU0>;
+				clock-names = "dcu";
+				tcon-controller = <&tcon0>;
+				status = "disabled";
+			};
+
 			i2c0: i2c@40066000 {
 				#address-cells = <1>;
 				#size-cells = <0>;
-- 
1.8.0



^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox