summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/rpi4'Sascha Hauer2022-06-292-0/+74
|\
| * ARM: rpi: parse useful data from vc fdtDaniel Brát2022-06-271-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Videocore first-stage loader on rpi passes us many useful information inside the vc fdt, including the real value of PM_RSTS register, not easily available by other means and which we can use to determine the reset cause. Also make the relevant funtions just print error/warning and continue in case of some errors, since the fdt from vc is now optional for barebox's basic function. Signed-off-by: Daniel Brát <danek.brat@gmail.com> Link: https://lore.barebox.org/20220617215811.5687-1-danek.brat@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: add dma_sync nop stubs for PBLAhmad Fatoum2022-06-171-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | We can implement dma_sync functions as compiler barriers when we are certain that the buffers are in coherent/uncached memory, e.g. because MMU is only enabled in barebox_arm_entry which hasn't run yet. This will come in handy when doing mailbox communication in PBL on the Raspberry Pi. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220614091556.1018102-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: avoid clash between static inline and extern dma_alloc declarationsAhmad Fatoum2022-06-171-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | dma_alloc/dma_sync/dma_free can be either either static inline definitions usually supplied per arch or extern definitions that can be either generic or supplied per arch. To avoid clashes, expect static inline definitions to define a preprocessor symbol for now. There is much duplication in the static inline helpers, which we can remove in future. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220614091556.1018102-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2022-06-297-9/+35
|\ \
| * | ddr: imx8m: remove header including itselfAhmad Fatoum2022-06-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | This line has noeffect because of the include guard, so just drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220623085741.3680767-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | env: Introduce pr_setenv()Sascha Hauer2022-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | It's a common pattern to (ba)sprintf to a string and then call setenv() with this string. Introduce pr_setenv() as a shortcut to simplify this pattern. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: request reserved memory regions so other code can'tAhmad Fatoum2022-06-151-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new of_reserved_mem_walk that can be used to request reserved memory regions. This avoids e.g. bootm trying to place the kernel into a reserved region. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609111810.2454588-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: add of_get_reserve_map stub for !CONFIG_OFTREERouven Czerwinski2022-06-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to unconditionally include of.h in files which did not require CONFIG_OFTREE, required for the MMU code in later patches. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609054342.661505-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: reset_source: Remove of_get_reset_source_priority()Alexander Shiyan2022-06-101-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | of_get_reset_source_priority() has no users, so it can be safely removed. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220608051244.2318-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | block: set S_IFBLK for block devices instead of S_IFCHRAhmad Fatoum2022-06-101-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In barebox, block devices are a special case of character devices. Nevertheless, differentiation can be useful to allow scripts iterating over all block devices without accounting for naming, e.g. for dev in /dev/*; do test -b $dev && echo $dev: blockdevice done Add the necessary support. This will break scripts that assume test -c blockdevice to be true, but that's a quite improbable check. Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220602195916.9061-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | globalvar: Add missing empty prototype for globalvar_set()Alexander Shiyan2022-06-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | common/fastboot.c: In function 'cb_boot': common/fastboot.c:396:2: error: implicit declaration of function 'globalvar_set' globalvar_set("bootm.image", ""); Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220601060226.3756-5-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mci: core: add device parameter for eMMC boot ackLucas Stach2022-06-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an easy way to enable the boot acknowledge function of a eMMC device, without the need to frob the EXT_CSD setting via the mmc_extcsd command. A boot ack is required whenever the boot partitions are read via the fast initialization boot protocol. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20200513114636.811-1-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/earlycon'Sascha Hauer2022-06-291-0/+2
|\ \ \
| * | | console: add new $global.bootm.earlycon parameterAhmad Fatoum2022-06-091-0/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox already fixes up a suitable console= parameter if it can determine one into the kernel command line. This doesn't help with early Linux issues, which can instead be debugged by the earlycon mechanism. For earlycon to work, the kernel DT must have a stdout-path or the user needs to explicitly specify what driver to use and how to access it (base address, optionally access_type). Make this easier by just having barebox fix up the needed information when $global.bootm.earlycon is true and the barebox serial driver provides the needed information. If the serial driver doesn't, a plain "earlycon" parameter will be fixed up. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220523092526.791716-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/arm'Sascha Hauer2022-06-292-1/+9
|\ \ \
| * | | filetype: differentiate between STM32MP FSBL and SSBL imagesAhmad Fatoum2022-06-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have some special handling for legacy (non-FIP) STM32 images: We have a bootm handler for chainloading and an update handler for use with GPT ssbl partitions. Both aren't applicable to the TF-A image used as FSBL. As barebox always has 0x00000000 at offset 0xfc and TF-A alrways has 0x10000000, we can use that to differentiate between the two images to make sure we refuse TF-A images when barebox images are expected. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | bbu: export bbu_std_file_handler for use in custom handlersAhmad Fatoum2022-06-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bbu_register_std_file_update() registers an update handler that updates a single file, usually a partition. Depending on SoC, we may want to compute the file path at install time. To save custom bbu code the hassle of reimplementing bbu_std_file_handler(), export it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | bbu: add flag for enabling eMMC boot ackAhmad Fatoum2022-06-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bbu_mmcboot_handler() already takes care to switch $mmc.boot to the freshly read inactive partition. On some SoCs like the STM32MP1, this is not enough, but the boot ack bit must be set as well, so the BootROM can communicate with the eMMC. Have this happen as part of the eMMC boot switch after a successful update if bbu_data::flags has BBU_FLAG_MMC_BOOT_ACK set. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | bbu: move barebox_update eMMC boot handling into common codeAhmad Fatoum2022-06-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like with the i.MX, the STM32MP1 BootROM also consults the EXT_CSD_PARTITION_CONFIG register to find out what to boot. The barebox_update code used for atomic update on i.MX is thus useful to the STM32MP as well, so move the boot switching part to a generic location. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | ddr: imx8m: workaround old spreadsheets not initializing ADDRMAP7Ahmad Fatoum2022-06-271-0/+1
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Older NXP DDR spreadsheets don't initialize ADDRMAP7, leaving it at its POR default of zero. Now that barebox looks at ADDRMAP7 to be able to correctly detect bigger memory sizes, barebox proper on out-of-tree boards with older spreadsheets may read back 4x times as much RAM as actually fitted. Work around this by writing a trailing 0xf0f (the neutral ignore-me value for the register) if the register wasn't written through dram_timing_info::ddrc_cfg. We consider this safe to do, because the DDRC is held in reset while these values are programmed. Fixes: dad2b5636bd8 ("ARM: imx: Add imx8 support for 18 bit SDRAM row size handle") Fixes: 6cf197fa61f9 ("arm: imx: mmdc_size: Increase row_max for imx8m") Tested-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220623130717.1447999-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | gui: image_renderer: Fix empty prototype for image_renderer_image()Alexander Shiyan2022-06-101-1/+4
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In file included from lib/gui/png.c:9: include/gui/image_renderer.h: In function 'image_renderer_file': include/gui/image_renderer.h:67:29: warning: passing argument 1 of 'image_renderer_image' from incompatible pointer type [-Wincompatible-pointer-types] ret = image_renderer_image(sc, s, img); include/gui/image_renderer.h:56:42: note: expected 'struct surface *' but argument is of type 'struct screen *' int image_renderer_image(struct surface *s, struct image *img); include/gui/image_renderer.h:67:33: warning: passing argument 2 of 'image_renderer_image' from incompatible pointer type [-Wincompatible-pointer-types] ret = image_renderer_image(sc, s, img); include/gui/image_renderer.h:56:59: note: expected 'struct image *' but argumentis of type 'struct surface *' int image_renderer_image(struct surface *s, struct image *img); include/gui/image_renderer.h:67:8: error: too many arguments to function 'image_renderer_image' ret = image_renderer_image(sc, s, img); include/gui/image_renderer.h:56:5: note: declared here int image_renderer_image(struct surface *s, struct image *img); Fixes: 3fa8d74abea3 ("gui: introduce screen and surface to factorize and simplify code") Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220610054051.4911-4-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Add missing inline for stub functionSascha Hauer2022-06-081-1/+1
|/ | | | | | Add missing inline to of_prepend_machine_compatible() wrapper. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rsa'Sascha Hauer2022-05-191-1/+6
|\
| * rsa: Add iterator for rsa keysSascha Hauer2022-05-041-0/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * rsa: Collect keys on listSascha Hauer2022-05-041-1/+2
| | | | | | | | | | | | | | | | Currently there is no way to iterate over all available RSA keys. This patch collects all keys on a list so we can add an iterator in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/of-board'Sascha Hauer2022-05-192-0/+12
|\ \
| * | of: add generic of_prepend_machine_compatible()Oleksij Rempel2022-05-052-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Add generic function to extend/fixup machine compatible. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220503091220.3871612-4-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: add $global.serial_number with device tree fixupAhmad Fatoum2022-05-051-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | This new variable can be set by boards from C code or from the environment to change the serial number fixed up into the kernel device tree. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220503091220.3871612-2-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2022-05-192-0/+50
|\ \ | |/ |/|
| * ata: disk_ata_drive: clean up code in ata_dump_id()Denis Orlov2022-04-291-0/+5
| | | | | | | | | | | | | | | | Add missing macros and fix misspellings. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20220426123434.18865-1-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * video: omap-fb: Rework to enable COMPILE_TEST optionAlexander Shiyan2022-04-251-0/+45
| | | | | | | | | | | | | | | | | | | | | | To add a compilation check for the omap-fb driver, move the omap-fb.h header to a global location. The "omap_add_display" function is used only for legacy boards, so we will move it to a common place for such calls (omap_devices.c). Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220422071158.14631-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2022-04-212-0/+2
|\|
| * libfile: implement new pread_fullAhmad Fatoum2022-03-281-0/+1
| | | | | | | | | | | | | | | | We already have pwrite_full, add pread_full for symmetry. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220318144942.498124-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * gpio: include header for BIT() used in <gpio.h>Ahmad Fatoum2022-03-281-0/+1
| | | | | | | | | | | | | | | | | | e.g. GPIOF_ACTIVE_HIGH/LOW uses currently depend on another header defining BIT(). Remedy this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220321111115.1569232-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/dsa'Sascha Hauer2022-04-219-3/+1871
|\ \
| * | add ethlog commandOleksij Rempel2022-04-191-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is kind of tcpdump or tshark for barebox. Instead of starting application it will let barebox dump everything to the console by still allowing to use other application. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-15-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | hexdump: provide support for dev_print_hex_dump()Oleksij Rempel2022-04-191-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases we need to know the interface name of dumped hex. So, provide optional device_d pointer and use it to get device name. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-14-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: dsa: add KSZ9477 switch SPI driverOleksij Rempel2022-04-141-0/+1665
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for Microchip KSZ9477 switch. With this driver we will be able to use KSZ9477 switch as port multiplexer. This driver is partially based on u-boot v2022.04-rc5: drivers/net/ksz9477.c and on the kernel v5.17 code: drivers/net/dsa/microchip/ksz9477.c Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-13-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of_net: add rev-rmii supportOleksij Rempel2022-04-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for the revert RMII device tree property. It is needed for SJA1105 switch driver. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-11-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: mdio: add MDIO_DEVAD_NONE defineOleksij Rempel2022-04-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We need it for SJA11xx driver. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-9-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | spi: port spi_sync_transfer() function from kernel v5.17Oleksij Rempel2022-04-141-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | This function is needed for SJA11xx switch driver Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-8-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: port part of if_vlan header from kernel v5.17Oleksij Rempel2022-04-141-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | This header is needed for SJA11xx switch driver Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-7-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | driver: add dev_get_priv() helperOleksij Rempel2022-04-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add dev_get_priv() to make driver porting easier. Needed for SJA11xx switch driver. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-6-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: add DSA framework to support basic switch functionalityOleksij Rempel2022-04-141-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add DSA based port multiplexing functionality for barebox. With this framework we will be able to use different ports of as switch separately. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-5-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: phy: export of_phy_register_fixed_link() functionOleksij Rempel2022-04-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We will need this function by DSA framework Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-4-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: add of_find_eth_device_by_node() functionOleksij Rempel2022-04-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | For DSA support we need to find MAC node by phandle from the switch port node. So, provide of_find_eth_device_by_node() to solve this task. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-3-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | net: add RX preprocessor supportOleksij Rempel2022-04-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add callback for optional rx_preprocessor. This is needed to add DSA switch support and demultiplex traffic received from different switch ports. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-2-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | mtd: peb: Add mtd_peb_read_file()Sascha Hauer2022-04-211-0/+2
|/ / | | | | | | | | | | Analog to mtd_peb_write_file() this adds a mtd_peb_read_file() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: mass-storage: reference count allocations used in bthreadAhmad Fatoum2022-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 997cca0f15dc ("bthread: replace blocking bthread_stop with nonblocking bthread_cancel"), the bthread may survive longer than the multigadget unbind. This didn't cause issues so far, because the multi gadget unbind didn't call usb_put_function[_instance] for mass-storage (but did so for other functions), so we just leaked the memory. In preparation for fixing the memory leak, we will need to straighten out the mass storage cleanup. We do so by reference counting the two shared structures: If bthread runs before usb_put_function[_instance], it will not free them yet (avoiding a double free) and if bthread runs after usb_put_function[_instance], it will still be able to access them (avoiding a use-after-free). A cleaner way would've been to wait for bthread completion, but we can't do that here, because gadget could be unbound in a poller and bthreads are only scheduled in command context. Fixes: 997cca0f15dc ("bthread: replace blocking bthread_stop with nonblocking bthread_cancel") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220319110246.2850396-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>