summaryrefslogtreecommitdiff
path: root/scripts/objdiff
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2026-04-24 05:33:38 +0200
committerMarek Vasut <[email protected]>2026-04-29 10:32:04 +0200
commitb27a31665da75134ec1ef25f91f27e56aa45e392 (patch)
tree778fa6a5c7dc57fc0480c44f744955090dc6169d /scripts/objdiff
parentd0d1d11119282b76551d45e531235238da51d7bc (diff)
cmd: ums: Switch HW partition before block access
An UMS session with eMMC device specifier "ums C mmc dev.part1,dev.part2" exposes the same eMMC HW partition 'part2' twice instead of exposing both HW partitions 'part1' and 'part2'. Fix this by switching the eMMC HW partition before block device read/write access. An eMMC is represented by a single struct blk_desc, with the currently selected HW partition being stored in this struct blk_desc. Each call to part_get_info_by_dev_and_name_or_num() with partition string dev[.partN] does trigger HW partition switch by calling blk_get_device_part_str() -> blk_get_device_part_str() -> get_dev_hwpart() -> get_dev_hwpart() -> blk_dselect_hwpart(). The ums_init() iterates over the device specifier string and calls part_get_info_by_dev_and_name_or_num() in a loop for each dev[.partN] entry used as the partition string. If the device specifier string contains more than one dev[.partN] partition strings for the same dev device, then it is the HW partition described in the last dev[.partN] partition string entry that is accessed for all dev device partition strings in the device specifier string, because that last dev[.partN] partition string entry was the last one that triggered blk_dselect_hwpart() call for that device. To access the expected HW partition for every dev[.partN] partition string entry, it is necessary to call blk_dselect_hwpart() before each block read or write. Store HW partition described for each dev[.partN] partition string in struct ums and use the stored value to make it so. The blk_dselect_hwpart() does test whether the currently selected HW partition is already configured in hardware and does not reconfigure the hardware if that is the case, therefore for the majority of block reads and writes, blk_dselect_hwpart() is a no-op with negligible performance impact. Example reproducer is listed below. The last sector of both eMMC HW BOOT partitions is populated with distinct test pattern and UMS is launched: " => mmc dev 1 1 ; mmc read $loadaddr 0x1fff 1 ; md $loadaddr 4 switch to partitions #1, OK mmc1(part 1) is current device MMC read: dev # 1, block # 8191, count 1 ... 1 blocks read: OK 84000000: 1234abcd 1234abcd 1234abcd 1234abcd ..4...4...4...4. => mmc dev 1 2 ; mmc read $loadaddr 0x1fff 1 ; md $loadaddr 4 switch to partitions #2, OK mmc1(part 2) is current device MMC read: dev # 1, block # 8191, count 1 ... 1 blocks read: OK 84000000: 567890ef 567890ef 567890ef 567890ef ..xV..xV..xV..xV => ums 0 mmc 1.1,1.2 UMS: LUN 0, dev mmc 1, hwpart 1, sector 0x0, count 0x2000 UMS: LUN 1, dev mmc 1, hwpart 2, sector 0x0, count 0x2000 " Read of the two block devices on host without this fix produces identical data present in HW BOOT partition 2: " $ dd if=/dev/sdX of=mmc-a.bin ; dd if=/dev/sdY of=mmc-b.bin $ hexdump -C mmc-a.bin | tail -n 3 | head -n 1 ; \ hexdump -C mmc-b.bin | tail -n 3 | head -n 1 003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV| 003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV| " Read of the two block devices on host with this fix produces the expected distinct data from either HW BOOT partition 1 or 2: " $ dd if=/dev/sdX of=mmc-a.bin ; dd if=/dev/sdY of=mmc-b.bin $ hexdump -C mmc-a.bin | tail -n 3 | head -n 1 ; \ hexdump -C mmc-b.bin | tail -n 3 | head -n 1 003ffe00 cd ab 34 12 cd ab 34 12 cd ab 34 12 cd ab 34 12 |..4...4...4...4.| 003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV| " Reported-by: Christoph Niedermaier <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'scripts/objdiff')
0 files changed, 0 insertions, 0 deletions