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 80953C433FE for ; Fri, 30 Sep 2022 12:02:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBC9884D22; Fri, 30 Sep 2022 14:02:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.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=amd.com header.i=@amd.com header.b="vQsek2v0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4630C84CE4; Fri, 30 Sep 2022 14:02:52 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) (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 03D8A84D80 for ; Fri, 30 Sep 2022 14:02:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZYvVYVWSi/2m9lztmouhmzxSf5F9xp60DC99QvwMfoe7wcJFRlJYdbk3TfJCsCR48Vlm8YHkKx0j2NCTKX5JCPhvA74VerDU1RPQ2zuZIpJ7rlr2xa0lNVjlDBN88F5CSqR7JDG0JE+QUl91ayoUi/TaYi89+pjZZM8DIZtpf8lMQ3zn17W+nMy3KjSEeQdUoxc28R/ZUPvC1rkUgVsev1i1G9+szkhccu+Pvv6Z+BpGq34CT0GvAAIn21dt9D8A3XAQyHD8+yPClBFGnlR2So8UidL5zmQSFuoppijzijA8yPuZPEEmHCM6KOk7ovpFKURMIm1Cyjn1ZzidM+P28g== 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=J/3XWc8mQ6YduJFRh7A5gAt3puLiJ48Jx7wwmiyJHDw=; b=U0+0bV5jIiofSSYNBTqoWhOMr9VlP+mZGnGnreUJIC4F4tNxF569sw4qNUOiVxU9+qLQU1nZR21IoB5T1+doBPpbdjyssXUULDK28PxP4rG+30fYAvUEeeTRZ0qK+R1njYNE519OCMDu/MOpK2dgP2nQc1paq89HrBqidi6Gb5YNAYRjkuE+lJoM4k6J2l63sRKORGr8acjNuOBESedGp0gEzf9r5+udhDkzsuygFxxcD5yJmP/zVzMAqs7VlWdK+hUyWNh7x2QR17ex/M14UByVVWmA+lzixUmjYVnbYMhLgu5AOCwy/LZ1lVVQfys37Qd//AqnnKCR0p5ar2WYzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J/3XWc8mQ6YduJFRh7A5gAt3puLiJ48Jx7wwmiyJHDw=; b=vQsek2v0H7P+s8UR1NhGNd90Bh5kp/UTVZaDVdbbTlixvwunhwqgWQS6Cozy/V76eIP8PgIgP09GmwfM/FWEYt0LuA+lYyjKwHHkoCwcPnVP7MU3A+hwVmc9/LdWtupqA48pzjEm1tQySf8ayXcbjTZpBkiG46IEIbIOXehW2Qc= Received: from BN9PR03CA0620.namprd03.prod.outlook.com (2603:10b6:408:106::25) by PH7PR12MB6908.namprd12.prod.outlook.com (2603:10b6:510:1ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Fri, 30 Sep 2022 12:02:44 +0000 Received: from BN8NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::30) by BN9PR03CA0620.outlook.office365.com (2603:10b6:408:106::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20 via Frontend Transport; Fri, 30 Sep 2022 12:02:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT110.mail.protection.outlook.com (10.13.176.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5676.17 via Frontend Transport; Fri, 30 Sep 2022 12:02:43 +0000 Received: from [10.254.241.52] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 30 Sep 2022 07:02:37 -0500 Message-ID: Date: Fri, 30 Sep 2022 14:02:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH 04/10] timer: cadence-ttc: Add timer_early functions Content-Language: en-US To: Simon Glass , Stefan Roese CC: Michal Simek , U-Boot Mailing List , Tom Rini References: <20220921140625.999002-1-sr@denx.de> <20220921140625.999002-5-sr@denx.de> <1570cc7c-5cdc-d2c5-60a1-ad83cc12bee9@denx.de> From: Michal Simek In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT110:EE_|PH7PR12MB6908:EE_ X-MS-Office365-Filtering-Correlation-Id: 757f4d56-cee8-46f9-90be-08daa2dbae41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pIDi31RhYlrN2iiRUyG0KYBSR6o/2TGLY4CNjbc4F9jtsHdi8Q3MRw8qpNoesNOgmXVfhg3nK6xiSO3IdRi0FlOjt3yx/+AvmomPjeNm6/fgrwqYv2odTtQQXwvJDZ1xNS0D3ZRZ9LV/bbIKs8RKhvwhLSvgIe4vLUS3t0bG4bDH1fa4nqX7dbsrVz6XoCWmd5syWa3gCmoC4R2A7cbRfxHJnpcOF01EmKNdkp1EeJuJQD0XZUvKmlislYTfdUdtcBvzE8ZSDJVSR3WFmp8vheCvN2briCEMujgUJlh88r/pFWt3iMtOeDIyhxXFZs/ta+4JOKsVw52rsmO4SN5/Nr02KHRtqusNDOmBXirHfWR1+1ZsIhJLRrPBhauSCzG0VeDDy1ZuBxHVO7859+rBzxXFVq5+qPOCkJGt3YKvX5Qb9QEZuvamPtpYPOZs/tNkS7jOWKiU7QkSGylJFhVQT7FoptdHs44EtHbr3UxSY9U9Jd/xfQztTchOUSU+0fqkKDqtJd6rLsP6VtFpjuOt86CctpH8HGIth6P0NUjm6mZOpYnbsgHmjOMCe1kIHGrPzOdJqsCBCBMdGebnXDQl5oTm52NVee1SLsLgIpGv2GyHcCeLnrN6NAATh0b+pHb6JpD1nISNLBi0PjouPhjbHN5mlI2Qp2zKxV88uc+mkDOvkQswHnHXflkUw9a2oz2+HvBvzfpazyncvvW/nN/w4S3VsHVEDeKQlEobgAVEuzW55RjS8QxLVPimUXQRoG6KWU/dzBFxmMuimIUwDB8anRcdjBcHQirDlU4wcyryHPW+HvlCEP+3oUjhJ3vawDZwDa6YUNaG5QaVD4J1G/pPJw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(40460700003)(478600001)(44832011)(356005)(5660300002)(336012)(31696002)(36860700001)(2616005)(426003)(316002)(8936002)(86362001)(16576012)(186003)(110136005)(16526019)(53546011)(26005)(54906003)(82740400003)(8676002)(70586007)(4326008)(70206006)(81166007)(31686004)(40480700001)(2906002)(47076005)(83380400001)(41300700001)(36756003)(36900700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2022 12:02:43.0791 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 757f4d56-cee8-46f9-90be-08daa2dbae41 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6908 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Simon and Stefan, On 9/28/22 03:54, Simon Glass wrote: >> Hi Simon, >> Hi Michal, >> >> On 25.09.22 16:15, Simon Glass wrote: >>> Hi Stefan, >>> >>> On Wed, 21 Sept 2022 at 08:06, Stefan Roese wrote: >>>> >>>> Currently this timer driver provides timer_get_boot_us() to support the >>>> BOOTSTAGE functionality. This patch adds the timer_early functions so >>>> that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY >>>> is enabled. >>>> >>>> timer_get_boot_us() will get removed in a follow-up patch, once the >>>> BOOTSTAGE interface is migrated to timer_get_us(). >>>> >>>> Signed-off-by: Stefan Roese >>>> Cc: Michal Simek >>>> --- >>>> drivers/timer/cadence-ttc.c | 25 +++++++++++++++++++++++++ >>>> 1 file changed, 25 insertions(+) >>>> >>>> diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c >>>> index 2eff45060ad6..e26c7923a140 100644 >>>> --- a/drivers/timer/cadence-ttc.c >>>> +++ b/drivers/timer/cadence-ttc.c >>>> @@ -58,6 +58,31 @@ ulong timer_get_boot_us(void) >>>> } >>>> #endif >>>> >>>> +unsigned long notrace timer_early_get_rate(void) >>>> +{ >>>> + return 1; >>>> +} >>>> + >>>> +u64 notrace timer_early_get_count(void) >>>> +{ >>>> + u64 ticks = 0; >>>> + u32 rate = 1; >>>> + u64 us; >>>> + int ret; >>>> + >>>> + ret = dm_timer_init(); >>> >>> I don't think you can call this if you want to support bootstage, >>> since driver model may not be inited. >> >> Yes, thanks for noticing. Still, this code is copied from the original >> timer_get_boot_us() function in this driver. Which also has problems >> with early timer access AFAICT. > > Yes, good point. > > Reviewed-by: Simon Glass I looked at it and kind of interesting code. For getting this working with this whole series if ttc gets u-boot,dm-pre-reloc everthing is working fine. diff --git a/arch/arm/dts/zynqmp-r5.dts b/arch/arm/dts/zynqmp-r5.dts index a72172ef2ea4..8059931f2162 100644 --- a/arch/arm/dts/zynqmp-r5.dts +++ b/arch/arm/dts/zynqmp-r5.dts @@ -56,6 +56,7 @@ ttc0: timer@ff110000 { compatible = "cdns,ttc"; + u-boot,dm-pre-reloc; status = "okay"; reg = <0xff110000 0x1000>; timer-width = <32>; What I see based on behavior. Every bootstage call is asking for timer_early_get_count() and because dm_timer_init() is failing 0 is returned. Inside initf_dm() dm_init_and_scan() is called and initialized timer uclass also with timer instance. With u-boot,dm-pre-reloc also cadence timer driver. On the next dm_timer_init() gd->timer is initialized and value is returned and initf_dm() passes. Here is the log and output from bootstage. U-Boot 2022.10-rc5-00130-g1be5bed207c9 (Sep 30 2022 - 14:00:08 +0200) Model: Xilinx ZynqMP R5 DRAM: 512 MiB Core: 7 devices, 7 uclasses, devicetree: embed MMC: Loading Environment from nowhere... OK In: serial@ff010000 Out: serial@ff010000 Err: serial@ff010000 Net: No ethernet found. ZynqMP r5> dm tree Class Index Probed Driver Name ----------------------------------------------------------- root 0 [ + ] root_driver root_driver clk 0 [ + ] fixed_clock |-- clk100 simple_bus 0 [ + ] simple_bus |-- amba timer 0 [ + ] cadence_ttc | |-- timer@ff110000 serial 0 [ + ] serial_zynq | `-- serial@ff010000 bootstd 0 [ ] bootstd_drv `-- bootstd bootmeth 0 [ ] bootmeth_distro `-- distro ZynqMP r5> bootstage report Timer summary in microseconds (8 records): Mark Elapsed Stage 0 0 reset 0 0 board_init_f 0 0 dm_f 0 0 dm_r 16,319 16,319 eth_common_init 18,061 1,742 main_loop 18,281 220 cli_loop 29,249 10,968 board_init_r Accumulated time: Would be good if you can also add u-boot,dm-pre-reloc before 9/10 patch which enables CONFIG_TIMER_EARLY. Thanks, Michal