[PULL] drm/tegra: Changes for v3.11-rc1

2013-06-27 Thread Thierry Reding
Hi Dave,

The following changes since commit c7788792a5e7b0d5d7f96d0766b4cb6112d47d75:

  Linux 3.10-rc2 (2013-05-20 14:37:38 -0700)

are available in the git repository at:

  git://anongit.freedesktop.org/tegra/linux.git drm/for-next

for you to fetch changes up to ebae30b1fbcc2cc991ce705cc82e16d1e5ddbf51:

  gpu: host1x: Rework CPU syncpoint increment (2013-06-22 12:43:55 +0200)

These changes are mostly minor fixes to things introduced in 3.10. The
biggest chunk is updates to the host1x firewall which checks job
submissions from userspace and wasn't working properly. All other
patches are mostly one-liners. Nothing new or too exciting this time
around.

Thierry


Arto Merilainen (5):
  gpu: host1x: Check reloc table before usage
  gpu: host1x: Copy gathers before verification
  gpu: host1x: Fix memory access in syncpt request
  gpu: host1x: Fix client_managed type
  gpu: host1x: Rework CPU syncpoint increment

Emil Goode (1):
  drm/tegra: Include header drm/drm.h

Laurent Pinchart (1):
  drm/tegra: Remove DRIVER_BUS_PLATFORM from driver_features

Terje Bergstrom (2):
  gpu: host1x: Check INCR opcode correctly
  gpu: host1x: Don't reset firewall between gathers

Thierry Reding (5):
  drm/tegra: Don't disable unused planes
  drm/tegra: Explicitly set irq_enabled
  drm/tegra: Honor pixel-format changes
  MAINTAINERS: Update Tegra DRM entry
  drm/tegra: Fix return value

Wei Yongjun (2):
  drm/tegra: fix missing unlock on error
  drm/tegra: fix error return code in gr2d_submit()

 MAINTAINERS   |   8 ++-
 drivers/gpu/host1x/dev.h  |   8 +--
 drivers/gpu/host1x/drm/dc.c   |   5 ++
 drivers/gpu/host1x/drm/drm.c  |  14 +++-
 drivers/gpu/host1x/drm/gr2d.c |  12 ++--
 drivers/gpu/host1x/hw/cdma_hw.c   |   2 +-
 drivers/gpu/host1x/hw/syncpt_hw.c |  12 ++--
 drivers/gpu/host1x/job.c  | 135 +-
 drivers/gpu/host1x/syncpt.c   |  26 +++-
 drivers/gpu/host1x/syncpt.h   |  13 ++--
 include/uapi/drm/tegra_drm.h  |   2 +
 11 files changed, 114 insertions(+), 123 deletions(-)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130627/635f49cc/attachment.pgp>


[Bug 65873] R600/SI: Cannot select store with truncate to 32-bit

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=65873

--- Comment #10 from Aaron Watry  ---
I've got a draft fix in my libclc repo on fdo.o.  I've tested for regressions
on Cedar (successfully), and I will test on SI with your 64-bit load patch asap
(hopefully tonight, but we'll see).

-- 
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/20130627/3b9d5c9b/attachment.html>


[PATCH v2 1/1] drm/mgag200: Added resolution and bandwidth limits for various G200e products.

2013-06-27 Thread Dave Airlie
> At the larger resolutions, the g200e series sometimes struggles with
> maintaining a proper output.  Problems like flickering or black bands 
> appearing
> on screen can occur.  In order to avoid this, limitations regarding 
> resolutions
> and bandwidth have been added for the different variations of the g200e 
> series.
> This code was ported from the old xorg mga driver.

Please run scripts/checkpatch.pl over patches before submitting them,
I'm seeing a few bad things in this.

Dave.

>
>
> Signed-off-by: Julia Lemire 
> ---
>  drivers/gpu/drm/mgag200/mgag200_drv.h  |3 +-
>  drivers/gpu/drm/mgag200/mgag200_main.c |2 +-
>  drivers/gpu/drm/mgag200/mgag200_mode.c |   64 
> ++--
>  3 files changed, 64 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
> b/drivers/gpu/drm/mgag200/mgag200_drv.h
> index bf29b2f..988911a 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.h
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
> @@ -198,7 +198,8 @@ struct mga_device {
> struct ttm_bo_device bdev;
> } ttm;
>
> -   u32 reg_1e24; /* SE model number */
> +   /* SE model number stored in reg 0x1e24 */
> +   u32 unique_rev_id;
>  };
>
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
> b/drivers/gpu/drm/mgag200/mgag200_main.c
> index 9905923..dafe049 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_main.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_main.c
> @@ -176,7 +176,7 @@ static int mgag200_device_init(struct drm_device *dev,
>
> /* stash G200 SE model number for later use */
> if (IS_G200_SE(mdev))
> -   mdev->reg_1e24 = RREG32(0x1e24);
> +   mdev->unique_rev_id = RREG32(0x1e24);
>
> ret = mga_vram_init(mdev);
> if (ret)
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
> b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index ee66bad..098bc3b 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -1008,7 +1008,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
>
>
> if (IS_G200_SE(mdev)) {
> -   if (mdev->reg_1e24 >= 0x02) {
> +   if (mdev->unique_rev_id >= 0x02) {
> u8 hi_pri_lvl;
> u32 bpp;
> u32 mb;
> @@ -1038,7 +1038,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
> WREG8(MGAREG_CRTCEXT_DATA, hi_pri_lvl);
> } else {
> WREG8(MGAREG_CRTCEXT_INDEX, 0x06);
> -   if (mdev->reg_1e24 >= 0x01)
> +   if (mdev->unique_rev_id >= 0x01)
> WREG8(MGAREG_CRTCEXT_DATA, 0x03);
> else
> WREG8(MGAREG_CRTCEXT_DATA, 0x04);
> @@ -1410,6 +1410,32 @@ static int mga_vga_get_modes(struct drm_connector 
> *connector)
> return ret;
>  }
>
> +static uint32_t mga_vga_calculate_mode_bandwidth(struct drm_display_mode * 
> mode,
> +   int bits_per_pixel)
> +{
> +   uint32_t total_area, divisor;
> +   uint64_t active_area, pixels_per_second, bandwidth;
> +   uint64_t bytes_per_pixel = (bits_per_pixel + 7) / 8;
> +
> +   divisor = 1024;
> +
> +   if(!mode->htotal || !mode->vtotal || !mode->clock)
> +   return 0;
> +
> +   active_area = mode->hdisplay * mode->vdisplay;
> +   total_area = mode->htotal * mode->vtotal;
> +
> +   pixels_per_second = active_area * mode->clock * 1000;
> +   do_div(pixels_per_second, total_area);
> +
> +   bandwidth = pixels_per_second * bytes_per_pixel * 100;
> +   do_div(bandwidth, divisor);
> +
> +   return (uint32_t)(bandwidth);
> +}
> +
> +#define MODE_BANDWIDTH MODE_BAD
> +
>  static int mga_vga_mode_valid(struct drm_connector *connector,
>  struct drm_display_mode *mode)
>  {
> @@ -1421,7 +1447,39 @@ static int mga_vga_mode_valid(struct drm_connector 
> *connector,
> int bpp = 32;
> int i = 0;
>
> -   /* FIXME: Add bandwidth and g200se limitations */
> +   if (IS_G200_SE(mdev)) {
> +   if (mdev->unique_rev_id == 0x01) {
> +   if (mode->hdisplay > 1600)
> +   return MODE_VIRTUAL_X;
> +   if (mode->vdisplay > 1200)
> +   return MODE_VIRTUAL_Y;
> +   if (mga_vga_calculate_mode_bandwidth(mode, bpp) > 
> (24400 * 1024))
> +   return MODE_BANDWIDTH;
> +   } else if (mdev->unique_rev_id >= 0x02) {
> +   if (mode->hdisplay > 1920)
> +   return MODE_VIRTUAL_X;
> +   if (mode->vdisplay > 1200)
> +   return MODE_VIRTUAL_Y;
> +   if 

[Bug 65873] R600/SI: Cannot select store with truncate to 32-bit

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=65873

--- Comment #9 from Tom Stellard  ---
The piglit test should work with this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130624/179364.html

But we should still try to fix the bug in libclc.

-- 
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/20130627/c02aa336/attachment.html>


[Bug 63599] [r600][r600] GPU lockup CP stall (kernel 3.2.47, 3.4, 3.8, 3.9)

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=63599

wojtek  changed:

   What|Removed |Added

Summary|[r600][r600] GPU lockup CP  |[r600][r600] GPU lockup CP
   |stall (kernel 3.8, 3.9) |stall (kernel
   ||3.2.47,3.4,3.8, 3.9)

--- Comment #12 from wojtek  ---
probably duplicate 
https://bugs.freedesktop.org/show_bug.cgi?id=56081
and almost the same issue
http://www.mail-archive.com/dri-devel at lists.freedesktop.org/msg40024.html

On my system with tree from 
http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip-4 
GPU lockup still present (tested on X11 and Wayland)

-- 
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/20130627/f2fa9cf1/attachment.html>


[pull] radeon drm-next-3.11

2013-06-27 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Hi Dave,

This is the pull request for radeon for 3.11.  Highlights include:

- Support for CIK (Sea Islands) asics: 3D, compute, UVD
- DPM (Dynamic Power Management) support for 6xx-SI
- ASPM support for 6xx-SI
- Assorted bug fixes

DPM is disabled by default for now until it gets further testing.  DPM
on 6xx and NI asics are still a bit problematic, but other asic families
are generally working well.  You can enable DPM by setting the dpm module
parameter to 1.

The following changes since commit 9b1be4dc02bb6b9761fbd8927c1750d75ddd2a8c:

  drm/radeon: fix UVD on big endian (2013-06-12 08:17:21 -0400)

are available in the git repository at:
  git://people.freedesktop.org/~agd5f/linux drm-next-3.11

Alex Deucher (166):
  drm/radeon: fix AVI infoframe generation
  drm/radeon: add backlight quirk for hybrid mac
  drm/radeon: add a reset work handler
  drm/radeon: add CIK chip families
  drm/radeon: add DCE8 macro for CIK
  drm/radeon: adapt to PCI BAR changes on CIK
  drm/radeon: add gpu init support for CIK (v9)
  drm/radeon: Add support for CIK GPU reset (v2)
  drm/radeon: add support for MC/VM setup on CIK (v6)
  drm/radeon/cik: stop page faults from hanging the system (v2)
  drm/radeon: add initial ucode loading for CIK (v5)
  drm/radeon: add support mc ucode loading on CIK (v2)
  drm/radeon: Add CP init for CIK (v7)
  drm/radeon: add IB and fence dispatch functions for CIK gfx (v7)
  drm/radeon: add ring and IB tests for CIK (v3)
  drm/radeon: implement async vm_flush for the CP (v7)
  drm/radeon: Add support for RLC init on CIK (v4)
  drm/radeon: add support for interrupts on CIK (v5)
  drm/radeon/cik: log and handle VM page fault interrupts
  drm/radeon/cik: add support for sDMA dma engines (v8)
  drm/radeon: implement async vm_flush for the sDMA (v6)
  drm/radeon/cik: add support for doing async VM pt updates (v5)
  drm/radeon/cik: fill in startup/shutdown callbacks (v5)
  drm/radeon: upstream ObjectID.h updates (v2)
  drm/radeon: upstream atombios.h updates (v2)
  drm/radeon: atombios power table updates (v2)
  drm/radeon: handle the integrated thermal controller on CI
  drm/radeon: update power state parsing for CI
  drm/radeon/dce8: add support for display watermark setup
  drm/radeon/cik: add hw cursor support (v2)
  drm/radeon/dce8: properly handle interlaced timing
  drm/radeon/dce8: crtc_set_base updates
  drm/radeon/atom: add DCE8 encoder support
  drm/radeon/atom: add support for new DVO tables
  drm/radeon: update DISPCLK programming for DCE8
  drm/radeon: add support pll selection for DCE8 (v4)
  drm/radeon: Handle PPLL0 powerdown on DCE8
  drm/radeon: use frac fb div on DCE8
  drm/radeon: add SS override support for KB/KV
  drm/radeon: Update radeon_info_ioctl for CIK (v2)
  drm/radeon: add get_gpu_clock_counter() callback for cik
  drm/radeon: update CIK soft reset
  drm/radeon: add indirect register accessors for SMC registers
  drm/radeon: add get_xclk() callback for CIK
  drm/radeon/cik: add pcie_port indirect register accessors
  drm/radeon: update radeon_atom_get_clock_dividers() for SI
  drm/radeon: update radeon_atom_get_clock_dividers for CIK
  drm/radeon/cik: add srbm_select function
  drm/radeon: use callbacks for ring pointer handling (v3)
  drm/radeon: implement simple doorbell page allocator
  drm/radeon/cik: Add support for compute queues (v4)
  drm/radeon/cik: switch to type3 nop packet for compute rings (v2)
  drm/radeon: fix up ring functions for compute rings
  drm/radeon/cik: add support for compute interrupts
  drm/radeon/cik: add support for golden register init
  drm/radeon: add radeon_asic struct for CIK (v12)
  drm/radeon: add cik tile mode array query
  drm/radeon: add current Bonaire PCI ids
  drm/radeon: add current KB pci ids
  drm/radeon/kms: add accessors for RCU indirect space
  drm/radeon/evergreen: add indirect register accessors for CG registers
  drm/radeon: make get_temperature functions a callback
  drm/radeon: add support for thermal sensor on tn
  drm/radeon/kms: move ucode defines to a separate header
  drm/radeon: properly set up the RLC on ON/LN/TN (v3)
  drm/radeon/kms: add atom helper functions for dpm (v3)
  drm/radeon/kms: add new asic struct for rv6xx (v4)
  drm/radeon/kms: add common dpm infrastructure
  drm/radeon/kms: fix up rs780/rs880 display watermark calc for dpm
  drm/radeon/kms: fix up 6xx/7xx display watermark calc for dpm
  drm/radeon/kms: fix up dce4/5 display watermark calc for dpm
  drm/radeon/kms: fix up dce6 display watermark calc for dpm
  drm/radeon/kms: add common r600 dpm functions
  drm/radeon/kms: add dpm support for rs780/rs880
  drm/radeon/kms: add dpm support for rv6xx 

[Bug 66243] X display is shifted upwards on GMA500

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=66243

Patrik Jakobsson  changed:

   What|Removed |Added

   Assignee|dri-devel at lists.freedesktop |patrik.r.jakobsson at 
gmail.co
   |.org|m

--- Comment #1 from Patrik Jakobsson  ---
Hi St?phane,
Thanks for reporting this bug. Could you try using the modesetting driver
instead of fbdev.

Also, I think this is solved by the following patch:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=61bb3fea44b71dd9935227920b036fdb96936f4d

So if you could try 3.10-rc7 while still using fbdev and report back, that
would be great.

-Patrik

-- 
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/20130627/d1d78111/attachment.html>


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Alex Deucher
On Thu, Jun 27, 2013 at 9:12 AM, Andy Furniss  wrote:
> Alex Deucher wrote:
>>
>> On Wed, Jun 26, 2013 at 9:21 AM,   wrote:
>>>
>>> From: Alex Deucher 
>>>
>>> These are the radeon patches for 3.11.  Some of these patches
>>> are huge so, it might be easier to review things here:
>>> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip
>>
>>
>> Updated branch:
>> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip-2
>> Takes into account comments from Jerome a Christian and contains a few
>> DPM fixes.
>
>
> I see there's a 3 now - I tested that (I guess currently it's the same as 2
> anyway).
>
> On my rv790 there are no regressions so far, but whatever I do it stays low.

This should work much better with with wip-5.

Alex


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 6:19 PM, James Cloos  wrote:
>> "AD" == Alex Deucher  writes:
>
> AD> Nope.  6xx and APUs do not require ucode.  only 7xx+ dGPUs.
>
> Does that mean that APUs do not require *any* ucode blobs?
>
> Or just that they do not require updated or additional blobs
> for the new functionality like DPM?
>
> -JimC
> --

They don't require any ucode blob for the power management. They do
require ucode blob for 3d acceleration, compute, well anything that
want to use the gpu really.

Cheers,
Jerome


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread James Cloos
> "AD" == Alex Deucher  writes:

AD> Nope.  6xx and APUs do not require ucode.  only 7xx+ dGPUs.

Does that mean that APUs do not require *any* ucode blobs?

Or just that they do not require updated or additional blobs
for the new functionality like DPM?

-JimC
-- 
James Cloos  OpenPGP: 1024D/ED7DAEA6


[Bug 65873] R600/SI: Cannot select store with truncate to 32-bit

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=65873

--- Comment #8 from Aaron Watry  ---
"Pointers on SI are 64-bit."

Talk about a "duh" moment. I'll see what I can do to fix and test the
vload/vstore implementation pointer generation since this is broken on SI,
maybe 64-bit PTX, and would also be broken on x86_64 (and others) if we ever
get around to supporting CPU targets in libclc.

-- 
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/20130627/ff7e665d/attachment.html>


[PATCH WW 11/13] drm/radeon: get rid of ttm_bo_is_reserved usage

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 01:48:26PM +0200, Maarten Lankhorst wrote:
> Try to use lockdep_assert_held or other alternatives where possible.
> 
> Signed-off-by: Maarten Lankhorst 

Reviewed-by: Jerome Glisse 

> ---
>  drivers/gpu/drm/radeon/radeon_object.c |  8 ++--
>  drivers/gpu/drm/radeon/radeon_object.h |  5 ---
>  drivers/gpu/drm/radeon/radeon_test.c   | 75 
> +-
>  3 files changed, 43 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
> b/drivers/gpu/drm/radeon/radeon_object.c
> index d850dc6..0219d26 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -400,7 +400,7 @@ int radeon_bo_get_surface_reg(struct radeon_bo *bo)
>   int steal;
>   int i;
>  
> - BUG_ON(!radeon_bo_is_reserved(bo));
> + lockdep_assert_held(>tbo.resv->lock.base);
>  
>   if (!bo->tiling_flags)
>   return 0;
> @@ -526,7 +526,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
>   uint32_t *tiling_flags,
>   uint32_t *pitch)
>  {
> - BUG_ON(!radeon_bo_is_reserved(bo));
> + lockdep_assert_held(>tbo.resv->lock.base);
> +
>   if (tiling_flags)
>   *tiling_flags = bo->tiling_flags;
>   if (pitch)
> @@ -536,7 +537,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
>  int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
>   bool force_drop)
>  {
> - BUG_ON(!radeon_bo_is_reserved(bo) && !force_drop);
> + if (!force_drop)
> + lockdep_assert_held(>tbo.resv->lock.base);
>  
>   if (!(bo->tiling_flags & RADEON_TILING_SURFACE))
>   return 0;
> diff --git a/drivers/gpu/drm/radeon/radeon_object.h 
> b/drivers/gpu/drm/radeon/radeon_object.h
> index 456ad6b..91519a5 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.h
> +++ b/drivers/gpu/drm/radeon/radeon_object.h
> @@ -98,11 +98,6 @@ static inline unsigned long radeon_bo_size(struct 
> radeon_bo *bo)
>   return bo->tbo.num_pages << PAGE_SHIFT;
>  }
>  
> -static inline bool radeon_bo_is_reserved(struct radeon_bo *bo)
> -{
> - return ttm_bo_is_reserved(>tbo);
> -}
> -
>  static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo)
>  {
>   return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE;
> diff --git a/drivers/gpu/drm/radeon/radeon_test.c 
> b/drivers/gpu/drm/radeon/radeon_test.c
> index bbed4af..f4d6bce 100644
> --- a/drivers/gpu/drm/radeon/radeon_test.c
> +++ b/drivers/gpu/drm/radeon/radeon_test.c
> @@ -35,7 +35,6 @@ static void radeon_do_test_moves(struct radeon_device 
> *rdev, int flag)
>  {
>   struct radeon_bo *vram_obj = NULL;
>   struct radeon_bo **gtt_obj = NULL;
> - struct radeon_fence *fence = NULL;
>   uint64_t gtt_addr, vram_addr;
>   unsigned i, n, size;
>   int r, ring;
> @@ -81,37 +80,38 @@ static void radeon_do_test_moves(struct radeon_device 
> *rdev, int flag)
>   }
>   r = radeon_bo_reserve(vram_obj, false);
>   if (unlikely(r != 0))
> - goto out_cleanup;
> + goto out_unref;
>   r = radeon_bo_pin(vram_obj, RADEON_GEM_DOMAIN_VRAM, _addr);
>   if (r) {
>   DRM_ERROR("Failed to pin VRAM object\n");
> - goto out_cleanup;
> + goto out_unres;
>   }
>   for (i = 0; i < n; i++) {
>   void *gtt_map, *vram_map;
>   void **gtt_start, **gtt_end;
>   void **vram_start, **vram_end;
> + struct radeon_fence *fence = NULL;
>  
>   r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
>RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i);
>   if (r) {
>   DRM_ERROR("Failed to create GTT object %d\n", i);
> - goto out_cleanup;
> + goto out_lclean;
>   }
>  
>   r = radeon_bo_reserve(gtt_obj[i], false);
>   if (unlikely(r != 0))
> - goto out_cleanup;
> + goto out_lclean_unref;
>   r = radeon_bo_pin(gtt_obj[i], RADEON_GEM_DOMAIN_GTT, _addr);
>   if (r) {
>   DRM_ERROR("Failed to pin GTT object %d\n", i);
> - goto out_cleanup;
> + goto out_lclean_unres;
>   }
>  
>   r = radeon_bo_kmap(gtt_obj[i], _map);
>   if (r) {
>   DRM_ERROR("Failed to map GTT object %d\n", i);
> - goto out_cleanup;
> + goto out_lclean_unpin;
>   }
>  
>   for (gtt_start = gtt_map, gtt_end = gtt_map + size;
> @@ -127,13 +127,13 @@ static void radeon_do_test_moves(struct radeon_device 
> *rdev, int flag)
>   r = radeon_copy_blit(rdev, gtt_addr, vram_addr, size / 
> RADEON_GPU_PAGE_SIZE, );
>   if (r) {

[PATCH WW 08/13] drm/radeon: inline reservations

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 01:48:23PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst 

Reviewed-by: Jerome Glisse 

> ---
>  drivers/gpu/drm/radeon/radeon_object.c | 23 ---
>  drivers/gpu/drm/radeon/radeon_object.h | 22 +-
>  2 files changed, 21 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
> b/drivers/gpu/drm/radeon/radeon_object.c
> index 71287bb..d850dc6 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -619,26 +619,3 @@ int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, 
> bool no_wait)
>   ttm_bo_unreserve(>tbo);
>   return r;
>  }
> -
> -
> -/**
> - * radeon_bo_reserve - reserve bo
> - * @bo:  bo structure
> - * @no_intr: don't return -ERESTARTSYS on pending signal
> - *
> - * Returns:
> - * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted 
> by
> - * a signal. Release all buffer reservations and return to user-space.
> - */
> -int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr)
> -{
> - int r;
> -
> - r = ttm_bo_reserve(>tbo, !no_intr, false, false, 0);
> - if (unlikely(r != 0)) {
> - if (r != -ERESTARTSYS)
> - dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
> - return r;
> - }
> - return 0;
> -}
> diff --git a/drivers/gpu/drm/radeon/radeon_object.h 
> b/drivers/gpu/drm/radeon/radeon_object.h
> index 3e62a3a..456ad6b 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.h
> +++ b/drivers/gpu/drm/radeon/radeon_object.h
> @@ -52,7 +52,27 @@ static inline unsigned radeon_mem_type_to_domain(u32 
> mem_type)
>   return 0;
>  }
>  
> -int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr);
> +/**
> + * radeon_bo_reserve - reserve bo
> + * @bo:  bo structure
> + * @no_intr: don't return -ERESTARTSYS on pending signal
> + *
> + * Returns:
> + * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted 
> by
> + * a signal. Release all buffer reservations and return to user-space.
> + */
> +static inline int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr)
> +{
> + int r;
> +
> + r = ttm_bo_reserve(>tbo, !no_intr, false, false, 0);
> + if (unlikely(r != 0)) {
> + if (r != -ERESTARTSYS)
> + dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
> + return r;
> + }
> + return 0;
> +}
>  
>  static inline void radeon_bo_unreserve(struct radeon_bo *bo)
>  {
> -- 
> 1.8.3.1
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH WW 04/13] drm/ttm: convert to the reservation api

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 01:48:19PM +0200, Maarten Lankhorst wrote:
> Now that the code is compatible in semantics, flip the switch.
> Use ww_mutex instead of the homegrown implementation.
> 
> ww_mutex uses -EDEADLK to signal that the caller has to back off,
> and -EALREADY to indicate this buffer is already held by the caller.
> 
> ttm used -EAGAIN and -EDEADLK for those, respectively. So some changes
> were needed to handle this correctly.
> 
> Signed-off-by: Maarten Lankhorst 

This one change the radeon cs kernel API. We will now return -EALREADY
if userspace try to send a cs with same bo two time on the list. Which
is bug in itself, but a bug that might have been abuse by some to force
trigger gpu reset (even if i am convince that i sent a patch at one
point to avoid that). I am not against that change just thought i should
point it off.

Reviewed-by: Jerome Glisse 

> ---
>  drivers/gpu/drm/nouveau/nouveau_gem.c  |   2 +-
>  drivers/gpu/drm/qxl/qxl_object.h   |   5 -
>  drivers/gpu/drm/ttm/ttm_bo.c   | 190 
> +
>  drivers/gpu/drm/ttm/ttm_bo_util.c  |   6 +-
>  drivers/gpu/drm/ttm/ttm_execbuf_util.c |  43 +++-
>  include/drm/ttm/ttm_bo_api.h   |  25 ++---
>  include/drm/ttm/ttm_execbuf_util.h |   1 -
>  7 files changed, 79 insertions(+), 193 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
> b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index e35d468..2b2077d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -368,7 +368,7 @@ retry:
>   ret = ttm_bo_reserve(>bo, true, false, true, >ticket);
>   if (ret) {
>   validate_fini_no_ticket(op, NULL);
> - if (unlikely(ret == -EAGAIN)) {
> + if (unlikely(ret == -EDEADLK)) {
>   ret = ttm_bo_reserve_slowpath(>bo, true,
> >ticket);
>   if (!ret)
> diff --git a/drivers/gpu/drm/qxl/qxl_object.h 
> b/drivers/gpu/drm/qxl/qxl_object.h
> index b4fd89f..ee7ad79 100644
> --- a/drivers/gpu/drm/qxl/qxl_object.h
> +++ b/drivers/gpu/drm/qxl/qxl_object.h
> @@ -57,11 +57,6 @@ static inline unsigned long qxl_bo_size(struct qxl_bo *bo)
>   return bo->tbo.num_pages << PAGE_SHIFT;
>  }
>  
> -static inline bool qxl_bo_is_reserved(struct qxl_bo *bo)
> -{
> - return !!atomic_read(>tbo.reserved);
> -}
> -
>  static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)
>  {
>   return bo->tbo.addr_space_offset;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index b912375..5f9fe80 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -150,6 +150,9 @@ static void ttm_bo_release_list(struct kref *list_kref)
>   if (bo->ttm)
>   ttm_tt_destroy(bo->ttm);
>   atomic_dec(>glob->bo_count);
> + if (bo->resv == >ttm_resv)
> + reservation_object_fini(>ttm_resv);
> +
>   if (bo->destroy)
>   bo->destroy(bo);
>   else {
> @@ -158,18 +161,6 @@ static void ttm_bo_release_list(struct kref *list_kref)
>   ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
>  }
>  
> -static int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
> -   bool interruptible)
> -{
> - if (interruptible) {
> - return wait_event_interruptible(bo->event_queue,
> -!ttm_bo_is_reserved(bo));
> - } else {
> - wait_event(bo->event_queue, !ttm_bo_is_reserved(bo));
> - return 0;
> - }
> -}
> -
>  void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
>  {
>   struct ttm_bo_device *bdev = bo->bdev;
> @@ -218,65 +209,27 @@ int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
> bool no_wait, bool use_ticket,
> struct ww_acquire_ctx *ticket)
>  {
> - int ret;
> + int ret = 0;
>  
> - while (unlikely(atomic_xchg(>reserved, 1) != 0)) {
> - /**
> -  * Deadlock avoidance for multi-bo reserving.
> -  */
> - if (use_ticket && bo->seq_valid) {
> - /**
> -  * We've already reserved this one.
> -  */
> - if (unlikely(ticket->stamp == bo->val_seq))
> - return -EDEADLK;
> - /**
> -  * Already reserved by a thread that will not back
> -  * off for us. We need to back off.
> -  */
> - if (unlikely(ticket->stamp - bo->val_seq <= LONG_MAX))
> - return -EAGAIN;
> - }
> + if (no_wait) {
> + bool success;
>  
> - if (no_wait)
> + /* not valid any more, fix your locking! */
> +  

[PATCH WW 02/13] drm/ttm: make ttm reservation calls behave like reservation calls

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 01:48:17PM +0200, Maarten Lankhorst wrote:
> This commit converts the source of the val_seq counter to
> the ww_mutex api. The reservation objects are converted later,
> because there is still a lockdep splat in nouveau that has to
> resolved first.
> 
> Signed-off-by: Maarten Lankhorst 

Reviewed-by: Jerome Glisse 

> ---
>  drivers/gpu/drm/nouveau/nouveau_gem.c| 38 ++---
>  drivers/gpu/drm/radeon/radeon.h  |  1 +
>  drivers/gpu/drm/radeon/radeon_cs.c   | 18 +-
>  drivers/gpu/drm/radeon/radeon_object.c   |  5 +--
>  drivers/gpu/drm/radeon/radeon_object.h   |  3 +-
>  drivers/gpu/drm/radeon/radeon_uvd.c  | 27 +++
>  drivers/gpu/drm/ttm/ttm_bo.c | 50 +--
>  drivers/gpu/drm/ttm/ttm_execbuf_util.c   | 58 
> +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  | 14 
>  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 23 -
>  include/drm/ttm/ttm_bo_api.h |  2 +-
>  include/drm/ttm/ttm_bo_driver.h  | 32 +-
>  include/drm/ttm/ttm_execbuf_util.h   | 13 +--
>  13 files changed, 172 insertions(+), 112 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
> b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 7054706..e35d468 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -277,10 +277,12 @@ struct validate_op {
>   struct list_head vram_list;
>   struct list_head gart_list;
>   struct list_head both_list;
> + struct ww_acquire_ctx ticket;
>  };
>  
>  static void
> -validate_fini_list(struct list_head *list, struct nouveau_fence *fence)
> +validate_fini_list(struct list_head *list, struct nouveau_fence *fence,
> +struct ww_acquire_ctx *ticket)
>  {
>   struct list_head *entry, *tmp;
>   struct nouveau_bo *nvbo;
> @@ -297,17 +299,24 @@ validate_fini_list(struct list_head *list, struct 
> nouveau_fence *fence)
>  
>   list_del(>entry);
>   nvbo->reserved_by = NULL;
> - ttm_bo_unreserve(>bo);
> + ttm_bo_unreserve_ticket(>bo, ticket);
>   drm_gem_object_unreference_unlocked(nvbo->gem);
>   }
>  }
>  
>  static void
> -validate_fini(struct validate_op *op, struct nouveau_fence* fence)
> +validate_fini_no_ticket(struct validate_op *op, struct nouveau_fence *fence)
>  {
> - validate_fini_list(>vram_list, fence);
> - validate_fini_list(>gart_list, fence);
> - validate_fini_list(>both_list, fence);
> + validate_fini_list(>vram_list, fence, >ticket);
> + validate_fini_list(>gart_list, fence, >ticket);
> + validate_fini_list(>both_list, fence, >ticket);
> +}
> +
> +static void
> +validate_fini(struct validate_op *op, struct nouveau_fence *fence)
> +{
> + validate_fini_no_ticket(op, fence);
> + ww_acquire_fini(>ticket);
>  }
>  
>  static int
> @@ -317,13 +326,11 @@ validate_init(struct nouveau_channel *chan, struct 
> drm_file *file_priv,
>  {
>   struct nouveau_cli *cli = nouveau_cli(file_priv);
>   struct drm_device *dev = chan->drm->dev;
> - struct nouveau_drm *drm = nouveau_drm(dev);
> - uint32_t sequence;
>   int trycnt = 0;
>   int ret, i;
>   struct nouveau_bo *res_bo = NULL;
>  
> - sequence = atomic_add_return(1, >ttm.validate_sequence);
> + ww_acquire_init(>ticket, _ww_class);
>  retry:
>   if (++trycnt > 10) {
>   NV_ERROR(cli, "%s failed and gave up.\n", __func__);
> @@ -338,6 +345,7 @@ retry:
>   gem = drm_gem_object_lookup(dev, file_priv, b->handle);
>   if (!gem) {
>   NV_ERROR(cli, "Unknown handle 0x%08x\n", b->handle);
> + ww_acquire_done(>ticket);
>   validate_fini(op, NULL);
>   return -ENOENT;
>   }
> @@ -352,21 +360,23 @@ retry:
>   NV_ERROR(cli, "multiple instances of buffer %d on "
> "validation list\n", b->handle);
>   drm_gem_object_unreference_unlocked(gem);
> + ww_acquire_done(>ticket);
>   validate_fini(op, NULL);
>   return -EINVAL;
>   }
>  
> - ret = ttm_bo_reserve(>bo, true, false, true, sequence);
> + ret = ttm_bo_reserve(>bo, true, false, true, >ticket);
>   if (ret) {
> - validate_fini(op, NULL);
> + validate_fini_no_ticket(op, NULL);
>   if (unlikely(ret == -EAGAIN)) {
> - sequence = atomic_add_return(1, 
> >ttm.validate_sequence);
>   ret = ttm_bo_reserve_slowpath(>bo, true,
> -   sequence);
> +   >ticket);
>

[PATCH WW 01/13] reservation: cross-device reservation support, v4

2013-06-27 Thread Jerome Glisse
On Thu, Jun 27, 2013 at 01:48:16PM +0200, Maarten Lankhorst wrote:
> This adds support for a generic reservations framework that can be
> hooked up to ttm and dma-buf and allows easy sharing of reservations
> across devices.
> 
> The idea is that a dma-buf and ttm object both will get a pointer
> to a struct reservation_object, which has to be reserved before
> anything is done with the contents of the dma-buf.
> 
> Changes since v1:
>  - Fix locking issue in ticket_reserve, which could cause mutex_unlock
>to be called too many times.
> Changes since v2:
>  - All fence related calls and members have been taken out for now,
>what's left is the bare minimum to be useful for ttm locking conversion.
> Changes since v3:
>  - Removed helper functions too. The documentation has an example
>implementation for locking. With the move to ww_mutex there is no
>need to have much logic any more.
> 
> Signed-off-by: Maarten Lankhorst 

Reviewed-by: Jerome Glisse 

> ---
>  Documentation/DocBook/device-drivers.tmpl |  2 +
>  drivers/base/Makefile |  2 +-
>  drivers/base/reservation.c| 39 +++
>  include/linux/reservation.h   | 62 
> +++
>  4 files changed, 104 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/base/reservation.c
>  create mode 100644 include/linux/reservation.h
> 
> diff --git a/Documentation/DocBook/device-drivers.tmpl 
> b/Documentation/DocBook/device-drivers.tmpl
> index c36892c..f0648a8 100644
> --- a/Documentation/DocBook/device-drivers.tmpl
> +++ b/Documentation/DocBook/device-drivers.tmpl
> @@ -126,6 +126,8 @@ X!Edrivers/base/interface.c
>   
>   Device Drivers DMA Management
>  !Edrivers/base/dma-buf.c
> +!Edrivers/base/reservation.c
> +!Iinclude/linux/reservation.h
>  !Edrivers/base/dma-coherent.c
>  !Edrivers/base/dma-mapping.c
>   
> diff --git a/drivers/base/Makefile b/drivers/base/Makefile
> index 4e22ce3..48029aa 100644
> --- a/drivers/base/Makefile
> +++ b/drivers/base/Makefile
> @@ -10,7 +10,7 @@ obj-$(CONFIG_CMA) += dma-contiguous.o
>  obj-y+= power/
>  obj-$(CONFIG_HAS_DMA)+= dma-mapping.o
>  obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
> -obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o
> +obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o
>  obj-$(CONFIG_ISA)+= isa.o
>  obj-$(CONFIG_FW_LOADER)  += firmware_class.o
>  obj-$(CONFIG_NUMA)   += node.o
> diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
> new file mode 100644
> index 000..a73fbf3
> --- /dev/null
> +++ b/drivers/base/reservation.c
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2012-2013 Canonical Ltd
> + *
> + * Based on bo.c which bears the following copyright notice,
> + * but is dual licensed:
> + *
> + * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
> + * All Rights Reserved.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the
> + * "Software"), to deal in the Software without restriction, including
> + * without limitation the rights to use, copy, modify, merge, publish,
> + * distribute, sub license, and/or sell copies of the Software, and to
> + * permit persons to whom the Software is furnished to do so, subject to
> + * the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> + * next paragraph) shall be included in all copies or substantial portions
> + * of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 
> CLAIM,
> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> + *
> + **/
> +/*
> + * Authors: Thomas Hellstrom 
> + */
> +
> +#include 
> +#include 
> +
> +DEFINE_WW_CLASS(reservation_ww_class);
> +EXPORT_SYMBOL(reservation_ww_class);
> diff --git a/include/linux/reservation.h b/include/linux/reservation.h
> new file mode 100644
> index 000..e9ee806
> --- /dev/null
> +++ b/include/linux/reservation.h
> @@ -0,0 +1,62 @@
> +/*
> + * Header file for reservations for dma-buf and ttm
> + *
> + * Copyright(C) 2011 Linaro Limited. All rights reserved.
> + * Copyright (C) 2012-2013 Canonical Ltd
> + * Copyright (C) 2012 Texas Instruments
> + *
> + * Authors:
> + * Rob Clark 
> + * Maarten Lankhorst 
> + * Thomas Hellstrom 
> + *
> + * Based on bo.c which bears the following copyright notice,
> + * but is dual licensed:
> + *
> + * Copyright (c) 2006-2009 

[Bug 65873] R600/SI: Cannot select store with truncate to 32-bit

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=65873

--- Comment #7 from Tom Stellard  ---
The SI backend needs to be fixed so it can handle zext i64 loads, but there is
also a bug in libclc.  The vload implementation assumes pointer types are
32-bit:

define <2 x i32> @__clc_vload2_impl_i32__global(i32 %offset,  i32 addrspace(1)*
nocapture %addr) nounwind readonly alwaysinline {
  %1 = ptrtoint i32 addrspace(1)* %addr to i32
  %2 = add i32 %1, %offset
  %3 = inttoptr i32 %2 to <2 x i32> addrspace(1)*
  %4 = load <2 x i32> addrspace(1)* %3, align 4, !tbaa !3
  ret <2 x i32> %4
}

Pointers on SI are 64-bit.  This ptrtoint, add, inttoptr sequence should be
replaced with a getelementptr and a bitcast.

-- 
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/20130627/38153bb5/attachment-0001.html>


Packard Bell EasyNote LV need i915.invert_brightness=1

2013-06-27 Thread Petter Reinholdtsen
[Daniel Vetter]
> The buttons might do something fancy behind the scenes (kernel or
> userspace), so can you please also check whether directly changing
> the backlight values in /sys/class/backlight works correctly?

There is full brightness when I set the value of max_brightness into
the brightness file (as in 'echo 4882 > brightness'), and complete
darkness when it is set to 0.  This was using acpi_backlight=vendor.
I suspect that mean the intel_backlight driver is working correctly,
but am not sure if 0 is supposed to be completely dark or not.

> acpi can't invert, and the different backlight drivers can affect
> each another in funny ways. Which is way we have a clearly defined
> priority order that userspace should use, and then _only_ touch the
> selected backlight. ACPI wins over i915, so if the ACPI backlight is
> broken (but the raw i915 backlight driver works) we need to
> blacklist it.

Right.  I guess my findings above mean the hardware should be
blacklisted (from acpi?).

Is there no way to discover using ACPI if the backlight brightness
setting should be inverted or not?

-- 
Happy hacking
Petter Reinholdtsen


[PATCH 02/24] drm/rcar-du: Use devm_ioremap_resource()

2013-06-27 Thread Sergei Shtylyov
Hello.

On 27-06-2013 13:49, Laurent Pinchart wrote:

> Replace the devm_request_mem_region() and devm_ioremap_nocache() calls
> with devm_ioremap_resource().

> Signed-off-by: Laurent Pinchart 
> ---
>   drivers/gpu/drm/rcar-du/rcar_du_drv.c | 20 ++--
>   1 file changed, 2 insertions(+), 18 deletions(-)

> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index 003b34e..24ab0ca 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
[...]
> @@ -129,24 +128,9 @@ static int rcar_du_load(struct drm_device *dev, unsigned 
> long flags)
>
>   /* I/O resources and clocks */
>   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
[...]
> + rcdu->mmio = devm_ioremap_resource(>dev, mem);
> + if (IS_ERR(rcdu->mmio))
>   return -ENOMEM;

You should return PTR_ERR(rcdu->mmio).

WBR, Sergei



[PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj

2013-06-27 Thread Maarten Lankhorst
Op 27-06-13 01:39, Seung-Woo Kim schreef:
> From: YoungJun Cho 
>
> The drm_gem_mmap_obj() has to be protected with dev->struct_mutex,
> but some caller functions do not. So it adds mutex lock to missing
> callers and adds assertion to check whether drm_gem_mmap_obj() is
> called with mutex lock or not.
>
> Signed-off-by: YoungJun Cho 
> Signed-off-by: Seung-Woo Kim 
> Signed-off-by: Kyungmin Park 
> CC: Laurent Pinchart 
> CC: Rob Clark 
>
Reviewed-by: Maarten Lankhorst 


[PATCH 069/165] drm/radeon/kms: add common dpm infrastructure

2013-06-27 Thread K. Schnass
Thanks for the work the whole thing seems to work fine on my RV770, although I 
cannot really say if does anything as I found no way to query the current clk 
or voltage?! There is one little gripe though, the rest of the code uses 
DRM_INFO() for printing whereas this series uses plain printk() resulting in 
some weird looking dmesg output:

Jun 27 14:41:54 my-little-devil kernel: [drm]   VGA-1
Jun 27 14:41:54 my-little-devil kernel: [drm]   DDC: 0x7e60 0x7e60 0x7e64 
0x7e64 0x7e68 0x7e68 0x7e6c 0x7e6c
Jun 27 14:41:54 my-little-devil kernel: [drm]   Encoders:
Jun 27 14:41:54 my-little-devil kernel: [drm] CRT2: INTERNAL_KLDSCP_DAC2
Jun 27 14:41:54 my-little-devil kernel: [drm] Internal thermal controller with 
fan control
Jun 27 14:41:54 my-little-devil kernel: == power state 0 ==
Jun 27 14:41:54 my-little-devil kernel: ui class: none
Jun 27 14:41:54 my-little-devil kernel: internal class: boot 
Jun 27 14:41:54 my-little-devil kernel: caps: video 
Jun 27 14:41:54 my-little-devil kernel: uvdvclk: 0 dclk: 0
Jun 27 14:41:54 my-little-devil kernel: power level 0sclk: 
62500 mclk: 99300 vddc: 1123
Jun 27 14:41:54 my-little-devil kernel: power level 1sclk: 
62500 mclk: 99300 vddc: 1123
Jun 27 14:41:54 my-little-devil kernel: power level 2sclk: 
62500 mclk: 99300 vddc: 1123

best regards
K. Schnass


Packard Bell EasyNote LV need i915.invert_brightness=1

2013-06-27 Thread Daniel Vetter
On Thu, Jun 27, 2013 at 3:03 PM, Petter Reinholdtsen  wrote:
> [Daniel Vetter]
>> acpi_backlight=vendor should disable the acpi backlights (you can
>> check that in /sys/class/backlight), which would mean that userspace
>> should fall back to intel backlight driver. Can you please check
>> whether that one works even without the invert_brightness knob? I.e.
>> not just whether you'll end up with a black screen, but whether
>> adjusting the backlight also works correctly.
>
> Adjusting backlight using the laptop keys for this work in KDE when I
> boot with acpi_backlight=vendor and without invert_brightness=1.  I am
> not sure if the buttons work the right way, though (never seen which
> should increase or decrease the brighness), so it might be inverted.

The buttons might do something fancy behind the scenes (kernel or
userspace), so can you please also check whether directly changing the
backlight values in /sys/class/backlight works correctly?

> Is it possible to tell acpi_backlight to invert the brighness setting?
> Would it affect i915 too?

acpi can't invert, and the different backlight drivers can affect each
another in funny ways. Which is way we have a clearly defined priority
order that userspace should use, and then _only_ touch the selected
backlight. ACPI wins over i915, so if the ACPI backlight is broken
(but the raw i915 backlight driver works) we need to blacklist it.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 64695] Enabling both MLAA and MLAA color 2D crashes Gnome Shell on Cayman (6950)

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=64695

--- Comment #4 from Brian Paul  ---
I'm going to push this patch since it fixes some issues we've seen here.

-- 
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/20130627/20e89eef/attachment.html>


Packard Bell EasyNote LV need i915.invert_brightness=1

2013-06-27 Thread Petter Reinholdtsen
[Daniel Vetter]
> acpi_backlight=vendor should disable the acpi backlights (you can
> check that in /sys/class/backlight), which would mean that userspace
> should fall back to intel backlight driver. Can you please check
> whether that one works even without the invert_brightness knob? I.e.
> not just whether you'll end up with a black screen, but whether
> adjusting the backlight also works correctly.

Adjusting backlight using the laptop keys for this work in KDE when I
boot with acpi_backlight=vendor and without invert_brightness=1.  I am
not sure if the buttons work the right way, though (never seen which
should increase or decrease the brighness), so it might be inverted.

Is it possible to tell acpi_backlight to invert the brighness setting?
Would it affect i915 too?

-- 
Happy hacking
Petter Reinholdtsen


[PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj

2013-06-27 Thread Laurent Pinchart
Hi,


On Thursday 27 June 2013 08:39:58 Seung-Woo Kim wrote:
> From: YoungJun Cho 
> 
> The drm_gem_mmap_obj() has to be protected with dev->struct_mutex,
> but some caller functions do not. So it adds mutex lock to missing
> callers and adds assertion to check whether drm_gem_mmap_obj() is
> called with mutex lock or not.
> 
> Signed-off-by: YoungJun Cho 
> Signed-off-by: Seung-Woo Kim 
> Signed-off-by: Kyungmin Park 
> CC: Laurent Pinchart 
> CC: Rob Clark 

Thanks for the patch.

Reviewed-by: Laurent Pinchart 

> ---
> This patch is based on drm-next branch.
> 
> Changes since v1:
> - Use lockdep_assert_held() instead of mutex_is_locked() as Maarten
> commented
> - Fix commit message about assertion
> 
>  drivers/gpu/drm/drm_gem.c |4 
>  drivers/gpu/drm/drm_gem_cma_helper.c  |3 +++
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |3 +++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 4321713..34c0be7 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -661,6 +661,8 @@ EXPORT_SYMBOL(drm_gem_vm_close);
>   * the GEM object is not looked up based on its fake offset. To implement
> the * DRM mmap operation, drivers should use the drm_gem_mmap() function. *
> + * NOTE: This function has to be protected with dev->struct_mutex
> + *
>   * Return 0 or success or -EINVAL if the object size is smaller than the
> VMA * size, or if no gem_vm_ops are provided.
>   */
> @@ -669,6 +671,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj,
> unsigned long obj_size, {
>   struct drm_device *dev = obj->dev;
> 
> + lockdep_assert_held(>struct_mutex);
> +
>   /* Check for valid size. */
>   if (obj_size < vma->vm_end - vma->vm_start)
>   return -EINVAL;
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c
> b/drivers/gpu/drm/drm_gem_cma_helper.c index 9efabce..ce06397 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -487,9 +487,12 @@ static int drm_gem_cma_dmabuf_mmap(struct dma_buf
> *dmabuf, {
>   struct drm_gem_cma_object *cma_obj = dmabuf->priv;
>   struct drm_gem_object *gem_obj = _obj->base;
> + struct drm_device *dev = gem_obj->dev;
>   int ret;
> 
> + mutex_lock(>struct_mutex);
>   ret = drm_gem_mmap_obj(gem_obj, gem_obj->size, vma);
> + mutex_unlock(>struct_mutex);
>   if (ret < 0)
>   return ret;
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 3256693..4fcca8d 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> @@ -140,12 +140,15 @@ static int omap_gem_dmabuf_mmap(struct dma_buf
> *buffer, struct vm_area_struct *vma)
>  {
>   struct drm_gem_object *obj = buffer->priv;
> + struct drm_device *dev = obj->dev;
>   int ret = 0;
> 
>   if (WARN_ON(!obj->filp))
>   return -EINVAL;
> 
> + mutex_lock(>struct_mutex);
>   ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
> + mutex_unlock(>struct_mutex);
>   if (ret < 0)
>   return ret;
-- 
Regards,

Laurent Pinchart



Packard Bell EasyNote LV need i915.invert_brightness=1

2013-06-27 Thread Daniel Vetter
On Wed, Jun 26, 2013 at 7:35 PM, Petter Reinholdtsen  wrote:
> [Daniel Vetter]
>>> Is there some other quirk table for acpi that also need to be updated?
>>
>> If the acpi brightness controller is broken, it needs to be quirked
>> away.  For that please file a bug report against the ACPI subsystem.
>
> Right.  Where do I do that?  I can do it if I know what to do. :)
>
>> With that done the automagic fallback rules of the intel DDX driver
>> should expose the "right" backlight interface through the backlight
>> xrandr property. If KDE's powerdevil isn't using that one (and frobs
>> around with the backlight controllers directly) that'd be a bug in
>> kde.
>
> I discovered that by adding acpi_backlight=vendor and keeping the
> i915.invert_brightness=1 setting, the screen went black again.  So
> these settings seem to cancel each other out.  But if I remove
> i915.invert_brightness=1, the screen no longer turn black, and KDE no
> longer turn off the screen when I log in, because instead of using the
> acpi_backlight interface it is using the intel_backlight interface,
> which is not inverted.
>
> So I wonder, perhaps i915.invert_brightness=1 is the wrong quirk for
> this machine?

acpi_backlight=vendor should disable the acpi backlights (you can
check that in /sys/class/backlight), which would mean that userspace
should fall back to intel backlight driver. Can you please check
whether that one works even without the invert_brightness knob? I.e.
not just whether you'll end up with a black screen, but whether
adjusting the backlight also works correctly.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH WW 10/13] drm/ttm: get rid of ttm_bo_is_reserved usage

2013-06-27 Thread Daniel Vetter
On Thu, Jun 27, 2013 at 01:48:25PM +0200, Maarten Lankhorst wrote:
> Use lockdep_assert_held instead.
> 
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index a8a27f5..6e6975c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -166,7 +166,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
>   struct ttm_bo_device *bdev = bo->bdev;
>   struct ttm_mem_type_manager *man;
>  
> - BUG_ON(!ttm_bo_is_reserved(bo));
> + lockdep_assert_held(>resv->lock.base);

What about assert_ttm_bo_is_reserved instead to both dtrt and also hide
the pointer chasing a bit better? Maybe even add a
assert_reservation_is_held helper to the very first patch?

Same comment applies to following patches which roll this change out on
the drivers.
-Daniel

>  
>   if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
>  
> @@ -671,7 +671,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, 
> bool interruptible,
>   goto out;
>   }
>  
> - BUG_ON(!ttm_bo_is_reserved(bo));
> + lockdep_assert_held(>resv->lock.base);
>  
>   evict_mem = bo->mem;
>   evict_mem.mm_node = NULL;
> @@ -961,7 +961,7 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
>   struct ttm_mem_reg mem;
>   struct ttm_bo_device *bdev = bo->bdev;
>  
> - BUG_ON(!ttm_bo_is_reserved(bo));
> + lockdep_assert_held(>resv->lock.base);
>  
>   /*
>* FIXME: It's possible to pipeline buffer moves.
> @@ -1020,7 +1020,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
>  {
>   int ret;
>  
> - BUG_ON(!ttm_bo_is_reserved(bo));
> + lockdep_assert_held(>resv->lock.base);
>   /* Check that range is valid */
>   if (placement->lpfn || placement->fpfn)
>   if (placement->fpfn > placement->lpfn ||
> -- 
> 1.8.3.1
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH WW 09/13] drm/ttm: inline ttm_bo_reserve and related calls

2013-06-27 Thread Daniel Vetter
On Thu, Jun 27, 2013 at 01:48:24PM +0200, Maarten Lankhorst wrote:
> Makes lockdep a lot more useful.
> 
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c   | 105 ++--
>  drivers/gpu/drm/ttm/ttm_execbuf_util.c |   9 +-
>  include/drm/ttm/ttm_bo_driver.h| 175 
> -

The function movement in the header makes the diff a bit hard to read. So
if possible I think that should be avoided. Anyway I think I've spotted a
few kerneldoc updates (like s/EAGAIN/EDEADLK/) which should be part of the
main conversion patch.
-Daniel

>  3 files changed, 117 insertions(+), 172 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 5f9fe80..a8a27f5 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -182,6 +182,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
>   }
>   }
>  }
> +EXPORT_SYMBOL(ttm_bo_add_to_lru);
>  
>  int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
>  {
> @@ -204,35 +205,6 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
>   return put_count;
>  }
>  
> -int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
> -   bool interruptible,
> -   bool no_wait, bool use_ticket,
> -   struct ww_acquire_ctx *ticket)
> -{
> - int ret = 0;
> -
> - if (no_wait) {
> - bool success;
> -
> - /* not valid any more, fix your locking! */
> - if (WARN_ON(ticket))
> - return -EBUSY;
> -
> - success = ww_mutex_trylock(>resv->lock);
> - return success ? 0 : -EBUSY;
> - }
> -
> - if (interruptible)
> - ret = ww_mutex_lock_interruptible(>resv->lock,
> -   ticket);
> - else
> - ret = ww_mutex_lock(>resv->lock, ticket);
> - if (ret == -EINTR)
> - return -ERESTARTSYS;
> - return ret;
> -}
> -EXPORT_SYMBOL(ttm_bo_reserve);
> -
>  static void ttm_bo_ref_bug(struct kref *list_kref)
>  {
>   BUG();
> @@ -245,77 +217,16 @@ void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, 
> int count,
>(never_free) ? ttm_bo_ref_bug : ttm_bo_release_list);
>  }
>  
> -int ttm_bo_reserve(struct ttm_buffer_object *bo,
> -bool interruptible,
> -bool no_wait, bool use_ticket,
> -struct ww_acquire_ctx *ticket)
> -{
> - struct ttm_bo_global *glob = bo->glob;
> - int put_count = 0;
> - int ret;
> -
> - ret = ttm_bo_reserve_nolru(bo, interruptible, no_wait, use_ticket,
> - ticket);
> - if (likely(ret == 0)) {
> - spin_lock(>lru_lock);
> - put_count = ttm_bo_del_from_lru(bo);
> - spin_unlock(>lru_lock);
> - ttm_bo_list_ref_sub(bo, put_count, true);
> - }
> -
> - return ret;
> -}
> -
> -int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
> - bool interruptible, struct ww_acquire_ctx *ticket)
> -{
> - struct ttm_bo_global *glob = bo->glob;
> - int put_count = 0;
> - int ret = 0;
> -
> - if (interruptible)
> - ret = ww_mutex_lock_slow_interruptible(>resv->lock,
> -ticket);
> - else
> - ww_mutex_lock_slow(>resv->lock, ticket);
> -
> - if (likely(ret == 0)) {
> - spin_lock(>lru_lock);
> - put_count = ttm_bo_del_from_lru(bo);
> - spin_unlock(>lru_lock);
> - ttm_bo_list_ref_sub(bo, put_count, true);
> - } else if (ret == -EINTR)
> - ret = -ERESTARTSYS;
> -
> - return ret;
> -}
> -EXPORT_SYMBOL(ttm_bo_reserve_slowpath);
> -
> -void ttm_bo_unreserve_ticket_locked(struct ttm_buffer_object *bo, struct 
> ww_acquire_ctx *ticket)
> +void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
>  {
> - ttm_bo_add_to_lru(bo);
> - ww_mutex_unlock(>resv->lock);
> -}
> -
> -void ttm_bo_unreserve(struct ttm_buffer_object *bo)
> -{
> - struct ttm_bo_global *glob = bo->glob;
> -
> - spin_lock(>lru_lock);
> - ttm_bo_unreserve_ticket_locked(bo, NULL);
> - spin_unlock(>lru_lock);
> -}
> -EXPORT_SYMBOL(ttm_bo_unreserve);
> -
> -void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, struct 
> ww_acquire_ctx *ticket)
> -{
> - struct ttm_bo_global *glob = bo->glob;
> + int put_count;
>  
> - spin_lock(>lru_lock);
> - ttm_bo_unreserve_ticket_locked(bo, ticket);
> - spin_unlock(>lru_lock);
> + spin_lock(>glob->lru_lock);
> + put_count = ttm_bo_del_from_lru(bo);
> + spin_unlock(>glob->lru_lock);
> + ttm_bo_list_ref_sub(bo, put_count, true);
>  }
> -EXPORT_SYMBOL(ttm_bo_unreserve_ticket);
> +EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
>  
>  /*
>   * Call bo->mutex locked.
> diff --git 

[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Andy Furniss
Alex Deucher wrote:
> On Wed, Jun 26, 2013 at 9:21 AM,   wrote:
>> From: Alex Deucher 
>>
>> These are the radeon patches for 3.11.  Some of these patches
>> are huge so, it might be easier to review things here:
>> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip
>
> Updated branch:
> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip-2
> Takes into account comments from Jerome a Christian and contains a few
> DPM fixes.

I see there's a 3 now - I tested that (I guess currently it's the same 
as 2 anyway).

On my rv790 there are no regressions so far, but whatever I do it stays low.

echo profile > /sys/class/drm/card0/device/power_method = write error, 
is there a way to go back to manual setting with dpm?

I haven't tried rv670 yet - I couldn't see a new firmware for that, does 
it just not need one?



[PATCH] drm/radeon: fix 32-bit compile after dpm merge

2013-06-27 Thread Dave Airlie
From: Dave Airlie 

feel free to split this back up and merge it into the individual commits.

should probably also confirm its doing sane things.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/radeon/ni_dpm.c|   10 +-
 drivers/gpu/drm/radeon/rv730_dpm.c |6 +++---
 drivers/gpu/drm/radeon/rv740_dpm.c |6 +++---
 drivers/gpu/drm/radeon/rv770_dpm.c |6 +++---
 drivers/gpu/drm/radeon/si_dpm.c|   11 ++-
 5 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index ee82495..d547c42 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -1376,8 +1376,8 @@ static u32 ni_calculate_power_boost_limit(struct 
radeon_device *rdev,
if (ret)
return 0;

-   tmp = ((u64)near_tdp_limit * ((u64)std_vddc_med * 
(u64)std_vddc_med) * 90) /
-   ((u64)std_vddc_high * (u64)std_vddc_high * 100);
+   tmp = ((u64)near_tdp_limit * ((u64)std_vddc_med * 
(u64)std_vddc_med) * 90);
+   do_div(tmp, ((u64)std_vddc_high * (u64)std_vddc_high * 100));
if (tmp >> 32)
return 0;
power_boost_limit = (u32)tmp;
@@ -1978,9 +1978,9 @@ static int ni_calculate_sclk_params(struct radeon_device 
*rdev,

reference_divider = 1 + dividers.ref_div;

-   tmp = (u64) engine_clock * reference_divider * dividers.post_div;
-
-   fbdiv = (u32) ((16384 * tmp) / reference_clock);
+   tmp = (u64) engine_clock * reference_divider * dividers.post_div * 
16834;
+   do_div(tmp, reference_clock);
+   fbdiv = (u32) tmp;

spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
diff --git a/drivers/gpu/drm/radeon/rv730_dpm.c 
b/drivers/gpu/drm/radeon/rv730_dpm.c
index b23be71..3f5e1cf 100644
--- a/drivers/gpu/drm/radeon/rv730_dpm.c
+++ b/drivers/gpu/drm/radeon/rv730_dpm.c
@@ -67,9 +67,9 @@ int rv730_populate_sclk_value(struct radeon_device *rdev,
else
post_divider = 1;

-   tmp = (u64) engine_clock * reference_divider * post_divider;
-
-   fbdiv = (u32) ((16384 * tmp) / reference_clock);
+   tmp = (u64) engine_clock * reference_divider * post_divider * 16384;
+   do_div(tmp, reference_clock);
+   fbdiv = (u32) tmp;

/* set up registers */
if (dividers.enable_post_div)
diff --git a/drivers/gpu/drm/radeon/rv740_dpm.c 
b/drivers/gpu/drm/radeon/rv740_dpm.c
index 7aa1608..c4c8da5 100644
--- a/drivers/gpu/drm/radeon/rv740_dpm.c
+++ b/drivers/gpu/drm/radeon/rv740_dpm.c
@@ -141,9 +141,9 @@ int rv740_populate_sclk_value(struct radeon_device *rdev, 
u32 engine_clock,

reference_divider = 1 + dividers.ref_div;

-   tmp = (u64) engine_clock * reference_divider * dividers.post_div;
-
-   fbdiv = (u32) ((16384 * tmp) / reference_clock);
+   tmp = (u64) engine_clock * reference_divider * dividers.post_div * 
16384;
+   do_div(tmp, reference_clock);
+   fbdiv = (u32) tmp;

spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c 
b/drivers/gpu/drm/radeon/rv770_dpm.c
index 038c013..e58f8b6 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -511,9 +511,9 @@ static int rv770_populate_sclk_value(struct radeon_device 
*rdev,
else
post_divider = 1;

-   tmp = (u64) engine_clock * reference_divider * post_divider;
-
-   fbdiv = (u32) ((16384 * tmp) / reference_clock);
+   tmp = (u64) engine_clock * reference_divider * post_divider * 16384;
+   do_div(tmp, reference_clock);
+   fbdiv = (u32) tmp;

if (dividers.enable_post_div)
spll_func_cntl |= SPLL_DIVEN;
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 4c5b258..98450d8 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2243,8 +2243,9 @@ static u16 si_calculate_power_efficiency_ratio(struct 
radeon_device *rdev,
if ((prev_vddc == 0) || (curr_vddc == 0))
return 0;

-   pwr_efficiency_ratio = ((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 
+ margin) /
-   (u64)1000) / (prev_vddc * prev_vddc);
+   pwr_efficiency_ratio = (u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + 
margin);
+   do_div(pwr_efficiency_ratio, 1000);
+   do_div(pwr_efficiency_ratio, (prev_vddc * prev_vddc));

if (pwr_efficiency_ratio > (u64)0x)
return 0;
@@ -4532,9 +4533,9 @@ static int si_calculate_sclk_params(struct radeon_device 
*rdev,

reference_divider = 1 + dividers.ref_div;

-   tmp = (uint64_t) engine_clock * reference_divider * dividers.post_div;
-
-   fbdiv = (u32) ((16384 * tmp) 

[PATCH WW 13/13] drm/ttm: get rid of ttm_bo_is_reserved

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 include/drm/ttm/ttm_bo_api.h | 14 --
 1 file changed, 14 deletions(-)

diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 31ad860..8a6aa56 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -712,18 +712,4 @@ extern ssize_t ttm_bo_io(struct ttm_bo_device *bdev, 
struct file *filp,

 extern void ttm_bo_swapout_all(struct ttm_bo_device *bdev);

-/**
- * ttm_bo_is_reserved - return an indication if a ttm buffer object is reserved
- *
- * @bo: The buffer object to check.
- *
- * This function returns an indication if a bo is reserved or not, and should
- * only be used to print an error when it is not from incorrect api usage, 
since
- * there's no guarantee that it is the caller that is holding the reservation.
- */
-static inline bool ttm_bo_is_reserved(struct ttm_buffer_object *bo)
-{
-   return ww_mutex_is_locked(>resv->lock);
-}
-
 #endif
-- 
1.8.3.1



[PATCH WW 12/13] drm/vmwgfx: get rid of ttm_bo_is_reserved usage

2013-06-27 Thread Maarten Lankhorst
Use lockdep_assert_held instead.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c   | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index 5fae06a..d4e54fc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -302,7 +302,7 @@ void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin)
uint32_t old_mem_type = bo->mem.mem_type;
int ret;

-   BUG_ON(!ttm_bo_is_reserved(bo));
+   lockdep_assert_held(>resv->lock.base);
BUG_ON(old_mem_type != TTM_PL_VRAM &&
   old_mem_type != VMW_PL_GMR);

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index ced7946..7953d1f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -958,13 +958,13 @@ void vmw_resource_unreserve(struct vmw_resource *res,
if (new_backup && new_backup != res->backup) {

if (res->backup) {
-   BUG_ON(!ttm_bo_is_reserved(>backup->base));
+   lockdep_assert_held(>backup->base.resv->lock.base);
list_del_init(>mob_head);
vmw_dmabuf_unreference(>backup);
}

res->backup = vmw_dmabuf_reference(new_backup);
-   BUG_ON(!ttm_bo_is_reserved(_backup->base));
+   lockdep_assert_held(_backup->base.resv->lock.base);
list_add_tail(>mob_head, _backup->res_list);
}
if (new_backup)
-- 
1.8.3.1



[PATCH WW 11/13] drm/radeon: get rid of ttm_bo_is_reserved usage

2013-06-27 Thread Maarten Lankhorst
Try to use lockdep_assert_held or other alternatives where possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/radeon/radeon_object.c |  8 ++--
 drivers/gpu/drm/radeon/radeon_object.h |  5 ---
 drivers/gpu/drm/radeon/radeon_test.c   | 75 +-
 3 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
b/drivers/gpu/drm/radeon/radeon_object.c
index d850dc6..0219d26 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -400,7 +400,7 @@ int radeon_bo_get_surface_reg(struct radeon_bo *bo)
int steal;
int i;

-   BUG_ON(!radeon_bo_is_reserved(bo));
+   lockdep_assert_held(>tbo.resv->lock.base);

if (!bo->tiling_flags)
return 0;
@@ -526,7 +526,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
uint32_t *tiling_flags,
uint32_t *pitch)
 {
-   BUG_ON(!radeon_bo_is_reserved(bo));
+   lockdep_assert_held(>tbo.resv->lock.base);
+
if (tiling_flags)
*tiling_flags = bo->tiling_flags;
if (pitch)
@@ -536,7 +537,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
 int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
bool force_drop)
 {
-   BUG_ON(!radeon_bo_is_reserved(bo) && !force_drop);
+   if (!force_drop)
+   lockdep_assert_held(>tbo.resv->lock.base);

if (!(bo->tiling_flags & RADEON_TILING_SURFACE))
return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_object.h 
b/drivers/gpu/drm/radeon/radeon_object.h
index 456ad6b..91519a5 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -98,11 +98,6 @@ static inline unsigned long radeon_bo_size(struct radeon_bo 
*bo)
return bo->tbo.num_pages << PAGE_SHIFT;
 }

-static inline bool radeon_bo_is_reserved(struct radeon_bo *bo)
-{
-   return ttm_bo_is_reserved(>tbo);
-}
-
 static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo)
 {
return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE;
diff --git a/drivers/gpu/drm/radeon/radeon_test.c 
b/drivers/gpu/drm/radeon/radeon_test.c
index bbed4af..f4d6bce 100644
--- a/drivers/gpu/drm/radeon/radeon_test.c
+++ b/drivers/gpu/drm/radeon/radeon_test.c
@@ -35,7 +35,6 @@ static void radeon_do_test_moves(struct radeon_device *rdev, 
int flag)
 {
struct radeon_bo *vram_obj = NULL;
struct radeon_bo **gtt_obj = NULL;
-   struct radeon_fence *fence = NULL;
uint64_t gtt_addr, vram_addr;
unsigned i, n, size;
int r, ring;
@@ -81,37 +80,38 @@ static void radeon_do_test_moves(struct radeon_device 
*rdev, int flag)
}
r = radeon_bo_reserve(vram_obj, false);
if (unlikely(r != 0))
-   goto out_cleanup;
+   goto out_unref;
r = radeon_bo_pin(vram_obj, RADEON_GEM_DOMAIN_VRAM, _addr);
if (r) {
DRM_ERROR("Failed to pin VRAM object\n");
-   goto out_cleanup;
+   goto out_unres;
}
for (i = 0; i < n; i++) {
void *gtt_map, *vram_map;
void **gtt_start, **gtt_end;
void **vram_start, **vram_end;
+   struct radeon_fence *fence = NULL;

r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
 RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i);
if (r) {
DRM_ERROR("Failed to create GTT object %d\n", i);
-   goto out_cleanup;
+   goto out_lclean;
}

r = radeon_bo_reserve(gtt_obj[i], false);
if (unlikely(r != 0))
-   goto out_cleanup;
+   goto out_lclean_unref;
r = radeon_bo_pin(gtt_obj[i], RADEON_GEM_DOMAIN_GTT, _addr);
if (r) {
DRM_ERROR("Failed to pin GTT object %d\n", i);
-   goto out_cleanup;
+   goto out_lclean_unres;
}

r = radeon_bo_kmap(gtt_obj[i], _map);
if (r) {
DRM_ERROR("Failed to map GTT object %d\n", i);
-   goto out_cleanup;
+   goto out_lclean_unpin;
}

for (gtt_start = gtt_map, gtt_end = gtt_map + size;
@@ -127,13 +127,13 @@ static void radeon_do_test_moves(struct radeon_device 
*rdev, int flag)
r = radeon_copy_blit(rdev, gtt_addr, vram_addr, size / 
RADEON_GPU_PAGE_SIZE, );
if (r) {
DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
-   goto out_cleanup;
+   goto out_lclean_unpin;
}

r = radeon_fence_wait(fence, 

[PATCH WW 10/13] drm/ttm: get rid of ttm_bo_is_reserved usage

2013-06-27 Thread Maarten Lankhorst
Use lockdep_assert_held instead.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index a8a27f5..6e6975c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -166,7 +166,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
struct ttm_bo_device *bdev = bo->bdev;
struct ttm_mem_type_manager *man;

-   BUG_ON(!ttm_bo_is_reserved(bo));
+   lockdep_assert_held(>resv->lock.base);

if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {

@@ -671,7 +671,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool 
interruptible,
goto out;
}

-   BUG_ON(!ttm_bo_is_reserved(bo));
+   lockdep_assert_held(>resv->lock.base);

evict_mem = bo->mem;
evict_mem.mm_node = NULL;
@@ -961,7 +961,7 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
struct ttm_mem_reg mem;
struct ttm_bo_device *bdev = bo->bdev;

-   BUG_ON(!ttm_bo_is_reserved(bo));
+   lockdep_assert_held(>resv->lock.base);

/*
 * FIXME: It's possible to pipeline buffer moves.
@@ -1020,7 +1020,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
 {
int ret;

-   BUG_ON(!ttm_bo_is_reserved(bo));
+   lockdep_assert_held(>resv->lock.base);
/* Check that range is valid */
if (placement->lpfn || placement->fpfn)
if (placement->fpfn > placement->lpfn ||
-- 
1.8.3.1



[PATCH WW 09/13] drm/ttm: inline ttm_bo_reserve and related calls

2013-06-27 Thread Maarten Lankhorst
Makes lockdep a lot more useful.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/ttm/ttm_bo.c   | 105 ++--
 drivers/gpu/drm/ttm/ttm_execbuf_util.c |   9 +-
 include/drm/ttm/ttm_bo_driver.h| 175 -
 3 files changed, 117 insertions(+), 172 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 5f9fe80..a8a27f5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -182,6 +182,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
}
}
 }
+EXPORT_SYMBOL(ttm_bo_add_to_lru);

 int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 {
@@ -204,35 +205,6 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
return put_count;
 }

-int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
- bool interruptible,
- bool no_wait, bool use_ticket,
- struct ww_acquire_ctx *ticket)
-{
-   int ret = 0;
-
-   if (no_wait) {
-   bool success;
-
-   /* not valid any more, fix your locking! */
-   if (WARN_ON(ticket))
-   return -EBUSY;
-
-   success = ww_mutex_trylock(>resv->lock);
-   return success ? 0 : -EBUSY;
-   }
-
-   if (interruptible)
-   ret = ww_mutex_lock_interruptible(>resv->lock,
- ticket);
-   else
-   ret = ww_mutex_lock(>resv->lock, ticket);
-   if (ret == -EINTR)
-   return -ERESTARTSYS;
-   return ret;
-}
-EXPORT_SYMBOL(ttm_bo_reserve);
-
 static void ttm_bo_ref_bug(struct kref *list_kref)
 {
BUG();
@@ -245,77 +217,16 @@ void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, 
int count,
 (never_free) ? ttm_bo_ref_bug : ttm_bo_release_list);
 }

-int ttm_bo_reserve(struct ttm_buffer_object *bo,
-  bool interruptible,
-  bool no_wait, bool use_ticket,
-  struct ww_acquire_ctx *ticket)
-{
-   struct ttm_bo_global *glob = bo->glob;
-   int put_count = 0;
-   int ret;
-
-   ret = ttm_bo_reserve_nolru(bo, interruptible, no_wait, use_ticket,
-   ticket);
-   if (likely(ret == 0)) {
-   spin_lock(>lru_lock);
-   put_count = ttm_bo_del_from_lru(bo);
-   spin_unlock(>lru_lock);
-   ttm_bo_list_ref_sub(bo, put_count, true);
-   }
-
-   return ret;
-}
-
-int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
-   bool interruptible, struct ww_acquire_ctx *ticket)
-{
-   struct ttm_bo_global *glob = bo->glob;
-   int put_count = 0;
-   int ret = 0;
-
-   if (interruptible)
-   ret = ww_mutex_lock_slow_interruptible(>resv->lock,
-  ticket);
-   else
-   ww_mutex_lock_slow(>resv->lock, ticket);
-
-   if (likely(ret == 0)) {
-   spin_lock(>lru_lock);
-   put_count = ttm_bo_del_from_lru(bo);
-   spin_unlock(>lru_lock);
-   ttm_bo_list_ref_sub(bo, put_count, true);
-   } else if (ret == -EINTR)
-   ret = -ERESTARTSYS;
-
-   return ret;
-}
-EXPORT_SYMBOL(ttm_bo_reserve_slowpath);
-
-void ttm_bo_unreserve_ticket_locked(struct ttm_buffer_object *bo, struct 
ww_acquire_ctx *ticket)
+void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
 {
-   ttm_bo_add_to_lru(bo);
-   ww_mutex_unlock(>resv->lock);
-}
-
-void ttm_bo_unreserve(struct ttm_buffer_object *bo)
-{
-   struct ttm_bo_global *glob = bo->glob;
-
-   spin_lock(>lru_lock);
-   ttm_bo_unreserve_ticket_locked(bo, NULL);
-   spin_unlock(>lru_lock);
-}
-EXPORT_SYMBOL(ttm_bo_unreserve);
-
-void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, struct 
ww_acquire_ctx *ticket)
-{
-   struct ttm_bo_global *glob = bo->glob;
+   int put_count;

-   spin_lock(>lru_lock);
-   ttm_bo_unreserve_ticket_locked(bo, ticket);
-   spin_unlock(>lru_lock);
+   spin_lock(>glob->lru_lock);
+   put_count = ttm_bo_del_from_lru(bo);
+   spin_unlock(>glob->lru_lock);
+   ttm_bo_list_ref_sub(bo, put_count, true);
 }
-EXPORT_SYMBOL(ttm_bo_unreserve_ticket);
+EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);

 /*
  * Call bo->mutex locked.
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c 
b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
index 7392da5..6c91178 100644
--- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
+++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
@@ -44,12 +44,10 @@ static void ttm_eu_backoff_reservation_locked(struct 
list_head *list,

entry->reserved = false;
if (entry->removed) {
-   ttm_bo_unreserve_ticket_locked(bo, ticket);
+   ttm_bo_add_to_lru(bo);

[PATCH WW 08/13] drm/radeon: inline reservations

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/radeon/radeon_object.c | 23 ---
 drivers/gpu/drm/radeon/radeon_object.h | 22 +-
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
b/drivers/gpu/drm/radeon/radeon_object.c
index 71287bb..d850dc6 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -619,26 +619,3 @@ int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, 
bool no_wait)
ttm_bo_unreserve(>tbo);
return r;
 }
-
-
-/**
- * radeon_bo_reserve - reserve bo
- * @bo:bo structure
- * @no_intr:   don't return -ERESTARTSYS on pending signal
- *
- * Returns:
- * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
- * a signal. Release all buffer reservations and return to user-space.
- */
-int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr)
-{
-   int r;
-
-   r = ttm_bo_reserve(>tbo, !no_intr, false, false, 0);
-   if (unlikely(r != 0)) {
-   if (r != -ERESTARTSYS)
-   dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
-   return r;
-   }
-   return 0;
-}
diff --git a/drivers/gpu/drm/radeon/radeon_object.h 
b/drivers/gpu/drm/radeon/radeon_object.h
index 3e62a3a..456ad6b 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -52,7 +52,27 @@ static inline unsigned radeon_mem_type_to_domain(u32 
mem_type)
return 0;
 }

