[Bug 110803] Coruption and flickering on polaris with mesa 19.0.5

2019-06-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110803

--- Comment #1 from crab2...@gmail.com ---
Almost same problem here. Drop in terimnal of visual studio code is failed to
be rendered. I can confirm the problem disappears if mesa downgrade to 19.0.4.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110803] Coruption and flickering on polaris with mesa 19.0.5

2019-06-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110803

crab2...@gmail.com changed:

   What|Removed |Added

 CC||crab2...@gmail.com

--- Comment #2 from crab2...@gmail.com ---
Created attachment 144408
  --> https://bugs.freedesktop.org/attachment.cgi?id=144408&action=edit
picture of visual studio code

I have noticed the problem on all of my machines with an polaris AMD card. 

RX 580
hades canyon

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 203779] drm:amdgpu_ib_ring_tests [amdgpu] *ERROR* IB test failed on gfx (-110)

2019-06-02 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=203779

--- Comment #1 from Gobinda Joy (gobinda@gmail.com) ---
Created attachment 283031
  --> https://bugzilla.kernel.org/attachment.cgi?id=283031&action=edit
Linux version 5.1.6-350.vanilla.knurd.1.fc30.x86_64

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 203781] New: AMDGPU Radeon VII crashes with dual monitors

2019-06-02 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=203781

Bug ID: 203781
   Summary: AMDGPU Radeon VII crashes with dual monitors
   Product: Drivers
   Version: 2.5
Kernel Version: 5.2.0-rc2, 5.1.x
  Hardware: x86-64
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: blocking
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-...@kernel-bugs.osdl.org
  Reporter: sehell...@gmail.com
Regression: No

Created attachment 283033
  --> https://bugzilla.kernel.org/attachment.cgi?id=283033&action=edit
dmesg with two monitors

System information:
Mainline kernel 5.2.0-rc2
Mesa 19.1.0_rc4
Card Radeon VII
Monitors LG 24UD58-B via DP

When using only one monitor, then everything works fine. But when using two,
the system starts to hang and try reset gpu.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 203781] AMDGPU Radeon VII crashes with dual monitors

2019-06-02 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=203781

--- Comment #1 from sehell...@gmail.com ---
Created attachment 283035
  --> https://bugzilla.kernel.org/attachment.cgi?id=283035&action=edit
dmesg with one monitor - all fine

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110813] Vega hung on Surviving Mars game

2019-06-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110813

Bug ID: 110813
   Summary: Vega hung on Surviving Mars game
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: stalk...@gmail.com
QA Contact: dri-devel@lists.freedesktop.org

Created attachment 144414
  --> https://bugs.freedesktop.org/attachment.cgi?id=144414&action=edit
kernel log

It happens every time after +-20 min of the gaming. (I have already many items
on the map)
it's happened last few months after update to kernel 5.0.

Kernel - 5.1.6-gentoo
GPU - Vega56
from glxinfo:
Radeon RX Vega (VEGA10, DRM 3.30.0, 5.1.6-gentoo, LLVM 9.0.0)
Mesa 19.2.0-devel (git-47a10edefb)


Call trace and error log in attachment.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/nouveau/bios: downgrade absence of tmds table to info from an error

2019-06-02 Thread Rhys Kidd
Absence of a TMDS Info Table is common on Optimus setups where the NVIDIA
gpu is not connected directly to any outputs.

Reporting an error in this scenario is too harsh. Accordingly, change the
error message to an info message.

By default the error message also causes a boot flicker for these sytems.

Signed-off-by: Rhys Kidd 
---
 drivers/gpu/drm/nouveau/nouveau_bios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c 
b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 66bf2aff4a3e..bdfadc63204a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -935,7 +935,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, 
struct nvbios *bios,
 
tmdstableptr = ROM16(bios->data[bitentry->offset]);
if (!tmdstableptr) {
-   NV_ERROR(drm, "Pointer to TMDS table invalid\n");
+   NV_INFO(drm, "Pointer to TMDS table not found\n");
return -EINVAL;
}
 
-- 
2.20.1



Re: [PATCH AUTOSEL 4.4 44/56] video: imsttfb: fix potential NULL pointer dereferences

2019-06-02 Thread Sasha Levin

On Sat, Jun 01, 2019 at 09:19:29AM -0700, Greg Kroah-Hartman wrote:

On Sat, Jun 01, 2019 at 09:25:48AM -0400, Sasha Levin wrote:

From: Kangjie Lu 

[ Upstream commit 1d84353d205a953e2381044953b7fa31c8c9702d ]

In case ioremap fails, the fix releases resources and returns
-ENOMEM to avoid NULL pointer dereferences.

Signed-off-by: Kangjie Lu 
Cc: Aditya Pakki 
Cc: Finn Thain 
Cc: Rob Herring 
Cc: Greg Kroah-Hartman 
[b.zolnierkie: minor patch summary fixup]
Signed-off-by: Bartlomiej Zolnierkiewicz 
Signed-off-by: Sasha Levin 
---
 drivers/video/fbdev/imsttfb.c | 5 +
 1 file changed, 5 insertions(+)


Why only 4.4.y?  Shouldn't this be queued up for everything or none?


It's on all branches. Something weird happened with git-send-email and
mail.kernel.org, and apparently the rest of the branches didn't get all
their mails sent out. Sadly I don't have the logs for that :(

--
Thanks,
Sasha
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 1/2] drm/nouveau/bios/init: handle INIT_RESET_BEGUN devinit opcode

2019-06-02 Thread Rhys Kidd
Signal that the reset sequence has begun.

This opcode signals that the software reset sequence has begun.
Ordinarily, no actual operations are performed by the opcode.
However it allows for possible software work arounds by devinit
engines in software agents other than the VBIOS, such as the resman,
FCODE, and EFI driver.

Signed-off-by: Rhys Kidd 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
index ec0e9f7224b5..a54b5e410dcd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
@@ -1934,6 +1934,17 @@ init_ram_restrict_pll(struct nvbios_init *init)
}
 }
 
+/**
+ * INIT_RESET_BEGUN - opcode 0x8c
+ *
+ */
+static void
+init_reset_begun(struct nvbios_init *init)
+{
+   trace("RESET_BEGUN\n");
+   init->offset += 1;
+}
+
 /**
  * INIT_GPIO - opcode 0x8e
  *
@@ -2260,7 +2271,7 @@ static struct nvbios_init_opcode {
[0x79] = { init_pll },
[0x7a] = { init_zm_reg },
[0x87] = { init_ram_restrict_pll },
-   [0x8c] = { init_reserved },
+   [0x8c] = { init_reset_begun },
[0x8d] = { init_reserved },
[0x8e] = { init_gpio },
[0x8f] = { init_ram_restrict_zm_reg_group },
-- 
2.20.1



[PATCH 0/2] drm/nouveau/bios/init: Improve pre-PMU devinit opcode coverage

2019-06-02 Thread Rhys Kidd
NVIDIA GPUs include a common scripting language (devinit) that can be
interpreted by a number of "engines", e.g. within a kernel-mode software
driver, the VGA BIOS or an on-board small microcontroller which provides
certain security assertions (the 'PMU').

This system allows a GPU programming sequence to be shared by multiple
entities that would not otherwise be able to execute common code.

This series adds support to nouveau for two opcodes seen on VBIOSes prior
to the locked-down PMU taking over responsibility for executing devinit
scripts.

Documentation for these two opcodes can be found at:

  https://github.com/envytools/envytools/pull/189

Rhys Kidd (2):
  drm/nouveau/bios/init: handle INIT_RESET_BEGUN devinit opcode
  drm/nouveau/bios/init: handle INIT_RESET_END devinit opcode

 .../gpu/drm/nouveau/nvkm/subdev/bios/init.c   | 26 +--
 1 file changed, 24 insertions(+), 2 deletions(-)

-- 
2.20.1



[PATCH 2/2] drm/nouveau/bios/init: handle INIT_RESET_END devinit opcode

2019-06-02 Thread Rhys Kidd
Signal that the reset sequence has completed.

This opcode signals that the software reset sequence has completed.
Ordinarily, no actual operations are performed by the opcode.
However it allows for possible software work arounds by devinit
engines in software agents other than the VBIOS, such as the resman,
FCODE, and EFI driver.

Signed-off-by: Rhys Kidd 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
index a54b5e410dcd..49d09503cd31 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
@@ -1945,6 +1945,17 @@ init_reset_begun(struct nvbios_init *init)
init->offset += 1;
 }
 
+/**
+ * INIT_RESET_END - opcode 0x8d
+ *
+ */
+static void
+init_reset_end(struct nvbios_init *init)
+{
+   trace("RESET_END\n");
+   init->offset += 1;
+}
+
 /**
  * INIT_GPIO - opcode 0x8e
  *
@@ -2272,7 +2283,7 @@ static struct nvbios_init_opcode {
[0x7a] = { init_zm_reg },
[0x87] = { init_ram_restrict_pll },
[0x8c] = { init_reset_begun },
-   [0x8d] = { init_reserved },
+   [0x8d] = { init_reset_end },
[0x8e] = { init_gpio },
[0x8f] = { init_ram_restrict_zm_reg_group },
[0x90] = { init_copy_zm_reg },
-- 
2.20.1



[PATCH -next] drm/amd/display: Use kmemdup in dc_copy_stream()

2019-06-02 Thread YueHaibing
Use kmemdup rather than duplicating its implementation.

Detected by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index a002e690814f..b166c732b532 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -167,12 +167,11 @@ struct dc_stream_state *dc_copy_stream(const struct 
dc_stream_state *stream)
 {
struct dc_stream_state *new_stream;
 
-   new_stream = kzalloc(sizeof(struct dc_stream_state), GFP_KERNEL);
+   new_stream = kmemdup(stream, sizeof(struct dc_stream_state),
+GFP_KERNEL);
if (!new_stream)
return NULL;
 
-   memcpy(new_stream, stream, sizeof(struct dc_stream_state));
-
if (new_stream->sink)
dc_sink_retain(new_stream->sink);



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] video: fbdev: Fix Warning comparing pointer to 0 reported by coccicheck

2019-06-02 Thread Shobhit Kukreti
drivers/video/fbdev/controlfb.c: WARNING comparing pointer to 0
drivers/video/fbdev/controlfb.c: WARNING comparing pointer to 0
drivers/video/fbdev/controlfb.c: WARNING comparing pointer to 0

Signed-off-by: Shobhit Kukreti 
---
 drivers/video/fbdev/controlfb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
index 7af8db2..07907c5 100644
--- a/drivers/video/fbdev/controlfb.c
+++ b/drivers/video/fbdev/controlfb.c
@@ -182,7 +182,7 @@ int init_module(void)
int ret = -ENXIO;
 
dp = of_find_node_by_name(NULL, "control");
-   if (dp != 0 && !control_of_init(dp))
+   if (dp != NULL && !control_of_init(dp))
ret = 0;
of_node_put(dp);
 
@@ -580,7 +580,7 @@ static int __init control_init(void)
control_setup(option);
 
dp = of_find_node_by_name(NULL, "control");
-   if (dp != 0 && !control_of_init(dp))
+   if (dp != NULL && !control_of_init(dp))
ret = 0;
of_node_put(dp);
 
@@ -683,8 +683,8 @@ static int __init control_of_init(struct device_node *dp)
return -ENXIO;
}
p = kzalloc(sizeof(*p), GFP_KERNEL);
-   if (p == 0)
-   return -ENXIO;
+   if (p == NULL)
+   return -ENOMEM;
control_fb = p; /* save it for cleanups */
 
/* Map in frame buffer and registers */
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm] etnaviv: Fix double-free in etna_bo_cache_free()

2019-06-02 Thread Marek Vasut
The following situation can happen in a multithreaded OpenGL application.
A BO is submitted from etna_cmd_stream #1 with flags set for read.
A BO is submitted from etna_cmd_stream #2 with flags set for write.
This triggers a flush on stream #1 and clears the BO's current_stream
pointer. If at this point, stream #2 attempts to queue BO again, which
does happen, the BO will be added to the submit list twice. The Linux
kernel driver correctly detects this and warns about it with "BO at
index %u already on submit list" kernel message.

However, when cleaning the BO cache in etna_bo_cache_free(), the BO
which was submitted twice will also be free()d twice, this triggering
a glibc double free detector.

The fix is easy, even if the BO does not have current_stream set,
iterate over current streams' list of BOs before adding the BO to it
and verify that the BO is not yet there.

Signed-off-by: Marek Vasut 
Cc: Christian Gmeiner 
Cc: Lucas Stach 
---
 etnaviv/etnaviv_cmd_stream.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/etnaviv/etnaviv_cmd_stream.c b/etnaviv/etnaviv_cmd_stream.c
index 7139c324..261777b0 100644
--- a/etnaviv/etnaviv_cmd_stream.c
+++ b/etnaviv/etnaviv_cmd_stream.c
@@ -150,11 +150,7 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, 
struct etna_bo *bo,
 
pthread_mutex_lock(&idx_lock);
 
-   if (!bo->current_stream) {
-   idx = append_bo(stream, bo);
-   bo->current_stream = stream;
-   bo->idx = idx;
-   } else if (bo->current_stream == stream) {
+   if (bo->current_stream == stream) {
idx = bo->idx;
} else {
/* slow-path: */
@@ -165,6 +161,8 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, 
struct etna_bo *bo,
/* not found */
idx = append_bo(stream, bo);
}
+   bo->current_stream = stream;
+   bo->idx = idx;
}
pthread_mutex_unlock(&idx_lock);
 
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 2/2] drm/panel: Add Novatek NT39016 panel support

2019-06-02 Thread Paul Cercueil
Add support for display panels built around the Novatek NT39016 display
controller, as found on e.g. the King Display KD035G6-54NT 24-bit
320x240 3.5" LCD panel which equips the GCW Zero open-source handheld
gaming console.

Signed-off-by: Paul Cercueil 
---
 drivers/gpu/drm/panel/Kconfig |   9 +
 drivers/gpu/drm/panel/Makefile|   1 +
 drivers/gpu/drm/panel/panel-novatek-nt39016.c | 368 ++
 3 files changed, 378 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-novatek-nt39016.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index e281fc544742..10b411b507cc 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -111,6 +111,15 @@ config DRM_PANEL_LG_LG4573
  Say Y here if you want to enable support for LG4573 RGB panel.
  To compile this driver as a module, choose M here.
 
+config DRM_PANEL_NOVATEK_NT39016
+   tristate "Novatek NT39016 RGB/SPI panel"
+   depends on OF && SPI
+   depends on BACKLIGHT_CLASS_DEVICE
+   select REGMAP_SPI
+   help
+ Say Y here if you want to enable support for the panels built
+ around the Novatek NT39016 display controller.
+
 config DRM_PANEL_OLIMEX_LCD_OLINUXINO
tristate "Olimex LCD-OLinuXino panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 78e3dc376bdd..c2c47fc99343 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_DRM_PANEL_INNOLUX_P079ZCA) += 
panel-innolux-p079zca.o
 obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o
 obj-$(CONFIG_DRM_PANEL_KINGDISPLAY_KD097D04) += panel-kingdisplay-kd097d04.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
+obj-$(CONFIG_DRM_PANEL_NOVATEK_NT39016) += panel-novatek-nt39016.o
 obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += panel-olimex-lcd-olinuxino.o
 obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
 obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += 
panel-panasonic-vvx10f034n00.o
diff --git a/drivers/gpu/drm/panel/panel-novatek-nt39016.c 
b/drivers/gpu/drm/panel/panel-novatek-nt39016.c
new file mode 100644
index ..2738d145d452
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-novatek-nt39016.c
@@ -0,0 +1,368 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Novatek NT39016 TFT LCD panel driver
+ *
+ * Copyright (C) 2017, Maarten ter Huurne 
+ * Copyright (C) 2019, Paul Cercueil 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+enum nt39016_regs {
+   NT39016_REG_SYSTEM,
+   NT39016_REG_TIMING,
+   NT39016_REG_OP,
+   NT39016_REG_DATA_IN,
+   NT39016_REG_SRC_TIMING_DELAY,
+   NT39016_REG_GATE_TIMING_DELAY,
+   NT39016_REG_RESERVED,
+   NT39016_REG_INITIAL_FUNC,
+   NT39016_REG_CONTRAST,
+   NT39016_REG_BRIGHTNESS,
+   NT39016_REG_HUE_SATURATION,
+   NT39016_REG_RB_SUBCONTRAST,
+   NT39016_REG_R_SUBBRIGHTNESS,
+   NT39016_REG_B_SUBBRIGHTNESS,
+   NT39016_REG_VCOMDC,
+   NT39016_REG_VCOMAC,
+   NT39016_REG_VGAM2,
+   NT39016_REG_VGAM34,
+   NT39016_REG_VGAM56,
+   NT39016_REG_VCOMDC_TRIM = 0x1e,
+   NT39016_REG_DISPLAY_MODE = 0x20,
+};
+
+struct nt39016_panel_info {
+   struct drm_display_mode display_mode;
+   u16 width_mm, height_mm;
+   u32 bus_format, bus_flags;
+};
+
+struct nt39016 {
+   struct drm_panel drm_panel;
+   struct device *dev;
+   struct regmap *map;
+   struct regulator *supply;
+   const struct nt39016_panel_info *panel_info;
+
+   struct gpio_desc *reset_gpio;
+
+   struct backlight_device *backlight;
+};
+
+static inline struct nt39016 *to_nt39016(struct drm_panel *panel)
+{
+   return container_of(panel, struct nt39016, drm_panel);
+}
+
+#define RV(REG, VAL) { .reg = (REG), .def = (VAL), .delay_us = 2 }
+static const struct reg_sequence nt39016_panel_regs[] = {
+   RV(NT39016_REG_SYSTEM, 0x04),
+   RV(NT39016_REG_TIMING, 0x00),
+   RV(NT39016_REG_OP, 0x03),
+   RV(NT39016_REG_DATA_IN, 0xCC),
+   RV(NT39016_REG_SRC_TIMING_DELAY, 0x46),
+   RV(NT39016_REG_GATE_TIMING_DELAY, 0x05),
+   RV(NT39016_REG_RESERVED, 0x00),
+   RV(NT39016_REG_INITIAL_FUNC, 0x00),
+   RV(NT39016_REG_CONTRAST, 0x08),
+   RV(NT39016_REG_BRIGHTNESS, 0x40),
+   RV(NT39016_REG_HUE_SATURATION, 0x88),
+   RV(NT39016_REG_RB_SUBCONTRAST, 0x88),
+   RV(NT39016_REG_R_SUBBRIGHTNESS, 0x20),
+   RV(NT39016_REG_B_SUBBRIGHTNESS, 0x20),
+   RV(NT39016_REG_VCOMDC, 0x67),
+   RV(NT39016_REG_VCOMAC, 0xA4),
+   RV(NT39016_REG_VGAM2, 0x04),
+   RV(NT39016_REG_VGAM34, 0x24),
+   RV(NT39016_REG_VGAM56, 0x24),
+   RV(NT39016_REG_DISPLAY_MODE, 0x00),
+};
+#undef RV
+
+static const struct regmap_range nt39016_regm

[PATCH 1/2] dt-bindings: display: Add King Display KD035G6-54NT panel documentation

2019-06-02 Thread Paul Cercueil
The KD035G6-54NT is a 3.5" 320x240 24-bit TFT LCD panel.

Signed-off-by: Paul Cercueil 
---
 .../panel/kingdisplay,kd035g6-54nt.txt| 27 +++
 1 file changed, 27 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt 
b/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
new file mode 100644
index ..a6e4a9af4925
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
@@ -0,0 +1,27 @@
+King Display KD035G6-54NT 3.5" (320x240 pixels) 24-bit TFT LCD panel
+
+Required properties:
+- compatible: should be "kingdisplay,kd035g6-54nt"
+- power-supply: See panel-common.txt
+- reset-gpios: See panel-common.txt
+
+Optional properties:
+- backlight: see panel-common.txt
+
+Example:
+
+&spi {
+   display-panel {
+   compatible = "kingdisplay,kd035g6-54nt";
+   reg = <0>;
+
+   spi-max-frequency = <3125000>;
+   spi-3wire;
+   spi-cs-high;
+
+   reset-gpios = <&gpe 2 GPIO_ACTIVE_LOW>;
+
+   backlight = <&backlight>;
+   power-supply = <&ldo6>;
+   };
+};
-- 
2.21.0.593.g511ec345e18



[Bug 110777] Kernel 5.1-5.2 MCLK stuck at 167MHz Vega 10 (56)

2019-06-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110777

--- Comment #1 from ant...@gmx.de ---
This is still occuring on latest linux master
cd6c84d8f0cdc911df435bb075ba22ce3c605b07

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/2] dt-bindings: display: Add King Display KD035G6-54NT panel documentation

2019-06-02 Thread Sam Ravnborg
Hi Paul.

As already said on irc, maybe add:

"The generic bindings for the SPI slaves documented in [1] also applies"
as we see other binding using spi already does.

Looking at: sitronix,st7789v.txt
should reg also be specified as required here?

Sam

On Sun, Jun 02, 2019 at 06:48:43PM +0200, Paul Cercueil wrote:
> The KD035G6-54NT is a 3.5" 320x240 24-bit TFT LCD panel.
> 
> Signed-off-by: Paul Cercueil 
> ---
>  .../panel/kingdisplay,kd035g6-54nt.txt| 27 +++
>  1 file changed, 27 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
>  
> b/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
> new file mode 100644
> index ..a6e4a9af4925
> --- /dev/null
> +++ 
> b/Documentation/devicetree/bindings/display/panel/kingdisplay,kd035g6-54nt.txt
> @@ -0,0 +1,27 @@
> +King Display KD035G6-54NT 3.5" (320x240 pixels) 24-bit TFT LCD panel
> +
> +Required properties:
> +- compatible: should be "kingdisplay,kd035g6-54nt"
> +- power-supply: See panel-common.txt
> +- reset-gpios: See panel-common.txt
> +
> +Optional properties:
> +- backlight: see panel-common.txt
> +
> +Example:
> +
> +&spi {
> + display-panel {
> + compatible = "kingdisplay,kd035g6-54nt";
> + reg = <0>;
> +
> + spi-max-frequency = <3125000>;
> + spi-3wire;
> + spi-cs-high;
> +
> + reset-gpios = <&gpe 2 GPIO_ACTIVE_LOW>;
> +
> + backlight = <&backlight>;
> + power-supply = <&ldo6>;
> + };
> +};
> -- 
> 2.21.0.593.g511ec345e18


Re: [PATCH 2/2] drm/panel: Add Novatek NT39016 panel support

2019-06-02 Thread Sam Ravnborg
Hi Paul.

Nice driver.
Feedback, mostly a repeat from irc, but you get it here too so others
can follow.

The backlight handling can be simplified.
Please see panel-innolux-p079zca.c as one (semi random) example.

Sam
> 
> Signed-off-by: Paul Cercueil 

This driver is authored by Maarten ter Huurne 
as well as you.
Could you get a s-o-b or at least some other formal
attribution of Maarten in the changelog.


> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Recently (after I was there) panels sort the include in blocks like
this:

#include 

#include 

#include 

Within each block the header files are sorted.

For media-bus-format.h - you could use:
#include 

> +
> +static int nt39016_prepare(struct drm_panel *drm_panel)
> +{
> + struct nt39016 *panel = to_nt39016(drm_panel);
> + int err;
> +
> + err = regulator_enable(panel->supply);
> + if (err) {
> + dev_err(panel->dev, "Failed to enable power supply: %i", err);
> + return err;
> + }
> +
> + /*
> +  * Reset the NT39016.
> +  * The documentation says the reset pulse should be at least 40 us to
> +  * pass the glitch filter, but when testing I see some resets fail and
> +  * some succeed when using a 70 us delay, so we use 100 us instead.
> +  */
> + gpiod_set_value_cansleep(panel->reset_gpio, 1);
> + usleep_range(100, 1000);
> + gpiod_set_value_cansleep(panel->reset_gpio, 0);
> + udelay(2);
> +
> + /* Init all registers. */
> + err = regmap_multi_reg_write(panel->map, nt39016_panel_regs,
> +  ARRAY_SIZE(nt39016_panel_regs));

Nice!

> + if (err) {
> + dev_err(panel->dev, "Failed to init registers: %i", err);

Maybe it is just me, but I wonder why %i and not %d?
You are consistent which is good.
But I saw no other panle drivers use %i, so consider to do like the
rest.


> + goto err_disable_regulator;
> + }
> +
> + return 0;
> +
> +err_disable_regulator:
> + regulator_disable(panel->supply);
> + return err;
> +}
> +
> +static int nt39016_unprepare(struct drm_panel *drm_panel)
> +{
> + struct nt39016 *panel = to_nt39016(drm_panel);
> +
> + gpiod_set_value_cansleep(panel->reset_gpio, 1);
> +
> + regulator_disable(panel->supply);
> +
> + return 0;
> +}
> +
> +static int nt39016_enable(struct drm_panel *drm_panel)
> +{
> + struct nt39016 *panel = to_nt39016(drm_panel);
> + int err;
> +
> + err = regmap_write(panel->map, NT39016_REG_SYSTEM, 0x07);
> + if (err) {
> + dev_err(panel->dev, "Unable to enable panel: %i", err);
> + return err;
> + }
> +
> + /* Wait for the picture to be ready before enabling backlight */
> + msleep(150);
> +
> + if (panel->backlight) {
> + panel->backlight->props.state &= ~BL_CORE_FBBLANK;
> + panel->backlight->props.power = FB_BLANK_UNBLANK;
> + backlight_update_status(panel->backlight);
> + }
> +
> + return 0;
> +}
> +
> +static int nt39016_disable(struct drm_panel *drm_panel)
> +{
> + struct nt39016 *panel = to_nt39016(drm_panel);
> + int err;
> +
> + if (panel->backlight) {
> + panel->backlight->props.power = FB_BLANK_POWERDOWN;
> + panel->backlight->props.state |= BL_CORE_FBBLANK;
> + backlight_update_status(panel->backlight);
> + }
> +
> + err = regmap_write(panel->map, NT39016_REG_SYSTEM, 0x05);
> + if (err) {
> + dev_err(panel->dev, "Unable to disable panel: %i", err);
> + return err;
> + }
> +
> + return 0;
> +}
Can we get some nice constants for 0x04, 0x05 and 0x07?
(All values written to NT39016_REG_SYSTEM).

> +
> +static int nt39016_get_modes(struct drm_panel *drm_panel)
> +{
> + struct nt39016 *panel = to_nt39016(drm_panel);
> + const struct nt39016_panel_info *panel_info = panel->panel_info;
> + struct drm_connector *connector = drm_panel->connector;
> + struct drm_display_mode *mode;
> +
> + mode = drm_mode_duplicate(drm_panel->drm, &panel_info->display_mode);
> + if (!mode)
> + return -ENOMEM;
> +
> + drm_mode_set_name(mode);
> +
> + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> + drm_mode_probed_add(connector, mode);
> +
> + connector->display_info.bpc = 8;
> + connector->display_info.width_mm = panel_info->width_mm;
> + connector->display_info.height_mm = panel_info->height_mm;
> +
> + drm_display_info_set_bus_formats(&connector->display_info,
> +  &panel_info->bus_format, 1);
> + connector->display_info.bus_flags = panel_info->bus_flags;
> +
> + return 1;
> +}
> +
> +static const struct drm_panel_funcs nt39016_funcs = {
> + .prepare= nt39016_prepare,
> + .unprepare  = nt39

Re: [PATCH] of/device: add blacklist for iommu dma_ops

2019-06-02 Thread Rob Clark
On Fri, May 10, 2019 at 7:35 AM Rob Clark  wrote:
>
> On Tue, Dec 4, 2018 at 2:29 PM Rob Herring  wrote:
> >
> > On Sat, Dec 1, 2018 at 10:54 AM Rob Clark  wrote:
> > >
> > > This solves a problem we see with drm/msm, caused by getting
> > > iommu_dma_ops while we attach our own domain and manage it directly at
> > > the iommu API level:
> > >
> > >   [0038] user address but active_mm is swapper
> > >   Internal error: Oops: 9605 [#1] PREEMPT SMP
> > >   Modules linked in:
> > >   CPU: 7 PID: 70 Comm: kworker/7:1 Tainted: GW 4.19.3 #90
> > >   Hardware name: xxx (DT)
> > >   Workqueue: events deferred_probe_work_func
> > >   pstate: 80c9 (Nzcv daif +PAN +UAO)
> > >   pc : iommu_dma_map_sg+0x7c/0x2c8
> > >   lr : iommu_dma_map_sg+0x40/0x2c8
> > >   sp : ff80095eb4f0
> > >   x29: ff80095eb4f0 x28: 
> > >   x27: ffc0f9431578 x26: 
> > >   x25:  x24: 0003
> > >   x23: 0001 x22: ffc0fa9ac010
> > >   x21:  x20: ffc0fab40980
> > >   x19: ffc0fab40980 x18: 0003
> > >   x17: 01c4 x16: 0007
> > >   x15: 000e x14: 
> > >   x13:  x12: 0028
> > >   x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f
> > >   x9 :  x8 : ffc0fab409a0
> > >   x7 :  x6 : 0002
> > >   x5 : 0001 x4 : 
> > >   x3 : 0001 x2 : 0002
> > >   x1 : ffc0f9431578 x0 : 
> > >   Process kworker/7:1 (pid: 70, stack limit = 0x17d08ffb)
> > >   Call trace:
> > >iommu_dma_map_sg+0x7c/0x2c8
> > >__iommu_map_sg_attrs+0x70/0x84
> > >get_pages+0x170/0x1e8
> > >msm_gem_get_iova+0x8c/0x128
> > >_msm_gem_kernel_new+0x6c/0xc8
> > >msm_gem_kernel_new+0x4c/0x58
> > >dsi_tx_buf_alloc_6g+0x4c/0x8c
> > >msm_dsi_host_modeset_init+0xc8/0x108
> > >msm_dsi_modeset_init+0x54/0x18c
> > >_dpu_kms_drm_obj_init+0x430/0x474
> > >dpu_kms_hw_init+0x5f8/0x6b4
> > >msm_drm_bind+0x360/0x6c8
> > >try_to_bring_up_master.part.7+0x28/0x70
> > >component_master_add_with_match+0xe8/0x124
> > >msm_pdev_probe+0x294/0x2b4
> > >platform_drv_probe+0x58/0xa4
> > >really_probe+0x150/0x294
> > >driver_probe_device+0xac/0xe8
> > >__device_attach_driver+0xa4/0xb4
> > >bus_for_each_drv+0x98/0xc8
> > >__device_attach+0xac/0x12c
> > >device_initial_probe+0x24/0x30
> > >bus_probe_device+0x38/0x98
> > >deferred_probe_work_func+0x78/0xa4
> > >process_one_work+0x24c/0x3dc
> > >worker_thread+0x280/0x360
> > >kthread+0x134/0x13c
> > >ret_from_fork+0x10/0x18
> > >   Code: d284 91000725 6b17039f 5400048a (f9401f40)
> > >   ---[ end trace f22dda57f3648e2c ]---
> > >   Kernel panic - not syncing: Fatal exception
> > >   SMP: stopping secondary CPUs
> > >   Kernel Offset: disabled
> > >   CPU features: 0x0,22802a18
> > >   Memory Limit: none
> > >
> > > The problem is that when drm/msm does it's own iommu_attach_device(),
> > > now the domain returned by iommu_get_domain_for_dev() is drm/msm's
> > > domain, and it doesn't have domain->iova_cookie.
> > >
> > > We kind of avoided this problem prior to sdm845/dpu because the iommu
> > > was attached to the mdp node in dt, which is a child of the toplevel
> > > mdss node (which corresponds to the dev passed in dma_map_sg()).  But
> > > with sdm845, now the iommu is attached at the mdss level so we hit the
> > > iommu_dma_ops in dma_map_sg().
> > >
> > > But auto allocating/attaching a domain before the driver is probed was
> > > already a blocking problem for enabling per-context pagetables for the
> > > GPU.  This problem is also now solved with this patch.
> > >
> > > Fixes: 97890ba9289c dma-mapping: detect and configure IOMMU in 
> > > of_dma_configure
> > > Tested-by: Douglas Anderson 
> > > Signed-off-by: Rob Clark 
> > > ---
> > > This is an alternative/replacement for [1].  What it lacks in elegance
> > > it makes up for in practicality ;-)
> > >
> > > [1] https://patchwork.freedesktop.org/patch/264930/
> > >
> > >  drivers/of/device.c | 22 ++
> > >  1 file changed, 22 insertions(+)
> > >
> > > diff --git a/drivers/of/device.c b/drivers/of/device.c
> > > index 5957cd4fa262..15ffee00fb22 100644
> > > --- a/drivers/of/device.c
> > > +++ b/drivers/of/device.c
> > > @@ -72,6 +72,14 @@ int of_device_add(struct platform_device *ofdev)
> > > return device_add(&ofdev->dev);
> > >  }
> > >
> > > +static const struct of_device_id iommu_blacklist[] = {
> > > +   { .compatible = "qcom,mdp4" },
> > > +   { .compatible = "qcom,mdss" },
> > > +   { .compatible = "qcom,sdm845-mdss" },
> > > +   { .compatible = "qcom,adreno" },
> > > +   {}
> > > +};
> >
> > Not completely clear to whether this is still needed or not, but this
> > really won't scale. Why can't the

[Bug 110781] Radeon: heavy r300 performance drop regression between 11.x and 19.x

2019-06-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110781

--- Comment #9 from Richard Thier  ---
The problem is now surely been between cf2e92262b4 (good) and 04ea03d99d8 (bad)
now. Still there are a number of some bisects still to do.

Also there is a chance there is a minor issue on the other side of 04ea03d99d8
as it was not that bad as the complete end-result, but the change is really
small on the other side so I went on bisecting the bigger problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

linux-next: unable to fetch the drm-intel-fixes tree

2019-06-02 Thread Stephen Rothwell
Hi all,

Trying to fetch the drm-intel-fixes tree today gives me this error:

-
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
-

The same for drm-misc-fixes, drm-intel and drm-misc.  These are all
hosted on git://anongit.freedesktop.org/ .

-- 
Cheers,
Stephen Rothwell


pgpftVnEXiVYn.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 00/10] Add C8, 30bpp and FP16 support to modetest

2019-06-02 Thread Ilia Mirkin
This series improves the pattern generation logic to support additional
formats, as well as a new "gradient" pattern (see patch comments on why
I found it useful).

Furthermore, these formats are piped through to modetest, including the
ability to set a gamma table, which is necessary for the C8 indexed
format.

This was tested on nouveau, and used for bring-up of the C8, XB30, and
FP16 formats on the NVIDIA hardware that supports these.

Ilia Mirkin (10):
  util: add C8 format, support it with SMPTE pattern
  util: fix MAKE_RGBA macro for 10bpp modes
  util: add gradient pattern
  util: add fp16 format support
  util: add cairo drawing for 30bpp formats when available
  modetest: don't pretend that atomic mode includes a format
  modetest: add an add_property_optional variant that does not print
errors
  modetest: add C8 support to generate SMPTE pattern
  modetest: add the ability to specify fill patterns on the commandline
  modetest: add FP16 format support

 tests/modetest/buffers.c  |  13 ++
 tests/modetest/modetest.c | 109 --
 tests/util/format.c   |   7 +
 tests/util/pattern.c  | 432 +-
 tests/util/pattern.h  |   7 +
 5 files changed, 543 insertions(+), 25 deletions(-)

-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 02/10] util: fix MAKE_RGBA macro for 10bpp modes

2019-06-02 Thread Ilia Mirkin
We need to shift the values up, otherwise we'd end up with a negative
shift. This works for up-to 16-bit components, which is fine for now.

Signed-off-by: Ilia Mirkin 
---
 tests/util/pattern.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index c84fee5a..8bdebd2c 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -60,11 +60,22 @@ struct color_yuv {
  .u = MAKE_YUV_601_U(r, g, b), \
  .v = MAKE_YUV_601_V(r, g, b) }
 
+static inline uint32_t shiftcolor(const struct util_color_component *comp,
+ uint32_t value)
+{
+   /* Fill the low bits with the high bits. */
+   value = (value << 8) | value;
+   /* Shift down to remove unwanted low bits */
+   value = value >> (16 - comp->length);
+   /* Shift back up to where the value should be */
+   return value << comp->offset;
+}
+
 #define MAKE_RGBA(rgb, r, g, b, a) \
-   r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \
-(((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \
-(((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
-(((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset))
+   (shiftcolor(&(rgb)->red, (r)) | \
+shiftcolor(&(rgb)->green, (g)) | \
+shiftcolor(&(rgb)->blue, (b)) | \
+shiftcolor(&(rgb)->alpha, (a)))
 
 #define MAKE_RGB24(rgb, r, g, b) \
{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 08/10] modetest: add C8 support to generate SMPTE pattern

2019-06-02 Thread Ilia Mirkin
This includes logic to configure the LUT accordingly.

Signed-off-by: Ilia Mirkin 
---
 tests/modetest/buffers.c  |  2 ++
 tests/modetest/modetest.c | 47 ++-
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 9b635c0c..5ec4ec8e 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -135,6 +135,7 @@ bo_create(int fd, unsigned int format,
int ret;
 
switch (format) {
+   case DRM_FORMAT_C8:
case DRM_FORMAT_NV12:
case DRM_FORMAT_NV21:
case DRM_FORMAT_NV16:
@@ -275,6 +276,7 @@ bo_create(int fd, unsigned int format,
planes[2] = virtual + offsets[2];
break;
 
+   case DRM_FORMAT_C8:
case DRM_FORMAT_ARGB:
case DRM_FORMAT_XRGB:
case DRM_FORMAT_ABGR:
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 71ddc861..7bb21d17 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1089,6 +1089,42 @@ static bool add_property_optional(struct device *dev, 
uint32_t obj_id,
return set_property(dev, &p);
 }
 
+static void set_gamma(struct device *dev, unsigned crtc_id, unsigned fourcc)
+{
+   unsigned blob_id = 0;
+   /* TODO: support 1024-sized LUTs, when the use-case arises */
+   struct drm_color_lut gamma_lut[256];
+   int i, ret;
+
+   if (fourcc == DRM_FORMAT_C8) {
+   /* TODO: Add C8 support for more patterns */
+   util_smpte_c8_gamma(256, gamma_lut);
+   drmModeCreatePropertyBlob(dev->fd, gamma_lut, 
sizeof(gamma_lut), &blob_id);
+   } else {
+   for (i = 0; i < 256; i++) {
+   gamma_lut[i].red =
+   gamma_lut[i].green =
+   gamma_lut[i].blue = i << 8;
+   }
+   }
+
+   add_property_optional(dev, crtc_id, "DEGAMMA_LUT", 0);
+   add_property_optional(dev, crtc_id, "CTM", 0);
+   if (!add_property_optional(dev, crtc_id, "GAMMA_LUT", blob_id)) {
+   uint16_t r[256], g[256], b[256];
+
+   for (i = 0; i < 256; i++) {
+   r[i] = gamma_lut[i].red;
+   g[i] = gamma_lut[i].green;
+   b[i] = gamma_lut[i].blue;
+   }
+
+   ret = drmModeCrtcSetGamma(dev->fd, crtc_id, 256, r, g, b);
+   if (ret)
+   fprintf(stderr, "failed to set gamma: %s\n", 
strerror(errno));
+   }
+}
+
 static int atomic_set_plane(struct device *dev, struct plane_arg *p,
int pattern, bool 
update)
 {
@@ -1270,6 +1306,8 @@ static void atomic_set_planes(struct device *dev, struct 
plane_arg *p,
for (i = 0; i < count; i++) {
if (i > 0)
pattern = UTIL_PATTERN_TILES;
+   else
+   set_gamma(dev, p[i].crtc_id, p[i].fourcc);
 
if (atomic_set_plane(dev, &p[i], pattern, update))
return;
@@ -1454,6 +1492,8 @@ static void set_mode(struct device *dev, struct pipe_arg 
*pipes, unsigned int co
fprintf(stderr, "failed to set mode: %s\n", 
strerror(errno));
return;
}
+
+   set_gamma(dev, pipe->crtc->crtc->crtc_id, pipe->fourcc);
}
 }
 
@@ -1728,11 +1768,8 @@ static int parse_plane(struct plane_arg *plane, const 
char *p)
}
 
if (*end == '@') {
-   p = end + 1;
-   if (strlen(p) != 4)
-   return -EINVAL;
-
-   strcpy(plane->format_str, p);
+   strncpy(plane->format_str, end + 1, 4);
+   plane->format_str[4] = '\0';
} else {
strcpy(plane->format_str, "XR24");
}
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 01/10] util: add C8 format, support it with SMPTE pattern

2019-06-02 Thread Ilia Mirkin
This also adds a helper to generate a color LUT, which has to be used in
conjunction with the C8 indexed format.

Signed-off-by: Ilia Mirkin 
---
 tests/util/format.c  |  2 ++
 tests/util/pattern.c | 75 
 tests/util/pattern.h |  4 +++
 3 files changed, 81 insertions(+)

diff --git a/tests/util/format.c b/tests/util/format.c
index 15ac5e1e..e52213bb 100644
--- a/tests/util/format.c
+++ b/tests/util/format.c
@@ -39,6 +39,8 @@
.yuv = { (order), (xsub), (ysub), (chroma_stride) }
 
 static const struct util_format_info format_info[] = {
+   /* Indexed */
+   { DRM_FORMAT_C8, "C8" },
/* YUV packed */
{ DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) },
{ DRM_FORMAT_VYUY, "VYUY", MAKE_YUV_INFO(YUV_YCrCb | YUV_CY, 2, 2, 2) },
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 9fa0a417..c84fee5a 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -457,6 +457,79 @@ static void fill_smpte_rgb32(const struct util_rgb_info 
*rgb, void *mem,
}
 }
 
+static void fill_smpte_c8(void *mem, unsigned int width, unsigned int height,
+ unsigned int stride)
+{
+   unsigned int x;
+   unsigned int y;
+
+   for (y = 0; y < height * 6 / 9; ++y) {
+   for (x = 0; x < width; ++x)
+   ((uint8_t *)mem)[x] = x * 7 / width;
+   mem += stride;
+   }
+
+   for (; y < height * 7 / 9; ++y) {
+   for (x = 0; x < width; ++x)
+   ((uint8_t *)mem)[x] = 7 + (x * 7 / width);
+   mem += stride;
+   }
+
+   for (; y < height; ++y) {
+   for (x = 0; x < width * 5 / 7; ++x)
+   ((uint8_t *)mem)[x] =
+   14 + (x * 4 / (width * 5 / 7));
+   for (; x < width * 6 / 7; ++x)
+   ((uint8_t *)mem)[x] =
+   14 + ((x - width * 5 / 7) * 3
+ / (width / 7) + 4);
+   for (; x < width; ++x)
+   ((uint8_t *)mem)[x] = 14 + 7;
+   mem += stride;
+   }
+}
+
+void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut)
+{
+   if (size < 7 + 7 + 8) {
+   printf("Error: gamma too small: %d < %d\n", size, 7 + 7 + 8);
+   return;
+   }
+   memset(lut, size * sizeof(struct drm_color_lut), 0);
+
+#define FILL_COLOR(idx, r, g, b) \
+   lut[idx].red = (r) << 8; \
+   lut[idx].green = (g) << 8; \
+   lut[idx].blue = (b) << 8
+
+   FILL_COLOR( 0, 192, 192, 192);  /* grey */
+   FILL_COLOR( 1, 192, 192, 0  );  /* yellow */
+   FILL_COLOR( 2, 0,   192, 192);  /* cyan */
+   FILL_COLOR( 3, 0,   192, 0  );  /* green */
+   FILL_COLOR( 4, 192, 0,   192);  /* magenta */
+   FILL_COLOR( 5, 192, 0,   0  );  /* red */
+   FILL_COLOR( 6, 0,   0,   192);  /* blue */
+
+   FILL_COLOR( 7, 0,   0,   192);  /* blue */
+   FILL_COLOR( 8, 19,  19,  19 );  /* black */
+   FILL_COLOR( 9, 192, 0,   192);  /* magenta */
+   FILL_COLOR(10, 19,  19,  19 );  /* black */
+   FILL_COLOR(11, 0,   192, 192);  /* cyan */
+   FILL_COLOR(12, 19,  19,  19 );  /* black */
+   FILL_COLOR(13, 192, 192, 192);  /* grey */
+
+   FILL_COLOR(14, 0,   33,  76);   /* in-phase */
+   FILL_COLOR(15, 255, 255, 255);  /* super white */
+   FILL_COLOR(16, 50,  0,   106);  /* quadrature */
+   FILL_COLOR(17, 19,  19,  19);   /* black */
+   FILL_COLOR(18, 9,   9,   9);/* 3.5% */
+   FILL_COLOR(19, 19,  19,  19);   /* 7.5% */
+   FILL_COLOR(20, 29,  29,  29);   /* 11.5% */
+   FILL_COLOR(21, 19,  19,  19);   /* black */
+
+#undef FILL_COLOR
+}
+
 static void fill_smpte(const struct util_format_info *info, void *planes[3],
   unsigned int width, unsigned int height,
   unsigned int stride)
@@ -464,6 +537,8 @@ static void fill_smpte(const struct util_format_info *info, 
void *planes[3],
unsigned char *u, *v;
 
switch (info->format) {
+   case DRM_FORMAT_C8:
+   return fill_smpte_c8(planes[0], width, height, stride);
case DRM_FORMAT_UYVY:
case DRM_FORMAT_VYUY:
case DRM_FORMAT_YUYV:
diff --git a/tests/util/pattern.h b/tests/util/pattern.h
index d5c4260c..c8708d02 100644
--- a/tests/util/pattern.h
+++ b/tests/util/pattern.h
@@ -26,6 +26,8 @@
 #ifndef UTIL_PATTERN_H
 #define UTIL_PATTERN_H
 
+#include 
+
 enum util_fill_pattern {
UTIL_PATTERN_TILES,
UTIL_PATTERN_PLAIN,
@@ -36,4 +38,6 @@ void util_fill_pattern(uint32_t format, enum 
util_fill_pattern pattern,
   void *planes[3], unsigned int width,
   unsigned int height, unsigned int stride);
 
+void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut);
+
 #endif /* UTIL_PATTERN_H */
-- 
2.21.0

_

[PATCH libdrm 03/10] util: add gradient pattern

2019-06-02 Thread Ilia Mirkin
The idea is to have a horizontal pattern split into two with the top and
bottom halves having different precision. This allows one to see whether
10bpc support is working properly or not, as there are many pieces to
the puzzle beyond the basic format support (gamma ramps, bpc encodings,
etc).

This is really only useful on 10bpc formats, but we also add support for
8bpc formats to ease testing. In the future, this could be applied to
16bpc formats as well.

Signed-off-by: Ilia Mirkin 
---
 tests/util/pattern.c | 113 +--
 tests/util/pattern.h |   1 +
 2 files changed, 109 insertions(+), 5 deletions(-)

diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 8bdebd2c..ff110fd7 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -60,9 +60,11 @@ struct color_yuv {
  .u = MAKE_YUV_601_U(r, g, b), \
  .v = MAKE_YUV_601_V(r, g, b) }
 
-static inline uint32_t shiftcolor(const struct util_color_component *comp,
+/* This function takes 8-bit color values */
+static inline uint32_t shiftcolor8(const struct util_color_component *comp,
  uint32_t value)
 {
+   value &= 0xff;
/* Fill the low bits with the high bits. */
value = (value << 8) | value;
/* Shift down to remove unwanted low bits */
@@ -71,11 +73,30 @@ static inline uint32_t shiftcolor(const struct 
util_color_component *comp,
return value << comp->offset;
 }
 
+/* This function takes 10-bit color values */
+static inline uint32_t shiftcolor10(const struct util_color_component *comp,
+   uint32_t value)
+{
+   value &= 0x3ff;
+   /* Fill the low bits with the high bits. */
+   value = (value << 6) | (value >> 4);
+   /* Shift down to remove unwanted low bits */
+   value = value >> (16 - comp->length);
+   /* Shift back up to where the value should be */
+   return value << comp->offset;
+}
+
+#define MAKE_RGBA10(rgb, r, g, b, a) \
+   (shiftcolor10(&(rgb)->red, (r)) | \
+shiftcolor10(&(rgb)->green, (g)) | \
+shiftcolor10(&(rgb)->blue, (b)) | \
+shiftcolor10(&(rgb)->alpha, (a)))
+
 #define MAKE_RGBA(rgb, r, g, b, a) \
-   (shiftcolor(&(rgb)->red, (r)) | \
-shiftcolor(&(rgb)->green, (g)) | \
-shiftcolor(&(rgb)->blue, (b)) | \
-shiftcolor(&(rgb)->alpha, (a)))
+   (shiftcolor8(&(rgb)->red, (r)) | \
+shiftcolor8(&(rgb)->green, (g)) | \
+shiftcolor8(&(rgb)->blue, (b)) | \
+shiftcolor8(&(rgb)->alpha, (a)))
 
 #define MAKE_RGB24(rgb, r, g, b) \
{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
@@ -912,6 +933,85 @@ static void fill_plain(void *planes[3],
memset(planes[0], 0x77, stride * height);
 }
 
+static void fill_gradient_rgb32(const struct util_rgb_info *rgb,
+   void *mem,
+   unsigned int width, unsigned int height,
+   unsigned int stride)
+{
+   int i, j;
+
+   for (i = 0; i < height / 2; i++) {
+   uint32_t *row = mem;
+
+   for (j = 0; j < width / 2; j++) {
+   uint32_t value = MAKE_RGBA10(rgb, j & 0x3ff, j & 0x3ff, 
j & 0x3ff, 0);
+   row[2*j] = row[2*j+1] = value;
+   }
+   mem += stride;
+   }
+
+   for (; i < height; i++) {
+   uint32_t *row = mem;
+
+   for (j = 0; j < width / 2; j++) {
+   uint32_t value = MAKE_RGBA10(rgb, j & 0x3fc, j & 0x3fc, 
j & 0x3fc, 0);
+   row[2*j] = row[2*j+1] = value;
+   }
+   mem += stride;
+   }
+}
+
+/* The gradient pattern creates two horizontal gray gradients, split
+ * into two halves. The top half has 10bpc precision, the bottom half
+ * has 8bpc precision. When using with a 10bpc fb format, there are 3
+ * possible outcomes:
+ *
+ *  - Pixel data is encoded as 8bpc to the display, no dithering. This
+ *would lead to the top and bottom halves looking identical.
+ *
+ *  - Pixel data is encoded as 8bpc to the display, with dithering. This
+ *would lead to there being a visible difference between the two halves,
+ *but the top half would look a little speck-y due to the dithering.
+ *
+ *  - Pixel data is encoded at 10bpc+ to the display (which implies
+ *the display is able to show this level of depth). This should
+ *lead to the top half being a very clean gradient, and visibly different
+ *from the bottom half.
+ *
+ * Once we support additional fb formats, this approach could be extended
+ * to distinguish even higher bpc precisions.
+ *
+ * Note that due to practical size considerations, for the screens
+ * where this matters, the pattern actually emits stripes 2-pixels
+ * wide for each gradient color. Otherwise the difference may be a bit
+ * hard to notice.
+ */
+static void fill_gradient(const struct util_format_info *info,

[PATCH libdrm 09/10] modetest: add the ability to specify fill patterns on the commandline

2019-06-02 Thread Ilia Mirkin
Instead of hacking the binary every time, we can now specify directly.

Signed-off-by: Ilia Mirkin 
---
 tests/modetest/modetest.c | 29 -
 tests/util/pattern.c  | 20 
 tests/util/pattern.h  |  2 ++
 3 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 7bb21d17..e66be660 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -67,6 +67,9 @@
 #include "buffers.h"
 #include "cursor.h"
 
+static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE;
+static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES;
+
 struct crtc {
drmModeCrtc *crtc;
drmModeObjectProperties *props;
@@ -1259,7 +1262,7 @@ static int set_plane(struct device *dev, struct plane_arg 
*p)
p->w, p->h, p->format_str, plane_id);
 
plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h, handles,
-pitches, offsets, UTIL_PATTERN_TILES);
+pitches, offsets, secondary_fill);
if (plane_bo == NULL)
return -1;
 
@@ -1300,12 +1303,12 @@ static int set_plane(struct device *dev, struct 
plane_arg *p)
 static void atomic_set_planes(struct device *dev, struct plane_arg *p,
  unsigned int count, bool update)
 {
-   unsigned int i, pattern = UTIL_PATTERN_SMPTE;
+   unsigned int i, pattern = primary_fill;
 
/* set up planes */
for (i = 0; i < count; i++) {
if (i > 0)
-   pattern = UTIL_PATTERN_TILES;
+   pattern = secondary_fill;
else
set_gamma(dev, p[i].crtc_id, p[i].fourcc);
 
@@ -1450,7 +1453,7 @@ static void set_mode(struct device *dev, struct pipe_arg 
*pipes, unsigned int co
 
bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
   dev->mode.height, handles, pitches, offsets,
-  UTIL_PATTERN_SMPTE);
+  primary_fill);
if (bo == NULL)
return;
 
@@ -1794,6 +1797,18 @@ static int parse_property(struct property_arg *p, const 
char *arg)
return 0;
 }
 
+static void parse_fill_patterns(char *arg)
+{
+   char *fill = strtok(arg, ",");
+   if (!fill)
+   return;
+   primary_fill = util_pattern_enum(fill);
+   fill = strtok(NULL, ",");
+   if (!fill)
+   return;
+   secondary_fill = util_pattern_enum(fill);
+}
+
 static void usage(char *name)
 {
fprintf(stderr, "usage: %s [-acDdefMPpsCvw]\n", name);
@@ -1811,6 +1826,7 @@ static void usage(char *name)
fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
fprintf(stderr, "\t-w ::\tset property\n");
fprintf(stderr, "\t-a \tuse atomic API\n");
+   fprintf(stderr, "\t-F pattern1,pattern2\tspecify fill patterns\n");
 
fprintf(stderr, "\n Generic options:\n\n");
fprintf(stderr, "\t-d\tdrop master after mode set\n");
@@ -1874,7 +1890,7 @@ static int pipe_resolve_connectors(struct device *dev, 
struct pipe_arg *pipe)
return 0;
 }
 
-static char optstr[] = "acdD:efM:P:ps:Cvw:";
+static char optstr[] = "acdD:efF:M:P:ps:Cvw:";
 
 int main(int argc, char **argv)
 {
@@ -1923,6 +1939,9 @@ int main(int argc, char **argv)
case 'f':
framebuffers = 1;
break;
+   case 'F':
+   parse_fill_patterns(optarg);
+   break;
case 'M':
module = optarg;
/* Preserve the default behaviour of dumping all 
information. */
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index d197c444..42a0e5c7 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -35,6 +35,7 @@
 #include 
 #endif
 
+#include "common.h"
 #include "format.h"
 #include "pattern.h"
 
@@ -1261,3 +1262,22 @@ void util_fill_pattern(uint32_t format, enum 
util_fill_pattern pattern,
break;
}
 }
+
+static const char *pattern_names[] = {
+   [UTIL_PATTERN_TILES] = "tiles",
+   [UTIL_PATTERN_SMPTE] = "smpte",
+   [UTIL_PATTERN_PLAIN] = "plain",
+   [UTIL_PATTERN_GRADIENT] = "gradient",
+};
+
+enum util_fill_pattern util_pattern_enum(const char *name)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(pattern_names); i++)
+   if (!strcmp(pattern_names[i], name))
+   return (enum util_fill_pattern)i;
+
+   printf("Error: unsupported test pattern %s.\n", name);
+   return UTIL_PATTERN_SMPTE;
+}
diff --git a/tests/util/pattern.h b/tests/util/pattern.h
index feac903a..424b0e19 100644
--- a/tests/util/pattern.h
+++ b/tests/util/pattern.h
@@ -41,4 +41,6 @@ void util_fill_pattern(uint32_t format, enum 
util_fill_pattern pattern,
 
 void util_smpte_c8_gamma(unsigned size, struct drm_color_lut 

[PATCH libdrm 07/10] modetest: add an add_property_optional variant that does not print errors

2019-06-02 Thread Ilia Mirkin
As new features are added and others are declared to be legacy, it's
nice to be able to implement fallbacks. As such, create a
property-setting variant that does not generate errors which can very
well be entirely expected.

Will be used for gamma control in a future change.

Signed-off-by: Ilia Mirkin 
---
 tests/modetest/modetest.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index a1c81f6c..71ddc861 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -948,9 +948,10 @@ struct property_arg {
char name[DRM_PROP_NAME_LEN+1];
uint32_t prop_id;
uint64_t value;
+   bool optional;
 };
 
-static void set_property(struct device *dev, struct property_arg *p)
+static bool set_property(struct device *dev, struct property_arg *p)
 {
drmModeObjectProperties *props = NULL;
drmModePropertyRes **props_info = NULL;
@@ -982,13 +983,13 @@ static void set_property(struct device *dev, struct 
property_arg *p)
if (p->obj_type == 0) {
fprintf(stderr, "Object %i not found, can't set property\n",
p->obj_id);
-   return;
+   return false;
}
 
if (!props) {
fprintf(stderr, "%s %i has no properties\n",
obj_type, p->obj_id);
-   return;
+   return false;
}
 
for (i = 0; i < (int)props->count_props; ++i) {
@@ -999,9 +1000,10 @@ static void set_property(struct device *dev, struct 
property_arg *p)
}
 
if (i == (int)props->count_props) {
-   fprintf(stderr, "%s %i has no %s property\n",
-   obj_type, p->obj_id, p->name);
-   return;
+   if (!p->optional)
+   fprintf(stderr, "%s %i has no %s property\n",
+   obj_type, p->obj_id, p->name);
+   return false;
}
 
p->prop_id = props->props[i];
@@ -1015,6 +1017,8 @@ static void set_property(struct device *dev, struct 
property_arg *p)
if (ret < 0)
fprintf(stderr, "failed to set %s %i property %s to %" PRIu64 
": %s\n",
obj_type, p->obj_id, p->name, p->value, 
strerror(errno));
+
+   return true;
 }
 
 /* -- 
*/
@@ -1072,6 +1076,19 @@ static void add_property(struct device *dev, uint32_t 
obj_id,
set_property(dev, &p);
 }
 
+static bool add_property_optional(struct device *dev, uint32_t obj_id,
+ const char *name, uint64_t value)
+{
+   struct property_arg p;
+
+   p.obj_id = obj_id;
+   strcpy(p.name, name);
+   p.value = value;
+   p.optional = true;
+
+   return set_property(dev, &p);
+}
+
 static int atomic_set_plane(struct device *dev, struct plane_arg *p,
int pattern, bool 
update)
 {
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 06/10] modetest: don't pretend that atomic mode includes a format

2019-06-02 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---
 tests/modetest/modetest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 9c85c07b..a1c81f6c 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1335,8 +1335,8 @@ static void atomic_set_mode(struct device *dev, struct 
pipe_arg *pipes, unsigned
if (pipe->mode == NULL)
continue;
 
-   printf("setting mode %s-%dHz@%s on connectors ",
-  pipe->mode_str, pipe->mode->vrefresh, pipe->format_str);
+   printf("setting mode %s-%dHz on connectors ",
+  pipe->mode_str, pipe->mode->vrefresh);
for (j = 0; j < pipe->num_cons; ++j) {
printf("%s, ", pipe->cons[j]);
add_property(dev, pipe->con_ids[j], "CRTC_ID", 
pipe->crtc->crtc->crtc_id);
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 04/10] util: add fp16 format support

2019-06-02 Thread Ilia Mirkin
This change adds support for all current patterns.

Signed-off-by: Ilia Mirkin 
---
 tests/util/format.c  |   5 ++
 tests/util/pattern.c | 207 ++-
 2 files changed, 209 insertions(+), 3 deletions(-)

diff --git a/tests/util/format.c b/tests/util/format.c
index e52213bb..1ca1b82c 100644
--- a/tests/util/format.c
+++ b/tests/util/format.c
@@ -93,6 +93,11 @@ static const struct util_format_info format_info[] = {
{ DRM_FORMAT_RGBX1010102, "RX30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 
0, 0) },
{ DRM_FORMAT_BGRA1010102, "BA30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 
2, 0) },
{ DRM_FORMAT_BGRX1010102, "BX30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 
0, 0) },
+   { DRM_FORMAT_XRGB16161616F, "XR4H", MAKE_RGB_INFO(16, 32, 16, 16, 16, 
0, 0, 0) },
+   { DRM_FORMAT_XBGR16161616F, "XB4H", MAKE_RGB_INFO(16, 0, 16, 16, 16, 
32, 0, 0) },
+   { DRM_FORMAT_ARGB16161616F, "AR4H", MAKE_RGB_INFO(16, 32, 16, 16, 16, 
0, 16, 48) },
+   { DRM_FORMAT_ABGR16161616F, "AB4H", MAKE_RGB_INFO(16, 0, 16, 16, 16, 
32, 16, 48) },
+
 };
 
 uint32_t util_format_fourcc(const char *name)
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index ff110fd7..37796dbf 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -86,6 +86,17 @@ static inline uint32_t shiftcolor10(const struct 
util_color_component *comp,
return value << comp->offset;
 }
 
+/* This function takes 16-bit color values */
+static inline uint64_t shiftcolor16(const struct util_color_component *comp,
+   uint64_t value)
+{
+   value &= 0x;
+   /* Shift down to remove unwanted low bits */
+   value = value >> (16 - comp->length);
+   /* Shift back up to where the value should be */
+   return value << comp->offset;
+}
+
 #define MAKE_RGBA10(rgb, r, g, b, a) \
(shiftcolor10(&(rgb)->red, (r)) | \
 shiftcolor10(&(rgb)->green, (g)) | \
@@ -101,6 +112,49 @@ static inline uint32_t shiftcolor10(const struct 
util_color_component *comp,
 #define MAKE_RGB24(rgb, r, g, b) \
{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
 
+
+/**
+  * Takes a uint16_t, divides by 65536, converts the infinite-precision
+  * result to fp16 with round-to-zero.
+  *
+  * Copied from mesa:src/util/half_float.c
+  */
+static uint16_t uint16_div_64k_to_half(uint16_t v)
+{
+   /* Zero or subnormal. Set the mantissa to (v << 8) and return. */
+   if (v < 4)
+   return v << 8;
+
+   /* Count the leading 0s in the uint16_t */
+   int n = __builtin_clz(v) - 16;
+
+   /* Shift the mantissa up so bit 16 is the hidden 1 bit,
+* mask it off, then shift back down to 10 bits
+*/
+   int m = ( ((uint32_t)v << (n + 1)) & 0x ) >> 6;
+
+   /*  (0{n} 1 X{15-n}) * 2^-16
+* = 1.X * 2^(15-n-16)
+* = 1.X * 2^(14-n - 15)
+* which is the FP16 form with e = 14 - n
+*/
+   int e = 14 - n;
+
+   return (e << 10) | m;
+}
+
+#define MAKE_RGBA8FP16(rgb, r, g, b, a) \
+   (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 8)) | \
+shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 8)) | \
+shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 8)) | \
+shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 8)))
+
+#define MAKE_RGBA10FP16(rgb, r, g, b, a) \
+   (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 6)) | \
+shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 6)) | \
+shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 6)) | \
+shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 6)))
+
 static void fill_smpte_yuv_planar(const struct util_yuv_info *yuv,
  unsigned char *y_mem, unsigned char *u_mem,
  unsigned char *v_mem, unsigned int width,
@@ -489,6 +543,67 @@ static void fill_smpte_rgb32(const struct util_rgb_info 
*rgb, void *mem,
}
 }
 
+static void fill_smpte_rgb16fp(const struct util_rgb_info *rgb, void *mem,
+  unsigned int width, unsigned int height,
+  unsigned int stride)
+{
+   const uint64_t colors_top[] = {
+   MAKE_RGBA8FP16(rgb, 192, 192, 192, 255),/* grey */
+   MAKE_RGBA8FP16(rgb, 192, 192, 0, 255),  /* yellow */
+   MAKE_RGBA8FP16(rgb, 0, 192, 192, 255),  /* cyan */
+   MAKE_RGBA8FP16(rgb, 0, 192, 0, 255),/* green */
+   MAKE_RGBA8FP16(rgb, 192, 0, 192, 255),  /* magenta */
+   MAKE_RGBA8FP16(rgb, 192, 0, 0, 255),/* red */
+   MAKE_RGBA8FP16(rgb, 0, 0, 192, 255),/* blue */
+   };
+   const uint64_t colors_middle[] = {
+   MAKE_RGBA8FP16(rgb, 0, 0, 192, 127),/* blue */
+   MAKE_RGBA8FP16(rgb, 19, 19, 19, 127),   /* black */
+   MAKE_RGBA8FP16(rgb, 192, 0, 192, 127),  /* magenta */
+

[PATCH libdrm 05/10] util: add cairo drawing for 30bpp formats when available

2019-06-02 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---
 tests/util/pattern.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 37796dbf..d197c444 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -788,6 +788,14 @@ static void make_pwetty(void *data, unsigned int width, 
unsigned int height,
case DRM_FORMAT_BGR565:
cairo_format = CAIRO_FORMAT_RGB16_565;
break;
+#if CAIRO_VERSION_MAJOR > 1 || (CAIRO_VERSION_MAJOR == 1 && 
CAIRO_VERSION_MINOR >= 12)
+   case DRM_FORMAT_ARGB2101010:
+   case DRM_FORMAT_XRGB2101010:
+   case DRM_FORMAT_ABGR2101010:
+   case DRM_FORMAT_XBGR2101010:
+   cairo_format = CAIRO_FORMAT_RGB30;
+   break;
+#endif
default:
return;
}
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH libdrm 10/10] modetest: add FP16 format support

2019-06-02 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---
 tests/modetest/buffers.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 5ec4ec8e..8a8d9e01 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -194,6 +194,13 @@ bo_create(int fd, unsigned int format,
bpp = 32;
break;
 
+   case DRM_FORMAT_XRGB16161616F:
+   case DRM_FORMAT_XBGR16161616F:
+   case DRM_FORMAT_ARGB16161616F:
+   case DRM_FORMAT_ABGR16161616F:
+   bpp = 64;
+   break;
+
default:
fprintf(stderr, "unsupported format 0x%08x\n",  format);
return NULL;
@@ -313,6 +320,10 @@ bo_create(int fd, unsigned int format,
case DRM_FORMAT_RGBX1010102:
case DRM_FORMAT_BGRA1010102:
case DRM_FORMAT_BGRX1010102:
+   case DRM_FORMAT_XRGB16161616F:
+   case DRM_FORMAT_XBGR16161616F:
+   case DRM_FORMAT_ARGB16161616F:
+   case DRM_FORMAT_ABGR16161616F:
offsets[0] = 0;
handles[0] = bo->handle;
pitches[0] = bo->pitch;
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/msm: correct attempted NULL pointer dereference in put_iova

2019-06-02 Thread Brian Masney
put_iova() would attempt to dereference a NULL pointer via the
address space pointer when no IOMMU is present. Correct this by adding
the appropriate check.

Signed-off-by: Brian Masney 
---
 drivers/gpu/drm/msm/msm_gem.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 35f55dd25994..d31d9f927887 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -352,8 +352,10 @@ put_iova(struct drm_gem_object *obj)
WARN_ON(!mutex_is_locked(&msm_obj->lock));
 
list_for_each_entry_safe(vma, tmp, &msm_obj->vmas, list) {
-   msm_gem_purge_vma(vma->aspace, vma);
-   msm_gem_close_vma(vma->aspace, vma);
+   if (vma->aspace) {
+   msm_gem_purge_vma(vma->aspace, vma);
+   msm_gem_close_vma(vma->aspace, vma);
+   }
del_vma(vma);
}
 }
-- 
2.20.1



Re: linux-next: unable to fetch the drm-intel-fixes tree

2019-06-02 Thread Stephen Rothwell
Hi Stephen,

On Mon, 3 Jun 2019 08:20:51 +1000 Stephen Rothwell  
wrote:
>
> Hi all,
> 
> Trying to fetch the drm-intel-fixes tree today gives me this error:
> 
> -
> fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights
> and the repository exists.
> -
> 
> The same for drm-misc-fixes, drm-intel and drm-misc.  These are all
> hosted on git://anongit.freedesktop.org/ .

Also the drm-tegra tree.

-- 
Cheers,
Stephen Rothwell


pgpxo1k1a0nxs.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [v4 1/7] drm/mediatek: move mipi_dsi_host_register to probe

2019-06-02 Thread CK Hu
Hi, Jitao:

On Sat, 2019-06-01 at 17:26 +0800, Jitao Shi wrote:
> DSI panel driver need attach function which is inculde in
> mipi_dsi_host_ops.
> 
> If mipi_dsi_host_register is not in probe, dsi panel will
> probe more delay.
> 
> So move the mipi_dsi_host_register to probe from bind.
> 
> Signed-off-by: Jitao Shi 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 50 ++
>  1 file changed, 30 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index b00eb2d2e086..6c4ac37f983d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -1045,12 +1045,6 @@ static int mtk_dsi_bind(struct device *dev, struct 
> device *master, void *data)
>   return ret;
>   }
>  
> - ret = mipi_dsi_host_register(&dsi->host);
> - if (ret < 0) {
> - dev_err(dev, "failed to register DSI host: %d\n", ret);
> - goto err_ddp_comp_unregister;
> - }
> -
>   ret = mtk_dsi_create_conn_enc(drm, dsi);
>   if (ret) {
>   DRM_ERROR("Encoder create failed with %d\n", ret);
> @@ -1060,8 +1054,6 @@ static int mtk_dsi_bind(struct device *dev, struct 
> device *master, void *data)
>   return 0;
>  
>  err_unregister:
> - mipi_dsi_host_unregister(&dsi->host);
> -err_ddp_comp_unregister:
>   mtk_ddp_comp_unregister(drm, &dsi->ddp_comp);
>   return ret;
>  }
> @@ -1097,31 +1089,37 @@ static int mtk_dsi_probe(struct platform_device *pdev)
>  
>   dsi->host.ops = &mtk_dsi_ops;
>   dsi->host.dev = dev;
> + dsi->dev = dev;

Except this line,

Reviewed-by: CK Hu 

> + ret = mipi_dsi_host_register(&dsi->host);
> + if (ret < 0) {
> + dev_err(dev, "failed to register DSI host: %d\n", ret);
> + return ret;
> + }
>  
>   ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> &dsi->panel, &dsi->bridge);
>   if (ret)
> - return ret;
> + goto err_unregister_host;
>  
>   dsi->engine_clk = devm_clk_get(dev, "engine");
>   if (IS_ERR(dsi->engine_clk)) {
>   ret = PTR_ERR(dsi->engine_clk);
>   dev_err(dev, "Failed to get engine clock: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   dsi->digital_clk = devm_clk_get(dev, "digital");
>   if (IS_ERR(dsi->digital_clk)) {
>   ret = PTR_ERR(dsi->digital_clk);
>   dev_err(dev, "Failed to get digital clock: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   dsi->hs_clk = devm_clk_get(dev, "hs");
>   if (IS_ERR(dsi->hs_clk)) {
>   ret = PTR_ERR(dsi->hs_clk);
>   dev_err(dev, "Failed to get hs clock: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1129,33 +1127,35 @@ static int mtk_dsi_probe(struct platform_device *pdev)
>   if (IS_ERR(dsi->regs)) {
>   ret = PTR_ERR(dsi->regs);
>   dev_err(dev, "Failed to ioremap memory: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   dsi->phy = devm_phy_get(dev, "dphy");
>   if (IS_ERR(dsi->phy)) {
>   ret = PTR_ERR(dsi->phy);
>   dev_err(dev, "Failed to get MIPI-DPHY: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DSI);
>   if (comp_id < 0) {
>   dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
> - return comp_id;
> + ret = comp_id;
> + goto err_unregister_host;
>   }
>  
>   ret = mtk_ddp_comp_init(dev, dev->of_node, &dsi->ddp_comp, comp_id,
>   &mtk_dsi_funcs);
>   if (ret) {
>   dev_err(dev, "Failed to initialize component: %d\n", ret);
> - return ret;
> + goto err_unregister_host;
>   }
>  
>   irq_num = platform_get_irq(pdev, 0);
>   if (irq_num < 0) {
> - dev_err(&pdev->dev, "failed to request dsi irq resource\n");
> - return -EPROBE_DEFER;
> + dev_err(&pdev->dev, "failed to get dsi irq_num: %d\n", irq_num);
> + ret = irq_num;
> + goto err_unregister_host;
>   }
>  
>   irq_set_status_flags(irq_num, IRQ_TYPE_LEVEL_LOW);
> @@ -1163,14 +1163,24 @@ static int mtk_dsi_probe(struct platform_device *pdev)
>  IRQF_TRIGGER_LOW, dev_name(&pdev->dev), dsi);
>   if (ret) {
>   dev_err(&pdev->dev, "failed to request mediatek dsi irq\n");
> - return -EPROBE_DEFER;
> + goto err_unregister_host;
>   }
>  
>   init_waitqueue_head(&dsi->irq_wait

Re: [v4 2/7] drm/mediatek: fixes CMDQ reg address of mt8173 is different with mt2701

2019-06-02 Thread CK Hu
Hi, Jitao:

On Sat, 2019-06-01 at 17:26 +0800, Jitao Shi wrote:
> Config the different CMDQ reg address in driver data.
> 
> Signed-off-by: Jitao Shi 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 29 -
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 6c4ac37f983d..a48db056df6c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -131,7 +131,6 @@
>  #define VM_CMD_ENBIT(0)
>  #define TS_VFP_ENBIT(5)
>  
> -#define DSI_CMDQ00x180
>  #define CONFIG   (0xff << 0)
>  #define SHORT_PACKET 0
>  #define LONG_PACKET  2
> @@ -156,6 +155,10 @@
>  
>  struct phy;
>  
> +struct mtk_dsi_driver_data {
> + const u32 reg_cmdq_off;
> +};
> +
>  struct mtk_dsi {
>   struct mtk_ddp_comp ddp_comp;
>   struct device *dev;
> @@ -182,6 +185,7 @@ struct mtk_dsi {
>   bool enabled;
>   u32 irq_data;
>   wait_queue_head_t irq_wait_queue;
> + const struct mtk_dsi_driver_data *driver_data;
>  };
>  
>  static inline struct mtk_dsi *encoder_to_dsi(struct drm_encoder *e)
> @@ -934,6 +938,7 @@ static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const 
> struct mipi_dsi_msg *msg)
>   const char *tx_buf = msg->tx_buf;
>   u8 config, cmdq_size, cmdq_off, type = msg->type;
>   u32 reg_val, cmdq_mask, i;
> + u32 reg_cmdq_off = dsi->driver_data->reg_cmdq_off;
>  
>   if (MTK_DSI_HOST_IS_READ(type))
>   config = BTA;
> @@ -953,9 +958,11 @@ static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const 
> struct mipi_dsi_msg *msg)
>   }
>  
>   for (i = 0; i < msg->tx_len; i++)
> - writeb(tx_buf[i], dsi->regs + DSI_CMDQ0 + cmdq_off + i);
> + mtk_dsi_mask(dsi, (reg_cmdq_off + cmdq_off + i) & (~0x3U),
> +  (0xffUL << (((i + cmdq_off) & 3U) * 8U)),
> +  tx_buf[i] << (((i + cmdq_off) & 3U) * 8U));

I've modify this line to

writeb(tx_buf[i], dsi->regs + reg_cmdq_off + cmdq_off + i);

and this works. The call trace list below

[8.189067] Call trace:
[8.191516]  dump_backtrace+0x0/0x164
[8.195172]  show_stack+0x20/0x2c
[8.198482]  dump_stack+0xc4/0xfc
[8.201792]  mtk_dsi_host_transfer+0x248/0x4ac
[8.206230]  mipi_dsi_device_transfer+0x50/0x64
[8.210753]  mipi_dsi_dcs_exit_sleep_mode+0x5c/0x8c
[8.215625]  innolux_panel_prepare+0x128/0x218
[8.220061]  mtk_dsi_poweron+0x74c/0x7c8
[8.223976]  mtk_dsi_ddp_start+0x1c/0x28
[8.227891]  mtk_drm_crtc_atomic_enable+0x310/0x428
[8.232765]  drm_atomic_helper_commit_modeset_enables+0xa0/0x200
[8.238764]  mtk_atomic_complete+0x84/0xd0
[8.242852]  mtk_atomic_commit+0xb8/0xe0
[8.246769]  drm_atomic_commit+0x50/0x5c
[8.250684]  drm_atomic_helper_set_config+0x98/0xa0
[8.25]  drm_mode_setcrtc+0x280/0x618
[8.259558]  drm_ioctl_kernel+0xcc/0x10c
[8.263473]  drm_ioctl+0x248/0x3d4
[8.266868]  drm_compat_ioctl+0xd8/0xe8
[8.270698]  __arm64_compat_sys_ioctl+0xf4/0x25c
[8.275309]  el0_svc_common+0x9c/0xfc
[8.278965]  el0_svc_compat_handler+0x2c/0x38
[8.283314]  el0_svc_compat+0x8/0x18

So I think writeb() could work correctly. If you have meet some problem,
it might be other problem.

Regards,
CK

>  
> - mtk_dsi_mask(dsi, DSI_CMDQ0, cmdq_mask, reg_val);
> + mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val);
>   mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size);
>  }
>  
> @@ -1101,6 +1108,8 @@ static int mtk_dsi_probe(struct platform_device *pdev)
>   if (ret)
>   goto err_unregister_host;
>  
> + dsi->driver_data = of_device_get_match_data(dev);
> +
>   dsi->engine_clk = devm_clk_get(dev, "engine");
>   if (IS_ERR(dsi->engine_clk)) {
>   ret = PTR_ERR(dsi->engine_clk);
> @@ -1193,9 +1202,19 @@ static int mtk_dsi_remove(struct platform_device *pdev)
>   return 0;
>  }
>  
> +static const struct mtk_dsi_driver_data mt8173_dsi_driver_data = {
> + .reg_cmdq_off = 0x200,
> +};
> +
> +static const struct mtk_dsi_driver_data mt2701_dsi_driver_data = {
> + .reg_cmdq_off = 0x180,
> +};
> +
>  static const struct of_device_id mtk_dsi_of_match[] = {
> - { .compatible = "mediatek,mt2701-dsi" },
> - { .compatible = "mediatek,mt8173-dsi" },
> + { .compatible = "mediatek,mt2701-dsi",
> +   .data = &mt2701_dsi_driver_data },
> + { .compatible = "mediatek,mt8173-dsi",
> +   .data = &mt8173_dsi_driver_data },
>   { },
>  };
>  


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [v4 3/7] drm/mediatek: add dsi reg commit disable control

2019-06-02 Thread CK Hu
Hi, Jitao:

On Sat, 2019-06-01 at 17:26 +0800, Jitao Shi wrote:
> New DSI IP has shadow register and working reg. The register
> values are writen to shadow register. And then trigger with
> commit reg, the register values will be moved working register.
> 
> This fucntion is defualt on. But this driver doesn't use this
> function. So add the disable control.

Reviewed-by: CK Hu 

> 
> Signed-off-by: Jitao Shi 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index a48db056df6c..eea47294079e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -131,6 +131,10 @@
>  #define VM_CMD_ENBIT(0)
>  #define TS_VFP_ENBIT(5)
>  
> +#define DSI_SHADOW_DEBUG 0x190U
> +#define FORCE_COMMIT BIT(0)
> +#define BYPASS_SHADOWBIT(1)
> +
>  #define CONFIG   (0xff << 0)
>  #define SHORT_PACKET 0
>  #define LONG_PACKET  2
> @@ -157,6 +161,7 @@ struct phy;
>  
>  struct mtk_dsi_driver_data {
>   const u32 reg_cmdq_off;
> + bool has_shadow_ctl;
>  };
>  
>  struct mtk_dsi {
> @@ -594,6 +599,11 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
>   }
>  
>   mtk_dsi_enable(dsi);
> +
> + if (dsi->driver_data->has_shadow_ctl)
> + writel(FORCE_COMMIT | BYPASS_SHADOW,
> +dsi->regs + DSI_SHADOW_DEBUG);
> +
>   mtk_dsi_reset_engine(dsi);
>   mtk_dsi_phy_timconfig(dsi);
>  


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [v4 6/7] drm/mediatek: change the dsi phytiming calculate method

2019-06-02 Thread CK Hu
Hi, Jitao:

On Sat, 2019-06-01 at 17:26 +0800, Jitao Shi wrote:
> Change the method of frame rate calc which can get more accurate
> frame rate.
> 
> data rate = pixel_clock * bit_per_pixel / lanes
> Adjust hfp_wc to adapt the additional phy_data
> 
> if MIPI_DSI_MODE_VIDEO_BURST
>   hfp_wc = hfp * bpp - data_phy_cycles * lanes - 12 - 6;
> else
>   hfp_wc = hfp * bpp - data_phy_cycles * lanes - 12;
> 
> Note:
> //(2: 1 for sync, 1 for phy idle)
> data_phy_cycles = T_hs_exit + T_lpx + T_hs_prepare + T_hs_zero + 2;
> 
> bpp: bit per pixel
> 
> Signed-off-by: Jitao Shi 
> Tested-by: Ryan Case 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 122 -
>  1 file changed, 83 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index abf6ddec5db6..558727c60ba3 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -144,12 +144,6 @@
>  #define DATA_0   (0xff << 16)
>  #define DATA_1   (0xff << 24)
>  
> -#define T_LPX5
> -#define T_HS_PREP6
> -#define T_HS_TRAIL   8
> -#define T_HS_EXIT7
> -#define T_HS_ZERO10
> -
>  #define NS_TO_CYCLE(n, c)((n) / (c) + (((n) % (c)) ? 1 : 0))
>  
>  #define MTK_DSI_HOST_IS_READ(type) \
> @@ -158,6 +152,25 @@
>   (type == MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM) || \
>   (type == MIPI_DSI_DCS_READ))
>  
> +struct mtk_phy_timing {
> + u32 lpx;
> + u32 da_hs_prepare;
> + u32 da_hs_zero;
> + u32 da_hs_trail;
> +
> + u32 ta_go;
> + u32 ta_sure;
> + u32 ta_get;
> + u32 da_hs_exit;
> +
> + u32 clk_hs_zero;
> + u32 clk_hs_trail;
> +
> + u32 clk_hs_prepare;
> + u32 clk_hs_post;
> + u32 clk_hs_exit;
> +};
> +
>  struct phy;
>  
>  struct mtk_dsi_driver_data {
> @@ -182,12 +195,13 @@ struct mtk_dsi {
>   struct clk *digital_clk;
>   struct clk *hs_clk;
>  
> - u32 data_rate;
> + u64 data_rate;
>  
>   unsigned long mode_flags;
>   enum mipi_dsi_pixel_format format;
>   unsigned int lanes;
>   struct videomode vm;
> + struct mtk_phy_timing phy_timing;
>   int refcount;
>   bool enabled;
>   u32 irq_data;
> @@ -221,17 +235,36 @@ static void mtk_dsi_phy_timconfig(struct mtk_dsi *dsi)
>  {
>   u32 timcon0, timcon1, timcon2, timcon3;
>   u32 ui, cycle_time;
> + struct mtk_phy_timing *timing = &dsi->phy_timing;
> +
> + ui = 10 / dsi->data_rate;
> + cycle_time = 80 / dsi->data_rate;
> +
> + timing->lpx = NS_TO_CYCLE(60, cycle_time);
> + timing->da_hs_prepare = NS_TO_CYCLE(40 + 5 * ui, cycle_time);
> + timing->da_hs_zero = NS_TO_CYCLE(110 + 6 * ui, cycle_time);
> + timing->da_hs_trail = NS_TO_CYCLE(80 + 4 * ui, cycle_time);
>  
> - ui = 1000 / dsi->data_rate + 0x01;
> - cycle_time = 8000 / dsi->data_rate + 0x01;
> + timing->ta_go = 4 * timing->lpx;
> + timing->ta_sure = 3 * timing->lpx / 2;
> + timing->ta_get = 5 * timing->lpx;
> + timing->da_hs_exit = 2 * timing->lpx;
>  
> - timcon0 = T_LPX | T_HS_PREP << 8 | T_HS_ZERO << 16 | T_HS_TRAIL << 24;
> - timcon1 = 4 * T_LPX | (3 * T_LPX / 2) << 8 | 5 * T_LPX << 16 |
> -   T_HS_EXIT << 24;
> - timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) |
> -   (NS_TO_CYCLE(0x150, cycle_time) << 16);
> - timcon3 = NS_TO_CYCLE(0x40, cycle_time) | (2 * T_LPX) << 16 |
> -   NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8;
> + timing->clk_hs_zero = NS_TO_CYCLE(336, cycle_time);
> + timing->clk_hs_trail = NS_TO_CYCLE(100, cycle_time) + 10;
> +
> + timing->clk_hs_prepare = NS_TO_CYCLE(64, cycle_time);
> + timing->clk_hs_post = NS_TO_CYCLE(80 + 52 * ui, cycle_time);
> + timing->clk_hs_exit = 2 * timing->lpx;
> +
> + timcon0 = timing->lpx | timing->da_hs_prepare << 8 |
> +   timing->da_hs_zero << 16 | timing->da_hs_trail << 24;
> + timcon1 = timing->ta_go | timing->ta_sure << 8 |
> +   timing->ta_get << 16 | timing->da_hs_exit << 24;
> + timcon2 = 1 << 8 | timing->clk_hs_zero << 16 |
> +   timing->clk_hs_trail << 24;
> + timcon3 = timing->clk_hs_prepare | timing->clk_hs_post << 8 |
> +   timing->clk_hs_exit << 16;
>  
>   writel(timcon0, dsi->regs + DSI_PHY_TIMECON0);
>   writel(timcon1, dsi->regs + DSI_PHY_TIMECON1);
> @@ -418,7 +451,8 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
>   u32 horizontal_sync_active_byte;
>   u32 horizontal_backporch_byte;
>   u32 horizontal_frontporch_byte;
> - u32 dsi_tmp_buf_bpp;
> + u32 dsi_tmp_buf_bpp, data_phy_cycles;
> + struct mtk_phy_timing *timing = &dsi->phy_timing;
>  
>   struct videomode *vm = &dsi->vm;
>  
> @@ -433,7 +467,8 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
>   writel(vm->vactive, dsi->regs + DSI_VACT_

Re: [v4 3/3] drm/mediatek: add mipi_tx driver for mt8183

2019-06-02 Thread CK Hu
Hi, Jitao:

On Sat, 2019-06-01 at 17:52 +0800, Jitao Shi wrote:
> This patch add mt8183 mipi_tx driver.
> And also support other chips that use the same binding and driver.
> 
> Signed-off-by: Jitao Shi 
> ---
>  drivers/gpu/drm/mediatek/Makefile |   1 +
>  drivers/gpu/drm/mediatek/mtk_mipi_tx.c|   2 +
>  drivers/gpu/drm/mediatek/mtk_mipi_tx.h|   1 +
>  drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c | 162 
> ++
>  4 files changed, 166 insertions(+)
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> 
> diff --git a/drivers/gpu/drm/mediatek/Makefile 
> b/drivers/gpu/drm/mediatek/Makefile
> index 2c8de1f5a5ee..8067a4be8311 100644
> --- a/drivers/gpu/drm/mediatek/Makefile
> +++ b/drivers/gpu/drm/mediatek/Makefile
> @@ -13,6 +13,7 @@ mediatek-drm-y := mtk_disp_color.o \
> mtk_dsi.o \
> mtk_mipi_tx.o \
> mtk_mt8173_mipi_tx.o \
> +   mtk_mt8183_mipi_tx.o \
> mtk_dpi.o
>  
>  obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
> diff --git a/drivers/gpu/drm/mediatek/mtk_mipi_tx.c 
> b/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> index cdc68b88cefd..ab0fbfba5572 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> @@ -182,6 +182,8 @@ static const struct of_device_id mtk_mipi_tx_match[] = {
> .data = &mt2701_mipitx_data },
>   { .compatible = "mediatek,mt8173-mipi-tx",
> .data = &mt8173_mipitx_data },
> + { .compatible = "mediatek,mt8183-mipi-tx",
> +   .data = &mt8183_mipitx_data },
>   { },
>  };
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_mipi_tx.h 
> b/drivers/gpu/drm/mediatek/mtk_mipi_tx.h
> index 660726924992..3fd24563952e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mipi_tx.h
> +++ b/drivers/gpu/drm/mediatek/mtk_mipi_tx.h
> @@ -45,5 +45,6 @@ unsigned long mtk_mipi_tx_pll_recalc_rate(struct clk_hw *hw,
>  
>  extern const struct mtk_mipitx_data mt2701_mipitx_data;
>  extern const struct mtk_mipitx_data mt8173_mipitx_data;
> +extern const struct mtk_mipitx_data mt8183_mipitx_data;
>  
>  #endif
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c 
> b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> new file mode 100644
> index ..a9f893d8e409
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> @@ -0,0 +1,162 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2019 MediaTek Inc.
> + * Author: jitao.shi 
> + */
> +
> +#include "mtk_mipi_tx.h"
> +
> +#define MIPITX_LANE_CON  0x000c
> +#define RG_DSI_CPHY_T1DRV_EN BIT(0)
> +#define RG_DSI_ANA_CK_SELBIT(1)
> +#define RG_DSI_PHY_CK_SELBIT(2)
> +#define RG_DSI_CPHY_EN   BIT(3)
> +#define RG_DSI_PHYCK_INV_EN  BIT(4)
> +#define RG_DSI_PWR04_EN  BIT(5)
> +#define RG_DSI_BG_LPF_EN BIT(6)
> +#define RG_DSI_BG_CORE_ENBIT(7)
> +#define RG_DSI_PAD_TIEL_SEL  BIT(8)
> +
> +#define MIPITX_PLL_PWR   0x0028
> +#define MIPITX_PLL_CON0  0x002c
> +#define MIPITX_PLL_CON1  0x0030
> +#define MIPITX_PLL_CON2  0x0034
> +#define MIPITX_PLL_CON3  0x0038
> +#define MIPITX_PLL_CON4  0x003c
> +#define RG_DSI_PLL_IBIAS (3 << 10)
> +
> +#define MIPITX_D2_SW_CTL_EN  0x0144
> +#define MIPITX_D0_SW_CTL_EN  0x0244
> +#define MIPITX_CK_CKMODE_EN  0x0328
> +#define DSI_CK_CKMODE_EN BIT(0)
> +#define MIPITX_CK_SW_CTL_EN  0x0344
> +#define MIPITX_D1_SW_CTL_EN  0x0444
> +#define MIPITX_D3_SW_CTL_EN  0x0544
> +#define DSI_SW_CTL_ENBIT(0)
> +#define AD_DSI_PLL_SDM_PWR_ONBIT(0)
> +#define AD_DSI_PLL_SDM_ISO_ENBIT(1)
> +
> +#define RG_DSI_PLL_ENBIT(4)
> +#define RG_DSI_PLL_POSDIV(0x7 << 8)
> +
> +static int mtk_mipi_tx_pll_prepare(struct clk_hw *hw)
> +{
> + struct mtk_mipi_tx *mipi_tx = mtk_mipi_tx_from_clk_hw(hw);
> + unsigned int txdiv, txdiv0;
> + u64 pcw;
> + int ret;
> +
> + dev_dbg(mipi_tx->dev, "prepare: %u bps\n", mipi_tx->data_rate);
> +
> + if (mipi_tx->data_rate >= 20) {
> + txdiv = 1;
> + txdiv0 = 0;
> + } else if (mipi_tx->data_rate >= 10) {
> + txdiv = 2;
> + txdiv0 = 1;
> + } else if (mipi_tx->data_rate >= 5) {
> + txdiv = 4;
> + txdiv0 = 2;
> + } else if (mipi_tx->data_rate > 25000) {
> + txdiv = 8;
> + txdiv0 = 3;
> + } else if (mipi_tx->data_rate >= 12500) {
> + txdiv = 16;
> + txdiv0 = 4;
> + } else {
> + return -EINVAL;
> + }
> +
> + ret = clk_prepare_enable(mipi_tx->ref_clk);

My last comment is in [1].

[1]
http://lists.infradead.org/pipermail/linux-mediatek/2019-May/019851.html

Regards,
CK

> + if (ret < 0) {
> + dev_err(mipi_

[Bug 203779] booting with kernel version 5.1.6 on RX 580 hangs

2019-06-02 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=203779

Gobinda Joy (gobinda@gmail.com) changed:

   What|Removed |Added

Summary|drm:amdgpu_ib_ring_tests|booting with kernel version
   |[amdgpu] *ERROR* IB test|5.1.6 on RX 580 hangs
   |failed on gfx (-110)|

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 0/7] Add HDMI audio support on RK3288 veyron board

2019-06-02 Thread Cheng-Yi Chiang
This patch series is to support HDMI audio on RK3288 veyron board.

To support jack reporting, there are two old patches:

video: add HDMI state notifier support



ASoC: hdmi-codec: use HDMI state notifier to add jack support



They are modified to pass checkpatch checking based on latest ASoC tree

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

for-next branch.

With these two patches at hand, hdmi-notifier support is then added to dw-hdmi
driver so the plug/unplug event can be passed to codec driver.

The rest patches are about machine driver rockchip_max98090.
A HDMI DAI link is added for HDMI playback so there will be two devices on
this sound card. One for max98090 and one for HDMI.
The HDMI node is passed from DTS so machine driver can set the correct
hdmi-notifier on codec driver.

Cheng-Yi Chiang (5):
  drm/bridge/synopsys: dw-hdmi: Add HDMI notifier support
  ASoC: rockchip_max98090: Add dai_link for HDMI
  ASoC: rockchip: rockchip-max98090: Add node for HDMI
  ASoC: rockchip_max98090: Add HDMI jack support
  ARM: dts: rockchip: Specify HDMI node to sound card node

Hans Verkuil (1):
  video: add HDMI state notifier support

Philipp Zabel (1):
  ASoC: hdmi-codec: use HDMI state notifier to add jack support

 .../bindings/sound/rockchip-max98090.txt  |   2 +
 MAINTAINERS   |   6 +
 .../boot/dts/rk3288-veyron-analog-audio.dtsi  |   1 +
 drivers/gpu/drm/bridge/synopsys/Kconfig   |   1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  28 +++-
 drivers/video/Kconfig |   3 +
 drivers/video/Makefile|   1 +
 drivers/video/hdmi-notifier.c | 145 ++
 include/linux/hdmi-notifier.h | 112 ++
 include/sound/hdmi-codec.h|   7 +
 sound/soc/codecs/Kconfig  |   1 +
 sound/soc/codecs/hdmi-codec.c | 104 -
 sound/soc/rockchip/rockchip_max98090.c| 123 ---
 13 files changed, 508 insertions(+), 26 deletions(-)
 create mode 100644 drivers/video/hdmi-notifier.c
 create mode 100644 include/linux/hdmi-notifier.h

-- 
2.22.0.rc1.257.g3120a18244-goog



[PATCH 2/7] ASoC: hdmi-codec: use HDMI state notifier to add jack support

2019-06-02 Thread Cheng-Yi Chiang
From: Philipp Zabel 

Use HDMI connection / disconnection notifications to update an ALSA
jack object. Also make a copy of the ELD block after every change.

This was posted by Philipp Zabel at

https://patchwork.kernel.org/patch/9430747/

Modified by Cheng-Yi Chiang:
- Fix the conflict of removed hdmi_codec_remove ops.
- Other minor fix for the conflict with latest hdmi-codec on ASoC
  for-next tree.

Signed-off-by: Philipp Zabel 
Signed-off-by: Cheng-Yi Chiang 
---
The original patch is at https://patchwork.kernel.org/patch/9430747/
I could not find the LKML link for the patch.

 include/sound/hdmi-codec.h|   7 +++
 sound/soc/codecs/Kconfig  |   1 +
 sound/soc/codecs/hdmi-codec.c | 104 +-
 3 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 9483c55f871b..4fa39c93363f 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -107,6 +107,13 @@ struct hdmi_codec_pdata {
void *data;
 };
 
+struct snd_soc_component;
+struct snd_soc_jack;
+
+int hdmi_codec_set_jack_detect(struct snd_soc_component *component,
+  struct snd_soc_jack *jack,
+  struct device *dev);
+
 #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
 
 #endif /* __HDMI_CODEC_H__ */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 8f577258080b..f5f6dd04234c 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -639,6 +639,7 @@ config SND_SOC_HDMI_CODEC
select SND_PCM_ELD
select SND_PCM_IEC958
select HDMI
+   select HDMI_NOTIFIERS
 
 config SND_SOC_ES7134
tristate "Everest Semi ES7134 CODEC"
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 6a0cc8d7e141..fe796a7475a5 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -12,9 +12,12 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * General Public License for more details.
  */
+#include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -282,6 +285,13 @@ struct hdmi_codec_priv {
struct snd_pcm_chmap *chmap_info;
unsigned int chmap_idx;
struct mutex lock;
+   struct snd_soc_jack *jack;
+   /* Lock to protect setting and getting eld. */
+   struct mutex eld_lock;
+   struct device *dev;
+   struct hdmi_notifier *notifier;
+   struct notifier_block nb;
+   unsigned int jack_status;
 };
 
 static const struct snd_soc_dapm_widget hdmi_widgets[] = {
@@ -308,7 +318,9 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
 
+   mutex_lock(&hcp->eld_lock);
memcpy(ucontrol->value.bytes.data, hcp->eld, sizeof(hcp->eld));
+   mutex_unlock(&hcp->eld_lock);
 
return 0;
 }
@@ -393,7 +405,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream 
*substream,
  struct snd_soc_dai *dai)
 {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
-   int ret = 0;
+   int ret;
 
ret = mutex_trylock(&hcp->lock);
if (!ret) {
@@ -408,9 +420,9 @@ static int hdmi_codec_startup(struct snd_pcm_substream 
*substream,
}
 
if (hcp->hcd.ops->get_eld) {
+   mutex_lock(&hcp->eld_lock);
ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data,
hcp->eld, sizeof(hcp->eld));
-
if (!ret) {
ret = snd_pcm_hw_constraint_eld(substream->runtime,
hcp->eld);
@@ -419,6 +431,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream 
*substream,
}
/* Select chmap supported */
hdmi_codec_eld_chmap(hcp);
+   mutex_unlock(&hcp->eld_lock);
}
return 0;
 
@@ -747,6 +760,77 @@ static const struct snd_soc_component_driver hdmi_driver = 
{
.non_legacy_dai_naming  = 1,
 };
 
+static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp,
+  unsigned int jack_status)
+{
+   if (!hcp->jack)
+   return;
+
+   if (jack_status != hcp->jack_status) {
+   snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT);
+   hcp->jack_status = jack_status;
+   }
+}
+
+static int hdmi_codec_notify(struct notifier_block *nb, unsigned long event,
+void *data)
+{
+   struct hdmi_codec_priv *hcp = container_of(nb, struct hdmi_codec_priv,
+  nb);
+   struct hdmi_notifier *n = data;
+
+   if (!hcp->jack)
+   return NOTIFY_OK;
+
+ 

[PATCH 6/7] ASoC: rockchip_max98090: Add HDMI jack support

2019-06-02 Thread Cheng-Yi Chiang
In machine driver, create a jack and let hdmi-codec report jack status.

Signed-off-by: Cheng-Yi Chiang 
---
 sound/soc/rockchip/rockchip_max98090.c | 41 ++
 1 file changed, 41 insertions(+)

diff --git a/sound/soc/rockchip/rockchip_max98090.c 
b/sound/soc/rockchip/rockchip_max98090.c
index 2dd247670c7a..17c50d9fbac1 100644
--- a/sound/soc/rockchip/rockchip_max98090.c
+++ b/sound/soc/rockchip/rockchip_max98090.c
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rockchip_i2s.h"
 #include "../codecs/ts3a227e.h"
@@ -131,6 +133,26 @@ enum {
DAILINK_HDMI,
 };
 
+static struct snd_soc_jack rk_hdmi_jack;
+
+static int rk_hdmi_init(struct snd_soc_pcm_runtime *runtime)
+{
+   struct snd_soc_card *card = runtime->card;
+   struct snd_soc_component *component = runtime->codec_dai->component;
+   struct device *hdmi_dev = snd_soc_card_get_drvdata(card);
+   int ret;
+
+   /* enable jack detection */
+   ret = snd_soc_card_jack_new(card, "HDMI Jack", SND_JACK_LINEOUT,
+   &rk_hdmi_jack, NULL, 0);
+   if (ret) {
+   dev_err(card->dev, "Can't new HDMI Jack %d\n", ret);
+   return ret;
+   }
+
+   return hdmi_codec_set_jack_detect(component, &rk_hdmi_jack, hdmi_dev);
+}
+
 /* max98090 and HDMI codec dai_link */
 static struct snd_soc_dai_link rk_dailinks[] = {
[DAILINK_MAX98090] = {
@@ -148,6 +170,7 @@ static struct snd_soc_dai_link rk_dailinks[] = {
.ops = &rk_aif1_ops,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
+   .init = rk_hdmi_init,
}
 };
 
@@ -200,6 +223,8 @@ static int snd_rk_mc_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct device_node *np_cpu;
struct of_phandle_args args;
+   struct device_node *np_hdmi;
+   struct platform_device *hdmi_pdev;
 
/* register the soc card */
card->dev = &pdev->dev;
@@ -248,6 +273,22 @@ static int snd_rk_mc_probe(struct platform_device *pdev)
return -EINVAL;
}
 
+   /* The hdmi device handles HDMI hotplug detection */
+   np_hdmi = of_parse_phandle(np, "rockchip,hdmi", 0);
+   if (!np_hdmi) {
+   dev_err(&pdev->dev, "Failed to find HDMI node\n");
+   return -EINVAL;
+   }
+
+   hdmi_pdev = of_find_device_by_node(np_hdmi);
+   if (!hdmi_pdev) {
+   dev_err(&pdev->dev, "Waiting for HDMI device %s\n",
+   np_hdmi->full_name);
+   return -EPROBE_DEFER;
+   }
+
+   snd_soc_card_set_drvdata(card, &hdmi_pdev->dev);
+
ret = snd_soc_of_parse_card_name(card, "rockchip,model");
if (ret) {
dev_err(&pdev->dev,
-- 
2.22.0.rc1.257.g3120a18244-goog



[PATCH 1/7] video: add HDMI state notifier support

2019-06-02 Thread Cheng-Yi Chiang
From: Hans Verkuil 

Add support for HDMI hotplug and EDID notifiers, which is used to convey
information from HDMI drivers to their CEC and audio counterparts.

Based on an earlier version from Russell King:

https://patchwork.kernel.org/patch/9277043/

The hdmi_notifier is a reference counted object containing the HDMI state
of an HDMI device.

When a new notifier is registered the current state will be reported to
that notifier at registration time.

Based on Hans Verkuil's patch:

https://patchwork.kernel.org/patch/9472521/

Modified by Cheng-Yi Chiang:
 - Add a section in MAINTAINER.
 - Changes connected and has_eld to bitfield of unsigned int.
 - Other minor fixes to pass checkpatch.pl --strict checks.

Signed-off-by: Hans Verkuil 
Acked-by: Philipp Zabel 
Signed-off-by: Cheng-Yi Chiang 
---
The original patch is at
https://lore.kernel.org/linux-arm-kernel/20161213150813.37966-2-hverk...@xs4all.nl

 MAINTAINERS   |   6 ++
 drivers/video/Kconfig |   3 +
 drivers/video/Makefile|   1 +
 drivers/video/hdmi-notifier.c | 145 ++
 include/linux/hdmi-notifier.h | 112 ++
 5 files changed, 267 insertions(+)
 create mode 100644 drivers/video/hdmi-notifier.c
 create mode 100644 include/linux/hdmi-notifier.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5cfbea4ce575..ffb7376f9509 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16676,6 +16676,12 @@ W: https://linuxtv.org
 S: Maintained
 F: drivers/media/platform/vicodec/*
 
+VIDEO FRAMEWORK
+M: Hans Verkuil 
+L: linux-me...@vger.kernel.org
+F: drivers/video/hdmi-notifier.*
+S: Maintained
+
 VIDEO MULTIPLEXER DRIVER
 M: Philipp Zabel 
 L: linux-me...@vger.kernel.org
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 83d3d271ca15..000ba9bc0ae7 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -34,6 +34,9 @@ config VIDEOMODE_HELPERS
 config HDMI
bool
 
+config HDMI_NOTIFIERS
+   bool
+
 endif # HAS_IOMEM
 
 if VT
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index df7650adede9..eff4736102ca 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VGASTATE)+= vgastate.o
 obj-$(CONFIG_HDMI)+= hdmi.o
+obj-$(CONFIG_HDMI_NOTIFIERS)  += hdmi-notifier.o
 
 obj-$(CONFIG_VT) += console/
 obj-$(CONFIG_FB_STI) += console/
diff --git a/drivers/video/hdmi-notifier.c b/drivers/video/hdmi-notifier.c
new file mode 100644
index ..d1eedf661648
--- /dev/null
+++ b/drivers/video/hdmi-notifier.c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0
+/* hdmi-notifier.c - notify interested parties of (dis)connect and EDID
+ * events
+ *
+ * Copyright 2016 Russell King 
+ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static LIST_HEAD(hdmi_notifiers);
+static DEFINE_MUTEX(hdmi_notifiers_lock);
+
+struct hdmi_notifier *hdmi_notifier_get(struct device *dev)
+{
+   struct hdmi_notifier *n;
+
+   mutex_lock(&hdmi_notifiers_lock);
+   list_for_each_entry(n, &hdmi_notifiers, head) {
+   if (n->dev == dev) {
+   mutex_unlock(&hdmi_notifiers_lock);
+   kref_get(&n->kref);
+   return n;
+   }
+   }
+   n = kzalloc(sizeof(*n), GFP_KERNEL);
+   if (!n)
+   goto unlock;
+   n->dev = dev;
+   mutex_init(&n->lock);
+   BLOCKING_INIT_NOTIFIER_HEAD(&n->notifiers);
+   kref_init(&n->kref);
+   list_add_tail(&n->head, &hdmi_notifiers);
+unlock:
+   mutex_unlock(&hdmi_notifiers_lock);
+   return n;
+}
+EXPORT_SYMBOL_GPL(hdmi_notifier_get);
+
+static void hdmi_notifier_release(struct kref *kref)
+{
+   struct hdmi_notifier *n =
+   container_of(kref, struct hdmi_notifier, kref);
+
+   mutex_lock(&hdmi_notifiers_lock);
+   list_del(&n->head);
+   mutex_unlock(&hdmi_notifiers_lock);
+   kfree(n->edid);
+   kfree(n);
+}
+
+void hdmi_notifier_put(struct hdmi_notifier *n)
+{
+   kref_put(&n->kref, hdmi_notifier_release);
+}
+EXPORT_SYMBOL_GPL(hdmi_notifier_put);
+
+int hdmi_notifier_register(struct hdmi_notifier *n, struct notifier_block *nb)
+{
+   int ret = blocking_notifier_chain_register(&n->notifiers, nb);
+
+   if (ret)
+   return ret;
+   kref_get(&n->kref);
+   mutex_lock(&n->lock);
+   if (n->connected) {
+   blocking_notifier_call_chain(&n->notifiers, HDMI_CONNECTED, n);
+   if (n->edid_size)
+   blocking_notifier_call_chain(&n->notifiers,
+HDMI_NEW_EDID, n);
+   if (n->has_eld)
+   blocking_notifier_call_chain(&n->notifiers,
+

[PATCH 3/7] drm/bridge/synopsys: dw-hdmi: Add HDMI notifier support

2019-06-02 Thread Cheng-Yi Chiang
Use hdmi-notifier to notify codec driver that there is HDMI plug/unplug
event.

Signed-off-by: Cheng-Yi Chiang 
---
 drivers/gpu/drm/bridge/synopsys/Kconfig   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 28 +--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/Kconfig 
b/drivers/gpu/drm/bridge/synopsys/Kconfig
index 3cc53b44186e..43192d9d7357 100644
--- a/drivers/gpu/drm/bridge/synopsys/Kconfig
+++ b/drivers/gpu/drm/bridge/synopsys/Kconfig
@@ -3,6 +3,7 @@ config DRM_DW_HDMI
select DRM_KMS_HELPER
select REGMAP_MMIO
select CEC_CORE if CEC_NOTIFIER
+   select HDMI_NOTIFIERS
 
 config DRM_DW_HDMI_AHB_AUDIO
tristate "Synopsys Designware AHB Audio interface"
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index ab7968c8f6a2..53701921eb1f 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -190,6 +191,7 @@ struct dw_hdmi {
void (*disable_audio)(struct dw_hdmi *hdmi);
 
struct cec_notifier *cec_notifier;
+   struct hdmi_notifier *hdmi_notifier;
 };
 
 #define HDMI_IH_PHY_STAT0_RX_SENSE \
@@ -2301,8 +2303,15 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
}
 
if (intr_stat & HDMI_IH_PHY_STAT0_HPD) {
-   dev_dbg(hdmi->dev, "EVENT=%s\n",
-   phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout");
+   if (phy_int_pol & HDMI_PHY_HPD) {
+   dev_dbg(hdmi->dev, "EVENT=plugin\n");
+   if (hdmi->hdmi_notifier)
+   hdmi_event_connect(hdmi->hdmi_notifier);
+   } else {
+   dev_dbg(hdmi->dev, "EVENT=plugout\n");
+   if (hdmi->hdmi_notifier)
+   hdmi_event_disconnect(hdmi->hdmi_notifier);
+   }
if (hdmi->bridge.dev)
drm_helper_hpd_irq_event(hdmi->bridge.dev);
}
@@ -2606,6 +2615,12 @@ __dw_hdmi_probe(struct platform_device *pdev,
goto err_iahb;
}
 
+   hdmi->hdmi_notifier = hdmi_notifier_get(dev);
+   if (!hdmi->hdmi_notifier) {
+   ret = -ENOMEM;
+   goto err_iahb;
+   }
+
/*
 * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator
 * N and cts values before enabling phy
@@ -2696,6 +2711,9 @@ __dw_hdmi_probe(struct platform_device *pdev,
if (hdmi->cec_notifier)
cec_notifier_put(hdmi->cec_notifier);
 
+   if (hdmi->hdmi_notifier)
+   hdmi_notifier_put(hdmi->hdmi_notifier);
+
clk_disable_unprepare(hdmi->iahb_clk);
if (hdmi->cec_clk)
clk_disable_unprepare(hdmi->cec_clk);
@@ -2709,6 +2727,9 @@ __dw_hdmi_probe(struct platform_device *pdev,
 
 static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
 {
+   if (hdmi->hdmi_notifier)
+   hdmi_event_disconnect(hdmi->hdmi_notifier);
+
if (hdmi->audio && !IS_ERR(hdmi->audio))
platform_device_unregister(hdmi->audio);
if (!IS_ERR(hdmi->cec))
@@ -2720,6 +2741,9 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
if (hdmi->cec_notifier)
cec_notifier_put(hdmi->cec_notifier);
 
+   if (hdmi->hdmi_notifier)
+   hdmi_notifier_put(hdmi->hdmi_notifier);
+
clk_disable_unprepare(hdmi->iahb_clk);
clk_disable_unprepare(hdmi->isfr_clk);
if (hdmi->cec_clk)
-- 
2.22.0.rc1.257.g3120a18244-goog



[PATCH 5/7] ASoC: rockchip: rockchip-max98090: Add node for HDMI

2019-06-02 Thread Cheng-Yi Chiang
Let user specify HDMI node so machine driver can use it to let codec
driver register callback on correct hdmi-notifier.

Signed-off-by: Cheng-Yi Chiang 
---
 Documentation/devicetree/bindings/sound/rockchip-max98090.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/rockchip-max98090.txt 
b/Documentation/devicetree/bindings/sound/rockchip-max98090.txt
index a805aa99ad75..dae57c14864e 100644
--- a/Documentation/devicetree/bindings/sound/rockchip-max98090.txt
+++ b/Documentation/devicetree/bindings/sound/rockchip-max98090.txt
@@ -7,6 +7,7 @@ Required properties:
   connected to the CODEC
 - rockchip,audio-codec: The phandle of the MAX98090 audio codec
 - rockchip,headset-codec: The phandle of Ext chip for jack detection
+- rockchip,hdmi: The phandle of HDMI node for HDMI jack detection
 
 Example:
 
@@ -16,4 +17,5 @@ sound {
rockchip,i2s-controller = <&i2s>;
rockchip,audio-codec = <&max98090>;
rockchip,headset-codec = <&headsetcodec>;
+   rockchip,hdmi= <&hdmi>;
 };
-- 
2.22.0.rc1.257.g3120a18244-goog



[PATCH 7/7] ARM: dts: rockchip: Specify HDMI node to sound card node

2019-06-02 Thread Cheng-Yi Chiang
Sound card needs HDMI node in order to register jack callback on HDMI
notifier.

Signed-off-by: Cheng-Yi Chiang 
---
 arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi 
b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi
index 445270aa136e..096ba4e96db2 100644
--- a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi
+++ b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi
@@ -14,6 +14,7 @@
rockchip,model = "VEYRON-I2S";
rockchip,i2s-controller = <&i2s>;
rockchip,audio-codec = <&max98090>;
+   rockchip,hdmi= <&hdmi>;
rockchip,hp-det-gpios = <&gpio6 RK_PA5 GPIO_ACTIVE_HIGH>;
rockchip,mic-det-gpios = <&gpio6 RK_PB3 GPIO_ACTIVE_LOW>;
rockchip,headset-codec = <&headsetcodec>;
-- 
2.22.0.rc1.257.g3120a18244-goog



[PATCH 4/7] ASoC: rockchip_max98090: Add dai_link for HDMI

2019-06-02 Thread Cheng-Yi Chiang
Use two dai_links. One for HDMI and one for max98090.
With this setup, audio can play to speaker and HDMI selectively.

Signed-off-by: Cheng-Yi Chiang 
---
 sound/soc/rockchip/rockchip_max98090.c | 82 +++---
 1 file changed, 60 insertions(+), 22 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_max98090.c 
b/sound/soc/rockchip/rockchip_max98090.c
index 789d6f1e2b5f..2dd247670c7a 100644
--- a/sound/soc/rockchip/rockchip_max98090.c
+++ b/sound/soc/rockchip/rockchip_max98090.c
@@ -53,6 +53,7 @@ static const struct snd_soc_dapm_widget rk_dapm_widgets[] = {
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("Int Mic", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
+   SND_SOC_DAPM_LINE("HDMI", NULL),
 };
 
 static const struct snd_soc_dapm_route rk_audio_map[] = {
@@ -64,6 +65,7 @@ static const struct snd_soc_dapm_route rk_audio_map[] = {
{"Headphone", NULL, "HPR"},
{"Speaker", NULL, "SPKL"},
{"Speaker", NULL, "SPKR"},
+   {"HDMI", NULL, "TX"},
 };
 
 static const struct snd_kcontrol_new rk_mc_controls[] = {
@@ -71,6 +73,7 @@ static const struct snd_kcontrol_new rk_mc_controls[] = {
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Int Mic"),
SOC_DAPM_PIN_SWITCH("Speaker"),
+   SOC_DAPM_PIN_SWITCH("HDMI"),
 };
 
 static int rk_aif1_hw_params(struct snd_pcm_substream *substream,
@@ -104,33 +107,48 @@ static int rk_aif1_hw_params(struct snd_pcm_substream 
*substream,
 
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
 SND_SOC_CLOCK_OUT);
-   if (ret < 0) {
-   dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret);
+   if (ret && ret != -ENOTSUPP) {
+   dev_err(cpu_dai->dev, "Can't set cpu dai clock %d\n", ret);
return ret;
}
 
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 SND_SOC_CLOCK_IN);
-   if (ret < 0) {
-   dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret);
+   if (ret && ret != -ENOTSUPP) {
+   dev_err(codec_dai->dev, "Can't set codec dai clock %d\n", ret);
return ret;
}
 
-   return ret;
+   return 0;
 }
 
 static const struct snd_soc_ops rk_aif1_ops = {
.hw_params = rk_aif1_hw_params,
 };
 
-static struct snd_soc_dai_link rk_dailink = {
-   .name = "max98090",
-   .stream_name = "Audio",
-   .codec_dai_name = "HiFi",
-   .ops = &rk_aif1_ops,
-   /* set max98090 as slave */
-   .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
-   SND_SOC_DAIFMT_CBS_CFS,
+enum {
+   DAILINK_MAX98090,
+   DAILINK_HDMI,
+};
+
+/* max98090 and HDMI codec dai_link */
+static struct snd_soc_dai_link rk_dailinks[] = {
+   [DAILINK_MAX98090] = {
+   .name = "max98090",
+   .stream_name = "Analog",
+   .ops = &rk_aif1_ops,
+   .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+   SND_SOC_DAIFMT_CBS_CFS,
+   },
+   [DAILINK_HDMI] = {
+   .name = "HDMI",
+   .stream_name = "HDMI",
+   .codec_name = "hdmi-audio-codec.3.auto",
+   .codec_dai_name = "i2s-hifi",
+   .ops = &rk_aif1_ops,
+   .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+   SND_SOC_DAIFMT_CBS_CFS,
+   }
 };
 
 static int rk_98090_headset_init(struct snd_soc_component *component);
@@ -143,8 +161,8 @@ static struct snd_soc_aux_dev rk_98090_headset_dev = {
 static struct snd_soc_card snd_soc_card_rk = {
.name = "ROCKCHIP-I2S",
.owner = THIS_MODULE,
-   .dai_link = &rk_dailink,
-   .num_links = 1,
+   .dai_link = rk_dailinks,
+   .num_links = ARRAY_SIZE(rk_dailinks),
.aux_dev = &rk_98090_headset_dev,
.num_aux_devs = 1,
.dapm_widgets = rk_dapm_widgets,
@@ -180,27 +198,47 @@ static int snd_rk_mc_probe(struct platform_device *pdev)
int ret = 0;
struct snd_soc_card *card = &snd_soc_card_rk;
struct device_node *np = pdev->dev.of_node;
+   struct device_node *np_cpu;
+   struct of_phandle_args args;
 
/* register the soc card */
card->dev = &pdev->dev;
 
-   rk_dailink.codec_of_node = of_parse_phandle(np,
-   "rockchip,audio-codec", 0);
-   if (!rk_dailink.codec_of_node) {
+   rk_dailinks[DAILINK_MAX98090].codec_of_node =
+   of_parse_phandle(np, "rockchip,audio-codec", 0);
+   if (!rk_dailinks[DAILINK_MAX98090].codec_of_node) {
dev_err(&pdev->dev,
"Property 'rockchip,audio-codec' missing or invalid\n");
return -EINVAL;
}
 
-   rk_dailink.cpu_of_node = of_parse_phandle(np,
-   "rockchip,i2s-controller", 0);
-   if (!rk_dailink.cpu_of_node) {
+   ret = o

Re: [v4 1/7] drm/mediatek: move mipi_dsi_host_register to probe

2019-06-02 Thread Hsin-Yi Wang
On Sat, Jun 1, 2019 at 9:26 AM Jitao Shi  wrote:

> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -1045,12 +1045,6 @@ static int mtk_dsi_bind(struct device *dev, struct 
> device *master, void *data)
> return ret;
> }
>
> -   ret = mipi_dsi_host_register(&dsi->host);
> -   if (ret < 0) {
> -   dev_err(dev, "failed to register DSI host: %d\n", ret);
> -   goto err_ddp_comp_unregister;
> -   }
> -

> @@ -1097,31 +1089,37 @@ static int mtk_dsi_probe(struct platform_device *pdev)
>
> dsi->host.ops = &mtk_dsi_ops;
> dsi->host.dev = dev;
> +   dsi->dev = dev;
> +   ret = mipi_dsi_host_register(&dsi->host);
> +   if (ret < 0) {
> +   dev_err(dev, "failed to register DSI host: %d\n", ret);
> +   return ret;
> +   }

(It's commented on v3, in case it's missed, sent this again.)
Since mipi_dsi_host_register() is moved from .bind to .probe,
mipi_dsi_host_unregister() should also be moved from .unbind to
.remove?

Thanks


Re: [PATCH] of/device: add blacklist for iommu dma_ops

2019-06-02 Thread Tomasz Figa
On Mon, Jun 3, 2019 at 4:40 AM Rob Clark  wrote:
>
> On Fri, May 10, 2019 at 7:35 AM Rob Clark  wrote:
> >
> > On Tue, Dec 4, 2018 at 2:29 PM Rob Herring  wrote:
> > >
> > > On Sat, Dec 1, 2018 at 10:54 AM Rob Clark  wrote:
> > > >
> > > > This solves a problem we see with drm/msm, caused by getting
> > > > iommu_dma_ops while we attach our own domain and manage it directly at
> > > > the iommu API level:
> > > >
> > > >   [0038] user address but active_mm is swapper
> > > >   Internal error: Oops: 9605 [#1] PREEMPT SMP
> > > >   Modules linked in:
> > > >   CPU: 7 PID: 70 Comm: kworker/7:1 Tainted: GW 4.19.3 
> > > > #90
> > > >   Hardware name: xxx (DT)
> > > >   Workqueue: events deferred_probe_work_func
> > > >   pstate: 80c9 (Nzcv daif +PAN +UAO)
> > > >   pc : iommu_dma_map_sg+0x7c/0x2c8
> > > >   lr : iommu_dma_map_sg+0x40/0x2c8
> > > >   sp : ff80095eb4f0
> > > >   x29: ff80095eb4f0 x28: 
> > > >   x27: ffc0f9431578 x26: 
> > > >   x25:  x24: 0003
> > > >   x23: 0001 x22: ffc0fa9ac010
> > > >   x21:  x20: ffc0fab40980
> > > >   x19: ffc0fab40980 x18: 0003
> > > >   x17: 01c4 x16: 0007
> > > >   x15: 000e x14: 
> > > >   x13:  x12: 0028
> > > >   x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f
> > > >   x9 :  x8 : ffc0fab409a0
> > > >   x7 :  x6 : 0002
> > > >   x5 : 0001 x4 : 
> > > >   x3 : 0001 x2 : 0002
> > > >   x1 : ffc0f9431578 x0 : 
> > > >   Process kworker/7:1 (pid: 70, stack limit = 0x17d08ffb)
> > > >   Call trace:
> > > >iommu_dma_map_sg+0x7c/0x2c8
> > > >__iommu_map_sg_attrs+0x70/0x84
> > > >get_pages+0x170/0x1e8
> > > >msm_gem_get_iova+0x8c/0x128
> > > >_msm_gem_kernel_new+0x6c/0xc8
> > > >msm_gem_kernel_new+0x4c/0x58
> > > >dsi_tx_buf_alloc_6g+0x4c/0x8c
> > > >msm_dsi_host_modeset_init+0xc8/0x108
> > > >msm_dsi_modeset_init+0x54/0x18c
> > > >_dpu_kms_drm_obj_init+0x430/0x474
> > > >dpu_kms_hw_init+0x5f8/0x6b4
> > > >msm_drm_bind+0x360/0x6c8
> > > >try_to_bring_up_master.part.7+0x28/0x70
> > > >component_master_add_with_match+0xe8/0x124
> > > >msm_pdev_probe+0x294/0x2b4
> > > >platform_drv_probe+0x58/0xa4
> > > >really_probe+0x150/0x294
> > > >driver_probe_device+0xac/0xe8
> > > >__device_attach_driver+0xa4/0xb4
> > > >bus_for_each_drv+0x98/0xc8
> > > >__device_attach+0xac/0x12c
> > > >device_initial_probe+0x24/0x30
> > > >bus_probe_device+0x38/0x98
> > > >deferred_probe_work_func+0x78/0xa4
> > > >process_one_work+0x24c/0x3dc
> > > >worker_thread+0x280/0x360
> > > >kthread+0x134/0x13c
> > > >ret_from_fork+0x10/0x18
> > > >   Code: d284 91000725 6b17039f 5400048a (f9401f40)
> > > >   ---[ end trace f22dda57f3648e2c ]---
> > > >   Kernel panic - not syncing: Fatal exception
> > > >   SMP: stopping secondary CPUs
> > > >   Kernel Offset: disabled
> > > >   CPU features: 0x0,22802a18
> > > >   Memory Limit: none
> > > >
> > > > The problem is that when drm/msm does it's own iommu_attach_device(),
> > > > now the domain returned by iommu_get_domain_for_dev() is drm/msm's
> > > > domain, and it doesn't have domain->iova_cookie.
> > > >
> > > > We kind of avoided this problem prior to sdm845/dpu because the iommu
> > > > was attached to the mdp node in dt, which is a child of the toplevel
> > > > mdss node (which corresponds to the dev passed in dma_map_sg()).  But
> > > > with sdm845, now the iommu is attached at the mdss level so we hit the
> > > > iommu_dma_ops in dma_map_sg().
> > > >
> > > > But auto allocating/attaching a domain before the driver is probed was
> > > > already a blocking problem for enabling per-context pagetables for the
> > > > GPU.  This problem is also now solved with this patch.
> > > >
> > > > Fixes: 97890ba9289c dma-mapping: detect and configure IOMMU in 
> > > > of_dma_configure
> > > > Tested-by: Douglas Anderson 
> > > > Signed-off-by: Rob Clark 
> > > > ---
> > > > This is an alternative/replacement for [1].  What it lacks in elegance
> > > > it makes up for in practicality ;-)
> > > >
> > > > [1] https://patchwork.freedesktop.org/patch/264930/
> > > >
> > > >  drivers/of/device.c | 22 ++
> > > >  1 file changed, 22 insertions(+)
> > > >
> > > > diff --git a/drivers/of/device.c b/drivers/of/device.c
> > > > index 5957cd4fa262..15ffee00fb22 100644
> > > > --- a/drivers/of/device.c
> > > > +++ b/drivers/of/device.c
> > > > @@ -72,6 +72,14 @@ int of_device_add(struct platform_device *ofdev)
> > > > return device_add(&ofdev->dev);
> > > >  }
> > > >
> > > > +static const struct of_device_id iommu_blacklist[] = {
> > > > +   { .compatible = "qcom,mdp4" },
> > > 

[PATCH v1 0/2] Adds slave pipeline support

2019-06-02 Thread Lowry Li (Arm Technology China)
Hi,

This serie aims at adding the support for slave pipeline on Komeda
driver. Also adds drop_master to shutdown the device and make sure
all the komeda resources shared between crtcs have been released.

This patch series depends on:
- https://patchwork.freedesktop.org/series/58710/
- https://patchwork.freedesktop.org/series/59000/
- https://patchwork.freedesktop.org/series/59002/
- https://patchwork.freedesktop.org/series/59747/
- https://patchwork.freedesktop.org/series/59915/
- https://patchwork.freedesktop.org/series/60083/
- https://patchwork.freedesktop.org/series/60698/
- https://patchwork.freedesktop.org/series/60856/
- https://patchwork.freedesktop.org/series/60893/
- https://patchwork.freedesktop.org/series/61370/

Regards,
Lowry

Lowry Li (Arm Technology China) (2):
  drm/komeda: Add slave pipeline support
  drm/komeda: Adds komeda_kms_drop_master

 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c   | 41 --
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c| 23 
 drivers/gpu/drm/arm/display/komeda/komeda_kms.h|  9 +
 .../gpu/drm/arm/display/komeda/komeda_pipeline.c   | 22 
 .../gpu/drm/arm/display/komeda/komeda_pipeline.h   |  2 ++
 .../drm/arm/display/komeda/komeda_pipeline_state.c | 15 
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c  | 32 -
 7 files changed, 141 insertions(+), 3 deletions(-)

-- 
1.9.1



[PATCH v1 2/2] drm/komeda: Adds komeda_kms_drop_master

2019-06-02 Thread Lowry Li (Arm Technology China)
The komeda internal resources (pipelines) are shared between crtcs,
and resources release by disable_crtc. This commit is working for once
user forgot disabling crtc like app quit abnomally, and then the
resources can not be used by another crtc. Adds drop_master to
shutdown the device and make sure all the komeda resources have been
released and can be used for the next usage.

Signed-off-by: Lowry Li (Arm Technology China) 
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 8543860..647bce5 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -54,11 +54,24 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void 
*data)
return status;
 }
 
+/* Komeda internal resources (pipelines) are shared between crtcs, and 
resources
+ * are released by disable_crtc. But if user forget disabling crtc like app 
quit
+ * abnormally, the resources can not be used by another crtc.
+ * Use drop_master to shutdown the device and make sure all the komeda 
resources
+ * have been released, and can be used for the next usage.
+ */
+static void komeda_kms_drop_master(struct drm_device *dev,
+  struct drm_file *file_priv)
+{
+   drm_atomic_helper_shutdown(dev);
+}
+
 static struct drm_driver komeda_kms_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
   DRIVER_PRIME | DRIVER_HAVE_IRQ,
.lastclose  = drm_fb_helper_lastclose,
.irq_handler= komeda_kms_irq_handler,
+   .master_drop= komeda_kms_drop_master,
.gem_free_object_unlocked   = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create= komeda_gem_cma_dumb_create,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v1 1/2] drm/komeda: Add slave pipeline support

2019-06-02 Thread Lowry Li (Arm Technology China)
One crtc can use two komeda_pipeline, and one works as master and as
slave. the slave pipeline doesn't have its own output and timing
ctrlr, but pre-composite the input layer data flow and then feed the
result to master. the pipeline configuration like:

slave-layer-0 \
...slave->CU
slave-layer-4 / \
\
master-layer-0 > master->CU -> ...
 ...  /
master-layer-4 -->

Since komeda Compiz doesn't output alpha, so the slave->CU result
only can be used as bottom input when blend it with master input data
flows.

Signed-off-by: Lowry Li (Arm Technology China) 
---
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c   | 41 --
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c| 10 ++
 drivers/gpu/drm/arm/display/komeda/komeda_kms.h|  9 +
 .../gpu/drm/arm/display/komeda/komeda_pipeline.c   | 22 
 .../gpu/drm/arm/display/komeda/komeda_pipeline.h   |  2 ++
 .../drm/arm/display/komeda/komeda_pipeline_state.c | 15 
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c  | 32 -
 7 files changed, 128 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 18c23f8..b5190a1 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -64,6 +64,10 @@ static void komeda_crtc_update_clock_ratio(struct 
komeda_crtc_state *kcrtc_st)
}
 
/* release unclaimed pipeline resources */
+   err = komeda_release_unclaimed_resources(kcrtc->slave, kcrtc_st);
+   if (err)
+   return err;
+
err = komeda_release_unclaimed_resources(kcrtc->master, kcrtc_st);
if (err)
return err;
@@ -230,6 +234,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc->state);
struct komeda_dev *mdev = kcrtc->base.dev->dev_private;
struct komeda_pipeline *master = kcrtc->master;
+   struct komeda_pipeline *slave = kcrtc->slave;
struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
struct drm_connector_state *conn_st;
 
@@ -241,6 +246,9 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
if (has_bit(master->id, kcrtc_st->affected_pipes))
komeda_pipeline_update(master, old->state);
 
+   if (slave && has_bit(slave->id, kcrtc_st->affected_pipes))
+   komeda_pipeline_update(slave, old->state);
+
conn_st = wb_conn ? wb_conn->base.base.state : NULL;
if (conn_st && conn_st->writeback_job)
drm_writeback_queue_job(&wb_conn->base, conn_st);
@@ -266,6 +274,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
struct komeda_crtc_state *old_st = to_kcrtc_st(old);
struct komeda_dev *mdev = crtc->dev->dev_private;
struct komeda_pipeline *master = kcrtc->master;
+   struct komeda_pipeline *slave  = kcrtc->slave;
struct completion *disable_done = &crtc->state->commit->flip_done;
struct completion temp;
int timeout;
@@ -274,6 +283,9 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
 drm_crtc_index(crtc),
 old_st->active_pipes, old_st->affected_pipes);
 
+   if (slave && has_bit(slave->id, old_st->active_pipes))
+   komeda_pipeline_disable(slave, old->state);
+
if (has_bit(master->id, old_st->active_pipes))
komeda_pipeline_disable(master, old->state);
 
@@ -425,6 +437,7 @@ static void komeda_crtc_reset(struct drm_crtc *crtc)
 
new->affected_pipes = old->active_pipes;
new->clock_ratio = old->clock_ratio;
+   new->max_slave_zorder = old->max_slave_zorder;
 
return &new->base;
 }
@@ -499,7 +512,7 @@ int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms,
master = mdev->pipelines[i];
 
crtc->master = master;
-   crtc->slave  = NULL;
+   crtc->slave  = komeda_pipeline_get_slave(master);
 
if (crtc->slave)
sprintf(str, "pipe-%d", crtc->slave->id);
@@ -533,6 +546,26 @@ static int komeda_crtc_create_clock_ratio_property(struct 
komeda_crtc *kcrtc)
return 0;
 }
 
+static int komeda_crtc_create_slave_planes_property(struct komeda_crtc *kcrtc)
+{
+   struct drm_crtc *crtc = &kcrtc->base;
+   struct drm_property *prop;
+
+   if (kcrtc->slave_planes == 0)
+   return 0;
+
+   prop = drm_property_create_range(crtc->dev, DRM_MODE_PROP_IMMUTABLE,
+"slave_planes", 0, U32_MAX);
+   if (!prop)
+   return -ENOMEM;
+
+   drm_object_attach_property(&crtc->base, prop, kcrtc->slave_planes);
+
+   kcrtc->slave_planes_property = prop;
+
+   return 0;
+}
+
 static struct drm_plane *
 get_crtc_