]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/AtaBus&ScsiBus: Dynamically calculate how long shall we wait for the...
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jan 2013 06:03:52 +0000 (06:03 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jan 2013 06:03:52 +0000 (06:03 +0000)
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Elvin Li <elvin.li@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14028 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c

index d44359cfcf99d1a7cdd15bd58f9fd5c4d2141bb2..2c79f46ed9cc57a8132c1461b89ad815a018f84c 100644 (file)
@@ -524,7 +524,36 @@ TransferAtaDevice (
 \r
   Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsWrite];\r
   Packet->Length = EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;\r
-  Packet->Timeout  = ATA_TIMEOUT;\r
+  //\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // | ATA PIO Transfer Mode  |  Transfer Rate  | ATA DMA Transfer Mode  |  Transfer Rate  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // |       PIO Mode 0       |  3.3Mbytes/sec  | Single-word DMA Mode 0 |  2.1Mbytes/sec  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // |       PIO Mode 1       |  5.2Mbytes/sec  | Single-word DMA Mode 1 |  4.2Mbytes/sec  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // |       PIO Mode 2       |  8.3Mbytes/sec  | Single-word DMA Mode 2 |  8.4Mbytes/sec  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // |       PIO Mode 3       | 11.1Mbytes/sec  | Multi-word DMA Mode 0  |  4.2Mbytes/sec  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  // |       PIO Mode 4       | 16.6Mbytes/sec  | Multi-word DMA Mode 1  | 13.3Mbytes/sec  |\r
+  // |------------------------|-----------------|------------------------|-----------------|\r
+  //\r
+  // As AtaBus is used to manage ATA devices, we have to use the lowest transfer rate to\r
+  // calculate the possible maximum timeout value for each read/write operation.\r
+  //\r
+  if (AtaDevice->UdmaValid) {\r
+    //\r
+    // Calculate the maximum timeout value for DMA read/write operation.\r
+    //\r
+    Packet->Timeout  = EFI_TIMER_PERIOD_SECONDS ((TransferLength * AtaDevice->BlockMedia.BlockSize) / 2100000 + 1);\r
+  } else {\r
+    //\r
+    // Calculate the maximum timeout value for PIO read/write operation\r
+    //\r
+    Packet->Timeout  = EFI_TIMER_PERIOD_SECONDS ((TransferLength * AtaDevice->BlockMedia.BlockSize) / 3300000 + 1);\r
+  }\r
+  \r
 \r
   return AtaDevicePassThru (AtaDevice, TaskPacket, Event);\r
 }\r
index 324964a81cc194de7c05ff35cd55bde934f74574..c6d96caeb82a1a4504d54f81c1225962cd5faaa5 100644 (file)
@@ -1815,7 +1815,36 @@ ScsiDiskReadSectors (
     }\r
 \r
     ByteCount = SectorCount * BlockSize;\r
-    Timeout   = EFI_TIMER_PERIOD_SECONDS (2);\r
+    //\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |   ATA Transfer Mode    |  Transfer Rate  |  SCSI Interface  |  Transfer Rate  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 0       |  3.3Mbytes/sec  |     SCSI-1       |    5Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 1       |  5.2Mbytes/sec  |    Fast SCSI     |   10Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 2       |  8.3Mbytes/sec  |  Fast-Wide SCSI  |   20Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 3       | 11.1Mbytes/sec  |    Ultra SCSI    |   20Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 4       | 16.6Mbytes/sec  |  Ultra Wide SCSI |   40Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 0 |  2.1Mbytes/sec  |    Ultra2 SCSI   |   40Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 1 |  4.2Mbytes/sec  | Ultra2 Wide SCSI |   80Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 2 |  8.4Mbytes/sec  |    Ultra3 SCSI   |  160Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Multi-word DMA Mode 0  |  4.2Mbytes/sec  |  Ultra-320 SCSI  |  320Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Multi-word DMA Mode 1  | 13.3Mbytes/sec  |  Ultra-640 SCSI  |  640Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    //\r
+    // As ScsiDisk and ScsiBus driver are used to manage SCSI or ATAPI devices, we have to use\r
+    // the lowest transfer rate to calculate the possible maximum timeout value for each operation.\r
+    // From the above table, we could know 2.1Mbytes per second is lowest one.\r
+    //\r
+    Timeout   = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 1);\r
 \r
     MaxRetry  = 2;\r
     for (Index = 0; Index < MaxRetry; Index++) {\r
@@ -1937,7 +1966,36 @@ ScsiDiskWriteSectors (
     }\r
 \r
     ByteCount = SectorCount * BlockSize;\r
-    Timeout   = EFI_TIMER_PERIOD_SECONDS (2);\r
+    //\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |   ATA Transfer Mode    |  Transfer Rate  |  SCSI Interface  |  Transfer Rate  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 0       |  3.3Mbytes/sec  |     SCSI-1       |    5Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 1       |  5.2Mbytes/sec  |    Fast SCSI     |   10Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 2       |  8.3Mbytes/sec  |  Fast-Wide SCSI  |   20Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 3       | 11.1Mbytes/sec  |    Ultra SCSI    |   20Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // |       PIO Mode 4       | 16.6Mbytes/sec  |  Ultra Wide SCSI |   40Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 0 |  2.1Mbytes/sec  |    Ultra2 SCSI   |   40Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 1 |  4.2Mbytes/sec  | Ultra2 Wide SCSI |   80Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Single-word DMA Mode 2 |  8.4Mbytes/sec  |    Ultra3 SCSI   |  160Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Multi-word DMA Mode 0  |  4.2Mbytes/sec  |  Ultra-320 SCSI  |  320Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    // | Multi-word DMA Mode 1  | 13.3Mbytes/sec  |  Ultra-640 SCSI  |  640Mbytes/sec  |\r
+    // |------------------------|-----------------|------------------|-----------------|\r
+    //\r
+    // As ScsiDisk and ScsiBus driver are used to manage SCSI or ATAPI devices, we have to use\r
+    // the lowest transfer rate to calculate the possible maximum timeout value for each operation.\r
+    // From the above table, we could know 2.1Mbytes per second is lowest one.\r
+    //\r
+    Timeout   = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 1);\r
     MaxRetry  = 2;\r
     for (Index = 0; Index < MaxRetry; Index++) {\r
       if (!ScsiDiskDevice->Cdb16Byte) {\r