Home | History | Annotate | Download | only in sdmmc
History log of /src/sys/dev/sdmmc/sdmmc_io.c
RevisionDateAuthorComments
 1.21  17-Oct-2020  mlelstv Fix error message. No functional change, both commands use the same
bit to select read or write mode.
 1.20  24-May-2020  riastradh Fix races in sdmmc tasks and teach ld@sdmmc to abort xfers on detach.

- Teach sdmmc_add_task to queue it only if not already queued.
- Remove now-redundant logic to avoid repeated queueing elsewhere.
- Teach sdmmc_del_task to wait until task has completed.
- Call sdmmc_del_task in various needful places.
- Replace abuse of pcq by a lock and a tailq.
(pcq is multi-producer, _single_-consumer, but there are potentially
multiple consumers here and really only one producer.)
- Teach ld_sdmmc to abort xfers on detach.
(Mechanism is kinda kludgey but it'll do for now; any effort one is
tempted to spend overhauling this should be spent overhauling sdmmc
to support proper asynchronous commands.)
- Make sure ld_sdmmc_discard either returns failure or eventually calls
ldenddiscard.

XXX Currently ld_sdmmc_detach aborts xfers _before_ ldbegindetach has
has committed to detaching or not. This is currently necessary to
avoid a deadlock because ldbegindetach waits for xfers to drain --
which strikes me as wrong; ldbegindetach shouldn't wait for anything,
and should only make the decision to commit to detaching or not so
the caller can decide whether to abort xfers before we actually wait
for them in ldenddetach.

