drm/nouveau: sparse cleanups for undeclared vs. static
Subsystems (3)
PATCH 1/7 drm/nouveau: sparse cleanups for undeclared vs. static
Module parameters declarations moved to nouveau_drv.h. Ioctl table declarations moved to nouveau_drv.h. nouveau_ioc32.c: include nouveau_drv.h for nouveau_compat_ioctl().
--- drivers/gpu/drm/nouveau/nouveau_bios.c | 3 --- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 -- drivers/gpu/drm/nouveau/nouveau_drv.c | 3 --- drivers/gpu/drm/nouveau/nouveau_drv.h | 9 +++++++++ drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 -- drivers/gpu/drm/nouveau/nouveau_ioc32.c | 2 +- drivers/gpu/drm/nouveau/nouveau_mem.c | 2 -- 7 files changed, 10 insertions(+), 13 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bios.c +0 -3
@@ -3249,9 +3249,6 @@ int nouveau_bios_parse_lvds_table(struct drm_device *dev, int pxclk, bool *dl, breturn 0 ; } -extern int nouveau_uscript_lvds; -extern int nouveau_uscript_tmds; -int nouveau_bios_run_display_table (struct drm_device *dev,struct dcb_entry *dcbent,int pxclk)
drivers/gpu/drm/nouveau/nouveau_connector.c +0 -2
@@ -34,8 +34,6 @@#include "nouveau_connector.h" #include "nouveau_hw.h" -extern int nouveau_duallink; -static struct nouveau_encoder *nouveau_connector_encoder_get (struct drm_connector *connector,int type) {
drivers/gpu/drm/nouveau/nouveau_drv.c +0 -3
@@ -277,9 +277,6 @@ nouveau_pci_resume(struct pci_dev *pdev)return 0 ; } -extern struct drm_ioctl_desc nouveau_ioctls[]; -extern int nouveau_max_ioctl; -static struct drm_driver driver = { .driver_features = DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
drivers/gpu/drm/nouveau/nouveau_drv.h +9 -0
@@ -606,6 +606,13 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) (ch) = nv->fifos[(id)]; \ }while (0 ) +/* nouveau_drv.c */ +extern int nouveau_noagp; +extern int nouveau_duallink; +extern int nouveau_uscript_lvds; +extern int nouveau_uscript_tmds; +extern int nouveau_fbpercrtc; +/* nouveau_state.c */ extern void nouveau_preclose (struct drm_device *dev,struct drm_file *);extern int nouveau_load (struct drm_device *,unsigned long flags);
@@ -658,6 +665,8 @@ extern int nouveau_ioctl_notifier_free(struct drm_device *, void *data, struct drm_file *);/* nouveau_fifo.c */ +extern struct drm_ioctl_desc nouveau_ioctls[]; +extern int nouveau_max_ioctl;extern int nouveau_fifo_init (struct drm_device *);extern int nouveau_fifo_ctx_size (struct drm_device *);extern void nouveau_fifo_cleanup (struct drm_device *,struct drm_file *);
drivers/gpu/drm/nouveau/nouveau_fbcon.c +0 -2
@@ -47,8 +47,6 @@#include "nouveau_fbcon.h" #include "nouveau_dma.h" -extern int nouveau_fbpercrtc; -static int nouveau_fbcon_sync (struct fb_info *info) {
drivers/gpu/drm/nouveau/nouveau_ioc32.c +1 -1
@@ -36,7 +36,7 @@#include "drmP.h" #include "drm.h" -#include "nouveau_drm.h" +#include "nouveau_drv.h" /** * Called whenever a 32-bit process running under a 64-bit kernel
drivers/gpu/drm/nouveau/nouveau_mem.c +0 -2
@@ -35,8 +35,6 @@#include "drm_sarea.h" #include "nouveau_drv.h" -extern int nouveau_noagp; -static struct mem_block *split_block (struct mem_block *p,uint64_t start,uint64_t size,struct drm_file *file_priv)
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/7 drm/nouveau: collect switch blocks in nouveau_fbcon.c
The two large switch blocks are refactored into a function. While doing this, some inconsistencies are corrected:
- in nouveau_fbcon_check_var(), case 30 was writing to a wrong structure.
- in nouveau_fbcon_create(), case 16 was missing transp.length.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 156 ++++++++++--------------------- 1 files changed, 51 insertions(+), 105 deletions(-)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +51 -105
@@ -153,46 +153,15 @@ static int nouveau_fbcon_setcolreg(unsigned regno, unsigned red, unsigned green,return 0 ; } -static int nouveau_fbcon_check_var (struct fb_var_screeninfo *var, -struct fb_info *info) +static int nouveau_fbcon_set_color_fields (int depth, +struct fb_var_screeninfo *var) { -struct nouveau_fbcon_par *par = info->par; -struct nouveau_framebuffer *nouveau_fb = par->nouveau_fb; -struct drm_device *dev = par->dev; -struct drm_framebuffer *fb = &nouveau_fb->base; -int depth; - -/* Need to resize the fb object !!! */ -if (var->xres > fb->width || var->yres > fb->height) { -NV_ERROR (dev,"Requested width/height is greater than current fb object %dx%d > %dx%d\n" ,var->xres,var->yres,fb->width,fb->height); -NV_ERROR (dev,"Need resizing code.\n" ); -return -EINVAL ; - } - -switch (var->bits_per_pixel) { -case 16 : - depth = (var->green.length ==6 ) ?16 :15 ; -break ; -case 32 : -if (var->transp.length ==2 ) - depth =30 ; -else -if (var->transp.length >0 ) - depth =32 ; -else - depth =24 ; -break ; -default : - depth = var->bits_per_pixel; -break ; - } -switch (depth) {case 8 : var->red.offset =0 ; var->green.offset =0 ; var->blue.offset =0 ; - var->red.length =8 ; + var->red.length =8 ;/* 8-bit DAC */ var->green.length =8 ; var->blue.length =8 ; var->transp.length =0 ;
@@ -229,14 +198,14 @@ static int nouveau_fbcon_check_var(struct fb_var_screeninfo *var, var->transp.offset =0 ;break ;case 30 : - info->var.red.offset =0 ; - info->var.green.offset =10 ; - info->var.blue.offset =20 ; - info->var.red.length =10 ; - info->var.green.length =10 ; - info->var.blue.length =10 ; - info->var.transp.offset =30 ; - info->var.transp.length =2 ; + var->red.offset =0 ; + var->green.offset =10 ; + var->blue.offset =20 ; + var->red.length =10 ; + var->green.length =10 ; + var->blue.length =10 ; + var->transp.offset =30 ; + var->transp.length =2 ;break ;case 32 : var->red.offset =16 ;
@@ -251,6 +220,45 @@ static int nouveau_fbcon_check_var(struct fb_var_screeninfo *var,default :return -EINVAL ; } +return 0 ; +} + +static int nouveau_fbcon_check_var (struct fb_var_screeninfo *var, +struct fb_info *info) +{ +struct nouveau_fbcon_par *par = info->par; +struct nouveau_framebuffer *nouveau_fb = par->nouveau_fb; +struct drm_device *dev = par->dev; +struct drm_framebuffer *fb = &nouveau_fb->base; +int depth; + +/* Need to resize the fb object !!! */ +if (var->xres > fb->width || var->yres > fb->height) { +NV_ERROR (dev,"Requested width/height is greater than current fb object %dx%d > %dx%d\n" ,var->xres,var->yres,fb->width,fb->height); +NV_ERROR (dev,"Need resizing code.\n" ); +return -EINVAL ; + } + +switch (var->bits_per_pixel) { +case 16 : + depth = (var->green.length ==6 ) ?16 :15 ; +break ; +case 32 : +if (var->transp.length ==2 ) + depth =30 ; +else +if (var->transp.length >0 ) + depth =32 ; +else + depth =24 ; +break ; +default : + depth = var->bits_per_pixel; +break ; + } + +if (nouveau_fbcon_set_color_fields (depth, var)) +return -EINVAL ;return 0 ; }
@@ -606,69 +614,7 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width, info->pixmap.flags =FB_PIXMAP_SYSTEM ; info->pixmap.scan_align =1 ; -switch (fb->depth) { -case 8 : - info->var.red.offset =0 ; - info->var.green.offset =0 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ;/* 8bit DAC */ - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =0 ; - info->var.transp.length =0 ; -break ; -case 15 : - info->var.red.offset =10 ; - info->var.green.offset =5 ; - info->var.blue.offset =0 ; - info->var.red.length =5 ; - info->var.green.length =5 ; - info->var.blue.length =5 ; - info->var.transp.offset =15 ; - info->var.transp.length =1 ; -break ; -case 16 : - info->var.red.offset =11 ; - info->var.green.offset =5 ; - info->var.blue.offset =0 ; - info->var.red.length =5 ; - info->var.green.length =6 ; - info->var.blue.length =5 ; - info->var.transp.offset =0 ; -break ; -case 24 : - info->var.red.offset =16 ; - info->var.green.offset =8 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ; - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =0 ; - info->var.transp.length =0 ; -break ; -case 30 : - info->var.red.offset =0 ; - info->var.green.offset =10 ; - info->var.blue.offset =20 ; - info->var.red.length =10 ; - info->var.green.length =10 ; - info->var.blue.length =10 ; - info->var.transp.offset =30 ; - info->var.transp.length =2 ; -break ; -case 32 : - info->var.red.offset =16 ; - info->var.green.offset =8 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ; - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =24 ; - info->var.transp.length =8 ; -break ; -default : -break ; - } +nouveau_fbcon_set_color_fields (fb->depth, &info->var); fb->fbdev = info;
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/7 drm/nouveau: FB_ACCEL_I830 in fbcon is wrong
fb_info::fix.accel field tells user space what kind of accelerations it can do via the framebuffer interface. Nouveau is definitely not i830, so set the field to FB_ACCEL_NONE. In the DRM world we have a lot better APIs for accelerated graphics.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -575,7 +575,7 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width, info->fix.xpanstep =1 ;/* doing it in hw */ info->fix.ypanstep =1 ;/* doing it in hw */ info->fix.ywrapstep =0 ; - info->fix.accel =FB_ACCEL_I830 ; + info->fix.accel =FB_ACCEL_NONE ; info->fix.type_aux =0 ; info->fbops = &nouveau_fbcon_ops;
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 4/7 drm/nouveau: convert struct down-cast macros to funcs
Turn macros, that cast parent class struct pointers to child class struct pointers, into static inline functions. Inline functions provide a little more type safety than the conversion macros, especially as several structs have the same parent member name.
Fixes one sparse warning.
Unfortunately, the same name cannot be at the same time a struct name, a function name and a variable name. Therefore some renames in nouveau_fbcon.c are necessary.
The macro nouveau_fdev() is not used and references to a member that does not exist. The macro is removed.
--- drivers/gpu/drm/nouveau/nouveau_connector.h | 7 +++++- drivers/gpu/drm/nouveau/nouveau_crtc.h | 6 ++++- drivers/gpu/drm/nouveau/nouveau_drv.h | 12 +++++----- drivers/gpu/drm/nouveau/nouveau_encoder.h | 6 ++++- drivers/gpu/drm/nouveau/nouveau_fb.h | 6 ++++- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 28 +++++++++++++------------- 6 files changed, 41 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/nouveau_connector.h +6 -1
@@ -45,7 +45,12 @@ struct nouveau_connector {struct edid *edid; }; -#define nouveau_connector (x) container_of((x), struct nouveau_connector, base) + +static inline struct nouveau_connector *nouveau_connector ( +struct drm_connector *con) +{ + return container_of(con, struct nouveau_connector, base); +}int nouveau_connector_create (struct drm_device *dev,int i2c_index,int type);
drivers/gpu/drm/nouveau/nouveau_crtc.h +5 -1
@@ -70,7 +70,11 @@ struct nouveau_crtc {int (*set_dither)(struct nouveau_crtc *crtc,bool on,bool update);int (*set_scale)(struct nouveau_crtc *crtc,int mode,bool update); }; -#define nouveau_crtc (x) container_of((x), struct nouveau_crtc, base) + +static inline struct nouveau_crtc *nouveau_crtc (struct drm_crtc *crtc) +{ + return container_of(crtc, struct nouveau_crtc, base); +}int nv50_crtc_create (struct drm_device *dev,int index);int nv50_cursor_init (struct nouveau_crtc *);
drivers/gpu/drm/nouveau/nouveau_drv.h +6 -6
@@ -51,12 +51,6 @@ struct nouveau_fpriv {#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) -#define nouveau_bdev (_bd) \ - container_of(_bd, struct drm_nouveau_private, ttm.bdev) - -#define nouveau_fdev (_fd) \ - container_of(_fd, struct drm_nouveau_private, ttm.fdev) -#include "nouveau_drm.h" #include "nouveau_reg.h" #include "nouveau_bios.h"
@@ -569,6 +563,12 @@ struct drm_nouveau_private {struct nouveau_channel *evo; }; +static inline struct drm_nouveau_private * +nouveau_bdev (struct ttm_bo_device *bd) +{ + return container_of(bd, struct drm_nouveau_private, ttm.bdev); +} +static inline int nouveau_bo_ref (struct nouveau_bo *ref,struct nouveau_bo **pnvbo) {
drivers/gpu/drm/nouveau/nouveau_encoder.h +5 -1
@@ -41,7 +41,11 @@ struct nouveau_encoder {struct nv04_output_reg restore; }; -#define nouveau_encoder (x) container_of((x), struct nouveau_encoder, base) + +static inline struct nouveau_encoder *nouveau_encoder (struct drm_encoder *enc) +{ + return container_of(enc, struct nouveau_encoder, base); +}int nv50_sor_create (struct drm_device *dev,struct dcb_entry *entry);int nv50_dac_create (struct drm_device *dev,struct dcb_entry *entry);
drivers/gpu/drm/nouveau/nouveau_fb.h +5 -1
@@ -32,7 +32,11 @@ struct nouveau_framebuffer {struct nouveau_bo *nvbo; }; -#define nouveau_framebuffer (x) container_of((x), struct nouveau_framebuffer, base) +static inline struct nouveau_framebuffer * +nouveau_framebuffer (struct drm_framebuffer *fb) +{ + return container_of(fb, struct nouveau_framebuffer, base); +}extern const struct drm_mode_config_funcs nouveau_mode_config_funcs;
drivers/gpu/drm/nouveau/nouveau_fbcon.c +14 -14
@@ -104,8 +104,8 @@ static int nouveau_fbcon_setcolreg(unsigned regno, unsigned red, unsigned green,int i;list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { -struct nouveau_crtc *nouveau_crtc =nouveau_crtc (crtc); -struct drm_mode_set *modeset = &nouveau_crtc->mode_set; +struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc); +struct drm_mode_set *modeset = &nv_crtc->mode_set;struct drm_framebuffer *fb = modeset->fb;for (i =0 ; i < par->crtc_count; i++)
@@ -283,7 +283,7 @@ static int nouveau_fbcon_set_par(struct fb_info *info)int ret;list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { -struct nouveau_crtc *nouveau_crtc =nouveau_crtc (crtc); +struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc);for (i =0 ; i < par->crtc_count; i++)if (crtc->base.id == par->crtc_ids[i])
@@ -292,9 +292,9 @@ static int nouveau_fbcon_set_par(struct fb_info *info)if (i == par->crtc_count)continue ; -if (crtc->fb == nouveau_crtc->mode_set.fb) { +if (crtc->fb == nv_crtc->mode_set.fb) {mutex_lock (&dev->mode_config.mutex); - ret = crtc->funcs->set_config (&nouveau_crtc->mode_set); + ret = crtc->funcs->set_config (&nv_crtc->mode_set);mutex_unlock (&dev->mode_config.mutex);if (ret)return ret;
@@ -311,7 +311,7 @@ static int nouveau_fbcon_pan_display(struct fb_var_screeninfo *var,struct drm_device *dev = par->dev;struct drm_mode_set *modeset;struct drm_crtc *crtc; -struct nouveau_crtc *nouveau_crtc; +struct nouveau_crtc *nv_crtc;int ret =0 ;int i;
@@ -323,8 +323,8 @@ static int nouveau_fbcon_pan_display(struct fb_var_screeninfo *var,if (i == par->crtc_count)continue ; - nouveau_crtc =nouveau_crtc (crtc); - modeset = &nouveau_crtc->mode_set; + nv_crtc =nouveau_crtc (crtc); + modeset = &nv_crtc->mode_set; modeset->x = var->xoffset; modeset->y = var->yoffset;
@@ -657,7 +657,7 @@ out:static int nouveau_fbcon_multi_fb_probe_crtc (struct drm_device *dev,struct drm_crtc *crtc) { -struct nouveau_crtc *nouveau_crtc =nouveau_crtc (crtc); +struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc);struct nouveau_framebuffer *nouveau_fb;struct drm_framebuffer *fb;struct drm_connector *connector;
@@ -678,13 +678,13 @@ static int nouveau_fbcon_multi_fb_probe_crtc(struct drm_device *dev, height = crtc->desired_mode->vdisplay;/* is there an fb bound to this crtc already */ -if (!nouveau_crtc->mode_set.fb) { +if (!nv_crtc->mode_set.fb) { ret =nouveau_fbcon_create (dev, width, height, width, height, &nouveau_fb);if (ret)return -EINVAL ; new_fb =1 ; }else { - fb = nouveau_crtc->mode_set.fb; + fb = nv_crtc->mode_set.fb; nouveau_fb =nouveau_framebuffer (fb);if ((nouveau_fb->base.width < width) || (nouveau_fb->base.height < height))return -EINVAL ;
@@ -693,7 +693,7 @@ static int nouveau_fbcon_multi_fb_probe_crtc(struct drm_device *dev, info = nouveau_fb->base.fbdev; par = info->par; - modeset = &nouveau_crtc->mode_set; + modeset = &nv_crtc->mode_set; modeset->fb = &nouveau_fb->base; conn_count =0 ;list_for_each_entry (connector, &dev->mode_config.connector_list, head) {
@@ -841,9 +841,9 @@ static int nouveau_fbcon_single_fb_probe(struct drm_device *dev)* set configuration. */ list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { -struct nouveau_crtc *nouveau_crtc =nouveau_crtc (crtc); +struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc); - modeset = &nouveau_crtc->mode_set; + modeset = &nv_crtc->mode_set; modeset->fb = &nouveau_fb->base; conn_count =0 ; list_for_each_entry(connector, &dev->mode_config.connector_list,
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 5/7 drm/nouveau: use PTR_ERR instead of a cast
A small cleanup in using the ERR_PTR API.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +3 -3
@@ -482,19 +482,19 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, pushbuf =u_memcpya (req->dwords, req->nr_dwords,sizeof (uint32_t ));if (IS_ERR (pushbuf)) -return (unsigned long )pushbuf; +return PTR_ERR (pushbuf); bo =u_memcpya (req->buffers, req->nr_buffers,sizeof (*bo));if (IS_ERR (bo)) {kfree (pushbuf); -return (unsigned long )bo; +return PTR_ERR (bo); } reloc =u_memcpya (req->relocs, req->nr_relocs,sizeof (*reloc));if (IS_ERR (reloc)) {kfree (bo);kfree (pushbuf); -return (unsigned long )reloc; +return PTR_ERR (reloc); }mutex_lock (&dev->struct_mutex);
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/7 drm/nouveau: expand some drm_os_linux macros
In a Linux tree there is no reason to use these macros anymore. Other DRM_* macros are IMO more readable than the Linux name, or they are non-trivial to expand.
--- drivers/gpu/drm/nouveau/nouveau_dma.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_drv.h | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fifo.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ioc32.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +2 -2
@@ -112,7 +112,7 @@ nouveau_dma_wait(struct nouveau_channel *chan, int size)if (get >NOUVEAU_DMA_SKIPS )break ; -DRM_UDELAY (1 ); +udelay (1 ); }if (i >= us_timeout)
@@ -133,7 +133,7 @@ nouveau_dma_wait(struct nouveau_channel *chan, int size)break ; } -DRM_UDELAY (1 ); +udelay (1 ); }return ret;
drivers/gpu/drm/nouveau/nouveau_drv.h +1 -1
@@ -600,7 +600,7 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)struct drm_nouveau_private *nv = dev->dev_private; \if (!nouveau_fifo_owner (dev, (cl), (id))) { \NV_ERROR (dev,"pid %d doesn't own channel %d\n" , \ -DRM_CURRENTPID , (id)); \ +task_pid_nr (current), (id)); \return -EPERM ; \ } \ (ch) = nv->fifos[(id)]; \
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -81,7 +81,7 @@ nouveau_fbcon_sync(struct fb_info *info) ret =0 ;break ; } -DRM_UDELAY (1 ); +udelay (1 ); }if (ret) {
drivers/gpu/drm/nouveau/nouveau_fence.c +1 -1
@@ -186,7 +186,7 @@ nouveau_fence_signalled(void *sync_obj, void *sync_arg)int nouveau_fence_wait (void *sync_obj,void *sync_arg,bool lazy,bool intr) { -unsigned long timeout = jiffies + (3 *DRM_HZ ); +unsigned long timeout = jiffies + (3 *HZ );int ret =0 ;__set_current_state (intr ?TASK_INTERRUPTIBLE :TASK_UNINTERRUPTIBLE );
drivers/gpu/drm/nouveau/nouveau_fifo.c +1 -1
@@ -680,4 +680,4 @@ struct drm_ioctl_desc nouveau_ioctls[] = { DRM_IOCTL_DEF(DRM_NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_AUTH), }; -int nouveau_max_ioctl =DRM_ARRAY_SIZE (nouveau_ioctls); +int nouveau_max_ioctl =ARRAY_SIZE (nouveau_ioctls);
drivers/gpu/drm/nouveau/nouveau_gem.c +2 -2
@@ -371,7 +371,7 @@ retry:if (apply_relocs) (*apply_relocs)++; -if (DRM_COPY_TO_USER ((void __user *)user_bo, b,sizeof (*b))) { +if (copy_to_user ((void __user *)user_bo, b,sizeof (*b))) { ret = -EFAULT ; goto out_unref; }
@@ -443,7 +443,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)if (!mem)return ERR_PTR (-ENOMEM ); -if (DRM_COPY_FROM_USER (mem, (void __user *)user, nmemb * size)) { +if (copy_from_user (mem, (void __user *)user, nmemb * size)) {kfree (mem);return ERR_PTR (-EFAULT ); }
drivers/gpu/drm/nouveau/nouveau_ioc32.c +1 -1
@@ -58,7 +58,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,return drm_compat_ioctl (filp, cmd, arg);#if 0 -if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (mga_compat_ioctls)) +if (nr <DRM_COMMAND_BASE +ARRAY_SIZE (mga_compat_ioctls)) fn = nouveau_compat_ioctls[nr -DRM_COMMAND_BASE ];#endif lock_kernel ();/* XXX for now */
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 7/7 drm/nouveau: fix and verify __user pointer casts
On 32-bit arch this fixes compiler warnings about casting an integer of different size to a pointer.
This also fixes sparse warnings about casting address spaces.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +8 -5
@@ -271,11 +271,13 @@ static int nouveau_gem_pushbuf_validate(struct nouveau_channel *chan, struct drm_file *file_priv, struct drm_nouveau_gem_pushbuf_bo *pbbo, - uint64_t user_bo, int nr_buffers, + uint64_t user_buffers, int nr_buffers, struct list_head *list, int *apply_relocs) { struct drm_device *dev = chan->dev;struct drm_nouveau_gem_pushbuf_bo *b; +struct drm_nouveau_gem_pushbuf_bo __user *user_pbbos = + (void __force __user *)(uintptr_t )user_buffers;struct nouveau_fence *prev_fence;struct nouveau_bo *nvbo;struct list_head *entry, *tmp;
@@ -358,7 +360,7 @@ retry: (nvbo->bo.mem.mem_type == TTM_PL_TT && b->presumed_domain & NOUVEAU_GEM_DOMAIN_GART))) { b++; - user_bo +=sizeof (*b); + user_pbbos++;continue ; }
@@ -371,13 +373,13 @@ retry:if (apply_relocs) (*apply_relocs)++; -if (copy_to_user ((void __user *)user_bo, b,sizeof (*b))) { +if (copy_to_user (user_pbbos, b,sizeof (*b))) { ret = -EFAULT ; goto out_unref; } b++; - user_bo +=sizeof (*b); + user_pbbos++; } out_unref:
@@ -438,12 +440,13 @@ static inline void * u_memcpya(uint64_t user, unsigned nmemb, unsigned size) { void *mem; +void __user *userptr = (void __force __user *)(uintptr_t )user; mem =kmalloc (nmemb * size,GFP_KERNEL );if (!mem)return ERR_PTR (-ENOMEM ); -if (copy_from_user (mem, (void __user *)user, nmemb * size)) { +if (copy_from_user (mem, userptr, nmemb * size)) {kfree (mem);return ERR_PTR (-EFAULT ); }
Signature · 1 line
1.6.3.3