[linux-next,v3,4/4] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module
Message ID | 20230419074910.10809-5-walter.chang@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp195038vqo; Wed, 19 Apr 2023 00:55:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YbbNrvrtyjPOy1SE/yH2C0BQoG2bfWoNq7VNwMS6JF4225/LkWa8tn2TPvr2wBeMxQyDV3 X-Received: by 2002:a05:6a20:6a1e:b0:f0:ac6b:379e with SMTP id p30-20020a056a206a1e00b000f0ac6b379emr3139184pzk.4.1681890905879; Wed, 19 Apr 2023 00:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681890905; cv=none; d=google.com; s=arc-20160816; b=Xchk5ATnG1u1cxv2Kgcs/uzXXV6iVQx8NXHpGQl+PJtNZJkMscN8JGLuDDn+WuCJOo SAduQMdHb35MMKRZbyEDEYJr7pc2fUM5zep8WvXEImsvpL+U060FnR4zdpJY0PUXh3IO 8xMgK56c/ENukDKLqHIiADSBGkuVSBugL2L5xkQd53LUu5dXmqbQ8YTzZONTlhdUTbB3 WyOVCxD1gGEmgr0anikpwSBCkxPlHxmmGEdLv3Dzdeq8LqsBzYa8s2Ks4sbjHY2QedZp Gv52Fqstx+Wbkd7D/PJfe/8M3WdM/zcuWDvftgSjPHolXIL7n9M3TmMEwJJjM6BJSrWH d69Q== 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=IHhBOfUYeT77YquBREt22vcfy911MiykLSdiMpD9Yo0=; b=N11bWPgrUvUyTuEiMODJ38AwJraL+Cnj6b5S5YV42kn8PkLpqJDKtC/xCGIQATTfjF oAcqi5uTDtCVHue/I0mPXPeF0o2XMnrpXPK14yBStp2Z5bNSyZF6hZb1cuCcG4lilgi8 hLRoeDCPEuogxo+Nu6jl2OsI+3SDjfe7+7IdB8Q+qmtV3R3VVPtKYMnjkOLU1I2dnlKU pV34e6D4kTlHj7cYkwLvnZEDPsTp2DKoPU2cIfJIHd/HuhDcAxq1On1wHWcxQIdEl08Y PCxx4nse1IxQOmOJx3suGupCuQcJMGPO0yBoQjxoACjxYZRsRUyETsdTF2wVeRo0KBey rKkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rFcmb5xM; 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 n6-20020a63ee46000000b0050f55427e3dsi16318509pgk.701.2023.04.19.00.54.54; Wed, 19 Apr 2023 00:55:05 -0700 (PDT) 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=rFcmb5xM; 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 S232321AbjDSHuI (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Wed, 19 Apr 2023 03:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232526AbjDSHt4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Apr 2023 03:49:56 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FE67AB9 for <linux-kernel@vger.kernel.org>; Wed, 19 Apr 2023 00:49:54 -0700 (PDT) X-UUID: c34bfc68de8611eda9a90f0bb45854f4-20230419 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=IHhBOfUYeT77YquBREt22vcfy911MiykLSdiMpD9Yo0=; b=rFcmb5xMxej7NRtBhk/SzLJTLmt+c2Cxowdk2S98KjpUHk/hl3u3dgms1J8fArLLXPBArfSgMsIVTmKL8Z/T6KtjEdQ3T2dnc1q2RUzc74U9qW+wGBlDGYxDqGE4PJJ87Q2u3ENhbzzqcwikCgY1EjGD2zsBserZ7wyITvAqafk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:b47f5395-83c6-4a88-954c-d51b21018799,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.22,REQID:b47f5395-83c6-4a88-954c-d51b21018799,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:120426c,CLOUDID:b0429084-cd9c-45f5-8134-710979e3df0e,B ulkID:23041915495126IH8NNF,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: c34bfc68de8611eda9a90f0bb45854f4-20230419 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] 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 668331487; Wed, 19 Apr 2023 15:49:50 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Wed, 19 Apr 2023 15:49:48 +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.1118.25 via Frontend Transport; Wed, 19 Apr 2023 15:49:48 +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>, <walter.chang@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 linux-next v3 4/4] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module Date: Wed, 19 Apr 2023 15:49:08 +0800 Message-ID: <20230419074910.10809-5-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230419074910.10809-1-walter.chang@mediatek.com> References: <20230419074910.10809-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,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED 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?1763590438538232829?= X-GMAIL-MSGID: =?utf-8?q?1763590438538232829?= |
Series |
Support timer drivers as loadable modules
|
|
Commit Message
Walter Chang (張維哲)
April 19, 2023, 7:49 a.m. UTC
From: Chun-Hung Wu <chun-hung.wu@mediatek.com> Make the timer-mediatek driver which can register an always-on timer as tick_broadcast_device on MediaTek SoCs become loadable module in GKI. Tested-by: Walter Chang <walter.chang@mediatek.com> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/timer-mediatek.c | 39 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-)
Comments
Il 19/04/23 09:49, walter.chang@mediatek.com ha scritto: > From: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > Make the timer-mediatek driver which can register > an always-on timer as tick_broadcast_device on > MediaTek SoCs become loadable module in GKI. > > Tested-by: Walter Chang <walter.chang@mediatek.com> > Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> I think I typoed your email when sending the example patch for the conversion to platform_device. Check [1], it may be better to just iterate through that? (please ignore the pure_initcall() part, that's a mistake, it's never gonna happen as it automatically becomes a module_init() call). It depends on what maintainers think about that clocksource.h addition, the patch got zero comments, so if you're interested in that perhaps we can explicitly ask what would be the best option between yours and mine; that addition is done only to avoid the big ifdef party that this patch proposes and makes things a bit shorter if this timer modularization goes on with more drivers, but I don't have strong opinions anyway. In the meanwhile, just to eventually speed up integrating this, or the other patch - I'll still give you a review of this one. [1]: https://patchwork.kernel.org/project/linux-mediatek/patch/20230309132119.175650-1-angelogioacchino.delregno@collabora.com/ > --- > drivers/clocksource/Kconfig | 2 +- > drivers/clocksource/timer-mediatek.c | 39 ++++++++++++++++++++++++++++ > 2 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > index 526382dc7482..a7413ad7b6ad 100644 > --- a/drivers/clocksource/Kconfig > +++ b/drivers/clocksource/Kconfig > @@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT > bool > > config MTK_TIMER > - bool "Mediatek timer driver" if COMPILE_TEST > + tristate "Mediatek timer driver" While at it, you could also fix the text, Mediatek -> MediaTek > depends on HAS_IOMEM > select TIMER_OF > select CLKSRC_MMIO > diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c > index 7bcb4a3f26fb..3448848682c0 100644 > --- a/drivers/clocksource/timer-mediatek.c > +++ b/drivers/clocksource/timer-mediatek.c > @@ -13,6 +13,9 @@ > #include <linux/clocksource.h> > #include <linux/interrupt.h> > #include <linux/irqreturn.h> > +#include <linux/module.h> > +#include <linux/of_device.h> > +#include <linux/platform_device.h> > #include <linux/sched_clock.h> > #include <linux/slab.h> > #include "timer-of.h" > @@ -337,5 +340,41 @@ static int __init mtk_gpt_init(struct device_node *node) > > return 0; > } > + > +#ifdef MODULE #ifndef MODULE ... two lines... #else ... a bunch of lines ... #endif looks more readable. I'd go with that. > +static int mtk_timer_probe(struct platform_device *pdev) > +{ > + int (*timer_init)(struct device_node *node); > + struct device_node *np = pdev->dev.of_node; > + > + timer_init = of_device_get_match_data(&pdev->dev); > + return timer_init(np); > +} > + > +static const struct of_device_id mtk_timer_match_table[] = { > + { > + .compatible = "mediatek,mt6577-timer", > + .data = mtk_gpt_init, Fits in one line! > + }, > + { > + .compatible = "mediatek,mt6765-timer", > + .data = mtk_syst_init, ditto. > + }, > + {} Always end with { /* sentinel */ } > +}; > + > +static struct platform_driver mtk_timer_driver = { > + .probe = mtk_timer_probe, > + .driver = { > + .name = "mtk-timer", "mediatek-timer" looks nicer :-) > + .of_match_table = mtk_timer_match_table, > + }, > +}; > +module_platform_driver(mtk_timer_driver); > + > +MODULE_DESCRIPTION("MediaTek Module Timer driver"); "MediaTek Timer driver" is enough, "Module" gets misleading if this gets compiled as built in platform driver (instead of built in timer_of). > +MODULE_LICENSE("GPL v2"); > +#else > TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); > TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); > +#endif
On Wed, 2023-04-19 at 10:10 +0200, AngeloGioacchino Del Regno wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > Il 19/04/23 09:49, walter.chang@mediatek.com ha scritto: > > From: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > > > Make the timer-mediatek driver which can register > > an always-on timer as tick_broadcast_device on > > MediaTek SoCs become loadable module in GKI. > > > > Tested-by: Walter Chang <walter.chang@mediatek.com> > > Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com> > > I think I typoed your email when sending the example patch for the > conversion to platform_device. Check [1], it may be better to just > iterate through that? (please ignore the pure_initcall() part, that's > a mistake, it's never gonna happen as it automatically becomes a > module_init() call). > > It depends on what maintainers think about that clocksource.h > addition, > the patch got zero comments, so if you're interested in that perhaps > we > can explicitly ask what would be the best option between yours and > mine; > that addition is done only to avoid the big ifdef party that this > patch > proposes and makes things a bit shorter if this timer modularization > goes on with more drivers, but I don't have strong opinions anyway. > > In the meanwhile, just to eventually speed up integrating this, or > the > other patch - I'll still give you a review of this one. > > [1]: > https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/20230309132119.175650-1-angelogioacchino.delregno@collabora.com/__;!!CTRNKA9wMg0ARbw!kellIP9qWQwZCUsbK9-s9WForDbz_5-CAGdMIzYbGSXgvXjVGnyGmlmGHeKEbXr_URQeKVHnb6eFAh-fBshGD1KTERh-mzSAlQ$ Thank you for providing an alternative implementation to make the timer driver loadable. We will study whether this solution is feasible. > > > --- > > drivers/clocksource/Kconfig | 2 +- > > drivers/clocksource/timer-mediatek.c | 39 > > ++++++++++++++++++++++++++++ > > 2 files changed, 40 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/clocksource/Kconfig > > b/drivers/clocksource/Kconfig > > index 526382dc7482..a7413ad7b6ad 100644 > > --- a/drivers/clocksource/Kconfig > > +++ b/drivers/clocksource/Kconfig > > @@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT > > bool > > > > config MTK_TIMER > > - bool "Mediatek timer driver" if COMPILE_TEST > > + tristate "Mediatek timer driver" > > While at it, you could also fix the text, Mediatek -> MediaTek > > > depends on HAS_IOMEM > > select TIMER_OF > > select CLKSRC_MMIO > > diff --git a/drivers/clocksource/timer-mediatek.c > > b/drivers/clocksource/timer-mediatek.c > > index 7bcb4a3f26fb..3448848682c0 100644 > > --- a/drivers/clocksource/timer-mediatek.c > > +++ b/drivers/clocksource/timer-mediatek.c > > @@ -13,6 +13,9 @@ > > #include <linux/clocksource.h> > > #include <linux/interrupt.h> > > #include <linux/irqreturn.h> > > +#include <linux/module.h> > > +#include <linux/of_device.h> > > +#include <linux/platform_device.h> > > #include <linux/sched_clock.h> > > #include <linux/slab.h> > > #include "timer-of.h" > > @@ -337,5 +340,41 @@ static int __init mtk_gpt_init(struct > > device_node *node) > > > > return 0; > > } > > + > > +#ifdef MODULE > > #ifndef MODULE > ... two lines... > #else > ... a bunch of lines ... > #endif > > looks more readable. I'd go with that. > > > +static int mtk_timer_probe(struct platform_device *pdev) > > +{ > > + int (*timer_init)(struct device_node *node); > > + struct device_node *np = pdev->dev.of_node; > > + > > + timer_init = of_device_get_match_data(&pdev->dev); > > + return timer_init(np); > > +} > > + > > +static const struct of_device_id mtk_timer_match_table[] = { > > + { > > + .compatible = "mediatek,mt6577-timer", > > + .data = mtk_gpt_init, > > Fits in one line! > > > + }, > > + { > > + .compatible = "mediatek,mt6765-timer", > > + .data = mtk_syst_init, > > ditto. > > > + }, > > + {} > > Always end with { /* sentinel */ } > > > +}; > > + > > +static struct platform_driver mtk_timer_driver = { > > + .probe = mtk_timer_probe, > > + .driver = { > > + .name = "mtk-timer", > > "mediatek-timer" looks nicer :-) > > > + .of_match_table = mtk_timer_match_table, > > + }, > > +}; > > +module_platform_driver(mtk_timer_driver); > > + > > +MODULE_DESCRIPTION("MediaTek Module Timer driver"); > > "MediaTek Timer driver" is enough, "Module" gets misleading if this > gets compiled > as built in platform driver (instead of built in timer_of). > Thanks for your review, I will fix these in next patch. Best regards, Walter Chang
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 526382dc7482..a7413ad7b6ad 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT bool config MTK_TIMER - bool "Mediatek timer driver" if COMPILE_TEST + tristate "Mediatek timer driver" depends on HAS_IOMEM select TIMER_OF select CLKSRC_MMIO diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c index 7bcb4a3f26fb..3448848682c0 100644 --- a/drivers/clocksource/timer-mediatek.c +++ b/drivers/clocksource/timer-mediatek.c @@ -13,6 +13,9 @@ #include <linux/clocksource.h> #include <linux/interrupt.h> #include <linux/irqreturn.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> #include <linux/sched_clock.h> #include <linux/slab.h> #include "timer-of.h" @@ -337,5 +340,41 @@ static int __init mtk_gpt_init(struct device_node *node) return 0; } + +#ifdef MODULE +static int mtk_timer_probe(struct platform_device *pdev) +{ + int (*timer_init)(struct device_node *node); + struct device_node *np = pdev->dev.of_node; + + timer_init = of_device_get_match_data(&pdev->dev); + return timer_init(np); +} + +static const struct of_device_id mtk_timer_match_table[] = { + { + .compatible = "mediatek,mt6577-timer", + .data = mtk_gpt_init, + }, + { + .compatible = "mediatek,mt6765-timer", + .data = mtk_syst_init, + }, + {} +}; + +static struct platform_driver mtk_timer_driver = { + .probe = mtk_timer_probe, + .driver = { + .name = "mtk-timer", + .of_match_table = mtk_timer_match_table, + }, +}; +module_platform_driver(mtk_timer_driver); + +MODULE_DESCRIPTION("MediaTek Module Timer driver"); +MODULE_LICENSE("GPL v2"); +#else TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); +#endif