diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/ChangeLog linux/drivers/scsi/aacraid/ChangeLog
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/ChangeLog	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/ChangeLog	Fri Nov 16 14:25:35 2001
@@ -1,3 +1,13 @@
+2001-11-16  Matt Domsch <Matt_Domsch@dell.com>
+* Applied patch from Chris Pascoe which should solve the NMI_DMA_0_ERROR
+and related fsck hang issues.  Turns out we were getting passed a buffer
+into high memory (>1GB) the driver wasn't handling properly.
+* Replaced all cases where DMA addresses were being used with
+kmalloc()/virt_to_phys() with
+pci_alloc_consistent()/pci_free_consistent().
+* Change type of PHYSICAL_ADDRESS to dma_addr_t
+* released patch against 2.4.15-pre4
+	
 2001-11-05  Matt Domsch <Matt_Domsch@dell.com>
 * Applied patch from Jon Fraser to rx.c and sap1sup.c to fix printing of
 error messages from firmware.
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/Makefile linux/drivers/scsi/aacraid/Makefile
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/Makefile	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/Makefile	Thu Nov 15 17:07:52 2001
@@ -91,7 +91,8 @@ INCS= \
 	-I./include \
 	-I../../../include -I..
 
-WARNINGS= -w -Wno-unused -Wno-switch -Wno-missing-prototypes -Wno-implicit
+#WARNINGS= -Wno-unused -Wno-switch -Wno-missing-prototypes -Wno-implicit
+WARNINGS= 
 
 COMMON_FLAGS=\
 	-DCVLOCK_USE_SPINLOCK -DLINUX \
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/aachba.c linux/drivers/scsi/aacraid/aachba.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/aachba.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/aachba.c	Fri Nov 16 12:22:10 2001
@@ -895,16 +895,18 @@ int AacHba_DoScsiRead(
 	{
 		struct scatterlist *scatterlist_ptr;
 		int segment;
+		int sg_count;
 		
 		scatterlist_ptr = ( struct scatterlist * )scsi_cmnd_ptr->request_buffer;
+		sg_count = pci_map_sg( CommonExtension->PciDev, scatterlist_ptr, scsi_cmnd_ptr->use_sg, PCI_DMA_FROMDEVICE );
 
 		byte_count = 0;
-		for( segment = 0; segment< scsi_cmnd_ptr->use_sg; segment++ ) 
+		for( segment = 0; segment < sg_count; segment++ ) 
 		{
 			BlockReadDisk->SgMap.SgEntry[segment].SgAddress = 
-				( void * )OsVirtToPhys( scatterlist_ptr[segment].address );
+				sg_dma_address( &scatterlist_ptr[segment] );
 			BlockReadDisk->SgMap.SgEntry[segment].SgByteCount = 
-				scatterlist_ptr[segment].length;
+				sg_dma_len( &scatterlist_ptr[segment] );
 
 #ifdef DEBUG_SGBUFFER
 			memset( scatterlist_ptr[segment].address, 0xa5, 
@@ -931,7 +933,7 @@ int AacHba_DoScsiRead(
 					BlockReadDisk->SgMap.SgEntry[segment].SgByteCount);
 			*/
 		}
-		BlockReadDisk->SgMap.SgCount = scsi_cmnd_ptr->use_sg;
+		BlockReadDisk->SgMap.SgCount = sg_count;
 
 		if( BlockReadDisk->SgMap.SgCount > MAX_DRIVER_SG_SEGMENT_COUNT ) 
 		{
@@ -943,8 +945,9 @@ int AacHba_DoScsiRead(
 	} 	
 	else		// one piece of contiguous phys mem
 	{
-		BlockReadDisk->SgMap.SgEntry[0].SgAddress = 
-			( void * )OsVirtToPhys( scsi_cmnd_ptr->request_buffer );
+		scsi_cmnd_ptr->SCp.dma_handle = pci_map_single( CommonExtension->PciDev, scsi_cmnd_ptr->request_buffer,
+								scsi_cmnd_ptr->request_bufflen, PCI_DMA_FROMDEVICE );
+		BlockReadDisk->SgMap.SgEntry[0].SgAddress = scsi_cmnd_ptr->SCp.dma_handle;
 		BlockReadDisk->SgMap.SgEntry[0].SgByteCount = scsi_cmnd_ptr->request_bufflen;
 
 		byte_count = scsi_cmnd_ptr->request_bufflen;
@@ -1153,16 +1156,17 @@ int AacHba_DoScsiWrite(
 	{
 		struct scatterlist *scatterlist_ptr;
 		int segment;
+		int sg_count;
 		
 		scatterlist_ptr = ( struct scatterlist * )scsi_cmnd_ptr->request_buffer;
-
+		sg_count = pci_map_sg( CommonExtension->PciDev, scatterlist_ptr, scsi_cmnd_ptr->use_sg, PCI_DMA_TODEVICE );
 		byte_count = 0;
-		for( segment = 0; segment< scsi_cmnd_ptr->use_sg; segment++ ) 
+		for( segment = 0; segment < sg_count; segment++ ) 
 		{
 			BlockWriteDisk->SgMap.SgEntry[segment].SgAddress = 
-				( HOSTADDRESS )OsVirtToPhys( scatterlist_ptr[segment].address );
+				sg_dma_address( &scatterlist_ptr[segment] );
 			BlockWriteDisk->SgMap.SgEntry[segment].SgByteCount = 
-				scatterlist_ptr[segment].length;
+				sg_dma_len( &scatterlist_ptr[segment] );
 			
 			byte_count += scatterlist_ptr[segment].length;
 
@@ -1185,7 +1189,7 @@ int AacHba_DoScsiWrite(
 					BlockWriteDisk->SgMap.SgEntry[segment].SgByteCount); 
 			*/
 		}
-		BlockWriteDisk->SgMap.SgCount = scsi_cmnd_ptr->use_sg;
+		BlockWriteDisk->SgMap.SgCount = sg_count;
 
 		if( BlockWriteDisk->SgMap.SgCount > MAX_DRIVER_SG_SEGMENT_COUNT ) 
 		{
@@ -1197,8 +1201,9 @@ int AacHba_DoScsiWrite(
 	} 
 	else		// one piece of contiguous phys mem
 	{
-		BlockWriteDisk->SgMap.SgEntry[0].SgAddress = 
-			( HOSTADDRESS )OsVirtToPhys( scsi_cmnd_ptr->request_buffer );
+		scsi_cmnd_ptr->SCp.dma_handle = pci_map_single( CommonExtension->PciDev, scsi_cmnd_ptr->request_buffer,
+								scsi_cmnd_ptr->request_bufflen, PCI_DMA_TODEVICE );
+		BlockWriteDisk->SgMap.SgEntry[0].SgAddress = scsi_cmnd_ptr->SCp.dma_handle;
 		BlockWriteDisk->SgMap.SgEntry[0].SgByteCount = scsi_cmnd_ptr->request_bufflen;
 
 		byte_count = scsi_cmnd_ptr->request_bufflen;
@@ -1371,6 +1376,15 @@ void AacHba_ReadCallback(  
 	}
 #endif
 
+	if ( scsi_cmnd_ptr->use_sg )
+		pci_unmap_sg( CommonExtension->PciDev, 
+				(struct scatterlist *)scsi_cmnd_ptr->request_buffer,
+				scsi_cmnd_ptr->use_sg, PCI_DMA_FROMDEVICE );
+	else
+		pci_unmap_single( CommonExtension->PciDev,
+				  scsi_cmnd_ptr->SCp.dma_handle,
+				  scsi_cmnd_ptr->request_bufflen, PCI_DMA_FROMDEVICE );
+
 	Adapter->CommFuncs.CompleteFib( FibContext );
 	Adapter->CommFuncs.FreeFib( FibContext );
 
@@ -1425,6 +1439,15 @@ void AacHba_WriteCallback(  
 			0, 0, 0, 0 );
 	}
 
+	if (scsi_cmnd_ptr->use_sg)
+		pci_unmap_sg(CommonExtension->PciDev, 
+				(struct scatterlist *)scsi_cmnd_ptr->request_buffer,
+				scsi_cmnd_ptr->use_sg, PCI_DMA_TODEVICE);
+	else
+		pci_unmap_single(CommonExtension->PciDev,
+				 scsi_cmnd_ptr->SCp.dma_handle,
+				 scsi_cmnd_ptr->request_bufflen, PCI_DMA_TODEVICE);
+
 	Adapter->CommFuncs.CompleteFib( FibContext );
 	Adapter->CommFuncs.FreeFib( FibContext );
 
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/aacid.c linux/drivers/scsi/aacraid/aacid.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/aacid.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/aacid.c	Tue Nov 13 09:53:15 2001
@@ -115,16 +115,14 @@ int
 SaInitDevice(
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 );
 
 int
 RxInitDevice(
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 );
 
 
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/commsup.c linux/drivers/scsi/aacraid/commsup.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/commsup.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/commsup.c	Wed Nov 14 15:26:28 2001
@@ -141,7 +141,7 @@ FsaExtendFibContextZone (IN PAFA_COMM_AD
 	PVOID FibContextSegment;
 	PCOMM_FIB_CONTEXT FibContext;
 	PFIB Fib;
-	PVOID FibPhysicalAddress;
+	dma_addr_t FibPhysicalAddress;
 	int i;
 	PFIB_CONTEXT_ZONE_SEGMENT ZoneSegment;
 	
@@ -200,10 +200,10 @@ FsaExtendFibContextZone (IN PAFA_COMM_AD
 		Fib->Header.XferState = 0xffffffff;
 		Fib->Header.SenderSize = sizeof(FIB);
 
-		FibContext->LogicalFibAddress.LowPart = (ULONG) FibPhysicalAddress;
+		FibContext->LogicalFibAddress = FibPhysicalAddress;
 
 		Fib = (PFIB)((PUCHAR)Fib + sizeof(FIB));
-		FibPhysicalAddress = (PVOID)((PUCHAR)FibPhysicalAddress + sizeof(FIB));
+		FibPhysicalAddress = FibPhysicalAddress + sizeof(FIB);
 	}
 
 	//
@@ -1078,7 +1078,7 @@ GetQueueEntry (IN PAFA_COMM_ADAPTER Adap
     //
 
     if (MapAddress) {
-		QueueEntry->FibAddress = (ULONG)(FibContext->LogicalFibAddress.LowPart);
+            QueueEntry->FibAddress = FibContext->LogicalFibAddress;
     }
     
     //
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/aac_unix_defs.h linux/drivers/scsi/aacraid/include/aac_unix_defs.h
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/aac_unix_defs.h	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/include/aac_unix_defs.h	Thu Nov 15 17:04:32 2001
@@ -61,7 +61,7 @@ typedef struct {
 	unsigned long	HighPart;
 } LARGE_INTEGER;
 
-typedef LARGE_INTEGER	PHYSICAL_ADDRESS;
+typedef dma_addr_t      PHYSICAL_ADDRESS;
 
 
 typedef struct _AFA_IOCTL_CMD {
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/adapter.h linux/drivers/scsi/aacraid/include/adapter.h
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/adapter.h	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/include/adapter.h	Wed Nov 14 15:24:31 2001
@@ -77,7 +77,7 @@ typedef struct _AFA_COMM_ADAPTER {
 	PVOID				FibContextTimedOutList;
 
 	PFIB				SyncFib;
-	ULONG				SyncFibPhysicalAddress;
+	dma_addr_t			SyncFibPhysicalAddress;
 
 	PCOMM_REGION 		CommRegion;
 
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/comstruc.h linux/drivers/scsi/aacraid/include/comstruc.h
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/comstruc.h	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/include/comstruc.h	Wed Nov 14 13:27:49 2001
@@ -392,13 +392,13 @@ typedef struct _ADAPTER_INIT_STRUCT {
 	AAC_UINT32		InitStructRevision;
 	AAC_UINT32		MiniPortRevision;
 	AAC_UINT32		FilesystemRevision;
-	PAAC_VOID		CommHeaderAddress;
+	PHYSICAL_ADDRESS	CommHeaderAddress;
 	PAAC_VOID		FastIoCommAreaAddress;
-	PAAC_VOID		AdapterFibsPhysicalAddress;
+	PHYSICAL_ADDRESS	AdapterFibsPhysicalAddress;
 	PAAC_VOID		AdapterFibsVirtualAddress;
 	AAC_UINT32		AdapterFibsSize;
 	AAC_UINT32		AdapterFibAlign;
-	PAAC_VOID		PrintfBufferAddress;
+	PHYSICAL_ADDRESS	PrintfBufferAddress;
 	AAC_UINT32		PrintfBufferSize;
 	AAC_UINT32		HostPhysMemPages;		// number of 4k pages of host physical memory
 	AAC_UINT32		HostElapsedSeconds;		// number of seconds since 1970.
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/fsaport.h linux/drivers/scsi/aacraid/include/fsaport.h
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/fsaport.h	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/include/fsaport.h	Wed Nov 14 13:30:21 2001
@@ -58,7 +58,7 @@ typedef struct _MAPFIB_CONTEXT {
     ULONG 		NumberMapRegs;
 	PVOID		FibVirtualAddress;
 	ULONG		Size;
-	PVOID	    FibPhysicalAddress;
+	dma_addr_t      FibPhysicalAddress;
 
 
 } MAPFIB_CONTEXT;
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/pcisup.h linux/drivers/scsi/aacraid/include/pcisup.h
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/include/pcisup.h	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/include/pcisup.h	Tue Nov 13 11:22:28 2001
@@ -39,8 +39,7 @@ static char *ident_pcisup = "aacraid_ide
 typedef struct _PCI_MINIPORT_COMMON_EXTENSION {
 	ULONG					AdapterNumber;			// Which FSA# this miniport is
 	
-	ULONG					PciBusNumber;			// Which PCI bus we are located on
-	ULONG					PciSlotNumber;			// Whiat PCI slot we are in
+	struct pci_dev *			PciDev;				// Which PCI bus we are located on
 	
 	PVOID					Adapter;				// Back pointer to Fsa adapter object
 	ULONG					AdapterIndex;			// Index into PlxAdapterTypes array
@@ -51,7 +50,7 @@ typedef struct _PCI_MINIPORT_COMMON_EXTE
 	
 	
 	PADAPTER_INIT_STRUCT	InitStruct;				// Holds initialization info to communicate with adapter
-	PVOID					PhysicalInitStruct; 	// Holds physical address of the init struct
+	dma_addr_t				PhysicalInitStruct; 	// Holds physical address of the init struct
 	
 	
 	PVOID					PrintfBufferAddress;	// pointer to buffer used for printf's from the adapter
@@ -62,7 +61,7 @@ typedef struct _PCI_MINIPORT_COMMON_EXTE
 	void *					MiniPort;
 	
 	caddr_t					CommAddress;	// Base address of Comm area
-	paddr32_t				CommPhysAddr;	// Physical Address of Comm area
+	dma_addr_t				CommPhysAddr;	// Physical Address of Comm area
 	size_t					CommSize;
 
 	OsKI_t 					OsDep;			// OS dependent kernel interfaces
@@ -76,8 +75,7 @@ typedef int
 (*PFSA_MINIPORT_INIT) (
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 	);
 
 typedef struct _FSA_MINIPORT {
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/linit.c linux/drivers/scsi/aacraid/linit.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/linit.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/linit.c	Thu Nov 15 16:19:31 2001
@@ -226,8 +226,6 @@ int AAC_DetectHostAdapter (Scsi_Host_Tem
 		fsadev_t *fsa_dev_ptr;
 		char *DeviceName;
 
-		struct pci_dev *devp;
-
 		int	first_index, last_index, increment;
 
 		CommPrinting = TRUE;
@@ -308,6 +306,9 @@ int AAC_DetectHostAdapter (Scsi_Host_Tem
 								continue;
 						}
 			
+						/* Configure DMA attributes (limit to 32-bit addresses). */
+						if (pci_set_dma_mask(dev, (u64) 0xffffffff))
+							continue;
 
 						printk(KERN_ALERT "%s device detected\n", DeviceName );
 						cmn_err(CE_DEBUG, "%x/%x/%x/%x", vendor_id, device_id, sub_vendor_id, sub_system_id);
@@ -327,6 +328,13 @@ int AAC_DetectHostAdapter (Scsi_Host_Tem
 						// specific information.
 						host_ptr = scsi_register( HostTemplate, sizeof( PCI_MINIPORT_COMMON_EXTENSION ) );
 
+/* These fields are only present in 2.4.x-ac kernels */
+#if 0
+						// Let the OS know we can handle highmem DMA and single-element scatter-gathers
+						host_ptr->can_dma_32 = 1;
+						host_ptr->single_sg_ok = 1;
+#endif
+
 						// These three parameters can be used to allow for wide SCSI 
 						// and for host adapters that support multiple buses.
 						host_ptr->max_id = 17;
@@ -336,7 +344,7 @@ int AAC_DetectHostAdapter (Scsi_Host_Tem
 
 						host_ptr->irq = dev->irq;		// Adapter IRQ number
 						/* host_ptr->base = ( char * )(dev->resource[0].start & ~0xff); */
-						host_ptr->base = ( char * )(dev->resource[0].start);
+						host_ptr->base = pci_resource_start(dev, 0);
 						scsi_set_pci_device(host_ptr, dev);
 
 						cmn_err( CE_DEBUG, "Device base address = 0x%lx [0x%lx]", host_ptr->base, dev->resource[0].start );
@@ -379,7 +387,7 @@ int AAC_DetectHostAdapter (Scsi_Host_Tem
 						// Call initialization routine
 						cmn_err (CE_DEBUG, "Initializing Hardware...\n");
 						if( ( *MiniPorts[index].InitRoutine )
-							( CommonExtensionPtr, host_ptr->unique_id, dev->bus->number, 0 ) != 0 )
+							( CommonExtensionPtr, host_ptr->unique_id, dev ) != 0 )
 						{
 								// device initialization failed
 								cmn_err( CE_WARN, "%s:%d device initialization failed", DeviceName, host_ptr->unique_id );
@@ -1066,22 +1074,18 @@ int AAC_ProcDirectoryInfo(
 void aac_allocate_SyncFibs (PCI_MINIPORT_COMMON_EXTENSION *CommonExtension)
 {
   void	 	*BaseAddress;
-  ULONG		PhysAddress;
-  int		size;
-  int		npages;
-  int 		i;
-
+  dma_addr_t	PhysAddress;
   AFA_COMM_ADAPTER		*Adapter;
   Adapter = CommonExtension->Adapter;
 
 
   // Allocate 1 fib for synch fibs
   // Allocate 1 page.
-  BaseAddress = OsAllocMemory ( PAGE_SIZE, OS_ALLOC_MEM_SLEEP);
+  BaseAddress = pci_alloc_consistent(CommonExtension->PciDev, PAGE_SIZE, &PhysAddress);
+  if (BaseAddress) {
   bzero(BaseAddress, PAGE_SIZE);
-  PhysAddress = virt_to_phys (BaseAddress);
   Adapter->SyncFib = BaseAddress;
   Adapter->SyncFibPhysicalAddress = PhysAddress;
   cmn_err(CE_DEBUG,"aac_allocate_SyncFibs: syncFib: vaddr: 0x%x paddr: 0x%x ", BaseAddress, PhysAddress);
-
+  }
 }
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/osddi.c linux/drivers/scsi/aacraid/osddi.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/osddi.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/osddi.c	Fri Nov 16 14:56:31 2001
@@ -286,21 +286,17 @@ ULONG *OsAllocCommPhysMem(
 	Sa_ADAPTER_EXTENSION 	*AdapterExtension, 
 	ULONG					size,
 	ULONG					**virt_addr_pptr,
-	ULONG					*phys_addr_ptr )
+	dma_addr_t              *phys_addr_ptr )
 /*----------------------------------------------------------------------------*/
 {
-	if( ( *virt_addr_pptr = ( ULONG * )OsAllocMemory( size, GFP_KERNEL ) ) )
+	/* Make a consistent mapping into PCI space for communications. */
+	*virt_addr_pptr = pci_alloc_consistent( AdapterExtension->Common->PciDev, size, phys_addr_ptr );
+	if ( !*virt_addr_pptr )
 	{
-		*phys_addr_ptr = OsVirtToPhys( ( volatile void * )*virt_addr_pptr );
-		if( !*phys_addr_ptr )
-		{
-			cmn_err( CE_WARN, "OsAllocCommPhysMem: OsVirtToPhys failed" );
-		}
-				
-		return( *virt_addr_pptr );
-	}
-	else
+		cmn_err( CE_WARN, "OsAllocCommPhysMem: pci_alloc_consistent failed" );
 		return( NULL );
+	}
+	return *virt_addr_pptr;
 }
 
 OsAifKernelThread(
@@ -386,20 +382,16 @@ BOOLEAN AfaPortAllocateAndMapFibSpace(
     IN PMAPFIB_CONTEXT MapFibContext )
 /*----------------------------------------------------------------------------*/
 {
-	PVOID 		BaseAddress;
-	ULONG		PhysAddress;
+	PPCI_MINIPORT_COMMON_EXTENSION CommonExtension = Arg1;
+	MapFibContext->FibVirtualAddress = pci_alloc_consistent(CommonExtension->PciDev,
+								MapFibContext->Size,
+								&MapFibContext->FibPhysicalAddress);
 
-	if( !( BaseAddress = (ULONG *)OsAllocMemory( MapFibContext->Size, GFP_KERNEL ) ) )
+	if( ! MapFibContext->FibVirtualAddress)
 	{
-		cmn_err( CE_WARN, "AfaPortAllocateAndMapFibSpace: OsAllocMemory failed" );
+		cmn_err( CE_WARN, "AfaPortAllocateAndMapFibSpace: pci_alloc_consistent failed" );
 		return( FALSE );
 	}
-
-	PhysAddress = OsVirtToPhys( BaseAddress );
-	
-	MapFibContext->FibVirtualAddress = BaseAddress;
-	MapFibContext->FibPhysicalAddress = (PVOID) PhysAddress;
-
 	return (TRUE);
 }
 
@@ -409,21 +401,31 @@ BOOLEAN AfaPortUnmapAndFreeFibSpace(
     IN PMAPFIB_CONTEXT MapFibContext )
 /*----------------------------------------------------------------------------*/
 {
-	PPCI_MINIPORT_COMMON_EXTENSION CommonExtension = (PPCI_MINIPORT_COMMON_EXTENSION) Arg1;
-
-	OsFreeMemory( MapFibContext->FibVirtualAddress, 0 );
+	PPCI_MINIPORT_COMMON_EXTENSION CommonExtension = Arg1;
+	pci_free_consistent(CommonExtension->PciDev,
+			    MapFibContext->Size,
+			    MapFibContext->FibVirtualAddress,
+			    MapFibContext->FibPhysicalAddress);
+	MapFibContext->FibVirtualAddress = NULL;
+	MapFibContext->FibPhysicalAddress = 0;
+	MapFibContext->Size = 0;
 
 	return (TRUE);
 }
 
 /*----------------------------------------------------------------------------*/
-BOOLEAN AfaPortFreeAdapterCommArea(
+BOOLEAN AfaPortFreeAdapterCommArea (
 	IN PVOID Arg1 )
 /*----------------------------------------------------------------------------*/
 {
-	PPCI_MINIPORT_COMMON_EXTENSION CommonExtension = (PPCI_MINIPORT_COMMON_EXTENSION) Arg1;
-
-	OsFreeMemory( CommonExtension->CommAddress, 0 );
+	PPCI_MINIPORT_COMMON_EXTENSION CommonExtension = Arg1;
+	pci_free_consistent(CommonExtension->PciDev,
+			    CommonExtension->CommSize,
+			    CommonExtension->CommAddress,
+			    CommonExtension->CommPhysAddr);
+	CommonExtension->CommAddress = NULL;
+	CommonExtension->CommPhysAddr = 0;
+	CommonExtension->CommSize = 0;
 
 	return (TRUE);
 }
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/osfuncs.c linux/drivers/scsi/aacraid/osfuncs.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/osfuncs.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/osfuncs.c	Thu Nov 15 16:24:19 2001
@@ -33,7 +33,7 @@ static char *ident_osfuncs = "aacraid_id
 extern aac_options_t g_options;
 
 OS_SOFTINTR g_idle_task = { 0, 0, 0, 0 };
-wait_queue_t * g_wait_queue_ptr = NULL;
+DECLARE_WAIT_QUEUE_HEAD(g_wait_queue_ptr);
 wait_queue_t g_wait;
 
 void OsTimeoutHandler( 
@@ -91,15 +91,6 @@ void OsUnregisterInterrupt(
 }
 
 
-/*----------------------------------------------------------------------------*/
-unsigned long OsVirtToPhys( 
-	void * virtual_address )
-/*----------------------------------------------------------------------------*/
-{
-	return( virt_to_phys( virtual_address ) );
-}
-
-
 //-----------------------------------------------------------------------------
 // MUTEX functions
 
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/port.c linux/drivers/scsi/aacraid/port.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/port.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/port.c	Wed Nov 14 13:27:02 2001
@@ -84,7 +84,7 @@ Return Value:
 
 }
 
-BOOLEAN
+VOID
 AfaPortGetNextAdapterNumber(
     IN  PDRIVER_OBJECT  DriverObject,
 	OUT PDEVICE_OBJECT 	*FsaDeviceObject,
@@ -93,6 +93,7 @@ AfaPortGetNextAdapterNumber(
 	)
 {
 }
+
 BOOLEAN
 AfaPortAllocateAdapterCommArea(
 	IN PVOID		Arg1,
@@ -113,7 +114,6 @@ AfaPortAllocateAdapterCommArea(
 	ULONG PrintfBufferSize = 256;
 	PADAPTER_INIT_STRUCT InitStruct;
 	extern int MiniPortRevision;
-	ULONG	PhysAddress;
 
 //	TotalSize = AdapterFibsSize + sizeof(ADAPTER_INIT_STRUCT) + CommAreaSize + CommAreaAlignment +
 //		 SizeOfFastIoComm + PrintfBufferSize;
@@ -121,17 +121,15 @@ AfaPortAllocateAdapterCommArea(
 		 PrintfBufferSize;
 
 
-	OsAllocCommPhysMem(CommonExtension->MiniPort, TotalSize, &BaseAddress, &PhysAddress);
+	OsAllocCommPhysMem(CommonExtension->MiniPort, TotalSize, &BaseAddress, &PhysicalBaseAddress);
+	if (!BaseAddress) return FALSE;
 
 	CommonExtension->CommAddress  = BaseAddress;
-	CommonExtension->CommPhysAddr = PhysAddress;
+	CommonExtension->CommPhysAddr = PhysicalBaseAddress;
 	CommonExtension->CommSize 	  = TotalSize;
 
-	PhysicalBaseAddress.HighPart = 0;
-	PhysicalBaseAddress.LowPart = PhysAddress;
-
 	CommonExtension->InitStruct = (PADAPTER_INIT_STRUCT)((PUCHAR)(BaseAddress) + AdapterFibsSize);
-	CommonExtension->PhysicalInitStruct = (PADAPTER_INIT_STRUCT)((PUCHAR)(PhysicalBaseAddress.LowPart) + AdapterFibsSize);
+	CommonExtension->PhysicalInitStruct = PhysicalBaseAddress + AdapterFibsSize;
 
 	InitStruct = CommonExtension->InitStruct;
 
@@ -143,7 +141,7 @@ AfaPortAllocateAdapterCommArea(
 	// Adapter Fibs are the first thing allocated so that they start page aligned
 	//
 	InitStruct->AdapterFibsVirtualAddress = BaseAddress;
-	InitStruct->AdapterFibsPhysicalAddress = (PVOID) PhysicalBaseAddress.LowPart;
+	InitStruct->AdapterFibsPhysicalAddress = PhysicalBaseAddress;
 	InitStruct->AdapterFibsSize = AdapterFibsSize;
 	InitStruct->AdapterFibAlign = sizeof(FIB);
 
@@ -151,33 +149,33 @@ AfaPortAllocateAdapterCommArea(
 	// Increment the base address by the amount already used
 	//
 	BaseAddress = (PVOID)((PUCHAR)(BaseAddress) + AdapterFibsSize + sizeof(ADAPTER_INIT_STRUCT));
-	PhysicalBaseAddress.LowPart = (ULONG)((PUCHAR)(PhysicalBaseAddress.LowPart) + AdapterFibsSize + sizeof(ADAPTER_INIT_STRUCT));
+	PhysicalBaseAddress = PhysicalBaseAddress + AdapterFibsSize + sizeof(ADAPTER_INIT_STRUCT);
 
 	//
 	// Align the beginning of Headers to CommAreaAlignment
 	//
 	BytesToAlign = (CommAreaAlignment - ((ULONG)(BaseAddress) & (CommAreaAlignment - 1)));
 	BaseAddress = (PVOID)((PUCHAR)(BaseAddress) + BytesToAlign);
-	PhysicalBaseAddress.LowPart = (ULONG)((PUCHAR)(PhysicalBaseAddress.LowPart) + BytesToAlign);
+	PhysicalBaseAddress = PhysicalBaseAddress + BytesToAlign;
 
 	//
 	// Fill in addresses of the Comm Area Headers and Queues
 	//
 	*CommHeaderAddress = BaseAddress;
-	InitStruct->CommHeaderAddress = (PVOID)PhysicalBaseAddress.LowPart;
+	InitStruct->CommHeaderAddress = PhysicalBaseAddress;
 
 	//
 	//	Increment the base address by the size of the CommArea
 	//
 	BaseAddress = (PVOID)((PUCHAR)(BaseAddress) + CommAreaSize);
-	PhysicalBaseAddress.LowPart = (ULONG)((PUCHAR)(PhysicalBaseAddress.LowPart) + CommAreaSize);
+	PhysicalBaseAddress = PhysicalBaseAddress + CommAreaSize;
 
 
 	//
 	// Place the Printf buffer area after the Fast I/O comm area.
 	//
 	CommonExtension->PrintfBufferAddress = (PVOID)(BaseAddress);
-	InitStruct->PrintfBufferAddress = (PVOID)PhysicalBaseAddress.LowPart;
+	InitStruct->PrintfBufferAddress = PhysicalBaseAddress;
 	InitStruct->PrintfBufferSize = PrintfBufferSize;
 	bzero (BaseAddress, PrintfBufferSize);
 
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/rx.c linux/drivers/scsi/aacraid/rx.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/rx.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/rx.c	Wed Nov 14 14:11:56 2001
@@ -69,8 +69,7 @@ int
 RxInitDevice(
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 );
 
 BOOLEAN
@@ -342,8 +341,7 @@ int
 RxInitDevice(
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 )
 
 /*++
@@ -375,6 +373,7 @@ Return Value:
 	int instance;
 	int nIntrs;
 	char * name;
+	dma_addr_t dma_handle;
 
     AfaPortPrint("In init device.\n");
 
@@ -384,10 +383,7 @@ Return Value:
 	CommonExtension->AdapterNumber = AdapterNumber;
 
 
-	CommonExtension->PciBusNumber = PciBus;
-	CommonExtension->PciSlotNumber = PciSlot;
-
-
+	CommonExtension->PciDev = pdev;
 	AdapterExtension = OsAllocMemory( sizeof(Rx_ADAPTER_EXTENSION), OS_ALLOC_MEM_SLEEP );
 	AdapterExtension->Common = CommonExtension;
 	CommonExtension->MiniPort = AdapterExtension;
diff -burNp --exclude-from=/home/mdomsch/excludes linux-2.4.14.oldaacraid/drivers/scsi/aacraid/sap1sup.c linux/drivers/scsi/aacraid/sap1sup.c
--- linux-2.4.14.oldaacraid/drivers/scsi/aacraid/sap1sup.c	Wed Nov 14 13:53:35 2001
+++ linux/drivers/scsi/aacraid/sap1sup.c	Wed Nov 14 14:11:50 2001
@@ -77,8 +77,7 @@ int
 SaInitDevice(
 	IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
 	IN ULONG AdapterNumber,
-	IN ULONG PciBus,
-	IN ULONG PciSlot
+	struct pci_dev *pdev
 );
 
 BOOLEAN
@@ -347,8 +346,7 @@ Return Value:
 --*/
 int
 SaInitDevice (IN PPCI_MINIPORT_COMMON_EXTENSION CommonExtension,
-			  IN ULONG AdapterNumber, IN ULONG PciBus,
-			  IN ULONG PciSlot)
+			  IN ULONG AdapterNumber, struct pci_dev *pdev)
 {
 	AAC_STATUS Status;
 	PSa_ADAPTER_EXTENSION AdapterExtension = NULL;
@@ -357,13 +355,13 @@ SaInitDevice (IN PPCI_MINIPORT_COMMON_EX
 	ULONG InitStatus;
 	int instance;
 	char *name;
+	dma_addr_t dma_addr;
 
     AfaPortPrint("In init device.\n");
 
 	CommonExtension->AdapterNumber = AdapterNumber;
 
-	CommonExtension->PciBusNumber = PciBus;
-	CommonExtension->PciSlotNumber = PciSlot;
+	CommonExtension->PciDev = pdev;
 
 	AdapterExtension = OsAllocMemory( sizeof(Sa_ADAPTER_EXTENSION), OS_ALLOC_MEM_SLEEP );
 	AdapterExtension->Common = CommonExtension;
