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 7B3E1C433EF for ; Fri, 22 Apr 2022 14:19:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9765A83CF3; Fri, 22 Apr 2022 16:19:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="tep9pSkk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E162383D62; Fri, 22 Apr 2022 16:19:26 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::62e]) (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 0AE868249D for ; Fri, 22 Apr 2022 16:19:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michals@xilinx.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BHPy+yWvENVCjBJRUaZNu776xGuiTnRfMmbHSs32beV5wwYY/y4eW19XR4cf9rRSGVxEw/7lt4sDG/seb3OKGojnxJQi6JnNLPUCDdMesmgPpr7vmKJO50RvyFTa+H2TY5DUlDSWsgEP/zLF+INcujbpNV3Q7tIvnVY2zrKtuXCSV3wmUeXSPibLs6EC9jMy0T1bb4sTdXhSG77KE4TvZvS27Ch0SCr5OjbRugYIN19kFJtQPEnkcll6XmNO4/rr8lRRMsUsU4Nzi2YWB0XuudNm0ai8T/PD7HJUPvMBZKiGVlY0Gk47sTzoxKpX8fIF4MS8eojdN7dExie42u3CCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tuld649b4K+oVgBTGrfmPOW9bUAoC2q5CfW07MMSE84=; b=PQt267mHV0MZf92EWv9J/a5EHbTWPdEpAJkWj9v2S9zrO41Wor3ZF0DSfjjU/mipzgW91qrH5KXv488Hvro4aFpA+xP/EeMhz7XldzgnFS8tBl1DWo9KGxDgzOhOOuIY/G2H39ts1EYiMsECS3QqDxUJUXPXivXIL7uadzMuwJB7B0PUmEx9w/VEEdE7JJGxp9ztCaonBZd3HX/sJYm/3Ehxd43WAGw/OUgASJcqsDmaslKenV32Nabx2vySkAenlLWuFQ52MPBQhAtGDnbNLr0IFKJShEO3WdZ1SLED4iPFPdPiQ4aQUBuwLId3Mm6HB28zigKUXLLsGRnli681sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=gmail.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tuld649b4K+oVgBTGrfmPOW9bUAoC2q5CfW07MMSE84=; b=tep9pSkk/cYl6AodzsR+AtbpVD+EwgyXQZh+kOiRZNevj9LZS0s2dYLOhj1i/3/54b38yuR+Ee3OSZRJJ7axbPvo2SvhQbL00oQUHT71ZmijYdaS4S+doExMhBm+fh9AHNb1Pc6Cm0Mz3oGDntfN0EdWQfLHQ2IPBfQtirz9TRw= Received: from BN8PR16CA0030.namprd16.prod.outlook.com (2603:10b6:408:4c::43) by MN2PR02MB6848.namprd02.prod.outlook.com (2603:10b6:208:1d6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Fri, 22 Apr 2022 14:19:20 +0000 Received: from BN1NAM02FT052.eop-nam02.prod.protection.outlook.com (2603:10b6:408:4c:cafe::4b) by BN8PR16CA0030.outlook.office365.com (2603:10b6:408:4c::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15 via Frontend Transport; Fri, 22 Apr 2022 14:19:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT052.mail.protection.outlook.com (10.13.2.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5186.14 via Frontend Transport; Fri, 22 Apr 2022 14:19:20 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 22 Apr 2022 07:19:17 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 22 Apr 2022 07:19:17 -0700 Envelope-to: ovpanait@gmail.com, u-boot@lists.denx.de, monstr@monstr.eu Received: from [10.254.241.50] (port=44940) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nhu7x-0004Eu-NA; Fri, 22 Apr 2022 07:19:17 -0700 Message-ID: Date: Fri, 22 Apr 2022 16:19:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 10/10] microblaze: cache: use fdt cache size info if available Content-Language: en-US To: Ovidiu Panait , CC: Michal Simek , Michal Simek References: <20220411162634.69647-1-ovpanait@gmail.com> <20220411162634.69647-10-ovpanait@gmail.com> From: Michal Simek In-Reply-To: <20220411162634.69647-10-ovpanait@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 559b456e-3094-4271-c7fb-08da246b17b5 X-MS-TrafficTypeDiagnostic: MN2PR02MB6848:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eFUhVx5gcdRarD/Xjc9BXHAPuITivLiLpHJJgMKkh2m+dJ9BL1Gq9T4cXJcQkWNFYsfo81E8AegqsU+IHUyFb03Feeo00s7E4mLLiAynOufUJs+Y+gv+CnYEX1aSGAoSTlHcAbCl0rIxTYXwD8S2Y6v1FfRQ3Vc7wuzzS36nR6tVfnQmmrlDiABOMrsa+Iu6btOFeY9iMQjo1L2tvm6I/utmxuqy1Sxjnp4APspgYPnz3FX9rgt6luxLhwGVYKPmGcbX6xybNTUC9FAohpvG5eZnoFX2ftJAJMVotgyWGdUJnLsqoNsYjqZ33wRopvvEDrEGKNoIuSiG85EEKVdVbL1TZk1wlIcUVRJA7TEm2vjW8P521TW6jooe7HvrdUch2EMDS0C5eI7rM2hwKGin+ZV9xJhJZ4GO39R4CZDtgbqijvsklPNKSYAVzCafVc50sTESbvRdwdO6g/rvGzqpS1AvDt7Hlg3/b1WwImB9TSyaEAzKZr5uhen1Yg7zFexEFck47/+g/izZPn0H+iN1CwuAJ8OHbQ2lpRGMZoK19q8ADF8IH9WomSGzCRkfvrgOOQzAOPwmUScqn7A8ie1MpZBdLv7Ug8sHKayFHU+xZX2knqoxghIXCySc3Wz6aMduuZLDV+hOjG/b23jgsv16RlPjhm4QLgIhl7ebyrA4XXLe8hm48tPB6uQ8IM/HR7XfEPVQQBZIqubPppmy6nkGZB89Poo89NhRvZXS4JKTl/Y= X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(83380400001)(426003)(7636003)(40460700003)(31696002)(47076005)(508600001)(9786002)(186003)(36756003)(316002)(336012)(4326008)(82310400005)(110136005)(70206006)(54906003)(31686004)(70586007)(8676002)(36860700001)(2616005)(26005)(53546011)(8936002)(356005)(44832011)(2906002)(5660300002)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 14:19:20.2673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 559b456e-3094-4271-c7fb-08da246b17b5 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT052.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB6848 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 4/11/22 18:26, Ovidiu Panait wrote: > If CONFIG_CPU_MICROBLAZE is enabled, the cache size and cache line size are > retrieved from the fdt by the microblaze cpu driver. Adjust cache flush > code to use those values if available. > > If a cache flush is requested very early in the boot (for example the > flush_cache_all() call in start.S) or before dm is ready, the default size > of CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE will be used instead. > > Signed-off-by: Ovidiu Panait > --- > > arch/microblaze/cpu/cache.c | 45 +++++++++++++++++++++++++++++++++---- > 1 file changed, 41 insertions(+), 4 deletions(-) > > diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c > index cce33a6eb5..8b7e212a26 100644 > --- a/arch/microblaze/cpu/cache.c > +++ b/arch/microblaze/cpu/cache.c > @@ -9,11 +9,21 @@ > #include > #include > #include > +#include > > static void __invalidate_icache(ulong addr, ulong size) > { > if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WIC)) { > - for (int i = 0; i < size; i += 4) { > + int line_length = 4; > + > + if (CONFIG_IS_ENABLED(CPU_MICROBLAZE)) { > + int size = microblaze_cpu_get_cacheline_size(ICACHE); > + > + if (size > 0) > + line_length = size; > + } > + > + for (int i = 0; i < size; i += line_length) { > asm volatile ( > "wic %0, r0;" > "nop;" > @@ -26,13 +36,31 @@ static void __invalidate_icache(ulong addr, ulong size) > > void invalidate_icache_all(void) > { > - __invalidate_icache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); > + int cache_size = CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE; > + > + if (CONFIG_IS_ENABLED(CPU_MICROBLAZE)) { > + int size = microblaze_cpu_get_cache_size(ICACHE); > + > + if (size >= 0) > + cache_size = size; > + } > + > + __invalidate_icache(0, cache_size); > } > > static void __flush_dcache(ulong addr, ulong size) > { > if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) { > - for (int i = 0; i < size; i += 4) { > + int line_length = 4; > + > + if (CONFIG_IS_ENABLED(CPU_MICROBLAZE)) { > + int size = microblaze_cpu_get_cacheline_size(DCACHE); > + > + if (size > 0) > + line_length = size; > + } > + > + for (int i = 0; i < size; i += line_length) { > asm volatile ( > "wdc.flush %0, r0;" > "nop;" > @@ -53,7 +81,16 @@ void flush_dcache_range(unsigned long start, unsigned long end) > > void flush_dcache_all(void) > { > - __flush_dcache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); > + int cache_size = CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE; > + > + if (CONFIG_IS_ENABLED(CPU_MICROBLAZE)) { > + int size = microblaze_cpu_get_cache_size(DCACHE); > + > + if (size >= 0) > + cache_size = size; > + } > + > + __flush_dcache(0, cache_size); > } > > int dcache_status(void) This patch can be dropped because these functions should only work based on data from cpuinfo structure that's why you don't need to call special function which are only available when driver is enabled. M