[PATCH v4 07/22] drm: mxsfb: Use LCDC_CTRL register name explicitly

2020-07-26 Thread Laurent Pinchart
The LCDC_CTRL register is located at address 0x. Some of the
accesses to the register simply use the mxsfb->base address. Reference
the LCDC_CTRL register explicitly instead to clarify the code.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index be60c4021e2f..722bd9b4f5f9 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -170,17 +170,17 @@ static int mxsfb_reset_block(struct mxsfb_drm_private 
*mxsfb)
 {
int ret;
 
-   ret = clear_poll_bit(mxsfb->base, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_SFTRST);
if (ret)
return ret;
 
-   writel(MODULE_CLKGATE, mxsfb->base + MXS_CLR_ADDR);
+   writel(MODULE_CLKGATE, mxsfb->base + LCDC_CTRL + MXS_CLR_ADDR);
 
-   ret = clear_poll_bit(mxsfb->base, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_SFTRST);
if (ret)
return ret;
 
-   return clear_poll_bit(mxsfb->base, MODULE_CLKGATE);
+   return clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_CLKGATE);
 }
 
 static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb)
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 17/22] drm: mxsfb: Update internal IP version number for i.MX6SX

2020-07-26 Thread Laurent Pinchart
The LCDIF present in the i.MX6SX has extra features compared to
the i.MX28. It has however lost its IP version register, so no official
version number is known. Bump the version to MXSFB_V6 following the i.MX
version, in preparation for support for the additional features.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index ff5551935574..9fe0a37e007d 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -35,6 +35,11 @@
 enum mxsfb_devtype {
MXSFB_V3,
MXSFB_V4,
+   /*
+* Starting at i.MX6 the hardware version register is gone, use the
+* i.MX family number as the version.
+*/
+   MXSFB_V6,
 };
 
 static const struct mxsfb_devdata mxsfb_devdata[] = {
@@ -52,6 +57,13 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
.hs_wdth_mask   = 0x3fff,
.hs_wdth_shift  = 18,
},
+   [MXSFB_V6] = {
+   .transfer_count = LCDC_V4_TRANSFER_COUNT,
+   .cur_buf= LCDC_V4_CUR_BUF,
+   .next_buf   = LCDC_V4_NEXT_BUF,
+   .hs_wdth_mask   = 0x3fff,
+   .hs_wdth_shift  = 18,
+   },
 };
 
 void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
@@ -271,7 +283,7 @@ static struct drm_driver mxsfb_driver = {
 static const struct platform_device_id mxsfb_devtype[] = {
{ .name = "imx23-fb", .driver_data = MXSFB_V3, },
{ .name = "imx28-fb", .driver_data = MXSFB_V4, },
-   { .name = "imx6sx-fb", .driver_data = MXSFB_V4, },
+   { .name = "imx6sx-fb", .driver_data = MXSFB_V6, },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, mxsfb_devtype);
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 10/22] drm: mxsfb: Rename mxsfb_crtc.c to mxsfb_kms.c

2020-07-26 Thread Laurent Pinchart
The mxsfb_crtc.c file doesn't handle just the CRTC, but also the other
KMS objects. Rename it accordingly.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/Makefile  | 2 +-
 drivers/gpu/drm/mxsfb/{mxsfb_crtc.c => mxsfb_kms.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/gpu/drm/mxsfb/{mxsfb_crtc.c => mxsfb_kms.c} (100%)

diff --git a/drivers/gpu/drm/mxsfb/Makefile b/drivers/gpu/drm/mxsfb/Makefile
index 811584e54ad1..26d153896d72 100644
--- a/drivers/gpu/drm/mxsfb/Makefile
+++ b/drivers/gpu/drm/mxsfb/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-mxsfb-y := mxsfb_drv.o mxsfb_crtc.o
+mxsfb-y := mxsfb_drv.o mxsfb_kms.o
 obj-$(CONFIG_DRM_MXSFB)+= mxsfb.o
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
similarity index 100%
rename from drivers/gpu/drm/mxsfb/mxsfb_crtc.c
rename to drivers/gpu/drm/mxsfb/mxsfb_kms.c
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 05/22] drm: mxsfb: Clarify format and bus width configuration

2020-07-26 Thread Laurent Pinchart
Replace the convoluted way to set the format and bus width through
difficult to read macros with more explicit ones. Also remove the
outdated comment related to the limitations on bus width setting as it
doesn't apply anymore (the bus width can be specified through the
display_info bus format).

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 17 +
 drivers/gpu/drm/mxsfb/mxsfb_regs.h | 17 -
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index b69ace8bf526..8b6339316929 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -52,13 +52,6 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private 
*mxsfb)
 
ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER;
 
-   /*
-* WARNING: The bus width, CTRL_SET_BUS_WIDTH(), is configured to
-* match the selected mode here. This differs from the original
-* MXSFB driver, which had the option to configure the bus width
-* to arbitrary value. This limitation should not pose an issue.
-*/
-
/* CTRL1 contains IRQ config and status bits, preserve those. */
ctrl1 = readl(mxsfb->base + LCDC_CTRL1);
ctrl1 &= CTRL1_CUR_FRAME_DONE_IRQ_EN | CTRL1_CUR_FRAME_DONE_IRQ;
@@ -66,12 +59,12 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private 
*mxsfb)
switch (format) {
case DRM_FORMAT_RGB565:
dev_dbg(drm->dev, "Setting up RGB565 mode\n");
-   ctrl |= CTRL_SET_WORD_LENGTH(0);
+   ctrl |= CTRL_WORD_LENGTH_16;
ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf);
break;
case DRM_FORMAT_XRGB:
dev_dbg(drm->dev, "Setting up XRGB mode\n");
-   ctrl |= CTRL_SET_WORD_LENGTH(3);
+   ctrl |= CTRL_WORD_LENGTH_24;
/* Do not use packed pixels = one pixel per word instead. */
ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0x7);
break;
@@ -104,13 +97,13 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private 
*mxsfb)
reg &= ~CTRL_BUS_WIDTH_MASK;
switch (bus_format) {
case MEDIA_BUS_FMT_RGB565_1X16:
-   reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_16BIT);
+   reg |= CTRL_BUS_WIDTH_16;
break;
case MEDIA_BUS_FMT_RGB666_1X18:
-   reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_18BIT);
+   reg |= CTRL_BUS_WIDTH_18;
break;
case MEDIA_BUS_FMT_RGB888_1X24:
-   reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_24BIT);
+   reg |= CTRL_BUS_WIDTH_24;
break;
default:
dev_err(drm->dev, "Unknown media bus format %d\n", bus_format);
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_regs.h 
b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
index 78e6cb754712..8ebb52bb1b46 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_regs.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
@@ -34,11 +34,15 @@
 #define CTRL_VSYNC_MODEBIT(18)
 #define CTRL_DOTCLK_MODE   BIT(17)
 #define CTRL_DATA_SELECT   BIT(16)
-#define CTRL_SET_BUS_WIDTH(x)  (((x) & 0x3) << 10)
-#define CTRL_GET_BUS_WIDTH(x)  (((x) >> 10) & 0x3)
+#define CTRL_BUS_WIDTH_16  (0 << 10)
+#define CTRL_BUS_WIDTH_8   (1 << 10)
+#define CTRL_BUS_WIDTH_18  (2 << 10)
+#define CTRL_BUS_WIDTH_24  (3 << 10)
 #define CTRL_BUS_WIDTH_MASK(0x3 << 10)
-#define CTRL_SET_WORD_LENGTH(x)(((x) & 0x3) << 8)
-#define CTRL_GET_WORD_LENGTH(x)(((x) >> 8) & 0x3)
+#define CTRL_WORD_LENGTH_16(0 << 8)
+#define CTRL_WORD_LENGTH_8 (1 << 8)
+#define CTRL_WORD_LENGTH_18(2 << 8)
+#define CTRL_WORD_LENGTH_24(3 << 8)
 #define CTRL_MASTERBIT(5)
 #define CTRL_DF16  BIT(3)
 #define CTRL_DF18  BIT(2)
@@ -91,9 +95,4 @@
 #define MXSFB_MAX_XRES 0x
 #define MXSFB_MAX_YRES 0x
 
-#define STMLCDIF_8BIT  1 /* pixel data bus to the display is of 8 bit width */
-#define STMLCDIF_16BIT 0 /* pixel data bus to the display is of 16 bit width */
-#define STMLCDIF_18BIT 2 /* pixel data bus to the display is of 18 bit width */
-#define STMLCDIF_24BIT 3 /* pixel data bus to the display is of 24 bit width */
-
 #endif /* __MXSFB_REGS_H__ */
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 15/22] drm: mxsfb: Remove mxsfb_devdata unused fields

2020-07-26 Thread Laurent Pinchart
The debug0 and ipversion fields of the mxsfb_devdata structure are
unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 
 drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 --
 2 files changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 85756d5907e3..ff5551935574 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -42,19 +42,15 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
.transfer_count = LCDC_V3_TRANSFER_COUNT,
.cur_buf= LCDC_V3_CUR_BUF,
.next_buf   = LCDC_V3_NEXT_BUF,
-   .debug0 = LCDC_V3_DEBUG0,
.hs_wdth_mask   = 0xff,
.hs_wdth_shift  = 24,
-   .ipversion  = 3,
},
[MXSFB_V4] = {
.transfer_count = LCDC_V4_TRANSFER_COUNT,
.cur_buf= LCDC_V4_CUR_BUF,
.next_buf   = LCDC_V4_NEXT_BUF,
-   .debug0 = LCDC_V4_DEBUG0,
.hs_wdth_mask   = 0x3fff,
.hs_wdth_shift  = 18,
-   .ipversion  = 4,
},
 };
 
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
index edd766ad254f..607a6a5e6be3 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
@@ -19,10 +19,8 @@ struct mxsfb_devdata {
unsigned int transfer_count;
unsigned int cur_buf;
unsigned int next_buf;
-   unsigned int debug0;
unsigned int hs_wdth_mask;
unsigned int hs_wdth_shift;
-   unsigned int ipversion;
 };
 
 struct mxsfb_drm_private {
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 03/22] drm: mxsfb: Use BIT() macro to define register bitfields

2020-07-26 Thread Laurent Pinchart
Using BIT() is preferred over manual shifts as it's more readable,
handles the 1 << 31 case properly, and avoids other mistakes as shown by
the DEBUG0_HSYNC and DEBUG0_VSYNC bits (that are currently unused). Use
it.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_regs.h | 56 +++---
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_regs.h 
b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
index 932d7ea08fd5..713d8f830135 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_regs.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
@@ -28,51 +28,51 @@
 #define LCDC_V4_DEBUG0 0x1d0
 #define LCDC_V3_DEBUG0 0x1f0
 
-#define CTRL_SFTRST(1 << 31)
-#define CTRL_CLKGATE   (1 << 30)
-#define CTRL_BYPASS_COUNT  (1 << 19)
-#define CTRL_VSYNC_MODE(1 << 18)
-#define CTRL_DOTCLK_MODE   (1 << 17)
-#define CTRL_DATA_SELECT   (1 << 16)
+#define CTRL_SFTRSTBIT(31)
+#define CTRL_CLKGATE   BIT(30)
+#define CTRL_BYPASS_COUNT  BIT(19)
+#define CTRL_VSYNC_MODEBIT(18)
+#define CTRL_DOTCLK_MODE   BIT(17)
+#define CTRL_DATA_SELECT   BIT(16)
 #define CTRL_SET_BUS_WIDTH(x)  (((x) & 0x3) << 10)
 #define CTRL_GET_BUS_WIDTH(x)  (((x) >> 10) & 0x3)
 #define CTRL_BUS_WIDTH_MASK(0x3 << 10)
 #define CTRL_SET_WORD_LENGTH(x)(((x) & 0x3) << 8)
 #define CTRL_GET_WORD_LENGTH(x)(((x) >> 8) & 0x3)
-#define CTRL_MASTER(1 << 5)
-#define CTRL_DF16  (1 << 3)
-#define CTRL_DF18  (1 << 2)
-#define CTRL_DF24  (1 << 1)
-#define CTRL_RUN   (1 << 0)
+#define CTRL_MASTERBIT(5)
+#define CTRL_DF16  BIT(3)
+#define CTRL_DF18  BIT(2)
+#define CTRL_DF24  BIT(1)
+#define CTRL_RUN   BIT(0)
 
-#define CTRL1_FIFO_CLEAR   (1 << 21)
+#define CTRL1_FIFO_CLEAR   BIT(21)
 #define CTRL1_SET_BYTE_PACKAGING(x)(((x) & 0xf) << 16)
 #define CTRL1_GET_BYTE_PACKAGING(x)(((x) >> 16) & 0xf)
-#define CTRL1_CUR_FRAME_DONE_IRQ_EN(1 << 13)
-#define CTRL1_CUR_FRAME_DONE_IRQ   (1 << 9)
+#define CTRL1_CUR_FRAME_DONE_IRQ_ENBIT(13)
+#define CTRL1_CUR_FRAME_DONE_IRQ   BIT(9)
 
 #define TRANSFER_COUNT_SET_VCOUNT(x)   (((x) & 0x) << 16)
 #define TRANSFER_COUNT_GET_VCOUNT(x)   (((x) >> 16) & 0x)
 #define TRANSFER_COUNT_SET_HCOUNT(x)   ((x) & 0x)
 #define TRANSFER_COUNT_GET_HCOUNT(x)   ((x) & 0x)
 
-#define VDCTRL0_ENABLE_PRESENT (1 << 28)
-#define VDCTRL0_VSYNC_ACT_HIGH (1 << 27)
-#define VDCTRL0_HSYNC_ACT_HIGH (1 << 26)
-#define VDCTRL0_DOTCLK_ACT_FALLING (1 << 25)
-#define VDCTRL0_ENABLE_ACT_HIGH(1 << 24)
-#define VDCTRL0_VSYNC_PERIOD_UNIT  (1 << 21)
-#define VDCTRL0_VSYNC_PULSE_WIDTH_UNIT (1 << 20)
-#define VDCTRL0_HALF_LINE  (1 << 19)
-#define VDCTRL0_HALF_LINE_MODE (1 << 18)
+#define VDCTRL0_ENABLE_PRESENT BIT(28)
+#define VDCTRL0_VSYNC_ACT_HIGH BIT(27)
+#define VDCTRL0_HSYNC_ACT_HIGH BIT(26)
+#define VDCTRL0_DOTCLK_ACT_FALLING BIT(25)
+#define VDCTRL0_ENABLE_ACT_HIGHBIT(24)
+#define VDCTRL0_VSYNC_PERIOD_UNIT  BIT(21)
+#define VDCTRL0_VSYNC_PULSE_WIDTH_UNIT BIT(20)
+#define VDCTRL0_HALF_LINE  BIT(19)
+#define VDCTRL0_HALF_LINE_MODE BIT(18)
 #define VDCTRL0_SET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3)
 #define VDCTRL0_GET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3)
 
 #define VDCTRL2_SET_HSYNC_PERIOD(x)((x) & 0x3)
 #define VDCTRL2_GET_HSYNC_PERIOD(x)((x) & 0x3)
 
-#define VDCTRL3_MUX_SYNC_SIGNALS   (1 << 29)
-#define VDCTRL3_VSYNC_ONLY (1 << 28)
+#define VDCTRL3_MUX_SYNC_SIGNALS   BIT(29)
+#define VDCTRL3_VSYNC_ONLY BIT(28)
 #define SET_HOR_WAIT_CNT(x)(((x) & 0xfff) << 16)
 #define GET_HOR_WAIT_CNT(x)(((x) >> 16) & 0xfff)
 #define SET_VERT_WAIT_CNT(x)   ((x) & 0x)
@@ -80,11 +80,11 @@
 
 #define VDCTRL4_SET_DOTCLK_DLY(x)  (((x) & 0x7) << 29) /* v4 only */
 #define VDCTRL4_GET_DOTCLK_DLY(x)  (((x) >> 29) & 0x7) /* v4 only */
-#define VDCTRL4_SYNC_SIGNALS_ON(1 << 18)
+#define VDCTRL4_SYNC_SIGNALS_ONBIT(18)
 #define SET_DOTCLK_H_VALID_DATA_CNT(x) ((x) & 0x3)
 
-#define DEBUG0_HSYNC   (1 < 26)
-#define DEBUG0_VSYNC   (1 < 25)
+#define DEBUG0_HSYNC   BIT(26)
+#define DEBUG0_VSYNC   BIT(25)
 
 #define MXSFB_MIN_XRES 120
 #define MXSFB_MIN_YRES 120
-- 
Regards,

Laurent Pinchart


[PATCH v4 14/22] drm: mxsfb: Enable vblank handling

2020-07-26 Thread Laurent Pinchart
Enable vblank handling when the CRTC is turned on and disable it when it
is turned off. This requires moving vblank init after the KMS pipeline
initialisation, otherwise drm_vblank_init() gets called with 0 CRTCs.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 15 +--
 drivers/gpu/drm/mxsfb/mxsfb_kms.c |  6 +-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index cac50fb4fc0f..85756d5907e3 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -161,12 +161,6 @@ static int mxsfb_load(struct drm_device *drm)
 
pm_runtime_enable(drm->dev);
 
-   ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
-   if (ret < 0) {
-   dev_err(drm->dev, "Failed to initialise vblank\n");
-   goto err_vblank;
-   }
-
/* Modeset init */
drm_mode_config_init(drm);
 
@@ -176,6 +170,15 @@ static int mxsfb_load(struct drm_device *drm)
goto err_vblank;
}
 
+   ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
+   if (ret < 0) {
+   dev_err(drm->dev, "Failed to initialise vblank\n");
+   goto err_vblank;
+   }
+
+   /* Start with vertical blanking interrupt reporting disabled. */
+   drm_crtc_vblank_off(>crtc);
+
ret = mxsfb_attach_bridge(mxsfb);
if (ret) {
dev_err(drm->dev, "Cannot connect bridge: %d\n", ret);
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 3e118848a083..70fd372952e1 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -322,8 +322,10 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
dma_addr_t paddr;
 
pm_runtime_get_sync(drm->dev);
-
mxsfb_enable_axi_clk(mxsfb);
+
+   drm_crtc_vblank_on(crtc);
+
mxsfb_crtc_mode_set_nofb(mxsfb);
 
/* Write cur_buf as well to avoid an initial corrupt frame */
@@ -353,6 +355,8 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
}
spin_unlock_irq(>event_lock);
 
+   drm_crtc_vblank_off(crtc);
+
mxsfb_disable_axi_clk(mxsfb);
pm_runtime_put_sync(drm->dev);
 }
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 16/22] drm: mxsfb: Add i.MX7 and i.MX8M to the list of supported SoCs in Kconfig

2020-07-26 Thread Laurent Pinchart
Extend the Kconfig option description by listing the i.MX7 and i.MX8M
SoCs, as they are supported by the same driver. Replace the list of SoCs
in the short description with just "(e)LCDIF LCD controller" to avoid
expanding it further in the future as support for more SoCs is added.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
Changes since v1:

- Make description more explicit by mentioning LCDIF and eLCDIF
- Add i.MX8M
---
 drivers/gpu/drm/mxsfb/Kconfig | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/Kconfig b/drivers/gpu/drm/mxsfb/Kconfig
index e43b326e9147..0143d539f8f8 100644
--- a/drivers/gpu/drm/mxsfb/Kconfig
+++ b/drivers/gpu/drm/mxsfb/Kconfig
@@ -5,7 +5,7 @@ config DRM_MXS
  Choose this option to select drivers for MXS FB devices
 
 config DRM_MXSFB
-   tristate "i.MX23/i.MX28/i.MX6SX MXSFB LCD controller"
+   tristate "i.MX (e)LCDIF LCD controller"
depends on DRM && OF
depends on COMMON_CLK
select DRM_MXS
@@ -15,7 +15,8 @@ config DRM_MXSFB
select DRM_PANEL
select DRM_PANEL_BRIDGE
help
- Choose this option if you have an i.MX23/i.MX28/i.MX6SX MXSFB
- LCD controller.
+ Choose this option if you have an LCDIF or eLCDIF LCD controller.
+ Those devices are found in various i.MX SoC (including i.MX23,
+ i.MX28, i.MX6SX, i.MX7 and i.MX8M).
 
  If M is selected the module will be called mxsfb.
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-26 Thread Laurent Pinchart
The DRM simple display pipeline helper only supports a single plane. In
order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
move away from the helper. No new feature is added.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
Changes since v2:

- Fix primary plane enable check in mxsfb_crtc_atomic_check()

Changes since v1:

- Move after mxsfb_crtc.c rename to mxsfb_kms.c
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 114 ++
 drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 190 +++---
 3 files changed, 203 insertions(+), 124 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 0ee9e5cd492b..08b2b2735bc6 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -10,22 +10,23 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
 
-#include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 #include "mxsfb_drv.h"
@@ -57,22 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
},
 };
 
-static const uint32_t mxsfb_formats[] = {
-   DRM_FORMAT_XRGB,
-   DRM_FORMAT_RGB565
-};
-
-static const uint64_t mxsfb_modifiers[] = {
-   DRM_FORMAT_MOD_LINEAR,
-   DRM_FORMAT_MOD_INVALID
-};
-
-static struct mxsfb_drm_private *
-drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
-{
-   return container_of(pipe, struct mxsfb_drm_private, pipe);
-}
-
 void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
 {
if (mxsfb->clk_axi)
@@ -95,77 +80,6 @@ static const struct drm_mode_config_helper_funcs 
mxsfb_mode_config_helpers = {
.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
 };
 
-static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
- struct drm_crtc_state *crtc_state,
- struct drm_plane_state *plane_state)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-   struct drm_device *drm = pipe->plane.dev;
-
-   pm_runtime_get_sync(drm->dev);
-   mxsfb_crtc_enable(mxsfb);
-}
-
-static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-   struct drm_device *drm = pipe->plane.dev;
-   struct drm_crtc *crtc = >crtc;
-   struct drm_pending_vblank_event *event;
-
-   mxsfb_crtc_disable(mxsfb);
-   pm_runtime_put_sync(drm->dev);
-
-   spin_lock_irq(>event_lock);
-   event = crtc->state->event;
-   if (event) {
-   crtc->state->event = NULL;
-   drm_crtc_send_vblank_event(crtc, event);
-   }
-   spin_unlock_irq(>event_lock);
-}
-
-static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
- struct drm_plane_state *plane_state)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   mxsfb_plane_atomic_update(mxsfb, plane_state);
-}
-
-static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   /* Clear and enable VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
-   mxsfb_disable_axi_clk(mxsfb);
-
-   return 0;
-}
-
-static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   /* Disable and clear VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   mxsfb_disable_axi_clk(mxsfb);
-}
-
-static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
-   .enable = mxsfb_pipe_enable,
-   .disable= mxsfb_pipe_disable,
-   .update = mxsfb_pipe_update,
-   .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
-   .enable_vblank  = mxsfb_pipe_enable_vblank,
-   .disable_vblank = mxsfb_pipe_disable_vblank,
-};
-
 static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 {
struct drm_device *drm = mxsfb->drm;
@@ -189,7 +103,7 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private 
*mxsfb)
if (!bridge)
return -ENODEV;
 
-   ret = drm_simple_display_pipe_attach_bridge(>pipe, bridge);
+   ret = drm_bridge_attach(>encoder, bridge, NULL, 0);
if (ret) {
DRM_DEV_ERROR(drm->dev,
  "failed to 

[PATCH v4 02/22] drm: mxsfb: Use drm_panel_bridge

2020-07-26 Thread Laurent Pinchart
Replace the manual connector implementation based on drm_panel with the
drm_panel_bridge helper. This simplifies the mxsfb driver by removing
connector-related code, and standardizing all pipeline control
operations on bridges.

A hack is needed to get hold of the connector, as that's our only source
of bus flags and formats for now. As soon as the bridge API provides us
with that information this can be fixed.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
Changes since v2:

- Use drm_panel_bridge_add_typed()

Changes since v1:

- Select DRM_PANEL_BRIDGE in Kconfig
---
 drivers/gpu/drm/mxsfb/Kconfig |   1 +
 drivers/gpu/drm/mxsfb/Makefile|   2 +-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 105 ++
 drivers/gpu/drm/mxsfb/mxsfb_drv.h |   5 +-
 drivers/gpu/drm/mxsfb/mxsfb_out.c |  99 
 5 files changed, 55 insertions(+), 157 deletions(-)
 delete mode 100644 drivers/gpu/drm/mxsfb/mxsfb_out.c

diff --git a/drivers/gpu/drm/mxsfb/Kconfig b/drivers/gpu/drm/mxsfb/Kconfig
index 0dca8f27169e..e43b326e9147 100644
--- a/drivers/gpu/drm/mxsfb/Kconfig
+++ b/drivers/gpu/drm/mxsfb/Kconfig
@@ -13,6 +13,7 @@ config DRM_MXSFB
select DRM_KMS_FB_HELPER
select DRM_KMS_CMA_HELPER
select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Choose this option if you have an i.MX23/i.MX28/i.MX6SX MXSFB
  LCD controller.
diff --git a/drivers/gpu/drm/mxsfb/Makefile b/drivers/gpu/drm/mxsfb/Makefile
index ff6e358088fa..811584e54ad1 100644
--- a/drivers/gpu/drm/mxsfb/Makefile
+++ b/drivers/gpu/drm/mxsfb/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-mxsfb-y := mxsfb_drv.o mxsfb_crtc.o mxsfb_out.o
+mxsfb-y := mxsfb_drv.o mxsfb_crtc.o
 obj-$(CONFIG_DRM_MXSFB)+= mxsfb.o
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 79cd2511a86b..689f50b1ef68 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -105,29 +104,11 @@ static void mxsfb_pipe_enable(struct 
drm_simple_display_pipe *pipe,
  struct drm_crtc_state *crtc_state,
  struct drm_plane_state *plane_state)
 {
-   struct drm_connector *connector;
struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
struct drm_device *drm = pipe->plane.dev;
 
-   if (!mxsfb->connector) {
-   list_for_each_entry(connector,
-   >mode_config.connector_list,
-   head)
-   if (connector->encoder == >pipe.encoder) {
-   mxsfb->connector = connector;
-   break;
-   }
-   }
-
-   if (!mxsfb->connector) {
-   dev_warn(drm->dev, "No connector attached, using default\n");
-   mxsfb->connector = >panel_connector;
-   }
-
pm_runtime_get_sync(drm->dev);
-   drm_panel_prepare(mxsfb->panel);
mxsfb_crtc_enable(mxsfb);
-   drm_panel_enable(mxsfb->panel);
 }
 
 static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
@@ -137,9 +118,7 @@ static void mxsfb_pipe_disable(struct 
drm_simple_display_pipe *pipe)
struct drm_crtc *crtc = >crtc;
struct drm_pending_vblank_event *event;
 
-   drm_panel_disable(mxsfb->panel);
mxsfb_crtc_disable(mxsfb);
-   drm_panel_unprepare(mxsfb->panel);
pm_runtime_put_sync(drm->dev);
 
spin_lock_irq(>event_lock);
@@ -149,9 +128,6 @@ static void mxsfb_pipe_disable(struct 
drm_simple_display_pipe *pipe)
drm_crtc_send_vblank_event(crtc, event);
}
spin_unlock_irq(>event_lock);
-
-   if (mxsfb->connector != >panel_connector)
-   mxsfb->connector = NULL;
 }
 
 static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -195,6 +171,49 @@ static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
.disable_vblank = mxsfb_pipe_disable_vblank,
 };
 
+static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
+{
+   struct drm_device *drm = mxsfb->drm;
+   struct drm_connector_list_iter iter;
+   struct drm_panel *panel;
+   struct drm_bridge *bridge;
+   int ret;
+
+   ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, ,
+ );
+   if (ret)
+   return ret;
+
+   if (panel) {
+   bridge = devm_drm_panel_bridge_add_typed(drm->dev, panel,
+
DRM_MODE_CONNECTOR_DPI);
+   if (IS_ERR(bridge))
+   return PTR_ERR(bridge);
+   }
+
+   if (!bridge)
+   return -ENODEV;
+
+   ret = 

[PATCH v4 00/22] drm: mxsfb: Add i.MX7 support

2020-07-26 Thread Laurent Pinchart
Hello,

This patch series adds i.MX7 support to the mxsfb driver. The eLCDIF
instance found in the i.MX7 is backward-compatible with the already
supported LCDC v4, but has extended features amongst which the most
notable one is a second plane.

The first 10 patches (01/22 to 10/22) contain miscellaneous cleanups and
refactoring to prepare for what is to come. Patch 11/22 starts the real
work with removal of the DRM simple display pipeline helper, as it
doesn't support multiple planes. The next patch (12/22) is an additional
cleanup.

Patches 13/22 to 15/22 fix vblank handling that I found to be broken
when testing on my device. Patch 16/22 then performs an additional small
cleanup, and patch 17/22 starts official support for i.MX7 by mentioning
it in Kconfig.

Patch 18/22 adds a new device model for the i.MX6SX and i.MX7 eLCDIF.
After three additional cleanups in patches 19/22 to 21/22, patch 22/22
finally adds support for the second plane.

The second plane suffers from an issue whose root cause hasn't been
found, which results in the first 64 bytes of the first line to contain
data of unknown origin. Help from NXP to diagnose this issue would be
useful and appreciated.

Compared to v3, the series has been rebased on the latest drm-misc,
without any other modifications.

The code is based on drm-misc-next and has been tested on an i.MX7D
platform with a DPI panel.

Laurent Pinchart (22):
  drm: mxsfb: Remove fbdev leftovers
  drm: mxsfb: Use drm_panel_bridge
  drm: mxsfb: Use BIT() macro to define register bitfields
  drm: mxsfb: Remove unused macros from mxsfb_regs.h
  drm: mxsfb: Clarify format and bus width configuration
  drm: mxsfb: Pass mxsfb_drm_private pointer to mxsfb_reset_block()
  drm: mxsfb: Use LCDC_CTRL register name explicitly
  drm: mxsfb: Remove register definitions from mxsfb_crtc.c
  drm: mxsfb: Remove unneeded includes
  drm: mxsfb: Rename mxsfb_crtc.c to mxsfb_kms.c
  drm: mxsfb: Stop using DRM simple display pipeline helper
  drm: mxsfb: Move vblank event arm to CRTC .atomic_flush()
  drm: mxsfb: Don't touch AXI clock in IRQ context
  drm: mxsfb: Enable vblank handling
  drm: mxsfb: Remove mxsfb_devdata unused fields
  drm: mxsfb: Add i.MX7 and i.MX8M to the list of supported SoCs in
Kconfig
  drm: mxsfb: Update internal IP version number for i.MX6SX
  drm: mxsfb: Drop non-OF support
  drm: mxsfb: Turn mxsfb_set_pixel_fmt() into a void function
  drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt()
  drm: mxsfb: Remove unnecessary spaces after tab
  drm: mxsfb: Support the alpha plane

 drivers/gpu/drm/mxsfb/Kconfig  |   8 +-
 drivers/gpu/drm/mxsfb/Makefile |   2 +-
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 343 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c  | 254 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.h  |  42 ++-
 drivers/gpu/drm/mxsfb/mxsfb_kms.c  | 571 +
 drivers/gpu/drm/mxsfb/mxsfb_out.c  |  99 -
 drivers/gpu/drm/mxsfb/mxsfb_regs.h | 103 +++---
 8 files changed, 739 insertions(+), 683 deletions(-)
 delete mode 100644 drivers/gpu/drm/mxsfb/mxsfb_crtc.c
 create mode 100644 drivers/gpu/drm/mxsfb/mxsfb_kms.c
 delete mode 100644 drivers/gpu/drm/mxsfb/mxsfb_out.c

-- 
Regards,

Laurent Pinchart

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


[PATCH v4 04/22] drm: mxsfb: Remove unused macros from mxsfb_regs.h

2020-07-26 Thread Laurent Pinchart
mxsfb_regs.h defines macros related to register bits. Some of them are
not used and don't clearly map to any particular register, so their
purpose isn't known. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_regs.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_regs.h 
b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
index 713d8f830135..78e6cb754712 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_regs.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_regs.h
@@ -91,17 +91,9 @@
 #define MXSFB_MAX_XRES 0x
 #define MXSFB_MAX_YRES 0x
 
-#define RED 0
-#define GREEN 1
-#define BLUE 2
-#define TRANSP 3
-
 #define STMLCDIF_8BIT  1 /* pixel data bus to the display is of 8 bit width */
 #define STMLCDIF_16BIT 0 /* pixel data bus to the display is of 16 bit width */
 #define STMLCDIF_18BIT 2 /* pixel data bus to the display is of 18 bit width */
 #define STMLCDIF_24BIT 3 /* pixel data bus to the display is of 24 bit width */
 
-#define MXSFB_SYNC_DATA_ENABLE_HIGH_ACT(1 << 6)
-#define MXSFB_SYNC_DOTCLK_FALLING_ACT  (1 << 7) /* negative edge sampling */
-
 #endif /* __MXSFB_REGS_H__ */
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 21/22] drm: mxsfb: Remove unnecessary spaces after tab

2020-07-26 Thread Laurent Pinchart
This is a cosmetic change only, no code change is included.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
index 607a6a5e6be3..f883b56caed3 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
@@ -16,11 +16,11 @@
 struct clk;
 
 struct mxsfb_devdata {
-   unsigned int transfer_count;
-   unsigned int cur_buf;
-   unsigned int next_buf;
-   unsigned int hs_wdth_mask;
-   unsigned int hs_wdth_shift;
+   unsigned inttransfer_count;
+   unsigned intcur_buf;
+   unsigned intnext_buf;
+   unsigned inths_wdth_mask;
+   unsigned inths_wdth_shift;
 };
 
 struct mxsfb_drm_private {
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 06/22] drm: mxsfb: Pass mxsfb_drm_private pointer to mxsfb_reset_block()

2020-07-26 Thread Laurent Pinchart
The mxsfb_reset_block() function isn't special, pass it the
mxsfb_drm_private pointer instead of a pointer to the base address.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index 8b6339316929..be60c4021e2f 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -166,21 +166,21 @@ static int clear_poll_bit(void __iomem *addr, u32 mask)
return readl_poll_timeout(addr, reg, !(reg & mask), 0, RESET_TIMEOUT);
 }
 
-static int mxsfb_reset_block(void __iomem *reset_addr)
+static int mxsfb_reset_block(struct mxsfb_drm_private *mxsfb)
 {
int ret;
 
-   ret = clear_poll_bit(reset_addr, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base, MODULE_SFTRST);
if (ret)
return ret;
 
-   writel(MODULE_CLKGATE, reset_addr + MXS_CLR_ADDR);
+   writel(MODULE_CLKGATE, mxsfb->base + MXS_CLR_ADDR);
 
-   ret = clear_poll_bit(reset_addr, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base, MODULE_SFTRST);
if (ret)
return ret;
 
-   return clear_poll_bit(reset_addr, MODULE_CLKGATE);
+   return clear_poll_bit(mxsfb->base, MODULE_CLKGATE);
 }
 
 static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb)
@@ -213,7 +213,7 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb)
 */
 
/* Mandatory eLCDIF reset as per the Reference Manual */
-   err = mxsfb_reset_block(mxsfb->base);
+   err = mxsfb_reset_block(mxsfb);
if (err)
return;
 
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 18/22] drm: mxsfb: Drop non-OF support

2020-07-26 Thread Laurent Pinchart
The mxsfb driver is only used by OF platforms. Drop non-OF support.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 9fe0a37e007d..bb80e12d9120 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -131,7 +131,8 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private 
*mxsfb)
return 0;
 }
 
-static int mxsfb_load(struct drm_device *drm)
+static int mxsfb_load(struct drm_device *drm,
+ const struct mxsfb_devdata *devdata)
 {
struct platform_device *pdev = to_platform_device(drm->dev);
struct mxsfb_drm_private *mxsfb;
@@ -144,7 +145,7 @@ static int mxsfb_load(struct drm_device *drm)
 
mxsfb->drm = drm;
drm->dev_private = mxsfb;
-   mxsfb->devdata = _devdata[pdev->id_entry->driver_data];
+   mxsfb->devdata = devdata;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mxsfb->base = devm_ioremap_resource(drm->dev, res);
@@ -280,18 +281,10 @@ static struct drm_driver mxsfb_driver = {
.minor  = 0,
 };
 
-static const struct platform_device_id mxsfb_devtype[] = {
-   { .name = "imx23-fb", .driver_data = MXSFB_V3, },
-   { .name = "imx28-fb", .driver_data = MXSFB_V4, },
-   { .name = "imx6sx-fb", .driver_data = MXSFB_V6, },
-   { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(platform, mxsfb_devtype);
-
 static const struct of_device_id mxsfb_dt_ids[] = {
-   { .compatible = "fsl,imx23-lcdif", .data = _devtype[0], },
-   { .compatible = "fsl,imx28-lcdif", .data = _devtype[1], },
-   { .compatible = "fsl,imx6sx-lcdif", .data = _devtype[2], },
+   { .compatible = "fsl,imx23-lcdif", .data = _devdata[MXSFB_V3], },
+   { .compatible = "fsl,imx28-lcdif", .data = _devdata[MXSFB_V4], },
+   { .compatible = "fsl,imx6sx-lcdif", .data = _devdata[MXSFB_V6], },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, mxsfb_dt_ids);
@@ -306,14 +299,11 @@ static int mxsfb_probe(struct platform_device *pdev)
if (!pdev->dev.of_node)
return -ENODEV;
 
-   if (of_id)
-   pdev->id_entry = of_id->data;
-
drm = drm_dev_alloc(_driver, >dev);
if (IS_ERR(drm))
return PTR_ERR(drm);
 
-   ret = mxsfb_load(drm);
+   ret = mxsfb_load(drm, of_id->data);
if (ret)
goto err_free;
 
@@ -367,7 +357,6 @@ static const struct dev_pm_ops mxsfb_pm_ops = {
 static struct platform_driver mxsfb_platform_driver = {
.probe  = mxsfb_probe,
.remove = mxsfb_remove,
-   .id_table   = mxsfb_devtype,
.driver = {
.name   = "mxsfb",
.of_match_table = mxsfb_dt_ids,
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 13/22] drm: mxsfb: Don't touch AXI clock in IRQ context

2020-07-26 Thread Laurent Pinchart
The driver attempts agressive power management by enabling and disabling
the AXI clock around register accesses. This results in attempts to
enable and disable the clock in the IRQ handler, which is a no-go as
preparing or unpreparing the clock may sleep.

On the other hand, the driver enables the AXI clock when enabling the
CRTC and keeps it enabled until the CRTC is disabled. This is correct,
and renders the power management attempt pointless, as interrupts are
not supposed to occur when the CRTC is off.

The same reasoning can be applied to the CRTC .enable_vblank() and
.disable_vblank() that are not supposed to be called when the CRTC off
and thus don't require manual handling of the AXI clock. Furthermore,
vblank handling is never enabled, which results in the vblank enable and
disable handlers never being called.

To fix this, remove the manual clock handling in the IRQ, the CRTC
.enable_vblank() and .disable_vblank() handlers and the plane
.atomic_update() handler. We however need to handle the clock manually
in mxsfb_irq_disable() as is calls .disable_vblank() manually and is
used both at probe and remove time.

The clock disabling is also moved to the last step of the
mxsfb_crtc_atomic_disable() function, to prepare for enabling vblank
handling.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c |  6 ++
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 15 ---
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 08b2b2735bc6..cac50fb4fc0f 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -232,7 +232,9 @@ static void mxsfb_irq_disable(struct drm_device *drm)
 {
struct mxsfb_drm_private *mxsfb = drm->dev_private;
 
+   mxsfb_enable_axi_clk(mxsfb);
mxsfb->crtc.funcs->disable_vblank(>crtc);
+   mxsfb_disable_axi_clk(mxsfb);
 }
 
 static irqreturn_t mxsfb_irq_handler(int irq, void *data)
@@ -241,8 +243,6 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
struct mxsfb_drm_private *mxsfb = drm->dev_private;
u32 reg;
 
-   mxsfb_enable_axi_clk(mxsfb);
-
reg = readl(mxsfb->base + LCDC_CTRL1);
 
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
@@ -250,8 +250,6 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
 
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
 
-   mxsfb_disable_axi_clk(mxsfb);
-
return IRQ_HANDLED;
 }
 
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 770546e67a8d..3e118848a083 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -344,9 +344,6 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
struct drm_pending_vblank_event *event;
 
mxsfb_disable_controller(mxsfb);
-   mxsfb_disable_axi_clk(mxsfb);
-
-   pm_runtime_put_sync(drm->dev);
 
spin_lock_irq(>event_lock);
event = crtc->state->event;
@@ -355,6 +352,9 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
drm_crtc_send_vblank_event(crtc, event);
}
spin_unlock_irq(>event_lock);
+
+   mxsfb_disable_axi_clk(mxsfb);
+   pm_runtime_put_sync(drm->dev);
 }
 
 static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
@@ -362,10 +362,8 @@ static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
 
/* Clear and enable VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
-   mxsfb_disable_axi_clk(mxsfb);
 
return 0;
 }
@@ -375,10 +373,8 @@ static void mxsfb_crtc_disable_vblank(struct drm_crtc 
*crtc)
struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
 
/* Disable and clear VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   mxsfb_disable_axi_clk(mxsfb);
 }
 
 static const struct drm_crtc_helper_funcs mxsfb_crtc_helper_funcs = {
@@ -433,11 +429,8 @@ static void mxsfb_plane_atomic_update(struct drm_plane 
*plane,
dma_addr_t paddr;
 
paddr = mxsfb_get_fb_paddr(mxsfb);
-   if (paddr) {
-   mxsfb_enable_axi_clk(mxsfb);
+   if (paddr)
writel(paddr, mxsfb->base + mxsfb->devdata->next_buf);
-   mxsfb_disable_axi_clk(mxsfb);
-   }
 }
 
 static const struct drm_plane_helper_funcs mxsfb_plane_helper_funcs = {
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org

[PATCH v4 08/22] drm: mxsfb: Remove register definitions from mxsfb_crtc.c

2020-07-26 Thread Laurent Pinchart
mxsfb_crtc.c defines several macros related to register addresses and
bit, which duplicates macros from mxsfb_regs.h. Use the macros from
mxsfb_regs.h instead and remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index 722bd9b4f5f9..aef72adabf41 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -29,10 +29,6 @@
 #include "mxsfb_drv.h"
 #include "mxsfb_regs.h"
 
-#define MXS_SET_ADDR   0x4
-#define MXS_CLR_ADDR   0x8
-#define MODULE_CLKGATE BIT(30)
-#define MODULE_SFTRST  BIT(31)
 /* 1 second delay should be plenty of time for block reset */
 #define RESET_TIMEOUT  100
 
@@ -162,7 +158,7 @@ static int clear_poll_bit(void __iomem *addr, u32 mask)
 {
u32 reg;
 
-   writel(mask, addr + MXS_CLR_ADDR);
+   writel(mask, addr + REG_CLR);
return readl_poll_timeout(addr, reg, !(reg & mask), 0, RESET_TIMEOUT);
 }
 
@@ -170,17 +166,17 @@ static int mxsfb_reset_block(struct mxsfb_drm_private 
*mxsfb)
 {
int ret;
 
-   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, CTRL_SFTRST);
if (ret)
return ret;
 
-   writel(MODULE_CLKGATE, mxsfb->base + LCDC_CTRL + MXS_CLR_ADDR);
+   writel(CTRL_CLKGATE, mxsfb->base + LCDC_CTRL + REG_CLR);
 
-   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_SFTRST);
+   ret = clear_poll_bit(mxsfb->base + LCDC_CTRL, CTRL_SFTRST);
if (ret)
return ret;
 
-   return clear_poll_bit(mxsfb->base + LCDC_CTRL, MODULE_CLKGATE);
+   return clear_poll_bit(mxsfb->base + LCDC_CTRL, CTRL_CLKGATE);
 }
 
 static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb)
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 09/22] drm: mxsfb: Remove unneeded includes

2020-07-26 Thread Laurent Pinchart
A fair number of includes are not needed. Drop them, and add a couple of
required includes that were included indirectly.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 12 +++-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c  |  5 -
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c 
b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index aef72adabf41..c4f1575b4210 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -10,19 +10,13 @@
 
 #include 
 #include 
-#include 
-#include 
+#include 
 
-#include 
-
-#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 689f50b1ef68..0ee9e5cd492b 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -9,15 +9,10 @@
  */
 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
 #include 
 
 #include 
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 22/22] drm: mxsfb: Support the alpha plane

2020-07-26 Thread Laurent Pinchart
The LCDIF in the i.MX6SX and i.MX7 have a second plane called the alpha
plane. Support it.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Emil Velikov 
Reviewed-by: Stefan Agner 
---
Changes since v1:

- Split whitespace cleanup to a separate patch
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c  |   3 +
 drivers/gpu/drm/mxsfb/mxsfb_drv.h  |   6 +-
 drivers/gpu/drm/mxsfb/mxsfb_kms.c  | 129 +
 drivers/gpu/drm/mxsfb/mxsfb_regs.h |  22 +
 4 files changed, 144 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index bb80e12d9120..8c549c3931af 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -49,6 +49,7 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
.next_buf   = LCDC_V3_NEXT_BUF,
.hs_wdth_mask   = 0xff,
.hs_wdth_shift  = 24,
+   .has_overlay= false,
},
[MXSFB_V4] = {
.transfer_count = LCDC_V4_TRANSFER_COUNT,
@@ -56,6 +57,7 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
.next_buf   = LCDC_V4_NEXT_BUF,
.hs_wdth_mask   = 0x3fff,
.hs_wdth_shift  = 18,
+   .has_overlay= false,
},
[MXSFB_V6] = {
.transfer_count = LCDC_V4_TRANSFER_COUNT,
@@ -63,6 +65,7 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
.next_buf   = LCDC_V4_NEXT_BUF,
.hs_wdth_mask   = 0x3fff,
.hs_wdth_shift  = 18,
+   .has_overlay= true,
},
 };
 
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
index f883b56caed3..399d23e91ed1 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
@@ -21,6 +21,7 @@ struct mxsfb_devdata {
unsigned intnext_buf;
unsigned inths_wdth_mask;
unsigned inths_wdth_shift;
+   boolhas_overlay;
 };
 
 struct mxsfb_drm_private {
@@ -32,7 +33,10 @@ struct mxsfb_drm_private {
struct clk  *clk_disp_axi;
 
struct drm_device   *drm;
-   struct drm_planeplane;
+   struct {
+   struct drm_planeprimary;
+   struct drm_planeoverlay;
+   } planes;
struct drm_crtc crtc;
struct drm_encoder  encoder;
struct drm_connector*connector;
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 505aa7e24239..b721b8b262ce 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -169,9 +169,9 @@ static int mxsfb_reset_block(struct mxsfb_drm_private 
*mxsfb)
return clear_poll_bit(mxsfb->base + LCDC_CTRL, CTRL_CLKGATE);
 }
 
-static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb)
+static dma_addr_t mxsfb_get_fb_paddr(struct drm_plane *plane)
 {
-   struct drm_framebuffer *fb = mxsfb->plane.state->fb;
+   struct drm_framebuffer *fb = plane->state->fb;
struct drm_gem_cma_object *gem;
 
if (!fb)
@@ -206,6 +206,9 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb)
/* Clear the FIFOs */
writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
 
+   if (mxsfb->devdata->has_overlay)
+   writel(0, mxsfb->base + LCDC_AS_CTRL);
+
mxsfb_set_formats(mxsfb);
 
clk_set_rate(mxsfb->clk, m->crtc_clock * 1000);
@@ -313,7 +316,7 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
mxsfb_crtc_mode_set_nofb(mxsfb);
 
/* Write cur_buf as well to avoid an initial corrupt frame */
-   paddr = mxsfb_get_fb_paddr(mxsfb);
+   paddr = mxsfb_get_fb_paddr(crtc->primary);
if (paddr) {
writel(paddr, mxsfb->base + mxsfb->devdata->cur_buf);
writel(paddr, mxsfb->base + mxsfb->devdata->next_buf);
@@ -410,20 +413,85 @@ static int mxsfb_plane_atomic_check(struct drm_plane 
*plane,
   false, true);
 }
 
-static void mxsfb_plane_atomic_update(struct drm_plane *plane,
- struct drm_plane_state *old_pstate)
+static void mxsfb_plane_primary_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state 
*old_pstate)
 {
struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev);
dma_addr_t paddr;
 
-   paddr = mxsfb_get_fb_paddr(mxsfb);
+   paddr = mxsfb_get_fb_paddr(plane);
if (paddr)
writel(paddr, mxsfb->base + mxsfb->devdata->next_buf);
 }
 
-static const struct drm_plane_helper_funcs mxsfb_plane_helper_funcs = {
+static void mxsfb_plane_overlay_atomic_update(struct drm_plane *plane,
+ struct 

[PATCH v4 12/22] drm: mxsfb: Move vblank event arm to CRTC .atomic_flush()

2020-07-26 Thread Laurent Pinchart
The vblank event is armed in the plane .atomic_update(). This works fine
as we have a single plane, and was the only option when the driver was
using the drm_simple_kms_helper helper, but will break as soon as
multiple planes are supported. Move it to CRTC .atomic_flush().

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
Changes since v1:

- Reword commit message
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 35 ++-
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 2346ad56daea..770546e67a8d 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -295,6 +295,25 @@ static int mxsfb_crtc_atomic_check(struct drm_crtc *crtc,
return drm_atomic_add_affected_planes(state->state, crtc);
 }
 
+static void mxsfb_crtc_atomic_flush(struct drm_crtc *crtc,
+   struct drm_crtc_state *old_state)
+{
+   struct drm_pending_vblank_event *event;
+
+   event = crtc->state->event;
+   crtc->state->event = NULL;
+
+   if (!event)
+   return;
+
+   spin_lock_irq(>dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(>dev->event_lock);
+}
+
 static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
 struct drm_crtc_state *old_state)
 {
@@ -364,6 +383,7 @@ static void mxsfb_crtc_disable_vblank(struct drm_crtc *crtc)
 
 static const struct drm_crtc_helper_funcs mxsfb_crtc_helper_funcs = {
.atomic_check = mxsfb_crtc_atomic_check,
+   .atomic_flush = mxsfb_crtc_atomic_flush,
.atomic_enable = mxsfb_crtc_atomic_enable,
.atomic_disable = mxsfb_crtc_atomic_disable,
 };
@@ -410,23 +430,8 @@ static void mxsfb_plane_atomic_update(struct drm_plane 
*plane,
  struct drm_plane_state *old_pstate)
 {
struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev);
-   struct drm_crtc *crtc = >crtc;
-   struct drm_pending_vblank_event *event;
dma_addr_t paddr;
 
-   spin_lock_irq(>dev->event_lock);
-   event = crtc->state->event;
-   if (event) {
-   crtc->state->event = NULL;
-
-   if (drm_crtc_vblank_get(crtc) == 0) {
-   drm_crtc_arm_vblank_event(crtc, event);
-   } else {
-   drm_crtc_send_vblank_event(crtc, event);
-   }
-   }
-   spin_unlock_irq(>dev->event_lock);
-
paddr = mxsfb_get_fb_paddr(mxsfb);
if (paddr) {
mxsfb_enable_axi_clk(mxsfb);
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 19/22] drm: mxsfb: Turn mxsfb_set_pixel_fmt() into a void function

2020-07-26 Thread Laurent Pinchart
The mxsfb_set_pixel_fmt() function returns an error when the selected
pixel format is unsupported. This can never happen, as such errors are
caught by the DRM core. Remove the error check.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 70fd372952e1..ee9ca541caea 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -43,7 +43,7 @@ static u32 set_hsync_pulse_width(struct mxsfb_drm_private 
*mxsfb, u32 val)
 }
 
 /* Setup the MXSFB registers for decoding the pixels out of the framebuffer */
-static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
+static void mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
 {
struct drm_device *drm = mxsfb->drm;
const u32 format = mxsfb->crtc.primary->state->fb->format->format;
@@ -67,15 +67,10 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private 
*mxsfb)
/* Do not use packed pixels = one pixel per word instead. */
ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0x7);
break;
-   default:
-   dev_err(drm->dev, "Unhandled pixel format %08x\n", format);
-   return -EINVAL;
}
 
writel(ctrl1, mxsfb->base + LCDC_CTRL1);
writel(ctrl, mxsfb->base + LCDC_CTRL);
-
-   return 0;
 }
 
 static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)
@@ -218,9 +213,7 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb)
/* Clear the FIFOs */
writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
 
-   err = mxsfb_set_pixel_fmt(mxsfb);
-   if (err)
-   return;
+   mxsfb_set_pixel_fmt(mxsfb);
 
clk_set_rate(mxsfb->clk, m->crtc_clock * 1000);
 
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 20/22] drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt()

2020-07-26 Thread Laurent Pinchart
The mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt() functions both deal
with format configuration, are always called in a row from
mxsfb_crtc_mode_set_nofb(), and set fields from the LCDC_CTRL register.
This requires a read-modify-update cycle in mxsfb_set_bus_fmt(). Make
this more efficient by merging them together.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 47 +--
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index ee9ca541caea..505aa7e24239 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -42,13 +42,23 @@ static u32 set_hsync_pulse_width(struct mxsfb_drm_private 
*mxsfb, u32 val)
mxsfb->devdata->hs_wdth_shift;
 }
 
-/* Setup the MXSFB registers for decoding the pixels out of the framebuffer */
-static void mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
+/*
+ * Setup the MXSFB registers for decoding the pixels out of the framebuffer and
+ * outputting them on the bus.
+ */
+static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb)
 {
struct drm_device *drm = mxsfb->drm;
const u32 format = mxsfb->crtc.primary->state->fb->format->format;
+   u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
u32 ctrl, ctrl1;
 
+   if (mxsfb->connector->display_info.num_bus_formats)
+   bus_format = mxsfb->connector->display_info.bus_formats[0];
+
+   DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
+bus_format);
+
ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER;
 
/* CTRL1 contains IRQ config and status bits, preserve those. */
@@ -69,40 +79,23 @@ static void mxsfb_set_pixel_fmt(struct mxsfb_drm_private 
*mxsfb)
break;
}
 
-   writel(ctrl1, mxsfb->base + LCDC_CTRL1);
-   writel(ctrl, mxsfb->base + LCDC_CTRL);
-}
-
-static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)
-{
-   struct drm_device *drm = mxsfb->drm;
-   u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
-   u32 reg;
-
-   reg = readl(mxsfb->base + LCDC_CTRL);
-
-   if (mxsfb->connector->display_info.num_bus_formats)
-   bus_format = mxsfb->connector->display_info.bus_formats[0];
-
-   DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
-bus_format);
-
-   reg &= ~CTRL_BUS_WIDTH_MASK;
switch (bus_format) {
case MEDIA_BUS_FMT_RGB565_1X16:
-   reg |= CTRL_BUS_WIDTH_16;
+   ctrl |= CTRL_BUS_WIDTH_16;
break;
case MEDIA_BUS_FMT_RGB666_1X18:
-   reg |= CTRL_BUS_WIDTH_18;
+   ctrl |= CTRL_BUS_WIDTH_18;
break;
case MEDIA_BUS_FMT_RGB888_1X24:
-   reg |= CTRL_BUS_WIDTH_24;
+   ctrl |= CTRL_BUS_WIDTH_24;
break;
default:
dev_err(drm->dev, "Unknown media bus format %d\n", bus_format);
break;
}
-   writel(reg, mxsfb->base + LCDC_CTRL);
+
+   writel(ctrl1, mxsfb->base + LCDC_CTRL1);
+   writel(ctrl, mxsfb->base + LCDC_CTRL);
 }
 
 static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
@@ -213,7 +206,7 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb)
/* Clear the FIFOs */
writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
 
-   mxsfb_set_pixel_fmt(mxsfb);
+   mxsfb_set_formats(mxsfb);
 
clk_set_rate(mxsfb->clk, m->crtc_clock * 1000);
 
@@ -255,8 +248,6 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb)
 
writel(vdctrl0, mxsfb->base + LCDC_VDCTRL0);
 
-   mxsfb_set_bus_fmt(mxsfb);
-
/* Frame length in lines. */
writel(m->crtc_vtotal, mxsfb->base + LCDC_VDCTRL1);
 
-- 
Regards,

Laurent Pinchart

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


[PATCH v4 01/22] drm: mxsfb: Remove fbdev leftovers

2020-07-26 Thread Laurent Pinchart
Commit 8e93f1028d74 ("drm/mxsfb: Use drm_fbdev_generic_setup()")
replaced fbdev handling with drm_fbdev_generic_setup() but left
inclusion of the drm/drm_fb_cma_helper.h header. Remove it.

Fixes: 8e93f1028d74 ("drm/mxsfb: Use drm_fbdev_generic_setup()")
Signed-off-by: Laurent Pinchart 
Reviewed-by: Stefan Agner 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 508764fccd27..79cd2511a86b 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
Regards,

Laurent Pinchart

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


[Bug 207383] [Regression] 5.7 amdgpu/polaris11 gpf: amdgpu_atomic_commit_tail

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=207383

--- Comment #99 from mn...@protonmail.com ---
(In reply to Nicholas Kazlauskas from comment #98)
> As much as I'd like to remove the DRM private object from the state instead
> of just carrying it over I'd really rather not be hacking around behavior
> from the DRM core itself.
> 
> Maybe there's value in adding these as DRM helpers in the case where a
> driver explicitly wants to remove something from the state. My guess as to
> why these don't exist today is because they can be bug prone since the core
> implicitly adds some objects (like CRTCs when you add a plane and CRTCs when
> you add connectors) but I don't see any technical limitation for not
> exposing this.

I'm a little bit confused, is there anything particularly illegal or
discouraged about the patch I sent? If so, how should I correct it?

Should I create some sort of DRM helper for deleting a private object and
use that to delete the state's associated private object?

-- 
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 207383] [Regression] 5.7 amdgpu/polaris11 gpf: amdgpu_atomic_commit_tail

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=207383

--- Comment #98 from Nicholas Kazlauskas (nicholas.kazlaus...@amd.com) ---
As much as I'd like to remove the DRM private object from the state instead of
just carrying it over I'd really rather not be hacking around behavior from the
DRM core itself.

Maybe there's value in adding these as DRM helpers in the case where a driver
explicitly wants to remove something from the state. My guess as to why these
don't exist today is because they can be bug prone since the core implicitly
adds some objects (like CRTCs when you add a plane and CRTCs when you add
connectors) but I don't see any technical limitation for not exposing this.

-- 
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 207383] [Regression] 5.7 amdgpu/polaris11 gpf: amdgpu_atomic_commit_tail

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=207383

mn...@protonmail.com changed:

   What|Removed |Added

 Attachment #290485|0   |1
is obsolete||

--- Comment #97 from mn...@protonmail.com ---
Created attachment 290591
  --> https://bugzilla.kernel.org/attachment.cgi?id=290591=edit
drm/amd/display: Clear dm_state for fast updates

drm/amd/display: Clear dm_state for fast updates

Alright, the bug patch I mentioned in the last comment seems to be good
after a few hours of testing.

Please try out this patch and see if it fixes the issue for the rest of
you.

In the meantime, I'm doing more extended tests on this patch to confirm it
works well enough before posting it on LKML.

Nicholas, I haven't tested your commit since I was too busy with this. I'll
try it out if this one fails though.

Also, can you please review this patch to confirm that I'm not doing
anything wrong here?

-- 
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 204181] NULL pointer dereference regression in amdgpu

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204181

--- Comment #67 from mn...@protonmail.com ---
(In reply to mnrzk from comment #66)
> Created attachment 290589 [details]
> drm/amd/display: Clear dm_state for fast updates
> 
> Alright, the bug patch I mentioned in the last comment seems to be good
> after a few hours of testing.
> 
> Please try out this patch and see if it fixes the issue for the rest of
> you.
> 
> In the meantime, I'm doing more extended tests on this patch to confirm it
> works well enough before posting it on LKML.
> 
> Nicholas, I haven't tested your commit since I was too busy with this. I'll
> try it out if this one fails though.
> 
> Also, can you please review this patch to confirm that I'm not doing
> anything wrong here?

Oh my god, I just responded to the wrong thread by accident, so sorry.

-- 
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 204181] NULL pointer dereference regression in amdgpu

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204181

mn...@protonmail.com changed:

   What|Removed |Added

 CC||mn...@protonmail.com

--- Comment #66 from mn...@protonmail.com ---
Created attachment 290589
  --> https://bugzilla.kernel.org/attachment.cgi?id=290589=edit
drm/amd/display: Clear dm_state for fast updates

Alright, the bug patch I mentioned in the last comment seems to be good
after a few hours of testing.

Please try out this patch and see if it fixes the issue for the rest of
you.

In the meantime, I'm doing more extended tests on this patch to confirm it
works well enough before posting it on LKML.

Nicholas, I haven't tested your commit since I was too busy with this. I'll
try it out if this one fails though.

Also, can you please review this patch to confirm that I'm not doing
anything wrong here?

-- 
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