-int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr);
+/**
+ * radeon_bo_reserve - reserve bo
+ * @bo:bo structure
+ * @no_intr:   don't return -ERESTARTSYS on pending signal
+ *
+ * Returns:
+ * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
+ * a signal. Release all buffer reservations and return to user-space.
+ */
+static inline int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr)
+{
+   int r;
+
+   r = ttm_bo_reserve(>tbo, !no_intr, false, false, 0);
+   if (unlikely(r != 0)) {
+   if (r != -ERESTARTSYS)
+   dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
+   return r;
+   }
+   return 0;
+}

 static inline void radeon_bo_unreserve(struct radeon_bo *bo)
 {
-- 
1.8.3.1



[PATCH WW 07/13] drm/mgag200: inline reservations

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h | 20 ++--
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 18 --
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 364a05a..b4f955b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -279,8 +279,24 @@ void mgag200_i2c_destroy(struct mga_i2c_chan *i2c);
 #define DRM_FILE_PAGE_OFFSET (0x1ULL >> PAGE_SHIFT)
 void mgag200_ttm_placement(struct mgag200_bo *bo, int domain);

-int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait);
-void mgag200_bo_unreserve(struct mgag200_bo *bo);
+static inline int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait)
+{
+   int ret;
+
+   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
+   if (ret) {
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
+   DRM_ERROR("reserve failed %p\n", bo);
+   return ret;
+   }
+   return 0;
+}
+
+static inline void mgag200_bo_unreserve(struct mgag200_bo *bo)
+{
+   ttm_bo_unreserve(>bo);
+}
+
 int mgag200_bo_create(struct drm_device *dev, int size, int align,
  uint32_t flags, struct mgag200_bo **pastbo);
 int mgag200_mm_init(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 0004f77..3acb2b0 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -303,24 +303,6 @@ void mgag200_ttm_placement(struct mgag200_bo *bo, int 
domain)
bo->placement.num_busy_placement = c;
 }

-int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait)
-{
-   int ret;
-
-   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
-   if (ret) {
-   if (ret != -ERESTARTSYS && ret != -EBUSY)
-   DRM_ERROR("reserve failed %p %d\n", bo, ret);
-   return ret;
-   }
-   return 0;
-}
-
-void mgag200_bo_unreserve(struct mgag200_bo *bo)
-{
-   ttm_bo_unreserve(>bo);
-}
-
 int mgag200_bo_create(struct drm_device *dev, int size, int align,
  uint32_t flags, struct mgag200_bo **pmgabo)
 {
-- 
1.8.3.1



[PATCH WW 06/13] drm/cirrus: inline reservations

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h | 21 +++--
 drivers/gpu/drm/cirrus/cirrus_ttm.c | 18 --
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 7ca0595..bae5560 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -240,8 +240,25 @@ void cirrus_ttm_placement(struct cirrus_bo *bo, int 
domain);
 int cirrus_bo_create(struct drm_device *dev, int size, int align,
 uint32_t flags, struct cirrus_bo **pcirrusbo);
 int cirrus_mmap(struct file *filp, struct vm_area_struct *vma);
-int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait);
-void cirrus_bo_unreserve(struct cirrus_bo *bo);
+
+static inline int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait)
+{
+   int ret;
+
+   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
+   if (ret) {
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
+   DRM_ERROR("reserve failed %p\n", bo);
+   return ret;
+   }
+   return 0;
+}
+
+static inline void cirrus_bo_unreserve(struct cirrus_bo *bo)
+{
+   ttm_bo_unreserve(>bo);
+}
+
 int cirrus_bo_push_sysram(struct cirrus_bo *bo);
 int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr);
 #endif /* __CIRRUS_DRV_H__ */
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 36b9b0b..0047012 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -308,24 +308,6 @@ void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
bo->placement.num_busy_placement = c;
 }

