From nobody@FreeBSD.org  Mon Oct 13 01:36:14 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D3C401065688
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 01:36:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id C0FDE8FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 01:36:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9D1aEIb089206
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 01:36:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9D1aE37089204;
	Mon, 13 Oct 2008 01:36:14 GMT
	(envelope-from nobody)
Message-Id: <200810130136.m9D1aE37089204@www.freebsd.org>
Date: Mon, 13 Oct 2008 01:36:14 GMT
From: Arthur Hartwig <arthur.hartwig@nokia.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: System hang on shutdown with PCMCIA-CF adapter inserted
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128037
>Category:       kern
>Synopsis:       [pccbb] [patch] System hang on shutdown with PCMCIA-CF adapter inserted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 13 01:40:01 UTC 2008
>Closed-Date:    
>Last-Modified:  Mon Oct 13 04:34:39 UTC 2008
>Originator:     Arthur Hartwig
>Release:        6.3
>Organization:
Nokia
>Environment:
>Description:
System has a TI PCI1520 Cardbus PCI bridge. If a PCMCIA to Compact Flash
adapter is inserted in the Cardbus slot and the system is shutdown then
the shutdown does not complete.

This has been not been observed on multi-CPU systems. It has been observed
on single CPU systems with a 1.5GHz Celeron CPU but not on a single CPU
system with a XEON 2.80GHz CPU. (This CPU has hyperthreading capability
but it is run with hyperthreading disabled and a single CPU kernel.)

Breaking into ddb from the console shows one thread in cbb_power() called
from cbb_shutdown() and another thread in cbb_intr(). From setting
breakpoints it appears the exca_clrb(&sc->exca[0], EXCA_INTR,
EXCA_INTR_RESET); call in cbb_shutdown() causes a delayed interrupt request
which, on slower CPUs, interrupts cbb_power() early in its execution and
certainly before power to the socket is turned off. The interrupt
apparently is not cleared by the interrupt handlers and repeats
indefinitely, preventing cbb_power() making progress to the points of
turning off power to the card. (On a multi-CPU system cbb_shutdown and
cbb_intr() can run in parallel concurrently so the continuous interrupts
don't stop cbb_power() making progress to the point of turning off power
to the socket.)


>How-To-Repeat:
Shutdown a "slower" single CPU system with a PCMCIA-Compact Flash adapter
in the slot of a TI PCI1520 Cardbus PCI bridge. (It is unknown if this
problem occurs with other Cardbus PCI bridges.)


>Fix:
In cbb_shutdown() in sys/dev/pccbb/pccbb.c add disable_intr() before the exca_clrb() and enable_intr() after cbb_power() so the code reads:

	disable_intr();
	exca_clrb(&sc->exca[0], EXCA_INTR, EXCA_INTR_RESET);

	cbb_set(sc, CBB_SOCKET_MASK, 0);
	cbb_set(sc, CBB_SOCKET_EVENT, 0xffffffff);

	cbb_power(brdev, CARD_OFF); 
	enable_intr();


>Release-Note:
>Audit-Trail:
>Unformatted:
