[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAL_Jsq+J+6gxOzsXe9t9==GGJ721jrbNhaGMHZyfCTxkM8B0eA@mail.gmail.com>
Date: Tue, 29 Jul 2025 16:38:04 -0500
From: Rob Herring <robh@...nel.org>
To: Joonwon Kang <kjw1627@...il.com>
Cc: saravanak@...gle.com, nsaenzjulienne@...e.de, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] of: address: Fix bug to get the highest cpu address of
subtrees for dma
On Sun, Jul 27, 2025 at 1:01 PM Joonwon Kang <kjw1627@...il.com> wrote:
>
> The function of_dma_get_max_cpu_address() for a device node should choose
> the highest cpu address among the ones that nodes can access.
> However, there was a bug of choosing the lowest cpu address and this
> commit is to fix it.
Please provide a test case in the DT unittests or at least details on
the DT that is affected by the bug.
> Signed-off-by: Joonwon Kang <kjw1627@...il.com>
> ---
> drivers/of/address.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index f0f8f0dd191c..5e984e0d372b 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -969,6 +969,7 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
> {
> phys_addr_t max_cpu_addr = PHYS_ADDR_MAX;
> struct of_range_parser parser;
> + phys_addr_t max_subtree_max_addr = PHYS_ADDR_MAX;
> phys_addr_t subtree_max_addr;
> struct device_node *child;
> struct of_range range;
> @@ -992,10 +993,17 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
>
> for_each_available_child_of_node(np, child) {
> subtree_max_addr = of_dma_get_max_cpu_address(child);
> - if (max_cpu_addr > subtree_max_addr)
> - max_cpu_addr = subtree_max_addr;
> + if (subtree_max_addr == PHYS_ADDR_MAX)
> + continue;
> +
> + if (max_subtree_max_addr == PHYS_ADDR_MAX)
> + max_subtree_max_addr = subtree_max_addr;
> + else
> + max_subtree_max_addr = max(max_subtree_max_addr, subtree_max_addr);
> }
>
> + max_cpu_addr = min(max_cpu_addr, max_subtree_max_addr);
> +
> return max_cpu_addr;
> }
>
> --
> 2.46.0
>
Powered by blists - more mailing lists