From nobody@FreeBSD.org  Thu Oct 12 03:22:20 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 344C916A494
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Oct 2006 03:22:20 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 60B5743D5E
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Oct 2006 03:22:19 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k9C3MIdL051463
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Oct 2006 03:22:18 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k9C3MIbT051462;
	Thu, 12 Oct 2006 03:22:18 GMT
	(envelope-from nobody)
Message-Id: <200610120322.k9C3MIbT051462@www.freebsd.org>
Date: Thu, 12 Oct 2006 03:22:18 GMT
From: Rich Wales<richw@richw.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Promise SATA PDC4xxxx cards -- port numbering problem
X-Send-Pr-Version: www-3.0

>Number:         104318
>Category:       kern
>Synopsis:       Promise SATA PDC4xxxx cards -- port numbering problem
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 12 03:30:09 GMT 2006
>Closed-Date:    Sat Feb 24 10:02:20 GMT 2007
>Last-Modified:  Sat Feb 24 10:02:20 GMT 2007
>Originator:     Rich Wales
>Release:        6.1-RELEASE-p10
>Organization:
>Environment:
FreeBSD tapeworm.richw.org 6.1-RELEASE-p10 FreeBSD 6.1-RELEASE-p10 #8: Tue Oct 10 18:37:52 PDT 2006     richw@tapeworm.richw.org:/usr/obj/usr/src/sys/WHODUNIT  i386
>Description:
On the newer 4-port Promise non-RAID SATA cards (with PDC4xxxx-series chips), the enumeration of the ports is jumbled.  The port labelled as "Port 1" on the card, for example, is being recognized as if it were port 4.

This problem has been noted with Linux systems as well; see this page, for instance:  http://www.thisishull.net/printthread.php?t=150545

>How-To-Repeat:

>Fix:
The accompanying patch rearranges the unit numbers so the enumeration of the ports will correspond to the physical labelling on the card.  This code assumes that ata_promise_mio_allocate() will only be called once for each device.

Patch attached with submission follows:

--- sys/dev/ata/ata-chipset.c.orig	Thu Mar 16 13:28:51 2006
+++ sys/dev/ata/ata-chipset.c	Tue Oct 10 00:14:16 2006
@@ -3332,6 +3332,11 @@
     return 0;
 }
 
+/*
+ * translation map for port enumeration on PDC4xxxx-series controllers
+ */
+static int pdc4_port_map[4] = {3, 1, 0, 2};
+
 static int
 ata_promise_mio_allocate(device_t dev)
 {
@@ -3339,6 +3344,15 @@
     struct ata_channel *ch = device_get_softc(dev);
     int offset = (ctlr->chip->cfg2 & PRSX4X) ? 0x000c0000 : 0;
     int i;
+
+    /*
+     * port enumeration on PDC4xxxx-series controllers
+     * doesn't correspond to labelling on the card;
+     * rearrange unit numbers to make them correspond
+     */
+    if ((ctlr->chip->cfg2 & PRSATA2)
+	&& ch->unit >= 0 && ch->unit <= 3)
+    	ch->unit = pdc4_port_map[ch->unit];
  
     for (i = ATA_DATA; i <= ATA_COMMAND; i++) {
 	ch->r_io[i].res = ctlr->r_res2;

>Release-Note:
>Audit-Trail:

From: Rich Wales <richw@stanford.edu>
To: bug-followup@FreeBSD.org,  richw@richw.org
Cc:  
Subject: Re: kern/104318: Promise SATA PDC4xxxx cards -- port numbering problem
Date: Wed, 21 Feb 2007 09:34:14 -0800

 Per e-mail comments from Sren, the real problem here is with the
 labelling on the card, not the driver; some (though not all) Promise
 PDC4xxxx-based cards do have the ports labelled correctly; and the
 proper solution is to correct the port labelling on the card itself
 rather than play around with the numbering of ports in the driver.
 
State-Changed-From-To: open->closed 
State-Changed-By: remko 
State-Changed-When: Sat Feb 24 10:02:18 UTC 2007 
State-Changed-Why:  
The submitter replies that manual corrections to the port labels have to 
be done on the card instead of in the driver itself. I think we can 
close the ticket with this. Please provide additional feedback if we 
cannot close this after all. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=104318 
>Unformatted:
