lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 10 Sep 2019 16:47:10 +0300
From:   Claudiu Beznea <claudiu.beznea@...rochip.com>
To:     <daniel.lezcano@...aro.org>, <robh+dt@...nel.org>,
        <mark.rutland@....com>, <linux@...linux.org.uk>, <nsekhar@...com>,
        <bgolaszewski@...libre.com>, <monstr@...str.eu>,
        <john@...ozen.org>, <ralf@...ux-mips.org>, <paul.burton@...s.com>,
        <jhogan@...nel.org>, <lftan@...era.com>, <tglx@...utronix.de>,
        <vgupta@...opsys.com>, <marc.zyngier@....com>,
        <patrice.chotard@...com>, <mcoquelin.stm32@...il.com>,
        <alexandre.torgue@...com>, <eric@...olt.net>, <wahrenst@....net>,
        <f.fainelli@...il.com>, <rjui@...adcom.com>,
        <sbranden@...adcom.com>, <bcm-kernel-feedback-list@...adcom.com>,
        <linus.walleij@...aro.org>, <shc_work@...l.ru>, <kgene@...nel.org>,
        <krzk@...nel.org>, <ysato@...rs.sourceforge.jp>,
        <liviu.dudau@....com>, <sudeep.holla@....com>,
        <lorenzo.pieralisi@....com>, <shawnguo@...nel.org>,
        <s.hauer@...gutronix.de>, <kernel@...gutronix.de>,
        <festevam@...il.com>, <linux-imx@....com>, <baohua@...nel.org>,
        <nicolas.ferre@...rochip.com>, <alexandre.belloni@...tlin.com>,
        <ludovic.desroches@...rochip.com>, <baruch@...s.co.il>,
        <u.kleine-koenig@...gutronix.de>, <guoren@...nel.org>,
        <kaloz@...nwrt.org>, <khalasa@...p.pl>, <ssantosh@...nel.org>,
        <vz@...ia.com>, <slemieux.tyco@...il.com>, <khilman@...libre.com>,
        <avifishman70@...il.com>, <tmaimon77@...il.com>,
        <tali.perry1@...il.com>, <venture@...gle.com>, <yuenn@...gle.com>,
        <benjaminfair@...gle.com>, <afaerber@...e.de>,
        <manivannan.sadhasivam@...aro.org>, <narmstrong@...libre.com>,
        <agross@...nel.org>, <palmer@...ive.com>, <aou@...s.berkeley.edu>,
        <heiko@...ech.de>, <orsonzhai@...il.com>, <baolin.wang@...aro.org>,
        <zhang.lyra@...il.com>, <maxime.ripard@...tlin.com>,
        <wens@...e.org>, <thierry.reding@...il.com>,
        <jonathanh@...dia.com>, <linux@...sktech.co.nz>,
        <john.stultz@...aro.org>, <sboyd@...nel.org>,
        <matthias.bgg@...il.com>
CC:     <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mips@...r.kernel.org>, <nios2-dev@...ts.rocketboards.org>,
        <linux-snps-arc@...ts.infradead.org>,
        <linux-stm32@...md-mailman.stormreply.com>,
        <linux-rpi-kernel@...ts.infradead.org>,
        <linux-samsung-soc@...r.kernel.org>,
        <uclinux-h8-devel@...ts.sourceforge.jp>,
        <linux-amlogic@...ts.infradead.org>, <openbmc@...ts.ozlabs.org>,
        <linux-oxnas@...ups.io>, <linux-arm-msm@...r.kernel.org>,
        <linux-unisoc@...ts.infradead.org>,
        <linux-riscv@...ts.infradead.org>,
        <linux-rockchip@...ts.infradead.org>,
        <linux-tegra@...r.kernel.org>,
        <linux-mediatek@...ts.infradead.org>,
        "Claudiu Beznea" <claudiu.beznea@...rochip.com>
Subject: [PATCH 1/7] clocksource/drivers/c-sky: request timer_of_init only for probing CPU

timer_of_init() was initially called for all possible CPUs although it
was requested clock with index 0 for the same device_node on behalf of
all possible CPUs. This patch keeps the timer_of_init() only for probing
CPU and use the information obtained by timer_of_init() to also
initialize the timer_of structure for the rest of CPUs. Since the
probing CPU was requested also a per CPU interrupt, and the
timer_of_init() has such a mechanism implemented, the patch took also
the chance to pass TIMER_OF_IRQ flag to timer_of_init(). Apart from
this csky_mptimer_irq variable was removed and information in per CPU
timer_of objects was used instead (to->clkevt.irq).

Signed-off-by: Claudiu Beznea <claudiu.beznea@...rochip.com>
---
 drivers/clocksource/timer-mp-csky.c | 45 +++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/clocksource/timer-mp-csky.c b/drivers/clocksource/timer-mp-csky.c
index 183a9955160a..dd263c8de580 100644
--- a/drivers/clocksource/timer-mp-csky.c
+++ b/drivers/clocksource/timer-mp-csky.c
@@ -15,7 +15,7 @@
 #define PTIM_LVR	"cr<6, 14>"
 #define PTIM_TSR	"cr<1, 14>"
 
-static int csky_mptimer_irq;
+static irqreturn_t csky_timer_interrupt(int irq, void *dev);
 
 static int csky_mptimer_set_next_event(unsigned long delta,
 				       struct clock_event_device *ce)
@@ -47,7 +47,7 @@ static int csky_mptimer_oneshot_stopped(struct clock_event_device *ce)
 }
 
 static DEFINE_PER_CPU(struct timer_of, csky_to) = {
-	.flags					= TIMER_OF_CLOCK,
+	.flags					= TIMER_OF_CLOCK | TIMER_OF_IRQ,
 	.clkevt = {
 		.rating				= 300,
 		.features			= CLOCK_EVT_FEAT_PERCPU |
@@ -57,6 +57,10 @@ static DEFINE_PER_CPU(struct timer_of, csky_to) = {
 		.set_state_oneshot_stopped	= csky_mptimer_oneshot_stopped,
 		.set_next_event			= csky_mptimer_set_next_event,
 	},
+	.of_irq = {
+		.percpu				= true,
+		.handler			= csky_timer_interrupt,
+	},
 };
 
 static irqreturn_t csky_timer_interrupt(int irq, void *dev)
@@ -79,7 +83,7 @@ static int csky_mptimer_starting_cpu(unsigned int cpu)
 
 	to->clkevt.cpumask = cpumask_of(cpu);
 
-	enable_percpu_irq(csky_mptimer_irq, 0);
+	enable_percpu_irq(to->clkevt.irq, 0);
 
 	clockevents_config_and_register(&to->clkevt, timer_of_rate(to),
 					2, ULONG_MAX);
@@ -89,7 +93,9 @@ static int csky_mptimer_starting_cpu(unsigned int cpu)
 
 static int csky_mptimer_dying_cpu(unsigned int cpu)
 {
-	disable_percpu_irq(csky_mptimer_irq);
+	struct timer_of *to = per_cpu_ptr(&csky_to, cpu);
+
+	disable_percpu_irq(to->clkevt.irq);
 
 	return 0;
 }
@@ -117,8 +123,8 @@ struct clocksource csky_clocksource = {
 
 static int __init csky_mptimer_init(struct device_node *np)
 {
-	int ret, cpu, cpu_rollback;
-	struct timer_of *to = NULL;
+	struct timer_of *to = this_cpu_ptr(&csky_to);
+	int ret, cpu;
 
 	/*
 	 * Csky_mptimer is designed for C-SKY SMP multi-processors and
@@ -132,20 +138,20 @@ static int __init csky_mptimer_init(struct device_node *np)
 	 * We use private irq for the mptimer and irq number is the same
 	 * for every core. So we use request_percpu_irq() in timer_of_init.
 	 */
-	csky_mptimer_irq = irq_of_parse_and_map(np, 0);
-	if (csky_mptimer_irq <= 0)
-		return -EINVAL;
 
-	ret = request_percpu_irq(csky_mptimer_irq, csky_timer_interrupt,
-				 "csky_mp_timer", &csky_to);
+	ret = timer_of_init(np, to);
 	if (ret)
 		return -EINVAL;
 
 	for_each_possible_cpu(cpu) {
-		to = per_cpu_ptr(&csky_to, cpu);
-		ret = timer_of_init(np, to);
-		if (ret)
-			goto rollback;
+		struct timer_of *cpu_to = per_cpu_ptr(&csky_to, cpu);
+
+		if (to == cpu_to)
+			continue;
+
+		cpu_to->clkevt.irq = to->of_irq.irq;
+		cpu_to->of_clk.rate = to->of_clk.rate;
+		cpu_to->of_clk.period = to->of_clk.period;
 	}
 
 	clocksource_register_hz(&csky_clocksource, timer_of_rate(to));
@@ -156,18 +162,13 @@ static int __init csky_mptimer_init(struct device_node *np)
 				csky_mptimer_starting_cpu,
 				csky_mptimer_dying_cpu);
 	if (ret)
-		return -EINVAL;
+		goto rollback;
 
 	return 0;
 
 rollback:
-	for_each_possible_cpu(cpu_rollback) {
-		if (cpu_rollback == cpu)
-			break;
+	timer_of_cleanup(to);
 
-		to = per_cpu_ptr(&csky_to, cpu_rollback);
-		timer_of_cleanup(to);
-	}
 	return -EINVAL;
 }
 TIMER_OF_DECLARE(csky_mptimer, "csky,mptimer", csky_mptimer_init);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