Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

atari_scsi: Allow can_queue to be increased for Falcon

The benefit of limiting can_queue to 1 is that atari_scsi shares the
ST DMA chip more fairly with other drivers (e.g. falcon-ide).

Unfortunately, this can limit SCSI bus utilization. On systems without
IDE, atari_scsi should issue SCSI commands whenever it can arbitrate for
the bus. Make that possible by making can_queue configurable.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Finn Thain and committed by
Martin K. Petersen
ded155b5 a5217a86

+22 -61
+22 -61
drivers/scsi/atari_scsi.c
··· 14 14 * 15 15 */ 16 16 17 - 18 - /**************************************************************************/ 19 - /* */ 20 - /* Notes for Falcon SCSI: */ 21 - /* ---------------------- */ 22 - /* */ 23 - /* Since the Falcon SCSI uses the ST-DMA chip, that is shared among */ 24 - /* several device drivers, locking and unlocking the access to this */ 25 - /* chip is required. But locking is not possible from an interrupt, */ 26 - /* since it puts the process to sleep if the lock is not available. */ 27 - /* This prevents "late" locking of the DMA chip, i.e. locking it just */ 28 - /* before using it, since in case of disconnection-reconnection */ 29 - /* commands, the DMA is started from the reselection interrupt. */ 30 - /* */ 31 - /* Two possible schemes for ST-DMA-locking would be: */ 32 - /* 1) The lock is taken for each command separately and disconnecting */ 33 - /* is forbidden (i.e. can_queue = 1). */ 34 - /* 2) The DMA chip is locked when the first command comes in and */ 35 - /* released when the last command is finished and all queues are */ 36 - /* empty. */ 37 - /* The first alternative would result in bad performance, since the */ 38 - /* interleaving of commands would not be used. The second is unfair to */ 39 - /* other drivers using the ST-DMA, because the queues will seldom be */ 40 - /* totally empty if there is a lot of disk traffic. */ 41 - /* */ 42 - /* For this reasons I decided to employ a more elaborate scheme: */ 43 - /* - First, we give up the lock every time we can (for fairness), this */ 44 - /* means every time a command finishes and there are no other commands */ 45 - /* on the disconnected queue. */ 46 - /* - If there are others waiting to lock the DMA chip, we stop */ 47 - /* issuing commands, i.e. moving them onto the issue queue. */ 48 - /* Because of that, the disconnected queue will run empty in a */ 49 - /* while. Instead we go to sleep on a 'fairness_queue'. */ 50 - /* - If the lock is released, all processes waiting on the fairness */ 51 - /* queue will be woken. The first of them tries to re-lock the DMA, */ 52 - /* the others wait for the first to finish this task. After that, */ 53 - /* they can all run on and do their commands... */ 54 - /* This sounds complicated (and it is it :-(), but it seems to be a */ 55 - /* good compromise between fairness and performance: As long as no one */ 56 - /* else wants to work with the ST-DMA chip, SCSI can go along as */ 57 - /* usual. If now someone else comes, this behaviour is changed to a */ 58 - /* "fairness mode": just already initiated commands are finished and */ 59 - /* then the lock is released. The other one waiting will probably win */ 60 - /* the race for locking the DMA, since it was waiting for longer. And */ 61 - /* after it has finished, SCSI can go ahead again. Finally: I hope I */ 62 - /* have not produced any deadlock possibilities! */ 63 - /* */ 64 - /**************************************************************************/ 65 - 17 + /* 18 + * Notes for Falcon SCSI DMA 19 + * 20 + * The 5380 device is one of several that all share the DMA chip. Hence 21 + * "locking" and "unlocking" access to this chip is required. 22 + * 23 + * Two possible schemes for ST DMA acquisition by atari_scsi are: 24 + * 1) The lock is taken for each command separately (i.e. can_queue == 1). 25 + * 2) The lock is taken when the first command arrives and released 26 + * when the last command is finished (i.e. can_queue > 1). 27 + * 28 + * The first alternative limits SCSI bus utilization, since interleaving 29 + * commands is not possible. The second gives better performance but is 30 + * unfair to other drivers needing to use the ST DMA chip. In order to 31 + * allow the IDE and floppy drivers equal access to the ST DMA chip 32 + * the default is can_queue == 1. 33 + */ 66 34 67 35 #include <linux/module.h> 68 36 #include <linux/types.h> ··· 411 443 if (IS_A_TT()) 412 444 return 1; 413 445 446 + if (stdma_is_locked_by(scsi_falcon_intr) && 447 + instance->hostt->can_queue > 1) 448 + return 1; 449 + 414 450 if (in_interrupt()) 415 451 return stdma_try_lock(scsi_falcon_intr, instance); 416 452 ··· 748 776 atari_scsi_reg_write = atari_scsi_falcon_reg_write; 749 777 } 750 778 751 - /* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. 752 - * Higher values should work, too; try it! 753 - * (But cmd_per_lun costs memory!) 754 - * 755 - * But there seems to be a bug somewhere that requires CAN_QUEUE to be 756 - * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since 757 - * changed CMD_PER_LUN... 758 - * 759 - * Note: The Falcon currently uses 8/1 setting due to unsolved problems 760 - * with cmd_per_lun != 1 761 - */ 762 779 if (ATARIHW_PRESENT(TT_SCSI)) { 763 780 atari_scsi_template.can_queue = 16; 764 781 atari_scsi_template.sg_tablesize = SG_ALL; 765 782 } else { 766 - atari_scsi_template.can_queue = 8; 783 + atari_scsi_template.can_queue = 1; 767 784 atari_scsi_template.sg_tablesize = SG_NONE; 768 785 } 769 786