Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp421611rdb; Thu, 2 Nov 2023 07:32:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEI16LfyOBpq8K2DZRTmB0s9HrZWzK5fIvklFa24N/RQJEWGvAxyNWyJg1izrE36gGbk03 X-Received: by 2002:a05:6a20:1588:b0:159:d4f5:d59 with SMTP id h8-20020a056a20158800b00159d4f50d59mr11480717pzj.12.1698935547140; Thu, 02 Nov 2023 07:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698935547; cv=none; d=google.com; s=arc-20160816; b=mimaN/5vPOZsJZIZ5a3Rmg5ZXScaIUHvYJ/0iAQnrlDmNSQSazTLPBXRrnOK4oX4vr g8fBTeae3XeNutoCHUWHzgK4fsFcbCsiS2vFH0wI+JywAcN0JRfUrdJ0herPhqHz1xqm h3asSB45Cysi/poANbjqqmYwLYA9/yN6Q/7mA6o8VicJHJxgZ+INQl4R4/hYGJzrBE3T S7rL3Uf3hKIV3bURMfu9aOVebbJm3qUKNoQAxceP1ZvuPie3FMNLp8pk673d8uAgTnnM ub+5KnZuT6vBb5SEKm7jdfky5y7pvhTJBw32KyhzODevEWIekHHUCA2cZZPswWOEkSyj JV6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=+zTIXrfkswX74UPgsg79qK4Ca7pyfesNXn6v+dgCKc8=; fh=cfXtmSRt+YBo9k0fau4iwubGUsKoQjrr0v0+boS6DS0=; b=gTqp/zH586j55m6dt+GUIsRIjRoBEZ/sgYjYoTVkfjei1kh4pEpm1kcP+3BUCEo92P GSmdSSA8qbXIVAF3GFeYt0VoDsZP0d1HnVTy0MRUrlXi4dIu1D1FDIdZC3uWmgVM4LC8 YdgoBwzBValYx+tGzRkMIZ61DQ7BYDU19L3eKfiiAsiIZk+Ei/Qo/LXmwSHGvQv4hoXs lLRB0LQ3I4zTNuCqmtzAEMxIxt8wDujDWxtYCH6hVOgTZPcgFsqq/WX6UcPFbyKAV2no YkxtGXk7ItmgLkF+n0xSkNT6aKKu/FNft6XJ2hy1Y4VkmPJqpzpgmZnyZF/NdM5mP1PK tFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ajkelu3t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id q2-20020a056a00150200b0068a3c575900si3730376pfu.84.2023.11.02.07.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 07:32:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ajkelu3t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6003282D87B1; Thu, 2 Nov 2023 07:32:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235640AbjKBOaa (ORCPT + 99 others); Thu, 2 Nov 2023 10:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235670AbjKBOaU (ORCPT ); Thu, 2 Nov 2023 10:30:20 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77FB8D7E for ; Thu, 2 Nov 2023 07:29:40 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso274124f8f.1 for ; Thu, 02 Nov 2023 07:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698935379; x=1699540179; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+zTIXrfkswX74UPgsg79qK4Ca7pyfesNXn6v+dgCKc8=; b=Ajkelu3tJZ6qlpnLxibTPuXpJ7zDqzkHgethk5yy4oph04AhBlv27oDqcBSdRApLdn vIEx9prhaU8GL45jFczNjkZ2m0L1RTT/AxG1dEDLYaWlfHhlQbfI2WkAHeMErte9Lsf9 euQvlB8bzv8fhQCVB1fON5f3awjTlbhLijH5yu/pVXjOQEtn0lEiaXqsLumGkiOhBo+l OiUDr4o4XQRSO5CM22DmGWh32FZvPsGjq1b9ry1BZy0grFITUZHhz75mqHJTKtHN6FVV apywaWaORAuag/ltC4cRoBRr97XJ0jtednvdaMVuovX0TEuWP45n3qU8neP/4WZ50pfl XXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698935379; x=1699540179; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+zTIXrfkswX74UPgsg79qK4Ca7pyfesNXn6v+dgCKc8=; b=LM3UNk9lmNBSO503GoVfRfAFYb3EnV08aaXA2Rnz80vCIOzgS/pBNFdAxgPV45bEh9 krHFPO+RPhIdeAYcvHYH/ms25AJTHD47HhpIyNxmyj7IhuZY/VBeorRvIwXygBBla4il chw4qsEqU0ndlHbHYjBeUDk+UdXhkzTgdOJFpwzA059mQSIyRwVGZFjOeuCjmqrF1IqW t1mM1euTxstaGZ5M5J9+Cbf+zhkTHgFjQUDWViFIOY55BHGl1jbH2b2bvZdwoxnJx442 ElKPXN7aCLNQS//jyaYkIQXkw07wIOSEskfNurPWWOYYV0su6VO6rkjNjZWxblGCkJOp TKkA== X-Gm-Message-State: AOJu0YzLx0KH0gHd5WgQuOkfw7z+rbduAdXycK1Su4J11q2yj2EODlQM 6a1Wz+8G9qAPVRvwK/MYfVuGdQ== X-Received: by 2002:a5d:4a0c:0:b0:32f:922a:fc49 with SMTP id m12-20020a5d4a0c000000b0032f922afc49mr7100033wrq.21.1698935378579; Thu, 02 Nov 2023 07:29:38 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:bd6b:8105:85a4:1102? ([2a05:6e02:1041:c10:bd6b:8105:85a4:1102]) by smtp.googlemail.com with ESMTPSA id w11-20020adfcd0b000000b00326f0ca3566sm2594397wrm.50.2023.11.02.07.29.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Nov 2023 07:29:38 -0700 (PDT) Message-ID: Date: Thu, 2 Nov 2023 15:29:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 2/3] clocksource: Add JH7110 timer driver Content-Language: en-US To: Xingyu Wu , Thomas Gleixner , Emil Renner Berthing , Christophe JAILLET Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Walker Chen , Samin Guo , linux-kernel@vger.kernel.org, Conor Dooley References: <20231019053501.46899-1-xingyu.wu@starfivetech.com> <20231019053501.46899-3-xingyu.wu@starfivetech.com> <3f76f965-7c7b-109e-2ee0-3033e332e84b@linaro.org> <540136d4-6f8f-49a6-80ff-cc621f2f462b@starfivetech.com> <65c38717-3e0c-46d3-a124-29cae48f1a2e@linaro.org> <72ad5029-42b2-481a-887f-8f6079d8859b@starfivetech.com> From: Daniel Lezcano In-Reply-To: <72ad5029-42b2-481a-887f-8f6079d8859b@starfivetech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 02 Nov 2023 07:32:08 -0700 (PDT) Hi Xingyu, On 02/11/2023 14:15, Xingyu Wu wrote: [ ... ] >>>>>>> +struct jh7110_clkevt { + struct clock_event_device >>>>>>> evt; + struct clocksource cs; + bool cs_is_valid; + >>>>>>> struct clk *clk; + struct reset_control *rst; + u32 >>>>>>> rate; + u32 reload_val; + void __iomem *base; + >>>>>>> char name[sizeof("jh7110-timer.chX")]; +}; + +struct >>>>>>> jh7110_timer_priv { + struct clk *pclk; + struct >>>>>>> reset_control *prst; + struct jh7110_clkevt >>>>>>> clkevt[JH7110_TIMER_CH_MAX]; >>>>>> >>>>>> Why do you need several clock events and clock sources ? >>>>> >>>>> This timer has four counters (channels) which run >>>>> independently. So each counter can have its own clock event >>>>> and clock source to configure different settings. >>>> >>>> The kernel only needs one clocksource. Usually multiple >>>> clockevents are per-cpu based system. >>>> >>>> The driver does not seem to have a per cpu timer but just >>>> initializing multiple clockevents which will end up unused, >>>> wasting energy. >>>> >>>> >>> >>> The board of the StarFive JH7110 SoC has two types of timer : >>> riscv-timer and jh7110-timer. It boots by >>> riscv-timer(clocksource) and the jh7110-timer is optional and >>> additional. I think I should initialize the four channels of >>> jh7110-timer as clockevents not clocksource pre-cpu. >> >> If no clocksource is needed on this SoC because riscv timers are >> used, then it is not useful to register a clocksource for this >> timer and the corresponding code can go away. >> >> If the clockevent is optional why do you need this driver at all? >> >> >> > > Hi Daniel, > > Sorry, maybe I didn't express it clearly enough. I use this > jh7110-timer as a global timer on the SoC and riscv-timer as cpu > local timer. So these are something different. > > These four counters in this jh7110-timer are exactly the same and > independent of each other. If this timer is used as a global timer, > do I use only one or all of the counters to register clocksource and > clockevent? Yes. The global timer is only there when the CPU is powered down at idle time, so the time framework will switch to the broadcast timer and there can be only one instance. If you register all the counters, only one will be used by the kernel, so it pointless to add them all. On the clocksource side, you may want to question if it is really useful. The riscv has a clocksource with a higher rate and flagged as continuous [1]. So if the JH7110 clocksource is registered, it won't be used too. Hope that helps -- Daniel [1] https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/tree/drivers/clocksource/timer-riscv.c#n68 -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog