NetBSD-Bugs archive

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

kern/55512: sdmmc locking broken



>Number:         55512
>Category:       kern
>Synopsis:       sdmmc locking broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 22 10:55:00 +0000 2020
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.69
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD space-truckin.duskware.de 9.99.69 NetBSD 9.99.69 (GENERIC) #93: Wed Jul 22 12:40:37 CEST 2020 martin%seven-days-to-the-wolves.aprisoft.de@localhost:/work/src/sys/arch/evbarm/compile/GENERIC evbarm
Architecture: earmv7hfeb
Machine: evbarm
>Description:

The locking in the sdmmc driver is broken (quite obviously) broken and it
actually works sometimes only by chance.

Not sure this is caused by it, but I do get:

[   5.2286102] sunximmc1: WARNING: driver submitted a command while the controller was busy
[   5.2386127] sdmmc1: extended I/O error 16, r=40992 p=0xc3ef6e94 l=4 read
[   5.3486139] bwfm0: CHIPACTIVE
[   5.3486139] bwfm0: wl0: May 16 2018 23:42:49 version 5.90.244 FWID 01-0

For broken locking just check the source:

sdmmcvar.h:#define      SDMMC_LOCK(sc)
sdmmcvar.h:#define      SDMMC_UNLOCK(sc)

and notice that *some* calls of SDMMC_LOCK/SDMMC_UNLOCK have additional
locks around them:

sdmmc_mem.c:    SDMMC_LOCK(sc);
sdmmc_mem.c-    mutex_enter(&sc->sc_mtx);

... but some do not.

Blindly removing all SDMMC_LOCK/SDMMC_UNLOCK and replacing them with sc_mtx
locks unfortunately does not work (causes locking against myself panics
during interrupt establish) - but probably is a first step forward and then
quite easy to cleanup.

>How-To-Repeat:
code inspection

>Fix:
n/a



Home | Main Index | Thread Index | Old Index