[Intel-gfx] [PATCH] drm: Simplify GETRESOURCES ioctl

Daniel Vetter daniel at ffwll.ch
Mon Dec 12 09:24:59 UTC 2016


On Sun, Dec 11, 2016 at 07:53:42PM +0000, Chris Wilson wrote:
> On Sun, Dec 11, 2016 at 08:20:19PM +0100, Daniel Vetter wrote:
> > Looping twice when we can do it once is silly. Also use a consistent
> > style. Note that there's a good race with the connector list walking,
> > since that is no longer protected by mode_config.mutex. But that's for
> > a later patch to fix.
> > 
> > v2: Actually try to not blow up, somehow I lost the hunk that checks
> > we don't copy too much. Noticed by Chris.
> > 
> > v3:
> > - squash all drm_mode_getresources cleanups into one
> > - use consistent style for walking objects (Chris)
> > 
> > v4:
> > - Use u64_to_user_ptr (Chris)
> > - Don't forget to copy the last connector (Chris)
> > 
> > v5: Chris was right ...

And CI finally concurred that v5 works ;-)

> > Cc: Chris Wilson <chris at chris-wilson.co.uk>
> > Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c | 111 ++++++++++++++------------------------
> >  1 file changed, 39 insertions(+), 72 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 2735a5847ffa..b1e8bbceaf39 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -84,17 +84,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
> >  			  struct drm_file *file_priv)
> >  {
> >  	struct drm_mode_card_res *card_res = data;
> > -	struct list_head *lh;
> >  	struct drm_framebuffer *fb;
> >  	struct drm_connector *connector;
> >  	struct drm_crtc *crtc;
> >  	struct drm_encoder *encoder;
> > -	int ret = 0;
> > -	int connector_count = 0;
> > -	int crtc_count = 0;
> > -	int fb_count = 0;
> > -	int encoder_count = 0;
> > -	int copied = 0;
> > +	int count, ret = 0;
> 
> I'm down to a minor int but uABI uses u32. This being C, it all comes
> out in the wash. One day we may have -Wsign-compare, but not today!
> 
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

Thanks for the review, applied to -misc. Can I volunteer you for 1-3 too
please?

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


More information about the Intel-gfx mailing list