mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	[PATCH] USB: usbtest: scatterlist OUT data pattern testing
Previously, scatterlist tests didn't write patterned data.  Given how many
corner cases are addresed by them, this was a significant gap in Linux-USB
test coverage.  Moreover, when peripherals checked for correct data patterns,
false error reports would drown out the true ones.
This adds the pattern on the way OUT from the host, so scatterlist tests can
now be used to uncover bugs like host TX or peripheral RX paths failing for
back-to-back short packets.  It's easy enough to get an error there with at
least one of the {DMA,PIO}{RX,TX} code paths, or run into hardware races
that need to be defended against.
Note this patch doesn't add checking for correct data patterns on the way
IN from peripherals, just a FIXME for later.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
			
			
This commit is contained in:
		
							parent
							
								
									68ba61b89c
								
							
						
					
					
						commit
						8b52490193
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -381,6 +381,7 @@ alloc_sglist (int nents, int max, int vary)
 | 
			
		|||
 | 
			
		||||
	for (i = 0; i < nents; i++) {
 | 
			
		||||
		char		*buf;
 | 
			
		||||
		unsigned	j;
 | 
			
		||||
 | 
			
		||||
		buf = kzalloc (size, SLAB_KERNEL);
 | 
			
		||||
		if (!buf) {
 | 
			
		||||
| 
						 | 
				
			
			@ -391,6 +392,16 @@ alloc_sglist (int nents, int max, int vary)
 | 
			
		|||
		/* kmalloc pages are always physically contiguous! */
 | 
			
		||||
		sg_init_one(&sg[i], buf, size);
 | 
			
		||||
 | 
			
		||||
		switch (pattern) {
 | 
			
		||||
		case 0:
 | 
			
		||||
			/* already zeroed */
 | 
			
		||||
			break;
 | 
			
		||||
		case 1:
 | 
			
		||||
			for (j = 0; j < size; j++)
 | 
			
		||||
				*buf++ = (u8) (j % 63);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (vary) {
 | 
			
		||||
			size += vary;
 | 
			
		||||
			size %= max;
 | 
			
		||||
| 
						 | 
				
			
			@ -425,6 +436,8 @@ static int perform_sglist (
 | 
			
		|||
		usb_sg_wait (req);
 | 
			
		||||
		retval = req->status;
 | 
			
		||||
 | 
			
		||||
		/* FIXME check resulting data pattern */
 | 
			
		||||
 | 
			
		||||
		/* FIXME if endpoint halted, clear halt (and log) */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue