* [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. @ 2018-02-28 15:27 Liviu Dudau 2018-02-28 15:40 ` Ville Syrjälä 0 siblings, 1 reply; 6+ messages in thread From: Liviu Dudau @ 2018-02-28 15:27 UTC (permalink / raw) To: DRI-devel Cc: Daniel Vetter, Sean Paul, David Airlie, Gustavo Padovan, Maarten Lankhorst, LKML, Liviu Dudau The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP ioctl expects that any capability set by the client will have a value of 1. Make the check early so that we don't have to test the value for each capability. Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> --- drivers/gpu/drm/drm_ioctl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index af782911c505..02ffa0e8d77b 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_set_client_cap *req = data; + if (req->value > 1) + return -EINVAL; + switch (req->capability) { case DRM_CLIENT_CAP_STEREO_3D: - if (req->value > 1) - return -EINVAL; file_priv->stereo_allowed = req->value; break; case DRM_CLIENT_CAP_UNIVERSAL_PLANES: - if (req->value > 1) - return -EINVAL; file_priv->universal_planes = req->value; break; case DRM_CLIENT_CAP_ATOMIC: if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) return -EINVAL; - if (req->value > 1) - return -EINVAL; file_priv->atomic = req->value; file_priv->universal_planes = req->value; break; -- 2.16.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. 2018-02-28 15:27 [PATCH] drm/drm_ioctl.c: Test client capability value early when setting Liviu Dudau @ 2018-02-28 15:40 ` Ville Syrjälä 2018-02-28 15:44 ` Liviu Dudau 0 siblings, 1 reply; 6+ messages in thread From: Ville Syrjälä @ 2018-02-28 15:40 UTC (permalink / raw) To: Liviu Dudau; +Cc: DRI-devel, David Airlie, Daniel Vetter, LKML On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > ioctl expects that any capability set by the client will have a value of 1. > Make the check early so that we don't have to test the value for each > capability. What if we want a a non-boolean capability at some point? > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> > --- > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > index af782911c505..02ffa0e8d77b 100644 > --- a/drivers/gpu/drm/drm_ioctl.c > +++ b/drivers/gpu/drm/drm_ioctl.c > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > { > struct drm_set_client_cap *req = data; > > + if (req->value > 1) > + return -EINVAL; > + > switch (req->capability) { > case DRM_CLIENT_CAP_STEREO_3D: > - if (req->value > 1) > - return -EINVAL; > file_priv->stereo_allowed = req->value; > break; > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > - if (req->value > 1) > - return -EINVAL; > file_priv->universal_planes = req->value; > break; > case DRM_CLIENT_CAP_ATOMIC: > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > return -EINVAL; > - if (req->value > 1) > - return -EINVAL; > file_priv->atomic = req->value; > file_priv->universal_planes = req->value; > break; > -- > 2.16.2 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrjälä Intel OTC ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. 2018-02-28 15:40 ` Ville Syrjälä @ 2018-02-28 15:44 ` Liviu Dudau 2018-02-28 15:57 ` Ville Syrjälä 0 siblings, 1 reply; 6+ messages in thread From: Liviu Dudau @ 2018-02-28 15:44 UTC (permalink / raw) To: Ville Syrjälä; +Cc: DRI-devel, David Airlie, Daniel Vetter, LKML On Wed, Feb 28, 2018 at 05:40:41PM +0200, Ville Syrjälä wrote: > On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > > ioctl expects that any capability set by the client will have a value of 1. > > Make the check early so that we don't have to test the value for each > > capability. > > What if we want a a non-boolean capability at some point? Well, I'm adding another boolean capability soon, so you will be going against the trend :) I guess you will have 2 options: revert the patch or add a condition to the test. I don't have strong feelings, just felt like too much copying when adding another capability so I thought to do some "cleanup". Best regards, Liviu > > > > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> > > --- > > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > index af782911c505..02ffa0e8d77b 100644 > > --- a/drivers/gpu/drm/drm_ioctl.c > > +++ b/drivers/gpu/drm/drm_ioctl.c > > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > > { > > struct drm_set_client_cap *req = data; > > > > + if (req->value > 1) > > + return -EINVAL; > > + > > switch (req->capability) { > > case DRM_CLIENT_CAP_STEREO_3D: > > - if (req->value > 1) > > - return -EINVAL; > > file_priv->stereo_allowed = req->value; > > break; > > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > > - if (req->value > 1) > > - return -EINVAL; > > file_priv->universal_planes = req->value; > > break; > > case DRM_CLIENT_CAP_ATOMIC: > > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > > return -EINVAL; > > - if (req->value > 1) > > - return -EINVAL; > > file_priv->atomic = req->value; > > file_priv->universal_planes = req->value; > > break; > > -- > > 2.16.2 > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > -- > Ville Syrjälä > Intel OTC -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. 2018-02-28 15:44 ` Liviu Dudau @ 2018-02-28 15:57 ` Ville Syrjälä 2018-02-28 16:34 ` Liviu Dudau 0 siblings, 1 reply; 6+ messages in thread From: Ville Syrjälä @ 2018-02-28 15:57 UTC (permalink / raw) To: Liviu Dudau; +Cc: DRI-devel, David Airlie, Daniel Vetter, LKML On Wed, Feb 28, 2018 at 03:44:44PM +0000, Liviu Dudau wrote: > On Wed, Feb 28, 2018 at 05:40:41PM +0200, Ville Syrjälä wrote: > > On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > > > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > > > ioctl expects that any capability set by the client will have a value of 1. > > > Make the check early so that we don't have to test the value for each > > > capability. > > > > What if we want a a non-boolean capability at some point? > > Well, I'm adding another boolean capability soon, so you will be going > against the trend :) Plenty of non-bools in driver specific counterparts I believe. > I guess you will have 2 options: revert the patch or add a condition to > the test. > > I don't have strong feelings, just felt like too much copying when > adding another capability so I thought to do some "cleanup". > > Best regards, > Liviu > > > > > > > > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> > > > --- > > > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > > index af782911c505..02ffa0e8d77b 100644 > > > --- a/drivers/gpu/drm/drm_ioctl.c > > > +++ b/drivers/gpu/drm/drm_ioctl.c > > > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > > > { > > > struct drm_set_client_cap *req = data; > > > > > > + if (req->value > 1) > > > + return -EINVAL; > > > + > > > switch (req->capability) { > > > case DRM_CLIENT_CAP_STEREO_3D: > > > - if (req->value > 1) > > > - return -EINVAL; > > > file_priv->stereo_allowed = req->value; > > > break; > > > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > > > - if (req->value > 1) > > > - return -EINVAL; > > > file_priv->universal_planes = req->value; > > > break; > > > case DRM_CLIENT_CAP_ATOMIC: > > > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > > > return -EINVAL; > > > - if (req->value > 1) > > > - return -EINVAL; > > > file_priv->atomic = req->value; > > > file_priv->universal_planes = req->value; > > > break; > > > -- > > > 2.16.2 > > > > > > _______________________________________________ > > > dri-devel mailing list > > > dri-devel@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- > > Ville Syrjälä > > Intel OTC > > -- > ==================== > | I would like to | > | fix the world, | > | but they're not | > | giving me the | > \ source code! / > --------------- > ¯\_(ツ)_/¯ -- Ville Syrjälä Intel OTC ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. 2018-02-28 15:57 ` Ville Syrjälä @ 2018-02-28 16:34 ` Liviu Dudau 2018-03-06 10:13 ` Daniel Vetter 0 siblings, 1 reply; 6+ messages in thread From: Liviu Dudau @ 2018-02-28 16:34 UTC (permalink / raw) To: Ville Syrjälä; +Cc: DRI-devel, David Airlie, Daniel Vetter, LKML On Wed, Feb 28, 2018 at 05:57:15PM +0200, Ville Syrjälä wrote: > On Wed, Feb 28, 2018 at 03:44:44PM +0000, Liviu Dudau wrote: > > On Wed, Feb 28, 2018 at 05:40:41PM +0200, Ville Syrjälä wrote: > > > On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > > > > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > > > > ioctl expects that any capability set by the client will have a value of 1. > > > > Make the check early so that we don't have to test the value for each > > > > capability. > > > > > > What if we want a a non-boolean capability at some point? > > > > Well, I'm adding another boolean capability soon, so you will be going > > against the trend :) > > Plenty of non-bools in driver specific counterparts I believe. So, is that a NACK? > > > I guess you will have 2 options: revert the patch or add a condition to > > the test. > > > > I don't have strong feelings, just felt like too much copying when > > adding another capability so I thought to do some "cleanup". > > > > Best regards, > > Liviu > > > > > > > > > > > > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> > > > > --- > > > > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > > > index af782911c505..02ffa0e8d77b 100644 > > > > --- a/drivers/gpu/drm/drm_ioctl.c > > > > +++ b/drivers/gpu/drm/drm_ioctl.c > > > > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > > > > { > > > > struct drm_set_client_cap *req = data; > > > > > > > > + if (req->value > 1) > > > > + return -EINVAL; > > > > + > > > > switch (req->capability) { > > > > case DRM_CLIENT_CAP_STEREO_3D: > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->stereo_allowed = req->value; > > > > break; > > > > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->universal_planes = req->value; > > > > break; > > > > case DRM_CLIENT_CAP_ATOMIC: > > > > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > > > > return -EINVAL; > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->atomic = req->value; > > > > file_priv->universal_planes = req->value; > > > > break; > > > > -- > > > > 2.16.2 > > > > > > > > _______________________________________________ > > > > dri-devel mailing list > > > > dri-devel@lists.freedesktop.org > > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > > > -- > > > Ville Syrjälä > > > Intel OTC > > > > -- > > ==================== > > | I would like to | > > | fix the world, | > > | but they're not | > > | giving me the | > > \ source code! / > > --------------- > > ¯\_(ツ)_/¯ > > -- > Ville Syrjälä > Intel OTC -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. 2018-02-28 16:34 ` Liviu Dudau @ 2018-03-06 10:13 ` Daniel Vetter 0 siblings, 0 replies; 6+ messages in thread From: Daniel Vetter @ 2018-03-06 10:13 UTC (permalink / raw) To: Liviu Dudau Cc: Ville Syrjälä, DRI-devel, David Airlie, Daniel Vetter, LKML On Wed, Feb 28, 2018 at 04:34:30PM +0000, Liviu Dudau wrote: > On Wed, Feb 28, 2018 at 05:57:15PM +0200, Ville Syrjälä wrote: > > On Wed, Feb 28, 2018 at 03:44:44PM +0000, Liviu Dudau wrote: > > > On Wed, Feb 28, 2018 at 05:40:41PM +0200, Ville Syrjälä wrote: > > > > On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > > > > > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > > > > > ioctl expects that any capability set by the client will have a value of 1. > > > > > Make the check early so that we don't have to test the value for each > > > > > capability. > > > > > > > > What if we want a a non-boolean capability at some point? > > > > > > Well, I'm adding another boolean capability soon, so you will be going > > > against the trend :) > > > > Plenty of non-bools in driver specific counterparts I believe. > > So, is that a NACK? Yeah I think this is overoptimizing for not repeating code. -Daniel > > > > > > > I guess you will have 2 options: revert the patch or add a condition to > > > the test. > > > > > > I don't have strong feelings, just felt like too much copying when > > > adding another capability so I thought to do some "cleanup". > > > > > > Best regards, > > > Liviu > > > > > > > > > > > > > > > > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> > > > > > --- > > > > > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > > > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > > > > index af782911c505..02ffa0e8d77b 100644 > > > > > --- a/drivers/gpu/drm/drm_ioctl.c > > > > > +++ b/drivers/gpu/drm/drm_ioctl.c > > > > > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > > > > > { > > > > > struct drm_set_client_cap *req = data; > > > > > > > > > > + if (req->value > 1) > > > > > + return -EINVAL; > > > > > + > > > > > switch (req->capability) { > > > > > case DRM_CLIENT_CAP_STEREO_3D: > > > > > - if (req->value > 1) > > > > > - return -EINVAL; > > > > > file_priv->stereo_allowed = req->value; > > > > > break; > > > > > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > > > > > - if (req->value > 1) > > > > > - return -EINVAL; > > > > > file_priv->universal_planes = req->value; > > > > > break; > > > > > case DRM_CLIENT_CAP_ATOMIC: > > > > > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > > > > > return -EINVAL; > > > > > - if (req->value > 1) > > > > > - return -EINVAL; > > > > > file_priv->atomic = req->value; > > > > > file_priv->universal_planes = req->value; > > > > > break; > > > > > -- > > > > > 2.16.2 > > > > > > > > > > _______________________________________________ > > > > > dri-devel mailing list > > > > > dri-devel@lists.freedesktop.org > > > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > > > > > -- > > > > Ville Syrjälä > > > > Intel OTC > > > > > > -- > > > ==================== > > > | I would like to | > > > | fix the world, | > > > | but they're not | > > > | giving me the | > > > \ source code! / > > > --------------- > > > ¯\_(ツ)_/¯ > > > > -- > > Ville Syrjälä > > Intel OTC > > -- > ==================== > | I would like to | > | fix the world, | > | but they're not | > | giving me the | > \ source code! / > --------------- > ¯\_(ツ)_/¯ -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-06 10:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-02-28 15:27 [PATCH] drm/drm_ioctl.c: Test client capability value early when setting Liviu Dudau 2018-02-28 15:40 ` Ville Syrjälä 2018-02-28 15:44 ` Liviu Dudau 2018-02-28 15:57 ` Ville Syrjälä 2018-02-28 16:34 ` Liviu Dudau 2018-03-06 10:13 ` Daniel Vetter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox