Re: [PATCH 03/10] block: allow block devices to implement the cdev erase operation

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 01:10:05PM +0200, Ahmad Fatoum wrote: > On 30.07.24 10:55, Sascha Hauer wrote: > > On Tue, Jul 30, 2024 at 09:19:22AM +0200, Ahmad Fatoum wrote: > >> We mainly implement cdev erase for raw flashes. Many block devices, like > >> NVMe, SSD or SD/MMC are also flash-based and ex

Re: [PATCH 07/10] mci: add support for discarding write blocks

2024-07-30 Thread Ahmad Fatoum
On 30.07.24 12:05, Sascha Hauer wrote: > On Tue, Jul 30, 2024 at 09:19:26AM +0200, Ahmad Fatoum wrote: >> +__be32 *ssr; >> +int err; >> +unsigned int au, eo, et, es; >> + >> +if (!IS_ENABLED(CONFIG_MCI_ERASE)) >> +return -ENOSYS; > > I think we settled on using -EOPNOT

Re: [PATCH 07/10] mci: add support for discarding write blocks

2024-07-30 Thread Ahmad Fatoum
Hello Yann, On 30.07.24 11:23, Yann Sionneau wrote: > Hello Ahmad, Thanks for the review. Can you please trim your replies in longer mails, so it's easier to find the review? > > Le 7/30/24 à 09:19, Ahmad Fatoum a écrit : >> From: Ahmad Fatoum >> +    while (i < blkcnt) { >> +    sector_t

Re: [PATCH 04/10] mci: turn bool members into bitfield in struct mci

2024-07-30 Thread Ahmad Fatoum
On 30.07.24 11:06, Sascha Hauer wrote: > On Tue, Jul 30, 2024 at 09:19:23AM +0200, Ahmad Fatoum wrote: >> In preparation for adding more boolean flags, turn the current two bools >> into two bits sharing the same u8-sized member. >> >> Signed-off-by: Ahmad Fatoum >> --- >> include/mci.h | 4 ++--

Re: [PATCH 03/10] block: allow block devices to implement the cdev erase operation

2024-07-30 Thread Ahmad Fatoum
On 30.07.24 10:55, Sascha Hauer wrote: > On Tue, Jul 30, 2024 at 09:19:22AM +0200, Ahmad Fatoum wrote: >> We mainly implement cdev erase for raw flashes. Many block devices, like >> NVMe, SSD or SD/MMC are also flash-based and expose a mechanism or >> multiple to trigger an erase on hardware or fla

Re: [PATCH 06/10] mci: core: use CONFIG_MCI_WRITE, not CONFIG_BLOCK_WRITE

2024-07-30 Thread Ahmad Fatoum
Hello Sascha, On 30.07.24 11:18, Sascha Hauer wrote: > On Tue, Jul 30, 2024 at 09:19:25AM +0200, Ahmad Fatoum wrote: >> There's a more specific CONFIG_MCI_WRITE that's so far only used to >> remove write support for in the Atmel MCI driver. We should use the same >> symbol also to remove support i

Re: [PATCH 05/10] mci: describe more command structure in mci.h

2024-07-30 Thread Ahmad Fatoum
On 30.07.24 11:25, Yann Sionneau wrote: > Hello Ahmad, > > Le 7/30/24 à 09:19, Ahmad Fatoum a écrit : >> This introduces no functional change, but adds a number of definitions >> that will come in handy when adding erase support in a later commit. >> >> Signed-off-by: Ahmad Fatoum >> --- >>   inc

Re: [PATCH v2 7/9] i.MX8M: HABv4: add an option to allow key revocation

2024-07-30 Thread Marco Felsch
On 24-07-30, Ahmad Fatoum wrote: > Hello Marco, > > On 7/4/24 10:15, Marco Felsch wrote: > > Hi Ahmad, > > > > On 24-07-03, Ahmad Fatoum wrote: > >> Hello Marco, > >> > >> On 03.07.24 19:20, Marco Felsch wrote: > >>> The HAB code needs an special [Unlock] instruction to keep the > >>> SRK_REVOKE

Re: [PATCH 1/2] restart: allow selecting restart handler by device name

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 16:30:06 +0200, Ahmad Fatoum wrote: > Many SoCs feature multiple instances of the same watchdog IP. For > example, the i.MX8MP has three watchdogs, which would be called wdog0, > wdog1, wdog2 in barebox, but they would all have imxwd as restart > handler name. > > To be able

Re: [PATCH v3 1/2] console: add new CONSOLE_ACTIVATE_ALL_FALLBACK option

