Message ID | 20230208094813.20874-2-walter.chang@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3362596wrn; Wed, 8 Feb 2023 01:54:33 -0800 (PST) X-Google-Smtp-Source: AK7set/b+j1n6eSObtfT8RHhZbtBTmyb/JIxmVqfvfnvxeYjezFKdSkkWK27bh/QSEhO1paci55M X-Received: by 2002:a17:906:1011:b0:8af:11b5:fabd with SMTP id 17-20020a170906101100b008af11b5fabdmr85009ejm.5.1675850073041; Wed, 08 Feb 2023 01:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675850073; cv=none; d=google.com; s=arc-20160816; b=I1cC7wSdbuG4O94g8hrlPV1D/2QPIFmaip/jlLuDepuoufrkZSU6HCJXyu9W1nQbpU 1jmbWT8V92XOvtZqcpmOkSnG0BMjLCF5UTeMW2OrBb5kPjuk1bSPJPHjp6RhFkrwCWxn OtxtVivf8SQtinRv2fnZGkBdPYg/Nscf/SFfxT+MjwgeY87M1cSvQunaCx8N93qn34hc IbCtRSkD6Qt9x2j7Nj6e/baCOXlZZgiuIk7bs5KCGx+Ld1pFaI4hBumQWyEkbiV2IxZ7 u2uC+Gr4KY0UURwGzTCxjWeXrMYcNCqFHWNFfJ8fCgb7JWun/yI1QdX5ZibXZsdSXHmr wBkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kV0J1/FM+1iF9G81TOXk0JsrKpONZFmg5K8V55ImZCc=; b=cgAzemY7B1F/6uDMuyTwMzAAXy5L5tE63/+jwgIvD245MJxzb8FSv5EmBS+odubcE9 mlx3tvsZud1visgSh3YNSoahfxysw08rkaJv0voVHG5VMDQpr4o6QKS39bs1wPUxzmxF /zWPwUGtJ2P0/4ajrxi7vycf9Fg2hElK43JScVHlsH6uqyD+QNzUq2OxZCVgxTPoBiPZ R7AjP2t3nuwzRqnF2DYBiEWihpH+l7/xwtdVoML4Zz55bQMOQ6KoeCOk+a2HaZI/Gi0v 0oXAMXvC+pxscsnOyXd6kZx2eYS7pQYZkNVxBXTXeS5BjcKJ+huZAF7rOdKZ4/IXjaqX 1DbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=nqcZlHh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a17090668ce00b008432fa22567si1092597ejr.649.2023.02.08.01.54.09; Wed, 08 Feb 2023 01:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=nqcZlHh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbjBHJuj (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Wed, 8 Feb 2023 04:50:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbjBHJuW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Feb 2023 04:50:22 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5021816307 for <linux-kernel@vger.kernel.org>; Wed, 8 Feb 2023 01:50:16 -0800 (PST) X-UUID: fb0d5250a79511eda06fc9ecc4dadd91-20230208 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=kV0J1/FM+1iF9G81TOXk0JsrKpONZFmg5K8V55ImZCc=; b=nqcZlHh+RLCBZJNKC2TI/DeatpTMppLWNeM76LFp11FQv9nyYbeK3Dcf7QUbiDhDmhizjhFjvWpELoQLCBkmcZMhmHB+BhA9QT1C0rXaY21WmhNnfIVOKUqhGPoK2xPSH/blYw4KYtJyNpfOGuw/+hyvSdYDbDgIUY4D64b/OFA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:2893d28c-26e7-4786-910f-f555578b4ad2,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:885ddb2,CLOUDID:105dd5f7-ff42-4fb0-b929-626456a83c14,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: fb0d5250a79511eda06fc9ecc4dadd91-20230208 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from <walter.chang@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 439345689; Wed, 08 Feb 2023 17:50:12 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.194) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 8 Feb 2023 17:50:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 8 Feb 2023 17:50:10 +0800 From: <walter.chang@mediatek.com> To: Daniel Lezcano <daniel.lezcano@linaro.org>, Thomas Gleixner <tglx@linutronix.de>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, "Maciej W . Rozycki" <macro@orcam.me.uk>, John Stultz <jstultz@google.com> CC: <wsd_upstream@mediatek.com>, <stanley.chu@mediatek.com>, <Chun-hung.Wu@mediatek.com>, <Freddy.Hsin@mediatek.com>, Chun-Hung Wu <chun-hung.wu@mediatek.com>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org> Subject: [PATCH 1/3] time/sched_clock: Export sched_clock_register() Date: Wed, 8 Feb 2023 17:48:02 +0800 Message-ID: <20230208094813.20874-2-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230208094813.20874-1-walter.chang@mediatek.com> References: <20230208094813.20874-1-walter.chang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757256166043696632?= X-GMAIL-MSGID: =?utf-8?q?1757256166043696632?= |
Series |
Support timer drivers as loadable modules
|
|
Commit Message
Walter Chang (張維哲)
Feb. 8, 2023, 9:48 a.m. UTC
From: Chun-Hung Wu <chun-hung.wu@mediatek.com> clocksource driver may use sched_clock_register() to resigter itself as a sched_clock source. Export it to support building such driver as module, like timer-mediatek.c Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> --- kernel/time/sched_clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 08/02/2023 10:48, walter.chang@mediatek.com wrote: > From: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > clocksource driver may use sched_clock_register() > to resigter itself as a sched_clock source. > Export it to support building such driver > as module, like timer-mediatek.c > > Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> > --- > kernel/time/sched_clock.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c > index 8464c5acc913..8e49e87d1221 100644 > --- a/kernel/time/sched_clock.c > +++ b/kernel/time/sched_clock.c > @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) > return HRTIMER_RESTART; > } > > -void __init > -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) Is there a non-init caller? > { > u64 res, wrap, new_mask, new_epoch, cyc, ns; > u32 new_mult, new_shift; > @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > > pr_debug("Registered %pS as sched_clock source\n", read); > } > +EXPORT_SYMBOL_GPL(sched_clock_register); Where is the module using it? You need to bring users of these two changes, not just prepare something for your out of tree patches. Best regards, Krzysztof
On 08/02/2023 15:24, Krzysztof Kozlowski wrote: > On 08/02/2023 10:48, walter.chang@mediatek.com wrote: >> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> >> >> clocksource driver may use sched_clock_register() >> to resigter itself as a sched_clock source. >> Export it to support building such driver >> as module, like timer-mediatek.c >> >> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> >> --- >> kernel/time/sched_clock.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c >> index 8464c5acc913..8e49e87d1221 100644 >> --- a/kernel/time/sched_clock.c >> +++ b/kernel/time/sched_clock.c >> @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) >> return HRTIMER_RESTART; >> } >> >> -void __init >> -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >> +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > > Is there a non-init caller? > >> { >> u64 res, wrap, new_mask, new_epoch, cyc, ns; >> u32 new_mult, new_shift; >> @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >> >> pr_debug("Registered %pS as sched_clock source\n", read); >> } >> +EXPORT_SYMBOL_GPL(sched_clock_register); > > Where is the module using it? > > You need to bring users of these two changes, not just prepare something > for your out of tree patches. > I'd propose to add at least one driver that will need these changes, to make it clear why you need that. Regards, Matthias
On 08/02/2023 20:41, Matthias Brugger wrote: > > > On 08/02/2023 15:24, Krzysztof Kozlowski wrote: >> On 08/02/2023 10:48, walter.chang@mediatek.com wrote: >>> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>> >>> clocksource driver may use sched_clock_register() >>> to resigter itself as a sched_clock source. >>> Export it to support building such driver >>> as module, like timer-mediatek.c >>> >>> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>> --- >>> kernel/time/sched_clock.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c >>> index 8464c5acc913..8e49e87d1221 100644 >>> --- a/kernel/time/sched_clock.c >>> +++ b/kernel/time/sched_clock.c >>> @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) >>> return HRTIMER_RESTART; >>> } >>> >>> -void __init >>> -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>> +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >> >> Is there a non-init caller? >> >>> { >>> u64 res, wrap, new_mask, new_epoch, cyc, ns; >>> u32 new_mult, new_shift; >>> @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>> >>> pr_debug("Registered %pS as sched_clock source\n", read); >>> } >>> +EXPORT_SYMBOL_GPL(sched_clock_register); >> >> Where is the module using it? >> >> You need to bring users of these two changes, not just prepare something >> for your out of tree patches. >> > > I'd propose to add at least one driver that will need these changes, to make it > clear why you need that. ... and actually test if the system works fine when booted from such clocksource as a module. I have doubts that and unfortunately folks working on GKI like to put whatever stuff from mainline into modules even if it does not make sense for us (see long time ago discussion about pinctrl drivers). Best regards, Krzysztof
On 08/02/2023 20:45, Krzysztof Kozlowski wrote: > On 08/02/2023 20:41, Matthias Brugger wrote: >> >> >> On 08/02/2023 15:24, Krzysztof Kozlowski wrote: >>> On 08/02/2023 10:48, walter.chang@mediatek.com wrote: >>>> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>> >>>> clocksource driver may use sched_clock_register() >>>> to resigter itself as a sched_clock source. >>>> Export it to support building such driver >>>> as module, like timer-mediatek.c >>>> >>>> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>> --- >>>> kernel/time/sched_clock.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c >>>> index 8464c5acc913..8e49e87d1221 100644 >>>> --- a/kernel/time/sched_clock.c >>>> +++ b/kernel/time/sched_clock.c >>>> @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) >>>> return HRTIMER_RESTART; >>>> } >>>> >>>> -void __init >>>> -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>>> +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>> >>> Is there a non-init caller? >>> >>>> { >>>> u64 res, wrap, new_mask, new_epoch, cyc, ns; >>>> u32 new_mult, new_shift; >>>> @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>>> >>>> pr_debug("Registered %pS as sched_clock source\n", read); >>>> } >>>> +EXPORT_SYMBOL_GPL(sched_clock_register); >>> >>> Where is the module using it? >>> >>> You need to bring users of these two changes, not just prepare something >>> for your out of tree patches. >>> >> >> I'd propose to add at least one driver that will need these changes, to make it >> clear why you need that. > > ... and actually test if the system works fine when booted from such > clocksource as a module. I have doubts that and unfortunately folks > working on GKI like to put whatever stuff from mainline into modules > even if it does not make sense for us (see long time ago discussion > about pinctrl drivers). > Yes thinking about it twice, it makes only sense if the Arm architecture timer is running. Otherwise the system will hang on boot. I know that older MediaTek devices had problems with that...
Il 08/02/23 23:22, Matthias Brugger ha scritto: > > > On 08/02/2023 20:45, Krzysztof Kozlowski wrote: >> On 08/02/2023 20:41, Matthias Brugger wrote: >>> >>> >>> On 08/02/2023 15:24, Krzysztof Kozlowski wrote: >>>> On 08/02/2023 10:48, walter.chang@mediatek.com wrote: >>>>> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>>> >>>>> clocksource driver may use sched_clock_register() >>>>> to resigter itself as a sched_clock source. >>>>> Export it to support building such driver >>>>> as module, like timer-mediatek.c >>>>> >>>>> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>>> --- >>>>> kernel/time/sched_clock.c | 4 ++-- >>>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c >>>>> index 8464c5acc913..8e49e87d1221 100644 >>>>> --- a/kernel/time/sched_clock.c >>>>> +++ b/kernel/time/sched_clock.c >>>>> @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct >>>>> hrtimer *hrt) >>>>> return HRTIMER_RESTART; >>>>> } >>>>> -void __init >>>>> -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>>>> +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) >>>> >>>> Is there a non-init caller? >>>> >>>>> { >>>>> u64 res, wrap, new_mask, new_epoch, cyc, ns; >>>>> u32 new_mult, new_shift; >>>>> @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned >>>>> long rate) >>>>> pr_debug("Registered %pS as sched_clock source\n", read); >>>>> } >>>>> +EXPORT_SYMBOL_GPL(sched_clock_register); >>>> >>>> Where is the module using it? >>>> >>>> You need to bring users of these two changes, not just prepare something >>>> for your out of tree patches. >>>> >>> >>> I'd propose to add at least one driver that will need these changes, to make it >>> clear why you need that. >> >> ... and actually test if the system works fine when booted from such >> clocksource as a module. I have doubts that and unfortunately folks >> working on GKI like to put whatever stuff from mainline into modules >> even if it does not make sense for us (see long time ago discussion >> about pinctrl drivers). >> > > Yes thinking about it twice, it makes only sense if the Arm architecture timer is > running. Otherwise the system will hang on boot. I know that older MediaTek devices > had problems with that... I think also some very old Qualcomm SoCs have the same timer "issue" and I bet that some others as well do. Now, I won't argue about the benefits or drawbacks of having X, Y or Z as a module because it's probably not the right time/place to... but! I was trying to get my brain ticking on this one and I immediately didn't like it: as a matter of fact, this kind of clocksources (especially the arch timer[s]) is boot critical and that's not limited to ARM, anyway... this means that a such a change can't be *that* easy, at all. If you really want to register such a clocksource driver, I would suggest instead to make an addition that allows you to do so, while *not* touching common code paths that are called by multiple architectures and that may need those to stay as they are for one reason or another. *If* this kind of modularization will ever happen, it's something that must be done slowly and again, not in one shot, especially not with one series "taking care of 'em all". Please be careful when touching *core* code. That was just an opinion on something that I can envision to be eventually going wrong in many, many ways... Regards, Angelo
On 08/02/2023 20:45, Krzysztof Kozlowski wrote: > On 08/02/2023 20:41, Matthias Brugger wrote: >> >> >> On 08/02/2023 15:24, Krzysztof Kozlowski wrote: >>> On 08/02/2023 10:48, walter.chang@mediatek.com wrote: >>>> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>> >>>> clocksource driver may use sched_clock_register() >>>> to resigter itself as a sched_clock source. >>>> Export it to support building such driver >>>> as module, like timer-mediatek.c >>>> >>>> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> >>>> --- [ ... ] > ... and actually test if the system works fine when booted from such > clocksource as a module. I have doubts that and unfortunately folks > working on GKI like to put whatever stuff from mainline into modules > even if it does not make sense for us (see long time ago discussion > about pinctrl drivers). +1 It is not the first time there is a proposal to convert the timers to modules. After asking, nobody came with a real study regarding the impact of the modularization of these drivers vs the time core framework and the benefit. My gut feeling is that is not that simple.
On Wed, Feb 08, 2023 at 08:45:15PM +0100, Krzysztof Kozlowski wrote: > On 08/02/2023 20:41, Matthias Brugger wrote: > > On 08/02/2023 15:24, Krzysztof Kozlowski wrote: > >> On 08/02/2023 10:48, walter.chang@mediatek.com wrote: > >>> From: Chun-Hung Wu <chun-hung.wu@mediatek.com> > >>> > >>> clocksource driver may use sched_clock_register() > >>> to resigter itself as a sched_clock source. > >>> Export it to support building such driver > >>> as module, like timer-mediatek.c > >>> > >>> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> > >>> --- > >>> kernel/time/sched_clock.c | 4 ++-- > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c > >>> index 8464c5acc913..8e49e87d1221 100644 > >>> --- a/kernel/time/sched_clock.c > >>> +++ b/kernel/time/sched_clock.c > >>> @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) > >>> return HRTIMER_RESTART; > >>> } > >>> > >>> -void __init > >>> -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > >>> +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > >> > >> Is there a non-init caller? > >> > >>> { > >>> u64 res, wrap, new_mask, new_epoch, cyc, ns; > >>> u32 new_mult, new_shift; > >>> @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) > >>> > >>> pr_debug("Registered %pS as sched_clock source\n", read); > >>> } > >>> +EXPORT_SYMBOL_GPL(sched_clock_register); > >> > >> Where is the module using it? > >> > >> You need to bring users of these two changes, not just prepare something > >> for your out of tree patches. > >> > > > > I'd propose to add at least one driver that will need these changes, to make it > > clear why you need that. > > ... and actually test if the system works fine when booted from such > clocksource as a module. I have doubts that and unfortunately folks > working on GKI like to put whatever stuff from mainline into modules > even if it does not make sense for us (see long time ago discussion > about pinctrl drivers). Just to add, system boot test with these as modules are not sufficient based on the usage of such timers. I am aware of systems where arm architected timer are functional in normal running state of the CPU. They may have bugs/errata where these arch timers(mmio access) are not available when CPUs enter low power idle states. Generally, CPUs enter idle states on boot, but one CPU may not as it will act as broadcast timer. With this added timer, they may achieve all CPUs entering idle states properly. In short the system might be bootable w/o such timers but not power efficient. We need to tests that involve loading and unloading of such modules to see if the transition between this timer as broadcast and one CPU itself as broadcast happens correctly and system survives across such loading and unloading of the modules. Note I am not for/against allowing the such timer as module, but just adding possible testcase to pass to consider if we are allowing it. -- Regards, Sudeep
On Wed, 2023-02-08 at 20:41 +0100, Matthias Brugger wrote: > > On 08/02/2023 15:24, Krzysztof Kozlowski wrote: > > On 08/02/2023 10:48, walter.chang@mediatek.com wrote: > > > From: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > > > > > clocksource driver may use sched_clock_register() > > > to resigter itself as a sched_clock source. > > > Export it to support building such driver > > > as module, like timer-mediatek.c > > > > > > Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > > --- > > > kernel/time/sched_clock.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/kernel/time/sched_clock.c > > > b/kernel/time/sched_clock.c > > > index 8464c5acc913..8e49e87d1221 100644 > > > --- a/kernel/time/sched_clock.c > > > +++ b/kernel/time/sched_clock.c > > > @@ -150,8 +150,7 @@ static enum hrtimer_restart > > > sched_clock_poll(struct hrtimer *hrt) > > > return HRTIMER_RESTART; > > > } > > > > > > -void __init > > > -sched_clock_register(u64 (*read)(void), int bits, unsigned long > > > rate) > > > +void sched_clock_register(u64 (*read)(void), int bits, unsigned > > > long rate) > > > > Is there a non-init caller? > > > > > { > > > u64 res, wrap, new_mask, new_epoch, cyc, ns; > > > u32 new_mult, new_shift; > > > @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int > > > bits, unsigned long rate) > > > > > > pr_debug("Registered %pS as sched_clock source\n", > > > read); > > > } > > > +EXPORT_SYMBOL_GPL(sched_clock_register); > > > > Where is the module using it? > > > > You need to bring users of these two changes, not just prepare > > something > > for your out of tree patches. > > > > I'd propose to add at least one driver that will need these changes, > to make it > clear why you need that. > > Regards, > Matthias I have uploaded another patch to make timer-mediatek.c driver become loadable module. https://lore.kernel.org/lkml/20230210100058.19861-1-walter.chang@mediatek.com/T/#u This driver registers an always-on timer as tick_broadcast_device on MediaTek SoCs. If the system does not load this module, system would also boot normally since Arm Generic Timer will take over this part. Thanks, Walter Chang
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 8464c5acc913..8e49e87d1221 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -150,8 +150,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt) return HRTIMER_RESTART; } -void __init -sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) +void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) { u64 res, wrap, new_mask, new_epoch, cyc, ns; u32 new_mult, new_shift; @@ -223,6 +222,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) pr_debug("Registered %pS as sched_clock source\n", read); } +EXPORT_SYMBOL_GPL(sched_clock_register); void __init generic_sched_clock_init(void) {