aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sdhci
Commit message (Collapse)AuthorAgeFilesLines
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace MAXPHYS by runtime variable maxphys. It is initialized from MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys. Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer cache buffers exactly to atop(maxbcachebuf) (currently it is sized to atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1. The +1 for pbufs allow several pbuf consumers, among them vmapbuf(), to use unaligned buffers still sized to maxphys, esp. when such buffers come from userspace (*). Overall, we save significant amount of otherwise wasted memory in b_pages[] for buffer cache buffers, while bumping MAXPHYS to desired high value. Eliminate all direct uses of the MAXPHYS constant in kernel and driver sources, except a place which initialize maxphys. Some random (and arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted straight. Some drivers, which use MAXPHYS to size embeded structures, get private MAXPHYS-like constant; their convertion is out of scope for this work. Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs, dev/siis, where either submitted by, or based on changes by mav. Suggested by: mav (*) Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions) Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27225 Notes: svn path=/head/; revision=368124
* sdhci: mmccam: Update vccq in the driver iosEmmanuel Vadot2020-11-261-0/+5
| | | | | | | Otherwise we always report that the card is running at 1.2V. Notes: svn path=/head/; revision=368061
* sdhci: Only print mmccam debug code if hw.sdhci.debug is > 1Emmanuel Vadot2020-11-261-8/+16
| | | | Notes: svn path=/head/; revision=368060
* sdhci: clean up empty lines in .c and .h filesMateusz Guzik2020-09-012-7/+2
| | | | Notes: svn path=/head/; revision=365158
* Introduce the SDHCI driver for NXP QorIQ Layerscape SoCsMarcin Wojtas2020-09-011-0/+680
| | | | | | | | | | | | | | | | | | | | | Implement support for an eSDHC controller found in NXP QorIQ Layerscape SoCs. This driver has been tested with NXP LS1046A and LX2160A (Honeycomb board), which is incompatible with the existing sdhci_fsl driver (aiming at older chips from this family). As such, it is not intended as replacement for the old driver, but rather serves as an improved alternative for SoCs that support it. It comes with support for both PIO and Single DMA modes and samples the clock from the extres clk API. Submitted by: Artur Rojek <ar@semihalf.com> Reviewed by: manu, mmel, kibab Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D26153 Notes: svn path=/head/; revision=365054
* sdhci(4): Recognize the Texas Instruments PCIxx12 card reader.Mark Johnston2020-08-251-0/+3
| | | | | | | | | PR: 248650 Submitted by: Lars Herschke <lhersch@dssgmbh.de> MFC after: 1 week Notes: svn path=/head/; revision=364779
* mmccam: Add a generic mmccam_start_discovery functionEmmanuel Vadot2020-07-221-44/+2
| | | | | | | | | | | This is a generic function start a scan request for the given cam_sim. Other driver can now just use this function to request a new rescan. Submitted by: kibab Notes: svn path=/head/; revision=363425
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* No need to have an extra layer of indirection here. Call the sdhci_cam_requiestWarner Losh2020-01-271-16/+1
| | | | | | | routine directly when handling a MMIO request. Notes: svn path=/head/; revision=357182
* Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. PassWarner Losh2020-01-271-26/+2
| | | | | | | in the parameters needed for the different sims, but it's almost all identical. Notes: svn path=/head/; revision=357181
* Regularize my copyright noticeWarner Losh2019-12-041-2/+1
| | | | | | | | | | | | o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
* Relax the sdhci(4) check that filters out the 1.8v voltage option unlessIan Lepore2019-10-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | the slot is flagged as 'embedded'. The features related to embedded and shared slots were added in v3.0 of the sdhci spec. Hardware prior to v3 sometimes supported 1.8v on non- removable devices in embedded systems, but had no way to indicate that via the standard sdhci registers (instead they use out of band metadata such as FDT data). This change adds the controller specification version to the check for whether to filter out the 1.8v selection. On older hardware, the 1.8v option is allowed to remain. On 3.0 or later it still requires the embedded-slot flag to remain. This is part of the fix for PR 241301 (eMMC not detected on Beaglebone). Changes to the sdhci_ti driver are also needed for a full fix. PR: 241301 Notes: svn path=/head/; revision=353651
* Allow the sdhci timeout sysctl var to be set as a tunable. Also, add aIan Lepore2019-08-101-2/+2
| | | | | | | missing newline in a warning printf. Notes: svn path=/head/; revision=350847
* Add emmc support for Rockchip RK3399 SoC.Ganbold Tsagaankhuu2019-07-201-0/+245
| | | | | | | | | | Tested on NanoPC-T4 board. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D20156 Notes: svn path=/head/; revision=350162
* Add support for the GPIO SD Card VCC regulator/switch and the GPIO SD CardLuiz Otavio O Souza2019-06-101-0/+83
| | | | | | | | | | | | | | detection pins to the Marvell Xenon SDHCI controller. These features are enable by 'vqmmc-supply' and 'cd-gpios' properties in the DTS. This fixes the SD Card detection on espressobin. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=348882
* Improve sdhci slot_printf() debug printing.Bjoern A. Zeeb2019-06-081-4/+9
| | | | | | | | | | | | | | | | | | | Currently slot_printf() uses two printf() calls to print the device-slot name, and actual message. When other printf()s are ongoing in parallel this can lead to interleaved message on the console, which is especially unhelpful for debugging or error messages. Take a hit on the stack and vsnprintf() the message to the buffer. This way it can be printed along with the device-slot name in one go avoiding console gibberish. Reviewed by: marius MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19747 Notes: svn path=/head/; revision=348801
* Introduce sim_dev and cam_sim_alloc_dev().Bjoern A. Zeeb2019-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add cam_sim_alloc_dev() as a wrapper to cam_sim_alloc() which takes a device_t instead of the unit_number (which we can derive from the dev again). Add device_t sim_dev to struct cam_sim. It will be used to pass through the bus for cases when both sides of CAM speak newbus already and we want to link them (yet make the calls through CAM for now). SDIO will be the first consumer of this. For that make use of cam_sim_alloc_dev() in sdhci under MMCCAM. This will also allow people to start iterating more on the idea to newbus-ify CAM without changing 50+ device drivers from the start. Also to be clear there are callers to cam_sim_alloc() which do not have a device_t (e.g., XPT) or provide their own unit number so we cannot simply switch the KPI entirely. Submitted by: kibab (original idea, see https://reviews.freebsd.org/D12467) Reviewed by: imp, chuck MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19746 Notes: svn path=/head/; revision=348800
* Improve error/debug messages in sdhci.cBjoern A. Zeeb2019-06-011-3/+5
| | | | | | | | | | | | | | When starting a command also print the opcode and flags. More consitently print flags as hex. Use slot_printf rather than printf in one case. MFC after: 6 weeks Reviewed by: marius, kibab, imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19748 Notes: svn path=/head/; revision=348493
* Implement CMD53 block mode support for SDHCI and AllWinner-based boardsIlya Bakulin2019-04-101-12/+39
| | | | | | | | | | | | If a custom block size requested, use it, otherwise revert to the previous logic of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise. Reviewed by: bz Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D19783 Notes: svn path=/head/; revision=346098
* Use information about max data size that the controller is able to operateIlya Bakulin2019-04-011-0/+14
| | | | | | | | | | | | | | Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the controller driver to provide maximum data size to MMCCAM, and use it there. The old stack already does this. Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15892 Notes: svn path=/head/; revision=345775
* Whitespace cleanup in sdhci.cBjoern A. Zeeb2019-03-211-47/+43
| | | | | | | | | | | No functional changes. Replace whitespace by tabs, indent with 4 spaces, coalesce multi-line shorter than 80 characters, MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345372
* Align struct sdhci_slot MMCCAM members.Bjoern A. Zeeb2019-03-211-4/+4
| | | | | | | | | | Whitespace only, no functional change. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345370
* o Don't allocate resources for SDMA in sdhci(4) if the controller or theMarius Strobl2018-12-307-94/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | front-end doesn't support SDMA or the latter implements a platform- specific transfer method instead. While at it, factor out allocation and freeing of SDMA resources to sdhci_dma_{alloc,free}() in order to keep the code more readable when adding support for ADMA variants. o Base the size of the SDMA bounce buffer on MAXPHYS up to the maximum of 512 KiB instead of using a fixed 4-KiB-buffer. With the default MAXPHYS of 128 KiB and depending on the controller and medium, this reduces the number of SDHCI interrupts by a factor of ~16 to ~32 on sequential reads while an increase of throughput of up to ~84 % was seen. Front-ends for broken controllers that only support an SDMA buffer boundary of a specific size may set SDHCI_QUIRK_BROKEN_SDMA_BOUNDARY and supply a size via struct sdhci_slot. According to Linux, only Qualcomm MSM-type SDHCI controllers are affected by this, though. Requested by: Shreyank Amartya (unconditional bump to 512 KiB) o Introduce a SDHCI_DEPEND macro for specifying the dependency of the front-end modules on the sdhci(4) one and bump the module version of sdhci(4) to 2 via an also newly introduced SDHCI_VERSION in order to ensure that all components are in sync WRT struct sdhci_slot. o In sdhci(4): - Make pointers const were applicable, - replace a few device_printf(9) calls with slot_printf() for consistency, and - sync some local functions with their prototypes WRT static. Notes: svn path=/head/; revision=342634
* sdhci_xenon: Add Marvell 8k compatible stringEmmanuel Vadot2018-12-121-0/+5
| | | | | | | Sponsored by: Rubicon Communications, LLC ("Netgate") Notes: svn path=/head/; revision=342017
* For consistency within the front-end, prefer SDHCI_{READ,WRITE}_{2,4}()Marius Strobl2018-11-191-7/+7
| | | | | | | | to sdhci_acpi_{read,write}_{2,4}() in the sdhci_acpi_set_uhs_timing() added in r340543. Notes: svn path=/head/; revision=340654
* Add a quirk handling for AMDI0040 controllers allowing them to do HS400.Marius Strobl2018-11-183-13/+68
| | | | | | | Submitted by: Shreyank Amartya (original version) Notes: svn path=/head/; revision=340543
* Distinguish _CID match and _HID match and make lower priority probeTakanori Watanabe2018-10-261-3/+4
| | | | | | | | | | when _CID match. Reviewed by: jhb, imp Differential Revision:https://reviews.freebsd.org/D16468 Notes: svn path=/head/; revision=339754
* [sdhci] Add ACPI identifier for AMD eMMC 5.0 controllerOleksandr Tymoshenko2018-09-291-0/+3
| | | | | | | | | Submitted by: Rajesh Kumar <rajfbsd@gmail.com> Approved by: re (rgrimes) Differential Revision: https://reviews.freebsd.org/D17189 Notes: svn path=/head/; revision=339007
* - Explicitly compare a pointer to NULL. The __builtin_expect() of clangMarius Strobl2018-09-061-2/+1
| | | | | | | | | | 3.4.1 otherwise isn't able to cope with the expression. - Fix a nearby whitespace bug. Approved by: re (gjb, kib) Notes: svn path=/head/; revision=338512
* arm64: GENERIC-MMCCAM: Fix build and module dependEmmanuel Vadot2018-08-292-1/+6
| | | | | | | | | | | | | | Fix the build of the GENERIC-MMCCAM kernel config after the sdhci_xenon driver was commited. While here correct sdhci_fdt and tegra_sdhci, even with MMCCAM they do need to depend on sdhci(4) Reported by: Reshetnikov Dmitriy <genserg@hotmail.com> Approved by: re (kib) Sponsored by: Rubicon Communications, LLC ("NetGate") Notes: svn path=/head/; revision=338371
* - According to section 2.2.5 of the SDHCI specification version 4.20,Marius Strobl2018-08-231-20/+46
| | | | | | | | | | | | | | | | | | | SDHCI_TRNS_ACMD12 is to be set only for multiple-block read/write commands without data length information, so don't unconditionally set this bit. The result matches what e. g. Linux does. - Section 2.2.19 of the SDHCI specification version 4.20 states that SDHCI_ACMD12_ERR should be only valid if SDHCI_INT_ACMD12ERR is set and hardware may clear SDHCI_ACMD12_ERR when SDHCI_INT_ACMD12ERR is cleared (differing silicon behavior is specifically allowed, though). Thus, read SDHCI_ACMD12_ERR before clearing SDHCI_INT_ACMD12ERR. While at it, use the 16-bit accessor rather than the 32-bit one for reading the 16-bit SDHCI_ACMD12_ERR. - SDHCI_INT_TUNEERR isn't one of the ROC bits in SDHCI_INT_STATUS so clear it explicitly. - Add missing prototypes and sort them. Notes: svn path=/head/; revision=338261
* Add support to the Marvell Xenon SDHCI controller.Luiz Otavio O Souza2018-08-142-0/+646
| | | | | | | | | | | Tested on Espresso.bin (37x0) and Macchiato.bin (8k) with SD cards and eMMCs. Obtained from: pfSense Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=337772
* The broken DDR52 support of Intel Bay Trail eMMC controllers rumoredMarius Strobl2018-05-142-5/+9
| | | | | | | | | | | in the commit log of r321385 has been confirmed via the public VLI54 erratum. Thus, stop advertising DDR52 for these controllers. Note that this change should hardly make a difference in practice as eMMC chips from the same era as these SoCs most likely support HS200 at least, probably even up to HS400ES. Notes: svn path=/head/; revision=333613
* Fix build when option MMCCAM is defined.Emmanuel Vadot2018-03-081-0/+4
| | | | Notes: svn path=/head/; revision=330673
* Don't call sdhci_cleanup_slot() if sdhci_init_slot() never got called.Ian Lepore2018-02-171-2/+7
| | | | | | | | Also, do callout_init() very early in attach, so that callout_drain() can be called in detach without worrying about whether it ever got init'd. Notes: svn path=/head/; revision=329480
* Add support for SDHCI controller found in Qualcomm Snapdragon 410e.Ruslan Bukin2018-01-251-0/+6
| | | | | | | | | Tested on DragonBoard 410c. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=328403
* Fix a bug introduced in r327339; at the point in time re-tuning isMarius Strobl2018-01-131-2/+10
| | | | | | | | | | | | | | | | | executed, the interrupt aggregation code might have disabled the SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE bits in slot->intmask and the SDHCI_SIGNAL_ENABLE register respectively. So when restoring the interrupt masks based on the previous contents of slot->intmask in sdhci_exec_tuning(), ensure that the SDHCI_INT_ENABLE register doesn't lose these two bits. While at it and in the spirit of r327339, let sdhci_tuning_intmask() set the tuning error and re-tuning interrupt bits based on the SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag being set, i. e. only when (re-)tuning is actually used. Currently, this changes makes no net difference, though. Notes: svn path=/head/; revision=327924
* - There is no need to keep the tuning error and re-tuning interruptsMarius Strobl2017-12-291-1/+5
| | | | | | | | | | | enabled (though, no interrupt generation enabled for them) all the time as soon as (re-)tuning is supported; only enable them and let them generate interrupts when actually using (re-)tuning. - Also disable all interrupts except SDHCI_INT_DATA_AVAIL ones while executing tuning and not just their signaling. Notes: svn path=/head/; revision=327339
* Probe Intel Denverton eMMC 5.0 controllers.Marius Strobl2017-12-281-0/+6
| | | | Notes: svn path=/head/; revision=327315
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-274-0/+8
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* Actually release resources in detach() rather than just returning EBUSY.Ian Lepore2017-10-271-10/+21
| | | | | | | This will enable use of 'devctl disable', allow creation of a module, etc. Notes: svn path=/head/; revision=325045
* Rename sdhci_cam_start_slot() into sdhci_start_slot()Ilya Bakulin2017-09-244-14/+3
| | | | | | | | | | | | | This change allows to just call sdhci_start_slot() in SDHCI drivers and not to think about which stack handles the operation. As a side effect, this will also fix MMCCAM with sdhci_acpi driver. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D12471 Notes: svn path=/head/; revision=323966
* - Check the slot type capability, set SDHCI_SLOT_{EMBEDDED,NON_REMOVABLE}Marius Strobl2017-07-264-10/+36
| | | | | | | | | | | | | | | | | | for embedded slots. Fail in the sdhci(4) initialization for slot type shared, which is completely unsupported by this driver at the moment. [1] For Intel eMMC controllers, taking the embedded slot type into account obsoltes setting SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE so remove these quirk entries. - Hide the 1.8 V VDD capability when the slot is detected as non-embedded, as the SDHCI specification explicitly states that 1.8 V VDD is applicable to embedded slots only. [2] - Define some easy bits of the SDHCI specification v4.20. [3] - Don't leak bus_dma(9) resources in failure paths of sdhci_init_slot(). Obtained from: DragonFlyBSD 65704a46 [1], 7ba10b88 [2], 0df14648 [3] Notes: svn path=/head/; revision=321589
* o Add support for eMMC HS200 and HS400 bus speed modes at 200 MHz toMarius Strobl2017-07-235-59/+458
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sdhci(4), mmc(4) and mmcsd(4). For the most part, this consists of: - Correcting and extending the infrastructure for negotiating and enabling post-DDR52 modes already added as part of r315598. In fact, HS400ES now should work as well but hasn't been activated due to lack of corresponding hardware. - Adding support executing standard SDHCI initial tuning as well as re-tuning as required for eMMC HS200/HS400 and the fast UHS-I SD card modes. Currently, corresponding methods are only hooked up to the ACPI and PCI front-ends of sdhci(4), though. Moreover, sdhci(4) won't offer any modes requiring (re-)tuning to the MMC/SD layer in order to not break operations with other sdhci(4) front- ends. Likewise, sdhci(4) now no longer offers modes requiring the set_uhs_timing method introduced in r315598 to be implemented/ hooked up (previously, this method was used with DDR52 only, which in turn is only available with Intel controllers so far, i. e. no such limitation was necessary before). Similarly for 1.2/1.8 V VCCQ support and the switch_vccq method. - Addition of locking to the IOCTL half of mmcsd(4) to prevent races with detachment and suspension, especially since it's required to immediately switch away from RPMB partitions again after an access to these (so re-tuning can take place anew, given that the current eMMC specification v5.1 doesn't allow tuning commands to be issued with a RPMB partition selected). Therefore, the existing part_mtx lock in the mmcsd(4) softc is additionally renamed to disk_mtx in order to denote that it only refers to the disk(9) half, likewise for corresponding macros. On the system where the addition of DDR52 support increased the read throughput to ~80 MB/s (from ~45 MB/s at high speed), HS200 yields ~154 MB/s and HS400 ~187 MB/s, i. e. performance now has more than quadrupled compared to pre-r315598. Also, with the advent of (re-)tuning support, most infrastructure necessary for SD card UHS-I modes up to SDR104 now is also in place. Note, though, that the standard SDHCI way of (re-)tuning is special in several ways, which also is why sending the actual tuning requests to the device is part of sdhci(4). SDHCI implementations not following the specification, MMC and non-SDHCI SD card controllers likely will use a generic implementation in the MMC/SD layer for executing tuning, which hasn't been written so far, though. However, in fact this isn't a feature-only change; there are boards based on Intel Bay Trail where DDR52 is problematic and the suggested workaround is to use HS200 mode instead. So far exact details are unknown, however, i. e. whether that's due to a defect in these SoCs or on the boards. Moreover, due to the above changes requiring to be aware of possible MMC siblings in the fast path of mmc(4), corresponding information now is cached in mmc_softc. As a side-effect, mmc_calculate_clock(), mmc_delete_cards(), mmc_discover_cards() and mmc_rescan_cards() now all are guaranteed to operate on the same set of devices as there no longer is any use of device_get_children(9), which can fail in low memory situations. Likewise, mmc_calculate_clock() now longer will trigger a panic due to the latter. o Fix a bug in the failure reporting of mmcsd_delete(); in case of an error when the starting block of a previously stored erase request is used (in order to be able to erase a full erase sector worth of data), the starting block of the newly supplied bio_pblkno has to be returned for indicating no progress. Otherwise, upper layers might be told that a negative number of BIOs have been completed, leading to a panic. o Fix 2 bugs on resume: - Things done in fork1(9) like the acquisition of an SX lock or the sleepable memory allocation are incompatible with a MTX_DEF taken. Thus, mmcsd_resume() must not call kproc_create(9), which in turn uses fork1(9), with the disk_mtx (formerly part_mtx) held. - In mmc_suspend(), the bus is powered down, which in the typical case of a device being selected at the time of suspension, causes the device deselection as part of the bus acquisition by mmc(4) in mmc_scan() to fail as the bus isn't powered up again before later in mmc_go_discovery(). Thus, power down with the bus acquired in mmc_suspend(), which will trigger the deselection up-front. o Fix a memory leak in mmcsd_ioctl() in case copyin(9) fails. [1] o Fix missing variable initialization in mmc_switch_status(). [2] o Fix R1_SWITCH_ERROR detection in mmc_switch_status(). [3] o Handle the case of device_add_child(9) failing, for example due to a memory shortage, gracefully in mmc(4) and sdhci(4), including not leaking memory for the instance variables in case of mmc(4) (which might or might not fix [4] as the latter problem has been discovered independently). o Handle the case of an unknown SD CSD version in mmc_decode_csd_sd() gracefully instead of calling panic(9). o Again, check and handle the return values of some additional function calls in mmc(4) instead of assuming that everything went right or mark non-fatal errors by casting the return value to void. o Correct a typo in the Linux IOCTL compatibility; it should have been MMC_IOC_MULTI_CMD rather than MMC_IOC_CMD_MULTI. o Now that we are reaching ever faster speeds (more improvement in this regard is to be expected when adding ADMA support to sdhci(4)), apply a few micro-optimizations like predicting mmc(4) and sdhci(4) debugging to be off or caching erase sector and maximum data sizes as well support of block addressing in mmsd(4) (instead of doing 2 indirections on every read/write request for determining the maximum data size for example). Reported by: Coverity CID: 1372612 [1], 1372624 [2], 1372594 [3], 1007069 [4] Notes: svn path=/head/; revision=321385
* Better contain MMCCAM parts of this fileWarner Losh2017-07-102-13/+22
| | | | | | | | | | | Remove some useless to the general user debugs Put debugs under sdhci_debug. Fix some style(9) regressions Submitted by: marius@ Notes: svn path=/head/; revision=320858
* Back out enabling the card interrupt detection bit. It is not ready toWarner Losh2017-07-091-5/+2
| | | | | | | | | commit. Noticed by: marius@ Notes: svn path=/head/; revision=320850
* An MMC/SD/SDIO stack using CAMWarner Losh2017-07-095-6/+546
| | | | | | | | | | | | | | | | | | | | | | | Implement the MMC/SD/SDIO protocol within a CAM framework. CAM's flexible queueing will make it easier to write non-storage drivers than the legacy stack. SDIO drivers from both the kernel and as userland daemons are possible, though much of that functionality will come later. Some of the CAM integration isn't complete (there are sleeps in the device probe state machine, for example), but those minor issues can be improved in-tree more easily than out of tree and shouldn't gate progress on other fronts. Appologies to reviews if specific items have been overlooked. Submitted by: Ilya Bakulin Reviewed by: emaste, imp, mav, adrian, ian Differential Review: https://reviews.freebsd.org/D4761 merge with first commit, various compile hacks. Notes: svn path=/head/; revision=320844
* Correct a typo in the comment part of r320577, later on copied intoMarius Strobl2017-07-031-1/+1
| | | | | | | | | | | | | | the commit message; as actually implemented, the intent is to retry up to 2 ms for controllers to enable bus power. Noticed by: ian@, rgrimes@ Additional note: Among others, the problem addressed by r320577 is the APL32 ("Storage Controllers May Not Be Power Gated") erratum. Hopefully, along with r318282, r320577 works around the remaining problems seen with Intel Apollo Lake eMMC and SDXC controllers. Notes: svn path=/head/; revision=320620
* Retry up to 20 ms to enable bus power as at least with some IntelMarius Strobl2017-07-021-2/+14
| | | | | | | | | SDHCI/eMMC controllers the first attempt after a D3 to D0 transition, i. e. when the firmware has put the devices into D3 state before, can fail. Notes: svn path=/head/; revision=320577
* Fix typo in Driver Type A/C/D capability checks in sdhci.Imre Vadász2017-05-311-6/+6
| | | | | | | | | | | | Use the SDHCI_CAN_DRIVE_TYPE_A/_C/_D masks to check for Driver Type support, instead of using the SDHCI_CTRL2_DRIVER_TYPE_A/_C/_D values which are meant for setting the Driver Type in the HOST_CONTROL2 register. Approved by: adrian (mentor), jmcneill Differential Revision: https://reviews.freebsd.org/D10999 Notes: svn path=/head/; revision=319350