From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E66DC433EF for ; Mon, 21 Feb 2022 10:52:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 743B682A59; Mon, 21 Feb 2022 11:52:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="DACg8uIq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B59E8367D; Mon, 21 Feb 2022 11:52:41 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E6745820F5 for ; Mon, 21 Feb 2022 11:52:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maz@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 654ACB80F96; Mon, 21 Feb 2022 10:52:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15A3CC340EB; Mon, 21 Feb 2022 10:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645440756; bh=NpiitPkJlKdqpamb7w3+qSQ2vH82vs0+kFP539ah2U0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DACg8uIqT0OOTZMiee7jaHoJFu72U3XDuhiuaKouMtigvQ7JlfBYwLUujrrTf1VmJ pA+fgzYNz5+VkxTtlFHN0Qvtx8Lx6sxwOe7WWCZlrXZF1BXDaDDA0vWnG5sjMHPMK+ i4/82nv2/QDuHaHTRlVd2UIJDOvy00n8r/E+L3IDAU43hvgSl+hYrndWYkp2lc2m4J jeN/oiA7HTXO1ETTJOFqXVYqrUZ6teqVbBrCowb4Ydg3My3GdlABan72dZyEMl26hQ 7TTE7HzKvI5F07eSS6qwgM6kjyexCrNOQqoa67QRtnTnZKzPP34Bxptz97bEclNHnJ YlTCloZTcH36Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nM6J0-009H7e-8q; Mon, 21 Feb 2022 10:52:34 +0000 Date: Mon, 21 Feb 2022 10:52:33 +0000 Message-ID: <87a6ek4hla.wl-maz@kernel.org> From: Marc Zyngier To: Michael Walle Cc: Wasim Khan , sjg@chromium.org, priyanka.jain@nxp.com, treding@nvidia.com, twarren@nvidia.com, V.Sethi@nxp.com, u-boot@lists.denx.de, Wasim Khan Subject: Re: [PATCH] armv8: fsl-layerscape: use previous aligned address for gic_lpi_base In-Reply-To: <25ff6150a612a113449f9f2068ca1060@walle.cc> References: <20220221101616.1195186-1-wasim.khan@oss.nxp.com> <25ff6150a612a113449f9f2068ca1060@walle.cc> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: michael@walle.cc, wasim.khan@oss.nxp.com, sjg@chromium.org, priyanka.jain@nxp.com, treding@nvidia.com, twarren@nvidia.com, V.Sethi@nxp.com, u-boot@lists.denx.de, wasim.khan@nxp.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Mon, 21 Feb 2022 10:24:36 +0000, Michael Walle wrote: > > Hi, > > Am 2022-02-21 11:16, schrieb Wasim Khan: > > From: Wasim Khan > > > > Memory after gd->arch.resv_ram is reserved for MC block. > > Use ALIGN_DOWN to avoid updating MC block for unaligned > > address. > > I cannot really tell what you are trying to do here. But I > know Marc has offered to also take a look at the GIC/LPI > stuff. So I've put him on CC. > > -michael > > > > > Signed-off-by: Wasim Khan > > --- > > arch/arm/cpu/armv8/fsl-layerscape/soc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c > > b/arch/arm/cpu/armv8/fsl-layerscape/soc.c > > index d3a5cfaac1..746c93cf51 100644 > > --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c > > +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c > > @@ -65,7 +65,7 @@ int ls_gic_rd_tables_init(void *blob) > > u64 gic_lpi_base; > > int ret; > > > > - gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K); > > + gic_lpi_base = ALIGN_DOWN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K); > > ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, > > GIC_LPI_SIZE); > > if (ret) > > return ret; > It is the usual accumulation of nonsense. We have #define ITS_MAX_LPI_NRBITS 16 which is not necessarily what the HW exposes #define PENDTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K) The *base* of the pending table has to be 64kB aligned, but not its size. Yes, that's a helpful shortcut, but that's still wrong. #define PROPTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K) This 64kB alignment is silly, specially considering the hardcoding of the number of ID bits. #define GIC_LPI_SIZE ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \ PROPTABLE_MAX_SZ, SZ_1M) This 1MB alignment doesn't exist. Convenience again? And then this patch adds some bizarre alignment for reasons that have nothing to do with the GIC, but because there is so other reservations this steps on, which probably means that the allocator is doing something wrong... The whole thing needs reworking from first principle, at which point it will become clearer what this is trying to do. M. -- Without deviation from the norm, progress is not possible.