From: Tobias Waldekranz <tobias@waldekranz.com>
To: Bin Meng <bmeng@tinylab.org>, Simon Glass <sjg@chromium.org>,
U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [PATCH 09/15] blk: blkmap: Support mapping to device of any block size
Date: Tue, 26 Sep 2023 21:29:10 +0200 [thread overview]
Message-ID: <875y3wohrt.fsf@waldekranz.com> (raw)
In-Reply-To: <20230926084346.2237483-10-bmeng@tinylab.org>
On tis, sep 26, 2023 at 16:43, Bin Meng <bmeng@tinylab.org> wrote:
> At present if a device to map has a block size other than 512,
> the blkmap map process just fails. There is no reason why we
> can't just use the block size of the mapped device.
Won't this be very confusing to the user?
The blkmap device uses a fixed block size of 512:
https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/block/blkmap.c?ref_type=heads#L393
So if I map a slice of a 4k device into a blkmap, then
blkmap read 0x80000000 0 1
would copy 4k instead of 512 bytes from the lower device to 0x80000000,
even though the blkmap reports a block size of 512.
It seems to me that the expected behavior would be that only the first
512 bytes would be copied in the command above.
>
> Signed-off-by: Bin Meng <bmeng@tinylab.org>
> ---
>
> drivers/block/blkmap.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
> index f6acfa8927..149a4cac3e 100644
> --- a/drivers/block/blkmap.c
> +++ b/drivers/block/blkmap.c
> @@ -171,11 +171,11 @@ int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>
> bd = dev_get_uclass_plat(bm->blk);
> lbd = dev_get_uclass_plat(lblk);
> - if (lbd->blksz != bd->blksz)
> - /* We could support block size translation, but we
> - * don't yet.
> - */
Hence this comment ^
> - return -EINVAL;
> + if (lbd->blksz != bd->blksz) {
> + /* update to match the mapped device */
> + bd->blksz = lbd->blksz;
> + bd->log2blksz = LOG2(bd->blksz);
> + }
>
> linear = malloc(sizeof(*linear));
> if (!linear)
> --
> 2.25.1
next prev parent reply other threads:[~2023-09-26 19:29 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 8:43 [PATCH 00/15] blk: sandbox: Support binding a device with a given logical block size Bin Meng
2023-09-26 8:43 ` [PATCH 01/15] blk: Use a macro for the typical " Bin Meng
2023-10-02 1:16 ` Simon Glass
2023-09-26 8:43 ` [PATCH 02/15] cmd: host: Mandate the filename parameter in the 'bind' command Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 03/15] blk: sandbox: Support binding a device with a given logical block size Bin Meng
2023-09-26 8:43 ` [PATCH 04/15] blk: host_dev: Make host_sb_detach_file() and host_sb_ops static Bin Meng
2023-10-02 1:16 ` Simon Glass
2023-09-26 8:43 ` [PATCH 05/15] blk: host_dev: Sanity check on the size of host backing file Bin Meng
2023-10-02 1:16 ` Simon Glass
2023-09-26 8:43 ` [PATCH 06/15] cmd: host: Print out the block size of the host device Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 07/15] blk: blkmap: Make bind/unbind routines static Bin Meng
2023-10-02 1:16 ` Simon Glass
2023-09-26 8:43 ` [PATCH 08/15] cmd: blkmap: Make map_handlers[] and its .fn static Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 09/15] blk: blkmap: Support mapping to device of any block size Bin Meng
2023-09-26 19:29 ` Tobias Waldekranz [this message]
2023-09-26 22:44 ` Bin Meng
2023-10-02 1:16 ` Simon Glass
2023-09-26 8:43 ` [PATCH 10/15] cmd: blk_common: Use macros for the return values Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-10-10 9:05 ` Bin Meng
2023-10-10 14:58 ` Simon Glass
2023-10-10 20:17 ` Tom Rini
2023-09-26 8:43 ` [PATCH 11/15] dm: blk: Rename get_desc() and make it externally visible Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 12/15] cmd: blk_common: Stop using hard-coded block size for Sandbox operations Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 13/15] dm: blk: Drop blk_{read,write}_devnum() Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 14/15] disk: part: Print out the unknown device uclass id Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:43 ` [PATCH 15/15] disk: part: Handle blkmap device in print_part_header() Bin Meng
2023-10-02 1:17 ` Simon Glass
2023-09-26 8:58 ` [PATCH 00/15] blk: sandbox: Support binding a device with a given logical block size Heinrich Schuchardt
2023-09-26 14:11 ` Bin Meng
2023-10-11 1:49 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875y3wohrt.fsf@waldekranz.com \
--to=tobias@waldekranz.com \
--cc=bmeng@tinylab.org \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox