Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp593400ybt; Fri, 19 Jun 2020 08:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxWqLzPnTcwPJQuYc+I4NifwAOM16+MRpzmAy0U56/GFJL9qlQqmxFvnLCQ4UiKXBIVxo1 X-Received: by 2002:a05:6402:31bb:: with SMTP id dj27mr4111887edb.156.1592582166709; Fri, 19 Jun 2020 08:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582166; cv=none; d=google.com; s=arc-20160816; b=rH6NktPL3MdQCNxUR90u2xCoC9+Y7Z5N28bG4fB8XzJGoQnx3MpJ++Imdy5zkVW568 sExVhL1ufjl/wSfmmOudqVlXaHNgzkMATgwngfynX6sHfXeV2S0oRGY44XHNPDQ5KY9F MoaGPT6QrYh5/XzOBjsr6AzFP6gWxp2r7pUbly3ZuJXWdCXjq4w3tRRY45pndTnGnbJa aOu/aHZhN2gCWEbhT8HeiQlQHOKJjwDhX5LI2vALUIUBkkNsXAxdZercHtNGbmiWMnWs PRIK9TMOtA4FuFWupipJIW0uL94yi7VNaW4QcOwBLs6ZqY3cKSiMTxFueYnOBd+TjyLf PYug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rbJspBvUlJc6hVaZk65ztULauJCxGxXYlWnjUli7hHI=; b=cME6pF2AAYyfCqYqvlE4qi1pz06zmmgj34OgPRyzUGdeNDjgxLV6jSGqsUDoDdtHMT r6lbjxLb6q+MrGnSdGyFHDQfnEJW41cXy6E1QxXj3oeda3wsRJnM1uQmeSkhhbRwlrn4 uxJpDd1cuTVXUchX6Pu5GvJFCOY9Gl1a5BElx5b+ZPgb0yVZrthGJzWYmTDNz18yGAow xyw+xvYQIKALWXb4T6zFByXuF0DHgfTAQThDW5dd7Rtf3N34md1Z3Gp5CoUi+v0Skoc+ rE/YAd8nFJSswcUyP9AbPks+1UMEKCh1bwUAZ960Vz2KMP7rXv2aKRkxyznM4ftZnHV7 T5jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JhCxhHjZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si3948501edx.37.2020.06.19.08.55.44; Fri, 19 Jun 2020 08:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JhCxhHjZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393063AbgFSPWs (ORCPT + 99 others); Fri, 19 Jun 2020 11:22:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:49238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392598AbgFSPS4 (ORCPT ); Fri, 19 Jun 2020 11:18:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B9A52158C; Fri, 19 Jun 2020 15:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579934; bh=Kjt7P2a4tbw5TuKZhyerlZXQZ4Y6YzQHMoiX4ctDvCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhCxhHjZV3hBKJbljR/erFnDBxkl75WPxnGtOZw9oWb+KODHjO+0x/Ccr/UuNa8kC AusmEXFTS6qEEFOdlehOO2ELSEas2MBRVBZS1U8lq1IZ5pGXx3izuFhx8L4B2f9NT8 u13SW0KCYo8m5/5amZAOsVu2c2fDJiYmd1xbBIsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Alessandro Zummo , Alexandre Belloni , Arnd Bergmann , Rob Herring , linux-mips@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, Daniel Lezcano , Sasha Levin Subject: [PATCH 5.7 060/376] clocksource: dw_apb_timer: Make CPU-affiliation being optional Date: Fri, 19 Jun 2020 16:29:38 +0200 Message-Id: <20200619141713.194570064@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Serge Semin [ Upstream commit cee43dbf2ee3f430434e2b66994eff8a1aeda889 ] Currently the DW APB Timer driver binds each clockevent timers to a particular CPU. This isn't good for multiple reasons. First of all seeing the device is placed on APB bus (which makes it accessible from any CPU core), accessible over MMIO and having the DYNIRQ flag set we can be sure that manually binding the timer to any CPU just isn't correct. By doing so we just set an extra limitation on device usage. This also doesn't reflect the device actual capability, since by setting the IRQ affinity we can make it virtually local to any CPU. Secondly imagine if you had a real CPU-local timer with the same rating and the same CPU-affinity. In this case if DW APB timer was registered first, then due to the clockevent framework tick-timer selection procedure we'll end up with the real CPU-local timer being left unselected for clock-events tracking. But on most of the platforms (MIPS/ARM/etc) such timers are normally embedded into the CPU core and are accessible with much better performance then devices placed on APB. For instance in MIPS architectures there is r4k-timer, which is CPU-local, assigned with the same rating, and normally its clockevent device is registered after the platform-specific one. So in order to fix all of these issues let's make the DW APB Timer CPU affinity being optional and deactivated by passing a negative CPU id, which will effectively set the DW APB clockevent timer cpumask to 'cpu_possible_mask'. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: Arnd Bergmann Cc: Rob Herring Cc: linux-mips@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20200521204818.25436-5-Sergey.Semin@baikalelectronics.ru Signed-off-by: Sasha Levin --- drivers/clocksource/dw_apb_timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c index b207a77b0831..f5f24a95ee82 100644 --- a/drivers/clocksource/dw_apb_timer.c +++ b/drivers/clocksource/dw_apb_timer.c @@ -222,7 +222,8 @@ static int apbt_next_event(unsigned long delta, /** * dw_apb_clockevent_init() - use an APB timer as a clock_event_device * - * @cpu: The CPU the events will be targeted at. + * @cpu: The CPU the events will be targeted at or -1 if CPU affiliation + * isn't required. * @name: The name used for the timer and the IRQ for it. * @rating: The rating to give the timer. * @base: I/O base for the timer registers. @@ -257,7 +258,7 @@ dw_apb_clockevent_init(int cpu, const char *name, unsigned rating, dw_ced->ced.max_delta_ticks = 0x7fffffff; dw_ced->ced.min_delta_ns = clockevent_delta2ns(5000, &dw_ced->ced); dw_ced->ced.min_delta_ticks = 5000; - dw_ced->ced.cpumask = cpumask_of(cpu); + dw_ced->ced.cpumask = cpu < 0 ? cpu_possible_mask : cpumask_of(cpu); dw_ced->ced.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_DYNIRQ; dw_ced->ced.set_state_shutdown = apbt_shutdown; -- 2.25.1