Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 May 2008 17:03:21 GMT
From:      Martin Johnson <martin@martinshouse.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/123980: Patch to implement ATA UDMA speed limit (hw.ata.ata_dma_limit)
Message-ID:  <200805251703.m4PH3LIQ013336@www.freebsd.org>
Resent-Message-ID: <200805251710.m4PHA1HZ053791@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         123980
>Category:       i386
>Synopsis:       Patch to implement ATA UDMA speed limit (hw.ata.ata_dma_limit)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 25 17:10:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Martin Johnson
>Release:        7.0-RELEASE-p1
>Organization:
n/a
>Environment:
FreeBSD toybox.internal 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #1: Sun May 25 08:41:05 BST 2008     root@toybox.internal:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
FreeBSD sometimes chooses an unsafe UDMA speed for IDE hard drives, despite best efforts made in the ATA driver code to prevent this.

An example is the Soekris net5501 embedded computer, using a Travelstar E7K100 2.5" hard drive.  FreeBSD 6.2-RELEASE chooses UDMA33 mode for this hardware - which works OK - but FreeBSD 7.0-RELEASE chooses UDMA100 mode, which is too fast and causes disk errors such as "ad0: WARNING - READ_DMA UDMA ICRC error (retrying request) LBA=3871".

The attached patch allows the user to set a new sysctl, hw.ata.ata_dma_limit, in /boot/loader.conf.  This acts as a speed limiter.  For example on the Soekris net5501 platform, this hw.ata.ata_dma_limit="4" reduces the speed to UDMA66 mode, which works well, giving a small performance increase over UDMA33 mode without the errors caused by UDMA100 mode.

>How-To-Repeat:
Clean install (via PXEBOOT and NFS) of FreeBSD 7.0-RELEASE onto Soekris net5501 with E7K100 Travelstar hard drive.   Errors will be reported after installation, particularly when disk activity is heavy.

http://jdc.parodius.com/freebsd/pxeboot_serial_install.html gives some hints including a workaround for a showstopper regarding loading gzip'd mfsroot from pxeboot.

>Fix:
See attached patch.  

This only implements the change for IDE (PATA) drives, and it's possible that similar code might be sensible for SATA drives.


Patch attached with submission follows:

--- ata-all.c.orig	2008-05-25 17:37:53.000000000 +0100
+++ ata-all.c	2008-05-25 17:37:51.000000000 +0100
@@ -78,6 +78,7 @@
 
 /* local vars */
 static int ata_dma = 1;
+static int ata_dma_limit = 6;
 static int atapi_dma = 1;
 
 /* sysctl vars */
@@ -85,6 +86,9 @@
 TUNABLE_INT("hw.ata.ata_dma", &ata_dma);
 SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma, CTLFLAG_RDTUN, &ata_dma, 0,
 	   "ATA disk DMA mode control");
+TUNABLE_INT("hw.ata.ata_dma_limit", &ata_dma_limit);
+SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma_limit, CTLFLAG_RDTUN, &ata_dma_limit, 0,
+	   "ATA disk DMA mode limit");
 TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma);
 SYSCTL_INT(_hw_ata, OID_AUTO, atapi_dma, CTLFLAG_RDTUN, &atapi_dma, 0,
 	   "ATAPI device DMA mode control");
@@ -900,17 +904,17 @@
 ata_umode(struct ata_params *ap)
 {
     if (ap->atavalid & ATA_FLAG_88) {
-	if (ap->udmamodes & 0x40)
+	if (ap->udmamodes & 0x40  &&  ata_dma_limit >= 6)
 	    return ATA_UDMA6;
-	if (ap->udmamodes & 0x20)
+	if (ap->udmamodes & 0x20  &&  ata_dma_limit >= 5)
 	    return ATA_UDMA5;
-	if (ap->udmamodes & 0x10)
+	if (ap->udmamodes & 0x10  &&  ata_dma_limit >= 4)
 	    return ATA_UDMA4;
-	if (ap->udmamodes & 0x08)
+	if (ap->udmamodes & 0x08  &&  ata_dma_limit >= 3)
 	    return ATA_UDMA3;
-	if (ap->udmamodes & 0x04)
+	if (ap->udmamodes & 0x04  &&  ata_dma_limit >= 2)
 	    return ATA_UDMA2;
-	if (ap->udmamodes & 0x02)
+	if (ap->udmamodes & 0x02  &&  ata_dma_limit >= 1)
 	    return ATA_UDMA1;
 	if (ap->udmamodes & 0x01)
 	    return ATA_UDMA0;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805251703.m4PH3LIQ013336>