NetBSD-Bugs archive

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

Re: kern/56438: panic when trying to use gpioiic in -current 9.99.90



The following reply was made to PR kern/56438; it has been noted by GNATS.

From: Brad Spencer <brad%anduin.eldar.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: kern/56438: panic when trying to use gpioiic in -current 9.99.90
Date: Mon, 04 Oct 2021 10:04:23 -0400

 mlelstv%serpens.de@localhost (Michael van Elst) writes:
 
 > The following reply was made to PR kern/56438; it has been noted by GNATS.
 >
 > From: mlelstv%serpens.de@localhost (Michael van Elst)
 > To: gnats-bugs%netbsd.org@localhost
 > Cc: 
 > Subject: Re: kern/56438: panic when trying to use gpioiic in -current 9.99.90
 > Date: Mon, 4 Oct 2021 05:42:14 -0000 (UTC)
 >
 >  brad%anduin.eldar.org@localhost writes:
 >  
 >  >[  13.2358565] panic: kernel diagnostic assertion "KERNEL_LOCKED_P()" failed: file "../../../../kern/subr_autoconf.c", line 1053
 >  >[  13.2487462] cpu0: Begin traceback...
 >  >[  13.2487462] 0xd1cf1b5c: netbsd:db_panic+0x14
 >  >[  13.2562360] 0xd1cf1b74: netbsd:vpanic+0x148
 >  >[  13.2562360] 0xd1cf1b8c: netbsd:__aeabi_uldivmod
 >  >[  13.2562360] 0xd1cf1bc4: netbsd:config_match+0x88
 >  >[  13.2680444] 0xd1cf1be4: netbsd:mapply+0x4c
 >  >[  13.2680444] 0xd1cf1c34: netbsd:config_search_internal+0x1a8
 >  >[  13.2771142] 0xd1cf1c5c: netbsd:config_search+0x90
 >  >[  13.2771142] 0xd1cf1cf4: netbsd:gpioioctl+0x3b0
 >  
 >  The attachment framework nowadays enforces that it is called with
 >  the kernel lock held. Since gpio(4) is tagged as 'mpsafe' it has
 >  to care itself about taking the kernel lock.
 >  
 
 
 So, something like the following..  I made this change and tested it and
 the panic appears to be gone and devices attach as expected again, but
 as I mentioned I am not that familar with the autoconfig framework.  I
 can commit this if there isn't any objections.
 
 --- gpio.c.ORIG 2021-09-26 13:41:58.259633657 -0400
 +++ gpio.c      2021-10-04 08:02:22.584845545 -0400
 @@ -849,6 +849,7 @@
                 locs[GPIOCF_MASK] = ga.ga_mask;
                 locs[GPIOCF_FLAG] = ga.ga_flags;
  
 +               KERNEL_LOCK(1, NULL);
                 cf = config_search(sc->sc_dev, &ga,
                     CFARGS(.locators = locs));
                 if (cf != NULL) {
 @@ -869,6 +870,7 @@
  #endif
                 } else
                         error = EINVAL;
 +               KERNEL_UNLOCK_ONE(NULL);
                 mutex_enter(&sc->sc_mtx);
                 sc->sc_attach_busy = 0;
                 cv_signal(&sc->sc_attach);
 
 
 
 
 
 -- 
 Brad Spencer - brad%anduin.eldar.org@localhost - KC8VKS - http://anduin.eldar.org
 


Home | Main Index | Thread Index | Old Index