NetBSD Problem Report #52209

From www@NetBSD.org  Tue May  2 18:15:05 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id ACCF57A1F7
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  2 May 2017 18:15:05 +0000 (UTC)
Message-Id: <20170502181504.A30317A2AF@mollari.NetBSD.org>
Date: Tue,  2 May 2017 18:15:04 +0000 (UTC)
From: smesgr@gmail.com
Reply-To: smesgr@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Gumstix: KDASSERT in pxa2x0_gpio if no PCMCIA  bushead given but present
X-Send-Pr-Version: www-1.0

>Number:         52209
>Category:       port-evbarm
>Synopsis:       Gumstix: KDASSERT in pxa2x0_gpio if no PCMCIA  bushead given but present
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 02 18:20:00 +0000 2017
>Closed-Date:    Sat Oct 29 14:09:25 +0000 2022
>Last-Modified:  Sat Oct 29 14:09:25 +0000 2022
>Originator:     Stephan Meisinger
>Release:        NetBSD 7.99.71
>Organization:
>Environment:
NetBSD 7.99.71 (GUMSTIX) #68: Tue May  2 19:47:52 CEST 2017
        root@netbsd:/usr/obj/sys/arch/evbarm/compile/GUMSTIX

>Description:
Gumstix Connex/Verdex is started

If no boot parameter `busheader` for a GPIO extension board is given but a extenstion board with a PCMCIA adapter is connected a kernel debugging assertion is triggered for the default GUMSTIX kernel.

pxapcic0 at pxaip0 addr 0x20000000: 1 slot
[...]
panic: kernel debugging assertion "gpio < GPIO_NPINS" failed: file "/usr/src/sys/arch/arm/xscale/pxa2x0_gpio.c", line 446

The kernel probes a pcmcia slot but doesn't setup the IRQ-pins. Later card s in the slot are read by using invalid PIN "-1" aka 0xFFFFFFF.



>How-To-Repeat:
boot a GUMSTIX Connex/Verdex board with PCMCIA extension board present but without busheader parameter.
Assertion occure. Expected no assertion occure and no pcmcia slot is available.

pxapcic0 at pxaip0 addr 0x20000000: 0 slot
[...]
boot device: <unknown>
root device: 

See below for suggested patch. The gxpcic now configures only valid slots and always uses the sc_irqcfpin & sc_irqpin array instead of its own copy.

Tested with an NetCF (@connex) and NetCF-Pro (@verdex) with and without the correct busheader parameter.
>Fix:
Index: gxpcic.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/gumstix/gxpcic.c,v
retrieving revision 1.13
diff -u -r1.13 gxpcic.c
--- gxpcic.c	2 Feb 2013 20:06:48 -0000	1.13
+++ gxpcic.c	2 May 2017 17:58:00 -0000
@@ -158,20 +158,22 @@
 {
 	struct pxapcic_softc *sc = device_private(self);
 	struct pxaip_attach_args *pxa = aux;
-	int nslot, i;
+	int nslot, i, j;

 	sc->sc_dev = self;
 	sc->sc_iot = pxa->pxa_iot;

 	nslot = gxpcic_count_slot(sc);

-	for (i = 0; i < nslot; i++) {
-		if (!gxpcic_slot_irqs[i].valid) 
+	for (i = 0, j = 0; i < nslot; i++) {
+		if (!gxpcic_slot_irqs[i].valid) {
+			j++;
 			continue;
-		sc->sc_irqpin[i] = gxpcic_slot_irqs[i].prdy;
-		sc->sc_irqcfpin[i] = gxpcic_slot_irqs[i].cd;
+		}
+		sc->sc_irqpin[i-j] = gxpcic_slot_irqs[i].prdy;
+		sc->sc_irqcfpin[i-j] = gxpcic_slot_irqs[i].cd;
 	}
-	sc->sc_nslots = nslot;
+	sc->sc_nslots = i-j;

 	pxapcic_attach_common(sc, &gxpcic_socket_setup);
 }
@@ -205,13 +207,12 @@

 	switch (which) {
 	case PXAPCIC_CARD_STATUS:
-		reg = pxa2x0_gpio_get_function(gxpcic_slot_irqs[so->socket].cd);
+		reg = pxa2x0_gpio_get_function(so->sc->sc_irqcfpin[so->socket]);
 		return (HAVE_CARD(reg) ?
 		    PXAPCIC_CARD_VALID : PXAPCIC_CARD_INVALID);

 	case PXAPCIC_CARD_READY:
-		reg = pxa2x0_gpio_get_function(
-		    gxpcic_slot_irqs[so->socket].prdy);
+		reg = pxa2x0_gpio_get_function(so->sc->sc_irqpin[so->socket]);
 		return (reg & GPIO_SET ? 1 : 0);

 	default:

>Release-Note:

>Audit-Trail:
From: "Nick Hudson" <skrll@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52209 CVS commit: src/sys/arch/evbarm/gumstix
Date: Fri, 5 Nov 2021 07:39:23 +0000

 Module Name:	src
 Committed By:	skrll
 Date:		Fri Nov  5 07:39:23 UTC 2021

 Modified Files:
 	src/sys/arch/evbarm/gumstix: gxpcic.c

 Log Message:
 Apply patch from PR port-evbarm/52209

 Gumstix: KDASSERT in pxa2x0_gpio if no PCMCIA  bushead given but present


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/gumstix/gxpcic.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: jmcneill@NetBSD.org
State-Changed-When: Sat, 29 Oct 2022 14:09:25 +0000
State-Changed-Why:
Patch from PR applied to HEAD. Thanks for the report!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.