From: Kevin Hao Subject: Re: [PATCH] drm: tilcdc: Calculate the vrefresh if it is not set by userspace Date: Wed, 11 Oct 2017 10:57:29 +0800 Message-ID: <20171011025729.GG23389@pek-khao-d1> References: <20171010120909.26290-1-kexin.hao@windriver.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1018253244==" Return-path: Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE0FB89C51 for ; Wed, 11 Oct 2017 03:07:31 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Jyri Sarha Cc: Tomi Valkeinen , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1018253244== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cf0hFtnykp6aONGL" Content-Disposition: inline --cf0hFtnykp6aONGL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 10, 2017 at 04:58:15PM +0300, Jyri Sarha wrote: >=20 > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/= Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki >=20 > On 10/10/17 15:09, Kevin Hao wrote: > > The check for vrefresh has been removed by commit 11abbc9f39e0 > > ("drm/tilcdc: Set framebuffer DMA address to HW only if CRTC is > > enabled"). But the userspace is really possible to request a display > > mode with vrefresh uninitialized, then it would cause the following > > calltrace: > > [] (unwind_backtrace) from [] (show_stack+0x20/0x= 24) > > [] (show_stack) from [] (dump_stack+0x20/0x28) > > [] (dump_stack) from [] (__div0+0x20/0x28) > > [] (__div0) from [] (Ldiv0+0x8/0x14) > > [] (Ldiv0) from [] (tilcdc_crtc_update_fb+0xa8/0x= 1d4) > > [] (tilcdc_crtc_update_fb) from [] (tilcdc_plane_= atomic_update+0x54/0x5c) > > [] (tilcdc_plane_atomic_update) from [] (drm_atom= ic_helper_commit_planes+0x1b4/0x270) > > [] (drm_atomic_helper_commit_planes) from [] (til= cdc_commit+0x58/0x84) > > [] (tilcdc_commit) from [] (drm_atomic_commit+0x5= 4/0x68) > > [] (drm_atomic_commit) from [] (drm_atomic_helper= _set_config+0x68/0x9c) > > [] (drm_atomic_helper_set_config) from [] (__drm_= mode_set_config_internal+0x60/0xe0) > > [] (__drm_mode_set_config_internal) from [] (drm_= mode_setcrtc+0x3a8/0x4c0) > > [] (drm_mode_setcrtc) from [] (drm_ioctl_kernel+0= x78/0xb0) > > [] (drm_ioctl_kernel) from [] (drm_ioctl+0x1fc/0x= 328) > > [] (drm_ioctl) from [] (vfs_ioctl+0x28/0x44) > > [] (vfs_ioctl) from [] (do_vfs_ioctl+0x890/0x8ec) > > [] (do_vfs_ioctl) from [] (SyS_ioctl+0x60/0x7c) > > [] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x48) > >=20 > > So calculate the vrefresh in mode_fixup() to make sure there always > > have a valid vrefresh. > >=20 >=20 > The earlier check was there for the frame buffer updates when the > display is not yet enabled and the hwmode's vrefresh is not valid yet. > Now, with the lock protected enabled state variable check, this should > never happen. >=20 > Do you have a reliable way to reproduce the problem you are seeing? I get the calltrace every time when I reboot my BeagleBone Black board. The following is the xorg.conf I used: root@beaglebone:~# cat /etc/X11/xorg.conf=20 Section "Monitor" Identifier "Builtin Default Monitor" EndSection =20 Section "Device" Identifier "Builtin Default fbdev Device 0" Driver "modesetting" EndSection =20 Section "Screen" Identifier "Builtin Default fbdev Screen 0" DefaultDepth 16 Device "Builtin Default fbdev Device 0" Monitor "Builtin Default Monitor" EndSection =20 Section "ServerLayout" Identifier "Builtin Default Layout" Screen "Builtin Default fbdev Screen 0" EndSection > Could try adding a test for the vrefresh validity in the > tilcdc_crtc_mode_valid() to see if that helps? No, this will break the modeset driver. I have added the following code: diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/til= cdc/tilcdc_crtc.c index d2589f310437..4dbce75272a3 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -845,6 +845,11 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, = struct drm_display_mode *mode) return MODE_BAD; } =20 + if (!mode->vrefresh) { + DBG("Pruning mode: invalid vrefresh"); + return MODE_BAD; + } + return MODE_OK; } And got the following error for Xorg: [ 17.563] (II) modeset(0): Damage tracking initialized [ 17.563] (II) modeset(0): Setting screen physical size to 169 x 127 [ 18.388] (EE) modeset(0): failed to set mode: Invalid argument [ 21.907] (II) modeset(0): Disabling kernel dirty updates, not requi= red. It seems that function drmmode_set_mode_major() in hw/xfree86/drivers/modes= etting/drmmode_display.c always invoke the drmModeSetCrtc() with a zero vrefresh. Thanks, Kevin >=20 > Adding the extra test in the mode validity check probably produces a > failed mode set attempt, which I guess is Ok if the mode has zero > vertical refresh time. But if this does not help, then the issue you are > seeing may be an indication of a synchronization problem somewhere. >=20 > Best regards, > Jyri >=20 > > Fixes: 11abbc9f39e0 ("drm/tilcdc: Set framebuffer DMA address to HW onl= y if CRTC is enabled") > > Cc: # v4.11+ > > Signed-off-by: Kevin Hao > > --- > > drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 3 +++ > > 1 file changed, 3 insertions(+) > >=20 > > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/til= cdc/tilcdc_crtc.c > > index d2589f310437..16b020a9044c 100644 > > --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c > > +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c > > @@ -690,6 +690,9 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc = *crtc, > > adjusted_mode->flags &=3D ~DRM_MODE_FLAG_PHSYNC; > > } > > =20 > > + if (!adjusted_mode->vrefresh) > > + adjusted_mode->vrefresh =3D drm_mode_vrefresh(adjusted_mode); > > + > > return true; > > } > > =20 > >=20 >=20 >=20 --cf0hFtnykp6aONGL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZ3YiZAAoJEJNY7TDerrFx6VYIALjrXO9xfM71zQ0G3sp/6rai b1+rDumDiV+3ECWtQ/S1FBoSSizCVucOzpd5+aOGym1UzBBVLi19E0d7XfLiStJD aXdvdd+30N8W+2qxwhagIzCJzhKQLtMLsT+Rc3DvfxGXocx5oCQxAqpjE/7HK1z2 avbinghvcoxsSvg9804zDob1VnNX+yI4XxMz2slD+TEaV3u/U91tpndDCJv/PFSj aqa9niEYSkTn2f35bT3kQbtBhHuwGjbmRCf09MxboJdBtjcdx4bdlAhbbFwWGIHu A2dib5FUE2A1/TTc/7g7qaACIqfVIoLrzvgn6FbOfGyz3AzkYd4Tebq0HCDzC7A= =f4VG -----END PGP SIGNATURE----- --cf0hFtnykp6aONGL-- --===============1018253244== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1018253244==--