Subject: asc_vsbus.c: the 64K DMA problem
To: None <port-vax@netbsd.org>
From: Chuck Cranor <chuck@research.att.com>
List: port-vax
Date: 09/10/2002 22:02:17
hi-

    i've got a vaxstation 4000/90 running a 1.6 kernel.

    after newfs'ing a large filesystem, i discovered that it
was not possible to fsck_ffs it.   fsck_ffs is failing because
of a short read: it issues a read(2) for 65536 bytes, but it
only gets 65521 back.    simple test program:

	vax[18]> cat dtest.c
	#include <fcntl.h>

	main(int argc, char **argv) 

	{
  	char buf[65536];
	  int fd, rv;
	
	  if (argc != 2) errx(1, "usage: dtest /dev/rsd...");
	
	  if ((fd = open(argv[1], O_RDONLY)) < 0) err(1, "open %s", argv[1]);
	
	  printf("read 65536 returns %d\n", read(fd, buf, sizeof(buf)));
	}
	vax[19]> ./dtest /dev/rsd0e
	read 65536 returns 65521
	vax[20]> 


that's not supposed to happen.

note that it works OK if size is a multiple of 512 <= to 64512
(which is 65536 - 512*2).


switching on some debugging statements in asc_vsbus.c shows this:

	asc0: start 65536@0x9a8d6668,0
	asc0: dma-load 64512@0x00000068
	asc_vsbus_intr: empty FIFO of 15 
	asc_vsbus_intr: tcl=0, tcm=0; trans=64497, resid=15

	asc0: start 1039@0x9a8e6259,0 
	asc0: dma-load 1039@0x00000059
	asc_vsbus_intr: tcl=15, tcm=0; trans=1024, resid=15


in the first transfer, the 65536 gets min()'d down to 64512
in asc_vsbus_dma_setup() because *dmasize is 64512 (why?).
then you get the "empty FIFO of 15" message and things go
downhill from there.



the debugging output from a successful read of 64512 doesn't
have any empty FIFO errors or secondary DMA transfers or 15
byte residuals:

	asc0: start 64512@0x9a8d6668,0
	asc0: dma-load 64512@0x00000068
	asc_vsbus_intr: tcl=0, tcm=0; trans=64512, resid=0




chuck