drivers/gpu/drm/drm_bufs.c:343:36: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Mon Aug 24 2020 - 13:27:40 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d012a7190fc1fd72ed48911e77ca97ba4521bccd
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces
date: 10 weeks ago
config: arc-randconfig-s032-20200824 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arc

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/drm_bufs.c:225:45: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *handle @@ got void [noderef] __iomem * @@
drivers/gpu/drm/drm_bufs.c:225:45: sparse: expected void *handle
drivers/gpu/drm/drm_bufs.c:225:45: sparse: got void [noderef] __iomem *
drivers/gpu/drm/drm_bufs.c:228:45: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *handle @@ got void [noderef] __iomem * @@
drivers/gpu/drm/drm_bufs.c:228:45: sparse: expected void *handle
drivers/gpu/drm/drm_bufs.c:228:45: sparse: got void [noderef] __iomem *
>> drivers/gpu/drm/drm_bufs.c:343:36: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *handle @@
>> drivers/gpu/drm/drm_bufs.c:343:36: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/drm_bufs.c:343:36: sparse: got void *handle
drivers/gpu/drm/drm_bufs.c:360:36: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *handle @@
drivers/gpu/drm/drm_bufs.c:360:36: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/drm_bufs.c:360:36: sparse: got void *handle
drivers/gpu/drm/drm_bufs.c:536:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *handle @@
drivers/gpu/drm/drm_bufs.c:536:28: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/drm_bufs.c:536:28: sparse: got void *handle
drivers/gpu/drm/drm_bufs.c: note: in included file (through include/linux/uaccess.h, include/linux/sched/task.h, include/linux/sched/signal.h, ...):
arch/arc/include/asm/uaccess.h:619:33: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char *d_char @@ got void [noderef] __user *to @@
arch/arc/include/asm/uaccess.h:619:33: sparse: expected unsigned char *d_char
arch/arc/include/asm/uaccess.h:619:33: sparse: got void [noderef] __user *to
--
>> drivers/gpu/drm/drm_vm.c:276:44: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *handle @@
>> drivers/gpu/drm/drm_vm.c:276:44: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/drm_vm.c:276:44: sparse: got void *handle
drivers/gpu/drm/drm_vm.c:487:51: sparse: sparse: undefined identifier '_PAGE_RW'
drivers/gpu/drm/drm_vm.c:571:51: sparse: sparse: undefined identifier '_PAGE_RW'
--
>> drivers/scsi/megaraid.c:4489:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void * @@
>> drivers/scsi/megaraid.c:4489:26: sparse: expected void const [noderef] __iomem *addr
drivers/scsi/megaraid.c:4489:26: sparse: got void *
drivers/scsi/megaraid.c:4548:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void * @@
drivers/scsi/megaraid.c:4548:26: sparse: expected void const [noderef] __iomem *addr
drivers/scsi/megaraid.c:4548:26: sparse: got void *
--
drivers/scsi/aic7xxx/aic7xxx_osm.c:1536:25: sparse: sparse: invalid assignment: |=
drivers/scsi/aic7xxx/aic7xxx_osm.c:1536:25: sparse: left side has type unsigned int
drivers/scsi/aic7xxx/aic7xxx_osm.c:1536:25: sparse: right side has type restricted __le32
drivers/scsi/aic7xxx/aic7xxx_osm.c:1541:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] sgptr @@ got restricted __le32 [usertype] @@
drivers/scsi/aic7xxx/aic7xxx_osm.c:1541:34: sparse: expected unsigned int [usertype] sgptr
drivers/scsi/aic7xxx/aic7xxx_osm.c:1541:34: sparse: got restricted __le32 [usertype]
drivers/scsi/aic7xxx/aic7xxx_osm.c:1551:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] sgptr @@ got restricted __le32 [usertype] @@
drivers/scsi/aic7xxx/aic7xxx_osm.c:1551:34: sparse: expected unsigned int [usertype] sgptr
drivers/scsi/aic7xxx/aic7xxx_osm.c:1551:34: sparse: got restricted __le32 [usertype]
drivers/scsi/aic7xxx/aic7xxx_osm.c:480:18: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] addr @@ got restricted __le32 [usertype] @@
drivers/scsi/aic7xxx/aic7xxx_osm.c:480:18: sparse: expected unsigned int [usertype] addr
drivers/scsi/aic7xxx/aic7xxx_osm.c:480:18: sparse: got restricted __le32 [usertype]
drivers/scsi/aic7xxx/aic7xxx_osm.c:487:17: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] len @@ got restricted __le32 [usertype] @@
drivers/scsi/aic7xxx/aic7xxx_osm.c:487:17: sparse: expected unsigned int [usertype] len
drivers/scsi/aic7xxx/aic7xxx_osm.c:487:17: sparse: got restricted __le32 [usertype]
>> drivers/scsi/aic7xxx/aic7xxx_osm.c:1241:41: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected void const [noderef] __iomem *addr @@ got unsigned char volatile [noderef] [usertype] __iomem *[usertype] maddr @@
>> drivers/scsi/aic7xxx/aic7xxx_osm.c:1241:41: sparse: expected void const [noderef] __iomem *addr
drivers/scsi/aic7xxx/aic7xxx_osm.c:1241:41: sparse: got unsigned char volatile [noderef] [usertype] __iomem *[usertype] maddr
--
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void [noderef] __user *__p @@ got unsigned int [usertype] * @@
>> drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: expected void [noderef] __user *__p
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: got unsigned int [usertype] *
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c:979:21: sparse: sparse: cast removes address space '__user' of expression
drivers/gpu/drm/radeon/radeon_ttm.c: note: in included file (through include/linux/uaccess.h, include/linux/sched/task.h, include/linux/sched/signal.h, ...):
arch/arc/include/asm/uaccess.h:619:33: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char *d_char @@ got void [noderef] __user *to @@
arch/arc/include/asm/uaccess.h:619:33: sparse: expected unsigned char *d_char
arch/arc/include/asm/uaccess.h:619:33: sparse: got void [noderef] __user *to
--
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:104:58: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got void * @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:104:58: sparse: expected void volatile [noderef] __iomem *addr
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:104:58: sparse: got void *
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:110:58: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void * @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:110:58: sparse: expected void const volatile [noderef] __iomem *addr
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:110:58: sparse: got void *
>> drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:157:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *[assigned] emap @@
>> drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:157:25: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:157:25: sparse: got void *[assigned] emap
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:174:19: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *map @@ got void [noderef] __iomem * @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:174:19: sparse: expected void *map
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:174:19: sparse: got void [noderef] __iomem *
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:225:28: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] __iomem * @@ got void *map @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:225:28: sparse: expected void [noderef] __iomem *
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:225:28: sparse: got void *map
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:233:28: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] __iomem * @@ got void *map @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:233:28: sparse: expected void [noderef] __iomem *
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:233:28: sparse: got void *map
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:240:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *map @@ got void *map @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:240:21: sparse: expected void [noderef] __iomem *map
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:240:21: sparse: got void *map
>> drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:327:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem *addr @@ got void *[assigned] map @@
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:327:25: sparse: expected void const [noderef] __iomem *addr
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c:327:25: sparse: got void *[assigned] map

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=670d0a4b10704667765f7d18f7592993d02783aa
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
vim +343 drivers/gpu/drm/drm_bufs.c

9a18664506dbce drivers/char/drm/drm_bufs.c Dave Airlie 2005-06-23 136
abee5491db9f33 drivers/gpu/drm/drm_bufs.c Benjamin Gaignard 2020-03-06 137 /*
f77d390c9779c4 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 138 * Core function to create a range of memory available for mapping by a
f77d390c9779c4 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 139 * non-root process.
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 140 *
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 141 * Adjusts the memory offset to its absolute value according to the mapping
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 142 * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 143 * applicable and if supported by the kernel.
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 144 */
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 145 static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
c60ce623bd1613 drivers/char/drm/drm_bufs.c Dave Airlie 2007-07-11 146 unsigned int size, enum drm_map_type type,
55910517af381e drivers/char/drm/drm_bufs.c Dave Airlie 2007-07-11 147 enum drm_map_flags flags,
55910517af381e drivers/char/drm/drm_bufs.c Dave Airlie 2007-07-11 148 struct drm_map_list **maplist)
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 149 {
f77d390c9779c4 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 150 struct drm_local_map *map;
55910517af381e drivers/char/drm/drm_bufs.c Dave Airlie 2007-07-11 151 struct drm_map_list *list;
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 152 unsigned long user_token;
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 153 int ret;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 154
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 155 map = kmalloc(sizeof(*map), GFP_KERNEL);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 156 if (!map)
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 157 return -ENOMEM;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 158
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 159 map->offset = offset;
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 160 map->size = size;
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 161 map->flags = flags;
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 162 map->type = type;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 163
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 164 /* Only allow shared memory to be removable since we only keep enough
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 165 * book keeping information about shared memory to allow for removal
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 166 * when processes fork.
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 167 */
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 168 if ((map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 169 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 170 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 171 }
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 172 DRM_DEBUG("offset = 0x%08llx, size = 0x%08lx, type = %d\n",
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 173 (unsigned long long)map->offset, map->size, map->type);
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 174
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 175 /* page-align _DRM_SHM maps. They are allocated here so there is no security
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 176 * hole created by that and it works around various broken drivers that use
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 177 * a non-aligned quantity to map the SAREA. --BenH
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 178 */
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 179 if (map->type == _DRM_SHM)
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 180 map->size = PAGE_ALIGN(map->size);
b674137755bbe2 drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-05-18 181
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 182 if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 183 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 184 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 185 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 186 map->mtrr = -1;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 187 map->handle = NULL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 188
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 189 switch (map->type) {
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 190 case _DRM_REGISTERS:
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 191 case _DRM_FRAME_BUFFER:
4b7fb9b5746554 drivers/gpu/drm/drm_bufs.c Jordan Crouse 2010-05-27 192 #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
8d2ea6258123d7 drivers/char/drm/drm_bufs.c Dave Airlie 2006-01-11 193 if (map->offset + (map->size-1) < map->offset ||
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 194 map->offset < virt_to_phys(high_memory)) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 195 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 196 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 197 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 198 #endif
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 199 /* Some drivers preinitialize some maps, without the X Server
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 200 * needing to be aware of it. Therefore, we just return success
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 201 * when the server tries to create a duplicate map.
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 202 */
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 203 list = drm_find_matching_map(dev, map);
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 204 if (list != NULL) {
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 205 if (list->map->size != map->size) {
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 206 DRM_DEBUG("Matching maps of type %d with "
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 207 "mismatched sizes, (%ld vs %ld)\n",
b5e89ed53ed8d2 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-25 208 map->type, map->size,
b5e89ed53ed8d2 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-25 209 list->map->size);
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 210 list->map->size = map->size;
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 211 }
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 212
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 213 kfree(map);
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 214 *maplist = list;
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 215 return 0;
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 216 }
836cf0465c422e drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 217
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 218 if (map->type == _DRM_FRAME_BUFFER ||
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 219 (map->flags & _DRM_WRITE_COMBINING)) {
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 220 map->mtrr =
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 221 arch_phys_wc_add(map->offset, map->size);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 222 }
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 223 if (map->type == _DRM_REGISTERS) {
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 224 if (map->flags & _DRM_WRITE_COMBINING)
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 @225 map->handle = ioremap_wc(map->offset,
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 226 map->size);
ff47eaf24d01b5 drivers/gpu/drm/drm_bufs.c Andy Lutomirski 2013-05-13 227 else
004a7727421fd2 drivers/char/drm/drm_bufs.c Christoph Hellwig 2007-01-08 228 map->handle = ioremap(map->offset, map->size);
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 229 if (!map->handle) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 230 kfree(map);
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 231 return -ENOMEM;
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 232 }
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 233 }
0769d39c993145 drivers/char/drm/drm_bufs.c Scott Thompson 2007-08-25 234
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 235 break;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 236 case _DRM_SHM:
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 237 list = drm_find_matching_map(dev, map);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 238 if (list != NULL) {
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 239 if (list->map->size != map->size) {
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 240 DRM_DEBUG("Matching maps of type %d with "
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 241 "mismatched sizes, (%ld vs %ld)\n",
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 242 map->type, map->size, list->map->size);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 243 list->map->size = map->size;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 244 }
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 245
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 246 kfree(map);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 247 *maplist = list;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 248 return 0;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 249 }
f239b7b0cac068 drivers/char/drm/drm_bufs.c Thomas Hellstrom 2007-01-08 250 map->handle = vmalloc_user(map->size);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 251 DRM_DEBUG("%lu %d %p\n",
04420c9c6a6d02 drivers/gpu/drm/drm_bufs.c Daniel Vetter 2013-07-10 252 map->size, order_base_2(map->size), map->handle);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 253 if (!map->handle) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 254 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 255 return -ENOMEM;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 256 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 257 map->offset = (unsigned long)map->handle;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 258 if (map->flags & _DRM_CONTAINS_LOCK) {
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 259 /* Prevent a 2nd X Server from creating a 2nd lock */
95c081c17f284d drivers/gpu/drm/drm_bufs.c Daniel Vetter 2016-06-21 260 if (dev->master->lock.hw_lock != NULL) {
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 261 vfree(map->handle);
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 262 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 263 return -EBUSY;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 264 }
95c081c17f284d drivers/gpu/drm/drm_bufs.c Daniel Vetter 2016-06-21 265 dev->sigdata.lock = dev->master->lock.hw_lock = map->handle; /* Pointer to lock */
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 266 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 267 break;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 268 case _DRM_AGP: {
55910517af381e drivers/char/drm/drm_bufs.c Dave Airlie 2007-07-11 269 struct drm_agp_mem *entry;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 270 int valid = 0;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 271
d9906753bb997d drivers/gpu/drm/drm_bufs.c Daniel Vetter 2013-12-11 272 if (!dev->agp) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 273 kfree(map);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 274 return -EINVAL;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 275 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 276 #ifdef __alpha__
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 277 map->offset += dev->hose->mem_space->start;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 278 #endif
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 279 /* In some cases (i810 driver), user space may have already
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 280 * added the AGP base itself, because dev->agp->base previously
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 281 * only got set during AGP enable. So, only add the base
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 282 * address if the map's offset isn't already within the
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 283 * aperture.
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 284 */
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 285 if (map->offset < dev->agp->base ||
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 286 map->offset > dev->agp->base +
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 287 dev->agp->agp_info.aper_size * 1024 * 1024 - 1) {
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 288 map->offset += dev->agp->base;
47a184a80800dd drivers/char/drm/drm_bufs.c Eric Anholt 2007-11-22 289 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 290 map->mtrr = dev->agp->agp_mtrr; /* for getmap */
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 291
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 292 /* This assumes the DRM is in total control of AGP space.
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 293 * It's not always the case as AGP can be in the control
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 294 * of user space (i.e. i810 driver). So this loop will get
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 295 * skipped and we double check that dev->agp->memory is
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 296 * actually set as well as being invalid before EPERM'ing
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 297 */
bd1b331fae2813 drivers/char/drm/drm_bufs.c Dave Airlie 2007-05-26 298 list_for_each_entry(entry, &dev->agp->memory, head) {
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 299 if ((map->offset >= entry->bound) &&
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 300 (map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) {
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 301 valid = 1;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 302 break;
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 303 }
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 304 }
bd1b331fae2813 drivers/char/drm/drm_bufs.c Dave Airlie 2007-05-26 305 if (!list_empty(&dev->agp->memory) && !valid) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 306 kfree(map);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 307 return -EPERM;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 308 }
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 309 DRM_DEBUG("AGP offset = 0x%08llx, size = 0x%08lx\n",
41c2e75e60200a drivers/gpu/drm/drm_bufs.c Benjamin Herrenschmidt 2009-02-02 310 (unsigned long long)map->offset, map->size);
54ba2f76e28128 drivers/char/drm/drm_bufs.c Dave Airlie 2007-02-10 311
a2c0a97b784f83 drivers/gpu/drm/drm_bufs.c Jesse Barnes 2008-11-05 312 break;
812c369dbf3b5a drivers/gpu/drm/drm_bufs.c Pekka Paalanen 2009-09-17 313 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 314 case _DRM_SCATTER_GATHER:
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 315 if (!dev->sg) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 316 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 317 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 318 }
d1f2b55ad2c11f drivers/char/drm/drm_bufs.c Dave Airlie 2005-08-05 319 map->offset += (unsigned long)dev->sg->virtual;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 320 break;
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 321 case _DRM_CONSISTENT:
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 322 /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G,
9c8da5ebbf6f87 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 323 * As we're limiting the address to 2^32-1 (or less),
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 324 * casting it down to 32 bits is no problem, but we
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 325 * need to point to a 64bit variable first. */
8e4ff9b5695728 drivers/gpu/drm/drm_bufs.c Chris Wilson 2020-02-02 326 map->handle = dma_alloc_coherent(&dev->pdev->dev,
8e4ff9b5695728 drivers/gpu/drm/drm_bufs.c Chris Wilson 2020-02-02 327 map->size,
8e4ff9b5695728 drivers/gpu/drm/drm_bufs.c Chris Wilson 2020-02-02 328 &map->offset,
8e4ff9b5695728 drivers/gpu/drm/drm_bufs.c Chris Wilson 2020-02-02 329 GFP_KERNEL);
8e4ff9b5695728 drivers/gpu/drm/drm_bufs.c Chris Wilson 2020-02-02 330 if (!map->handle) {
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 331 kfree(map);
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 332 return -ENOMEM;
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 333 }
2d0f9eaff8e1d0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 334 break;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 335 default:
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 336 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 337 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 338 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 339
94e3370eb9fc00 drivers/gpu/drm/drm_bufs.c Davidlohr Bueso 2010-08-11 340 list = kzalloc(sizeof(*list), GFP_KERNEL);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 341 if (!list) {
85abb3f95010b2 drivers/char/drm/drm_bufs.c Amol Lad 2006-10-25 342 if (map->type == _DRM_REGISTERS)
004a7727421fd2 drivers/char/drm/drm_bufs.c Christoph Hellwig 2007-01-08 @343 iounmap(map->handle);
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 344 kfree(map);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 345 return -EINVAL;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 346 }
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 347 list->map = map;
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 348
30e2fb18819490 drivers/char/drm/drm_bufs.c Dave Airlie 2006-02-02 349 mutex_lock(&dev->struct_mutex);
bd1b331fae2813 drivers/char/drm/drm_bufs.c Dave Airlie 2007-05-26 350 list_add(&list->head, &dev->maplist);
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 351
d1f2b55ad2c11f drivers/char/drm/drm_bufs.c Dave Airlie 2005-08-05 352 /* Assign a 32-bit handle */
30e2fb18819490 drivers/char/drm/drm_bufs.c Dave Airlie 2006-02-02 353 /* We do it here so that dev->struct_mutex protects the increment */
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 354 user_token = (map->type == _DRM_SHM) ? (unsigned long)map->handle :
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 355 map->offset;
f1a2a9b6189f9f drivers/gpu/drm/drm_bufs.c David Miller 2009-02-18 356 ret = drm_map_handle(dev, &list->hash, user_token, 0,
f1a2a9b6189f9f drivers/gpu/drm/drm_bufs.c David Miller 2009-02-18 357 (map->type == _DRM_SHM));
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 358 if (ret) {
85abb3f95010b2 drivers/char/drm/drm_bufs.c Amol Lad 2006-10-25 359 if (map->type == _DRM_REGISTERS)
004a7727421fd2 drivers/char/drm/drm_bufs.c Christoph Hellwig 2007-01-08 360 iounmap(map->handle);
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 361 kfree(map);
9a298b2acd771d drivers/gpu/drm/drm_bufs.c Eric Anholt 2009-03-24 362 kfree(list);
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 363 mutex_unlock(&dev->struct_mutex);
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 364 return ret;
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 365 }
8d153f7107ff2c drivers/char/drm/drm_bufs.c Thomas Hellstrom 2006-08-07 366
1545085a28f226 drivers/char/drm/drm_bufs.c Thomas Hellstrom 2007-02-08 367 list->user_token = list->hash.key << PAGE_SHIFT;
30e2fb18819490 drivers/char/drm/drm_bufs.c Dave Airlie 2006-02-02 368 mutex_unlock(&dev->struct_mutex);
^1da177e4c3f41 drivers/char/drm/drm_bufs.c Linus Torvalds 2005-04-16 369
2ff2e8a3e1898e drivers/gpu/drm/drm_bufs.c Ben Skeggs 2009-05-26 370 if (!(map->flags & _DRM_DRIVER))
95c081c17f284d drivers/gpu/drm/drm_bufs.c Daniel Vetter 2016-06-21 371 list->master = dev->master;
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 372 *maplist = list;
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 373 return 0;
7ab984012a879a drivers/char/drm/drm_bufs.c Dave Airlie 2005-07-10 374 }
89625eb186b9b0 drivers/char/drm/drm_bufs.c Dave Airlie 2005-09-05 375

:::::: The code at line 343 was first introduced by commit
:::::: 004a7727421fd202bbdfcc0231a3359085199a52 drm: remove drm_ioremap and drm_ioremapfree

:::::: TO: Christoph Hellwig <hch@xxxxxx>
:::::: CC: Dave Airlie <airlied@xxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip