Revision: 14068
          http://edk2.svn.sourceforge.net/edk2/?rev=14068&view=rev
Author:   vanjeff
Date:     2013-01-18 02:23:33 +0000 (Fri, 18 Jan 2013)
Log Message:
-----------
Sync patch r14028 from main trunk.
MdeModulePkg/AtaBus&ScsiBus: Dynamically calculate how long shall we wait for 
the finish of a read/write operation according to the actual transfer length.

Revision Links:
--------------
    http://edk2.svn.sourceforge.net/edk2/?rev=14028&view=rev

Modified Paths:
--------------
    branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
    branches/UDK2010.SR1/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c

Modified: 
branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c    
2013-01-18 02:22:42 UTC (rev 14067)
+++ branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c    
2013-01-18 02:23:33 UTC (rev 14068)
@@ -526,7 +526,36 @@
 
   Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsWrite];
   Packet->Length = EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
-  Packet->Timeout  = ATA_TIMEOUT;
+  //
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // | ATA PIO Transfer Mode  |  Transfer Rate  | ATA DMA Transfer Mode  |  
Transfer Rate  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // |       PIO Mode 0       |  3.3Mbytes/sec  | Single-word DMA Mode 0 |  
2.1Mbytes/sec  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // |       PIO Mode 1       |  5.2Mbytes/sec  | Single-word DMA Mode 1 |  
4.2Mbytes/sec  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // |       PIO Mode 2       |  8.3Mbytes/sec  | Single-word DMA Mode 2 |  
8.4Mbytes/sec  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // |       PIO Mode 3       | 11.1Mbytes/sec  | Multi-word DMA Mode 0  |  
4.2Mbytes/sec  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  // |       PIO Mode 4       | 16.6Mbytes/sec  | Multi-word DMA Mode 1  | 
13.3Mbytes/sec  |
+  // 
|------------------------|-----------------|------------------------|-----------------|
+  //
+  // As AtaBus is used to manage ATA devices, we have to use the lowest 
transfer rate to
+  // calculate the possible maximum timeout value for each read/write 
operation.
+  //
+  if (AtaDevice->UdmaValid) {
+    //
+    // Calculate the maximum timeout value for DMA read/write operation.
+    //
+    Packet->Timeout  = EFI_TIMER_PERIOD_SECONDS ((TransferLength * 
AtaDevice->BlockMedia.BlockSize) / 2100000 + 1);
+  } else {
+    //
+    // Calculate the maximum timeout value for PIO read/write operation
+    //
+    Packet->Timeout  = EFI_TIMER_PERIOD_SECONDS ((TransferLength * 
AtaDevice->BlockMedia.BlockSize) / 3300000 + 1);
+  }
+  
 
   return AtaDevicePassThru (AtaDevice, TaskPacket, Event);
 }

Modified: branches/UDK2010.SR1/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c   
2013-01-18 02:22:42 UTC (rev 14067)
+++ branches/UDK2010.SR1/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c   
2013-01-18 02:23:33 UTC (rev 14068)
@@ -1815,7 +1815,36 @@
     }
 
     ByteCount = SectorCount * BlockSize;
-    Timeout   = EFI_TIMER_PERIOD_SECONDS (2);
+    //
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |   ATA Transfer Mode    |  Transfer Rate  |  SCSI Interface  |  
Transfer Rate  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 0       |  3.3Mbytes/sec  |     SCSI-1       |    
5Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 1       |  5.2Mbytes/sec  |    Fast SCSI     |   
10Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 2       |  8.3Mbytes/sec  |  Fast-Wide SCSI  |   
20Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 3       | 11.1Mbytes/sec  |    Ultra SCSI    |   
20Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 4       | 16.6Mbytes/sec  |  Ultra Wide SCSI |   
40Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 0 |  2.1Mbytes/sec  |    Ultra2 SCSI   |   
40Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 1 |  4.2Mbytes/sec  | Ultra2 Wide SCSI |   
80Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 2 |  8.4Mbytes/sec  |    Ultra3 SCSI   |  
160Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Multi-word DMA Mode 0  |  4.2Mbytes/sec  |  Ultra-320 SCSI  |  
320Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Multi-word DMA Mode 1  | 13.3Mbytes/sec  |  Ultra-640 SCSI  |  
640Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    //
+    // As ScsiDisk and ScsiBus driver are used to manage SCSI or ATAPI 
devices, we have to use
+    // the lowest transfer rate to calculate the possible maximum timeout 
value for each operation.
+    // From the above table, we could know 2.1Mbytes per second is lowest one.
+    //
+    Timeout   = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 1);
 
     MaxRetry  = 2;
     for (Index = 0; Index < MaxRetry; Index++) {
@@ -1937,7 +1966,36 @@
     }
 
     ByteCount = SectorCount * BlockSize;
-    Timeout   = EFI_TIMER_PERIOD_SECONDS (2);
+    //
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |   ATA Transfer Mode    |  Transfer Rate  |  SCSI Interface  |  
Transfer Rate  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 0       |  3.3Mbytes/sec  |     SCSI-1       |    
5Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 1       |  5.2Mbytes/sec  |    Fast SCSI     |   
10Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 2       |  8.3Mbytes/sec  |  Fast-Wide SCSI  |   
20Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 3       | 11.1Mbytes/sec  |    Ultra SCSI    |   
20Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // |       PIO Mode 4       | 16.6Mbytes/sec  |  Ultra Wide SCSI |   
40Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 0 |  2.1Mbytes/sec  |    Ultra2 SCSI   |   
40Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 1 |  4.2Mbytes/sec  | Ultra2 Wide SCSI |   
80Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Single-word DMA Mode 2 |  8.4Mbytes/sec  |    Ultra3 SCSI   |  
160Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Multi-word DMA Mode 0  |  4.2Mbytes/sec  |  Ultra-320 SCSI  |  
320Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    // | Multi-word DMA Mode 1  | 13.3Mbytes/sec  |  Ultra-640 SCSI  |  
640Mbytes/sec  |
+    // 
|------------------------|-----------------|------------------|-----------------|
+    //
+    // As ScsiDisk and ScsiBus driver are used to manage SCSI or ATAPI 
devices, we have to use
+    // the lowest transfer rate to calculate the possible maximum timeout 
value for each operation.
+    // From the above table, we could know 2.1Mbytes per second is lowest one.
+    //
+    Timeout   = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 1);
     MaxRetry  = 2;
     for (Index = 0; Index < MaxRetry; Index++) {
       if (!ScsiDiskDevice->Cdb16Byte) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to