Re: [PATCH] drm: ast: fix double __iomem sparse warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Randy,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on linus/master v5.9-rc1 next-20200818]
[cannot apply to linux/master drm-intel/for-linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Randy-Dunlap/drm-ast-fix-double-__iomem-sparse-warning/20200819-043022
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: i386-randconfig-s002-20200818 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-183-gaa6ede3b-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/ast/ast_cursor.c:42:59: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void *vaddr @@     got void [noderef] __iomem * @@
>> drivers/gpu/drm/ast/ast_cursor.c:42:59: sparse:     expected void *vaddr
>> drivers/gpu/drm/ast/ast_cursor.c:42:59: sparse:     got void [noderef] __iomem *
>> drivers/gpu/drm/ast/ast_cursor.c:80:23: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __iomem *vaddr @@     got void * @@
>> drivers/gpu/drm/ast/ast_cursor.c:80:23: sparse:     expected void [noderef] __iomem *vaddr
>> drivers/gpu/drm/ast/ast_cursor.c:80:23: sparse:     got void *
   drivers/gpu/drm/ast/ast_cursor.c:98:59: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void *vaddr @@     got void [noderef] __iomem * @@
   drivers/gpu/drm/ast/ast_cursor.c:98:59: sparse:     expected void *vaddr
   drivers/gpu/drm/ast/ast_cursor.c:98:59: sparse:     got void [noderef] __iomem *
>> drivers/gpu/drm/ast/ast_cursor.c:126:19: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/gpu/drm/ast/ast_cursor.c:126:16: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected unsigned char [noderef] [usertype] __iomem *dstxor @@     got unsigned char [usertype] * @@
>> drivers/gpu/drm/ast/ast_cursor.c:126:16: sparse:     expected unsigned char [noderef] [usertype] __iomem *dstxor
>> drivers/gpu/drm/ast/ast_cursor.c:126:16: sparse:     got unsigned char [usertype] *

# https://github.com/0day-ci/linux/commit/7e1ff39fdb33febec4c542a6be21c28b352eb588
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Randy-Dunlap/drm-ast-fix-double-__iomem-sparse-warning/20200819-043022
git checkout 7e1ff39fdb33febec4c542a6be21c28b352eb588
vim +42 drivers/gpu/drm/ast/ast_cursor.c

2ccebf561e4a902 Thomas Zimmermann 2020-07-02   34  
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   35  static void ast_cursor_fini(struct ast_private *ast)
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   36  {
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   37  	size_t i;
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   38  	struct drm_gem_vram_object *gbo;
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   39  
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   40  	for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   41  		gbo = ast->cursor.gbo[i];
3e9d787371eaa84 Thomas Zimmermann 2020-07-02  @42  		drm_gem_vram_vunmap(gbo, ast->cursor.vaddr[i]);
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   43  		drm_gem_vram_unpin(gbo);
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   44  		drm_gem_vram_put(gbo);
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   45  	}
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   46  }
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   47  
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   48  static void ast_cursor_release(struct drm_device *dev, void *ptr)
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   49  {
365c0e70da83a52 Thomas Zimmermann 2020-07-30   50  	struct ast_private *ast = to_ast_private(dev);
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   51  
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   52  	ast_cursor_fini(ast);
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   53  }
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   54  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   55  /*
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   56   * Allocate cursor BOs and pins them at the end of VRAM.
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   57   */
beb2355eecbf67d Thomas Zimmermann 2020-07-02   58  int ast_cursor_init(struct ast_private *ast)
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   59  {
e0f5a738cfe572b Thomas Zimmermann 2020-07-30   60  	struct drm_device *dev = &ast->base;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   61  	size_t size, i;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   62  	struct drm_gem_vram_object *gbo;
0d384eec10ea723 Thomas Zimmermann 2020-07-02   63  	void __iomem *vaddr;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   64  	int ret;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   65  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   66  	size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   67  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   68  	for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   69  		gbo = drm_gem_vram_create(dev, size, 0);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   70  		if (IS_ERR(gbo)) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   71  			ret = PTR_ERR(gbo);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   72  			goto err_drm_gem_vram_put;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   73  		}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   74  		ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM |
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   75  					    DRM_GEM_VRAM_PL_FLAG_TOPDOWN);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   76  		if (ret) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   77  			drm_gem_vram_put(gbo);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   78  			goto err_drm_gem_vram_put;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   79  		}
0d384eec10ea723 Thomas Zimmermann 2020-07-02  @80  		vaddr = drm_gem_vram_vmap(gbo);
0d384eec10ea723 Thomas Zimmermann 2020-07-02   81  		if (IS_ERR(vaddr)) {
0d384eec10ea723 Thomas Zimmermann 2020-07-02   82  			ret = PTR_ERR(vaddr);
0d384eec10ea723 Thomas Zimmermann 2020-07-02   83  			drm_gem_vram_unpin(gbo);
0d384eec10ea723 Thomas Zimmermann 2020-07-02   84  			drm_gem_vram_put(gbo);
0d384eec10ea723 Thomas Zimmermann 2020-07-02   85  			goto err_drm_gem_vram_put;
0d384eec10ea723 Thomas Zimmermann 2020-07-02   86  		}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   87  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   88  		ast->cursor.gbo[i] = gbo;
0d384eec10ea723 Thomas Zimmermann 2020-07-02   89  		ast->cursor.vaddr[i] = vaddr;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   90  	}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   91  
3e9d787371eaa84 Thomas Zimmermann 2020-07-02   92  	return drmm_add_action_or_reset(dev, ast_cursor_release, NULL);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   93  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   94  err_drm_gem_vram_put:
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   95  	while (i) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   96  		--i;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   97  		gbo = ast->cursor.gbo[i];
0d384eec10ea723 Thomas Zimmermann 2020-07-02   98  		drm_gem_vram_vunmap(gbo, ast->cursor.vaddr[i]);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02   99  		drm_gem_vram_unpin(gbo);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  100  		drm_gem_vram_put(gbo);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  101  	}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  102  	return ret;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  103  }
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  104  
932a62aa3bfd96e Thomas Zimmermann 2020-07-02  105  static void update_cursor_image(u8 __iomem *dst, const u8 *src, int width, int height)
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  106  {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  107  	union {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  108  		u32 ul;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  109  		u8 b[4];
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  110  	} srcdata32[2], data32;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  111  	union {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  112  		u16 us;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  113  		u8 b[2];
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  114  	} data16;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  115  	u32 csum = 0;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  116  	s32 alpha_dst_delta, last_alpha_dst_delta;
932a62aa3bfd96e Thomas Zimmermann 2020-07-02  117  	u8 __iomem *dstxor;
932a62aa3bfd96e Thomas Zimmermann 2020-07-02  118  	const u8 *srcxor;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  119  	int i, j;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  120  	u32 per_pixel_copy, two_pixel_copy;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  121  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  122  	alpha_dst_delta = AST_MAX_HWC_WIDTH << 1;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  123  	last_alpha_dst_delta = alpha_dst_delta - (width << 1);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  124  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  125  	srcxor = src;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02 @126  	dstxor = (u8 *)dst + last_alpha_dst_delta + (AST_MAX_HWC_HEIGHT - height) * alpha_dst_delta;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  127  	per_pixel_copy = width & 1;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  128  	two_pixel_copy = width >> 1;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  129  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  130  	for (j = 0; j < height; j++) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  131  		for (i = 0; i < two_pixel_copy; i++) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  132  			srcdata32[0].ul = *((u32 *)srcxor) & 0xf0f0f0f0;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  133  			srcdata32[1].ul = *((u32 *)(srcxor + 4)) & 0xf0f0f0f0;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  134  			data32.b[0] = srcdata32[0].b[1] | (srcdata32[0].b[0] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  135  			data32.b[1] = srcdata32[0].b[3] | (srcdata32[0].b[2] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  136  			data32.b[2] = srcdata32[1].b[1] | (srcdata32[1].b[0] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  137  			data32.b[3] = srcdata32[1].b[3] | (srcdata32[1].b[2] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  138  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  139  			writel(data32.ul, dstxor);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  140  			csum += data32.ul;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  141  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  142  			dstxor += 4;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  143  			srcxor += 8;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  144  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  145  		}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  146  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  147  		for (i = 0; i < per_pixel_copy; i++) {
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  148  			srcdata32[0].ul = *((u32 *)srcxor) & 0xf0f0f0f0;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  149  			data16.b[0] = srcdata32[0].b[1] | (srcdata32[0].b[0] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  150  			data16.b[1] = srcdata32[0].b[3] | (srcdata32[0].b[2] >> 4);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  151  			writew(data16.us, dstxor);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  152  			csum += (u32)data16.us;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  153  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  154  			dstxor += 2;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  155  			srcxor += 4;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  156  		}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  157  		dstxor += last_alpha_dst_delta;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  158  	}
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  159  
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  160  	/* write checksum + signature */
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  161  	dst += AST_HWC_SIZE;
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  162  	writel(csum, dst);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  163  	writel(width, dst + AST_HWC_SIGNATURE_SizeX);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  164  	writel(height, dst + AST_HWC_SIGNATURE_SizeY);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  165  	writel(0, dst + AST_HWC_SIGNATURE_HOTSPOTX);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  166  	writel(0, dst + AST_HWC_SIGNATURE_HOTSPOTY);
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  167  }
2ccebf561e4a902 Thomas Zimmermann 2020-07-02  168  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux