Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2228206/?format=api
{ "id": 2228206, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2228206/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260424033401.90360-1-marex@nabladev.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/1.1/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<20260424033401.90360-1-marex@nabladev.com>", "date": "2026-04-24T03:33:38", "name": "cmd: ums: Switch HW partition before block access", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "25cf198e3000f510abd7038df46aa45b44fd0e12", "submitter": { "id": 91452, "url": "http://patchwork.ozlabs.org/api/1.1/people/91452/?format=api", "name": "Marek Vasut", "email": "marex@nabladev.com" }, "delegate": { "id": 117687, "url": "http://patchwork.ozlabs.org/api/1.1/users/117687/?format=api", "username": "mkorpershoek", "first_name": "Mattijs", "last_name": "Korpershoek", "email": "mkorpershoek@baylibre.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260424033401.90360-1-marex@nabladev.com/mbox/", "series": [ { "id": 501456, "url": "http://patchwork.ozlabs.org/api/1.1/series/501456/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=501456", "date": "2026-04-24T03:33:38", "name": "cmd: ums: Switch HW partition before block access", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501456/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2228206/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2228206/checks/", "tags": {}, "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=nabladev.com header.i=@nabladev.com header.a=rsa-sha256\n header.s=dkim header.b=anNe8jSi;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=nabladev.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=nabladev.com header.i=@nabladev.com\n header.b=\"anNe8jSi\";\n\tdkim-atps=neutral", "phobos.denx.de; dmarc=pass (p=reject dis=none)\n header.from=nabladev.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=marex@nabladev.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g2w7h1241z1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 02:21:36 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 0900284353;\n\tSat, 25 Apr 2026 18:21:34 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 229DD84307; Sat, 25 Apr 2026 18:21:33 +0200 (CEST)", "from mx.nabladev.com (mx.nabladev.com\n [IPv6:2a00:f820:417:0:178:251:229:89])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id A666183FB0\n for <u-boot@lists.denx.de>; Sat, 25 Apr 2026 18:21:30 +0200 (CEST)", "from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id C75C1113EC9; Fri, 24 Apr 2026 05:34:32 +0200 (CEST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=nabladev.com;\n s=dkim; t=1777001673; h=from:subject:date:message-id:to:cc:mime-version:\n content-transfer-encoding; bh=XvAF1MvuDmuaq8/lCMu2laOm9UdT/sKurjF2POSfH2w=;\n b=anNe8jSiMZ4qm+BTsm2/rDY6aWJGjnW8HIQ7iuLdx/GxSf4D5MCoi8TdC0kUxePvTlkcF1\n DnzNMLMOx+vsdriDo3aS27XqfH7aKcYVSuQZQksr2aKbqtKNLii5QXaO+adb+r3RUJOCne\n UHhk0C0/nY0yMdVVcNjeNy2EPT97QV/eEoJFLa949ddorI1CJyGR5xi8TSFl3a239LUnRh\n Nmz/e6k2786qkVgpSIm4s9XZd/QNdhLg1sXcyjvKJrGoghztsP9EgsMG/ffAiS+bWAwEXN\n ge7icISm/YRQvLqFjvQGy/TLj0eHWCvpQ5pVfCxeNvj9UWtRm7pCI5pKc31m/w==", "From": "Marek Vasut <marex@nabladev.com>", "To": "u-boot@lists.denx.de", "Cc": "Marek Vasut <marex@nabladev.com>,\n Christoph Niedermaier <cniedermaier@dh-electronics.com>,\n Lukasz Majewski <lukma@denx.de>,\n Mattijs Korpershoek <mkorpershoek@kernel.org>,\n Tom Rini <trini@konsulko.com>", "Subject": "[PATCH] cmd: ums: Switch HW partition before block access", "Date": "Fri, 24 Apr 2026 05:33:38 +0200", "Message-ID": "<20260424033401.90360-1-marex@nabladev.com>", "X-Mailer": "git-send-email 2.53.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Last-TLS-Session-Version": "TLSv1.3", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "An UMS session with eMMC device specifier \"ums C mmc dev.part1,dev.part2\"\nexposes the same eMMC HW partition 'part2' twice instead of exposing both\nHW partitions 'part1' and 'part2'. Fix this by switching the eMMC HW\npartition before block device read/write access.\n\nAn eMMC is represented by a single struct blk_desc, with the currently\nselected HW partition being stored in this struct blk_desc. Each call to\npart_get_info_by_dev_and_name_or_num() with partition string dev[.partN]\ndoes trigger HW partition switch by calling blk_get_device_part_str() ->\nblk_get_device_part_str() -> get_dev_hwpart() -> get_dev_hwpart() ->\nblk_dselect_hwpart(). The ums_init() iterates over the device specifier\nstring and calls part_get_info_by_dev_and_name_or_num() in a loop for\neach dev[.partN] entry used as the partition string. If the device\nspecifier string contains more than one dev[.partN] partition strings\nfor the same dev device, then it is the HW partition described in the\nlast dev[.partN] partition string entry that is accessed for all dev\ndevice partition strings in the device specifier string, because that\nlast dev[.partN] partition string entry was the last one that triggered\nblk_dselect_hwpart() call for that device.\n\nTo access the expected HW partition for every dev[.partN] partition string\nentry, it is necessary to call blk_dselect_hwpart() before each block read\nor write. Store HW partition described for each dev[.partN] partition string\nin struct ums and use the stored value to make it so.\n\nThe blk_dselect_hwpart() does test whether the currently selected HW\npartition is already configured in hardware and does not reconfigure\nthe hardware if that is the case, therefore for the majority of block\nreads and writes, blk_dselect_hwpart() is a no-op with negligible\nperformance impact.\n\nExample reproducer is listed below. The last sector of both eMMC HW BOOT\npartitions is populated with distinct test pattern and UMS is launched:\n\n\"\n=> mmc dev 1 1 ; mmc read $loadaddr 0x1fff 1 ; md $loadaddr 4\nswitch to partitions #1, OK\nmmc1(part 1) is current device\nMMC read: dev # 1, block # 8191, count 1 ... 1 blocks read: OK\n84000000: 1234abcd 1234abcd 1234abcd 1234abcd ..4...4...4...4.\n\n=> mmc dev 1 2 ; mmc read $loadaddr 0x1fff 1 ; md $loadaddr 4\nswitch to partitions #2, OK\nmmc1(part 2) is current device\nMMC read: dev # 1, block # 8191, count 1 ... 1 blocks read: OK\n84000000: 567890ef 567890ef 567890ef 567890ef ..xV..xV..xV..xV\n\n=> ums 0 mmc 1.1,1.2\nUMS: LUN 0, dev mmc 1, hwpart 1, sector 0x0, count 0x2000\nUMS: LUN 1, dev mmc 1, hwpart 2, sector 0x0, count 0x2000\n\"\n\nRead of the two block devices on host without this fix produces\nidentical data present in HW BOOT partition 2:\n\n\"\n$ dd if=/dev/sdX of=mmc-a.bin ; dd if=/dev/sdY of=mmc-b.bin\n$ hexdump -C mmc-a.bin | tail -n 3 | head -n 1 ; \\\n hexdump -C mmc-b.bin | tail -n 3 | head -n 1\n003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV|\n003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV|\n\"\n\nRead of the two block devices on host with this fix produces the\nexpected distinct data from either HW BOOT partition 1 or 2:\n\n\"\n$ dd if=/dev/sdX of=mmc-a.bin ; dd if=/dev/sdY of=mmc-b.bin\n$ hexdump -C mmc-a.bin | tail -n 3 | head -n 1 ; \\\n hexdump -C mmc-b.bin | tail -n 3 | head -n 1\n003ffe00 cd ab 34 12 cd ab 34 12 cd ab 34 12 cd ab 34 12 |..4...4...4...4.|\n003ffe00 ef 90 78 56 ef 90 78 56 ef 90 78 56 ef 90 78 56 |..xV..xV..xV..xV|\n\"\n\nReported-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>\nSigned-off-by: Marek Vasut <marex@nabladev.com>\n---\nCc: Lukasz Majewski <lukma@denx.de>\nCc: Mattijs Korpershoek <mkorpershoek@kernel.org>\nCc: Tom Rini <trini@konsulko.com>\nCc: u-boot@lists.denx.de\n---\n cmd/usb_mass_storage.c | 11 +++++++++++\n include/usb_mass_storage.h | 1 +\n 2 files changed, 12 insertions(+)", "diff": "diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c\nindex 47e8b70cd10..e8b87045bdc 100644\n--- a/cmd/usb_mass_storage.c\n+++ b/cmd/usb_mass_storage.c\n@@ -24,6 +24,11 @@ static int ums_read_sector(struct ums *ums_dev,\n {\n \tstruct blk_desc *block_dev = &ums_dev->block_dev;\n \tlbaint_t blkstart = start + ums_dev->start_sector;\n+\tint ret;\n+\n+\tret = blk_dselect_hwpart(block_dev, ums_dev->hwpart);\n+\tif (ret && ret != -ENOSYS)\n+\t\treturn ret;\n \n \treturn blk_dread(block_dev, blkstart, blkcnt, buf);\n }\n@@ -33,6 +38,11 @@ static int ums_write_sector(struct ums *ums_dev,\n {\n \tstruct blk_desc *block_dev = &ums_dev->block_dev;\n \tlbaint_t blkstart = start + ums_dev->start_sector;\n+\tint ret;\n+\n+\tret = blk_dselect_hwpart(block_dev, ums_dev->hwpart);\n+\tif (ret && ret != -ENOSYS)\n+\t\treturn ret;\n \n \treturn blk_dwrite(block_dev, blkstart, blkcnt, buf);\n }\n@@ -110,6 +120,7 @@ static int ums_init(const char *devtype, const char *devnums_part_str)\n \t\tsnprintf(name, UMS_NAME_LEN, \"UMS disk %d\", ums_count);\n \t\tums[ums_count].name = name;\n \t\tums[ums_count].block_dev = *block_dev;\n+\t\tums[ums_count].hwpart = block_dev->hwpart;\n \n \t\tprintf(\"UMS: LUN %d, dev %s %d, hwpart %d, sector %#x, count %#x\\n\",\n \t\t ums_count, devtype, ums[ums_count].block_dev.devnum,\ndiff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h\nindex 6d83d93cad7..9be704ea8b7 100644\n--- a/include/usb_mass_storage.h\n+++ b/include/usb_mass_storage.h\n@@ -22,6 +22,7 @@ struct ums {\n \tunsigned int num_sectors;\n \tconst char *name;\n \tstruct blk_desc block_dev;\n+\tint hwpart;\n };\n \n int fsg_init(struct ums *ums_devs, int count, struct udevice *udc);\n", "prefixes": [] }