XXX pullup -- although this changes some kernel symbols (sdmmc_add_task
and sdmmc_del_task), it shouldn't affect any existing modules; the only
module that uses sdmmc is ld_sdmmc.kmod, which is `.if 0' in the build
so there shouldn't be any of them floating around.
 1.19  04-Jan-2020  mlelstv Be less noisy for some commands.
 1.18  28-Oct-2019  mlelstv Simplyfy sdmmc_io_set_blocklen function signature by dropping the
extra softc pointer. Aligns with OpenBSD.
 1.17  28-Oct-2019  mlelstv Add and use sdmmc_pause to avoid long-term busy waits.
Add sdio abort function.
Additional error messages.
Print parameters for SDIO devices.
Minor cosmetics.
 1.16  02-Sep-2019  jmcneill SD_IO_RW_EXTENDED is a data transfer command, so set ADTC flag instead of AC
 1.15  01-Sep-2019  mlelstv From OpenBSD:
- support block length per function
- add functions to read/write regions
Decode (but not use) SDIO tuple in CIS.
Fix locking.
Add more SDIO defines (partially from version 3.0).
 1.14  14-Oct-2018  jdolecek branches: 1.14.4;
remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect
 1.13  23-Oct-2017  jmcneill branches: 1.13.2; 1.13.4;
- Get SDIO reset working (from OpenBSD).
- After switching bus width, notify the host controller of the change.
 1.12  06-Oct-2015  mlelstv support hiding command timeout messages with a new command flag and use this
when probing for cards. Should fix PR 50302.
 1.11  05-Aug-2015  mlelstv lock around interrupt registration.
don't release lock around interrupt handlers, the code cannot
handle an unstable handler list.
 1.10  03-Aug-2015  jmcneill Add support for DDR50 transfer modes.
 1.9  03-Aug-2015  mlelstv use mutex locking for MP safety.
 1.8  28-Jul-2015  mlelstv cosmetic change only.
 1.7  01-Feb-2012  matt branches: 1.7.6; 1.7.24;
Use "opt_sdmmc.h" for SDMMC_DEBUG, etc.
 1.6  13-Feb-2011  nonaka branches: 1.6.4; 1.6.8;
- Don't switch MMC high-speed timing, if host controller isn't supported.
- Only check EXT_CSD STRUCTURE version when CSD version is 3.
- initialize width at sdmmc_function_alloc().
 1.5  07-Oct-2010  kiyohara branches: 1.5.2; 1.5.4;
Fix read CIS. And pass to attach args the standard function interface code.
 1.4  07-Oct-2010  kiyohara Remove unnecessary Tab.
 1.3  07-Oct-2010  kiyohara Support High-Speed mode.
 1.2  05-Dec-2009  pooka branches: 1.2.2; 1.2.4; 1.2.6;
Convert tsleep(&lbolt) to kpause(). Make ltsleep/mtsleep on lbolt
illegal. I examined all places where lbolt is referenced to make
sure there were pointer aliases of it passed to tsleep, but put a
KASSERT in m/ltsleep() just to be sure.
 1.1  21-Apr-2009  nonaka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Added SD/MMC support from OpenBSD.
tested on i386, amd64 at current-users ML by pgoyette@.
tested on zaurus by myself.
 1.1.8.2  07-Oct-2009  sborrill Pull up the following revisions(s) (requested by jmcneill in ticket #1044):
distrib/sets/lists/man/mi: patch
share/man/man4/Makefile: patch
sys/arch/amd64/conf/files.amd64: 1.67
sys/arch/i386/conf/files.i386: 1.349
sys/conf/files 1.945
share/man/man4/sdmmc.4: 1.1-1.4
sys/dev/sdmmc/Makefile.sdmmcdevs 1.1
sys/dev/sdmmc/devlist2h.awk 1.1
sys/dev/sdmmc/files.sdmmc 1.1-1.2
sys/dev/sdmmc/ld_sdmmc.c 1.1-1.3
sys/dev/sdmmc/sbt.c 1.1-1.2
sys/dev/sdmmc/sdhc.c 1.1-1.3
sys/dev/sdmmc/sdhcreg.h 1.1
sys/dev/sdmmc/sdhcvar.h 1.1
sys/dev/sdmmc/sdmmc.c 1.1
sys/dev/sdmmc/sdmmc_cis.c 1.1
sys/dev/sdmmc/sdmmc_io.c 1.1
sys/dev/sdmmc/sdmmc_ioreg.h 1.1
sys/dev/sdmmc/sdmmc_mem.c 1.1-1.2
sys/dev/sdmmc/sdmmcchip.h 1.1
sys/dev/sdmmc/sdmmcdevs 1.1
sys/dev/sdmmc/sdmmcdevs.h 1.1-1.2
sys/dev/sdmmc/sdmmcreg.h 1.1-1.3
sys/dev/sdmmc/sdmmcvar.h 1.1

Add sdmmc framework
 1.1.8.1  21-Apr-2009  sborrill file sdmmc_io.c was added on branch netbsd-5 on 2009-10-07 15:41:13 +0000
 1.1.6.2  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1  21-Apr-2009  jym file sdmmc_io.c was added on branch jym-xensuspend on 2009-05-13 17:21:29 +0000
 1.1.4.4  09-Oct-2010  yamt sync with head
 1.1.4.3  11-Mar-2010  yamt sync with head
 1.1.4.2  04-May-2009  yamt sync with head.
 1.1.4.1  21-Apr-2009  yamt file sdmmc_io.c was added on branch yamt-nfs-mp on 2009-05-04 08:13:18 +0000
 1.1.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1  21-Apr-2009  skrll file sdmmc_io.c was added on branch nick-hppapmap on 2009-04-28 07:36:33 +0000
 1.2.6.2  21-Apr-2010  matt sync to netbsd-5
 1.2.6.1  05-Dec-2009  matt file sdmmc_io.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:52 +0000
 1.2.4.1  05-Mar-2011  rmind sync with head
 1.2.2.1  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.5.4.1  17-Feb-2011  bouyer Sync with HEAD
 1.5.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.6.8.1  18-Feb-2012  mrg merge to -current.
 1.6.4.1  17-Apr-2012  yamt sync with head
 1.7.24.2  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.7.24.1  22-Sep-2015  skrll Sync with HEAD
 1.7.6.1  03-Dec-2017  jdolecek update from HEAD
 1.13.4.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.4.1  10-Jun-2019  christos Sync with HEAD
 1.13.2.1  20-Oct-2018  pgoyette Sync with head
 1.14.4.2  09-Aug-2020  martin Pull up following revision(s) (requested by mrg in ticket #1042):

sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.19
sys/dev/sdmmc/ld_sdmmc.c: revision 1.38
sys/dev/sdmmc/sdmmcvar.h: revision 1.35
sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.5
sys/dev/ic/bwfm.c: revision 1.26
sys/dev/ic/bwfm.c: revision 1.27
sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.20
sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.21
sys/dev/sdmmc/sdmmc_io.c: revision 1.20
sys/dev/sdmmc/sdmmc_mem.c: revision 1.72
sys/dev/sdmmc/sdmmc.c: revision 1.40
sys/dev/sdmmc/sdmmc_ioreg.h: revision 1.6
sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.16

Don't pass empty mbufs to the network stack.

Avoid changing signedness bit with << in sdmmc_ioreg.h
Reported by <prlw1>

If the controller doesn't support switch func (opcode 6) then skip
setting this but continue with other settings. This allows us to use
a card, albeit at a lower speed.

Fix races in sdmmc tasks and teach ld@sdmmc to abort xfers on detach.
- Teach sdmmc_add_task to queue it only if not already queued.
- Remove now-redundant logic to avoid repeated queueing elsewhere.
- Teach sdmmc_del_task to wait until task has completed.
- Call sdmmc_del_task in various needful places.
- Replace abuse of pcq by a lock and a tailq.
(pcq is multi-producer, _single_-consumer, but there are potentially
multiple consumers here and really only one producer.)
- Teach ld_sdmmc to abort xfers on detach.
(Mechanism is kinda kludgey but it'll do for now; any effort one is
tempted to spend overhauling this should be spent overhauling sdmmc
to support proper asynchronous commands.)
- Make sure ld_sdmmc_discard either returns failure or eventually calls
ldenddiscard.

XXX Currently ld_sdmmc_detach aborts xfers _before_ ldbegindetach has
has committed to detaching or not. This is currently necessary to
avoid a deadlock because ldbegindetach waits for xfers to drain --
which strikes me as wrong; ldbegindetach shouldn't wait for anything,
and should only make the decision to commit to detaching or not so
the caller can decide whether to abort xfers before we actually wait
for them in ldenddetach.

XXX pullup -- although this changes some kernel symbols (sdmmc_add_task
and sdmmc_del_task), it shouldn't affect any existing modules; the only
module that uses sdmmc is ld_sdmmc.kmod, which is `.if 0' in the build
so there shouldn't be any of them floating around.

