[PATCH 3/3] drm/gma500: Code cleanup - removal of centralized exiting of function

2014-03-13 Thread Arthur Borsboom
Removed centralized exiting of function (goto statement), since it was the only 
used in one single location with only a return statement.

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index ae95e31..8d6ad6c 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -182,12 +182,9 @@ static int psb_do_init(struct drm_device *dev)

uint32_t stolen_gtt;

-   int ret = -ENOMEM;
-
if (pg->mmu_gatt_start & 0x0FFF) {
dev_err(dev->dev, "Gatt must be 256M aligned. This is a 
bug.\n");
-   ret = -EINVAL;
-   goto out_err;
+   return -EINVAL;
}

stolen_gtt = (pg->stolen_size >> PAGE_SHIFT) * 4;
@@ -210,8 +207,6 @@ static int psb_do_init(struct drm_device *dev)
/* mmu_gatt ?? */
PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
return 0;
-out_err:
-   return ret;
 }

 static int psb_driver_unload(struct drm_device *dev)
-- 
1.9.0



[PATCH 2/3] drm/gma500: Code cleanup - style fixes

2014-03-13 Thread Arthur Borsboom
Cleanup of code by following i915 constant/variable names and ordering
Cleanup of code by following directions from kernel documentation: Codingstyle
Cleanup of code by following directions from kernel documentation: DRM

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 132 +++
 drivers/gpu/drm/gma500/psb_drv.h |  39 
 2 files changed, 77 insertions(+), 94 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 5c6cdd0..ae95e31 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -37,9 +37,11 @@
 #include 
 #include 

+static struct drm_driver driver;
+
 static int drm_psb_trap_pagefaults;

-static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent);

 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
@@ -62,44 +64,43 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops },
 #if defined(CONFIG_DRM_GMA600)
-   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
-   /* Atom E620 */
-   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops},
+   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
+   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
_chip_ops },
 #endif
 #if defined(CONFIG_DRM_MEDFIELD)
-   {0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   {0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
+   { 0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
+   { 0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops 
},
 #endif
 #if defined(CONFIG_DRM_GMA3600)
-   { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0be9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0bea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0beb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 0x0bec, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops},
-   { 0x8086, 

[PATCH 1/3] drm/gma500: Code cleanup - inline documentation

2014-03-13 Thread Arthur Borsboom
Improve readability by adding/changing inline documentation

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 56 +---
 drivers/gpu/drm/gma500/psb_drv.h | 24 +++--
 2 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1199180..5c6cdd0 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -44,7 +44,20 @@ static int psb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);

-
+/*
+ * The table below contains a mapping of the PCI vendor ID and the PCI Device 
ID
+ * to the different groups of PowerVR 5-series chip designs
+ *
+ * 0x8086 = Intel Corporation
+ *
+ * PowerVR SGX535- Poulsbo- Intel GMA 500, Intel Atom Z5xx
+ * PowerVR SGX535- Moorestown - Intel GMA 600
+ * PowerVR SGX535- Oaktrail   - Intel GMA 600, Intel Atom Z6xx, E6xx
+ * PowerVR SGX540- Medfield   - Intel Atom Z2460
+ * PowerVR SGX544MP2 - Medfield   -
+ * PowerVR SGX545- Cedartrail - Intel GMA 3600, Intel Atom D2500, N2600
+ * PowerVR SGX545- Cedartrail - Intel GMA 3650, Intel Atom D2550, D2700, 
N2800
+ */
 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) _chip_ops },
@@ -207,8 +220,7 @@ static int psb_driver_unload(struct drm_device *dev)
 {
struct drm_psb_private *dev_priv = dev->dev_private;

-   /* Kill vblank etc here */
-
+   /* TODO: Kill vblank etc here */

if (dev_priv) {
if (dev_priv->backlight_device)
@@ -268,7 +280,22 @@ static int psb_driver_unload(struct drm_device *dev)
return 0;
 }

-
+/*
+ * psb_driver_load - setup chip and create an initial config
+ * @dev: DRM device
+ * @flags: startup flags, containing the driver_data field belonging to
+ * the PCI device ID
+ *
+ * The driver load routine has to do several things:
+ *   - allocating and initializing driver private data
+ *   - performing resource allocation and mapping
+ *   - initialize the memory manager
+ *   - setup the DRM framebuffer with the allocated memory
+ *   - install the IRQ handler
+ *   - setup vertical blanking handling
+ *   - mode setting
+ *   - set inital output configuration
+ */
 static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 {
struct drm_psb_private *dev_priv;
@@ -278,6 +305,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long chipset)
struct drm_connector *connector;
struct gma_encoder *gma_encoder;

+   /* allocating and initializing driver private data */
dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
if (dev_priv == NULL)
return -ENOMEM;
@@ -369,6 +397,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long chipset)

acpi_video_register();

+   /*
+* Setup vertical blanking handling
+*/
ret = drm_vblank_init(dev, dev_priv->num_pipe);
if (ret)
goto out_err;
@@ -416,11 +447,11 @@ static int psb_driver_load(struct drm_device *dev, 
unsigned long chipset)
return ret;
psb_intel_opregion_enable_asle(dev);
 #if 0
-   /*enable runtime pm at last*/
+   /* Enable runtime pm at last */
pm_runtime_enable(>pdev->dev);
pm_runtime_set_active(>pdev->dev);
 #endif
-   /*Intel drm driver load is done, continue doing pvr load*/
+   /* Intel drm driver load is done, continue doing pvr load */
return 0;
 out_err:
psb_driver_unload(dev);
@@ -561,7 +592,7 @@ static int psb_mode_operation_ioctl(struct drm_device *dev, 
void *data,
arg->data = resp;
}

-   /*do some clean up work*/
+   /* Do some clean up work */
if (mode)
drm_mode_destroy(dev, mode);
 mode_op_out:
@@ -614,8 +645,8 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned 
int cmd,
/* FIXME: do we need to wrap the other side of this */
 }

-
-/* When a client dies:
+/*
+ * When a client dies:
  *- Check for and clean up flipped page state
  */
 static void psb_driver_preclose(struct drm_device *dev, struct drm_file *priv)
@@ -655,6 +686,13 @@ static const struct file_operations psb_gem_fops = {
.read = drm_read,
 };

+/*
+ * DRM driver structure initialization
+ *
+ * The drm_driver structure contains static information that describes
+ * the driver and features it supports, and pointers to methods that DRM
+ * core will call to implement DRM API.
+ */
 static struct drm_driver driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \

[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread Daniel Vetter
On Thu, Mar 13, 2014 at 1:28 PM, Thomas Hellstrom  
wrote:
> But a compiler can't (or shouldn't) make that assumption. Just as an
> (adapted) example, imagine that
> each test had a 20% probability of returning an error. The probability
> of the function returning an error would
> then be 68%..

Otoh if you'd put the unlikely just onto the if (ret) then the
compiler could infer that by necessity all branches leading towards
this one are also unlikely. Dunno whether compilers are this clever
though, and I also don't really care if we throw a few too many
likely/unlikely annotations over the place. Just figured I'll throw
this in.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #17 from Alex Deucher  ---
(In reply to comment #16)
> Setting radeon.runpm=0 helped. Suspend, resume work correctly now.
> 
> Which kernel version should I apply the patches to and test with? Latest git
> commit (3.14-git), or stable 3.13.x kernel code?

They are against 3.14, but they should apply to 3.13 as well.

-- 
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/20140313/45c26bd8/attachment.html>


[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #16 from Sandeep  ---
Setting radeon.runpm=0 helped. Suspend, resume work correctly now.

Which kernel version should I apply the patches to and test with? Latest git
commit (3.14-git), or stable 3.13.x kernel code?

-- 
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/20140313/79014235/attachment.html>


[PATCH v4 00/34] drm/exynos: Refactor parts of the exynos driver

2014-03-13 Thread Tomasz Figa
On 13.03.2014 16:48, Inki Dae wrote:
> Hi Tomasz,
>
> 2014-03-13 23:05 GMT+09:00 Tomasz Figa :
>> Hi Inki,
>>
>>
>> On 13.03.2014 08:33, Inki Dae wrote:
>>>
>>> Hi Sean,
>>>
>>> Merged your all patch series except for dt binding patches - it needs
>>> more cleanups about ddc and phy - and I had a little change just for
>>> cleanup.
>>> And some more cleanups and enhanced feature set on top of your patch
>>> series would be merged, and then they will go to -next.
>>
>>
>> I assume you just applied this series to your tree to a temporary branch and
>> it won't be merged until are regressions introduced by it are fixed, right?
>
> Generally right. These has been merged to exynos-drm-next so that
> other people can clean up and enhance our driver on top of the
> refactoring patch series.
> And I'm planning to have pull request if ddc and hdmi phy cleanups are
> posted from Tomasz Stanislawski. The only critical thing we should fix
> would be hdmi dt broken issue.
>
> Give me more comments if there is any critical issue we should fix for
> this cycle.

As I have already mentioned in another reply to this thread (and also 
quite a long time ago in my review comments for previous version of this 
series), refactoring of FIMD driver removes support for parallel 
displays that seems to be used by exynos4210-origen, exynos4412-origen, 
smdk5250 and smdk5420 boards, which is a regression.

Best regards,
Tomasz


[Bug 76130] Radeon HD 4570 set dpm state fails after suspend

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76130

--- Comment #2 from Alex Deucher  ---
Does this work better with a 3.14 kernel?

-- 
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/20140313/bfb2d17b/attachment.html>


[PATCH 12/12] ARM: imx_v6_v7_defconfig: Add more drm drivers.

2014-03-13 Thread Denis Carikli
The DRM_PANEL_SIMPLE is needed by the eukrea
mbimxsd51's displays.

Signed-off-by: Denis Carikli 
---
- New patch, splitting it would be overkill.
---
 arch/arm/configs/imx_v6_v7_defconfig |2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 09e9743..0316926 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -183,6 +183,7 @@ CONFIG_V4L_MEM2MEM_DRIVERS=y
 CONFIG_VIDEO_CODA=y
 CONFIG_SOC_CAMERA_OV2640=y
 CONFIG_DRM=y
+CONFIG_DRM_PANEL_SIMPLE=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_L4F00242T03=y
@@ -245,6 +246,7 @@ CONFIG_DRM_IMX_TVE=y
 CONFIG_DRM_IMX_LDB=y
 CONFIG_DRM_IMX_IPUV3_CORE=y
 CONFIG_DRM_IMX_IPUV3=y
+CONFIG_DRM_IMX_HDMI=y
 CONFIG_COMMON_CLK_DEBUG=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_PWM=y
-- 
1.7.9.5



[PATCH 11/12] ARM: dts: mbimx51sd: Add CMO-QVGA backlight support.

2014-03-13 Thread Denis Carikli
Signed-off-by: Denis Carikli 
---
ChangeLog v9->v11:
- Now uses the drm-panel instead of the display-timings.

ChangeLog v8->v9:
- Removed the Cc. They are now set in git-send-email directly.
- The backlight is now on at boot.

ChangeLog v6->v7:
- Shrinked even more the Cc list.

ChangeLog v5->v6:
- Reordered the Cc list.

ChangeLog v3->v5:
- Updated to the new GPIO defines.

ChangeLog v2->v3:
- Splitted out from the patch that added support for the cpuimx51/mbimxsd51 
boards.
- This patch now only adds backlight support.
- Added some interested people in the Cc list, and removed some people that
  might be annoyed by the receiving of that patch which is unrelated to their
  subsystem.
---
 .../imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts  |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts 
b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
index 7c280f8..4a3f805 100644
--- a/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
+++ b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
@@ -17,9 +17,19 @@
model = "Eukrea MBIMXSD51 with the CMO-QVGA Display";
compatible = "eukrea,mbimxsd51-baseboard-cmo-qvga", 
"eukrea,mbimxsd51-baseboard", "eukrea,cpuimx51", "fsl,imx51";

+   backlight: backlight {
+   compatible = "gpio-backlight";
+   pinctrl-names = "default";
+   pinctrl-0 = <_backlight_1>;
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   default-brightness-level = <1>;
+   default-on;
+   };
+
panel: panel {
compatible = "eukrea,mbimxsd51-cmo-qvga", "simple-panel";
power-supply = <_lcd_3v3>;
+   backlight = <>;
};

reg_lcd_3v3: lcd-en {
-- 
1.7.9.5



[PATCH 10/12] ARM: dts: mbimx51sd: Add display support.

2014-03-13 Thread Denis Carikli
The CMO-QVGA, DVI-SVGA and DVI-VGA are added.

Signed-off-by: Denis Carikli 
---
ChangeLog v10->v11:
- Now uses the drm-panel instead of the display-timings.
  This is to get regulator support, which is lacking in
  the imx-drm driver when using the display-timings.

ChangeLog v9->v10:
- Rebased
- Now enables the cmo-qvga regulator at boot.

ChangeLog v8->v9:
- Removed the Cc. They are now set in git-send-email directly.
- updated pixelclk-active after the following patch:
  "imx-drm: Match ipu_di_signal_cfg's clk_pol with its description."

ChangeLog v7->v8:
- Rebased the patch: added the now required imx-drm node.
- Adapted the svga clock-frequency value in order to still
  be able to display an image after the following commit:
  "imx-drm: ipu-v3: more inteligent DI clock selection"

ChangeLog v6->v7:
- Shrinked even more the Cc list.
- Since the pingrp headers were removed, the references
  to it where replaced by the actual pins.
- Added the targets to arch/arm/boot/dts/Makefile

ChangeLog v5->v6:
- Reordered the Cc list.

ChangeLog v3->v5:
- Updated to new GPIO defines.
- Updated to new licenses checkpatch requirements.
- one whitespace cleanup.

ChangeLog v2->v3:
- Splitted out from the patch that added support for the cpuimx51/mbimxsd51 
boards.
- This patch now only adds display support.
- Added some interested people in the Cc list, and removed some people that
  might be annoyed by the receiving of that patch which is unrelated to their
  subsystem.
- rebased and reworked the dts displays addition.
- Also rebased and reworked the fsl,pins usage.
---
 arch/arm/boot/dts/Makefile |3 ++
 .../imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts  |   41 
 .../imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dts  |   28 +++
 .../imx51-eukrea-mbimxsd51-baseboard-dvi-vga.dts   |   28 +++
 .../boot/dts/imx51-eukrea-mbimxsd51-baseboard.dts  |   49 
 5 files changed, 149 insertions(+)
 create mode 100644 
arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
 create mode 100644 
arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dts
 create mode 100644 
arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-dvi-vga.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cf6c523..1f18800 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -178,6 +178,9 @@ dtb-$(CONFIG_ARCH_MXC) += \
imx51-apf51dev.dtb \
imx51-babbage.dtb \
imx51-eukrea-mbimxsd51-baseboard.dtb \
+   imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dtb \
+   imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dtb \
+   imx51-eukrea-mbimxsd51-baseboard-dvi-vga.dtb \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
diff --git a/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts 
b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
new file mode 100644
index 000..7c280f8
--- /dev/null
+++ b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-cmo-qvga.dts
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2013 Eukr?a Electromatique 
+ *
+ * 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "imx51-eukrea-mbimxsd51-baseboard.dts"
+
+/ {
+   model = "Eukrea MBIMXSD51 with the CMO-QVGA Display";
+   compatible = "eukrea,mbimxsd51-baseboard-cmo-qvga", 
"eukrea,mbimxsd51-baseboard", "eukrea,cpuimx51", "fsl,imx51";
+
+   panel: panel {
+   compatible = "eukrea,mbimxsd51-cmo-qvga", "simple-panel";
+   power-supply = <_lcd_3v3>;
+   };
+
+   reg_lcd_3v3: lcd-en {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_reg_lcd_3v3>;
+   regulator-name = "lcd-3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = < 13 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   regulator-boot-on;
+   };
+};
+
+ {
+   status = "okay";
+   fsl,panel = <>;
+};
diff --git a/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dts 
b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dts
new file mode 100644
index 000..323ebf4
--- /dev/null
+++ b/arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard-dvi-svga.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 Eukr?a Electromatique 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 

[PATCH 09/12] drm/panel: Add Eukrea mbimxsd51 displays.

2014-03-13 Thread Denis Carikli
Signed-off-by: Denis Carikli 
---
ChangeLog v10->v11:
- New patch.
---
 .../bindings/panel/eukrea,mbimxsd51-cmo-qvga.txt   |7 ++
 .../bindings/panel/eukrea,mbimxsd51-dvi-svga.txt   |7 ++
 .../bindings/panel/eukrea,mbimxsd51-dvi-vga.txt|7 ++
 drivers/gpu/drm/panel/panel-simple.c   |   81 
 4 files changed, 102 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-cmo-qvga.txt
 create mode 100644 
Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-svga.txt
 create mode 100644 
Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-vga.txt

diff --git 
a/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-cmo-qvga.txt 
b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-cmo-qvga.txt
new file mode 100644
index 000..03679d0
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-cmo-qvga.txt
@@ -0,0 +1,7 @@
+Eukrea CMO-QVGA (320x240 pixels) TFT LCD panel
+
+Required properties:
+- compatible: should be "eukrea,mbimxsd51-cmo-qvga"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git 
a/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-svga.txt 
b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-svga.txt
new file mode 100644
index 000..f408c9a
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-svga.txt
@@ -0,0 +1,7 @@
+Eukrea DVI-SVGA (800x600 pixels) DVI output.
+
+Required properties:
+- compatible: should be "eukrea,mbimxsd51-dvi-svga"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git 
a/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-vga.txt 
b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-vga.txt
new file mode 100644
index 000..8ea90da
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/eukrea,mbimxsd51-dvi-vga.txt
@@ -0,0 +1,7 @@
+Eukrea DVI-VGA (640x480 pixels) DVI output.
+
+Required properties:
+- compatible: should be "eukrea,mbimxsd51-dvi-vga"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 0231945..96918bb 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -361,6 +361,78 @@ static const struct panel_desc chunghwa_claa101wb01 = {
},
 };

+static const struct drm_display_mode eukrea_mbimxsd51_cmoqvga_mode = {
+   .clock = 6500,
+   .hdisplay = 320,
+   .hsync_start = 320 + 38,
+   .hsync_end = 320 + 38 + 20,
+   .htotal = 320 + 38 + 20 + 30,
+   .vdisplay = 240,
+   .vsync_start = 240 + 15,
+   .vsync_end = 240 + 15 + 4,
+   .vtotal = 240 + 15 + 4 + 3,
+   .vrefresh = 60,
+   .pol_flags = DRM_MODE_FLAG_POL_PIXDATA_NEGEDGE |
+DRM_MODE_FLAG_POL_DE_NEGEDGE,
+};
+
+static const struct panel_desc eukrea_mbimxsd51_cmoqvga = {
+   .modes = _mbimxsd51_cmoqvga_mode,
+   .num_modes = 1,
+   .size = {
+   .width = 73,
+   .height = 56,
+   },
+};
+
+static const struct drm_display_mode eukrea_mbimxsd51_dvisvga_mode = {
+   .clock = 44333,
+   .hdisplay = 800,
+   .hsync_start = 800 + 112,
+   .hsync_end = 800 + 112 + 32,
+   .htotal = 800 + 112 + 32 + 80,
+   .vdisplay = 600,
+   .vsync_start = 600 + 3,
+   .vsync_end = 600 + 3 + 17,
+   .vtotal = 600 + 3 + 17 + 4,
+   .vrefresh = 60,
+   .pol_flags = DRM_MODE_FLAG_POL_PIXDATA_POSEDGE |
+DRM_MODE_FLAG_POL_DE_POSEDGE,
+};
+
+static const struct panel_desc eukrea_mbimxsd51_dvisvga = {
+   .modes = _mbimxsd51_dvisvga_mode,
+   .num_modes = 1,
+   .size = {
+   .width = 0,
+   .height = 0,
+   },
+};
+
+static const struct drm_display_mode eukrea_mbimxsd51_dvivga_mode = {
+   .clock = 23750,
+   .hdisplay = 640,
+   .hsync_start = 640 + 80,
+   .hsync_end = 640 + 80 + 16,
+   .htotal = 640 + 80 + 16 + 64,
+   .vdisplay = 480,
+   .vsync_start = 480 + 3,
+   .vsync_end = 480 + 3 + 13,
+   .vtotal  = 480 + 3 + 13 + 4,
+   .vrefresh = 60,
+   .pol_flags = DRM_MODE_FLAG_POL_PIXDATA_POSEDGE |
+DRM_MODE_FLAG_POL_DE_POSEDGE,
+};
+
+static const struct panel_desc eukrea_mbimxsd51_dvivga = {
+   .modes = _mbimxsd51_dvivga_mode,
+   .num_modes = 1,
+   .size = {
+   .width = 0,
+   .height = 0,
+   },
+};
+
 static const struct drm_display_mode lg_lp129qe_mode = {
.clock = 285250,
.hdisplay = 2560,
@@ -413,6 +485,15 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "chunghwa,claa101wa01a",
.data 

[PATCH 08/12] imx-drm: Use drm_display_mode timings flags.

2014-03-13 Thread Denis Carikli
The previous hardware behaviour was kept if the
flags are not set.

Signed-off-by: Denis Carikli 
---
ChangeLog v10->v11:
- This patch was splitted-out and adapted from:
  "Prepare imx-drm for extra display-timings retrival."
- The display-timings dt specific part was removed.
- The flags names were changed to use the DRM ones from:
  "drm: drm_display_mode: add signal polarity flags"
---
 drivers/staging/imx-drm/imx-drm-core.c  |   10 ++
 drivers/staging/imx-drm/imx-drm.h   |6 ++
 drivers/staging/imx-drm/imx-hdmi.c  |3 +++
 drivers/staging/imx-drm/imx-ldb.c   |3 +++
 drivers/staging/imx-drm/imx-tve.c   |3 +++
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h |6 --
 drivers/staging/imx-drm/ipu-v3/ipu-di.c |7 ++-
 drivers/staging/imx-drm/ipuv3-crtc.c|   21 +++--
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h 
b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
index b95cba1..3abeea3 100644
--- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
+++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
@@ -29,9 +29,11 @@ enum ipuv3_type {

 #define CLK_POL_ACTIVE_LOW 0
 #define CLK_POL_ACTIVE_HIGH1
+#define CLK_POL_PRESERVE   2

 #define ENABLE_POL_NEGEDGE 0
 #define ENABLE_POL_POSEDGE 1
+#define ENABLE_POL_PRESERVE2

 /*
  * Bitfield of Display Interface signal polarities.
@@ -43,10 +45,10 @@ struct ipu_di_signal_cfg {
unsigned clksel_en:1;
unsigned clkidle_en:1;
unsigned data_pol:1;/* true = inverted */
-   unsigned clk_pol:1;
-   unsigned enable_pol:1;
unsigned Hsync_pol:1;   /* true = active high */
unsigned Vsync_pol:1;
+   u8 clk_pol;
+   u8 enable_pol;

u16 width;
u16 height;
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
index 53646aa..791080b 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
@@ -597,6 +597,8 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
ipu_di_signal_cfg *sig)

if (sig->clk_pol == CLK_POL_ACTIVE_HIGH)
di_gen |= DI_GEN_POLARITY_DISP_CLK;
+   else if (sig->clk_pol == CLK_POL_ACTIVE_LOW)
+   di_gen &= ~DI_GEN_POLARITY_DISP_CLK;

ipu_di_write(di, di_gen, DI_GENERAL);

@@ -604,10 +606,13 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
ipu_di_signal_cfg *sig)
 DI_SYNC_AS_GEN);

reg = ipu_di_read(di, DI_POL);
-   reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);
+   reg &= ~(DI_POL_DRDY_DATA_POLARITY);

if (sig->enable_pol == ENABLE_POL_POSEDGE)
reg |= DI_POL_DRDY_POLARITY_15;
+   else if (sig->enable_pol == ENABLE_POL_NEGEDGE)
+   reg &= ~DI_POL_DRDY_POLARITY_15;
+
if (sig->data_pol)
reg |= DI_POL_DRDY_DATA_POLARITY;

diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
b/drivers/staging/imx-drm/ipuv3-crtc.c
index 8cfeb47..c75034e 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -157,8 +157,25 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
if (mode->flags & DRM_MODE_FLAG_PVSYNC)
sig_cfg.Vsync_pol = 1;

-   sig_cfg.enable_pol = ENABLE_POL_POSEDGE;
-   sig_cfg.clk_pol = CLK_POL_ACTIVE_LOW;
+   if (mode->pol_flags & DRM_MODE_FLAG_POL_PIXDATA_POSEDGE)
+   sig_cfg.enable_pol = ENABLE_POL_POSEDGE;
+   else if (mode->pol_flags & DRM_MODE_FLAG_POL_DE_NEGEDGE)
+   sig_cfg.enable_pol = ENABLE_POL_NEGEDGE;
+   else if (mode->pol_flags & DRM_MODE_FLAG_POL_PIXDATA_PRESERVE)
+   sig_cfg.enable_pol = ENABLE_POL_PRESERVE;
+   else
+   sig_cfg.enable_pol = ENABLE_POL_POSEDGE;
+
+   if (mode->private_flags & DRM_MODE_FLAG_POL_DE_POSEDGE)
+   sig_cfg.clk_pol = CLK_POL_ACTIVE_HIGH;
+   else if (mode->private_flags & DRM_MODE_FLAG_POL_DE_NEGEDGE)
+   sig_cfg.clk_pol = CLK_POL_ACTIVE_LOW;
+   else if (mode->private_flags & DRM_MODE_FLAG_POL_DE_PRESERVE)
+   sig_cfg.clk_pol = CLK_POL_PRESERVE;
+   else
+   sig_cfg.clk_pol = CLK_POL_ACTIVE_LOW;
+
+
sig_cfg.width = mode->hdisplay;
sig_cfg.height = mode->vdisplay;
sig_cfg.pixel_fmt = out_pixel_fmt;
-- 
1.7.9.5



[PATCH 07/12] drm: drm_display_mode: add signal polarity flags

2014-03-13 Thread Denis Carikli
We need a way to pass signal polarity informations
  between DRM panels, and the display drivers.

To do that, a pol_flags field was added to drm_display_mode.

Signed-off-by: Denis Carikli 
---
ChangeLog v10->v11:
- Since the imx-drm won't be able to retrive its regulators
  from the device tree when using display-timings nodes,
  and that I was told that the drm simple-panel driver 
  already supported that, I then, instead, added what was
  lacking to make the eukrea displays work with the
  drm-simple-panel driver.

  That required a way to get back the display polarity
  informations from the imx-drm driver without affecting
  userspace.
---
 include/drm/drm_crtc.h |8 
 1 file changed, 8 insertions(+)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f764654..61a4fe1 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -131,6 +131,13 @@ enum drm_mode_status {

 #define DRM_MODE_FLAG_3D_MAX   DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF

+#define DRM_MODE_FLAG_POL_PIXDATA_NEGEDGE  BIT(1)
+#define DRM_MODE_FLAG_POL_PIXDATA_POSEDGE  BIT(2)
+#define DRM_MODE_FLAG_POL_PIXDATA_PRESERVE BIT(3)
+#define DRM_MODE_FLAG_POL_DE_NEGEDGE   BIT(4)
+#define DRM_MODE_FLAG_POL_DE_POSEDGE   BIT(5)
+#define DRM_MODE_FLAG_POL_DE_PRESERVE  BIT(6)
+
 struct drm_display_mode {
/* Header */
struct list_head head;
@@ -183,6 +190,7 @@ struct drm_display_mode {
int vrefresh;   /* in Hz */
int hsync;  /* in kHz */
enum hdmi_picture_aspect picture_aspect_ratio;
+   unsigned int pol_flags;
 };

 static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
-- 
1.7.9.5



[PATCH v11][ 06/12] ARM: dts: imx5*, imx6*: correct display-timings nodes.

2014-03-13 Thread Denis Carikli
The imx-drm driver can't use the de-active and
pixelclk-active display-timings properties yet.

Instead the data-enable and the pixel data clock
polarity are hardcoded in the imx-drm driver.

So theses properties are now set to keep
the same behaviour when imx-drm will start
using them.

Signed-off-by: Denis Carikli 
---
ChangeLog v9->v10:
- New patch that was splitted out of:
  "staging imx-drm: Use de-active and pixelclk-active
  display-timings."
---
 arch/arm/boot/dts/imx51-babbage.dts   |2 ++
 arch/arm/boot/dts/imx53-m53evk.dts|2 ++
 arch/arm/boot/dts/imx53-tx53-x03x.dts |2 +-
 arch/arm/boot/dts/imx6qdl-gw53xx.dtsi |2 ++
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi |2 ++
 arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi |2 ++
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi  |2 ++
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi  |2 ++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi|2 ++
 9 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx51-babbage.dts 
b/arch/arm/boot/dts/imx51-babbage.dts
index 9e9deb2..4732a00 100644
--- a/arch/arm/boot/dts/imx51-babbage.dts
+++ b/arch/arm/boot/dts/imx51-babbage.dts
@@ -38,6 +38,8 @@
vfront-porch = <7>;
hsync-len = <60>;
vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};

diff --git a/arch/arm/boot/dts/imx53-m53evk.dts 
b/arch/arm/boot/dts/imx53-m53evk.dts
index 4646ea9..d6e1046 100644
--- a/arch/arm/boot/dts/imx53-m53evk.dts
+++ b/arch/arm/boot/dts/imx53-m53evk.dts
@@ -40,6 +40,8 @@
vfront-porch = <9>;
vsync-len = <3>;
vsync-active = <1>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};
};
diff --git a/arch/arm/boot/dts/imx53-tx53-x03x.dts 
b/arch/arm/boot/dts/imx53-tx53-x03x.dts
index 0217dde3..4092a81 100644
--- a/arch/arm/boot/dts/imx53-tx53-x03x.dts
+++ b/arch/arm/boot/dts/imx53-tx53-x03x.dts
@@ -93,7 +93,7 @@
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
-   pixelclk-active = <1>;
+   pixelclk-active = <0>;
};

ET0500 {
diff --git a/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi 
b/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi
index c8e5ae0..43f48f2 100644
--- a/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi
@@ -494,6 +494,8 @@
vfront-porch = <7>;
hsync-len = <60>;
vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};
};
diff --git a/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi 
b/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi
index 2795dfc..59ecfd1 100644
--- a/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi
@@ -516,6 +516,8 @@
vfront-porch = <7>;
hsync-len = <60>;
vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};
};
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi 
b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
index 99be301..e9419a2 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
@@ -349,6 +349,8 @@
vfront-porch = <7>;
hsync-len = <60>;
vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};
};
diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 009abd6..230bbc6 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -405,6 +405,8 @@
vfront-porch = <7>;
hsync-len = <60>;
vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
};
};
};
diff --git a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi 

[PATCH v11][ 05/12] imx-drm: use defines for clock polarity settings

2014-03-13 Thread Denis Carikli
Signed-off-by: Denis Carikli 
---
ChangeLog v9->v10:
- New patch which was splitted out from:
  "staging: imx-drm: Use de-active and pixelclk-active display-timings.".
- Fixes many issues in "staging: imx-drm: Use de-active and pixelclk-active
  display-timings.":
  - More clear meaning of the polarity settings.
  - The SET_CLK_POL and SET_DE_POL masks are not
needed anymore.
---
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h |8 +++-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c |4 ++--
 drivers/staging/imx-drm/ipuv3-crtc.c|4 ++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h 
b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
index c4d14ea..b95cba1 100644
--- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
+++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
@@ -27,6 +27,12 @@ enum ipuv3_type {

 #define IPU_PIX_FMT_GBR24  v4l2_fourcc('G', 'B', 'R', '3')

+#define CLK_POL_ACTIVE_LOW 0
+#define CLK_POL_ACTIVE_HIGH1
+
+#define ENABLE_POL_NEGEDGE 0
+#define ENABLE_POL_POSEDGE 1
+
 /*
  * Bitfield of Display Interface signal polarities.
  */
@@ -37,7 +43,7 @@ struct ipu_di_signal_cfg {
unsigned clksel_en:1;
unsigned clkidle_en:1;
unsigned data_pol:1;/* true = inverted */
-   unsigned clk_pol:1; /* true = rising edge */
+   unsigned clk_pol:1;
unsigned enable_pol:1;
unsigned Hsync_pol:1;   /* true = active high */
unsigned Vsync_pol:1;
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
index 849b3e1..53646aa 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
@@ -595,7 +595,7 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
ipu_di_signal_cfg *sig)
}
}

-   if (sig->clk_pol)
+   if (sig->clk_pol == CLK_POL_ACTIVE_HIGH)
di_gen |= DI_GEN_POLARITY_DISP_CLK;

ipu_di_write(di, di_gen, DI_GENERAL);
@@ -606,7 +606,7 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
ipu_di_signal_cfg *sig)
reg = ipu_di_read(di, DI_POL);
reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);

-   if (sig->enable_pol)
+   if (sig->enable_pol == ENABLE_POL_POSEDGE)
reg |= DI_POL_DRDY_POLARITY_15;
if (sig->data_pol)
reg |= DI_POL_DRDY_DATA_POLARITY;
diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
b/drivers/staging/imx-drm/ipuv3-crtc.c
index db6bd64..8cfeb47 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -157,8 +157,8 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
if (mode->flags & DRM_MODE_FLAG_PVSYNC)
sig_cfg.Vsync_pol = 1;

-   sig_cfg.enable_pol = 1;
-   sig_cfg.clk_pol = 0;
+   sig_cfg.enable_pol = ENABLE_POL_POSEDGE;
+   sig_cfg.clk_pol = CLK_POL_ACTIVE_LOW;
sig_cfg.width = mode->hdisplay;
sig_cfg.height = mode->vdisplay;
sig_cfg.pixel_fmt = out_pixel_fmt;
-- 
1.7.9.5



[PATCH v11][ 04/12] imx-drm: Match ipu_di_signal_cfg's clk_pol with its description.

2014-03-13 Thread Denis Carikli
According to the datasheet, setting the di0_polarity_disp_clk
field in the GENERAL di register sets the output clock polarity
to active high.

Signed-off-by: Denis Carikli 
---
ChangeLog v9->v10:
- New patch that is now needed by the
  "staging: imx-drm: Use de-active and pixelclk-active" patch.
---
 drivers/staging/imx-drm/ipu-v3/ipu-di.c |2 +-
 drivers/staging/imx-drm/ipuv3-crtc.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
index 82a9eba..849b3e1 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
@@ -595,7 +595,7 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
ipu_di_signal_cfg *sig)
}
}

-   if (!sig->clk_pol)
+   if (sig->clk_pol)
di_gen |= DI_GEN_POLARITY_DISP_CLK;

ipu_di_write(di, di_gen, DI_GENERAL);
diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
b/drivers/staging/imx-drm/ipuv3-crtc.c
index a8d0178..db6bd64 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -158,7 +158,7 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
sig_cfg.Vsync_pol = 1;

sig_cfg.enable_pol = 1;
-   sig_cfg.clk_pol = 1;
+   sig_cfg.clk_pol = 0;
sig_cfg.width = mode->hdisplay;
sig_cfg.height = mode->vdisplay;
sig_cfg.pixel_fmt = out_pixel_fmt;
-- 
1.7.9.5



[PATCH v11][ 03/12] imx-drm: Correct BGR666 and the board's dts that use them.

2014-03-13 Thread Denis Carikli
The current BGR666 is not consistent with the other color mapings like BGR24.
BGR666 should be in the same byte order than BGR24.

Signed-off-by: Denis Carikli 
Acked-by: Philipp Zabel 
---
ChangeLog v9->v10:
- Rebased.
- Added Philipp Zabel's Ack.
- Included Lothar Wa?mann's suggestion about imx-ldb.c.
- Shortened the patch title

ChangeLog v8->v9:
- Removed the Cc. They are now set in git-send-email directly.

ChangeLog v7->v8:
- Shrinked even more the Cc list.

ChangeLog v6->v7:
- Shrinked even more the Cc list.

ChangeLog v5->v6:
- Remove people not concerned by this patch from the Cc list.
- Added a better explanation of the change.

ChangeLog v5:
- New patch.
---
 arch/arm/boot/dts/imx51-apf51dev.dts|2 +-
 arch/arm/boot/dts/imx53-m53evk.dts  |2 +-
 drivers/staging/imx-drm/imx-ldb.c   |4 ++--
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c |4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/imx51-apf51dev.dts 
b/arch/arm/boot/dts/imx51-apf51dev.dts
index c5a9a24..7b3851d 100644
--- a/arch/arm/boot/dts/imx51-apf51dev.dts
+++ b/arch/arm/boot/dts/imx51-apf51dev.dts
@@ -18,7 +18,7 @@

display at di1 {
compatible = "fsl,imx-parallel-display";
-   interface-pix-fmt = "bgr666";
+   interface-pix-fmt = "rgb666";
pinctrl-names = "default";
pinctrl-0 = <_ipu_disp1>;

diff --git a/arch/arm/boot/dts/imx53-m53evk.dts 
b/arch/arm/boot/dts/imx53-m53evk.dts
index f6d3ac3..4646ea9 100644
--- a/arch/arm/boot/dts/imx53-m53evk.dts
+++ b/arch/arm/boot/dts/imx53-m53evk.dts
@@ -23,7 +23,7 @@
soc {
display1: display at di1 {
compatible = "fsl,imx-parallel-display";
-   interface-pix-fmt = "bgr666";
+   interface-pix-fmt = "rgb666";
pinctrl-names = "default";
pinctrl-0 = <_ipu_disp1>;

diff --git a/drivers/staging/imx-drm/imx-ldb.c 
b/drivers/staging/imx-drm/imx-ldb.c
index 33d2b883..e6d7bc7 100644
--- a/drivers/staging/imx-drm/imx-ldb.c
+++ b/drivers/staging/imx-drm/imx-ldb.c
@@ -185,11 +185,11 @@ static void imx_ldb_encoder_prepare(struct drm_encoder 
*encoder)
switch (imx_ldb_ch->chno) {
case 0:
pixel_fmt = (ldb->ldb_ctrl & LDB_DATA_WIDTH_CH0_24) ?
-   V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_BGR666;
+   V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_RGB666;
break;
case 1:
pixel_fmt = (ldb->ldb_ctrl & LDB_DATA_WIDTH_CH1_24) ?
-   V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_BGR666;
+   V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_RGB666;
break;
default:
dev_err(ldb->dev, "unable to config di%d panel format\n",
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
index 6f9abe8..154d293 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
@@ -397,9 +397,9 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,

/* bgr666 */
ipu_dc_map_clear(priv, IPU_DC_MAP_BGR666);
-   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 0, 5, 0xfc); /* blue */
+   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 0, 17, 0xfc); /* blue */
ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 1, 11, 0xfc); /* green */
-   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 17, 0xfc); /* red */
+   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 5, 0xfc); /* red */

/* bgr24 */
ipu_dc_map_clear(priv, IPU_DC_MAP_BGR24);
-- 
1.7.9.5



[PATCH v11][ 02/12] imx-drm: Add RGB666 support for parallel display.

2014-03-13 Thread Denis Carikli
Signed-off-by: Denis Carikli 
Acked-by: Philipp Zabel 
---
ChangeLog v8->v9:
- Rebased.
- Added Philipp Zabel's ack.
- Shortened the patch title.

ChangeLog v8->v9:
- Removed the Cc. They are now set in git-send-email directly.
- Rebased.

ChangeLog v7->v8:
- Shrinked even more the Cc list.

ChangeLog v6->v7:
- Shrinked even more the Cc list.

ChangeLog v5->v6:
- Remove people not concerned by this patch from the Cc list.

ChangeLog v3->v5:
- Use the correct RGB order.

ChangeLog v2->v3:
- Added some interested people in the Cc list.
- Removed the commit message long desciption that was just a copy of the short
  description.
- Rebased the patch.
- Fixed a copy-paste error in the ipu_dc_map_clear parameter.
---
 .../bindings/staging/imx-drm/fsl-imx-drm.txt   |3 ++-
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c|9 +
 drivers/staging/imx-drm/parallel-display.c |2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt 
b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
index 3be5ce7..83137ef 100644
--- a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
+++ b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
@@ -60,7 +60,8 @@ Required properties:
 - compatible: Should be "fsl,imx-parallel-display"
 Optional properties:
 - interface_pix_fmt: How this display is connected to the
-  display interface. Currently supported types: "rgb24", "rgb565", "bgr666"
+  display interface. Currently supported types: "rgb24", "rgb565", "bgr666",
+  "rgb666"
 - edid: verbatim EDID data block describing attached display.
 - ddc: phandle describing the i2c bus handling the display data
   channel
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
index d5de8bb..6f9abe8 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
@@ -92,6 +92,7 @@ enum ipu_dc_map {
IPU_DC_MAP_GBR24, /* TVEv2 */
IPU_DC_MAP_BGR666,
IPU_DC_MAP_BGR24,
+   IPU_DC_MAP_RGB666,
 };

 struct ipu_dc {
@@ -155,6 +156,8 @@ static int ipu_pixfmt_to_map(u32 fmt)
return IPU_DC_MAP_BGR666;
case V4L2_PIX_FMT_BGR24:
return IPU_DC_MAP_BGR24;
+   case V4L2_PIX_FMT_RGB666:
+   return IPU_DC_MAP_RGB666;
default:
return -EINVAL;
}
@@ -404,6 +407,12 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,
ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 1, 15, 0xff); /* green */
ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 0, 23, 0xff); /* blue */

+   /* rgb666 */
+   ipu_dc_map_clear(priv, IPU_DC_MAP_RGB666);
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 0, 5, 0xfc); /* blue */
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 1, 11, 0xfc); /* green */
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 2, 17, 0xfc); /* red */
+
return 0;
 }

diff --git a/drivers/staging/imx-drm/parallel-display.c 
b/drivers/staging/imx-drm/parallel-display.c
index c60b6c6..01b7ce5 100644
--- a/drivers/staging/imx-drm/parallel-display.c
+++ b/drivers/staging/imx-drm/parallel-display.c
@@ -219,6 +219,8 @@ static int imx_pd_bind(struct device *dev, struct device 
*master, void *data)
imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
else if (!strcmp(fmt, "bgr666"))
imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
+   else if (!strcmp(fmt, "rgb666"))
+   imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB666;
}

panel_node = of_parse_phandle(np, "fsl,panel", 0);
-- 
1.7.9.5



[PATCH v11][ 01/12] [media] v4l2: add new V4L2_PIX_FMT_RGB666 pixel format.

2014-03-13 Thread Denis Carikli
That new macro is needed by the imx_drm staging driver
  for supporting the QVGA display of the eukrea-cpuimx51 board.

Signed-off-by: Denis Carikli 
Acked-by: Mauro Carvalho Chehab 
Acked-by: Laurent Pinchart 
Acked-by: Philipp Zabel 
---
ChangeLog v9->v10:
- Rebased on top of:
  "211e7f2 [media] DocBook media: drop the old incorrect packed RGB table"
- Added Philipp Zabel's Ack.

ChangeLog v8->v9:
- Removed the Cc. They are now set in git-send-email directly.

ChangeLog v7->v8:
- Added Mauro Carvalho Chehab back to the list of Cc

ChangeLog v6->v7:
- Shrinked even more the Cc list.
ChangeLog v5->v6:
- Remove people not concerned by this patch from the Cc list.

ChangeLog v3->v4:
- Added Laurent Pinchart's Ack.

ChangeLog v2->v3:
- Added some interested people in the Cc list.
- Added Mauro Carvalho Chehab's Ack.
- Added documentation.
---
 .../DocBook/media/v4l/pixfmt-packed-rgb.xml|   39 
 include/uapi/linux/videodev2.h |1 +
 2 files changed, 40 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml 
b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
index e1c4f8b..88a7fe1 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
@@ -279,6 +279,45 @@ colorspace 
V4L2_COLORSPACE_SRGB.


  
+ 
+   V4L2_PIX_FMT_RGB666
+   'RGBH'
+   
+   r5
+   r4
+   r3
+   r2
+   r1
+   r0
+   g5
+   g4
+   
+   g3
+   g2
+   g1
+   g0
+   b5
+   b4
+   b3
+   b2
+   
+   b1
+   b0
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+ 
  
V4L2_PIX_FMT_BGR24
'BGR3'
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 4dc7052..efcbc15 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -299,6 +299,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16  RGB-5-5-5 
BE  */
 #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 
BE  */
 #define V4L2_PIX_FMT_BGR666  v4l2_fourcc('B', 'G', 'R', 'H') /* 18  BGR-6-6-6  
  */
+#define V4L2_PIX_FMT_RGB666  v4l2_fourcc('R', 'G', 'B', 'H') /* 18  RGB-6-6-6  
  */
 #define V4L2_PIX_FMT_BGR24   v4l2_fourcc('B', 'G', 'R', '3') /* 24  BGR-8-8-8  
   */
 #define V4L2_PIX_FMT_RGB24   v4l2_fourcc('R', 'G', 'B', '3') /* 24  RGB-8-8-8  
   */
 #define V4L2_PIX_FMT_BGR32   v4l2_fourcc('B', 'G', 'R', '4') /* 32  
BGR-8-8-8-8   */
-- 
1.7.9.5



[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #15 from Alex Deucher  ---
Please try these patches:
http://cgit.freedesktop.org/~agd5f/linux/commit/?h=drm-fixes-3.14=9babd35ad72af631547c7ca294bc2e931cc40e58
http://cgit.freedesktop.org/~agd5f/linux/commit/?h=drm-fixes-3.14=7848865914c6a63ead674f0f5604b77df7d3874f

You can also force runpm off by booting with radeon.runpm=0 on the kernel
command line in grub.

-- 
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/20140313/355088f0/attachment.html>


[Bug 76130] Radeon HD 4570 set dpm state fails after suspend

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76130

--- Comment #1 from Aleksandr Oksenenko  ---
BTW, my kernel is a stock Archlinux kernel 3.13.6.

-- 
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/20140313/ed68eb8e/attachment.html>


[Bug 76130] New: Radeon HD 4570 set dpm state fails after suspend

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76130

  Priority: medium
Bug ID: 76130
  Assignee: dri-devel at lists.freedesktop.org
   Summary: Radeon HD 4570 set dpm state fails after suspend
  Severity: normal
Classification: Unclassified
OS: Linux (All)
  Reporter: crew4ok at gmail.com
  Hardware: x86 (IA32)
Status: NEW
   Version: unspecified
 Component: DRM/Radeon
   Product: DRI

Created attachment 95731
  --> https://bugs.freedesktop.org/attachment.cgi?id=95731=edit
dmesg

Right before the system go to suspend, the following line appears in dmesg:

[drm:rv730_stop_dpm] *ERROR* Could not force DPM to low

After wakeup i see this in dmesg:

[drm:rv770_dpm_set_power_state] *ERROR* rv770_set_sw_state failed

Also i notice a degradation in performance in some games (e.g. in Teeworlds
before the suspend i have 60fps, after suspend - 30-40 fps).

-- 
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/20140313/e99ef81c/attachment.html>


[PATCH 2/2] drm/exynos: hdmi: use i2c_adapter instead of i2c_client

2014-03-13 Thread Inki Dae
This patch changes i2c_client for ddc to i2c_adapter
because ddc needs only i2c_adapter.

Signed-off-by: Inki Dae 
Signed-off-by: Kyungmin Park 
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index b695398..a060363 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -184,7 +184,7 @@ struct hdmi_context {
void __iomem*regs;
int irq;

-   struct i2c_client   *ddc_port;
+   struct i2c_adapter  *ddc_adpt;
struct i2c_client   *hdmiphy_port;

/* current hdmiphy conf regs */
@@ -765,10 +765,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
struct hdmi_context *hdata = ctx_from_connector(connector);
struct edid *edid;

-   if (!hdata->ddc_port)
+   if (!hdata->ddc_adpt)
return -ENODEV;

-   edid = drm_get_edid(connector, hdata->ddc_port->adapter);
+   edid = drm_get_edid(connector, hdata->ddc_adpt);
if (!edid)
return -ENODEV;

@@ -2040,9 +2040,9 @@ static int hdmi_probe(struct platform_device *pdev)
DRM_ERROR("Failed to find ddc node in device tree\n");
return -ENODEV;
}
-   hdata->ddc_port = of_find_i2c_device_by_node(ddc_node);
-   if (!hdata->ddc_port) {
-   DRM_ERROR("Failed to get ddc i2c client by node\n");
+   hdata->ddc_adpt = of_find_i2c_adapter_by_node(ddc_node);
+   if (!hdata->ddc_adpt) {
+   DRM_ERROR("Failed to get ddc i2c adapter by node\n");
return -ENODEV;
}

@@ -2092,7 +2092,7 @@ static int hdmi_probe(struct platform_device *pdev)
 err_hdmiphy:
put_device(>hdmiphy_port->dev);
 err_ddc:
-   put_device(>ddc_port->dev);
+   put_device(>ddc_adpt->dev);
return ret;
 }

@@ -2103,7 +2103,7 @@ static int hdmi_remove(struct platform_device *pdev)
struct hdmi_context *hdata = display->ctx;

put_device(>hdmiphy_port->dev);
-   put_device(>ddc_port->dev);
+   put_device(>ddc_adpt->dev);
pm_runtime_disable(>dev);

return 0;
-- 
1.7.9.5



[PATCH 1/2] drm/exynos: hdmi: consider APB PHY

2014-03-13 Thread Inki Dae
This patch returns error in case of using APB PHY.

Exynos5420 SoC and maybe later would use APB PHY instead of
I2C PHY so such case should be considered.

Signed-off-by: Inki Dae 
Signed-off-by: Kyungmin Park 
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |   26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index e6ce363..b695398 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -63,6 +63,11 @@ enum hdmi_type {
HDMI_TYPE14,
 };

+struct hdmi_driver_data {
+   unsigned int type;
+   unsigned int is_apb_phy:1;
+};
+
 struct hdmi_resources {
struct clk  *hdmi;
struct clk  *sclk_hdmi;
@@ -197,6 +202,14 @@ struct hdmiphy_config {
u8 conf[32];
 };

+struct hdmi_driver_data exynos4212_hdmi_driver_data = {
+   .type   = HDMI_TYPE14,
+};
+
+struct hdmi_driver_data exynos5_hdmi_driver_data = {
+   .type   = HDMI_TYPE14,
+};
+
 /* list of phy config settings */
 static const struct hdmiphy_config hdmiphy_v13_configs[] = {
{
@@ -1959,10 +1972,10 @@ err_data:
 static struct of_device_id hdmi_match_types[] = {
{
.compatible = "samsung,exynos5-hdmi",
-   .data   = (void *)HDMI_TYPE14,
+   .data = _hdmi_driver_data,
}, {
.compatible = "samsung,exynos4212-hdmi",
-   .data   = (void *)HDMI_TYPE14,
+   .data = _hdmi_driver_data,
}, {
/* end node */
}
@@ -1976,6 +1989,7 @@ static int hdmi_probe(struct platform_device *pdev)
struct resource *res;
const struct of_device_id *match;
struct device_node *ddc_node, *phy_node;
+   struct hdmi_driver_data *drv_data;
int ret;

 if (!dev->of_node)
@@ -1996,7 +2010,9 @@ static int hdmi_probe(struct platform_device *pdev)
match = of_match_node(hdmi_match_types, dev->of_node);
if (!match)
return -ENODEV;
-   hdata->type = (enum hdmi_type)match->data;
+
+   drv_data = (struct hdmi_driver_data *)match->data;
+   hdata->type = drv_data->type;

hdata->hpd_gpio = pdata->hpd_gpio;
hdata->dev = dev;
@@ -2030,6 +2046,10 @@ static int hdmi_probe(struct platform_device *pdev)
return -ENODEV;
}

+   /* Not support APB PHY yet. */
+   if (drv_data->is_apb_phy)
+   return -EPERM;
+
/* hdmiphy i2c driver */
phy_node = of_parse_phandle(dev->of_node, "phy", 0);
if (!phy_node) {
-- 
1.7.9.5



[PATCH v4 00/34] drm/exynos: Refactor parts of the exynos driver

2014-03-13 Thread Inki Dae
Hi Sean,

Merged your all patch series except for dt binding patches - it needs
more cleanups about ddc and phy - and I had a little change just for
cleanup.
And some more cleanups and enhanced feature set on top of your patch
series would be merged, and then they will go to -next.

Thanks,
Inki Dae


2014-01-31 6:18 GMT+09:00 Sean Paul :
> This patchset refactors parts of the exynos driver to move it closer to a 
> proper
> drm driver (rather than just implementing a drm layer on top of the hardware
> drivers). The hope is to get to a point where the dp/hdmi drivers can 
> implement
> drm_connector/drm_encoder directly, and fimd/mixer can directly implement
> drm_crtc.
>
> The notable changes in this set:
> - drm_encoder funcs no longer route through the crtc
> - DP driver has been moved from video into the drm driver
> - fimd no longer implements encoder callbacks
> - exynos_drm_hdmi is removed in favor of generic manager/display
>   handling
>
> At a glance, differences between v1 and v2:
> - Passing manager/display in callbacks instead of ctx
> - Tacked on some dpms patches on the end to handle suspend/resume
>   through the dpms path
>
> At a glance, differences between v2 and v3:
> - Fixed vidi issues
> - Moved exynos_drm_hdmi.c removal to the right place
> - Added the exynos_drm_connector removal patches on the end
>
> At a glance, differences between v3 and v4:
> - Rebased on top of exynos-drm-next
> - Addressed review comments, no major functional changes
>
> Sean
>
>
>
> Daniel Kurtz (1):
>   drm/exynos: hdmi: remove the i2c drivers and use devtree
>
> Sean Paul (32):
>   drm/exynos: Rename hdmi_infoframe to avoid collision
>   drm/exynos: Merge overlay_ops into manager_ops
>   drm/exynos: Add an initialize function to manager and display
>   drm/exynos: Use manager_op initialize in fimd
>   drm/exynos: hdmi: Implement initialize op for hdmi
>   drm/exynos: Pass exynos_drm_manager in manager ops instead of dev
>   drm/exynos: Remove apply manager callback
>   drm/exynos: Remove dpms link between encoder/connector
>   drm/exynos: Rename display_op power_on to dpms
>   drm/exynos: Don't keep dpms state in encoder
>   drm/exynos: Use unsigned long for possible_crtcs
>   drm/exynos: Split manager/display/subdrv
>   ARM: dts: exynos: Add i2c phandles to hdmi node
>   drm/exynos: Remove exynos_drm_hdmi shim
>   drm/exynos: Use drm_mode_copy to copy modes
>   drm/exynos: Disable unused crtc planes from crtc
>   drm/exynos: Add mode_set manager operation
>   drm/exynos: Implement mode_fixup manager operation
>   drm/exynos: Use mode_set to configure fimd
>   drm/exynos: Remove unused/useless fimd_context members
>   drm/exynos: Move dp driver from video/ to drm/
>   drm/exynos: Move display implementation into dp
>   ARM: dts: Move display-timings node from fimd to dp
>   drm/exynos: Implement dpms display callback in DP
>   drm/exynos: Clean up FIMD power on/off routines
>   drm/exynos: Consolidate suspend/resume in drm_drv
>   drm/exynos: Add create_connector callback
>   drm/exynos: Implement drm_connector in hdmi directly
>   drm/exynos: Implement drm_connector directly in dp driver
>   drm/exynos: Implement drm_connector directly in vidi driver
>   drm/exynos: Move lvds bridge discovery into DP driver
>   drm/exynos: Remove the exynos_drm_connector shim
>
> St?phane Marchesin (1):
>   drm/exynos: Remove useless slab.h include
>
>  .../devicetree/bindings/video/exynos_dp.txt|   17 +
>  .../devicetree/bindings/video/exynos_hdmi.txt  |5 +
>  .../devicetree/bindings/video/samsung-fimd.txt |2 +
>  MAINTAINERS|7 -
>  arch/arm/boot/dts/cros5250-common.dtsi |6 +-
>  arch/arm/boot/dts/exynos5250-arndale.dts   |7 +-
>  arch/arm/boot/dts/exynos5250-smdk5250.dts  |   13 +-
>  arch/arm/boot/dts/exynos5250-snow.dts  |7 +-
>  arch/arm/boot/dts/exynos5420-smdk5420.dts  |7 +-
>  drivers/gpu/drm/exynos/Kconfig |7 +
>  drivers/gpu/drm/exynos/Makefile|7 +-
>  drivers/gpu/drm/exynos/exynos_ddc.c|   63 -
>  drivers/gpu/drm/exynos/exynos_dp_core.c| 1357 
> 
>  drivers/gpu/drm/exynos/exynos_dp_core.h|  329 +
>  drivers/gpu/drm/exynos/exynos_dp_reg.c | 1243 ++
>  drivers/gpu/drm/exynos/exynos_dp_reg.h |  366 ++
>  drivers/gpu/drm/exynos/exynos_drm_connector.c  |  304 -
>  drivers/gpu/drm/exynos/exynos_drm_connector.h  |   24 -
>  drivers/gpu/drm/exynos/exynos_drm_core.c   |  233 ++--
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c   |  139 +-
>  drivers/gpu/drm/exynos/exynos_drm_crtc.h   |   20 +-
>  drivers/gpu/drm/exynos/exynos_drm_drv.c|  155 ++-
>  drivers/gpu/drm/exynos/exynos_drm_drv.h 

[RFC PATCH v2 00/21] Add DSI display support for Exynos based boards

2014-03-13 Thread Inki Dae
2014-03-12 20:16 GMT+09:00 Tomasz Figa :
> On 12.03.2014 11:08, Inki Dae wrote:
>>
>> 2014-03-07 19:00 GMT+09:00 Andrzej Hajda :
>>>
>>> On 03/05/2014 03:56 AM, Inki Dae wrote:

 Hi Andrzej,

 Thanks for your contributions.

 2014-02-12 20:31 GMT+09:00 Andrzej Hajda :
>
> Hi,
>
> This patchset adds drivers and bindings to the following devices:
> - Exynos DSI master,
> - S6E8AA0 DSI panel,
> - TC358764 DSI/LVDS bridge,
> - HV070WSA-100 LVDS panel.
>
> It adds also display support in DTS files for the following boards:
> - Exynos4210/Trats,
> - Exynos4412/Trats2,
> - Exynos5250/Arndale.
>
> Things worth mentioning:
>
> 1. I have implemented DSI/LVDS bridge using drm_panel framework, ie.
> the driver exposes drm_panel interface on DSI side, and interact with
> panels on LVDS side using drm_panel framework. This approach seems to
> me simpler and more natural than using drm_bridge.

 Can you give me more details about why you think better to use panel
 framework than using drm_bridge?  "Simpler" and "more natural" are
 ambiguous to me.
>>>
>>> In this particular case DSI master expects on the other end
>>> any device having DSI slave interface, it could be panel or bridge.
>>> So it seems natural that both types of slave devices should expose
>>> the same interface also  on programming level.
>>> Another problem with drm_bridge is that it is not scalable -
>>> if some manufacturer will decide to add another block between the bridge
>>> and the panel there is no drm component which can be used for it.
>>> Using drm_panel the way I have used in toshiba bridge makes scalability
>>> possible,
>>> it will be only a matter of adding a driver for new block and making
>>> proper links in device tree, I see no easy way of doing it with
>>> drm_bridge approach.
>>
>>
>> Now drm_bridge may not cover all hardware. However drm_bridge has
>> already been merged to mainline so I think we need to use drm_bridge
>> somehow instead of using other one, and also we could extend
>> drm_bridge if needed. It would be definitely impossible for a new
>> framework to cover all hardware because there may be other hardware
>> not appeared yet. That is what we are doing for mainline until now.
>>
>
> Well, maybe drm_bridge has been merged, but so has been drm_panel. Moreover,
> merged code is not carved in stone, if there is a better option that could
> replace it, users of it can be converted to the new approach and the old one
> can be removed.
>
> As I believe Andrzej has demonstrated, drm_panel framework is clearly
> superior over drm_bridge and I can't think of any good reason why it
> couldn't become more generic and replace drm_bridge. Of course it can be
> renamed then to something more generic appropriately.
>
>
>>>
>>>

 Using same drm_panel framework for LDVS bridge and real panel drivers
 isn't reasonable to me as now because drm_panel framework would be for
 real panel device even if the use of drm_panel framework looks like
 suitable to LVDS bridge driver. I thought Sean's way, ptn3460 driver
 using drm_bride stuff, is good enough, and that would be why
 drm_bridge exists and why drm_encoder has drm_bridge.

 And I'm finding more generic way, how to handle LVDS bridge using
 super node so that  LVDS bridge driver isn't embedded to connector
 drivers such as eDP and MIPI-DSI, and dt binding of LVDS bridge can be
 done at top level of Exynos drm. Once the binding is done, encoder of
 display bus driver will have drm_bridge object of LVDS bridge driver
 so that display bus driver can handle LVDS bridge driver.
>>>
>>> Could you explain what you mean by "dt binding of LVDS bridge can be
>>> done at top level of Exynos drm" ? How it will look like if there
>>> will be more bridges, one for DSI, one for HDMI, etc... What if there
>>> will be two
>>> bridges in one chain. How it will cope with video pipeline bindings?
>>
>>
>> it was just my idea so I have no implementation about it yet.
>>
>> My idea is that crtc and encoder are binded at top level of Exynos drm
>> as is. And for bridge support, the only difference is, in case that
>> encoder driver has bridge, the dt binding of the encoder driver is
>> done once last one between encoder and bridge driver is binded. It
>> would mean that bridge driver can use driver model and it doesn't need
>> to concern about probe order issue.
>>
>> For this, encoder driver with bridge, MIPI-DSI or eDP, would need to
>> use component interfaces specific to Exynos drm. As a result, once the
>> dt bindings of crtc and encoder are completed at top level, encoder
>> driver has its own drm_bridge for bridge, and dt binding you proposed
>> could be used without any change, and drm_panel could also be used
>> only for real lcd panel driver.
>>
>> And below is a block diagram I think,
>>
>>

[PATCH v4 00/34] drm/exynos: Refactor parts of the exynos driver

2014-03-13 Thread Tomasz Figa
Hi Inki,

On 13.03.2014 08:33, Inki Dae wrote:
> Hi Sean,
>
> Merged your all patch series except for dt binding patches - it needs
> more cleanups about ddc and phy - and I had a little change just for
> cleanup.
> And some more cleanups and enhanced feature set on top of your patch
> series would be merged, and then they will go to -next.

I assume you just applied this series to your tree to a temporary branch 
and it won't be merged until are regressions introduced by it are fixed, 
right?

Best regards,
Tomasz


nouveau_fan_update: possible circular locking dependency detected

2014-03-13 Thread Martin Peres
Le 13/03/2014 14:38, Ilia Mirkin a ?crit :
> On Sun, Mar 9, 2014 at 10:51 AM, Marcin Slusarz
>  wrote:
>> [  326.168487] ==
>> [  326.168491] [ INFO: possible circular locking dependency detected ]
>> [  326.168496] 3.13.6 #1270 Not tainted
>> [  326.168500] ---
>> [  326.168504] ldconfig/22297 is trying to acquire lock:
>> [  326.168507]  (&(>fan->lock)->rlock){-.-...}, at: 
>> [] nouveau_fan_update+0xeb/0x252 [nouveau]
>> [  326.168551]
>> but task is already holding lock:
>> [  326.168555]  (&(>sensor.alarm_program_lock)->rlock){-.-...}, at: 
>> [] alarm_timer_callback+0xf1/0x179 [nouveau]
>> [  326.168587]
>> which lock already depends on the new lock.
>>
>> [  326.168592]
>> the existing dependency chain (in reverse order) is:
>> [  326.168596]
>> -> #1 (&(>sensor.alarm_program_lock)->rlock){-.-...}:
>> [  326.168606][] lock_acquire+0xce/0x117
>> [  326.168615][] _raw_spin_lock_irqsave+0x3f/0x51
>> [  326.168623][] alarm_timer_callback+0xf1/0x179 
>> [nouveau]
>> [  326.168651][] 
>> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
>> [  326.168679][] nv04_timer_alarm+0xb5/0xbe 
>> [nouveau]
>> [  326.168708][] nouveau_fan_update+0x234/0x252 
>> [nouveau]
>> [  326.168735][] nouveau_fan_alarm+0x15/0x17 
>> [nouveau]
>> [  326.168763][] 
>> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
>> [  326.168790][] nv04_timer_intr+0x5b/0x13c 
>> [nouveau]
>> [  326.168817][] nouveau_mc_intr+0x2e2/0x3b1 
>> [nouveau]
>> [  326.168838][] handle_irq_event_percpu+0x5c/0x1dc
>> [  326.168846][] handle_irq_event+0x3c/0x5c
>> [  326.168852][] handle_edge_irq+0xc4/0xeb
>> [  326.168860][] handle_irq+0x120/0x12d
>> [  326.168868][] do_IRQ+0x48/0xaf
>> [  326.168873][] ret_from_intr+0x0/0x13
>> [  326.168881][] arch_cpu_idle+0x13/0x1d
>> [  326.168887][] cpu_startup_entry+0x140/0x218
>> [  326.168895][] start_secondary+0x1bf/0x1c4
>> [  326.168902]
>> -> #0 (&(>fan->lock)->rlock){-.-...}:
>> [  326.168913][] __lock_acquire+0x10be/0x182b
>> [  326.168920][] lock_acquire+0xce/0x117
>> [  326.168924][] _raw_spin_lock_irqsave+0x3f/0x51
>> [  326.168931][] nouveau_fan_update+0xeb/0x252 
>> [nouveau]
>> [  326.168958][] nouveau_therm_fan_set+0x14/0x16 
>> [nouveau]
>> [  326.168984][] nouveau_therm_update+0x303/0x312 
>> [nouveau]
>> [  326.169011][] nouveau_therm_alarm+0x13/0x15 
>> [nouveau]
>> [  326.169038][] 
>> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
>> [  326.169059][] nv04_timer_alarm+0xb5/0xbe 
>> [nouveau]
>> [  326.169079][] alarm_timer_callback+0x15e/0x179 
>> [nouveau]
>> [  326.169101][] 
>> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
>> [  326.169121][] nv04_timer_intr+0x5b/0x13c 
>> [nouveau]
>> [  326.169142][] nouveau_mc_intr+0x2e2/0x3b1 
>> [nouveau]
>> [  326.169160][] handle_irq_event_percpu+0x5c/0x1dc
>> [  326.169165][] handle_irq_event+0x3c/0x5c
>> [  326.169170][] handle_edge_irq+0xc4/0xeb
>> [  326.169175][] handle_irq+0x120/0x12d
>> [  326.169179][] do_IRQ+0x48/0xaf
>> [  326.169183][] ret_from_intr+0x0/0x13
>> [  326.169189]
>> other info that might help us debug this:
>>
>> [  326.169193]  Possible unsafe locking scenario:
>>
>> [  326.169195]CPU0CPU1
>> [  326.169197]
>> [  326.169199]   lock(&(>sensor.alarm_program_lock)->rlock);
>> [  326.169205]
>> lock(&(>fan->lock)->rlock);
>> [  326.169211]
>> lock(&(>sensor.alarm_program_lock)->rlock);
>> [  326.169216]   lock(&(>fan->lock)->rlock);
>> [  326.169221]
>>   *** DEADLOCK ***
>>
>>   [  326.169225] 1 lock held by ldconfig/22297:
>>   [  326.169229]  #0:  (&(>sensor.alarm_program_lock)->rlock){-.-...}, 
>> at: [] alarm_timer_callback+0xf1/0x179 [nouveau]
>>   [  326.169253]
>>   stack backtrace:
>>   [  326.169258] CPU: 7 PID: 22297 Comm: ldconfig Not tainted 3.13.6 #1270
>>   [  326.169260] Hardware name: System manufacturer System Product Name/P6T 
>> SE, BIOS 060309/02/2009
>>   [  326.169264]  90fb6360 8801bfdc3a38 9059e369 
>> 0006
>>   [  326.169273]  90fb61b0 8801bfdc3a88 905998cf 
>> 0002
>>   [  326.169282]  8800b148dbe0 0001 8800b148e1e0 
>> 0001
>>   [  326.169342] Call Trace:
>>   [  326.169344][] dump_stack+0x4e/0x71
>>   [  326.169352]  [] print_circular_bug+0x2ad/0x2be
>>   [  326.169356]  [] __lock_acquire+0x10be/0x182b
>>   [  326.169360]  [] ? check_irq_usage+0x99/0xab
>>   [  326.169365]  [] lock_acquire+0xce/0x117
>>   [  326.169384]  [] ? nouveau_fan_update+0xeb/0x252 
>> [nouveau]
>>   [ 

[RFC PATCH v2 00/21] Add DSI display support for Exynos based boards

2014-03-13 Thread Andrzej Hajda
On 03/13/2014 08:08 AM, Inki Dae wrote:
> 2014-03-12 20:16 GMT+09:00 Tomasz Figa :
>> On 12.03.2014 11:08, Inki Dae wrote:
>>> 2014-03-07 19:00 GMT+09:00 Andrzej Hajda :
 On 03/05/2014 03:56 AM, Inki Dae wrote:
> Hi Andrzej,
>
> Thanks for your contributions.
>
> 2014-02-12 20:31 GMT+09:00 Andrzej Hajda :
>> Hi,
>>
>> This patchset adds drivers and bindings to the following devices:
>> - Exynos DSI master,
>> - S6E8AA0 DSI panel,
>> - TC358764 DSI/LVDS bridge,
>> - HV070WSA-100 LVDS panel.
>>
>> It adds also display support in DTS files for the following boards:
>> - Exynos4210/Trats,
>> - Exynos4412/Trats2,
>> - Exynos5250/Arndale.
>>
>> Things worth mentioning:
>>
>> 1. I have implemented DSI/LVDS bridge using drm_panel framework, ie.
>> the driver exposes drm_panel interface on DSI side, and interact with
>> panels on LVDS side using drm_panel framework. This approach seems to
>> me simpler and more natural than using drm_bridge.
> Can you give me more details about why you think better to use panel
> framework than using drm_bridge?  "Simpler" and "more natural" are
> ambiguous to me.
 In this particular case DSI master expects on the other end
 any device having DSI slave interface, it could be panel or bridge.
 So it seems natural that both types of slave devices should expose
 the same interface also  on programming level.
 Another problem with drm_bridge is that it is not scalable -
 if some manufacturer will decide to add another block between the bridge
 and the panel there is no drm component which can be used for it.
 Using drm_panel the way I have used in toshiba bridge makes scalability
 possible,
 it will be only a matter of adding a driver for new block and making
 proper links in device tree, I see no easy way of doing it with
 drm_bridge approach.
>>>
>>> Now drm_bridge may not cover all hardware. However drm_bridge has
>>> already been merged to mainline so I think we need to use drm_bridge
>>> somehow instead of using other one, and also we could extend
>>> drm_bridge if needed. It would be definitely impossible for a new
>>> framework to cover all hardware because there may be other hardware
>>> not appeared yet. That is what we are doing for mainline until now.
>>>
>> Well, maybe drm_bridge has been merged, but so has been drm_panel. Moreover,
>> merged code is not carved in stone, if there is a better option that could
>> replace it, users of it can be converted to the new approach and the old one
>> can be removed.
>>
>> As I believe Andrzej has demonstrated, drm_panel framework is clearly
>> superior over drm_bridge and I can't think of any good reason why it
>> couldn't become more generic and replace drm_bridge. Of course it can be
>> renamed then to something more generic appropriately.
>>
>>

> Using same drm_panel framework for LDVS bridge and real panel drivers
> isn't reasonable to me as now because drm_panel framework would be for
> real panel device even if the use of drm_panel framework looks like
> suitable to LVDS bridge driver. I thought Sean's way, ptn3460 driver
> using drm_bride stuff, is good enough, and that would be why
> drm_bridge exists and why drm_encoder has drm_bridge.
>
> And I'm finding more generic way, how to handle LVDS bridge using
> super node so that  LVDS bridge driver isn't embedded to connector
> drivers such as eDP and MIPI-DSI, and dt binding of LVDS bridge can be
> done at top level of Exynos drm. Once the binding is done, encoder of
> display bus driver will have drm_bridge object of LVDS bridge driver
> so that display bus driver can handle LVDS bridge driver.
 Could you explain what you mean by "dt binding of LVDS bridge can be
 done at top level of Exynos drm" ? How it will look like if there
 will be more bridges, one for DSI, one for HDMI, etc... What if there
 will be two
 bridges in one chain. How it will cope with video pipeline bindings?
>>>
>>> it was just my idea so I have no implementation about it yet.
>>>
>>> My idea is that crtc and encoder are binded at top level of Exynos drm
>>> as is. And for bridge support, the only difference is, in case that
>>> encoder driver has bridge, the dt binding of the encoder driver is
>>> done once last one between encoder and bridge driver is binded. It
>>> would mean that bridge driver can use driver model and it doesn't need
>>> to concern about probe order issue.
>>>
>>> For this, encoder driver with bridge, MIPI-DSI or eDP, would need to
>>> use component interfaces specific to Exynos drm. As a result, once the
>>> dt bindings of crtc and encoder are completed at top level, encoder
>>> driver has its own drm_bridge for bridge, and dt binding you proposed
>>> could be used without any change, and drm_panel could also be used
>>> only for real lcd panel 

[PATCH 5/5] drm: Remove the minor master list

2014-03-13 Thread Thomas Hellstrom
It doesn't appear to be used anywhere.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: David Herrmann 
---
 drivers/gpu/drm/drm_stub.c |5 -
 include/drm/drmP.h |2 --
 2 files changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 98a33c580..4f17c79 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -152,8 +152,6 @@ struct drm_master *drm_master_create(struct drm_minor 
*minor)
INIT_LIST_HEAD(>magicfree);
master->minor = minor;

-   list_add_tail(>head, >master_list);
-
return master;
 }

@@ -171,8 +169,6 @@ static void drm_master_destroy(struct kref *kref)
struct drm_device *dev = master->minor->dev;
struct drm_map_list *r_list, *list_temp;

-   list_del(>head);
-
if (dev->driver->master_destroy)
dev->driver->master_destroy(dev, master);

@@ -296,7 +292,6 @@ static int drm_get_minor(struct drm_device *dev, struct 
drm_minor **minor,
new_minor->device = MKDEV(DRM_MAJOR, minor_id);
new_minor->dev = dev;
new_minor->index = minor_id;
-   INIT_LIST_HEAD(_minor->master_list);

idr_replace(_minors_idr, new_minor, minor_id);

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0465ab2..49ead1a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -718,7 +718,6 @@ struct drm_master {

struct kref refcount; /* refcount for this master */

-   struct list_head head; /**< each minor contains a list of masters */
struct drm_minor *minor; /**< link back to minor we are a master for */

char *unique;   /**< Unique identifier: e.g., busid */
@@ -1050,7 +1049,6 @@ struct drm_minor {
struct mutex debugfs_lock; /* Protects debugfs_list. */

struct drm_master *master; /* currently active master for this node */
-   struct list_head master_list;
struct drm_mode_group mode_group;
 };

-- 
1.7.10.4


[PATCH 4/5] drm: Improve on minor type helpers v2

2014-03-13 Thread Thomas Hellstrom
Add a drm_is_legacy() helper, constify argument to drm_is_render_client(),
and use / change helpers where appropriate.

v2: s/drm_is_legacy/drm_is_legacy_client/ and adapt to new code context.

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_crtc.c |4 ++--
 drivers/gpu/drm/drm_fops.c |6 ++
 include/drm/drmP.h |7 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 740a9ba3..c39e54b 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1429,7 +1429,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
mutex_unlock(_priv->fbs_lock);

drm_modeset_lock_all(dev);
-   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
+   if (!drm_is_legacy_client(file_priv)) {

mode_group = NULL;
list_for_each(lh, >mode_config.crtc_list)
@@ -2717,7 +2717,7 @@ int drm_mode_getfb(struct drm_device *dev,
r->pitch = fb->pitches[0];
if (fb->funcs->create_handle) {
if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
-   file_priv->minor->type == DRM_MINOR_CONTROL) {
+   drm_is_control_client(file_priv)) {
ret = fb->funcs->create_handle(fb, file_priv,
   >handle);
} else {
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 547ab7f..260b5b1 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -259,8 +259,7 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
/* if there is no current master make this fd it, but do not create
 * any master object for render clients */
mutex_lock(>struct_mutex);
-   if (!priv->minor->master && !drm_is_render_client(priv) &&
-   !drm_is_control_client(priv)) {
+   if (drm_is_legacy_client(priv) && !priv->minor->master) {
/* create a new master */
priv->minor->master = drm_master_create(priv->minor);
if (!priv->minor->master) {
@@ -298,8 +297,7 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
goto out_close;
}
}
-   } else if (!drm_is_render_client(priv) &&
-  !drm_is_control_client(priv)) {
+   } else if (drm_is_legacy_client(priv)) {
/* get a reference to the master */
priv->master = drm_master_get(priv->minor->master);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 229d307..0465ab2 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1241,7 +1241,7 @@ static inline bool drm_modeset_is_locked(struct 
drm_device *dev)
return mutex_is_locked(>mode_config.mutex);
 }

-static inline bool drm_is_render_client(struct drm_file *file_priv)
+static inline bool drm_is_render_client(const struct drm_file *file_priv)
 {
return file_priv->minor->type == DRM_MINOR_RENDER;
 }
@@ -1251,6 +1251,11 @@ static inline bool drm_is_control_client(const struct 
drm_file *file_priv)
return file_priv->minor->type == DRM_MINOR_CONTROL;
 }

+static inline bool drm_is_legacy_client(const struct drm_file *file_priv)
+{
+   return file_priv->minor->type == DRM_MINOR_LEGACY;
+}
+
 /**/
 /** \name Internal function definitions */
 /*@{*/
-- 
1.7.10.4


[PATCH 3/5] drm: Make control nodes master-less v3

2014-03-13 Thread Thomas Hellstrom
Like for render-nodes, there is no point in maintaining the master concept
for control nodes, so set the struct drm_file::master pointer to NULL.

At the same time, make sure DRM_MASTER | DRM_CONTROL_ALLOW ioctls are always
allowed when called through the control node. Previously the caller also
needed to be master.

v2: Adapt to refactoring of ioctl permission check.
v3: Formatting of logical expression. Use drm_is_control_client() instead of
drm_is_control().

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_drv.c  |9 +
 drivers/gpu/drm/drm_fops.c |6 --
 include/drm/drmP.h |5 +
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 002596c..552dbe8 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -305,14 +305,15 @@ static int drm_ioctl_permit(u32 flags, struct drm_file 
*file_priv)
if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
 !file_priv->authenticated))
return -EACCES;
-
-   /* MASTER is only for master */
-   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
+   
+   /* MASTER is only for master or control clients */
+   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master &&
+!drm_is_control_client(file_priv)))
return -EACCES;

/* Control clients must be explicitly allowed */
if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
-file_priv->minor->type == DRM_MINOR_CONTROL))
+drm_is_control_client(file_priv)))
return -EACCES;

/* Render clients must be explicitly allowed */
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7f2af9a..547ab7f 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -259,7 +259,8 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
/* if there is no current master make this fd it, but do not create
 * any master object for render clients */
mutex_lock(>struct_mutex);
-   if (!priv->minor->master && !drm_is_render_client(priv)) {
+   if (!priv->minor->master && !drm_is_render_client(priv) &&
+   !drm_is_control_client(priv)) {
/* create a new master */
priv->minor->master = drm_master_create(priv->minor);
if (!priv->minor->master) {
@@ -297,7 +298,8 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
goto out_close;
}
}
-   } else if (!drm_is_render_client(priv)) {
+   } else if (!drm_is_render_client(priv) &&
+  !drm_is_control_client(priv)) {
/* get a reference to the master */
priv->master = drm_master_get(priv->minor->master);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 04a7f31..229d307 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1246,6 +1246,11 @@ static inline bool drm_is_render_client(struct drm_file 
*file_priv)
return file_priv->minor->type == DRM_MINOR_RENDER;
 }

+static inline bool drm_is_control_client(const struct drm_file *file_priv)
+{
+   return file_priv->minor->type == DRM_MINOR_CONTROL;
+}
+
 /**/
 /** \name Internal function definitions */
 /*@{*/
-- 
1.7.10.4


[PATCH 2/5] drm: Break out ioctl permission check to a separate function v2

2014-03-13 Thread Thomas Hellstrom
Helps reviewing and understanding these checks.
v2: Remove misplaced newlines.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: David Herrmann 
---
 drivers/gpu/drm/drm_drv.c |  113 ++---
 1 file changed, 75 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 345be03..002596c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -286,6 +286,44 @@ static int drm_version(struct drm_device *dev, void *data,
 }

 /**
+ * drm_ioctl_permit - Check ioctl permissions against caller
+ *
+ * @flags: ioctl permission flags.
+ * @file_priv: Pointer to struct drm_file identifying the caller.
+ *
+ * Checks whether the caller is allowed to run an ioctl with the
+ * indicated permissions. If so, returns zero. Otherwise returns an
+ * error code suitable for ioctl return.
+ */
+static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
+{
+   /* ROOT_ONLY is only for CAP_SYS_ADMIN */
+   if (unlikely((flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)))
+   return -EACCES;
+
+   /* AUTH is only for authenticated or render client */
+   if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
+!file_priv->authenticated))
+   return -EACCES;
+
+   /* MASTER is only for master */
+   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
+   return -EACCES;
+
+   /* Control clients must be explicitly allowed */
+   if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
+file_priv->minor->type == DRM_MINOR_CONTROL))
+   return -EACCES;
+
+   /* Render clients must be explicitly allowed */
+   if (unlikely(!(flags & DRM_RENDER_ALLOW) &&
+drm_is_render_client(file_priv)))
+   return -EACCES;
+
+   return 0;
+}
+
+/**
  * Called whenever a process performs an ioctl on /dev/drm.
  *
  * \param inode device inode.
@@ -350,52 +388,51 @@ long drm_ioctl(struct file *filp,
/* Do not trust userspace, use our own definition */
func = ioctl->func;

