summaryrefslogtreecommitdiff
path: root/drivers/scsi
AgeCommit message (Collapse)Author
4 daysscsi: move scsi_scan() call out of scsi_get_blk_by_uuid()David Lechner
Move scsi_scan() call out of scsi_get_blk_by_uuid(). The only caller, env_scsi_get_part(), should be managing this call since it may also want to use different ways to get the partition information in the future. Signed-off-by: David Lechner <[email protected]>
4 daysscsi: return ENODEV in scsi_get_blk_by_uuid()David Lechner
Change scsi_get_blk_by_uuid() to return -ENODEV instead of -1 on error. Other scsi_* functions return an error code rather than -1. 1 is EPERM, which doesn't make sense here. So we use ENODEV instead. The only caller only checks for !success, so changing the value has no effect on the caller. Signed-off-by: David Lechner <[email protected]>
2026-03-16scsi: Adjust SCSI inquiry command data lengthMacpaul Lin
Per the SCSI SPC-4 specification, the standard inquiry data length should not be less than 36 bytes. The current implementation uses 512 bytes, which causes detection failures on some UFS devices (e.g., Longsys) that do not expect a transfer length exceeding the standard inquiry size. Align the default standard inquiry length with the Linux kernel's implementation (see drivers/scsi/scsi_scan.c), which uses 36 bytes as the default. Devices requiring vendor-specific inquiry lengths should be handled through quirk settings in the future. Signed-off-by: ht.lin <[email protected]> Signed-off-by: Macpaul Lin <[email protected]> Reviewed-by: Marek Vasut <[email protected]>
2026-03-12spl: Make UFS available for SPL buildsAlexey Charkov
Add minimal infrastructure to build SPL images with support for UFS storage devices. This also pulls in SCSI support and charset functions, which are dependencies of the UFS code. With this, only a fixed offset is supported for loading the next image, which should be specified in CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR as the number of 4096-byte sectors into the UFS block device. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Alexey Charkov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-12-22drivers: scsi: fix double decrement of block count in 64-bit LBA pathBalaji Selvanathan
The scsi_read function incorrectly decrements the block count twice when handling large disks that trigger the CONFIG_SYS_64BIT_LBA code path (reads beyond block 268,435,455). The variable 'blks' was being decremented both inside the 64-bit LBA block and after the successful scsi_exec() call, causing incorrect block count tracking and data abort errors on large capacity disks. Signed-off-by: Balaji Selvanathan <[email protected]> Tested-by: Tony Dinh <[email protected]>
2025-11-11scsi: Fix the name string memory leak during scsi scanBin Meng
There is a memory leak during the scsi scan process due to the strdup'ed name string is never freed. Actually it is unnecessary to pass a strdup'ed name string to blk_create_devicef() as we can use the name string on the stack directly. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-08-07drivers: scsi: fix inaccurate block count reporting in scsi operationsBalaji Selvanathan
The 'blks' variable in scsi_read/write/erase functions is updated regardless of pass/fail of the scsi operation . If the scsi operation fails, 'blkcnt' is updated using an incorrect value of 'blks'. This wrong 'blkcnt' is returned to the caller and it assumes all blocks were processed correctly. Fix this by updating the 'blks' variable only if the scsi operation succeeds. Signed-off-by: Balaji Selvanathan <[email protected]> Signed-off-by: Varadarajan Narayanan <[email protected]> Reviewed-by: Neil Armstrong <[email protected]>
2025-07-14scsi: Make static functions consistent using lbaint_tAndrew Goodbody
The static helper functions are inconsistent in their use of their third parameter which is used to pass a block count. Keep consistency by always using lbaint_t here. This will fix an issue where two left shifts were overflowing the variable type in use. This issue found by Smatch Signed-off-by: Andrew Goodbody <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2025-05-29scsi: Implement get_blk() functionVaradarajan Narayanan
Add a function to obtain the block device for SCSI. Signed-off-by: Varadarajan Narayanan <[email protected]> Acked-by: Casey Connolly <[email protected]>
2025-04-10drivers: scsi: Add 'erase' supportVaradarajan Narayanan
UFS devices uses the block and scsi frameworks. Enable UFS erase support by adding erase support to SCSI. Signed-off-by: Varadarajan Narayanan <[email protected]>
2025-04-10scsi: sync cache on writeCaleb Connolly
We don't have a mechanism to safely shutdown block devices prior to a baord reset or driver removal. Prevent data loss by synchronizing the SCSI cache after every write. In particular this solves the issue of capsule updates looping on some devices because the board resets immediately after deleting the capsule file and this write wouldn't be flushed in time. This may impact NAND wear, but should be negligible given the usecases for disk write in U-Boot. Signed-off-by: Caleb Connolly <[email protected]> Reviewed-by: Neil Armstrong <[email protected]>
2025-04-10scsi: fix typo in setup_read_ext()Caleb Connolly
This clears the 6th byte of cmd twice rather than setting the 9th byte to 0. Fix it. The only other command that sets the 9th byte is the 64-bit read, so this likely never caused issues in practise. Signed-off-by: Caleb Connolly <[email protected]> Reviewed-by: Neil Armstrong <[email protected]>
2025-01-31scsi: do not fill the LUN in the second CDB byteNeil Armstrong
The SCSI specification originally required that the second Command Data Byte contain the LUN value in its high-order bits, but this field has been marked as reserved since the SCSI-3 spec from 1996. Some vendors uses this byte to pass vendor specific data, and specifying the LUN can trigger strange behaviors. For the record, this happened on an UFS device where LUN0 was working perfectly and reading the other LUNs would get the last buffer data that was read for LUN0, making this issue very very hard to debug. It's sane to assume U-Boot will probably never encounter an SCSI-2 multi-LUN device, if somehow it happens the enquiry command would need to get the SCSI level to handle this case. The Linux fix was added in [1] to fix the exact same issue. [1] https://lore.kernel.org/all/[email protected]/ Signed-off-by: Neil Armstrong <[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-11-01scsi: fix disk capacity too small by one sectorJulius Lehmann
SCSI READ CAPACITY reports the address of the last block and the block size. The total number of blocks is thus last block address plus one. This also fixes the corresponding test case.
2024-10-11global: Rename SPL_TPL_ to PHASE_Simon Glass
Use PHASE_ as the symbol to select a particular XPL build. This means that SPL_TPL_ is no-longer set. Update the comment in bootstage to refer to this symbol, instead of SPL_ Signed-off-by: Simon Glass <[email protected]>
2024-10-11drivers: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILDSimon Glass
Use the new symbol to refer to any 'SPL' build, including TPL and VPL Signed-off-by: Simon Glass <[email protected]>
2024-07-22drivers: scsi: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[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-07scsi: 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]>
2023-11-20Merge tag 'v2024.01-rc3' into nextTom Rini
Prepare v2024.01-rc3
2023-11-20scsi: set dma direction to NONE for TEST UNIT READYNikita Yushchenko
SCSI device scan code was executing TEST UNIT READY command without explicitly setting dma direction in struct scsi_cmd to NONE, so command was passed to driver with dma direction set to DMA_FROM_DEVICE, inherited from older usage. With WDC SDINDDH6-64G ufs device, that caused TEST UNIT READY to return error. Fix that, by explicitly setting dma direction to NONE for TEST UNIT READY, and restoring it back DMA_FROM_DEVICE for the following READ CAPACITY. Signed-off-by: Nikita Yushchenko <[email protected]> Reviewed-by: Marek Vasut <[email protected]>
2023-11-10scsi: Have scsi_init_dev_desc_priv() use memsetTom Rini
When we do not have CONFIG_BOUNCE_BUFFER enabled, inside of scsi_init_dev_desc_priv we never set the 'bb' field to false, we only initialize it to true when CONFIG_BOUNCE_BUFFER is set. Given that we have a number of other fields here we had been explicitly setting to zero, change to first calling memset to clear the struct and then initialize only the fields that need non-zero default values. Addresses-Coverity-ID: 467407 ("Uninitialized variables (UNINIT)") Fixes: 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc") Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-11-07scsi: Forceably finish migration to DM_SCSITom Rini
The migration deadline for moving to DM_SCSI was v2023.04. A further reminder was sent out in August 2023 to the remaining platforms that had not migrated already, and that a few more over the line (or configs deleted). With this commit we: - Rename CONFIG_DM_SCSI to CONFIG_SCSI. - Remove all of the non-DM SCSI code. This includes removing other legacy symbols and code and removes some legacy non-DM AHCI code. - Some platforms that had previously been DM_SCSI=y && SCSI=n are now fully migrated to DM_SCSI as a few corner cases in the code assumed DM_SCSI=y meant SCSI=y. Signed-off-by: Tom Rini <[email protected]>
2023-10-24rockchip: block: blk-uclass: add bounce buffer flag to blk_descJohan Jonker
Currently bounce buffer support is enabled for all block devices when available. Add a flag to blk_desc to enable only on demand. Signed-off-by: Johan Jonker <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Kever Yang <[email protected]>
2023-08-22scsi: Add buffer_aligned check pass-throughMarek Vasut
Some devices have limited DMA capabilities and require that the buffers passed to them fit specific properties. Add new optional callback which can be used at driver level to indicate whether a buffer alignment is suitable for the device DMA or not. This is a pass-through callback from block uclass to drivers. Signed-off-by: Marek Vasut <[email protected]>
2023-08-21Merge tag 'v2023.10-rc3' into nextTom Rini
Prepare v2023.10-rc3 Signed-off-by: Tom Rini <[email protected]>
2023-08-17scsi: Cache align temporary bufferMarek Vasut
The temporary buffer may be passed to DMA capable device, make sure it is cache aligned. Signed-off-by: Marek Vasut <[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-16bootstd: Use bootdev instead of bootdeviceSimon Glass
It seems better to call this a 'bootdev' since this is name used in the documentation. The older 'Bootdevice' name is no-longer used and may cause confusion with the 'bootdevice' environment variable. Update throughout to use bootdev. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2023-04-01scsi: typo supporedtHeinrich Schuchardt
%s/supporedt/supported/ Fixes: edca8cf72130 ("Convert CONFIG_SCSI_AHCI_PLAT et al to Kconfig") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[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 a SCSI bootdevSimon Glass
Add a bootdev for SCSI so that these devices can be used with standard boot. Signed-off-by: Simon Glass <[email protected]>
2023-01-23scsi: Remove all children of SCSI devices before rescanningSimon Glass
At present this only unbinds block devices of a certain type. But SCSI device can have different types of children, including bootdevs. Unbind all children so tht everything is clean and ready for a new scan. Signed-off-by: Simon Glass <[email protected]>
2023-01-23scsi: Correct allocation of block-device nameSimon Glass
This should be allocated so that it does not go out of scope. Fix this and set the log category while we are here. Signed-off-by: Simon Glass <[email protected]>
2022-12-23global: Migrate CONFIG_SCSI_DEV_LIST to CFGTom Rini
Perform a simple rename of CONFIG_SCSI_DEV_LIST to CFG_SCSI_DEV_LIST Signed-off-by: Tom Rini <[email protected]>
2022-10-31usb: Update the test to cover reading and writingSimon Glass
Add test coverage for blk_write() as well. The blk_erase() is not tested for now as the USB stor interface does not support erase. Signed-off-by: Simon Glass <[email protected]>
2022-09-25sandbox: Convert to use driver model for SCSISimon Glass
At present sandbox is producing a warning about SCSI migration. Drop the legacy code and replace it with a new implementation. Also drop the SATA command, which does not work with driver model. Signed-off-by: Simon Glass <[email protected]>
2022-09-25sandbox: scsi: Move request-handling code to scsi_emulSimon Glass
Move this code into the emulator file so it can be used by multiple drivers. Signed-off-by: Simon Glass <[email protected]>
2022-09-25blk: Rename if_type to uclass_idSimon Glass
Use the word 'uclass' instead of 'if_type' to complete the conversion. Signed-off-by: Simon Glass <[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-04-09scsi: call device_probe() after scanningAKASHI Takahiro
Every time a scsi bus/port is scanned and a new block 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-09Convert CONFIG_SCSI_AHCI_PLAT et al to KconfigSimon Glass
This converts the following to Kconfig: CONFIG_SCSI_AHCI_PLAT CONFIG_SYS_SCSI_MAX_SCSI_ID CONFIG_SYS_SCSI_MAX_LUN CONFIG_SYS_SATA_MAX_DEVICE Drop CONFIG_SCSI for everything except the sandbox build. We only need one build for tests. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2022-02-09scsi: Drop CONFIG_SYS_SCSI_MAX_DEVICESimon Glass
This is defined based on two other CONFIGs for all boards except sandbox and durian. For sandbox the value does not matter. For durian the value seems excessive. Drop the option completely, to simplify configuration and reduce the number of things we need to convert to Kconfig. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-09-04sata: Rename SATA_SUPPORT to SATASimon Glass
Rename this options so that CONFIG_IS_ENABLED can be used with it. Signed-off-by: Simon Glass <[email protected]>
2021-08-05pci: scsi: pci: Drop DM_PCI check from scsiSimon Glass
We don't need this check anymore since when PCI is enabled, driver model is always used. Drop it. Signed-off-by: Simon Glass <[email protected]>