Make this work on big endian machines

move some of the patching of callbacks and other data after
ieee80211_ifattach() but before if_deferred_start_init().
may fix panic i saw in after restarting wpa_supplicant.
from mlelstv.

only ask for SDPCMD_INTSTATUS_HMB_SW_MASK and SDPCMD_INTSTATUS_CHIPACTIVE
interrupts, not all of them. we only ack these ones.
mostly fixes pinebookpro wifi hard hangs. still is problematic and can
trigger interrupt storm that appears as a hard hang without NET_MPSAFE,
and a follow up, less clearly right, change will reduce that to a soft
hang of the interface that can be cleared with 'ifconfig bwfm0 down up',
and even often recovers itself now.

clear all interrupts, not just those we expect from the hostintmask.
this removes the final hard hang i have seen in pinebookpro wifi,
though one may still need to 'ifconfig bwfm0 down up' occasionally,
so we still have bugs to fix here (the hang is usually associated
with 'checksum error' from bwfm/sdio.)

Sort #includes. Nix trailing whitespace.
No functional change intended.
 1.14.4.1  25-Feb-2020  martin Pull up following revision(s) (requested by mrg in ticket #717):

sys/dev/fdt/dwcmmc_fdt.c 1.11
sys/dev/ic/bwfm.c 1.15-1.18
sys/dev/ic/bwfmreg.h 1.4-1.6
sys/dev/ic/bwfmvar.h 1.4,1.5
sys/dev/ic/dwc_mmc.c 1.21,1.22
sys/dev/ic/dwc_mmc_reg.h 1.8,1.9,1.12,1.13
sys/dev/pcmcia/pcmciareg.h 1.11
sys/dev/sdmmc/if_bwfm_sdio.c 1.4,1.6-1.12
sys/dev/sdmmc/if_bwfm_sdio.h 1.1,1.2
sys/dev/sdmmc/sdhc.c 1.105,1.106
sys/dev/sdmmc/sdmmc.c 1.37,1.39
sys/dev/sdmmc/sdmmc_cis.c 1.6,1.8
sys/dev/sdmmc/sdmmc_io.c 1.15-1.19
sys/dev/sdmmc/sdmmc_ioreg.h 1.4,1.5
sys/dev/sdmmc/sdmmc_mem.c 1.69-1.71
sys/dev/sdmmc/sdmmcdevs 1.5-1.8
sys/dev/sdmmc/sdmmcvar.h 1.31,1.33,1.34
sys/net/if_media.h 1.66

Add Broadcom devices
-
Fix typo
-
add PCMCIA_CISTPL_SDIO definition.
-
From OpenBSD:
- move event handling to workqueue
- check for save/restore capability
-
Tag work queue as MPsafe and increase length.
-
Juse use bpf_mtap(), the 802.11 encapsulation is handled by firmware.
-
From OpenBSD:
- support block length per function
- add functions to read/write regions
-
Decode (but not use) SDIO tuple in CIS.
-
Fix locking.
-
Add more SDIO defines (partially from version 3.0).
-
From OpenBSD:
- All the missing pieces (firmware load, chip setup, protocol handling)
TX queue and interrupt handling via sdmmc_task.
-
Fix locking.
-
Fix packet parsing.
-
Add parser for original firmware config files.
-
tagging work queue as MPSAFE was premature. Revert.
-
SD_IO_RW_EXTENDED is a data transfer command, so set ADTC flag instead of AC
Use correct function to verify if a task has been queued. Avoids race
that can corrupt the task queue.
-
More register definitions.
-
Add IFM_IEEE80211_VHT subtype, IFM_IEEE80211_11AC operating mode, and missing descriptions
-
If firmware is connected in HT or VHT mode, report it to SIOCGIFMEDIA
-
white space police.

Skip setting power when the voltage doesn't change.
Also increase some timeouts.
-
Add and use sdmmc_pause to avoid long-term busy waits.
-
Add sdio abort function.
-
Additional error messages.
-
Print parameters for SDIO devices.
-
Minor cosmetics.
-
Simplyfy sdmmc_io_set_blocklen function signature by dropping the
extra softc pointer. Aligns with OpenBSD.
-
Missing commit for sdio abort function.
-
More code from OpenBSD
-
no need to splnet() when enqueing packets
-
explicit structure padding
-
make internal functions static
-
also prepare for GPIO interrupts.
-
Avoid warnings for tautological shifts as sole conditional.
-
Follow the Linux driver an use the FDT "compatible" property to build a
filename for the nvram config file, fall back to the standard filename.
E.g.
[Caching 123 nodes and 1093 properties]
compatible 73696e6f 766f6970 2c627069 2d6d322d "sinovoip,bpi-m2-
0010: 7a65726f 00...... ........ ........ zero"
0015: 616c6c77 696e6e65 722c7375 6e38692d "allwinner,sun8i-
0025: 68322d70 6c757300 ........ ........ h2-plus"
interrupt-parent 00000001 ........ ........ ........ ....
model 42616e61 6e612050 69204250 492d4d32 "Banana Pi BPI-M2
0010: 2d5a6572 6f00.... ........ ........ -Zero"
name 00...... ........ ........ ........ ""
serial-number 30326330 30303432 65636431 36376566 02c00042ecd167ef
0010: 00...... ........ ........ ........ .
-rw-r--r-- 1 root wheel 875 Nov 2 12:06 brcmfmac43430-sdio.AP6212.txt
lrwxr-xr-x 1 root wheel 29 Dec 30 16:19 brcmfmac43430-sdio.sinovoip,bpi-m2-zero.txt -> brcmfmac43430-sdio.AP6212.txt
-rw-r--r-- 1 root wheel 874 Jun 30 2019 brcmfmac43430-sdio.raspberrypi,3-model-b.txt
-rw-r--r-- 1 root wheel 1864 Jun 30 2019 brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
lrwxr-xr-x 1 root wheel 29 Dec 30 11:24 brcmfmac43455-sdio.raspberrypi,4-model-b-plus.txt -> brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
-
Add product ID for Broadcom BCM43455
-
Use correct firmware for BCM43456
-
size check was backwards.
-
Be less noisy for some commands.
-
Fix DWC_MMC_INT_SDIO_INT bit
-
dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers
-
More SDIO stability and performance fixes

RSS XML Feed