Re: [PATCH] common: state: check length

2019-05-22 Thread Sascha Hauer
On Tue, May 21, 2019 at 04:44:13PM +0200, Jan Remmet wrote: > if written_length is read from a partial written bucket it may be to > big and xmalloc will panic barebox. > > Check if the value is sane. > > Signed-off-by: Jan Remmet > --- > common/state/backend_bucket_direct.c | 4 > 1 file

[PATCH] images: remove forgotten occurences of *.imx-sram-img

2019-05-22 Thread Ulrich Ölmann
Starting with commit 5a1a5ed2537d ("ARM: images: use piggydata") this file type is not known anymore, so clean up. Signed-off-by: Ulrich Ölmann --- images/.gitignore | 1 - images/Makefile | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/images/.gitignore b/images/.gitigno

[PATCH] Documentation: imx8mq-evk: collapse BMOD switch superposition

2019-05-22 Thread Ahmad Fatoum
Table 3. Boot mode setting in the user's guide[1] lists 0010 as 'Boot from EMMC'. Adjust diagram accordingly. [1]: https://www.mouser.com/ds/2/302/IMX8MDQLQEVKHUG-1280333.pdf Signed-off-by: Ahmad Fatoum --- Documentation/boards/imx/nxp-imx8mq-evk.rst | 2 +- 1 file changed, 1 insertion(+), 1 de

[PATCH v3] ARM: Initial OP-TEE support

2019-05-22 Thread Rouven Czerwinski
From: Sascha Hauer This adds initial support for OP-TEE, see https://www.op-tee.org/ barebox starts in secure mode as usual. When booting a kernel the bootm code also loads the optee_os binary. Instead of jumping into the kernel barebox jumps into the optee_os binary and puts the kernel executio

[PATCH 16/18] usb: host: ehci: Treat ehci->qh_list as an array

2019-05-22 Thread Andrey Smirnov
Since ehci->qh_list is an array, convert the code to use ehci->qh_list[0] to access its first element to make things a bit more clear. No functional change intended. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-

[PATCH 15/18] usb: host: ehci: Drop explicit memset() in ehci_init()

2019-05-22 Thread Andrey Smirnov
Memory allocated by dma_alloc_coherent() is already zeroed out, ehci->qh_list[0] never changes during the operation of the driver and ehci->qh_list[1] will be explicitly initialized by ehci_submit_async() so this additional memset() shouldn't be necessary. Signed-off-by: Andrey Smirnov --- drive

[PATCH 10/18] usb: host: ehci: Simplify ehci_submit_async()'s epilogue

2019-05-22 Thread Andrey Smirnov
Re-organize the epilogue of ehci_submit_async() to bail out early if token is still marked as "active" and drop no longer necessary check for "dev->status != USB_ST_NOT_PROC". While at it return -EIO instead of -1 in the case of error. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.

[PATCH 14/18] usb: host: ehci: Replace explicit printf() with dev_err()

2019-05-22 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a6f497925..050a3166e 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hc

[PATCH 17/18] ush: host: ehci: Simplify QH initialization in ehci_submit_async()

2019-05-22 Thread Andrey Smirnov
We use a fixed circular list for asynchronous schedule that never changes, so if we drop an explicit memset() that zeros out an entire struct and replace it with code initializine all of the fields explicitly, we can set QH list once in ehci_init() and never touch it again. While at it move qt_alt

[PATCH 11/18] usb: host: ehci: Drop needless assignments in ehci_submit_async()

2019-05-22 Thread Andrey Smirnov
Neither of those is necessary, since both will be overwritten further down in the code. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 7194a48c0..0

[PATCH 12/18] usb: host: ehci: Use bool to simplify ehci_submit_async()

2019-05-22 Thread Andrey Smirnov
Change the type of 'c' to bool and drop the trigrah. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 03ab56b30..f0d899e82 100644 --- a/drivers/u

[PATCH 04/18] usb: host: ehci: Replace magic number with macros

2019-05-22 Thread Andrey Smirnov
Import a number of missing macros from U-Boot and convert ehci-hcd to use them instead of explicitly specifying magic shifts. No functional change intended. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 96 + drivers/usb/host/ehci.h | 49

[PATCH 18/18] usb: host: ehci: Allocate only NUM_QH queue heads for qh_list

2019-05-22 Thread Andrey Smirnov
Use NUM_QH, not NUM_TD to specify allocation size. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b336164f6..f3be177ce 100644 --- a/drivers/usb/host/

[PATCH 08/18] usb: host: ehci: Simplify ehci_td_buffer()

2019-05-22 Thread Andrey Smirnov
Rework the code of ehci_td_buffer() with following trivial changes: * Switch to using dma_addr_t for 'delta' and 'next' * Convert while to for loop * Replace explicit magic number with dedicated contants derived via ARRAY_SIZE * Use ALIGN_DOWN to calculate 'next' * Return

[PATCH 13/18] usb: host: ehci: Add a comment explaing IOC setting for data

2019-05-22 Thread Andrey Smirnov
Add a comment explaining the rationale behinde QT_TOKEN_IOC(req == NULL). Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f0d899e82..a6f497925 100644 --- a/d

[PATCH 06/18] usb: host: ehci: Introduce ehci_prepare_qtd()

2019-05-22 Thread Andrey Smirnov
Move shared struct qTD initialization code into a subroutine and convert the rest of the code to use it. No functional change intended. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 66 - 1 file changed, 35 insertions(+), 31 deletions(-) dif

[PATCH 02/18] usb: host: ehci: Share code to enable/disable async schedule

2019-05-22 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 39 +++-- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 54ab32830..4ccaec743 100644 --- a/drivers/usb/host/ehci-hcd.c +

[PATCH 09/18] usb: host: ehci: Initialize qTDs explicitly

2019-05-22 Thread Andrey Smirnov
Convert the code to initialize only used qTDs as well as initializing all of the fields explicitly without doing a wholesale memset() first. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehc

[PATCH 00/18] EHCI improvements

2019-05-22 Thread Andrey Smirnov
Everyone: This series is a number of improvements (or so I though) I made while woring with USB on i.MX6. All of the patches are optional, so if some of the changes don't seem like an improvmement they can be dropped. Feedback is welcome! Thanks, Andrey Smirnov Andrey Smirnov (18): usb: host:

[PATCH 05/18] usb: host: ehci: Drop unnecessary cleanup code

2019-05-22 Thread Andrey Smirnov
This looks like a leftover from U-Boot. Analogous code there would walk all qTDs and call ehci_free() on each one of them, but since we don't have anything of the sort it seems the whole loop can be dropped. Note that U-Boot dropped that code in de98e8b22a10676fd226318c92a9be7f519208ca Signed-off-

[PATCH 07/18] usb: host: ehci: Simplify qTD buffer synchronization

2019-05-22 Thread Andrey Smirnov
Only two buffers ever need to be sychronized and DMA direction of it is always known based on the type of request we are processing. Simplify the code by moving synchronization to be a part of ehci_prepare_qtd(). While at it convert the code to use dma_map_single() API. Signed-off-by: Andrey Smirn

[PATCH 01/18] usb: host: ehci: Do not zero out DMA coherent memory

2019-05-22 Thread Andrey Smirnov
Memory returned by dma_alloc_coherent() should already be zeroed out, so there's no need to do this explicitly. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 87af9

[PATCH 2/3] usb: storage: Default to a single LUN

2019-05-22 Thread Andrey Smirnov
For loop below is: for (lun=0; lun<=us->max_lun; lun++) ... so we need to set max_lun to 0 in order to default to having only one LUN. Otherwise, we end up assuming the device has 2 valid LUNs. Signed-off-by: Andrey Smirnov --- drivers/usb/storage/usb.c | 2 +- 1 file chang

[PATCH 03/18] usb: host: ehci: Use to USBSTS to wait for transfer completion

2019-05-22 Thread Andrey Smirnov
Since we already set up our last qTD to have IOC flag set we may as well take advange of that and poll USBSTS to wait for transfer completion. Doesn't change much, but allows us to drop a custom polling loop and re-use handshake() instead. Signed-off-by: Andrey Smirnov --- drivers/usb/host/ehci-

[PATCH 3/3] usb: storage: Fix TEST_UNIT_READY command size

2019-05-22 Thread Andrey Smirnov
TEST_UNIT_READY is 6 bytes long instead of 12. Fix it. Signed-off-by: Andrey Smirnov --- drivers/usb/storage/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 79561ee6f..63d624e91 100644 --- a/drivers/usb/storage

[PATCH 1/3] usb: storage: Zero CDB out before sending it

2019-05-22 Thread Andrey Smirnov
Since cbw.Length can be less that sizeof(cbw.CDB), add code to zero the whole struct out to avoid sending random stack data as a part of payload. There's no known case where this causes a problem, but it's a reasonable thing to do anyway. Signed-off-by: Andrey Smirnov --- drivers/usb/storage/tra