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 X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F339C2D0A8 for ; Tue, 29 Sep 2020 02:03:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A254A20774 for ; Tue, 29 Sep 2020 02:03:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MU+s9hKP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Q0m6MsJk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A254A20774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Date:To:From: Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4LL0VbQRiibRaAF1vVD2vp7VDR7Y5FQL1lCdaDE9Z6A=; b=MU+s9hKPINdsWJ6XxAsaD/Ghh aEB2VjwEhkQQyocVDJ3yIIjl734bE37dO0/TvLxeLMYFQjyktF3AomMmBSydjLYuWdpERAUdhj/GI zwtBztd9Qo6PJZOKOzzxfNvV90uO+9dMh+42QoLw/74W9xW14Z3co/7I8ZsDEqz7Q88jXnAyp09QN pJE0p1eK6CZJ7ikTe3cbDnVbLCBSt+Uh4iw9TCq/jcxnzoCpNpsA1kqkKX0j4FUYhWosS1zP4mWWl xT30ztOHEpcLdUZU+GVmIQqdTqsR5Nnbgs3fo+2r+YEBpXrEJkdKiHctItEdf62wQx5EBoRJB731q ZJrAaeKtQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kN4xT-0004Pe-HX; Tue, 29 Sep 2020 02:01:35 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kN4xM-0004PC-Vt for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 02:01:33 +0000 X-UUID: ebe7536ef1d64078ad881d7b10681a27-20200928 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=wYBsvhLOmOkEO9oRiClNxAo7IOXOPekgnv6Q8UoSMfo=; b=Q0m6MsJkqe+EeWJY85Rd0NuPJy47wI7VHGo51k/pzjkjYKiutwROURL72i0Tt+6WFafL32AFYglUD9qbdJmXOIsAUQWoUbJZdsvC6aunYe4Q7xPT4kGWg14XxnbcfT1y26CBq2e0cXWAgqcvv0vV4a63A7ExcU0neMdcvKgsf4g=; X-UUID: ebe7536ef1d64078ad881d7b10681a27-20200928 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 45673072; Mon, 28 Sep 2020 18:01:20 -0800 Received: from MTKMBS01N2.mediatek.inc (172.21.101.79) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 28 Sep 2020 18:59:56 -0700 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 29 Sep 2020 09:59:47 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 29 Sep 2020 09:59:48 +0800 Message-ID: <1601344788.23513.0.camel@mtkswgap22> Subject: Re: [PATCH v1 2/2] timer: mt6873: porting Mediatek timer driver to loadable module From: Freddy.Hsin To: Saravana Kannan Date: Tue, 29 Sep 2020 09:59:48 +0800 In-Reply-To: <1598520140.14037.11.camel@mtkswgap22> References: <1595931377-21627-1-git-send-email-freddy.hsin@mediatek.com> <1595931377-21627-3-git-send-email-freddy.hsin@mediatek.com> <87mu3ia2zn.fsf@nanos.tec.linutronix.de> <1598520140.14037.11.camel@mtkswgap22> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-TM-SNTS-SMTP: 7BD11C0BE0089BF4EE6EDC85E8F60EEC0120CA96F97C70D7CF436136051E3B082000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_220130_005486_F1A1B148 X-CRM114-Status: GOOD ( 38.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wsd_upstream@mediatek.com, Daniel Lezcano , kuohong.wang@mediatek.com, LKML , Paul Cercueil , Baolin Wang , "Ben Dooks \(Codethink\)" , chang-an.chen@mediatek.com, "Ahmed S. Darwish" , Matthias Brugger , Thomas Gleixner , stanley.chu@mediatek.com, "moderated list:ARM/Mediatek SoC support" , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 2020-08-27 at 17:22 +0800, Freddy.Hsin wrote: > On Wed, 2020-07-29 at 11:42 -0700, Saravana Kannan wrote: > > On Wed, Jul 29, 2020 at 6:02 AM Thomas Gleixner wrote: > > > > > > Freddy, > > > > > > Freddy Hsin writes: > > > > > > again, please be more careful with subject lines. git log $FILE will > > > give you a hint. > > > > > > > porting Mediatek timer driver to loadable module > > > > > > Repeating the sentence in the subject line is not giving any > > > information. Also changelogs want to tell the WHY and not the WHAT. This > > > also lacks any information why this is actually safe when booting such a > > > system w/o this particular driver built in. What is early boot - up to > > > module load - using as clocksource and timer? > > > > > > > diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c > > > > index 9de7515..5504569 100644 > > > > --- a/drivers/clocksource/mmio.c > > > > +++ b/drivers/clocksource/mmio.c > > > > @@ -21,6 +21,7 @@ u64 clocksource_mmio_readl_up(struct clocksource *c) > > > > { > > > > return (u64)readl_relaxed(to_mmio_clksrc(c)->reg); > > > > } > > > > +EXPORT_SYMBOL(clocksource_mmio_readl_up); > > > > > > Again EXPORT_SYMBOL_GPL() and this wants to be a seperate patch. It has > > > absolutely no business with the mediatek timer changes. > > > > > > > u64 clocksource_mmio_readl_down(struct clocksource *c) > > > > { > > > > @@ -46,7 +47,7 @@ u64 clocksource_mmio_readw_down(struct clocksource *c) > > > > * @bits: Number of valid bits > > > > * @read: One of clocksource_mmio_read*() above > > > > */ > > > > -int __init clocksource_mmio_init(void __iomem *base, const char *name, > > > > +int clocksource_mmio_init(void __iomem *base, const char *name, > > > > > > > > unsigned long hz, int rating, unsigned bits, > > > > u64 (*read)(struct clocksource *)) > > > > { > > > > @@ -68,3 +69,4 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name, > > > > > > > > return clocksource_register_hz(&cs->clksrc, hz); > > > > } > > > > +EXPORT_SYMBOL(clocksource_mmio_init); > > > > > > See above. > > > > > > > diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c > > > > index 9318edc..5c89b6b 100644 > > > > --- a/drivers/clocksource/timer-mediatek.c > > > > +++ b/drivers/clocksource/timer-mediatek.c > > > > @@ -13,6 +13,9 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > +#include > > > > +#include > > > > #include > > > > #include > > > > #include "timer-of.h" > > > > @@ -309,5 +312,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_DESCRIPTION("MEDIATEK Module timer driver"); > > > > +MODULE_LICENSE("GPL v2"); > > > > + > > > > +module_platform_driver(mtk_timer_driver); > > > > +#else > > > > TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); > > > > TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); > > > > +#endif > > > > > > Sorry no. This is not going to happen. > > > > > > The above probe, match table and platform driver structs plus the module* > > > thingies are going to be repeated in every single driver which is going > > > to support module build. Tons of boilerplate copied over and over > > > again. > > > > > > We had exactly the same before TIMER_OF_DECLARE() came around, so pretty > > > please this want's to be some smart macro which handles all of this > > > automatically. > > > > Probably something like what I did for IRQCHIP? > > https://lore.kernel.org/lkml/20200718000637.3632841-1-saravanak@google.com/ > > > > Also, one point that came up with IRQCHIP is that if these drivers can > > be platform drivers, then they should stay that way even when it's > > built in. I'm not sure if that has any other special implications for > > timer code, but raising it in case you'd prefer that here too. > > > > > > -Saravana > > Hi Sravana, > > Thanks for your advice. I already tried to add a common macro for > timer ko drivers as you did for irqchip, but there are some issues > need to be solved. e.g. the event handler cannot be changed to > tick_handle_oneshot_broadcast and rcu warning caused by some cores > are already in idle loop. > > > cat /proc/timer_list > ========================== > > Tick Device: mode: 1 > Broadcast device > Clock Event Device: mtk-clkevt > max_delta_ns: 330382104634 > min_delta_ns: 1000 > mult: 27917287 > shift: 31 > mode: 3 > next_event: 86709384386 nsecs > set_next_event: mtk_syst_clkevt_next_event > shutdown: mtk_syst_clkevt_shutdown > oneshot: mtk_syst_clkevt_oneshot > resume: mtk_syst_clkevt_resume > event_handler: tick_handle_periodic_broadcast > retries: 4 > > > log of loading timer-mediatek.ko > ============================ > > [ 25.658884] init 7: Loaded kernel > module /lib/modules/timer-mediatek.ko > [ 25.658946] ============================= > [ 25.660010] init 7: Loading module /lib/modules/reboot-mode.ko with > args "" > [ 25.660364] WARNING: suspicious RCU usage > [ 25.661831] 5.4.46-g325aef33bcb1-dirty #17 Tainted: G S > W > [ 25.662707] ----------------------------- > [ 25.663254] include/linux/rcupdate.h:601 rcu_read_lock() used > illegally while idle! > [ 25.664279] > [ 25.664279] other info that might help us debug this: > [ 25.665350] RCU used illegally from idle CPU! > [ 25.665350] rcu_scheduler_active = 2, debug_locks = 1 > [ 25.666796] RCU used illegally from extended quiescent state! > [ 25.667571] 2 locks held by swapper/1/0: > [ 25.668105] #0: ffffffec240b9a58 (tick_broadcast_lock){-.-.}, at: > __tick_broadcast_oneshot_control+0x6c/0x444 > [ 25.669460] #1: ffffffec2410e020 (rcu_read_lock){....}, at: > rcu_lock_acquire+0x0/0x40 > [ 25.670536] stack backtrace: > [ 25.671131] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G S W > 5.4.46-g325aef33bcb1-dirty #17 > [ 25.672350] Hardware name: mediatek,mt6873 (DT) > [ 25.672964] Call trace: > [ 25.673310] dump_backtrace.cfi_jt+0x0/0x4 > [ 25.673872] dump_stack+0xf4/0x178 > [ 25.674344] lockdep_rcu_suspicious+0x138/0x154 > [ 25.674961] __cfi_slowpath+0x7c/0x1ec > [ 25.675475] clockevents_program_event+0x288/0x290 > [ 25.676126] __tick_broadcast_oneshot_control+0x2f8/0x444 > [ 25.676856] tick_broadcast_oneshot_control+0x58/0x68 > [ 25.677544] cpuidle_enter_state+0x4c/0x314 > [ 25.678115] cpuidle_enter+0x38/0x50 > [ 25.678608] do_idle.llvm.7895800599653321206+0x1e0/0x2e8 > [ 25.679338] cpu_startup_entry+0x24/0x28 > > BRs, > FreddyHsin > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel