From owner-freebsd-i386@FreeBSD.ORG Sun May 25 17:10:06 2008 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BB4F1065674 for ; Sun, 25 May 2008 17:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 378BC8FC12 for ; Sun, 25 May 2008 17:10:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m4PHA11h053792 for ; Sun, 25 May 2008 17:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m4PHA1HZ053791; Sun, 25 May 2008 17:10:01 GMT (envelope-from gnats) Resent-Date: Sun, 25 May 2008 17:10:01 GMT Resent-Message-Id: <200805251710.m4PHA1HZ053791@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Johnson Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64A5F1065672 for ; Sun, 25 May 2008 17:04:54 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 52BDF8FC21 for ; Sun, 25 May 2008 17:04:54 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m4PH3LOZ013337 for ; Sun, 25 May 2008 17:03:21 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m4PH3LIQ013336; Sun, 25 May 2008 17:03:21 GMT (envelope-from nobody) Message-Id: <200805251703.m4PH3LIQ013336@www.freebsd.org> Date: Sun, 25 May 2008 17:03:21 GMT From: Martin Johnson To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: i386/123980: Patch to implement ATA UDMA speed limit (hw.ata.ata_dma_limit) X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 May 2008 17:10:06 -0000 >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: