From: Marek Vasut <marex@denx.de>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Bin Meng <bmeng.cn@gmail.com>
Cc: Caleb Connolly <caleb.connolly@linaro.org>,
u-boot-qcom@groups.io, u-boot@lists.denx.de
Subject: Re: [PATCH v4 2/3] usb: dwc3: fix dcache flush range calculation
Date: Sat, 12 Oct 2024 05:37:37 +0200 [thread overview]
Message-ID: <2eaba59e-bc6d-4ffc-b4eb-0eebc0b090a9@denx.de> (raw)
In-Reply-To: <20241011-u-boot-dwc3-gadget-dcache-fixup-v4-2-5f3498d8035b@linaro.org>
On 10/11/24 4:38 PM, Neil Armstrong wrote:
> The current flush operation will omit doing a flush/invalidate on
> the first and last bytes if the base address and size are not aligned
> with CACHELINE_SIZE.
>
> This causes operation failures Qualcomm platforms.
>
> Take in account the alignment and size of the buffer and also
> flush the previous and last cacheline.
>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> drivers/usb/dwc3/io.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h
> index 04791d4c9be..0ede323671b 100644
> --- a/drivers/usb/dwc3/io.h
> +++ b/drivers/usb/dwc3/io.h
> @@ -50,6 +50,9 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
>
> static inline void dwc3_flush_cache(uintptr_t addr, int length)
> {
> - flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE));
> + uintptr_t start_addr = (uintptr_t)addr & ~(CACHELINE_SIZE - 1);
> + uintptr_t end_addr = ALIGN((uintptr_t)addr + length, CACHELINE_SIZE);
> +
> + flush_dcache_range((unsigned long)start_addr, (unsigned long)end_addr);
> }
> #endif /* __DRIVERS_USB_DWC3_IO_H */
You likely want a max(CONFIG_SYS_CACHELINE_SIZE,
dwc3-buffer-alignment-requirement) to really correctly align the buffer.
next prev parent reply other threads:[~2024-10-12 3:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 14:38 [PATCH v4 0/3] dwc3: gadget: properly fix cache operations Neil Armstrong
2024-10-11 14:38 ` [PATCH v4 1/3] usb: dwc3: allocate setup_buf with dma_alloc_coherent() Neil Armstrong
2024-10-11 14:38 ` [PATCH v4 2/3] usb: dwc3: fix dcache flush range calculation Neil Armstrong
2024-10-12 3:37 ` Marek Vasut [this message]
2024-10-13 16:35 ` Neil Armstrong
2024-10-13 20:37 ` Marek Vasut
2024-10-11 14:38 ` [PATCH v4 3/3] usb: dwc3: invalidate dcache on buffer used in interrupt handling Neil Armstrong
2024-10-13 20:38 ` Marek Vasut
2024-12-28 13:46 ` Ahmad Fatoum
2024-12-30 10:35 ` Neil Armstrong
2024-12-30 18:49 ` Ahmad Fatoum
2024-10-15 9:06 ` [PATCH v4 0/3] dwc3: gadget: properly fix cache operations Mattijs Korpershoek
2024-10-21 23:31 ` Tom Rini
2024-10-22 9:10 ` Mattijs Korpershoek
2024-10-22 14:19 ` 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=2eaba59e-bc6d-4ffc-b4eb-0eebc0b090a9@denx.de \
--to=marex@denx.de \
--cc=bmeng.cn@gmail.com \
--cc=caleb.connolly@linaro.org \
--cc=lukma@denx.de \
--cc=mkorpershoek@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot-qcom@groups.io \
--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