| .. | .. | 
|---|
| 1 |  | -/**  | 
|---|
 | 1 | +// SPDX-License-Identifier: GPL-2.0-only  | 
|---|
 | 2 | +/*  | 
|---|
| 2 | 3 |   * IBM Accelerator Family 'GenWQE' | 
|---|
| 3 | 4 |   * | 
|---|
| 4 | 5 |   * (C) Copyright IBM Corp. 2013 | 
|---|
| .. | .. | 
|---|
| 7 | 8 |   * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com> | 
|---|
| 8 | 9 |   * Author: Michael Jung <mijung@gmx.net> | 
|---|
| 9 | 10 |   * Author: Michael Ruettger <michael@ibmra.de> | 
|---|
| 10 |  | - *  | 
|---|
| 11 |  | - * This program is free software; you can redistribute it and/or modify  | 
|---|
| 12 |  | - * it under the terms of the GNU General Public License (version 2 only)  | 
|---|
| 13 |  | - * as published by the Free Software Foundation.  | 
|---|
| 14 |  | - *  | 
|---|
| 15 |  | - * This program is distributed in the hope that it will be useful,  | 
|---|
| 16 |  | - * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
|---|
| 17 |  | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
|---|
| 18 |  | - * GNU General Public License for more details.  | 
|---|
| 19 | 11 |   */ | 
|---|
| 20 | 12 |   | 
|---|
| 21 | 13 |  /* | 
|---|
| .. | .. | 
|---|
| 95 | 87 |   * @cfile:	Descriptor of opened file | 
|---|
| 96 | 88 |   * @u_addr:	User virtual address | 
|---|
| 97 | 89 |   * @size:	Size of buffer | 
|---|
| 98 |  | - * @dma_addr:	DMA address to be updated  | 
|---|
 | 90 | + * @virt_addr:	Virtual address to be updated  | 
|---|
| 99 | 91 |   * | 
|---|
| 100 | 92 |   * Return: Pointer to the corresponding mapping	NULL if not found | 
|---|
| 101 | 93 |   */ | 
|---|
| .. | .. | 
|---|
| 152 | 144 |   * @u_addr:	user virtual address | 
|---|
| 153 | 145 |   * @size:	size of buffer | 
|---|
| 154 | 146 |   * @dma_addr:	DMA address to be updated | 
|---|
 | 147 | + * @virt_addr:	Virtual address to be updated  | 
