summaryrefslogtreecommitdiff
path: root/drivers/scsi/NCR5380.h
AgeCommit message (Collapse)Author
2016-01-06ncr5380: Use runtime register mappingOndrej Zary
Convert compile-time C400_ register mapping to runtime mapping. This removes the weird negative register offsets and allows adding additional mappings. While at it, convert read/write loops into insb/outsb. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Fix EH during arbitration and selectionFinn Thain
During arbitration and selection, the relevant command is invisible to exception handlers and can be found only in a pointer on the stack of a different thread. When eh_abort_handler can't find a given command, it can't decide whether that command was completed already or is still in arbitration or selection phase. But it must return either SUCCESS (e.g. command completed earlier) or FAILED (could not abort the nexus, try bus reset). The solution is to make sure all commands belonging to the LLD are always visible to exception handlers. Add another scsi_cmnd pointer to the hostdata struct to track the command in arbitration or selection phase. Replace 'retain_dma_irq' with the new 'selecting' pointer, to bring atari_NCR5380.c into line with NCR5380.c. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Fix autosense bugsFinn Thain
NCR5380_information_transfer() may re-queue a command for autosense, after calling scsi_eh_prep_cmnd(). This creates several possibilities: 1. Reselection may intervene before the re-queued command gets processed. If the reconnected command then undergoes autosense, this causes the scsi_eh_save data from the previous command to be overwritten. 2. After NCR5380_information_transfer() calls scsi_eh_prep_cmnd(), a new REQUEST SENSE command may arrive. This would be queued ahead of any command already undergoing autosense, which means the scsi_eh_save data might be restored to the wrong command. 3. After NCR5380_information_transfer() calls scsi_eh_prep_cmnd(), eh_abort_handler() may abort the command. But the scsi_eh_save data is not discarded, which means the scsi_eh_save data might be incorrectly restored to the next REQUEST SENSE command issued. This patch adds a new autosense list so that commands that are re-queued because of a CHECK CONDITION result can be kept apart from the REQUEST SENSE commands that arrive via queuecommand. This patch also adds a function dedicated to dequeueing and preparing the next command for processing. By refactoring the main loop in this way, scsi_eh_save takes place when an autosense command is dequeued rather than when re-queued. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Use standard list data structureFinn Thain
The NCR5380 drivers have a home-spun linked list implementation for scsi_cmnd structs that uses cmd->host_scribble as a 'next' pointer. Adopt the standard list_head data structure and list operations instead. Remove the eh_abort_handler rather than convert it. Doing the conversion would only be churn because the existing EH handlers don't work and get replaced in a subsequent patch. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Remove redundant volatile qualifiersFinn Thain
The hostdata struct is now protected by a spin lock so the volatile qualifiers are redundant. Remove them. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Remove H_NO macro and introduce dsprintkFinn Thain
Replace all H_NO and some HOSTNO macros (both peculiar to atari_NCR5380.c) with a new dsprintk macro that's more useful and more consistent. The new macro avoids a lot of boilerplate in new code in subsequent patches. Keep NCR5380.c in sync. Remaining HOSTNO macros are removed as side-effects of subsequent patches. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Change instance->host_lock to hostdata->lockFinn Thain
NCR5380.c presently uses the instance->host_lock spin lock. Convert this to a new spin lock that protects the NCR5380_hostdata struct. atari_NCR5380.c previously used local_irq_save/restore() rather than a spin lock. Convert this to hostdata->lock in irq mode. For SMP platforms, the interrupt handler now also acquires the spin lock. This brings all locking in the two core drivers into agreement. Adding this locking also means that a bunch of volatile qualifiers can be removed from the members of the NCR5380_hostdata struct. This is done in a subsequent patch. Proper locking will allow the abort handler to locate a command being aborted. This is presently impossible if the abort handler is invoked when the command has been moved from a queue to a pointer on the stack. (If eh_abort_handler can't determine whether a command has been completed or is still being processed then it can't decide whether to return success or failure.) The hostdata spin lock is now held when calling NCR5380_select() and NCR5380_information_transfer(). Where possible, the lock is dropped for polling and PIO transfers. Clean up the now-redundant SELECT_ENABLE_REG writes, that used to provide limited mutual exclusion between information_transfer() and reselect(). Accessing hostdata->connected without data races means taking the lock; cleanup these accesses. The new spin lock falls away for m68k and other UP builds, so this should have little impact there. In the SMP case the new lock should be uncontested even when the SCSI bus is contested. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Remove redundant ICR_ARBITRATION_LOST test and eliminate FLAG_DTC3181EFinn Thain
Remove FLAG_DTC3181E. It was used to suppress a final Arbitration Lost (SEL asserted) test that isn't actually needed. The test was suppressed because it causes problems for DTC436 and DTC536 chips. It takes place after the host wins arbitration, so SEL has been asserted. These chips can't seem to tell whether it was the host or another bus device that did so. This questionable final test appears in a flow chart in an early NCR5380 datasheet. It was removed from later documents like the DP5380 datasheet. By the time this final test takes place, the driver has already tested the Arbitration Lost bit several times. The first test happens 3 us after BUS FREE (or longer due to register access delays). The protocol requires that a device stop signalling within 1.8 us after BUS FREE unless it won arbitration, in which case it must assert SEL, which is detected 1.2 us later by the first Arbitration Lost test. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Cleanup #include directivesFinn Thain
Remove unused includes (stat.h, signal.h, proc_fs.h) and move includes needed by the core drivers into the common header (delay.h etc). Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Replace redundant flags with FLAG_NO_DMA_FIXUPFinn Thain
The flags DMA_WORKS_RIGHT, FLAG_NCR53C400 and FLAG_HAS_LAST_BYTE_SENT all mean the same thing, i.e. the chip is not a 538[01]. (More recent devices such as the 53C80 have a 'Last Byte Sent' bit in the Target Command Register as well as other fixes for End-of-DMA errata.) These flags have no additional meanings since previous cleanup patches eliminated the NCR53C400 macro, moved g_NCR5380-specific code out of the core driver and standardized interrupt handling. Use the FLAG_NO_DMA_FIXUP flag to suppress End-of-DMA errata workarounds, for those cards and drivers that make use of the TCR_LAST_BYTE_SENT bit. Remove the old flags. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Standardize work queueing algorithmFinn Thain
The complex main_running/queue_main mechanism is peculiar to atari_NCR5380.c. It isn't SMP safe and offers little value given that the work queue already offers concurrency management. Remove this complexity to bring atari_NCR5380.c closer to NCR5380.c. It is not a good idea to call the information transfer state machine from queuecommand because, according to Documentation/scsi/scsi_mid_low_api.txt that could happen in soft irq context. Fix this. 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>
2016-01-06ncr5380: Use work_struct instead of delayed_workFinn Thain
Each host instance now has it's own work queue so the main() work item can sleep when necessary. That means we can use a simple work item rather than a delayed work item. This brings NCR5380.c closer to atari_NCR5380.c. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Rework disconnect versus poll logicFinn Thain
The atari_NCR5380.c and NCR5380.c core drivers differ in their handling of target disconnection. This is partly because atari_NCR5380.c had all of the polling and sleeping removed to become entirely interrupt-driven, and it is partly because of damage done to NCR5380.c after atari_NCR5380.c was forked. See commit 37cd23b44929 ("Linux 2.1.105") in history/history.git. The polling changes that were made in v2.1.105 are questionable at best: if REQ is not already asserted when NCR5380_transfer_pio() is invoked, and if the expected phase is DATA IN or DATA OUT, the function will schedule main() to execute after USLEEP_SLEEP jiffies and then return. The problems here are the expected REQ timing and the sleep interval*. Avoid this issue by using NCR5380_poll_politely() instead of scheduling main(). The atari_NCR5380.c core driver requires the use of the chip interrupt and always permits target disconnection. It sets the cmd->device->disconnect flag when a device disconnects, but never tests this flag. The NCR5380.c core driver permits disconnection only when instance->irq != NO_IRQ. It sets the cmd->device->disconnect flag when a device disconnects and it tests this flag in a couple of places: 1. During NCR5380_information_transfer(), following COMMAND OUT phase, if !cmd->device->disconnect, the initiator will take a guess as to whether or not the target will then choose to go to MESSAGE IN phase and disconnect. If the driver guesses "yes", it will schedule main() to execute after USLEEP_SLEEP jiffies and then return there. Unfortunately the driver may guess "yes" even after it has denied the target the disconnection privilege. When the target does not disconnect, the sleep can be beneficial, assuming the sleep interval is appropriate (mostly it is not*). And even if the driver guesses "yes" correctly, and the target would then disconnect, the driver still has to go through the MESSAGE IN phase in order to get to BUS FREE phase. The main loop can do nothing useful until BUS FREE, and sleeping just delays the phase transition. 2. If !cmd->device->disconnect and REQ is not already asserted when NCR5380_information_transfer() is invoked, the function polls for REQ for USLEEP_POLL jiffies. If REQ is not asserted, it then schedules main() to execute after USLEEP_SLEEP jiffies and returns. The idea is apparently to yeild the CPU while waiting for REQ. This is conditional upon !cmd->device->disconnect, but there seems to be no rhyme or reason for that. For example, the flag may be unset because disconnection privilege was denied because the driver has no IRQ. Or the flag may be unset because the device has never needed to disconnect before. Or if the flag is set, disconnection may have no relevance to the present bus phase. Another deficiency of the existing algorithm is as follows. When the driver has no IRQ, it prevents disconnection, and generally polls and sleeps more than it would normally. Now, if the driver is going to poll anyway, why not allow the target to disconnect? That way the driver can do something useful with the bus instead of polling unproductively! Avoid this pointless latency, complexity and guesswork by using NCR5380_poll_politely() instead of scheduling main(). * For g_NCR5380, the time intervals for USLEEP_SLEEP and USLEEP_POLL are 200 ms and 10 ms, respectively. They are 20 ms and 200 ms respectively for the other NCR5380 drivers. There doesn't seem to be any reason for this discrepancy. The timing seems to have no relation to the type of adapter. Bizarrely, the timing in g_NCR5380 seems to relate only to one particular type of target device. This patch attempts to solve the problem for all NCR5380 drivers and all target devices. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Eliminate selecting stateFinn Thain
Linux v2.1.105 changed the algorithm for polling for the BSY signal in NCR5380_select() and NCR5380_main(). Presently, this code has a bug. Back then, NCR5380_set_timer(hostdata, 1) meant reschedule main() after sleeping for 10 ms. Repeated 25 times this provided the recommended 250 ms selection time-out delay. This got broken when HZ became configurable. We could fix this but there's no need to reschedule the main loop. This BSY polling presently happens when the NCR5380_main() work queue item calls NCR5380_select(), which in turn schedules NCR5380_main(), which calls NCR5380_select() again, and so on. This algorithm is a deviation from the simpler one in atari_NCR5380.c. The extra complexity and state is pointless. There's no reason to stop selection half-way and return to to the main loop when the main loop can do nothing useful until selection completes. So just poll for BSY. We can sleep while polling now that we have a suitable workqueue. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Sleep when polling, if possibleFinn Thain
When in process context, sleep during polling if doing so won't add significant latency. In interrupt context or if the lock is held, poll briefly then give up. Keep both core drivers in sync. Calibrate busy-wait iterations to allow for variation in chip register access times between different 5380 hardware implementations. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Introduce unbound workqueueFinn Thain
Allocate a work queue that will permit busy waiting and sleeping. This means NCR5380_init() can potentially fail, so add this error path. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Always escalate bad target time-out in NCR5380_select()Finn Thain
Remove the restart_select and targets_present variables introduced in Linux v1.1.38. The former was used only for a questionable debug printk and the latter "so we can call a select failure a retryable condition". Well, retrying select failure in general is a different problem to a target that doesn't assert BSY. We need to handle these two cases differently; the latter case can be left to the SCSI ML. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Remove unused hostdata->aborted flagFinn Thain
The aborted flag was introduced in v1.1.38 but never used. Remove it. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06atari_NCR5380: Remove RESET_BOOT, CONFIG_ATARI_SCSI_TOSHIBA_DELAY and ↵Finn Thain
CONFIG_ATARI_SCSI_RESET_BOOT The atari_NCR5380.c core driver now takes care of bus reset upon driver initialization if required (same as NCR5380.c). Move the Toshiba CD-ROM support into the core driver, enabled with a host flag, so that all NCR5380 drivers can make use of it. Drop the RESET_BOOT macros and the ATARI_SCSI_RESET_BOOT and ATARI_SCSI_TOSHIBA_DELAY Kconfig symbols, which are now redundant. Remove the atari_scsi_reset_boot(), mac_scsi_reset_boot() and sun3_scsi_reset_boot() routines. None of this duplicated code is needed now that all drivers can use NCR5380_maybe_reset_bus(). This brings atari_scsi, mac_scsi and sun3_scsi into line with all of the other NCR5380 drivers. The bus reset may raise an interrupt. That would be new behaviour for atari_scsi only when CONFIG_ATARI_SCSI_RESET_BOOT=n. The ST DMA interrupt is not assigned to atari_scsi at this stage, so CONFIG_ATARI_SCSI_RESET_BOOT=y may well be problematic already. Regardless, do_reset() now raises and clears the interrupt within local_irq_save/restore which should avoid problems. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Split NCR5380_init() into two functionsFinn Thain
This patch splits the NCR5380_init() function into two parts, similar to the scheme used with atari_NCR5380.c. This avoids two problems. Firstly, NCR5380_init() may perform a bus reset, which would cause the chip to assert IRQ. The chip is unable to mask its bus reset interrupt. Drivers can't call request_irq() before calling NCR5380_init(), because initialization must happen before the interrupt handler executes. If driver initialization causes an interrupt it may be problematic on some platforms. To avoid that, first move the bus reset code into NCR5380_maybe_reset_bus(). Secondly, NCR5380_init() contains some board-specific interrupt setup code for the NCR53C400 that does not belong in the core driver. In moving this code, better not re-order interrupt initialization and bus reset. Again, the solution is to move the bus reset code into NCR5380_maybe_reset_bus(). Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-06ncr5380: Remove more pointless macrosFinn Thain
ASM macro is never defined. rtrc in pas16.c is not used. NCR5380_map_config, do_NCR5380_intr, do_t128_intr and do_pas16_intr are unused. NCR_NOT_SET harms readability. Remove them. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2014-11-20atari_NCR5380: Move static co-routine variables to host dataFinn Thain
Unlike NCR5380.c, the atari_NCR5380.c core driver is limited to a single instance because co-routine state is stored globally. Fix this by removing the static scsi host pointer. For the co-routine, obtain this pointer from the work_struct pointer instead. For the interrupt handler, obtain it from the dev_id argument. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20atari_NCR5380: Move static TagAlloc array to host dataFinn Thain
The atari_NCR5380.c core driver keeps some per-host data in a static variable which limits the driver to a single instance. Fix this by moving TagAlloc to the hostdata struct. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20atari_NCR5380: Introduce FLAG_TAGGED_QUEUINGFinn Thain
The static variable setup_use_tagged_queuing is declared in mac_scsi.c, sun3_scsi.c and atari_scsi.c and doesn't belong in the core driver. None of the other NCR5380 drivers suffer from this layering issue which makes merging the core drivers more difficult and will likely hinder plans for future use of platform data to configure the driver. Replace the static variable with a host flag. This way it can be reported along with the other flags. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20atari_NCR5380: Refactor Falcon special casesFinn Thain
Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others by moving some of the Falcon-specific code out of the core driver: !IS_A_TT, atari_read_overruns and falcon_dont_release. Replace these with hostdata variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c so don't set it. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Drop legacy scsi.h includeFinn Thain
Convert Scsi_Cmnd to struct scsi_cmnd and drop the #include "scsi.h". The sun3_NCR5380.c core driver already uses struct scsi_cmnd so converting the other core drivers reduces the diff which makes them easier to unify. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Remove *_RELEASE macrosFinn Thain
The *_RELEASE macros don't tell me anything. In some cases the version in the macro contradicts the version in the comments. Anyway, the Linux kernel version is sufficient information. Remove these macros to improve readability. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Move static PDMA spin counters to host dataFinn Thain
Static variables from dtc.c and pas16.c should not appear in the core NCR5380.c driver. Aside from being a layering issue this worsens the divergence between the three core driver variants (atari_NCR5380.c and sun3_NCR5380.c don't support PSEUDO_DMA) and it can mean multiple hosts share the same counters. Fix this by making the pseudo DMA spin counters in the core more generic. This also avoids the abuse of the {DTC,PAS16}_PUBLIC_RELEASE macros, so they can be removed. oak.c doesn't use PDMA and hence it doesn't use the counters and hence it needs no write_info() method. Remove it. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Cleanup host info() methodsFinn Thain
If the host->info() method is not set, then host->name is used by default. For atari_scsi, that is exactly the same text. So remove the redundant info() method. Keep sun3_scsi.c in line with atari_scsi. Some NCR5380 drivers return an empty string from the info() method (arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default (dmx3191d dtc.c g_NCR5380.c pas16.c t128.c). Implement a common info() method to replace a lot of duplicated code which the various drivers use to announce the same information. This replaces most of the (deprecated) show_info() output and all of the NCR5380_print_info() output. This also eliminates a bunch of code in g_NCR5380 which just duplicates functionality in the core driver. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Remove NCR5380_STATSFinn Thain
The NCR5380_STATS option is only enabled by g_NCR5380 yet it adds clutter to all three core drivers. The atari_NCR5380.c and sun3_NCR5380.c core drivers have a slightly different implementation of the NCR5380_STATS option. Out of all ten NCR5380 drivers, only one of them (g_NCR5380) actually has the code to report on the collected stats. Aside from being unreadable, that code seems to be broken because there's no initialization of timebase. sun3_NCR5380.c and atari_NCR5380.c have the timebase initialization but lack the code to report the stats. Remove all of this code to improve readability and reduce divergence between the three core drivers. This patch and the next one completely eliminate the PRINTP and ANDP pre-processor abuse. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Fix SCSI_IRQ_NONE bugsFinn Thain
Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE if it is to issue IDENTIFY commands that prevent target disconnection. And, as Geert points out, IRQ_NONE is part of enum irqreturn. Other drivers, when they can't get an IRQ or can't use one, will set host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will attempt to free IRQ 255 which was never requested. Fix these bugs by using NO_IRQ in place of SCSI_IRQ_NONE and IRQ_NONE. That means IRQ 0 is no longer probed by ISA drivers but I don't think this matters. Setting IRQ = 255 for these ISA drivers is understood to mean no IRQ. This remains supported so as to avoid breaking existing ISA setups (which can be difficult to get working) and because existing documentation (SANE, TLDP etc) describes this usage for the ISA NCR5380 driver options. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Remove redundant AUTOSENSE macroFinn Thain
Every NCR5380 driver sets AUTOSENSE so it need not be optional (and the mid-layer expects it). Remove this redundant macro to improve readability. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Cleanup TAG_NEXT and TAG_NONE macrosFinn Thain
Both atari_NCR5380.c and sun3_NCR5380.c core drivers #undef TAG_NONE and then redefine it. But the original definition is unused because NCR5380.c lacks support for tagged queueing. So just define it once. The TAG_NEXT macro only appears in the arguments to NCR5380_select() calls. But that routine doesn't use its tag argument as the tag was already assigned in NCR5380_main(). So remove the unused argument and the macro. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Remove more useless prototypesFinn Thain
Make use of the host template static initializer instead of assigning handlers at run-time. Move __maybe_unused qualifiers from declarations to definitions. Move the atari_scsi_bus_reset() wrapper after the definition of NCR5380_bus_reset(). All of the host template handler prototypes are now redundant so remove them. The write_info() handler is only relevant to drivers using PSEUDO_DMA so this patch fixes the compiler warning in atari_NCR5380.c and sun3_NCR5380.c: CC drivers/scsi/atari_scsi.o drivers/scsi/NCR5380.h:329: warning: 'NCR5380_write_info' declared 'static' but never defined Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-20ncr5380: Use printk() not pr_debug()Finn Thain
Having defined NDEBUG, and having set the console log level, I'd like to see some output. Don't use pr_debug(), it's annoying to have to define DEBUG as well. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-28scsi/NCR5380: dprintk macroFinn Thain
This is the delta between the two submissions: [PATCH 00/12] scsi/NCR5380: fix debugging macros and #include structure and [PATCH v2 00/12] scsi/NCR5380: fix debugging macros and #include structure The macro definition changes were discussed on the mailing list during review. The idea is to get the compiler to check the parameters of disabled printk() calls so that the debugging code doesn't rot again. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-28scsi/NCR5380: fix and standardize NDEBUG macrosFinn Thain
All three NCR5380 core driver implementations share the same NCR5380.h header file so they need to agree on certain macro definitions. The flag bit used by the NDEBUG_MERGING macro in atari_NCR5380 and sun3_NCR5380 collides with the bit used by NDEBUG_LISTS. Moreover, NDEBUG_ABORT appears in NCR5380.c so it should be defined in NCR5380.h rather than in each of the many drivers using that core. An undefined NDEBUG_ABORT macro caused compiler errors and led to dodgy workarounds in the core driver that can now be removed. (See commits f566a576bca09de85bf477fc0ab2c8c96405b77b and 185a7a1cd79b9891e3c17abdb103ba1c98d6ca7a.) Move all of the NDEBUG_ABORT, NDEBUG_TAGS and NDEBUG_MERGING macro definitions into NCR5380.h where all the other NDEBUG macros live. Also, incorrect "#ifdef NDEBUG" becomes "#if NDEBUG" to fix the warning: drivers/scsi/mac_scsi.c: At top level: drivers/scsi/NCR5380.c:418: warning: 'NCR5380_print' defined but not used drivers/scsi/NCR5380.c:459: warning: 'NCR5380_print_phase' defined but not used The debugging code is now enabled when NDEBUG != 0. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Sam Creasey <sammy@sammy.net> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-28scsi/NCR5380: fix dprintk macro usage and definitionFinn Thain
There are three implementations of the core NCR5380 driver and three sets of debugging macro definitions. And all three implementations use the NCR5380.h header as well. Two of the definitions of the dprintk macro accept a variable argument list whereas the third does not. Standardize on the variable argument list. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Sam Creasey <sammy@sammy.net> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-28scsi/NCR5380: remove old CVS keywordsFinn Thain
Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Sam Creasey <sammy@sammy.net> Signed-off-by: Christoph Hellwig <hch@lst.de>
2013-04-09NCR5830: switch to ->show_info()Al Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-11-16SCSI host lock push-downJeff Garzik
Move the mid-layer's ->queuecommand() invocation from being locked with the host lock to being unlocked to facilitate speeding up the critical path for drivers who don't need this lock taken anyway. The patch below presents a simple SCSI host lock push-down as an equivalent transformation. No locking or other behavior should change with this patch. All existing bugs and locking orders are preserved. Additionally, add one parameter to queuecommand, struct Scsi_Host * and remove one parameter from queuecommand, void (*done)(struct scsi_cmnd *) Scsi_Host* is a convenient pointer that most host drivers need anyway, and 'done' is redundant to struct scsi_cmnd->scsi_done. Minimal code disturbance was attempted with this change. Most drivers needed only two one-line modifications for their host lock push-down. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: James Bottomley <James.Bottomley@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-12[SCSI] NCR5380: Use scsi_eh API for REQUEST_SENSE invocationBoaz Harrosh
- Use new scsi_eh_prep/restor_cmnd() for synchronous REQUEST_SENSE invocation. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-05-24[SCSI] ncr5380 warning fixesAndrew Morton
squish these: drivers/scsi/NCR5380.c:360: warning: 'phases' defined but not used drivers/scsi/NCR5380.c:360: warning: 'phases' defined but not used drivers/scsi/NCR5380.c:633: warning: 'NCR5380_print_options' defined but not used drivers/scsi/NCR5380.c:708: warning: 'NCR5380_proc_info' defined but not used drivers/scsi/NCR5380.c:360: warning: 'phases' defined but not used drivers/scsi/NCR5380.c:579: warning: 'NCR5380_probe_irq' defined but not used drivers/scsi/NCR5380.c:360: warning: 'phases' defined but not used drivers/scsi/NCR5380.c:708: warning: 'notyet_generic_proc_info' defined but not used drivers/scsi/NCR5380.c:708: warning: 'notyet_generic_proc_info' defined but not used Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-11-22WorkStruct: make allyesconfigDavid Howells
Fix up for make allyesconfig. Signed-Off-By: David Howells <dhowells@redhat.com>
2006-10-05IRQ: Maintain regs pointer globally rather than passing to IRQ handlersDavid Howells
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead of passing regs around manually through all ~1800 interrupt handlers in the Linux kernel. The regs pointer is used in few places, but it potentially costs both stack space and code to pass it around. On the FRV arch, removing the regs parameter from all the genirq function results in a 20% speed up of the IRQ exit path (ie: from leaving timer_interrupt() to leaving do_IRQ()). Where appropriate, an arch may override the generic storage facility and do something different with the variable. On FRV, for instance, the address is maintained in GR28 at all times inside the kernel as part of general exception handling. Having looked over the code, it appears that the parameter may be handed down through up to twenty or so layers of functions. Consider a USB character device attached to a USB hub, attached to a USB controller that posts its interrupts through a cascaded auxiliary interrupt controller. A character device driver may want to pass regs to the sysrq handler through the input layer which adds another few layers of parameter passing. I've build this code with allyesconfig for x86_64 and i386. I've runtested the main part of the code on FRV and i386, though I can't test most of the drivers. I've also done partial conversion for powerpc and MIPS - these at least compile with minimal configurations. This will affect all archs. Mostly the changes should be relatively easy. Take do_IRQ(), store the regs pointer at the beginning, saving the old one: struct pt_regs *old_regs = set_irq_regs(regs); And put the old one back at the end: set_irq_regs(old_regs); Don't pass regs through to generic_handle_irq() or __do_IRQ(). In timer_interrupt(), this sort of change will be necessary: - update_process_times(user_mode(regs)); - profile_tick(CPU_PROFILING, regs); + update_process_times(user_mode(get_irq_regs())); + profile_tick(CPU_PROFILING); I'd like to move update_process_times()'s use of get_irq_regs() into itself, except that i386, alone of the archs, uses something other than user_mode(). Some notes on the interrupt handling in the drivers: (*) input_dev() is now gone entirely. The regs pointer is no longer stored in the input_dev struct. (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does something different depending on whether it's been supplied with a regs pointer or not. (*) Various IRQ handler function pointers have been moved to type irq_handler_t. Signed-Off-By: David Howells <dhowells@redhat.com> (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2005-06-17[SCSI] Remove no-op implementations of SCSI EH hooksJeff Garzik
Drivers need not implement a hook that returns FAILED, and does nothing else, since the SCSI midlayer code will do that for us. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-04-16Linux-2.6.12-rc2Linus Torvalds
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!