Re: docs/41104: Stale comment removal from pccardd(8)

John Baldwin <[email protected]>
Newsgroups gmane.os.freebsd.devel.mobile
Message-ID <[email protected]>
[ cc's adjusted to better conform to reality ]

On 29-Jul-2002 M. Warner Losh wrote:
> In message: <[email protected]>
>             John Baldwin <[email protected]> writes:
>: 
>: On 29-Jul-2002 M. Warner Losh wrote:
>: > In message: <[email protected]>
>: >             John Baldwin <[email protected]> writes:
>: >: Unfortunately using KLD's does not fix this problem and it is still an
>: >: issue.  I can't eject my cardbus rl0 card w/o my laptop locking up for
>: >: exactly this reason.  This patch should not be committed unless Warner
>: >: (imp@, cc'd) approves.
>: > 
>: > Yes, the comments in the pccardd man page are correct (eg, that's why
>: > things are they way they are).  However, once the underlying problems
>: > in the kernel were fixed, pccardd wasn't updated to be less smart
>: > about the resources a card uses.  Likely it should read:
>: > 
>: >       The primary reasons are historical.
>: 
>: Ah, ok.
>: 
>: > What happens in NEWCARD with a rl card aren't relevant to this
>: > discussion :-) The reason that you can't eject the rl0 card has to do
>: > with something else (likely an ISR that doesn't properly terminate
>: > when the card is gone or a detach routine that's minorly bogus).
>: 
>: Well, it's the same behavior. :-P  The rl(4) driver doesn't allow for
>: devices to go away and gets stuck in a loop spinning forever waiting
>: for a card reset to succeed and the reset keeps failing for obvious
>: reasons.  Completely hangs the machine.  *sigh*
> 
> Yes.  I've seen it succeed for me.  any chance you can get me a
> traceback of where it is happening?

This patch fixes it:

Index: if_rl.c
===================================================================
RCS file: /usr/cvs/src/sys/pci/if_rl.c,v
retrieving revision 1.71
diff -u -r1.71 if_rl.c
--- if_rl.c     30 Jun 2002 22:16:22 -0000      1.71
+++ if_rl.c     29 Jul 2002 17:09:35 -0000
@@ -1380,6 +1380,8 @@
                u_int16_t       status;
 
                status = CSR_READ_2(sc, RL_ISR);
+               if (status == 0xffff)
+                       goto done;
                if (status)
                        CSR_WRITE_2(sc, RL_ISR, status);
 
@@ -1426,6 +1428,9 @@
        for (;;) {
 
                status = CSR_READ_2(sc, RL_ISR);
+               /* If a cardbus card goes away, the read returns 0xffff. */
+               if (status == 0xffff)
+                       break;
                if (status)
                        CSR_WRITE_2(sc, RL_ISR, status);

I think this is hackish, and that 0xffff is too cardbus specific.
We probably should be asking our parent if we are still around
(device_present()?) before doing the read instead.

-- 

John Baldwin <[email protected]>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-mobile" in the body of the message
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.