Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1163165rdh; Fri, 27 Oct 2023 06:35:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyXG3UjVCyjv6TpOjowYk8sJLNp/2eJrpC+re07GP1YH0TfffgWj2S4J7qCuEpJiSy31oD X-Received: by 2002:a9d:6ac3:0:b0:6b8:9483:35ba with SMTP id m3-20020a9d6ac3000000b006b8948335bamr2803230otq.24.1698413700207; Fri, 27 Oct 2023 06:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698413700; cv=none; d=google.com; s=arc-20160816; b=CaT8fO95O0838PZJlTxRewTROxCVWrfBBWr/oWXpkSchhvVDXNQbVg2xWPhk9YCHna 0mHpTFQysCsp257ehWWph0rkaVjc9ZAsuB23aupMLUn8aYCeOqRxJd/CvUcmJ3daX38s 4vlWRfsc8btN5fIg41xYyotzoSUGIekTcFrjdoNYMnSgUCIGWQmmZPkbLiAYrKy3Htg3 cw+ZODdGxntERas+fGiq3OhM0DoVQBdbh/bEi8rZc0fEFtWARoCFFftTh/5mqb0SHc2/ MYB6mPY2qjduaQ6LLYEq9CtDG/fg8rAIFPQLBtN9Ah45BlAiR5ANZ+j4idqmKpHtzJUF GEow== 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=rWXlEVm7BmX7wHuL11qkF7f8G0gaxC3EbzsfoFC6RTo=; fh=cfXtmSRt+YBo9k0fau4iwubGUsKoQjrr0v0+boS6DS0=; b=koqvtSLrg4fdlc0HNAQD7uhCGP67VPoOy52Eym+SLir2X0vfF+SslPX25kFGIOgIna 1kloGQXrpFIH0NzUPnHfUz+3edU5w/v2ehOh0/+/auRcztTE4HWsOJLtlIY2OG0dgtlw jDIQVuavOPgti48/Lmehv8eoVYOep9sq0Npm+zdu6qOsBi3x7qGgvBDYbf3yui37OedA Ji6Q+i/rl8o1yZHXEQn1wTNRYILjq6r14ilS5aIMHq/U1YU42oVizpC5jDw45bk0/5sI 3ls+R5FPvpm++bxNhVdP32Le53QW9RAgp+i0ols0rkPg8xHJo7wUj9te/5b6kGE9dyT3 D+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zdBw1+6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x22-20020a0dd516000000b0059f4fa06dd0si2802708ywd.241.2023.10.27.06.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 06:35:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zdBw1+6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id DA70F8301521; Fri, 27 Oct 2023 06:34:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345958AbjJ0Ned (ORCPT + 99 others); Fri, 27 Oct 2023 09:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345851AbjJ0Ne1 (ORCPT ); Fri, 27 Oct 2023 09:34:27 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EBADE5 for ; Fri, 27 Oct 2023 06:34:25 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-32d895584f1so1439750f8f.1 for ; Fri, 27 Oct 2023 06:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698413663; x=1699018463; 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=rWXlEVm7BmX7wHuL11qkF7f8G0gaxC3EbzsfoFC6RTo=; b=zdBw1+6dqq6zp8OOVFFDqgNOKJW3PaHVqyfyzvlKfQh5xnZXbSua0J0DoJHog6QSD5 bZRk86KXO9dCNAEd7IP94xof1mKUVqtqN8fjiDr6sNDJDvpz2VCCaTGxz/8QyNNe2JOx 6V2P7efoRGn/W5KaEnw6wysMngh/Efwwc7T/gwh9pAJqoufwvXhYiX17sPpMNADSVy77 admWsjqJdrlML3THIUIjMb9+4h9Q2ah9sztlQpZ78DTb+t9A3N1eHJGzaEHcZirMMmYf VrntfQfauWn5P+D9Bve9kjXNqj0BEF8aimfuo5GbjPenpvYYwQfnlfSb1Vd1X7++ejZD INdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698413663; x=1699018463; 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=rWXlEVm7BmX7wHuL11qkF7f8G0gaxC3EbzsfoFC6RTo=; b=uFMfthsAVn0sElgZmGsA7LKPRjN7FBT4HpOZkVL542MoMuxlwUpVyo65nNwUfXzRTX h+W0LzGaffxxttverjyfaTF3+TDoi7bagmU9uXn7cfXFZNX2V/l8mnb3+m1jiANHlA5F stx1AvQM34YTW6lUk7RASpteX5QWMytzt9PfTtw+nD4CCkMYVJW9F1AODsOsf83kwZUH GS8wDtIpQQX1elnivgTQJhfRLtnm2JoCYLiqwuPaR4Z7iBK5CFA/bnlAoQ58S3Sx+G7v Qr6kqwDc3ztj+ifKrCai6fAe/OOZyqdzGefEEtqvnglbKVl31ae+1KT/+qemOelUsEu8 ZXkA== X-Gm-Message-State: AOJu0Yx76yFiq8jU2nv9Eg5Z4SR7wfb9ewznBxvCV+Qlaf7/br/zckxt 4DDUFJQLJKaW9fez1Gv9yoVZtg== X-Received: by 2002:adf:f6c7:0:b0:32d:c0c9:f661 with SMTP id y7-20020adff6c7000000b0032dc0c9f661mr2335821wrp.51.1698413663368; Fri, 27 Oct 2023 06:34:23 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:7207:bbe0:91fb:ad90? ([2a05:6e02:1041:c10:7207:bbe0:91fb:ad90]) by smtp.googlemail.com with ESMTPSA id d5-20020a5d6445000000b0032da4f70756sm1796089wrw.5.2023.10.27.06.34.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Oct 2023 06:34:22 -0700 (PDT) Message-ID: <65c38717-3e0c-46d3-a124-29cae48f1a2e@linaro.org> Date: Fri, 27 Oct 2023 15:34:21 +0200 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> From: Daniel Lezcano In-Reply-To: <540136d4-6f8f-49a6-80ff-cc621f2f462b@starfivetech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 27 Oct 2023 06:34:52 -0700 (PDT) On 27/10/2023 11:17, Xingyu Wu wrote: > On 2023/10/25 22:39, Daniel Lezcano wrote: >> >> Hi Xingyu, >> >> >> On 25/10/2023 11:04, Xingyu Wu wrote: >>> On 2023/10/24 22:56, Daniel Lezcano wrote: >>>> >>>> Hi Xingyu, >>>> >>>> >>>> On 19/10/2023 07:35, Xingyu Wu wrote: >>>>> Add timer driver for the StarFive JH7110 SoC. >>>> >>>> As it is a new timer, please add a proper nice description >>>> explaining the timer hardware, thanks. >>> >>> OK. Will add the description in next version. >>> >>>> >>>>> Signed-off-by: Xingyu Wu --- >>>>> MAINTAINERS | 7 + >>>>> drivers/clocksource/Kconfig | 11 + >>>>> drivers/clocksource/Makefile | 1 + >>>>> drivers/clocksource/timer-jh7110.c | 380 >>>>> +++++++++++++++++++++++++++++ 4 files changed, 399 >>>>> insertions(+) create mode 100644 >>>>> drivers/clocksource/timer-jh7110.c >>>>> >>>>> diff --git a/MAINTAINERS b/MAINTAINERS index >>>>> 7a7bd8bd80e9..91c09b399131 100644 --- a/MAINTAINERS +++ >>>>> b/MAINTAINERS @@ -20473,6 +20473,13 @@ S: Maintained F: >>>>> Documentation/devicetree/bindings/sound/starfive,jh7110-tdm.yaml >>>>> >>>>> F: sound/soc/starfive/jh7110_tdm.c >>>>> +STARFIVE JH7110 TIMER DRIVER +M: Samin Guo >>>>> +M: Xingyu Wu >>>>> +S: Supported +F: >>>>> Documentation/devicetree/bindings/timer/starfive,jh7110-timer.yaml >>>>> >>>>> +F: drivers/clocksource/timer-jh7110.c >>>>> + STARFIVE JH71X0 CLOCK DRIVERS M: Emil Renner Berthing >>>>> M: Hal Feng >>>>> diff --git a/drivers/clocksource/Kconfig >>>>> b/drivers/clocksource/Kconfig index >>>>> 0ba0dc4ecf06..821abcc1e517 100644 --- >>>>> a/drivers/clocksource/Kconfig +++ >>>>> b/drivers/clocksource/Kconfig @@ -641,6 +641,17 @@ config >>>>> RISCV_TIMER is accessed via both the SBI and the rdcycle >>>>> instruction. This is required for all RISC-V systems. >>>>> +config STARFIVE_JH7110_TIMER + bool "Timer for the >>>>> STARFIVE JH7110 SoC" + depends on ARCH_STARFIVE || >>>>> COMPILE_TEST >>>> >>>> You may want to use ARCH_STARFIVE only if the platform can make >>>> this timer optional. Otherwise, set the option from the >>>> platform Kconfig and put the bool "bla bla" if COMPILE_TEST >>> >>> Yes, this timer only be used on the StarFive SoC. So I intend to >>> modify to this: >>> >>> bool "Timer for the STARFIVE JH7110 SoC" if COMPILE_TEST depends >>> on ARCH_STARFIVE >> >> In this case, you should change the platform config and select the >> timer from there. Remove the depends on ARCH_STARFIVE so it is >> possible enable cross test compilation. Otherwise COMPILE_TEST will >> not work on other platforms. >> >> [ ... ] >> > > It is not a kernel timer or clocksource. It will not work on other > platforms and is just used on the JH7110 SoC. I think I needn't > remove it. Maybe I modify to this: > > bool "Timer for the STARFIVE JH7110 SoC" if COMPILE_TEST depends on > ARCH_STARFIVE || COMPILE_TEST I think there is a misunderstanding. If we want to compile on x86 drivers for other platforms, we select COMPILE_TEST so we can enable the timer and do compilation testing. In this case, we may want to compile the STARFIVE JH7110 on x86 just to double check it is correctly compiling (eg. we do changes impacting all the drivers). If the ARCH_STARFIVE dependency is set, then that won't be possible. So it should be: bool "Timer for the STARFIVE JH7110 SoC" if COMPILE_TEST ... And in arch/riscv/Kconfig.socs config SOC_STARFIVE ... select STARFIVE_JH7110_TIMER ... >>>>> +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? -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog