summaryrefslogtreecommitdiff
path: root/drivers/nvme
AgeCommit message (Collapse)Author
2025-08-11nvme: Tighten requirements on NVME_APPLE driverTom Rini
This driver requires Apple rtkit headers in order to build. Express that requirement in Kconfig as well. Signed-off-by: Tom Rini <[email protected]>
2025-07-10nvme: Fix memory leak on error path of nvme_initAndrew Goodbody
The use of log_msg_ret to log a message and return an error meant that memory allocated earlier in the function was not freed on this error path. Instead log the message in the same way that log_msg_ret would do and then goto the cleanup code to free the memory. This issue found by Smatch. Signed-off-by: Andrew Goodbody <[email protected]>
2025-04-11Kbuild: Always use $(PHASE_)Tom Rini
It is confusing to have both "$(PHASE_)" and "$(XPL_)" be used in our Makefiles as part of the macros to determine when to do something in our Makefiles based on what phase of the build we are in. For consistency, bring this down to a single macro and use "$(PHASE_)" only. Signed-off-by: Tom Rini <[email protected]>
2025-01-20blk: Make block subsystems select BLKTom Rini
The BLK symbol has a few meanings, one of which is that it controls the driver model portion of a "block device". Rather than having this hidden symbol be "default y if ..." it should be select'd by the various block subsystems. Symbols such as PVBLOCK which already select'd BLK are unchanged". Reviewed-by: Peter Robinson <[email protected]> Reviewed-by: Quentin Schulz <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-10-11global: Rename SPL_ to XPL_Simon Glass
Use XPL_ as the symbol to indicate an SPL build. This means that SPL_ is no-longer set. Signed-off-by: Simon Glass <[email protected]>
2024-06-24Merge tag 'v2024.07-rc5' into nextTom Rini
Prepare v2024.07-rc5
2024-06-13Fix typo in NVME show commandThomas Perl
Foramt -> Format Signed-off-by: Thomas Perl <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-07nvme: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this driver directory and when needed add missing include files directly. Signed-off-by: Tom Rini <[email protected]>
2024-01-18nvme: Update nvme_scan_namespace to keep trying on busyMoritz Fischer
A busy controller shouldn't be game-over for all controllers, so keep trying on hitting -EBUSY. This change brings the actual behavior of the routine in line with what the descriptions says. Fixes: 982388eaa991 ("nvme: Add NVM Express driver support") Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Moritz Fischer <[email protected]>
2024-01-18nvme: Fix error code and log to indicate busyMoritz Fischer
Return -EBUSY if controller is found busy rather than -ENOMEM and update the error message accordingly. Fixes: 982388eaa991 ("nvme: Add NVM Express driver support") Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Moritz Fischer <[email protected]>
2023-10-10blk: Use a macro for the typical block sizeBin Meng
Avoid using the magic number 512 directly. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-08-09bootstd: Rename bootdev_setup_sibling_blk()Simon Glass
This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]>
2023-07-17nvme: Provide more useful debugging messagesSimon Glass
When scanning fails it is useful to be able to decode what went wrong. Add some debugging for this. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2023-06-19nvme: pci: Enable for SPLMayuresh Chitale
Enable NVME and PCI NVMe drivers for SPL builds. Also enable PCI_PNP for SPL which is required to auto configure the PCIe devices. Signed-off-by: Mayuresh Chitale <[email protected]>
2023-05-11nvme: Enable PCI bus masteringSimon Glass
U-Boot sets up devices ready for use, but coreboot does not. Enable this so that NVMe works OK from coreboot. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2023-01-23bootstd: Add a new pre-scan priority for bootdevsSimon Glass
We need extensions to be set up before we start trying to boot any of the bootdevs. Add a new priority before all the others for tht sort of thing. Also add a 'none' option, so that the first one is not 0. While we are here, comment enum bootdev_prio_t fully and expand the test for the 'bootdev hunt' command. Signed-off-by: Simon Glass <[email protected]>
2023-01-23bootstd: Add an NVMe bootdevSimon Glass
Add a bootdev for NVMe so that these devices can be used with standard boot. Signed-off-by: Simon Glass <[email protected]>
2022-09-19Merge branch 'master' into nextTom Rini
Signed-off-by: Tom Rini <[email protected]>
2022-09-16blk: Switch over to using uclass IDsSimon Glass
We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <[email protected]>
2022-09-16blk: Select SPL_LEGACY_BLOCK automaticallySimon Glass
Selecting this option can be handled in the Kconfig option itself, as it is with BLK. Update this an drop the various 'select' clauses. Signed-off-by: Simon Glass <[email protected]>
2022-09-16blk: Rename HAVE_BLOCK_DEVICESimon Glass
This option is fact really related to SPL. For U-Boot proper we always use driver model for block devices, so CONFIG_BLK is enabled if block devices are in use. It is only for SPL that we have two cases: - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c - SPL_BLK is not enabled, in which case (if we need block devices) we must use blk_legacy.c Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is different enough from BLK and SPL_BLK that there should be no confusion. Signed-off-by: Simon Glass <[email protected]>
2022-09-16blk: Enable CONFIG_BLK for all mediaSimon Glass
Enable this option on all boards which support block devices. Drop the related depencies on BLK since these are not needed anymore. Disable BLOCK_CACHE on M5253DEMO as this causes a build error. Signed-off-by: Simon Glass <[email protected]>
2022-09-15nvme: Fix multipage prp-listAlexander Sowarka
The nvme driver falsely assumed that the last entry on a page of the prp-list always points to the next page of the prp-list. This potentially can lead to the illegal creation of pages on the prp-list with only a single entry. This change now ensures that splitting the prp-list into multiple pages, behaves now as required by the NVME-Spec. Related to this, also the size of the memory allocation is adjusted accordingly. Signed-off-by: Alexander Sowarka <[email protected]>
2022-08-26nvme: Do a clean NVMe shutdownHector Martin
The brute-force controller disable method can end up racing controller initialization and causing a crash when we shut down Apple ANS2 NVMe controllers. Do a proper controlled shutdown, which does block until things are quiesced properly. This is nicer in general for all controllers. Signed-off-by: Hector Martin <[email protected]> Tested-by: Mark Kettenis <[email protected]> (firefly-rk3399)
2022-06-23arm: apple: nvme: Add SART support and RTKit buffer managementJanne Grunau
The NVMe firmware in the macOS 13 beta blocks or crashes with u-boot's current minimal RTKit implementation. It does not provide buffers for the firmware's buffer requests. The ANS2 firmware included in macOS 11 and 12 tolerates this. The firmware included in the first macOS 13 beta requires buffers for the crashlog and ioreport endpoints to function. In the case of the NVMe the buffers are physical memory. Access to physical memory is guarded by what Apple calls SART. Import m1n1's SART driver (exclusively used for the NVMe controller). Implement buffer management helpers for RTKit. These are generic since other devices (none in u-boot so far) require different handling. Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Mark Kettenis <[email protected]> Tested-by: Mark Kettenis <[email protected]>
2022-05-03pci: Add mask parameter to dm_pci_map_bar()Andrew Scull
Add a mask parameter to control the lookup of the PCI region from which the mapping can be made. Signed-off-by: Andrew Scull <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-05-03pci: Map bars with offset and lengthAndrew Scull
Evolve dm_pci_map_bar() to include an offset and length parameter. These allow a portion of the memory to be mapped and range checks to be applied. Passing both the offset and length as zero results in the previous behaviour and this is used to migrate the previous callers. Signed-off-by: Andrew Scull <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-04-09nvme: call device_probe() after scanningAKASHI Takahiro
Every time a nvme bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-02-10nvme: apple: Add driver for Apple NVMe storage controllerMark Kettenis
Add a driver for the NVMe storage controller integrated on Apple SoCs. This NVMe controller isn't PCI based and deviates from the NVMe standard in its implementation of the command submission queue and the integration of an NVMMU that needs to be managed. This commit tweaks the core NVMe code to support the linear command submission queue implemented by this controller. But setting up the submission queue and managing the NVMMU controller is handled by implementing the driver ops that were added in an earlier commit. Signed-off-by: Mark Kettenis <[email protected]> Tested-on: firefly-rk3399 Tested-by: Mark Kettenis <[email protected]> Tested on: Macbook Air M1 Tested-by: Simon Glass <[email protected]>
2022-02-10nvme: Add shutdown functionMark Kettenis
Add a function to disable the NVMe controller. This will be used to let the driver for the NVMe storage integrated on Apple SoCs shutdown the NVMe controller such we can shutdown the NVMe IOP controller in a clean way afterwards before handing control to the OS. Signed-off-by: Mark Kettenis <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested on: Macbook Air M1 Tested-by: Simon Glass <[email protected]>
2022-02-10nvme: Introduce driver opsMark Kettenis
The NVMe storage controller integrated on Apple SoCs deviates from the NVMe standard in two aspects. It uses a "linear" submission queue and it integrates an NVMMU that needs to be programmed for each NVMe command. Introduce driver ops such that we can set up the linear submission queue and program the NVMMU in the driver for this strange beast. Signed-off-by: Mark Kettenis <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested on: Macbook Air M1 Tested-by: Simon Glass <[email protected]>
2022-02-10nvme: Split out PCI supportMark Kettenis
Apple SoCs have an integrated NVMe controller that isn't connected over a PCIe bus. In preparation for adding support for this NVMe controller, split out the PCI support into its own file. This file is selected through a new CONFIG_NVME_PCI Kconfig option, so do a wholesale replacement of CONFIG_NVME with CONFIG_NVME_PCI. Signed-off-by: Mark Kettenis <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested on: Macbook Air M1 Tested-by: Simon Glass <[email protected]>
2022-01-14nvme: Do not allocate 8kB buffer on stackPali Rohár
Calling 'nvme scan' followed by 'nvme detail' crashes U-Boot on Turris Omnia with the following error: undefined instruction pc : [<0a000000>] lr : [<7ff80bfc>] reloc pc : [<8a8c0000>] lr : [<00840bfc>] sp : 7fb2b908 ip : 0000002a fp : 02000000 r10: 04000000 r9 : 7fb2fed0 r8 : e1000000 r7 : 0c000000 r6 : 03000000 r5 : 06000000 r4 : 01000000 r3 : 7fb30928 r2 : 7fb30928 r1 : 00000000 r0 : 00000000 Flags: nZCv IRQs off FIQs off Mode SVC_32 Code: 0f0fb4f0 0f0fb4f0 0f0fb4f0 0f0fb4f0 (f0f04b0f) Resetting CPU ... This happens when nvme_print_info() tries to return to the caller. It looks like this error is caused by trying to allocate 8 KiB of memory on the stack by the two uses of ALLOC_CACHE_ALIGN_BUFFER(). Use malloc_cache_aligned() to allocate this memory dynamically instead. This fixes 'nvme detail' on Turris Omnia. Note that similar change was applied to file drivers/nvme/nvme.c in past by commit 2f83481dff9c ("nvme: use page-aligned buffer for identify command"). Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Marek Behún <[email protected]>
2021-10-12nvme: invalidate correct memory range after readStefan Agner
The current code invalidates the range after the read buffer since the buffer pointer gets incremented in the read loop. Use a temporary pointer to make sure we have a pristine pointer to invalidate the correct memory range after read. Fixes: 704e040a51d2 ("nvme: Apply cache operations on the DMA buffers") Reviewed-by: Andre Przywara <[email protected]> Signed-off-by: Stefan Agner <[email protected]>
2021-07-06dm: define LOG_CATEGORY for all uclassPatrick Delaunay
Define LOG_CATEGORY for all uclass to allow filtering with log command. Signed-off-by: Patrick Delaunay <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-06-23nvme: Don't clear nvme blk device's priv spaceBin Meng
A udevice's priv space is cleared in alloc_priv() in the DM core. Don't do it again in its probe() routine. Signed-off-by: Bin Meng <[email protected]>
2021-06-23nvme: Drop useless members of 'struct nvme_ns'Bin Meng
mode_select_num_blocks and mode_select_block_len in 'struct nvme_ns' are not useful. Drop them. Signed-off-by: Bin Meng <[email protected]>
2021-06-23nvme: Eliminate the offset of one during block dev creationBin Meng
At present there is an offset of one added during the creation of block device. This can be very confusing as we wanted to encode the namespace id in the block device name but namespae id cannot be zero. This changes to use the namespace id directly in the block device name, eliminating the offset of one effectively. Suggested-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Bin Meng <[email protected]>
2021-06-23nvme: Skip block device creation for inactive namespacesBin Meng
At present for each namespace there is a block device created for it. There is no issue if the number of supported namespaces reported from the NVMe device is only 1. Since QEMU commit 7f0f1acedf15 ("hw/block/nvme: support multiple namespaces"), the number of supported namespaces reported has been changed from 1 to 256, but not all of them are active namespaces. The actual active one depends on the QEMU command line parameters. A common case is that namespace 1 being active and all other 255 being inactive. If a namespace is inactive, the namespace identify command returns a zero filled data structure. We can use field NSZE (namespace size) to decide whether a block device should be created for it. Reported-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Bin Meng <[email protected]>
2021-06-23nvme: Move block dev creation from uclass post_probe() to driver probe()Bin Meng
At present the block device creation happens in the NVMe uclass driver post_probe() phase. In preparation to support multiple namespaces, we should issue namespace identify before creating block devices but that touches the underlying hardware hence it is not appropriate to do such in the uclass driver post_probe(). Let's move it to driver probe() phase instead. Signed-off-by: Bin Meng <[email protected]>
2021-06-23nvme: Remove the redundant aqa value settingWesley Sheng
AQA (Admin Queue Attributes) register is a dword size with lower word of ASQS, and higher word of ACQS. The code set the variable aqa twice, but it is redundant. Signed-off-by: Wesley Sheng <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2021-06-23nvme: Correct the prps per page calculation methodWesley Sheng
Each prp is 8 bytes, calculate the number of prps per page should just divide page size by 8 there is no need to minus 1 Signed-off-by: Wesley Sheng <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2021-06-23nvme: fix for big endian systemsDavid Lamparter
writel() and co. already include the endian swap; doing the swap twice is, er, unhelpful. Tested on a P4080DS, which boots perfectly fine off NVMe with this. Signed-off-by: David Lamparter <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2021-03-19nvme: Elaborate on cache maintenance operation in get/set_featuresAndre Przywara
At the moment the nvme_get_features() and nvme_set_features() functions carry a (somewhat misleading) comment about missing cache maintenance. As it turns out, nvme_get_features() has no caller at all in the tree, and nvme_set_features' only user doesn't use a DMA buffer. Mention that in the comment, and leave some breadcrumbs for the future, should those functions attract more users. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Michael Trimarchi <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2021-03-19nvme: Always invalidate whole cqes[] arrayAndre Przywara
At the moment nvme_read_completion_status() tries to invalidate a single member of the cqes[] array, which is shady as just a single entry is not cache line aligned. The structure is dictated by hardware, and with 16 bytes is smaller than any cache line we usually deal with. Also multiple entries need to be consecutive in memory, so we can't pad them to cover a whole cache line. As a consequence we can only always invalidate all of them - U-Boot just uses two of them anyway. This is fine, as they are only ever read by the CPU (apart from the initial zeroing), so they can't become dirty. Make this obvious by always invalidating the whole array, regardless of the entry number we are about to read. Also blow up the allocation size to cover whole cache lines, to avoid other heap allocations to sneak in. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Michael Trimarchi <[email protected]> Tested-by: Neil Armstrong <[email protected]>
2021-01-05Merge tag 'v2021.01-rc5' into nextTom Rini
Prepare v2021.01-rc5 Signed-off-by: Tom Rini <[email protected]>
2021-01-04nvme: Use only 32-bit accesses in nvme_writeq/nvme_readqStefan Agner
There might be hardware configurations where 64-bit data accesses to NVMe registers are not supported properly. This patch removes the readq/writeq so always two 32-bit accesses are used to read/write 64-bit NVMe registers, similarly as it is done in Linux kernel. This patch fixes operation of NVMe devices on RPi4 Broadcom BCM2711 SoC based board, where the PCIe Root Complex, which is attached to the system through the SCB bridge. Even though the architecture is 64-bit the PCIe BAR is 32-bit and likely the 64-bit wide register accesses initiated by the CPU are not properly translated to a sequence of 32-bit PCIe accesses. nvme_readq(), for example, always returns same value in upper and lower 32-bits, e.g. 0x3c033fff3c033fff which lead to NVMe devices to fail probing. This fix is analogous to commit 8e2ab05000ab ("usb: xhci: Use only 32-bit accesses in xhci_writeq/xhci_readq"). Cc: Sylwester Nawrocki <[email protected]> Cc: Nicolas Saenz Julienne <[email protected]> Cc: Matthias Brugger <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Reviewed-by: Bin Meng <[email protected]> Signed-off-by: Stefan Agner <[email protected]>
2020-12-13dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass
Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <[email protected]>