-   if (!func) {
+   if (unlikely(!func)) {
DRM_DEBUG("no function\n");
retcode = -EINVAL;
-   } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) 
||
-  ((ioctl->flags & DRM_AUTH) && 
!drm_is_render_client(file_priv) && !file_priv->authenticated) ||
-  ((ioctl->flags & DRM_MASTER) && !file_priv->is_master) ||
-  (!(ioctl->flags & DRM_CONTROL_ALLOW) && 
(file_priv->minor->type == DRM_MINOR_CONTROL)) ||
-  (!(ioctl->flags & DRM_RENDER_ALLOW) && 
drm_is_render_client(file_priv))) {
-   retcode = -EACCES;
-   } else {
-   if (cmd & (IOC_IN | IOC_OUT)) {
-   if (asize <= sizeof(stack_kdata)) {
-   kdata = stack_kdata;
-   } else {
-   kdata = kmalloc(asize, GFP_KERNEL);
-   if (!kdata) {
-   retcode = -ENOMEM;
-   goto err_i1;
-   }
-   }
-   if (asize > usize)
-   memset(kdata + usize, 0, asize - usize);
-   }
+   goto err_i1;
+   }

-   if (cmd & IOC_IN) {
-   if (copy_from_user(kdata, (void __user *)arg,
-  usize) != 0) {
-   retcode = -EFAULT;
+   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
+   if (unlikely(retcode))
+   goto err_i1;
+
+   if (cmd & (IOC_IN | IOC_OUT)) {
+   if (asize <= sizeof(stack_kdata)) {
+   kdata = stack_kdata;
+   } else {
+   kdata = kmalloc(asize, GFP_KERNEL);
+   if (!kdata) {
+   retcode = -ENOMEM;
goto err_i1;
}
-   } else
-   memset(kdata, 0, usize);
-
-   if (ioctl->flags & DRM_UNLOCKED)
-   retcode = func(dev, kdata, file_priv);
-   else {
-   mutex_lock(_global_mutex);
-   retcode = func(dev, kdata, file_priv);
-   mutex_unlock(_global_mutex);
}
+   if (asize > usize)
+   memset(kdata + usize, 0, asize - usize);
+   }

-   if (cmd & IOC_OUT) {
-   if (copy_to_user((void __user *)arg, kdata,
-usize) != 0)
-   retcode = -EFAULT;
+   if (cmd & IOC_IN) {
+   if (copy_from_user(kdata, (void __user 

[PATCH 1/5] drm: Have the crtc code only reference master from legacy nodes v2

2014-03-13 Thread Thomas Hellstrom
control- and render nodes are intended to be master-less.

v2: Replace tests for !legacy with tests for !mode_group for readability.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: David Herrmann 
---
 drivers/gpu/drm/drm_crtc.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 3b7d32d..740a9ba3 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1429,9 +1429,9 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
mutex_unlock(_priv->fbs_lock);

drm_modeset_lock_all(dev);
-   mode_group = _priv->master->minor->mode_group;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (file_priv->minor->type != DRM_MINOR_LEGACY) {

+   mode_group = NULL;
list_for_each(lh, >mode_config.crtc_list)
crtc_count++;

@@ -1442,6 +1442,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
encoder_count++;
} else {

+   mode_group = _priv->master->minor->mode_group;
crtc_count = mode_group->num_crtcs;
connector_count = mode_group->num_connectors;
encoder_count = mode_group->num_encoders;
@@ -1456,7 +1457,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_crtcs >= crtc_count) {
copied = 0;
crtc_id = (uint32_t __user *)(unsigned 
long)card_res->crtc_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (!mode_group) {
list_for_each_entry(crtc, >mode_config.crtc_list,
head) {
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
@@ -1483,7 +1484,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_encoders >= encoder_count) {
copied = 0;
encoder_id = (uint32_t __user *)(unsigned 
long)card_res->encoder_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (!mode_group) {
list_for_each_entry(encoder,
>mode_config.encoder_list,
head) {
@@ -1514,7 +1515,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_connectors >= connector_count) {
copied = 0;
connector_id = (uint32_t __user *)(unsigned 
long)card_res->connector_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (!mode_group) {
list_for_each_entry(connector,
>mode_config.connector_list,
head) {
@@ -2715,7 +2716,8 @@ int drm_mode_getfb(struct drm_device *dev,
r->bpp = fb->bits_per_pixel;
r->pitch = fb->pitches[0];
if (fb->funcs->create_handle) {
-   if (file_priv->is_master || capable(CAP_SYS_ADMIN)) {
+   if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
+   file_priv->minor->type == DRM_MINOR_CONTROL) {
ret = fb->funcs->create_handle(fb, file_priv,
   >handle);
} else {
-- 
1.7.10.4


[PATCH 0/5] Control node master fixes v2

2014-03-13 Thread Thomas Hellstrom
After a previous patch series and a discussion with Daniel Vetter and
David Herrmann, I've reworked the patches a bit. Please review.

Patch 1,2 and 5 already reviewed.

Thanks,
Thomas


[PULL] drm documentation updates for 3.15

2014-03-13 Thread Daniel Vetter
Hi Dave,

Here's my drm documentation update and driver api polish pull request.
Alex reviewed the entire pile, I've applied a little bit of spelling
polish in a few places since then and otherwise the Usual Suspects (David,
Rob, ...) don't seem up to have another look at it (I've poked them on
irc). So I think it's as good as it gets ;-)

Note that I've dropped the final imx breaker patch since that's blocked on
imx getting sane. Once that's landed I'll ping you to pick up that
straggler.

Cheers, Daniel


The following changes since commit 786a7828bc74b9b1466e83abb200b75f80f94121:

  Merge branch 'drm-next-3.15' of 
git://people.freedesktop.org/~deathsimple/linux into drm-next (2014-03-05 
14:52:19 +1000)

are available in the git repository at:


  ssh://people.freedesktop.org/~danvet/drm.git drm-docs

for you to fetch changes up to c8e32cc1219fc15135b696b726421571f68bd97e:

  drm: kerneldoc polish for drm_crtc.c (2014-03-13 12:48:49 +0100)


Daniel Vetter (33):
  drm/doc: Clarify the dumb object interfaces
  drm/doc: Fix up kerneldoc in drm_edid.c
  drm/doc: Clean up and integrate kerneldoc for drm_gem.c
  drm/doc: Remove  from rendernode docs
  drm/doc: Reorganize driver documentation
  drm/doc: Move the vma offset manager to the right spot
  drm/doc: Remove the "command submissin and fencing" section
  drm/doc: No more drm perf counters
  drm/doc: Document drm_helper_resume_force_mode
  drm/doc: Hide legacy horrors better
  drm/docs: Include hdmi infoframe helper reference
  drm/doc: Clarify PRIME documentation
  drm/doc: Add PRIME function references
  drm/doc: Update copyright
  drm/mm: Remove MM_UNUSED_TARGET
  drm/doc: Overview documentation for drm_mm.c
  drm/doc: Add function reference documentation for drm_mm.c
  drm/kms: rip out drm_mode_connector_detach_encoder
  drm/doc: Integrate drm_modes.c kerneldoc
  drm/doc: Repleace LOCKING kerneldoc sections in drm_modes.c
  drm: move drm_mode related functions into drm_modes.c
  drm: extract drm_modes.h for drm_crtc.h functions
  drm/modes: remove drm_mode_height/width
  drm/modes: drop return value from drm_display_mode_from_videomode
  drm/modes: drop maxPitch from drm_mode_validate_size
  drm: polish function kerneldoc for drm_modes.[hc]
  drm: remove drm_display_mode->private_size
  drm/doc: Fix misplaced 
  drm: remove return value from drm_helper_mode_fill_fb_struct
  drm/crtc-helper: remove LOCKING from kerneldoc
  drm: drop error code for drm_helper_resume_force_mode
  drm: kerneldoc polish for drm_crtc_helper.c
  drm: kerneldoc polish for drm_crtc.c

 Documentation/DocBook/drm.tmpl | 500 ++---
 drivers/gpu/drm/drm_crtc.c | 697 -
 drivers/gpu/drm/drm_crtc_helper.c  | 193 ++--
 drivers/gpu/drm/drm_crtc_internal.h|  38 ++
 drivers/gpu/drm/drm_edid.c |  30 +-
 drivers/gpu/drm/drm_fb_helper.c|   4 +-
 drivers/gpu/drm/drm_gem.c  |  63 ++-
 drivers/gpu/drm/drm_mm.c   | 211 -
 drivers/gpu/drm/drm_modes.c| 346 +++---
 drivers/gpu/drm/drm_prime.c| 110 -
 drivers/staging/imx-drm/imx-ldb.c  |   2 -
 drivers/staging/imx-drm/parallel-display.c |   2 -
 include/drm/drmP.h |  29 --
 include/drm/drm_crtc.h | 174 +--
 include/drm/drm_crtc_helper.h  |   6 +-
 include/drm/drm_mm.h   | 154 +--
 include/drm/drm_modes.h| 237 ++
 include/linux/hdmi.h   |  12 +
 18 files changed, 2013 insertions(+), 795 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_crtc_internal.h
 create mode 100644 include/drm/drm_modes.h
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread Thomas Hellstrom
On 03/13/2014 01:15 PM, David Herrmann wrote:
> Hi
>
> On Thu, Mar 13, 2014 at 1:11 PM, Thomas Hellstrom  
> wrote:
>> Hi.
>>
>> Thanks for reviewing. I'll incorporate your suggestions, except this
>> one, and resend.
>>
>>
>> On 03/13/2014 12:19 PM, David Herrmann wrote:
>>> Hi
>>>
>>> On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
>>>  wrote:
>> ...
>>
>> -   if (cmd & IOC_IN) {
>> -   if (copy_from_user(kdata, (void __user *)arg,
>> -  usize) != 0) {
>> -   retcode = -EFAULT;
>> +   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
>> +   if (unlikely(retcode))
>>
>>> That "unlikely" seems redundant given that all error paths in
>>> drm_ioctl_permit() already are "unlikely".
>> Yes, we know that's true, but I don't think compilers in general can
>> combine branch prediction hints in that way,
>> or even have the information necessary to do it.
>> I mean even if each individual test resulting in an error is unlikely,
>> how could the compiler know that
>> all tests combined would result in an error being unlikely?
> The function is static, so the compiler can see that it returns "!=0"
> only if one of the "unlikely" branches was hit. So I think it's safe
> to assume the whole thing returns "!=0" only in unlikely conditions.
>

But a compiler can't (or shouldn't) make that assumption. Just as an
(adapted) example, imagine that
each test had a 20% probability of returning an error. The probability
of the function returning an error would
then be 68%..

> I'm no big fan of excessive likely/unlikely annotations, but I'm fine
> if you want to keep it.

Fair enough.

Thanks,
Thomas


>
> Thanks
> David
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread David Herrmann
Hi

On Thu, Mar 13, 2014 at 1:11 PM, Thomas Hellstrom  
wrote:
> Hi.
>
> Thanks for reviewing. I'll incorporate your suggestions, except this
> one, and resend.
>
>
> On 03/13/2014 12:19 PM, David Herrmann wrote:
>> Hi
>>
>> On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
>>  wrote:
> ...
>
> -   if (cmd & IOC_IN) {
> -   if (copy_from_user(kdata, (void __user *)arg,
> -  usize) != 0) {
> -   retcode = -EFAULT;
> +   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
> +   if (unlikely(retcode))
>
>> That "unlikely" seems redundant given that all error paths in
>> drm_ioctl_permit() already are "unlikely".
>
> Yes, we know that's true, but I don't think compilers in general can
> combine branch prediction hints in that way,
> or even have the information necessary to do it.
> I mean even if each individual test resulting in an error is unlikely,
> how could the compiler know that
> all tests combined would result in an error being unlikely?

The function is static, so the compiler can see that it returns "!=0"
only if one of the "unlikely" branches was hit. So I think it's safe
to assume the whole thing returns "!=0" only in unlikely conditions.
But it's probably inlined, anyway..

I'm no big fan of excessive likely/unlikely annotations, but I'm fine
if you want to keep it.

Thanks
David


[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread Thomas Hellstrom
Hi.

Thanks for reviewing. I'll incorporate your suggestions, except this
one, and resend.


On 03/13/2014 12:19 PM, David Herrmann wrote:
> Hi
>
> On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
>  wrote:
...

-   if (cmd & IOC_IN) {
-   if (copy_from_user(kdata, (void __user *)arg,
-  usize) != 0) {
-   retcode = -EFAULT;
+   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
+   if (unlikely(retcode))

> That "unlikely" seems redundant given that all error paths in
> drm_ioctl_permit() already are "unlikely".

Yes, we know that's true, but I don't think compilers in general can
combine branch prediction hints in that way,
or even have the information necessary to do it.
I mean even if each individual test resulting in an error is unlikely,
how could the compiler know that
all tests combined would result in an error being unlikely?

/Thomas


[PATCH 3/5] drm: Make control nodes master-less v2

2014-03-13 Thread David Herrmann
Hi

On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
 wrote:
> Like for render-nodes, there is no point in maintaining the master concept
> for control nodes, so set the struct drm_file::master pointer to NULL.
>
> At the same time, make sure DRM_MASTER | DRM_CONTROL_ALLOW ioctls are always
> allowed when called through the control node. Previously the caller also
> needed to be master.
>
> v2: Adapt to refactoring of ioctl permission check.
>
> Signed-off-by: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/drm_drv.c  |9 +
>  drivers/gpu/drm/drm_fops.c |5 +++--
>  include/drm/drmP.h |5 +
>  3 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 0afc6e4..e41ee82 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -307,14 +307,15 @@ static int drm_ioctl_permit(u32 flags, struct drm_file 
> *file_priv)
> if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
>  !file_priv->authenticated))
> return -EACCES;
> -
> -   /* MASTER is only for master */
> -   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
> +
> +   /* MASTER is only for master or control clients */
> +   if (unlikely((flags & DRM_MASTER) &&
> +!(file_priv->is_master || drm_is_control(file_priv

imo this looks nicer:
(flags & XY) && !is_master && !drm_is_control()

but that's probably a matter of taste

> return -EACCES;
>
> /* Control clients must be explicitly allowed */
> if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
> -file_priv->minor->type == DRM_MINOR_CONTROL))
> +drm_is_control(file_priv)))
> return -EACCES;
>
> /* Render clients must be explicitly allowed */
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 7f2af9a..08a3196 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -259,7 +259,8 @@ static int drm_open_helper(struct inode *inode, struct 
> file *filp,
> /* if there is no current master make this fd it, but do not create
>  * any master object for render clients */
> mutex_lock(>struct_mutex);
> -   if (!priv->minor->master && !drm_is_render_client(priv)) {
> +   if (!priv->minor->master && !drm_is_render_client(priv) &&
> +   !drm_is_control(priv)) {
> /* create a new master */
> priv->minor->master = drm_master_create(priv->minor);
> if (!priv->minor->master) {
> @@ -297,7 +298,7 @@ static int drm_open_helper(struct inode *inode, struct 
> file *filp,
> goto out_close;
> }
> }
> -   } else if (!drm_is_render_client(priv)) {
> +   } else if (!drm_is_render_client(priv) && !drm_is_control(priv)) {
> /* get a reference to the master */
> priv->master = drm_master_get(priv->minor->master);
> }
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 04a7f31..ff68e26 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1246,6 +1246,11 @@ static inline bool drm_is_render_client(struct 
> drm_file *file_priv)
> return file_priv->minor->type == DRM_MINOR_RENDER;
>  }
>
> +static inline bool drm_is_control(struct drm_file *file_priv)

drm_is_control()? Pretty inexpressive.. Why not keep the _client
suffix? drm_is_control_client()..

Thanks
David

> +{
> +   return file_priv->minor->type == DRM_MINOR_CONTROL;
> +}
> +
>  /**/
>  /** \name Internal function definitions */
>  /*@{*/
> --
> 1.7.10.4
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread David Herrmann
Hi

On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
 wrote:
> Helps reviewing and understanding these checks.
>
> Signed-off-by: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/drm_drv.c |  116 
> ++---
>  1 file changed, 78 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 345be03..0afc6e4 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -285,6 +285,47 @@ static int drm_version(struct drm_device *dev, void 
> *data,
> return err;
>  }
>
> +

Why the double blank line?

> +/**
> + * drm_ioctl_permit - Check ioctl permissions against caller
> + *
> + * @flags: ioctl permission flags.
> + * @file_priv: Pointer to struct drm_file identifying the caller.
> + *
> + * Checks whether the caller is allowed to run an ioctl with the
> + * indicated permissions. If so, returns zero. Otherwise returns an
> + * error code suitable for ioctl return.
> + */
> +static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
> +{
> +

We don't do blank lines after function-headers.

> +   /* ROOT_ONLY is only for CAP_SYS_ADMIN */
> +   if (unlikely((flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)))
> +   return -EACCES;
> +
> +   /* AUTH is only for authenticated or render client */
> +   if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
> +!file_priv->authenticated))
> +   return -EACCES;
> +
> +   /* MASTER is only for master */
> +   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
> +   return -EACCES;
> +
> +   /* Control clients must be explicitly allowed */
> +   if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
> +file_priv->minor->type == DRM_MINOR_CONTROL))
> +   return -EACCES;
> +
> +   /* Render clients must be explicitly allowed */
> +   if (unlikely(!(flags & DRM_RENDER_ALLOW) &&
> +drm_is_render_client(file_priv)))
> +   return -EACCES;
> +
> +   return 0;
> +}
> +
> +

Again, double blank-line.

>  /**
>   * Called whenever a process performs an ioctl on /dev/drm.
>   *
> @@ -350,52 +391,51 @@ long drm_ioctl(struct file *filp,
> /* Do not trust userspace, use our own definition */
> func = ioctl->func;
>
> -   if (!func) {
> +   if (unlikely(!func)) {
> DRM_DEBUG("no function\n");
> retcode = -EINVAL;
> -   } else if (((ioctl->flags & DRM_ROOT_ONLY) && 
> !capable(CAP_SYS_ADMIN)) ||
> -  ((ioctl->flags & DRM_AUTH) && 
> !drm_is_render_client(file_priv) && !file_priv->authenticated) ||
> -  ((ioctl->flags & DRM_MASTER) && !file_priv->is_master) ||
> -  (!(ioctl->flags & DRM_CONTROL_ALLOW) && 
> (file_priv->minor->type == DRM_MINOR_CONTROL)) ||
> -  (!(ioctl->flags & DRM_RENDER_ALLOW) && 
> drm_is_render_client(file_priv))) {
> -   retcode = -EACCES;
> -   } else {
> -   if (cmd & (IOC_IN | IOC_OUT)) {
> -   if (asize <= sizeof(stack_kdata)) {
> -   kdata = stack_kdata;
> -   } else {
> -   kdata = kmalloc(asize, GFP_KERNEL);
> -   if (!kdata) {
> -   retcode = -ENOMEM;
> -   goto err_i1;
> -   }
> -   }
> -   if (asize > usize)
> -   memset(kdata + usize, 0, asize - usize);
> -   }
> +   goto err_i1;
> +   }
>
> -   if (cmd & IOC_IN) {
> -   if (copy_from_user(kdata, (void __user *)arg,
> -  usize) != 0) {
> -   retcode = -EFAULT;
> +   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
> +   if (unlikely(retcode))

That "unlikely" seems redundant given that all error paths in
drm_ioctl_permit() already are "unlikely".

Otherwise, patch looks good:
Reviewed-by: David Herrmann 

Thanks
David

> +   goto err_i1;
> +
> +   if (cmd & (IOC_IN | IOC_OUT)) {
> +   if (asize <= sizeof(stack_kdata)) {
> +   kdata = stack_kdata;
> +   } else {
> +   kdata = kmalloc(asize, GFP_KERNEL);
> +   if (!kdata) {
> +   retcode = -ENOMEM;
> goto err_i1;
> }
> -   } else
> -   memset(kdata, 0, usize);
> -
> -   if (ioctl->flags & DRM_UNLOCKED)
> -   retcode = func(dev, kdata, file_priv);
> -   else {
> -   mutex_lock(_global_mutex);
> -   

[PATCH 1/5] drm: Have the crtc code only reference master from legacy nodes

2014-03-13 Thread David Herrmann
Hi

On Thu, Mar 13, 2014 at 11:57 AM, Thomas Hellstrom
 wrote:
> control- and render nodes are intended to be master-less.
>
> Signed-off-by: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/drm_crtc.c |   15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 3b7d32d..c9d895a 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1398,7 +1398,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> uint32_t __user *crtc_id;
> uint32_t __user *connector_id;
> uint32_t __user *encoder_id;
> -   struct drm_mode_group *mode_group;
> +   struct drm_mode_group *mode_group = NULL;

Why not move this mode_group=NULL; into the if() condition below?
Avoids global initialization and makes the "if() - else" parts easier
to read as you directly see that mode_group is set to NULL for
non-legacy nodes.

>
> if (!drm_core_check_feature(dev, DRIVER_MODESET))
> return -EINVAL;
> @@ -1429,8 +1429,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> mutex_unlock(_priv->fbs_lock);
>
> drm_modeset_lock_all(dev);
> -   mode_group = _priv->master->minor->mode_group;
> -   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
> +   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
>
> list_for_each(lh, >mode_config.crtc_list)
> crtc_count++;
> @@ -1442,6 +1441,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> encoder_count++;
> } else {
>
> +   mode_group = _priv->master->minor->mode_group;
> crtc_count = mode_group->num_crtcs;
> connector_count = mode_group->num_connectors;
> encoder_count = mode_group->num_encoders;
> @@ -1456,7 +1456,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> if (card_res->count_crtcs >= crtc_count) {
> copied = 0;
> crtc_id = (uint32_t __user *)(unsigned 
> long)card_res->crtc_id_ptr;
> -   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
> +   if (file_priv->minor->type != DRM_MINOR_LEGACY) {

if (!mode_group) {

You set mode_group=NULL with your patch, so I think it's much easier
to read if you replace all these minor-id-tests with "if
(!mode_group)". This moves the group-selection to the head of the
function and makes the remaining parts just work on the selected group
(or global if NULL).

Same for the two conditions below..

Apart from that:
Reviewed-by: David Herrmann 

Thanks
David

> list_for_each_entry(crtc, >mode_config.crtc_list,
> head) {
> DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
> @@ -1483,7 +1483,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> if (card_res->count_encoders >= encoder_count) {
> copied = 0;
> encoder_id = (uint32_t __user *)(unsigned 
> long)card_res->encoder_id_ptr;
> -   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
> +   if (file_priv->minor->type != DRM_MINOR_LEGACY) {

if (!mode_group) {

> list_for_each_entry(encoder,
> >mode_config.encoder_list,
> head) {
> @@ -1514,7 +1514,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
> *data,
> if (card_res->count_connectors >= connector_count) {
> copied = 0;
> connector_id = (uint32_t __user *)(unsigned 
> long)card_res->connector_id_ptr;
> -   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
> +   if (file_priv->minor->type != DRM_MINOR_LEGACY) {

if (!mode_group) {

> list_for_each_entry(connector,
> >mode_config.connector_list,
> head) {
> @@ -2715,7 +2715,8 @@ int drm_mode_getfb(struct drm_device *dev,
> r->bpp = fb->bits_per_pixel;
> r->pitch = fb->pitches[0];
> if (fb->funcs->create_handle) {
> -   if (file_priv->is_master || capable(CAP_SYS_ADMIN)) {
> +   if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
> +   file_priv->minor->type == DRM_MINOR_CONTROL) {
> ret = fb->funcs->create_handle(fb, file_priv,
>>handle);
> } else {
> --
> 1.7.10.4
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/5] Control node master fixes WAS:

2014-03-13 Thread Thomas Hellstrom
Hmm. Screwed up git-send-email a bit :(
Resending with new subject.

/Thomas


On 03/13/2014 11:57 AM, Thomas Hellstrom wrote:
> After a previous patch series and a discussion with Daniel Vetter and
> David Herrmann, I've reworked the patches a bit. Please review.
>
> Patch 5 is already reviewed.
>
> /Thomas
>
> >From Thomas Hellstrom  # This line is ignored.
> From: Thomas Hellstrom 
> Subject: 
> In-Reply-To: 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] drm: Remove the minor master list

2014-03-13 Thread Thomas Hellstrom
It doesn't appear to be used anywhere.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: David Herrmann 
---
 drivers/gpu/drm/drm_stub.c |5 -
 include/drm/drmP.h |2 --
 2 files changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 98a33c580..4f17c79 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -152,8 +152,6 @@ struct drm_master *drm_master_create(struct drm_minor 
*minor)
INIT_LIST_HEAD(>magicfree);
master->minor = minor;

-   list_add_tail(>head, >master_list);
-
return master;
 }

@@ -171,8 +169,6 @@ static void drm_master_destroy(struct kref *kref)
struct drm_device *dev = master->minor->dev;
struct drm_map_list *r_list, *list_temp;

-   list_del(>head);
-
if (dev->driver->master_destroy)
dev->driver->master_destroy(dev, master);

@@ -296,7 +292,6 @@ static int drm_get_minor(struct drm_device *dev, struct 
drm_minor **minor,
new_minor->device = MKDEV(DRM_MAJOR, minor_id);
new_minor->dev = dev;
new_minor->index = minor_id;
-   INIT_LIST_HEAD(_minor->master_list);

idr_replace(_minors_idr, new_minor, minor_id);

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 5db7f86..33e55c7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -718,7 +718,6 @@ struct drm_master {

struct kref refcount; /* refcount for this master */

-   struct list_head head; /**< each minor contains a list of masters */
struct drm_minor *minor; /**< link back to minor we are a master for */

char *unique;   /**< Unique identifier: e.g., busid */
@@ -1050,7 +1049,6 @@ struct drm_minor {
struct mutex debugfs_lock; /* Protects debugfs_list. */

struct drm_master *master; /* currently active master for this node */
-   struct list_head master_list;
struct drm_mode_group mode_group;
 };

-- 
1.7.10.4


[PATCH 4/5] drm: Improve on minor type helpers

2014-03-13 Thread Thomas Hellstrom
Add a drm_is_legacy() helper, constify argument to drm_is_render_client(),
and use / change helpers where appropriate.

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_crtc.c |   10 +-
 drivers/gpu/drm/drm_fops.c |5 ++---
 include/drm/drmP.h |9 +++--
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index c9d895a..4190c7e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1429,7 +1429,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
mutex_unlock(_priv->fbs_lock);

drm_modeset_lock_all(dev);
-   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
+   if (!drm_is_legacy(file_priv)) {

list_for_each(lh, >mode_config.crtc_list)
crtc_count++;
@@ -1456,7 +1456,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_crtcs >= crtc_count) {
copied = 0;
crtc_id = (uint32_t __user *)(unsigned 
long)card_res->crtc_id_ptr;
-   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
+   if (!drm_is_legacy(file_priv)) {
list_for_each_entry(crtc, >mode_config.crtc_list,
head) {
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
@@ -1483,7 +1483,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_encoders >= encoder_count) {
copied = 0;
encoder_id = (uint32_t __user *)(unsigned 
long)card_res->encoder_id_ptr;
-   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
+   if (!drm_is_legacy(file_priv)) {
list_for_each_entry(encoder,
>mode_config.encoder_list,
head) {
@@ -1514,7 +1514,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_connectors >= connector_count) {
copied = 0;
connector_id = (uint32_t __user *)(unsigned 
long)card_res->connector_id_ptr;
-   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
+   if (!drm_is_legacy(file_priv)) {
list_for_each_entry(connector,
>mode_config.connector_list,
head) {
@@ -2716,7 +2716,7 @@ int drm_mode_getfb(struct drm_device *dev,
r->pitch = fb->pitches[0];
if (fb->funcs->create_handle) {
if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
-   file_priv->minor->type == DRM_MINOR_CONTROL) {
+   drm_is_control(file_priv)) {
ret = fb->funcs->create_handle(fb, file_priv,
   >handle);
} else {
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 08a3196..31a4655 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -259,8 +259,7 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
/* if there is no current master make this fd it, but do not create
 * any master object for render clients */
mutex_lock(>struct_mutex);
-   if (!priv->minor->master && !drm_is_render_client(priv) &&
-   !drm_is_control(priv)) {
+   if (drm_is_legacy(priv) && !priv->minor->master) {
/* create a new master */
priv->minor->master = drm_master_create(priv->minor);
if (!priv->minor->master) {
@@ -298,7 +297,7 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
goto out_close;
}
}
-   } else if (!drm_is_render_client(priv) && !drm_is_control(priv)) {
+   } else if (drm_is_legacy(priv)) {
/* get a reference to the master */
priv->master = drm_master_get(priv->minor->master);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ff68e26..5db7f86 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1241,16 +1241,21 @@ static inline bool drm_modeset_is_locked(struct 
drm_device *dev)
return mutex_is_locked(>mode_config.mutex);
 }

-static inline bool drm_is_render_client(struct drm_file *file_priv)
+static inline bool drm_is_render_client(const struct drm_file *file_priv)
 {
return file_priv->minor->type == DRM_MINOR_RENDER;
 }

-static inline bool drm_is_control(struct drm_file *file_priv)
+static inline bool drm_is_control(const struct drm_file *file_priv)
 {
return file_priv->minor->type == DRM_MINOR_CONTROL;
 }

+static inline bool drm_is_legacy(const struct drm_file *file_priv)
+{
+   return file_priv->minor->type == 

[PATCH 3/5] drm: Make control nodes master-less v2

2014-03-13 Thread Thomas Hellstrom
Like for render-nodes, there is no point in maintaining the master concept
for control nodes, so set the struct drm_file::master pointer to NULL.

At the same time, make sure DRM_MASTER | DRM_CONTROL_ALLOW ioctls are always
allowed when called through the control node. Previously the caller also
needed to be master.

v2: Adapt to refactoring of ioctl permission check.

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_drv.c  |9 +
 drivers/gpu/drm/drm_fops.c |5 +++--
 include/drm/drmP.h |5 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 0afc6e4..e41ee82 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -307,14 +307,15 @@ static int drm_ioctl_permit(u32 flags, struct drm_file 
*file_priv)
if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
 !file_priv->authenticated))
return -EACCES;
-
-   /* MASTER is only for master */
-   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
+   
+   /* MASTER is only for master or control clients */
+   if (unlikely((flags & DRM_MASTER) &&
+!(file_priv->is_master || drm_is_control(file_priv
return -EACCES;

/* Control clients must be explicitly allowed */
if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
-file_priv->minor->type == DRM_MINOR_CONTROL))
+drm_is_control(file_priv)))
return -EACCES;

/* Render clients must be explicitly allowed */
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7f2af9a..08a3196 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -259,7 +259,8 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
/* if there is no current master make this fd it, but do not create
 * any master object for render clients */
mutex_lock(>struct_mutex);
-   if (!priv->minor->master && !drm_is_render_client(priv)) {
+   if (!priv->minor->master && !drm_is_render_client(priv) &&
+   !drm_is_control(priv)) {
/* create a new master */
priv->minor->master = drm_master_create(priv->minor);
if (!priv->minor->master) {
@@ -297,7 +298,7 @@ static int drm_open_helper(struct inode *inode, struct file 
*filp,
goto out_close;
}
}
-   } else if (!drm_is_render_client(priv)) {
+   } else if (!drm_is_render_client(priv) && !drm_is_control(priv)) {
/* get a reference to the master */
priv->master = drm_master_get(priv->minor->master);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 04a7f31..ff68e26 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1246,6 +1246,11 @@ static inline bool drm_is_render_client(struct drm_file 
*file_priv)
return file_priv->minor->type == DRM_MINOR_RENDER;
 }

+static inline bool drm_is_control(struct drm_file *file_priv)
+{
+   return file_priv->minor->type == DRM_MINOR_CONTROL;
+}
+
 /**/
 /** \name Internal function definitions */
 /*@{*/
-- 
1.7.10.4


[PATCH 2/5] drm: Break out ioctl permission check to a separate function

2014-03-13 Thread Thomas Hellstrom
Helps reviewing and understanding these checks.

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_drv.c |  116 ++---
 1 file changed, 78 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 345be03..0afc6e4 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -285,6 +285,47 @@ static int drm_version(struct drm_device *dev, void *data,
return err;
 }

+
+/**
+ * drm_ioctl_permit - Check ioctl permissions against caller
+ *
+ * @flags: ioctl permission flags.
+ * @file_priv: Pointer to struct drm_file identifying the caller.
+ *
+ * Checks whether the caller is allowed to run an ioctl with the
+ * indicated permissions. If so, returns zero. Otherwise returns an
+ * error code suitable for ioctl return.
+ */
+static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
+{
+
+   /* ROOT_ONLY is only for CAP_SYS_ADMIN */
+   if (unlikely((flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)))
+   return -EACCES;
+
+   /* AUTH is only for authenticated or render client */
+   if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
+!file_priv->authenticated))
+   return -EACCES;
+
+   /* MASTER is only for master */
+   if (unlikely((flags & DRM_MASTER) && !file_priv->is_master))
+   return -EACCES;
+
+   /* Control clients must be explicitly allowed */
+   if (unlikely(!(flags & DRM_CONTROL_ALLOW) &&
+file_priv->minor->type == DRM_MINOR_CONTROL))
+   return -EACCES;
+
+   /* Render clients must be explicitly allowed */
+   if (unlikely(!(flags & DRM_RENDER_ALLOW) &&
+drm_is_render_client(file_priv)))
+   return -EACCES;
+
+   return 0;
+}
+
+
 /**
  * Called whenever a process performs an ioctl on /dev/drm.
  *
@@ -350,52 +391,51 @@ long drm_ioctl(struct file *filp,
/* Do not trust userspace, use our own definition */
func = ioctl->func;

-   if (!func) {
+   if (unlikely(!func)) {
DRM_DEBUG("no function\n");
retcode = -EINVAL;
-   } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) 
||
-  ((ioctl->flags & DRM_AUTH) && 
!drm_is_render_client(file_priv) && !file_priv->authenticated) ||
-  ((ioctl->flags & DRM_MASTER) && !file_priv->is_master) ||
-  (!(ioctl->flags & DRM_CONTROL_ALLOW) && 
(file_priv->minor->type == DRM_MINOR_CONTROL)) ||
-  (!(ioctl->flags & DRM_RENDER_ALLOW) && 
drm_is_render_client(file_priv))) {
-   retcode = -EACCES;
-   } else {
-   if (cmd & (IOC_IN | IOC_OUT)) {
-   if (asize <= sizeof(stack_kdata)) {
-   kdata = stack_kdata;
-   } else {
-   kdata = kmalloc(asize, GFP_KERNEL);
-   if (!kdata) {
-   retcode = -ENOMEM;
-   goto err_i1;
-   }
-   }
-   if (asize > usize)
-   memset(kdata + usize, 0, asize - usize);
-   }
+   goto err_i1;
+   }

-   if (cmd & IOC_IN) {
-   if (copy_from_user(kdata, (void __user *)arg,
-  usize) != 0) {
-   retcode = -EFAULT;
+   retcode = drm_ioctl_permit(ioctl->flags, file_priv);
+   if (unlikely(retcode))
+   goto err_i1;
+
+   if (cmd & (IOC_IN | IOC_OUT)) {
+   if (asize <= sizeof(stack_kdata)) {
+   kdata = stack_kdata;
+   } else {
+   kdata = kmalloc(asize, GFP_KERNEL);
+   if (!kdata) {
+   retcode = -ENOMEM;
goto err_i1;
}
-   } else
-   memset(kdata, 0, usize);
-
-   if (ioctl->flags & DRM_UNLOCKED)
-   retcode = func(dev, kdata, file_priv);
-   else {
-   mutex_lock(_global_mutex);
-   retcode = func(dev, kdata, file_priv);
-   mutex_unlock(_global_mutex);
}
+   if (asize > usize)
+   memset(kdata + usize, 0, asize - usize);
+   }

-   if (cmd & IOC_OUT) {
-   if (copy_to_user((void __user *)arg, kdata,
-usize) != 0)
-   retcode = -EFAULT;
+   if (cmd & IOC_IN) {
+   if (copy_from_user(kdata, (void __user *)arg,
+  usize) != 0) {
+ 

[PATCH 1/5] drm: Have the crtc code only reference master from legacy nodes

2014-03-13 Thread Thomas Hellstrom
control- and render nodes are intended to be master-less.

Signed-off-by: Thomas Hellstrom 
---
 drivers/gpu/drm/drm_crtc.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 3b7d32d..c9d895a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1398,7 +1398,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
uint32_t __user *crtc_id;
uint32_t __user *connector_id;
uint32_t __user *encoder_id;
-   struct drm_mode_group *mode_group;
+   struct drm_mode_group *mode_group = NULL;

if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
@@ -1429,8 +1429,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
mutex_unlock(_priv->fbs_lock);

drm_modeset_lock_all(dev);
-   mode_group = _priv->master->minor->mode_group;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (file_priv->minor->type != DRM_MINOR_LEGACY) {

list_for_each(lh, >mode_config.crtc_list)
crtc_count++;
@@ -1442,6 +1441,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
encoder_count++;
} else {

+   mode_group = _priv->master->minor->mode_group;
crtc_count = mode_group->num_crtcs;
connector_count = mode_group->num_connectors;
encoder_count = mode_group->num_encoders;
@@ -1456,7 +1456,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_crtcs >= crtc_count) {
copied = 0;
crtc_id = (uint32_t __user *)(unsigned 
long)card_res->crtc_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
list_for_each_entry(crtc, >mode_config.crtc_list,
head) {
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
@@ -1483,7 +1483,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_encoders >= encoder_count) {
copied = 0;
encoder_id = (uint32_t __user *)(unsigned 
long)card_res->encoder_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
list_for_each_entry(encoder,
>mode_config.encoder_list,
head) {
@@ -1514,7 +1514,7 @@ int drm_mode_getresources(struct drm_device *dev, void 
*data,
if (card_res->count_connectors >= connector_count) {
copied = 0;
connector_id = (uint32_t __user *)(unsigned 
long)card_res->connector_id_ptr;
-   if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
+   if (file_priv->minor->type != DRM_MINOR_LEGACY) {
list_for_each_entry(connector,
>mode_config.connector_list,
head) {
@@ -2715,7 +2715,8 @@ int drm_mode_getfb(struct drm_device *dev,
r->bpp = fb->bits_per_pixel;
r->pitch = fb->pitches[0];
if (fb->funcs->create_handle) {
-   if (file_priv->is_master || capable(CAP_SYS_ADMIN)) {
+   if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
+   file_priv->minor->type == DRM_MINOR_CONTROL) {
ret = fb->funcs->create_handle(fb, file_priv,
   >handle);
} else {
-- 
1.7.10.4


No subject

2014-03-13 Thread Thomas Hellstrom
After a previous patch series and a discussion with Daniel Vetter and
David Herrmann, I've reworked the patches a bit. Please review.

Patch 5 is already reviewed.

/Thomas

>From Thomas Hellstrom  # This line is ignored.
From: Thomas Hellstrom 
Subject: 
In-Reply-To: 


[PATCH] drm/exynos: set the active aspect ratio as per mode

2014-03-13 Thread Shirish S
Now that the drm_display_mode also provides aspect
ratio for all resolutions, this patch adds its usage
to set the active aspect ratio of AVI info frame
packets as per CEA-861-D standard's Table 9.

This is also needed to abide by the 7-27
compliance test of HDMI.

Signed-off-by: Shirish S 
---
V2: rebased on new branch
V3: Incorporated review comments

 drivers/gpu/drm/exynos/exynos_hdmi.c |   35 +++---
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 12fdf55..9b0b617 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -53,12 +53,13 @@
 /* AVI header and aspect ratio */
 #define HDMI_AVI_VERSION   0x02
 #define HDMI_AVI_LENGTH0x0D
-#define AVI_PIC_ASPECT_RATIO_16_9  (2 << 4)
-#define AVI_SAME_AS_PIC_ASPECT_RATIO   8

 /* AUI header info */
 #define HDMI_AUI_VERSION   0x01
 #define HDMI_AUI_LENGTH0x0A
+#defineAVI_SAME_AS_PIC_ASPECT_RATIO 0x8
+#defineAVI_4_3_CENTER_RATIO0x9
+#defineAVI_16_9_CENTER_RATIO   0xa

 enum hdmi_type {
HDMI_TYPE13,
@@ -162,6 +163,7 @@ struct hdmi_v14_conf {
 struct hdmi_conf_regs {
int pixel_clock;
int cea_video_id;
+   enum hdmi_picture_aspect aspect_ratio;
union {
struct hdmi_v13_conf v13_conf;
struct hdmi_v14_conf v14_conf;
@@ -669,7 +671,6 @@ static void hdmi_reg_infoframe(struct hdmi_context *hdata,
 {
u32 hdr_sum;
u8 chksum;
-   u32 aspect_ratio;
u32 mod;
u32 vic;

@@ -698,10 +699,28 @@ static void hdmi_reg_infoframe(struct hdmi_context *hdata,
AVI_ACTIVE_FORMAT_VALID |
AVI_UNDERSCANNED_DISPLAY_VALID);

-   aspect_ratio = AVI_PIC_ASPECT_RATIO_16_9;
-
-   hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2), aspect_ratio |
-   AVI_SAME_AS_PIC_ASPECT_RATIO);
+   /*
+* Set the aspect ratio as per the mode, mentioned in
+* Table 9 AVI InfoFrame Data Byte 2 of CEA-861-D Standard
+*/
+   switch (hdata->mode_conf.aspect_ratio) {
+   case HDMI_PICTURE_ASPECT_4_3:
+   hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+   hdata->mode_conf.aspect_ratio |
+   AVI_4_3_CENTER_RATIO);
+   break;
+   case HDMI_PICTURE_ASPECT_16_9:
+   hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+   hdata->mode_conf.aspect_ratio |
+   AVI_16_9_CENTER_RATIO);
+   break;
+   case HDMI_PICTURE_ASPECT_NONE:
+   default:
+   hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+   hdata->mode_conf.aspect_ratio |
+   AVI_SAME_AS_PIC_ASPECT_RATIO);
+   break;
+   }

vic = hdata->mode_conf.cea_video_id;
hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(4), vic);
@@ -1519,6 +1538,7 @@ static void hdmi_v13_mode_set(struct hdmi_context *hdata,
hdata->mode_conf.cea_video_id =
drm_match_cea_mode((struct drm_display_mode *)m);
hdata->mode_conf.pixel_clock = m->clock * 1000;
+   hdata->mode_conf.aspect_ratio = m->picture_aspect_ratio;

hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay);
hdmi_set_reg(core->h_v_line, 3, (m->htotal << 12) | m->vtotal);
@@ -1615,6 +1635,7 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata,
hdata->mode_conf.cea_video_id =
drm_match_cea_mode((struct drm_display_mode *)m);
hdata->mode_conf.pixel_clock = m->clock * 1000;
+   hdata->mode_conf.aspect_ratio = m->picture_aspect_ratio;

hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay);
hdmi_set_reg(core->v_line, 2, m->vtotal);
-- 
1.7.10.4



[PATCH] drm/exynos: add phy settings for RB resolutions

2014-03-13 Thread Shirish S
This patch adds support for the below mentioned
pixel clocks in Exynos5250.
Without them, following display modes won?t
be supported:

71 MHz  - 1280x800 at 60Hz RB
73.25 MHz   - 800x600 at 120Hz RB
88.75 MHz   - 1440x900 at 60Hz RB
115.5 MHz   - 1024x768 at 120Hz RB
119 MHz - 1680x1050 at 60Hz RB

Signed-off-by: Shirish S 
---
V2: Incorporated review comments

 drivers/gpu/drm/exynos/exynos_hdmi.c |   45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 12fdf55..406d89d 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -304,6 +304,24 @@ static const struct hdmiphy_config hdmiphy_v14_configs[] = 
{
},
},
{
+   .pixel_clock = 7100,
+   .conf = {
+   0x01, 0x91, 0x1e, 0x15, 0x40, 0x3c, 0xce, 0x08,
+   0x04, 0x20, 0xb2, 0xd8, 0x45, 0xa0, 0xac, 0x80,
+   0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86,
+   0x54, 0xad, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80,
+   },
+   },
+   {
+   .pixel_clock = 7325,
+   .conf = {
+   0x01, 0xd1, 0x1f, 0x15, 0x40, 0x18, 0xe9, 0x08,
+   0x02, 0xa0, 0xb7, 0xd8, 0x45, 0xa0, 0xac, 0x80,
+   0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86,
+   0x54, 0xa8, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80,
+   },
+   },
+   {
.pixel_clock = 74176000,
.conf = {
0x01, 0xd1, 0x3e, 0x35, 0x40, 0x5b, 0xde, 0x08,
@@ -331,6 +349,15 @@ static const struct hdmiphy_config hdmiphy_v14_configs[] = 
{
},
},
{
+   .pixel_clock = 8875,
+   .conf = {
+   0x01, 0x91, 0x25, 0x17, 0x40, 0x30, 0xfe, 0x08,
+   0x06, 0x20, 0xde, 0xd8, 0x45, 0xa0, 0xac, 0x80,
+   0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86,
+   0x54, 0x8a, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80,
+   },
+   },
+   {
.pixel_clock = 10650,
.conf = {
0x01, 0xd1, 0x2c, 0x12, 0x40, 0x0c, 0x09, 0x08,
@@ -349,6 +376,24 @@ static const struct hdmiphy_config hdmiphy_v14_configs[] = 
{
},
},
{
+   .pixel_clock = 11550,
+   .conf = {
+   0x01, 0xd1, 0x30, 0x1a, 0x40, 0x40, 0x10, 0x04,
+   0x04, 0xa0, 0x21, 0xd9, 0x45, 0xa0, 0xac, 0x80,
+   0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86,
+   0x54, 0xaa, 0x25, 0x03, 0x00, 0x00, 0x01, 0x80,
+   },
+   },
+   {
+   .pixel_clock = 11900,
+   .conf = {
+   0x01, 0x91, 0x32, 0x14, 0x40, 0x60, 0xd8, 0x08,
+   0x06, 0x20, 0x2a, 0xd9, 0x45, 0xa0, 0xac, 0x80,
+   0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86,
+   0x54, 0x9d, 0x25, 0x03, 0x00, 0x00, 0x01, 0x80,
+   },
+   },
+   {
.pixel_clock = 14625,
.conf = {
0x01, 0xd1, 0x3d, 0x15, 0x40, 0x18, 0xfd, 0x08,
-- 
1.7.10.4



nouveau_fan_update: possible circular locking dependency detected

2014-03-13 Thread Ilia Mirkin
On Sun, Mar 9, 2014 at 10:51 AM, Marcin Slusarz
 wrote:
> [  326.168487] ==
> [  326.168491] [ INFO: possible circular locking dependency detected ]
> [  326.168496] 3.13.6 #1270 Not tainted
> [  326.168500] ---
> [  326.168504] ldconfig/22297 is trying to acquire lock:
> [  326.168507]  (&(>fan->lock)->rlock){-.-...}, at: 
> [] nouveau_fan_update+0xeb/0x252 [nouveau]
> [  326.168551]
> but task is already holding lock:
> [  326.168555]  (&(>sensor.alarm_program_lock)->rlock){-.-...}, at: 
> [] alarm_timer_callback+0xf1/0x179 [nouveau]
> [  326.168587]
> which lock already depends on the new lock.
>
> [  326.168592]
> the existing dependency chain (in reverse order) is:
> [  326.168596]
> -> #1 (&(>sensor.alarm_program_lock)->rlock){-.-...}:
> [  326.168606][] lock_acquire+0xce/0x117
> [  326.168615][] _raw_spin_lock_irqsave+0x3f/0x51
> [  326.168623][] alarm_timer_callback+0xf1/0x179 
> [nouveau]
> [  326.168651][] 
> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
> [  326.168679][] nv04_timer_alarm+0xb5/0xbe 
> [nouveau]
> [  326.168708][] nouveau_fan_update+0x234/0x252 
> [nouveau]
> [  326.168735][] nouveau_fan_alarm+0x15/0x17 
> [nouveau]
> [  326.168763][] 
> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
> [  326.168790][] nv04_timer_intr+0x5b/0x13c 
> [nouveau]
> [  326.168817][] nouveau_mc_intr+0x2e2/0x3b1 
> [nouveau]
> [  326.168838][] handle_irq_event_percpu+0x5c/0x1dc
> [  326.168846][] handle_irq_event+0x3c/0x5c
> [  326.168852][] handle_edge_irq+0xc4/0xeb
> [  326.168860][] handle_irq+0x120/0x12d
> [  326.168868][] do_IRQ+0x48/0xaf
> [  326.168873][] ret_from_intr+0x0/0x13
> [  326.168881][] arch_cpu_idle+0x13/0x1d
> [  326.168887][] cpu_startup_entry+0x140/0x218
> [  326.168895][] start_secondary+0x1bf/0x1c4
> [  326.168902]
> -> #0 (&(>fan->lock)->rlock){-.-...}:
> [  326.168913][] __lock_acquire+0x10be/0x182b
> [  326.168920][] lock_acquire+0xce/0x117
> [  326.168924][] _raw_spin_lock_irqsave+0x3f/0x51
> [  326.168931][] nouveau_fan_update+0xeb/0x252 
> [nouveau]
> [  326.168958][] nouveau_therm_fan_set+0x14/0x16 
> [nouveau]
> [  326.168984][] nouveau_therm_update+0x303/0x312 
> [nouveau]
> [  326.169011][] nouveau_therm_alarm+0x13/0x15 
> [nouveau]
> [  326.169038][] 
> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
> [  326.169059][] nv04_timer_alarm+0xb5/0xbe 
> [nouveau]
> [  326.169079][] alarm_timer_callback+0x15e/0x179 
> [nouveau]
> [  326.169101][] 
> nv04_timer_alarm_trigger+0x1b1/0x1cb [nouveau]
> [  326.169121][] nv04_timer_intr+0x5b/0x13c 
> [nouveau]
> [  326.169142][] nouveau_mc_intr+0x2e2/0x3b1 
> [nouveau]
> [  326.169160][] handle_irq_event_percpu+0x5c/0x1dc
> [  326.169165][] handle_irq_event+0x3c/0x5c
> [  326.169170][] handle_edge_irq+0xc4/0xeb
> [  326.169175][] handle_irq+0x120/0x12d
> [  326.169179][] do_IRQ+0x48/0xaf
> [  326.169183][] ret_from_intr+0x0/0x13
> [  326.169189]
> other info that might help us debug this:
>
> [  326.169193]  Possible unsafe locking scenario:
>
> [  326.169195]CPU0CPU1
> [  326.169197]
> [  326.169199]   lock(&(>sensor.alarm_program_lock)->rlock);
> [  326.169205]
> lock(&(>fan->lock)->rlock);
> [  326.169211]
> lock(&(>sensor.alarm_program_lock)->rlock);
> [  326.169216]   lock(&(>fan->lock)->rlock);
> [  326.169221]
>  *** DEADLOCK ***
>
>  [  326.169225] 1 lock held by ldconfig/22297:
>  [  326.169229]  #0:  (&(>sensor.alarm_program_lock)->rlock){-.-...}, 
> at: [] alarm_timer_callback+0xf1/0x179 [nouveau]
>  [  326.169253]
>  stack backtrace:
>  [  326.169258] CPU: 7 PID: 22297 Comm: ldconfig Not tainted 3.13.6 #1270
>  [  326.169260] Hardware name: System manufacturer System Product Name/P6T 
> SE, BIOS 060309/02/2009
>  [  326.169264]  90fb6360 8801bfdc3a38 9059e369 
> 0006
>  [  326.169273]  90fb61b0 8801bfdc3a88 905998cf 
> 0002
>  [  326.169282]  8800b148dbe0 0001 8800b148e1e0 
> 0001
>  [  326.169342] Call Trace:
>  [  326.169344][] dump_stack+0x4e/0x71
>  [  326.169352]  [] print_circular_bug+0x2ad/0x2be
>  [  326.169356]  [] __lock_acquire+0x10be/0x182b
>  [  326.169360]  [] ? check_irq_usage+0x99/0xab
>  [  326.169365]  [] lock_acquire+0xce/0x117
>  [  326.169384]  [] ? nouveau_fan_update+0xeb/0x252 
> [nouveau]
>  [  326.169388]  [] _raw_spin_lock_irqsave+0x3f/0x51
>  [  326.169407]  [] ? nouveau_fan_update+0xeb/0x252 
> [nouveau]
>  [  326.169426]  [] ? nv04_timer_alarm_trigger+0x18d/0x1cb 

[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #14 from Sandeep  ---
Confirmed:

This commit : 10ebc0bc09344ab6310309169efc73dfe6c23d72

is the first bad commit where problems occur.

-- 
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/20140313/f349901d/attachment.html>


[Q] tilcdc and FBIO_WAITFORVSYNC

2014-03-13 Thread Robert Kuhn
Hi,

Rob Clark [robdclark at gmail.com]:
> you probably should use the KMS interface directly, rather than fbdev.
> Then you can modeset, do actual pageflips, get vblank events, etc.

> A couple examples:

Thanks for the hint. I compiled modeset buth was overwhelmed with the mode 
string (-s parameter).

Now I got a working example from
https://raw.github.com/dvdhrm/docs/master/drm-howto/modeset.c
and it seems it does what I want.

Thanks!

I know this is a developer list but I hope its okay to ask such questions.


[PULL] vmwgfx-fixes-3.14

2014-03-13 Thread Thomas Hellstrom
Dave,
A single fix for the new device code.

The following changes since commit 45db98e54242f3ae94bdcfbfe754e743252eb168:

  Merge branch 'drm-fixes-3.14' of git://people.freedesktop.org/~agd5f/linux 
into drm-fixes (2014-03-07 09:27:22 +1000)

are available in the git repository at:


  git://people.freedesktop.org/~thomash/linux tags/vmwgfx-fixes-3.14-2014-03-13

for you to fetch changes up to 4b0c82529b92cda4723cf1d09e1e2ee9b9ae96f1:

  drm/vmwgfx: Fix a surface reference corner-case in legacy emulation mode 
(2014-03-13 07:51:32 +0100)


Pull request of 2014-03-13


Thomas Hellstrom (1):
  drm/vmwgfx: Fix a surface reference corner-case in legacy emulation mode

 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |   18 ++
 1 file changed, 18 insertions(+)


[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #13 from Sandeep  ---
Still have 2-3 more revisions to test.

I suspect it is most likely this commit:
10ebc0bc09344ab6310309169efc73dfe6c23d72

-- 
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/20140313/fd9c40bd/attachment.html>


[PATCH 1/3] nouveau: cleanup error handling during nouveau_device_wrap

2014-03-13 Thread Emil Velikov
On 13/03/14 01:05, Ilia Mirkin wrote:
[snip]
>
> Not really. drm->drm_version will be 0 if ver fails.
>
Indeed, dev is calloc'ated by its callers, and if they mess around with 
that's their own fault.

Sorry for the noise.
-Emil


[PATCH 2/3] nouveau: sanitise NOUVEAU_LIBDRM_*_LIMIT_PERCENT input

2014-03-13 Thread Emil Velikov
On 13/03/14 00:49, Ilia Mirkin wrote:
> On Wed, Mar 12, 2014 at 4:45 PM, Emil Velikov  
> wrote:
>> Current handling relies on atoi which does not detect errors
>> additionally, any integer value will be considered as a valid
>> percent.
>>
>> Resolve that by using strtol and limiting the value within
>> the 5-100 (percent) range.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>   nouveau/nouveau.c | 24 +++-
>>   1 file changed, 15 insertions(+), 9 deletions(-)
>>
>> diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
>> index d6013db..06cd804 100644
>> --- a/nouveau/nouveau.c
>> +++ b/nouveau/nouveau.c
>> @@ -76,7 +76,7 @@ nouveau_device_wrap(int fd, int close, struct 
>> nouveau_device **pdev)
>>  struct nouveau_device *dev = >base;
>>  uint64_t chipset, vram, gart, bousage;
>>  drmVersionPtr ver;
>> -   int ret;
>> +   int ret, limit;
>>  char *tmp;
>>
>>   #ifdef DEBUG
>> @@ -121,16 +121,22 @@ nouveau_device_wrap(int fd, int close, struct 
>> nouveau_device **pdev)
>>
>>  nvdev->close = close;
>>
>> +   nvdev->vram_limit_percent = 80;
>>  tmp = getenv("NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT");
>> -   if (tmp)
>> -   nvdev->vram_limit_percent = atoi(tmp);
>> -   else
>> -   nvdev->vram_limit_percent = 80;
>> +   if (tmp) {
>> +   limit = strtol(tmp, NULL, 10);
>> +   if (limit >= 5 && limit <= 100)
>> +   nvdev->vram_limit_percent = limit;
>> +   }
>
> Wouldn't it be easier to just clamp the value no matter what? i.e.
> leave the current code alone, and add a clamp helper function + use
> it? These are pretty rare env vars to set... presumably the person
> setting them knows what they're doing. And if not, they get what they
> deserve.
>
> On a related topic, I'd personally rather not throw in arbitrary
> restrictions to code like this -- it makes debugging harder later on.
> (e.g. what's wrong with 0 percent? let's say i want to disable
> gart/vram entirely?)
>

Valid arguments, thanks.

-Emil
>> +
>> +   nvdev->gart_limit_percent = 80;
>>  tmp = getenv("NOUVEAU_LIBDRM_GART_LIMIT_PERCENT");
>> -   if (tmp)
>> -   nvdev->gart_limit_percent = atoi(tmp);
>> -   else
>> -   nvdev->gart_limit_percent = 80;
>> +   if (tmp) {
>> +   limit = strtol(tmp, NULL, 10);
>> +   if (limit >= 5 && limit <= 100)
>> +   nvdev->gart_limit_percent = limit;
>> +   }
>> +
>>  DRMINITLISTHEAD(>bo_list);
>>  nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS;
>>  nvdev->base.lib_version = 0x0100;
>> --
>> 1.9.0
>>
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel



[PATCH 1/3] nouveau: cleanup error handling during nouveau_device_wrap

2014-03-13 Thread Emil Velikov
On 13/03/14 00:45, Ilia Mirkin wrote:
> On Wed, Mar 12, 2014 at 4:45 PM, Emil Velikov  
> wrote:
>> In theory it's possible for any of the nouveau_getparam calls to
>> fail whist the last one being successful.
>>
>> Thus at least one of the following (hard requirements) drmVersion,
>> chipset and vram/gart memory size will be filled with garbage and
>> sent to the userspace drivers.
>
> What was wrong with the old logic again? Except annoying indentation?
>
> ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_CHIPSET_ID, );
> if (ret == 0)
> ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_FB_SIZE, );
> if (ret == 0)
> ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, );
> if (ret) {
> nouveau_device_del();
> return ret;
> }
>
> It will only run each successive getparam if the previous one succeeded...
>
Good point, the lovely indentation got me. So it seems only !ver 
handling is needed.

>
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>   nouveau/nouveau.c | 30 +++---
>>   1 file changed, 19 insertions(+), 11 deletions(-)
>>
>> diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
>> index ee7893b..d6013db 100644
>> --- a/nouveau/nouveau.c
>> +++ b/nouveau/nouveau.c
>> @@ -88,27 +88,32 @@ nouveau_device_wrap(int fd, int close, struct 
>> nouveau_device **pdev)
>>  nvdev->base.fd = fd;
>>
>>  ver = drmGetVersion(fd);
>> -   if (ver) dev->drm_version = (ver->version_major << 24) |
>> -   (ver->version_minor << 8) |
>> -ver->version_patchlevel;
>> +   if (!ver) {
>> +   ret = -errno;
>> +   goto error;
>> +   }
>> +
>> +   dev->drm_version = (ver->version_major << 24) |
>> +   (ver->version_minor << 8) |
>> +ver->version_patchlevel;
>>  drmFreeVersion(ver);
>>
>>  if ( dev->drm_version != 0x0010 &&
>>  (dev->drm_version <  0x0100 ||
>>   dev->drm_version >= 0x0200)) {
>> -   nouveau_device_del();
>> -   return -EINVAL;
>> +   ret = -EINVAL;
>> +   goto error;
>>  }
>>
>>  ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_CHIPSET_ID, );
>> -   if (ret == 0)
>> +   if (ret)
>> +   goto error;
>>  ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_FB_SIZE, );
>> -   if (ret == 0)
>> +   if (ret)
>> +   goto error;
>>  ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, );
>> -   if (ret) {
>> -   nouveau_device_del();
>> -   return ret;
>> -   }
>> +   if (ret)
>> +   goto error;
>>
>>  ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_HAS_BO_USAGE, 
>> );
>>  if (ret == 0)
>> @@ -139,6 +144,9 @@ nouveau_device_wrap(int fd, int close, struct 
>> nouveau_device **pdev)
>>
>>  *pdev = >base;
>>  return 0;
>> +error:
>> +   nouveau_device_del();
>> +   return -ret;
>
> you mean 'ret' of course.
>
Yikes, thanks.

-Emil

>>   }
>>
>>   int
>> --
>> 1.9.0
>>
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel



WARN_ON() and X session lost from i915 on 3.14-rc6

2014-03-13 Thread Pavel Machek
Hi!

This cost me two half-written mails...

So far it happened once, so it may be very infrequent; but I do not
think I seen similar failure from i915 before, so it may be an
regression. Well...

-22 should be EINVAL afaict.

Any ideas?
Pavel

[drm:i915_gem_object_get_pages] *ERROR* Attempting to obtain a
purgeable object
[drm:i915_gem_object_get_pages] *ERROR* Attempting to obtain a
purgeable object
[ cut here ]
WARNING: CPU: 0 PID: 2945 at drivers/gpu/drm/i915/i915_gem.c:1459
i915_gem_fault+0x10c/0x240()
unhandled error in i915_gem_fault: -22
Modules linked in:
CPU: 0 PID: 2945 Comm: Xorg Tainted: GW3.14.0-rc6+ #325
Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
03/31/2011
 05b3 f00ade08 c47db94b c4a318f4 f00ade38 c4037f9a c4a31ed0
 f00ade64
 0b81 c4a318f4 05b3 c436cb9c c436cb9c 0002 ea35af00
 f00adebc
 f00ade50 c403803e 0009 f00ade48 c4a31ed0 f00ade64 f00ade90
 c436cb9c
Call Trace:
 [] dump_stack+0x41/0x52
 [] warn_slowpath_common+0x7a/0xa0
 [] ? i915_gem_fault+0x10c/0x240
 [] ? i915_gem_fault+0x10c/0x240
 [] warn_slowpath_fmt+0x2e/0x30
 [] i915_gem_fault+0x10c/0x240
 [] __do_fault+0x57/0x490
 [] ? __lock_acquire+0x3ae/0xc80
 [] ? i915_gem_pwrite_ioctl+0x8a0/0x8a0
 [] handle_mm_fault+0x14b/0x750
 [] ? __do_page_fault+0xaf/0x410
 [] ? __do_page_fault+0x410/0x410
 [] ? __do_page_fault+0x410/0x410
 [] __do_page_fault+0xfc/0x410
 [] ? SyS_setitimer+0x45/0xd0
 [] ? SyS_ioctl+0x45/0x70
 [] ? __do_page_fault+0x410/0x410
 [] do_page_fault+0xb/0x10
 [] error_code+0x67/0x6c
---[ end trace c124d19552341c51 ]---
wlan0: deauthenticating from 00:33:13:01:31:45 by local choice
(reason=3)
cfg80211: Calling CRDA to update world regulatory domain
Chrome_IOThread[20585]: segfault at 0 ip b459e086 sp ad7f9da0 error 4
in chromium-browser[b3ecd000+390f000]
wlan0: authenticate with 00:33:13:01:31:45
wlan0: send auth to 00:33:13:01:31:45 (try 1/3)
wlan0: authenticated
wlan0: associate with 00:33:13:01:31:45 (try 1/3)


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


WARN_ON() and X session lost from i915 on 3.14-rc6

2014-03-13 Thread Chris Wilson
On Thu, Mar 13, 2014 at 12:30:39AM +0100, Pavel Machek wrote:
> Hi!
> 
> This cost me two half-written mails...
> 
> So far it happened once, so it may be very infrequent; but I do not
> think I seen similar failure from i915 before, so it may be an
> regression. Well...

It's a userspace use-after-free bug. Please file a bug on
bugs.freedesktop.org.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 75127] Radeon SUMO: GPU reset

2014-03-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=75127

--- Comment #12 from Sandeep  ---
I'm still bisecting, should be done after a few more revisions.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: