From patchwork Thu Sep 12 23:48:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 274621 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D8B2C2C0368 for ; Fri, 13 Sep 2013 09:49:49 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKGdU-0003P3-Jx; Thu, 12 Sep 2013 23:49:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKGdS-0004HD-E9; Thu, 12 Sep 2013 23:49:18 +0000 Received: from mail-db9lp0249.outbound.messaging.microsoft.com ([213.199.154.249] helo=db9outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKGdP-0004Fm-V0 for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2013 23:49:17 +0000 Received: from mail42-db9-R.bigfish.com (10.174.16.243) by DB9EHSOBE023.bigfish.com (10.174.14.86) with Microsoft SMTP Server id 14.1.225.22; Thu, 12 Sep 2013 23:48:46 +0000 Received: from mail42-db9 (localhost [127.0.0.1]) by mail42-db9-R.bigfish.com (Postfix) with ESMTP id 5973B1800FC; Thu, 12 Sep 2013 23:48:46 +0000 (UTC) X-Forefront-Antispam-Report: CIP:149.199.60.83; KIP:(null); UIP:(null); IPV:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI X-SpamScore: -2 X-BigFish: VPS-2(zz98dIc89bh1432I4015Izz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h1de097h8275dhz2fh95h839h93fhd24hf0ah119dh1288h12a5h12a9h12bdh137ah13b6h1441h14ddh1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1fe8h1ff5h209eh906i1155h192ch) Received-SPF: pass (mail42-db9: domain of xilinx.com designates 149.199.60.83 as permitted sender) client-ip=149.199.60.83; envelope-from=soren.brinkmann@xilinx.com; helo=xsj-gw1 ; helo=xsj-gw1 ; Received: from mail42-db9 (localhost.localdomain [127.0.0.1]) by mail42-db9 (MessageSwitch) id 1379029724547098_12017; Thu, 12 Sep 2013 23:48:44 +0000 (UTC) Received: from DB9EHSMHS019.bigfish.com (unknown [10.174.16.236]) by mail42-db9.bigfish.com (Postfix) with ESMTP id 7E5AB140040; Thu, 12 Sep 2013 23:48:44 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by DB9EHSMHS019.bigfish.com (10.174.14.29) with Microsoft SMTP Server id 14.16.227.3; Thu, 12 Sep 2013 23:48:43 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1.xilinx.com) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1VKGct-000351-2g; Thu, 12 Sep 2013 16:48:43 -0700 Date: Thu, 12 Sep 2013 16:48:32 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Thomas Gleixner Subject: Re: [PATCH 1/2] tick: broadcast: Deny per-cpu clockevents from being broadcast sources References: <1379004640-15117-1-git-send-email-soren.brinkmann@xilinx.com> <1379004640-15117-2-git-send-email-soren.brinkmann@xilinx.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-RCIS-Action: ALLOW Message-ID: <54e79f60-d0c4-4897-ab16-ecd50ae7ec0d@DB9EHSMHS019.ehs.local> X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130912_194916_206586_7330D556 X-CRM114-Status: GOOD ( 26.15 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.199.154.249 listed in list.dnswl.org] 0.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Mark Rutland , devicetree@vger.kernel.org, Daniel Lezcano , Russell King , Pawel Moll , Ian Campbell , Stephen Warren , Stephen Boyd , Michal Simek , Rob Herring , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Hi Thomas, On Thu, Sep 12, 2013 at 10:30:15PM +0200, Thomas Gleixner wrote: > On Thu, 12 Sep 2013, Soren Brinkmann wrote: > > From: Stephen Boyd > > > > On most ARM systems the per-cpu clockevents are truly per-cpu in > > the sense that they can't be controlled on any other CPU besides > > the CPU that they interrupt. If one of these clockevents were to > > become a broadcast source we will run into a lot of trouble > > because the broadcast source is enabled on the first CPU to go > > into deep idle (if that CPU suffers from FEAT_C3_STOP) and that > > could be a different CPU than what the clockevent is interrupting > > (or even worse the CPU that the clockevent interrupts could be > > offline). > > > > Theoretically it's possible to support per-cpu clockevents as the > > broadcast source but so far we haven't needed this and supporting > > it is rather complicated. Let's just deny the possibility for now > > until this becomes a reality (let's hope it never does!). > > Well, we can't do it this way. There are globally accessible clock > event devices which deliver only to cpu0. So the mask check might be > causing failure here. > > Just add a feature flag CLOCK_EVT_FEAT_PERCPU to the clock event > device and check for it. I gave it a shot. Is this what you imagine: If this is the way to go, I can prepare this in a v2. Thanks, Sören diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index b66c1f3..c639b1a 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -169,7 +169,8 @@ static int gt_clockevents_init(struct clock_event_device *clk) int cpu = smp_processor_id(); clk->name = "arm_global_timer"; - clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; + clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | + CLOCK_EVT_FEAT_PERCPU; clk->set_mode = gt_clockevent_set_mode; clk->set_next_event = gt_clockevent_set_next_event; clk->cpumask = cpumask_of(cpu); diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 0857922..493aa02 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -60,6 +60,7 @@ enum clock_event_mode { * Core shall set the interrupt affinity dynamically in broadcast mode */ #define CLOCK_EVT_FEAT_DYNIRQ 0x000020 +#define CLOCK_EVT_FEAT_PERCPU 0x000040 /** * struct clock_event_device - clock event device descriptor diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index d3539e5..de4c5d8 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -70,16 +70,14 @@ static bool tick_check_broadcast_device(struct clock_event_device *curdev, struct clock_event_device *newdev) { if ((newdev->features & CLOCK_EVT_FEAT_DUMMY) || - (newdev->features & CLOCK_EVT_FEAT_C3STOP)) + (newdev->features & CLOCK_EVT_FEAT_C3STOP) || + (newdev->features & CLOCK_EVT_FEAT_PERCPU)) return false; if (tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT && !(newdev->features & CLOCK_EVT_FEAT_ONESHOT)) return false; - if (cpumask_equal(newdev->cpumask, cpumask_of(smp_processor_id()))) - return false; - return !curdev || newdev->rating > curdev->rating; }