It is annoying to have disk images in the source directory since it
clutters up the working space.
Remove cur_dir=True from DiskHelper calls so disk images are written to
the persistent-data directory instead.
Move scsi.img too (used by the bootstd tests) and mmc6.img (used by the
MBR tests.
Add a few comments as to where the images are used.
This keeps the source tree clean and puts disk images in the same place
as other test data.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The current logic is fairly confusing. We always add to_read to start
and we always subtract it from blks. Even the place where blks is set to
0 is really just subtracting to_read.
So move these additions and subtractions out of the if() logic and to
the end of the loop. This is much easier to follow.
Signed-off-by: Simon Glass <sjg@chromium.org>
Each time around the loop a certain number of blocks are processed. Put
this in a variable (to_read/to_write) and avoid changing the input
parameter
Signed-off-by: Simon Glass <sjg@chromium.org>
The current code never returns an error if something goes wrong. While
it is normally useful to return the number of blocks processed, when
nothing is read/written at all, there is clearly something wrong.
Update the logic to return -EIO in this case.
Avoid changing blkcnt since it is an input parameter and this is
confusing.
Signed-off-by: Simon Glass <sjg@chromium.org>
Newer SCSI controllers handle the LUN in a different place from the SCSI
command. Detect this and adjust the command accordingly.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than doing the same shift operation each time, create a function
which writes in the correct command and the LUN. This will allows us to
handle newer controllers which do not want the LUN in the command.
Fix checkpatch warnings about CONFIG_SYS_64BIT_LBA while here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Use if() for this condition. Adjust scsi_setup_read16() to use a
standard unaligned access to avoid shifting more than 32 on a 32-bit
architecture (which produces a compiler warning).
Signed-off-by: Simon Glass <sjg@chromium.org>
The word 'block_dev' suggests it is a device, but this struct is not the
device (now that we use driver model), only some information about it.
We use desc (for descriptor) elsewhere in the code, so update scsi to do
the same.
Signed-off-by: Simon Glass <sjg@chromium.org>
We have a struct for the response data now, so use that instead of
accessing the bytes directly.
Move setting of the device type higher, so that the field is not
overwritten by the following commands.
Signed-off-by: Simon Glass <sjg@chromium.org>
The current algortihm scans all LUNs on all targets. Where the potential
number is very large, as with QEMU (256 targets each with 4K LUNs) this
is a substantial waste of time.
Use the REPORT LUNS command to determine the number of LUNs on each
target. Where that fails, fall back to scanning everything.
Signed-off-by: Simon Glass <sjg@chromium.org>
Use hex values to fit better with how these devices are accessed with
the 'part list' command and others.
Signed-off-by: Simon Glass <sjg@chromium.org>
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 <pbrobinson@gmail.com>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
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.
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 <sjg@chromium.org>
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 <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
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 c8ffd1356d, reversing
changes made to 2ee6f3a5f7.
Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
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 <nikita.yoush@cogentembedded.com>
Reviewed-by: Marek Vasut <marex@denx.de>
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: 81bd22e935 ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
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 <trini@konsulko.com>
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 <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
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 <marek.vasut+renesas@mailbox.org>
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 <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
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 <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>
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 <sjg@chromium.org>