-int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait)
-{
-   int ret;
-
-   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
-   if (ret) {
-   if (ret != -ERESTARTSYS && ret != -EBUSY)
-   DRM_ERROR("reserve failed %p\n", bo);
-   return ret;
-   }
-   return 0;
-}
-
-void cirrus_bo_unreserve(struct cirrus_bo *bo)
-{
-   ttm_bo_unreserve(>bo);
-}
-
 int cirrus_bo_create(struct drm_device *dev, int size, int align,
  uint32_t flags, struct cirrus_bo **pcirrusbo)
 {
-- 
1.8.3.1



[PATCH WW 05/13] drm/ast: inline reservations

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/ast/ast_drv.h | 20 ++--
 drivers/gpu/drm/ast/ast_ttm.c | 18 --
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 02e52d5..622d4ae 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -348,8 +348,24 @@ int ast_gem_create(struct drm_device *dev,
 int ast_bo_pin(struct ast_bo *bo, u32 pl_flag, u64 *gpu_addr);
 int ast_bo_unpin(struct ast_bo *bo);

-int ast_bo_reserve(struct ast_bo *bo, bool no_wait);
-void ast_bo_unreserve(struct ast_bo *bo);
+static inline int ast_bo_reserve(struct ast_bo *bo, bool no_wait)
+{
+   int ret;
+
+   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
+   if (ret) {
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
+   DRM_ERROR("reserve failed %p\n", bo);
+   return ret;
+   }
+   return 0;
+}
+
+static inline void ast_bo_unreserve(struct ast_bo *bo)
+{
+   ttm_bo_unreserve(>bo);
+}
+
 void ast_ttm_placement(struct ast_bo *bo, int domain);
 int ast_bo_push_sysram(struct ast_bo *bo);
 int ast_mmap(struct file *filp, struct vm_area_struct *vma);
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index a5a1a03..98d6708 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -303,24 +303,6 @@ void ast_ttm_placement(struct ast_bo *bo, int domain)
bo->placement.num_busy_placement = c;
 }

-int ast_bo_reserve(struct ast_bo *bo, bool no_wait)
-{
-   int ret;
-
-   ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
-   if (ret) {
-   if (ret != -ERESTARTSYS && ret != -EBUSY)
-   DRM_ERROR("reserve failed %p\n", bo);
-   return ret;
-   }
-   return 0;
-}
-
-void ast_bo_unreserve(struct ast_bo *bo)
-{
-   ttm_bo_unreserve(>bo);
-}
-
 int ast_bo_create(struct drm_device *dev, int size, int align,
  uint32_t flags, struct ast_bo **pastbo)
 {
-- 
1.8.3.1



[PATCH WW 04/13] drm/ttm: convert to the reservation api

2013-06-27 Thread Maarten Lankhorst
Now that the code is compatible in semantics, flip the switch.
Use ww_mutex instead of the homegrown implementation.

ww_mutex uses -EDEADLK to signal that the caller has to back off,
and -EALREADY to indicate this buffer is already held by the caller.

ttm used -EAGAIN and -EDEADLK for those, respectively. So some changes
were needed to handle this correctly.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c  |   2 +-
 drivers/gpu/drm/qxl/qxl_object.h   |   5 -
 drivers/gpu/drm/ttm/ttm_bo.c   | 190 +
 drivers/gpu/drm/ttm/ttm_bo_util.c  |   6 +-
 drivers/gpu/drm/ttm/ttm_execbuf_util.c |  43 +++-
 include/drm/ttm/ttm_bo_api.h   |  25 ++---
 include/drm/ttm/ttm_execbuf_util.h |   1 -
 7 files changed, 79 insertions(+), 193 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index e35d468..2b2077d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -368,7 +368,7 @@ retry:
ret = ttm_bo_reserve(>bo, true, false, true, >ticket);
if (ret) {
validate_fini_no_ticket(op, NULL);
-   if (unlikely(ret == -EAGAIN)) {
+   if (unlikely(ret == -EDEADLK)) {
ret = ttm_bo_reserve_slowpath(>bo, true,
  >ticket);
if (!ret)
diff --git a/drivers/gpu/drm/qxl/qxl_object.h b/drivers/gpu/drm/qxl/qxl_object.h
index b4fd89f..ee7ad79 100644
--- a/drivers/gpu/drm/qxl/qxl_object.h
+++ b/drivers/gpu/drm/qxl/qxl_object.h
@@ -57,11 +57,6 @@ static inline unsigned long qxl_bo_size(struct qxl_bo *bo)
return bo->tbo.num_pages << PAGE_SHIFT;
 }

-static inline bool qxl_bo_is_reserved(struct qxl_bo *bo)
-{
-   return !!atomic_read(>tbo.reserved);
-}
-
 static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)
 {
return bo->tbo.addr_space_offset;
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index b912375..5f9fe80 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -150,6 +150,9 @@ static void ttm_bo_release_list(struct kref *list_kref)
if (bo->ttm)
ttm_tt_destroy(bo->ttm);
atomic_dec(>glob->bo_count);
+   if (bo->resv == >ttm_resv)
+   reservation_object_fini(>ttm_resv);
+
if (bo->destroy)
bo->destroy(bo);
else {
@@ -158,18 +161,6 @@ static void ttm_bo_release_list(struct kref *list_kref)
ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
 }

-static int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
- bool interruptible)
-{
-   if (interruptible) {
-   return wait_event_interruptible(bo->event_queue,
-  !ttm_bo_is_reserved(bo));
-   } else {
-   wait_event(bo->event_queue, !ttm_bo_is_reserved(bo));
-   return 0;
-   }
-}
-
 void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 {
struct ttm_bo_device *bdev = bo->bdev;
@@ -218,65 +209,27 @@ int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
  bool no_wait, bool use_ticket,
  struct ww_acquire_ctx *ticket)
 {
-   int ret;
+   int ret = 0;

-   while (unlikely(atomic_xchg(>reserved, 1) != 0)) {
-   /**
-* Deadlock avoidance for multi-bo reserving.
-*/
-   if (use_ticket && bo->seq_valid) {
-   /**
-* We've already reserved this one.
-*/
-   if (unlikely(ticket->stamp == bo->val_seq))
-   return -EDEADLK;
-   /**
-* Already reserved by a thread that will not back
-* off for us. We need to back off.
-*/
-   if (unlikely(ticket->stamp - bo->val_seq <= LONG_MAX))
-   return -EAGAIN;
-   }
+   if (no_wait) {
+   bool success;

-   if (no_wait)
+   /* not valid any more, fix your locking! */
+   if (WARN_ON(ticket))
return -EBUSY;

-   ret = ttm_bo_wait_unreserved(bo, interruptible);
-
-   if (unlikely(ret))
-   return ret;
-   }
-
-   if (use_ticket) {
-   bool wake_up = false;
-
-   /**
-* Wake up waiters that may need to recheck for deadlock,
-* if we decreased the sequence number.
-*/
-   if (unlikely((bo->val_seq - ticket->stamp <= LONG_MAX)
-|| !bo->seq_valid))
-  

[PATCH WW 03/13] drm/nouveau: make flipping lockdep safe

2013-06-27 Thread Maarten Lankhorst
cli->mutex was inverted with reservations, and multiple reservations were
used without a ticket, fix both. This commit had to be done after the previous
commit, because otherwise ttm_eu_* calls would use a different seqno counter..

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 103 +-
 1 file changed, 45 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index f17dc2a..87afb0c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -26,6 +26,7 @@

 #include 
 #include 
+#include 

 #include "nouveau_fbcon.h"
 #include "dispnv04/hw.h"
@@ -457,51 +458,6 @@ nouveau_display_resume(struct drm_device *dev)
 }

 static int
-nouveau_page_flip_reserve(struct nouveau_bo *old_bo,
- struct nouveau_bo *new_bo)
-{
-   int ret;
-
-   ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
-   if (ret)
-   return ret;
-
-   ret = ttm_bo_reserve(_bo->bo, false, false, false, 0);
-   if (ret)
-   goto fail;
-
-   if (likely(old_bo != new_bo)) {
-   ret = ttm_bo_reserve(_bo->bo, false, false, false, 0);
-   if (ret)
-   goto fail_unreserve;
-   }
-
-   return 0;
-
-fail_unreserve:
-   ttm_bo_unreserve(_bo->bo);
-fail:
-   nouveau_bo_unpin(new_bo);
-   return ret;
-}
-
-static void
-nouveau_page_flip_unreserve(struct nouveau_bo *old_bo,
-   struct nouveau_bo *new_bo,
-   struct nouveau_fence *fence)
-{
-   nouveau_bo_fence(new_bo, fence);
-   ttm_bo_unreserve(_bo->bo);
-
-   if (likely(old_bo != new_bo)) {
-   nouveau_bo_fence(old_bo, fence);
-   ttm_bo_unreserve(_bo->bo);
-   }
-
-   nouveau_bo_unpin(old_bo);
-}
-
-static int
 nouveau_page_flip_emit(struct nouveau_channel *chan,
   struct nouveau_bo *old_bo,
   struct nouveau_bo *new_bo,
@@ -563,6 +519,9 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct 
drm_framebuffer *fb,
struct nouveau_page_flip_state *s;
struct nouveau_channel *chan = NULL;
struct nouveau_fence *fence;
+   struct list_head res;
+   struct ttm_validate_buffer res_val[2];
+   struct ww_acquire_ctx ticket;
int ret;

if (!drm->channel)
@@ -572,25 +531,43 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct 
drm_framebuffer *fb,
if (!s)
return -ENOMEM;

-   /* Don't let the buffers go away while we flip */
-   ret = nouveau_page_flip_reserve(old_bo, new_bo);
-   if (ret)
-   goto fail_free;
-
-   /* Initialize a page flip struct */
-   *s = (struct nouveau_page_flip_state)
-   { { }, event, nouveau_crtc(crtc)->index,
- fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
- new_bo->bo.offset };
-
/* Choose the channel the flip will be handled in */
+   spin_lock(_bo->bo.bdev->fence_lock);
fence = new_bo->bo.sync_obj;
if (fence)
chan = fence->channel;
if (!chan)
chan = drm->channel;
+   spin_unlock(_bo->bo.bdev->fence_lock);
+
mutex_lock(>cli->mutex);

+   if (new_bo != old_bo) {
+   ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
+   if (likely(!ret)) {
+   res_val[0].bo = _bo->bo;
+   res_val[1].bo = _bo->bo;
+   INIT_LIST_HEAD();
+   list_add_tail(_val[0].head, );
+   list_add_tail(_val[1].head, );
+   ret = ttm_eu_reserve_buffers(, );
+   if (ret)
+   nouveau_bo_unpin(new_bo);
+   }
+   } else
+   ret = ttm_bo_reserve(_bo->bo, false, false, false, 0);
+
+   if (ret) {
+   mutex_unlock(>cli->mutex);
+   goto fail_free;
+   }
+
+   /* Initialize a page flip struct */
+   *s = (struct nouveau_page_flip_state)
+   { { }, event, nouveau_crtc(crtc)->index,
+ fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
+ new_bo->bo.offset };
+
/* Emit a page flip */
if (nv_device(drm->device)->card_type >= NV_50) {
ret = nv50_display_flip_next(crtc, fb, chan, 0);
@@ -608,12 +585,22 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct 
drm_framebuffer *fb,
/* Update the crtc struct and cleanup */
crtc->fb = fb;

-   nouveau_page_flip_unreserve(old_bo, new_bo, fence);
+   if (old_bo != new_bo) {
+   ttm_eu_fence_buffer_objects(, , fence);
+   nouveau_bo_unpin(old_bo);
+   } else {
+   nouveau_bo_fence(new_bo, fence);
+   

[PATCH WW 02/13] drm/ttm: make ttm reservation calls behave like reservation calls

2013-06-27 Thread Maarten Lankhorst
This commit converts the source of the val_seq counter to
the ww_mutex api. The reservation objects are converted later,
because there is still a lockdep splat in nouveau that has to
resolved first.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c| 38 ++---
 drivers/gpu/drm/radeon/radeon.h  |  1 +
 drivers/gpu/drm/radeon/radeon_cs.c   | 18 +-
 drivers/gpu/drm/radeon/radeon_object.c   |  5 +--
 drivers/gpu/drm/radeon/radeon_object.h   |  3 +-
 drivers/gpu/drm/radeon/radeon_uvd.c  | 27 +++
 drivers/gpu/drm/ttm/ttm_bo.c | 50 +--
 drivers/gpu/drm/ttm/ttm_execbuf_util.c   | 58 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  | 14 
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 23 -
 include/drm/ttm/ttm_bo_api.h |  2 +-
 include/drm/ttm/ttm_bo_driver.h  | 32 +-
 include/drm/ttm/ttm_execbuf_util.h   | 13 +--
 13 files changed, 172 insertions(+), 112 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 7054706..e35d468 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -277,10 +277,12 @@ struct validate_op {
struct list_head vram_list;
struct list_head gart_list;
struct list_head both_list;
+   struct ww_acquire_ctx ticket;
 };

 static void
-validate_fini_list(struct list_head *list, struct nouveau_fence *fence)
+validate_fini_list(struct list_head *list, struct nouveau_fence *fence,
+  struct ww_acquire_ctx *ticket)
 {
struct list_head *entry, *tmp;
struct nouveau_bo *nvbo;
@@ -297,17 +299,24 @@ validate_fini_list(struct list_head *list, struct 
nouveau_fence *fence)

list_del(>entry);
nvbo->reserved_by = NULL;
-   ttm_bo_unreserve(>bo);
+   ttm_bo_unreserve_ticket(>bo, ticket);
drm_gem_object_unreference_unlocked(nvbo->gem);
}
 }

 static void
-validate_fini(struct validate_op *op, struct nouveau_fence* fence)
+validate_fini_no_ticket(struct validate_op *op, struct nouveau_fence *fence)
 {
-   validate_fini_list(>vram_list, fence);
-   validate_fini_list(>gart_list, fence);
-   validate_fini_list(>both_list, fence);
+   validate_fini_list(>vram_list, fence, >ticket);
+   validate_fini_list(>gart_list, fence, >ticket);
+   validate_fini_list(>both_list, fence, >ticket);
+}
+
+static void
+validate_fini(struct validate_op *op, struct nouveau_fence *fence)
+{
+   validate_fini_no_ticket(op, fence);
+   ww_acquire_fini(>ticket);
 }

 static int
@@ -317,13 +326,11 @@ validate_init(struct nouveau_channel *chan, struct 
drm_file *file_priv,
 {
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct drm_device *dev = chan->drm->dev;
-   struct nouveau_drm *drm = nouveau_drm(dev);
-   uint32_t sequence;
int trycnt = 0;
int ret, i;
struct nouveau_bo *res_bo = NULL;

-   sequence = atomic_add_return(1, >ttm.validate_sequence);
+   ww_acquire_init(>ticket, _ww_class);
 retry:
if (++trycnt > 10) {
NV_ERROR(cli, "%s failed and gave up.\n", __func__);
@@ -338,6 +345,7 @@ retry:
gem = drm_gem_object_lookup(dev, file_priv, b->handle);
if (!gem) {
NV_ERROR(cli, "Unknown handle 0x%08x\n", b->handle);
+   ww_acquire_done(>ticket);
validate_fini(op, NULL);
return -ENOENT;
}
@@ -352,21 +360,23 @@ retry:
NV_ERROR(cli, "multiple instances of buffer %d on "
  "validation list\n", b->handle);
drm_gem_object_unreference_unlocked(gem);
+   ww_acquire_done(>ticket);
validate_fini(op, NULL);
return -EINVAL;
}

-   ret = ttm_bo_reserve(>bo, true, false, true, sequence);
+   ret = ttm_bo_reserve(>bo, true, false, true, >ticket);
if (ret) {
-   validate_fini(op, NULL);
+   validate_fini_no_ticket(op, NULL);
if (unlikely(ret == -EAGAIN)) {
-   sequence = atomic_add_return(1, 
>ttm.validate_sequence);
ret = ttm_bo_reserve_slowpath(>bo, true,
- sequence);
+ >ticket);
if (!ret)
res_bo = nvbo;
}
if (unlikely(ret)) {
+   ww_acquire_done(>ticket);
+

[PATCH WW 01/13] reservation: cross-device reservation support, v4

2013-06-27 Thread Maarten Lankhorst
This adds support for a generic reservations framework that can be
hooked up to ttm and dma-buf and allows easy sharing of reservations
across devices.

The idea is that a dma-buf and ttm object both will get a pointer
to a struct reservation_object, which has to be reserved before
anything is done with the contents of the dma-buf.

Changes since v1:
 - Fix locking issue in ticket_reserve, which could cause mutex_unlock
   to be called too many times.
Changes since v2:
 - All fence related calls and members have been taken out for now,
   what's left is the bare minimum to be useful for ttm locking conversion.
Changes since v3:
 - Removed helper functions too. The documentation has an example
   implementation for locking. With the move to ww_mutex there is no
   need to have much logic any more.

Signed-off-by: Maarten Lankhorst 
---
 Documentation/DocBook/device-drivers.tmpl |  2 +
 drivers/base/Makefile |  2 +-
 drivers/base/reservation.c| 39 +++
 include/linux/reservation.h   | 62 +++
 4 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 drivers/base/reservation.c
 create mode 100644 include/linux/reservation.h

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index c36892c..f0648a8 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -126,6 +126,8 @@ X!Edrivers/base/interface.c
  
  Device Drivers DMA Management
 !Edrivers/base/dma-buf.c
+!Edrivers/base/reservation.c
+!Iinclude/linux/reservation.h
 !Edrivers/base/dma-coherent.c
 !Edrivers/base/dma-mapping.c
  
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 4e22ce3..48029aa 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_CMA) += dma-contiguous.o
 obj-y  += power/
 obj-$(CONFIG_HAS_DMA)  += dma-mapping.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
-obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o
+obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o
 obj-$(CONFIG_ISA)  += isa.o
 obj-$(CONFIG_FW_LOADER)+= firmware_class.o
 obj-$(CONFIG_NUMA) += node.o
diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
new file mode 100644
index 000..a73fbf3
--- /dev/null
+++ b/drivers/base/reservation.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012-2013 Canonical Ltd
+ *
+ * Based on bo.c which bears the following copyright notice,
+ * but is dual licensed:
+ *
+ * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+/*
+ * Authors: Thomas Hellstrom 
+ */
+
+#include 
+#include 
+
+DEFINE_WW_CLASS(reservation_ww_class);
+EXPORT_SYMBOL(reservation_ww_class);
diff --git a/include/linux/reservation.h b/include/linux/reservation.h
new file mode 100644
index 000..e9ee806
--- /dev/null
+++ b/include/linux/reservation.h
@@ -0,0 +1,62 @@
+/*
+ * Header file for reservations for dma-buf and ttm
+ *
+ * Copyright(C) 2011 Linaro Limited. All rights reserved.
+ * Copyright (C) 2012-2013 Canonical Ltd
+ * Copyright (C) 2012 Texas Instruments
+ *
+ * Authors:
+ * Rob Clark 
+ * Maarten Lankhorst 
+ * Thomas Hellstrom 
+ *
+ * Based on bo.c which bears the following copyright notice,
+ * but is dual licensed:
+ *
+ * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * 

[PATCH WW 00/13] Convert TTM to Wound/wait mutexes.

2013-06-27 Thread Maarten Lankhorst
With all the previous fixes in place, and my previous patch series applied
to prevent fallout, it's time to throw the switch!

Thanks to Deveryone who made this possible, in particular danvet,
robclark, airlied and peterz.

The first 4 patches are the real meat, the rest is just some cleanups.

Maarten Lankhorst (13):
  reservation: cross-device reservation support, v4
  drm/ttm: make ttm reservation calls behave like reservation calls
  drm/nouveau: make flipping lockdep safe
  drm/ttm: convert to the reservation api
  drm/ast: inline reservations
  drm/cirrus: inline reservations
  drm/mgag200: inline reservations
  drm/radeon: inline reservations
  drm/ttm: inline ttm_bo_reserve and related calls
  drm/ttm: get rid of ttm_bo_is_reserved usage
  drm/radeon: get rid of ttm_bo_is_reserved usage
  drm/vmwgfx: get rid of ttm_bo_is_reserved usage
  drm/ttm: get rid of ttm_bo_is_reserved

 Documentation/DocBook/device-drivers.tmpl |   2 +
 drivers/base/Makefile |   2 +-
 drivers/base/reservation.c|  39 +
 drivers/gpu/drm/ast/ast_drv.h |  20 ++-
 drivers/gpu/drm/ast/ast_ttm.c |  18 ---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  21 ++-
 drivers/gpu/drm/cirrus/cirrus_ttm.c   |  18 ---
 drivers/gpu/drm/mgag200/mgag200_drv.h |  20 ++-
 drivers/gpu/drm/mgag200/mgag200_ttm.c |  18 ---
 drivers/gpu/drm/nouveau/nouveau_display.c | 103 ++---
 drivers/gpu/drm/nouveau/nouveau_gem.c |  40 +++--
 drivers/gpu/drm/qxl/qxl_object.h  |   5 -
 drivers/gpu/drm/radeon/radeon.h   |   1 +
 drivers/gpu/drm/radeon/radeon_cs.c|  18 ++-
 drivers/gpu/drm/radeon/radeon_object.c|  36 +
 drivers/gpu/drm/radeon/radeon_object.h|  30 +++-
 drivers/gpu/drm/radeon/radeon_test.c  |  75 +-
 drivers/gpu/drm/radeon/radeon_uvd.c   |  27 ++--
 drivers/gpu/drm/ttm/ttm_bo.c  | 233 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c |   6 +-
 drivers/gpu/drm/ttm/ttm_execbuf_util.c|  86 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c|   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   |  14 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  |  27 ++--
 include/drm/ttm/ttm_bo_api.h  |  37 +
 include/drm/ttm/ttm_bo_driver.h   | 169 ++
 include/drm/ttm/ttm_execbuf_util.h|  12 +-
 include/linux/reservation.h   |  62 
 28 files changed, 549 insertions(+), 592 deletions(-)
 create mode 100644 drivers/base/reservation.c
 create mode 100644 include/linux/reservation.h

-- 
1.8.3.1



[PULL] final drm-intel-next pull for 3.11

2013-06-27 Thread Daniel Vetter
Hi Dave,

Last 3.11 feature pull. I have a few odds bits and pieces and fixes in my
queue, I'll sort them out later on to see what's for 3.11-fixes and what's
for 3.12. But nothing to hold this here up imo.

Highlights:
- more hangcheck work from Mika and Chris to prepare for arb robustness
- trickle feed fixes from Ville
- first parts of the shared pch pll rework, with some basic hw state
  readout and cross-checking (this shuts up the confused pch pll refcount
  WARN that Linus just recently forwarded)
- Haswell audio power well support from Wang Xingchao (alsa bits acked by
  Takashi)
- some cleanups and asserts sprinkling around the plane/gamma enabling
  sequence from Ville
- more gtt refactoring from Ben
- clear up the adjusted->mode vs. pixel clock vs. port clock confusion
- 30bpp support, this time for real hopefully

Now that you've backmerged 3.10-rc7 into drm-next the ugly conflicts are
gone, on a quick testmerge it was just 2 cases for nearby lines changed.
You can't use my -nightly branch though to peek since I first merge in my
on -fixes, so the entire sdvo conflict mess is still there.

Cheers, Daniel

The following changes since commit 92d44621ad2d083bc03920c904ca0a5eb10d9ded:

  drm/i915: add i915_ips_status debugfs entry (2013-05-31 21:40:20 +0200)

are available in the git repository at:

  git://people.freedesktop.org/~danvet/drm-intel tags/drm-intel-next-2013-06-18

for you to fetch changes up to 854c94a7854a4fabdd7db451cf1774e6dcba6bab:

  drm/i915: remove a superflous semi-colon (2013-06-18 14:05:22 +0200)


Ben Widawsky (6):
  drm/i915: Demote unknown param to DRM_DEBUG
  drm/i915: Make stolen use pin pages
  drm/i915: Unpin stolen pages
  drm/i915: unpin pages at unbind
  drm/i915: Rename the gtt_list to global_list
  drm/i915: Remove extra "ring" from error message

Chris Wilson (8):
  drm/i915: Track clients and print their object usage in debugfs
  drm/i915: Track when we dirty the scanout with render commands
  drm/i915: Remove dead code from SDVO initialisation
  drm/i915: Initialize ring->hangcheck upon ring init
  drm/i915: Only slightly increment hangcheck score if we succesfully kick 
a ring
  drm/i915: Don't count semaphore waits towards a stuck ring
  drm/i915: Eliminate the addr/seqno from the hangcheck warning
  drm/i915: WARN if the fence pin_count is invalid

Damien Lespiau (3):
  drm/i915: Use FBINFO_STATE defines instead of 0 and 1
  drm/i915: Fix old reference to i830_sdvo_get_capabilities()
  drm/i915: Initialize active_outputs to never read unitialized values

Dan Carpenter (1):
  drm/i915: remove a superflous semi-colon

Daniel Vetter (43):
  drm/i915: optimize vblank waits in set_base_atomic
  drm/i915: refactor sink bpp clamping
  drm/i915: fix EDID/sink-based bpp clamping
  drm/i915: split out intel_pnv_find_best_PLL
  drm/i915: move find_pll callback to dev_priv->display
  drm/i915: fold in IS_PNV checks from the split up find_dpll functions
  drm/i915: clear up the fdi dotclock semantics for M/N computation
  drm/i915: refactor cpu eDP PLL handling a bit
  drm/i915: store adjusted dotclock in adjusted_mode->clock
  drm/i915: Drop some no longer required mode/adjusted_mode parameters
  drm/i915: check for strange pfit pipe assignemnt on ivb/hsw
  drm/i915: consolidate and tighten encoder cloning checks
  drm/i915: set default value for config->pixel_multiplier
  drm/i915: hw state readout support for pixel_multiplier
  drm/i915: pipe config quirk infrastructure plus sdvo mode.flags fix
  drm/i915: enable 30bpp for DP outputs
  drm/i915: fix up pch pll handling in ->mode_set
  drm/i915: conditionally disable pch resources in ilk_crtc_disable
  drm/i915: lock down pch pll accouting some more
  drm/i915: s/pch_pll/shared_dpll/
  drm/i915: switch crtc->shared_dpll from a pointer to an enum
  drm/i915: move shared_dpll into the pipe config
  drm/i915: refactor PCH_DPLL_SEL #defines
  drm/i915: hw state readout for shared pch plls
  drm/i915: consolidate ->num_shared_dplls assignement
  drm/i915: metadata for shared dplls
  drm/i915: scrap register address storage
  drm/i915: enable/disable hooks for shared dplls
  drm/i915: drop crtc checking from assert_shared_dpll
  drm/i915: disable sdvo pixel multiplier cross-check for HAS_PCH_SPLIT
  drm/i915: pnv dpll doesn't use m1!
  drm/i915: display pll hw state readout and checking
  drm/i915: extract readout_hw_state from setup_hw_state
  drm/i915: split up intel_modeset_check_state
  drm/i915: WARN on lack of shared dpll
  drm/i915: hw state readout and cross-checking for shared dplls
  drm/i915: fix up pch pll enabling for pixel multipliers
  drm/i915: set up PIPECONF explicitly on ilk-ivb
  drm/i915: set up PIPECONF explicitly 

[PATCH v3 0/1] drm/mgag200: Added resolution and bandwidth limits for various G200e products.

2013-06-27 Thread Julia Lemire
I fixed all of the formatting errors found by scripts/checkpatch.pl.

Julia Lemire (1):
  drm/mgag200: Added resolution and bandwidth limits for various G200e
products.

 drivers/gpu/drm/mgag200/mgag200_drv.h  |3 +-
 drivers/gpu/drm/mgag200/mgag200_main.c |2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c |   70 ++--
 3 files changed, 70 insertions(+), 5 deletions(-)

-- 
1.7.10.4



[PATCH v3 1/1] drm/mgag200: Added resolution and bandwidth limits for various G200e products.

2013-06-27 Thread Julia Lemire
At the larger resolutions, the g200e series sometimes struggles with
maintaining a proper output.  Problems like flickering or black bands appearing
on screen can occur.  In order to avoid this, limitations regarding resolutions
and bandwidth have been added for the different variations of the g200e series.
This code was ported from the old xorg mga driver.

Signed-off-by: Julia Lemire 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  |3 +-
 drivers/gpu/drm/mgag200/mgag200_main.c |2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c |   70 ++--
 3 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index bf29b2f..988911a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -198,7 +198,8 @@ struct mga_device {
struct ttm_bo_device bdev;
} ttm;

-   u32 reg_1e24; /* SE model number */
+   /* SE model number stored in reg 0x1e24 */
+   u32 unique_rev_id;
 };


diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index 9905923..dafe049 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -176,7 +176,7 @@ static int mgag200_device_init(struct drm_device *dev,

/* stash G200 SE model number for later use */
if (IS_G200_SE(mdev))
-   mdev->reg_1e24 = RREG32(0x1e24);
+   mdev->unique_rev_id = RREG32(0x1e24);

ret = mga_vram_init(mdev);
if (ret)
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index ee66bad..99e07b6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1008,7 +1008,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,


if (IS_G200_SE(mdev)) {
-   if (mdev->reg_1e24 >= 0x02) {
+   if (mdev->unique_rev_id >= 0x02) {
u8 hi_pri_lvl;
u32 bpp;
u32 mb;
@@ -1038,7 +1038,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
WREG8(MGAREG_CRTCEXT_DATA, hi_pri_lvl);
} else {
WREG8(MGAREG_CRTCEXT_INDEX, 0x06);
-   if (mdev->reg_1e24 >= 0x01)
+   if (mdev->unique_rev_id >= 0x01)
WREG8(MGAREG_CRTCEXT_DATA, 0x03);
else
WREG8(MGAREG_CRTCEXT_DATA, 0x04);
@@ -1410,6 +1410,32 @@ static int mga_vga_get_modes(struct drm_connector 
*connector)
return ret;
 }

+static uint32_t mga_vga_calculate_mode_bandwidth(struct drm_display_mode *mode,
+   int bits_per_pixel)
+{
+   uint32_t total_area, divisor;
+   int64_t active_area, pixels_per_second, bandwidth;
+   uint64_t bytes_per_pixel = (bits_per_pixel + 7) / 8;
+
+   divisor = 1024;
+
+   if (!mode->htotal || !mode->vtotal || !mode->clock)
+   return 0;
+
+   active_area = mode->hdisplay * mode->vdisplay;
+   total_area = mode->htotal * mode->vtotal;
+
+   pixels_per_second = active_area * mode->clock * 1000;
+   do_div(pixels_per_second, total_area);
+
+   bandwidth = pixels_per_second * bytes_per_pixel * 100;
+   do_div(bandwidth, divisor);
+
+   return (uint32_t)(bandwidth);
+}
+
+#define MODE_BANDWIDTH MODE_BAD
+
 static int mga_vga_mode_valid(struct drm_connector *connector,
 struct drm_display_mode *mode)
 {
@@ -1421,7 +1447,45 @@ static int mga_vga_mode_valid(struct drm_connector 
*connector,
int bpp = 32;
int i = 0;

-   /* FIXME: Add bandwidth and g200se limitations */
+   if (IS_G200_SE(mdev)) {
+   if (mdev->unique_rev_id == 0x01) {
+   if (mode->hdisplay > 1600)
+   return MODE_VIRTUAL_X;
+   if (mode->vdisplay > 1200)
+   return MODE_VIRTUAL_Y;
+   if (mga_vga_calculate_mode_bandwidth(mode, bpp)
+   > (24400 * 1024))
+   return MODE_BANDWIDTH;
+   } else if (mdev->unique_rev_id >= 0x02) {
+   if (mode->hdisplay > 1920)
+   return MODE_VIRTUAL_X;
+   if (mode->vdisplay > 1200)
+   return MODE_VIRTUAL_Y;
+   if (mga_vga_calculate_mode_bandwidth(mode, bpp)
+   > (30100 * 1024))
+   return MODE_BANDWIDTH;
+   }
+   } else if (mdev->type == G200_WB) {
+   if (mode->hdisplay > 1280)
+   return MODE_VIRTUAL_X;
+   if (mode->vdisplay > 1024)
+

[PATCH 9/9] drm/ast: do not attempt to acquire a reservation while in an interrupt handler

2013-06-27 Thread Maarten Lankhorst
Mutexes should not be acquired in interrupt context. While the trylock
fastpath is arguably safe on all implementations, the slowpath
unlock path definitely isn't.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/ast/ast_fb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index fbc0823..7b33e14 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -51,7 +51,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
struct ast_bo *bo;
int src_offset, dst_offset;
int bpp = (afbdev->afb.base.bits_per_pixel + 7)/8;
-   int ret;
+   int ret = -EBUSY;
bool unmap = false;
bool store_for_later = false;
int x2, y2;
@@ -65,7 +65,8 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
 * then the BO is being moved and we should
 * store up the damage until later.
 */
-   ret = ast_bo_reserve(bo, true);
+   if (!in_interrupt())
+   ret = ast_bo_reserve(bo, true);
if (ret) {
if (ret != -EBUSY)
return;
-- 
1.8.3.1



[PATCH 8/9] drm/mgag200: do not attempt to acquire a reservation while in an interrupt handler

2013-06-27 Thread Maarten Lankhorst
Mutexes should not be acquired in interrupt context. While the trylock
fastpath is arguably safe on all implementations, the slowpath
unlock path definitely isn't.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/mgag200/mgag200_fb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 5da824c..964f58c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -27,7 +27,7 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
struct mgag200_bo *bo;
int src_offset, dst_offset;
int bpp = (mfbdev->mfb.base.bits_per_pixel + 7)/8;
-   int ret;
+   int ret = -EBUSY;
bool unmap = false;
bool store_for_later = false;
int x2, y2;
@@ -41,7 +41,8 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
 * then the BO is being moved and we should
 * store up the damage until later.
 */
-   ret = mgag200_bo_reserve(bo, true);
+   if (!in_interrupt())
+   ret = mgag200_bo_reserve(bo, true);
if (ret) {
if (ret != -EBUSY)
return;
-- 
1.8.3.1



[PATCH 7/9] drm/cirrus: do not attempt to acquire a reservation while in an interrupt handler

2013-06-27 Thread Maarten Lankhorst
Mutexes should not be acquired in interrupt context. While the trylock
fastpath is arguably safe on all implementations, the slowpath
unlock path definitely isn't. This fixes the following lockdep splat:

[   13.044313] [ cut here ]
[   13.044367] WARNING: at /c/kernel-tests/src/tip/kernel/mutex.c:858 
mutex_trylock+0x87/0x220()
[   13.044378] DEBUG_LOCKS_WARN_ON(in_interrupt())
[   13.044378] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 
3.10.0-rc4-00296-ga2963dd #20
[   13.044379] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
[   13.044390]  0009 88000de039f8 81fc86d5 
88000de03a38
[   13.044395]  810d511b 8818 88000f33c690 
0001
[   13.044398]  03f0 88000f4677c8  
88000de03a98
[   13.044400] Call Trace:
[   13.044412][] dump_stack+0x19/0x1b
[   13.01]  [] warn_slowpath_common+0x6b/0x90
[   13.05]  [] warn_slowpath_fmt+0x46/0x50
[   13.08]  [] mutex_trylock+0x87/0x220
[   13.044482]  [] cirrus_dirty_update+0x1cd/0x330
[   13.044486]  [] cirrus_imageblit+0x38/0x50
[   13.044506]  [] soft_cursor+0x22e/0x240
[   13.044510]  [] bit_cursor+0x581/0x5b0
[   13.044525]  [] ? vsnprintf+0x124/0x670
[   13.044529]  [] ? get_color.isra.16+0x43/0x130
[   13.044532]  [] fbcon_cursor+0x18a/0x1d0
[   13.044535]  [] ? update_attr.isra.2+0xa0/0xa0
[   13.044556]  [] hide_cursor+0x32/0xa0
[   13.044565]  [] vt_console_print+0x103/0x3b0
[   13.044569]  [] ? print_time+0x9c/0xb0
[   13.044576]  [] ? print_prefix+0xa0/0xc0
[   13.044580]  [] 
call_console_drivers.constprop.6+0x146/0x1f0
[   13.044593]  [] ? do_raw_spin_unlock+0xc8/0x100
[   13.044597]  [] console_unlock+0x2f7/0x460
[   13.044600]  [] vprintk_emit+0x59a/0x5e0
[   13.044615]  [] printk+0x4d/0x4f
[   13.044650]  [] print_local_APIC+0x28/0x41c
[   13.044672]  [] 
generic_smp_call_function_single_interrupt+0x145/0x2b0
[   13.044688]  [] 
smp_call_function_single_interrupt+0x27/0x40
[   13.044697]  [] call_function_single_interrupt+0x72/0x80
[   13.044707][] ? native_safe_halt+0x6/0x10
[   13.044717]  [] ? trace_hardirqs_on+0xd/0x10
[   13.044738]  [] default_idle+0x59/0x120
[   13.044742]  [] arch_cpu_idle+0x18/0x40
[   13.044754]  [] cpu_startup_entry+0x235/0x410
[   13.044763]  [] rest_init+0xd1/0xe0
[   13.044766]  [] ? rest_init+0x5/0xe0
[   13.044778]  [] start_kernel+0x425/0x493
[   13.044781]  [] ? repair_env_string+0x5e/0x5e
[   13.044786]  [] x86_64_start_reservations+0x2a/0x2c
[   13.044789]  [] x86_64_start_kernel+0xf1/0x100
[   13.044799] ---[ end trace 113ad28772af4058 ]---

Reported-by: Fengguang Wu 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 3541b56..b27e956 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -25,7 +25,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
struct cirrus_bo *bo;
int src_offset, dst_offset;
int bpp = (afbdev->gfb.base.bits_per_pixel + 7)/8;
-   int ret;
+   int ret = -EBUSY;
bool unmap = false;
bool store_for_later = false;
int x2, y2;
@@ -39,7 +39,8 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 * then the BO is being moved and we should
 * store up the damage until later.
 */
-   ret = cirrus_bo_reserve(bo, true);
+   if (!in_interrupt())
+   ret = cirrus_bo_reserve(bo, true);
if (ret) {
if (ret != -EBUSY)
return;
-- 
1.8.3.1



[PATCH 6/9] drm/nouveau: always select ACPI_VIDEO if ACPI is enabled.

2013-06-27 Thread Maarten Lankhorst
Having nouveau builtin would still allow ACPI_VIDEO to be used as external 
module
if some of the deps for acpi_video have not been met, which would result in a 
linking
failure. Solve this by selecting all dependencies as well.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/Kconfig | 1 +
 drivers/gpu/drm/nouveau/Kconfig | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 71ca63b..a7c54c8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -139,6 +139,7 @@ config DRM_I915
select BACKLIGHT_CLASS_DEVICE if ACPI
select VIDEO_OUTPUT_CONTROL if ACPI
select INPUT if ACPI
+   select THERMAL if ACPI
select ACPI_VIDEO if ACPI
select ACPI_BUTTON if ACPI
help
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index a7ff6d5..ff80f12 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -15,6 +15,13 @@ config DRM_NOUVEAU
select ACPI_WMI if ACPI && X86
select MXM_WMI if ACPI && X86
select POWER_SUPPLY
+   # Similar to i915, we need to select ACPI_VIDEO and it's dependencies
+   select BACKLIGHT_LCD_SUPPORT if ACPI && X86
+   select BACKLIGHT_CLASS_DEVICE if ACPI && X86
+   select VIDEO_OUTPUT_CONTROL if ACPI && X86
+   select INPUT if ACPI && X86
+   select THERMAL if ACPI && X86
+   select ACPI_VIDEO if ACPI && X86
help
  Choose this option for open-source nVidia support.

-- 
1.8.3.1



[PATCH 5/9] drm/nouveau: complain loudly if buffer is pinned during destruction

2013-06-27 Thread Maarten Lankhorst
Shouldn't happen, and we invert the struct_mutex with reservation here,
potentially leading to deadlocks. Once reservations become lockdep annotated,
lockdep will go splat on this.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index b4b4d0c..7054706 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -50,7 +50,8 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
return;
nvbo->gem = NULL;

-   if (unlikely(nvbo->pin_refcnt)) {
+   /* Lockdep hates you for doing reserve with gem object lock held */
+   if (WARN_ON_ONCE(nvbo->pin_refcnt)) {
nvbo->pin_refcnt = 1;
nouveau_bo_unpin(nvbo);
}
-- 
1.8.3.1



[PATCH 4/9] drm/nouveau: fixup fbcon failure paths

2013-06-27 Thread Maarten Lankhorst
Add missing calls, and fix a leak from forgetting to call the unpin function.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index b035317..ecbfe69 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -289,16 +289,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM);
if (ret) {
NV_ERROR(drm, "failed to pin fb: %d\n", ret);
-   nouveau_bo_ref(NULL, );
-   goto out;
+   goto out_unref;
}

ret = nouveau_bo_map(nvbo);
if (ret) {
NV_ERROR(drm, "failed to map fb: %d\n", ret);
-   nouveau_bo_unpin(nvbo);
-   nouveau_bo_ref(NULL, );
-   goto out;
+   goto out_unpin;
}

chan = nouveau_nofbaccel ? NULL : drm->channel;
@@ -316,13 +313,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
info = framebuffer_alloc(0, >dev);
if (!info) {
ret = -ENOMEM;
-   goto out_unref;
+   goto out_unlock;
}

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

info->par = fbcon;
@@ -337,7 +335,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
fbcon->helper.fbdev = info;

strcpy(info->fix.id, "nouveaufb");
-   if (nouveau_nofbaccel)
+   if (!chan)
info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED;
else
info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
@@ -383,8 +381,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(dev->pdev, info);
return 0;

-out_unref:
+out_unlock:
mutex_unlock(>struct_mutex);
+   if (chan)
+   nouveau_bo_vma_del(nvbo, >nouveau_fb.vma);
+out_unpin:
+   nouveau_bo_unpin(nvbo);
+out_unref:
+   nouveau_bo_ref(NULL, );
 out:
return ret;
 }
@@ -413,6 +417,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct 
nouveau_fbdev *fbcon)
if (nouveau_fb->nvbo) {
nouveau_bo_unmap(nouveau_fb->nvbo);
nouveau_bo_vma_del(nouveau_fb->nvbo, _fb->vma);
+   nouveau_bo_unpin(nouveau_fb->nvbo);
drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem);
nouveau_fb->nvbo = NULL;
}
-- 
1.8.3.1



[PATCH 3/9] drm/nouveau: unpin notify object in chan_fini

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c 
b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 1c4c6c9..8f467e7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -129,6 +129,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,

if (chan->ntfy) {
nouveau_bo_vma_del(chan->ntfy, >ntfy_vma);
+   nouveau_bo_unpin(chan->ntfy);
drm_gem_object_unreference_unlocked(chan->ntfy->gem);
}

-- 
1.8.3.1



[PATCH 2/9] drm/nouveau: implement prime helper unpin function

2013-06-27 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 +
 drivers/gpu/drm/nouveau/nouveau_gem.h   | 1 +
 drivers/gpu/drm/nouveau/nouveau_prime.c | 9 -
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 383f4e6..218a4b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -702,6 +702,7 @@ driver = {
.gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import,
.gem_prime_pin = nouveau_gem_prime_pin,
+   .gem_prime_unpin = nouveau_gem_prime_unpin,
.gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
.gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
.gem_prime_vmap = nouveau_gem_prime_vmap,
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h 
b/drivers/gpu/drm/nouveau/nouveau_gem.h
index 8d7a3f0..502e429 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.h
@@ -36,6 +36,7 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
  struct drm_file *);

 extern int nouveau_gem_prime_pin(struct drm_gem_object *);
+extern void nouveau_gem_prime_unpin(struct drm_gem_object *);
 extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object 
*);
 extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
struct drm_device *, size_t size, struct sg_table *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c 
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index f53e108..e90468d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -84,7 +84,7 @@ struct drm_gem_object 
*nouveau_gem_prime_import_sg_table(struct drm_device *dev,
 int nouveau_gem_prime_pin(struct drm_gem_object *obj)
 {
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
-   int ret = 0;
+   int ret;

/* pin buffer into GTT */
ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_TT);
@@ -93,3 +93,10 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj)

return 0;
 }
+
+void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
+{
+   struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+
+   nouveau_bo_unpin(nvbo);
+}
-- 
1.8.3.1



[PATCH 1/9] drm/radeon: implement unpin function, v2

2013-06-27 Thread Maarten Lankhorst
Changes since v1:
- Fixup compiler warning in unpin function.

Signed-off-by: Maarten Lankhorst 
Reviewed-by: Jerome Glisse 
Acked-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon_drv.c   |  2 ++
 drivers/gpu/drm/radeon/radeon_prime.c | 18 +-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 094e7e5..f191e97 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -127,6 +127,7 @@ struct drm_gem_object 
*radeon_gem_prime_import_sg_table(struct drm_device *dev,
size_t size,
struct sg_table *sg);
 int radeon_gem_prime_pin(struct drm_gem_object *obj);
+void radeon_gem_prime_unpin(struct drm_gem_object *obj);
 void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
 void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
 extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd,
@@ -422,6 +423,7 @@ static struct drm_driver kms_driver = {
.gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import,
.gem_prime_pin = radeon_gem_prime_pin,
+   .gem_prime_unpin = radeon_gem_prime_unpin,
.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
.gem_prime_vmap = radeon_gem_prime_vmap,
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c 
b/drivers/gpu/drm/radeon/radeon_prime.c
index 4940af7..65b9eab 100644
--- a/drivers/gpu/drm/radeon/radeon_prime.c
+++ b/drivers/gpu/drm/radeon/radeon_prime.c
@@ -88,11 +88,19 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj)

/* pin buffer into GTT */
ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
-   if (ret) {
-   radeon_bo_unreserve(bo);
-   return ret;
-   }
radeon_bo_unreserve(bo);
+   return ret;
+}
+
+void radeon_gem_prime_unpin(struct drm_gem_object *obj)
+{
+   struct radeon_bo *bo = gem_to_radeon_bo(obj);
+   int ret = 0;

-   return 0;
+   ret = radeon_bo_reserve(bo, false);
+   if (unlikely(ret != 0))
+   return;
+
+   radeon_bo_unpin(bo);
+   radeon_bo_unreserve(bo);
 }
-- 
1.8.3.1



RADEON / DPM: GPU cannot properly up-clock

2013-06-27 Thread Alex Deucher
On Wed, Jun 26, 2013 at 4:57 PM, Joshua C.  wrote:
> 2013/6/26 Deucher, Alexander :
>>
>>
>>> -Original Message-
>>> From: Joshua C. [mailto:joshuacov at gmail.com]
>>> Sent: Wednesday, June 26, 2013 1:52 PM
>>> To: dri-devel at lists.freedesktop.org
>>> Cc: Deucher, Alexander
>>> Subject: RADEON / DPM: GPU cannot properly up-clock
>>>
>>> First of all thank you guys for pushing this out! Great work!
>>>
>>> I tried the latest code in drm-next-3.11-wip (up to commit
>>> b3c1e0c3ba885db44 "drm/radeon: fix endian issues in atombios dpm
>>> code") in connection with the latest radeon_ucode (latest update on
>>> 2013-06-26). I also reintroduced the debugfs info so that I can better
>>> observe the gpu-settings. For this I put back the following patch:
>>>
>>> diff --git a/drivers/gpu/drm/radeon/radeon_pm.c
>>> b/drivers/gpu/drm/radeon/radeon_pm.c
>>> index 7ba5d6f..9367234 100644
>>> --- a/drivers/gpu/drm/radeon/radeon_pm.c
>>> +++ b/drivers/gpu/drm/radeon/radeon_pm.c
>>> @@ -1066,6 +1066,11 @@ static int radeon_pm_init_dpm(struct
>>> radeon_device *rdev)
>>>  ret = device_create_file(rdev->dev, _attr_power_method);
>>>  if (ret)
>>>  DRM_ERROR("failed to create device file for power method\n");
>>> +
>>> +if (radeon_debugfs_pm_init(rdev)) {
>>> +DRM_ERROR("Failed to register debugfs file for PM!\n");
>>> +}
>>> +
>>>  DRM_INFO("radeon: dpm initialized\n");
>>>  }
>>>
>>> --
>>> 1.8.2.1
>>
>> I removed that code for a reason when DPM is active.  With DPM the hardware 
>> changes the power state dynamically internally so that old debugging 
>> information is completely irrelevant when DPM is active.
>>
>> Alex
>>
>>
>
> I see. Do you have any idea why I see those delays when playing a
> HD-movie? They do not appear when switching to dynpm. I use the latest
> llvm(3.4svn), libdrm(2.4.45), mesa(9.2.0 devel), xserver(1.14.99.0),
> xf86-video-ati(deve) - all fetched from git as of 2013-06-26.

What type of movie is it and what are you using to decode the movie? UVD?  CPU?

Alex


[PATCH] gpu/host1x: Remove DRIVER_BUS_PLATFORM from driver_features

2013-06-27 Thread Thierry Reding
On Thu, Jun 27, 2013 at 11:09:39AM +0200, Laurent Pinchart wrote:
> Hi Thierry,
> 
> On Wednesday 29 May 2013 12:50:40 Thierry Reding wrote:
> > On Wed, May 29, 2013 at 07:44:34AM +0200, Laurent Pinchart wrote:
> > > From: Laurent Pinchart 
> > > 
> > > DRIVER_BUS_PLATFORM is not a DRM driver feature flag, it must not be set
> > > in the driver's driver_features field.
> > > 
> > > Signed-off-by: Laurent Pinchart 
> > > ---
> > > 
> > >  drivers/gpu/host1x/drm/drm.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Applied, thanks. I did modify the subject's prefix to "drm/tegra: " for
> > consistency, though.
> 
> Do you plan to push the patch to v3.11 through Dave's tree ? I can't find it 
> in drm-next.

Yes, I have it in my for-next branch (so it should be in linux-next)
that I'll request Dave to pull from for 3.11.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130627/daf95b42/attachment.pgp>


[PATCH 24/24] drm/rcar-du: Add internal LVDS encoder support

2013-06-27 Thread Laurent Pinchart
The R8A7790 includes two internal LVDS encoders. Support them in the DU
driver.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Kconfig   |   7 ++
 drivers/gpu/drm/rcar-du/Makefile  |   4 +-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c|   2 -
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h|   2 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.h |   4 +
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c |  38 ++
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |   5 +
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 194 ++
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h |  46 +++
 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h  |  69 +++
 12 files changed, 372 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 72887df..c590cd9 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -7,3 +7,10 @@ config DRM_RCAR_DU
help
  Choose this option if you have an R-Car chipset.
  If M is selected the module will be called rcar-du-drm.
+
+config DRM_RCAR_LVDS
+   bool "R-Car DU LVDS Encoder Support"
+   depends on DRM_RCAR_DU
+   help
+ Enable support the R-Car Display Unit embedded LVDS encoders
+ (currently only on R8A7790).
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index b9b5e66..12b8d44 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -7,4 +7,6 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_plane.o \
 rcar_du_vgacon.o

-obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
+rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o
+
+obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 245800d..33df7a5 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -26,8 +26,6 @@
 #include "rcar_du_plane.h"
 #include "rcar_du_regs.h"

-#define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc)
-
 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
 {
struct rcar_du_device *rcdu = rcrtc->group->dev;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 39a983d..43e7575 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -39,6 +39,8 @@ struct rcar_du_crtc {
struct rcar_du_plane *plane;
 };

+#define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc)
+
 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
 void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
 void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 28654e7..53cc827 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -227,6 +227,7 @@ static const struct rcar_du_device_info 
rcar_du_r8a7779_info = {
.encoder_type = DRM_MODE_ENCODER_NONE,
},
},
+   .num_lvds = 0,
 };

 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
@@ -250,6 +251,7 @@ static const struct rcar_du_device_info 
rcar_du_r8a7790_info = {
.encoder_type = DRM_MODE_ENCODER_LVDS,
},
},
+   .num_lvds = 2,
 };

 static const struct platform_device_id rcar_du_id_table[] = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 924f5e0..050d71c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -24,6 +24,7 @@ struct clk;
 struct device;
 struct drm_device;
 struct rcar_du_device;
+struct rcar_du_lvdsenc;

 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0)/* Per-CRTC IRQ and 
clock */
 #define RCAR_DU_FEATURE_ALIGN_128B (1 << 1)/* Align pitches to 128 
bytes */
@@ -48,11 +49,13 @@ struct rcar_du_output_routing {
  * @features: device features (RCAR_DU_FEATURE_*)
  * @num_crtcs: total number of CRTCs
  * @routes: array of CRTC to output routes, indexed by output 
(RCAR_DU_OUTPUT_*)
+ * @num_lvds: number of internal LVDS encoders
  */
 struct rcar_du_device_info {
unsigned int features;
unsigned int num_crtcs;
struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
+   unsigned int num_lvds;
 };

 struct rcar_du_device {
@@ -70,6 +73,7 @@ struct rcar_du_device {

[PATCH 23/24] drm/rcar-du: Configure RGB output routing to DPAD0

2013-06-27 Thread Laurent Pinchart
The R8A7790 DU variant has a single RGB output called DPAD0 that can be
fed with the output of DU0, DU1 or DU2. Making the routing configurable.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  5 
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 45 ++---
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 +-
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 680606e..245800d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -139,6 +139,11 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,
 * configured when starting the CRTC.
 */
rcrtc->outputs |= BIT(output);
+
+   /* Store RGB routing to DPAD0 for R8A7790. */
+   if (rcar_du_has(rcdu, RCAR_DU_FEATURE_DEFR8) &&
+   output == RCAR_DU_OUTPUT_DPAD0)
+   rcdu->dpad0_source = rcrtc->index;
 }

 void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index d5243f4..924f5e0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -68,6 +68,8 @@ struct rcar_du_device {
unsigned int num_crtcs;

struct rcar_du_group groups[2];
+
+   unsigned int dpad0_source;
 };

 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 9df6fb6..eb53cd9 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -27,6 +27,7 @@
  * counterpart in the DU documentation, that models those semi-global 
resources.
  */

+#include 
 #include 

 #include "rcar_du_drv.h"
@@ -43,6 +44,22 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32 
reg, u32 data)
rcar_du_write(rgrp->dev, rgrp->mmio_offset + reg, data);
 }

+static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp)
+{
+   u32 defr8 = DEFR8_CODE | DEFR8_DEFE8;
+
+   if (!rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_DEFR8))
+   return;
+
+   /* The DEFR8 register for the first group also controls RGB output
+* routing to DPAD0
+*/
+   if (rgrp->index == 0)
+   defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source);
+
+   rcar_du_group_write(rgrp, DEFR8, defr8);
+}
+
 static void rcar_du_group_setup(struct rcar_du_group *rgrp)
 {
/* Enable extended features */
@@ -51,8 +68,8 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp)
rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3);
rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5);
-   if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_DEFR8))
-   rcar_du_group_write(rgrp, DEFR8, DEFR8_CODE | DEFR8_DEFE8);
+
+   rcar_du_group_setup_defr8(rgrp);

/* Use DS1PR and DS2PR to configure planes priorities and connects the
 * superposition 0 to DU0 pins. DU1 pins will be configured dynamically.
@@ -128,7 +145,27 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp)
__rcar_du_group_start_stop(rgrp, true);
 }

-void rcar_du_group_set_routing(struct rcar_du_group *rgrp)
+static int rcar_du_set_dpad0_routing(struct rcar_du_device *rcdu)
+{
+   int ret;
+
+   /* RGB output routing to DPAD0 is configured in the DEFR8 register of
+* the first group. As this function can be called with the DU0 and DU1
+* CRTCs disabled, we need to enable the first group clock before
+* accessing the register.
+*/
+   ret = clk_prepare_enable(rcdu->crtcs[0].clock);
+   if (ret < 0)
+   return ret;
+
+   rcar_du_group_setup_defr8(>groups[0]);
+
+   clk_disable_unprepare(rcdu->crtcs[0].clock);
+
+   return 0;
+}
+
+int rcar_du_group_set_routing(struct rcar_du_group *rgrp)
 {
struct rcar_du_crtc *crtc0 = >dev->crtcs[rgrp->index * 2];
u32 dorcr = rcar_du_group_read(rgrp, DORCR);
@@ -145,4 +182,6 @@ void rcar_du_group_set_routing(struct rcar_du_group *rgrp)
dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2;

rcar_du_group_write(rgrp, DORCR, dorcr);
+
+   return rcar_du_set_dpad0_routing(rgrp->dev);
 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h 
b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index 4487e83..5025930 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -45,6 +45,6 @@ int rcar_du_group_get(struct rcar_du_group *rgrp);
 void rcar_du_group_put(struct rcar_du_group *rgrp);
 void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start);
 void rcar_du_group_restart(struct rcar_du_group 

[PATCH 22/24] drm/rcar-du: Rework output routing support

2013-06-27 Thread Laurent Pinchart
Split the output routing specification between SoC-internal data,
specified in the rcar_du_device_info structure, and board data, passed
through platform data.

The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). SoC-internal
output routing data specify which output are valid, which CRTCs can be
connected to the valid outputs, and the type of in-SoC encoder for the
output.

Platform data then specifies external encoders and the output they are
connected to.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c|  6 --
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h|  4 +++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 30 ++
 drivers/gpu/drm/rcar-du/rcar_du_drv.h | 16 
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 26 +-
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  5 +++--
 drivers/gpu/drm/rcar-du/rcar_du_group.c   |  8 
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 17 +++--
 include/linux/platform_data/rcar-du.h | 17 +++--
 9 files changed, 107 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a340224..680606e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -129,14 +129,16 @@ static void rcar_du_crtc_set_display_timing(struct 
rcar_du_crtc *rcrtc)
rcar_du_crtc_write(rcrtc, DEWR,  mode->hdisplay);
 }

-void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output)
+void rcar_du_crtc_route_output(struct drm_crtc *crtc,
+  enum rcar_du_output output)
 {
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+   struct rcar_du_device *rcdu = rcrtc->group->dev;

/* Store the route from the CRTC output to the DU output. The DU will be
 * configured when starting the CRTC.
 */
-   rcrtc->outputs |= 1 << output;
+   rcrtc->outputs |= BIT(output);
 }

 void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 542a7fe..39a983d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -15,6 +15,7 @@
 #define __RCAR_DU_CRTC_H__

 #include 
+#include 

 #include 
 #include 
@@ -45,7 +46,8 @@ void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);

-void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output);
+void rcar_du_crtc_route_output(struct drm_crtc *crtc,
+  enum rcar_du_output output);
 void rcar_du_crtc_update_planes(struct drm_crtc *crtc);

 #endif /* __RCAR_DU_CRTC_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index dd1950d..28654e7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -214,12 +214,42 @@ static int rcar_du_remove(struct platform_device *pdev)
 static const struct rcar_du_device_info rcar_du_r8a7779_info = {
.features = 0,
.num_crtcs = 2,
+   .routes = {
+   /* R8A7779 has two RGB outputs and one (currently unsupported)
+* TCON output.
+*/
+   [RCAR_DU_OUTPUT_DPAD0] = {
+   .possible_crtcs = BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_NONE,
+   },
+   [RCAR_DU_OUTPUT_DPAD1] = {
+   .possible_crtcs = BIT(1) | BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_NONE,
+   },
+   },
 };

 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B
  | RCAR_DU_FEATURE_DEFR8,
.num_crtcs = 3,
+   .routes = {
+   /* R8A7790 has one RGB output, two LVDS outputs and one
+* (currently unsupported) TCON output.
+*/
+   [RCAR_DU_OUTPUT_DPAD0] = {
+   .possible_crtcs = BIT(2) | BIT(1) | BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_NONE,
+   },
+   [RCAR_DU_OUTPUT_LVDS0] = {
+   .possible_crtcs = BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_LVDS,
+   },
+   [RCAR_DU_OUTPUT_LVDS1] = {
+   .possible_crtcs = BIT(2) | BIT(1),
+   .encoder_type = DRM_MODE_ENCODER_LVDS,
+   },
+   },
 };

 static const struct platform_device_id rcar_du_id_table[] = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 70c335f..d5243f4 100644
--- 

[PATCH 21/24] drm/rcar-du: Add support for DEFR8 register

2013-06-27 Thread Laurent Pinchart
The R8A7790 DU has a new extended function control register. Support it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 3 ++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   | 1 +
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 98e35aa..dd1950d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -217,7 +217,8 @@ static const struct rcar_du_device_info 
rcar_du_r8a7779_info = {
 };

 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
-   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B,
+   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B
+ | RCAR_DU_FEATURE_DEFR8,
.num_crtcs = 3,
 };

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 160e5eb..70c335f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -27,6 +27,7 @@ struct rcar_du_device;

 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0)/* Per-CRTC IRQ and 
clock */
 #define RCAR_DU_FEATURE_ALIGN_128B (1 << 1)/* Align pitches to 128 
bytes */
+#define RCAR_DU_FEATURE_DEFR8  (1 << 2)/* Has DEFR8 register */

 /*
  * struct rcar_du_device_info - DU model-specific information
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 0eb106e..f3ba0ca 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -51,6 +51,8 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp)
rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3);
rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5);
+   if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_DEFR8))
+   rcar_du_group_write(rgrp, DEFR8, DEFR8_CODE | DEFR8_DEFE8);

/* Use DS1PR and DS2PR to configure planes priorities and connects the
 * superposition 0 to DU0 pins. DU1 pins will be configured dynamically.
-- 
1.8.1.5



[PATCH 20/24] drm/rcar-du: Add support for multiple groups

2013-06-27 Thread Laurent Pinchart
The R8A7790 DU has 3 CRTCs, split in two groups. Support them.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  | 25 ++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |  6 +++--
 drivers/gpu/drm/rcar-du/rcar_du_group.c |  4 +--
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  3 +++
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 43 -
 drivers/gpu/drm/rcar-du/rcar_du_plane.c |  6 +++--
 drivers/gpu/drm/rcar-du/rcar_du_regs.h  |  4 ++-
 8 files changed, 63 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 6a2b959..a340224 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -91,7 +91,6 @@ static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc)
 static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
 {
const struct drm_display_mode *mode = >crtc.mode;
-   struct rcar_du_device *rcdu = rcrtc->group->dev;
unsigned long clk;
u32 value;
u32 div;
@@ -101,9 +100,9 @@ static void rcar_du_crtc_set_display_timing(struct 
rcar_du_crtc *rcrtc)
div = DIV_ROUND_CLOSEST(clk, mode->clock * 1000);
div = clamp(div, 1U, 64U) - 1;

-   rcar_du_write(rcdu, rcrtc->index ? ESCR2 : ESCR,
- ESCR_DCLKSEL_CLKS | div);
-   rcar_du_write(rcdu, rcrtc->index ? OTAR2 : OTAR, 0);
+   rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? ESCR2 : ESCR,
+   ESCR_DCLKSEL_CLKS | div);
+   rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? OTAR2 : OTAR, 0);

/* Signal polarities */
value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
@@ -143,7 +142,6 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc, 
unsigned int output)
 void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
 {
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
-   struct rcar_du_device *rcdu = rcrtc->group->dev;
struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES];
unsigned int num_planes = 0;
unsigned int prio = 0;
@@ -189,8 +187,8 @@ void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
/* Select display timing and dot clock generator 2 for planes associated
 * with superposition controller 2.
 */
-   if (rcrtc->index) {
-   u32 value = rcar_du_read(rcdu, DPTSR);
+   if (rcrtc->index % 2) {
+   u32 value = rcar_du_group_read(rcrtc->group, DPTSR);

/* The DPTSR register is updated when the display controller is
 * stopped. We thus need to restart the DU. Once again, sorry
@@ -200,13 +198,14 @@ void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
 * occur only if we need to break the pre-association.
 */
if (value != dptsr) {
-   rcar_du_write(rcdu, DPTSR, dptsr);
+   rcar_du_group_write(rcrtc->group, DPTSR, dptsr);
if (rcrtc->group->used_crtcs)
rcar_du_group_restart(rcrtc->group);
}
}

-   rcar_du_write(rcdu, rcrtc->index ? DS2PR : DS1PR, dspr);
+   rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
+   dspr);
 }

 static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)
@@ -528,6 +527,10 @@ static const struct drm_crtc_funcs crtc_funcs = {

 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
 {
+   static const unsigned int mmio_offsets[] = {
+   DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET
+   };
+
struct rcar_du_device *rcdu = rgrp->dev;
struct platform_device *pdev = to_platform_device(rcdu->dev);
struct rcar_du_crtc *rcrtc = >crtcs[index];
@@ -553,10 +556,10 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, 
unsigned int index)
}

rcrtc->group = rgrp;
-   rcrtc->mmio_offset = index ? DISP2_REG_OFFSET : 0;
+   rcrtc->mmio_offset = mmio_offsets[index];
rcrtc->index = index;
rcrtc->dpms = DRM_MODE_DPMS_OFF;
-   rcrtc->plane = >planes.planes[index];
+   rcrtc->plane = >planes.planes[index % 2];

rcrtc->plane->crtc = crtc;

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fe93670..98e35aa 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -213,10 +213,12 @@ static int rcar_du_remove(struct platform_device *pdev)

 static const struct rcar_du_device_info rcar_du_r8a7779_info = {
.features = 0,
+   .num_crtcs = 2,
 };

 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B,
+ 

[PATCH 19/24] drm/rcar-du: Fix buffer pitch alignment for R8A7790 DU

2013-06-27 Thread Laurent Pinchart
The R8A7790 DU seems to require a 128 bytes pitch alignment, even though
the documentation only mentions a 16 pixels alignement as for the
R8A7779 DU. Make this configurable through a device flag.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h |  1 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 17 ++---
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 9c7406c..fe93670 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -216,7 +216,7 @@ static const struct rcar_du_device_info 
rcar_du_r8a7779_info = {
 };

 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
-   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK,
+   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B,
 };

 static const struct platform_device_id rcar_du_id_table[] = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 5b57a2f..072e28e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -26,6 +26,7 @@ struct drm_device;
 struct rcar_du_device;

 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0)/* Per-CRTC IRQ and 
clock */
+#define RCAR_DU_FEATURE_ALIGN_128B (1 << 1)/* Align pitches to 128 
bytes */

 /*
  * struct rcar_du_device_info - DU model-specific information
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 845bcb3..418d902 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -111,11 +111,18 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 
fourcc)
 int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args)
 {
+   struct rcar_du_device *rcdu = dev->dev_private;
unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
unsigned int align;

-   /* The pitch must be aligned to a 16 pixels boundary. */
-   align = 16 * args->bpp / 8;
+   /* The R8A7779 DU requires a 16 pixels pitch alignment as documented,
+* but the R8A7790 DU seems to require a 128 bytes pitch alignment.
+*/
+   if (rcar_du_has(rcdu, RCAR_DU_FEATURE_ALIGN_128B))
+   align = 128;
+   else
+   align = 16 * args->bpp / 8;
+
args->pitch = roundup(max(args->pitch, min_pitch), align);

return drm_gem_cma_dumb_create(file, dev, args);
@@ -125,6 +132,7 @@ static struct drm_framebuffer *
 rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
  struct drm_mode_fb_cmd2 *mode_cmd)
 {
+   struct rcar_du_device *rcdu = dev->dev_private;
const struct rcar_du_format_info *format;
unsigned int align;

@@ -135,7 +143,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file 
*file_priv,
return ERR_PTR(-EINVAL);
}

-   align = 16 * format->bpp / 8;
+   if (rcar_du_has(rcdu, RCAR_DU_FEATURE_ALIGN_128B))
+   align = 128;
+   else
+   align = 16 * format->bpp / 8;

if (mode_cmd->pitches[0] & (align - 1) ||
mode_cmd->pitches[0] >= 8192) {
-- 
1.8.1.5



[PATCH 18/24] drm/rcar-du: Add support for the R8A7790 DU

2013-06-27 Thread Laurent Pinchart
The DU revision in the R8A7790 SoC uses one IRQ and clock per CRTC. Add
a corresponding entry in the module platform ID table.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  5 +++
 drivers/gpu/drm/rcar-du/rcar_du_regs.h | 66 --
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fe61962..9c7406c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -215,8 +215,13 @@ static const struct rcar_du_device_info 
rcar_du_r8a7779_info = {
.features = 0,
 };

+static const struct rcar_du_device_info rcar_du_r8a7790_info = {
+   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK,
+};
+
 static const struct platform_device_id rcar_du_id_table[] = {
{ "rcar-du-r8a7779", (kernel_ulong_t)_du_r8a7779_info },
+   { "rcar-du-r8a7790", (kernel_ulong_t)_du_r8a7790_info },
{ }
 };

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index 195ed7e..f62a9f3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -196,6 +196,68 @@
 #define DEFR6_DEFAULT  (DEFR6_CODE | DEFR6_TCNE2)

 /* 
-
+ * R8A7790-only Control Registers
+ */
+
+#define DD1SSR 0x20008
+#define DD1SSR_TVR (1 << 15)
+#define DD1SSR_FRM (1 << 14)
+#define DD1SSR_BUF (1 << 12)
+#define DD1SSR_VBK (1 << 11)
+#define DD1SSR_RINT(1 << 9)
+#define DD1SSR_HBK (1 << 8)
+#define DD1SSR_ADC(n)  (1 << ((n)-1))
+
+#define DD1SRCR0x2000c
+#define DD1SRCR_TVR(1 << 15)
+#define DD1SRCR_FRM(1 << 14)
+#define DD1SRCR_BUF(1 << 12)
+#define DD1SRCR_VBK(1 << 11)
+#define DD1SRCR_RINT   (1 << 9)
+#define DD1SRCR_HBK(1 << 8)
+#define DD1SRCR_ADC(n) (1 << ((n)-1))
+
+#define DD1IER 0x20010
+#define DD1IER_TVR (1 << 15)
+#define DD1IER_FRM (1 << 14)
+#define DD1IER_BUF (1 << 12)
+#define DD1IER_VBK (1 << 11)
+#define DD1IER_RINT(1 << 9)
+#define DD1IER_HBK (1 << 8)
+#define DD1IER_ADC(n)  (1 << ((n)-1))
+
+#define DEFR8  0x20020
+#define DEFR8_CODE (0x7790 << 16)
+#define DEFR8_VSCS (1 << 6)
+#define DEFR8_DRGBS_DU(n)  ((n) << 4)
+#define DEFR8_DRGBS_MASK   (3 << 4)
+#define DEFR8_DEFE8(1 << 0)
+
+#define DOFLR  0x20024
+#define DOFLR_CODE (0x7790 << 16)
+#define DOFLR_HSYCFL1  (1 << 13)
+#define DOFLR_VSYCFL1  (1 << 12)
+#define DOFLR_ODDFL1   (1 << 11)
+#define DOFLR_DISPFL1  (1 << 10)
+#define DOFLR_CDEFL1   (1 << 9)
+#define DOFLR_RGBFL1   (1 << 8)
+#define DOFLR_HSYCFL0  (1 << 5)
+#define DOFLR_VSYCFL0  (1 << 4)
+#define DOFLR_ODDFL0   (1 << 3)
+#define DOFLR_DISPFL0  (1 << 2)
+#define DOFLR_CDEFL0   (1 << 1)
+#define DOFLR_RGBFL0   (1 << 0)
+
+#define DIDSR  0x20028
+#define DIDSR_CODE (0x7790 << 16)
+#define DIDSR_LCDS_DCLKIN(n)   (0 << (8 + (n) * 2))
+#define DIDSR_LCDS_LVDS0(n)(2 << (8 + (n) * 2))
+#define DIDSR_LCDS_LVDS1(n)(3 << (8 + (n) * 2))
+#define DIDSR_LCDS_MASK(n) (3 << (8 + (n) * 2))
+#define DIDSR_PCDS_CLK(n, clk) (clk << ((n) * 2))
+#define DIDSR_PCDS_MASK(n) (3 << ((n) * 2))
+
+/* 
-
  * Display Timing Generation Registers
  */

@@ -364,12 +426,10 @@
  * Display Capture Registers
  */

+#define DCMR   0x0c100
 #define DCMWR  0x0c104
-#define DC2MWR 0x0c204
 #define DCSAR  0x0c120
-#define DC2SAR 0x0c220
 #define DCMLR  0x0c150
-#define DC2MLR 0x0c250

 /* 
-
  * Color Palette Registers
-- 
1.8.1.5



[PATCH 17/24] drm/rcar-du: Move output routing configuration to group

2013-06-27 Thread Laurent Pinchart
Output routing is configured in group registers, move the corresponding
code from rcar_du_crtc.c to rcar_du_group.c.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  | 21 +
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 19 +++
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 +-
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 7784a3b..6a2b959 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -130,25 +130,6 @@ static void rcar_du_crtc_set_display_timing(struct 
rcar_du_crtc *rcrtc)
rcar_du_crtc_write(rcrtc, DEWR,  mode->hdisplay);
 }

-static void rcar_du_crtc_set_routing(struct rcar_du_crtc *rcrtc)
-{
-   struct rcar_du_device *rcdu = rcrtc->group->dev;
-   u32 dorcr = rcar_du_read(rcdu, DORCR);
-
-   dorcr &= ~(DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_MASK);
-
-   /* Set the DU1 pins sources. Select CRTC 0 if explicitly requested and
-* CRTC 1 in all other cases to avoid cloning CRTC 0 to DU0 and DU1 by
-* default.
-*/
-   if (rcrtc->outputs & (1 << 1) && rcrtc->index == 0)
-   dorcr |= DORCR_PG2D_DS1;
-   else
-   dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2;
-
-   rcar_du_write(rcdu, DORCR, dorcr);
-}
-
 void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output)
 {
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
@@ -245,7 +226,7 @@ static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)

/* Configure display timings and output routing */
rcar_du_crtc_set_display_timing(rcrtc);
-   rcar_du_crtc_set_routing(rcrtc);
+   rcar_du_group_set_routing(rcrtc->group);

mutex_lock(>group->planes.lock);
rcrtc->plane->enabled = true;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 625b9f4..7e75451 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -125,3 +125,22 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp)
__rcar_du_group_start_stop(rgrp, false);
__rcar_du_group_start_stop(rgrp, true);
 }
+
+void rcar_du_group_set_routing(struct rcar_du_group *rgrp)
+{
+   struct rcar_du_crtc *crtc0 = >dev->crtcs[rgrp->index * 2];
+   u32 dorcr = rcar_du_group_read(rgrp, DORCR);
+
+   dorcr &= ~(DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_MASK);
+
+   /* Set the DU1 pins sources. Select CRTC 0 if explicitly requested and
+* CRTC 1 in all other cases to avoid cloning CRTC 0 to DU0 and DU1 by
+* default.
+*/
+   if (crtc0->outputs & (1 << 1))
+   dorcr |= DORCR_PG2D_DS1;
+   else
+   dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2;
+
+   rcar_du_group_write(rgrp, DORCR, dorcr);
+}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h 
b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index 748331b..180c739 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -42,6 +42,6 @@ int rcar_du_group_get(struct rcar_du_group *rgrp);
 void rcar_du_group_put(struct rcar_du_group *rgrp);
 void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start);
 void rcar_du_group_restart(struct rcar_du_group *rgrp);
-
+void rcar_du_group_set_routing(struct rcar_du_group *rgrp);

 #endif /* __RCAR_DU_GROUP_H__ */
-- 
1.8.1.5



[PATCH 16/24] drm/rcar-du: Remove register definitions for the second channel

2013-06-27 Thread Laurent Pinchart
Channels are accessed through a global channel memory offset, there's no
need to define register addresses for the second channel.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_regs.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index 3aba27f..195ed7e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -20,7 +20,6 @@
  */

 #define DSYSR  0x0 /* display 1 */
-#define D2SYSR 0x3 /* display 2 */
 #define DSYSR_ILTS (1 << 29)
 #define DSYSR_DSEC (1 << 20)
 #define DSYSR_IUPD (1 << 16)
@@ -35,7 +34,6 @@
 #define DSYSR_SCM_INT_VIDEO(3 << 4)

 #define DSMR   0x4
-#define D2SMR  0x30004
 #define DSMR_VSPM  (1 << 28)
 #define DSMR_ODPM  (1 << 27)
 #define DSMR_DIPM_DISP (0 << 25)
@@ -60,7 +58,6 @@
 #define DSMR_CSY_MASK  (3 << 6)

 #define DSSR   0x8
-#define D2SSR  0x30008
 #define DSSR_VC1FB_DSA0(0 << 30)
 #define DSSR_VC1FB_DSA1(1 << 30)
 #define DSSR_VC1FB_DSA2(2 << 30)
@@ -80,7 +77,6 @@
 #define DSSR_ADC(n)(1 << ((n)-1))

 #define DSRCR  0xc
-#define D2SRCR 0x3000c
 #define DSRCR_TVCL (1 << 15)
 #define DSRCR_FRCL (1 << 14)
 #define DSRCR_VBCL (1 << 11)
@@ -90,7 +86,6 @@
 #define DSRCR_MASK 0xcbff

 #define DIER   0x00010
-#define D2IER  0x30010
 #define DIER_TVE   (1 << 15)
 #define DIER_FRE   (1 << 14)
 #define DIER_VBE   (1 << 11)
@@ -114,7 +109,6 @@
 #define DPPR_BPP32 (DPPR_BPP32_P1 | DPPR_BPP32_P2) /* plane1 & 2 */

 #define DEFR   0x00020
-#define D2EFR  0x30020
 #define DEFR_CODE  (0x7773 << 16)
 #define DEFR_EXSL  (1 << 12)
 #define DEFR_EXVL  (1 << 11)
@@ -137,12 +131,10 @@
 #define DCPCR_DCE  (1 << 0)

 #define DEFR2  0x00034
-#define D2EFR2 0x30034
 #define DEFR2_CODE (0x7775 << 16)
 #define DEFR2_DEFE2G   (1 << 0)

 #define DEFR3  0x00038
-#define D2EFR3 0x30038
 #define DEFR3_CODE (0x7776 << 16)
 #define DEFR3_EVDA (1 << 14)
 #define DEFR3_EVDM_1   (1 << 12)
@@ -153,7 +145,6 @@
 #define DEFR3_DEFE3(1 << 0)

 #define DEFR4  0x0003c
-#define D2EFR4 0x3003c
 #define DEFR4_CODE (0x << 16)
 #define DEFR4_LRUO (1 << 5)
 #define DEFR4_SPCE (1 << 4)
-- 
1.8.1.5



[PATCH 15/24] drm/rcar-du: Use dynamic number of CRTCs instead of CRTCs array size

2013-06-27 Thread Laurent Pinchart
The rcar_du_device structure contains a field that stores the number of
CRTCs, use it instead of the CRTCs array size. This prepares the driver
to support a variable number of CRTCs.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 5e4168d..fe61962 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -105,7 +105,7 @@ static void rcar_du_preclose(struct drm_device *dev, struct 
drm_file *file)
struct rcar_du_device *rcdu = dev->dev_private;
unsigned int i;

-   for (i = 0; i < ARRAY_SIZE(rcdu->crtcs); ++i)
+   for (i = 0; i < rcdu->num_crtcs; ++i)
rcar_du_crtc_cancel_page_flip(>crtcs[i], file);
 }

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index c32e0f9..845bcb3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -197,7 +197,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
if (pdata->type == RCAR_DU_ENCODER_UNUSED)
continue;

-   if (pdata->output >= ARRAY_SIZE(rcdu->crtcs)) {
+   if (pdata->output >= rcdu->num_crtcs) {
dev_warn(rcdu->dev,
 "encoder %u references unexisting output %u, 
skipping\n",
 i, pdata->output);
-- 
1.8.1.5



[PATCH 14/24] drm/rcar-du: Introduce CRTCs groups

2013-06-27 Thread Laurent Pinchart
The R8A7779 DU is split in per-CRTC resources (scan-out engine, blending
unit, timings generator, ...) and device-global resources (start/stop
control, planes, ...) shared between the two CRTCs.

The R8A7790 introduced a third CRTC with its own set of global resources
This would be modeled as two separate DU device instances if it wasn't
for a handful or resources that are shared between the three CRTCs
(mostly related to input and output routing). For this reason the
R8A7790 DU must be modeled as a single device with three CRTCs, two sets
of "semi-global" resources, and a few device-global resources.

Introduce a new rcar_du_group driver-specific object, without any real
counterpart in the DU documentation, that models those semi-global
resources.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Makefile|   1 +
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  92 ++-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h  |   5 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   |  46 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |  10 +--
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 127 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  47 ++
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  11 ++-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 155 
 drivers/gpu/drm/rcar-du/rcar_du_plane.h |   8 +-
 10 files changed, 299 insertions(+), 203 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.h

diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 57b0fe1..b9b5e66 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -1,6 +1,7 @@
 rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_drv.o \
 rcar_du_encoder.o \
+rcar_du_group.o \
 rcar_du_kms.o \
 rcar_du_lvdscon.o \
 rcar_du_plane.o \
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 03dd701..7784a3b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -30,21 +30,21 @@

 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   struct rcar_du_device *rcdu = rcrtc->group->dev;

return rcar_du_read(rcdu, rcrtc->mmio_offset + reg);
 }

 static void rcar_du_crtc_write(struct rcar_du_crtc *rcrtc, u32 reg, u32 data)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   struct rcar_du_device *rcdu = rcrtc->group->dev;

rcar_du_write(rcdu, rcrtc->mmio_offset + reg, data);
 }

 static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   struct rcar_du_device *rcdu = rcrtc->group->dev;

rcar_du_write(rcdu, rcrtc->mmio_offset + reg,
  rcar_du_read(rcdu, rcrtc->mmio_offset + reg) & ~clr);
@@ -52,7 +52,7 @@ static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 
reg, u32 clr)

 static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   struct rcar_du_device *rcdu = rcrtc->group->dev;

rcar_du_write(rcdu, rcrtc->mmio_offset + reg,
  rcar_du_read(rcdu, rcrtc->mmio_offset + reg) | set);
@@ -61,7 +61,7 @@ static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 
reg, u32 set)
 static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg,
 u32 clr, u32 set)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   struct rcar_du_device *rcdu = rcrtc->group->dev;
u32 value = rcar_du_read(rcdu, rcrtc->mmio_offset + reg);

rcar_du_write(rcdu, rcrtc->mmio_offset + reg, (value & ~clr) | set);
@@ -69,14 +69,13 @@ static void rcar_du_crtc_clr_set(struct rcar_du_crtc 
*rcrtc, u32 reg,

 static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
int ret;

ret = clk_prepare_enable(rcrtc->clock);
if (ret < 0)
return ret;

-   ret = rcar_du_get(rcdu);
+   ret = rcar_du_group_get(rcrtc->group);
if (ret < 0)
clk_disable_unprepare(rcrtc->clock);

@@ -85,17 +84,14 @@ static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc)

 static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
-
-   rcar_du_put(rcdu);
+   rcar_du_group_put(rcrtc->group);
clk_disable_unprepare(rcrtc->clock);
 }

 static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
 {
-   struct drm_crtc 

[PATCH 13/24] drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_*

2013-06-27 Thread Laurent Pinchart
The functions initialize or register all planes, rename them
accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 4 ++--
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 4 ++--
 drivers/gpu/drm/rcar-du/rcar_du_plane.h | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index a8eef16..a1343fb 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -174,7 +174,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
rcdu->ddev->mode_config.max_height = 2047;
rcdu->ddev->mode_config.funcs = _du_mode_config_funcs;

-   ret = rcar_du_plane_init(rcdu);
+   ret = rcar_du_planes_init(rcdu);
if (ret < 0)
return ret;

@@ -215,7 +215,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
encoder->possible_clones = 1 << 0;
}

-   ret = rcar_du_plane_register(rcdu);
+   ret = rcar_du_planes_register(rcdu);
if (ret < 0)
return ret;

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index 38ebd20..29f2147 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -435,7 +435,7 @@ static const uint32_t formats[] = {
DRM_FORMAT_NV16,
 };

-int rcar_du_plane_init(struct rcar_du_device *rcdu)
+int rcar_du_planes_init(struct rcar_du_device *rcdu)
 {
unsigned int i;

@@ -475,7 +475,7 @@ int rcar_du_plane_init(struct rcar_du_device *rcdu)
return 0;
 }

-int rcar_du_plane_register(struct rcar_du_device *rcdu)
+int rcar_du_planes_register(struct rcar_du_device *rcdu)
 {
unsigned int i;
int ret;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index 5c8488c..bcf6f76 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -67,8 +67,9 @@ struct rcar_du_planes {
struct drm_property *zpos;
 };

-int rcar_du_plane_init(struct rcar_du_device *rcdu);
-int rcar_du_plane_register(struct rcar_du_device *rcdu);
+int rcar_du_planes_init(struct rcar_du_device *rcdu);
+int rcar_du_planes_register(struct rcar_du_device *rcdu);
+
 void rcar_du_plane_setup(struct rcar_du_plane *plane);
 void rcar_du_plane_update_base(struct rcar_du_plane *plane);
 void rcar_du_plane_compute_base(struct rcar_du_plane *plane,
-- 
1.8.1.5



[PATCH 12/24] drm/rcar-du: Create rcar_du_planes structure

2013-06-27 Thread Laurent Pinchart
Move the plane-related fields of struct rcar_du_device to their own
structure.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   | 11 +--
 drivers/gpu/drm/rcar-du/rcar_du_plane.h | 17 +++--
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 7d2320f..0305c21 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -15,7 +15,6 @@
 #define __RCAR_DU_DRV_H__

 #include 
-#include 
 #include 

 #include "rcar_du_crtc.h"
@@ -49,15 +48,7 @@ struct rcar_du_device {
unsigned int used_crtcs;
unsigned int num_crtcs;

-   struct {
-   struct rcar_du_plane planes[RCAR_DU_NUM_SW_PLANES];
-   unsigned int free;
-   struct mutex lock;
-
-   struct drm_property *alpha;
-   struct drm_property *colorkey;
-   struct drm_property *zpos;
-   } planes;
+   struct rcar_du_planes planes;
 };

 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index 5397dba..5c8488c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -14,8 +14,11 @@
 #ifndef __RCAR_DU_PLANE_H__
 #define __RCAR_DU_PLANE_H__

-struct drm_crtc;
-struct drm_framebuffer;
+#include 
+
+#include 
+#include 
+
 struct rcar_du_device;
 struct rcar_du_format_info;

@@ -54,6 +57,16 @@ struct rcar_du_plane {
unsigned int dst_y;
 };

+struct rcar_du_planes {
+   struct rcar_du_plane planes[RCAR_DU_NUM_SW_PLANES];
+   unsigned int free;
+   struct mutex lock;
+
+   struct drm_property *alpha;
+   struct drm_property *colorkey;
+   struct drm_property *zpos;
+};
+
 int rcar_du_plane_init(struct rcar_du_device *rcdu);
 int rcar_du_plane_register(struct rcar_du_device *rcdu);
 void rcar_du_plane_setup(struct rcar_du_plane *plane);
-- 
1.8.1.5



[PATCH 11/24] drm/rcar-du: Rename platform data fields to match what they describe

2013-06-27 Thread Laurent Pinchart
The struct rcar_du_encoder_data encoder::field describes the encoder
type, and the rcar_du_encoder_lvds_data and rcar_du_encoder_vga_data
structures describe connector properties. Rename them accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  3 ++-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |  5 ++---
 include/linux/platform_data/rcar-du.h | 19 +--
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index 15a5643..0d0375c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -137,7 +137,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
switch (type) {
case RCAR_DU_ENCODER_LVDS:
return rcar_du_lvds_connector_init(rcdu, renc,
-  >u.lvds.panel);
+  >connector.lvds.panel);

case RCAR_DU_ENCODER_VGA:
return rcar_du_vga_connector_init(rcdu, renc);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
index 4f76e16..08cde12 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
@@ -14,10 +14,11 @@
 #ifndef __RCAR_DU_ENCODER_H__
 #define __RCAR_DU_ENCODER_H__

+#include 
+
 #include 

 struct rcar_du_device;
-struct rcar_du_encoder_data;

 struct rcar_du_encoder {
struct drm_encoder encoder;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 3f8483c..a8eef16 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -191,7 +191,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
const struct rcar_du_encoder_data *pdata =
>pdata->encoders[i];

-   if (pdata->encoder == RCAR_DU_ENCODER_UNUSED)
+   if (pdata->type == RCAR_DU_ENCODER_UNUSED)
continue;

if (pdata->output >= ARRAY_SIZE(rcdu->crtcs)) {
@@ -201,8 +201,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
continue;
}

-   rcar_du_encoder_init(rcdu, pdata->encoder, pdata->output,
-pdata);
+   rcar_du_encoder_init(rcdu, pdata->type, pdata->output, pdata);
}

/* Set the possible CRTCs and possible clones. All encoders can be
diff --git a/include/linux/platform_data/rcar-du.h 
b/include/linux/platform_data/rcar-du.h
index 80587fd..64cd863 100644
--- a/include/linux/platform_data/rcar-du.h
+++ b/include/linux/platform_data/rcar-du.h
@@ -28,22 +28,29 @@ struct rcar_du_panel_data {
struct drm_mode_modeinfo mode;
 };

-struct rcar_du_encoder_lvds_data {
+struct rcar_du_connector_lvds_data {
struct rcar_du_panel_data panel;
 };

-struct rcar_du_encoder_vga_data {
+struct rcar_du_connector_vga_data {
/* TODO: Add DDC information for EDID retrieval */
 };

+/*
+ * struct rcar_du_encoder_data - Encoder platform data
+ * @type: the encoder type (RCAR_DU_ENCODER_*)
+ * @output: the DU output the connector is connected to
+ * @connector.lvds: platform data for LVDS connectors
+ * @connector.vga: platform data for VGA connectors
+ */
 struct rcar_du_encoder_data {
-   enum rcar_du_encoder_type encoder;
+   enum rcar_du_encoder_type type;
unsigned int output;

union {
-   struct rcar_du_encoder_lvds_data lvds;
-   struct rcar_du_encoder_vga_data vga;
-   } u;
+   struct rcar_du_connector_lvds_data lvds;
+   struct rcar_du_connector_vga_data vga;
+   } connector;
 };

 struct rcar_du_platform_data {
-- 
1.8.1.5



[PATCH 10/24] drm/rcar-du: Merge LVDS and VGA encoder code

2013-06-27 Thread Laurent Pinchart
Create a single rcar_du_encoder structure that implements a KMS encoder.
The current implementation is straightforward and only configures CRTC
output routing.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Makefile  |   3 +-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c|   2 -
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 148 ++
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  45 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |  49 ++
 drivers/gpu/drm/rcar-du/rcar_du_kms.h |  29 +-
 drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 100 
 drivers/gpu/drm/rcar-du/rcar_du_lvds.h|  24 -
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c |   1 +
 drivers/gpu/drm/rcar-du/rcar_du_vga.c |  67 --
 drivers/gpu/drm/rcar-du/rcar_du_vga.h |  24 -
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c  |   1 +
 12 files changed, 205 insertions(+), 288 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.h
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.h
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.h

diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 45a8479..57b0fe1 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -1,10 +1,9 @@
 rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_drv.o \
+rcar_du_encoder.o \
 rcar_du_kms.o \
-rcar_du_lvds.o \
 rcar_du_lvdscon.o \
 rcar_du_plane.o \
-rcar_du_vga.o \
 rcar_du_vgacon.o

 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index aefc8a0..03dd701 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -23,10 +23,8 @@
 #include "rcar_du_crtc.h"
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
-#include "rcar_du_lvds.h"
 #include "rcar_du_plane.h"
 #include "rcar_du_regs.h"
-#include "rcar_du_vga.h"

 #define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
new file mode 100644
index 000..15a5643
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -0,0 +1,148 @@
+/*
+ * rcar_du_encoder.c  --  R-Car Display Unit Encoder
+ *
+ * Copyright (C) 2013 Renesas Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart at ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+
+#include "rcar_du_drv.h"
+#include "rcar_du_encoder.h"
+#include "rcar_du_kms.h"
+#include "rcar_du_lvdscon.h"
+#include "rcar_du_vgacon.h"
+
+/* 
-
+ * Common connector functions
+ */
+
+struct drm_encoder *
+rcar_du_connector_best_encoder(struct drm_connector *connector)
+{
+   struct rcar_du_connector *rcon = to_rcar_connector(connector);
+
+   return >encoder->encoder;
+}
+
+/* 
-
+ * Encoder
+ */
+
+static void rcar_du_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+}
+
+static bool rcar_du_encoder_mode_fixup(struct drm_encoder *encoder,
+  const struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted_mode)
+{
+   const struct drm_display_mode *panel_mode;
+   struct drm_device *dev = encoder->dev;
+   struct drm_connector *connector;
+   bool found = false;
+
+   /* DAC encoders have currently no restriction on the mode. */
+   if (encoder->encoder_type == DRM_MODE_ENCODER_DAC)
+   return true;
+
+   list_for_each_entry(connector, >mode_config.connector_list, head) {
+   if (connector->encoder == encoder) {
+   found = true;
+   break;
+   }
+   }
+
+   if (!found) {
+   dev_dbg(dev->dev, "mode_fixup: no connector found\n");
+   return false;
+   }
+
+   if (list_empty(>modes)) {
+   dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+   return false;
+   }
+
+   panel_mode = list_first_entry(>modes,
+ struct drm_display_mode, head);
+
+   /* We're not allowed to 

[PATCH 09/24] drm/rcar-du: Split VGA encoder and connector

2013-06-27 Thread Laurent Pinchart
This prepares for the encoders rework.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Makefile |  3 +-
 drivers/gpu/drm/rcar-du/rcar_du_vga.c| 86 +
 drivers/gpu/drm/rcar-du/rcar_du_vga.h|  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 95 
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h | 23 
 5 files changed, 123 insertions(+), 86 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h

diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 5def510..45a8479 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -4,6 +4,7 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_lvds.o \
 rcar_du_lvdscon.o \
 rcar_du_plane.o \
-rcar_du_vga.o
+rcar_du_vga.o \
+rcar_du_vgacon.o

 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vga.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vga.c
index 327289e..369ab32 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vga.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vga.c
@@ -1,5 +1,5 @@
 /*
- * rcar_du_vga.c  --  R-Car Display Unit VGA DAC and Connector
+ * rcar_du_vga.c  --  R-Car Display Unit VGA DAC
  *
  * Copyright (C) 2013 Renesas Corporation
  *
@@ -18,89 +18,7 @@
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_vga.h"
-
-/* 
-
- * Connector
- */
-
-static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
-{
-   return 0;
-}
-
-static int rcar_du_vga_connector_mode_valid(struct drm_connector *connector,
-   struct drm_display_mode *mode)
-{
-   return MODE_OK;
-}
-
-static const struct drm_connector_helper_funcs connector_helper_funcs = {
-   .get_modes = rcar_du_vga_connector_get_modes,
-   .mode_valid = rcar_du_vga_connector_mode_valid,
-   .best_encoder = rcar_du_connector_best_encoder,
-};
-
-static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
-{
-   drm_sysfs_connector_remove(connector);
-   drm_connector_cleanup(connector);
-}
-
-static enum drm_connector_status
-rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
-{
-   return connector_status_unknown;
-}
-
-static const struct drm_connector_funcs connector_funcs = {
-   .dpms = drm_helper_connector_dpms,
-   .detect = rcar_du_vga_connector_detect,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = rcar_du_vga_connector_destroy,
-};
-
-static int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
- struct rcar_du_encoder *renc)
-{
-   struct rcar_du_connector *rcon;
-   struct drm_connector *connector;
-   int ret;
-
-   rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
-   if (rcon == NULL)
-   return -ENOMEM;
-
-   connector = >connector;
-   connector->display_info.width_mm = 0;
-   connector->display_info.height_mm = 0;
-
-   ret = drm_connector_init(rcdu->ddev, connector, _funcs,
-DRM_MODE_CONNECTOR_VGA);
-   if (ret < 0)
-   return ret;
-
-   drm_connector_helper_add(connector, _helper_funcs);
-   ret = drm_sysfs_connector_add(connector);
-   if (ret < 0)
-   return ret;
-
-   drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-   drm_object_property_set_value(>base,
-   rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
-
-   ret = drm_mode_connector_attach_encoder(connector, >encoder);
-   if (ret < 0)
-   return ret;
-
-   connector->encoder = >encoder;
-   rcon->encoder = renc;
-
-   return 0;
-}
-
-/* 
-
- * Encoder
- */
+#include "rcar_du_vgacon.h"

 static void rcar_du_vga_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vga.h 
b/drivers/gpu/drm/rcar-du/rcar_du_vga.h
index 66b4d2d..b969b20 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vga.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vga.h
@@ -1,5 +1,5 @@
 /*
- * rcar_du_vga.h  --  R-Car Display Unit VGA DAC and Connector
+ * rcar_du_vga.h  --  R-Car Display Unit VGA DAC
  *
  * Copyright (C) 2013 Renesas Corporation
  *
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
new file mode 100644
index 000..2ee3203
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
@@ -0,0 +1,95 @@
+/*
+ * rcar_du_vgacon.c  --  R-Car Display Unit VGA Connector
+ *
+ * Copyright (C) 2013 Renesas 

[PATCH 08/24] drm/rcar-du: Split LVDS encoder and connector

2013-06-27 Thread Laurent Pinchart
This prepares for the encoders rework.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Makefile  |   1 +
 drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 120 +--
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 129 ++
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h |  25 ++
 4 files changed, 157 insertions(+), 118 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h

diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 7333c00..5def510 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -2,6 +2,7 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_drv.o \
 rcar_du_kms.o \
 rcar_du_lvds.o \
+rcar_du_lvdscon.o \
 rcar_du_plane.o \
 rcar_du_vga.o

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c
index 7aefe72..82e5157 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c
@@ -1,5 +1,5 @@
 /*
- * rcar_du_lvds.c  --  R-Car Display Unit LVDS Encoder and Connector
+ * rcar_du_lvds.c  --  R-Car Display Unit LVDS Encoder
  *
  * Copyright (C) 2013 Renesas Corporation
  *
@@ -18,123 +18,7 @@
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_lvds.h"
-
-struct rcar_du_lvds_connector {
-   struct rcar_du_connector connector;
-
-   const struct rcar_du_panel_data *panel;
-};
-
-#define to_rcar_lvds_connector(c) \
-   container_of(c, struct rcar_du_lvds_connector, connector.connector)
-
-/* 
-
- * Connector
- */
-
-static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector)
-{
-   struct rcar_du_lvds_connector *lvdscon = 
to_rcar_lvds_connector(connector);
-   struct drm_display_mode *mode;
-
-   mode = drm_mode_create(connector->dev);
-   if (mode == NULL)
-   return 0;
-
-   mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
-   mode->clock = lvdscon->panel->mode.clock;
-   mode->hdisplay = lvdscon->panel->mode.hdisplay;
-   mode->hsync_start = lvdscon->panel->mode.hsync_start;
-   mode->hsync_end = lvdscon->panel->mode.hsync_end;
-   mode->htotal = lvdscon->panel->mode.htotal;
-   mode->vdisplay = lvdscon->panel->mode.vdisplay;
-   mode->vsync_start = lvdscon->panel->mode.vsync_start;
-   mode->vsync_end = lvdscon->panel->mode.vsync_end;
-   mode->vtotal = lvdscon->panel->mode.vtotal;
-   mode->flags = lvdscon->panel->mode.flags;
-
-   drm_mode_set_name(mode);
-   drm_mode_probed_add(connector, mode);
-
-   return 1;
-}
-
-static int rcar_du_lvds_connector_mode_valid(struct drm_connector *connector,
-   struct drm_display_mode *mode)
-{
-   return MODE_OK;
-}
-
-static const struct drm_connector_helper_funcs connector_helper_funcs = {
-   .get_modes = rcar_du_lvds_connector_get_modes,
-   .mode_valid = rcar_du_lvds_connector_mode_valid,
-   .best_encoder = rcar_du_connector_best_encoder,
-};
-
-static void rcar_du_lvds_connector_destroy(struct drm_connector *connector)
-{
-   drm_sysfs_connector_remove(connector);
-   drm_connector_cleanup(connector);
-}
-
-static enum drm_connector_status
-rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force)
-{
-   return connector_status_connected;
-}
-
-static const struct drm_connector_funcs connector_funcs = {
-   .dpms = drm_helper_connector_dpms,
-   .detect = rcar_du_lvds_connector_detect,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = rcar_du_lvds_connector_destroy,
-};
-
-static int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
-  struct rcar_du_encoder *renc,
-  const struct rcar_du_panel_data *panel)
-{
-   struct rcar_du_lvds_connector *lvdscon;
-   struct drm_connector *connector;
-   int ret;
-
-   lvdscon = devm_kzalloc(rcdu->dev, sizeof(*lvdscon), GFP_KERNEL);
-   if (lvdscon == NULL)
-   return -ENOMEM;
-
-   lvdscon->panel = panel;
-
-   connector = >connector.connector;
-   connector->display_info.width_mm = panel->width_mm;
-   connector->display_info.height_mm = panel->height_mm;
-
-   ret = drm_connector_init(rcdu->ddev, connector, _funcs,
-DRM_MODE_CONNECTOR_LVDS);
-   if (ret < 0)
-   return ret;
-
-   drm_connector_helper_add(connector, _helper_funcs);
-   ret = drm_sysfs_connector_add(connector);
-   if (ret < 0)
-   return ret;
-
-   

[PATCH 07/24] drm/rcar-du: Clarify comment regarding plane Y source coordinate

2013-06-27 Thread Laurent Pinchart
The R8A7790 DU documentation contains further information regarding the
plane Y source coordinate. Update the comment accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index a65f81d..38ebd20 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -103,9 +103,12 @@ void rcar_du_plane_update_base(struct rcar_du_plane *plane)
struct rcar_du_device *rcdu = plane->dev;
unsigned int index = plane->hwindex;

-   /* According to the datasheet the Y position is expressed in raster line
-* units. However, 32bpp formats seem to require a doubled Y position
-* value. Similarly, for the second plane, NV12 and NV21 formats seem to
+   /* The Y position is expressed in raster line units and must be doubled
+* for 32bpp formats, according to the R8A7790 datasheet. No mention of
+* doubling the Y position is found in the R8A7779 datasheet, but the
+* rule seems to apply there as well.
+*
+* Similarly, for the second plane, NV12 and NV21 formats seem to
 * require a halved Y position value.
 */
rcar_du_plane_write(rcdu, index, PnSPXR, plane->src_x);
-- 
1.8.1.5



[PATCH 06/24] drm/rcar-du: Fix buffer pitch alignment

2013-06-27 Thread Laurent Pinchart
The DU requires a 16 pixels pitch alignement. Make sure dumb buffers are
allocated with the correct pitch, and validate the pitch when creating
frame buffers.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 19 ++-
 drivers/gpu/drm/rcar-du/rcar_du_kms.h |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 2a85056..bcda2e0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -200,7 +200,7 @@ static struct drm_driver rcar_du_driver = {
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import   = drm_gem_cma_dmabuf_import,
.gem_prime_export   = drm_gem_cma_dmabuf_export,
-   .dumb_create= drm_gem_cma_dumb_create,
+   .dumb_create= rcar_du_dumb_create,
.dumb_map_offset= drm_gem_cma_dumb_map_offset,
.dumb_destroy   = drm_gem_cma_dumb_destroy,
.fops   = _du_fops,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 06cacf6..d30c2e2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -138,11 +138,25 @@ void rcar_du_encoder_mode_commit(struct drm_encoder 
*encoder)
  * Frame buffer
  */

+int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
+   struct drm_mode_create_dumb *args)
+{
+   unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+   unsigned int align;
+
+   /* The pitch must be aligned to a 16 pixels boundary. */
+   align = 16 * args->bpp / 8;
+   args->pitch = roundup(max(args->pitch, min_pitch), align);
+
+   return drm_gem_cma_dumb_create(file, dev, args);
+}
+
 static struct drm_framebuffer *
 rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
  struct drm_mode_fb_cmd2 *mode_cmd)
 {
const struct rcar_du_format_info *format;
+   unsigned int align;

format = rcar_du_format_info(mode_cmd->pixel_format);
if (format == NULL) {
@@ -151,7 +165,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file 
*file_priv,
return ERR_PTR(-EINVAL);
}

-   if (mode_cmd->pitches[0] & 15 || mode_cmd->pitches[0] >= 8192) {
+   align = 16 * format->bpp / 8;
+
+   if (mode_cmd->pitches[0] & (align - 1) ||
+   mode_cmd->pitches[0] >= 8192) {
dev_dbg(dev->dev, "invalid pitch value %u\n",
mode_cmd->pitches[0]);
return ERR_PTR(-EINVAL);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
index e4d8db0..dba4722 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
@@ -56,4 +56,7 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder);

 int rcar_du_modeset_init(struct rcar_du_device *rcdu);

+int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
+   struct drm_mode_create_dumb *args);
+
 #endif /* __RCAR_DU_KMS_H__ */
-- 
1.8.1.5



[PATCH 05/24] drm/rcar-du: Support per-CRTC clock and IRQ

2013-06-27 Thread Laurent Pinchart
Some of the DU revisions use one clock and IRQ per CRTC instead of one
clock and IRQ per device. Retrieve the correct clock and register the
correct IRQ for each CRTC.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 120 +
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  52 +++---
 drivers/gpu/drm/rcar-du/rcar_du_drv.h  |   3 +-
 4 files changed, 103 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 24183fb..aefc8a0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -69,6 +69,30 @@ static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, 
u32 reg,
rcar_du_write(rcdu, rcrtc->mmio_offset + reg, (value & ~clr) | set);
 }

+static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc)
+{
+   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+   int ret;
+
+   ret = clk_prepare_enable(rcrtc->clock);
+   if (ret < 0)
+   return ret;
+
+   ret = rcar_du_get(rcdu);
+   if (ret < 0)
+   clk_disable_unprepare(rcrtc->clock);
+
+   return ret;
+}
+
+static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc)
+{
+   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
+
+   rcar_du_put(rcdu);
+   clk_disable_unprepare(rcrtc->clock);
+}
+
 static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
 {
struct drm_crtc *crtc = >crtc;
@@ -79,7 +103,7 @@ static void rcar_du_crtc_set_display_timing(struct 
rcar_du_crtc *rcrtc)
u32 div;

/* Dot clock */
-   clk = clk_get_rate(rcdu->clock);
+   clk = clk_get_rate(rcrtc->clock);
div = DIV_ROUND_CLOSEST(clk, mode->clock * 1000);
div = clamp(div, 1U, 64U) - 1;

@@ -313,20 +337,16 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)

 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
-
rcar_du_crtc_stop(rcrtc);
-   rcar_du_put(rcdu);
+   rcar_du_crtc_put(rcrtc);
 }

 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
 {
-   struct rcar_du_device *rcdu = rcrtc->crtc.dev->dev_private;
-
if (rcrtc->dpms != DRM_MODE_DPMS_ON)
return;

-   rcar_du_get(rcdu);
+   rcar_du_crtc_get(rcrtc);
rcar_du_crtc_start(rcrtc);
 }

@@ -340,18 +360,17 @@ static void rcar_du_crtc_update_base(struct rcar_du_crtc 
*rcrtc)

 static void rcar_du_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-   struct rcar_du_device *rcdu = crtc->dev->dev_private;
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);

if (rcrtc->dpms == mode)
return;

if (mode == DRM_MODE_DPMS_ON) {
-   rcar_du_get(rcdu);
+   rcar_du_crtc_get(rcrtc);
rcar_du_crtc_start(rcrtc);
} else {
rcar_du_crtc_stop(rcrtc);
-   rcar_du_put(rcdu);
+   rcar_du_crtc_put(rcrtc);
}

rcrtc->dpms = mode;
@@ -367,13 +386,12 @@ static bool rcar_du_crtc_mode_fixup(struct drm_crtc *crtc,

 static void rcar_du_crtc_mode_prepare(struct drm_crtc *crtc)
 {
-   struct rcar_du_device *rcdu = crtc->dev->dev_private;
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);

/* We need to access the hardware during mode set, acquire a reference
-* to the DU.
+* to the CRTC.
 */
-   rcar_du_get(rcdu);
+   rcar_du_crtc_get(rcrtc);

/* Stop the CRTC and release the plane. Force the DPMS mode to off as a
 * result.
@@ -423,10 +441,10 @@ static int rcar_du_crtc_mode_set(struct drm_crtc *crtc,

 error:
/* There's no rollback/abort operation to clean up in case of error. We
-* thus need to release the reference to the DU acquired in prepare()
+* thus need to release the reference to the CRTC acquired in prepare()
 * here.
 */
-   rcar_du_put(rcdu);
+   rcar_du_crtc_put(rcrtc);
return ret;
 }

@@ -514,6 +532,24 @@ static void rcar_du_crtc_finish_page_flip(struct 
rcar_du_crtc *rcrtc)
drm_vblank_put(dev, rcrtc->index);
 }

+static irqreturn_t rcar_du_crtc_irq(int irq, void *arg)
+{
+   struct rcar_du_crtc *rcrtc = arg;
+   irqreturn_t ret = IRQ_NONE;
+   u32 status;
+
+   status = rcar_du_crtc_read(rcrtc, DSSR);
+   rcar_du_crtc_write(rcrtc, DSRCR, status & DSRCR_MASK);
+
+   if (status & DSSR_VBK) {
+   drm_handle_vblank(rcrtc->crtc.dev, rcrtc->index);
+   rcar_du_crtc_finish_page_flip(rcrtc);
+   ret = IRQ_HANDLED;
+   }
+
+   return ret;
+}
+
 static int rcar_du_crtc_page_flip(struct drm_crtc *crtc,
  struct drm_framebuffer *fb,
 

[PATCH 04/24] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value

2013-06-27 Thread Laurent Pinchart
Handle error cases correctly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 9c63f39..06cacf6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -191,8 +191,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
if (ret < 0)
return ret;

-   for (i = 0; i < ARRAY_SIZE(rcdu->crtcs); ++i)
-   rcar_du_crtc_create(rcdu, i);
+   for (i = 0; i < ARRAY_SIZE(rcdu->crtcs); ++i) {
+   ret = rcar_du_crtc_create(rcdu, i);
+   if (ret < 0)
+   return ret;
+   }

rcdu->used_crtcs = 0;
rcdu->num_crtcs = i;
-- 
1.8.1.5



[PATCH 03/24] drm/rcar-du: Add platform module device table

2013-06-27 Thread Laurent Pinchart
The platform device id driver data field points to a device information
structure that only contains a (currently empty) features field for now.
Support for additional model-dependent features will be added later.

Only the R8A7779 variant is currently supported.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 13 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.h | 15 +++
 2 files changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 24ab0ca..d705990 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -123,6 +123,7 @@ static int rcar_du_load(struct drm_device *dev, unsigned 
long flags)

rcdu->dev = >dev;
rcdu->pdata = pdata;
+   rcdu->info = (struct rcar_du_device_info *)pdev->id_entry->driver_data;
rcdu->ddev = dev;
dev->dev_private = rcdu;

@@ -292,6 +293,17 @@ static int rcar_du_remove(struct platform_device *pdev)
return 0;
 }

+static const struct rcar_du_device_info rcar_du_r8a7779_info = {
+   .features = 0,
+};
+
+static const struct platform_device_id rcar_du_id_table[] = {
+   { "rcar-du-r8a7779", (kernel_ulong_t)_du_r8a7779_info },
+   { }
+};
+
+MODULE_DEVICE_TABLE(platform, rcar_du_id_table);
+
 static struct platform_driver rcar_du_platform_driver = {
.probe  = rcar_du_probe,
.remove = rcar_du_remove,
@@ -300,6 +312,7 @@ static struct platform_driver rcar_du_platform_driver = {
.name   = "rcar-du",
.pm = _du_pm_ops,
},
+   .id_table   = rcar_du_id_table,
 };

 module_platform_driver(rcar_du_platform_driver);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 193cc59..06dbf4f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -25,9 +25,18 @@ struct clk;
 struct device;
 struct drm_device;

+/*
+ * struct rcar_du_device_info - DU model-specific information
+ * @features: device features (RCAR_DU_FEATURE_*)
+ */
+struct rcar_du_device_info {
+   unsigned int features;
+};
+
 struct rcar_du_device {
struct device *dev;
const struct rcar_du_platform_data *pdata;
+   const struct rcar_du_device_info *info;

void __iomem *mmio;
struct clk *clock;
@@ -50,6 +59,12 @@ struct rcar_du_device {
} planes;
 };

+static inline bool rcar_du_has(struct rcar_du_device *rcdu,
+  unsigned int feature)
+{
+   return rcdu->info->features & feature;
+}
+
 int rcar_du_get(struct rcar_du_device *rcdu);
 void rcar_du_put(struct rcar_du_device *rcdu);

-- 
1.8.1.5



[PATCH 02/24] drm/rcar-du: Use devm_ioremap_resource()

2013-06-27 Thread Laurent Pinchart
Replace the devm_request_mem_region() and devm_ioremap_nocache() calls
with devm_ioremap_resource().

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 003b34e..24ab0ca 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -107,7 +107,6 @@ static int rcar_du_load(struct drm_device *dev, unsigned 
long flags)
struct platform_device *pdev = dev->platformdev;
struct rcar_du_platform_data *pdata = pdev->dev.platform_data;
struct rcar_du_device *rcdu;
-   struct resource *ioarea;
struct resource *mem;
int ret;

@@ -129,24 +128,9 @@ static int rcar_du_load(struct drm_device *dev, unsigned 
long flags)

/* I/O resources and clocks */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (mem == NULL) {
-   dev_err(>dev, "failed to get memory resource\n");
-   return -EINVAL;
-   }
-
-   ioarea = devm_request_mem_region(>dev, mem->start,
-resource_size(mem), pdev->name);
-   if (ioarea == NULL) {
-   dev_err(>dev, "failed to request memory region\n");
-   return -EBUSY;
-   }
-
-   rcdu->mmio = devm_ioremap_nocache(>dev, ioarea->start,
- resource_size(ioarea));
-   if (rcdu->mmio == NULL) {
-   dev_err(>dev, "failed to remap memory resource\n");
+   rcdu->mmio = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(rcdu->mmio))
return -ENOMEM;
-   }

rcdu->clock = devm_clk_get(>dev, NULL);
if (IS_ERR(rcdu->clock)) {
-- 
1.8.1.5



[PATCH 01/24] drm/rcar-du: Add missing alpha plane register definitions

2013-06-27 Thread Laurent Pinchart
Several alpha plane register definitions are missing, add them.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_regs.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index 69f21f1..3aba27f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -349,10 +349,25 @@
 #define APnMR_BM_AD(2 << 4)/* Auto Display Change Mode */

 #define APnMWR 0x0a104
+
+#define APnDSXR0x0a110
+#define APnDSYR0x0a114
+#define APnDPXR0x0a118
+#define APnDPYR0x0a11c
+
 #define APnDSA0R   0x0a120
 #define APnDSA1R   0x0a124
 #define APnDSA2R   0x0a128
+
+#define APnSPXR0x0a130
+#define APnSPYR0x0a134
+#define APnWASPR   0x0a138
+#define APnWAMWR   0x0a13c
+
+#define APnBTR 0x0a140
+
 #define APnMLR 0x0a150
+#define APnSWAPR   0x0a180

 /* 
-
  * Display Capture Registers
-- 
1.8.1.5



[PATCH 00/24] R-Car DU DRM support for R8A7790

2013-06-27 Thread Laurent Pinchart
Hello,

Here's a set of patches that adds support for the DU found in the R8A7790 SoC.

Compared to the R8A7779 DU, the R8A7790 has a third CRTC, internal LVDS
encoders and different output routing options.

These patches are targetted at v3.12 so there's no rush (but please don't take
that as an excuse to skip reviewing them :-)).

Laurent Pinchart (24):
  drm/rcar-du: Add missing alpha plane register definitions
  drm/rcar-du: Use devm_ioremap_resource()
  drm/rcar-du: Add platform module device table
  drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
  drm/rcar-du: Support per-CRTC clock and IRQ
  drm/rcar-du: Fix buffer pitch alignment
  drm/rcar-du: Clarify comment regarding plane Y source coordinate
  drm/rcar-du: Split LVDS encoder and connector
  drm/rcar-du: Split VGA encoder and connector
  drm/rcar-du: Merge LVDS and VGA encoder code
  drm/rcar-du: Rename platform data fields to match what they describe
  drm/rcar-du: Create rcar_du_planes structure
  drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_*
  drm/rcar-du: Introduce CRTCs groups
  drm/rcar-du: Use dynamic number of CRTCs instead of CRTCs array size
  drm/rcar-du: Remove register definitions for the second channel
  drm/rcar-du: Move output routing configuration to group
  drm/rcar-du: Add support for the R8A7790 DU
  drm/rcar-du: Fix buffer pitch alignment for R8A7790 DU
  drm/rcar-du: Add support for multiple groups
  drm/rcar-du: Add support for DEFR8 register
  drm/rcar-du: Rework output routing support
  drm/rcar-du: Configure RGB output routing to DPAD0
  drm/rcar-du: Add internal LVDS encoder support

 drivers/gpu/drm/rcar-du/Kconfig   |   7 +
 drivers/gpu/drm/rcar-du/Makefile  |  10 +-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 255 --
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h|  13 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 169 
 drivers/gpu/drm/rcar-du/rcar_du_drv.h |  61 +--
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 202 +++
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  49 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.c   | 187 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.h   |  50 ++
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 135 +---
 drivers/gpu/drm/rcar-du/rcar_du_kms.h |  32 +---
 drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 216 -
 drivers/gpu/drm/rcar-du/rcar_du_lvds.h|  24 ---
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 130 +++
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h |  25 +++
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 194 +++
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h |  46 ++
 drivers/gpu/drm/rcar-du/rcar_du_plane.c   | 170 ++--
 drivers/gpu/drm/rcar-du/rcar_du_plane.h   |  26 ++-
 drivers/gpu/drm/rcar-du/rcar_du_regs.h|  94 +--
 drivers/gpu/drm/rcar-du/rcar_du_vga.c | 149 -
 drivers/gpu/drm/rcar-du/rcar_du_vga.h |  24 ---
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c  |  96 +++
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h  |  23 +++
 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h  |  69 
 include/linux/platform_data/rcar-du.h |  34 +++-
 27 files changed, 1639 insertions(+), 851 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.h
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h

-- 
Regards,

Laurent Pinchart



[PATCH v6 08/23] modetest: Add a command line parameter to set properties

2013-06-27 Thread Ville Syrjälä
On Thu, Jun 27, 2013 at 10:10:43AM +0200, Laurent Pinchart wrote:
> Hi Ville,
> 
> Thank you for the review.
> 
> On Monday 24 June 2013 18:08:37 Ville Syrj?l? wrote:
> > On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote:
> > > The -w parameter can be used to set a property value from the command
> > > line, using the target object ID and the property name.
> > > 
> > > Signed-off-by: Laurent Pinchart 
> > > ---
> > > 
> > >  tests/modetest/modetest.c | 108 -
> > >  1 file changed, 106 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> > > index 778af62..858d480 100644
> > > --- a/tests/modetest/modetest.c
> > > +++ b/tests/modetest/modetest.c
> > 
> > 
> > 
> > > @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const
> > > char *arg)> 
> > >   return 0;
> > >  
> > >  }
> > > 
> > > +static int parse_property(struct property_arg *p, const char *arg)
> > > +{
> > > + if (sscanf(arg, "%d:%32[^:]:%" SCNu64, >obj_id, p->name, 
> >value)
> > > != 3)
> > nit: could use stringification to get rid of the magic number 32 here.
> 
> What do you mean exactly ?

Something like this:

#define str(x) #x
#define xstr(x) str(x)
sscanf(arg, "%d:%" xstr(DRM_PROP_NAME_LEN) "[^:]:%" SCNu64, ...

Although it does make it a bit hard to parse for a human.

-- 
Ville Syrj?l?
Intel OTC


[PATCH v6 08/23] modetest: Add a command line parameter to set properties

2013-06-27 Thread Laurent Pinchart
On Thursday 27 June 2013 11:31:48 Ville Syrj?l? wrote:
> On Thu, Jun 27, 2013 at 10:10:43AM +0200, Laurent Pinchart wrote:
> > On Monday 24 June 2013 18:08:37 Ville Syrj?l? wrote:
> > > On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote:
> > > > The -w parameter can be used to set a property value from the command
> > > > line, using the target object ID and the property name.
> > > > 
> > > > Signed-off-by: Laurent Pinchart 
> > > > ---
> > > > 
> > > >  tests/modetest/modetest.c | 108 -
> > > >  1 file changed, 106 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> > > > index 778af62..858d480 100644
> > > > --- a/tests/modetest/modetest.c
> > > > +++ b/tests/modetest/modetest.c
> > > 
> > > 
> > > 
> > > > @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p,
> > > > const char *arg)
> > > > return 0;
> > > >  }
> > > > 
> > > > +static int parse_property(struct property_arg *p, const char *arg)
> > > > +{
> > > > +   if (sscanf(arg, "%d:%32[^:]:%" SCNu64, >obj_id, p->name, 
> > >
> > >value)
> > >
> > > > != 3)
> > > 
> > > nit: could use stringification to get rid of the magic number 32 here.
> > 
> > What do you mean exactly ?
> 
> Something like this:
> 
> #define str(x) #x
> #define xstr(x) str(x)
> sscanf(arg, "%d:%" xstr(DRM_PROP_NAME_LEN) "[^:]:%" SCNu64, ...
> 
> Although it does make it a bit hard to parse for a human.

Right. I'm fine with both. "%m[^:]" might be an interesting alternative 
option.

-- 
Regards,

Laurent Pinchart



[PATCH] gpu/host1x: Remove DRIVER_BUS_PLATFORM from driver_features

2013-06-27 Thread Laurent Pinchart
Hi Thierry,

On Wednesday 29 May 2013 12:50:40 Thierry Reding wrote:
> On Wed, May 29, 2013 at 07:44:34AM +0200, Laurent Pinchart wrote:
> > From: Laurent Pinchart 
> > 
> > DRIVER_BUS_PLATFORM is not a DRM driver feature flag, it must not be set
> > in the driver's driver_features field.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/gpu/host1x/drm/drm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Applied, thanks. I did modify the subject's prefix to "drm/tegra: " for
> consistency, though.

Do you plan to push the patch to v3.11 through Dave's tree ? I can't find it 
in drm-next.

-- 
Regards,

Laurent Pinchart



Armada DRM driver on OLPC XO

2013-06-27 Thread Russell King - ARM Linux
On Tue, Jun 25, 2013 at 04:47:26PM -0400, Daniel Drake wrote:
> Hi Russell,
> 
> Thanks a lot for writing the Armada DRM driver.
> 
> I have tested it on OLPC XO-1.75 (MMP2 aka Armada610) and OLPC XO-4 (MMP3
> aka PXA2128). After a bit of fighting, I have it running. Could you share your
> X driver, or your methodology for testing hardware cursors? I'd like to test
> your work there too.
> 
> It's probably easiest to get your cubox driver merged before adding MMP2/MMP3
> complications into the mix. At that point, I will hopefully have time to
> follow up developing MMP2/MMP3 support, which will involve the points
> mentioned below.

As a side note, you've looked at a previous generation of the patches -
in that same thread, there are two versions of these patches.  The original
set was an older version that I mis-posted.

The later version removes the clock handling for the LCDs out of
armada_crtc.c into armada_drv.c.


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Alex Deucher
On Thu, Jun 27, 2013 at 9:12 AM, Andy Furniss  wrote:
> Alex Deucher wrote:
>>
>> On Wed, Jun 26, 2013 at 9:21 AM,   wrote:
>>>
>>> From: Alex Deucher 
>>>
>>> These are the radeon patches for 3.11.  Some of these patches
>>> are huge so, it might be easier to review things here:
>>> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip
>>
>>
>> Updated branch:
>> http://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-3.11-wip-2
>> Takes into account comments from Jerome a Christian and contains a few
>> DPM fixes.
>
>
> I see there's a 3 now - I tested that (I guess currently it's the same as 2
> anyway).
>
> On my rv790 there are no regressions so far, but whatever I do it stays low.
>

We may need to tweak the scaling parameters a bit to force higher
states more readily.  They are pretty conservative right now.

> echo profile > /sys/class/drm/card0/device/power_method = write error, is
> there a way to go back to manual setting with dpm?

Not yet.  I'm working on an infrastructure to force DPM modes, but
it's not ready yet.

>
> I haven't tried rv670 yet - I couldn't see a new firmware for that, does it
> just not need one?
>

Nope.  6xx and APUs do not require ucode.  only 7xx+ dGPUs.

Alex


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Jerome Glisse
On Wed, Jun 26, 2013 at 6:51 PM, Julian Wollrath  wrote:
> Hi,
>
>> I just tried the DPM support out on a E-450 APU (HD6320) and it did
>> not work like expected. In the terminal everything seemed ok but when
>> I started a display manager, the screen showed garbage and the system
>> basically locked up. The radeon and drm related parts of the syslog
>> are below.
> I saw, that you updated the patches, therefore I tried out the branch
> drm-next-3.11-wip-2 and I got, additionally to the problem mentioned in
> my first e-mail, the following warning:
>
> [   14.274349] [ cut here ]
> [   14.274369] WARNING: at kernel/workqueue.c:1365 __queue_work+0x260/0x2c0()
> [   14.274374] Modules linked in: bluetooth crc16 acpi_cpufreq 
> snd_hda_codec_hdmi iwlwifi uvcvideo mperf radeon(+) videobuf2_vmalloc 
> cfg80211 snd_hda_intel(+) battery processor button thinkpad_acpi video nvram 
> rfkill videobuf2_memops videobuf2_core videodev snd_hda_codec kvm_amd 
> i2c_algo_bit kvm snd_hwdep snd_pcm snd_timer snd_page_alloc ac drm_kms_helper 
> ttm snd drm soundcore wmi i2c_piix4 agpgart pcspkr i2c_core evdev k10temp 
> psmouse serio_raw sha256_ssse3 sha256_generic twofish_x86_64_3way glue_helper 
> xts lrw gf128mul twofish_x86_64 twofish_common cbc dm_crypt dm_mod sd_mod 
> crc_t10dif rtsx_pci_sdmmc mmc_core microcode thermal thermal_sys ahci libahci 
> ohci_hcd ehci_pci ehci_hcd rtsx_pci mfd_core usbcore usb_common libata 
> scsi_mod
> [   14.274517] CPU: 1 PID: 497 Comm: modprobe Not tainted 3.10.0-rc7-wl+ #3
> [   14.274524] Hardware name: LENOVO 30515YG/30515YG, BIOS 8RET52WW (1.15 ) 
> 11/15/2011
> [   14.274530]  813fc83e 81037a7a 88011ec12540 
> 88011ed15d00
> [   14.274539]  8801164a5bc8 0002 88011e060a00 
> 81053590
> [   14.274548]  0002 8801164a5e9c 0001 
> 0010
> [   14.274558] Call Trace:
> [   14.274563][] ? dump_stack+0xc/0x15
> [   14.274582]  [] ? warn_slowpath_common+0x6a/0xa0
> [   14.274594]  [] ? __queue_work+0x260/0x2c0
> [   14.274605]  [] ? queue_work_on+0x1d/0x30
> [   14.274703]  [] ? evergreen_irq_process+0x906/0xd20 
> [radeon]
> [   14.274715]  [] ? handle_irq_event_percpu+0x2d/0x1a0
> [   14.274724]  [] ? handle_irq_event+0x36/0x60
> [   14.274734]  [] ? handle_edge_irq+0x67/0x110
> [   14.274743]  [] ? handle_irq+0x15/0x20
> [   14.274751]  [] ? do_IRQ+0x51/0xd0
> [   14.274761]  [] ? common_interrupt+0x6a/0x6a
> [   14.274765][] ? delay_tsc+0x29/0x60
> [   14.274850]  [] ? sumo_set_uvd_clock+0x8a/0xb0 [radeon]
> [   14.274926]  [] ? sumo_set_uvd_clocks+0x4d/0xe0 [radeon]
> [   14.274999]  [] ? r600_uvd_init+0x25/0x390 [radeon]
> [   14.275073]  [] ? evergreen_startup+0x1952/0x1960 
> [radeon]
> [   14.275146]  [] ? evergreen_init+0x17b/0x2c0 [radeon]
> [   14.275208]  [] ? radeon_device_init+0x5b5/0x6d0 [radeon]
> [   14.275219]  [] ? pci_find_capability+0x45/0x60
> [   14.275279]  [] ? radeon_driver_load_kms+0x84/0x140 
> [radeon]
> [   14.275303]  [] ? drm_get_pci_dev+0x17d/0x290 [drm]
> [   14.275314]  [] ? pci_device_probe+0x98/0xe0
> [   14.275325]  [] ? driver_probe_device+0x68/0x210
> [   14.275333]  [] ? __driver_attach+0x93/0xa0
> [   14.275341]  [] ? __device_attach+0x60/0x60
> [   14.275351]  [] ? bus_for_each_dev+0x53/0x90
> [   14.275359]  [] ? bus_add_driver+0x1c0/0x250
> [   14.275367]  [] ? driver_register+0x69/0x140
> [   14.275380]  [] ? 0xa050afff
> [   14.275390]  [] ? 0xa050afff
> [   14.275399]  [] ? do_one_initcall+0x10a/0x160
> [   14.275408]  [] ? load_module+0x1cd8/0x2390
> [   14.275416]  [] ? store_uevent+0x50/0x50
> [   14.275427]  [] ? SyS_init_module+0xb8/0xe0
> [   14.275438]  [] ? system_call_fastpath+0x16/0x1b
> [   14.275444] ---[ end trace 1f1cbf85b14e84a1 ]---
>
> With best regards,
> Julian Wollrath


This patch should fix your issue :

http://people.freedesktop.org/~glisse/0001-radeon-do-no-schedule-thermal-work-if-dpm-is-not-ena.patch

Cheers,
Jerome


[PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj

2013-06-27 Thread Rob Clark
On Wed, Jun 26, 2013 at 7:39 PM, Seung-Woo Kim  
wrote:
> From: YoungJun Cho 
>
> The drm_gem_mmap_obj() has to be protected with dev->struct_mutex,
> but some caller functions do not. So it adds mutex lock to missing
> callers and adds assertion to check whether drm_gem_mmap_obj() is
> called with mutex lock or not.

Yeah, looks like since drm_gem_mmap_obj() is using
drm_vm_open_locked() (vs drm_vm_open() / vm_ops->open()), we need
this.  I missed that when reviewing the original patch to
drm_gem_mmap_obj()'ify things.

Reviewed-by: Rob Clark 


> Signed-off-by: YoungJun Cho 
> Signed-off-by: Seung-Woo Kim 
> Signed-off-by: Kyungmin Park 
> CC: Laurent Pinchart 
> CC: Rob Clark 
> ---
> This patch is based on drm-next branch.
>
> Changes since v1:
> - Use lockdep_assert_held() instead of mutex_is_locked() as Maarten commented
> - Fix commit message about assertion
>
>  drivers/gpu/drm/drm_gem.c |4 
>  drivers/gpu/drm/drm_gem_cma_helper.c  |3 +++
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |3 +++
>  3 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 4321713..34c0be7 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -661,6 +661,8 @@ EXPORT_SYMBOL(drm_gem_vm_close);
>   * the GEM object is not looked up based on its fake offset. To implement the
>   * DRM mmap operation, drivers should use the drm_gem_mmap() function.
>   *
> + * NOTE: This function has to be protected with dev->struct_mutex
> + *
>   * Return 0 or success or -EINVAL if the object size is smaller than the VMA
>   * size, or if no gem_vm_ops are provided.
>   */
> @@ -669,6 +671,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned 
> long obj_size,
>  {
> struct drm_device *dev = obj->dev;
>
> +   lockdep_assert_held(>struct_mutex);
> +
> /* Check for valid size. */
> if (obj_size < vma->vm_end - vma->vm_start)
> return -EINVAL;
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c 
> b/drivers/gpu/drm/drm_gem_cma_helper.c
> index 9efabce..ce06397 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -487,9 +487,12 @@ static int drm_gem_cma_dmabuf_mmap(struct dma_buf 
> *dmabuf,
>  {
> struct drm_gem_cma_object *cma_obj = dmabuf->priv;
> struct drm_gem_object *gem_obj = _obj->base;
> +   struct drm_device *dev = gem_obj->dev;
> int ret;
>
> +   mutex_lock(>struct_mutex);
> ret = drm_gem_mmap_obj(gem_obj, gem_obj->size, vma);
> +   mutex_unlock(>struct_mutex);
> if (ret < 0)
> return ret;
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c 
> b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> index 3256693..4fcca8d 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> @@ -140,12 +140,15 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
> struct vm_area_struct *vma)
>  {
> struct drm_gem_object *obj = buffer->priv;
> +   struct drm_device *dev = obj->dev;
> int ret = 0;
>
> if (WARN_ON(!obj->filp))
> return -EINVAL;
>
> +   mutex_lock(>struct_mutex);
> ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
> +   mutex_unlock(>struct_mutex);
> if (ret < 0)
> return ret;
>
> --
> 1.7.9.5
>


[PATCH v6 00/23] modetest enhancements

2013-06-27 Thread Laurent Pinchart
Hi Jerome, Marek,

On Friday 14 June 2013 23:34:34 Laurent Pinchart wrote:
> Hello,
> 
> Here's the sixth (and hopefully final) version of my modeset enhancements
> patch set.
> 
> Beside various cleanups, these patches allow dropping master after mode set,
> configuring more than two pipes and planes, setting properties from the
> command line, setting plane positions and configuring pipes with multiple
> connectors in cloned mode.
> 
> The code has been tested with the R-Car DU DRM driver.

Any chance to get this series applied ?

-- 
Regards,

Laurent Pinchart



[PATCH v6 08/23] modetest: Add a command line parameter to set properties

2013-06-27 Thread Laurent Pinchart
Hi Ville,

Thank you for the review.

On Monday 24 June 2013 18:08:37 Ville Syrj?l? wrote:
> On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote:
> > The -w parameter can be used to set a property value from the command
> > line, using the target object ID and the property name.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  tests/modetest/modetest.c | 108 -
> >  1 file changed, 106 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> > index 778af62..858d480 100644
> > --- a/tests/modetest/modetest.c
> > +++ b/tests/modetest/modetest.c
> 
> 
> 
> > @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const
> > char *arg)> 
> > return 0;
> >  
> >  }
> > 
> > +static int parse_property(struct property_arg *p, const char *arg)
> > +{
> > +   if (sscanf(arg, "%d:%32[^:]:%" SCNu64, >obj_id, p->name, 
>value)
> > != 3)
> nit: could use stringification to get rid of the magic number 32 here.

What do you mean exactly ?

> I didn't spot any real problems in the series. But I must admit that I
> mainly just glanced at most of the changes in since many of the diffs
> are a bit hard to read.
> 
> I also gave it a quick try using sprites and setting a few modes. And I
> found a bug in i915 while doing that, so clearly it has already proved
> useful ;)

That's nice to know :-)

> > +   return -1;
> > +
> > +   p->obj_type = 0;
> > +   p->name[DRM_PROP_NAME_LEN] = '\0';
> > +
> > +   return 0;
> > +}
> > +
> > 
> >  static void usage(char *name)
> >  {
> > 
> > -   fprintf(stderr, "usage: %s [-cdefMmPpsv]\n", name);
> > +   fprintf(stderr, "usage: %s [-cdefMmPpsvw]\n", name);
> > 
> > fprintf(stderr, "\n Query options:\n\n");
> > fprintf(stderr, "\t-c\tlist connectors\n");
-- 
Regards,

Laurent Pinchart



[PATCH v2] drm/gem: fix not to assign error value to gem name

2013-06-27 Thread Chris Wilson
On Thu, Jun 27, 2013 at 08:58:33AM +0900, Seung-Woo Kim wrote:
> From: YoungJun Cho 
> 
> If idr_alloc() is failed, obj->name can be error value. Also
> it cleans up duplicated flink processing code.
> 
> This regression has been introduced in
> 
> commit 2e928815c1886fe628ed54623aa98d0889cf5509
> Author: Tejun Heo 
> Date:   Wed Feb 27 17:04:08 2013 -0800
> 
> drm: convert to idr_alloc()
> 
> Signed-off-by: YoungJun Cho 
> Signed-off-by: Seung-Woo Kim 
> Signed-off-by: Kyungmin Park 

Reviewed-by: Chris Wilson 

Minor comment inline.

> ---
> change since v1:
> - Add a regression commit information in commit msg as Chris commented
> 
>  drivers/gpu/drm/drm_gem.c |   18 +++---
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 4321713..c9d7081 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
>   spin_lock(>object_name_lock);
>   if (!obj->name) {
>   ret = idr_alloc(>object_name_idr, obj, 1, 0, GFP_NOWAIT);
> - obj->name = ret;
> - args->name = (uint64_t) obj->name;
> - spin_unlock(>object_name_lock);
> - idr_preload_end();
> -
>   if (ret < 0)
>   goto err;

Being pedantic, ret == 0 is also an error - but a programming error
leading to an object leak. BUG_ON(ret == 0) ?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[PATCH v2] drm/gem: fix not to assign error value to gem name

2013-06-27 Thread Seung-Woo Kim
From: YoungJun Cho 

If idr_alloc() is failed, obj->name can be error value. Also
it cleans up duplicated flink processing code.

This regression has been introduced in

commit 2e928815c1886fe628ed54623aa98d0889cf5509
Author: Tejun Heo 
Date:   Wed Feb 27 17:04:08 2013 -0800

drm: convert to idr_alloc()

Signed-off-by: YoungJun Cho 
Signed-off-by: Seung-Woo Kim 
Signed-off-by: Kyungmin Park 
---
change since v1:
- Add a regression commit information in commit msg as Chris commented

 drivers/gpu/drm/drm_gem.c |   18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4321713..c9d7081 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
spin_lock(>object_name_lock);
if (!obj->name) {
ret = idr_alloc(>object_name_idr, obj, 1, 0, GFP_NOWAIT);
-   obj->name = ret;
-   args->name = (uint64_t) obj->name;
-   spin_unlock(>object_name_lock);
-   idr_preload_end();
-
if (ret < 0)
goto err;
-   ret = 0;
+
+   obj->name = ret;

/* Allocate a reference for the name table.  */
drm_gem_object_reference(obj);
-   } else {
-   args->name = (uint64_t) obj->name;
-   spin_unlock(>object_name_lock);
-   idr_preload_end();
-   ret = 0;
}

+   args->name = (uint64_t) obj->name;
+   ret = 0;
+
 err:
+   spin_unlock(>object_name_lock);
+   idr_preload_end();
drm_gem_object_unreference_unlocked(obj);
return ret;
 }
-- 
1.7.9.5



[PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj

2013-06-27 Thread Seung-Woo Kim
From: YoungJun Cho 

The drm_gem_mmap_obj() has to be protected with dev->struct_mutex,
but some caller functions do not. So it adds mutex lock to missing
callers and adds assertion to check whether drm_gem_mmap_obj() is
called with mutex lock or not.

Signed-off-by: YoungJun Cho 
Signed-off-by: Seung-Woo Kim 
Signed-off-by: Kyungmin Park 
CC: Laurent Pinchart 
CC: Rob Clark 
---
This patch is based on drm-next branch.

Changes since v1:
- Use lockdep_assert_held() instead of mutex_is_locked() as Maarten commented
- Fix commit message about assertion

 drivers/gpu/drm/drm_gem.c |4 
 drivers/gpu/drm/drm_gem_cma_helper.c  |3 +++
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |3 +++
 3 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4321713..34c0be7 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -661,6 +661,8 @@ EXPORT_SYMBOL(drm_gem_vm_close);
  * the GEM object is not looked up based on its fake offset. To implement the
  * DRM mmap operation, drivers should use the drm_gem_mmap() function.
  *
+ * NOTE: This function has to be protected with dev->struct_mutex
+ *
  * Return 0 or success or -EINVAL if the object size is smaller than the VMA
  * size, or if no gem_vm_ops are provided.
  */
@@ -669,6 +671,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned 
long obj_size,
 {
struct drm_device *dev = obj->dev;

+   lockdep_assert_held(>struct_mutex);
+
/* Check for valid size. */
if (obj_size < vma->vm_end - vma->vm_start)
return -EINVAL;
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c 
b/drivers/gpu/drm/drm_gem_cma_helper.c
index 9efabce..ce06397 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -487,9 +487,12 @@ static int drm_gem_cma_dmabuf_mmap(struct dma_buf *dmabuf,
 {
struct drm_gem_cma_object *cma_obj = dmabuf->priv;
struct drm_gem_object *gem_obj = _obj->base;
+   struct drm_device *dev = gem_obj->dev;
int ret;

+   mutex_lock(>struct_mutex);
ret = drm_gem_mmap_obj(gem_obj, gem_obj->size, vma);
+   mutex_unlock(>struct_mutex);
if (ret < 0)
return ret;

diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c 
b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index 3256693..4fcca8d 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -140,12 +140,15 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
struct vm_area_struct *vma)
 {
struct drm_gem_object *obj = buffer->priv;
+   struct drm_device *dev = obj->dev;
int ret = 0;

if (WARN_ON(!obj->filp))
return -EINVAL;

+   mutex_lock(>struct_mutex);
ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
+   mutex_unlock(>struct_mutex);
if (ret < 0)
return ret;

-- 
1.7.9.5



[Bug 66243] X display is shifted upwards on GMA500

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=66243

St?phane Aulery  changed:

   What|Removed |Added

   See Also||http://bugs.debian.org/7142
   ||17

-- 
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/20130627/ba13514c/attachment.html>


[Bug 66243] New: X display is shifted upwards on GMA500

2013-06-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=66243

  Priority: medium
Bug ID: 66243
  Assignee: dri-devel at lists.freedesktop.org
   Summary: X display is shifted upwards on GMA500
  Severity: normal
Classification: Unclassified
OS: Linux (All)
  Reporter: lkppo at free.fr
  Hardware: x86 (IA32)
Status: NEW
   Version: XOrg CVS
 Component: DRM/other
   Product: DRI

Created attachment 81533
  --> https://bugs.freedesktop.org/attachment.cgi?id=81533=edit
Kernel log

Dear Developer,

I went from a kernel linux-image-3.2.0-4-686-pae to kernel
linux-image-3.9-1-686-pae (on Debian testing/Jessie). Since the X display is
shifted upwards and reveals a piece of the linux console at the bottom of
screen.

I can not attach a screenshot, because utility capture buffer X server
but are not offset on the screen.

Regards,



-- Package-specific info:
** Version:
Linux version 3.9-1-686-pae (debian-kernel at lists.debian.org) (gcc version 
4.7.3
(Debian 4.7.3-4) ) #1 SMP Debian 3.9.6-1

** Command line:
BOOT_IMAGE=/boot/vmlinuz-3.9-1-686-pae
root=UUID=fea5336a-726d-4e2c-a0cc-61b633ddcbaa ro drm.debug=0x86



-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (650, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.9-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages linux-image-3.9-1-686-pae depends on:
ii  debconf [debconf-2.0]   1.5.50
ii  initramfs-tools [linux-initramfs-tool]  0.112
ii  kmod9-3
ii  linux-base  3.5
ii  module-init-tools   9-3

Versions of packages linux-image-3.9-1-686-pae recommends:
ii  firmware-linux-free  3.2
ii  libc6-i686   2.17-3

Versions of packages linux-image-3.9-1-686-pae suggests:
ii  debian-kernel-handbook  1.0.15
ii  grub-pc 1.99-27+deb7u1
ii  linux-doc-3.9   3.9.6-1

Versions of packages linux-image-3.9-1-686-pae is related to:
pn  firmware-atheros
pn  firmware-bnx2   
pn  firmware-bnx2x  
pn  firmware-brcm80211  
pn  firmware-intelwimax 
pn  firmware-ipw2x00
pn  firmware-ivtv   
pn  firmware-iwlwifi
pn  firmware-libertas   
pn  firmware-linux  
pn  firmware-linux-nonfree  
pn  firmware-myricom
pn  firmware-netxen 
pn  firmware-qlogic 
ii  firmware-ralink 0.38
ii  firmware-realtek0.38
pn  xen-hypervisor  

-- debconf information:
  linux-image-3.9-1-686-pae/prerm/removing-running-kernel-3.9-1-686-pae: true
  linux-image-3.9-1-686-pae/postinst/missing-firmware-3.9-1-686-pae:
  linux-image-3.9-1-686-pae/postinst/ignoring-ramdisk:
  linux-image-3.9-1-686-pae/postinst/depmod-error-initrd-3.9-1-686-pae: false

-- 
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/20130627/4620118c/attachment.html>


[PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj

2013-06-27 Thread Maarten Lankhorst
Op 27-06-13 01:39, Seung-Woo Kim schreef:
> From: YoungJun Cho 
>
> The drm_gem_mmap_obj() has to be protected with dev->struct_mutex,
> but some caller functions do not. So it adds mutex lock to missing
> callers and adds assertion to check whether drm_gem_mmap_obj() is
> called with mutex lock or not.
>
> Signed-off-by: YoungJun Cho 
> Signed-off-by: Seung-Woo Kim 
> Signed-off-by: Kyungmin Park 
> CC: Laurent Pinchart 
> CC: Rob Clark 
> ---
>
Reviewed-by: Maarten Lankhorst 


[RFC PATCH] dmabuf-sync: Introduce buffer synchronization framework

2013-06-27 Thread Inki Dae
2013/6/25 Jerome Glisse :
> On Tue, Jun 25, 2013 at 10:17 AM, Inki Dae  wrote:
>> 2013/6/25 Rob Clark :
>>> On Tue, Jun 25, 2013 at 5:09 AM, Inki Dae  wrote:
> that
> should be the role of kernel memory management which of course needs
> synchronization btw A and B. But in no case this should be done using
> dma-buf. dma-buf is for sharing content btw different devices not
> sharing resources.
>

 hmm, is that true? And are you sure? Then how do you think about
 reservation? the reservation also uses dma-buf with same reason as long
 as I
 know: actually, we use reservation to use dma-buf. As you may know, a
 reservation object is allocated and initialized when a buffer object is
 exported to a dma buf.
>>>
>>> no, this is why the reservation object can be passed in when you
>>> construction the dmabuf.
>>
>> Right, that way, we could use dma buf for buffer synchronization. I
>> just wanted to ask for why Jerome said that "dma-buf is for sharing
>> content btw different devices not sharing resources".
>
> From memory, the motivation of dma-buf was to done for few use case,
> among them webcam capturing frame into a buffer and having gpu using
> it directly without memcpy, or one big gpu rendering a scene into a
> buffer that is then use by low power gpu for display ie it was done to
> allow different device to operate on same data using same backing
> memory.
>
> AFAICT you seem to want to use dma-buf to create scratch buffer, ie a
> process needs to use X amount of memory for an operation, it can
> release|free this memory once its done
> and a process B can the use
> this X memory for its own operation discarding content of process A.
> presume that next frame would have the sequence repeat, process A do
> something, then process B does its thing.
> So to me it sounds like you
> want to implement global scratch buffer using the dmabuf API and that
> sounds bad to me.
>
> I know most closed driver have several pool of memory, long lived
> object, short lived object and scratch space, then user space allocate
> from one of this pool and there is synchronization done by driver
> using driver specific API to reclaim memory.
> Of course this work
> nicely if you only talking about one logic block or at very least hw
> that have one memory controller.
>
> Now if you are thinking of doing scratch buffer for several different
> device and share the memory among then you need to be aware of
> security implication, most obvious being that you don't want process B
> being able to read process A scratch memory.
> I know the argument about
> it being graphic but one day this might become gpu code and it might
> be able to insert jump to malicious gpu code.
>

If you think so, it seems like that there is *definitely* your
misunderstanding. My approach is similar to dma fence: it guarantees
that a DMA cannot access a buffer while other DMA is accessing the
buffer. I guess now some gpu drivers in mainline have been using
specific mechanism for it. And when it comes to the portion you
commented, please know that I just introduced user side mechanism for
buffer sychronization between CPU and CPU, and CPU and DMA in
addition; not implemented but just planned.

Thanks,
Inki Dae

> Cheers,
> Jerome


[PATCH 000/165] radeon drm-next patches

2013-06-27 Thread Julian Wollrath
Hi,

> I just tried the DPM support out on a E-450 APU (HD6320) and it did
> not work like expected. In the terminal everything seemed ok but when
> I started a display manager, the screen showed garbage and the system
> basically locked up. The radeon and drm related parts of the syslog
> are below.
I saw, that you updated the patches, therefore I tried out the branch
drm-next-3.11-wip-2 and I got, additionally to the problem mentioned in
my first e-mail, the following warning:

[   14.274349] [ cut here ]
[   14.274369] WARNING: at kernel/workqueue.c:1365 __queue_work+0x260/0x2c0()
[   14.274374] Modules linked in: bluetooth crc16 acpi_cpufreq 
snd_hda_codec_hdmi iwlwifi uvcvideo mperf radeon(+) videobuf2_vmalloc cfg80211 
snd_hda_intel(+) battery processor button thinkpad_acpi video nvram rfkill 
videobuf2_memops videobuf2_core videodev snd_hda_codec kvm_amd i2c_algo_bit kvm 
snd_hwdep snd_pcm snd_timer snd_page_alloc ac drm_kms_helper ttm snd drm 
soundcore wmi i2c_piix4 agpgart pcspkr i2c_core evdev k10temp psmouse serio_raw 
sha256_ssse3 sha256_generic twofish_x86_64_3way glue_helper xts lrw gf128mul 
twofish_x86_64 twofish_common cbc dm_crypt dm_mod sd_mod crc_t10dif 
rtsx_pci_sdmmc mmc_core microcode thermal thermal_sys ahci libahci ohci_hcd 
ehci_pci ehci_hcd rtsx_pci mfd_core usbcore usb_common libata scsi_mod
[   14.274517] CPU: 1 PID: 497 Comm: modprobe Not tainted 3.10.0-rc7-wl+ #3
[   14.274524] Hardware name: LENOVO 30515YG/30515YG, BIOS 8RET52WW (1.15 ) 
11/15/2011
[   14.274530]  813fc83e 81037a7a 88011ec12540 
88011ed15d00
[   14.274539]  8801164a5bc8 0002 88011e060a00 
81053590
[   14.274548]  0002 8801164a5e9c 0001 
0010
[   14.274558] Call Trace:
[   14.274563][] ? dump_stack+0xc/0x15
[   14.274582]  [] ? warn_slowpath_common+0x6a/0xa0
[   14.274594]  [] ? __queue_work+0x260/0x2c0
[   14.274605]  [] ? queue_work_on+0x1d/0x30
[   14.274703]  [] ? evergreen_irq_process+0x906/0xd20 
[radeon]
[   14.274715]  [] ? handle_irq_event_percpu+0x2d/0x1a0
[   14.274724]  [] ? handle_irq_event+0x36/0x60
[   14.274734]  [] ? handle_edge_irq+0x67/0x110
[   14.274743]  [] ? handle_irq+0x15/0x20
[   14.274751]  [] ? do_IRQ+0x51/0xd0
[   14.274761]  [] ? common_interrupt+0x6a/0x6a
[   14.274765][] ? delay_tsc+0x29/0x60
[   14.274850]  [] ? sumo_set_uvd_clock+0x8a/0xb0 [radeon]
[   14.274926]  [] ? sumo_set_uvd_clocks+0x4d/0xe0 [radeon]
[   14.274999]  [] ? r600_uvd_init+0x25/0x390 [radeon]
[   14.275073]  [] ? evergreen_startup+0x1952/0x1960 [radeon]
[   14.275146]  [] ? evergreen_init+0x17b/0x2c0 [radeon]
[   14.275208]  [] ? radeon_device_init+0x5b5/0x6d0 [radeon]
[   14.275219]  [] ? pci_find_capability+0x45/0x60
[   14.275279]  [] ? radeon_driver_load_kms+0x84/0x140 
[radeon]
[   14.275303]  [] ? drm_get_pci_dev+0x17d/0x290 [drm]
[   14.275314]  [] ? pci_device_probe+0x98/0xe0
[   14.275325]  [] ? driver_probe_device+0x68/0x210
[   14.275333]  [] ? __driver_attach+0x93/0xa0
[   14.275341]  [] ? __device_attach+0x60/0x60
[   14.275351]  [] ? bus_for_each_dev+0x53/0x90
[   14.275359]  [] ? bus_add_driver+0x1c0/0x250
[   14.275367]  [] ? driver_register+0x69/0x140
[   14.275380]  [] ? 0xa050afff
[   14.275390]  [] ? 0xa050afff
[   14.275399]  [] ? do_one_initcall+0x10a/0x160
[   14.275408]  [] ? load_module+0x1cd8/0x2390
[   14.275416]  [] ? store_uevent+0x50/0x50
[   14.275427]  [] ? SyS_init_module+0xb8/0xe0
[   14.275438]  [] ? system_call_fastpath+0x16/0x1b
[   14.275444] ---[ end trace 1f1cbf85b14e84a1 ]---

With best regards,
Julian Wollrath


  1   2   3   >