|---|
| 155 | 148 |   * Return: Pointer to the corresponding mapping	NULL if not found | 
|---|
| 156 | 149 |   */ | 
|---|
| 157 | 150 |  static struct dma_mapping *__genwqe_search_mapping(struct genwqe_file *cfile, | 
|---|
| .. | .. | 
|---|
| 257 | 250 |   | 
|---|
| 258 | 251 |  /** | 
|---|
| 259 | 252 |   * genwqe_kill_fasync() - Send signal to all processes with open GenWQE files | 
|---|
 | 253 | + * @cd: GenWQE device information  | 
|---|
 | 254 | + * @sig: Signal to send out  | 
|---|
| 260 | 255 |   * | 
|---|
| 261 | 256 |   * E.g. genwqe_send_signal(cd, SIGIO); | 
|---|
| 262 | 257 |   */ | 
|---|
| .. | .. | 
|---|
| 388 | 383 |   | 
|---|
| 389 | 384 |  /** | 
|---|
| 390 | 385 |   * genwqe_vma_close() - Called each time when vma is unmapped | 
|---|
 | 386 | + * @vma: VMA area to close  | 
|---|
| 391 | 387 |   * | 
|---|
| 392 | 388 |   * Free memory which got allocated by GenWQE mmap(). | 
|---|
| 393 | 389 |   */ | 
|---|
| .. | .. | 
|---|
| 424 | 420 |   | 
|---|
| 425 | 421 |  /** | 
|---|
| 426 | 422 |   * genwqe_mmap() - Provide contignous buffers to userspace | 
|---|
 | 423 | + * @filp:	File pointer (unused)  | 
|---|
 | 424 | + * @vma:	VMA area to map  | 
|---|
| 427 | 425 |   * | 
|---|
| 428 | 426 |   * We use mmap() to allocate contignous buffers used for DMA | 
|---|
| 429 | 427 |   * transfers. After the buffer is allocated we remap it to user-space | 
|---|
| .. | .. | 
|---|
| 492 | 490 |  	return rc; | 
|---|
| 493 | 491 |  } | 
|---|
| 494 | 492 |   | 
|---|
 | 493 | +#define	FLASH_BLOCK	0x40000	/* we use 256k blocks */  | 
|---|
 | 494 | +  | 
|---|
| 495 | 495 |  /** | 
|---|
| 496 | 496 |   * do_flash_update() - Excute flash update (write image or CVPD) | 
|---|
| 497 |  | - * @cd:        genwqe device  | 
|---|
 | 497 | + * @cfile:	Descriptor of opened file  | 
|---|
| 498 | 498 |   * @load:      details about image load | 
|---|
| 499 | 499 |   * | 
|---|
| 500 | 500 |   * Return: 0 if successful | 
|---|
| 501 | 501 |   */ | 
|---|
| 502 |  | -  | 
|---|
| 503 |  | -#define	FLASH_BLOCK	0x40000	/* we use 256k blocks */  | 
|---|
| 504 |  | -  | 
|---|
| 505 | 502 |  static int do_flash_update(struct genwqe_file *cfile, | 
|---|
| 506 | 503 |  			   struct genwqe_bitstream *load) | 
|---|
| 507 | 504 |  { | 
|---|
| .. | .. | 
|---|
| 828 | 825 |   | 
|---|
| 829 | 826 |  /** | 
|---|
| 830 | 827 |   * ddcb_cmd_cleanup() - Remove dynamically created fixup entries | 
|---|
 | 828 | + * @cfile:	Descriptor of opened file  | 
|---|
 | 829 | + * @req:	DDCB work request  | 
|---|
| 831 | 830 |   * | 
|---|
| 832 | 831 |   * Only if there are any. Pinnings are not removed. | 
|---|
| 833 | 832 |   */ | 
|---|
| .. | .. | 
|---|
| 852 | 851 |   | 
|---|
| 853 | 852 |  /** | 
|---|
| 854 | 853 |   * ddcb_cmd_fixups() - Establish DMA fixups/sglists for user memory references | 
|---|
 | 854 | + * @cfile:	Descriptor of opened file  | 
|---|
 | 855 | + * @req:	DDCB work request  | 
|---|
| 855 | 856 |   * | 
|---|
| 856 | 857 |   * Before the DDCB gets executed we need to handle the fixups. We | 
|---|
| 857 | 858 |   * replace the user-space addresses with DMA addresses or do | 
|---|
| .. | .. | 
|---|
| 982 | 983 |   | 
|---|
| 983 | 984 |  /** | 
|---|
| 984 | 985 |   * genwqe_execute_ddcb() - Execute DDCB using userspace address fixups | 
|---|
 | 986 | + * @cfile:	Descriptor of opened file  | 
|---|
 | 987 | + * @cmd:        Command identifier (passed from user)  | 
|---|
| 985 | 988 |   * | 
|---|
| 986 | 989 |   * The code will build up the translation tables or lookup the | 
|---|
| 987 | 990 |   * contignous memory allocation table to find the right translations | 
|---|
| .. | .. | 
|---|
| 1223 | 1226 |  	return rc; | 
|---|
| 1224 | 1227 |  } | 
|---|
| 1225 | 1228 |   | 
|---|
| 1226 |  | -#if defined(CONFIG_COMPAT)  | 
|---|
| 1227 |  | -/**  | 
|---|
| 1228 |  | - * genwqe_compat_ioctl() - Compatibility ioctl  | 
|---|
| 1229 |  | - *  | 
|---|
| 1230 |  | - * Called whenever a 32-bit process running under a 64-bit kernel  | 
|---|
| 1231 |  | - * performs an ioctl on /dev/genwqe<n>_card.  | 
|---|
| 1232 |  | - *  | 
|---|
| 1233 |  | - * @filp:        file pointer.  | 
|---|
| 1234 |  | - * @cmd:         command.  | 
|---|
| 1235 |  | - * @arg:         user argument.  | 
|---|
| 1236 |  | - * Return:       zero on success or negative number on failure.  | 
|---|
| 1237 |  | - */  | 
|---|
| 1238 |  | -static long genwqe_compat_ioctl(struct file *filp, unsigned int cmd,  | 
|---|
| 1239 |  | -				unsigned long arg)  | 
|---|
| 1240 |  | -{  | 
|---|
| 1241 |  | -	return genwqe_ioctl(filp, cmd, arg);  | 
|---|
| 1242 |  | -}  | 
|---|
| 1243 |  | -#endif /* defined(CONFIG_COMPAT) */  | 
|---|
| 1244 |  | -  | 
|---|
| 1245 | 1229 |  static const struct file_operations genwqe_fops = { | 
|---|
| 1246 | 1230 |  	.owner		= THIS_MODULE, | 
|---|
| 1247 | 1231 |  	.open		= genwqe_open, | 
|---|
| 1248 | 1232 |  	.fasync		= genwqe_fasync, | 
|---|
| 1249 | 1233 |  	.mmap		= genwqe_mmap, | 
|---|
| 1250 | 1234 |  	.unlocked_ioctl	= genwqe_ioctl, | 
|---|
| 1251 |  | -#if defined(CONFIG_COMPAT)  | 
|---|
| 1252 |  | -	.compat_ioctl   = genwqe_compat_ioctl,  | 
|---|
| 1253 |  | -#endif  | 
|---|
 | 1235 | +	.compat_ioctl   = compat_ptr_ioctl,  | 
|---|
| 1254 | 1236 |  	.release	= genwqe_release, | 
|---|
| 1255 | 1237 |  }; | 
|---|
| 1256 | 1238 |   | 
|---|
| .. | .. | 
|---|
| 1309 | 1291 |  		goto err_cdev; | 
|---|
| 1310 | 1292 |  	} | 
|---|
| 1311 | 1293 |   | 
|---|
| 1312 |  | -	rc = genwqe_init_debugfs(cd);  | 
|---|
| 1313 |  | -	if (rc != 0)  | 
|---|
| 1314 |  | -		goto err_debugfs;  | 
|---|
 | 1294 | +	genwqe_init_debugfs(cd);  | 
|---|
| 1315 | 1295 |   | 
|---|
| 1316 | 1296 |  	return 0; | 
|---|
| 1317 | 1297 |   | 
|---|
| 1318 |  | - err_debugfs:  | 
|---|
| 1319 |  | -	device_destroy(cd->class_genwqe, cd->devnum_genwqe);  | 
|---|
| 1320 | 1298 |   err_cdev: | 
|---|
| 1321 | 1299 |  	cdev_del(&cd->cdev_genwqe); | 
|---|
| 1322 | 1300 |   err_add: | 
|---|
| .. | .. | 
|---|
| 1372 | 1350 |   | 
|---|
| 1373 | 1351 |  /** | 
|---|
| 1374 | 1352 |   * genwqe_device_remove() - Remove genwqe's char device | 
|---|
 | 1353 | + * @cd: GenWQE device information  | 
|---|
| 1375 | 1354 |   * | 
|---|
| 1376 | 1355 |   * This function must be called after the client devices are removed | 
|---|
| 1377 | 1356 |   * because it will free the major/minor number range for the genwqe | 
|---|