Commit 3679a65c authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] un'fix' NCR scsi driver.

Linus,
 Current driver in your tree has been 'fixed' by someone without
understanding just how broken it was. Numerous fixes were done in 2.4
after the 2.5 split by Alan.

This patch reverts the damage the driver does in your tree, and brings
Alan's 2.4 bits over instead. Downside: It doesn't compile.
Upside: It doesn't pretend to work and corrupt data, and at least
is the right base for people to start fixing.
parent 0170bcbb
This diff is collapsed.
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#define NDEBUG_C400_PWRITE 0x200000 #define NDEBUG_C400_PWRITE 0x200000
#define NDEBUG_LISTS 0x400000 #define NDEBUG_LISTS 0x400000
#define NDEBUG_ANY 0xFFFFFFFFUL
/* /*
* The contents of the OUTPUT DATA register are asserted on the bus when * The contents of the OUTPUT DATA register are asserted on the bus when
* either arbitration is occurring or the phase-indicating signals ( * either arbitration is occurring or the phase-indicating signals (
...@@ -263,12 +265,10 @@ struct NCR5380_hostdata { ...@@ -263,12 +265,10 @@ struct NCR5380_hostdata {
NCR5380_select() */ NCR5380_select() */
volatile unsigned aborted:1; /* flag, says aborted */ volatile unsigned aborted:1; /* flag, says aborted */
int flags; int flags;
#ifdef USLEEP
unsigned long time_expires; /* in jiffies, set prior to sleeping */ unsigned long time_expires; /* in jiffies, set prior to sleeping */
struct Scsi_Host *next_timer; struct Scsi_Host *next_timer;
int select_time; /* timer in select for target response */ int select_time; /* timer in select for target response */
volatile Scsi_Cmnd *selecting; volatile Scsi_Cmnd *selecting;
#endif
#ifdef NCR5380_STATS #ifdef NCR5380_STATS
unsigned timebase; /* Base for time calcs */ unsigned timebase; /* Base for time calcs */
long time_read[8]; /* time to do reads */ long time_read[8]; /* time to do reads */
...@@ -283,92 +283,148 @@ struct NCR5380_hostdata { ...@@ -283,92 +283,148 @@ struct NCR5380_hostdata {
#ifdef __KERNEL__ #ifdef __KERNEL__
static struct Scsi_Host *first_instance; /* linked list of 5380's */ static struct Scsi_Host *first_instance; /* linked list of 5380's */
#define dprintk(a,b) do {} while(0)
#define NCR5380_dprint(a,b) do {} while(0)
#define NCR5380_dprint_phase(a,b) do {} while(0)
#if defined(AUTOPROBE_IRQ) #if defined(AUTOPROBE_IRQ)
static int NCR5380_probe_irq (struct Scsi_Host *instance, int possible); static int NCR5380_probe_irq(struct Scsi_Host *instance, int possible);
#endif #endif
static void NCR5380_init (struct Scsi_Host *instance, int flags); static void NCR5380_init(struct Scsi_Host *instance, int flags);
static void NCR5380_information_transfer (struct Scsi_Host *instance); static void NCR5380_information_transfer(struct Scsi_Host *instance);
#ifndef DONT_USE_INTR #ifndef DONT_USE_INTR
static void NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs); static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs);
static void do_NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs); static void do_NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs);
#endif #endif
static void NCR5380_main (void); static void NCR5380_main(void);
static void NCR5380_print_options (struct Scsi_Host *instance); static void NCR5380_print_options(struct Scsi_Host *instance);
static void NCR5380_print_phase (struct Scsi_Host *instance); static void NCR5380_print_phase(struct Scsi_Host *instance);
static void NCR5380_print (struct Scsi_Host *instance); static void NCR5380_print(struct Scsi_Host *instance);
#ifndef NCR5380_abort #ifndef NCR5380_abort
static static
#endif #endif
int NCR5380_abort (Scsi_Cmnd *cmd); int NCR5380_abort(Scsi_Cmnd * cmd);
#ifndef NCR5380_reset #ifndef NCR5380_reset
static static
#endif #endif
int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int reset_flags); int NCR5380_reset(Scsi_Cmnd * cmd, unsigned int reset_flags);
#ifndef NCR5380_queue_command #ifndef NCR5380_queue_command
static static
#endif #endif
int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)); int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *));
static void NCR5380_reselect (struct Scsi_Host *instance); static void NCR5380_reselect(struct Scsi_Host *instance);
static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag); static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag);
#if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL) #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
static int NCR5380_transfer_dma (struct Scsi_Host *instance, static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
unsigned char *phase, int *count, unsigned char **data);
#endif #endif
static int NCR5380_transfer_pio (struct Scsi_Host *instance, static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
unsigned char *phase, int *count, unsigned char **data);
#if (defined(REAL_DMA) || defined(REAL_DMA_POLL)) #if (defined(REAL_DMA) || defined(REAL_DMA_POLL))
#if defined(i386) || defined(__alpha__) #if defined(i386) || defined(__alpha__)
static __inline__ int NCR5380_pc_dma_setup (struct Scsi_Host *instance, /**
unsigned char *ptr, unsigned int count, unsigned char mode) { * NCR5380_pc_dma_setup - setup ISA DMA
* @instance: adapter to set up
* @ptr: block to transfer (virtual address)
* @count: number of bytes to transfer
* @mode: DMA controller mode to use
*
* Program the DMA controller ready to perform an ISA DMA transfer
* on this chip.
*
* Locks: takes and releases the ISA DMA lock.
*/
static __inline__ int NCR5380_pc_dma_setup(struct Scsi_Host *instance, unsigned char *ptr, unsigned int count, unsigned char mode)
{
unsigned limit; unsigned limit;
unsigned long bus_addr = virt_to_bus(ptr); unsigned long bus_addr = virt_to_bus(ptr);
unsigned long flags;
if (instance->dma_channel <=3) { if (instance->dma_channel <= 3) {
if (count > 65536) if (count > 65536)
count = 65536; count = 65536;
limit = 65536 - (bus_addr & 0xFFFF); limit = 65536 - (bus_addr & 0xFFFF);
} else { } else {
if (count > 65536 * 2) if (count > 65536 * 2)
count = 65536 * 2; count = 65536 * 2;
limit = 65536* 2 - (bus_addr & 0x1FFFF); limit = 65536 * 2 - (bus_addr & 0x1FFFF);
} }
if (count > limit) count = limit; if (count > limit)
count = limit;
if ((count & 1) || (bus_addr & 1)) if ((count & 1) || (bus_addr & 1))
panic ("scsi%d : attempted unaligned DMA transfer\n", instance->host_no); panic("scsi%d : attempted unaligned DMA transfer\n", instance->host_no);
cli();
flags=claim_dma_lock();
disable_dma(instance->dma_channel); disable_dma(instance->dma_channel);
clear_dma_ff(instance->dma_channel); clear_dma_ff(instance->dma_channel);
set_dma_addr(instance->dma_channel, bus_addr); set_dma_addr(instance->dma_channel, bus_addr);
set_dma_count(instance->dma_channel, count); set_dma_count(instance->dma_channel, count);
set_dma_mode(instance->dma_channel, mode); set_dma_mode(instance->dma_channel, mode);
enable_dma(instance->dma_channel); enable_dma(instance->dma_channel);
sti(); release_dma_lock(flags);
return count; return count;
} }
static __inline__ int NCR5380_pc_dma_write_setup (struct Scsi_Host *instance, /**
unsigned char *src, unsigned int count) { * NCR5380_pc_dma_write_setup - setup ISA DMA write
return NCR5380_pc_dma_setup (instance, src, count, DMA_MODE_WRITE); * @instance: adapter to set up
* @ptr: block to transfer (virtual address)
* @count: number of bytes to transfer
*
* Program the DMA controller ready to perform an ISA DMA write to the
* SCSI controller.
*
* Locks: called routines take and release the ISA DMA lock.
*/
static __inline__ int NCR5380_pc_dma_write_setup(struct Scsi_Host *instance, unsigned char *src, unsigned int count)
{
return NCR5380_pc_dma_setup(instance, src, count, DMA_MODE_WRITE);
} }
static __inline__ int NCR5380_pc_dma_read_setup (struct Scsi_Host *instance, /**
unsigned char *src, unsigned int count) { * NCR5380_pc_dma_read_setup - setup ISA DMA read
return NCR5380_pc_dma_setup (instance, src, count, DMA_MODE_READ); * @instance: adapter to set up
* @ptr: block to transfer (virtual address)
* @count: number of bytes to transfer
*
* Program the DMA controller ready to perform an ISA DMA read from the
* SCSI controller.
*
* Locks: called routines take and release the ISA DMA lock.
*/
static __inline__ int NCR5380_pc_dma_read_setup(struct Scsi_Host *instance, unsigned char *src, unsigned int count)
{
return NCR5380_pc_dma_setup(instance, src, count, DMA_MODE_READ);
} }
static __inline__ int NCR5380_pc_dma_residual (struct Scsi_Host *instance) { /**
register int tmp; * NCR5380_pc_dma_residual - return bytes left
cli(); * @instance: adapter
*
* Reports the number of bytes left over after the DMA was terminated.
*
* Locks: takes and releases the ISA DMA lock.
*/
static __inline__ int NCR5380_pc_dma_residual(struct Scsi_Host *instance)
{
unsigned long flags;
int tmp;
flags = claim_dma_lock();
clear_dma_ff(instance->dma_channel); clear_dma_ff(instance->dma_channel);
tmp = get_dma_residue(instance->dma_channel); tmp = get_dma_residue(instance->dma_channel);
sti(); release_dma_lock(flags);
return tmp; return tmp;
} }
#endif /* defined(i386) || defined(__alpha__) */ #endif /* defined(i386) || defined(__alpha__) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment