[PATCH RESEND v2 15/25] drm/gma500: Use new drm_fb_helper functions

2015-07-22 Thread Patrik Jakobsson
On Wed, Jul 22, 2015 at 11:28 AM, Archit Taneja  
wrote:
> Use the newly created wrapper drm_fb_helper functions instead of calling
> core fbdev functions directly. They also simplify the fb_info creation.
>
> v2:
> - removed unused variable 'device' in psbfb_create
>
> Cc: Patrik Jakobsson 
> Cc: Daniel Vetter 
>
> Signed-off-by: Archit Taneja 
> ---
>  drivers/gpu/drm/gma500/accel_2d.c|  6 ++---
>  drivers/gpu/drm/gma500/framebuffer.c | 48 
> 
>  2 files changed, 19 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/accel_2d.c 
> b/drivers/gpu/drm/gma500/accel_2d.c
> index de6f62a..db9f7d0 100644
> --- a/drivers/gpu/drm/gma500/accel_2d.c
> +++ b/drivers/gpu/drm/gma500/accel_2d.c
> @@ -276,12 +276,12 @@ static void psbfb_copyarea_accel(struct fb_info *info,
> break;
> default:
> /* software fallback */
> -   cfb_copyarea(info, a);
> +   drm_fb_helper_cfb_copyarea(info, a);
> return;
> }
>
> if (!gma_power_begin(dev, false)) {
> -   cfb_copyarea(info, a);
> +   drm_fb_helper_cfb_copyarea(info, a);
> return;
> }
> psb_accel_2d_copy(dev_priv,
> @@ -308,7 +308,7 @@ void psbfb_copyarea(struct fb_info *info,
> /* Avoid the 8 pixel erratum */
> if (region->width == 8 || region->height == 8 ||
> (info->flags & FBINFO_HWACCEL_DISABLED))
> -   return cfb_copyarea(info, region);
> +   return drm_fb_helper_cfb_copyarea(info, region);
>
> psbfb_copyarea_accel(info, region);
>  }
> diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
> b/drivers/gpu/drm/gma500/framebuffer.c
> index 2d42ce6..2eaf1b3 100644
> --- a/drivers/gpu/drm/gma500/framebuffer.c
> +++ b/drivers/gpu/drm/gma500/framebuffer.c
> @@ -194,9 +194,9 @@ static struct fb_ops psbfb_ops = {
> .fb_set_par = drm_fb_helper_set_par,
> .fb_blank = drm_fb_helper_blank,
> .fb_setcolreg = psbfb_setcolreg,
> -   .fb_fillrect = cfb_fillrect,
> +   .fb_fillrect = drm_fb_helper_cfb_fillrect,
> .fb_copyarea = psbfb_copyarea,
> -   .fb_imageblit = cfb_imageblit,
> +   .fb_imageblit = drm_fb_helper_cfb_imageblit,
> .fb_mmap = psbfb_mmap,
> .fb_sync = psbfb_sync,
> .fb_ioctl = psbfb_ioctl,
> @@ -208,9 +208,9 @@ static struct fb_ops psbfb_roll_ops = {
> .fb_set_par = drm_fb_helper_set_par,
> .fb_blank = drm_fb_helper_blank,
> .fb_setcolreg = psbfb_setcolreg,
> -   .fb_fillrect = cfb_fillrect,
> -   .fb_copyarea = cfb_copyarea,
> -   .fb_imageblit = cfb_imageblit,
> +   .fb_fillrect = drm_fb_helper_cfb_fillrect,
> +   .fb_copyarea = drm_fb_helper_cfb_copyarea,
> +   .fb_imageblit = drm_fb_helper_cfb_imageblit,
> .fb_pan_display = psbfb_pan,
> .fb_mmap = psbfb_mmap,
> .fb_ioctl = psbfb_ioctl,
> @@ -222,9 +222,9 @@ static struct fb_ops psbfb_unaccel_ops = {
> .fb_set_par = drm_fb_helper_set_par,
> .fb_blank = drm_fb_helper_blank,
> .fb_setcolreg = psbfb_setcolreg,
> -   .fb_fillrect = cfb_fillrect,
> -   .fb_copyarea = cfb_copyarea,
> -   .fb_imageblit = cfb_imageblit,
> +   .fb_fillrect = drm_fb_helper_cfb_fillrect,
> +   .fb_copyarea = drm_fb_helper_cfb_copyarea,
> +   .fb_imageblit = drm_fb_helper_cfb_imageblit,
> .fb_mmap = psbfb_mmap,
> .fb_ioctl = psbfb_ioctl,
>  };
> @@ -343,7 +343,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
> struct drm_framebuffer *fb;
> struct psb_framebuffer *psbfb = >pfb;
> struct drm_mode_fb_cmd2 mode_cmd;
> -   struct device *device = >pdev->dev;
> int size;
> int ret;
> struct gtt_range *backing;
> @@ -409,9 +408,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,
>
> mutex_lock(>struct_mutex);
>
> -   info = framebuffer_alloc(0, device);
> -   if (!info) {
> -   ret = -ENOMEM;
> +   info = drm_fb_helper_alloc_fbi(>psb_fb_helper);
> +   if (IS_ERR(info)) {
> +   ret = PTR_ERR(info);
> goto out_err1;
> }
> info->par = fbdev;
> @@ -426,7 +425,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
> psbfb->fbdev = info;
>
> fbdev->psb_fb_helper.fb = fb;
> -   fbdev->psb_fb_helper.fbdev = info;
>
> drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
> strcpy(info->fix.id, "psbdrmfb");
> @@ -440,12 +438,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
> } else  /* Software */
> info->fbops = _unaccel_ops;
>
> -   ret = fb_alloc_cmap(>cmap, 256, 0);
> -   if (ret) {
> -   ret = -ENOMEM;
> -   goto out_unref;
> -   }
> -
> info->fix.smem_start = dev->mode_config.fb_base;
> info->fix.smem_len = size;
> 

[PATCH v5 1/6] drm: bridge/dw_hdmi: add audio support for more display resolutions

2015-07-22 Thread Russell King - ARM Linux
On Sat, Jun 20, 2015 at 12:19:12AM +0800, Yakir Yang wrote:
> The exact relationship between the two clocks will be:
>   128 * SampleRate = TmdsClock * N / CTS.
> So this patch would generate the correct N/CTS values, add audio support
> for the below  tmds clocks:
> 25.175MHz, 40MHz, 54MHz, 65MHz, 74.25MHz, 83.5MHz, 106.5MHz, 108Mhz

Having played around with the iMX6 devices, I can now say that the
statement in the iMX6 manuals is basically wrong.  There's two things
which leads me to that conclusion.

1. They list the standard values for CTS/N at standard TMDS frequencies
   as listed in the HDMI specification (with the /1.001 and *1.001 omitted.)
   In other words, there is nothing non-standard about these values.

2. The dw_hdmi driver as from Freescale as N values for all standard
   TMDS frequencies given in the HDMI specification, including the
   /1.001 and *1.001 frequencies.  However, the CTS calculation errors
   these out.  (Note that under DRM, these can never match, because DRM
   uses frequencies of kHz resolution, not 10kHz.)

3. They then say that when using deep colour modes, the CTS values have
   to be scaled with the TMDS clock.  So, from that we can ascertain that
   other CTS values which are not listed in the table are permissible.
   This statement implies that *1.25, *1.5, *2 factors on the listed
   TMDS clock and CTS value must also be supported.

4. Practical experimentation on iMX6 Solo and Quad hardware (which have
   two different revisions of the Designware IP) show that the use of any
   CTS/N values derived from the standard ones work.  By that, I mean
   using the "other" N value and calculating CTS for non-listed TMDS
   clocks does indeed work.  Relaxing the restriction in the driver (as
   below) and running through all modes which my TV supports results in
   audio playback working, from 1080p at 60 down to 640x480 at 59.94Hz.

So, I'm now of the opinion that the statement in iMX6 manuals concerning
restrictions on N/CTS values is incorrect, and no such restriction on
these exists.

In light of that, I now have code which removes this restriction from
dw_hdmi - we generate a standard-specified N value for standard clocks,
and then calculate the CTS value from that via:

unsigned long ftdms = pixel_clk;
u64 tmp;

/*
 * Compute the CTS value from the N value.  Note that CTS and N
 * can be up to 20 bits in total, so we need 64-bit math.  Also
 * note that our TDMS clock is not fully accurate; it is accurate
 * to kHz.  This can introduce an unnecessary remainder in the
 * calculation below, so we don't try to warn about that.
 */
tmp = (u64)ftdms * n;
do_div(tmp, 128 * sample_rate);
cts = tmp;

Note: I've removed all the deep colour and pixel repetition support here
because that's basically broken - the "ratio" was always 100.  If we need
pixel repetition (which is unsupported right now) it should be a matter of
scaling the ftmds appropriately which then scales the CTS value by the
same ratio.  "ftmds" above should be as close as possible to the _real_
TMDS clock rate, not the pixel clock.  In the case of deep colour, that
may influence the N value too (as 1.25x doesn't end up producing an
integer CTS value every time) so that would need to be re-addressed.

As for this specific patch, the part which remains relevant:

> diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c 
> b/drivers/gpu/drm/bridge/dw_hdmi.c
> index dc0aed1..f717a2a 100644
> --- a/drivers/gpu/drm/bridge/dw_hdmi.c
> +++ b/drivers/gpu/drm/bridge/dw_hdmi.c
> @@ -222,8 +222,24 @@ static unsigned int hdmi_compute_n(unsigned int freq, 
> unsigned long pixel_clk,
>   case 44100:
>   if (pixel_clk == 2517)
>   n = 7007;
> + else if (pixel_clk == 25175000)
> + n = 28224;

That value is wrong.  HDMI requires:

128 * fs / 1500Hz <= n <= 128 * fs / 300Hz

For 44.1kHz, that gives a range of 3763.2 to 18816.  Presumably this
restriction is to limit the range of the feedback path in the clock
regenerator in the sink so that designers have some parameters to work
with.  Going outside these limits is unwise, and while it may work with
some sinks, it's definitely outside of the HDMI spec.

> + else if (pixel_clk == 4000)
> + n = 7056;
> + else if (pixel_clk == 5400)
> + n = 6272;
> + else if (pixel_clk == 6500)
> + n = 7056;

Rather than a big if () else if () else if (), can't we have:

if (pixel_clk == 25175000)
n = 7007;
else if (pixel_clk == 4000 || pixel_clk == 6500 ||
 pixel_clk == 8350)
n = 7056;
else ...

etc?

I'm also thinking that these values are pretty standard, and they
should not be internal to 

Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Inki Dae
On 2015년 07월 22일 17:42, Joonyoung Shim wrote:
> On 07/22/2015 05:22 PM, Inki Dae wrote:
>> On 2015년 07월 22일 17:12, Joonyoung Shim wrote:
>>> On 07/22/2015 01:55 PM, Inki Dae wrote:
 On 2015년 07월 22일 11:02, Joonyoung Shim wrote:
> On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
>> Hi,
>>
>> Today's linux-next (next-20150721) encounters boot failures on Exynos
>> Octa (Exynos5422) based boards. The boards hangs. I bisected it to:
>>
>> d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
>> commit d80167b85024982c5f18d0481a5c248100360118
>> Author: Joonyoung Shim 
>> Date:   Thu Jul 2 21:49:39 2015 +0900
>>
>> drm/exynos: remove drm_iommu_attach_device_if_possible
>>
>> Already drm_iommu_attach_device checks whether support iommu 
>> internally.
>> It should clear channels always regardless iommu support. We didn't 
>> know
>> because we can detect the problem when iommu is enabled, so we don't
>> have to use drm_iommu_attach_device_if_possible and then we can 
>> remove
>> drm_iommu_attach_device_if_possible and clear_channels function 
>> pointer.
>>
>> Signed-off-by: Joonyoung Shim 
>> Tested-by: Marek Szyprowski 
>> Signed-off-by: Inki Dae 
>>
>> :04 04 83379efbf4960f58d680371628ec04387935bd53
>> da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers
>>
>>
>> Config: exynos
>> Boot log from Odroid XU3-Lite attached.
>>
>> Any hints or ideas?
>
> The point that hangs is when accesses fimd register in
> fimd_clear_channels function, so i doubt clock setting for fimd.
>
> It's gone something that hangs after i enable gating for ACLK_200_DISP1
> clock.
>
> If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
> support. Any ideas?

 I think bootloader should have enabled ACLK_200_DISP1 clock and also
 device driver should enable all relevant clocks before the device
 accesses its own registers.

 Best way would be that the clock is enabled by common clock framework
 but it seems there is no anything that the clock framework can do it. So
 I think what we have to do is to add the clock support to device tree.
>>>
>>> It's not easy problem to me. Should we add which clock? I think we
>>> cannot control ACLK_200_DISP1 or CLKDIV2_DISP1_BLK directly by below
>>> hierarchy, right? Then we should control gate clocks, but we have not
>>> controlled any gate clocks using BTS_ prefix.
>>>
>>> The clock hierarchy from Exynos5422 user manual,
>>> ACLK_200_DISP1 -- CLKDIV2_DISP1_BLK -- HDMI LINK
>>>HDMI PHY
>>>MIC1
>>>DSIM1
>>>DPTX LINK
>>>MDNIE1
>>>SYSMMU_MIXER
>>>SYSMMU_FIMD1_M0
>>>SYSMMU_FIMD1_M1
>>>BTS_TVM0
>>>BTS_TVM1
>>>BTS_FIMD1_M0
>>>BTS_FIMD1_M1
>>>
>>> Other way, IMHO, fimd driver doesn't have to enable ACLK_200_DISP1 clock,
>>> just it should be controlled by connector drivers, e.g. dsi, dp because
>>> fimd only cannot operate, so dsi or dp must need (Actually i'm not sure
>>> about this, just i thought that Exynos5 SoCs don't have any gpios for
>>> dpi, so they cannot use dpi, right?).
>>>
>>> It needs to probe connector driver like dsi or dp earlier than fimd and
>>> fimd_bind function should return error if connector driver like dsi or
>>> dp was not probed. This is also not easy to me.
>>
>> In this case, if one of above gate clocks is enabled, the ACLK_200_DISP1
>> should be enabled. So I guess the problem would be due to below line of
>> clk-exynos5420.c,
>>
>> GATE(CLK_FIMD1, "fimd1", "aclk300_disp1", GATE_IP_DISP1, 0, 0, 0),
>>
>> Can you check it again after modifying it like below?,
>> GATE(CLK_FIMD1, "fimd1", "aclk200_disp1", GATE_IP_DISP1, 0, 0, 0),
> 
> No, parent clock of fimd1 gate clock is ACLK_300_DISP1.

Yes, I checked just it through exynos5420 and exynos5422 document. I
just guessed. So do you mean that aclk200_disp1 affects FIMD controller
even though aclk200_disp1 isn't a parent clock of FIMD? If so, it's very
strange.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



[PATCH 1/2] drm/radeon: Drop drm/ prefix for including drm.h in radeon_drm.h

2015-07-22 Thread Michel Dänzer
On 22.07.2015 18:16, Daniel Vetter wrote:
> On Wed, Jul 22, 2015 at 10:38:18AM +0200, Christian König wrote:
>> On 22.07.2015 10:29, Michel Dänzer wrote:
>>> From: Michel Dänzer 
>>>
>>> This allows radeon_drm.h to be reused verbatim in libdrm.
>>>
>>> Signed-off-by: Michel Dänzer 
>>
>> For both patches Reviewed-by: Christian König 
> 
> #ifdef __KERNEL__
> #include 
> #else
> #include 
> #endif
> 
> then run
> 
> $ make headers_install
> 
> and copy results verbatim to libdrm. That's at least how it's supposed to
> be done.

What's the point of that?

#include "drm.h"

works in the kernel as well as in libdrm.


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


[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

Laurent Carlier  changed:

   What|Removed |Added

 CC||lordheavym at gmail.com

--- Comment #5 from Laurent Carlier  ---
(In reply to beta992 from comment #4)
> (In reply to Alex Deucher from comment #3)
> > It's just a new firmware for the VCE (video encode) block.  It should
> > eventually boot, you just have to wait for the kernel firmware loader to
> > time out.
> 
> I've updated the linux-firmware packages (Arch Linux has it in testing) and 
> indeed it now boots without any issues.
> 
> Thanks again for the help!

This bug report is the reason for i've pushed the package in the testing repo
:)

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[PATCH] drm/atomic-helper: Add option to update planes only on active crtc

2015-07-22 Thread Daniel Vetter
With drivers supporting runtime pm it's generally not a good idea to
touch the hardware when it's off. Add an option to the commit_planes
helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset
happens, hence plane updates will not be lost if drivers set this to
true.

v2: Check for NULL state->crtc before chasing the pointer. Also check
both old and new crtc if there's a switch. Finally just outright
disallow switching crtcs for a plane if the plane is in active use, on
most hardware that doesn't make sense.

Cc: Maarten Lankhorst 
Cc: Thierry Reding 
Cc: Maarten Lankhorst 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_atomic_helper.c| 29 +++--
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c   |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
 drivers/gpu/drm/sti/sti_drm_drv.c  |  2 +-
 drivers/gpu/drm/tegra/drm.c|  2 +-
 include/drm/drm_atomic_helper.h|  3 ++-
 8 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 99656815641d..2122c2b844da 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -471,6 +471,14 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
if (!funcs || !funcs->atomic_check)
continue;

+   if (plane->state->crtc && plane_state->crtc &&
+   plane->state->crtc != plane_state->crtc &&
+   plane->state->crtc->state->active) {
+   DRM_DEBUG_ATOMIC("[PLANE:%d] changing crtc while still 
active\n",
+plane->base.id);
+   return -EINVAL;
+   }
+
ret = funcs->atomic_check(plane, plane_state);
if (ret) {
DRM_DEBUG_ATOMIC("[PLANE:%d] atomic driver check 
failed\n",
@@ -995,7 +1003,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,

drm_atomic_helper_commit_modeset_disables(dev, state);

-   drm_atomic_helper_commit_planes(dev, state);
+   drm_atomic_helper_commit_planes(dev, state, false);

drm_atomic_helper_commit_modeset_enables(dev, state);

@@ -1110,10 +1118,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);

+bool plane_crtc_active(struct drm_plane_state *state)
+{
+   return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1128,7 +1142,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-struct drm_atomic_state *old_state)
+struct drm_atomic_state *old_state,
+bool active_only)
 {
struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state;
@@ -1144,6 +1159,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs || !funcs->atomic_begin)
continue;

+   if (active_only && !crtc->state->active)
+   continue;
+
funcs->atomic_begin(crtc);
}

@@ -1155,6 +1173,10 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs)
continue;

+   if (active_only && !plane_crtc_active(plane->state) &&
+   !plane_crtc_active(old_plane_state))
+   continue;
+
/*
 * Special-case disabling the plane if drivers support it.
 */
@@ -1174,6 +1196,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs || !funcs->atomic_flush)
continue;

+   if (active_only && !crtc->state->active)
+   continue;
+
funcs->atomic_flush(crtc);
}
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c 
b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 2b6320e6eae2..7b383acbb5af 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -293,7 +293,7 @@ static int exynos_atomic_commit(struct drm_device *dev,
 * have the relevant clocks enabled to perform the update.
 */

-   drm_atomic_helper_commit_planes(dev, state);
+   

Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Joonyoung Shim
On 07/22/2015 05:22 PM, Inki Dae wrote:
> On 2015년 07월 22일 17:12, Joonyoung Shim wrote:
>> On 07/22/2015 01:55 PM, Inki Dae wrote:
>>> On 2015년 07월 22일 11:02, Joonyoung Shim wrote:
 On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
> Hi,
>
> Today's linux-next (next-20150721) encounters boot failures on Exynos
> Octa (Exynos5422) based boards. The boards hangs. I bisected it to:
>
> d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
> commit d80167b85024982c5f18d0481a5c248100360118
> Author: Joonyoung Shim 
> Date:   Thu Jul 2 21:49:39 2015 +0900
>
> drm/exynos: remove drm_iommu_attach_device_if_possible
>
> Already drm_iommu_attach_device checks whether support iommu 
> internally.
> It should clear channels always regardless iommu support. We didn't 
> know
> because we can detect the problem when iommu is enabled, so we don't
> have to use drm_iommu_attach_device_if_possible and then we can remove
> drm_iommu_attach_device_if_possible and clear_channels function 
> pointer.
>
> Signed-off-by: Joonyoung Shim 
> Tested-by: Marek Szyprowski 
> Signed-off-by: Inki Dae 
>
> :04 04 83379efbf4960f58d680371628ec04387935bd53
> da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers
>
>
> Config: exynos
> Boot log from Odroid XU3-Lite attached.
>
> Any hints or ideas?

 The point that hangs is when accesses fimd register in
 fimd_clear_channels function, so i doubt clock setting for fimd.

 It's gone something that hangs after i enable gating for ACLK_200_DISP1
 clock.

 If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
 support. Any ideas?
>>>
>>> I think bootloader should have enabled ACLK_200_DISP1 clock and also
>>> device driver should enable all relevant clocks before the device
>>> accesses its own registers.
>>>
>>> Best way would be that the clock is enabled by common clock framework
>>> but it seems there is no anything that the clock framework can do it. So
>>> I think what we have to do is to add the clock support to device tree.
>>
>> It's not easy problem to me. Should we add which clock? I think we
>> cannot control ACLK_200_DISP1 or CLKDIV2_DISP1_BLK directly by below
>> hierarchy, right? Then we should control gate clocks, but we have not
>> controlled any gate clocks using BTS_ prefix.
>>
>> The clock hierarchy from Exynos5422 user manual,
>> ACLK_200_DISP1 -- CLKDIV2_DISP1_BLK -- HDMI LINK
>>HDMI PHY
>>MIC1
>>DSIM1
>>DPTX LINK
>>MDNIE1
>>SYSMMU_MIXER
>>SYSMMU_FIMD1_M0
>>SYSMMU_FIMD1_M1
>>BTS_TVM0
>>BTS_TVM1
>>BTS_FIMD1_M0
>>BTS_FIMD1_M1
>>
>> Other way, IMHO, fimd driver doesn't have to enable ACLK_200_DISP1 clock,
>> just it should be controlled by connector drivers, e.g. dsi, dp because
>> fimd only cannot operate, so dsi or dp must need (Actually i'm not sure
>> about this, just i thought that Exynos5 SoCs don't have any gpios for
>> dpi, so they cannot use dpi, right?).
>>
>> It needs to probe connector driver like dsi or dp earlier than fimd and
>> fimd_bind function should return error if connector driver like dsi or
>> dp was not probed. This is also not easy to me.
> 
> In this case, if one of above gate clocks is enabled, the ACLK_200_DISP1
> should be enabled. So I guess the problem would be due to below line of
> clk-exynos5420.c,
> 
> GATE(CLK_FIMD1, "fimd1", "aclk300_disp1", GATE_IP_DISP1, 0, 0, 0),
> 
> Can you check it again after modifying it like below?,
> GATE(CLK_FIMD1, "fimd1", "aclk200_disp1", GATE_IP_DISP1, 0, 0, 0),

No, parent clock of fimd1 gate clock is ACLK_300_DISP1.


[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

beta992 at gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |PATCH_ALREADY_AVAILABLE

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

--- Comment #4 from beta992 at gmail.com ---
(In reply to Alex Deucher from comment #3)
> It's just a new firmware for the VCE (video encode) block.  It should
> eventually boot, you just have to wait for the kernel firmware loader to
> time out.

I've updated the linux-firmware packages (Arch Linux has it in testing) and 
indeed it now boots without any issues.

Thanks again for the help!

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[PATCH 1/2] drm/atomic-helper: Add option to update planes only on active crtc

2015-07-22 Thread Maarten Lankhorst
Op 22-07-15 om 16:30 schreef Daniel Vetter:
> With drivers supporting runtime pm it's generally not a good idea to
> touch the hardware when it's off. Add an option to the commit_planes
> helper to support this case.
>
> Note that the helpers already add all planes on a crtc when a modeset
> happens, hence plane updates will not be lost if drivers set this to
> true.
>
> Cc: Thierry Reding 
> Cc: Maarten Lankhorst 
> Cc: Laurent Pinchart 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c| 15 +--
>  drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
>  drivers/gpu/drm/msm/msm_atomic.c   |  2 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c |  2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
>  drivers/gpu/drm/sti/sti_drm_drv.c  |  2 +-
>  drivers/gpu/drm/tegra/drm.c|  2 +-
>  include/drm/drm_atomic_helper.h|  3 ++-
>  8 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 91ad6bd13734..192412277586 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -989,7 +989,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>  
>   drm_atomic_helper_commit_modeset_disables(dev, state);
>  
> - drm_atomic_helper_commit_planes(dev, state);
> + drm_atomic_helper_commit_planes(dev, state, false);
>  
>   drm_atomic_helper_commit_modeset_enables(dev, state);
>  
> @@ -1108,6 +1108,7 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
>   * drm_atomic_helper_commit_planes - commit plane state
>   * @dev: DRM device
>   * @old_state: atomic state object with old state structures
> + * @active_only: Only commit on active CRTC if set
>   *
>   * This function commits the new plane state using the plane and atomic 
> helper
>   * functions for planes and crtcs. It assumes that the atomic state has 
> already
> @@ -1122,7 +1123,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
>   * drm_atomic_helper_commit_planes_on_crtc() instead.
>   */
>  void drm_atomic_helper_commit_planes(struct drm_device *dev,
> -  struct drm_atomic_state *old_state)
> +  struct drm_atomic_state *old_state,
> +  bool active_only)
>  {
>   struct drm_crtc *crtc;
>   struct drm_crtc_state *old_crtc_state;
> @@ -1138,6 +1140,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
> *dev,
>   if (!funcs || !funcs->atomic_begin)
>   continue;
>  
> + if (active_only && !crtc->state->active)
> + continue;
> +
>   funcs->atomic_begin(crtc);
>   }
>  
> @@ -1149,6 +1154,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
> *dev,
>   if (!funcs)
>   continue;
>  
> + if (active_only && !plane->state->crtc->state->active)
> + continue;
>
Find the null pointer deref. ;-)

Otherwise r-b.

~Maarten


[PATCH 2/2] drm/amdgpu: Drop drm/ prefix for including drm.h in amdgpu_drm.h

2015-07-22 Thread Michel Dänzer
From: Michel Dänzer 

This allows amdgpu_drm.h to be reused verbatim in libdrm.

Signed-off-by: Michel Dänzer 
---
 include/uapi/drm/amdgpu_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 780a581..ce4d617 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -32,7 +32,7 @@
 #ifndef __AMDGPU_DRM_H__
 #define __AMDGPU_DRM_H__

-#include 
+#include "drm.h"

 #define DRM_AMDGPU_GEM_CREATE  0x00
 #define DRM_AMDGPU_GEM_MMAP0x01
-- 
2.1.4



[PATCH 1/2] drm/radeon: Drop drm/ prefix for including drm.h in radeon_drm.h

2015-07-22 Thread Michel Dänzer
From: Michel Dänzer 

This allows radeon_drm.h to be reused verbatim in libdrm.

Signed-off-by: Michel Dänzer 
---
 include/uapi/drm/radeon_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h
index 1ef7666..01aa2a8 100644
--- a/include/uapi/drm/radeon_drm.h
+++ b/include/uapi/drm/radeon_drm.h
@@ -33,7 +33,7 @@
 #ifndef __RADEON_DRM_H__
 #define __RADEON_DRM_H__

-#include 
+#include "drm.h"

 /* WARNING: If you change any of these defines, make sure to change the
  * defines in the X server file (radeon_sarea.h)
-- 
2.1.4



Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Inki Dae
On 2015년 07월 22일 17:12, Joonyoung Shim wrote:
> On 07/22/2015 01:55 PM, Inki Dae wrote:
>> On 2015년 07월 22일 11:02, Joonyoung Shim wrote:
>>> On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
 Hi,

 Today's linux-next (next-20150721) encounters boot failures on Exynos
 Octa (Exynos5422) based boards. The boards hangs. I bisected it to:

 d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
 commit d80167b85024982c5f18d0481a5c248100360118
 Author: Joonyoung Shim 
 Date:   Thu Jul 2 21:49:39 2015 +0900

 drm/exynos: remove drm_iommu_attach_device_if_possible

 Already drm_iommu_attach_device checks whether support iommu 
 internally.
 It should clear channels always regardless iommu support. We didn't 
 know
 because we can detect the problem when iommu is enabled, so we don't
 have to use drm_iommu_attach_device_if_possible and then we can remove
 drm_iommu_attach_device_if_possible and clear_channels function 
 pointer.

 Signed-off-by: Joonyoung Shim 
 Tested-by: Marek Szyprowski 
 Signed-off-by: Inki Dae 

 :04 04 83379efbf4960f58d680371628ec04387935bd53
 da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers


 Config: exynos
 Boot log from Odroid XU3-Lite attached.

 Any hints or ideas?
>>>
>>> The point that hangs is when accesses fimd register in
>>> fimd_clear_channels function, so i doubt clock setting for fimd.
>>>
>>> It's gone something that hangs after i enable gating for ACLK_200_DISP1
>>> clock.
>>>
>>> If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
>>> support. Any ideas?
>>
>> I think bootloader should have enabled ACLK_200_DISP1 clock and also
>> device driver should enable all relevant clocks before the device
>> accesses its own registers.
>>
>> Best way would be that the clock is enabled by common clock framework
>> but it seems there is no anything that the clock framework can do it. So
>> I think what we have to do is to add the clock support to device tree.
> 
> It's not easy problem to me. Should we add which clock? I think we
> cannot control ACLK_200_DISP1 or CLKDIV2_DISP1_BLK directly by below
> hierarchy, right? Then we should control gate clocks, but we have not
> controlled any gate clocks using BTS_ prefix.
> 
> The clock hierarchy from Exynos5422 user manual,
> ACLK_200_DISP1 -- CLKDIV2_DISP1_BLK -- HDMI LINK
>HDMI PHY
>MIC1
>DSIM1
>DPTX LINK
>MDNIE1
>SYSMMU_MIXER
>SYSMMU_FIMD1_M0
>SYSMMU_FIMD1_M1
>BTS_TVM0
>BTS_TVM1
>BTS_FIMD1_M0
>BTS_FIMD1_M1
> 
> Other way, IMHO, fimd driver doesn't have to enable ACLK_200_DISP1 clock,
> just it should be controlled by connector drivers, e.g. dsi, dp because
> fimd only cannot operate, so dsi or dp must need (Actually i'm not sure
> about this, just i thought that Exynos5 SoCs don't have any gpios for
> dpi, so they cannot use dpi, right?).
> 
> It needs to probe connector driver like dsi or dp earlier than fimd and
> fimd_bind function should return error if connector driver like dsi or
> dp was not probed. This is also not easy to me.

In this case, if one of above gate clocks is enabled, the ACLK_200_DISP1
should be enabled. So I guess the problem would be due to below line of
clk-exynos5420.c,

GATE(CLK_FIMD1, "fimd1", "aclk300_disp1", GATE_IP_DISP1, 0, 0, 0),

Can you check it again after modifying it like below?,
GATE(CLK_FIMD1, "fimd1", "aclk200_disp1", GATE_IP_DISP1, 0, 0, 0),

Thanks,
Inki Dae

> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



[PATCH] libdrm/amdgpu: Fixed drm.h include.

2015-07-22 Thread Michel Dänzer
On 22.07.2015 16:33, Alexandr Akulich wrote:
> On Wed, Jul 22, 2015 at 1:19 PM, Michel Dänzer  wrote:
>> On 17.07.2015 22:33, Alexandr Akulich wrote:
>>> As I see, this is not a kernel header, but a local (belongs to libdrm) one.
>>> (Otherwise, I would like you to point me on such file at, say,
>>> https://github.com/torvalds/linux/tree/master/include/drm)
>>
>> https://github.com/torvalds/linux/blob/master/include/uapi/drm/amdgpu_drm.h
>>
>>
>>> At files drm_sarea.h, mga_drm.h, qxl_drm.h, radeon_drm.h and via_drm.h we 
>>> have
>>>
>>> #include "drm.h"
>>>
>>> At the same time, at i915_drm.h and tegra_drm.h. we have
>>>
>>> #include 
>>>
>>> I'm pretty sure that the first case is correct, because drm.h is
>>> always would be local file (in the same directory), related to
>>> amdgpu_drm.h, and that is why local include "drm.h" would be always
>>> valid.
>>
>> Makes sense to me, the patch is
>>
>> Reviewed-by: Michel Dänzer 
> Thanks! I have no write access to this fd.o repository. Can you apply it 
> please?

I assume your patch is against the amdgpu branch of
http://cgit.freedesktop.org/~agd5f/drm/, right? Only Alex Deucher has
write access to that.


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


Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Joonyoung Shim
On 07/22/2015 01:55 PM, Inki Dae wrote:
> On 2015년 07월 22일 11:02, Joonyoung Shim wrote:
>> On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
>>> Hi,
>>>
>>> Today's linux-next (next-20150721) encounters boot failures on Exynos
>>> Octa (Exynos5422) based boards. The boards hangs. I bisected it to:
>>>
>>> d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
>>> commit d80167b85024982c5f18d0481a5c248100360118
>>> Author: Joonyoung Shim 
>>> Date:   Thu Jul 2 21:49:39 2015 +0900
>>>
>>> drm/exynos: remove drm_iommu_attach_device_if_possible
>>>
>>> Already drm_iommu_attach_device checks whether support iommu internally.
>>> It should clear channels always regardless iommu support. We didn't know
>>> because we can detect the problem when iommu is enabled, so we don't
>>> have to use drm_iommu_attach_device_if_possible and then we can remove
>>> drm_iommu_attach_device_if_possible and clear_channels function pointer.
>>>
>>> Signed-off-by: Joonyoung Shim 
>>> Tested-by: Marek Szyprowski 
>>> Signed-off-by: Inki Dae 
>>>
>>> :04 04 83379efbf4960f58d680371628ec04387935bd53
>>> da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers
>>>
>>>
>>> Config: exynos
>>> Boot log from Odroid XU3-Lite attached.
>>>
>>> Any hints or ideas?
>>
>> The point that hangs is when accesses fimd register in
>> fimd_clear_channels function, so i doubt clock setting for fimd.
>>
>> It's gone something that hangs after i enable gating for ACLK_200_DISP1
>> clock.
>>
>> If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
>> support. Any ideas?
> 
> I think bootloader should have enabled ACLK_200_DISP1 clock and also
> device driver should enable all relevant clocks before the device
> accesses its own registers.
> 
> Best way would be that the clock is enabled by common clock framework
> but it seems there is no anything that the clock framework can do it. So
> I think what we have to do is to add the clock support to device tree.

It's not easy problem to me. Should we add which clock? I think we
cannot control ACLK_200_DISP1 or CLKDIV2_DISP1_BLK directly by below
hierarchy, right? Then we should control gate clocks, but we have not
controlled any gate clocks using BTS_ prefix.

The clock hierarchy from Exynos5422 user manual,
ACLK_200_DISP1 -- CLKDIV2_DISP1_BLK -- HDMI LINK
   HDMI PHY
   MIC1
   DSIM1
   DPTX LINK
   MDNIE1
   SYSMMU_MIXER
   SYSMMU_FIMD1_M0
   SYSMMU_FIMD1_M1
   BTS_TVM0
   BTS_TVM1
   BTS_FIMD1_M0
   BTS_FIMD1_M1

Other way, IMHO, fimd driver doesn't have to enable ACLK_200_DISP1 clock,
just it should be controlled by connector drivers, e.g. dsi, dp because
fimd only cannot operate, so dsi or dp must need (Actually i'm not sure
about this, just i thought that Exynos5 SoCs don't have any gpios for
dpi, so they cannot use dpi, right?).

It needs to probe connector driver like dsi or dp earlier than fimd and
fimd_bind function should return error if connector driver like dsi or
dp was not probed. This is also not easy to me.


[PATCH] drm/i915: add error path

2015-07-22 Thread Sudip Mukherjee
If any of the debug file creation fails we were just returning the
error code to the drm layer. But the debug files that we created in the
process were not removed. And debugfs files are not automatically
cleaned up.

Signed-off-by: Sudip Mukherjee 
---

Hi Daniel,
Whom should i keep Cc: for this patch? Original code was from 2009, then
more codes have been added and changed in it.

 drivers/gpu/drm/i915/i915_debugfs.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index caf1382..24b04f9 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -5147,7 +5147,7 @@ int i915_debugfs_init(struct drm_minor *minor)
for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
ret = i915_pipe_crc_create(minor->debugfs_root, minor, i);
if (ret)
-   return ret;
+   goto err_pipe_crc;
}

for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
@@ -5155,12 +5155,34 @@ int i915_debugfs_init(struct drm_minor *minor)
  i915_debugfs_files[i].name,
  i915_debugfs_files[i].fops);
if (ret)
-   return ret;
+   goto err_debugfs;
}

return drm_debugfs_create_files(i915_debugfs_list,
I915_DEBUGFS_ENTRIES,
minor->debugfs_root, minor);
+
+err_debugfs:
+   while (--i >= 0) {
+   struct drm_info_list *info_list =
+   (struct drm_info_list *)i915_debugfs_files[i].fops;
+
+   drm_debugfs_remove_files(info_list, 1, minor);
+   }
+
+err_pipe_crc:
+   if (i == -1)
+   i = ARRAY_SIZE(i915_pipe_crc_data);
+
+   while (--i >= 0) {
+   struct drm_info_list *info_list =
+   (struct drm_info_list *)_pipe_crc_data[i];
+   drm_debugfs_remove_files(info_list, 1, minor);
+   }
+   drm_debugfs_remove_files((struct drm_info_list *)_forcewake_fops,
+1, minor);
+
+   return ret;
 }

 void i915_debugfs_cleanup(struct drm_minor *minor)
-- 
1.8.1.2



[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

--- Comment #3 from Alex Deucher  ---
It's just a new firmware for the VCE (video encode) block.  It should
eventually boot, you just have to wait for the kernel firmware loader to time
out.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[PATCH 14/14] drm: gc now dead mode_group code

2015-07-22 Thread Daniel Vetter
On Wed, Jul 22, 2015 at 03:05:06PM +0200, Maarten Lankhorst wrote:
> Op 09-07-15 om 23:44 schreef Daniel Vetter:
> > Two nice things here:
> > - drm_dev_register will truly register everything in the right order
> >   if the driver doesn't have a ->load callback. Before this we had to
> >   init the primary mode_group after the device nodes where already
> >   registered.
> >
> > - Less things to keep track of when reworking the connector locking,
> >   yay!
> >
> Been wondering what it was when investigating the dp hotplug.
> Patch series looks sane. :-)
> 
> r-b

Thanks, all applied, plus one cma patch from the struct_mutex series which
is needed here. I've pinged Laurent for an r-b on that one.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

--- Comment #2 from beta992 at gmail.com ---
Thanks! Didn't know a firmware upgrade was needed.
Will try and report if it works again.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[PATCH 2/2] drm/rcar: Only update planes on active crtc

2015-07-22 Thread Daniel Vetter
R-car does runtime pm (that's why it's committing plane state only at
the end). Therefore better to only update planes on active crtc. Note
that since the helpers always add all enabled planes when doing a
modeset change on a crtc we are guaranteed to update plane hw state to
the latest requested state each time the crtc is enabled.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index ca12e8ca5552..20813582fbf1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit 
*commit)
/* Apply the atomic update. */
drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_modeset_enables(dev, old_state);
-   drm_atomic_helper_commit_planes(dev, old_state, false);
+   drm_atomic_helper_commit_planes(dev, old_state, true);

drm_atomic_helper_wait_for_vblanks(dev, old_state);

-- 
2.1.4



[PATCH 1/2] drm/atomic-helper: Add option to update planes only on active crtc

2015-07-22 Thread Daniel Vetter
With drivers supporting runtime pm it's generally not a good idea to
touch the hardware when it's off. Add an option to the commit_planes
helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset
happens, hence plane updates will not be lost if drivers set this to
true.

Cc: Thierry Reding 
Cc: Maarten Lankhorst 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_atomic_helper.c| 15 +--
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c   |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
 drivers/gpu/drm/sti/sti_drm_drv.c  |  2 +-
 drivers/gpu/drm/tegra/drm.c|  2 +-
 include/drm/drm_atomic_helper.h|  3 ++-
 8 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 91ad6bd13734..192412277586 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -989,7 +989,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,

drm_atomic_helper_commit_modeset_disables(dev, state);

-   drm_atomic_helper_commit_planes(dev, state);
+   drm_atomic_helper_commit_planes(dev, state, false);

drm_atomic_helper_commit_modeset_enables(dev, state);

@@ -1108,6 +1108,7 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1122,7 +1123,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-struct drm_atomic_state *old_state)
+struct drm_atomic_state *old_state,
+bool active_only)
 {
struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state;
@@ -1138,6 +1140,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs || !funcs->atomic_begin)
continue;

+   if (active_only && !crtc->state->active)
+   continue;
+
funcs->atomic_begin(crtc);
}

@@ -1149,6 +1154,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs)
continue;

+   if (active_only && !plane->state->crtc->state->active)
+   continue;
+
/*
 * Special-case disabling the plane if drivers support it.
 */
@@ -1168,6 +1176,9 @@ void drm_atomic_helper_commit_planes(struct drm_device 
*dev,
if (!funcs || !funcs->atomic_flush)
continue;

+   if (active_only && !crtc->state->active)
+   continue;
+
funcs->atomic_flush(crtc);
}
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c 
b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 2b6320e6eae2..7b383acbb5af 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -293,7 +293,7 @@ static int exynos_atomic_commit(struct drm_device *dev,
 * have the relevant clocks enabled to perform the update.
 */

-   drm_atomic_helper_commit_planes(dev, state);
+   drm_atomic_helper_commit_planes(dev, state, false);

drm_atomic_helper_cleanup_planes(dev, state);

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 1b22d8bfe142..0709b97251bf 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -125,7 +125,7 @@ static void complete_commit(struct msm_commit *c)

drm_atomic_helper_commit_modeset_disables(dev, state);

-   drm_atomic_helper_commit_planes(dev, state);
+   drm_atomic_helper_commit_planes(dev, state, false);

drm_atomic_helper_commit_modeset_enables(dev, state);

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index e888a831dd3c..0ecce79fc782 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -96,7 +96,7 @@ static void omap_atomic_complete(struct 
omap_atomic_state_commit *commit)
dispc_runtime_get();

drm_atomic_helper_commit_modeset_disables(dev, old_state);
-   drm_atomic_helper_commit_planes(dev, old_state);
+   drm_atomic_helper_commit_planes(dev, old_state, false);
drm_atomic_helper_commit_modeset_enables(dev, old_state);


[PATCH] libdrm/amdgpu: Fixed drm.h include.

2015-07-22 Thread Michel Dänzer
On 17.07.2015 22:33, Alexandr Akulich wrote:
> As I see, this is not a kernel header, but a local (belongs to libdrm) one.
> (Otherwise, I would like you to point me on such file at, say,
> https://github.com/torvalds/linux/tree/master/include/drm)

https://github.com/torvalds/linux/blob/master/include/uapi/drm/amdgpu_drm.h


> At files drm_sarea.h, mga_drm.h, qxl_drm.h, radeon_drm.h and via_drm.h we have
> 
> #include "drm.h"
> 
> At the same time, at i915_drm.h and tegra_drm.h. we have
> 
> #include 
> 
> I'm pretty sure that the first case is correct, because drm.h is
> always would be local file (in the same directory), related to
> amdgpu_drm.h, and that is why local include "drm.h" would be always
> valid.

Makes sense to me, the patch is

Reviewed-by: Michel Dänzer 


> This fixes libdrm build with amdgpu support on bare system for me.

FWIW though, that's because you're dropping the drm/ prefix, not because
you're changing from <> to "".


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


[Bug 101811] Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

Alex Deucher  changed:

   What|Removed |Added

 CC||alexdeucher at gmail.com

--- Comment #1 from Alex Deucher  ---
Make sure you have the necessary firmware installed.  4.2 added support for VCE
on SI hardware so you need to make sure you have the vce firmware installed and
available in your initrd.
http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/radeon/TAHITI_vce.bin

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[Bug 101811] New: Club 3D Radeon R9 270 royalQueen hangs on startup (opensource driver)

2015-07-22 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=101811

Bug ID: 101811
   Summary: Club 3D Radeon R9 270 royalQueen hangs on startup
(opensource driver)
   Product: Drivers
   Version: 2.5
Kernel Version: Linux 4.2RC1, Linux 4.2RC2 & Linux 4.2RC3
  Hardware: All
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: blocking
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-dri at kernel-bugs.osdl.org
  Reporter: beta992 at gmail.com
Regression: No

Keeps hanging after initramfs; it cannot parse the ROM
Normally it shows an invalid ROM error (don't know why, but it works fine).

No issues so far on Linux <4.2.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[Bug 91416] vsync limits fps but still tearing in picture

2015-07-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91416

--- Comment #2 from Markus Mitsch  ---
running fullscreen nor changing any of the compositing options of my kubuntu
kde did make a difference. i really tried but could not find any way to fix
this so i thought it might be a bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150722/0987cc66/attachment-0001.html>


[PATCH 2/2] drm/amdgpu: Drop drm/ prefix for including drm.h in amdgpu_drm.h

2015-07-22 Thread Alex Deucher
On Wed, Jul 22, 2015 at 4:29 AM, Michel Dänzer  wrote:
> From: Michel Dänzer 
>
> This allows amdgpu_drm.h to be reused verbatim in libdrm.
>
> Signed-off-by: Michel Dänzer 

Reviewed-by: Alex Deucher 

> ---
>  include/uapi/drm/amdgpu_drm.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
> index 780a581..ce4d617 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -32,7 +32,7 @@
>  #ifndef __AMDGPU_DRM_H__
>  #define __AMDGPU_DRM_H__
>
> -#include 
> +#include "drm.h"
>
>  #define DRM_AMDGPU_GEM_CREATE  0x00
>  #define DRM_AMDGPU_GEM_MMAP0x01
> --
> 2.1.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 91371] Tonga HDMI Audio none on TV working on monitor - possible eld issue

2015-07-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91371

--- Comment #10 from Andy Furniss  ---
(In reply to Andy Furniss from comment #9)

> I played a bit more round this eld thing and it seems there is a bug 

Of course it's not a bug at all if you read FL/FR FC as stereo OR mono ...

Whatever it seems to be nothing to do with the issue here anyway.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150722/4a78b98c/attachment.html>


[PATCH 14/14] drm: gc now dead mode_group code

2015-07-22 Thread Maarten Lankhorst
Op 09-07-15 om 23:44 schreef Daniel Vetter:
> Two nice things here:
> - drm_dev_register will truly register everything in the right order
>   if the driver doesn't have a ->load callback. Before this we had to
>   init the primary mode_group after the device nodes where already
>   registered.
>
> - Less things to keep track of when reworking the connector locking,
>   yay!
>
Been wondering what it was when investigating the dp hotplug.
Patch series looks sane. :-)

r-b


[PATCH RESEND v2 25/25] drm/fb_cma_helper: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Lars-Peter Clausen 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 45 +
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index 5c1aca4..0da6a24 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -234,9 +234,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);

 static struct fb_ops drm_fbdev_cma_ops = {
.owner  = THIS_MODULE,
-   .fb_fillrect= sys_fillrect,
-   .fb_copyarea= sys_copyarea,
-   .fb_imageblit   = sys_imageblit,
+   .fb_fillrect= drm_fb_helper_sys_fillrect,
+   .fb_copyarea= drm_fb_helper_sys_copyarea,
+   .fb_imageblit   = drm_fb_helper_sys_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -275,10 +275,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,
if (IS_ERR(obj))
return -ENOMEM;

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
-   dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-   ret = -ENOMEM;
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
+   ret = PTR_ERR(fbi);
goto err_drm_gem_cma_free_object;
}

@@ -286,23 +285,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,
if (IS_ERR(fbdev_cma->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(fbdev_cma->fb);
-   goto err_framebuffer_release;
+   goto err_fb_info_destroy;
}

fb = _cma->fb->fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _fbdev_cma_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   dev_err(dev->dev, "Failed to allocate color map.\n");
-   goto err_drm_fb_cma_destroy;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -317,11 +309,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,

return 0;

-err_drm_fb_cma_destroy:
-   drm_framebuffer_unregister_private(fb);
-   drm_fb_cma_destroy(fb);
-err_framebuffer_release:
-   framebuffer_release(fbi);
+err_fb_info_destroy:
+   drm_fb_helper_release_fbi(helper);
 err_drm_gem_cma_free_object:
drm_gem_cma_free_object(>base);
return ret;
@@ -397,20 +386,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
  */
 void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
 {
-   if (fbdev_cma->fb_helper.fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = fbdev_cma->fb_helper.fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer()\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(_cma->fb_helper);
+   drm_fb_helper_release_fbi(_cma->fb_helper);

if (fbdev_cma->fb) {
drm_framebuffer_unregister_private(_cma->fb->fb);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 24/25] drm/virtio: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- add missing header for virtgpu_fb.c

Cc: David Airlie 
Cc: Gerd Hoffmann 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c |  3 ++-
 drivers/gpu/drm/virtio/virtgpu_drv.h |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c  | 32 +---
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c 
b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
index 88a3916..aea1bac 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
@@ -52,7 +52,8 @@ static void virtio_pci_kick_out_firmware_fb(struct pci_dev 
*pci_dev)
primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
& IORESOURCE_ROM_SHADOW;

-   remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb",
+   primary);

kfree(ap);
 }
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 6d4db2d..7b747ba 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c 
b/drivers/gpu/drm/virtio/virtgpu_fb.c
index df198d9..6a81e08 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -173,7 +173,7 @@ static void virtio_gpu_3d_fillrect(struct fb_info *info,
   const struct fb_fillrect *rect)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
virtio_gpu_dirty_update(>vgfb, true, rect->dx, rect->dy,
 rect->width, rect->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -183,7 +183,7 @@ static void virtio_gpu_3d_copyarea(struct fb_info *info,
   const struct fb_copyarea *area)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
virtio_gpu_dirty_update(>vgfb, true, area->dx, area->dy,
   area->width, area->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -193,7 +193,7 @@ static void virtio_gpu_3d_imageblit(struct fb_info *info,
const struct fb_image *image)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
virtio_gpu_dirty_update(>vgfb, true, image->dx, image->dy,
 image->width, image->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -230,7 +230,6 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd = {};
struct virtio_gpu_object *obj;
-   struct device *device = vgdev->dev;
uint32_t resid, format, size;
int ret;

@@ -317,18 +316,12 @@ static int virtio_gpufb_create(struct drm_fb_helper 
*helper,
if (ret)
goto err_obj_attach;

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto err_fb_alloc;
}

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto err_fb_alloc_cmap;
-   }
-
info->par = helper;

ret = virtio_gpu_framebuffer_init(dev, >vgfb,
@@ -339,7 +332,6 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
fb = >vgfb.base;

vfbdev->helper.fb = fb;
-   vfbdev->helper.fbdev = info;

strcpy(info->fix.id, "virtiodrmfb");
info->flags = FBINFO_DEFAULT;
@@ -357,9 +349,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
return 0;

 err_fb_init:
-   fb_dealloc_cmap(>cmap);
-err_fb_alloc_cmap:
-   framebuffer_release(info);
+   drm_fb_helper_release_fbi(helper);
 err_fb_alloc:
virtio_gpu_cmd_resource_inval_backing(vgdev, resid);
 err_obj_attach:
@@ -371,15 +361,11 @@ err_obj_vmap:
 static int virtio_gpu_fbdev_destroy(struct drm_device *dev,
struct virtio_gpu_fbdev *vgfbdev)
 {
-   struct fb_info *info;
struct virtio_gpu_framebuffer *vgfb = >vgfb;

-   if (vgfbdev->helper.fbdev) {
-   info = vgfbdev->helper.fbdev;
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

-   

[PATCH RESEND v2 23/25] drm/amdgpu: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- Fixed PTR_ERR issue mentioned by kbuild bot

Cc: Fengguang Wu 
Cc: Alex Deucher 
Cc: Oded Gabbay 
Cc: "Christian König" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  | 45 ++---
 2 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 56da962..52d7cfd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -35,6 +35,7 @@
 #include "amdgpu_drv.h"

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -267,7 +268,8 @@ static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb",
+   primary);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c1645d2..81b8212 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -179,7 +179,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct amdgpu_bo *rbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
unsigned long tmp;

@@ -201,9 +200,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
rbo = gem_to_amdgpu_bo(gobj);

/* okay we have an object now allocate the framebuffer */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -212,14 +211,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
ret = amdgpu_framebuffer_init(adev->ddev, >rfb, _cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_unref;
+   goto out_destroy_fbi;
}

fb = >rfb.base;

/* setup helper */
rfbdev->helper.fb = fb;
-   rfbdev->helper.fbdev = info;

memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo));

@@ -239,11 +237,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = adev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = adev->mc.aper_size;

@@ -251,13 +244,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -269,6 +256,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unref:
if (rbo) {

@@ -290,17 +279,10 @@ void amdgpu_fb_output_poll_changed(struct amdgpu_device 
*adev)

 static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev 
*rfbdev)
 {
-   struct fb_info *info;
struct amdgpu_framebuffer *rfb = >rfb;

-   if (rfbdev->helper.fbdev) {
-   info = rfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   

[PATCH RESEND v2 22/25] drm/bochs: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- remove unused variable device in bochsfb_create

Cc: David Airlie 
Cc: Gerd Hoffmann 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bochs/bochs_drv.c   |  6 +++---
 drivers/gpu/drm/bochs/bochs_fbdev.c | 36 +++-
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index 98837bd..7802fc6 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -109,7 +109,7 @@ static int bochs_pm_suspend(struct device *dev)

if (bochs->fb.initialized) {
console_lock();
-   fb_set_suspend(bochs->fb.helper.fbdev, 1);
+   drm_fb_helper_set_suspend(>fb.helper, 1);
console_unlock();
}

@@ -126,7 +126,7 @@ static int bochs_pm_resume(struct device *dev)

if (bochs->fb.initialized) {
console_lock();
-   fb_set_suspend(bochs->fb.helper.fbdev, 0);
+   drm_fb_helper_set_suspend(>fb.helper, 0);
console_unlock();
}

@@ -153,7 +153,7 @@ static int bochs_kick_out_firmware_fb(struct pci_dev *pdev)

ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0);
-   remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c 
b/drivers/gpu/drm/bochs/bochs_fbdev.c
index 976d979..09a0637 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -24,9 +24,9 @@ static struct fb_ops bochsfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -56,11 +56,9 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 {
struct bochs_device *bochs =
container_of(helper, struct bochs_device, fb.helper);
-   struct drm_device *dev = bochs->dev;
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
struct drm_gem_object *gobj = NULL;
struct bochs_bo *bo = NULL;
int size, ret;
@@ -106,22 +104,23 @@ static int bochsfb_create(struct drm_fb_helper *helper,
ttm_bo_unreserve(>bo);

/* init fb device */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = >fb.helper;

ret = bochs_framebuffer_init(bochs->dev, >fb.gfb, _cmd, 
gobj);
-   if (ret)
+   if (ret) {
+   drm_fb_helper_release_fbi(helper);
return ret;
+   }

bochs->fb.size = size;

/* setup helper */
fb = >fb.gfb.base;
bochs->fb.helper.fb = fb;
-   bochs->fb.helper.fbdev = info;

strcpy(info->fix.id, "bochsdrmfb");

@@ -139,30 +138,17 @@ static int bochsfb_create(struct drm_fb_helper *helper,
info->fix.smem_start = 0;
info->fix.smem_len = size;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
-   return -ENOMEM;
-   }
-
return 0;
 }

 static int bochs_fbdev_destroy(struct bochs_device *bochs)
 {
struct bochs_framebuffer *gfb = >fb.gfb;
-   struct fb_info *info;

DRM_DEBUG_DRIVER("\n");

-   if (bochs->fb.helper.fbdev) {
-   info = bochs->fb.helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>fb.helper);
+   drm_fb_helper_release_fbi(>fb.helper);

if (gfb->obj) {
drm_gem_object_unreference_unlocked(gfb->obj);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 21/25] drm/udl: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- remove unused variable device in udlfb_create

Cc: David Airlie 
Cc: Haixia Shi 
Cc: "Stéphane Marchesin" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/udl/udl_fb.c | 41 -
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 5fc16ce..62c7b1d 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -288,7 +288,7 @@ static void udl_fb_fillrect(struct fb_info *info, const 
struct fb_fillrect *rect
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);

udl_handle_damage(>ufb, rect->dx, rect->dy, rect->width,
  rect->height);
@@ -298,7 +298,7 @@ static void udl_fb_copyarea(struct fb_info *info, const 
struct fb_copyarea *regi
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_copyarea(info, region);
+   drm_fb_helper_sys_copyarea(info, region);

udl_handle_damage(>ufb, region->dx, region->dy, region->width,
  region->height);
@@ -308,7 +308,7 @@ static void udl_fb_imageblit(struct fb_info *info, const 
struct fb_image *image)
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);

udl_handle_damage(>ufb, image->dx, image->dy, image->width,
  image->height);
@@ -476,7 +476,6 @@ static int udlfb_create(struct drm_fb_helper *helper,
container_of(helper, struct udl_fbdev, helper);
struct drm_device *dev = ufbdev->helper.dev;
struct fb_info *info;
-   struct device *device = dev->dev;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
struct udl_gem_object *obj;
@@ -506,21 +505,20 @@ static int udlfb_create(struct drm_fb_helper *helper,
goto out_gfree;
}

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_gfree;
}
info->par = ufbdev;

ret = udl_framebuffer_init(dev, >ufb, _cmd, obj);
if (ret)
-   goto out_gfree;
+   goto out_destroy_fbi;

fb = >ufb.base;

ufbdev->helper.fb = fb;
-   ufbdev->helper.fbdev = info;

strcpy(info->fix.id, "udldrmfb");

@@ -533,18 +531,13 @@ static int udlfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_gfree;
-   }
-
-
DRM_DEBUG_KMS("allocated %dx%d vmal %p\n",
  fb->width, fb->height,
  ufbdev->ufb.obj->vmapping);

return ret;
+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_gfree:
drm_gem_object_unreference(>ufb.obj->base);
 out:
@@ -558,14 +551,8 @@ static const struct drm_fb_helper_funcs 
udl_fb_helper_funcs = {
 static void udl_fbdev_destroy(struct drm_device *dev,
  struct udl_fbdev *ufbdev)
 {
-   struct fb_info *info;
-   if (ufbdev->helper.fbdev) {
-   info = ufbdev->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);
drm_fb_helper_fini(>helper);
drm_framebuffer_unregister_private(>ufb.base);
drm_framebuffer_cleanup(>ufb.base);
@@ -631,11 +618,7 @@ void udl_fbdev_unplug(struct drm_device *dev)
return;

ufbdev = udl->fbdev;
-   if (ufbdev->helper.fbdev) {
-   struct fb_info *info;
-   info = ufbdev->helper.fbdev;
-   unlink_framebuffer(info);
-   }
+   drm_fb_helper_unlink_fbi(>helper);
 }

 struct drm_framebuffer *
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 20/25] drm/nouveau: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- remove unused variable pdev in nouveau_fbcon_create

Cc: David Airlie 
Cc: Ben Skeggs 
Cc: Alexandre Courbot 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  3 ++-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 39 ++---
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 649024d..01d3fb2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -317,7 +317,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
 #endif
if (nouveau_modeset != 2)
-   remove_conflicting_framebuffers(aper, "nouveaufb", boot);
+   drm_fb_helper_remove_conflicting_framebuffers(aper, "nouveaufb",
+   boot);
kfree(aper);

ret = nvkm_device_create(pdev, NVKM_BUS_PCI,
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 6751553..2791701 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -84,7 +84,7 @@ nouveau_fbcon_fillrect(struct fb_info *info, const struct 
fb_fillrect *rect)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_fillrect(info, rect);
+   drm_fb_helper_cfb_fillrect(info, rect);
 }

 static void
@@ -116,7 +116,7 @@ nouveau_fbcon_copyarea(struct fb_info *info, const struct 
fb_copyarea *image)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_copyarea(info, image);
+   drm_fb_helper_cfb_copyarea(info, image);
 }

 static void
@@ -148,7 +148,7 @@ nouveau_fbcon_imageblit(struct fb_info *info, const struct 
fb_image *image)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_imageblit(info, image);
+   drm_fb_helper_cfb_imageblit(info, image);
 }

 static int
@@ -197,9 +197,9 @@ static struct fb_ops nouveau_fbcon_sw_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -319,7 +319,6 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
struct nouveau_channel *chan;
struct nouveau_bo *nvbo;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct pci_dev *pdev = dev->pdev;
int size, ret;

mode_cmd.width = sizes->surface_width;
@@ -365,20 +364,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,

mutex_lock(>struct_mutex);

-   info = framebuffer_alloc(0, >dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unlock;
}
info->skip_vt_switch = 1;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   framebuffer_release(info);
-   goto out_unlock;
-   }
-
info->par = fbcon;

nouveau_framebuffer_init(dev, >nouveau_fb, _cmd, nvbo);
@@ -388,7 +380,6 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,

/* setup helper */
fbcon->helper.fb = fb;
-   fbcon->helper.fbdev = info;

strcpy(info->fix.id, "nouveaufb");
if (!chan)
@@ -450,15 +441,9 @@ static int
 nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
 {
struct nouveau_framebuffer *nouveau_fb = >nouveau_fb;
-   struct fb_info *info;

-   if (fbcon->helper.fbdev) {
-   info = fbcon->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (nouveau_fb->nvbo) {
nouveau_bo_unmap(nouveau_fb->nvbo);
@@ -496,7 +481,7 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
console_lock();
if (state == FBINFO_STATE_RUNNING)
nouveau_fbcon_accel_restore(dev);
-   fb_set_suspend(drm->fbcon->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>fbcon->helper, state);
if 

[PATCH RESEND v2 19/25] drm/i915: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Daniel Vetter 
Cc: Jani Nikula 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/i915/i915_dma.c|  3 ++-
 drivers/gpu/drm/i915/intel_fbdev.c | 40 --
 2 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index d2df321..10f6019 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -498,7 +498,8 @@ static int i915_kick_out_firmware_fb(struct 
drm_i915_private *dev_priv)
primary =
pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;

-   ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
+   ret = drm_fb_helper_remove_conflicting_framebuffers(ap, "inteldrmfb",
+   primary);

kfree(ap);

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index 6372cfc..4aa21f7 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -126,9 +126,9 @@ static struct fb_ops intelfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = intel_fbdev_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = intel_fbdev_pan_display,
.fb_blank = intel_fbdev_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -237,9 +237,9 @@ static int intelfb_create(struct drm_fb_helper *helper,
obj = intel_fb->obj;
size = obj->base.size;

-   info = framebuffer_alloc(0, >pdev->dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unpin;
}

@@ -248,24 +248,13 @@ static int intelfb_create(struct drm_fb_helper *helper,
fb = >fb->base;

ifbdev->helper.fb = fb;
-   ifbdev->helper.fbdev = info;

strcpy(info->fix.id, "inteldrmfb");

info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = _ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unpin;
-   }
/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unpin;
-   }
info->apertures->ranges[0].base = dev->mode_config.fb_base;
info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;

@@ -277,7 +266,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
   size);
if (!info->screen_base) {
ret = -ENOSPC;
-   goto out_unpin;
+   goto out_destroy_fbi;
}
info->screen_size = size;

@@ -304,6 +293,8 @@ static int intelfb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(dev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unpin:
i915_gem_object_ggtt_unpin(obj);
drm_gem_object_unreference(>base);
@@ -550,16 +541,9 @@ static const struct drm_fb_helper_funcs 
intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
struct intel_fbdev *ifbdev)
 {
-   if (ifbdev->helper.fbdev) {
-   struct fb_info *info = ifbdev->helper.fbdev;

-   unregister_framebuffer(info);
-   iounmap(info->screen_base);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

drm_fb_helper_fini(>helper);

@@ -810,7 +794,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size);

-   fb_set_suspend(info, state);
+   drm_fb_helper_set_suspend(>helper, state);
console_unlock();
 }

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 18/25] drm/qxl: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: David Airlie 
Cc: Frediano Ziglio 
Cc: Maarten Lankhorst 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/qxl/qxl_fb.c | 40 +---
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 6b6e57e..41c422f 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -197,7 +197,7 @@ static void qxl_fb_fillrect(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
qxl_dirty_update(qfbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -207,7 +207,7 @@ static void qxl_fb_copyarea(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
qxl_dirty_update(qfbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -217,7 +217,7 @@ static void qxl_fb_imageblit(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
qxl_dirty_update(qfbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -345,7 +345,6 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct qxl_bo *qbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
int size;
int bpp = sizes->surface_bpp;
@@ -374,9 +373,9 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
 shadow);
size = mode_cmd.pitches[0] * mode_cmd.height;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(>helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -388,7 +387,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,

/* setup helper with fb data */
qfbdev->helper.fb = fb;
-   qfbdev->helper.fbdev = info;
+
qfbdev->shadow = shadow;
strcpy(info->fix.id, "qxldrmfb");

@@ -410,11 +409,6 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
   sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = qdev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = qdev->vram_size;

@@ -423,13 +417,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

info->fbdefio = _defio;
@@ -441,6 +429,8 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
DRM_INFO("fb: depth %d, pitch %d, width %d, height %d\n", fb->depth, 
fb->pitches[0], fb->width, fb->height);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(>helper);
 out_unref:
if (qbo) {
ret = qxl_bo_reserve(qbo, false);
@@ -479,15 +469,11 @@ static int qxl_fb_find_or_create_single(

 static int qxl_fbdev_destroy(struct drm_device *dev, struct qxl_fbdev *qfbdev)
 {
-   struct fb_info *info;
struct qxl_framebuffer *qfb = >qfb;

-   if (qfbdev->helper.fbdev) {
-   info = qfbdev->helper.fbdev;
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

-   unregister_framebuffer(info);
-   framebuffer_release(info);
-   }
if (qfb->obj) {
qxlfb_destroy_pinned_object(qfb->obj);
qfb->obj = NULL;
@@ -557,7 +543,7 @@ void qxl_fbdev_fini(struct qxl_device *qdev)

 void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state)
 {
-   fb_set_suspend(qdev->mode_info.qfbdev->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>mode_info.qfbdev->helper, state);
 }

 bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 17/25] drm/radeon: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- Fix build break because of missing include of drm_fb_helper in
  radeon_drv.c

Cc: Alex Deucher 
Cc: "Christian König" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/radeon/radeon_drv.c |  4 +++-
 drivers/gpu/drm/radeon/radeon_fb.c  | 42 +++--
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 5751446..98ee541 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "drm_crtc_helper.h"
 #include "radeon_kfd.h"
@@ -390,7 +391,8 @@ static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb",
+   primary);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c 
b/drivers/gpu/drm/radeon/radeon_fb.c
index 634793e..e0fcd3d 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -82,9 +82,9 @@ static struct fb_ops radeonfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = radeon_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -227,7 +227,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct radeon_bo *rbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
unsigned long tmp;

@@ -250,9 +249,9 @@ static int radeonfb_create(struct drm_fb_helper *helper,
rbo = gem_to_radeon_bo(gobj);

/* okay we have an object now allocate the framebuffer */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -261,14 +260,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
ret = radeon_framebuffer_init(rdev->ddev, >rfb, _cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_unref;
+   goto out_destroy_fbi;
}

fb = >rfb.base;

/* setup helper */
rfbdev->helper.fb = fb;
-   rfbdev->helper.fbdev = info;

memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));

@@ -288,11 +286,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = rdev->mc.aper_size;

@@ -300,13 +293,7 @@ static int radeonfb_create(struct drm_fb_helper *helper,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -318,6 +305,8 @@ static int radeonfb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unref:
if (rbo) {

@@ -338,17 +327,10 @@ void radeon_fb_output_poll_changed(struct radeon_device 
*rdev)

 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev 
*rfbdev)
 {
-   struct fb_info *info;
struct radeon_framebuffer *rfb = >rfb;

-   if (rfbdev->helper.fbdev) {
-   info = rfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+  

[PATCH RESEND v2 16/25] drm/mgag200: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- remove unused goto label 'out'

Cc: Daniel Vetter 
Cc: David Airlie 
Cc: Alex Deucher 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c  |  3 ++-
 drivers/gpu/drm/mgag200/mgag200_fb.c   | 39 +++---
 drivers/gpu/drm/mgag200/mgag200_main.c |  2 +-
 3 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 9774599..38363f8 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -55,7 +55,8 @@ static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "mgag200drmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb",
+   primary);
kfree(ap);
 }

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index c36b830..dc06f8b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -101,7 +101,7 @@ static void mga_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
mga_dirty_update(mfbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -110,7 +110,7 @@ static void mga_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
mga_dirty_update(mfbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -119,7 +119,7 @@ static void mga_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
mga_dirty_update(mfbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -166,7 +166,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_gem_object *gobj = NULL;
-   struct device *device = >pdev->dev;
struct mgag200_bo *bo;
int ret;
void *sysram;
@@ -191,9 +190,9 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = mfbdev;

@@ -208,14 +207,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,

/* setup helper */
mfbdev->helper.fb = fb;
-   mfbdev->helper.fbdev = info;
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
-   ret = -ENOMEM;
-   goto out;
-   }

strcpy(info->fix.id, "mgadrmfb");

@@ -223,11 +214,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
info->fbops = _ops;

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out;
-   }
info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base;
info->apertures->ranges[0].size = mdev->mc.vram_size;

@@ -242,24 +228,15 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_DEBUG_KMS("allocated %dx%d\n",
  fb->width, fb->height);
return 0;
-out:
-   return ret;
 }

 static int mga_fbdev_destroy(struct drm_device *dev,
struct mga_fbdev *mfbdev)
 {
-   struct fb_info *info;
struct mga_framebuffer *mfb = >mfb;

-   if (mfbdev->helper.fbdev) {
-   info = mfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (mfb->obj) {
drm_gem_object_unreference_unlocked(mfb->obj);
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index f6b283b..b435d3c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ 

[PATCH RESEND v2 15/25] drm/gma500: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- removed unused variable 'device' in psbfb_create

Cc: Patrik Jakobsson 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/gma500/accel_2d.c|  6 ++---
 drivers/gpu/drm/gma500/framebuffer.c | 48 
 2 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/gma500/accel_2d.c 
b/drivers/gpu/drm/gma500/accel_2d.c
index de6f62a..db9f7d0 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -276,12 +276,12 @@ static void psbfb_copyarea_accel(struct fb_info *info,
break;
default:
/* software fallback */
-   cfb_copyarea(info, a);
+   drm_fb_helper_cfb_copyarea(info, a);
return;
}

if (!gma_power_begin(dev, false)) {
-   cfb_copyarea(info, a);
+   drm_fb_helper_cfb_copyarea(info, a);
return;
}
psb_accel_2d_copy(dev_priv,
@@ -308,7 +308,7 @@ void psbfb_copyarea(struct fb_info *info,
/* Avoid the 8 pixel erratum */
if (region->width == 8 || region->height == 8 ||
(info->flags & FBINFO_HWACCEL_DISABLED))
-   return cfb_copyarea(info, region);
+   return drm_fb_helper_cfb_copyarea(info, region);

psbfb_copyarea_accel(info, region);
 }
diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 2d42ce6..2eaf1b3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -194,9 +194,9 @@ static struct fb_ops psbfb_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = psbfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_mmap = psbfb_mmap,
.fb_sync = psbfb_sync,
.fb_ioctl = psbfb_ioctl,
@@ -208,9 +208,9 @@ static struct fb_ops psbfb_roll_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = psbfb_pan,
.fb_mmap = psbfb_mmap,
.fb_ioctl = psbfb_ioctl,
@@ -222,9 +222,9 @@ static struct fb_ops psbfb_unaccel_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_mmap = psbfb_mmap,
.fb_ioctl = psbfb_ioctl,
 };
@@ -343,7 +343,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
struct drm_framebuffer *fb;
struct psb_framebuffer *psbfb = >pfb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
int size;
int ret;
struct gtt_range *backing;
@@ -409,9 +408,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,

mutex_lock(>struct_mutex);

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(>psb_fb_helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_err1;
}
info->par = fbdev;
@@ -426,7 +425,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
psbfb->fbdev = info;

fbdev->psb_fb_helper.fb = fb;
-   fbdev->psb_fb_helper.fbdev = info;

drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
strcpy(info->fix.id, "psbdrmfb");
@@ -440,12 +438,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
} else  /* Software */
info->fbops = _unaccel_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
-
info->fix.smem_start = dev->mode_config.fb_base;
info->fix.smem_len = size;
info->fix.ywrapstep = gtt_roll;
@@ -456,11 +448,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
info->screen_size = size;

if (dev_priv->gtt.stolen_size) {
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-

[PATCH RESEND v2 14/25] drm/exynos: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- Remove unnecessary dealloc cmap in error handling path

Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Seung-Woo Kim 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 47 ---
 1 file changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e0b085b..dd64bc0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -65,9 +65,9 @@ static int exynos_drm_fb_mmap(struct fb_info *info,
 static struct fb_ops exynos_drm_fb_ops = {
.owner  = THIS_MODULE,
.fb_mmap= exynos_drm_fb_mmap,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -142,10 +142,10 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,

mutex_lock(>struct_mutex);

-   fbi = framebuffer_alloc(0, >dev);
-   if (!fbi) {
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
DRM_ERROR("failed to allocate fb info.\n");
-   ret = -ENOMEM;
+   ret = PTR_ERR(fbi);
goto out;
}

@@ -165,7 +165,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,

if (IS_ERR(exynos_gem_obj)) {
ret = PTR_ERR(exynos_gem_obj);
-   goto err_release_framebuffer;
+   goto err_release_fbi;
}

exynos_fbdev->exynos_gem_obj = exynos_gem_obj;
@@ -178,33 +178,23 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,
goto err_destroy_gem;
}

-   helper->fbdev = fbi;
-
fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _drm_fb_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("failed to allocate cmap.\n");
-   goto err_destroy_framebuffer;
-   }
-
ret = exynos_drm_fbdev_update(helper, sizes, helper->fb);
if (ret < 0)
-   goto err_dealloc_cmap;
+   goto err_destroy_framebuffer;

mutex_unlock(>struct_mutex);
return ret;

-err_dealloc_cmap:
-   fb_dealloc_cmap(>cmap);
 err_destroy_framebuffer:
drm_framebuffer_cleanup(helper->fb);
 err_destroy_gem:
exynos_drm_gem_destroy(exynos_gem_obj);
-err_release_framebuffer:
-   framebuffer_release(fbi);
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);

 /*
  * if failed, all resources allocated above would be released by
@@ -312,21 +302,8 @@ static void exynos_drm_fbdev_destroy(struct drm_device 
*dev,
}
}

-   /* release linux framebuffer */
-   if (fb_helper->fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = fb_helper->fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer()\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(fb_helper);
+   drm_fb_helper_release_fbi(fb_helper);

drm_fb_helper_fini(fb_helper);
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 13/25] drm/msm: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Rob Clark 
Cc: Stephane Viau 
Cc: Hai Li 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/msm/msm_fbdev.c | 34 ++
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 95f6532..f97a196 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -43,11 +43,11 @@ static struct fb_ops msm_fb_ops = {
/* Note: to properly handle manual update displays, we wrap the
 * basic fbdev ops which write to the framebuffer
 */
-   .fb_read = fb_sys_read,
-   .fb_write = fb_sys_write,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_read = drm_fb_helper_sys_read,
+   .fb_write = drm_fb_helper_sys_write,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_mmap = msm_fbdev_mmap,

.fb_check_var = drm_fb_helper_check_var,
@@ -144,10 +144,10 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
goto fail_unlock;
}

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
dev_err(dev->dev, "failed to allocate fb info\n");
-   ret = -ENOMEM;
+   ret = PTR_ERR(fbi);
goto fail_unlock;
}

@@ -155,7 +155,6 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,

fbdev->fb = fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_DEFAULT;
@@ -163,12 +162,6 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,

strcpy(fbi->fix.id, "msm");

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto fail_unlock;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -191,7 +184,6 @@ fail_unlock:
 fail:

if (ret) {
-   framebuffer_release(fbi);
if (fb) {
drm_framebuffer_unregister_private(fb);
drm_framebuffer_remove(fb);
@@ -266,17 +258,11 @@ void msm_fbdev_free(struct drm_device *dev)
struct msm_drm_private *priv = dev->dev_private;
struct drm_fb_helper *helper = priv->fbdev;
struct msm_fbdev *fbdev;
-   struct fb_info *fbi;

DBG();

-   fbi = helper->fbdev;
-
-   /* only cleanup framebuffer if it is present */
-   if (fbi) {
-   unregister_framebuffer(fbi);
-   framebuffer_release(fbi);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

drm_fb_helper_fini(helper);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 12/25] drm/tegra: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

v2:
- Fix up error handling path in tegra_fbdev_probe

Cc: Thierry Reding 
Cc: "Terje Bergström" 
Cc: Stephen Warren 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/tegra/fb.c | 35 +--
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 397fb34..07c844b 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -184,9 +184,9 @@ unreference:
 #ifdef CONFIG_DRM_TEGRA_FBDEV
 static struct fb_ops tegra_fb_ops = {
.owner = THIS_MODULE,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
@@ -224,11 +224,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
if (IS_ERR(bo))
return PTR_ERR(bo);

-   info = framebuffer_alloc(0, drm->dev);
-   if (!info) {
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
dev_err(drm->dev, "failed to allocate framebuffer info\n");
drm_gem_object_unreference_unlocked(>gem);
-   return -ENOMEM;
+   return PTR_ERR(info);
}

fbdev->fb = tegra_fb_alloc(drm, , , 1);
@@ -248,12 +248,6 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
info->flags = FBINFO_FLAG_DEFAULT;
info->fbops = _fb_ops;

-   err = fb_alloc_cmap(>cmap, 256, 0);
-   if (err < 0) {
-   dev_err(drm->dev, "failed to allocate color map: %d\n", err);
-   goto destroy;
-   }
-
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(info, helper, fb->width, fb->height);

@@ -282,7 +276,7 @@ destroy:
drm_framebuffer_unregister_private(fb);
tegra_fb_destroy(fb);
 release:
-   framebuffer_release(info);
+   drm_fb_helper_release_fbi(helper);
return err;
 }

@@ -347,20 +341,9 @@ fini:

 static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
 {
-   struct fb_info *info = fbdev->base.fbdev;
-
-   if (info) {
-   int err;

-   err = unregister_framebuffer(info);
-   if (err < 0)
-   DRM_DEBUG_KMS("failed to unregister framebuffer\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>base);
+   drm_fb_helper_release_fbi(>base);

if (fbdev->fb) {
drm_framebuffer_unregister_private(>fb->base);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 11/25] drm/omap: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Tomi Valkeinen 
Cc: Laurent Pinchart 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 34 +++---
 1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c 
b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 23b5a84..a388a85 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -86,11 +86,11 @@ static struct fb_ops omap_fb_ops = {
/* Note: to properly handle manual update displays, we wrap the
 * basic fbdev ops which write to the framebuffer
 */
-   .fb_read = fb_sys_read,
-   .fb_write = fb_sys_write,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_read = drm_fb_helper_sys_read,
+   .fb_write = drm_fb_helper_sys_write,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,

.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
@@ -179,7 +179,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

mutex_lock(>struct_mutex);

-   fbi = framebuffer_alloc(0, dev->dev);
+   fbi = drm_fb_helper_alloc_fbi(helper);
if (!fbi) {
dev_err(dev->dev, "failed to allocate fb info\n");
ret = -ENOMEM;
@@ -190,7 +190,6 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

fbdev->fb = fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_DEFAULT;
@@ -198,12 +197,6 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

strcpy(fbi->fix.id, MODULE_NAME);

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto fail_unlock;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -236,8 +229,9 @@ fail_unlock:
 fail:

if (ret) {
-   if (fbi)
-   framebuffer_release(fbi);
+
+   drm_fb_helper_release_fbi(helper);
+
if (fb) {
drm_framebuffer_unregister_private(fb);
drm_framebuffer_remove(fb);
@@ -312,17 +306,11 @@ void omap_fbdev_free(struct drm_device *dev)
struct omap_drm_private *priv = dev->dev_private;
struct drm_fb_helper *helper = priv->fbdev;
struct omap_fbdev *fbdev;
-   struct fb_info *fbi;

DBG();

-   fbi = helper->fbdev;
-
-   /* only cleanup framebuffer if it is present */
-   if (fbi) {
-   unregister_framebuffer(fbi);
-   framebuffer_release(fbi);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

drm_fb_helper_fini(helper);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 10/25] drm/ast: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cleaned up the error handling in astfb_create a bit.

v2:
- removed unused variable 'device' in astfb_create

Cc: David Airlie 
Cc: "Y.C. Chen" 
Cc: Alex Deucher 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/ast/ast_fb.c | 48 
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index ff68eef..f31db28 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -125,7 +125,7 @@ static void ast_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
ast_dirty_update(afbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -134,7 +134,7 @@ static void ast_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
ast_dirty_update(afbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -143,7 +143,7 @@ static void ast_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
ast_dirty_update(afbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -193,7 +193,6 @@ static int astfb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct fb_info *info;
int size, ret;
-   struct device *device = >pdev->dev;
void *sysram;
struct drm_gem_object *gobj = NULL;
struct ast_bo *bo = NULL;
@@ -217,40 +216,28 @@ static int astfb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
-   goto out;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
+   goto err_free_vram;
}
info->par = afbdev;

ret = ast_framebuffer_init(dev, >afb, _cmd, gobj);
if (ret)
-   goto out;
+   goto err_release_fbi;

afbdev->sysram = sysram;
afbdev->size = size;

fb = >afb.base;
afbdev->helper.fb = fb;
-   afbdev->helper.fbdev = info;

strcpy(info->fix.id, "astdrmfb");

info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = _ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out;
-   }
-
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out;
-   }
info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);

@@ -266,7 +253,11 @@ static int astfb_create(struct drm_fb_helper *helper,
  fb->width, fb->height);

return 0;
-out:
+
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);
+err_free_vram:
+   vfree(afbdev->sysram);
return ret;
 }

@@ -297,15 +288,10 @@ static const struct drm_fb_helper_funcs 
ast_fb_helper_funcs = {
 static void ast_fbdev_destroy(struct drm_device *dev,
  struct ast_fbdev *afbdev)
 {
-   struct fb_info *info;
struct ast_framebuffer *afb = >afb;
-   if (afbdev->helper.fbdev) {
-   info = afbdev->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (afb->obj) {
drm_gem_object_unreference_unlocked(afb->obj);
@@ -377,5 +363,5 @@ void ast_fbdev_set_suspend(struct drm_device *dev, int 
state)
if (!ast->fbdev)
return;

-   fb_set_suspend(ast->fbdev->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>fbdev->helper, state);
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 09/25] drm/armada: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Russell King 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/armada/armada_fbdev.c | 33 ++---
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 7838e73..7d03c51 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -22,9 +22,9 @@ static /*const*/ struct fb_ops armada_fb_ops = {
.owner  = THIS_MODULE,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank   = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -80,18 +80,12 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
if (IS_ERR(dfb))
return PTR_ERR(dfb);

-   info = framebuffer_alloc(0, dev->dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(fbh);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto err_fballoc;
}

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto err_fbcmap;
-   }
-
strlcpy(info->fix.id, "armada-drmfb", sizeof(info->fix.id));
info->par = fbh;
info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
@@ -101,7 +95,7 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
info->screen_size = obj->obj.size;
info->screen_base = ptr;
fbh->fb = >fb;
-   fbh->fbdev = info;
+
drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth);
drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);

@@ -111,8 +105,6 @@ static int armada_fb_create(struct drm_fb_helper *fbh,

return 0;

- err_fbcmap:
-   framebuffer_release(info);
  err_fballoc:
dfb->fb.funcs->destroy(>fb);
return ret;
@@ -171,6 +163,7 @@ int armada_fbdev_init(struct drm_device *dev)

return 0;
  err_fb_setup:
+   drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
  err_fb_helper:
priv->fbdev = NULL;
@@ -191,14 +184,8 @@ void armada_fbdev_fini(struct drm_device *dev)
struct drm_fb_helper *fbh = priv->fbdev;

if (fbh) {
-   struct fb_info *info = fbh->fbdev;
-
-   if (info) {
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(fbh);
+   drm_fb_helper_release_fbi(fbh);

drm_fb_helper_fini(fbh);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 08/25] drm/rockchip: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

This is an effort to create a top level drm fbdev emulation option.

Cc: Mark Yao 
Cc: Daniel Vetter 
Cc: Rob Clark 
Cc: Daniel Kurtz 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 47 +++
 1 file changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 5b0dc0f..f261512 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -37,9 +37,9 @@ static int rockchip_fbdev_mmap(struct fb_info *info,
 static struct fb_ops rockchip_drm_fbdev_ops = {
.owner  = THIS_MODULE,
.fb_mmap= rockchip_fbdev_mmap,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -77,10 +77,10 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,

private->fbdev_bo = _obj->base;

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
-   dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-   ret = -ENOMEM;
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
+   dev_err(dev->dev, "Failed to create framebuffer info.\n");
+   ret = PTR_ERR(fbi);
goto err_rockchip_gem_free_object;
}

@@ -89,21 +89,13 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,
if (IS_ERR(helper->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(helper->fb);
-   goto err_framebuffer_release;
+   goto err_release_fbi;
}

-   helper->fbdev = fbi;
-
fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _drm_fbdev_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   dev_err(dev->dev, "Failed to allocate color map.\n");
-   goto err_drm_framebuffer_unref;
-   }
-
fb = helper->fb;
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
@@ -124,10 +116,8 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,

return 0;

-err_drm_framebuffer_unref:
-   drm_framebuffer_unreference(helper->fb);
-err_framebuffer_release:
-   framebuffer_release(fbi);
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);
 err_rockchip_gem_free_object:
rockchip_gem_free_object(_obj->base);
return ret;
@@ -190,21 +180,8 @@ void rockchip_drm_fbdev_fini(struct drm_device *dev)

helper = >fbdev_helper;

-   if (helper->fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = helper->fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer() - %d\n",
- ret);
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

if (helper->fb)
drm_framebuffer_unreference(helper->fb);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 07/25] drm/cirrus: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly.

v2:
- Remove stray goto label out_iounmap

Cc: Thierry Reding 
Cc: Zach Reizner 
Cc: Russell King 
Cc: Fabian Frederick 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c   |  7 +++---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 41 +++
 2 files changed, 12 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index b914003..08bd176 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -56,7 +56,8 @@ static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb",
+   primary);
kfree(ap);

return 0;
@@ -92,7 +93,7 @@ static int cirrus_pm_suspend(struct device *dev)

if (cdev->mode_info.gfbdev) {
console_lock();
-   fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 1);
+   drm_fb_helper_set_suspend(>mode_info.gfbdev->helper, 1);
console_unlock();
}

@@ -109,7 +110,7 @@ static int cirrus_pm_resume(struct device *dev)

if (cdev->mode_info.gfbdev) {
console_lock();
-   fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 0);
+   drm_fb_helper_set_suspend(>mode_info.gfbdev->helper, 0);
console_unlock();
}

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 13ddf1c..589103b 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -98,7 +98,7 @@ static void cirrus_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
cirrus_dirty_update(afbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -107,7 +107,7 @@ static void cirrus_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
cirrus_dirty_update(afbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -116,7 +116,7 @@ static void cirrus_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
cirrus_dirty_update(afbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -165,12 +165,10 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 {
struct cirrus_fbdev *gfbdev =
container_of(helper, struct cirrus_fbdev, helper);
-   struct drm_device *dev = gfbdev->helper.dev;
struct cirrus_device *cdev = gfbdev->helper.dev->dev_private;
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
void *sysram;
struct drm_gem_object *gobj = NULL;
struct cirrus_bo *bo = NULL;
@@ -195,9 +193,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = gfbdev;

@@ -216,11 +214,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper,

/* setup helper */
gfbdev->helper.fb = fb;
-   gfbdev->helper.fbdev = info;

strcpy(info->fix.id, "cirrusdrmfb");

-
info->flags = FBINFO_DEFAULT;
info->fbops = _ops;

@@ -229,11 +225,6 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
   sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_iounmap;
-   }
info->apertures->ranges[0].base = cdev->dev->mode_config.fb_base;
info->apertures->ranges[0].size = cdev->mc.vram_size;

@@ -246,13 +237,6 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
info->fix.mmio_start = 0;
info->fix.mmio_len = 0;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-

[PATCH RESEND v2 06/25] drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers

2015-07-22 Thread Archit Taneja
Some drm drivers call remove_conflicting_framebuffers. Create a
drm_fb_helper function that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

v2:
- Added kerneldocs
- Follow the drm way of aligning of arguments in func definitions

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 15 +++
 include/drm/drm_fb_helper.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9620aa5..86e4e2c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -894,6 +894,21 @@ void drm_fb_helper_set_suspend(struct drm_fb_helper 
*fb_helper, int state)
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend);

+/**
+ * drm_fb_helper_remove_conflicting_framebuffers - wrapper around
+ * remove_conflicting_framebuffers
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around remove_conflicting_framebuffers implemented by fbdev core
+ */
+int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
+ const char *name,
+ bool primary)
+{
+   return remove_conflicting_framebuffers(a, name, primary);
+}
+EXPORT_SYMBOL(drm_fb_helper_remove_conflicting_framebuffers);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index ef32500..cbdc69d 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -168,6 +168,10 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info,

 void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state);

+int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
+ const char *name,
+ bool primary);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 05/25] drm/fb_helper: Create a wrapper for fb_set_suspend

2015-07-22 Thread Archit Taneja
Some drm drivers call fb_set_suspend. Create a drm_fb_helper function
that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

v2:
- Added kerneldocs
- Added a check for non-NULL fb_helper before proceeding. This will
  make the helpers work when we have a module param for fbdev emulation
- Follow the drm way of aligning of arguments in func definitions

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 13 +
 include/drm/drm_fb_helper.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1312b6b..9620aa5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -881,6 +881,19 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info,
 }
 EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);

+/**
+ * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_set_suspend implemented by fbdev core
+ */
+void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state)
+{
+   if (fb_helper && fb_helper->fbdev)
+   fb_set_suspend(fb_helper->fbdev, state);
+}
+EXPORT_SYMBOL(drm_fb_helper_set_suspend);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 180290e..ef32500 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -166,6 +166,8 @@ void drm_fb_helper_cfb_copyarea(struct fb_info *info,
 void drm_fb_helper_cfb_imageblit(struct fb_info *info,
 const struct fb_image *image);

+void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 04/25] drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs

2015-07-22 Thread Archit Taneja
drm drivers that emulate fbdev populate their fb_fillrect, fb_copyarea
and fb_imageblit fb_ops with the help of cfb_* or sys_* fbdev core
helper functions.

Create drm_fb_helper functions that wrap around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

v2:
- Added kerneldocs
- Follow the drm way of aligning of arguments in func definitions
- Remove unnecessary checks for non NULL fb_info

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/Kconfig |  6 
 drivers/gpu/drm/drm_fb_helper.c | 78 +
 include/drm/drm_fb_helper.h | 14 
 3 files changed, 98 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 6ab503b..35a8c0b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -38,6 +38,12 @@ config DRM_KMS_FB_HELPER
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
select FB_SYS_FOPS
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index abb36f9..1312b6b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -803,6 +803,84 @@ ssize_t drm_fb_helper_sys_write(struct fb_info *info, 
const char __user *buf,
 }
 EXPORT_SYMBOL(drm_fb_helper_sys_write);

+/**
+ * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_fillrect implemented by fbdev core
+ */
+void drm_fb_helper_sys_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect)
+{
+   sys_fillrect(info, rect);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
+
+/**
+ * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_copyarea implemented by fbdev core
+ */
+void drm_fb_helper_sys_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area)
+{
+   sys_copyarea(info, area);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
+
+/**
+ * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_sys_imageblit(struct fb_info *info,
+const struct fb_image *image)
+{
+   sys_imageblit(info, image);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
+
+/**
+ * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_cfb_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect)
+{
+   cfb_fillrect(info, rect);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect);
+
+/**
+ * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_copyarea implemented by fbdev core
+ */
+void drm_fb_helper_cfb_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area)
+{
+   cfb_copyarea(info, area);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea);
+
+/**
+ * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_cfb_imageblit(struct fb_info *info,
+const struct fb_image *image)
+{
+   cfb_imageblit(info, image);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index fc12368..180290e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -152,6 +152,20 @@ ssize_t drm_fb_helper_sys_read(struct fb_info *info, char 
__user *buf,
 ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos);

+void drm_fb_helper_sys_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect);
+void drm_fb_helper_sys_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area);
+void drm_fb_helper_sys_imageblit(struct fb_info *info,
+const struct fb_image *image);
+
+void drm_fb_helper_cfb_fillrect(struct fb_info *info,
+   const struct fb_fillrect 

[PATCH RESEND v2 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-22 Thread Archit Taneja
Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
ops.

Create a drm_fb_helper function that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

v2:
- Added kerneldocs
- Follow the drm way of aligning of arguments in func definitions
- Remove unnecessary checks for non NULL fb_info

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/Kconfig |  1 +
 drivers/gpu/drm/drm_fb_helper.c | 26 ++
 include/drm/drm_fb_helper.h |  5 +
 3 files changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c46ca31..6ab503b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
select FB
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
+   select FB_SYS_FOPS
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2f8dd8d..abb36f9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -777,6 +777,32 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);

+/**
+ * drm_fb_helper_sys_read - wrapper around fb_sys_read
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_sys_read implemented by fbdev core
+ */
+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+  size_t count, loff_t *ppos)
+{
+   return fb_sys_read(info, buf, count, ppos);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_read);
+
+/**
+ * drm_fb_helper_sys_write - wrapper around fb_sys_write
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_sys_write implemented by fbdev core
+ */
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos)
+{
+   return fb_sys_write(info, buf, count, ppos);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_write);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 4c90837..fc12368 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -147,6 +147,11 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t 
pitch,

 void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);

+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+  size_t count, loff_t *ppos);
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 02/25] drm/fb_helper: Create a wrapper for unlink_framebuffer

2015-07-22 Thread Archit Taneja
Some drm drivers call unlink_framebuffer. Create a drm_fb_helper function
that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

v2:
- Added kerneldocs
- Added a check for non-NULL fb_helper before proceeding. This will
  make the helpers work when we have a module param for fbdev emulation

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 13 +
 include/drm/drm_fb_helper.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a5ae64a..2f8dd8d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -764,6 +764,19 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_fini);

+/**
+ * drm_fb_helper_unlink_fbi - wrapper around unlink_framebuffer
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around unlink_framebuffer implemented by fbdev core
+ */
+void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper && fb_helper->fbdev)
+   unlink_framebuffer(fb_helper->fbdev);
+}
+EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 2ee4ec5..4c90837 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -145,6 +145,8 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct 
drm_fb_helper *fb_helpe
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
uint32_t depth);

+void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 01/25] drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation

2015-07-22 Thread Archit Taneja
Every drm driver calls framebuffer_alloc, fb_alloc_cmap,
unregister_framebuffer, fb_dealloc_cmap and framebuffer_release in
order to emulate fbdev support.

Create drm_fb_helper functions that perform the above operations.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly. It also removes repetitive code from drivers.

There are some drivers that call alloc_apertures after framebuffer_alloc
and some that don't. Make the helper always call alloc_apertures. This
would make certain drivers allocate memory for apertures but not use
them. Since it's a small amount of memory, it shouldn't be an issue.

v2:
- Added kerneldocs
- Added a check for non-NULL fb_helper before proceeding. This will
  make the helpers work when we have a module param for fbdev emulation

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 80 +
 include/drm/drm_fb_helper.h |  4 +++
 2 files changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cac4229..a5ae64a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -667,6 +667,86 @@ out_free:
 }
 EXPORT_SYMBOL(drm_fb_helper_init);

+/**
+ * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to alloc fb_info and the members cmap and apertures. Called
+ * by the driver within the fb_probe fb_helper callback function.
+ *
+ * RETURNS:
+ * fb_info pointer if things went okay, pointer containing error code
+ * otherwise
+ */
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
+{
+   struct device *dev = fb_helper->dev->dev;
+   struct fb_info *info;
+   int ret;
+
+   info = framebuffer_alloc(0, dev);
+   if (!info)
+   return ERR_PTR(-ENOMEM);
+
+   ret = fb_alloc_cmap(>cmap, 256, 0);
+   if (ret)
+   goto err_release;
+
+   info->apertures = alloc_apertures(1);
+   if (!info->apertures) {
+   ret = -ENOMEM;
+   goto err_free_cmap;
+   }
+
+   fb_helper->fbdev = info;
+
+   return info;
+
+err_free_cmap:
+   fb_dealloc_cmap(>cmap);
+err_release:
+   framebuffer_release(info);
+   return ERR_PTR(ret);
+}
+EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
+
+/**
+ * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around unregister_framebuffer, to release the fb_info
+ * framebuffer device
+ */
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper && fb_helper->fbdev)
+   unregister_framebuffer(fb_helper->fbdev);
+}
+EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
+
+/**
+ * drm_fb_helper_release_fbi - dealloc fb_info and its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to free memory taken by fb_info and the members cmap and
+ * apertures
+ */
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper) {
+   struct fb_info *info = fb_helper->fbdev;
+
+   if (info) {
+   if (info->cmap.len)
+   fb_dealloc_cmap(>cmap);
+   framebuffer_release(info);
+   }
+
+   fb_helper->fbdev = NULL;
+   }
+}
+EXPORT_SYMBOL(drm_fb_helper_release_fbi);
+
 void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 {
if (!list_empty(_helper->kernel_fb_list)) {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 0dfd94def..2ee4ec5 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -136,6 +136,10 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);

 bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper 
*fb_helper);
+
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper);
 void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper 
*fb_helper,
uint32_t fb_width, uint32_t fb_height);
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH RESEND v2 00/25] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs

2015-07-22 Thread Archit Taneja
DRM drivers using drm_fb_helpers still call some fbdev core functions.
This makes the driver depend on CONFIG_FB, resulting in complicated
Kconfig options, and preventing us from creating a top level drm config
option to enable/disable FBDEV emulation.

Create new drm_fb_helper functions that replace these fbdev functions.

In most cases, the new helper funcs simply wrap around the original fbdev
functions. For a few (like framebufer_alloc), we actually do some work
that is currently redundant across multiple drivers.

With these patches, the drivers don't call any fbdev functions directly.
They are now called through functions in drm_fb_helper.c. We will later
create a fbdev emulation config option to stub out the fb helpers.

The only exception is vmwgfx driver. This doesn't use drm_fb_helper. It
creates a fb device how a driver in drivers/video/fbdev would. Maybe this
needs to be converted to use drm_fb_helpers.

For more info, have a look at the threads:
http://lists.freedesktop.org/archives/dri-devel/2015-March/078729.html
http://lists.freedesktop.org/archives/dri-devel/2015-March/078975.html

changes in v2:
- Incorporated comments
- Misc fixes for build wannings/errors
- resend version has v2 changes in changelog, 'compile tested only' is
  removed.

Archit Taneja (25):
  drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation
  drm/fb_helper: Create a wrapper for unlink_framebuffer
  drm/fb_helper: Create wrappers for fb_sys_read/write funcs
  drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs
  drm/fb_helper: Create a wrapper for fb_set_suspend
  drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers
  drm/cirrus: Use new drm_fb_helper functions
  drm/rockchip: Use new drm_fb_helper functions
  drm/armada: Use new drm_fb_helper functions
  drm/ast: Use new drm_fb_helper functions
  drm/omap: Use new drm_fb_helper functions
  drm/tegra: Use new drm_fb_helper functions
  drm/msm: Use new drm_fb_helper functions
  drm/exynos: Use new drm_fb_helper functions
  drm/gma500: Use new drm_fb_helper functions
  drm/mgag200: Use new drm_fb_helper functions
  drm/radeon: Use new drm_fb_helper functions
  drm/qxl: Use new drm_fb_helper functions
  drm/i915: Use new drm_fb_helper functions
  drm/nouveau: Use new drm_fb_helper functions
  drm/udl: Use new drm_fb_helper functions
  drm/bochs: Use new drm_fb_helper functions
  drm/amdgpu: Use new drm_fb_helper functions
  drm/virtio: Use new drm_fb_helper functions
  drm/fb_cma_helper: Use new drm_fb_helper functions

 drivers/gpu/drm/Kconfig   |   7 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c|  45 ++
 drivers/gpu/drm/armada/armada_fbdev.c |  33 ++--
 drivers/gpu/drm/ast/ast_fb.c  |  48 ++
 drivers/gpu/drm/bochs/bochs_drv.c |   6 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c   |  36 ++---
 drivers/gpu/drm/cirrus/cirrus_drv.c   |   7 +-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  41 +
 drivers/gpu/drm/drm_fb_cma_helper.c   |  45 ++
 drivers/gpu/drm/drm_fb_helper.c   | 225 ++
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  47 ++
 drivers/gpu/drm/gma500/accel_2d.c |   6 +-
 drivers/gpu/drm/gma500/framebuffer.c  |  48 ++
 drivers/gpu/drm/i915/i915_dma.c   |   3 +-
 drivers/gpu/drm/i915/intel_fbdev.c|  40 ++---
 drivers/gpu/drm/mgag200/mgag200_drv.c |   3 +-
 drivers/gpu/drm/mgag200/mgag200_fb.c  |  39 +
 drivers/gpu/drm/mgag200/mgag200_main.c|   2 +-
 drivers/gpu/drm/msm/msm_fbdev.c   |  34 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c |   3 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   |  39 ++---
 drivers/gpu/drm/omapdrm/omap_fbdev.c  |  34 ++--
 drivers/gpu/drm/qxl/qxl_fb.c  |  40 ++---
 drivers/gpu/drm/radeon/radeon_drv.c   |   4 +-
 drivers/gpu/drm/radeon/radeon_fb.c|  42 ++---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  47 ++
 drivers/gpu/drm/tegra/fb.c|  35 ++--
 drivers/gpu/drm/udl/udl_fb.c  |  41 ++---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c  |   3 +-
 drivers/gpu/drm/virtio/virtgpu_drv.h  |   1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c   |  32 ++--
 include/drm/drm_fb_helper.h   |  31 
 33 files changed, 508 insertions(+), 563 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH V4 4/6] mm: mlock: Introduce VM_LOCKONFAULT and add mlock flags to enable it

2015-07-22 Thread Eric B Munson
ulates it would work and it would do away with most of the
places I had to touch to handle VM_LOCKONFAULT properly.

I picked VM_LOCKONFAULT because it is explicit about what it is for and
there is little risk of someone coming along in 5 years and saying "why
not overload this flag to do this other thing completely unrelated to
mlock?".  A flag for controling speculative population is more likely to
be overloaded outside of mlock().

If you have a sane way of handling mlockall(MCL_ONFAULT) without a new
VMA flag, I am happy to give it a try, but I haven't been able to come
up with one that doesn't have its own gremlins.

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150722/eafcc072/attachment.sig>


[PATCH v2 00/25] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs

2015-07-22 Thread Archit Taneja


On 07/22/2015 01:11 PM, Daniel Vetter wrote:
> On Wed, Jul 22, 2015 at 12:29:36PM +0530, Archit Taneja wrote:
>> DRM drivers using drm_fb_helpers still call some fbdev core functions.
>> This makes the driver depend on CONFIG_FB, resulting in complicated
>> Kconfig options, and preventing us from creating a top level drm config
>> option to enable/disable FBDEV emulation.
>>
>> Create new drm_fb_helper functions that replace these fbdev functions.
>>
>> In most cases, the new helper funcs simply wrap around the original fbdev
>> functions. For a few (like framebufer_alloc), we actually do some work
>> that is currently redundant across multiple drivers.
>>
>> With these patches, the drivers don't call any fbdev functions directly.
>> They are now called through functions in drm_fb_helper.c. We will later
>> create a fbdev emulation config option to stub out the fb helpers.
>>
>> The only exception is vmwgfx driver. This doesn't use drm_fb_helper. It
>> creates a fb device how a driver in drivers/video/fbdev would. Maybe this
>> needs to be converted to use drm_fb_helpers.
>>
>> For more info, have a look at the threads:
>> http://lists.freedesktop.org/archives/dri-devel/2015-March/078729.html
>> http://lists.freedesktop.org/archives/dri-devel/2015-March/078975.html
>>
>> v2:
>> - Remove if (info) checks in fb_sys functions
>> - Use 'if (fb_helper && fb_helper->fbdev)' checks where appropriate
>> - Add kerneldocs for the new helper funcs
>> - Follow drm way of aligning of arguments in func definitions
>> - Fixed build error in drm/virtio
>> - Fixed error cleanup path in drm/tegra
>> - Fixed build error in drm/rockchip
>> - Fixed return issue in drm/amdgpu
>> - Fixed 'unused variable' warnings in bochs, ast, udl and radeon
>> - Fixed stray goto labels in cirrus, exynos, mgag
>
> When resending patches please also have changelogs per-patch, not just in
> the cover letter. Otherwise you have to constantly jump back
>
> Also I'd drop the compile tested only from patches, just adds noise.

I'll remove the 'compile tested only' line from the patches.

About the changelogs per-patch, I'll add them for the drm_fb_helper.c 
changes, and for a few drm drivers where people found flaws in the 
changes. I'm going to skip for the ones which were build error/warning 
fixes found by kbots. I didn't intend the first version to be full 
proof, just wanted people to have a look.

Thanks,
Archit

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Inki Dae
On 2015년 07월 22일 11:02, Joonyoung Shim wrote:
> On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
>> Hi,
>>
>> Today's linux-next (next-20150721) encounters boot failures on Exynos
>> Octa (Exynos5422) based boards. The boards hangs. I bisected it to:
>>
>> d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
>> commit d80167b85024982c5f18d0481a5c248100360118
>> Author: Joonyoung Shim 
>> Date:   Thu Jul 2 21:49:39 2015 +0900
>>
>> drm/exynos: remove drm_iommu_attach_device_if_possible
>>
>> Already drm_iommu_attach_device checks whether support iommu internally.
>> It should clear channels always regardless iommu support. We didn't know
>> because we can detect the problem when iommu is enabled, so we don't
>> have to use drm_iommu_attach_device_if_possible and then we can remove
>> drm_iommu_attach_device_if_possible and clear_channels function pointer.
>>
>> Signed-off-by: Joonyoung Shim 
>> Tested-by: Marek Szyprowski 
>> Signed-off-by: Inki Dae 
>>
>> :04 04 83379efbf4960f58d680371628ec04387935bd53
>> da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers
>>
>>
>> Config: exynos
>> Boot log from Odroid XU3-Lite attached.
>>
>> Any hints or ideas?
> 
> The point that hangs is when accesses fimd register in
> fimd_clear_channels function, so i doubt clock setting for fimd.
> 
> It's gone something that hangs after i enable gating for ACLK_200_DISP1
> clock.
> 
> If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
> support. Any ideas?

I think bootloader should have enabled ACLK_200_DISP1 clock and also
device driver should enable all relevant clocks before the device
accesses its own registers.

Best way would be that the clock is enabled by common clock framework
but it seems there is no anything that the clock framework can do it. So
I think what we have to do is to add the clock support to device tree.

Other idea?

Thanks,
Inki Dae

> 
> Thanks.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



[PATCH] libdrm/amdgpu: Fixed drm.h include.

2015-07-22 Thread Alexandr Akulich
>> Makes sense to me, the patch is
>>
>> Reviewed-by: Michel Dänzer 
> Thanks! I have no write access to this fd.o repository. Can you apply it 
> please?
I mean "apply the patch".


[PATCH] libdrm/amdgpu: Fixed drm.h include.

2015-07-22 Thread Alexandr Akulich
On Wed, Jul 22, 2015 at 1:19 PM, Michel Dänzer  wrote:
> On 17.07.2015 22:33, Alexandr Akulich wrote:
>> As I see, this is not a kernel header, but a local (belongs to libdrm) one.
>> (Otherwise, I would like you to point me on such file at, say,
>> https://github.com/torvalds/linux/tree/master/include/drm)
>
> https://github.com/torvalds/linux/blob/master/include/uapi/drm/amdgpu_drm.h
>
>
>> At files drm_sarea.h, mga_drm.h, qxl_drm.h, radeon_drm.h and via_drm.h we 
>> have
>>
>> #include "drm.h"
>>
>> At the same time, at i915_drm.h and tegra_drm.h. we have
>>
>> #include 
>>
>> I'm pretty sure that the first case is correct, because drm.h is
>> always would be local file (in the same directory), related to
>> amdgpu_drm.h, and that is why local include "drm.h" would be always
>> valid.
>
> Makes sense to me, the patch is
>
> Reviewed-by: Michel Dänzer 
Thanks! I have no write access to this fd.o repository. Can you apply it please?
>
>> This fixes libdrm build with amdgpu support on bare system for me.
>
> FWIW though, that's because you're dropping the drm/ prefix, not because
> you're changing from <> to "".
I know :-). Compiler would "fallback" from <> to "", if it can't find
a header in passed include directories.
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer


[Intel-gfx] [PATCH] drm/i915: add error path

2015-07-22 Thread Chris Wilson
On Wed, Jul 22, 2015 at 04:58:47PM +0530, Sudip Mukherjee wrote:
> If any of the debug file creation fails we were just returning the
> error code to the drm layer. But the debug files that we created in the
> process were not removed. And debugfs files are not automatically
> cleaned up.

Just handle the failure to add gracefully by only removing the ones we
add during debugfs cleanup. One thing we do not actually want to do here
is return an error - not setting up every file in debugfs shouldn't stop
the driver from loading.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[PATCH v2 25/25] drm/fb_cma_helper: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Lars-Peter Clausen 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 45 +
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index 5c1aca4..0da6a24 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -234,9 +234,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);

 static struct fb_ops drm_fbdev_cma_ops = {
.owner  = THIS_MODULE,
-   .fb_fillrect= sys_fillrect,
-   .fb_copyarea= sys_copyarea,
-   .fb_imageblit   = sys_imageblit,
+   .fb_fillrect= drm_fb_helper_sys_fillrect,
+   .fb_copyarea= drm_fb_helper_sys_copyarea,
+   .fb_imageblit   = drm_fb_helper_sys_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -275,10 +275,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,
if (IS_ERR(obj))
return -ENOMEM;

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
-   dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-   ret = -ENOMEM;
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
+   ret = PTR_ERR(fbi);
goto err_drm_gem_cma_free_object;
}

@@ -286,23 +285,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,
if (IS_ERR(fbdev_cma->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(fbdev_cma->fb);
-   goto err_framebuffer_release;
+   goto err_fb_info_destroy;
}

fb = _cma->fb->fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _fbdev_cma_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   dev_err(dev->dev, "Failed to allocate color map.\n");
-   goto err_drm_fb_cma_destroy;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -317,11 +309,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,

return 0;

-err_drm_fb_cma_destroy:
-   drm_framebuffer_unregister_private(fb);
-   drm_fb_cma_destroy(fb);
-err_framebuffer_release:
-   framebuffer_release(fbi);
+err_fb_info_destroy:
+   drm_fb_helper_release_fbi(helper);
 err_drm_gem_cma_free_object:
drm_gem_cma_free_object(>base);
return ret;
@@ -397,20 +386,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
  */
 void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
 {
-   if (fbdev_cma->fb_helper.fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = fbdev_cma->fb_helper.fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer()\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(_cma->fb_helper);
+   drm_fb_helper_release_fbi(_cma->fb_helper);

if (fbdev_cma->fb) {
drm_framebuffer_unregister_private(_cma->fb->fb);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 24/25] drm/virtio: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: Gerd Hoffmann 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c |  3 ++-
 drivers/gpu/drm/virtio/virtgpu_drv.h |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c  | 32 +---
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c 
b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
index 88a3916..aea1bac 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
@@ -52,7 +52,8 @@ static void virtio_pci_kick_out_firmware_fb(struct pci_dev 
*pci_dev)
primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
& IORESOURCE_ROM_SHADOW;

-   remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb",
+   primary);

kfree(ap);
 }
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 6d4db2d..7b747ba 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c 
b/drivers/gpu/drm/virtio/virtgpu_fb.c
index df198d9..6a81e08 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -173,7 +173,7 @@ static void virtio_gpu_3d_fillrect(struct fb_info *info,
   const struct fb_fillrect *rect)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
virtio_gpu_dirty_update(>vgfb, true, rect->dx, rect->dy,
 rect->width, rect->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -183,7 +183,7 @@ static void virtio_gpu_3d_copyarea(struct fb_info *info,
   const struct fb_copyarea *area)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
virtio_gpu_dirty_update(>vgfb, true, area->dx, area->dy,
   area->width, area->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -193,7 +193,7 @@ static void virtio_gpu_3d_imageblit(struct fb_info *info,
const struct fb_image *image)
 {
struct virtio_gpu_fbdev *vfbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
virtio_gpu_dirty_update(>vgfb, true, image->dx, image->dy,
 image->width, image->height);
schedule_delayed_work(>work, VIRTIO_GPU_FBCON_POLL_PERIOD);
@@ -230,7 +230,6 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd = {};
struct virtio_gpu_object *obj;
-   struct device *device = vgdev->dev;
uint32_t resid, format, size;
int ret;

@@ -317,18 +316,12 @@ static int virtio_gpufb_create(struct drm_fb_helper 
*helper,
if (ret)
goto err_obj_attach;

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto err_fb_alloc;
}

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto err_fb_alloc_cmap;
-   }
-
info->par = helper;

ret = virtio_gpu_framebuffer_init(dev, >vgfb,
@@ -339,7 +332,6 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
fb = >vgfb.base;

vfbdev->helper.fb = fb;
-   vfbdev->helper.fbdev = info;

strcpy(info->fix.id, "virtiodrmfb");
info->flags = FBINFO_DEFAULT;
@@ -357,9 +349,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
return 0;

 err_fb_init:
-   fb_dealloc_cmap(>cmap);
-err_fb_alloc_cmap:
-   framebuffer_release(info);
+   drm_fb_helper_release_fbi(helper);
 err_fb_alloc:
virtio_gpu_cmd_resource_inval_backing(vgdev, resid);
 err_obj_attach:
@@ -371,15 +361,11 @@ err_obj_vmap:
 static int virtio_gpu_fbdev_destroy(struct drm_device *dev,
struct virtio_gpu_fbdev *vgfbdev)
 {
-   struct fb_info *info;
struct virtio_gpu_framebuffer *vgfb = >vgfb;

-   if (vgfbdev->helper.fbdev) {
-   info = vgfbdev->helper.fbdev;
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

-   

[PATCH v2 23/25] drm/amdgpu: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

v2: Fixed PTR_ERR issue mentioned by kbuild bot

Cc: Fengguang Wu 
Cc: Alex Deucher 
Cc: Oded Gabbay 
Cc: "Christian König" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  | 45 ++---
 2 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 56da962..52d7cfd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -35,6 +35,7 @@
 #include "amdgpu_drv.h"

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -267,7 +268,8 @@ static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb",
+   primary);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c1645d2..81b8212 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -179,7 +179,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct amdgpu_bo *rbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
unsigned long tmp;

@@ -201,9 +200,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
rbo = gem_to_amdgpu_bo(gobj);

/* okay we have an object now allocate the framebuffer */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -212,14 +211,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
ret = amdgpu_framebuffer_init(adev->ddev, >rfb, _cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_unref;
+   goto out_destroy_fbi;
}

fb = >rfb.base;

/* setup helper */
rfbdev->helper.fb = fb;
-   rfbdev->helper.fbdev = info;

memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo));

@@ -239,11 +237,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = adev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = adev->mc.aper_size;

@@ -251,13 +244,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -269,6 +256,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unref:
if (rbo) {

@@ -290,17 +279,10 @@ void amdgpu_fb_output_poll_changed(struct amdgpu_device 
*adev)

 static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev 
*rfbdev)
 {
-   struct fb_info *info;
struct amdgpu_framebuffer *rfb = >rfb;

-   if (rfbdev->helper.fbdev) {
-   info = rfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   

[PATCH v2 22/25] drm/bochs: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: Gerd Hoffmann 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bochs/bochs_drv.c   |  6 +++---
 drivers/gpu/drm/bochs/bochs_fbdev.c | 36 +++-
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index 98837bd..7802fc6 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -109,7 +109,7 @@ static int bochs_pm_suspend(struct device *dev)

if (bochs->fb.initialized) {
console_lock();
-   fb_set_suspend(bochs->fb.helper.fbdev, 1);
+   drm_fb_helper_set_suspend(>fb.helper, 1);
console_unlock();
}

@@ -126,7 +126,7 @@ static int bochs_pm_resume(struct device *dev)

if (bochs->fb.initialized) {
console_lock();
-   fb_set_suspend(bochs->fb.helper.fbdev, 0);
+   drm_fb_helper_set_suspend(>fb.helper, 0);
console_unlock();
}

@@ -153,7 +153,7 @@ static int bochs_kick_out_firmware_fb(struct pci_dev *pdev)

ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0);
-   remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c 
b/drivers/gpu/drm/bochs/bochs_fbdev.c
index 976d979..09a0637 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -24,9 +24,9 @@ static struct fb_ops bochsfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -56,11 +56,9 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 {
struct bochs_device *bochs =
container_of(helper, struct bochs_device, fb.helper);
-   struct drm_device *dev = bochs->dev;
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
struct drm_gem_object *gobj = NULL;
struct bochs_bo *bo = NULL;
int size, ret;
@@ -106,22 +104,23 @@ static int bochsfb_create(struct drm_fb_helper *helper,
ttm_bo_unreserve(>bo);

/* init fb device */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = >fb.helper;

ret = bochs_framebuffer_init(bochs->dev, >fb.gfb, _cmd, 
gobj);
-   if (ret)
+   if (ret) {
+   drm_fb_helper_release_fbi(helper);
return ret;
+   }

bochs->fb.size = size;

/* setup helper */
fb = >fb.gfb.base;
bochs->fb.helper.fb = fb;
-   bochs->fb.helper.fbdev = info;

strcpy(info->fix.id, "bochsdrmfb");

@@ -139,30 +138,17 @@ static int bochsfb_create(struct drm_fb_helper *helper,
info->fix.smem_start = 0;
info->fix.smem_len = size;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
-   return -ENOMEM;
-   }
-
return 0;
 }

 static int bochs_fbdev_destroy(struct bochs_device *bochs)
 {
struct bochs_framebuffer *gfb = >fb.gfb;
-   struct fb_info *info;

DRM_DEBUG_DRIVER("\n");

-   if (bochs->fb.helper.fbdev) {
-   info = bochs->fb.helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>fb.helper);
+   drm_fb_helper_release_fbi(>fb.helper);

if (gfb->obj) {
drm_gem_object_unreference_unlocked(gfb->obj);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 21/25] drm/udl: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: Haixia Shi 
Cc: "Stéphane Marchesin" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/udl/udl_fb.c | 41 -
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 5fc16ce..62c7b1d 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -288,7 +288,7 @@ static void udl_fb_fillrect(struct fb_info *info, const 
struct fb_fillrect *rect
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);

udl_handle_damage(>ufb, rect->dx, rect->dy, rect->width,
  rect->height);
@@ -298,7 +298,7 @@ static void udl_fb_copyarea(struct fb_info *info, const 
struct fb_copyarea *regi
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_copyarea(info, region);
+   drm_fb_helper_sys_copyarea(info, region);

udl_handle_damage(>ufb, region->dx, region->dy, region->width,
  region->height);
@@ -308,7 +308,7 @@ static void udl_fb_imageblit(struct fb_info *info, const 
struct fb_image *image)
 {
struct udl_fbdev *ufbdev = info->par;

-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);

udl_handle_damage(>ufb, image->dx, image->dy, image->width,
  image->height);
@@ -476,7 +476,6 @@ static int udlfb_create(struct drm_fb_helper *helper,
container_of(helper, struct udl_fbdev, helper);
struct drm_device *dev = ufbdev->helper.dev;
struct fb_info *info;
-   struct device *device = dev->dev;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
struct udl_gem_object *obj;
@@ -506,21 +505,20 @@ static int udlfb_create(struct drm_fb_helper *helper,
goto out_gfree;
}

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_gfree;
}
info->par = ufbdev;

ret = udl_framebuffer_init(dev, >ufb, _cmd, obj);
if (ret)
-   goto out_gfree;
+   goto out_destroy_fbi;

fb = >ufb.base;

ufbdev->helper.fb = fb;
-   ufbdev->helper.fbdev = info;

strcpy(info->fix.id, "udldrmfb");

@@ -533,18 +531,13 @@ static int udlfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_gfree;
-   }
-
-
DRM_DEBUG_KMS("allocated %dx%d vmal %p\n",
  fb->width, fb->height,
  ufbdev->ufb.obj->vmapping);

return ret;
+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_gfree:
drm_gem_object_unreference(>ufb.obj->base);
 out:
@@ -558,14 +551,8 @@ static const struct drm_fb_helper_funcs 
udl_fb_helper_funcs = {
 static void udl_fbdev_destroy(struct drm_device *dev,
  struct udl_fbdev *ufbdev)
 {
-   struct fb_info *info;
-   if (ufbdev->helper.fbdev) {
-   info = ufbdev->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);
drm_fb_helper_fini(>helper);
drm_framebuffer_unregister_private(>ufb.base);
drm_framebuffer_cleanup(>ufb.base);
@@ -631,11 +618,7 @@ void udl_fbdev_unplug(struct drm_device *dev)
return;

ufbdev = udl->fbdev;
-   if (ufbdev->helper.fbdev) {
-   struct fb_info *info;
-   info = ufbdev->helper.fbdev;
-   unlink_framebuffer(info);
-   }
+   drm_fb_helper_unlink_fbi(>helper);
 }

 struct drm_framebuffer *
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 20/25] drm/nouveau: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: Ben Skeggs 
Cc: Alexandre Courbot 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  3 ++-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 39 ++---
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 649024d..01d3fb2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -317,7 +317,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
 #endif
if (nouveau_modeset != 2)
-   remove_conflicting_framebuffers(aper, "nouveaufb", boot);
+   drm_fb_helper_remove_conflicting_framebuffers(aper, "nouveaufb",
+   boot);
kfree(aper);

ret = nvkm_device_create(pdev, NVKM_BUS_PCI,
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 6751553..2791701 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -84,7 +84,7 @@ nouveau_fbcon_fillrect(struct fb_info *info, const struct 
fb_fillrect *rect)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_fillrect(info, rect);
+   drm_fb_helper_cfb_fillrect(info, rect);
 }

 static void
@@ -116,7 +116,7 @@ nouveau_fbcon_copyarea(struct fb_info *info, const struct 
fb_copyarea *image)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_copyarea(info, image);
+   drm_fb_helper_cfb_copyarea(info, image);
 }

 static void
@@ -148,7 +148,7 @@ nouveau_fbcon_imageblit(struct fb_info *info, const struct 
fb_image *image)

if (ret != -ENODEV)
nouveau_fbcon_gpu_lockup(info);
-   cfb_imageblit(info, image);
+   drm_fb_helper_cfb_imageblit(info, image);
 }

 static int
@@ -197,9 +197,9 @@ static struct fb_ops nouveau_fbcon_sw_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -319,7 +319,6 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
struct nouveau_channel *chan;
struct nouveau_bo *nvbo;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct pci_dev *pdev = dev->pdev;
int size, ret;

mode_cmd.width = sizes->surface_width;
@@ -365,20 +364,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,

mutex_lock(>struct_mutex);

-   info = framebuffer_alloc(0, >dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unlock;
}
info->skip_vt_switch = 1;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   framebuffer_release(info);
-   goto out_unlock;
-   }
-
info->par = fbcon;

nouveau_framebuffer_init(dev, >nouveau_fb, _cmd, nvbo);
@@ -388,7 +380,6 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,

/* setup helper */
fbcon->helper.fb = fb;
-   fbcon->helper.fbdev = info;

strcpy(info->fix.id, "nouveaufb");
if (!chan)
@@ -450,15 +441,9 @@ static int
 nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
 {
struct nouveau_framebuffer *nouveau_fb = >nouveau_fb;
-   struct fb_info *info;

-   if (fbcon->helper.fbdev) {
-   info = fbcon->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (nouveau_fb->nvbo) {
nouveau_bo_unmap(nouveau_fb->nvbo);
@@ -496,7 +481,7 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
console_lock();
if (state == FBINFO_STATE_RUNNING)
nouveau_fbcon_accel_restore(dev);
-   fb_set_suspend(drm->fbcon->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>fbcon->helper, state);
if (state != FBINFO_STATE_RUNNING)
   

[PATCH v2 19/25] drm/i915: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Daniel Vetter 
Cc: Jani Nikula 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/i915/i915_dma.c|  3 ++-
 drivers/gpu/drm/i915/intel_fbdev.c | 40 --
 2 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index d2df321..10f6019 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -498,7 +498,8 @@ static int i915_kick_out_firmware_fb(struct 
drm_i915_private *dev_priv)
primary =
pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;

-   ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
+   ret = drm_fb_helper_remove_conflicting_framebuffers(ap, "inteldrmfb",
+   primary);

kfree(ap);

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index 6372cfc..4aa21f7 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -126,9 +126,9 @@ static struct fb_ops intelfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = intel_fbdev_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = intel_fbdev_pan_display,
.fb_blank = intel_fbdev_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -237,9 +237,9 @@ static int intelfb_create(struct drm_fb_helper *helper,
obj = intel_fb->obj;
size = obj->base.size;

-   info = framebuffer_alloc(0, >pdev->dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unpin;
}

@@ -248,24 +248,13 @@ static int intelfb_create(struct drm_fb_helper *helper,
fb = >fb->base;

ifbdev->helper.fb = fb;
-   ifbdev->helper.fbdev = info;

strcpy(info->fix.id, "inteldrmfb");

info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = _ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unpin;
-   }
/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unpin;
-   }
info->apertures->ranges[0].base = dev->mode_config.fb_base;
info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;

@@ -277,7 +266,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
   size);
if (!info->screen_base) {
ret = -ENOSPC;
-   goto out_unpin;
+   goto out_destroy_fbi;
}
info->screen_size = size;

@@ -304,6 +293,8 @@ static int intelfb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(dev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unpin:
i915_gem_object_ggtt_unpin(obj);
drm_gem_object_unreference(>base);
@@ -550,16 +541,9 @@ static const struct drm_fb_helper_funcs 
intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
struct intel_fbdev *ifbdev)
 {
-   if (ifbdev->helper.fbdev) {
-   struct fb_info *info = ifbdev->helper.fbdev;

-   unregister_framebuffer(info);
-   iounmap(info->screen_base);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

drm_fb_helper_fini(>helper);

@@ -810,7 +794,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size);

-   fb_set_suspend(info, state);
+   drm_fb_helper_set_suspend(>helper, state);
console_unlock();
 }

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 18/25] drm/qxl: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: Frediano Ziglio 
Cc: Maarten Lankhorst 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/qxl/qxl_fb.c | 40 +---
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 6b6e57e..41c422f 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -197,7 +197,7 @@ static void qxl_fb_fillrect(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
qxl_dirty_update(qfbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -207,7 +207,7 @@ static void qxl_fb_copyarea(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
qxl_dirty_update(qfbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -217,7 +217,7 @@ static void qxl_fb_imageblit(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
qxl_dirty_update(qfbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -345,7 +345,6 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct qxl_bo *qbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
int size;
int bpp = sizes->surface_bpp;
@@ -374,9 +373,9 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
 shadow);
size = mode_cmd.pitches[0] * mode_cmd.height;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(>helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -388,7 +387,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,

/* setup helper with fb data */
qfbdev->helper.fb = fb;
-   qfbdev->helper.fbdev = info;
+
qfbdev->shadow = shadow;
strcpy(info->fix.id, "qxldrmfb");

@@ -410,11 +409,6 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
   sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = qdev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = qdev->vram_size;

@@ -423,13 +417,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

info->fbdefio = _defio;
@@ -441,6 +429,8 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
DRM_INFO("fb: depth %d, pitch %d, width %d, height %d\n", fb->depth, 
fb->pitches[0], fb->width, fb->height);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(>helper);
 out_unref:
if (qbo) {
ret = qxl_bo_reserve(qbo, false);
@@ -479,15 +469,11 @@ static int qxl_fb_find_or_create_single(

 static int qxl_fbdev_destroy(struct drm_device *dev, struct qxl_fbdev *qfbdev)
 {
-   struct fb_info *info;
struct qxl_framebuffer *qfb = >qfb;

-   if (qfbdev->helper.fbdev) {
-   info = qfbdev->helper.fbdev;
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

-   unregister_framebuffer(info);
-   framebuffer_release(info);
-   }
if (qfb->obj) {
qxlfb_destroy_pinned_object(qfb->obj);
qfb->obj = NULL;
@@ -557,7 +543,7 @@ void qxl_fbdev_fini(struct qxl_device *qdev)

 void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state)
 {
-   fb_set_suspend(qdev->mode_info.qfbdev->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>mode_info.qfbdev->helper, state);
 }

 bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 17/25] drm/radeon: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Alex Deucher 
Cc: "Christian König" 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/radeon/radeon_drv.c |  4 +++-
 drivers/gpu/drm/radeon/radeon_fb.c  | 42 +++--
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 5751446..98ee541 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "drm_crtc_helper.h"
 #include "radeon_kfd.h"
@@ -390,7 +391,8 @@ static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb",
+   primary);
kfree(ap);

return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c 
b/drivers/gpu/drm/radeon/radeon_fb.c
index 634793e..e0fcd3d 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -82,9 +82,9 @@ static struct fb_ops radeonfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = radeon_fb_helper_set_par,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -227,7 +227,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
struct radeon_bo *rbo = NULL;
-   struct device *device = >pdev->dev;
int ret;
unsigned long tmp;

@@ -250,9 +249,9 @@ static int radeonfb_create(struct drm_fb_helper *helper,
rbo = gem_to_radeon_bo(gobj);

/* okay we have an object now allocate the framebuffer */
-   info = framebuffer_alloc(0, device);
-   if (info == NULL) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_unref;
}

@@ -261,14 +260,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
ret = radeon_framebuffer_init(rdev->ddev, >rfb, _cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_unref;
+   goto out_destroy_fbi;
}

fb = >rfb.base;

/* setup helper */
rfbdev->helper.fb = fb;
-   rfbdev->helper.fbdev = info;

memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));

@@ -288,11 +286,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, >helper, sizes->fb_width, 
sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = rdev->mc.aper_size;

@@ -300,13 +293,7 @@ static int radeonfb_create(struct drm_fb_helper *helper,

if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_unref;
-   }
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
+   goto out_destroy_fbi;
}

DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -318,6 +305,8 @@ static int radeonfb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
return 0;

+out_destroy_fbi:
+   drm_fb_helper_release_fbi(helper);
 out_unref:
if (rbo) {

@@ -338,17 +327,10 @@ void radeon_fb_output_poll_changed(struct radeon_device 
*rdev)

 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev 
*rfbdev)
 {
-   struct fb_info *info;
struct radeon_framebuffer *rfb = >rfb;

-   if (rfbdev->helper.fbdev) {
-   info = rfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (rfb->obj) {
 

[PATCH v2 16/25] drm/mgag200: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Daniel Vetter 
Cc: David Airlie 
Cc: Alex Deucher 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c  |  3 ++-
 drivers/gpu/drm/mgag200/mgag200_fb.c   | 39 +++---
 drivers/gpu/drm/mgag200/mgag200_main.c |  2 +-
 3 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 9774599..38363f8 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -55,7 +55,8 @@ static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "mgag200drmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb",
+   primary);
kfree(ap);
 }

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index c36b830..dc06f8b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -101,7 +101,7 @@ static void mga_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
mga_dirty_update(mfbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -110,7 +110,7 @@ static void mga_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
mga_dirty_update(mfbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -119,7 +119,7 @@ static void mga_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct mga_fbdev *mfbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
mga_dirty_update(mfbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -166,7 +166,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_gem_object *gobj = NULL;
-   struct device *device = >pdev->dev;
struct mgag200_bo *bo;
int ret;
void *sysram;
@@ -191,9 +190,9 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = mfbdev;

@@ -208,14 +207,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,

/* setup helper */
mfbdev->helper.fb = fb;
-   mfbdev->helper.fbdev = info;
-
-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
-   ret = -ENOMEM;
-   goto out;
-   }

strcpy(info->fix.id, "mgadrmfb");

@@ -223,11 +214,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
info->fbops = _ops;

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out;
-   }
info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base;
info->apertures->ranges[0].size = mdev->mc.vram_size;

@@ -242,24 +228,15 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_DEBUG_KMS("allocated %dx%d\n",
  fb->width, fb->height);
return 0;
-out:
-   return ret;
 }

 static int mga_fbdev_destroy(struct drm_device *dev,
struct mga_fbdev *mfbdev)
 {
-   struct fb_info *info;
struct mga_framebuffer *mfb = >mfb;

-   if (mfbdev->helper.fbdev) {
-   info = mfbdev->helper.fbdev;
-
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (mfb->obj) {
drm_gem_object_unreference_unlocked(mfb->obj);
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index f6b283b..b435d3c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ 

[PATCH v2 15/25] drm/gma500: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Patrik Jakobsson 
Cc: Daniel Vetter 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/gma500/accel_2d.c|  6 ++---
 drivers/gpu/drm/gma500/framebuffer.c | 48 
 2 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/gma500/accel_2d.c 
b/drivers/gpu/drm/gma500/accel_2d.c
index de6f62a..db9f7d0 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -276,12 +276,12 @@ static void psbfb_copyarea_accel(struct fb_info *info,
break;
default:
/* software fallback */
-   cfb_copyarea(info, a);
+   drm_fb_helper_cfb_copyarea(info, a);
return;
}

if (!gma_power_begin(dev, false)) {
-   cfb_copyarea(info, a);
+   drm_fb_helper_cfb_copyarea(info, a);
return;
}
psb_accel_2d_copy(dev_priv,
@@ -308,7 +308,7 @@ void psbfb_copyarea(struct fb_info *info,
/* Avoid the 8 pixel erratum */
if (region->width == 8 || region->height == 8 ||
(info->flags & FBINFO_HWACCEL_DISABLED))
-   return cfb_copyarea(info, region);
+   return drm_fb_helper_cfb_copyarea(info, region);

psbfb_copyarea_accel(info, region);
 }
diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 2d42ce6..2eaf1b3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -194,9 +194,9 @@ static struct fb_ops psbfb_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = psbfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_mmap = psbfb_mmap,
.fb_sync = psbfb_sync,
.fb_ioctl = psbfb_ioctl,
@@ -208,9 +208,9 @@ static struct fb_ops psbfb_roll_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = psbfb_pan,
.fb_mmap = psbfb_mmap,
.fb_ioctl = psbfb_ioctl,
@@ -222,9 +222,9 @@ static struct fb_ops psbfb_unaccel_ops = {
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
.fb_setcolreg = psbfb_setcolreg,
-   .fb_fillrect = cfb_fillrect,
-   .fb_copyarea = cfb_copyarea,
-   .fb_imageblit = cfb_imageblit,
+   .fb_fillrect = drm_fb_helper_cfb_fillrect,
+   .fb_copyarea = drm_fb_helper_cfb_copyarea,
+   .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_mmap = psbfb_mmap,
.fb_ioctl = psbfb_ioctl,
 };
@@ -343,7 +343,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
struct drm_framebuffer *fb;
struct psb_framebuffer *psbfb = >pfb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
int size;
int ret;
struct gtt_range *backing;
@@ -409,9 +408,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,

mutex_lock(>struct_mutex);

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(>psb_fb_helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto out_err1;
}
info->par = fbdev;
@@ -426,7 +425,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
psbfb->fbdev = info;

fbdev->psb_fb_helper.fb = fb;
-   fbdev->psb_fb_helper.fbdev = info;

drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
strcpy(info->fix.id, "psbdrmfb");
@@ -440,12 +438,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
} else  /* Software */
info->fbops = _unaccel_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out_unref;
-   }
-
info->fix.smem_start = dev->mode_config.fb_base;
info->fix.smem_len = size;
info->fix.ywrapstep = gtt_roll;
@@ -456,11 +448,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
info->screen_size = size;

if (dev_priv->gtt.stolen_size) {
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_unref;
-  

[PATCH v2 14/25] drm/exynos: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Seung-Woo Kim 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 47 ---
 1 file changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e0b085b..dd64bc0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -65,9 +65,9 @@ static int exynos_drm_fb_mmap(struct fb_info *info,
 static struct fb_ops exynos_drm_fb_ops = {
.owner  = THIS_MODULE,
.fb_mmap= exynos_drm_fb_mmap,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -142,10 +142,10 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,

mutex_lock(>struct_mutex);

-   fbi = framebuffer_alloc(0, >dev);
-   if (!fbi) {
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
DRM_ERROR("failed to allocate fb info.\n");
-   ret = -ENOMEM;
+   ret = PTR_ERR(fbi);
goto out;
}

@@ -165,7 +165,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,

if (IS_ERR(exynos_gem_obj)) {
ret = PTR_ERR(exynos_gem_obj);
-   goto err_release_framebuffer;
+   goto err_release_fbi;
}

exynos_fbdev->exynos_gem_obj = exynos_gem_obj;
@@ -178,33 +178,23 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper 
*helper,
goto err_destroy_gem;
}

-   helper->fbdev = fbi;
-
fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _drm_fb_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("failed to allocate cmap.\n");
-   goto err_destroy_framebuffer;
-   }
-
ret = exynos_drm_fbdev_update(helper, sizes, helper->fb);
if (ret < 0)
-   goto err_dealloc_cmap;
+   goto err_destroy_framebuffer;

mutex_unlock(>struct_mutex);
return ret;

-err_dealloc_cmap:
-   fb_dealloc_cmap(>cmap);
 err_destroy_framebuffer:
drm_framebuffer_cleanup(helper->fb);
 err_destroy_gem:
exynos_drm_gem_destroy(exynos_gem_obj);
-err_release_framebuffer:
-   framebuffer_release(fbi);
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);

 /*
  * if failed, all resources allocated above would be released by
@@ -312,21 +302,8 @@ static void exynos_drm_fbdev_destroy(struct drm_device 
*dev,
}
}

-   /* release linux framebuffer */
-   if (fb_helper->fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = fb_helper->fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer()\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(fb_helper);
+   drm_fb_helper_release_fbi(fb_helper);

drm_fb_helper_fini(fb_helper);
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 13/25] drm/msm: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Rob Clark 
Cc: Stephane Viau 
Cc: Hai Li 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/msm/msm_fbdev.c | 34 ++
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 95f6532..f97a196 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -43,11 +43,11 @@ static struct fb_ops msm_fb_ops = {
/* Note: to properly handle manual update displays, we wrap the
 * basic fbdev ops which write to the framebuffer
 */
-   .fb_read = fb_sys_read,
-   .fb_write = fb_sys_write,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_read = drm_fb_helper_sys_read,
+   .fb_write = drm_fb_helper_sys_write,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_mmap = msm_fbdev_mmap,

.fb_check_var = drm_fb_helper_check_var,
@@ -144,10 +144,10 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
goto fail_unlock;
}

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
dev_err(dev->dev, "failed to allocate fb info\n");
-   ret = -ENOMEM;
+   ret = PTR_ERR(fbi);
goto fail_unlock;
}

@@ -155,7 +155,6 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,

fbdev->fb = fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_DEFAULT;
@@ -163,12 +162,6 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,

strcpy(fbi->fix.id, "msm");

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto fail_unlock;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -191,7 +184,6 @@ fail_unlock:
 fail:

if (ret) {
-   framebuffer_release(fbi);
if (fb) {
drm_framebuffer_unregister_private(fb);
drm_framebuffer_remove(fb);
@@ -266,17 +258,11 @@ void msm_fbdev_free(struct drm_device *dev)
struct msm_drm_private *priv = dev->dev_private;
struct drm_fb_helper *helper = priv->fbdev;
struct msm_fbdev *fbdev;
-   struct fb_info *fbi;

DBG();

-   fbi = helper->fbdev;
-
-   /* only cleanup framebuffer if it is present */
-   if (fbi) {
-   unregister_framebuffer(fbi);
-   framebuffer_release(fbi);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

drm_fb_helper_fini(helper);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 12/25] drm/tegra: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Thierry Reding 
Cc: "Terje Bergström" 
Cc: Stephen Warren 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/tegra/fb.c | 35 +--
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 397fb34..07c844b 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -184,9 +184,9 @@ unreference:
 #ifdef CONFIG_DRM_TEGRA_FBDEV
 static struct fb_ops tegra_fb_ops = {
.owner = THIS_MODULE,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank,
@@ -224,11 +224,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
if (IS_ERR(bo))
return PTR_ERR(bo);

-   info = framebuffer_alloc(0, drm->dev);
-   if (!info) {
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
dev_err(drm->dev, "failed to allocate framebuffer info\n");
drm_gem_object_unreference_unlocked(>gem);
-   return -ENOMEM;
+   return PTR_ERR(info);
}

fbdev->fb = tegra_fb_alloc(drm, , , 1);
@@ -248,12 +248,6 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
info->flags = FBINFO_FLAG_DEFAULT;
info->fbops = _fb_ops;

-   err = fb_alloc_cmap(>cmap, 256, 0);
-   if (err < 0) {
-   dev_err(drm->dev, "failed to allocate color map: %d\n", err);
-   goto destroy;
-   }
-
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(info, helper, fb->width, fb->height);

@@ -282,7 +276,7 @@ destroy:
drm_framebuffer_unregister_private(fb);
tegra_fb_destroy(fb);
 release:
-   framebuffer_release(info);
+   drm_fb_helper_release_fbi(helper);
return err;
 }

@@ -347,20 +341,9 @@ fini:

 static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
 {
-   struct fb_info *info = fbdev->base.fbdev;
-
-   if (info) {
-   int err;

-   err = unregister_framebuffer(info);
-   if (err < 0)
-   DRM_DEBUG_KMS("failed to unregister framebuffer\n");
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(>base);
+   drm_fb_helper_release_fbi(>base);

if (fbdev->fb) {
drm_framebuffer_unregister_private(>fb->base);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 11/25] drm/omap: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Tomi Valkeinen 
Cc: Laurent Pinchart 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 34 +++---
 1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c 
b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 23b5a84..a388a85 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -86,11 +86,11 @@ static struct fb_ops omap_fb_ops = {
/* Note: to properly handle manual update displays, we wrap the
 * basic fbdev ops which write to the framebuffer
 */
-   .fb_read = fb_sys_read,
-   .fb_write = fb_sys_write,
-   .fb_fillrect = sys_fillrect,
-   .fb_copyarea = sys_copyarea,
-   .fb_imageblit = sys_imageblit,
+   .fb_read = drm_fb_helper_sys_read,
+   .fb_write = drm_fb_helper_sys_write,
+   .fb_fillrect = drm_fb_helper_sys_fillrect,
+   .fb_copyarea = drm_fb_helper_sys_copyarea,
+   .fb_imageblit = drm_fb_helper_sys_imageblit,

.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
@@ -179,7 +179,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

mutex_lock(>struct_mutex);

-   fbi = framebuffer_alloc(0, dev->dev);
+   fbi = drm_fb_helper_alloc_fbi(helper);
if (!fbi) {
dev_err(dev->dev, "failed to allocate fb info\n");
ret = -ENOMEM;
@@ -190,7 +190,6 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

fbdev->fb = fb;
helper->fb = fb;
-   helper->fbdev = fbi;

fbi->par = helper;
fbi->flags = FBINFO_DEFAULT;
@@ -198,12 +197,6 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,

strcpy(fbi->fix.id, MODULE_NAME);

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto fail_unlock;
-   }
-
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);

@@ -236,8 +229,9 @@ fail_unlock:
 fail:

if (ret) {
-   if (fbi)
-   framebuffer_release(fbi);
+
+   drm_fb_helper_release_fbi(helper);
+
if (fb) {
drm_framebuffer_unregister_private(fb);
drm_framebuffer_remove(fb);
@@ -312,17 +306,11 @@ void omap_fbdev_free(struct drm_device *dev)
struct omap_drm_private *priv = dev->dev_private;
struct drm_fb_helper *helper = priv->fbdev;
struct omap_fbdev *fbdev;
-   struct fb_info *fbi;

DBG();

-   fbi = helper->fbdev;
-
-   /* only cleanup framebuffer if it is present */
-   if (fbi) {
-   unregister_framebuffer(fbi);
-   framebuffer_release(fbi);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

drm_fb_helper_fini(helper);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 10/25] drm/ast: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cleaned up the error handling in astfb_create a bit.

COMPILE TESTED ONLY.

Cc: David Airlie 
Cc: "Y.C. Chen" 
Cc: Alex Deucher 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/ast/ast_fb.c | 48 
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index ff68eef..f31db28 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -125,7 +125,7 @@ static void ast_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
ast_dirty_update(afbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -134,7 +134,7 @@ static void ast_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
ast_dirty_update(afbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -143,7 +143,7 @@ static void ast_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct ast_fbdev *afbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
ast_dirty_update(afbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -193,7 +193,6 @@ static int astfb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct fb_info *info;
int size, ret;
-   struct device *device = >pdev->dev;
void *sysram;
struct drm_gem_object *gobj = NULL;
struct ast_bo *bo = NULL;
@@ -217,40 +216,28 @@ static int astfb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (!info) {
-   ret = -ENOMEM;
-   goto out;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
+   goto err_free_vram;
}
info->par = afbdev;

ret = ast_framebuffer_init(dev, >afb, _cmd, gobj);
if (ret)
-   goto out;
+   goto err_release_fbi;

afbdev->sysram = sysram;
afbdev->size = size;

fb = >afb.base;
afbdev->helper.fb = fb;
-   afbdev->helper.fbdev = info;

strcpy(info->fix.id, "astdrmfb");

info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = _ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto out;
-   }
-
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out;
-   }
info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);

@@ -266,7 +253,11 @@ static int astfb_create(struct drm_fb_helper *helper,
  fb->width, fb->height);

return 0;
-out:
+
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);
+err_free_vram:
+   vfree(afbdev->sysram);
return ret;
 }

@@ -297,15 +288,10 @@ static const struct drm_fb_helper_funcs 
ast_fb_helper_funcs = {
 static void ast_fbdev_destroy(struct drm_device *dev,
  struct ast_fbdev *afbdev)
 {
-   struct fb_info *info;
struct ast_framebuffer *afb = >afb;
-   if (afbdev->helper.fbdev) {
-   info = afbdev->helper.fbdev;
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+
+   drm_fb_helper_unregister_fbi(>helper);
+   drm_fb_helper_release_fbi(>helper);

if (afb->obj) {
drm_gem_object_unreference_unlocked(afb->obj);
@@ -377,5 +363,5 @@ void ast_fbdev_set_suspend(struct drm_device *dev, int 
state)
if (!ast->fbdev)
return;

-   fb_set_suspend(ast->fbdev->helper.fbdev, state);
+   drm_fb_helper_set_suspend(>fbdev->helper, state);
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 09/25] drm/armada: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

COMPILE TESTED ONLY.

Cc: Russell King 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/armada/armada_fbdev.c | 33 ++---
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 7838e73..7d03c51 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -22,9 +22,9 @@ static /*const*/ struct fb_ops armada_fb_ops = {
.owner  = THIS_MODULE,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank   = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
@@ -80,18 +80,12 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
if (IS_ERR(dfb))
return PTR_ERR(dfb);

-   info = framebuffer_alloc(0, dev->dev);
-   if (!info) {
-   ret = -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(fbh);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto err_fballoc;
}

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   ret = -ENOMEM;
-   goto err_fbcmap;
-   }
-
strlcpy(info->fix.id, "armada-drmfb", sizeof(info->fix.id));
info->par = fbh;
info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
@@ -101,7 +95,7 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
info->screen_size = obj->obj.size;
info->screen_base = ptr;
fbh->fb = >fb;
-   fbh->fbdev = info;
+
drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth);
drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);

@@ -111,8 +105,6 @@ static int armada_fb_create(struct drm_fb_helper *fbh,

return 0;

- err_fbcmap:
-   framebuffer_release(info);
  err_fballoc:
dfb->fb.funcs->destroy(>fb);
return ret;
@@ -171,6 +163,7 @@ int armada_fbdev_init(struct drm_device *dev)

return 0;
  err_fb_setup:
+   drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
  err_fb_helper:
priv->fbdev = NULL;
@@ -191,14 +184,8 @@ void armada_fbdev_fini(struct drm_device *dev)
struct drm_fb_helper *fbh = priv->fbdev;

if (fbh) {
-   struct fb_info *info = fbh->fbdev;
-
-   if (info) {
-   unregister_framebuffer(info);
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(fbh);
+   drm_fb_helper_release_fbi(fbh);

drm_fb_helper_fini(fbh);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 08/25] drm/rockchip: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

This is an effort to create a top level drm fbdev emulation option.

COMPILE TESTED ONLY.

Cc: Mark Yao 
Cc: Daniel Vetter 
Cc: Rob Clark 
Cc: Daniel Kurtz 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 47 +++
 1 file changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 5b0dc0f..f261512 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -37,9 +37,9 @@ static int rockchip_fbdev_mmap(struct fb_info *info,
 static struct fb_ops rockchip_drm_fbdev_ops = {
.owner  = THIS_MODULE,
.fb_mmap= rockchip_fbdev_mmap,
-   .fb_fillrect= cfb_fillrect,
-   .fb_copyarea= cfb_copyarea,
-   .fb_imageblit   = cfb_imageblit,
+   .fb_fillrect= drm_fb_helper_cfb_fillrect,
+   .fb_copyarea= drm_fb_helper_cfb_copyarea,
+   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_blank   = drm_fb_helper_blank,
@@ -77,10 +77,10 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,

private->fbdev_bo = _obj->base;

-   fbi = framebuffer_alloc(0, dev->dev);
-   if (!fbi) {
-   dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-   ret = -ENOMEM;
+   fbi = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(fbi)) {
+   dev_err(dev->dev, "Failed to create framebuffer info.\n");
+   ret = PTR_ERR(fbi);
goto err_rockchip_gem_free_object;
}

@@ -89,21 +89,13 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,
if (IS_ERR(helper->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(helper->fb);
-   goto err_framebuffer_release;
+   goto err_release_fbi;
}

-   helper->fbdev = fbi;
-
fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = _drm_fbdev_ops;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   dev_err(dev->dev, "Failed to allocate color map.\n");
-   goto err_drm_framebuffer_unref;
-   }
-
fb = helper->fb;
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
@@ -124,10 +116,8 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,

return 0;

-err_drm_framebuffer_unref:
-   drm_framebuffer_unreference(helper->fb);
-err_framebuffer_release:
-   framebuffer_release(fbi);
+err_release_fbi:
+   drm_fb_helper_release_fbi(helper);
 err_rockchip_gem_free_object:
rockchip_gem_free_object(_obj->base);
return ret;
@@ -190,21 +180,8 @@ void rockchip_drm_fbdev_fini(struct drm_device *dev)

helper = >fbdev_helper;

-   if (helper->fbdev) {
-   struct fb_info *info;
-   int ret;
-
-   info = helper->fbdev;
-   ret = unregister_framebuffer(info);
-   if (ret < 0)
-   DRM_DEBUG_KMS("failed unregister_framebuffer() - %d\n",
- ret);
-
-   if (info->cmap.len)
-   fb_dealloc_cmap(>cmap);
-
-   framebuffer_release(info);
-   }
+   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_release_fbi(helper);

if (helper->fb)
drm_framebuffer_unreference(helper->fb);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 07/25] drm/cirrus: Use new drm_fb_helper functions

2015-07-22 Thread Archit Taneja
Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly.

COMPILE TESTED ONLY.

Cc: Thierry Reding 
Cc: Zach Reizner 
Cc: Russell King 
Cc: Fabian Frederick 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c   |  7 +++---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 41 +++
 2 files changed, 12 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index b914003..08bd176 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -56,7 +56,8 @@ static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-   remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
+   drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb",
+   primary);
kfree(ap);

return 0;
@@ -92,7 +93,7 @@ static int cirrus_pm_suspend(struct device *dev)

if (cdev->mode_info.gfbdev) {
console_lock();
-   fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 1);
+   drm_fb_helper_set_suspend(>mode_info.gfbdev->helper, 1);
console_unlock();
}

@@ -109,7 +110,7 @@ static int cirrus_pm_resume(struct device *dev)

if (cdev->mode_info.gfbdev) {
console_lock();
-   fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 0);
+   drm_fb_helper_set_suspend(>mode_info.gfbdev->helper, 0);
console_unlock();
}

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 13ddf1c..589103b 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -98,7 +98,7 @@ static void cirrus_fillrect(struct fb_info *info,
 const struct fb_fillrect *rect)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_fillrect(info, rect);
+   drm_fb_helper_sys_fillrect(info, rect);
cirrus_dirty_update(afbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -107,7 +107,7 @@ static void cirrus_copyarea(struct fb_info *info,
 const struct fb_copyarea *area)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_copyarea(info, area);
+   drm_fb_helper_sys_copyarea(info, area);
cirrus_dirty_update(afbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -116,7 +116,7 @@ static void cirrus_imageblit(struct fb_info *info,
  const struct fb_image *image)
 {
struct cirrus_fbdev *afbdev = info->par;
-   sys_imageblit(info, image);
+   drm_fb_helper_sys_imageblit(info, image);
cirrus_dirty_update(afbdev, image->dx, image->dy, image->width,
 image->height);
 }
@@ -165,12 +165,10 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 {
struct cirrus_fbdev *gfbdev =
container_of(helper, struct cirrus_fbdev, helper);
-   struct drm_device *dev = gfbdev->helper.dev;
struct cirrus_device *cdev = gfbdev->helper.dev->dev_private;
struct fb_info *info;
struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd;
-   struct device *device = >pdev->dev;
void *sysram;
struct drm_gem_object *gobj = NULL;
struct cirrus_bo *bo = NULL;
@@ -195,9 +193,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
if (!sysram)
return -ENOMEM;

-   info = framebuffer_alloc(0, device);
-   if (info == NULL)
-   return -ENOMEM;
+   info = drm_fb_helper_alloc_fbi(helper);
+   if (IS_ERR(info))
+   return PTR_ERR(info);

info->par = gfbdev;

@@ -216,11 +214,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper,

/* setup helper */
gfbdev->helper.fb = fb;
-   gfbdev->helper.fbdev = info;

strcpy(info->fix.id, "cirrusdrmfb");

-
info->flags = FBINFO_DEFAULT;
info->fbops = _ops;

@@ -229,11 +225,6 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
   sizes->fb_height);

/* setup aperture base/size for vesafb takeover */
-   info->apertures = alloc_apertures(1);
-   if (!info->apertures) {
-   ret = -ENOMEM;
-   goto out_iounmap;
-   }
info->apertures->ranges[0].base = cdev->dev->mode_config.fb_base;
info->apertures->ranges[0].size = cdev->mc.vram_size;

@@ -246,13 +237,6 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
info->fix.mmio_start = 0;
info->fix.mmio_len = 0;

-   ret = fb_alloc_cmap(>cmap, 256, 0);
-   if (ret) {
-   DRM_ERROR("%s: 

[PATCH v2 06/25] drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers

2015-07-22 Thread Archit Taneja
Some drm drivers call remove_conflicting_framebuffers. Create a
drm_fb_helper function that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 15 +++
 include/drm/drm_fb_helper.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9620aa5..d503528 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -894,6 +894,21 @@ void drm_fb_helper_set_suspend(struct drm_fb_helper 
*fb_helper, int state)
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend);

+/**
+ * drm_fb_helper_remove_conflicting_framebuffers - wrapper around
+ *
remove_conflicting_framebuffers
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around remove_conflicting_framebuffers implemented by fbdev core
+ */
+int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
+ const char *name,
+ bool primary)
+{
+   return remove_conflicting_framebuffers(a, name, primary);
+}
+EXPORT_SYMBOL(drm_fb_helper_remove_conflicting_framebuffers);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index ef32500..cbdc69d 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -168,6 +168,10 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info,

 void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state);

+int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
+ const char *name,
+ bool primary);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 05/25] drm/fb_helper: Create a wrapper for fb_set_suspend

2015-07-22 Thread Archit Taneja
Some drm drivers call fb_set_suspend. Create a drm_fb_helper function
that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 13 +
 include/drm/drm_fb_helper.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1312b6b..9620aa5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -881,6 +881,19 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info,
 }
 EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);

+/**
+ * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_set_suspend implemented by fbdev core
+ */
+void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state)
+{
+   if (fb_helper && fb_helper->fbdev)
+   fb_set_suspend(fb_helper->fbdev, state);
+}
+EXPORT_SYMBOL(drm_fb_helper_set_suspend);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 180290e..ef32500 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -166,6 +166,8 @@ void drm_fb_helper_cfb_copyarea(struct fb_info *info,
 void drm_fb_helper_cfb_imageblit(struct fb_info *info,
 const struct fb_image *image);

+void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 04/25] drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs

2015-07-22 Thread Archit Taneja
drm drivers that emulate fbdev populate their fb_fillrect, fb_copyarea
and fb_imageblit fb_ops with the help of cfb_* or sys_* fbdev core
helper functions.

Create drm_fb_helper functions that wrap around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/Kconfig |  6 
 drivers/gpu/drm/drm_fb_helper.c | 78 +
 include/drm/drm_fb_helper.h | 14 
 3 files changed, 98 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 6ab503b..35a8c0b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -38,6 +38,12 @@ config DRM_KMS_FB_HELPER
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
select FB_SYS_FOPS
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index abb36f9..1312b6b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -803,6 +803,84 @@ ssize_t drm_fb_helper_sys_write(struct fb_info *info, 
const char __user *buf,
 }
 EXPORT_SYMBOL(drm_fb_helper_sys_write);

+/**
+ * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_fillrect implemented by fbdev core
+ */
+void drm_fb_helper_sys_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect)
+{
+   sys_fillrect(info, rect);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
+
+/**
+ * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_copyarea implemented by fbdev core
+ */
+void drm_fb_helper_sys_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area)
+{
+   sys_copyarea(info, area);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
+
+/**
+ * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around sys_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_sys_imageblit(struct fb_info *info,
+const struct fb_image *image)
+{
+   sys_imageblit(info, image);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
+
+/**
+ * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_cfb_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect)
+{
+   cfb_fillrect(info, rect);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect);
+
+/**
+ * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_copyarea implemented by fbdev core
+ */
+void drm_fb_helper_cfb_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area)
+{
+   cfb_copyarea(info, area);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea);
+
+/**
+ * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around cfb_imageblit implemented by fbdev core
+ */
+void drm_fb_helper_cfb_imageblit(struct fb_info *info,
+const struct fb_image *image)
+{
+   cfb_imageblit(info, image);
+}
+EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index fc12368..180290e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -152,6 +152,20 @@ ssize_t drm_fb_helper_sys_read(struct fb_info *info, char 
__user *buf,
 ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos);

+void drm_fb_helper_sys_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect);
+void drm_fb_helper_sys_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area);
+void drm_fb_helper_sys_imageblit(struct fb_info *info,
+const struct fb_image *image);
+
+void drm_fb_helper_cfb_fillrect(struct fb_info *info,
+   const struct fb_fillrect *rect);
+void drm_fb_helper_cfb_copyarea(struct fb_info *info,
+   const struct fb_copyarea *area);
+void 

[PATCH v2 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-22 Thread Archit Taneja
Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
ops.

Create a drm_fb_helper function that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/Kconfig |  1 +
 drivers/gpu/drm/drm_fb_helper.c | 26 ++
 include/drm/drm_fb_helper.h |  5 +
 3 files changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c46ca31..6ab503b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
select FB
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
+   select FB_SYS_FOPS
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2f8dd8d..abb36f9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -777,6 +777,32 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);

+/**
+ * drm_fb_helper_sys_read - wrapper around fb_sys_read
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_sys_read implemented by fbdev core
+ */
+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+  size_t count, loff_t *ppos)
+{
+   return fb_sys_read(info, buf, count, ppos);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_read);
+
+/**
+ * drm_fb_helper_sys_write - wrapper around fb_sys_write
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around fb_sys_write implemented by fbdev core
+ */
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos)
+{
+   return fb_sys_write(info, buf, count, ppos);
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_write);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 4c90837..fc12368 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -147,6 +147,11 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t 
pitch,

 void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);

+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+  size_t count, loff_t *ppos);
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 02/25] drm/fb_helper: Create a wrapper for unlink_framebuffer

2015-07-22 Thread Archit Taneja
Some drm drivers call unlink_framebuffer. Create a drm_fb_helper function
that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 13 +
 include/drm/drm_fb_helper.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a5ae64a..2f8dd8d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -764,6 +764,19 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_fini);

+/**
+ * drm_fb_helper_unlink_fbi - wrapper around unlink_framebuffer
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around unlink_framebuffer implemented by fbdev core
+ */
+void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper && fb_helper->fbdev)
+   unlink_framebuffer(fb_helper->fbdev);
+}
+EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 2ee4ec5..4c90837 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -145,6 +145,8 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct 
drm_fb_helper *fb_helpe
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
uint32_t depth);

+void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 01/25] drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation

2015-07-22 Thread Archit Taneja
Every drm driver calls framebuffer_alloc, fb_alloc_cmap,
unregister_framebuffer, fb_dealloc_cmap and framebuffer_release in
order to emulate fbdev support.

Create drm_fb_helper functions that perform the above operations.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly. It also removes repetitive code from drivers.

There are some drivers that call alloc_apertures after framebuffer_alloc
and some that don't. Make the helper always call alloc_apertures. This
would make certain drivers allocate memory for apertures but not use
them. Since it's a small amount of memory, it shouldn't be an issue.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_fb_helper.c | 80 +
 include/drm/drm_fb_helper.h |  4 +++
 2 files changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cac4229..a5ae64a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -667,6 +667,86 @@ out_free:
 }
 EXPORT_SYMBOL(drm_fb_helper_init);

+/**
+ * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to alloc fb_info and the members cmap and apertures. Called
+ * by the driver within the fb_probe fb_helper callback function.
+ *
+ * RETURNS:
+ * fb_info pointer if things went okay, pointer containing error code
+ * otherwise
+ */
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
+{
+   struct device *dev = fb_helper->dev->dev;
+   struct fb_info *info;
+   int ret;
+
+   info = framebuffer_alloc(0, dev);
+   if (!info)
+   return ERR_PTR(-ENOMEM);
+
+   ret = fb_alloc_cmap(>cmap, 256, 0);
+   if (ret)
+   goto err_release;
+
+   info->apertures = alloc_apertures(1);
+   if (!info->apertures) {
+   ret = -ENOMEM;
+   goto err_free_cmap;
+   }
+
+   fb_helper->fbdev = info;
+
+   return info;
+
+err_free_cmap:
+   fb_dealloc_cmap(>cmap);
+err_release:
+   framebuffer_release(info);
+   return ERR_PTR(ret);
+}
+EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
+
+/**
+ * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around unregister_framebuffer, to release the fb_info
+ * framebuffer device
+ */
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper && fb_helper->fbdev)
+   unregister_framebuffer(fb_helper->fbdev);
+}
+EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
+
+/**
+ * drm_fb_helper_release_fbi - dealloc fb_info and its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to free memory taken by fb_info and the members cmap and
+ * apertures
+ */
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper)
+{
+   if (fb_helper) {
+   struct fb_info *info = fb_helper->fbdev;
+
+   if (info) {
+   if (info->cmap.len)
+   fb_dealloc_cmap(>cmap);
+   framebuffer_release(info);
+   }
+
+   fb_helper->fbdev = NULL;
+   }
+}
+EXPORT_SYMBOL(drm_fb_helper_release_fbi);
+
 void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 {
if (!list_empty(_helper->kernel_fb_list)) {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 0dfd94def..2ee4ec5 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -136,6 +136,10 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);

 bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper 
*fb_helper);
+
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper);
 void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper 
*fb_helper,
uint32_t fb_width, uint32_t fb_height);
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v2 00/25] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs

2015-07-22 Thread Archit Taneja
DRM drivers using drm_fb_helpers still call some fbdev core functions.
This makes the driver depend on CONFIG_FB, resulting in complicated
Kconfig options, and preventing us from creating a top level drm config
option to enable/disable FBDEV emulation.

Create new drm_fb_helper functions that replace these fbdev functions.

In most cases, the new helper funcs simply wrap around the original fbdev
functions. For a few (like framebufer_alloc), we actually do some work
that is currently redundant across multiple drivers.

With these patches, the drivers don't call any fbdev functions directly.
They are now called through functions in drm_fb_helper.c. We will later
create a fbdev emulation config option to stub out the fb helpers.

The only exception is vmwgfx driver. This doesn't use drm_fb_helper. It
creates a fb device how a driver in drivers/video/fbdev would. Maybe this
needs to be converted to use drm_fb_helpers.

For more info, have a look at the threads:
http://lists.freedesktop.org/archives/dri-devel/2015-March/078729.html
http://lists.freedesktop.org/archives/dri-devel/2015-March/078975.html

v2:
- Remove if (info) checks in fb_sys functions
- Use 'if (fb_helper && fb_helper->fbdev)' checks where appropriate
- Add kerneldocs for the new helper funcs
- Follow drm way of aligning of arguments in func definitions
- Fixed build error in drm/virtio
- Fixed error cleanup path in drm/tegra
- Fixed build error in drm/rockchip
- Fixed return issue in drm/amdgpu
- Fixed 'unused variable' warnings in bochs, ast, udl and radeon
- Fixed stray goto labels in cirrus, exynos, mgag

Archit Taneja (25):
  drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation
  drm/fb_helper: Create a wrapper for unlink_framebuffer
  drm/fb_helper: Create wrappers for fb_sys_read/write funcs
  drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs
  drm/fb_helper: Create a wrapper for fb_set_suspend
  drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers
  drm/cirrus: Use new drm_fb_helper functions
  drm/rockchip: Use new drm_fb_helper functions
  drm/armada: Use new drm_fb_helper functions
  drm/ast: Use new drm_fb_helper functions
  drm/omap: Use new drm_fb_helper functions
  drm/tegra: Use new drm_fb_helper functions
  drm/msm: Use new drm_fb_helper functions
  drm/exynos: Use new drm_fb_helper functions
  drm/gma500: Use new drm_fb_helper functions
  drm/mgag200: Use new drm_fb_helper functions
  drm/radeon: Use new drm_fb_helper functions
  drm/qxl: Use new drm_fb_helper functions
  drm/i915: Use new drm_fb_helper functions
  drm/nouveau: Use new drm_fb_helper functions
  drm/udl: Use new drm_fb_helper functions
  drm/bochs: Use new drm_fb_helper functions
  drm/amdgpu: Use new drm_fb_helper functions
  drm/virtio: Use new drm_fb_helper functions
  drm/fb_cma_helper: Use new drm_fb_helper functions

 drivers/gpu/drm/Kconfig   |   7 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c|  45 ++
 drivers/gpu/drm/armada/armada_fbdev.c |  33 ++--
 drivers/gpu/drm/ast/ast_fb.c  |  48 ++
 drivers/gpu/drm/bochs/bochs_drv.c |   6 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c   |  36 ++---
 drivers/gpu/drm/cirrus/cirrus_drv.c   |   7 +-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  41 +
 drivers/gpu/drm/drm_fb_cma_helper.c   |  45 ++
 drivers/gpu/drm/drm_fb_helper.c   | 225 ++
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  47 ++
 drivers/gpu/drm/gma500/accel_2d.c |   6 +-
 drivers/gpu/drm/gma500/framebuffer.c  |  48 ++
 drivers/gpu/drm/i915/i915_dma.c   |   3 +-
 drivers/gpu/drm/i915/intel_fbdev.c|  40 ++---
 drivers/gpu/drm/mgag200/mgag200_drv.c |   3 +-
 drivers/gpu/drm/mgag200/mgag200_fb.c  |  39 +
 drivers/gpu/drm/mgag200/mgag200_main.c|   2 +-
 drivers/gpu/drm/msm/msm_fbdev.c   |  34 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c |   3 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   |  39 ++---
 drivers/gpu/drm/omapdrm/omap_fbdev.c  |  34 ++--
 drivers/gpu/drm/qxl/qxl_fb.c  |  40 ++---
 drivers/gpu/drm/radeon/radeon_drv.c   |   4 +-
 drivers/gpu/drm/radeon/radeon_fb.c|  42 ++---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  47 ++
 drivers/gpu/drm/tegra/fb.c|  35 ++--
 drivers/gpu/drm/udl/udl_fb.c  |  41 ++---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c  |   3 +-
 drivers/gpu/drm/virtio/virtgpu_drv.h  |   1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c   |  32 ++--
 include/drm/drm_fb_helper.h   |  31 
 33 files changed, 508 insertions(+), 563 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH V4 4/6] mm: mlock: Introduce VM_LOCKONFAULT and add mlock flags to enable it

2015-07-22 Thread Vlastimil Babka
On 07/21/2015 09:59 PM, Eric B Munson wrote:
> The cost of faulting in all memory to be locked can be very high when
> working with large mappings.  If only portions of the mapping will be
> used this can incur a high penalty for locking.
>
> For the example of a large file, this is the usage pattern for a large
> statical language model (probably applies to other statical or graphical
> models as well).  For the security example, any application transacting
> in data that cannot be swapped out (credit card data, medical records,
> etc).
>
> This patch introduces the ability to request that pages are not
> pre-faulted, but are placed on the unevictable LRU when they are finally
> faulted in.  This can be done area at a time via the
> mlock2(MLOCK_ONFAULT) or the mlockall(MCL_ONFAULT) system calls.  These
> calls can be undone via munlock2(MLOCK_ONFAULT) or
> munlockall2(MCL_ONFAULT).
>
> Applying the VM_LOCKONFAULT flag to a mapping with pages that are
> already present required the addition of a function in gup.c to pin all
> pages which are present in an address range.  It borrows heavily from
> __mm_populate().
>
> To keep accounting checks out of the page fault path, users are billed
> for the entire mapping lock as if MLOCK_LOCKED was used.

Hi,

I think you should include a complete description of which transitions 
for vma states and mlock2/munlock2 flags applied on them are valid and 
what they do. It will also help with the manpages.
You explained some to Jon in the last thread, but I think there should 
be a canonical description in changelog (if not also Documentation, if 
mlock is covered there).

For example the scenario Jon asked, what happens after a 
mlock2(MLOCK_ONFAULT) followed by mlock2(MLOCK_LOCKED), and that the 
answer is "nothing". Your promised code comment for apply_vma_flags() 
doesn't suffice IMHO (and I'm not sure it's there, anyway?).

But the more I think about the scenario and your new VM_LOCKONFAULT vma 
flag, it seems awkward to me. Why should munlocking at all care if the 
vma was mlocked with MLOCK_LOCKED or MLOCK_ONFAULT? In either case the 
result is that all pages currently populated are munlocked. So the flags 
for munlock2 should be unnecessary.

I also think VM_LOCKONFAULT is unnecessary. VM_LOCKED should be enough - 
see how you had to handle the new flag in all places that had to handle 
the old flag? I think the information whether mlock was supposed to 
fault the whole vma is obsolete at the moment mlock returns. VM_LOCKED 
should be enough for both modes, and the flag to mlock2 could just 
control whether the pre-faulting is done.

So what should be IMHO enough:
- munlock can stay without flags
- mlock2 has only one new flag MLOCK_ONFAULT. If specified, pre-faulting 
is not done, just set VM_LOCKED and mlock pages already present.
- same with mmap(MAP_LOCKONFAULT) (need to define what happens when both 
MAP_LOCKED and MAP_LOCKONFAULT are specified).

Now mlockall(MCL_FUTURE) muddles the situation in that it stores the 
information for future VMA's in current->mm->def_flags, and this 
def_flags would need to distinguish VM_LOCKED with population and 
without. But that could be still solvable without introducing a new vma 
flag everywhere.


[PATCH 1/2] drm/radeon: Drop drm/ prefix for including drm.h in radeon_drm.h

2015-07-22 Thread Daniel Vetter
On Wed, Jul 22, 2015 at 06:16:41PM +0900, Michel Dänzer wrote:
> On 22.07.2015 18:16, Daniel Vetter wrote:
> > On Wed, Jul 22, 2015 at 10:38:18AM +0200, Christian König wrote:
> >> On 22.07.2015 10:29, Michel Dänzer wrote:
> >>> From: Michel Dänzer 
> >>>
> >>> This allows radeon_drm.h to be reused verbatim in libdrm.
> >>>
> >>> Signed-off-by: Michel Dänzer 
> >>
> >> For both patches Reviewed-by: Christian König  >> amd.com>
> > 
> > #ifdef __KERNEL__
> > #include 
> > #else
> > #include 
> > #endif
> > 
> > then run
> > 
> > $ make headers_install
> > 
> > and copy results verbatim to libdrm. That's at least how it's supposed to
> > be done.
> 
> What's the point of that?
> 
> #include "drm.h"
> 
> works in the kernel as well as in libdrm.

None for this case, was just an example how to handle the userspace
headers since you've said verbatim copy. It shouldn't ever be a verbatim
copy but always go through make headers_install. And it might make sense
to clean this up for all drivers since there's a bunch of random
differences in these. Anyway was just an idea.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 1/2] drm/radeon: Drop drm/ prefix for including drm.h in radeon_drm.h

2015-07-22 Thread Daniel Vetter
On Wed, Jul 22, 2015 at 10:38:18AM +0200, Christian König wrote:
> On 22.07.2015 10:29, Michel Dänzer wrote:
> >From: Michel Dänzer 
> >
> >This allows radeon_drm.h to be reused verbatim in libdrm.
> >
> >Signed-off-by: Michel Dänzer 
> 
> For both patches Reviewed-by: Christian König 

#ifdef __KERNEL__
#include 
#else
#include 
#endif

then run

$ make headers_install

and copy results verbatim to libdrm. That's at least how it's supposed to
be done. Might be useful to do that for all headers and sync up latest
headers with their copies in libdrm ...
-Daniel

> 
> >---
> >  include/uapi/drm/radeon_drm.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h
> >index 1ef7666..01aa2a8 100644
> >--- a/include/uapi/drm/radeon_drm.h
> >+++ b/include/uapi/drm/radeon_drm.h
> >@@ -33,7 +33,7 @@
> >  #ifndef __RADEON_DRM_H__
> >  #define __RADEON_DRM_H__
> >-#include 
> >+#include "drm.h"
> >  /* WARNING: If you change any of these defines, make sure to change the
> >   * defines in the X server file (radeon_sarea.h)
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


Linux-next, Exynos Octa boot fail, bisected to: "drm/exynos: remove drm_iommu_attach_device_if_possible"

2015-07-22 Thread Joonyoung Shim
On 07/21/2015 10:19 PM, Krzysztof Kozlowski wrote:
> Hi,
> 
> Today's linux-next (next-20150721) encounters boot failures on Exynos
> Octa (Exynos5422) based boards. The boards hangs. I bisected it to:
> 
> d80167b85024982c5f18d0481a5c248100360118 is the first bad commit
> commit d80167b85024982c5f18d0481a5c248100360118
> Author: Joonyoung Shim 
> Date:   Thu Jul 2 21:49:39 2015 +0900
> 
> drm/exynos: remove drm_iommu_attach_device_if_possible
> 
> Already drm_iommu_attach_device checks whether support iommu internally.
> It should clear channels always regardless iommu support. We didn't know
> because we can detect the problem when iommu is enabled, so we don't
> have to use drm_iommu_attach_device_if_possible and then we can remove
> drm_iommu_attach_device_if_possible and clear_channels function pointer.
> 
> Signed-off-by: Joonyoung Shim 
> Tested-by: Marek Szyprowski 
> Signed-off-by: Inki Dae 
> 
> :04 04 83379efbf4960f58d680371628ec04387935bd53
> da03c338b88e7cb6bda895b3dd52d78d9b6eba30 M drivers
> 
> 
> Config: exynos
> Boot log from Odroid XU3-Lite attached.
> 
> Any hints or ideas?

The point that hangs is when accesses fimd register in
fimd_clear_channels function, so i doubt clock setting for fimd.

It's gone something that hangs after i enable gating for ACLK_200_DISP1
clock.

If ACLK_200_DISP1 clock needs for fimd really, i'm thinking how can it
support. Any ideas?

Thanks.


[PATCH 1/2] drm/radeon: Drop drm/ prefix for including drm.h in radeon_drm.h

2015-07-22 Thread Christian König
On 22.07.2015 10:29, Michel Dänzer wrote:
> From: Michel Dänzer 
>
> This allows radeon_drm.h to be reused verbatim in libdrm.
>
> Signed-off-by: Michel Dänzer 

For both patches Reviewed-by: Christian König 

> ---
>   include/uapi/drm/radeon_drm.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h
> index 1ef7666..01aa2a8 100644
> --- a/include/uapi/drm/radeon_drm.h
> +++ b/include/uapi/drm/radeon_drm.h
> @@ -33,7 +33,7 @@
>   #ifndef __RADEON_DRM_H__
>   #define __RADEON_DRM_H__
>   
> -#include 
> +#include "drm.h"
>   
>   /* WARNING: If you change any of these defines, make sure to change the
>* defines in the X server file (radeon_sarea.h)



[PATCH v2 00/25] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs

2015-07-22 Thread Daniel Vetter
On Wed, Jul 22, 2015 at 12:29:36PM +0530, Archit Taneja wrote:
> DRM drivers using drm_fb_helpers still call some fbdev core functions.
> This makes the driver depend on CONFIG_FB, resulting in complicated
> Kconfig options, and preventing us from creating a top level drm config
> option to enable/disable FBDEV emulation.
> 
> Create new drm_fb_helper functions that replace these fbdev functions.
> 
> In most cases, the new helper funcs simply wrap around the original fbdev
> functions. For a few (like framebufer_alloc), we actually do some work
> that is currently redundant across multiple drivers.
> 
> With these patches, the drivers don't call any fbdev functions directly.
> They are now called through functions in drm_fb_helper.c. We will later
> create a fbdev emulation config option to stub out the fb helpers.
> 
> The only exception is vmwgfx driver. This doesn't use drm_fb_helper. It
> creates a fb device how a driver in drivers/video/fbdev would. Maybe this
> needs to be converted to use drm_fb_helpers.
> 
> For more info, have a look at the threads:
> http://lists.freedesktop.org/archives/dri-devel/2015-March/078729.html
> http://lists.freedesktop.org/archives/dri-devel/2015-March/078975.html
> 
> v2:
> - Remove if (info) checks in fb_sys functions
> - Use 'if (fb_helper && fb_helper->fbdev)' checks where appropriate
> - Add kerneldocs for the new helper funcs
> - Follow drm way of aligning of arguments in func definitions
> - Fixed build error in drm/virtio
> - Fixed error cleanup path in drm/tegra
> - Fixed build error in drm/rockchip
> - Fixed return issue in drm/amdgpu
> - Fixed 'unused variable' warnings in bochs, ast, udl and radeon
> - Fixed stray goto labels in cirrus, exynos, mgag

When resending patches please also have changelogs per-patch, not just in
the cover letter. Otherwise you have to constantly jump back

Also I'd drop the compile tested only from patches, just adds noise.
-Daniel

> 
> Archit Taneja (25):
>   drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation
>   drm/fb_helper: Create a wrapper for unlink_framebuffer
>   drm/fb_helper: Create wrappers for fb_sys_read/write funcs
>   drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs
>   drm/fb_helper: Create a wrapper for fb_set_suspend
>   drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers
>   drm/cirrus: Use new drm_fb_helper functions
>   drm/rockchip: Use new drm_fb_helper functions
>   drm/armada: Use new drm_fb_helper functions
>   drm/ast: Use new drm_fb_helper functions
>   drm/omap: Use new drm_fb_helper functions
>   drm/tegra: Use new drm_fb_helper functions
>   drm/msm: Use new drm_fb_helper functions
>   drm/exynos: Use new drm_fb_helper functions
>   drm/gma500: Use new drm_fb_helper functions
>   drm/mgag200: Use new drm_fb_helper functions
>   drm/radeon: Use new drm_fb_helper functions
>   drm/qxl: Use new drm_fb_helper functions
>   drm/i915: Use new drm_fb_helper functions
>   drm/nouveau: Use new drm_fb_helper functions
>   drm/udl: Use new drm_fb_helper functions
>   drm/bochs: Use new drm_fb_helper functions
>   drm/amdgpu: Use new drm_fb_helper functions
>   drm/virtio: Use new drm_fb_helper functions
>   drm/fb_cma_helper: Use new drm_fb_helper functions
> 
>  drivers/gpu/drm/Kconfig   |   7 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |   4 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c|  45 ++
>  drivers/gpu/drm/armada/armada_fbdev.c |  33 ++--
>  drivers/gpu/drm/ast/ast_fb.c  |  48 ++
>  drivers/gpu/drm/bochs/bochs_drv.c |   6 +-
>  drivers/gpu/drm/bochs/bochs_fbdev.c   |  36 ++---
>  drivers/gpu/drm/cirrus/cirrus_drv.c   |   7 +-
>  drivers/gpu/drm/cirrus/cirrus_fbdev.c |  41 +
>  drivers/gpu/drm/drm_fb_cma_helper.c   |  45 ++
>  drivers/gpu/drm/drm_fb_helper.c   | 225 
> ++
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  47 ++
>  drivers/gpu/drm/gma500/accel_2d.c |   6 +-
>  drivers/gpu/drm/gma500/framebuffer.c  |  48 ++
>  drivers/gpu/drm/i915/i915_dma.c   |   3 +-
>  drivers/gpu/drm/i915/intel_fbdev.c|  40 ++---
>  drivers/gpu/drm/mgag200/mgag200_drv.c |   3 +-
>  drivers/gpu/drm/mgag200/mgag200_fb.c  |  39 +
>  drivers/gpu/drm/mgag200/mgag200_main.c|   2 +-
>  drivers/gpu/drm/msm/msm_fbdev.c   |  34 ++--
>  drivers/gpu/drm/nouveau/nouveau_drm.c |   3 +-
>  drivers/gpu/drm/nouveau/nouveau_fbcon.c   |  39 ++---
>  drivers/gpu/drm/omapdrm/omap_fbdev.c  |  34 ++--
>  drivers/gpu/drm/qxl/qxl_fb.c  |  40 ++---
>  drivers/gpu/drm/radeon/radeon_drv.c   |   4 +-
>  drivers/gpu/drm/radeon/radeon_fb.c|  42 ++---
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  47 ++
>  drivers/gpu/drm/tegra/fb.c|  35 ++--
>  

[PATCH v1.1 2/5] drm/atomic: Make prepare_fb/cleanup_fb only take state, v2.

2015-07-22 Thread Rob Clark
On Thu, Jul 16, 2015 at 10:13 AM, Maarten Lankhorst
 wrote:
> This removes the need to separately track fb changes i915.
>
> Changes since v1:
> - Add dri-devel to cc.
> - Fix a check in intel's prepare and cleanup fb to take rotation
>   into account.
>
> Cc: dri-devel at lists.freedesktop.org
> Signed-off-by: Maarten Lankhorst 

Reviewed-by: Rob Clark 

> ---
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index be9fa8220499..36fda86b3518 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -712,11 +712,13 @@ static int atmel_hlcdc_plane_atomic_check(struct 
> drm_plane *p,
>  }
>
>  static int atmel_hlcdc_plane_prepare_fb(struct drm_plane *p,
> -   struct drm_framebuffer *fb,
> const struct drm_plane_state 
> *new_state)
>  {
> struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
>
> +   if (!new_state->fb)
> +   return 0;
> +
> return atmel_hlcdc_layer_update_start(>layer);
>  }
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 0898afbc9e23..e52dfc828e60 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1063,17 +1063,14 @@ int drm_atomic_helper_prepare_planes(struct 
> drm_device *dev,
> const struct drm_plane_helper_funcs *funcs;
> struct drm_plane *plane = state->planes[i];
> struct drm_plane_state *plane_state = state->plane_states[i];
> -   struct drm_framebuffer *fb;
>
> if (!plane)
> continue;
>
> funcs = plane->helper_private;
>
> -   fb = plane_state->fb;
> -
> -   if (fb && funcs->prepare_fb) {
> -   ret = funcs->prepare_fb(plane, fb, plane_state);
> +   if (funcs->prepare_fb) {
> +   ret = funcs->prepare_fb(plane, plane_state);
> if (ret)
> goto fail;
> }
> @@ -1086,17 +1083,14 @@ fail:
> const struct drm_plane_helper_funcs *funcs;
> struct drm_plane *plane = state->planes[i];
> struct drm_plane_state *plane_state = state->plane_states[i];
> -   struct drm_framebuffer *fb;
>
> if (!plane)
> continue;
>
> funcs = plane->helper_private;
>
> -   fb = state->plane_states[i]->fb;
> -
> -   if (fb && funcs->cleanup_fb)
> -   funcs->cleanup_fb(plane, fb, plane_state);
> +   if (funcs->cleanup_fb)
> +   funcs->cleanup_fb(plane, plane_state);
>
> }
>
> @@ -1252,14 +1246,11 @@ void drm_atomic_helper_cleanup_planes(struct 
> drm_device *dev,
>
> for_each_plane_in_state(old_state, plane, plane_state, i) {
> const struct drm_plane_helper_funcs *funcs;
> -   struct drm_framebuffer *old_fb;
>
> funcs = plane->helper_private;
>
> -   old_fb = plane_state->fb;
> -
> -   if (old_fb && funcs->cleanup_fb)
> -   funcs->cleanup_fb(plane, old_fb, plane_state);
> +   if (funcs->cleanup_fb)
> +   funcs->cleanup_fb(plane, plane_state);
> }
>  }
>  EXPORT_SYMBOL(drm_atomic_helper_cleanup_planes);
> diff --git a/drivers/gpu/drm/drm_plane_helper.c 
> b/drivers/gpu/drm/drm_plane_helper.c
> index b07a213f5655..03b7afe455e6 100644
> --- a/drivers/gpu/drm/drm_plane_helper.c
> +++ b/drivers/gpu/drm/drm_plane_helper.c
> @@ -425,7 +425,7 @@ int drm_plane_helper_commit(struct drm_plane *plane,
>
> if (plane_funcs->prepare_fb && plane_state->fb &&
> plane_state->fb != old_fb) {
> -   ret = plane_funcs->prepare_fb(plane, plane_state->fb,
> +   ret = plane_funcs->prepare_fb(plane,
>   plane_state);
> if (ret)
> goto out;
> @@ -478,8 +478,8 @@ int drm_plane_helper_commit(struct drm_plane *plane,
> ret = 0;
> }
>
> -   if (plane_funcs->cleanup_fb && old_fb)
> -   plane_funcs->cleanup_fb(plane, old_fb, plane_state);
> +   if (plane_funcs->cleanup_fb)
> +   plane_funcs->cleanup_fb(plane, plane_state);
>  out:
> if (plane_state) {
> if (plane->funcs->atomic_destroy_state)
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index 7dbfeacf0f38..b3990264e137 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4775,17 +4775,6 @@ static void intel_pre_plane_update(struct intel_crtc 
> *crtc)
>  

[Bug 91416] vsync limits fps but still tearing in picture

2015-07-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91416

--- Comment #1 from Michel Dänzer  ---
Yes, in order to avoid tearing, you either need to run the (OpenGL) application
in fullscreen with page flipping enabled, or you need to use a compositing
manager which does the same thing. When using a compositing manager, enabling
DRI3 may help.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150722/e21f7202/attachment.html>