From ari@pommac.syncrontech.com  Wed Jul  7 06:26:43 2004
Return-Path: <ari@pommac.syncrontech.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5563D16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 Jul 2004 06:26:43 +0000 (GMT)
Received: from cocoa.syncrontech.com (cocoa-e0.syncrontech.com [62.71.8.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 03B7243D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 Jul 2004 06:26:42 +0000 (GMT)
	(envelope-from ari@pommac.syncrontech.com)
Received: from guinness.syncrontech.com (guinness.syncrontech.com [62.71.8.19])
	by cocoa.syncrontech.com (8.12.8p2/8.12.8) with ESMTP id i676QcWw054195
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 7 Jul 2004 09:26:39 +0300 (EEST)
	(envelope-from ari@pommac.syncrontech.com)
Received: from pommac.syncrontech.com (pommac.syncrontech.com [62.71.8.20])
	by guinness.syncrontech.com (8.12.9p2/8.12.9) with ESMTP id i676Qb0V051187
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 7 Jul 2004 09:26:38 +0300 (EEST)
	(envelope-from ari@pommac.syncrontech.com)
Received: from pommac.syncrontech.com (localhost [127.0.0.1])
	by pommac.syncrontech.com (8.12.11/8.12.11) with ESMTP id i668mfsJ018337
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 6 Jul 2004 11:48:41 +0300 (EEST)
	(envelope-from ari@pommac.syncrontech.com)
Received: (from ari@localhost)
	by pommac.syncrontech.com (8.12.11/8.12.11/Submit) id i668mfBK018336;
	Tue, 6 Jul 2004 11:48:41 +0300 (EEST)
	(envelope-from ari)
Message-Id: <200407060848.i668mfBK018336@pommac.syncrontech.com>
Date: Tue, 6 Jul 2004 11:48:41 +0300 (EEST)
From: Ari Suutari <ari.suutari@syncrontech.com>
Reply-To: Ari Suutari <ari.suutari@syncrontech.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: isdn4bsd driver for AVM Fritz V2 does not always work after boot
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         68756
>Category:       kern
>Synopsis:       isdn4bsd driver for AVM Fritz V2 does not always work after boot
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 07 06:30:18 GMT 2004
>Closed-Date:    Mon Jul 26 09:15:40 GMT 2004
>Last-Modified:  Mon Jul 26 09:15:40 GMT 2004
>Originator:     Ari Suutari
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
Syncron Tech Oy
>Environment:
System: FreeBSD pommac.syncrontech.com 4.9-RELEASE FreeBSD 4.9-RELEASE #23: Thu May 27 14:09:16 EEST 2004 ari@pommac.syncrontech.com:/usr/obj/usr/src/sys/POMMAC i386


>Description:
	I'm facing odd but repeatable problems with FreeBSD 4.9 and
	AVM Fritz V2 PCI isdn cards. It seems that if I reboot my
	server the isdn card no longer works. However, if I power-off
	and power-on the card works again.

	Without power-off, I'm getting messages like "Awaiting signal"
	from ifpi2 driver and the system never recovers.

	I have tried replacing the isdn card, but it doesn't help. The machines
	are HP Compaq 2000 models.

>How-To-Repeat:
	Install and configure AVM Fritz V2 card and reboot without
	cycling power. Isdn doesn't always come up.
>Fix:

	I compared drivers for this card on Linux and FreeBSD. Linux
	driver writes to STAT0 register during initilization value which
	FreeBSD version does not. Adding this reset code seems to
	fix the problem for me.

	Patch (agains 4.9) follows:


Index: i4b_ifpi2_pci.c
===================================================================
RCS file: /opt/freebsd-cvs/src/sys/i4b/layer1/ifpi2/i4b_ifpi2_pci.c,v
retrieving revision 1.6.2.2
diff -c -r1.6.2.2 i4b_ifpi2_pci.c
*** i4b_ifpi2_pci.c	15 May 2002 08:12:42 -0000	1.6.2.2
--- i4b_ifpi2_pci.c	6 Jul 2004 08:18:35 -0000
***************
*** 155,160 ****
--- 155,161 ----
  /*
   *	AVM PCI Status Latch 0 read only bits
   */
+ #define ASL_RESET		0x01
  #define ASL_TIMERRESET 		0x04
  #define ASL_ENABLE_INT		0x08
  
***************
*** 566,571 ****
--- 567,579 ----
  #ifdef AVMA1PCI_V2_DEBUG
  	printf("avma1pp2_attach: 1 HSCX_STAT %x\n", v);
  #endif
+ 
+ 	bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
+ 	DELAY(SEC_DELAY/100); /* 10 ms */
+ 	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET);
+ 	DELAY(SEC_DELAY/100); /* 10 ms */
+ 	bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
+ 	DELAY(SEC_DELAY/100); /* 10 ms */
  
  	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET);
  	DELAY(SEC_DELAY/100); /* 10 ms */


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gj 
Responsible-Changed-By: gj 
Responsible-Changed-When: Sun Jul 18 20:13:55 GMT 2004 
Responsible-Changed-Why:  
I'll take this, I wrote the driver. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=68756 
State-Changed-From-To: open->closed 
State-Changed-By: gj 
State-Changed-When: Mon Jul 26 09:13:37 GMT 2004 
State-Changed-Why:  
Patch applied to -current and -stable, thanks! 

Project policy only allows security-relevant changes to 4.9, so I 
cannot apply your patch to 4.9. Sorry, but you'll have to maintain 
this patch yourself if you really want to keep using 4.9. 

It's also doubtfull whether I'll be able to commit this patch to 
4.10, since only really critical changes are allowed against that branch, 
and this isn't really critical. 

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