Re: [PATCH v4 15/15] drm/bridge: nxp-ptn3460: add drm_panel_bridge support

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:24PM +0200, Sam Ravnborg wrote:
> Prepare the bridge driver for use in a chained setup.
> 
> - Replacing direct use of drm_panel with drm_panel_bridge support.
> - Make the connector creation optional
> 
> Note: the bridge panel will use the connector type from the panel.
> 
> v2:
>   - Use panel_bridge for local variable name to align with other drivers
>   - Fix that connector was created twice (Laurent)
>   - Set bridge.type to DRM_MODE_CONNECTOR_LVDS.
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> ---
>  drivers/gpu/drm/bridge/nxp-ptn3460.c | 60 ++--
>  1 file changed, 20 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
> b/drivers/gpu/drm/bridge/nxp-ptn3460.c
> index 2805c8938f98..a49616855dd3 100644
> --- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
> +++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
> @@ -29,7 +29,7 @@ struct ptn3460_bridge {
>   struct drm_connector connector;
>   struct i2c_client *client;
>   struct drm_bridge bridge;
> - struct drm_panel *panel;
> + struct drm_bridge *panel_bridge;
>   struct gpio_desc *gpio_pd_n;
>   struct gpio_desc *gpio_rst_n;
>   u32 edid_emulation;
> @@ -126,11 +126,6 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
>   usleep_range(10, 20);
>   gpiod_set_value(ptn_bridge->gpio_rst_n, 1);
>  
> - if (drm_panel_prepare(ptn_bridge->panel)) {
> - DRM_ERROR("failed to prepare panel\n");
> - return;
> - }
> -
>   /*
>* There's a bug in the PTN chip where it falsely asserts hotplug before
>* it is fully functional. We're forced to wait for the maximum start up
> @@ -145,16 +140,6 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
>   ptn_bridge->enabled = true;
>  }
>  
> -static void ptn3460_enable(struct drm_bridge *bridge)
> -{
> - struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
> -
> - if (drm_panel_enable(ptn_bridge->panel)) {
> - DRM_ERROR("failed to enable panel\n");
> - return;
> - }
> -}
> -
>  static void ptn3460_disable(struct drm_bridge *bridge)
>  {
>   struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
> @@ -164,24 +149,10 @@ static void ptn3460_disable(struct drm_bridge *bridge)
>  
>   ptn_bridge->enabled = false;
>  
> - if (drm_panel_disable(ptn_bridge->panel)) {
> - DRM_ERROR("failed to disable panel\n");
> - return;
> - }
> -
>   gpiod_set_value(ptn_bridge->gpio_rst_n, 1);
>   gpiod_set_value(ptn_bridge->gpio_pd_n, 0);
>  }
>  
> -static void ptn3460_post_disable(struct drm_bridge *bridge)
> -{
> - struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
> -
> - if (drm_panel_unprepare(ptn_bridge->panel)) {
> - DRM_ERROR("failed to unprepare panel\n");
> - return;
> - }
> -}
>  

Extra blank line.

>  static struct edid *ptn3460_get_edid(struct drm_bridge *bridge,
>struct drm_connector *connector)
> @@ -245,12 +216,18 @@ static int ptn3460_bridge_attach(struct drm_bridge 
> *bridge,
>enum drm_bridge_attach_flags flags)
>  {
>   struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
> + enum drm_bridge_attach_flags panel_flags;
>   int ret;
>  
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> - DRM_ERROR("Fix bridge driver to make connector optional!");
> - return -EINVAL;
> - }
> + /* Let this driver create connector if requested */
> + panel_flags = flags & ~DRM_BRIDGE_ATTACH_NO_CONNECTOR;

Same as in a previous patch, should this be

panel_flags = flags | DRM_BRIDGE_ATTACH_NO_CONNECTOR;

?

> + ret = drm_bridge_attach(bridge->encoder, ptn_bridge->panel_bridge,
> + bridge, panel_flags);
> + if (ret < 0)
> + return ret;
> +
> + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> + return 0;
>  
>   if (!bridge->encoder) {
>   DRM_ERROR("Parent encoder object not found");
> @@ -270,9 +247,6 @@ static int ptn3460_bridge_attach(struct drm_bridge 
> *bridge,
>   drm_connector_attach_encoder(_bridge->connector,
>   bridge->encoder);
>  
> - if (ptn_bridge->panel)
> - drm_panel_attach(ptn_bridge->panel, _bridge->connector);
> -
>   drm_helper_hpd_irq_event(ptn_bridge->connector.dev);
>  
>   return ret;
> @@ -280,9 +254,7 @@ static int ptn3460_bridge_attach(struct drm_bridge 
> *bridge,
>  
>  static const struct drm_bridge_funcs ptn3460_bridge_funcs = {
>   .pre_enable = ptn3460_pre_enable,
> - .enable = ptn3460_enable,
>   .disable = ptn3460_disable,
> - .post_disable 

Re: [PATCH v4 14/15] drm/bridge: nxp-ptn3460: add get_edid bridge operation

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:23PM +0200, Sam Ravnborg wrote:
> Add the get_edid() bridge operation to prepare for
> use as a chained bridge.
> Add helper function that is also used by the connector.
> 
> v2:
>   - Fix memory leak (Laurent)
>   - Do not save a copy of edid, read it when needed
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/bridge/nxp-ptn3460.c | 43 
>  1 file changed, 25 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
> b/drivers/gpu/drm/bridge/nxp-ptn3460.c
> index 438e566ce0a4..2805c8938f98 100644
> --- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
> +++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
> @@ -29,7 +29,6 @@ struct ptn3460_bridge {
>   struct drm_connector connector;
>   struct i2c_client *client;
>   struct drm_bridge bridge;
> - struct edid *edid;
>   struct drm_panel *panel;
>   struct gpio_desc *gpio_pd_n;
>   struct gpio_desc *gpio_rst_n;
> @@ -184,17 +183,13 @@ static void ptn3460_post_disable(struct drm_bridge 
> *bridge)
>   }
>  }
>  
> -static int ptn3460_get_modes(struct drm_connector *connector)
> +static struct edid *ptn3460_get_edid(struct drm_bridge *bridge,
> +  struct drm_connector *connector)
>  {
> - struct ptn3460_bridge *ptn_bridge;
> - u8 *edid;
> - int ret, num_modes = 0;
> + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
>   bool power_off;
> -
> - ptn_bridge = connector_to_ptn3460(connector);
> -
> - if (ptn_bridge->edid)
> - return drm_add_edid_modes(connector, ptn_bridge->edid);
> + u8 *edid;
> + int ret;
>  
>   power_off = !ptn_bridge->enabled;
>   ptn3460_pre_enable(_bridge->bridge);
> @@ -202,30 +197,40 @@ static int ptn3460_get_modes(struct drm_connector 
> *connector)
>   edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
>   if (!edid) {
>   DRM_ERROR("Failed to allocate EDID\n");
> - return 0;
> + goto out;
>   }
>  
>   ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid,
> - EDID_LENGTH);
> +  EDID_LENGTH);
>   if (ret) {
>   kfree(edid);
> + edid = NULL;
>   goto out;
>   }
>  
> - ptn_bridge->edid = (struct edid *)edid;
> - drm_connector_update_edid_property(connector, ptn_bridge->edid);
> -
> - num_modes = drm_add_edid_modes(connector, ptn_bridge->edid);
> -
>  out:
>   if (power_off)
>   ptn3460_disable(_bridge->bridge);
>  
> + return (struct edid *)edid;
> +}
> +
> +static int ptn3460_connector_get_modes(struct drm_connector *connector)
> +{
> + struct ptn3460_bridge *ptn_bridge = connector_to_ptn3460(connector);
> + struct edid *edid;
> + int num_modes;
> +
> + edid = ptn3460_get_edid(_bridge->bridge, connector);
> + drm_connector_update_edid_property(connector, edid);
> + num_modes = drm_add_edid_modes(connector, edid);
> + kfree(edid);
> +
>   return num_modes;
>  }
>  
>  static const struct drm_connector_helper_funcs 
> ptn3460_connector_helper_funcs = {
> - .get_modes = ptn3460_get_modes,
> + .get_modes = ptn3460_connector_get_modes,
>  };
>  
>  static const struct drm_connector_funcs ptn3460_connector_funcs = {
> @@ -279,6 +284,7 @@ static const struct drm_bridge_funcs ptn3460_bridge_funcs 
> = {
>   .disable = ptn3460_disable,
>   .post_disable = ptn3460_post_disable,
>   .attach = ptn3460_bridge_attach,
> + .get_edid = ptn3460_get_edid,
>  };
>  
>  static int ptn3460_probe(struct i2c_client *client,
> @@ -327,6 +333,7 @@ static int ptn3460_probe(struct i2c_client *client,
>   }
>  
>   ptn_bridge->bridge.funcs = _bridge_funcs;
> + ptn_bridge->bridge.ops = DRM_BRIDGE_OP_EDID;
>   ptn_bridge->bridge.of_node = dev->of_node;
>   drm_bridge_add(_bridge->bridge);
>  

-- 
Regards,

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


Re: [PATCH v4 13/15] drm/bridge: megachips: make connector creation optional

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:22PM +0200, Sam Ravnborg wrote:
> Make the connector creation optional to enable usage of the
> megachips-stdp-ge-b850v3-fw bridge with the DRM bridge connector
> helper.
> 
> v2:
>   - Set bridge.type to DRM_MODE_CONNECTOR_DisplayPort
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Peter Senna Tschudin 
> Cc: Martin Donnelly 
> Cc: Martyn Welch 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 

Reviewed-by: Laurent Pinchart 

> ---
>  .../drm/bridge/megachips-stdp-ge-b850v3-fw.c | 16 +---
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
> b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> index f7b55dc374ac..61a24f265c7a 100644
> --- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> +++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> @@ -245,16 +245,6 @@ static int ge_b850v3_lvds_attach(struct drm_bridge 
> *bridge,
>  {
>   struct i2c_client *stdp4028_i2c
>   = ge_b850v3_lvds_ptr->stdp4028_i2c;
> - int ret;
> -
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> - DRM_ERROR("Fix bridge driver to make connector optional!");
> - return -EINVAL;
> - }
> -
> - ret = ge_b850v3_lvds_create_connector(bridge);
> - if (ret)
> - return ret;
>  
>   /* Configures the bridge to re-enable interrupts after each ack. */
>   i2c_smbus_write_word_data(stdp4028_i2c,
> @@ -266,7 +256,10 @@ static int ge_b850v3_lvds_attach(struct drm_bridge 
> *bridge,
> STDP4028_DPTX_IRQ_EN_REG,
> STDP4028_DPTX_IRQ_CONFIG);
>  
> - return 0;
> + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> + return 0;
> +
> + return ge_b850v3_lvds_create_connector(bridge);
>  }
>  
>  static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
> @@ -327,6 +320,7 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
> *stdp4028_i2c,
>   ge_b850v3_lvds_ptr->bridge.funcs = _b850v3_lvds_funcs;
>   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
>DRM_BRIDGE_OP_EDID;
> + ge_b850v3_lvds_ptr->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
>   ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
>   drm_bridge_add(_b850v3_lvds_ptr->bridge);
>  

-- 
Regards,

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


Re: [PATCH v4 12/15] drm/bridge: megachips: add get_edid bridge operation

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:21PM +0200, Sam Ravnborg wrote:
> To prepare for a chained bridge setup add support for the
> get_edid bridge operation.
> There is no need for a copy of the edid - so drop
> the pointer to the copy.
> 
> v2:
>   - Fix so we do not leak memory (Laurent)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Peter Senna Tschudin 
> Cc: Martin Donnelly 
> Cc: Martyn Welch 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 

Reviewed-by: Laurent Pinchart 

> ---
>  .../bridge/megachips-stdp-ge-b850v3-fw.c  | 31 ++-
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
> b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> index 450dca33ea48..f7b55dc374ac 100644
> --- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> +++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> @@ -61,7 +61,6 @@ struct ge_b850v3_lvds {
>   struct drm_bridge bridge;
>   struct i2c_client *stdp4028_i2c;
>   struct i2c_client *stdp2690_i2c;
> - struct edid *edid;
>  };
>  
>  static struct ge_b850v3_lvds *ge_b850v3_lvds_ptr;
> @@ -131,22 +130,26 @@ static u8 *stdp2690_get_edid(struct i2c_client *client)
>   return NULL;
>  }
>  
> -static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
> +static struct edid *ge_b850v3_lvds_get_edid(struct drm_bridge *bridge,
> + struct drm_connector *connector)
>  {
>   struct i2c_client *client;
> - int num_modes = 0;
>  
>   client = ge_b850v3_lvds_ptr->stdp2690_i2c;
>  
> - kfree(ge_b850v3_lvds_ptr->edid);
> - ge_b850v3_lvds_ptr->edid = (struct edid *)stdp2690_get_edid(client);
> + return (struct edid *)stdp2690_get_edid(client);
> +}
>  
> - if (ge_b850v3_lvds_ptr->edid) {
> - drm_connector_update_edid_property(connector,
> -   ge_b850v3_lvds_ptr->edid);
> - num_modes = drm_add_edid_modes(connector,
> -ge_b850v3_lvds_ptr->edid);
> - }
> +static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
> +{
> + struct edid *edid;
> + int num_modes;
> +
> + edid = ge_b850v3_lvds_get_edid(_b850v3_lvds_ptr->bridge, connector);
> +
> + drm_connector_update_edid_property(connector, edid);
> + num_modes = drm_add_edid_modes(connector, edid);
> + kfree(edid);
>  
>   return num_modes;
>  }
> @@ -269,6 +272,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge 
> *bridge,
>  static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
>   .attach = ge_b850v3_lvds_attach,
>   .detect = ge_b850v3_lvds_bridge_detect,
> + .get_edid = ge_b850v3_lvds_get_edid,
>  };
>  
>  static int ge_b850v3_lvds_init(struct device *dev)
> @@ -304,8 +308,6 @@ static void ge_b850v3_lvds_remove(void)
>  
>   drm_bridge_remove(_b850v3_lvds_ptr->bridge);
>  
> - kfree(ge_b850v3_lvds_ptr->edid);
> -
>   ge_b850v3_lvds_ptr = NULL;
>  out:
>   mutex_unlock(_b850v3_lvds_dev_mutex);
> @@ -323,7 +325,8 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
> *stdp4028_i2c,
>  
>   /* drm bridge initialization */
>   ge_b850v3_lvds_ptr->bridge.funcs = _b850v3_lvds_funcs;
> - ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT;
> + ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
> +  DRM_BRIDGE_OP_EDID;
>   ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
>   drm_bridge_add(_b850v3_lvds_ptr->bridge);
>  

-- 
Regards,

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


Re: [PATCH v4 08/15] drm/bridge: parade-ps8622: add drm_panel_bridge support

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:17PM +0200, Sam Ravnborg wrote:
> Prepare the bridge driver for use in a chained setup by
> replacing direct use of drm_panel with drm_panel_bridge support.
> 
> The connecter is now either created by the panel bridge or the display
> driver. So all code for connector creation in this driver is no longer
> relevant and thus dropped.
> 
> The connector code had some special polling handling:
> connector.polled = DRM_CONNECTOR_POLL_HPD;
> drm_helper_hpd_irq_event(ps8622->bridge.dev);
> 
> This code was most likely added to speed up detection of the connector.
> If really needed then this functionality belongs somewhere else.
> 
> Note: the bridge panel will use the connector type from the panel.
> 
> v2:
>   - Fix to avoid creating connector twice (Laurent)
>   - Drop all connector code - defer to bridge panel
>   - Use panel_bridge for local variable to align with other drivers
>   - Set bridge.type to DRM_MODE_CONNECTOR_LVDS;
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> ---
>  drivers/gpu/drm/bridge/parade-ps8622.c | 100 -
>  1 file changed, 13 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
> b/drivers/gpu/drm/bridge/parade-ps8622.c
> index d789ea2a7fb9..614b19f0f1b7 100644
> --- a/drivers/gpu/drm/bridge/parade-ps8622.c
> +++ b/drivers/gpu/drm/bridge/parade-ps8622.c
> @@ -42,10 +42,9 @@
>  #endif
>  
>  struct ps8622_bridge {
> - struct drm_connector connector;
>   struct i2c_client *client;
>   struct drm_bridge bridge;
> - struct drm_panel *panel;
> + struct drm_bridge *panel_bridge;
>   struct regulator *v12;
>   struct backlight_device *bl;
>  
> @@ -64,12 +63,6 @@ static inline struct ps8622_bridge *
>   return container_of(bridge, struct ps8622_bridge, bridge);
>  }
>  
> -static inline struct ps8622_bridge *
> - connector_to_ps8622(struct drm_connector *connector)
> -{
> - return container_of(connector, struct ps8622_bridge, connector);
> -}
> -
>  static int ps8622_set(struct i2c_client *client, u8 page, u8 reg, u8 val)
>  {
>   int ret;
> @@ -365,11 +358,6 @@ static void ps8622_pre_enable(struct drm_bridge *bridge)
>   DRM_ERROR("fails to enable ps8622->v12");
>   }
>  
> - if (drm_panel_prepare(ps8622->panel)) {
> - DRM_ERROR("failed to prepare panel\n");
> - return;
> - }
> -
>   gpiod_set_value(ps8622->gpio_slp, 1);
>  
>   /*
> @@ -399,24 +387,9 @@ static void ps8622_pre_enable(struct drm_bridge *bridge)
>   ps8622->enabled = true;
>  }
>  
> -static void ps8622_enable(struct drm_bridge *bridge)
> -{
> - struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
> -
> - if (drm_panel_enable(ps8622->panel)) {
> - DRM_ERROR("failed to enable panel\n");
> - return;
> - }
> -}
> -
>  static void ps8622_disable(struct drm_bridge *bridge)
>  {
> - struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
> -
> - if (drm_panel_disable(ps8622->panel)) {
> - DRM_ERROR("failed to disable panel\n");
> - return;
> - }
> + /* Delay after panel is disabled */
>   msleep(PS8622_PWMO_END_T12_MS);

I really don't understand why a delay would be needed here.

Reviewed-by: Laurent Pinchart 

>  }
>  
> @@ -436,11 +409,6 @@ static void ps8622_post_disable(struct drm_bridge 
> *bridge)
>*/
>   gpiod_set_value(ps8622->gpio_slp, 0);
>  
> - if (drm_panel_unprepare(ps8622->panel)) {
> - DRM_ERROR("failed to unprepare panel\n");
> - return;
> - }
> -
>   if (ps8622->v12)
>   regulator_disable(ps8622->v12);
>  
> @@ -455,67 +423,17 @@ static void ps8622_post_disable(struct drm_bridge 
> *bridge)
>   msleep(PS8622_POWER_OFF_T17_MS);
>  }
>  
> -static int ps8622_get_modes(struct drm_connector *connector)
> -{
> - struct ps8622_bridge *ps8622;
> -
> - ps8622 = connector_to_ps8622(connector);
> -
> - return drm_panel_get_modes(ps8622->panel, connector);
> -}
> -
> -static const struct drm_connector_helper_funcs ps8622_connector_helper_funcs 
> = {
> - .get_modes = ps8622_get_modes,
> -};
> -
> -static const struct drm_connector_funcs ps8622_connector_funcs = {
> - .fill_modes = drm_helper_probe_single_connector_modes,
> - .destroy = drm_connector_cleanup,
> - .reset = drm_atomic_helper_connector_reset,
> - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> -};
> -
>  static int ps8622_attach(struct drm_bridge *bridge,
>enum drm_bridge_attach_flags flags)
>  {
>   struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
> - int ret;
> -
> - if (flags & 

Re: [PATCH v4 07/15] drm/bridge: tc358767: add drm_panel_bridge support

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:16PM +0200, Sam Ravnborg wrote:
> With the bridge operations implemented the last step to prepare
> this driver for a chained setup is the use of the bridge panel driver.
> 
> The bridge panel driver is only used when a prot@2 is present in

s/prot/port/

> the DT. So when the display driver request a connector

s/request/requests/

> support both situations:
> - connector created by bridge panel driver
> - connector created by this driver
> 
> And on top, support that the display driver creates the connector,
> which is the preferred setup.
> 
> Note: the bridge panel will use the connector type from the panel.
> 
> v2:
>   - Merge connector and drm_panel_bridge patches
> and fix so we do not create two connectors (Laurent)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Laurent Pinchart 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> ---
>  drivers/gpu/drm/bridge/tc358767.c | 70 +++
>  1 file changed, 35 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> b/drivers/gpu/drm/bridge/tc358767.c
> index d86d7f06bebb..75a2cd792ccc 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -244,8 +244,8 @@ struct tc_data {
>   struct drm_dp_aux   aux;
>  
>   struct drm_bridge   bridge;
> + struct drm_bridge   *panel_bridge;
>   struct drm_connectorconnector;
> - struct drm_panel*panel;
>  
>   /* link settings */
>   struct tc_edp_link  link;
> @@ -1234,13 +1234,6 @@ static int tc_stream_disable(struct tc_data *tc)
>   return 0;
>  }
>  
> -static void tc_bridge_pre_enable(struct drm_bridge *bridge)
> -{
> - struct tc_data *tc = bridge_to_tc(bridge);
> -
> - drm_panel_prepare(tc->panel);
> -}
> -
>  static void tc_bridge_enable(struct drm_bridge *bridge)
>  {
>   struct tc_data *tc = bridge_to_tc(bridge);
> @@ -1264,8 +1257,6 @@ static void tc_bridge_enable(struct drm_bridge *bridge)
>   tc_main_link_disable(tc);
>   return;
>   }
> -
> - drm_panel_enable(tc->panel);
>  }
>  
>  static void tc_bridge_disable(struct drm_bridge *bridge)
> @@ -1273,8 +1264,6 @@ static void tc_bridge_disable(struct drm_bridge *bridge)
>   struct tc_data *tc = bridge_to_tc(bridge);
>   int ret;
>  
> - drm_panel_disable(tc->panel);
> -
>   ret = tc_stream_disable(tc);
>   if (ret < 0)
>   dev_err(tc->dev, "main link stream stop error: %d\n", ret);
> @@ -1284,13 +1273,6 @@ static void tc_bridge_disable(struct drm_bridge 
> *bridge)
>   dev_err(tc->dev, "main link disable error: %d\n", ret);
>  }
>  
> -static void tc_bridge_post_disable(struct drm_bridge *bridge)
> -{
> - struct tc_data *tc = bridge_to_tc(bridge);
> -
> - drm_panel_unprepare(tc->panel);
> -}
> -
>  static bool tc_bridge_mode_fixup(struct drm_bridge *bridge,
>const struct drm_display_mode *mode,
>struct drm_display_mode *adj)
> @@ -1354,9 +1336,11 @@ static int tc_connector_get_modes(struct drm_connector 
> *connector)
>   return 0;
>   }
>  
> - num_modes = drm_panel_get_modes(tc->panel, connector);
> - if (num_modes > 0)
> - return num_modes;
> + if (tc->panel_bridge) {
> + num_modes = drm_bridge_get_modes(tc->panel_bridge, connector);
> + if (num_modes > 0)
> + return num_modes;
> + }
>  
>   edid = tc_get_edid(>bridge, connector);
>   num_modes = drm_add_edid_modes(connector, edid);
> @@ -1396,7 +1380,7 @@ tc_connector_detect(struct drm_connector *connector, 
> bool force)
>   if (tc->hpd_pin >= 0)
>   return tc_bridge_detect(>bridge);
>   else
> - if (tc->panel)
> + if (tc->panel_bridge)
>   return connector_status_connected;
>  
>   return connector_status_unknown;
> @@ -1419,16 +1403,23 @@ static int tc_bridge_attach(struct drm_bridge *bridge,
>   struct drm_device *drm = bridge->dev;
>   int ret;
>  
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> - DRM_ERROR("Fix bridge driver to make connector optional!");
> - return -EINVAL;
> + if (tc->panel_bridge) {
> + enum drm_bridge_attach_flags panel_flags;
> +
> + /* If a connector is required then this driver shall create it 
> */
> + panel_flags = flags & ~DRM_BRIDGE_ATTACH_NO_CONNECTOR;

Shouldn't this be

panel_flags = flags | DRM_BRIDGE_ATTACH_NO_CONNECTOR;

to ensure that the panel driver will not create a connector ?

> + ret = drm_bridge_attach(tc->bridge.encoder, tc->panel_bridge,
> + >bridge, panel_flags);
> + if (ret)
> + return ret;
>   }
>  
> + 

Re: [PATCH v4 06/15] drm/bridge: tc358767: add get_edid bridge operation

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:15PM +0200, Sam Ravnborg wrote:
> Prepare for chained bridge with the addition of
> get_edid support.
> 
> v2:
>   - Fixed handling of edid storage (Laurent)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/bridge/tc358767.c | 34 ---
>  1 file changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> b/drivers/gpu/drm/bridge/tc358767.c
> index e8ba713bedac..d86d7f06bebb 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -250,8 +250,6 @@ struct tc_data {
>   /* link settings */
>   struct tc_edp_link  link;
>  
> - /* display edid */
> - struct edid *edid;
>   /* current mode */
>   struct drm_display_mode mode;
>  
> @@ -1335,11 +1333,19 @@ static void tc_bridge_mode_set(struct drm_bridge 
> *bridge,
>   tc->mode = *mode;
>  }
>  
> +static struct edid *tc_get_edid(struct drm_bridge *bridge,
> + struct drm_connector *connector)
> +{
> + struct tc_data *tc = bridge_to_tc(bridge);
> +
> + return drm_get_edid(connector, >aux.ddc);
> +}
> +
>  static int tc_connector_get_modes(struct drm_connector *connector)
>  {
>   struct tc_data *tc = connector_to_tc(connector);
> + int num_modes;
>   struct edid *edid;
> - int count;
>   int ret;
>  
>   ret = tc_get_display_props(tc);
> @@ -1348,21 +1354,15 @@ static int tc_connector_get_modes(struct 
> drm_connector *connector)
>   return 0;
>   }
>  
> - count = drm_panel_get_modes(tc->panel, connector);
> - if (count > 0)
> - return count;
> -
> - edid = drm_get_edid(connector, >aux.ddc);
> -
> - kfree(tc->edid);
> - tc->edid = edid;
> - if (!edid)
> - return 0;
> + num_modes = drm_panel_get_modes(tc->panel, connector);
> + if (num_modes > 0)
> + return num_modes;
>  
> - drm_connector_update_edid_property(connector, edid);
> - count = drm_add_edid_modes(connector, edid);
> + edid = tc_get_edid(>bridge, connector);
> + num_modes = drm_add_edid_modes(connector, edid);
> + kfree(edid);
>  
> - return count;
> + return num_modes;
>  }
>  
>  static const struct drm_connector_helper_funcs tc_connector_helper_funcs = {
> @@ -1465,6 +1465,7 @@ static const struct drm_bridge_funcs tc_bridge_funcs = {
>   .post_disable = tc_bridge_post_disable,
>   .mode_fixup = tc_bridge_mode_fixup,
>   .detect = tc_bridge_detect,
> + .get_edid = tc_get_edid,
>  };
>  
>  static bool tc_readable_reg(struct device *dev, unsigned int reg)
> @@ -1689,6 +1690,7 @@ static int tc_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
>   tc->bridge.funcs = _bridge_funcs;
>   if (tc->hpd_pin >= 0)
>   tc->bridge.ops |= DRM_BRIDGE_OP_DETECT;
> + tc->bridge.ops |= DRM_BRIDGE_OP_EDID;
>  
>   tc->bridge.of_node = dev->of_node;
>   drm_bridge_add(>bridge);

-- 
Regards,

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


Re: [PATCH v4 04/15] drm/bridge: tc358764: add drm_panel_bridge support

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:13PM +0200, Sam Ravnborg wrote:
> Prepare the tc358764 bridge driver for use in a chained setup by
> replacing direct use of drm_panel with drm_panel_bridge support.
> 
> The bridge panel will use the connector type reported by the panel,
> where the connector for this driver hardcodes DRM_MODE_CONNECTOR_LVDS.
> 
> The tc358764 did not any additional info the the connector so the

Did you mean s/did not any/did not add any/ ?
s/the the/to the/

> connector creation is passed to the bridge panel driver.
> 
> v3:
>   - Merge with patch to make connector creation optional to avoid
> creating two connectors (Laurent)
>   - Pass connector creation to bridge panel, as this bridge driver
> did not add any extra info to the connector.
>   - Set bridge.type to DRM_MODE_CONNECTOR_LVDS.
> 
> v2:
>   - Use PTR_ERR_OR_ZERO() (kbuild test robot)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Laurent Pinchart 
> Cc: kbuild test robot 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> ---
>  drivers/gpu/drm/bridge/tc358764.c | 107 +-
>  1 file changed, 16 insertions(+), 91 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358764.c 
> b/drivers/gpu/drm/bridge/tc358764.c
> index a277739fab58..fdde4cfdc724 100644
> --- a/drivers/gpu/drm/bridge/tc358764.c
> +++ b/drivers/gpu/drm/bridge/tc358764.c
> @@ -153,10 +153,9 @@ static const char * const tc358764_supplies[] = {
>  struct tc358764 {
>   struct device *dev;
>   struct drm_bridge bridge;
> - struct drm_connector connector;
>   struct regulator_bulk_data supplies[ARRAY_SIZE(tc358764_supplies)];
>   struct gpio_desc *gpio_reset;
> - struct drm_panel *panel;
> + struct drm_bridge *panel_bridge;
>   int error;
>  };
>  
> @@ -210,12 +209,6 @@ static inline struct tc358764 *bridge_to_tc358764(struct 
> drm_bridge *bridge)
>   return container_of(bridge, struct tc358764, bridge);
>  }
>  
> -static inline
> -struct tc358764 *connector_to_tc358764(struct drm_connector *connector)
> -{
> - return container_of(connector, struct tc358764, connector);
> -}
> -
>  static int tc358764_init(struct tc358764 *ctx)
>  {
>   u32 v = 0;
> @@ -278,43 +271,11 @@ static void tc358764_reset(struct tc358764 *ctx)
>   usleep_range(1000, 2000);
>  }
>  
> -static int tc358764_get_modes(struct drm_connector *connector)
> -{
> - struct tc358764 *ctx = connector_to_tc358764(connector);
> -
> - return drm_panel_get_modes(ctx->panel, connector);
> -}
> -
> -static const
> -struct drm_connector_helper_funcs tc358764_connector_helper_funcs = {
> - .get_modes = tc358764_get_modes,
> -};
> -
> -static const struct drm_connector_funcs tc358764_connector_funcs = {
> - .fill_modes = drm_helper_probe_single_connector_modes,
> - .destroy = drm_connector_cleanup,
> - .reset = drm_atomic_helper_connector_reset,
> - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> -};
> -
> -static void tc358764_disable(struct drm_bridge *bridge)
> -{
> - struct tc358764 *ctx = bridge_to_tc358764(bridge);
> - int ret = drm_panel_disable(bridge_to_tc358764(bridge)->panel);
> -
> - if (ret < 0)
> - dev_err(ctx->dev, "error disabling panel (%d)\n", ret);
> -}
> -
>  static void tc358764_post_disable(struct drm_bridge *bridge)
>  {
>   struct tc358764 *ctx = bridge_to_tc358764(bridge);
>   int ret;
>  
> - ret = drm_panel_unprepare(ctx->panel);
> - if (ret < 0)
> - dev_err(ctx->dev, "error unpreparing panel (%d)\n", ret);
>   tc358764_reset(ctx);
>   usleep_range(1, 15000);
>   ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
> @@ -335,70 +296,28 @@ static void tc358764_pre_enable(struct drm_bridge 
> *bridge)
>   ret = tc358764_init(ctx);
>   if (ret < 0)
>   dev_err(ctx->dev, "error initializing bridge (%d)\n", ret);
> - ret = drm_panel_prepare(ctx->panel);
> - if (ret < 0)
> - dev_err(ctx->dev, "error preparing panel (%d)\n", ret);
> -}
> -
> -static void tc358764_enable(struct drm_bridge *bridge)
> -{
> - struct tc358764 *ctx = bridge_to_tc358764(bridge);
> - int ret = drm_panel_enable(ctx->panel);
> -
> - if (ret < 0)
> - dev_err(ctx->dev, "error enabling panel (%d)\n", ret);
>  }
>  
>  static int tc358764_attach(struct drm_bridge *bridge,
>  enum drm_bridge_attach_flags flags)
> -{
> - struct tc358764 *ctx = bridge_to_tc358764(bridge);
> - struct drm_device *drm = bridge->dev;
> - int ret;
> -
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> - DRM_ERROR("Fix bridge driver to make connector optional!");
> - return -EINVAL;
> - }
> -
> - ctx->connector.polled = DRM_CONNECTOR_POLL_HPD;
> - ret 

Re: [PATCH v4 05/15] drm/bridge: tc358767: add detect bridge operation

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:14PM +0200, Sam Ravnborg wrote:
> Prepare the bridge driver for chained operation by adding
> support for the detect operation.
> 
> v2:
>   - Do not announce detect operation if there is no hpd pin (Laurent)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> ---
>  drivers/gpu/drm/bridge/tc358767.c | 30 --
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> b/drivers/gpu/drm/bridge/tc358767.c
> index c2777b226c75..e8ba713bedac 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1369,21 +1369,13 @@ static const struct drm_connector_helper_funcs 
> tc_connector_helper_funcs = {
>   .get_modes = tc_connector_get_modes,
>  };
>  
> -static enum drm_connector_status tc_connector_detect(struct drm_connector 
> *connector,
> -  bool force)
> +static enum drm_connector_status tc_bridge_detect(struct drm_bridge *bridge)
>  {
> - struct tc_data *tc = connector_to_tc(connector);
> + struct tc_data *tc = bridge_to_tc(bridge);
>   bool conn;
>   u32 val;
>   int ret;
>  
> - if (tc->hpd_pin < 0) {
> - if (tc->panel)
> - return connector_status_connected;
> - else
> - return connector_status_unknown;
> - }
> -
>   ret = regmap_read(tc->regmap, GPIOI, );
>   if (ret)
>   return connector_status_unknown;
> @@ -1396,6 +1388,20 @@ static enum drm_connector_status 
> tc_connector_detect(struct drm_connector *conne
>   return connector_status_disconnected;
>  }
>  
> +static enum drm_connector_status
> +tc_connector_detect(struct drm_connector *connector, bool force)
> +{
> + struct tc_data *tc = connector_to_tc(connector);
> +
> + if (tc->hpd_pin >= 0)
> + return tc_bridge_detect(>bridge);
> + else
> + if (tc->panel)
> + return connector_status_connected;
> +
> + return connector_status_unknown;

I'd write this

if (tc->hpd_pin >= 0)
return tc_bridge_detect(>bridge);

if (tc->panel)
return connector_status_connected;
else
return connector_status_unknown;

Reviewed-by: Laurent Pinchart 

> +}
> +
>  static const struct drm_connector_funcs tc_connector_funcs = {
>   .detect = tc_connector_detect,
>   .fill_modes = drm_helper_probe_single_connector_modes,
> @@ -1458,6 +1464,7 @@ static const struct drm_bridge_funcs tc_bridge_funcs = {
>   .disable = tc_bridge_disable,
>   .post_disable = tc_bridge_post_disable,
>   .mode_fixup = tc_bridge_mode_fixup,
> + .detect = tc_bridge_detect,
>  };
>  
>  static bool tc_readable_reg(struct device *dev, unsigned int reg)
> @@ -1680,6 +1687,9 @@ static int tc_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
>   return ret;
>  
>   tc->bridge.funcs = _bridge_funcs;
> + if (tc->hpd_pin >= 0)
> + tc->bridge.ops |= DRM_BRIDGE_OP_DETECT;
> +
>   tc->bridge.of_node = dev->of_node;
>   drm_bridge_add(>bridge);
>  

-- 
Regards,

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


Re: [PATCH v4 02/15] drm/panel: panel-simple: add default connector_type

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:11PM +0200, Sam Ravnborg wrote:
> All panels shall report a connector type.
> panel-simple has a lot of panels with no connector_type,
> and for these fall back to DPI as the default.
> 
> v2:
>   - Rebased on top of validation of panel description
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Laurent Pinchart 
> Cc: Thierry Reding 
> Cc: Sam Ravnborg 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/panel/panel-simple.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-simple.c 
> b/drivers/gpu/drm/panel/panel-simple.c
> index a8d68102931e..56ab073e4e6e 100644
> --- a/drivers/gpu/drm/panel/panel-simple.c
> +++ b/drivers/gpu/drm/panel/panel-simple.c
> @@ -500,6 +500,7 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   struct panel_simple *panel;
>   struct display_timing dt;
>   struct device_node *ddc;
> + int connector_type;
>   u32 bus_flags;
>   int err;
>  
> @@ -550,10 +551,12 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   panel_simple_parse_panel_timing_node(dev, panel, );
>   }
>  
> + connector_type = desc->connector_type;
>   /* Catch common mistakes for panels. */
> - switch (desc->connector_type) {
> + switch (connector_type) {
>   case 0:
>   dev_warn(dev, "Specify missing connector_type\n");
> + connector_type = DRM_MODE_CONNECTOR_DPI;
>   break;
>   case DRM_MODE_CONNECTOR_LVDS:
>   WARN_ON(desc->bus_flags &
> @@ -600,11 +603,11 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   break;
>   default:
>   dev_warn(dev, "Specify a valid connector_type: %d\n", 
> desc->connector_type);
> + connector_type = DRM_MODE_CONNECTOR_DPI;
>   break;
>   }
>  
> - drm_panel_init(>base, dev, _simple_funcs,
> -desc->connector_type);
> + drm_panel_init(>base, dev, _simple_funcs, connector_type);
>  
>   err = drm_panel_of_backlight(>base);
>   if (err)

-- 
Regards,

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


Re: [PATCH v4 01/15] drm/panel: panel-simple: validate panel description

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:10PM +0200, Sam Ravnborg wrote:
> Warn if we detect a panel with incomplete/wrong description.
> This is inspired by a similar patch by Laurent that introduced checks
> for LVDS panels - this extends the checks to the remaining type of
> connectors.
> 
> This is known to warn for some of the existing panels but added
> despite this as we need help from people using the panels to
> add the missing info.
> The checks are not complete but will catch the most common mistakes.
> 
> The checks at the same time serves as documentation for the minimum

s/serves/serve/

> required description for a panel.
> 
> The checks uses dev_warn() as we know this will hit. WARN() was
> too noisy at the moment for anything else than LVDS.
> 
> v2:
>   - Use dev_warn (Laurent)
>   - Check for empty bus_flags
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Laurent Pinchart 
> Cc: Thierry Reding 
> Cc: Sam Ravnborg 
> ---
>  drivers/gpu/drm/panel/panel-simple.c | 41 ++--
>  1 file changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-simple.c 
> b/drivers/gpu/drm/panel/panel-simple.c
> index 54323515ca2c..a8d68102931e 100644
> --- a/drivers/gpu/drm/panel/panel-simple.c
> +++ b/drivers/gpu/drm/panel/panel-simple.c
> @@ -500,6 +500,7 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   struct panel_simple *panel;
>   struct display_timing dt;
>   struct device_node *ddc;
> + u32 bus_flags;
>   int err;
>  
>   panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
> @@ -549,8 +550,12 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   panel_simple_parse_panel_timing_node(dev, panel, );
>   }
>  
> - if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {
> - /* Catch common mistakes for LVDS panels. */
> + /* Catch common mistakes for panels. */
> + switch (desc->connector_type) {
> + case 0:
> + dev_warn(dev, "Specify missing connector_type\n");
> + break;
> + case DRM_MODE_CONNECTOR_LVDS:
>   WARN_ON(desc->bus_flags &
>   ~(DRM_BUS_FLAG_DE_LOW |
> DRM_BUS_FLAG_DE_HIGH |
> @@ -564,6 +569,38 @@ static int panel_simple_probe(struct device *dev, const 
> struct panel_desc *desc)
>   WARN_ON((desc->bus_format == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG ||
>desc->bus_format == MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA) 
> &&
>   desc->bpc != 8);
> + break;
> + case DRM_MODE_CONNECTOR_eDP:
> + if (desc->bus_format == 0)
> + dev_warn(dev, "Specify missing bus_format\n");
> + if (desc->bpc != 6 && desc->bpc != 8)
> + dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
> desc->bpc);

bpc is unsigned, so s/%d/%u/

> + break;
> + case DRM_MODE_CONNECTOR_DSI:
> + if (desc->bpc != 6 && desc->bpc != 8)
> + dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
> desc->bpc);

Same here.

> + break;
> + case DRM_MODE_CONNECTOR_DPI:
> + bus_flags = DRM_BUS_FLAG_DE_LOW |
> + DRM_BUS_FLAG_DE_HIGH |
> + DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE |
> + DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
> + DRM_BUS_FLAG_DATA_MSB_TO_LSB |
> + DRM_BUS_FLAG_DATA_LSB_TO_MSB |
> + DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE |
> + DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE;
> + if (desc->bus_flags & ~bus_flags)
> + dev_warn(dev, "Unexpected bus_flags(%d)\n", 
> desc->bus_flags & ~bus_flags);
> + if (!(desc->bus_flags & bus_flags))
> + dev_warn(dev, "Specify missing bus_flags\n");
> + if (desc->bus_format == 0)
> + dev_warn(dev, "Specify missing bus_format\n");
> + if (desc->bpc != 6 && desc->bpc != 8)
> + dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
> desc->bpc);

And here too.

Reviewed-by: Laurent Pinchart 

> + break;
> + default:
> + dev_warn(dev, "Specify a valid connector_type: %d\n", 
> desc->connector_type);
> + break;
>   }
>  
>   drm_panel_init(>base, dev, _simple_funcs,

-- 
Regards,

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


Re: [PATCH 2/2] drm/bridge: tc358762: Add basic driver for Toshiba TC358762 DSI-to-DPI bridge

2020-07-26 Thread Sam Ravnborg
Hi Marek.

On Sun, Jul 26, 2020 at 12:17:46PM +0200, Marek Vasut wrote:
> On 7/26/20 9:15 AM, Sam Ravnborg wrote:
> > Hi Marek.
> 
> Hi,
> 
> > On Sat, Jul 25, 2020 at 11:14:57PM +0200, Marek Vasut wrote:
> >> Add very basic driver for Toshiba TC358762 DSI-to-DPI bridge, derived
> >> from tc358764 driver and panel-raspberrypi-touchscreen. This driver is
> >> meant to replace the panel-raspberrypi-touchscreen too, as the bridge
> >> connection can be described in DT too.
> >>
> >> Signed-off-by: Marek Vasut 
> >> To: dri-devel@lists.freedesktop.org
> >> Cc: Eric Anholt 
> >> Cc: Rob Herring 
> >> Cc: Sam Ravnborg 
> >> Cc: devicet...@vger.kernel.org
> >> ---
> > 
> > Two general comments.
> > - This driver should use the bridge panel - this will simplify the
> >   driver in many places. We already have several good examples in-tree
> >   that does this.
> 
> Can you list such an example ?

Take a look at tc358764.c in following patch-set:
https://lore.kernel.org/dri-devel/20200726203324.3722593-1-...@ravnborg.org/

Your current driver will be even smaller after implmenting these
changes.

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


[PATCH v4 05/15] drm/bridge: tc358767: add detect bridge operation

2020-07-26 Thread Sam Ravnborg
Prepare the bridge driver for chained operation by adding
support for the detect operation.

v2:
  - Do not announce detect operation if there is no hpd pin (Laurent)

Signed-off-by: Sam Ravnborg 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/tc358767.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index c2777b226c75..e8ba713bedac 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1369,21 +1369,13 @@ static const struct drm_connector_helper_funcs 
tc_connector_helper_funcs = {
.get_modes = tc_connector_get_modes,
 };
 
-static enum drm_connector_status tc_connector_detect(struct drm_connector 
*connector,
-bool force)
+static enum drm_connector_status tc_bridge_detect(struct drm_bridge *bridge)
 {
-   struct tc_data *tc = connector_to_tc(connector);
+   struct tc_data *tc = bridge_to_tc(bridge);
bool conn;
u32 val;
int ret;
 
-   if (tc->hpd_pin < 0) {
-   if (tc->panel)
-   return connector_status_connected;
-   else
-   return connector_status_unknown;
-   }
-
ret = regmap_read(tc->regmap, GPIOI, );
if (ret)
return connector_status_unknown;
@@ -1396,6 +1388,20 @@ static enum drm_connector_status 
tc_connector_detect(struct drm_connector *conne
return connector_status_disconnected;
 }
 
+static enum drm_connector_status
+tc_connector_detect(struct drm_connector *connector, bool force)
+{
+   struct tc_data *tc = connector_to_tc(connector);
+
+   if (tc->hpd_pin >= 0)
+   return tc_bridge_detect(>bridge);
+   else
+   if (tc->panel)
+   return connector_status_connected;
+
+   return connector_status_unknown;
+}
+
 static const struct drm_connector_funcs tc_connector_funcs = {
.detect = tc_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
@@ -1458,6 +1464,7 @@ static const struct drm_bridge_funcs tc_bridge_funcs = {
.disable = tc_bridge_disable,
.post_disable = tc_bridge_post_disable,
.mode_fixup = tc_bridge_mode_fixup,
+   .detect = tc_bridge_detect,
 };
 
 static bool tc_readable_reg(struct device *dev, unsigned int reg)
@@ -1680,6 +1687,9 @@ static int tc_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return ret;
 
tc->bridge.funcs = _bridge_funcs;
+   if (tc->hpd_pin >= 0)
+   tc->bridge.ops |= DRM_BRIDGE_OP_DETECT;
+
tc->bridge.of_node = dev->of_node;
drm_bridge_add(>bridge);
 
-- 
2.25.1

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


[PATCH v4 15/15] drm/bridge: nxp-ptn3460: add drm_panel_bridge support

2020-07-26 Thread Sam Ravnborg
Prepare the bridge driver for use in a chained setup.

- Replacing direct use of drm_panel with drm_panel_bridge support.
- Make the connector creation optional

Note: the bridge panel will use the connector type from the panel.

v2:
  - Use panel_bridge for local variable name to align with other drivers
  - Fix that connector was created twice (Laurent)
  - Set bridge.type to DRM_MODE_CONNECTOR_LVDS.

Signed-off-by: Sam Ravnborg 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/nxp-ptn3460.c | 60 ++--
 1 file changed, 20 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
b/drivers/gpu/drm/bridge/nxp-ptn3460.c
index 2805c8938f98..a49616855dd3 100644
--- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -29,7 +29,7 @@ struct ptn3460_bridge {
struct drm_connector connector;
struct i2c_client *client;
struct drm_bridge bridge;
-   struct drm_panel *panel;
+   struct drm_bridge *panel_bridge;
struct gpio_desc *gpio_pd_n;
struct gpio_desc *gpio_rst_n;
u32 edid_emulation;
@@ -126,11 +126,6 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
usleep_range(10, 20);
gpiod_set_value(ptn_bridge->gpio_rst_n, 1);
 
-   if (drm_panel_prepare(ptn_bridge->panel)) {
-   DRM_ERROR("failed to prepare panel\n");
-   return;
-   }
-
/*
 * There's a bug in the PTN chip where it falsely asserts hotplug before
 * it is fully functional. We're forced to wait for the maximum start up
@@ -145,16 +140,6 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
ptn_bridge->enabled = true;
 }
 
-static void ptn3460_enable(struct drm_bridge *bridge)
-{
-   struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
-
-   if (drm_panel_enable(ptn_bridge->panel)) {
-   DRM_ERROR("failed to enable panel\n");
-   return;
-   }
-}
-
 static void ptn3460_disable(struct drm_bridge *bridge)
 {
struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
@@ -164,24 +149,10 @@ static void ptn3460_disable(struct drm_bridge *bridge)
 
ptn_bridge->enabled = false;
 
-   if (drm_panel_disable(ptn_bridge->panel)) {
-   DRM_ERROR("failed to disable panel\n");
-   return;
-   }
-
gpiod_set_value(ptn_bridge->gpio_rst_n, 1);
gpiod_set_value(ptn_bridge->gpio_pd_n, 0);
 }
 
-static void ptn3460_post_disable(struct drm_bridge *bridge)
-{
-   struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
-
-   if (drm_panel_unprepare(ptn_bridge->panel)) {
-   DRM_ERROR("failed to unprepare panel\n");
-   return;
-   }
-}
 
 static struct edid *ptn3460_get_edid(struct drm_bridge *bridge,
 struct drm_connector *connector)
@@ -245,12 +216,18 @@ static int ptn3460_bridge_attach(struct drm_bridge 
*bridge,
 enum drm_bridge_attach_flags flags)
 {
struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
+   enum drm_bridge_attach_flags panel_flags;
int ret;
 
-   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
-   DRM_ERROR("Fix bridge driver to make connector optional!");
-   return -EINVAL;
-   }
+   /* Let this driver create connector if requested */
+   panel_flags = flags & ~DRM_BRIDGE_ATTACH_NO_CONNECTOR;
+   ret = drm_bridge_attach(bridge->encoder, ptn_bridge->panel_bridge,
+   bridge, panel_flags);
+   if (ret < 0)
+   return ret;
+
+   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+   return 0;
 
if (!bridge->encoder) {
DRM_ERROR("Parent encoder object not found");
@@ -270,9 +247,6 @@ static int ptn3460_bridge_attach(struct drm_bridge *bridge,
drm_connector_attach_encoder(_bridge->connector,
bridge->encoder);
 
-   if (ptn_bridge->panel)
-   drm_panel_attach(ptn_bridge->panel, _bridge->connector);
-
drm_helper_hpd_irq_event(ptn_bridge->connector.dev);
 
return ret;
@@ -280,9 +254,7 @@ static int ptn3460_bridge_attach(struct drm_bridge *bridge,
 
 static const struct drm_bridge_funcs ptn3460_bridge_funcs = {
.pre_enable = ptn3460_pre_enable,
-   .enable = ptn3460_enable,
.disable = ptn3460_disable,
-   .post_disable = ptn3460_post_disable,
.attach = ptn3460_bridge_attach,
.get_edid = ptn3460_get_edid,
 };
@@ -292,6 +264,8 @@ static int ptn3460_probe(struct i2c_client *client,
 {
struct device *dev = >dev;
struct ptn3460_bridge *ptn_bridge;
+   struct drm_bridge *panel_bridge;
+   struct drm_panel *panel;
int ret;
 

[PATCH v4 01/15] drm/panel: panel-simple: validate panel description

2020-07-26 Thread Sam Ravnborg
Warn if we detect a panel with incomplete/wrong description.
This is inspired by a similar patch by Laurent that introduced checks
for LVDS panels - this extends the checks to the remaining type of
connectors.

This is known to warn for some of the existing panels but added
despite this as we need help from people using the panels to
add the missing info.
The checks are not complete but will catch the most common mistakes.

The checks at the same time serves as documentation for the minimum
required description for a panel.

The checks uses dev_warn() as we know this will hit. WARN() was
too noisy at the moment for anything else than LVDS.

v2:
  - Use dev_warn (Laurent)
  - Check for empty bus_flags

Signed-off-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: Thierry Reding 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/panel/panel-simple.c | 41 ++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 54323515ca2c..a8d68102931e 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -500,6 +500,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct panel_simple *panel;
struct display_timing dt;
struct device_node *ddc;
+   u32 bus_flags;
int err;
 
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
@@ -549,8 +550,12 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
-   if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {
-   /* Catch common mistakes for LVDS panels. */
+   /* Catch common mistakes for panels. */
+   switch (desc->connector_type) {
+   case 0:
+   dev_warn(dev, "Specify missing connector_type\n");
+   break;
+   case DRM_MODE_CONNECTOR_LVDS:
WARN_ON(desc->bus_flags &
~(DRM_BUS_FLAG_DE_LOW |
  DRM_BUS_FLAG_DE_HIGH |
@@ -564,6 +569,38 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
WARN_ON((desc->bus_format == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG ||
 desc->bus_format == MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA) 
&&
desc->bpc != 8);
+   break;
+   case DRM_MODE_CONNECTOR_eDP:
+   if (desc->bus_format == 0)
+   dev_warn(dev, "Specify missing bus_format\n");
+   if (desc->bpc != 6 && desc->bpc != 8)
+   dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
desc->bpc);
+   break;
+   case DRM_MODE_CONNECTOR_DSI:
+   if (desc->bpc != 6 && desc->bpc != 8)
+   dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
desc->bpc);
+   break;
+   case DRM_MODE_CONNECTOR_DPI:
+   bus_flags = DRM_BUS_FLAG_DE_LOW |
+   DRM_BUS_FLAG_DE_HIGH |
+   DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE |
+   DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
+   DRM_BUS_FLAG_DATA_MSB_TO_LSB |
+   DRM_BUS_FLAG_DATA_LSB_TO_MSB |
+   DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE |
+   DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE;
+   if (desc->bus_flags & ~bus_flags)
+   dev_warn(dev, "Unexpected bus_flags(%d)\n", 
desc->bus_flags & ~bus_flags);
+   if (!(desc->bus_flags & bus_flags))
+   dev_warn(dev, "Specify missing bus_flags\n");
+   if (desc->bus_format == 0)
+   dev_warn(dev, "Specify missing bus_format\n");
+   if (desc->bpc != 6 && desc->bpc != 8)
+   dev_warn(dev, "Expected bpc in {6,8} but got: %d\n", 
desc->bpc);
+   break;
+   default:
+   dev_warn(dev, "Specify a valid connector_type: %d\n", 
desc->connector_type);
+   break;
}
 
drm_panel_init(>base, dev, _simple_funcs,
-- 
2.25.1

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


[PATCH v4 03/15] drm/bridge: tc358764: drop drm_connector_(un)register

2020-07-26 Thread Sam Ravnborg
Drop drm_connector handling that is not needed:

- drm_dev_register() in the display controller driver takes
  care of registering connectors.
  So the call to drm_connector_register() call is not needed in the bridge
  driver.

- Use of drm_connector_unregister() is only required for drivers that
  explicit have called drm_dev_register.

- The reference counting using drm_connector_put() is likewise not needed.

Signed-off-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/tc358764.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358764.c 
b/drivers/gpu/drm/bridge/tc358764.c
index 5ac1430fab04..a277739fab58 100644
--- a/drivers/gpu/drm/bridge/tc358764.c
+++ b/drivers/gpu/drm/bridge/tc358764.c
@@ -375,7 +375,6 @@ static int tc358764_attach(struct drm_bridge *bridge,
drm_connector_attach_encoder(>connector, bridge->encoder);
drm_panel_attach(ctx->panel, >connector);
ctx->connector.funcs->reset(>connector);
-   drm_connector_register(>connector);
 
return 0;
 }
@@ -384,10 +383,8 @@ static void tc358764_detach(struct drm_bridge *bridge)
 {
struct tc358764 *ctx = bridge_to_tc358764(bridge);
 
-   drm_connector_unregister(>connector);
drm_panel_detach(ctx->panel);
ctx->panel = NULL;
-   drm_connector_put(>connector);
 }
 
 static const struct drm_bridge_funcs tc358764_bridge_funcs = {
-- 
2.25.1

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


[PATCH v4 04/15] drm/bridge: tc358764: add drm_panel_bridge support

2020-07-26 Thread Sam Ravnborg
Prepare the tc358764 bridge driver for use in a chained setup by
replacing direct use of drm_panel with drm_panel_bridge support.

The bridge panel will use the connector type reported by the panel,
where the connector for this driver hardcodes DRM_MODE_CONNECTOR_LVDS.

The tc358764 did not any additional info the the connector so the
connector creation is passed to the bridge panel driver.

v3:
  - Merge with patch to make connector creation optional to avoid
creating two connectors (Laurent)
  - Pass connector creation to bridge panel, as this bridge driver
did not add any extra info to the connector.
  - Set bridge.type to DRM_MODE_CONNECTOR_LVDS.

v2:
  - Use PTR_ERR_OR_ZERO() (kbuild test robot)

Signed-off-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: kbuild test robot 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/tc358764.c | 107 +-
 1 file changed, 16 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358764.c 
b/drivers/gpu/drm/bridge/tc358764.c
index a277739fab58..fdde4cfdc724 100644
--- a/drivers/gpu/drm/bridge/tc358764.c
+++ b/drivers/gpu/drm/bridge/tc358764.c
@@ -153,10 +153,9 @@ static const char * const tc358764_supplies[] = {
 struct tc358764 {
struct device *dev;
struct drm_bridge bridge;
-   struct drm_connector connector;
struct regulator_bulk_data supplies[ARRAY_SIZE(tc358764_supplies)];
struct gpio_desc *gpio_reset;
-   struct drm_panel *panel;
+   struct drm_bridge *panel_bridge;
int error;
 };
 
@@ -210,12 +209,6 @@ static inline struct tc358764 *bridge_to_tc358764(struct 
drm_bridge *bridge)
return container_of(bridge, struct tc358764, bridge);
 }
 
-static inline
-struct tc358764 *connector_to_tc358764(struct drm_connector *connector)
-{
-   return container_of(connector, struct tc358764, connector);
-}
-
 static int tc358764_init(struct tc358764 *ctx)
 {
u32 v = 0;
@@ -278,43 +271,11 @@ static void tc358764_reset(struct tc358764 *ctx)
usleep_range(1000, 2000);
 }
 
-static int tc358764_get_modes(struct drm_connector *connector)
-{
-   struct tc358764 *ctx = connector_to_tc358764(connector);
-
-   return drm_panel_get_modes(ctx->panel, connector);
-}
-
-static const
-struct drm_connector_helper_funcs tc358764_connector_helper_funcs = {
-   .get_modes = tc358764_get_modes,
-};
-
-static const struct drm_connector_funcs tc358764_connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = drm_connector_cleanup,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-static void tc358764_disable(struct drm_bridge *bridge)
-{
-   struct tc358764 *ctx = bridge_to_tc358764(bridge);
-   int ret = drm_panel_disable(bridge_to_tc358764(bridge)->panel);
-
-   if (ret < 0)
-   dev_err(ctx->dev, "error disabling panel (%d)\n", ret);
-}
-
 static void tc358764_post_disable(struct drm_bridge *bridge)
 {
struct tc358764 *ctx = bridge_to_tc358764(bridge);
int ret;
 
-   ret = drm_panel_unprepare(ctx->panel);
-   if (ret < 0)
-   dev_err(ctx->dev, "error unpreparing panel (%d)\n", ret);
tc358764_reset(ctx);
usleep_range(1, 15000);
ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
@@ -335,70 +296,28 @@ static void tc358764_pre_enable(struct drm_bridge *bridge)
ret = tc358764_init(ctx);
if (ret < 0)
dev_err(ctx->dev, "error initializing bridge (%d)\n", ret);
-   ret = drm_panel_prepare(ctx->panel);
-   if (ret < 0)
-   dev_err(ctx->dev, "error preparing panel (%d)\n", ret);
-}
-
-static void tc358764_enable(struct drm_bridge *bridge)
-{
-   struct tc358764 *ctx = bridge_to_tc358764(bridge);
-   int ret = drm_panel_enable(ctx->panel);
-
-   if (ret < 0)
-   dev_err(ctx->dev, "error enabling panel (%d)\n", ret);
 }
 
 static int tc358764_attach(struct drm_bridge *bridge,
   enum drm_bridge_attach_flags flags)
-{
-   struct tc358764 *ctx = bridge_to_tc358764(bridge);
-   struct drm_device *drm = bridge->dev;
-   int ret;
-
-   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
-   DRM_ERROR("Fix bridge driver to make connector optional!");
-   return -EINVAL;
-   }
-
-   ctx->connector.polled = DRM_CONNECTOR_POLL_HPD;
-   ret = drm_connector_init(drm, >connector,
-_connector_funcs,
-DRM_MODE_CONNECTOR_LVDS);
-   if (ret) {
-   DRM_ERROR("Failed to initialize connector\n");
-   return ret;
-   }
-
-   drm_connector_helper_add(>connector,
-

[PATCH v4 08/15] drm/bridge: parade-ps8622: add drm_panel_bridge support

2020-07-26 Thread Sam Ravnborg
Prepare the bridge driver for use in a chained setup by
replacing direct use of drm_panel with drm_panel_bridge support.

The connecter is now either created by the panel bridge or the display
driver. So all code for connector creation in this driver is no longer
relevant and thus dropped.

The connector code had some special polling handling:
connector.polled = DRM_CONNECTOR_POLL_HPD;
drm_helper_hpd_irq_event(ps8622->bridge.dev);

This code was most likely added to speed up detection of the connector.
If really needed then this functionality belongs somewhere else.

Note: the bridge panel will use the connector type from the panel.

v2:
  - Fix to avoid creating connector twice (Laurent)
  - Drop all connector code - defer to bridge panel
  - Use panel_bridge for local variable to align with other drivers
  - Set bridge.type to DRM_MODE_CONNECTOR_LVDS;

Signed-off-by: Sam Ravnborg 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/parade-ps8622.c | 100 -
 1 file changed, 13 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
b/drivers/gpu/drm/bridge/parade-ps8622.c
index d789ea2a7fb9..614b19f0f1b7 100644
--- a/drivers/gpu/drm/bridge/parade-ps8622.c
+++ b/drivers/gpu/drm/bridge/parade-ps8622.c
@@ -42,10 +42,9 @@
 #endif
 
 struct ps8622_bridge {
-   struct drm_connector connector;
struct i2c_client *client;
struct drm_bridge bridge;
-   struct drm_panel *panel;
+   struct drm_bridge *panel_bridge;
struct regulator *v12;
struct backlight_device *bl;
 
@@ -64,12 +63,6 @@ static inline struct ps8622_bridge *
return container_of(bridge, struct ps8622_bridge, bridge);
 }
 
-static inline struct ps8622_bridge *
-   connector_to_ps8622(struct drm_connector *connector)
-{
-   return container_of(connector, struct ps8622_bridge, connector);
-}
-
 static int ps8622_set(struct i2c_client *client, u8 page, u8 reg, u8 val)
 {
int ret;
@@ -365,11 +358,6 @@ static void ps8622_pre_enable(struct drm_bridge *bridge)
DRM_ERROR("fails to enable ps8622->v12");
}
 
-   if (drm_panel_prepare(ps8622->panel)) {
-   DRM_ERROR("failed to prepare panel\n");
-   return;
-   }
-
gpiod_set_value(ps8622->gpio_slp, 1);
 
/*
@@ -399,24 +387,9 @@ static void ps8622_pre_enable(struct drm_bridge *bridge)
ps8622->enabled = true;
 }
 
-static void ps8622_enable(struct drm_bridge *bridge)
-{
-   struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
-
-   if (drm_panel_enable(ps8622->panel)) {
-   DRM_ERROR("failed to enable panel\n");
-   return;
-   }
-}
-
 static void ps8622_disable(struct drm_bridge *bridge)
 {
-   struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
-
-   if (drm_panel_disable(ps8622->panel)) {
-   DRM_ERROR("failed to disable panel\n");
-   return;
-   }
+   /* Delay after panel is disabled */
msleep(PS8622_PWMO_END_T12_MS);
 }
 
@@ -436,11 +409,6 @@ static void ps8622_post_disable(struct drm_bridge *bridge)
 */
gpiod_set_value(ps8622->gpio_slp, 0);
 
-   if (drm_panel_unprepare(ps8622->panel)) {
-   DRM_ERROR("failed to unprepare panel\n");
-   return;
-   }
-
if (ps8622->v12)
regulator_disable(ps8622->v12);
 
@@ -455,67 +423,17 @@ static void ps8622_post_disable(struct drm_bridge *bridge)
msleep(PS8622_POWER_OFF_T17_MS);
 }
 
-static int ps8622_get_modes(struct drm_connector *connector)
-{
-   struct ps8622_bridge *ps8622;
-
-   ps8622 = connector_to_ps8622(connector);
-
-   return drm_panel_get_modes(ps8622->panel, connector);
-}
-
-static const struct drm_connector_helper_funcs ps8622_connector_helper_funcs = 
{
-   .get_modes = ps8622_get_modes,
-};
-
-static const struct drm_connector_funcs ps8622_connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = drm_connector_cleanup,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
 static int ps8622_attach(struct drm_bridge *bridge,
 enum drm_bridge_attach_flags flags)
 {
struct ps8622_bridge *ps8622 = bridge_to_ps8622(bridge);
-   int ret;
-
-   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
-   DRM_ERROR("Fix bridge driver to make connector optional!");
-   return -EINVAL;
-   }
 
-   if (!bridge->encoder) {
-   DRM_ERROR("Parent encoder object not found");
-   return -ENODEV;
-   }
-
-   ps8622->connector.polled = DRM_CONNECTOR_POLL_HPD;
-   ret = 

[PATCH v4 02/15] drm/panel: panel-simple: add default connector_type

2020-07-26 Thread Sam Ravnborg
All panels shall report a connector type.
panel-simple has a lot of panels with no connector_type,
and for these fall back to DPI as the default.

v2:
  - Rebased on top of validation of panel description

Signed-off-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: Thierry Reding 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/panel/panel-simple.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index a8d68102931e..56ab073e4e6e 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -500,6 +500,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct panel_simple *panel;
struct display_timing dt;
struct device_node *ddc;
+   int connector_type;
u32 bus_flags;
int err;
 
@@ -550,10 +551,12 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+   connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
-   switch (desc->connector_type) {
+   switch (connector_type) {
case 0:
dev_warn(dev, "Specify missing connector_type\n");
+   connector_type = DRM_MODE_CONNECTOR_DPI;
break;
case DRM_MODE_CONNECTOR_LVDS:
WARN_ON(desc->bus_flags &
@@ -600,11 +603,11 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
break;
default:
dev_warn(dev, "Specify a valid connector_type: %d\n", 
desc->connector_type);
+   connector_type = DRM_MODE_CONNECTOR_DPI;
break;
}
 
-   drm_panel_init(>base, dev, _simple_funcs,
-  desc->connector_type);
+   drm_panel_init(>base, dev, _simple_funcs, connector_type);
 
err = drm_panel_of_backlight(>base);
if (err)
-- 
2.25.1

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


[PATCH v4 11/15] drm/bridge: megachips: enable detect bridge operation

2020-07-26 Thread Sam Ravnborg
To prepare for use in a chained bridge setup enable the
detect operation.

Signed-off-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 .../gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c  | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index cf1dfbc88acf..450dca33ea48 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -163,8 +163,7 @@ drm_connector_helper_funcs 
ge_b850v3_lvds_connector_helper_funcs = {
.mode_valid = ge_b850v3_lvds_mode_valid,
 };
 
-static enum drm_connector_status ge_b850v3_lvds_detect(
-   struct drm_connector *connector, bool force)
+static enum drm_connector_status ge_b850v3_lvds_bridge_detect(struct 
drm_bridge *bridge)
 {
struct i2c_client *stdp4028_i2c =
ge_b850v3_lvds_ptr->stdp4028_i2c;
@@ -182,6 +181,12 @@ static enum drm_connector_status ge_b850v3_lvds_detect(
return connector_status_unknown;
 }
 
+static enum drm_connector_status ge_b850v3_lvds_detect(struct drm_connector 
*connector,
+  bool force)
+{
+   return ge_b850v3_lvds_bridge_detect(_b850v3_lvds_ptr->bridge);
+}
+
 static const struct drm_connector_funcs ge_b850v3_lvds_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes,
.detect = ge_b850v3_lvds_detect,
@@ -263,6 +268,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
 
 static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
.attach = ge_b850v3_lvds_attach,
+   .detect = ge_b850v3_lvds_bridge_detect,
 };
 
 static int ge_b850v3_lvds_init(struct device *dev)
@@ -317,6 +323,7 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
*stdp4028_i2c,
 
/* drm bridge initialization */
ge_b850v3_lvds_ptr->bridge.funcs = _b850v3_lvds_funcs;
+   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT;
ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
drm_bridge_add(_b850v3_lvds_ptr->bridge);
 
-- 
2.25.1

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


[PATCH v4 13/15] drm/bridge: megachips: make connector creation optional

2020-07-26 Thread Sam Ravnborg
Make the connector creation optional to enable usage of the
megachips-stdp-ge-b850v3-fw bridge with the DRM bridge connector
helper.

v2:
  - Set bridge.type to DRM_MODE_CONNECTOR_DisplayPort

Signed-off-by: Sam Ravnborg 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 .../drm/bridge/megachips-stdp-ge-b850v3-fw.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index f7b55dc374ac..61a24f265c7a 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -245,16 +245,6 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
 {
struct i2c_client *stdp4028_i2c
= ge_b850v3_lvds_ptr->stdp4028_i2c;
-   int ret;
-
-   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
-   DRM_ERROR("Fix bridge driver to make connector optional!");
-   return -EINVAL;
-   }
-
-   ret = ge_b850v3_lvds_create_connector(bridge);
-   if (ret)
-   return ret;
 
/* Configures the bridge to re-enable interrupts after each ack. */
i2c_smbus_write_word_data(stdp4028_i2c,
@@ -266,7 +256,10 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
  STDP4028_DPTX_IRQ_EN_REG,
  STDP4028_DPTX_IRQ_CONFIG);
 
-   return 0;
+   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+   return 0;
+
+   return ge_b850v3_lvds_create_connector(bridge);
 }
 
 static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
@@ -327,6 +320,7 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
*stdp4028_i2c,
ge_b850v3_lvds_ptr->bridge.funcs = _b850v3_lvds_funcs;
ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
 DRM_BRIDGE_OP_EDID;
+   ge_b850v3_lvds_ptr->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
drm_bridge_add(_b850v3_lvds_ptr->bridge);
 
-- 
2.25.1

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


[PATCH v4 0/15] drm/bridge: support chained bridges + panel updates

2020-07-26 Thread Sam Ravnborg
The objective is that all bridge drivers shall support a chained setup
connector creation is moved to the display drivers.
This is just one step on this path.

The general approach for the bridge drivers:
- Introduce bridge operations
- Introduce use of panel bridge and make connector creation optional

v4:
  - Dropped patch for ti-sn65dsi86. Await full conversion.
  - Dropped patch for ti-tpd12s015. It was wrong (Laurent)
  - Drop boe,hv070wsa-100 patch, it was applied
  - Combined a few patches to fix connector created twice (Laurent)
  - Fix memory leak in get_edid in several drivers (Laurent)
  - Added patch to validate panel descriptions in panel-simple
  - Set bridge.type in relevant drivers
 
v3:
  - Rebase on top of drm-misc-next
  - Address kbuild test robot feedback
 
v2:
  - Updated bus_flags for boe,hv070wsa-100
  - Collected r-b, but did not apply patches yet
  - On the panel side the panel-simple driver gained a default
connector type for all the dumb panels that do not
include so in their description.
With this change panels always provide a connector type,
and we have the potential to drop most uses of
devm_drm_panel_bridge_add_typed().
  - Added conversion of a few more bridge drivers

Patches can build but no run-time testing.
So both test and review feedback appreciated!

Sam

Sam Ravnborg (15):
  drm/panel: panel-simple: validate panel description
  drm/panel: panel-simple: add default connector_type
  drm/bridge: tc358764: drop drm_connector_(un)register
  drm/bridge: tc358764: add drm_panel_bridge support
  drm/bridge: tc358767: add detect bridge operation
  drm/bridge: tc358767: add get_edid bridge operation
  drm/bridge: tc358767: add drm_panel_bridge support
  drm/bridge: parade-ps8622: add drm_panel_bridge support
  drm/bridge: megachips: add helper to create connector
  drm/bridge: megachips: get drm_device from bridge
  drm/bridge: megachips: enable detect bridge operation
  drm/bridge: megachips: add get_edid bridge operation
  drm/bridge: megachips: make connector creation optional
  drm/bridge: nxp-ptn3460: add get_edid bridge operation
  drm/bridge: nxp-ptn3460: add drm_panel_bridge support

 .../drm/bridge/megachips-stdp-ge-b850v3-fw.c   |  97 +---
 drivers/gpu/drm/bridge/nxp-ptn3460.c   | 103 -
 drivers/gpu/drm/bridge/parade-ps8622.c | 100 +++-
 drivers/gpu/drm/bridge/tc358764.c  | 110 +++---
 drivers/gpu/drm/bridge/tc358767.c  | 126 +++--
 drivers/gpu/drm/panel/panel-simple.c   |  48 +++-
 6 files changed, 242 insertions(+), 342 deletions(-)


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


[PATCH v4 14/15] drm/bridge: nxp-ptn3460: add get_edid bridge operation

2020-07-26 Thread Sam Ravnborg
Add the get_edid() bridge operation to prepare for
use as a chained bridge.
Add helper function that is also used by the connector.

v2:
  - Fix memory leak (Laurent)
  - Do not save a copy of edid, read it when needed

Signed-off-by: Sam Ravnborg 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/nxp-ptn3460.c | 43 
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
b/drivers/gpu/drm/bridge/nxp-ptn3460.c
index 438e566ce0a4..2805c8938f98 100644
--- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -29,7 +29,6 @@ struct ptn3460_bridge {
struct drm_connector connector;
struct i2c_client *client;
struct drm_bridge bridge;
-   struct edid *edid;
struct drm_panel *panel;
struct gpio_desc *gpio_pd_n;
struct gpio_desc *gpio_rst_n;
@@ -184,17 +183,13 @@ static void ptn3460_post_disable(struct drm_bridge 
*bridge)
}
 }
 
-static int ptn3460_get_modes(struct drm_connector *connector)
+static struct edid *ptn3460_get_edid(struct drm_bridge *bridge,
+struct drm_connector *connector)
 {
-   struct ptn3460_bridge *ptn_bridge;
-   u8 *edid;
-   int ret, num_modes = 0;
+   struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge);
bool power_off;
-
-   ptn_bridge = connector_to_ptn3460(connector);
-
-   if (ptn_bridge->edid)
-   return drm_add_edid_modes(connector, ptn_bridge->edid);
+   u8 *edid;
+   int ret;
 
power_off = !ptn_bridge->enabled;
ptn3460_pre_enable(_bridge->bridge);
@@ -202,30 +197,40 @@ static int ptn3460_get_modes(struct drm_connector 
*connector)
edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
if (!edid) {
DRM_ERROR("Failed to allocate EDID\n");
-   return 0;
+   goto out;
}
 
ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid,
-   EDID_LENGTH);
+EDID_LENGTH);
if (ret) {
kfree(edid);
+   edid = NULL;
goto out;
}
 
-   ptn_bridge->edid = (struct edid *)edid;
-   drm_connector_update_edid_property(connector, ptn_bridge->edid);
-
-   num_modes = drm_add_edid_modes(connector, ptn_bridge->edid);
-
 out:
if (power_off)
ptn3460_disable(_bridge->bridge);
 
+   return (struct edid *)edid;
+}
+
+static int ptn3460_connector_get_modes(struct drm_connector *connector)
+{
+   struct ptn3460_bridge *ptn_bridge = connector_to_ptn3460(connector);
+   struct edid *edid;
+   int num_modes;
+
+   edid = ptn3460_get_edid(_bridge->bridge, connector);
+   drm_connector_update_edid_property(connector, edid);
+   num_modes = drm_add_edid_modes(connector, edid);
+   kfree(edid);
+
return num_modes;
 }
 
 static const struct drm_connector_helper_funcs ptn3460_connector_helper_funcs 
= {
-   .get_modes = ptn3460_get_modes,
+   .get_modes = ptn3460_connector_get_modes,
 };
 
 static const struct drm_connector_funcs ptn3460_connector_funcs = {
@@ -279,6 +284,7 @@ static const struct drm_bridge_funcs ptn3460_bridge_funcs = 
{
.disable = ptn3460_disable,
.post_disable = ptn3460_post_disable,
.attach = ptn3460_bridge_attach,
+   .get_edid = ptn3460_get_edid,
 };
 
 static int ptn3460_probe(struct i2c_client *client,
@@ -327,6 +333,7 @@ static int ptn3460_probe(struct i2c_client *client,
}
 
ptn_bridge->bridge.funcs = _bridge_funcs;
+   ptn_bridge->bridge.ops = DRM_BRIDGE_OP_EDID;
ptn_bridge->bridge.of_node = dev->of_node;
drm_bridge_add(_bridge->bridge);
 
-- 
2.25.1

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


[PATCH v4 10/15] drm/bridge: megachips: get drm_device from bridge

2020-07-26 Thread Sam Ravnborg
Fix so drm_device is read from the bridge.
This is a preparation for the connector being optional.

Signed-off-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index 258e0525cdcc..cf1dfbc88acf 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -226,8 +226,8 @@ static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void 
*dev_id)
  STDP4028_DPTX_IRQ_STS_REG,
  STDP4028_DPTX_IRQ_CLEAR);
 
-   if (ge_b850v3_lvds_ptr->connector.dev)
-   drm_kms_helper_hotplug_event(ge_b850v3_lvds_ptr->connector.dev);
+   if (ge_b850v3_lvds_ptr->bridge.dev)
+   drm_kms_helper_hotplug_event(ge_b850v3_lvds_ptr->bridge.dev);
 
return IRQ_HANDLED;
 }
-- 
2.25.1

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


[PATCH v4 09/15] drm/bridge: megachips: add helper to create connector

2020-07-26 Thread Sam Ravnborg
Factor out connector creation to a small helper function.

Signed-off-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 .../bridge/megachips-stdp-ge-b850v3-fw.c  | 47 +++
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index 6200f12a37e6..258e0525cdcc 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -191,6 +191,32 @@ static const struct drm_connector_funcs 
ge_b850v3_lvds_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
+static int ge_b850v3_lvds_create_connector(struct drm_bridge *bridge)
+{
+   struct drm_connector *connector = _b850v3_lvds_ptr->connector;
+   int ret;
+
+   if (!bridge->encoder) {
+   DRM_ERROR("Parent encoder object not found");
+   return -ENODEV;
+   }
+
+   connector->polled = DRM_CONNECTOR_POLL_HPD;
+
+   drm_connector_helper_add(connector,
+_b850v3_lvds_connector_helper_funcs);
+
+   ret = drm_connector_init(bridge->dev, connector,
+_b850v3_lvds_connector_funcs,
+DRM_MODE_CONNECTOR_DisplayPort);
+   if (ret) {
+   DRM_ERROR("Failed to initialize connector with drm\n");
+   return ret;
+   }
+
+   return drm_connector_attach_encoder(connector, bridge->encoder);
+}
+
 static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void *dev_id)
 {
struct i2c_client *stdp4028_i2c
@@ -209,7 +235,6 @@ static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void 
*dev_id)
 static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
 enum drm_bridge_attach_flags flags)
 {
-   struct drm_connector *connector = _b850v3_lvds_ptr->connector;
struct i2c_client *stdp4028_i2c
= ge_b850v3_lvds_ptr->stdp4028_i2c;
int ret;
@@ -219,25 +244,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
return -EINVAL;
}
 
-   if (!bridge->encoder) {
-   DRM_ERROR("Parent encoder object not found");
-   return -ENODEV;
-   }
-
-   connector->polled = DRM_CONNECTOR_POLL_HPD;
-
-   drm_connector_helper_add(connector,
-_b850v3_lvds_connector_helper_funcs);
-
-   ret = drm_connector_init(bridge->dev, connector,
-_b850v3_lvds_connector_funcs,
-DRM_MODE_CONNECTOR_DisplayPort);
-   if (ret) {
-   DRM_ERROR("Failed to initialize connector with drm\n");
-   return ret;
-   }
-
-   ret = drm_connector_attach_encoder(connector, bridge->encoder);
+   ret = ge_b850v3_lvds_create_connector(bridge);
if (ret)
return ret;
 
-- 
2.25.1

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


[PATCH v4 07/15] drm/bridge: tc358767: add drm_panel_bridge support

2020-07-26 Thread Sam Ravnborg
With the bridge operations implemented the last step to prepare
this driver for a chained setup is the use of the bridge panel driver.

The bridge panel driver is only used when a prot@2 is present in
the DT. So when the display driver request a connector
support both situations:
- connector created by bridge panel driver
- connector created by this driver

And on top, support that the display driver creates the connector,
which is the preferred setup.

Note: the bridge panel will use the connector type from the panel.

v2:
  - Merge connector and drm_panel_bridge patches
and fix so we do not create two connectors (Laurent)

Signed-off-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/tc358767.c | 70 +++
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index d86d7f06bebb..75a2cd792ccc 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -244,8 +244,8 @@ struct tc_data {
struct drm_dp_aux   aux;
 
struct drm_bridge   bridge;
+   struct drm_bridge   *panel_bridge;
struct drm_connectorconnector;
-   struct drm_panel*panel;
 
/* link settings */
struct tc_edp_link  link;
@@ -1234,13 +1234,6 @@ static int tc_stream_disable(struct tc_data *tc)
return 0;
 }
 
-static void tc_bridge_pre_enable(struct drm_bridge *bridge)
-{
-   struct tc_data *tc = bridge_to_tc(bridge);
-
-   drm_panel_prepare(tc->panel);
-}
-
 static void tc_bridge_enable(struct drm_bridge *bridge)
 {
struct tc_data *tc = bridge_to_tc(bridge);
@@ -1264,8 +1257,6 @@ static void tc_bridge_enable(struct drm_bridge *bridge)
tc_main_link_disable(tc);
return;
}
-
-   drm_panel_enable(tc->panel);
 }
 
 static void tc_bridge_disable(struct drm_bridge *bridge)
@@ -1273,8 +1264,6 @@ static void tc_bridge_disable(struct drm_bridge *bridge)
struct tc_data *tc = bridge_to_tc(bridge);
int ret;
 
-   drm_panel_disable(tc->panel);
-
ret = tc_stream_disable(tc);
if (ret < 0)
dev_err(tc->dev, "main link stream stop error: %d\n", ret);
@@ -1284,13 +1273,6 @@ static void tc_bridge_disable(struct drm_bridge *bridge)
dev_err(tc->dev, "main link disable error: %d\n", ret);
 }
 
-static void tc_bridge_post_disable(struct drm_bridge *bridge)
-{
-   struct tc_data *tc = bridge_to_tc(bridge);
-
-   drm_panel_unprepare(tc->panel);
-}
-
 static bool tc_bridge_mode_fixup(struct drm_bridge *bridge,
 const struct drm_display_mode *mode,
 struct drm_display_mode *adj)
@@ -1354,9 +1336,11 @@ static int tc_connector_get_modes(struct drm_connector 
*connector)
return 0;
}
 
-   num_modes = drm_panel_get_modes(tc->panel, connector);
-   if (num_modes > 0)
-   return num_modes;
+   if (tc->panel_bridge) {
+   num_modes = drm_bridge_get_modes(tc->panel_bridge, connector);
+   if (num_modes > 0)
+   return num_modes;
+   }
 
edid = tc_get_edid(>bridge, connector);
num_modes = drm_add_edid_modes(connector, edid);
@@ -1396,7 +1380,7 @@ tc_connector_detect(struct drm_connector *connector, bool 
force)
if (tc->hpd_pin >= 0)
return tc_bridge_detect(>bridge);
else
-   if (tc->panel)
+   if (tc->panel_bridge)
return connector_status_connected;
 
return connector_status_unknown;
@@ -1419,16 +1403,23 @@ static int tc_bridge_attach(struct drm_bridge *bridge,
struct drm_device *drm = bridge->dev;
int ret;
 
-   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
-   DRM_ERROR("Fix bridge driver to make connector optional!");
-   return -EINVAL;
+   if (tc->panel_bridge) {
+   enum drm_bridge_attach_flags panel_flags;
+
+   /* If a connector is required then this driver shall create it 
*/
+   panel_flags = flags & ~DRM_BRIDGE_ATTACH_NO_CONNECTOR;
+   ret = drm_bridge_attach(tc->bridge.encoder, tc->panel_bridge,
+   >bridge, panel_flags);
+   if (ret)
+   return ret;
}
 
+   if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+   return 0;
+
/* Create DP/eDP connector */
drm_connector_helper_add(>connector, _connector_helper_funcs);
-   ret = drm_connector_init(drm, >connector, _connector_funcs,
-tc->panel ? DRM_MODE_CONNECTOR_eDP :
-DRM_MODE_CONNECTOR_DisplayPort);
+   ret = drm_connector_init(drm, >connector, 

[PATCH v4 12/15] drm/bridge: megachips: add get_edid bridge operation

2020-07-26 Thread Sam Ravnborg
To prepare for a chained bridge setup add support for the
get_edid bridge operation.
There is no need for a copy of the edid - so drop
the pointer to the copy.

v2:
  - Fix so we do not leak memory (Laurent)

Signed-off-by: Sam Ravnborg 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 .../bridge/megachips-stdp-ge-b850v3-fw.c  | 31 ++-
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index 450dca33ea48..f7b55dc374ac 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -61,7 +61,6 @@ struct ge_b850v3_lvds {
struct drm_bridge bridge;
struct i2c_client *stdp4028_i2c;
struct i2c_client *stdp2690_i2c;
-   struct edid *edid;
 };
 
 static struct ge_b850v3_lvds *ge_b850v3_lvds_ptr;
@@ -131,22 +130,26 @@ static u8 *stdp2690_get_edid(struct i2c_client *client)
return NULL;
 }
 
-static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
+static struct edid *ge_b850v3_lvds_get_edid(struct drm_bridge *bridge,
+   struct drm_connector *connector)
 {
struct i2c_client *client;
-   int num_modes = 0;
 
client = ge_b850v3_lvds_ptr->stdp2690_i2c;
 
-   kfree(ge_b850v3_lvds_ptr->edid);
-   ge_b850v3_lvds_ptr->edid = (struct edid *)stdp2690_get_edid(client);
+   return (struct edid *)stdp2690_get_edid(client);
+}
 
-   if (ge_b850v3_lvds_ptr->edid) {
-   drm_connector_update_edid_property(connector,
- ge_b850v3_lvds_ptr->edid);
-   num_modes = drm_add_edid_modes(connector,
-  ge_b850v3_lvds_ptr->edid);
-   }
+static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
+{
+   struct edid *edid;
+   int num_modes;
+
+   edid = ge_b850v3_lvds_get_edid(_b850v3_lvds_ptr->bridge, connector);
+
+   drm_connector_update_edid_property(connector, edid);
+   num_modes = drm_add_edid_modes(connector, edid);
+   kfree(edid);
 
return num_modes;
 }
@@ -269,6 +272,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
 static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
.attach = ge_b850v3_lvds_attach,
.detect = ge_b850v3_lvds_bridge_detect,
+   .get_edid = ge_b850v3_lvds_get_edid,
 };
 
 static int ge_b850v3_lvds_init(struct device *dev)
@@ -304,8 +308,6 @@ static void ge_b850v3_lvds_remove(void)
 
drm_bridge_remove(_b850v3_lvds_ptr->bridge);
 
-   kfree(ge_b850v3_lvds_ptr->edid);
-
ge_b850v3_lvds_ptr = NULL;
 out:
mutex_unlock(_b850v3_lvds_dev_mutex);
@@ -323,7 +325,8 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
*stdp4028_i2c,
 
/* drm bridge initialization */
ge_b850v3_lvds_ptr->bridge.funcs = _b850v3_lvds_funcs;
-   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT;
+   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
+DRM_BRIDGE_OP_EDID;
ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
drm_bridge_add(_b850v3_lvds_ptr->bridge);
 
-- 
2.25.1

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


[PATCH v4 06/15] drm/bridge: tc358767: add get_edid bridge operation

2020-07-26 Thread Sam Ravnborg
Prepare for chained bridge with the addition of
get_edid support.

v2:
  - Fixed handling of edid storage (Laurent)

Signed-off-by: Sam Ravnborg 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 drivers/gpu/drm/bridge/tc358767.c | 34 ---
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index e8ba713bedac..d86d7f06bebb 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -250,8 +250,6 @@ struct tc_data {
/* link settings */
struct tc_edp_link  link;
 
-   /* display edid */
-   struct edid *edid;
/* current mode */
struct drm_display_mode mode;
 
@@ -1335,11 +1333,19 @@ static void tc_bridge_mode_set(struct drm_bridge 
*bridge,
tc->mode = *mode;
 }
 
+static struct edid *tc_get_edid(struct drm_bridge *bridge,
+   struct drm_connector *connector)
+{
+   struct tc_data *tc = bridge_to_tc(bridge);
+
+   return drm_get_edid(connector, >aux.ddc);
+}
+
 static int tc_connector_get_modes(struct drm_connector *connector)
 {
struct tc_data *tc = connector_to_tc(connector);
+   int num_modes;
struct edid *edid;
-   int count;
int ret;
 
ret = tc_get_display_props(tc);
@@ -1348,21 +1354,15 @@ static int tc_connector_get_modes(struct drm_connector 
*connector)
return 0;
}
 
-   count = drm_panel_get_modes(tc->panel, connector);
-   if (count > 0)
-   return count;
-
-   edid = drm_get_edid(connector, >aux.ddc);
-
-   kfree(tc->edid);
-   tc->edid = edid;
-   if (!edid)
-   return 0;
+   num_modes = drm_panel_get_modes(tc->panel, connector);
+   if (num_modes > 0)
+   return num_modes;
 
-   drm_connector_update_edid_property(connector, edid);
-   count = drm_add_edid_modes(connector, edid);
+   edid = tc_get_edid(>bridge, connector);
+   num_modes = drm_add_edid_modes(connector, edid);
+   kfree(edid);
 
-   return count;
+   return num_modes;
 }
 
 static const struct drm_connector_helper_funcs tc_connector_helper_funcs = {
@@ -1465,6 +1465,7 @@ static const struct drm_bridge_funcs tc_bridge_funcs = {
.post_disable = tc_bridge_post_disable,
.mode_fixup = tc_bridge_mode_fixup,
.detect = tc_bridge_detect,
+   .get_edid = tc_get_edid,
 };
 
 static bool tc_readable_reg(struct device *dev, unsigned int reg)
@@ -1689,6 +1690,7 @@ static int tc_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
tc->bridge.funcs = _bridge_funcs;
if (tc->hpd_pin >= 0)
tc->bridge.ops |= DRM_BRIDGE_OP_DETECT;
+   tc->bridge.ops |= DRM_BRIDGE_OP_EDID;
 
tc->bridge.of_node = dev->of_node;
drm_bridge_add(>bridge);
-- 
2.25.1

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


Re: [PATCH v3 13/21] drm/bridge: megachips: add helper to create connector

2020-07-26 Thread Sam Ravnborg
On Sat, Jul 11, 2020 at 01:34:30AM +0300, Laurent Pinchart wrote:
> Hi Sam,
> 
> Thank you for the patch.
> 
> On Fri, Jul 03, 2020 at 09:24:09PM +0200, Sam Ravnborg wrote:
> > Factor out connector creation to a small helper function.
> > 
> > Signed-off-by: Sam Ravnborg 
> > Cc: Peter Senna Tschudin 
> > Cc: Martin Donnelly 
> > Cc: Martyn Welch 
> > Cc: Andrzej Hajda 
> > Cc: Neil Armstrong 
> > Cc: Laurent Pinchart 
> > Cc: Jonas Karlman 
> > Cc: Jernej Skrabec 
> > ---
> >  .../bridge/megachips-stdp-ge-b850v3-fw.c  | 47 +++
> >  1 file changed, 27 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
> > b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> > index 6200f12a37e6..258e0525cdcc 100644
> > --- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> > +++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> > @@ -191,6 +191,32 @@ static const struct drm_connector_funcs 
> > ge_b850v3_lvds_connector_funcs = {
> > .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> >  };
> >  
> > +static int ge_b850v3_lvds_create_connector(struct drm_bridge *bridge)
> > +{
> > +   struct drm_connector *connector = _b850v3_lvds_ptr->connector;
> 
> Wow, storing device state in a global variable... :-( How did this go
> past review ?
Took a short look at eliminating this.
But there are two module entries involved so I droppet it again.

> 
> Reviewed-by: Laurent Pinchart 
> 
> > +   int ret;
> > +
> > +   if (!bridge->encoder) {
> > +   DRM_ERROR("Parent encoder object not found");
> > +   return -ENODEV;
> > +   }
> > +
> > +   connector->polled = DRM_CONNECTOR_POLL_HPD;
> > +
> > +   drm_connector_helper_add(connector,
> > +_b850v3_lvds_connector_helper_funcs);
> > +
> > +   ret = drm_connector_init(bridge->dev, connector,
> > +_b850v3_lvds_connector_funcs,
> > +DRM_MODE_CONNECTOR_DisplayPort);
> > +   if (ret) {
> > +   DRM_ERROR("Failed to initialize connector with drm\n");
> > +   return ret;
> > +   }
> > +
> > +   return drm_connector_attach_encoder(connector, bridge->encoder);
> > +}
> > +
> >  static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void *dev_id)
> >  {
> > struct i2c_client *stdp4028_i2c
> > @@ -209,7 +235,6 @@ static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, 
> > void *dev_id)
> >  static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
> >  enum drm_bridge_attach_flags flags)
> >  {
> > -   struct drm_connector *connector = _b850v3_lvds_ptr->connector;
> > struct i2c_client *stdp4028_i2c
> > = ge_b850v3_lvds_ptr->stdp4028_i2c;
> > int ret;
> > @@ -219,25 +244,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge 
> > *bridge,
> > return -EINVAL;
> > }
> >  
> > -   if (!bridge->encoder) {
> > -   DRM_ERROR("Parent encoder object not found");
> > -   return -ENODEV;
> > -   }
> > -
> > -   connector->polled = DRM_CONNECTOR_POLL_HPD;
> > -
> > -   drm_connector_helper_add(connector,
> > -_b850v3_lvds_connector_helper_funcs);
> > -
> > -   ret = drm_connector_init(bridge->dev, connector,
> > -_b850v3_lvds_connector_funcs,
> > -DRM_MODE_CONNECTOR_DisplayPort);
> > -   if (ret) {
> > -   DRM_ERROR("Failed to initialize connector with drm\n");
> > -   return ret;
> > -   }
> > -
> > -   ret = drm_connector_attach_encoder(connector, bridge->encoder);
> > +   ret = ge_b850v3_lvds_create_connector(bridge);
> > if (ret)
> > return ret;
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 207383] [Regression] 5.7 amdgpu/polaris11 gpf: amdgpu_atomic_commit_tail

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=207383

--- Comment #96 from mn...@protonmail.com ---
(In reply to Nicholas Kazlauskas from comment #95)
> Created attachment 290583 [details]
> 0001-drm-amd-display-Force-add-all-CRTCs-to-state-when-us.patch
> 
> So the sequence looks like the following:
> 
> 1. Non-blocking commit #1 requested, checked, swaps state and deferred to
> work queue.
> 
> 2. Non-blocking commit #2 requested, checked, swaps state and deferred to
> work queue.
> 
> Commits #1 and #2 don't touch any of the same core DRM objects (CRTCs,
> Planes, Connectors) so Commit #2 does not stall for Commit #1. DRM Private
> Objects have always been avoided in stall checks, so we have no safety from
> DRM core in this regard.
> 
> 3. Due to system load commit #2 executes first and finishes its commit tail
> work. At the end of commit tail, as part of DRM core, it calls
> drm_atomic_state_put().
> 
> Since this was the pageflip IOCTL we likely already dropped the reference on
> the state held by the IOCTL itself. So it's going to actually free at this
> point.
> 
> This eventually calls drm_atomic_state_clear() which does the following:
> 
> obj->funcs->atomic_destroy_state(obj, state->private_objs[i].state);
> 
> Note that it clears "state" here. Commit sets "state" to the following:
> 
> state->private_objs[i].state = old_obj_state;
> obj->state = new_obj_state;

What line number roughly does that happen on? I can't seem to find that 
anywhere in amdgpu_dm.c

> 
> Since Commit #1 swapped first this means Commit #2 actually does free Commit
> #1's private object.
> 
> 4. Commit #1 then executes and we get a use after free.
> 
> Same bug, it's just this was never corrupted before by the slab changes.
> It's been sitting dormant for 5.0~5.8.
> 
> Attached is a patch that might help resolve this.

I actually just started testing my own patch, but I'll apply your patch
and see if it works though.

My patch is based on how you solved bug 204181 [1] and instead of setting
the new dc_state to the old dc_state, it frees the dm_state and removes
the associated private object.

If I understand correctly, if dm_state is set to NULL (i.e. new state
cannot be found), commit_tail retains the current state and context.
Since dm_state only contains the context (which is unused), I don't see
why freeing the state and clearing the private object beforehand would
be an issue.

I would attach the patch but I'll need to clean up my code first. If the
patch works for the next few hours, I'll clean it up and attach it.

[1] https://patchwork.freedesktop.org/patch/320797/

-- 
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


Re: [PATCH] amdgpu_dm: fix nonblocking atomic commit use-after-free

2020-07-26 Thread Mazin Rezk
On Saturday, July 25, 2020 12:59 AM, Duncan <1i5t5.dun...@cox.net> wrote:

> On Sat, 25 Jul 2020 03:03:52 +
> Mazin Rezk mn...@protonmail.com wrote:
>
> > > Am 24.07.20 um 19:33 schrieb Kees Cook:
> > >
> > > > There was a fix to disable the async path for this driver that
> > > > worked around the bug too, yes? That seems like a safer and more
> > > > focused change that doesn't revert the SLUB defense for all
> > > > users, and would actually provide a complete, I think, workaround
> >
> > That said, I haven't seen the async disabling patch. If you could
> > link to it, I'd be glad to test it out and perhaps we can use that
> > instead.
>
> I'm confused. Not to put words in Kees' mouth; /I/ am confused (which
> admittedly could well be just because I make no claims to be a
> coder and am simply reading the bug and thread, but I'd appreciate some
> "unconfusing" anyway).
>
> My interpretation of the "async disabling" reference was that it was to
> comment #30 on the bug:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=207383#c30
>
> ... which (if I'm not confused on this point too) appears to be yours.
> There it was stated...
>
> > > > >
>
> I've also found that this bug exclusively occurs when commit_work is on
> the workqueue. After forcing drm_atomic_helper_commit to run all of the
> commits without adding to the workqueue and running the OS, the issue
> seems to have disappeared.
> 
>
> Would not forcing all commits to run directly, without placing them on
> the workqueue, be "async disabling"? That's what I /thought/ he was
> referencing.

Oh, I thought he was referring to a different patch. Kees, could I get
your confirmation on this?

The change I made actually affected all of the DRM code, although this could
easily be changed to be specific to amdgpu. (By forcing blocking on
amdgpu_dm's non-blocking commit code)

That said, I'd still need to test further because I only did test it for a
couple of hours then. Although it should work in theory.

>
> OTOH your base/context swap idea sounds like a possibly "less
> disturbance" workaround, if it works, and given the point in the
> commit cycle... (But if it's out Sunday it's likely too late to test
> and get it in now anyway; if it's another week, tho...)

The base/context swap idea should make the use-after-free behave how it
did in 5.6. Since the bug doesn't cause an issue in 5.6, it's less of a
"less disturbance" workaround and more of a "no disturbance" workaround.

Thanks,
Mazin Rezk

>
> 
>
> Duncan - No HTML messages please; they are filtered as spam.
> "Every nonfree program has a lord, a master --
> and if you use the program, he is your master." Richard Stallman


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


Re: [PATCH] amdgpu_dm: fix nonblocking atomic commit use-after-free

2020-07-26 Thread Mazin Rezk
On Thursday, July 23, 2020 6:57 PM, Mazin Rezk  wrote:

> It seems that I spoke too soon. I ran the system for another hour after
> submitting the patch and the bug just occurred. :/
>
> Sadly, that means the bug isn't really fixed and that I have to go
> investigate further.
>
> At the very least, this patch seems to delay the occurrence of the bug
> significantly which may help in further discovering the cause.
>
> On Thursday, July 23, 2020 6:16 PM, Kazlauskas, Nicholas 
> nicholas.kazlaus...@amd.com wrote:
>
> > On 2020-07-23 5:10 p.m., Mazin Rezk wrote:
> >
> > > When amdgpu_dm_atomic_commit_tail is running in the workqueue,
> > > drm_atomic_state_put will get called while amdgpu_dm_atomic_commit_tail is
> > > running, causing a race condition where state (and then dm_state) is
> > > sometimes freed while amdgpu_dm_atomic_commit_tail is running. This bug 
> > > has
> > > occurred since 5.7-rc1 and is well documented among polaris11 users [1].
> > > Prior to 5.7, this was not a noticeable issue since the freelist pointer
> > > was stored at the beginning of dm_state (base), which was unused. After
> > > changing the freelist pointer to be stored in the middle of the struct, 
> > > the
> > > freelist pointer overwrote the context, causing dc_state to become garbage
> > > data and made the call to dm_enable_per_frame_crtc_master_sync dereference
> > > a freelist pointer.
> > > This patch fixes the aforementioned issue by calling drm_atomic_state_get
> > > in amdgpu_dm_atomic_commit before drm_atomic_helper_commit is called and
> > > drm_atomic_state_put after amdgpu_dm_atomic_commit_tail is complete.
> > > According to my testing on 5.8.0-rc6, this should fix bug 207383 on
> > > Bugzilla [1].
> > > [1] https://bugzilla.kernel.org/show_bug.cgi?id=207383
> > > Fixes: 3202fa62f ("slub: relocate freelist pointer to middle of object")
> > > Reported-by: Duncan 1i5t5.dun...@cox.net
> > > Signed-off-by: Mazin Rezk mn...@protonmail.com
> >
> > Thanks for the investigation and your patch. I appreciate the help in
> > trying to narrow down the root cause as this issue has been difficult to
> > reproduce on my setups.
> > Though I'm not sure this really resolves the issue - we make use of the
> > drm_atomic_helper_commit helper function from DRM which internally does
> > what you're doing with this patch:
> > drm_atomic_state_get(state);
> > if (nonblock)
> > queue_work(system_unbound_wq, >commit_work);
> >
> > else
> > commit_tail(state);
> >
> >
> > So even when it gets queued off to the unbound workqueue we still have a
> > reference on the state.
> > That reference gets dropped as part of commit tail helper in DRM as well:
> > if (funcs && funcs->atomic_commit_tail)
> >
> > funcs->atomic_commit_tail(old_state);
> >
> > else
> > drm_atomic_helper_commit_tail(old_state);
> >
> >
> > commit_time_ms = ktime_ms_delta(ktime_get(), start);
> > if (commit_time_ms > 0)
> >
> > drm_self_refresh_helper_update_avg_times(old_state,
> >  (unsigned long)commit_time_ms,
> >  new_self_refresh_mask);
> >
> >
> > drm_atomic_helper_commit_cleanup_done(old_state);
> > drm_atomic_state_put(old_state);
>
> I initially noticed that right after I wrote this patch so I was expecting
> the patch to fail. However, after several hours of testing, the crash just
> didn't occur so I believed the bug was fixed.
>
> > So instead of a use after free happening when we access the state we get
> > a double-free happening later at the end of commit tail in DRM.
> > What I think would be the right next step here is to actually determine
> > what sequence of IOCTLs and atomic commits are happening under your
> > setup with a very verbose dmesg log. You can set a debug level for DRM
> > in your kernel parameters with something like:
> > drm.debug=0x54
> > I don't see anything in amdgpu_dm.c that looks like it would be freeing
> > the state so I suspect something in the core is this doing this.
>
> Going through the KASAN use-after-free bug report in the Bugzilla
> attachments, it appears that the state is being freed at the end of
> commit_tail. Perhaps amdgpu_dm_atomic_commit_tail is being called on the
> the same old state twice? I can't quite think of any other possible
> explanation as to why that happens.

I think I've more or less confirmed that this is the case.

I created two padding variables, one to store debug magic numbers and one
to store the freelist pointer. I had magic numbers for initialised,
preuse, and used states. When the dm_atomic_state is initialised, the
padding is set to the init magic number. Right before commit_tail is
called, the padding is set to the preuse magic number. During
dm_atomic_get_new_state checks the magic number to confirm that it
was in the preuse state and then set it to used. If it failed that check
and it was already in a used state, there was a breakpoint set so 

[PATCH v9 00/12] PCI: brcmstb: enable PCIe for STB chips

2020-07-26 Thread Jim Quinlan


Patchset Summary:
  Enhance a PCIe host controller driver.  Because of its unusual design
  we are foced to change dev->dma_pfn_offset into a more general role
  allowing multiple offsets.  See the 'v1' notes below for more info.

NOTE: ChristophH wanted the dma_set_offset_range() function
  to have a range from [0...~(phys_addr_t)0], i.e. no specific
  bounds.  RobinM requested this function to have specific bounds,
  which has been implemented since v6.  If I do not hear from
  Robin in the near future about this request, I will submit
  v10 which will have no specific bounds.

v9:
  Commit: "device core: Introduce DMA range map, supplanting ..."
  -- A number of code improvements were implemented as suggested by
 ChristophH.  Unfortunately, some of these changes reversed the
 implemented suggestions of other reviewers; for example, the new
 macros PFN_DMA_ADDR(), DMA_ADDR_PFN() have been pulled.

v8:
  Commit: "device core: Introduce DMA range map, supplanting ..."
  -- To satisfy a specific m68 compile configuration, I moved the 'struct
 bus_dma_region; definition out of #ifdef CONFIG_HAS_DMA and also defined
 three inline functions for !CONFIG_HAS_DMA (kernel test robot).
  -- The sunXi drivers -- suc4i_csi, sun6i_csi, cedrus_hw -- set
 a pfn_offset outside of_dma_configure() but the code offers no 
 insight on the size of the translation window.  V7 had me using
 SIZE_MAX as the size.  I have since contacted the sunXi maintainer and
 he said that using a size of SZ_4G would cover sunXi configurations.

v7:
  Commit: "device core: Introduce DMA range map, supplanting ..."
  -- remove second kcalloc/copy in device.c (AndyS)
  -- use PTR_ERR_OR_ZERO() and PHYS_PFN() (AndyS)
  -- indentation, sizeof(struct ...) => sizeof(*r) (AndyS)
  -- add pfn.h definitions: PFN_DMA_ADDR(), DMA_ADDR_PFN() (AndyS)
  -- Fixed compile error in "sun6i_csi.c" (kernel test robot)
  Commit "ata: ahci_brcm: Fix use of BCM7216 reset controller"
  -- correct name of function in the commit msg (SergeiS)
  
v6:
  Commit "device core: Introduce DMA range map":
  -- of_dma_get_range() now takes a single argument and returns either
 NULL, a valid map, or an ERR_PTR. (Robin)
  -- offsets are no longer a PFN value but an actual address. (Robin)
  -- the bus_dma_region struct stores the range size instead of
 the cpu_end and pci_end values. (Robin)
  -- devices that were setting a single offset with no boundaries
 have been modified to have boundaries; in a few places
 where this information was unavilable a /* FIXME: ... */
 comment was added. (Robin)
  -- dma_attach_offset_range() can be called when an offset
 map already exists; if it's range is already present
 nothing is done and success is returned. (Robin)
  All commits:
  -- Man name/style/corrections/etc changed (Bjorn)
  -- rebase to Torvalds master

v5:
  Commit "device core: Introduce multiple dma pfn offsets"
  -- in of/address.c: "map_size = 0" => "*map_size = 0"
  -- use kcalloc instead of kzalloc (AndyS)
  -- use PHYS_ADDR_MAX instead of "~(phys_addr_t)0"
  Commit "PCI: brcmstb: Set internal memory viewport sizes"
  -- now gives error on missing dma-ranges property.
  Commit "dt-bindings: PCI: Add bindings for more Brcmstb chips"
  -- removed "Allof:" from brcm,scb-sizes definition (RobH)
  All Commits:
  -- indentation style, use max chars 100 (AndyS)
  -- rebased to torvalds master

v4:
  Commit "device core: Introduce multiple dma pfn offsets"
  -- of_dma_get_range() does not take a dev param but instead
 takes two "out" params: map and map_size.  We do this so
 that the code that parses dma-ranges is separate from
 the code that modifies 'dev'.   (Nicolas)
  -- the separate case of having a single pfn offset has
 been removed and is now processed by going through the
 map array. (Nicolas)
  -- move attach_uniform_dma_pfn_offset() from of/address.c to
 dma/mapping.c so that it does not depend on CONFIG_OF. (Nicolas)
  -- devm_kcalloc => devm_kzalloc (DanC)
  -- add/fix assignment to dev->dma_pfn_offset_map for func
 attach_uniform_dma_pfn_offset() (DanC, Nicolas)
  -- s/struct dma_pfn_offset_region/struct bus_dma_region/ (Nicolas)
  -- s/attach_uniform_dma_pfn_offset/dma_attach_uniform_pfn_offset/
  -- s/attach_dma_pfn_offset_map/dma_attach_pfn_offset_map/
  -- More use of PFN_{PHYS,DOWN,UP}. (AndyS)
  Commit "of: Include a dev param in of_dma_get_range()"
  -- this commit was sqaushed with "device core: Introduce ..."

v3:
  Commit "device core: Introduce multiple dma pfn offsets"
  Commit "arm: dma-mapping: Invoke dma offset func if needed"
  -- The above two commits have been squashed.  More importantly,
 the code has been modified so that the functionality for
 multiple pfn offsets subsumes the use of dev->dma_pfn_offset.
 In fact, dma_pfn_offset is removed and supplanted by
 dma_pfn_offset_map, which is a pointer to an array.  The

Re: [PATCH] amdgpu_dm: fix nonblocking atomic commit use-after-free

2020-07-26 Thread Mazin Rezk
On Friday, July 24, 2020 5:19 PM, Paul Menzel  wrote:

> Dear Kees,
>
> Am 24.07.20 um 19:33 schrieb Kees Cook:
>
> > On Fri, Jul 24, 2020 at 09:45:18AM +0200, Paul Menzel wrote:
> >
> > > Am 24.07.20 um 00:32 schrieb Kees Cook:
> > >
> > > > On Thu, Jul 23, 2020 at 09:10:15PM +, Mazin Rezk wrote:
> > > > As Linux 5.8-rc7 is going to be released this Sunday, I wonder, if 
> > > > commit
> > > > 3202fa62f ("slub: relocate freelist pointer to middle of object") 
> > > > should be
> > > > reverted for now to fix the regression for the users according to 
> > > > Linux’ no
> > > > regression policy. Once the AMDGPU/DRM driver issue is fixed, it can be
> > > > reapplied. I know it’s not optimal, but as some testing is going to be
> > > > involved for the fix, I’d argue it’s the best option for the users.
> >
> > Well, the SLUB defense was already released in v5.7, so I'm not sure it
> > really helps for amdgpu_dm users seeing it there too.
>
> In my opinion, it would help, as the stable release could pick up the
> revert, ones it’s in Linus’ master branch.
>
> > There was a fix to disable the async path for this driver that worked
> > around the bug too, yes? That seems like a safer and more focused
> > change that doesn't revert the SLUB defense for all users, and would
> > actually provide a complete, I think, workaround whereas reverting
> > the SLUB change means the race still exists. For example, it would be
> > hit with slab poisoning, etc.
>
> I do not know. If there is such a fix, that would be great. But if you
> do not know, how should a normal user? ;-)
>
> Kind regards,
>
> Paul
>
> Kind regards,
>
> Paul

If we're talking about workarounds now, I suggest simply swapping the base
and context variables in struct dm_atomic_state. By that way, we won't need
to change non-amdgpu parts of the code (e.g. by reverting the SLUB patch).

Prior to 3202fa62f, the freelist pointer was stored in dm_state->base which
was never dereferenced and therefore caused no noticeable issue. After
3202fa62f, the freelist pointer is stored in the middle of the struct (i.e.
dm_state->context).

Swapping the position of the base and context variables in dm_atomic_state
should, in theory, revert this code back to it's pre-5.7 state since the
code would be back to overwriting base instead.

If we decide to use this workaround, I can write the patch and do more
extended tests to confirm it works around the issues.

That said, I haven't seen the async disabling patch. If you could link to
it, I'd be glad to test it out and perhaps we can use that instead.

Thanks,
Mazin Rezk

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


[PATCH v9 08/12] device core: Introduce DMA range map, supplanting dma_pfn_offset

2020-07-26 Thread Jim Quinlan
The new field 'dma_range_map' in struct device is used to facilitate the
use of single or multiple offsets between mapping regions of cpu addrs and
dma addrs.  It subsumes the role of "dev->dma_pfn_offset" which was only
capable of holding a single uniform offset and had no region bounds
checking.

The function of_dma_get_range() has been modified so that it takes a single
argument -- the device node -- and returns a map, NULL, or an error code.
The map is an array that holds the information regarding the DMA regions.
Each range entry contains the address offset, the cpu_start address, the
dma_start address, and the size of the region.

of_dma_configure() is the typical manner to set range offsets but there are
a number of ad hoc assignments to "dev->dma_pfn_offset" in the kernel
driver code.  These cases now invoke the function
dma_attach_offset_range(dev, cpu_addr, dma_addr, size).

Signed-off-by: Jim Quinlan 
---
 arch/arm/include/asm/dma-mapping.h| 10 +--
 arch/arm/mach-keystone/keystone.c | 17 +++--
 arch/sh/drivers/pci/pcie-sh7786.c |  9 +--
 arch/sh/kernel/dma-coherent.c | 15 ++--
 arch/x86/pci/sta2x11-fixup.c  |  7 +-
 drivers/acpi/arm64/iort.c |  5 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c |  5 +-
 drivers/iommu/io-pgtable-arm.c|  2 +-
 .../platform/sunxi/sun4i-csi/sun4i_csi.c  |  5 +-
 .../platform/sunxi/sun6i-csi/sun6i_csi.c  |  4 +-
 drivers/of/address.c  | 71 ---
 drivers/of/device.c   | 43 ++-
 drivers/of/of_private.h   | 10 +--
 drivers/of/unittest.c | 32 ++---
 drivers/pci/controller/pcie-brcmstb.c |  1 +
 drivers/remoteproc/remoteproc_core.c  |  2 +-
 .../staging/media/sunxi/cedrus/cedrus_hw.c|  7 +-
 drivers/usb/core/message.c|  4 +-
 drivers/usb/core/usb.c|  2 +-
 include/linux/device.h|  4 +-
 include/linux/dma-direct.h|  8 +--
 include/linux/dma-mapping.h   | 34 +
 kernel/dma/coherent.c | 10 +--
 kernel/dma/mapping.c  | 63 
 24 files changed, 248 insertions(+), 122 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h 
b/arch/arm/include/asm/dma-mapping.h
index bdd80ddbca34..2405afeb7957 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -35,8 +35,11 @@ static inline const struct dma_map_ops 
*get_arch_dma_ops(struct bus_type *bus)
 #ifndef __arch_pfn_to_dma
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
-   if (dev)
-   pfn -= dev->dma_pfn_offset;
+   if (dev) {
+   phys_addr_t paddr = PFN_PHYS(pfn);
+
+   pfn -= (dma_offset_from_phys_addr(dev, paddr) >> PAGE_SHIFT);
+   }
return (dma_addr_t)__pfn_to_bus(pfn);
 }
 
@@ -45,8 +48,7 @@ static inline unsigned long dma_to_pfn(struct device *dev, 
dma_addr_t addr)
unsigned long pfn = __bus_to_pfn(addr);
 
if (dev)
-   pfn += dev->dma_pfn_offset;
-
+   pfn += (dma_offset_from_dma_addr(dev, addr) >> PAGE_SHIFT);
return pfn;
 }
 
diff --git a/arch/arm/mach-keystone/keystone.c 
b/arch/arm/mach-keystone/keystone.c
index 638808c4e122..78808942ad1c 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -8,6 +8,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -24,8 +25,6 @@
 
 #include "keystone.h"
 
-static unsigned long keystone_dma_pfn_offset __read_mostly;
-
 static int keystone_platform_notifier(struct notifier_block *nb,
  unsigned long event, void *data)
 {
@@ -38,9 +37,12 @@ static int keystone_platform_notifier(struct notifier_block 
*nb,
return NOTIFY_BAD;
 
if (!dev->of_node) {
-   dev->dma_pfn_offset = keystone_dma_pfn_offset;
-   dev_err(dev, "set dma_pfn_offset%08lx\n",
-   dev->dma_pfn_offset);
+   int ret = dma_set_offset_range(dev, KEYSTONE_HIGH_PHYS_START,
+  KEYSTONE_LOW_PHYS_START,
+  KEYSTONE_HIGH_PHYS_SIZE);
+   dev_err(dev, "set dma_offset%08llx%s\n",
+   KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START,
+   ret ? " failed" : "");
}
return NOTIFY_OK;
 }
@@ -51,11 +53,8 @@ static struct notifier_block platform_nb = {
 
 static void __init keystone_init(void)
 {
-   if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START) {
-   keystone_dma_pfn_offset = PFN_DOWN(KEYSTONE_HIGH_PHYS_START -
-  KEYSTONE_LOW_PHYS_START);
+   if 

[Bug 207383] [Regression] 5.7 amdgpu/polaris11 gpf: amdgpu_atomic_commit_tail

2020-07-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=207383

--- Comment #95 from Nicholas Kazlauskas (nicholas.kazlaus...@amd.com) ---
Created attachment 290583
  --> https://bugzilla.kernel.org/attachment.cgi?id=290583=edit
0001-drm-amd-display-Force-add-all-CRTCs-to-state-when-us.patch

So the sequence looks like the following:

1. Non-blocking commit #1 requested, checked, swaps state and deferred to work
queue.

2. Non-blocking commit #2 requested, checked, swaps state and deferred to work
queue.

Commits #1 and #2 don't touch any of the same core DRM objects (CRTCs, Planes,
Connectors) so Commit #2 does not stall for Commit #1. DRM Private Objects have
always been avoided in stall checks, so we have no safety from DRM core in this
regard.

3. Due to system load commit #2 executes first and finishes its commit tail
work. At the end of commit tail, as part of DRM core, it calls
drm_atomic_state_put().

Since this was the pageflip IOCTL we likely already dropped the reference on
the state held by the IOCTL itself. So it's going to actually free at this
point.

This eventually calls drm_atomic_state_clear() which does the following:

obj->funcs->atomic_destroy_state(obj, state->private_objs[i].state);

Note that it clears "state" here. Commit sets "state" to the following:

state->private_objs[i].state = old_obj_state;
obj->state = new_obj_state;

Since Commit #1 swapped first this means Commit #2 actually does free Commit
#1's private object.

4. Commit #1 then executes and we get a use after free.

Same bug, it's just this was never corrupted before by the slab changes. It's
been sitting dormant for 5.0~5.8.

Attached is a patch that might help resolve this.

-- 
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


Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-26 Thread Laurent Pinchart
Hi Stefan,

On Fri, Jul 17, 2020 at 05:06:55AM +0300, Laurent Pinchart wrote:
> On Thu, Jul 09, 2020 at 12:25:42PM +0200, Stefan Agner wrote:
> > On 2020-06-16 03:50, Laurent Pinchart wrote:
> >> On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
> >>> On 2020-05-30 05:10, Laurent Pinchart wrote:
>  The DRM simple display pipeline helper only supports a single plane. In
>  order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
>  move away from the helper. No new feature is added.
> 
>  Signed-off-by: Laurent Pinchart 
>  ---
>  Changes since v1:
> 
>  - Move after mxsfb_crtc.c rename to mxsfb_kms.c
>  ---
>   drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
>   drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
>   drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
>   3 files changed, 197 insertions(+), 118 deletions(-)
> 
>  diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  index 204c1e52e9aa..a8da92976d13 100644
>  --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  @@ -10,22 +10,23 @@
> 
>   #include 
>   #include 
>  +#include 
>   #include 
>   #include 
>  +#include 
>   #include 
>  -#include 
> 
>  -#include 
>   #include 
>  -#include 
>  +#include 
>  +#include 
>   #include 
>   #include 
>   #include 
>   #include 
>   #include 
>  +#include 
>   #include 
>   #include 
>  -#include 
>   #include 
> 
>   #include "mxsfb_drv.h"
>  @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
>   },
>   };
> 
>  -static const uint32_t mxsfb_formats[] = {
>  -DRM_FORMAT_XRGB,
>  -DRM_FORMAT_RGB565
>  -};
>  -
>  -static struct mxsfb_drm_private *
>  -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
>  -{
>  -return container_of(pipe, struct mxsfb_drm_private, pipe);
>  -}
>  -
>   void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
>   {
>   if (mxsfb->clk_axi)
>  @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
>  mxsfb_mode_config_helpers = {
>   .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>   };
> 
>  -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
>  -  struct drm_crtc_state *crtc_state,
>  -  struct drm_plane_state *plane_state)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -struct drm_device *drm = pipe->plane.dev;
>  -
>  -pm_runtime_get_sync(drm->dev);
>  -mxsfb_crtc_enable(mxsfb);
>  -}
>  -
>  -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -struct drm_device *drm = pipe->plane.dev;
>  -struct drm_crtc *crtc = >crtc;
>  -struct drm_pending_vblank_event *event;
>  -
>  -mxsfb_crtc_disable(mxsfb);
>  -pm_runtime_put_sync(drm->dev);
>  -
>  -spin_lock_irq(>event_lock);
>  -event = crtc->state->event;
>  -if (event) {
>  -crtc->state->event = NULL;
>  -drm_crtc_send_vblank_event(crtc, event);
>  -}
>  -spin_unlock_irq(>event_lock);
>  -}
>  -
>  -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
>  -  struct drm_plane_state *plane_state)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -mxsfb_plane_atomic_update(mxsfb, plane_state);
>  -}
>  -
>  -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe 
>  *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -/* Clear and enable VBLANK IRQ */
>  -mxsfb_enable_axi_clk(mxsfb);
>  -writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + 
>  REG_CLR);
>  -writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + 
>  REG_SET);
>  -mxsfb_disable_axi_clk(mxsfb);
>  -
>  -return 0;
>  -}
>  -
>  -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe 
>  *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -/* Disable and clear VBLANK IRQ */
>  -mxsfb_enable_axi_clk(mxsfb);
>  -   

Re: [PATCH] drm/mcde: Fix stability issue

2020-07-26 Thread Stephan Gerhold
On Sun, Jul 19, 2020 at 01:33:22AM +0200, Linus Walleij wrote:
> Whenener a display update was sent, apart from updating
> the memory base address we called mcde_display_send_one_frame()
> which also sent a command to the display requesting the TE IRQ
> and enabling the FIFO.
> 
> When continous updates are running this is wrong: we need
> to only send this to start the flow to the display on
> the very first update. This lead to the display pipeline
> locking up and crashing.
> 
> Check if the flow is already running and in that case
> do not call mcde_display_send_one_frame().
> 
> This fixes crashes on the Samsung GT-S7710 (Skomer).
> 
> Cc: Stephan Gerhold 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Linus Walleij 
> ---
>  drivers/gpu/drm/mcde/mcde_display.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mcde/mcde_display.c 
> b/drivers/gpu/drm/mcde/mcde_display.c
> index 212aee60cf61..1d8ea8830a17 100644
> --- a/drivers/gpu/drm/mcde/mcde_display.c
> +++ b/drivers/gpu/drm/mcde/mcde_display.c
> @@ -1086,9 +1086,14 @@ static void mcde_display_update(struct 
> drm_simple_display_pipe *pipe,
>*/
>   if (fb) {
>   mcde_set_extsrc(mcde, drm_fb_cma_get_gem_addr(fb, pstate, 0));
> - if (!mcde->video_mode)
> - /* Send a single frame using software sync */
> - mcde_display_send_one_frame(mcde);
> + if (!mcde->video_mode) {
> + /*
> +  * Send a single frame using software sync if the flow
> +  * is not active yet.
> +  */
> + if (mcde->flow_active == 0)
> + mcde_display_send_one_frame(mcde);
> + }

I think this makes sense as a fix for the issue you described, so FWIW:
Acked-by: Stephan Gerhold 

While looking at this I had a few thoughts for potential future patches:

 - Clearly mcde_display_send_one_frame() does not only send a single
   frame only in some cases (when te_sync = true), so maybe it should
   be named differently?

 - I was a bit confused because with this change we also call
   mcde_dsi_te_request() only once. Looking at the vendor driver the
   nova_dsilink_te_request() function that is very similar is only
   called within mcde_add_bta_te_oneshot_listener(), which is only
   called for MCDE_SYNCSRC_BTA.

   However, the rest of the MCDE code looks more similar to
   MCDE_SYNCSRC_TE0, which does not call that function in the vendor
   driver. I wonder if mcde_dsi_te_request() is needed at all?

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


Re: [PATCH v7 3/3] drm: bridge: cdns-mhdp: Add j721e wrapper

2020-07-26 Thread Sam Ravnborg
Hi Swapnil

Small nits in the following.

Sam

On Wed, Jul 22, 2020 at 09:40:40AM +0200, Swapnil Jakhade wrote:
> Add j721e wrapper for mhdp, which sets up the clock and data muxes.
> 
> Signed-off-by: Jyri Sarha 
> Signed-off-by: Yuti Amonkar 
> Signed-off-by: Swapnil Jakhade 
> Reviewed-by: Tomi Valkeinen 
> Reviewed-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/bridge/Kconfig   | 13 
>  drivers/gpu/drm/bridge/Makefile  |  5 ++
>  drivers/gpu/drm/bridge/cdns-mhdp-core.c  | 15 +
>  drivers/gpu/drm/bridge/cdns-mhdp-core.h  |  1 +
>  drivers/gpu/drm/bridge/cdns-mhdp-j721e.c | 75 
>  drivers/gpu/drm/bridge/cdns-mhdp-j721e.h | 19 ++
>  6 files changed, 128 insertions(+)
>  create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-j721e.c
>  create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-j721e.h
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index 6a4c324302a8..8c1738653b7e 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -38,6 +38,19 @@ config DRM_CDNS_MHDP
> It takes a DPI stream as input and outputs it encoded
> in DP format.
>  
> +if DRM_CDNS_MHDP
> +
> +config DRM_CDNS_MHDP_J721E
> + depends on ARCH_K3_J721E_SOC
> + bool "J721E Cadence DPI/DP wrapper support"
> + default y
> + help
> +   Support J721E Cadence DPI/DP wrapper. This is a wrapper
> +   which adds support for J721E related platform ops. It
> +   initializes the J721e Display Port and sets up the
> +   clock and data muxes.
> +endif
> +
>  config DRM_CHRONTEL_CH7033
>   tristate "Chrontel CH7033 Video Encoder"
>   depends on OF
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index 0080a9f80f29..f81d606e9598 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -2,6 +2,11 @@
>  obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o
>  obj-$(CONFIG_DRM_CDNS_MHDP) += cdns-mhdp.o
>  cdns-mhdp-objs := cdns-mhdp-core.o
> +
> +ifeq ($(CONFIG_DRM_CDNS_MHDP_J721E),y)
> + cdns-mhdp-objs += cdns-mhdp-j721e.o
> +endif

Use the idiomatic:
cdns-mhdp-$(CONFIG_DRM_CDNS_MHDP_J721E) += cdns-mhdp-j721e.o


> +
>  obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o
>  obj-$(CONFIG_DRM_DISPLAY_CONNECTOR) += display-connector.o
>  obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o
> diff --git a/drivers/gpu/drm/bridge/cdns-mhdp-core.c 
> b/drivers/gpu/drm/bridge/cdns-mhdp-core.c
> index b16c5503cef1..eeb33c54334f 100644
> --- a/drivers/gpu/drm/bridge/cdns-mhdp-core.c
> +++ b/drivers/gpu/drm/bridge/cdns-mhdp-core.c
> @@ -38,6 +38,8 @@
>  
>  #include "cdns-mhdp-core.h"
>  
> +#include "cdns-mhdp-j721e.h"
> +
>  static DECLARE_WAIT_QUEUE_HEAD(fw_load_wq);
>  
>  static int cdns_mhdp_mailbox_read(struct cdns_mhdp_device *mhdp)
> @@ -1691,6 +1693,16 @@ static int cdns_mhdp_attach(struct drm_bridge *bridge,
>  
>   conn->display_info.bus_flags = DRM_BUS_FLAG_DE_HIGH;
>  
> + if (of_device_is_compatible(mhdp->dev->of_node, "ti,j721e-mhdp8546"))
> + /*
> +  * DP is internal to J7 SoC and we need to use DRIVE_POSEDGE
> +  * in the display controller. This is achieved for the time being
> +  * by defining SAMPLE_NEGEDGE here.
> +  */
> + conn->display_info.bus_flags |=
> + DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
> + DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE;
> +
>   ret = drm_connector_attach_encoder(conn, bridge->encoder);
>   if (ret) {
>   dev_err(mhdp->dev, "failed to attach connector to encoder\n");
> @@ -2470,6 +2482,9 @@ static int cdns_mhdp_remove(struct platform_device 
> *pdev)
>  
>  static const struct of_device_id mhdp_ids[] = {
>   { .compatible = "cdns,mhdp8546", },
> +#ifdef CONFIG_DRM_CDNS_MHDP_J721E
> + { .compatible = "ti,j721e-mhdp8546", .data = _ti_j721e_ops },
> +#endif
>   { /* sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, mhdp_ids);
> diff --git a/drivers/gpu/drm/bridge/cdns-mhdp-core.h 
> b/drivers/gpu/drm/bridge/cdns-mhdp-core.h
> index d1bfcdef4249..4e176698caca 100644
> --- a/drivers/gpu/drm/bridge/cdns-mhdp-core.h
> +++ b/drivers/gpu/drm/bridge/cdns-mhdp-core.h
> @@ -343,6 +343,7 @@ struct cdns_mhdp_bridge_state {
>  
>  struct cdns_mhdp_device {
>   void __iomem *regs;
> + void __iomem *j721e_regs;
>  
>   struct device *dev;
>   struct clk *clk;
> diff --git a/drivers/gpu/drm/bridge/cdns-mhdp-j721e.c 
> b/drivers/gpu/drm/bridge/cdns-mhdp-j721e.c
> new file mode 100644
> index ..7555c217c9a0
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/cdns-mhdp-j721e.c
> @@ -0,0 +1,75 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * TI j721e Cadence MHDP DP wrapper
> + *
> + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
> + * Author: Jyri Sarha  + */
> +
> +#include 
> +#include 
> +
> +#include "cdns-mhdp-j721e.h"
> 

Re: [PATCH v7 2/3] drm: bridge: Add support for Cadence MHDP DPI/DP bridge

2020-07-26 Thread Sam Ravnborg
Hi Swapnil

Thanks for submitting this driver.

A few highlevel things.

New bridge drivers shall be prepare for use in a chained
bridge driver setup.
This prompts you to add the following:
- Reelvant bridge operations
I noticed at least get_edid, and detect seems applicable.
- Support the flags argument and only create the connector if requested
  to do so.

Take a look at other bridge drivers that set DRM_BRIDGE_OP_EDID and
DRM_BRIDGE_OP_DETECT for examples.

A few notes follows but I did not look at the full driver.

Sam

On Wed, Jul 22, 2020 at 09:40:39AM +0200, Swapnil Jakhade wrote:
> Add a new DRM bridge driver for Cadence MHDP DPTX IP used in TI J721e SoC.
> MHDP DPTX IP is the component that complies with VESA DisplayPort (DP) and
> embedded Display Port (eDP) standards. It integrates uCPU running the
> embedded Firmware (FW) interfaced over APB interface.
> 
> Basically, it takes a DPI stream as input and outputs it encoded in DP
> format. Currently, it supports only SST mode.
> 
> Co-developed-by: Tomi Valkeinen 
> Signed-off-by: Tomi Valkeinen 
> Co-developed-by: Jyri Sarha 
> Signed-off-by: Jyri Sarha 
> Signed-off-by: Quentin Schulz 
> Signed-off-by: Yuti Amonkar 
> Signed-off-by: Swapnil Jakhade 
> ---
>  drivers/gpu/drm/bridge/Kconfig  |   11 +
>  drivers/gpu/drm/bridge/Makefile |2 +
>  drivers/gpu/drm/bridge/cdns-mhdp-core.c | 2493 +++
>  drivers/gpu/drm/bridge/cdns-mhdp-core.h |  396 
>  4 files changed, 2902 insertions(+)
>  create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-core.c
>  create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-core.h
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index 43271c21d3fc..6a4c324302a8 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -27,6 +27,17 @@ config DRM_CDNS_DSI
> Support Cadence DPI to DSI bridge. This is an internal
> bridge and is meant to be directly embedded in a SoC.
>  
> +config DRM_CDNS_MHDP
> + tristate "Cadence DPI/DP bridge"
> + select DRM_KMS_HELPER
> + select DRM_PANEL_BRIDGE
> + depends on OF
> + help
> +   Support Cadence DPI to DP bridge. This is an internal
> +   bridge and is meant to be directly embedded in a SoC.
> +   It takes a DPI stream as input and outputs it encoded
> +   in DP format.
> +
>  config DRM_CHRONTEL_CH7033
>   tristate "Chrontel CH7033 Video Encoder"
>   depends on OF
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index d63d4b7e4347..0080a9f80f29 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -1,5 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o
> +obj-$(CONFIG_DRM_CDNS_MHDP) += cdns-mhdp.o
> +cdns-mhdp-objs := cdns-mhdp-core.o
As the bridge driver is a sinlge file there is no need for the extra
indirection.
If you plan to add extra files later use:
cdns-mhdp-y := cdns-mhdp-core.o

The "-y" syntax is recommended today.

>  obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o
>  obj-$(CONFIG_DRM_DISPLAY_CONNECTOR) += display-connector.o
>  obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o
> diff --git a/drivers/gpu/drm/bridge/cdns-mhdp-core.c 
> b/drivers/gpu/drm/bridge/cdns-mhdp-core.c
> new file mode 100644
> index ..b16c5503cef1
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/cdns-mhdp-core.c
> @@ -0,0 +1,2493 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Cadence MHDP DP bridge driver.
> + *
> + * Copyright: 2019 Cadence Design Systems, Inc.
2020?

> + *
> + * Author: Quentin Schulz 
Does not match changelog description - several more authors are listed.


> +++ b/drivers/gpu/drm/bridge/cdns-mhdp-core.h
> @@ -0,0 +1,396 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Cadence MHDP DP bridge driver.
> + *
> + * Copyright: 2019 Cadence Design Systems, Inc.
> + *
> + * Author: Quentin Schulz 
> + * Swapnil Jakhade 
> + */
> +
> +#ifndef CDNS_MHDP_CORE_H
> +#define CDNS_MHDP_CORE_H
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +struct clk;
> +struct device;
> +struct phy;
> +
> +/* Register offsets */
> +#define CDNS_APB_CTRL0x0
> +#define CDNS_CPU_STALL   BIT(3)
> +
> +#define CDNS_MAILBOX_FULL0x8
> +#define CDNS_MAILBOX_EMPTY   0xc
> +#define CDNS_MAILBOX_TX_DATA 0x00010
> +#define CDNS_MAILBOX_RX_DATA 0x00014
> +#define CDNS_KEEP_ALIVE  0x00018
> +#define CDNS_KEEP_ALIVE_MASK GENMASK(7, 0)
> +
> +#define CDNS_VER_L   0x0001C
> +#define CDNS_VER_H   0x00020
> +#define CDNS_LIB_L_ADDR  0x00024
> +#define CDNS_LIB_H_ADDR  0x00028
> +

Re: [PATCH v7 1/3] dt-bindings: drm/bridge: Document Cadence MHDP bridge bindings

2020-07-26 Thread Sam Ravnborg
Hi Swapnil.

On Wed, Jul 22, 2020 at 09:40:38AM +0200, Swapnil Jakhade wrote:
> From: Yuti Amonkar 
> 
> Document the bindings used for the Cadence MHDP DPI/DP bridge in
> yaml format.
> 
> Signed-off-by: Yuti Amonkar 
> Signed-off-by: Swapnil Jakhade 
> Reviewed-by: Rob Herring 
> Reviewed-by: Laurent Pinchart 
> ---
>  .../bindings/display/bridge/cdns,mhdp.yaml| 127 ++
>  1 file changed, 127 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/bridge/cdns,mhdp.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/bridge/cdns,mhdp.yaml 
> b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp.yaml
> new file mode 100644
> index ..cdf5760d4ec5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp.yaml
> @@ -0,0 +1,127 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/display/bridge/cdns,mhdp.yaml#;
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
> +
> +title: Cadence MHDP bridge
> +
> +maintainers:
> +  - Swapnil Jakhade 
> +  - Yuti Amonkar 
> +
> +properties:
> +  compatible:
> +enum:
> +  - cdns,mhdp8546
> +  - ti,j721e-mhdp8546
> +
> +  reg:
> +minItems: 1
> +maxItems: 2
> +items:
> +  - description:
> +  Register block of mhdptx apb registers up to PHY mapped area 
> (AUX_CONFIG_P).
> +  The AUX and PMA registers are not part of this range, they are 
> instead
> +  included in the associated PHY.
> +  - description:
> +  Register block for DSS_EDP0_INTG_CFG_VP registers in case of TI J7 
> SoCs.
> +
> +  reg-names:
> +minItems: 1
> +maxItems: 2
> +items:
> +  - const: mhdptx
> +  - const: j721e-intg
> +
> +  clocks:
> +maxItems: 1
> +description:
> +  DP bridge clock, used by the IP to know how to translate a number of
> +  clock cycles into a time (which is used to comply with DP standard 
> timings
> +  and delays).
> +
> +  phys:
> +description:
> +  phandle to the DisplayPort PHY.
> +
> +  ports:
> +type: object
> +description:
> +  Ports as described in Documentation/devicetree/bindings/graph.txt.
> +
> +properties:
> +  '#address-cells':
> +const: 1
> +
> +  '#size-cells':
> +const: 0
> +
> +  port@0:
> +type: object
> +description:
> +  Input port representing the DP bridge input.
> +
> +  port@1:
> +type: object
> +description:
> +  Output port representing the DP bridge output.
> +
> +required:
> +  - port@0
> +  - port@1
> +  - '#address-cells'
> +  - '#size-cells'
> +
> +allOf:
> +  - if:
> +  properties:
> +compatible:
> +  contains:
> +const: ti,j721e-mhdp8546
> +then:
> +  properties:
> +reg:
> +  minItems: 2
> +reg-names:
> +  minItems: 2
> +
> +required:
> +  - compatible
> +  - clocks
> +  - reg
> +  - reg-names
> +  - phys
> +  - ports
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +mhdp: dp-bridge@f0fb00 {
> +compatible = "cdns,mhdp8546";
> +reg = <0xf0 0xfb00 0x0 0x100>;
> +reg-names = "mhdptx";
> +clocks = <_clock>;
> +phys = <_phy>;
> +
> +ports {

Please be consistent in indent.
We do not aling below '{'.
Keep using 4 spaces for indent for the full example.

Sam

> +  #address-cells = <1>;
> +  #size-cells = <0>;
> +
> +  port@0 {
> + reg = <0>;
> + dp_bridge_input: endpoint {
> +remote-endpoint = <_dpi_output>;
> + };
> +  };
> +
> +  port@1 {
> + reg = <1>;
> + dp_bridge_output: endpoint {
> +remote-endpoint = <_dp_connector_input>;
> + };
> +  };
> +};
> +};
> +...
> -- 
> 2.26.1
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] drm/fourcc: fix Amlogic Video Framebuffer Compression macro

2020-07-26 Thread Sam Ravnborg
Hi Neil.

On Thu, Jul 23, 2020 at 11:05:50AM +0200, Neil Armstrong wrote:
> Fix the Amlogic Video Framebuffer Compression modifier macro to
> correctly add the layout options, a pair of parenthesis was missing.
> 
> Fixes: d6528ec88309 ("drm/fourcc: Add modifier definitions for describing 
> Amlogic Video Framebuffer Compression")
> Signed-off-by: Neil Armstrong 
Looks correct just looking at the patch below.
Acked-by: Sam Ravnborg 

I assume you will apply the patch.

Sam

> ---
>  include/uapi/drm/drm_fourcc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> index 4bee7de5f306..82f327801267 100644
> --- a/include/uapi/drm/drm_fourcc.h
> +++ b/include/uapi/drm/drm_fourcc.h
> @@ -1004,7 +1004,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 
> modifier)
>  #define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \
>   fourcc_mod_code(AMLOGIC, \
>   ((__layout) & __fourcc_mod_amlogic_layout_mask) | \
> - ((__options) & __fourcc_mod_amlogic_options_mask \
> + (((__options) & __fourcc_mod_amlogic_options_mask) \
><< __fourcc_mod_amlogic_options_shift))
>  
>  /* Amlogic FBC Layouts */
> -- 
> 2.22.0
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] video: fbdev: added driver for sharp memory lcd displays

2020-07-26 Thread Sam Ravnborg
Hi Rodrigo.

On Fri, Jul 24, 2020 at 05:34:04PM -0300, Rodrigo Alencar wrote:
> The supported displays are ls027b7dh01 (tested), ls044q7dh01,
> ls013b7dh05, ls013b7dh03
> 
> Signed-off-by: Rodrigo Alencar <455.rodrigo.alen...@gmail.com>

Thanks for submitting this driver.
Unfortunately I have some bad news for you...

The binding needs to be submitted as a seperate patch, and all new
bindings must use the DT schema format (.yaml files).
See Documentation/devicetree/bindings/*.rst for more info.

And on top of this fbdev/ is in maintenance mode so no new drivers.
New display drivers and panel drivers must go to gpu/drm/
and use the frameworks available there.

It looks like what we have here is a panel driver.
Look for other similar sharp panels in drm/panel/ to get an idea how to
add support for these new panels.

Soory, but looks forward for an updated patch.

Sam


> ---
>  .../devicetree/bindings/display/smemlcdfb.txt |  46 ++
>  drivers/video/fbdev/Kconfig   |  14 +
>  drivers/video/fbdev/Makefile  |   1 +
>  drivers/video/fbdev/smemlcdfb.c   | 485 ++
>  4 files changed, 546 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/smemlcdfb.txt
>  create mode 100644 drivers/video/fbdev/smemlcdfb.c
> 
> diff --git a/Documentation/devicetree/bindings/display/smemlcdfb.txt 
> b/Documentation/devicetree/bindings/display/smemlcdfb.txt
> new file mode 100644
> index ..e33025dd3374
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/smemlcdfb.txt
> @@ -0,0 +1,46 @@
> +Sharp Memory LCD Linux Framebuffer Driver
> +
> +Required properties:
> +  - compatible: It should be "sharp,". The supported displays are 
> + ls027b7dh01, ls044q7dh01, ls013b7dh05, ls013b7dh03. Maybe other 
> + monochromatic models can be supported with the current code.
> +  - reg: SPI chip select number for the device.
> +  - spi-max-frequency: Max SPI frequency to use. One must verify the 
> datasheet.
> +  - spi-cs-high: Sharp Memory LCD needs chipselect high.
> +
> +Optional properties:
> +  - sharp,frames-per-sec: It should contain the desired frames per second.
> + It does not represent the actual frame rate. Default: 10
> +  - sharp,extmode-high: External COM Input signal is expected in EXTCOMIN 
> port.
> + This is recommended to reduce CPU and SPI Load.
> +  - pwm: If property "sharp,extmode-high" is specified, this is recommended.
> + It should contain the pwm to use, according to
> + Documentation/devicetree/bindings/pwm/pwm.txt
> + Verify the display datasheet for the EXTCOMIN signal period
> +  - disp-gpios: The GPIO used to enable the display, if available. See
> + Documentation/devicetree/bindings/gpio/gpio.txt for details.
> +
> +Examples:
> +
> +ls027b7dh01: smemlcd@0 {
> +compatible = "sharp,ls027b7dh01";
> +reg = <0>;
> +spi-max-frequency = <100>;
> +spi-cs-high;
> +disp-gpios = < 7>;
> +disp-active-high;
> +sharp,extmode-high;
> +pwms = < 0 1>;
> +};
> +
> +ls013b7dh05: smemlcd@3 {
> +compatible = "sharp,ls013b7dh05";
> +reg = <3>;
> +spi-max-frequency = <100>;
> +spi-cs-high;
> +disp-gpios = < 13>;
> +disp-active-high;
> +sharp,extmode-high;
> +pwms = < 0 5000>;
> +sharp,frames-per-sec = <20>;
> +};
> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
> index b2c9dd4f0cb5..0fff47a59d8b 100644
> --- a/drivers/video/fbdev/Kconfig
> +++ b/drivers/video/fbdev/Kconfig
> @@ -2221,6 +2221,20 @@ config FB_SSD1307
> This driver implements support for the Solomon SSD1307
> OLED controller over I2C.
>  
> +config FB_SMEMLCD
> + tristate "Sharp Memory LCD framebuffer support"
> + depends on FB && SPI
> + depends on OF
> + depends on GPIOLIB || COMPILE_TEST
> + select FB_SYS_FOPS
> + select FB_SYS_FILLRECT
> + select FB_SYS_COPYAREA
> + select FB_SYS_IMAGEBLIT
> + select FB_DEFERRED_IO
> + select PWM
> + help
> +   This driver implements support for the Sharp Memory LCD
> +
>  config FB_SM712
>   tristate "Silicon Motion SM712 framebuffer support"
>   depends on FB && PCI
> diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile
> index cad4fb64442a..5c58dfd8ac08 100644
> --- a/drivers/video/fbdev/Makefile
> +++ b/drivers/video/fbdev/Makefile
> @@ -128,6 +128,7 @@ obj-$(CONFIG_FB_OF)   += offb.o
>  obj-$(CONFIG_FB_MX3)   += mx3fb.o
>  obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o
>  obj-$(CONFIG_FB_SSD1307)   += ssd1307fb.o
> +obj-$(CONFIG_FB_SMEMLCD)  += smemlcdfb.o
>  obj-$(CONFIG_FB_SIMPLE)   += simplefb.o
>  
>  # the test framebuffer is last
> diff --git a/drivers/video/fbdev/smemlcdfb.c b/drivers/video/fbdev/smemlcdfb.c
> new file mode 

Re: [PATCH] drm: of: Fix double-free bug

2020-07-26 Thread Sam Ravnborg
Hi Biju

On Thu, Jul 23, 2020 at 12:10:54PM +0100, Biju Das wrote:
> Fix double-free bug in the error path.
> 
> Fixes: 6529007522de ("drm: of: Add drm_of_lvds_get_dual_link_pixel_order")
> Reported-by: Pavel Machek 
> Signed-off-by: Biju Das 
> Cc: sta...@vger.kernel.org

Thanks, applied to drm-misc-fixes.

Sam

> ---
> This patch is tested against drm-fixes and drm-next.
> ---
>  drivers/gpu/drm/drm_of.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index fdb05fb..ca04c34 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -331,10 +331,8 @@ static int drm_of_lvds_get_remote_pixels_type(
>* configurations by passing the endpoints explicitly to
>* drm_of_lvds_get_dual_link_pixel_order().
>*/
> - if (!current_pt || pixels_type != current_pt) {
> - of_node_put(remote_port);
> + if (!current_pt || pixels_type != current_pt)
>   return -EINVAL;
> - }
>   }
>  
>   return pixels_type;
> -- 
> 2.7.4
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v10 08/13] drm/msm: Add a context pointer to the submitqueue

2020-07-26 Thread Rob Clark
On Mon, Jul 20, 2020 at 8:41 AM Jordan Crouse  wrote:
>
> Each submitqueue is attached to a context. Add a pointer to the
> context to the submitqueue at create time and refcount it so
> that it stays around through the life of the queue.
>
> GPU submissions can access the active context via the submitqueue
> instead of requiring it to be passed around from function to
> function.
>
> Signed-off-by: Jordan Crouse 
> ---
>
>  drivers/gpu/drm/msm/adreno/a5xx_gpu.c   | 12 +---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c   |  5 ++---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c |  5 ++---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.h |  3 +--
>  drivers/gpu/drm/msm/msm_drv.c   |  3 ++-
>  drivers/gpu/drm/msm/msm_drv.h   |  8 
>  drivers/gpu/drm/msm/msm_gem.h   |  1 +
>  drivers/gpu/drm/msm/msm_gem_submit.c|  8 
>  drivers/gpu/drm/msm/msm_gpu.c   |  9 -
>  drivers/gpu/drm/msm/msm_gpu.h   |  7 +++
>  drivers/gpu/drm/msm/msm_submitqueue.c   |  8 +++-
>  11 files changed, 39 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> index 9e63a190642c..eff2439ea57b 100644
> --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> @@ -43,8 +43,7 @@ static void a5xx_flush(struct msm_gpu *gpu, struct 
> msm_ringbuffer *ring)
> gpu_write(gpu, REG_A5XX_CP_RB_WPTR, wptr);
>  }
>
> -static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct msm_gem_submit 
> *submit,
> -   struct msm_file_private *ctx)
> +static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct msm_gem_submit 
> *submit)
>  {
> struct msm_drm_private *priv = gpu->dev->dev_private;
> struct msm_ringbuffer *ring = submit->ring;
> @@ -57,7 +56,7 @@ static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct 
> msm_gem_submit *submit
> case MSM_SUBMIT_CMD_IB_TARGET_BUF:
> break;
> case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
> -   if (priv->lastctx == ctx)
> +   if (priv->lastctx == submit->queue->ctx)
> break;
> /* fall-thru */
> case MSM_SUBMIT_CMD_BUF:
> @@ -103,8 +102,7 @@ static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct 
> msm_gem_submit *submit
> msm_gpu_retire(gpu);
>  }
>
> -static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
> -   struct msm_file_private *ctx)
> +static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
>  {
> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);
> @@ -114,7 +112,7 @@ static void a5xx_submit(struct msm_gpu *gpu, struct 
> msm_gem_submit *submit,
>
> if (IS_ENABLED(CONFIG_DRM_MSM_GPU_SUDO) && submit->in_rb) {
> priv->lastctx = NULL;
> -   a5xx_submit_in_rb(gpu, submit, ctx);
> +   a5xx_submit_in_rb(gpu, submit);
> return;
> }
>
> @@ -148,7 +146,7 @@ static void a5xx_submit(struct msm_gpu *gpu, struct 
> msm_gem_submit *submit,
> case MSM_SUBMIT_CMD_IB_TARGET_BUF:
> break;
> case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
> -   if (priv->lastctx == ctx)
> +   if (priv->lastctx == submit->queue->ctx)
> break;
> /* fall-thru */
> case MSM_SUBMIT_CMD_BUF:
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index c5a3e4d4c007..5eabb0109577 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -81,8 +81,7 @@ static void get_stats_counter(struct msm_ringbuffer *ring, 
> u32 counter,
> OUT_RING(ring, upper_32_bits(iova));
>  }
>
> -static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
> -   struct msm_file_private *ctx)
> +static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
>  {
> unsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT;
> struct msm_drm_private *priv = gpu->dev->dev_private;
> @@ -115,7 +114,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct 
> msm_gem_submit *submit,
> case MSM_SUBMIT_CMD_IB_TARGET_BUF:
> break;
> case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
> -   if (priv->lastctx == ctx)
> +   if (priv->lastctx == submit->queue->ctx)
> break;
> /* fall-thru */
> case MSM_SUBMIT_CMD_BUF:
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
> b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index e23641a5ec84..b38a8126541a 100644
> --- 

Re: [PATCH] drm/bridge/adv7511: set the bridge type properly

2020-07-26 Thread Sam Ravnborg
On Mon, Jul 20, 2020 at 03:42:27PM +0300, Laurentiu Palcu wrote:
> From: Laurentiu Palcu 
> 
> After the drm_bridge_connector_init() helper function has been added, the ADV
> driver has been changed accordingly. However, the 'type' field of the bridge
> structure was left unset, which makes the helper function always return 
> -EINVAL.
> 
> Signed-off-by: Laurentiu Palcu 

Thanks, applied to drm-misc-fixes.

Sam

> ---
> Hi,
> 
> I've hit this while trying to use this helper in the new i.MX8MQ DCSS
> driver, as suggested by Sam, and I wanted to test it with NWL MIPI_DSI and
> ADV since support is already in mainline.
> 
> Thanks,
> laurentiu
> 
> 
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index f45cdca9cce5..a0d392c338da 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -1283,6 +1283,7 @@ static int adv7511_probe(struct i2c_client *i2c, const 
> struct i2c_device_id *id)
>   adv7511->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
>   | DRM_BRIDGE_OP_HPD;
>   adv7511->bridge.of_node = dev->of_node;
> + adv7511->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
>  
>   drm_bridge_add(>bridge);
>  
> -- 
> 2.23.0
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/mcde: Fix stability issue

2020-07-26 Thread Sam Ravnborg
Hi Linus.

On Sun, Jul 19, 2020 at 01:33:22AM +0200, Linus Walleij wrote:
> Whenener a display update was sent, apart from updating
s/Whenener/Whenever
> the memory base address we called mcde_display_send_one_frame()
 ^ insert comma?

> which also sent a command to the display requesting the TE IRQ
> and enabling the FIFO.
> 
> When continous updates are running this is wrong: we need
> to only send this to start the flow to the display on
> the very first update. This lead to the display pipeline
> locking up and crashing.
> 
> Check if the flow is already running and in that case
> do not call mcde_display_send_one_frame().
> 
> This fixes crashes on the Samsung GT-S7710 (Skomer).
> 
> Cc: Stephan Gerhold 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Linus Walleij 
Patch looks fine.
Acked-by: Sam Ravnborg 

> ---
>  drivers/gpu/drm/mcde/mcde_display.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mcde/mcde_display.c 
> b/drivers/gpu/drm/mcde/mcde_display.c
> index 212aee60cf61..1d8ea8830a17 100644
> --- a/drivers/gpu/drm/mcde/mcde_display.c
> +++ b/drivers/gpu/drm/mcde/mcde_display.c
> @@ -1086,9 +1086,14 @@ static void mcde_display_update(struct 
> drm_simple_display_pipe *pipe,
>*/
>   if (fb) {
>   mcde_set_extsrc(mcde, drm_fb_cma_get_gem_addr(fb, pstate, 0));
> - if (!mcde->video_mode)
> - /* Send a single frame using software sync */
> - mcde_display_send_one_frame(mcde);
> + if (!mcde->video_mode) {
> + /*
> +  * Send a single frame using software sync if the flow
> +  * is not active yet.
> +  */
> + if (mcde->flow_active == 0)
> + mcde_display_send_one_frame(mcde);
> + }
>   dev_info_once(mcde->dev, "sent first display update\n");
>   } else {
>   /*
> -- 
> 2.26.2
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v1 0/1] drm/bridge: nwl-dsi: Drop DRM_BRIDGE_ATTACH_NO_CONNECTOR check.

2020-07-26 Thread Sam Ravnborg
Hi Guido.

On Sat, Jul 18, 2020 at 08:26:36PM +0200, Guido Günther wrote:
> 
> We don't create a connector but let panel_bridge handle that so there's
> no point in rejecting DRM_BRIDGE_ATTACH_NO_CONNECTOR.
> 
> This was prompted by Sam in
> https://lore.kernel.org/dri-devel/20200718115734.ga2989...@ravnborg.org/
> 
> Signed-off-by: Guido Günther 

Now applied to drm-misc-fixes.

Sam

> 
> Guido Günther (1):
>   drm/bridge: nwl-dsi: Drop DRM_BRIDGE_ATTACH_NO_CONNECTOR check.
> 
>  drivers/gpu/drm/bridge/nwl-dsi.c | 5 -
>  1 file changed, 5 deletions(-)
> 
> -- 
> 2.26.2
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: panel: simple: Delay HPD checking on boe_nv133fhm_n61 for 15 ms

2020-07-26 Thread Sam Ravnborg
On Thu, Jul 16, 2020 at 01:21:22PM -0700, Douglas Anderson wrote:
> On boe_nv133fhm_n62 (and presumably on boe_nv133fhm_n61) a scope shows
> a small spike on the HPD line right when you power the panel on.  The
> picture looks something like this:
> 
>  +--
>  |
>  |
>  |
> Power ---+
>+---
>|
>   ++   |
>  ++|   |
> HPD -+ +---+
> 
> So right when power is applied there's a little bump in HPD and then
> there's small spike right before it goes low.  The total time of the
> little bump plus the spike was measured on one panel as being 8 ms
> long.  The total time for the HPD to go high on the same panel was
> 51.2 ms, though the datasheet only promises it is < 200 ms.
> 
> When asked about this glitch, BOE indicated that it was expected and
> persisted until the TCON has been initialized.
> 
> If this was a real hotpluggable DP panel then this wouldn't matter a
> whole lot.  We'd debounce the HPD signal for a really long time and so
> the little blip wouldn't hurt.  However, this is not a hotpluggable DP
> panel and the the debouncing logic isn't needed and just shows down
> the time needed to get the display working.  This is why the code in
> panel_simple_prepare() doesn't do debouncing and just waits for HPD to
> go high once.  Unfortunately if we get unlucky and happen to poll the
> HPD line right at the spike we can try talking to the panel before
> it's ready.
> 
> Let's handle this situation by putting in a 15 ms prepare delay and
> decreasing the "hpd absent delay" by 15 ms.  That means:
> * If you don't have HPD hooked up at all you've still got the
>   hardcoded 200 ms delay.
> * If you've got HPD hooked up you will always wait at least 15 ms
>   before checking HPD.  The only case where this could be bad is if
>   the panel is sharing a voltage rail with something else in the
>   system and was already turned on long before the panel came up.  In
>   such a case we'll be delaying 15 ms for no reason, but it's not a
>   huge delay and I don't see any other good solution to handle that
>   case.
> 
> Even though the delay was measured as 8 ms, 15 ms was chosen to give a
> bit of margin.
> 
> Signed-off-by: Douglas Anderson 

Nice drawing and good explanation.
Applied to drm-misc-fixes.

Sam

> ---
> I don't actually have a device in front of me that is exhibiting these
> problems.  I believe that it is only some devices and some of the
> time.  Still, this patch seems safe and seems likely to fix the issue
> given the scope shots.
> 
>  drivers/gpu/drm/panel/panel-simple.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-simple.c 
> b/drivers/gpu/drm/panel/panel-simple.c
> index 88493538a147..046a06b55800 100644
> --- a/drivers/gpu/drm/panel/panel-simple.c
> +++ b/drivers/gpu/drm/panel/panel-simple.c
> @@ -1260,7 +1260,21 @@ static const struct panel_desc boe_nv133fhm_n61 = {
>   .height = 165,
>   },
>   .delay = {
> - .hpd_absent_delay = 200,
> + /*
> +  * When power is first given to the panel there's a short
> +  * spike on the HPD line.  It was explained that this spike
> +  * was until the TCON data download was complete.  On
> +  * one system this was measured at 8 ms.  We'll put 15 ms
> +  * in the prepare delay just to be safe and take it away
> +  * from the hpd_absent_delay (which would otherwise be 200 ms)
> +  * to handle this.  That means:
> +  * - If HPD isn't hooked up you still have 200 ms delay.
> +  * - If HPD is hooked up we won't try to look at it for the
> +  *   first 15 ms.
> +  */
> + .prepare = 15,
> + .hpd_absent_delay = 185,
> +
>   .unprepare = 500,
>   },
>   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
> -- 
> 2.28.0.rc0.105.gf9edc3c819-goog
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/panel: Fix auo, kd101n80-45na horizontal noise on edges of panel

2020-07-26 Thread Sam Ravnborg
On Tue, Jul 14, 2020 at 08:33:32PM +0800, Jitao Shi wrote:
> Fine tune the HBP and HFP to avoid the dot noise on the left and right edges.
> 
> Signed-off-by: Jitao Shi 
> ---
>  drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c 
> b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> index 48a164257d18..3edb33e61908 100644
> --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> @@ -615,9 +615,9 @@ static const struct panel_desc boe_tv101wum_nl6_desc = {
>  static const struct drm_display_mode auo_kd101n80_45na_default_mode = {
>   .clock = 157000,
>   .hdisplay = 1200,
> - .hsync_start = 1200 + 80,
> - .hsync_end = 1200 + 80 + 24,
> - .htotal = 1200 + 80 + 24 + 36,
> + .hsync_start = 1200 + 60,
> + .hsync_end = 1200 + 60 + 24,
> + .htotal = 1200 + 60 + 24 + 56,
>   .vdisplay = 1920,
>   .vsync_start = 1920 + 16,
>   .vsync_end = 1920 + 16 + 4,

Applied to drm-misc-fixes.

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


Re: [PATCH] drm/ttm: fix pipelined gutting for evictions v2

2020-07-26 Thread Sierra Guiza, Alejandro (Alex)


On 7/24/2020 10:01 AM, Felix Kuehling wrote:

Am 2020-07-24 um 7:56 a.m. schrieb Christian König:

We can't pipeline that during eviction because the memory needs
to be available immediately.

v2: fix how we cleanup the BOs resources

Signed-off-by: Christian König 

Reviewed-by: Felix Kuehling 

It would be good to get a Tested-by from Alex as well.

Thanks,
   Felix


Tested-by: Alex Sierra 

Regards,

Alex Sierra




---
  drivers/gpu/drm/ttm/ttm_bo.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 0768a054a916..469aa93ea317 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -652,8 +652,12 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
placement.num_busy_placement = 0;
bdev->driver->evict_flags(bo, );
  
-	if (!placement.num_placement && !placement.num_busy_placement)

-   return ttm_bo_pipeline_gutting(bo);
+   if (!placement.num_placement && !placement.num_busy_placement) {
+   ttm_bo_wait(bo, false, false);
+
+   ttm_bo_cleanup_memtype_use(bo);
+   return 0;
+   }
  
  	evict_mem = bo->mem;

evict_mem.mm_node = NULL;

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


Re: [PATCH v6 0/3] Add LT9611 DSI to HDMI bridge

2020-07-26 Thread Sam Ravnborg
Hi Vinod.

On Thu, Jul 23, 2020 at 10:04:39PM +0530, Vinod Koul wrote:
> Hi,
> 
> This series adds driver and bindings for Lontium LT9611 bridge chip which
> takes MIPI DSI as input and HDMI as output.
> 
> This chip can be found in 96boards RB3 platform [1] commonly called DB845c.
> 
> [1]: https://www.96boards.org/product/rb3-platform/
> 
> Changes in v6:
>  - Drop msm/dsi patch as we need to get more bridges fixed before we add that
>  - Bring back support for DRM_BRIDGE_ATTACH_NO_CONNECTOR not set, now driver
>   supports both
>  - Fix nits found by Sam
> 
> Changes in v5:
>  - make symbol static, reported by kbuild-bot
> 
> Changes in v4:
>  - Add msm/dsi patch to create connector and support 
> DRM_BRIDGE_ATTACH_NO_CONNECTOR
>  - Fix comments provided by Sam
> 
> Changes in v3:
>  - fix kbuild reported error
>  - rebase on v5.8-rc1
> 
> Changes in v2:
>  - Add acks by Rob
>  - Fix comments reported by Emil and rename the file to lontium-lt9611.c
>  - Fix comments reported by Laurent on binding and driver
>  - Add HDMI audio support
> 
> Vinod Koul (3):
>   dt-bindings: vendor-prefixes: Add Lontium vendor prefix
>   dt-bindings: display: bridge: Add documentation for LT9611
>   drm/bridge: Introduce LT9611 DSI to HDMI bridge

Fixed prototype for lt9611_bridge_mode_valid() and applied the
series to drm-misc-next.

Sam

> 
>  .../display/bridge/lontium,lt9611.yaml|  176 +++
>  .../devicetree/bindings/vendor-prefixes.yaml  |2 +
>  drivers/gpu/drm/bridge/Kconfig|   13 +
>  drivers/gpu/drm/bridge/Makefile   |1 +
>  drivers/gpu/drm/bridge/lontium-lt9611.c   | 1229 +
>  5 files changed, 1421 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/bridge/lontium,lt9611.yaml
>  create mode 100644 drivers/gpu/drm/bridge/lontium-lt9611.c
> 
> -- 
> 2.26.2
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/9] drivers: usb: dwc3-qcom: Add sdm660 compatible

2020-07-26 Thread Konrad Dybcio
Signed-off-by: Konrad Dybcio 
---
 Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 1 +
 drivers/usb/dwc3/dwc3-qcom.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml 
b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
index dac10848dd7f..c5280d6406ec 100644
--- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
+++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
@@ -16,6 +16,7 @@ properties:
   - qcom,msm8996-dwc3
   - qcom,msm8998-dwc3
   - qcom,sc7180-dwc3
+  - qcom,sdm660-dwc3
   - qcom,sdm845-dwc3
   - const: qcom,dwc3
 
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 1dfd024cd06b..d6b3e1bb550a 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -753,6 +753,7 @@ static const struct of_device_id dwc3_qcom_of_match[] = {
{ .compatible = "qcom,dwc3" },
{ .compatible = "qcom,msm8996-dwc3" },
{ .compatible = "qcom,msm8998-dwc3" },
+   { .compatible = "qcom,sdm660-dwc3" },
{ .compatible = "qcom,sdm845-dwc3" },
{ }
 };
-- 
2.27.0

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


[PATCH 2/9] phy: qcom-qusb2: Add support for SDM630/660

2020-07-26 Thread Konrad Dybcio
QUSB on these SoCs actually uses *almost* the same
configuration that msm8996 does, so we can reuse
the phy_cfg from there with just a single change
(se clock scheme).

Signed-off-by: Konrad Dybcio 
---
 Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml | 1 +
 drivers/phy/qualcomm/phy-qcom-qusb2.c | 7 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml
index b5a6195de7ff..e61a3ca3deba 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml
@@ -20,6 +20,7 @@ properties:
 - enum:
   - qcom,msm8996-qusb2-phy
   - qcom,msm8998-qusb2-phy
+  - qcom,sdm660-qusb2-phy
   - items:
 - enum:
   - qcom,sc7180-qusb2-phy
diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c 
b/drivers/phy/qualcomm/phy-qcom-qusb2.c
index 393011a05b48..11852ebe9e49 100644
--- a/drivers/phy/qualcomm/phy-qcom-qusb2.c
+++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c
@@ -702,7 +702,8 @@ static int qusb2_phy_init(struct phy *phy)
usleep_range(150, 160);
 
/* Default is single-ended clock on msm8996 */
-   qphy->has_se_clk_scheme = true;
+   if (!of_device_is_compatible(phy->dev.of_node, "qcom,sdm660-qusb2-phy"))
+   qphy->has_se_clk_scheme = true;
/*
 * read TCSR_PHY_CLK_SCHEME register to check if single-ended
 * clock scheme is selected. If yes, then disable differential
@@ -815,6 +816,10 @@ static const struct of_device_id 
qusb2_phy_of_match_table[] = {
}, {
.compatible = "qcom,msm8998-qusb2-phy",
.data   = _phy_cfg,
+   }, {
+   .compatible = "qcom,sdm660-qusb2-phy",
+   /* sdm630/660 use the same config as msm8996. */
+   .data   = _phy_cfg,
}, {
/*
 * Deprecated. Only here to support legacy device
-- 
2.27.0

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


Re: [PATCH v2 0/5] drm: rockchip: various ports for older VOPs

2020-07-26 Thread Alex Bee



Am 22.07.20 um 23:43 schrieb Daniel Vetter:

On Wed, Jul 22, 2020 at 8:13 PM Alex Bee  wrote:

Hi,

this series mainly ports existining functionality to older SoCs - most
importantly enables alpha blending for RK3036, RK3066, RK3126 and
RK3188.
Besides that, it also changes the window type from DRM_PLANE_TYPE_CURSOR
to DRM_PLANE_TYPE_OVERLAY for VOPs that have only one (1) overlay window.

This doesn't make much sense, the cursor overlay is really just a hint
for legacy ioctls that this is the overlay that should be used for
cursors. Compositors should try to use such planes as full overlays
(if they don't want to use them as a cursor). So sounds like a case of
"fix your compositor".
I agree here - but: If HWC windows would have been implemented in this 
particular driver, their max size would be 128x128 on some SoCs - so 
they woudn't be really suitable to create an OSD overlay at 4K, for 
example. I don't know, but I guess other vendors implement their HWC 
windows on this reduced HW resources as well. I guess that is one of the 
reasons, why userspace, which aims to be cross-plattfrom, avoids 
DRM_PLANE_TYPE_CURSOR when its looking for an usable overlay plane. (a 
heuristic, indeed)

For atomic there's 0 difference between a overlay or a cursor (primary
plane is still treated somewhat special in the RMFB ioctl, but again
that's for backwards compat reasons with existing uapi, not because
the primary plane is different).

What does happen though is that this breaks cursor for legacy
userspace, which is probably not really what you want.


Indeed not.

Beforhand I was submiiting this, I looked arround and couldn't find 
anything which relies or even depends of a cursor window to be 
available. Even if: as per spec only one DRM_PLANE_TYPE_PRIMARY is 
mandatory, everything else is optional.



-Daniel



Regards,
Alex

Changes in v2:
- drop not yet upstreamed dsp_data_swap from RK3188 regs
- rephrase most commit messages

Alex Bee (5):
   drm: rockchip: add scaling for RK3036 win1
   drm: rockchip: add missing registers for RK3188
   drm: rockchip: add alpha support for RK3036, RK3066, RK3126 and RK3188
   drm: rockchip: set alpha_en to 0 if it is not used
   drm: rockchip: use overlay windows as such

  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  1 +
  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 42 ++---
  drivers/gpu/drm/rockchip/rockchip_vop_reg.h |  1 +
  3 files changed, 38 insertions(+), 6 deletions(-)

--
2.17.1



--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


Best Regards

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


Re: [PATCH] amdgpu_dm: fix nonblocking atomic commit use-after-free

2020-07-26 Thread Duncan
On Sat, 25 Jul 2020 03:03:52 +
Mazin Rezk  wrote:

> > Am 24.07.20 um 19:33 schrieb Kees Cook:
> >  
> > > There was a fix to disable the async path for this driver that
> > > worked around the bug too, yes? That seems like a safer and more
> > > focused change that doesn't revert the SLUB defense for all
> > > users, and would actually provide a complete, I think, workaround
> 
> That said, I haven't seen the async disabling patch. If you could
> link to it, I'd be glad to test it out and perhaps we can use that
> instead.

I'm confused.  Not to put words in Kees' mouth; /I/ am confused (which
admittedly could well be just because I make no claims to be a
coder and am simply reading the bug and thread, but I'd appreciate some
"unconfusing" anyway).

My interpretation of the "async disabling" reference was that it was to
comment #30 on the bug:

https://bugzilla.kernel.org/show_bug.cgi?id=207383#c30

... which (if I'm not confused on this point too) appears to be yours.
There it was stated...


I've also found that this bug exclusively occurs when commit_work is on
the workqueue. After forcing drm_atomic_helper_commit to run all of the
commits without adding to the workqueue and running the OS, the issue
seems to have disappeared.


Would not forcing all commits to run directly, without placing them on
the workqueue, be "async disabling"?  That's what I /thought/ he was
referencing.

OTOH your base/context swap idea sounds like a possibly "less
disturbance" workaround, if it works, and given the point in the
commit cycle... (But if it's out Sunday it's likely too late to test
and get it in now anyway; if it's another week, tho...)

-- 
Duncan - No HTML messages please; they are filtered as spam.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/9] drm/msm/mdp5: Add MDP5 configuration for SDM630

2020-07-26 Thread Konrad Dybcio
This commit adds support for the MDP5 IP on Snapdragon
630. The configuration is different from SDM660's, as
the latter one has two DSI outputs.

Signed-off-by: Konrad Dybcio 
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c | 93 
 1 file changed, 93 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
index 25a13a2a57a9..2e02de8a7e41 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
@@ -910,6 +910,98 @@ static const struct mdp5_cfg_hw msm8998_config = {
.max_clk = 41250,
 };
 
+static const struct mdp5_cfg_hw sdm630_config = {
+   .name = "sdm630",
+   .mdp = {
+   .count = 1,
+   .caps = MDP_CAP_CDM |
+   MDP_CAP_SRC_SPLIT |
+   0,
+   },
+   .ctl = {
+   .count = 5,
+   .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
+   .flush_hw_mask = 0xf4ff,
+   },
+   .pipe_vig = {
+   .count = 1,
+   .base = { 0x04000 },
+   .caps = MDP_PIPE_CAP_HFLIP  |
+   MDP_PIPE_CAP_VFLIP  |
+   MDP_PIPE_CAP_SCALE  |
+   MDP_PIPE_CAP_CSC|
+   MDP_PIPE_CAP_DECIMATION |
+   MDP_PIPE_CAP_SW_PIX_EXT |
+   0,
+   },
+   .pipe_rgb = {
+   .count = 4,
+   .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
+   .caps = MDP_PIPE_CAP_HFLIP  |
+   MDP_PIPE_CAP_VFLIP  |
+   MDP_PIPE_CAP_SCALE  |
+   MDP_PIPE_CAP_DECIMATION |
+   MDP_PIPE_CAP_SW_PIX_EXT |
+   0,
+   },
+   .pipe_dma = {
+   .count = 2, /* driver supports max of 2 currently */
+   .base = { 0x24000, 0x26000, 0x28000 },
+   .caps = MDP_PIPE_CAP_HFLIP  |
+   MDP_PIPE_CAP_VFLIP  |
+   MDP_PIPE_CAP_SW_PIX_EXT |
+   0,
+   },
+   .pipe_cursor = {
+   .count = 1,
+   .base = { 0x34000 },
+   .caps = MDP_PIPE_CAP_HFLIP  |
+   MDP_PIPE_CAP_VFLIP  |
+   MDP_PIPE_CAP_SW_PIX_EXT |
+   MDP_PIPE_CAP_CURSOR |
+   0,
+   },
+
+   .lm = {
+   .count = 2,
+   .base = { 0x44000, 0x46000 },
+   .instances = {
+   { .id = 0, .pp = 0, .dspp = 0,
+ .caps = MDP_LM_CAP_DISPLAY |
+ MDP_LM_CAP_PAIR, },
+   { .id = 1, .pp = 1, .dspp = -1,
+ .caps = MDP_LM_CAP_WB, },
+   },
+   .nb_stages = 8,
+   .max_width = 2048,
+   .max_height = 0x,
+   },
+   .dspp = {
+   .count = 1,
+   .base = { 0x54000 },
+   },
+   .ad = {
+   .count = 2,
+   .base = { 0x78000, 0x78800 },
+   },
+   .pp = {
+   .count = 3,
+   .base = { 0x7, 0x71000, 0x72000 },
+   },
+   .cdm = {
+   .count = 1,
+   .base = { 0x79200 },
+   },
+   .intf = {
+   .base = { 0x6a000, 0x6a800 },
+   .connect = {
+   [0] = INTF_DISABLED,
+   [1] = INTF_DSI,
+   },
+   },
+   .max_clk = 41250,
+};
+
 static const struct mdp5_cfg_handler cfg_handlers_v1[] = {
{ .revision = 0, .config = { .hw = _config } },
{ .revision = 2, .config = { .hw = _config } },
@@ -924,6 +1016,7 @@ static const struct mdp5_cfg_handler cfg_handlers_v1[] = {
 
 static const struct mdp5_cfg_handler cfg_handlers_v3[] = {
{ .revision = 0, .config = { .hw = _config } },
+   { .revision = 3, .config = { .hw = _config } },
 };
 
 static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);
-- 
2.27.0

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


[PATCH 6/9] drm/msm/dsi: Add DSI configuration for SDM660

2020-07-26 Thread Konrad Dybcio
This also applies to sdm630/636 and their SDA
counterparts.

Signed-off-by: Konrad Dybcio 
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.c | 21 +
 drivers/gpu/drm/msm/dsi/dsi_cfg.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c 
b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 813d69deb5e8..f892f2cbe8bb 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -149,6 +149,25 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
.num_dsi = 2,
 };
 
+static const char * const dsi_sdm660_bus_clk_names[] = {
+   "iface", "bus", "core", "core_mmss",
+};
+
+static const struct msm_dsi_config sdm660_dsi_cfg = {
+   .io_offset = DSI_6G_REG_SHIFT,
+   .reg_cfg = {
+   .num = 2,
+   .regs = {
+   {"vdd", 73400, 32 },/* 0.9 V */
+   {"vdda", 12560, 4 },/* 1.2 V */
+   },
+   },
+   .bus_clk_names = dsi_sdm660_bus_clk_names,
+   .num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
+   .io_start = { 0xc994000, 0xc996000 },
+   .num_dsi = 2,
+};
+
 static const char * const dsi_sdm845_bus_clk_names[] = {
"iface", "bus",
 };
@@ -240,6 +259,8 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] 
= {
_dsi_cfg, _dsi_6g_host_ops},
{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_4_2,
_dsi_cfg, _dsi_6g_host_ops},
+   {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_1_0,
+   _dsi_cfg, _dsi_6g_v2_host_ops},
{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_0,
_dsi_cfg, _dsi_6g_v2_host_ops},
{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_1,
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h 
b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index 217e24a65178..efd469d1db45 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -18,6 +18,7 @@
 #define MSM_DSI_6G_VER_MINOR_V1_3_10x10030001
 #define MSM_DSI_6G_VER_MINOR_V1_4_10x10040001
 #define MSM_DSI_6G_VER_MINOR_V1_4_20x10040002
+#define MSM_DSI_6G_VER_MINOR_V2_1_00x2001
 #define MSM_DSI_6G_VER_MINOR_V2_2_00x2000
 #define MSM_DSI_6G_VER_MINOR_V2_2_10x20020001
 #define MSM_DSI_6G_VER_MINOR_V2_4_10x20040001
-- 
2.27.0

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


[PATCH 1/3] dt-bindings: Add vendor prefix for Powertip

2020-07-26 Thread Marek Vasut
The Powertip Tech. Corp. is an LCD panel manufacturer.

Signed-off-by: Marek Vasut 
To: dri-devel@lists.freedesktop.org
Cc: Eric Anholt 
Cc: Rob Herring 
Cc: Sam Ravnborg 
Cc: devicet...@vger.kernel.org
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 30d2232ccc0f..0f8894e54878 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -826,6 +826,8 @@ patternProperties:
 description: Poslab Technology Co., Ltd.
   "^pov,.*":
 description: Point of View International B.V.
+  "^powertip,.*":
+description: Powertip Tech. Corp.
   "^powervr,.*":
 description: PowerVR (deprecated, use img)
   "^primux,.*":
-- 
2.27.0

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


[PATCH 2/3] dt-bindings: Add DT bindings for Powertip PH800480T013

2020-07-26 Thread Marek Vasut
Add DT bindings for Powertip PH800480T013 800x480 parallel LCD,
this one is used in the Raspberry Pi 7" touchscreen display unit.

Signed-off-by: Marek Vasut 
To: dri-devel@lists.freedesktop.org
Cc: Eric Anholt 
Cc: Rob Herring 
Cc: Sam Ravnborg 
Cc: devicet...@vger.kernel.org
---
 .../panel/powertip,ph800480t013-idf02.yaml| 28 +++
 1 file changed, 28 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/powertip,ph800480t013-idf02.yaml

diff --git 
a/Documentation/devicetree/bindings/display/panel/powertip,ph800480t013-idf02.yaml
 
b/Documentation/devicetree/bindings/display/panel/powertip,ph800480t013-idf02.yaml
new file mode 100644
index ..8a2a4f79f365
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/display/panel/powertip,ph800480t013-idf02.yaml
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/powertip,ph800480t013-idf02#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: POWERTIP PH800480T013-IDF2 7.0" WVGA TFT LCD panel
+
+maintainers:
+  - Marek Vasut 
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: powertip,ph800480t013-idf02
+
+  power-supply: true
+  backlight: true
+  port: true
+
+additionalProperties: false
+
+required:
+  - compatible
+
+...
-- 
2.27.0

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


[PATCH 8/9] clk: qcom: gcc-sdm660: Fix up gcc_mss_mnoc_bimc_axi_clk

2020-07-26 Thread Konrad Dybcio
Add missing halt_check, hwcg_reg and hwcg_bit properties.
These were likely omitted when porting the driver upstream.

Signed-off-by: Konrad Dybcio 
---
 drivers/clk/qcom/gcc-sdm660.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/qcom/gcc-sdm660.c b/drivers/clk/qcom/gcc-sdm660.c
index a85283786278..f0b47b7d50ca 100644
--- a/drivers/clk/qcom/gcc-sdm660.c
+++ b/drivers/clk/qcom/gcc-sdm660.c
@@ -1715,6 +1715,9 @@ static struct clk_branch gcc_mss_cfg_ahb_clk = {
 
 static struct clk_branch gcc_mss_mnoc_bimc_axi_clk = {
.halt_reg = 0x8a004,
+   .halt_check = BRANCH_HALT,
+   .hwcg_reg = 0x8a004,
+   .hwcg_bit = 1,
.clkr = {
.enable_reg = 0x8a004,
.enable_mask = BIT(0),
-- 
2.27.0

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


Re: [v7, PATCH 2/7] mtk-mmsys: add mmsys private data

2020-07-26 Thread Yongqiang Niu
On Sat, 2020-07-25 at 10:11 +0800, Chun-Kuang Hu wrote:
> Hi, Yongqiang:
> 
> Yongqiang Niu  於 2020年7月23日 週四 上午10:05寫道:
> >
> > add mmsys private data
> >
> > Feature: drm/mediatek
> > Signed-off-by: Yongqiang Niu 
> > ---
> >  drivers/soc/mediatek/Makefile |   1 +
> >  drivers/soc/mediatek/mmsys/Makefile   |   2 +
> >  drivers/soc/mediatek/mmsys/mt2701-mmsys.c | 250 +++
> >  drivers/soc/mediatek/mtk-mmsys.c  | 271 
> > +-
> >  include/linux/soc/mediatek/mtk-mmsys.h|  15 ++
> >  5 files changed, 314 insertions(+), 225 deletions(-)
> >  create mode 100644 drivers/soc/mediatek/mmsys/Makefile
> >  create mode 100644 drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> >
> > diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
> > index 2afa7b9..b37ac2c 100644
> > --- a/drivers/soc/mediatek/Makefile
> > +++ b/drivers/soc/mediatek/Makefile
> > @@ -3,3 +3,4 @@ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
> >  obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
> >  obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
> >  obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > +obj-$(CONFIG_MTK_MMSYS) += mmsys/
> > diff --git a/drivers/soc/mediatek/mmsys/Makefile 
> > b/drivers/soc/mediatek/mmsys/Makefile
> > new file mode 100644
> > index 000..33b0dab
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/Makefile
> > @@ -0,0 +1,2 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +obj-y += mt2701-mmsys.o
> > diff --git a/drivers/soc/mediatek/mmsys/mt2701-mmsys.c 
> > b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> > new file mode 100644
> > index 000..b8e53b0
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> > @@ -0,0 +1,250 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// Copyright (c) 2020 MediaTek Inc.
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define DISP_REG_CONFIG_DISP_OVL0_MOUT_EN  0x040
> > +#define DISP_REG_CONFIG_DISP_OVL1_MOUT_EN  0x044
> > +#define DISP_REG_CONFIG_DISP_OD_MOUT_EN0x048
> > +#define DISP_REG_CONFIG_DISP_GAMMA_MOUT_EN 0x04c
> > +#define DISP_REG_CONFIG_DISP_UFOE_MOUT_EN  0x050
> > +#define DISP_REG_CONFIG_DISP_COLOR0_SEL_IN 0x084
> > +#define DISP_REG_CONFIG_DISP_COLOR1_SEL_IN 0x088
> > +#define DISP_REG_CONFIG_DSIE_SEL_IN0x0a4
> > +#define DISP_REG_CONFIG_DSIO_SEL_IN0x0a8
> > +#define DISP_REG_CONFIG_DPI_SEL_IN 0x0ac
> > +#define DISP_REG_CONFIG_DISP_RDMA2_SOUT0x0b8
> > +#define DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN 0x0c4
> > +#define DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN 0x0c8
> > +#define DISP_REG_CONFIG_MMSYS_CG_CON0  0x100
> > +
> > +#define DISP_REG_CONFIG_DISP_OVL_MOUT_EN   0x030
> > +#define DISP_REG_CONFIG_OUT_SEL0x04c
> > +#define DISP_REG_CONFIG_DSI_SEL0x050
> > +#define DISP_REG_CONFIG_DPI_SEL0x064
> > +
> > +#define OVL0_MOUT_EN_COLOR00x1
> > +#define OD_MOUT_EN_RDMA0   0x1
> > +#define OD1_MOUT_EN_RDMA1  BIT(16)
> > +#define UFOE_MOUT_EN_DSI0  0x1
> > +#define COLOR0_SEL_IN_OVL0 0x1
> > +#define OVL1_MOUT_EN_COLOR10x1
> > +#define GAMMA_MOUT_EN_RDMA10x1
> > +#define RDMA0_SOUT_DPI00x2
> > +#define RDMA0_SOUT_DPI10x3
> > +#define RDMA0_SOUT_DSI10x1
> > +#define RDMA0_SOUT_DSI20x4
> > +#define RDMA0_SOUT_DSI30x5
> > +#define RDMA1_SOUT_DPI00x2
> > +#define RDMA1_SOUT_DPI10x3
> > +#define RDMA1_SOUT_DSI10x1
> > +#define RDMA1_SOUT_DSI20x4
> > +#define RDMA1_SOUT_DSI30x5
> > +#define RDMA2_SOUT_DPI00x2
> > +#define RDMA2_SOUT_DPI10x3
> > +#define RDMA2_SOUT_DSI10x1
> > +#define RDMA2_SOUT_DSI20x4
> > +#define RDMA2_SOUT_DSI30x5
> > +#define DPI0_SEL_IN_RDMA1  0x1
> > +#define DPI0_SEL_IN_RDMA2  0x3
> > +#define DPI1_SEL_IN_RDMA1  (0x1 << 8)
> > +#define DPI1_SEL_IN_RDMA2  (0x3 << 8)
> > +#define DSI0_SEL_IN_RDMA1  0x1
> > +#define DSI0_SEL_IN_RDMA2  0x4
> > +#define DSI1_SEL_IN_RDMA1  0x1
> > +#define DSI1_SEL_IN_RDMA2  0x4
> > +#define DSI2_SEL_IN_RDMA1  (0x1 << 16)
> > +#define DSI2_SEL_IN_RDMA2  (0x4 << 16)
> > +#define DSI3_SEL_IN_RDMA1   

Re: [v7, PATCH 2/7] mtk-mmsys: add mmsys private data

2020-07-26 Thread Yongqiang Niu
On Thu, 2020-07-23 at 11:32 +0200, Enric Balletbo Serra wrote:
> Hi Yongqiang Niu,
> 
> Thank you for your patch.
> 
> Missatge de Yongqiang Niu  del dia dj., 23
> de jul. 2020 a les 4:05:
> >
> > add mmsys private data
> >
> 
> I think this change requires a better explanation of what you are
> doing. Although I'm really uncomfortable with this change, why you
> need to create a new mt2701-mmsys file?

reason:
1.there will more and more Mediatek Soc upstream, and the display path
connection function mtk_mmsys_ddp_mout_en, mtk_mmsys_ddp_sel_in and
mtk_mmsys_ddp_sout_sel will complicated more and more, 
2. many of the connection are only used in some SoC, and useless for
other SoC and not readable,
3. if we add a new SoC connection, we need check is this affect other
Soc,
> 
> > Feature: drm/mediatek
> 
> Remove this.
next version will remove this
> 
> > Signed-off-by: Yongqiang Niu 
> > ---
> >  drivers/soc/mediatek/Makefile |   1 +
> >  drivers/soc/mediatek/mmsys/Makefile   |   2 +
> >  drivers/soc/mediatek/mmsys/mt2701-mmsys.c | 250 +++
> >  drivers/soc/mediatek/mtk-mmsys.c  | 271 
> > +-
> >  include/linux/soc/mediatek/mtk-mmsys.h|  15 ++
> >  5 files changed, 314 insertions(+), 225 deletions(-)
> >  create mode 100644 drivers/soc/mediatek/mmsys/Makefile
> >  create mode 100644 drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> >
> > diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
> > index 2afa7b9..b37ac2c 100644
> > --- a/drivers/soc/mediatek/Makefile
> > +++ b/drivers/soc/mediatek/Makefile
> > @@ -3,3 +3,4 @@ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
> >  obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
> >  obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
> >  obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > +obj-$(CONFIG_MTK_MMSYS) += mmsys/
> > diff --git a/drivers/soc/mediatek/mmsys/Makefile 
> > b/drivers/soc/mediatek/mmsys/Makefile
> > new file mode 100644
> > index 000..33b0dab
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/Makefile
> > @@ -0,0 +1,2 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +obj-y += mt2701-mmsys.o
> > diff --git a/drivers/soc/mediatek/mmsys/mt2701-mmsys.c 
> > b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> > new file mode 100644
> > index 000..b8e53b0
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
> > @@ -0,0 +1,250 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// Copyright (c) 2020 MediaTek Inc.
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define DISP_REG_CONFIG_DISP_OVL0_MOUT_EN  0x040
> > +#define DISP_REG_CONFIG_DISP_OVL1_MOUT_EN  0x044
> > +#define DISP_REG_CONFIG_DISP_OD_MOUT_EN0x048
> > +#define DISP_REG_CONFIG_DISP_GAMMA_MOUT_EN 0x04c
> > +#define DISP_REG_CONFIG_DISP_UFOE_MOUT_EN  0x050
> > +#define DISP_REG_CONFIG_DISP_COLOR0_SEL_IN 0x084
> > +#define DISP_REG_CONFIG_DISP_COLOR1_SEL_IN 0x088
> > +#define DISP_REG_CONFIG_DSIE_SEL_IN0x0a4
> > +#define DISP_REG_CONFIG_DSIO_SEL_IN0x0a8
> > +#define DISP_REG_CONFIG_DPI_SEL_IN 0x0ac
> > +#define DISP_REG_CONFIG_DISP_RDMA2_SOUT0x0b8
> > +#define DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN 0x0c4
> > +#define DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN 0x0c8
> > +#define DISP_REG_CONFIG_MMSYS_CG_CON0  0x100
> > +
> > +#define DISP_REG_CONFIG_DISP_OVL_MOUT_EN   0x030
> > +#define DISP_REG_CONFIG_OUT_SEL0x04c
> > +#define DISP_REG_CONFIG_DSI_SEL0x050
> > +#define DISP_REG_CONFIG_DPI_SEL0x064
> > +
> > +#define OVL0_MOUT_EN_COLOR00x1
> > +#define OD_MOUT_EN_RDMA0   0x1
> > +#define OD1_MOUT_EN_RDMA1  BIT(16)
> > +#define UFOE_MOUT_EN_DSI0  0x1
> > +#define COLOR0_SEL_IN_OVL0 0x1
> > +#define OVL1_MOUT_EN_COLOR10x1
> > +#define GAMMA_MOUT_EN_RDMA10x1
> > +#define RDMA0_SOUT_DPI00x2
> > +#define RDMA0_SOUT_DPI10x3
> > +#define RDMA0_SOUT_DSI10x1
> > +#define RDMA0_SOUT_DSI20x4
> > +#define RDMA0_SOUT_DSI30x5
> > +#define RDMA1_SOUT_DPI00x2
> > +#define RDMA1_SOUT_DPI10x3
> > +#define RDMA1_SOUT_DSI10x1
> > +#define RDMA1_SOUT_DSI20x4
> > +#define RDMA1_SOUT_DSI30x5
> > +#define RDMA2_SOUT_DPI00x2
> > +#define RDMA2_SOUT_DPI10x3
> > +#define RDMA2_SOUT_DSI10x1
> > +#define RDMA2_SOUT_DSI20x4
> > 

[PATCH 0/9] SDM630/36/60 driver enablement

2020-07-26 Thread Konrad Dybcio
Hi!

This series brings most of the changes that have been
brought to sdm630/636/660 SoCs apart from device tree
part (I cannot add anything unless some [1] smmu quirks
are merged.. blame qcom!)

So far, the platform is shaping up nicely, though some
peripherals seem to be living their own lives (I'm looking
at you, modem!)

The QPNP-REVID driver is taken from downstream but seems to
work fine upstream. I understand it may need some cleaning-up
before it's merged.

Current out-of-tree progress can be seen at [2].

[1] https://patchwork.kernel.org/patch/11643603/
[2] https://github.com/konradybcio/linux/commits/ninges_labs

Konrad Dybcio (8):
  clk: qcom: gcc-sdm660: Add missing modem reset
  phy: qcom-qusb2: Add support for SDM630/660
  drivers: usb: dwc3-qcom: Add sdm660 compatible
  drm/msm/dsi: Add phy configuration for SDM630/636/660
  drm/msm/mdp5: Add MDP5 configuration for SDM630
  drm/msm/dsi: Add DSI configuration for SDM660
  drm/msm/mdp5: Add MDP5 configuration for SDM636/660
  clk: qcom: gcc-sdm660: Fix up gcc_mss_mnoc_bimc_axi_clk

Xiaozhe Shi (1):
  soc/qcom: Add REVID driver

 .../devicetree/bindings/display/msm/dsi.txt   |   1 +
 .../bindings/phy/qcom,qusb2-phy.yaml  |   1 +
 .../bindings/soc/qcom/qcom,qpnp-revid.yaml|  38 ++
 .../devicetree/bindings/usb/qcom,dwc3.yaml|   1 +
 drivers/clk/qcom/gcc-sdm660.c |   4 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c  | 198 ++
 drivers/gpu/drm/msm/dsi/dsi_cfg.c |  21 +
 drivers/gpu/drm/msm/dsi/dsi_cfg.h |   1 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |   2 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   1 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c|  18 +
 drivers/phy/qualcomm/phy-qcom-qusb2.c |   7 +-
 drivers/soc/qcom/Kconfig  |   9 +
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/qpnp-revid.c | 288 ++
 drivers/usb/dwc3/dwc3-qcom.c  |   1 +
 include/dt-bindings/clock/qcom,gcc-sdm660.h   |   1 +
 include/linux/qpnp/qpnp-revid.h   | 369 ++
 18 files changed, 961 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/soc/qcom/qcom,qpnp-revid.yaml
 create mode 100644 drivers/soc/qcom/qpnp-revid.c
 create mode 100644 include/linux/qpnp/qpnp-revid.h

-- 
2.27.0

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


[PATCH 1/2] dt-bindings: Add DT bindings for Toshiba TC358762 DSI-to-DPI bridge

2020-07-26 Thread Marek Vasut
Add DT bindings for Toshiba TC358762 DSI-to-DPI bridge, this
one is used in the Raspberry Pi 7" touchscreen display unit.

Signed-off-by: Marek Vasut 
To: dri-devel@lists.freedesktop.org
Cc: Eric Anholt 
Cc: Rob Herring 
Cc: Sam Ravnborg 
Cc: devicet...@vger.kernel.org
---
 .../display/bridge/toshiba,tc358762.yaml  | 116 ++
 1 file changed, 116 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/toshiba,tc358762.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/toshiba,tc358762.yaml 
b/Documentation/devicetree/bindings/display/bridge/toshiba,tc358762.yaml
new file mode 100644
index ..40098ca761a3
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/toshiba,tc358762.yaml
@@ -0,0 +1,116 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/toshiba,tc358762.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Toshiba TC358762 MIPI DSI to MIPI DPI bridge
+
+maintainers:
+  - Marek Vasut 
+
+description: |
+  The TC358762 is bridge device which converts MIPI DSI to MIPI DPI.
+
+properties:
+  compatible:
+enum:
+  - toshiba,tc358762
+
+  reg:
+maxItems: 1
+description: virtual channel number of a DSI peripheral
+
+  vddc-supply:
+description: Regulator for 1.2V internal core power.
+
+  ports:
+type: object
+
+properties:
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 0
+
+  port@0:
+type: object
+additionalProperties: false
+
+description: |
+  Video port for MIPI DSI input
+
+properties:
+  reg:
+const: 0
+
+patternProperties:
+  endpoint:
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+
+required:
+  - reg
+
+  port@1:
+type: object
+additionalProperties: false
+
+description: |
+  Video port for MIPI DPI output (panel or connector).
+
+properties:
+  reg:
+const: 1
+
+patternProperties:
+  endpoint:
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+
+required:
+  - reg
+
+required:
+  - "#address-cells"
+  - "#size-cells"
+  - port@0
+  - port@1
+
+required:
+  - compatible
+  - reg
+  - vddc-supply
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+bridge@0 {
+reg = <0>;
+compatible = "toshiba,tc358762";
+vddc-supply = <_1v2_reg>;
+#address-cells = <1>;
+#size-cells = <0>;
+port@0 {
+reg = <0>;
+bridge_in: endpoint {
+remote-endpoint = <_out>;
+};
+};
+
+port@1 {
+reg = <1>;
+bridge_out: endpoint {
+remote-endpoint = <_in>;
+};
+};
+};
-- 
2.27.0

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


Re: [v7, PATCH 7/7] drm/mediatek: add support for mediatek SOC MT8183

2020-07-26 Thread Yongqiang Niu
On Sat, 2020-07-25 at 07:24 +0800, Chun-Kuang Hu wrote:
> Hi Yongqiang:
> 
> Yongqiang Niu  於 2020年7月23日 週四 上午10:15寫道:
> >
> > This patch add support for mediatek SOC MT8183
> > 1.ovl_2l share driver with ovl
> 
> I think this is done in [1], [2], [3], this patch just add the support
> of mt8183-ovl and mt8183-ovl-2l.
> 
> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek?h=v5.8-rc6=132c6e250ed745443973cada8db17cdbaebdf551
> [2] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek?h=v5.8-rc6=318462d1a568634ba09263cc730cb0fb1d56c2b3
> [3] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek?h=v5.8-rc6=57148baac8b78461e394953cfd5317bde8f795ab
> 
> > 2.rdma1 share drive with rdma0, but fifo size is different
> 
> I think this is done in [4], this patch just add the support of mt8183-rdma.
> 
> [4] https://patchwork.kernel.org/patch/11679549/
> 
> > 3.add mt8183 mutex private data, and mmsys private data
> > 4.add mt8183 main and external path module for crtc create
> 
> The fourth item is the mmsys private data in third item, so you need
> not to repeat it.
> 

i will remove some useless description in next version.
> >
> > Signed-off-by: Yongqiang Niu 
> > ---
> >  drivers/gpu/drm/mediatek/mtk_disp_ovl.c  | 18 
> >  drivers/gpu/drm/mediatek/mtk_disp_rdma.c |  6 
> >  drivers/gpu/drm/mediatek/mtk_drm_ddp.c   | 47 
> > 
> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c   | 43 +
> >  4 files changed, 114 insertions(+)
> >
> 
> [snip]
> 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c 
> > b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > index 014c1bb..60788c1 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > @@ -15,6 +15,8 @@
> >
> >  #define MT2701_DISP_MUTEX0_MOD00x2c
> >  #define MT2701_DISP_MUTEX0_SOF00x30
> > +#define MT8183_DISP_MUTEX0_MOD00x30
> > +#define MT8183_DISP_MUTEX0_SOF00x2c
> >
> >  #define DISP_REG_MUTEX_EN(n)   (0x20 + 0x20 * (n))
> >  #define DISP_REG_MUTEX(n)  (0x24 + 0x20 * (n))
> > @@ -25,6 +27,18 @@
> >
> >  #define INT_MUTEX  BIT(1)
> >
> > +#define MT8183_MUTEX_MOD_DISP_RDMA00
> > +#define MT8183_MUTEX_MOD_DISP_RDMA11
> > +#define MT8183_MUTEX_MOD_DISP_OVL0 9
> > +#define MT8183_MUTEX_MOD_DISP_OVL0_2L  10
> > +#define MT8183_MUTEX_MOD_DISP_OVL1_2L  11
> > +#define MT8183_MUTEX_MOD_DISP_WDMA012
> > +#define MT8183_MUTEX_MOD_DISP_COLOR0   13
> > +#define MT8183_MUTEX_MOD_DISP_CCORR0   14
> > +#define MT8183_MUTEX_MOD_DISP_AAL0 15
> > +#define MT8183_MUTEX_MOD_DISP_GAMMA0   16
> > +#define MT8183_MUTEX_MOD_DISP_DITHER0  17
> > +
> >  #define MT8173_MUTEX_MOD_DISP_OVL0 11
> >  #define MT8173_MUTEX_MOD_DISP_OVL1 12
> >  #define MT8173_MUTEX_MOD_DISP_RDMA013
> > @@ -74,6 +88,10 @@
> >  #define MUTEX_SOF_DSI2 5
> >  #define MUTEX_SOF_DSI3 6
> >
> > +#define MT8183_MUTEX_SOF_DPI0  2
> > +#define MT8183_MUTEX_EOF_DSI0  (MUTEX_SOF_DSI0 << 6)
> > +#define MT8183_MUTEX_EOF_DPI0  (MT8183_MUTEX_SOF_DPI0 << 6)
> > +
> >
> >  struct mtk_disp_mutex {
> > int id;
> > @@ -153,6 +171,20 @@ struct mtk_ddp {
> > [DDP_COMPONENT_WDMA1] = MT8173_MUTEX_MOD_DISP_WDMA1,
> >  };
> >
> > +static const unsigned int mt8183_mutex_mod[DDP_COMPONENT_ID_MAX] = {
> > +   [DDP_COMPONENT_AAL0] = MT8183_MUTEX_MOD_DISP_AAL0,
> > +   [DDP_COMPONENT_CCORR] = MT8183_MUTEX_MOD_DISP_CCORR0,
> > +   [DDP_COMPONENT_COLOR0] = MT8183_MUTEX_MOD_DISP_COLOR0,
> > +   [DDP_COMPONENT_DITHER] = MT8183_MUTEX_MOD_DISP_DITHER0,
> > +   [DDP_COMPONENT_GAMMA] = MT8183_MUTEX_MOD_DISP_GAMMA0,
> > +   [DDP_COMPONENT_OVL0] = MT8183_MUTEX_MOD_DISP_OVL0,
> > +   [DDP_COMPONENT_OVL_2L0] = MT8183_MUTEX_MOD_DISP_OVL0_2L,
> > +   [DDP_COMPONENT_OVL_2L1] = MT8183_MUTEX_MOD_DISP_OVL1_2L,
> > +   [DDP_COMPONENT_RDMA0] = MT8183_MUTEX_MOD_DISP_RDMA0,
> > +   [DDP_COMPONENT_RDMA1] = MT8183_MUTEX_MOD_DISP_RDMA1,
> > +   [DDP_COMPONENT_WDMA0] = MT8183_MUTEX_MOD_DISP_WDMA0,
> > +};
> > +
> >  static const unsigned int mt2712_mutex_sof[DDP_MUTEX_SOF_DSI3 + 1] = {
> > [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE,
> > [DDP_MUTEX_SOF_DSI0] = MUTEX_SOF_DSI0,
> > @@ -163,6 +195,12 @@ struct mtk_ddp {
> > [DDP_MUTEX_SOF_DSI3] = MUTEX_SOF_DSI3,
> >  };
> >
> > +static const unsigned int mt8183_mutex_sof[DDP_MUTEX_SOF_DSI3 + 1] = {
> > +   [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE,
> > +   

[PATCH -next] vc: Fix build errors

2020-07-26 Thread Ming Li
Build errors are seen on MIPS platforms because of
vc state separation and the following build erros
were reported.

../linux/drivers/video/console/newport_con.c: In function ‘newport_clear’:
../linux/drivers/video/console/newport_con.c:365:15: error:
‘struct vc_data’ has no member named ‘vc_color’; did you mean ‘vc_cols’?
  (vc->vc_color & 0xf0) >> 4);
   ^~~~
   vc_cols
../linux/drivers/video/console/newport_con.c:368:15: error:
‘struct vc_data’ has no member named ‘vc_color’; did you mean ‘vc_cols’?
  (vc->vc_color & 0xf0) >> 4);
   ^~~~
   vc_cols
../linux/drivers/video/console/newport_con.c:370:15: error:
‘struct vc_data’ has no member named ‘vc_color’; did you mean ‘vc_cols’?
  (vc->vc_color & 0xf0) >> 4);
   ^~~~
   vc_cols
../linux/drivers/video/console/newport_con.c: In function ‘newport_scroll’:
../linux/drivers/video/console/newport_con.c:594:15: error:
‘struct vc_data’ has no member named ‘vc_color’; did you mean ‘vc_cols’?
  (vc->vc_color & 0xf0) >> 4);
   ^~~~
   vc_cols
../linux/drivers/video/console/newport_con.c:598:15: error:
‘struct vc_data’ has no member named ‘vc_color’; did you mean ‘vc_cols’?
  (vc->vc_color & 0xf0) >> 4);
   ^~~~
   vc_cols
make[4]: *** [/scratch/linux/scripts/Makefile.build:280: 
drivers/video/console/newport_con.o] Error 1
make[3]: *** [/scratch/linux/scripts/Makefile.build:497: drivers/video/console] 
Error 2
make[3]: *** Waiting for unfinished jobs

Fixes: 28bc24fc46f9 ("vc: separate state")
Signed-off-by: Ming Li 
Cc: Jiri Slaby 
Cc: Greg Kroah-Hartman 
Cc: Bartlomiej Zolnierkiewicz 
---
 drivers/video/console/newport_con.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/console/newport_con.c 
b/drivers/video/console/newport_con.c
index df3c52d72159..72f146d047d9 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -362,12 +362,12 @@ static void newport_clear(struct vc_data *vc, int sy, int 
sx, int height,
 
if (ystart < yend) {
newport_clear_screen(sx << 3, ystart, xend, yend,
-(vc->vc_color & 0xf0) >> 4);
+(vc->state.color & 0xf0) >> 4);
} else {
newport_clear_screen(sx << 3, ystart, xend, 1023,
-(vc->vc_color & 0xf0) >> 4);
+(vc->state.color & 0xf0) >> 4);
newport_clear_screen(sx << 3, 0, xend, yend,
-(vc->vc_color & 0xf0) >> 4);
+(vc->state.color & 0xf0) >> 4);
}
 }
 
@@ -591,11 +591,11 @@ static bool newport_scroll(struct vc_data *vc, unsigned 
int t, unsigned int b,
topscan = (topscan + (lines << 4)) & 0x3ff;
newport_clear_lines(vc->vc_rows - lines,
vc->vc_rows - 1,
-   (vc->vc_color & 0xf0) >> 4);
+   (vc->state.color & 0xf0) >> 4);
} else {
topscan = (topscan + (-lines << 4)) & 0x3ff;
newport_clear_lines(0, lines - 1,
-   (vc->vc_color & 0xf0) >> 4);
+   (vc->state.color & 0xf0) >> 4);
}
npregs->cset.topscan = (topscan - 1) & 0x3ff;
return false;
-- 
2.17.1

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


Re: nouveau regression with 5.7 caused by "PCI/PM: Assume ports without DLL Link Active train links in 100 ms"

2020-07-26 Thread Mika Westerberg
On Thu, Jul 23, 2020 at 10:30:58PM +0200, Karol Herbst wrote:
> On Wed, Jul 22, 2020 at 11:25 AM Mika Westerberg
>  wrote:
> >
> > On Tue, Jul 21, 2020 at 01:37:12PM -0500, Patrick Volkerding wrote:
> > > On 7/21/20 10:27 AM, Mika Westerberg wrote:
> > > > On Tue, Jul 21, 2020 at 11:01:55AM -0400, Lyude Paul wrote:
> > > >> Sure thing. Also, feel free to let me know if you'd like access to one 
> > > >> of the
> > > >> systems we saw breaking with this patch - I'm fairly sure I've got one 
> > > >> of them
> > > >> locally at my apartment and don't mind setting up AMT/KVM/SSH
> > > > Probably no need for remote access (thanks for the offer, though). I
> > > > attached a test patch to the bug report:
> > > >
> > > >   https://bugzilla.kernel.org/show_bug.cgi?id=208597
> > > >
> > > > that tries to work it around (based on the ->pm_cap == 0). I wonder if
> > > > anyone would have time to try it out.
> > >
> > >
> > > Hi Mika,
> > >
> > > I can confirm that this patch applied to 5.4.52 fixes the issue with
> > > hybrid graphics on the Thinkpad X1 Extreme gen2.
> >
> > Great, thanks for testing!
> >
> 
> yeah, works on the P1G2 as well.