2024-07-30 Thread Sascha Hauer
On Tue, 30 Jul 2024 10:34:50 +0200, Ahmad Fatoum wrote: > We already have three CONSOLE_ACTIVATE options and every one of them has > drawbacks: > > - ACTIVATE_ALL: May write barebox log to external devices like MCUs > that don't expect it > > - ACTIVATE_FIRST: Not applicable for most sy

Re: [PATCH] common: clarify help text for CONFIG_CONSOLE_ACTIVATE_* options

2024-07-30 Thread Sascha Hauer
On Fri, 26 Jul 2024 14:23:36 +0200, Ahmad Fatoum wrote: > CONFIG_CONSOLE_ACTIVATE_NONE is an unfortunate name. The help text > explains how consoles are still activated, but omits the main way they > are activated: The device tree's /chosen/stdout-path property. > > Similarly, CONFIG_CONSOLE_ACT

Re: [PATCH 09/10] mci: core: remove reference to SD Card from common mci_card_probe

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:28AM +0200, Ahmad Fatoum wrote: > mci_card_probe is called for both SD cards and MMC, so reporting that > an SD Card was successfully added is misleading. > > There is an info message that reports whether it's a MMC or SD card > already, so just remove the SD from thi

Re: [PATCH 08/10] commands: sync: add new command to flush cached writes

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:27AM +0200, Ahmad Fatoum wrote: > In barebox, the dirty block cache for a given device is flushed when > closing all file descriptors to it, a cached block needs to be evicted > due to pressure or when barebox shuts down. > > There are valid uses to do it explicitly h

Re: [PATCH 07/10] mci: add support for discarding write blocks

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:26AM +0200, Ahmad Fatoum wrote: > /** > * Read one or several block(s) of data from the card > * @param mci MCI instance > @@ -773,6 +850,49 @@ static int sd_switch(struct mci *mci, unsigned mode, > unsigned group, > return mci_send_cmd(mci, &cmd, &data); >

Re: [PATCH v2] of: fdt: fix overflows when parsing sizes

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:25:52 +0200, Ahmad Fatoum wrote: > The function dt_struct_advance() is used to advance a pointer to the next > offset within the structure block, while checking that the result is in > bounds. > > Unfortunately, the function used a signed size argument. This had the > effe

Re: [PATCH] ext4: Fix integer overflow in ext4fs_read_symlink()

2024-07-30 Thread Sascha Hauer
On Tue, 02 Jul 2024 21:44:27 +0200, Richard Weinberger wrote: > While zalloc() takes a size_t type, adding 1 to the le32 variable > will overflow. > A carefully crafted ext4 filesystem can exhibit an inode size of 0x > and as consequence zalloc() will do a zero allocation. > > Later in t

Re: [PATCH] commands: sync: add new command to flush cached writes

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:16:32AM +0200, Ahmad Fatoum wrote: > In barebox, the dirty block cache for a given device is flushed when > closing all file descriptors to it, a cached block needs to be evicted > due to pressure or when barebox shuts down. > > There are valid uses to do it explicitly h

Re: [PATCH 05/10] mci: describe more command structure in mci.h

2024-07-30 Thread Yann Sionneau
Hello Ahmad, Le 7/30/24 à 09:19, Ahmad Fatoum a écrit : This introduces no functional change, but adds a number of definitions that will come in handy when adding erase support in a later commit. Signed-off-by: Ahmad Fatoum --- include/mci.h | 61 +

Re: [PATCH 07/10] mci: add support for discarding write blocks

2024-07-30 Thread Yann Sionneau
Hello Ahmad, Le 7/30/24 à 09:19, Ahmad Fatoum a écrit : From: Ahmad Fatoum A common optimization for flashing is to skip gaps between partitions and only flash actual data. The problem with that is that data from the previous installation may persist and confuse later software, e.g. an existin

Re: [PATCH 06/10] mci: core: use CONFIG_MCI_WRITE, not CONFIG_BLOCK_WRITE

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:25AM +0200, Ahmad Fatoum wrote: > There's a more specific CONFIG_MCI_WRITE that's so far only used to > remove write support for in the Atmel MCI driver. We should use the same > symbol also to remove support in the MCI core instead of relying on its > parent CONFIG_BL

Re: [PATCH 04/10] mci: turn bool members into bitfield in struct mci

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:23AM +0200, Ahmad Fatoum wrote: > In preparation for adding more boolean flags, turn the current two bools > into two bits sharing the same u8-sized member. > > Signed-off-by: Ahmad Fatoum > --- > include/mci.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletion

Re: [PATCH 03/10] block: allow block devices to implement the cdev erase operation

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:22AM +0200, Ahmad Fatoum wrote: > We mainly implement cdev erase for raw flashes. Many block devices, like > NVMe, SSD or SD/MMC are also flash-based and expose a mechanism or > multiple to trigger an erase on hardware or flash translation layer > level without an acco

[PATCH v3 1/2] console: add new CONSOLE_ACTIVATE_ALL_FALLBACK option

2024-07-30 Thread Ahmad Fatoum
We already have three CONSOLE_ACTIVATE options and every one of them has drawbacks: - ACTIVATE_ALL: May write barebox log to external devices like MCUs that don't expect it - ACTIVATE_FIRST: Not applicable for most systems that probe from device tree, where the order of probe is not n

[PATCH v3 2/2] common: clarify help text for CONFIG_CONSOLE_ACTIVATE_* options

2024-07-30 Thread Ahmad Fatoum
CONFIG_CONSOLE_ACTIVATE_NONE is an unfortunate name. The help text explains how consoles are still activated, but omits the main way they are activated: The device tree's /chosen/stdout-path property. Similarly, CONFIG_CONSOLE_ACTIVATE_(FIRST/NONE) don't talk about the implications of selecting th

Re: [RESEND][PATCH 1/2] console: add new CONSOLE_ACTIVATE_ALL_FALLBACK option

2024-07-30 Thread Ahmad Fatoum
On 7/30/24 10:09, Sascha Hauer wrote: > On Fri, Jul 26, 2024 at 02:26:22PM +0200, Ahmad Fatoum wrote: >> We already have three CONSOLE_ACTIVATE options and every one of them has >> drawbacks: >> >> - ACTIVATE_ALL: May write barebox log to external devices like MCUs >> that don't expect it

Re: [PATCH 01/10] fs: give erase() a new erase_type parameter

2024-07-30 Thread Ahmad Fatoum
On 7/30/24 10:31, Sascha Hauer wrote: > On Tue, Jul 30, 2024 at 09:19:20AM +0200, Ahmad Fatoum wrote: >> Many managed flashes provide an erase operation, which need not be used >> for regular writes, but is provided nonetheless for efficient clearing >> of large regions of storage to a fixed bit

Re: [PATCH 01/10] fs: give erase() a new erase_type parameter

2024-07-30 Thread Sascha Hauer
On Tue, Jul 30, 2024 at 09:19:20AM +0200, Ahmad Fatoum wrote: > Many managed flashes provide an erase operation, which need not be used > for regular writes, but is provided nonetheless for efficient clearing > of large regions of storage to a fixed bit pattern. The erase type allows > users to spe

Re: [PATCH v2 7/9] i.MX8M: HABv4: add an option to allow key revocation

2024-07-30 Thread Ahmad Fatoum
Hello Marco, On 7/4/24 10:15, Marco Felsch wrote: > Hi Ahmad, > > On 24-07-03, Ahmad Fatoum wrote: >> Hello Marco, >> >> On 03.07.24 19:20, Marco Felsch wrote: >>> The HAB code needs an special [Unlock] instruction to keep the >>> SRK_REVOKE fuse bank unlocked. This is required if a key needs to

Re: [PATCH] fs: ramfs: simplify len calculation in ramfs_find_chunk

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:09:32 +0200, Ahmad Fatoum wrote: > ramfs_find_chunk finds the correct chunk and additionally returns via > argument pointers the offset to use and the remaining length. > > While correct, the way the remaining len is calculated can be simplified > by using the offset previ

Re: [PATCH v2] of: fdt: fix overflows when parsing sizes

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:25:52 +0200, Ahmad Fatoum wrote: > The function dt_struct_advance() is used to advance a pointer to the next > offset within the structure block, while checking that the result is in > bounds. > > Unfortunately, the function used a signed size argument. This had the > effe

Re: [PATCH master] of: fdt: fix overflows when parsing sizes

2024-07-30 Thread Sascha Hauer
On Mon, 22 Jul 2024 19:24:10 +0200, Ahmad Fatoum wrote: > The function dt_struct_advance() is used to advance a pointer to the next > offset within the structure block, while checking that the result is in > bounds. > > Unfortunately, the function used a signed size argument. This had the > effe

Re: [PATCH] rsa: fix deleting RSA keys

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:47:02 +0200, Ahmad Fatoum wrote: > RSA keys are appended onto rsa_keys with rsa_key_add, so it makes sense > that rsa_key_free would remove them from the key ring's linked list. > > It's possible to have "standalone" RSA keys outside the key ring, but > those would be glob

Re: [PATCH] calloc: handle wrap around in total buffer size correctly

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:47:45 +0200, Ahmad Fatoum wrote: > calloc() should allocate a memory buffer that fits the product of its > arguments or return NULL if this is not possible. > > We violated this so far and a wraparound would result in allocating a > too small buffer leading to buffer overf

Re: [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 11:47:31 +0200, Ahmad Fatoum wrote: > All other prints in the file use the DMA address except for this single > print inside debug_dma_map(). Let's use the DMA address there as well to > fix the warning about casting a 32-bit pointer to a 64 bit integer and > to align error me

Re: [PATCH] env: suggest global/nv command when calling setenv on non-existent parameter

2024-07-30 Thread Sascha Hauer
On Fri, 26 Jul 2024 13:25:56 +0200, Ahmad Fatoum wrote: > Unlike regular environment variables, device parameters have to be > explicitly created before they are used: > > global.linux.bootargs.memsize="mem=3072M" > Cannot set parameter global.linux.bootargs.memsize: No such device > > The

Re: [PATCH] net: designware: dma_sync_single_for_device buffer before passing to HW

2024-07-30 Thread Sascha Hauer
On Wed, 24 Jul 2024 17:23:27 +0200, Ahmad Fatoum wrote: > For cache-incoherent DMA, dma_sync_single_for_cpu with DMA_FROM_DEVICE > invalidates the cache, so no stale lines in the cache hide what the > hardware had written to RAM. > > On the same systems, dma_sync_single_for_device with DMA_FROM_

Re: [RESEND][PATCH 1/2] console: add new CONSOLE_ACTIVATE_ALL_FALLBACK option

2024-07-30 Thread Sascha Hauer
On Fri, Jul 26, 2024 at 02:26:22PM +0200, Ahmad Fatoum wrote: > We already have three CONSOLE_ACTIVATE options and every one of them has > drawbacks: > > - ACTIVATE_ALL: May write barebox log to external devices like MCUs > that don't expect it > > - ACTIVATE_FIRST: Not applicable for mos

Re: (subset) [PATCH 2/2] ARM: i.MX8MP: tqma8mpxl: match board code against SoM compatible

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 16:33:47 +0200, Ahmad Fatoum wrote: > The board code has nothing baseboard-specific: It just registers the > barebox update handler and activates the environment on the bootsource, > both of which are applicable to any boards using the same SoM. > > Therefore, let's replace t

Re: (subset) [PATCH 1/2] ARM: i.MX8MP: tqma8mpxl: fix eMMC barebox update handler

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 16:33:46 +0200, Ahmad Fatoum wrote: > While the eMMC is indeed uSDHC3, the board's device tree aliases shuffle > around the order, so the eMMC is at mmc0 and the SD is at mmc1. > > We thus need to follow suit in the board code as to register the correct > device with the eMMC

Re: [PATCH] bbu: report what device caused the handler to be unavailble

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 16:32:33 +0200, Ahmad Fatoum wrote: > The current message only lists the handler name, but to understand why > the operation failed, it's useful to print also the path of the device > that wasn't found. Change the info message to list both. > > Applied, thanks! [1/1] bbu:

Re: [PATCH] fixup! ARM: cpuinfo: add option to print early memory map

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 15:51:37 +0200, Ahmad Fatoum wrote: > ARM: cpu: uncompress: fix endmem passed to print_pbl_mem_layout > > The function expects the end of memory and not a size as second > argument. > > Applied, thanks! [1/1] fixup! ARM: cpuinfo: add option to print early memory map

Re: [PATCH] MIPS: : use generic io accessors

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 00:19:29 +0300, Antony Pavlov wrote: > Applied, thanks! [1/1] MIPS: : use generic io accessors https://git.pengutronix.de/cgit/barebox/commit/?id=4a0b13ce8a61 (link may not be stable) Best regards, -- Sascha Hauer

Re: [PATCH] mci: core: remove reference to SD Card from common mci_card_probe

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 21:06:53 +0200, Ahmad Fatoum wrote: > mci_card_probe is called for both SD cards and MMC, so reporting that > an SD Card was successfully added is misleading. > > There is an info message that reports whether it's a MMC or SD card > already, so just remove the SD from this la

Re: [PATCH] watchdog: imxwd: more info in imx21_watchdog_set_timeout debug message

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 19:22:49 +0200, Ahmad Fatoum wrote: > The function behaves differently depending on whether priv->ext_reset > and priv->suspend_in_lpm is set. To make the debugging prints more > useful add this information into the debug message. > > Applied, thanks! [1/1] watchdog: imxwd

Re: [PATCH] optee: ioctl takes unsigned int argument

2024-07-30 Thread Sascha Hauer
On Mon, 29 Jul 2024 16:34:39 +0200, Sascha Hauer wrote: > Fix incompatible pointer warning. the ioctl() op now takes a unsigned > int as command argument. > > Applied, thanks! [1/1] optee: ioctl takes unsigned int argument https://git.pengutronix.de/cgit/barebox/commit/?id=aa650bf29486

[PATCH 10/10] commands: blkstats: add command to print block device statistics

2024-07-30 Thread Ahmad Fatoum
To test proper operations of block device operations, add a command that prints how many sectors were read/written/erased for a device so far. Signed-off-by: Ahmad Fatoum --- commands/Kconfig| 11 + commands/Makefile | 1 + commands/blkstats.c | 60

[PATCH 05/10] mci: describe more command structure in mci.h

2024-07-30 Thread Ahmad Fatoum
This introduces no functional change, but adds a number of definitions that will come in handy when adding erase support in a later commit. Signed-off-by: Ahmad Fatoum --- include/mci.h | 61 ++- 1 file changed, 60 insertions(+), 1 deletion(-) dif

[PATCH 01/10] fs: give erase() a new erase_type parameter

2024-07-30 Thread Ahmad Fatoum
Many managed flashes provide an erase operation, which need not be used for regular writes, but is provided nonetheless for efficient clearing of large regions of storage to a fixed bit pattern. The erase type allows users to specify _why_ the erase operation is done, so the driver or the core code

[PATCH 07/10] mci: add support for discarding write blocks

2024-07-30 Thread Ahmad Fatoum
From: Ahmad Fatoum A common optimization for flashing is to skip gaps between partitions and only flash actual data. The problem with that is that data from the previous installation may persist and confuse later software, e.g. an existing barebox state partition not contained in the image may su

[PATCH 00/10] mmc: add SD/eMMC erase support

2024-07-30 Thread Ahmad Fatoum
A common optimization for flashing is to skip gaps between partitions and only flash actual data. The problem with that is that data from the previous installation may persist and confuse later software, e.g. an existing barebox state partition not contained in the image may survive, when the expec

[PATCH 04/10] mci: turn bool members into bitfield in struct mci

2024-07-30 Thread Ahmad Fatoum
In preparation for adding more boolean flags, turn the current two bools into two bits sharing the same u8-sized member. Signed-off-by: Ahmad Fatoum --- include/mci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mci.h b/include/mci.h index 773aed896c96..4f1ff9d

[PATCH 09/10] mci: core: remove reference to SD Card from common mci_card_probe

2024-07-30 Thread Ahmad Fatoum
mci_card_probe is called for both SD cards and MMC, so reporting that an SD Card was successfully added is misleading. There is an info message that reports whether it's a MMC or SD card already, so just remove the SD from this last debug print. Signed-off-by: Ahmad Fatoum --- drivers/mci/mci-c

[PATCH 02/10] block: factor out chunk_flush helper

2024-07-30 Thread Ahmad Fatoum
We have two places where we flush chunks: when explicitly flushing all buffered blocks and when there are no idle blocks. A third place will be added soon for the new erasure callback, so prepare for that by factoring out the helper. Signed-off-by: Ahmad Fatoum --- common/block.c | 42 +

[PATCH 06/10] mci: core: use CONFIG_MCI_WRITE, not CONFIG_BLOCK_WRITE

2024-07-30 Thread Ahmad Fatoum
There's a more specific CONFIG_MCI_WRITE that's so far only used to remove write support for in the Atmel MCI driver. We should use the same symbol also to remove support in the MCI core instead of relying on its parent CONFIG_BLOCK_WRITE option. Signed-off-by: Ahmad Fatoum --- drivers/mci/mci-c

[PATCH 08/10] commands: sync: add new command to flush cached writes

2024-07-30 Thread Ahmad Fatoum
In barebox, the dirty block cache for a given device is flushed when closing all file descriptors to it, a cached block needs to be evicted due to pressure or when barebox shuts down. There are valid uses to do it explicitly however: - When benchmarking write speed to a block device - Before

[PATCH 03/10] block: allow block devices to implement the cdev erase operation

2024-07-30 Thread Ahmad Fatoum
We mainly implement cdev erase for raw flashes. Many block devices, like NVMe, SSD or SD/MMC are also flash-based and expose a mechanism or multiple to trigger an erase on hardware or flash translation layer level without an accompanied write. To make it possible to use this functionality elsewher

[PATCH] commands: sync: add new command to flush cached writes

2024-07-30 Thread Ahmad Fatoum
In barebox, the dirty block cache for a given device is flushed when closing all file descriptors to it, a cached block needs to be evicted due to pressure or when barebox shuts down. There are valid uses to do it explicitly however: - When benchmarking write speed to a block device - Before