Lines Matching +full:512 +full:- +full:bytes

2  * atari_scsi.c -- Device dependent functions for the Atari generic SCSI port
4 * Copyright 1994 Roman Hodek <[email protected]-erlangen.de>
7 * - working real DMA
8 * - Falcon support (untested yet!) ++bjoern fixed and now it works
9 * - lots of extensions and bug fixes.
137 * scatter-gather anyway, so most transfers are 1024 byte only. In the rare
143 /* mask for address bits that can't be used with the ST-DMA */
147 static int setup_can_queue = -1;
149 static int setup_cmd_per_lun = -1;
151 static int setup_sg_tablesize = -1;
153 static int setup_hostid = -1;
155 static int setup_toshiba_delay = -1;
166 /* A bus error happens when DMA-ing from the last page of a in scsi_dma_is_ignored_buserr()
199 printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!"); in scsi_tt_intr()
205 * This means we have residual bytes, if the desired end address in scsi_tt_intr()
206 * is not yet reached. Maybe we have to fetch some bytes from the in scsi_tt_intr()
209 * addr reg counts bytes not yet written and pending in the rest in scsi_tt_intr()
213 atari_dma_residual = hostdata->dma_len - in scsi_tt_intr()
214 (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr); in scsi_tt_intr()
216 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", in scsi_tt_intr()
224 * transport some rest bytes in scsi_tt_intr()
229 * There seems to be a nasty bug in some SCSI-DMA/NCR in scsi_tt_intr()
232 * DMA may be a few bytes farer than it actually read. in scsi_tt_intr()
235 * dma_addr is 9 bytes to high, but this could vary. in scsi_tt_intr()
248 "difference %ld bytes\n", in scsi_tt_intr()
249 512 - (atari_dma_residual & 0x1ff)); in scsi_tt_intr()
256 /* If the DMA is finished, fetch the rest bytes and turn it off */ in scsi_tt_intr()
292 * calculate the number of residual bytes and give a warning if in scsi_falcon_intr()
293 * bytes are stuck in the ST-DMA fifo (there's no way to reach them!) in scsi_falcon_intr()
298 transferred = SCSI_DMA_GETADR() - atari_dma_startaddr; in scsi_falcon_intr()
299 /* The ST-DMA address is incremented in 2-byte steps, but the in scsi_falcon_intr()
300 * data are written only in 16-byte chunks. If the number of in scsi_falcon_intr()
301 * transferred bytes is not divisible by 16, the remainder is in scsi_falcon_intr()
305 printk(KERN_ERR "SCSI DMA error: %ld bytes lost in " in scsi_falcon_intr()
306 "ST-DMA fifo\n", transferred & 15); in scsi_falcon_intr()
308 atari_dma_residual = hostdata->dma_len - transferred; in scsi_falcon_intr()
309 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", in scsi_falcon_intr()
316 /* If the dribble buffer was used on a read operation, copy the DMA-ed in scsi_falcon_intr()
320 hostdata->dma_len - atari_dma_residual); in scsi_falcon_intr()
336 /* fetch rest bytes in the DMA register */ in atari_scsi_fetch_restbytes()
340 /* there are 'nr' bytes left for the last long address in atari_scsi_fetch_restbytes()
343 dprintk(NDEBUG_DMA, "SCSI DMA: there are %d rest bytes for phys addr 0x%08lx", in atari_scsi_fetch_restbytes()
348 for (src = (char *)&tt_scsi_dma.dma_restdata; nr != 0; --nr) in atari_scsi_fetch_restbytes()
367 /* This function manages the locking of the ST-DMA.
371 * command immediately but tell the SCSI mid-layer to defer.
428 hostdata->host->host_no, data, addr, count, dir); in atari_scsi_dma_setup()
431 /* If we have a non-DMAable address on a Falcon, use the dribble in atari_scsi_dma_setup()
447 * the ST-DMA begins to fill internal buffers right after setup. For in atari_scsi_dma_setup()
472 /* On writes, round up the transfer length to the next multiple of 512 in atari_scsi_dma_setup()
509 unsigned char opcode = cmd->cmnd[0]; in falcon_classify_cmd()
517 /* In case of a sequential-access target (tape), special care is in falcon_classify_cmd()
518 * needed here: The transfer is block-mode only if the 'fixed' bit is in falcon_classify_cmd()
520 if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) in falcon_classify_cmd()
529 /* This function calculates the number of bytes that can be transferred via
531 * ST-DMA chip. There are only multiples of 512 bytes possible and max.
532 * 255*512 bytes :-( This means also, that defining READ_OVERRUNS is not
534 * n*512 - atari_read_overrun bytes. But it seems that the Falcon doesn't have
535 * the overrun problem, so this question is academic :-)
541 int wanted_len = NCR5380_to_ncmd(cmd)->this_residual; in atari_scsi_dma_xfer_len()
548 /* TT SCSI DMA can transfer arbitrary #bytes */ in atari_scsi_dma_xfer_len()
551 /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max. in atari_scsi_dma_xfer_len()
552 * 255*512 bytes, but this should be enough) in atari_scsi_dma_xfer_len()
554 * ++roman: Aaargl! Another Falcon-SCSI problem... There are some commands in atari_scsi_dma_xfer_len()
555 * that return a number of bytes which cannot be known beforehand. In this in atari_scsi_dma_xfer_len()
557 * can happen that this allocation length is a multiple of 512 bytes and in atari_scsi_dma_xfer_len()
558 * the DMA is used. But if not n*512 bytes really arrive, some input data in atari_scsi_dma_xfer_len()
559 * will be lost in the ST-DMA's FIFO :-( Thus, we have to distinguish in atari_scsi_dma_xfer_len()
565 * The solution: We classify SCSI commands in 1) surely block-mode cmd.s, in atari_scsi_dma_xfer_len()
566 * 2) surely byte-mode cmd.s and 3) cmd.s with unknown mode. In case 1) in atari_scsi_dma_xfer_len()
573 * receiving a sufficient number of bytes. in atari_scsi_dma_xfer_len()
575 * Another point: If the transfer is from/to an non-ST-RAM address, we in atari_scsi_dma_xfer_len()
576 * use the dribble buffer and thus can do only STRAM_BUFFER_SIZE bytes. in atari_scsi_dma_xfer_len()
579 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in atari_scsi_dma_xfer_len()
581 * be rounded up to the next multiple of 512 (atari_dma_setup() does in atari_scsi_dma_xfer_len()
587 * 512, we cannot use DMA, since the ST-DMA cannot split transfers in atari_scsi_dma_xfer_len()
613 limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(NCR5380_to_ncmd(cmd)->ptr))) ? in atari_scsi_dma_xfer_len()
614 STRAM_BUFFER_SIZE : 255*512; in atari_scsi_dma_xfer_len()
619 dprintk(NDEBUG_DMA, "DMA transfer now %d bytes instead of %d\n", in atari_scsi_dma_xfer_len()
713 .dma_boundary = PAGE_SIZE - 1,
726 return -ENODEV; in atari_scsi_probe()
771 /* If running on a Falcon and if there's TT-Ram (i.e., more than one in atari_scsi_probe()
772 * memory block, since there's always ST-Ram in a Falcon), then in atari_scsi_probe()
780 pr_err(PFX "can't allocate ST-RAM double buffer\n"); in atari_scsi_probe()
781 return -ENOMEM; in atari_scsi_probe()
790 error = -ENOMEM; in atari_scsi_probe()
794 instance->irq = irq->start; in atari_scsi_probe()
804 error = request_irq(instance->irq, scsi_tt_intr, 0, in atari_scsi_probe()
808 instance->irq); in atari_scsi_probe()
811 tt_mfp.active_edge |= 0x80; /* SCSI int on L->H */ in atari_scsi_probe()
832 hostdata->read_overruns = 4; in atari_scsi_probe()
835 /* Nothing to do for the interrupt: the ST-DMA is initialized in atari_scsi_probe()
857 free_irq(instance->irq, instance); in atari_scsi_probe()
874 free_irq(instance->irq, instance); in atari_scsi_remove()