Thanks for testing!

Since we have the revert queued for this release cycle, I think I will
send an updated version of "PCI/PM: Assume ports without DLL Link Active
train links in 100 ms" after v5.9-rc1 is released that has this
workaround in place.

(I'm continuing my vacation so will be offline next week).
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/bridge: tc358762: Add basic driver for Toshiba TC358762 DSI-to-DPI bridge

2020-07-26 Thread Marek Vasut
Add very basic driver for Toshiba TC358762 DSI-to-DPI bridge, derived
from tc358764 driver and panel-raspberrypi-touchscreen. This driver is
meant to replace the panel-raspberrypi-touchscreen too, as the bridge
connection can be described in DT too.

Signed-off-by: Marek Vasut 
To: dri-devel@lists.freedesktop.org
Cc: Eric Anholt 
Cc: Rob Herring 
Cc: Sam Ravnborg 
Cc: devicet...@vger.kernel.org
---
 drivers/gpu/drm/bridge/Kconfig|   9 +
 drivers/gpu/drm/bridge/Makefile   |   1 +
 drivers/gpu/drm/bridge/tc358762.c | 352 ++
 3 files changed, 362 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/tc358762.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 43271c21d3fc..3e76e3fccb78 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -153,6 +153,15 @@ config DRM_THINE_THC63LVD1024
help
  Thine THC63LVD1024 LVDS/parallel converter driver.
 
+config DRM_TOSHIBA_TC358762
+   tristate "TC358762 DSI/DPI bridge"
+   depends on OF
+   select DRM_MIPI_DSI
+   select DRM_KMS_HELPER
+   select DRM_PANEL
+   help
+ Toshiba TC358762 DSI/DPI bridge driver.
+
 config DRM_TOSHIBA_TC358764
tristate "TC358764 DSI/LVDS bridge"
depends on OF
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index d63d4b7e4347..b341c60ee96a 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_DRM_SII902X) += sii902x.o
 obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_SIMPLE_BRIDGE) += simple-bridge.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
+obj-$(CONFIG_DRM_TOSHIBA_TC358762) += tc358762.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358768) += tc358768.o
diff --git a/drivers/gpu/drm/bridge/tc358762.c 
b/drivers/gpu/drm/bridge/tc358762.c
new file mode 100644
index ..6eb0c0c10623
--- /dev/null
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -0,0 +1,352 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Marek Vasut 
+ *
+ * Based on tc358764.c by
+ *  Andrzej Hajda 
+ *  Maciej Purski 
+ *
+ * Based on rpi_touchscreen.c by
+ *  Eric Anholt 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* PPI layer registers */
+#define PPI_STARTPPI   0x0104 /* START control bit */
+#define PPI_LPTXTIMECNT0x0114 /* LPTX timing signal */
+#define PPI_D0S_ATMR   0x0144
+#define PPI_D1S_ATMR   0x0148
+#define PPI_D0S_CLRSIPOCOUNT   0x0164 /* Assertion timer for Lane 0 */
+#define PPI_D1S_CLRSIPOCOUNT   0x0168 /* Assertion timer for Lane 1 */
+#define PPI_START_FUNCTION 1
+
+/* DSI layer registers */
+#define DSI_STARTDSI   0x0204 /* START control bit of DSI-TX */
+#define DSI_LANEENABLE 0x0210 /* Enables each lane */
+#define DSI_RX_START   1
+
+/* LCDC/DPI Host Registers */
+#define LCDCTRL0x0420
+
+/* SPI Master Registers */
+#define SPICMR 0x0450
+#define SPITCR 0x0454
+
+/* System Controller Registers */
+#define SYSCTRL0x0464
+
+/* System registers */
+#define LPX_PERIOD 3
+
+/* Lane enable PPI and DSI register bits */
+#define LANEENABLE_CLENBIT(0)
+#define LANEENABLE_L0ENBIT(1)
+#define LANEENABLE_L1ENBIT(2)
+
+struct tc358762 {
+   struct device *dev;
+   struct drm_bridge bridge;
+   struct drm_connector connector;
+   struct regulator *regulator;
+   struct drm_panel *panel;
+   bool pre_enabled;
+   int error;
+};
+
+static int tc358762_clear_error(struct tc358762 *ctx)
+{
+   int ret = ctx->error;
+
+   ctx->error = 0;
+   return ret;
+}
+
+static void tc358762_write(struct tc358762 *ctx, u16 addr, u32 val)
+{
+   struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+   ssize_t ret;
+   u8 data[6];
+
+   if (ctx->error)
+   return;
+
+   data[0] = addr;
+   data[1] = addr >> 8;
+   data[2] = val;
+   data[3] = val >> 8;
+   data[4] = val >> 16;
+   data[5] = val >> 24;
+
+   ret = mipi_dsi_generic_write(dsi, data, sizeof(data));
+   if (ret < 0)
+   ctx->error = ret;
+}
+
+static inline struct tc358762 *bridge_to_tc358762(struct drm_bridge *bridge)
+{
+   return container_of(bridge, struct tc358762, bridge);
+}
+
+static inline
+struct tc358762 *connector_to_tc358762(struct drm_connector *connector)
+{
+   return container_of(connector, struct tc358762, connector);
+}
+
+static int tc358762_init(struct tc358762 *ctx)
+{
+   tc358762_write(ctx, DSI_LANEENABLE,
+  LANEENABLE_L0EN | LANEENABLE_CLEN);
+   

[PATCH] drm/sun4i: mixer: Enable register value caching

2020-07-26 Thread Jernej Skrabec
It was discovered in the past by Ondrej Jirman that mixer register read
may occasionally return wrong value, most likely zero. It turns out
that all mixer units are affected by this issue. This becomes especially
obvious with applications like video player. After a few minutes of a
playback visual glitches appeared but not always in the same way. After
register inspection it was clear that some bits are not set even when
they should be.

Best solution would be to shuffle the code a bit to avoid
read-modify-write operations and use only register writes. However,
quicker solution is to enable caching support in regmap which is also
used here. Such fix is also easier to backport in stable kernels.

Fixes: 9d75b8c0b999 ("drm/sun4i: add support for Allwinner DE2 mixers")
Signed-off-by: Jernej Skrabec 
---
 drivers/gpu/drm/sun4i/sun8i_mixer.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c 
b/drivers/gpu/drm/sun4i/sun8i_mixer.c
index cc4fb916318f..f8f17c51c96d 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -303,11 +303,23 @@ static const struct sunxi_engine_ops sun8i_engine_ops = {
.layers_init= sun8i_layers_init,
 };
 
+static bool sun8i_mixer_volatile_reg(struct device *dev, unsigned int reg)
+{
+   switch (reg) {
+   case SUN8I_MIXER_GLOBAL_STATUS:
+   case SUN8I_MIXER_GLOBAL_DBUFF:
+   return true;
+   }
+   return false;
+}
+
 static struct regmap_config sun8i_mixer_regmap_config = {
+   .cache_type = REGCACHE_FLAT,
.reg_bits   = 32,
.val_bits   = 32,
.reg_stride = 4,
.max_register   = 0xbfffc, /* guessed */
+   .volatile_reg   = sun8i_mixer_volatile_reg,
 };
 
 static int sun8i_mixer_of_get_id(struct device_node *node)
-- 
2.27.0

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


Re: [PATCH 5/5] drm: rockchip: use overlay windows as such

2020-07-26 Thread Paolo Sabatino

On 18/07/20 22:03, Alex Bee wrote:

  static const int rk3188_vop_intrs[] = {
@@ -980,7 +980,7 @@ static const struct vop_win_data rk3228_vop_win_data[] = {
{ .base = 0x00, .phy = _win01_data,
  .type = DRM_PLANE_TYPE_PRIMARY },
{ .base = 0x40, .phy = _win01_data,
- .type = DRM_PLANE_TYPE_CURSOR },
+ .type = DRM_PLANE_TYPE_OVERLAY },
  };
  
  static const struct vop_data rk3228_vop = {


Tried on several rk322x boards, it worked fine.

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


Re: [PATCH 9/9] soc/qcom: Add REVID driver

2020-07-26 Thread Konrad Dybcio
Hi Greg, thanks for your review!

>Why do we need this noise in the kernel log?

I guess it could be left there as a debug print? Knowing your hardware
revision seems like a good, but yeah, not a necessary thing.

>You can drop the GPL boilerplate text and add a proper SPDX line at the
>top.

Seems I only did that in my other local tree.. whoops!

>Drivers should always use dev_err() and friends, as you have access to a
>struct device * always.  Please fix up the driver here to use that api
>instead, no pr_* should be needed at all.

Will do.

>Horrible global symbol name.  Who calls this?

Welcome to development on qcom platforms :D

>This is the last patch in
>the series, so if there is no user for this, please don't export it.

Other downstream drivers make use of it.. need to get this up first, sorry :V

>Why do you need a .h file in the include directory if only a single .c
>file needs it?  Just put that info in the .c file itself.

Again, other downstream drivers which some people and I intend to
bring to upstream standards use that to access the PMIC model/hw revision.

>But again, who uses this module?  If it's only good for a single line in
>the kernel log, that feels like a huge waste to me.

downstream-kernel-dir$ rg -l qpnp-revid.h | wc -l
25

So yeah, quite a bunch of other qcom-specific drivers.

I'll try to fix these and send a v2.

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


  1   2   >