From wghicks@bellsouth.net Sun Oct 17 13:36:42 1999
Return-Path: <wghicks@bellsouth.net>
Received: from mail0.atl.bellsouth.net (mail0.atl.bellsouth.net [205.152.0.27])
	by hub.freebsd.org (Postfix) with ESMTP id C710C15139
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 17 Oct 1999 13:36:35 -0700 (PDT)
	(envelope-from wghicks@bellsouth.net)
Received: from wghicks.bellsouth.net (host-216-78-46-111.ath.bellsouth.net [216.78.46.111])
	by mail0.atl.bellsouth.net (3.3.4alt/0.75.2) with ESMTP id QAA20196
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 17 Oct 1999 16:34:12 -0400 (EDT)
Received: (from wghicks@localhost)
	by wghicks.bellsouth.net (8.9.3/8.9.2) id QAA01111;
	Sun, 17 Oct 1999 16:41:14 -0400 (EDT)
	(envelope-from wghicks)
Message-Id: <199910172041.QAA01111@bellsouth.net>
Date: Sun, 17 Oct 1999 16:41:14 -0400 (EDT)
From: wghicks@bellsouth.net
Reply-To: wghicks@bellsouth.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] if_de workaround for when BIOS doesn't set busmaster 
X-Send-Pr-Version: 3.2

>Number:         14380
>Category:       kern
>Synopsis:       [PATCH] if_de workaround for when BIOS doesn't set busmaster
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 17 13:40:01 PDT 1999
>Closed-Date:    Sun Dec 2 12:01:46 PST 2001
>Last-Modified:  Sun Dec 02 12:02:04 PST 2001
>Originator:     W Gerald Hicks
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Fair Play, Uninc.
>Environment:

Ziatech CompactPCI ZT5510/ZT6650

FreeBSD zilch.bellsouth.net 4.0-CURRENT FreeBSD 4.0-CURRENT \
#0: Sun Oct 17 17:23:34 GMT 1999     \
root@zilch.bellsouth.net:/usr/src/sys/compile/ZILCH  i386

>Description:

Apparently the Ziatech BIOS doesn't enable busmastering for their
Dec/Intel 21X4X devices, causing the cards to fail initialization
with the message: 'deX: autosense failed: cable problem?'

After investigating the problem for some time, Mike Smith suggested
setting the PCI configuration busmaster bit.

Thanks Mike!  This solved the problem and makes FreeBSD work for
several models of Ziatech CompactPCI systems here.  I'm not sure
if this should be dealt with at a higher level but this driver
specific patch got me going here :-)

>How-To-Repeat:

100% reproducible.

>Fix:

--- src/sys/pci/if_de.c.orig	Sat Sep 25 12:06:00 1999
+++ src/sys/pci/if_de.c	Sun Oct 17 18:33:32 1999
@@ -81,6 +81,7 @@
 
 #include <net/if_var.h>
 #include <vm/pmap.h>
+#include <pci/pcireg.h>
 #include <pci/pcivar.h>
 #include <pci/dc21040reg.h>
 
@@ -5136,6 +5137,7 @@
 #endif
     int retval, idx;
     u_int32_t revinfo, cfdainfo, id;
+    u_int32_t cfcsinfo;
 #if !defined(TULIP_IOMAPPED)
     vm_offset_t pa_csrs;
 #endif
@@ -5154,6 +5156,37 @@
     revinfo  = pci_conf_read(config_id, PCI_CFRV) & 0xFF;
     id       = pci_conf_read(config_id, PCI_CFID);
     cfdainfo = pci_conf_read(config_id, PCI_CFDA);
+    cfcsinfo = pci_conf_read(config_id, PCI_CFCS);
+
+#if defined(TULIP_DEBUG)
+    printf("    revinfo = 0x%02x\n", revinfo);
+    printf("         id = 0x%08x\n", id);
+    printf("   cfdainfo = 0x%08x\n", cfdainfo);
+    printf("   cfcsinfo = 0x%08x\n", cfcsinfo);
+#endif
+
+    /* turn busmaster on in case BIOS doesn't set it */
+    if(!(cfcsinfo & PCIM_CMD_BUSMASTEREN)) {
+	printf("de%d: enabling busmaster operation\n", unit);
+	cfcsinfo |= PCIM_CMD_BUSMASTEREN;
+	pci_conf_write(config_id, PCI_CFCS, cfcsinfo);
+    }
+
+#if 0
+#if defined(TULIP_IOMAPPED)
+    /* XXX - "other operating systems" set this bit too */
+    if(!(cfcsinfo & PCIM_CMD_PORTEN)) {
+    	printf("de%d: enabling port mapped operation\n", unit);
+	cfcsinfo |= PCIM_CMD_PORTEN;
+	pci_conf_write(config_id, PCI_CFCS, cfcsinfo);
+    }
+#endif
+#endif
+
+#if defined(TULIP_DEBUG)
+    printf("   cfcsinfo = 0x%08x\n", 
+	(unsigned) pci_conf_read(config_id, PCI_CFCS));
+#endif
 
     if (PCI_VENDORID(id) == DEC_VENDORID) {
 	if (PCI_CHIPID(id) == CHIPID_21040)

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Sun Dec 2 11:31:49 PST 2001 
State-Changed-Why:  

Is this patch still required with more recent releases? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14380 
State-Changed-From-To: feedback->closed 
State-Changed-By: iedowse 
State-Changed-When: Sun Dec 2 12:01:46 PST 2001 
State-Changed-Why:  

Mail to submitter bounces. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14380 
>Unformatted:
