Subject: kern/13540: HPT-370A patch for NetBSD 1.5.1 (release)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <skanto@sjk-software.fi>
List: netbsd-bugs
Date: 07/23/2001 16:44:24
>Number:         13540
>Category:       kern
>Synopsis:       HPT-370A detection "bug"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          support
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 23 06:41:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.5.1
>Organization:
>Environment:
AMD Athlon 1.33GHz on EPOX 8KTA3+
System: NetBSD haapana 1.5.1 NetBSD 1.5.1 (HAAPANA) #1: Sat Jul 21 05:12:08 EEST 2001 root@haapana:/usr/src/sys/arch/i386/compile/HAAPANA i386


>Description:
	PCIIDE-driver detects HPT-370A chip incorrectly as HPT-366. This is
	because HPT-370A has different revision number than HPT-370 chip.

	This is not a problem when using just primary-channel but when using
	secondary channel also. PCIIDE-driver tries to configure the
	secondary channel in compatibility mode which does not work for 
	HPT-370+ (I think).

>How-To-Repeat:
	Well, install NetBSD-1.5.1 in a machine that has HPT-370A chip and
	try to use secondary channel.

>Fix:
	Modify pciide.c to check that the chip revision is equal to or 
	greater than HPT370_REV. Lines 3003, 3017 and 3085. I'm not sure
	is this the correct way but it seems to work for me.

----8<-----------8<-------------8<------

*** sys-1.5.1/dev/pci/pciide.c	Mon Jul  2 18:21:03 2001
--- sys/dev/pci/pciide.c	Mon Jul 23 14:06:16 2001
***************
*** 3000,3007 ****
  		return;
  	revision = PCI_REVISION(pa->pa_class);
  	printf(": Triones/Highpoint ");
! 	if (revision == HPT370_REV)
! 		printf("HPT370 IDE Controller\n");
  	else
  		printf("HPT366 IDE Controller\n");
  
--- 3000,3008 ----
  		return;
  	revision = PCI_REVISION(pa->pa_class);
  	printf(": Triones/Highpoint ");
! 	if (revision >= HPT370_REV)
! 		printf("HPT370%s IDE Controller\n", revision == HPT370A_REV ?
! 			"A" : "");
  	else
  		printf("HPT366 IDE Controller\n");
  
***************
*** 3014,3020 ****
  	} else {
  		interface = PCIIDE_INTERFACE_BUS_MASTER_DMA |
  		    PCIIDE_INTERFACE_PCI(0);
! 		if (revision == HPT370_REV)
  			interface |= PCIIDE_INTERFACE_PCI(1);
  	}
  
--- 3015,3021 ----
  	} else {
  		interface = PCIIDE_INTERFACE_BUS_MASTER_DMA |
  		    PCIIDE_INTERFACE_PCI(0);
! 		if (revision >= HPT370_REV)
  			interface |= PCIIDE_INTERFACE_PCI(1);
  	}
  
***************
*** 3082,3088 ****
  		wdcattach(&cp->wdc_channel);
  		hpt_setup_channel(&cp->wdc_channel);
  	}
! 	if (revision == HPT370_REV) {
  		/*
  		 * HPT370_REV has a bit to disable interrupts, make sure
  		 * to clear it
--- 3083,3089 ----
  		wdcattach(&cp->wdc_channel);
  		hpt_setup_channel(&cp->wdc_channel);
  	}
! 	if (revision >= HPT370_REV) {
  		/*
  		 * HPT370_REV has a bit to disable interrupts, make sure
  		 * to clear it
*** sys-1.5.1/dev/pci/pciide_hpt_reg.h	Sun Feb  4 20:42:17 2001
--- sys/dev/pci/pciide_hpt_reg.h	Mon Jul 23 14:06:21 2001
***************
*** 46,51 ****
--- 46,52 ----
   */
  #define HPT366_REV 0x01
  #define HPT370_REV 0x03
+ #define HPT370A_REV 0x04
  
  #define HPT_IDETIM(chan, drive) (0x40 + ((drive) * 4) + ((chan) * 8))
  #define HPT_IDETIM_BUFEN		0x80000000
>Release-Note:
>Audit-Trail:
>Unformatted: