From nobody@FreeBSD.org  Thu Jan 31 03:47:53 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8288416A418
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Jan 2008 03:47:53 +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 6CD2F13C458
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Jan 2008 03:47:53 +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 m0V3k3Kc006195
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Jan 2008 03:46:03 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m0V3k3h4006193;
	Thu, 31 Jan 2008 03:46:03 GMT
	(envelope-from nobody)
Message-Id: <200801310346.m0V3k3h4006193@www.freebsd.org>
Date: Thu, 31 Jan 2008 03:46:03 GMT
From: Trevor Blackwell <tlb@tlb.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ATA DMA modes don't work on CF cards
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         120177
>Category:       kern
>Synopsis:       [ata] ATA DMA modes don't work on CF cards
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 31 03:50:00 UTC 2008
>Closed-Date:    
>Last-Modified:  Tue Jul 29 05:20:04 UTC 2008
>Originator:     Trevor Blackwell
>Release:        6.2-PRERELEASE
>Organization:
Anybots
>Environment:
FreeBSD waldo.anybots.com 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #3: Thu Dec  6 23:22:05 PST 2007     root@turbine.anybots.com:/usr/obj/usr/src.RELENG_6/sys/WALDO  i386

>Description:
I can't make any ATA DMA modes work on this system, so I have to use PIO.
The CF card, a Transcend 16 GB card (TS16GCF133), is rated to handle
UDMA 0-4. The motherboard is a embedded system with a CF slot.

Normally, it won't boot at all. If I add hw.ata.ata_dma=0 in
/boot/loader.conf it runs OK in PIO4 mode, but when I say 'atacontrol
mode ad2 UDMA2' it gives a errors like

ad2: TIMEOUT - WRITE_DMA retrying (1 retry left) LBA=16936175
ad2: TIMEOUT - WRITE_DMA retrying (0 retries left) LBA=16936175
ad2: FAILURE - WRITE_DMA timed out LBA=16936175
g_vfs_done():ad2s1a[WRITE(offset=8671281152, length=16384)]error = 5

It seems to get nothing written so it freezes and eventually reboots.

Dmesg shows:

CPU: Intel(R) Pentium(R) III CPU - S          933MHz (930.96-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6b4  Stepping = 4
Features=0x383f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE>
..
acpi0: <VIA606 AWRDACPI> on motherboard
..
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff,0x4000-0x407f,0x4080-0x40ff,0x5000-0x500f,0x6000-0x607f on acpi0
pci0: <ACPI PCI bus> on pcib0
..
atapci0: <VIA 82C686B UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xd000-0xd00f at device 7.1 on pci0
ata1: <ATA channel 1> on atapci0
..
ad2: 15296MB <TRANSCEND 20070831> at ata1-master PIO4

I have a few of these machines and I'm willing to try stuff on them.

>How-To-Repeat:

>Fix:
The workaround is to use PIO mode, but that significantly impacts
real-time performance of my system.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Feb 3 22:28:47 UTC 2008 
Responsible-Changed-Why:  
This does not sound i386-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=120177 

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: bug-followup@FreeBSD.org, tlb@tlb.org
Cc:  
Subject: Re: kern/120177: [ata] ATA DMA modes don't work on CF cards
Date: Tue, 29 Jul 2008 08:52:42 +0400

 Hi, Trevor.
 
 Can you try to set UDMA33 or UDMA66 mode?
 If it will work you can try this patch:
 http://butcher.heavennet.ru/patches/kernel/ata/ata_limit_mode_from_device_hints.diff
 
 With this patch you can set mode in /boot/device.hints (or from loader
   prompt), for example:
 hint.ad.0.mode="UDMA33"
 hint.ad.1.mode="UDMA66"
 
 -- 
 WBR, Andrey V. Elsukov
>Unformatted:
