Bug 6249 - in PCCARD, alocate driver failed, not release IRQ
Summary: in PCCARD, alocate driver failed, not release IRQ
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 2.2.6-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: nate
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1998-04-08 06:30 UTC by mac
Modified: 1998-04-15 00:28 UTC (History)
0 users

See Also:


Attachments
file.diff (120 bytes, patch)
1998-04-08 06:30 UTC, mac
no flags Details | Diff
file.diff (221 bytes, patch)
1998-04-08 06:30 UTC, mac
no flags Details | Diff
file.diff (169 bytes, patch)
1998-04-08 06:30 UTC, mac
no flags Details | Diff
file.diff (540 bytes, patch)
1998-04-08 06:30 UTC, mac
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mac 1998-04-08 06:30:00 UTC
(Sorry, previous send-pr attached patch has problem. Please replace this send-pr)

When PC card insert, not release IRQ if alocate_driver() fail.
In 2.2.5-RELEASE, if remove_driver() fail, call remove_driver() and
it is unregister_intr() whether devi->running is 0 or not.
But 2.2.6-RELEASE, unregister_intr() is not called devi->running is 0.

Forwhy, In 2.2.5-RELEASE, diable_slot() and remove_driver() function's 
behavior of unregister IRQ are not same, but, In 2.2.6-RELASE, these are same.

Fix: can use this patch
----------------------------------------------------------------
static int            allocate_driver(struct slot *, struct dev_desc *);
  static void           inserted(void *);
! static void           unregister_device_interrupt(struct pccard_devinfo *);
  static void           disable_slot(struct slot *);
  static int            invalid_io_memory(unsigned long, int);
  static struct pccard_device *find_driver(char *);
--- 80,86 ----

  static int            allocate_driver(struct slot *, struct dev_desc *);
  static void           inserted(void *);
! static void           unregister_device_interrupt(struct pccard_devinfo *, int
 force);
  static void           disable_slot(struct slot *);
  static int            invalid_io_memory(unsigned long, int);
  static struct pccard_device *find_driver(char *);
***************
!       if (devi->running) {
                s = splhigh();
!               devi->drv->disable(devi);
!               devi->running = 0;
                if (devi->isahd.id_irq && --slt->irqref <= 0) {
                        printf("Return IRQ=%d\n",slt->irq);
                        slt->ctrl->mapirq(slt, 0);
--- 296,312 ----
   *    the device driver which is handling it, so we can remove it.
   */
  static void
! unregister_device_interrupt(struct pccard_devinfo *devi,int force)
  {
        struct slot *slt = devi->slt;
        int s;

!       if ((devi->running) || (force == 1)) {
                s = splhigh();
!               if (devi->running) {
!                       devi->drv->disable(devi);
!                       devi->running = 0;
!               }
                if (devi->isahd.id_irq && --slt->irqref <= 0) {
                        printf("Return IRQ=%d\n",slt->irq);
                        slt->ctrl->mapirq(slt, 0);
***************
/* Power off the slot 1/2 second after removal of the card */
        timeout(power_off_slot, (caddr_t)slt, hz / 2);
--- 344,350 ----
         * all bets are off...
         */
        for (devi = slt->devices; devi; devi = devi->next)
!               unregister_device_interrupt(devi, 1);

        /* Power off the slot 1/2 second after removal of the card */
        timeout(power_off_slot, (caddr_t)slt, hz / 2);
***************
How-To-Repeat: Inser disable device PC card, remove it.
display console messages,
        /kernel: Slot 1, unfielded interrupt (10)
Comment 1 nate freebsd_committer freebsd_triage 1998-04-08 15:29:11 UTC
State Changed
From-To: open->analyzed

This is indeed a problem, but the way we do probes needs to be redone, so let 
me see if I can fix the original problem.  If not, I'll apply the patch. 


Comment 2 nate freebsd_committer freebsd_triage 1998-04-08 15:29:11 UTC
Responsible Changed
From-To: freebsd-bugs->nate

My code, my bug. 

Comment 3 nate 1998-04-08 16:06:33 UTC
> >Number:         6249
> >Category:       kern
> >Synopsis:       in PCCARD, alocate driver failed, not release IRQ
> >Confidential:   no
> >Severity:       critical
> >Priority:       high
> >Responsible:    freebsd-bugs
> >State:          open
> >Quarter:
> >Keywords:
> >Date-Required:
> >Class:          sw-bug
> >Submitter-Id:   current-users
> >Arrival-Date:   Tue Apr  7 22:30:00 PDT 1998
> >Last-Modified:
> >Originator:     Masahide NODA
> >Organization:
> Fujitsu Lab.
> >Release:        2.2.6-RELEASE
> >Environment:
> FreeBSD gnome.pssys.flab.fujitsu.co.jp 2.2.6-RELEASE FreeBSD 2.2.6-RELEASE #7: W
> ed Apr  8 13:17:25 JST 1998     mac@gnome.pssys.flab.fujitsu.co.jp:/usr/home/mac
> /sys/compile/gnome  i386
> >Description:
> When PC card insert, not release IRQ if alocate_driver() fail.

Ok, can you try out the fix I just committed to both -current and
-stable.  This isn't the 'correct' fix for the probes, but should fix
the bug that you reported.  'running' is a flag that says that the
device is completely 'running', but is also mis-used as a flag to say
that interrupts have been allocated (if necessary), so I simply stated
that the driver was running after interrupts were allocated, and it will
do the right thing to disable running if the probe fails.

Thanks!


Nate
Comment 4 jmb freebsd_committer freebsd_triage 1998-04-15 00:26:48 UTC
State Changed
From-To: analyzed->closed

fixed by Nate Williams in revision 1.57 to /sys/pccard.c