All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janne Grunau <janne@jannau.net>
To: Sughosh Ganu <sughosh.ganu@linaro.org>
Cc: u-boot@lists.denx.de, "Simon Glass" <sjg@chromium.org>,
	"Tom Rini" <trini@konsulko.com>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Marek Vasut" <marex@denx.de>,
	"Mark Kettenis" <mark.kettenis@xs4all.nl>,
	"Michal Simek" <michal.simek@amd.com>,
	"Patrick DELAUNAY" <patrick.delaunay@foss.st.com>,
	"Patrice CHOTARD" <patrice.chotard@foss.st.com>,
	"Marek Behún" <kabel@kernel.org>,
	asahi@lists.linux.dev
Subject: Re: [PATCH v4 05/27] lmb: make LMB memory map persistent and global
Date: Mon, 28 Oct 2024 22:20:38 +0100	[thread overview]
Message-ID: <ZyAAJsnV4uz2Btwy@robin> (raw)
In-Reply-To: <20240826115940.3233167-6-sughosh.ganu@linaro.org>

On Mon, Aug 26, 2024 at 05:29:18PM +0530, Sughosh Ganu wrote:
> The current LMB API's for allocating and reserving memory use a
> per-caller based memory view. Memory allocated by a caller can then be
> overwritten by another caller. Make these allocations and reservations
> persistent using the alloced list data structure.
> 
> Two alloced lists are declared -- one for the available(free) memory,
> and one for the used memory. Once full, the list can then be extended
> at runtime.
> 
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> [sjg: Optimise the logic to add a region in lmb_add_region_flags()]
> [sjg: Use a stack to store pointer of lmb struct when running lmb tests]
> ---
> Changes since V3:
> * Fix checkpatch warnings of spaces between function name and
>   open parantheses.
> * s/uint64_t/u64 as suggested by checkpatch.
> * Remove unneccessary parantheses in lmb.c as suggested by checkpatch.
> * Fix alignment in test/cmd/bdinfo.c as suggested by checkpatch.

[...]
 
>  drivers/iommu/apple_dart.c           |   8 +-

[...]

> diff --git a/drivers/iommu/apple_dart.c b/drivers/iommu/apple_dart.c
> index 9327dea1e3..611ac7cd6d 100644
> --- a/drivers/iommu/apple_dart.c
> +++ b/drivers/iommu/apple_dart.c
> @@ -70,7 +70,6 @@
>  
>  struct apple_dart_priv {
>  	void *base;
> -	struct lmb lmb;
>  	u64 *l1, *l2;
>  	int bypass, shift;
>  
> @@ -124,7 +123,7 @@ static dma_addr_t apple_dart_map(struct udevice *dev, void *addr, size_t size)
>  	off = (phys_addr_t)addr - paddr;
>  	psize = ALIGN(size + off, DART_PAGE_SIZE);
>  
> -	dva = lmb_alloc(&priv->lmb, psize, DART_PAGE_SIZE);
> +	dva = lmb_alloc(psize, DART_PAGE_SIZE);
>  
>  	idx = dva / DART_PAGE_SIZE;
>  	for (i = 0; i < psize / DART_PAGE_SIZE; i++) {
> @@ -160,7 +159,7 @@ static void apple_dart_unmap(struct udevice *dev, dma_addr_t addr, size_t size)
>  			   (unsigned long)&priv->l2[idx + i]);
>  	priv->flush_tlb(priv);
>  
> -	lmb_free(&priv->lmb, dva, psize);
> +	lmb_free(dva, psize);
>  }
>  
>  static struct iommu_ops apple_dart_ops = {
> @@ -213,8 +212,7 @@ static int apple_dart_probe(struct udevice *dev)
>  	priv->dvabase = DART_PAGE_SIZE;
>  	priv->dvaend = SZ_4G - DART_PAGE_SIZE;
>  
> -	lmb_init(&priv->lmb);
> -	lmb_add(&priv->lmb, priv->dvabase, priv->dvaend - priv->dvabase);
> +	lmb_add(priv->dvabase, priv->dvaend - priv->dvabase);

no. This breaks everything. apple_dart is an iommu and used struct lmb
to manage the IO virtual address space. This has nothing to do
with system memory.
Depending on the allocation strategy this will cause all sorts of
problems since the IO and the physical memory address space does not
overlap on apple silicon devices. IOVA is for many devices only 32-bit
but physical memory starts at 0x10_0000_0000 or 0x100_0000_0000.
Every device has its own iommu / IOVA space so sharing the space between
all of them is another problem. I'd assume only theoretical due to the
limited driver support and memory use in u-boot.

My current plan to fix this is to resurrect the old lmb code under a
different name.

Not sure about the same change in sandbox_iommu but I guess it could be
ok as there is no sandbox.

Janne

  parent reply	other threads:[~2024-10-28 21:20 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 11:59 [PATCH v4 00/27] Make LMB memory map global and persistent Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 01/27] alist: add a helper to check if the list is full Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 02/27] lmb: remove the unused lmb_is_reserved() function Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 03/27] lmb: staticize __lmb_alloc_base() Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 04/27] lmb: use the BIT macro for lmb flags Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 05/27] lmb: make LMB memory map persistent and global Sughosh Ganu
2024-09-16  6:04   ` Vaishnav Achath
2024-09-16  6:32     ` Sughosh Ganu
     [not found]   ` <65996987-dda0-4396-8624-1fbe1307facf@ti.com>
2024-09-16  6:29     ` Sughosh Ganu
2024-09-16  8:38       ` Vaishnav Achath
2024-09-16  9:16         ` Sughosh Ganu
2024-09-16 16:48           ` Vaishnav Achath
2024-09-16 18:11             ` Sughosh Ganu
2024-09-16  9:29         ` Sughosh Ganu
2024-10-28 21:20   ` Janne Grunau [this message]
2024-10-28 23:11     ` Tom Rini
2024-10-29  3:49     ` Sughosh Ganu
2024-10-29  4:32       ` Sughosh Ganu
2024-10-29  6:45         ` Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 06/27] lmb: allow for resizing lmb regions Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 07/27] lmb: remove config symbols used for lmb region count Sughosh Ganu
2024-08-27  6:24   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 08/27] lmb: config: add lmb config symbols for SPL Sughosh Ganu
2024-08-27  6:24   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 09/27] lmb: allow lmb module to be used in SPL Sughosh Ganu
2024-08-27  6:25   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 10/27] lmb: introduce a function to add memory to the lmb memory map Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 11/27] lmb: reserve common areas during board init Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 12/27] lmb: remove the lmb_init_and_reserve() function Sughosh Ganu
2024-08-27  6:26   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 13/27] lmb: remove lmb_init_and_reserve_range() function Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 14/27] lmb: bootm: remove superfluous lmb stub functions Sughosh Ganu
2024-08-27  6:27   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 15/27] lmb: init: initialise the lmb data structures during board init Sughosh Ganu
2024-08-27  6:27   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 16/27] ppc: lmb: move arch specific lmb reservations to arch_misc_init() Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 17/27] lmb: do away with arch_lmb_reserve() Sughosh Ganu
2024-08-27  6:34   ` Ilias Apalodimas
2024-08-26 11:59 ` [PATCH v4 18/27] lmb: remove the unused board_lmb_reserve() function Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 19/27] sandbox: move the TCG event log to the start of ram memory Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 20/27] spl: call spl_board_init() at the end of the spl init sequence Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 21/27] spl: sandbox: initialise the ram banksize in spl Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 22/27] sandbox: spl: enable lmb config for SPL Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 23/27] sandbox: iommu: remove lmb allocation in the driver Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 24/27] zynq: lmb: do not add to lmb map before relocation Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 25/27] stm32mp: allow calling optee_get_reserved_memory() from U-Boot Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 26/27] stm32mp: compute ram_top based on the optee base address Sughosh Ganu
2024-08-26 11:59 ` [PATCH v4 27/27] lmb: add logic to print lmb flag strings Sughosh Ganu
2024-09-04  0:20 ` [PATCH v4 00/27] Make LMB memory map global and persistent 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=ZyAAJsnV4uz2Btwy@robin \
    --to=janne@jannau.net \
    --cc=asahi@lists.linux.dev \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kabel@kernel.org \
    --cc=marex@denx.de \
    --cc=mark.kettenis@xs4all.nl \
    --cc=michal.simek@amd.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.