NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-hpcmips/41164



The following reply was made to PR port-hpcmips/41164; it has been noted by 
GNATS.

From: "Valeriy E. Ushakov" <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: port-hpcmips/41164
Date: Thu, 14 May 2009 03:31:39 +0400

 On Wed, May 06, 2009 at 12:30:56 -0400, Edward Swiftwood wrote:
 
 > pcic0: controller 0 (Ricoh RF5C396) has sockets A and B
 
 Looks like an old race condition in sys/dev/ic/i82365.c that is
 exposed only now that kernel is more threaded internally -
 config_pending_decr() is called too early, before the card in the
 socket is actually attached, so the kernel proceeds and tries to mount
 root while event thread is still attaching the card.
 
 
 In i82365_isa.c at the very end of pcic_isa_attach() we do
 
    pcic_attach_sockets(sc);
    config_interrupts(self, pcic_isa_config_interrupts);
 
 pcic_attach_sockets() calls pcic_attach_socket() for each socket, and
 the latter calls config_pending_incr() and creates a kthread for the
 socket that executes pcic_event_thread().
 
 pcic_isa_config_interrupts() (in i82365_isasubr.c) is called when
 interrupts are enabled and eventually calls pcic_attach_sockets_finish(),
 which calls pcic_attach_socket_finish() for each socket, ending with:
 
         /* if there's a card there, then attach it. */
         reg = pcic_read(h, PCIC_IF_STATUS);
         if ((reg & PCIC_IF_STATUS_CARDDETECT_MASK) ==
             PCIC_IF_STATUS_CARDDETECT_PRESENT) {
                 pcic_queue_event(h, PCIC_EVENT_INSERTION);
                 h->laststate = PCIC_LASTSTATE_PRESENT;
         }
         [...]
 
 
 Meanwhile... pcic_event_thread() calls config_pending_decr() when it
 sees an empty queue for the first time.  The intention here, as far as
 I can tell, is that it should happen when either the above
 PCIC_EVENT_INSERTION has been processed or the card is not present,
 but if pcic_event_thread() is scheduled before pcic_attach_socket_finish()
 had a chance to run, event thread calls config_pending_decr()
 immediately as if no card is present, and thus let the kernel to mount
 root.  Later on pcic_attach_socket_finish() runs and posts that
 insertion event into the queue, and the card is attached by the event
 thread, but it's already too late.
 
 -uwe
 


Home | Main Index | Thread Index | Old Index