Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Oct 2002 00:42:59 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        iwasaki@jp.FreeBSD.org
Cc:        iedowse@maths.tcd.ie, freebsd-mobile@FreeBSD.ORG
Subject:   Re: Patch to fix/shorten "wi" freezes
Message-ID:  <20021029.004259.107520615.imp@bsdimp.com>
In-Reply-To: <20021029.122934.67876690.iwasaki@jp.FreeBSD.org>
References:  <200210271800.aa11251@salmon.maths.tcd.ie> <20021029.122934.67876690.iwasaki@jp.FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20021029.122934.67876690.iwasaki@jp.FreeBSD.org>
            Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org> writes:
: Here are 2 patches against similar problems related wi.
: Please review them.  TIA.
: 
: 1. The suspend methods problem with NEWARD cardbus and pccard.
:    cardbus_suspend() forced cbb into power off via
:    cbb_power(CARD_VCC_0V) before pccard_suspend() detach wi properly.

Good call.  I agree that this is the bug, but I'm not sure I like the
solution.

: ----
: Index: cardbus.c
: ===================================================================
: RCS file: /home/ncvs/src/sys/dev/cardbus/cardbus.c,v
: retrieving revision 1.24
: diff -u -r1.24 cardbus.c
: --- cardbus.c	7 Oct 2002 23:00:51 -0000	1.24
: +++ cardbus.c	11 Oct 2002 02:22:28 -0000
: @@ -148,6 +148,8 @@
:  static int	cardbus_write_ivar(device_t cbdev, device_t child, int which,
:  		    uintptr_t value);
:  
: +#define DETACH_NOWARN 0x800
: +
:  /************************************************************************/
:  /* Probe/Attach								*/
:  /************************************************************************/
: @@ -175,7 +177,7 @@
:  static int
:  cardbus_suspend(device_t self)
:  {
: -	cardbus_detach_card(self, DETACH_FORCE);
: +	cardbus_detach_card(self, DETACH_NOWARN); /* detach existing cards */
:  	return (0);
:  }
:  
: @@ -208,8 +210,6 @@
:  	PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 0x14, 1);
:  	cfg->maxlat = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 1);
:  }
: -
: -#define DETACH_NOWARN 0x800
:  
:  static int
:  cardbus_attach_card(device_t cbdev)

This is both right and wrong a the same time.  It is right in that it
forces cardbus_detach_card to not power down the card.  It is wrong in
that it fixes the problem one layer too high.  cardbus_detach_card has
no business turning the power off if there are no children.  Also, the
warning is bogus, imho.  So, here's my patch that corrects these
problems.  It eliminates NOWARN, eliminates the bogus printf and power
cycle, and adds a set of nice parens :-)

Comments?

Warner

P.S. I'm still trying to understand the wi patch and the need for it.
Timeout leaks seem like they would show up all over the place...

--- //depot/user/imp/newcard/dev/cardbus/cardbus.c	2002/10/10 08:32:14
+++ //depot/user/imp/newcard/dev/cardbus/cardbus.c	2002/10/28 23:36:38
@@ -209,8 +209,6 @@
 	cfg->maxlat = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 1);
 }
 
-#define DETACH_NOWARN 0x800
-
 static int
 cardbus_attach_card(device_t cbdev)
 {
@@ -219,7 +217,7 @@
 	static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */
 	int bus, slot, func;
 
-	cardbus_detach_card(cbdev, DETACH_NOWARN); /* detach existing cards */
+	cardbus_detach_card(cbdev, 0); /* detach existing cards */
 
 	POWER_ENABLE_SOCKET(brdev, cbdev);
 	bus = pcib_get_bus(cbdev);
@@ -283,10 +281,6 @@
 	device_get_children(cbdev, &devlist, &numdevs);
 
 	if (numdevs == 0) {
-		if (!(flags & DETACH_NOWARN)) {
-			DEVPRINTF((cbdev, "detach_card: no card to detach!\n"));
-			POWER_DISABLE_SOCKET(device_get_parent(cbdev), cbdev);
-		}
 		free(devlist, M_TEMP);
 		return ENOENT;
 	}
@@ -297,7 +291,7 @@
 
 		if (status == DS_ATTACHED || status == DS_BUSY) {
 			if (device_detach(dinfo->pci.cfg.dev) == 0 ||
-			    flags & DETACH_FORCE) {
+			    (flags & DETACH_FORCE)) {
 				cardbus_release_all_resources(cbdev, dinfo);
 				device_delete_child(cbdev, devlist[tmp]);
 			} else {

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021029.004259.107520615.imp>