From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932676AbdBWAwo (ORCPT ); Wed, 22 Feb 2017 19:52:44 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:33010 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbdBWAwi (ORCPT ); Wed, 22 Feb 2017 19:52:38 -0500 Date: Wed, 22 Feb 2017 16:52:33 -0800 From: Maxime Ripard To: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Cc: Stefan Lengfeld , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter Subject: Re: [PATCH v3 2/2] drm/fb-helper: implement ioctl FBIO_WAITFORVSYNC Message-ID: <20170223005233.idtde27hkqlewkii@lukather> References: <20170221100059.GD17643@sill.h.stcim.de> <20170221105501.GC31595@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ivjvzgoh5aquax6g" Content-Disposition: inline In-Reply-To: <20170221105501.GC31595@intel.com> User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ivjvzgoh5aquax6g Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Ville, Stefan, On Tue, Feb 21, 2017 at 12:55:01PM +0200, Ville Syrj=E4l=E4 wrote: > On Tue, Feb 21, 2017 at 11:00:59AM +0100, Stefan Lengfeld wrote: > > Hi Maxime, > >=20 > > On Wed, Feb 15, 2017 at 05:19:09PM +0100, Maxime Ripard wrote: > > > From: Stefan Christ > > >=20 > >=20 > > Maybe change the author here. Only the boilerplate code looks my origin= al > > patch. The real code is your work ;-) > >=20 > > > Implement legacy framebuffer ioctl FBIO_WAITFORVSYNC in the generic > > > framebuffer emulation driver. Legacy framebuffer users like non kms/d= rm > > > based OpenGL(ES)/EGL implementations may require the ioctl to > > > synchronize drawing or buffer flip for double buffering. It is tested= on > > > the i.MX6. > > >=20 > > > Code is based on > > > https://github.com/Xilinx/linux-xlnx/blob/master/drivers/gpu/drm/= xilinx/xilinx_drm_fb.c#L196 > > >=20 > > > Signed-off-by: Stefan Christ > > > Signed-off-by: Maxime Ripard > > > --- > > > drivers/gpu/drm/drm_fb_helper.c | 63 +++++++++++++++++++++++++++++++= +++- > > > include/drm/drm_fb_helper.h | 12 +++++- > > > 2 files changed, 74 insertions(+), 1 deletion(-) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb= _helper.c > > > index c6de87abaca8..15ee9641c725 100644 > > > --- a/drivers/gpu/drm/drm_fb_helper.c > > > +++ b/drivers/gpu/drm/drm_fb_helper.c > > > @@ -1240,6 +1240,69 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap= , struct fb_info *info) > > > EXPORT_SYMBOL(drm_fb_helper_setcmap); > > > =20 > > > /** > > > + * drm_fb_helper_ioctl - legacy ioctl implementation > > > + * @info: fbdev registered by the helper > > > + * @cmd: ioctl command > > > + * @arg: ioctl argument > > > + * > > > + * A helper to implement the standard fbdev ioctl. Only > > > + * FBIO_WAITFORVSYNC is implemented for now. > > > + */ > > > +int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, > > > + unsigned long arg) > > > +{ > > > + struct drm_fb_helper *fb_helper =3D info->par; > > > + struct drm_device *dev =3D fb_helper->dev; > > > + struct drm_mode_set *mode_set; > > > + struct drm_crtc *crtc; > > > + u32 karg; > > > + int ret =3D 0; > > > + > > > + mutex_lock(&dev->mode_config.mutex); > > > + if (!drm_fb_helper_is_bound(fb_helper)) { > > > + ret =3D -EBUSY; > > > + goto unlock; > > > + } > > > + > > > + switch (cmd) { > > > + case FBIO_WAITFORVSYNC: > > > + if (get_user(karg, (__u32 __user *)arg)) { > > > + ret =3D -EFAULT; > > > + goto unlock; > > > + } > > > + > > > + if (karg >=3D fb_helper->crtc_count) { > > > + ret =3D -EINVAL; > > > + goto unlock; > > > + } > >=20 > > Ville Syrj=E4l=E4 said [1]: > >=20 > > FBIO_WAITFORVSYNC takes the crtc as a parmeter, so I'm not sure we = want > > to do this for all the crtcs. Though what that crtc means for fb is > > rather poorly defined. > >=20 > > Don't think it takes the crtc as a parameter in 'arg'. When you look at= the > > existing fb_ioctl implementations in the directory drivers/video/fbdev/= , the > > argument 'arg' is either ignored or must be '0'. >=20 > Have a look at matroxfb. >=20 > >=20 > > Furthmore most exiting userspace code just passes the value "0" as the > > argument. For example DirectFB: > >=20 > > static const int zero =3D 0; > > [...] > > if (ioctl( dfb_fbdev->fd, FBIO_WAITFORVSYNC, &zero )) >=20 > Again the matrox driver is different. And looks like unichrome might have > done something even more exotic with the argument. >=20 > But I do agree that using this with the kms fbdev implementation could > be quite problematic as you can't actually know which crtcs the > fb_helper has picked. I'm not sure what a good solution might be then. Is just waiting for always the first crtc acceptable? All the code I could find is passing 0 as an argument anyway, so that's effectively the same behaviour anyway here. And getting tearing might be a good argument in favour of moving to KMS :) Thanks Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --ivjvzgoh5aquax6g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYrjJRAAoJEBx+YmzsjxAgO4kP/0yNL3xq3JmsO07EyqFGYT6C eyT0AXQVaa77w9me9iEz0Tg4v1JYlwxMWfTkaq2Gt5Oo5nr20MSJjj0DYLn1Pozb ppOs7kI9w8cV+uZouljRgDt96mWEdCOruetBbXWiZpTn2MIiZhmjBCql9RLzYXIL L3D3NA+6wD0lKcqREqq1cVEQpgDJu9XuHa5FF2JFG3yjPucRTcBA26/fMGgqYRW4 2ervW9aZVAGblrQUFvVebvSRL10CbBnWSCM9/+P1QRQoMWKOypMtUzZESHnSx23W Wa1276Gjlx5GsF+qjHgCcEMaPFAgUiPf2lqZRIoNisEu0d56mXUGLPsBXMHupH/P bl+ddo+eQrWDoOOTUxhrDCEaT8Xc2zk99x+AIXp5c6gqD6krtJl9+6AL4DDd5ti9 auhKQJXWHNtr68zYYHgcMGUj5hx2pwBcZsRj20kEkThmCtRXJYj1h48r5yAD8wAh UiCHCF/Aq+bnfAYJ4SKKhIikVr3+wLN5fDueEDnLvsBh+ysR0GkeVu7c1VzRN5kE RelL2h325spcznzTdmPGEBxeKaq30EnDJF2G4+1RKH6SYeYPLAyc0b1mdCGbwkDl 86YqJ9vxsaFGz6FoT/6XIotKGm6TDQqrLKz2AVHRb3sdaJYBbjfpZn0yg3a+RqAH LxVy3Lg+XgTwvrBXM140 =3fnq -----END PGP SIGNATURE----- --ivjvzgoh5aquax6g-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Ripard Subject: Re: [PATCH v3 2/2] drm/fb-helper: implement ioctl FBIO_WAITFORVSYNC Date: Wed, 22 Feb 2017 16:52:33 -0800 Message-ID: <20170223005233.idtde27hkqlewkii@lukather> References: <20170221100059.GD17643@sill.h.stcim.de> <20170221105501.GC31595@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1620917934==" Return-path: Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 02C4B6E034 for ; Thu, 23 Feb 2017 00:52:37 +0000 (UTC) In-Reply-To: <20170221105501.GC31595@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Cc: Stefan Lengfeld , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter List-Id: dri-devel@lists.freedesktop.org --===============1620917934== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ivjvzgoh5aquax6g" Content-Disposition: inline --ivjvzgoh5aquax6g Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Ville, Stefan, On Tue, Feb 21, 2017 at 12:55:01PM +0200, Ville Syrj=E4l=E4 wrote: > On Tue, Feb 21, 2017 at 11:00:59AM +0100, Stefan Lengfeld wrote: > > Hi Maxime, > >=20 > > On Wed, Feb 15, 2017 at 05:19:09PM +0100, Maxime Ripard wrote: > > > From: Stefan Christ > > >=20 > >=20 > > Maybe change the author here. Only the boilerplate code looks my origin= al > > patch. The real code is your work ;-) > >=20 > > > Implement legacy framebuffer ioctl FBIO_WAITFORVSYNC in the generic > > > framebuffer emulation driver. Legacy framebuffer users like non kms/d= rm > > > based OpenGL(ES)/EGL implementations may require the ioctl to > > > synchronize drawing or buffer flip for double buffering. It is tested= on > > > the i.MX6. > > >=20 > > > Code is based on > > > https://github.com/Xilinx/linux-xlnx/blob/master/drivers/gpu/drm/= xilinx/xilinx_drm_fb.c#L196 > > >=20 > > > Signed-off-by: Stefan Christ > > > Signed-off-by: Maxime Ripard > > > --- > > > drivers/gpu/drm/drm_fb_helper.c | 63 +++++++++++++++++++++++++++++++= +++- > > > include/drm/drm_fb_helper.h | 12 +++++- > > > 2 files changed, 74 insertions(+), 1 deletion(-) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb= _helper.c > > > index c6de87abaca8..15ee9641c725 100644 > > > --- a/drivers/gpu/drm/drm_fb_helper.c > > > +++ b/drivers/gpu/drm/drm_fb_helper.c > > > @@ -1240,6 +1240,69 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap= , struct fb_info *info) > > > EXPORT_SYMBOL(drm_fb_helper_setcmap); > > > =20 > > > /** > > > + * drm_fb_helper_ioctl - legacy ioctl implementation > > > + * @info: fbdev registered by the helper > > > + * @cmd: ioctl command > > > + * @arg: ioctl argument > > > + * > > > + * A helper to implement the standard fbdev ioctl. Only > > > + * FBIO_WAITFORVSYNC is implemented for now. > > > + */ > > > +int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, > > > + unsigned long arg) > > > +{ > > > + struct drm_fb_helper *fb_helper =3D info->par; > > > + struct drm_device *dev =3D fb_helper->dev; > > > + struct drm_mode_set *mode_set; > > > + struct drm_crtc *crtc; > > > + u32 karg; > > > + int ret =3D 0; > > > + > > > + mutex_lock(&dev->mode_config.mutex); > > > + if (!drm_fb_helper_is_bound(fb_helper)) { > > > + ret =3D -EBUSY; > > > + goto unlock; > > > + } > > > + > > > + switch (cmd) { > > > + case FBIO_WAITFORVSYNC: > > > + if (get_user(karg, (__u32 __user *)arg)) { > > > + ret =3D -EFAULT; > > > + goto unlock; > > > + } > > > + > > > + if (karg >=3D fb_helper->crtc_count) { > > > + ret =3D -EINVAL; > > > + goto unlock; > > > + } > >=20 > > Ville Syrj=E4l=E4 said [1]: > >=20 > > FBIO_WAITFORVSYNC takes the crtc as a parmeter, so I'm not sure we = want > > to do this for all the crtcs. Though what that crtc means for fb is > > rather poorly defined. > >=20 > > Don't think it takes the crtc as a parameter in 'arg'. When you look at= the > > existing fb_ioctl implementations in the directory drivers/video/fbdev/= , the > > argument 'arg' is either ignored or must be '0'. >=20 > Have a look at matroxfb. >=20 > >=20 > > Furthmore most exiting userspace code just passes the value "0" as the > > argument. For example DirectFB: > >=20 > > static const int zero =3D 0; > > [...] > > if (ioctl( dfb_fbdev->fd, FBIO_WAITFORVSYNC, &zero )) >=20 > Again the matrox driver is different. And looks like unichrome might have > done something even more exotic with the argument. >=20 > But I do agree that using this with the kms fbdev implementation could > be quite problematic as you can't actually know which crtcs the > fb_helper has picked. I'm not sure what a good solution might be then. Is just waiting for always the first crtc acceptable? All the code I could find is passing 0 as an argument anyway, so that's effectively the same behaviour anyway here. And getting tearing might be a good argument in favour of moving to KMS :) Thanks Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --ivjvzgoh5aquax6g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYrjJRAAoJEBx+YmzsjxAgO4kP/0yNL3xq3JmsO07EyqFGYT6C eyT0AXQVaa77w9me9iEz0Tg4v1JYlwxMWfTkaq2Gt5Oo5nr20MSJjj0DYLn1Pozb ppOs7kI9w8cV+uZouljRgDt96mWEdCOruetBbXWiZpTn2MIiZhmjBCql9RLzYXIL L3D3NA+6wD0lKcqREqq1cVEQpgDJu9XuHa5FF2JFG3yjPucRTcBA26/fMGgqYRW4 2ervW9aZVAGblrQUFvVebvSRL10CbBnWSCM9/+P1QRQoMWKOypMtUzZESHnSx23W Wa1276Gjlx5GsF+qjHgCcEMaPFAgUiPf2lqZRIoNisEu0d56mXUGLPsBXMHupH/P bl+ddo+eQrWDoOOTUxhrDCEaT8Xc2zk99x+AIXp5c6gqD6krtJl9+6AL4DDd5ti9 auhKQJXWHNtr68zYYHgcMGUj5hx2pwBcZsRj20kEkThmCtRXJYj1h48r5yAD8wAh UiCHCF/Aq+bnfAYJ4SKKhIikVr3+wLN5fDueEDnLvsBh+ysR0GkeVu7c1VzRN5kE RelL2h325spcznzTdmPGEBxeKaq30EnDJF2G4+1RKH6SYeYPLAyc0b1mdCGbwkDl 86YqJ9vxsaFGz6FoT/6XIotKGm6TDQqrLKz2AVHRb3sdaJYBbjfpZn0yg3a+RqAH LxVy3Lg+XgTwvrBXM140 =3fnq -----END PGP SIGNATURE----- --ivjvzgoh5aquax6g-- --===============1620917934== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1620917934==--