Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp993482ybt; Fri, 19 Jun 2020 20:54:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqwvDD+j7iXOPp2Jnt9ERDwOjMIBfwLS5vt0C0cd5UTAQa46G8S7Q4r3NjbZaP87CSNBDd X-Received: by 2002:a17:907:1118:: with SMTP id qu24mr6259449ejb.287.1592625283723; Fri, 19 Jun 2020 20:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625283; cv=none; d=google.com; s=arc-20160816; b=H9Xe2flkTH1CEHLwUb0mdBYYj4OEi7IFEHTAlOeAnW/mdExQZua67ZXztpfUYint56 ML47kssoHAxc2gZUFGC7UW6wpKdtkKqt8RzKN1kQxUxD0NsAQzfJtmC7YH2hCY3bNVhA oWL9k3kEP9byb1oFrtf1r5Ui5Sd9hpB06JV7jJ+XVmMLQch2HmOtcXHxXWt6r5K/vsvN c786cCwimrB7ZzmHYpNdvuSD65887sL5/Yrr+WTBhDQeeETUCm0q0sdqK2NZNB/T9zJi vXlOnh8T1SDV5IaQKjPUo8HDllUObsjQVkYDKdDytYeG9jm/+thSgtFzkKtsrvJyCXOS KQTw== 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=whEQpGNd80Zgg4Eommg8FdVZKtnpQTlju5fM/C3zX7U=; b=GUnHTtiL68FZoJhHsbiweX8qojachMFszD79LjpqSBp7VH2fvhaIF/Ti12URDVYdKt XyHot7mxre1W7GEpyxRmGY6gIXsUJUiwww6LCqgun6bGlGZRcgK4DCMiEdPSFqn0i1mv au79aNr2QLaAYuXHTydRsCNAMNw/HV4s0G1djkGOcRaMDRHsV0kZSlwAWrKyDbTaSssn DbsLbrdbktnxmx0x4pkX9zNJ1/4BujVgCpAzoBqG5zF+bJenDCXIUN48SwzV4mZV9/An UcDmeUNSsRHu3h75a15oEjjUz6aHEseGOC5lmqRJlOQ8R+KaHt+PnzoSaDjSGvpySVHW VBhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sTnmdRBD; 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 i2si4861209ejr.278.2020.06.19.20.54.21; Fri, 19 Jun 2020 20:54:43 -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=sTnmdRBD; 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 S2394815AbgFSQYy (ORCPT + 99 others); Fri, 19 Jun 2020 12:24:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389898AbgFSO5v (ORCPT ); Fri, 19 Jun 2020 10:57:51 -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 A4F4521835; Fri, 19 Jun 2020 14:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578671; bh=stJzp+0uDkiYIjALJsrQp9bsVu0wkK33koz/CtwL74o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTnmdRBDmcEeIKlOu9GEN6wlvhqqqT8Yrpe+hQMKhbZG9wG1ohhx01SfZ0hjiJYFc 8Zo4qMQMvl/WLbz6D4Md71uB++36WNES+w4Zcd/gG1E9mxTCFHYkMHPU/4DlYvUu1f GXGocqQqgGiK34nZ3RwQZkzC2ZTptwXUcoPn9Fkk= 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 4.19 111/267] clocksource: dw_apb_timer: Make CPU-affiliation being optional Date: Fri, 19 Jun 2020 16:31:36 +0200 Message-Id: <20200619141654.178893412@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@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 1f5f734e4919..a018199575e3 100644 --- a/drivers/clocksource/dw_apb_timer.c +++ b/drivers/clocksource/dw_apb_timer.c @@ -225,7 +225,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. @@ -260,7 +261,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