U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: "Simon Glass" <sjg@chromium.org>,
	e@freeshell.de,
	"Rayagonda Kokatanur" <rayagonda.kokatanur@broadcom.com>,
	"Tang Yuantian" <andy.tang@nxp.com>,
	"Mingkai Hu" <mingkai.hu@nxp.com>,
	"Ashish Kumar" <Ashish.Kumar@nxp.com>,
	"Priyanka Jain" <priyanka.jain@nxp.com>,
	"Wasim Khan" <wasim.khan@nxp.com>,
	"Udit Agarwal" <udit.agarwal@nxp.com>,
	"Meenakshi Aggarwal" <meenakshi.aggarwal@nxp.com>,
	"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
	"Patrice Chotard" <patrice.chotard@foss.st.com>,
	"Manish Tomar" <Manish.Tomar@nxp.com>,
	"Mathew McBride" <matt@traverse.com.au>,
	"Caleb Connolly" <caleb.connolly@linaro.org>,
	"Tien Fong Chee" <tien.fong.chee@altera.com>,
	"Michal Simek" <michal.simek@amd.com>,
	"Sumit Garg" <sumit.garg@kernel.org>,
	"Patrick Rudolph" <patrick.rudolph@9elements.com>,
	"Alif Zakuan Yuslaimi" <alif.zakuan.yuslaimi@intel.com>,
	"Oliver Gaskell" <Oliver.Gaskell@analog.com>,
	"Duje Mihanović" <duje.mihanovic@skole.hr>,
	"Robert Marko" <robert.marko@sartura.hr>,
	"Lukas Funke" <lukas.funke@weidmueller.com>,
	"Peng Fan" <peng.fan@nxp.com>,
	"Wei Ming Chen" <jj251510319013@gmail.com>,
	"Adriano Cordova" <adrianox@gmail.com>,
	"Sughosh Ganu" <sughosh.ganu@linaro.org>,
	"Vincent Stehlé" <vincent.stehle@arm.com>,
	"Raymond Mao" <raymond.mao@linaro.org>,
	"Maks Mishin" <maks.mishinfz@gmail.com>,
	"Sam Protsenko" <semen.protsenko@linaro.org>,
	u-boot@lists.denx.de, uboot-stm32@st-md-mailman.stormreply.com,
	"Mark Kettenis" <mark.kettenis@xs4all.nl>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>
Subject: Re: [PATCH] efi_loader: remove EFI_BOUNCE_BUFFER
Date: Fri, 28 Mar 2025 10:25:39 -0600	[thread overview]
Message-ID: <20250328162539.GC93000@bill-the-cat> (raw)
In-Reply-To: <2c9efc39-b0b9-41e7-b42e-1d026bc286a7@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 5322 bytes --]

On Fri, Mar 28, 2025 at 05:17:36PM +0100, Heinrich Schuchardt wrote:
> On 28.03.25 17:04, Tom Rini wrote:
> > On Fri, Mar 28, 2025 at 02:26:39PM +0200, Ilias Apalodimas wrote:
> > > On Fri, 28 Mar 2025 at 13:34, Simon Glass <sjg@chromium.org> wrote:
> > > > 
> > > > Hi Ilias,
> > > > 
> > > > On Thu, 27 Mar 2025 at 15:19, Ilias Apalodimas
> > > > <ilias.apalodimas@linaro.org> wrote:
> > > > > 
> > > > > Hi Simon
> > > > > 
> > > > > On Thu, 27 Mar 2025 at 15:33, Simon Glass <sjg@chromium.org> wrote:
> > > > > > 
> > > > > > Hi Ilias,
> > > > > > 
> > > > > > On Wed, 26 Mar 2025 at 02:37, Ilias Apalodimas
> > > > > > <ilias.apalodimas@linaro.org> wrote:
> > > > > > > 
> > > > > > > Hi Heinrich,
> > > > > > > 
> > > > > > > On Mon, 24 Mar 2025 at 19:50, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> > > > > > > > 
> > > > > > > > On 17.03.25 14:38, Ilias Apalodimas wrote:
> > > > > > > > 
> > > > > > > > %s/EFI_BOUNCE_BUFFER/CONFIG_EFI_LOADER_BOUNCE_BUFFER/
> > > > > > > > 
> > > > > > > > > The EFI subsystem defines its own bounce buffer for devices that
> > > > > > > > > can't transfer data > 4GB. U-Boot already has a generic BOUNCE_BUFFER
> > > > > > > > > which can be reused instead of defining another symbol.
> > > > > > > > > The only limitation for EFI is that we don't know how big the file a user
> > > > > > > > > chooses to transfer is and as a result we can't depend on allocating the
> > > > > > > > > memory from the malloc area, which can prove too small.
> > > > > > > > > 
> > > > > > > > > So allocate an EFI buffer of the correct size and pass it to the DM,
> > > > > > > > > which already supports bounce buffering via bounce_buffer_start_extalign()
> > > > > > > > 
> > > > > > > > Looking at
> > > > > > > > 
> > > > > > > >       if (IS_ENABLED(CONFIG_BOUNCE_BUFFER) && desc->bb) {
> > > > > > > > 
> > > > > > > > in drivers/block/blk-uclass.c the bounce buffer has to be explicitly
> > > > > > > > enabled by the device driver. Only the scsi drivers sets bb = true.
> > > > > > > > 
> > > > > > > > Cf. 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag
> > > > > > > > to blk_desc")
> > > > > > > > 
> > > > > > > > Which device-drivers of the boards mentioned below do actually need
> > > > > > > > bounce buffering?
> > > > > > > 
> > > > > > > Unfortunately, I don't have any of the hardware to test and I havent
> > > > > > > worked with that platform much.
> > > > > > > That 'bb' variable and the fact that EFI needs bigger allocations is
> > > > > > > why I ended up allocationg properly aligned memory from the EFI
> > > > > > > subsystem. But as Mark pointed out, the cache flush is a no go for
> > > > > > > now, so I'll drop this and see if I find time to rework the bounce
> > > > > > > buffer logic overall
> > > > > > 
> > > > > > There was quite a bit of discussion about all this in the context of
> > > > > > my attempt to just add a message to warn the user[1]
> > > > > > 
> > > > > > We might consider adding an event to reserve memory before relocation,
> > > > > > along with a way to discover (in board_r) where the memory was
> > > > > > allocated. That would make the solution more generic.
> > > > > 
> > > > > I am not sure what you are trying to solve here. The EFI bounce buffer
> > > > > after the LMB patches can't overwrite memory, nor can it be
> > > > > overwritten.
> > > > 
> > > > I am thinking of we can create a single implementation of the
> > > > bouncebuf logic which also works for EFI.
> > > > 
> > > > I think the two sane things to do are:
> > > > - restrict U-Boot to using memory below 4GB for platforms which have
> > > > the DMA limitation
> > > 
> > > You don't need that. The bounce buf code has a callback you can use to
> > > define the limitations
> > > 
> > > > - create (in board_f) a special region below 4GB for use with the
> > > > bouncebuf logic
> > > 
> > > The only problem with EFI is that you don't know how much memory it
> > > needs and we can't use the existing memalign calls. So if we replace
> > > that memalign in the bounce buffer code, with an lmb reservation we
> > > have everything we need.
> > 
> > It's not even an EFI problem is it? You could hit the same problem
> > reading a file from a filesystem outside of EFI too. These specific
> > SoCs just aren't heavily exercised is one of the challenges I think and
> > so it's possible that we have a few things to yet improve in the
> > bounce buffer code (which was added for other SoCs and done as generic
> > enough starting point for others).
> > 
> 
> EFI or LMB allocate memory top down. So EFI applications have a good
> chance of loading files into high memory. Other file-system operations
> typically use predefined addresses line $loadaddr. This is why the
> problem became more visible in EFI.
> 
> It is evident that the bounce-buffer functionality is not EFI specific
> per se.

Right. But it's not the destination address we're talking about but
rather that for "fun" system design reasons we need to have the storage
IP block read from device to one address and then bounce it over to the
final address. Or have I missed understood which kind of bounce buffer
we're needing something here for?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2025-03-28 16:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17 13:38 [PATCH] efi_loader: remove EFI_BOUNCE_BUFFER Ilias Apalodimas
2025-03-17 16:18 ` Mark Kettenis
2025-03-17 19:06   ` Ilias Apalodimas
2025-03-23 21:51     ` Mark Kettenis
2025-03-24 17:50 ` Heinrich Schuchardt
2025-03-26  8:36   ` Ilias Apalodimas
2025-03-27 13:33     ` Simon Glass
2025-03-27 21:19       ` Ilias Apalodimas
2025-03-28 11:34         ` Simon Glass
2025-03-28 12:26           ` Ilias Apalodimas
2025-03-28 16:04             ` Tom Rini
2025-03-28 16:17               ` Heinrich Schuchardt
2025-03-28 16:25                 ` Tom Rini [this message]
2025-03-28 17:15               ` Mark Kettenis
2025-03-29  9:05                 ` Ilias Apalodimas

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=20250328162539.GC93000@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=Ashish.Kumar@nxp.com \
    --cc=Manish.Tomar@nxp.com \
    --cc=Oliver.Gaskell@analog.com \
    --cc=adrianox@gmail.com \
    --cc=alif.zakuan.yuslaimi@intel.com \
    --cc=andy.tang@nxp.com \
    --cc=caleb.connolly@linaro.org \
    --cc=duje.mihanovic@skole.hr \
    --cc=e@freeshell.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jj251510319013@gmail.com \
    --cc=lukas.funke@weidmueller.com \
    --cc=maks.mishinfz@gmail.com \
    --cc=mark.kettenis@xs4all.nl \
    --cc=matt@traverse.com.au \
    --cc=meenakshi.aggarwal@nxp.com \
    --cc=michal.simek@amd.com \
    --cc=mingkai.hu@nxp.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=patrick.rudolph@9elements.com \
    --cc=peng.fan@nxp.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=raymond.mao@linaro.org \
    --cc=robert.marko@sartura.hr \
    --cc=semen.protsenko@linaro.org \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=sumit.garg@kernel.org \
    --cc=tien.fong.chee@altera.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.com \
    --cc=udit.agarwal@nxp.com \
    --cc=vincent.stehle@arm.com \
    --cc=wasim.khan@nxp.com \
    --cc=xypron.glpk@gmx.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