+20200130 6.2.15
+ - Fix issue writing more than 512kb of data in one write command
+ (bug introduced 6.2.7)
+ - Fix possible data corruption bug when reading or writing more than
+ 64kb per command (fixed in most cases by 6.2.14)
+
20200101 6.2.14
- Fix for invalid CDROM READ TOC responses (Thanks Simon Gander)
- Fix for data corruption for hosts that transfer more than 64k per
static_assert(SCSI_XFER_MAX >= sizeof(scsiDev.data), "Assumes SCSI_XFER_MAX >= sizeof(scsiDev.data)");\r
\r
// Start reading and filling fifos as soon as possible.\r
- DWT->CYCCNT = 0; // Start counting cycles\r
- scsiSetDataCount(transfer.blocks * bytesPerSector);\r
+ // It's highly unlikely that someone is going to use huge transfers\r
+ // per scsi command, but if they do it'll be slower than usual.\r
+ // Note: Happens in Macintosh FWB HDD Toolkit benchmarks which default\r
+ // to 768kb\r
+ uint32_t totalTransferBytes = transfer.blocks * bytesPerSector;\r
+ int useSlowDataCount = totalTransferBytes >= SCSI_XFER_MAX;\r
+ if (!useSlowDataCount)\r
+ {\r
+ DWT->CYCCNT = 0; // Start counting cycles\r
+ scsiSetDataCount(totalTransferBytes);\r
+ }\r
\r
while ((i < totalSDSectors) &&\r
likely(scsiDev.phase == DATA_OUT) &&\r
sdSpeedKBs,\r
scsiDev.hostSpeedKBs);\r
\r
+ if (useSlowDataCount)\r
+ {\r
+ DWT->CYCCNT = 0; // Start counting cycles\r
+ scsiSetDataCount(totalBytes);\r
+ }\r
+\r
uint32_t scsiBytesRead = 0;\r
if (readAheadBytes > 0)\r
{\r
&parityError);\r
scsiBytesRead += readAheadBytes;\r
\r
- if (i == 0)\r
+ if (i == 0 && !useSlowDataCount)\r
{\r
uint32_t elapsedCycles = DWT->CYCCNT;\r
\r
// do this in a half-duplex fashion. We need to write as much as\r
// possible in each SD card transaction.\r
// use sg_dd from sg_utils3 tools to test.\r
+\r
+ if (useSlowDataCount)\r
+ {\r
+ scsiSetDataCount(sectors * bytesPerSector);\r
+ }\r
+\r
for (int scsiSector = i; scsiSector < i + sectors; ++scsiSector)\r
{\r
int dmaBytes = SD_SECTOR_SIZE;\r