summaryrefslogtreecommitdiffstats
path: root/sys/pccard/pccard.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-12-01 07:38:54 +0000
committerimp <imp@FreeBSD.org>1999-12-01 07:38:54 +0000
commit737361b49b1d4f61109a883539d69e85ed2ccbc3 (patch)
tree9e08c340cddbf5bd0598f71b4907763bb7026d68 /sys/pccard/pccard.c
parentb8799773608c6c088346b7cb09851b9b556a2cb4 (diff)
downloadFreeBSD-src-737361b49b1d4f61109a883539d69e85ed2ccbc3.zip
FreeBSD-src-737361b49b1d4f61109a883539d69e85ed2ccbc3.tar.gz
Fix the hang on card eject problem and maybe the hang on suspend
problem. o Create new timeout routine so we don't detach the card inside a ISR but instead drop back to spl0 via a timeout of 0. o Actually delete the child of the pccard device rather than just faking it badly. o Fix sio, ed and ep to have pccard detach routines that are int rather than void. o Fix ep and ed pccard detach routines to use if_detach rather than just if_down. if_detach destroys the device, while if_down just marks it down. In this incarnation of the pccard things, we map the disable the slot action to detach the driver, which removes the driver from the device tree. When that is done, a panic would soon follow as the ifconfig tried to down the device. Didn't fix: o Should cache the pccard dev child's pointer in struct slot o remove now unused parts of struct slot o Any driver using softc after detach has been called. sio's softc used to be statically allocated, so you could check sc->gone, but that is now gone. o Didn't remove gone from softc of drivers that use the old pccard method. Didn't test: o ed driver changes o sio driver changes on pccards o suspend (no laptop or apm support on my desktop)
Diffstat (limited to 'sys/pccard/pccard.c')
-rw-r--r--sys/pccard/pccard.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c
index c9f6940..ae09a7f 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -93,6 +93,8 @@ SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
static int allocate_driver(struct slot *, struct dev_desc *);
static void inserted(void *);
static void disable_slot(struct slot *);
+static void disable_slot_spl0(struct slot *);
+static void disable_slot_to(void *);
static int invalid_io_memory(unsigned long, int);
static void power_off_slot(void *);
@@ -176,34 +178,52 @@ power_off_slot(void *arg)
static void
disable_slot(struct slot *slt)
{
+ /* XXX Need to store pccarddev in slt. */
device_t pccarddev;
- struct pccard_devinfo *devi;
+ device_t *kids;
+ int nkids;
int i;
+ int ret;
/*
- * Unload all the drivers on this slot. Note we can't
- * remove the device structures themselves, because this
- * may be called from the event routine, which is called
- * from the slot controller's ISR, and removing the structures
- * shouldn't happen during the middle of some driver activity.
- *
* Note that a race condition is possible here; if a
* driver is accessing the device and it is removed, then
* all bets are off...
*/
- pccarddev = devclass_get_device(pccard_devclass, 0);
- for (devi = slt->devices; devi; devi = devi->next) {
- if (devi->isahd.id_device != 0) {
- device_delete_child(pccarddev, devi->isahd.id_device);
- devi->isahd.id_device = 0;
- }
- }
+ pccarddev = devclass_get_device(pccard_devclass, slt->slotnum);
+ device_get_children(pccarddev, &kids, &nkids);
+ for (i = 0; i < nkids; i++) {
+ if ((ret = device_delete_child(pccarddev, kids[i])) != 0)
+ printf("pccard: delete failed: %d\n", ret);
+ }
/* Power off the slot 1/2 second after removal of the card */
slt->poff_ch = timeout(power_off_slot, (caddr_t)slt, hz / 2);
slt->pwr_off_pending = 1;
}
+static void
+disable_slot_to(void *argp)
+{
+ struct slot *slt = (struct slot *) argp;
+
+ disable_slot(slt);
+ slt->state = empty;
+ printf("pccard: card removed, slot %d\n", slt->slotnum);
+ pccard_remove_beep();
+ selwakeup(&slt->selp);
+}
+
+/*
+ * Disables the slot later when we drop to spl0 via a timeout.
+ */
+static void
+disable_slot_spl0(struct slot *slt)
+{
+ slt->disable_ch = timeout(disable_slot_to, (caddr_t) slt, 0);
+}
+
+
/*
* APM hooks for suspending and resuming.
*/
@@ -226,6 +246,7 @@ slot_suspend(void *arg)
* Disable any pending timeouts for this slot since we're
* powering it down/disabling now.
*/
+ untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
slt->ctrl->disable(slt);
return (0);
@@ -296,6 +317,7 @@ pccard_alloc_slot(struct slot_ctrl *ctrl)
}
callout_handle_init(&slt->insert_ch);
callout_handle_init(&slt->poff_ch);
+ callout_handle_init(&slt->disable_ch);
#if NAPM > 0
{
struct apmhook *ap;
@@ -385,6 +407,7 @@ inserted(void *arg)
* power it off right now. Then, re-enable the power using
* the (possibly new) power settings.
*/
+ untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
power_off_slot(slt);
slt->ctrl->power(slt);
@@ -415,13 +438,7 @@ pccard_event(struct slot *slt, enum card_event event)
* data structures are not unlinked.
*/
if (slt->state == filled) {
- int s = splhigh();
- disable_slot(slt);
- slt->state = empty;
- splx(s);
- printf("pccard: card removed, slot %d\n", slt->slotnum);
- pccard_remove_beep();
- selwakeup(&slt->selp);
+ disable_slot_spl0(slt);
}
break;
case card_inserted:
OpenPOWER on IntegriCloud