From nobody@FreeBSD.org  Thu May 22 07:05:47 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 30D15106567A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2008 07:05:47 +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 20E7F8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2008 07:05:47 +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 m4M74MAL040542
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2008 07:04:22 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m4M74LAD040541;
	Thu, 22 May 2008 07:04:21 GMT
	(envelope-from nobody)
Message-Id: <200805220704.m4M74LAD040541@www.freebsd.org>
Date: Thu, 22 May 2008 07:04:21 GMT
From: "J. Su" <minichocobo@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: PDC20262 does not support 48 bit DMA access
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         123887
>Category:       kern
>Synopsis:       [ata] PDC20262 does not support 48 bit DMA access
>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 May 22 07:10:01 UTC 2008
>Closed-Date:    
>Last-Modified:  Thu May 22 08:45:55 UTC 2008
>Originator:     J. Su
>Release:        6.3-RELEASE
>Organization:
>Environment:
FreeBSD rasputin.eecs.harvard.edu 6.3-RELEASE-p2 FreeBSD 6.3-RELEASE-p2 #2: Thu May 22 00:30:06 EDT 2008 root@somewhere.net:/usr/src/sys/i386/compile/MYKERNEL i386


>Description:


  My system has a Promise Ultra66 and two 400GB hard disks on it. 

 If I enable IDE DMA, everything works fine until my system start to access something above 137GB boundary. It keeps produce error messages like:

kernel: ad6: FAILURE - READ_DMA48 timed out LBA=781422764
kernel: ad6: FAILURE - READ_DMA timed out LBA=0
kernel: ad6: FAILURE - READ_DMA48 timed out LBA=781422767
kernel: ad6: TIMEOUT - READ_DMA retrying (1 retry left) LBA=1
kernel: ad6: FAILURE - READ_DMA48 timed out LBA=781422705

If I disable DMA ( hw.ata.ata_dma=0), accessing is fine but accessing speed is very low.

I checked the linux kernel mailing list. It seems that Ultra66 does not support the hardware hack of LBA48 support used by Ultra 100, as claimed by Hank Yang. http://lwn.net/Articles/7253/

Linux 2.4.20 kernel source also indicate that the DMA hack is disabled for Ultra66 ( chip: PDC20262 ) as well. check http://lxr-itec.uni-klu.ac.at/um-linux-2.4.20/source/drivers/ide/pdc202xx.c

   I tried to disable the DMA hack for PDC20262. It will generate the same error messages as shown above. I end up making another path disable the DMA support for LBA48. Now everything looks fine now.



>How-To-Repeat:

  Pug in a Ultra 66 and put a >137GB hard drive on it. Do a "dd if=/dev/zero of=/dev/ad4" 


>Fix:

1. Disable ata DMA support. 
2. Use the attached patch, which disables 48bit DMA access.



Patch attached with submission follows:

*** sys/dev/ata/ata-chipset.c.orig	Wed May 21 21:31:49 2008
--- sys/dev/ata/ata-chipset.c	Thu May 22 00:23:25 2008
***************
*** 3264,3273 ****
--- 3264,3279 ----
  	/* FALLTHROUGH */
  
      case PROLD:
  	/* enable burst mode */
  	ATA_OUTB(ctlr->r_res1, 0x1f, ATA_INB(ctlr->r_res1, 0x1f) | 0x01);
+ 
+ 	if (ctlr->chip->chipid == ATA_PDC20262)
+ 	    device_printf(dev,
+ 			  "using PIO transfers above 137GB as workaround for "
+ 			  "48bit DMA access bug, expect reduced performance\n");
+ 
  	ctlr->allocate = ata_promise_allocate;
  	ctlr->setmode = ata_promise_setmode;
  	return 0;
  
      case PRTX:
***************
*** 3387,3401 ****
  }
  
  static int
  ata_promise_allocate(device_t dev)
  {
      struct ata_channel *ch = device_get_softc(dev);
! 
      if (ata_pci_allocate(dev))
  	return ENXIO;
  
      ch->hw.status = ata_promise_status;
      return 0;
  }
  
  static int
--- 3393,3411 ----
  }
  
  static int
  ata_promise_allocate(device_t dev)
  {
+     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
      struct ata_channel *ch = device_get_softc(dev);
!  
      if (ata_pci_allocate(dev))
  	return ENXIO;
  
+     if (ctlr->chip->chipid == ATA_PDC20262)
+         ch->flags |= ATA_NO_48BIT_DMA;
+ 
      ch->hw.status = ata_promise_status;
      return 0;
  }
  
  static int


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