Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp117874ybg; Mon, 8 Jun 2020 18:06:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN6ahw/wqp5mxvNlKm6Qc2q5V69kcDJ1ftG0LAd7fXHlurSnvxEEO2Hll88TPSdHRseoX4 X-Received: by 2002:a50:eb0c:: with SMTP id y12mr23863267edp.165.1591664781966; Mon, 08 Jun 2020 18:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664781; cv=none; d=google.com; s=arc-20160816; b=LD4kDW+aDsShz9kYWyA8ShgTAbusCPQeW0Sjob7mBZ05uKjPss5EnoUg4x50NHL4QA ewKxYofO+upKs6u2jAqa1esjTJYKs9ms54dGZ5VGDZ5Bjgy0gAdo51bJyqhsQSy6fhMm QZMAKAOKE3CUgnT9OkLAadoZJqkKsRitz+o1TM+vKn4CyopeLtCttR2dVq9KPGoj81fD QAwYAlaW9hv6dubB9pT8IZzMp27XLkO/WXiCrHIOHGdKar36s57Fi+uiwbS/vfTGA1AE VGznfN0WvlcsVCtib0+WEwgisz5vVIAnfwvx+qYvQZ1uUphds4t7kgupMKNMajw1nFxa LVYA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rbJspBvUlJc6hVaZk65ztULauJCxGxXYlWnjUli7hHI=; b=z8+XQEJsawMSeocMoyopEFpymL5WHyBIjyu2diaH4l0JDqEgI16jFWHDYHYpVUnDxQ DFAfy19ejJ0cYz0kKJ14fOHRw8eRy8D+jeoGEzLDh/W27j6uLxW6lutt/6bYCflbtNQj MiY7Sb6m9Vprgxykn8LD5ZCx+GaZ9fRI0zbb551HushCoiLHg+Ly2LdZglCJyawo7fl+ Zq9oLPxgHjW8EgUbIE3H7tkA1ysUGyHsgcKzgPmiaKWXQ78Vw2AaiSr4B0xGgskBMRjU O+MSJuhQfGj0XRziHCwMxbjptfG9Jws4YXpjGcxiPJbV383Z0Hk8NFUvP7ypPRlUhTcS vtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=njYHY3EI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si9502361ejv.109.2020.06.08.18.05.59; Mon, 08 Jun 2020 18:06:21 -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=njYHY3EI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733222AbgFIBEM (ORCPT + 99 others); Mon, 8 Jun 2020 21:04:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbgFHXHb (ORCPT ); Mon, 8 Jun 2020 19:07:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F7AB20842; Mon, 8 Jun 2020 23:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657650; bh=Kjt7P2a4tbw5TuKZhyerlZXQZ4Y6YzQHMoiX4ctDvCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=njYHY3EIiURi4PbA97BlH/BC27GKJPQVQxo8/UaLPpv9vk2+PkJQyCaLnlrn67Gq3 JG3kaA0DW2EPXaVKLbQG+loEe0JAR3vOW/sxWMKYvGw8BHaUlm/QZ8Iu02TzSJZJBa faZBSTTAYcFMlk7XO++ATU3O72eaQIEPWH4i291Q= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: 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 AUTOSEL 5.7 064/274] clocksource: dw_apb_timer: Make CPU-affiliation being optional Date: Mon, 8 Jun 2020 19:02:37 -0400 Message-Id: <20200608230607.3361041-64-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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