All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/sun4i: Handle DRM_BUS_FLAG_PIXDATA_*EDGE checking if panel is used.
@ 2018-10-01  9:36 Dan Carpenter
  2018-10-02 13:26 ` Giulio Benetti
                   ` (2 more replies)
  0 siblings, 3 replies; 50+ messages in thread
From: Dan Carpenter @ 2018-10-01  9:36 UTC (permalink / raw)
  To: giulio.benetti; +Cc: dri-devel

Hello Giulio Benetti,

The patch 490cda5a3c82: "drm/sun4i: Handle DRM_BUS_FLAG_PIXDATA_*EDGE
checking if panel is used." from Jul 18, 2018, leads to the following
static checker warning:

	drivers/gpu/drm/sun4i/sun4i_tcon.c:558 sun4i_tcon0_mode_set_rgb()
	warn: 'tcon->panel' isn't an ERR_PTR

drivers/gpu/drm/sun4i/sun4i_tcon.c
   481                                       const struct drm_display_mode *mode)
   482  {
   483          unsigned int bp, hsync, vsync;
   484          u8 clk_delay;
   485          u32 val = 0;
   486  
   487          WARN_ON(!tcon->quirks->has_channel_0);
   488  
   489          tcon->dclk_min_div = 6;
   490          tcon->dclk_max_div = 127;
   491          sun4i_tcon0_mode_set_common(tcon, mode);
   492  
   493          /* Set dithering if needed */
   494          sun4i_tcon0_mode_set_dithering(tcon, tcon->panel->connector);
                                                     ^^^^^^^^^^^^^
Dereference.

   495  
   496          /* Adjust clock delay */
   497          clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
   498          regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
   499                             SUN4I_TCON0_CTL_CLK_DELAY_MASK,
   500                             SUN4I_TCON0_CTL_CLK_DELAY(clk_delay));
   501  
   502          /*
   503           * This is called a backporch in the register documentation,
   504           * but it really is the back porch + hsync
   505           */
   506          bp = mode->crtc_htotal - mode->crtc_hsync_start;
   507          DRM_DEBUG_DRIVER("Setting horizontal total %d, backporch %d\n",
   508                           mode->crtc_htotal, bp);
   509  
   510          /* Set horizontal display timings */
   511          regmap_write(tcon->regs, SUN4I_TCON0_BASIC1_REG,
   512                       SUN4I_TCON0_BASIC1_H_TOTAL(mode->crtc_htotal) |
   513                       SUN4I_TCON0_BASIC1_H_BACKPORCH(bp));
   514  
   515          /*
   516           * This is called a backporch in the register documentation,
   517           * but it really is the back porch + hsync
   518           */
   519          bp = mode->crtc_vtotal - mode->crtc_vsync_start;
   520          DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
   521                           mode->crtc_vtotal, bp);
   522  
   523          /* Set vertical display timings */
   524          regmap_write(tcon->regs, SUN4I_TCON0_BASIC2_REG,
   525                       SUN4I_TCON0_BASIC2_V_TOTAL(mode->crtc_vtotal * 2) |
   526                       SUN4I_TCON0_BASIC2_V_BACKPORCH(bp));
   527  
   528          /* Set Hsync and Vsync length */
   529          hsync = mode->crtc_hsync_end - mode->crtc_hsync_start;
   530          vsync = mode->crtc_vsync_end - mode->crtc_vsync_start;
   531          DRM_DEBUG_DRIVER("Setting HSYNC %d, VSYNC %d\n", hsync, vsync);
   532          regmap_write(tcon->regs, SUN4I_TCON0_BASIC3_REG,
   533                       SUN4I_TCON0_BASIC3_V_SYNC(vsync) |
   534                       SUN4I_TCON0_BASIC3_H_SYNC(hsync));
   535  
   536          /* Setup the polarity of the various signals */
   537          if (mode->flags & DRM_MODE_FLAG_PHSYNC)
   538                  val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE;
   539  
   540          if (mode->flags & DRM_MODE_FLAG_PVSYNC)
   541                  val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
   542  
   543          /*
   544           * On A20 and similar SoCs, the only way to achieve Positive Edge
   545           * (Rising Edge), is setting dclk clock phase to 2/3(240°).
   546           * By default TCON works in Negative Edge(Falling Edge),
   547           * this is why phase is set to 0 in that case.
   548           * Unfortunately there's no way to logically invert dclk through
   549           * IO_POL register.
   550           * The only acceptable way to work, triple checked with scope,
   551           * is using clock phase set to 0° for Negative Edge and set to 240°
   552           * for Positive Edge.
   553           * On A33 and similar SoCs there would be a 90° phase option,
   554           * but it divides also dclk by 2.
   555           * Following code is a way to avoid quirks all around TCON
   556           * and DOTCLOCK drivers.
   557           */
   558          if (!IS_ERR(tcon->panel)) {
                     ^^^^^^^^^^^^^^^^^^
Unpossible to be an error pointer!

   559                  struct drm_panel *panel = tcon->panel;
   560                  struct drm_connector *connector = panel->connector;
   561                  struct drm_display_info display_info = connector->display_info;
   562  
   563                  if (display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)

regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2018-11-06 15:57 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  9:36 [bug report] drm/sun4i: Handle DRM_BUS_FLAG_PIXDATA_*EDGE checking if panel is used Dan Carpenter
2018-10-02 13:26 ` Giulio Benetti
2018-10-02 14:12   ` Giulio Benetti
2018-10-02 20:40     ` Giulio Benetti
2018-10-11  7:16   ` Dan Carpenter
2018-10-11 21:36     ` Giulio Benetti
2018-10-02 20:48 ` [PATCH 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Giulio Benetti
2018-10-02 20:48   ` Giulio Benetti
2018-10-02 20:49   ` [PATCH 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if null Giulio Benetti
2018-10-02 20:49     ` Giulio Benetti
2018-10-02 21:59 ` [PATCH 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Giulio Benetti
2018-10-02 21:59   ` Giulio Benetti
2018-10-02 21:59   ` Giulio Benetti
2018-10-02 21:59   ` [PATCH 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if null Giulio Benetti
2018-10-02 21:59     ` Giulio Benetti
2018-10-03  7:34     ` Chen-Yu Tsai
2018-10-03  7:34       ` Chen-Yu Tsai
2018-10-02 22:00   ` [PATCH 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Giulio Benetti
2018-10-02 22:00     ` Giulio Benetti
2018-10-02 22:00     ` Giulio Benetti
2018-10-03  9:43   ` Chen-Yu Tsai
2018-10-03  9:43     ` Chen-Yu Tsai
2018-10-03 12:13     ` Giulio Benetti
2018-10-03 12:13       ` Giulio Benetti
2018-10-03 14:24       ` [PATCH v2 " Giulio Benetti
2018-10-03 14:24         ` Giulio Benetti
2018-10-03 14:24         ` [PATCH v2 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if null Giulio Benetti
2018-10-03 14:24           ` Giulio Benetti
2018-10-03 14:24           ` Giulio Benetti
2018-10-04 19:56           ` Maxime Ripard
2018-10-04 19:56             ` Maxime Ripard
2018-10-04 19:56             ` Maxime Ripard
2018-10-05 21:38             ` Giulio Benetti
2018-10-05 21:38               ` Giulio Benetti
2018-10-05 21:59             ` [PATCH v3 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Giulio Benetti
2018-10-05 21:59               ` Giulio Benetti
2018-10-05 21:59               ` Giulio Benetti
2018-10-05 21:59               ` [PATCH v3 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if NULL Giulio Benetti
2018-10-05 21:59                 ` Giulio Benetti
2018-10-08  9:21                 ` Maxime Ripard
2018-10-08  9:21                   ` Maxime Ripard
2018-10-12 10:03                   ` Chen-Yu Tsai
2018-10-12 10:03                     ` Chen-Yu Tsai
2018-11-05 13:23                   ` Icenowy Zheng
2018-11-05 13:23                     ` Icenowy Zheng
2018-11-06 15:57                     ` Maxime Ripard
2018-11-06 15:57                       ` Maxime Ripard
2018-10-04 19:54         ` [PATCH v2 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Maxime Ripard
2018-10-04 19:54           ` Maxime Ripard
2018-10-04 19:54           ` Maxime Ripard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.