NetBSD Problem Report #42807

From www@NetBSD.org  Sat Feb 13 20:16:57 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id C6A4063BDFE
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 13 Feb 2010 20:16:56 +0000 (UTC)
Message-Id: <20100213201656.7C03F63B8DE@www.NetBSD.org>
Date: Sat, 13 Feb 2010 20:16:56 +0000 (UTC)
From: jmosalmi@cc.hut.fi
Reply-To: jmosalmi@cc.hut.fi
To: gnats-bugs@NetBSD.org
Subject: sm0 driver should provide a way to select which INTR line of SMC91C96 to use
X-Send-Pr-Version: www-1.0

>Number:         42807
>Category:       kern
>Synopsis:       sm0 driver should provide a way to select which INTR line of SMC91C96 to use
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 13 20:20:01 +0000 2010
>Originator:     Juho Salminen
>Release:        NetBSD 5.99.24
>Organization:
Home
>Environment:
NetBSD turpiaali 5.99.24 NetBSD 5.99.24 (COREMODULE) #3: Sat Feb 13 18:38:41 EET 2010  fijusal@siniara.jmos.iki.fi:/usr/netbsd-current/obj-486/sys/arch/i386/compile/COREMODULE i386
>Description:
I'm using Ampro MM2-ETH-Q-72 NIC with CoreModule CM2-4DE-Q-74 PC/104
single-board computer. The NIC is connected in the ISA bus as is usual
in PC/104 equipment, and it is based on SMC91C96 chip.

The NIC is detected and attached by the sm(4) driver and can be
configured with ifconfig(8). When attempting to, for example, ping other
hosts on the network, some ARP packets are sent from the NIC to the
network. However, no packets are received back from the NIC. In the
kernel output, the following error messages are printed:

sm0: device timeout

The problem is caused by the interrupts generated by the NIC not getting
through to the ISA bus.

This is due to the fact that in ISA mode, the SMC91C96 has four
interrupt pins (INTR0...INTR3), only one of which is selected (in
software) to be used to generate the interrupt. In this particular NIC,
only pins INTR2 and INTR3 are connected to the jumpers that are used to
select the IRQ to use, and INTR0 and INTR1 are not connected. The card
seems to use one of the unconnected pins by default, and the driver
should therefore change the selection to the correct pin (in my case
INTR2, which is then jumpered to IRQ10 line).

The sm(4) driver does not provide the means to select the INTR pin to
use.



>How-To-Repeat:
Attempt to use MM2-ETH-Q-72 NIC with CM2-4DE-Q-74 single-board computer to ping other hosts on the network.

>Fix:
The 91C96's INTR line selection is made with bits CR_INT_SEL0 and
CR_INT_SEL1 in the CONFIG_REG_W register.

In my case, the following patch does the trick and with it applied, the
card works like a charm; however, it is probably wrong for majority of
the other cards that use some other INTR line for interrupts:

Index: smc91cxx.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/smc91cxx.c,v
retrieving revision 1.77
diff -u -r1.77 smc91cxx.c
--- smc91cxx.c  19 Jan 2010 22:06:25 -0000      1.77
+++ smc91cxx.c  13 Feb 2010 19:39:50 -0000
@@ -319,6 +319,13 @@
            IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
        IFQ_SET_READY(&ifp->if_snd);

+       /* Select the interrupt pin to use */
+       SMC_SELECT_BANK(sc, 1);
+       tmp = bus_space_read_2(bst, bsh, CONFIG_REG_W);
+       tmp &= ~(CR_INT_SEL0 | CR_INT_SEL1);
+       tmp |= CR_INT_SEL1;
+       bus_space_write_2(bst, bsh, CONFIG_REG_W, tmp);
+    
        /* Attach the interface. */
        if_attach(ifp);
        ether_ifattach(ifp, myea);


Therefore, the interrupt line selection should at least be made some
kind of configurable option for the sm(4) driver. Could this be set in
the kernel configuration, for example? The perfect solution would of
course be to somehow "autodetect" this, but I don't know if it's
possible or even necessary, since this apparently is a rare problem
anyway.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.