From patchwork Tue Jul 23 03:31:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 18524 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B047427776 for ; Tue, 23 Jul 2013 03:31:48 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id q12sf9213543vbe.1 for ; Mon, 22 Jul 2013 20:31:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-transfer-encoding; bh=+5gjI4h5cym4QV1vda3FF7f7+g8EDI1K2qYDhQXjFOM=; b=HHWUvMQLrhyI74B4BCjU57/FrxZnS6nb65UhKIJvagEzTVY30p60Cldq0Kz2iD7Yjo J06bpTcYFR3PwUdUtmCOi+3GMXsLoZHOzRQdHXFCUhdTK0upFe3foY5wFZPZDpc7qOj+ vPDy8nAYgb4gd8wQGRjDj1cgHRPCuQceB131VgCnCJUKdbvAEz0ou5mCqk0qOC6s5wnG Mc/4MfF50S+iwHiaLpWxlCdSW7x4LTEbDlRVaji198omsohDaclTPoYTP072+sfocRPb OEjsKWHXJYgKLN5xe5/GQBlRmWHVY55YoVUW2Jj+bg+IcXzTnll3Yua822bjxNbb1peT bsDQ== X-Received: by 10.236.129.178 with SMTP id h38mr15995549yhi.12.1374550308181; Mon, 22 Jul 2013 20:31:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.129.69 with SMTP id nu5ls2988402qeb.77.gmail; Mon, 22 Jul 2013 20:31:48 -0700 (PDT) X-Received: by 10.220.45.132 with SMTP id e4mr10404879vcf.56.1374550307950; Mon, 22 Jul 2013 20:31:47 -0700 (PDT) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id x9si7825353vec.42.2013.07.22.20.31.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 20:31:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id p13so5196690vbe.28 for ; Mon, 22 Jul 2013 20:31:47 -0700 (PDT) X-Received: by 10.220.203.197 with SMTP id fj5mr10644733vcb.60.1374550307864; Mon, 22 Jul 2013 20:31:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp84144veb; Mon, 22 Jul 2013 20:31:47 -0700 (PDT) X-Received: by 10.224.20.196 with SMTP id g4mr25708658qab.45.1374550305108; Mon, 22 Jul 2013 20:31:45 -0700 (PDT) Received: from relais.videotron.ca (relais.videotron.ca. [24.201.245.36]) by mx.google.com with ESMTP id i7si5237393qcu.54.2013.07.22.20.31.44 for ; Mon, 22 Jul 2013 20:31:45 -0700 (PDT) Received-SPF: neutral (google.com: 24.201.245.36 is neither permitted nor denied by best guess record for domain of nicolas.pitre@linaro.org) client-ip=24.201.245.36; Received: from yoda.home ([70.83.209.44]) by VL-VM-MR004.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0MQD009ECDSV4940@VL-VM-MR004.ip.videotron.ca>; Mon, 22 Jul 2013 23:31:43 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id B65752DA0511; Mon, 22 Jul 2013 23:31:43 -0400 (EDT) From: Nicolas Pitre To: linux-arm-kernel@lists.infradead.org Cc: dave.martin@linaro.org, lorenzo.pieralisi@arm.com, patches@linaro.org Subject: [PATCH 04/13] ARM: bL_switcher: add clockevent save/restore support Date: Mon, 22 Jul 2013 23:31:20 -0400 Message-id: <1374550289-25305-5-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-reply-to: <1374550289-25305-1-git-send-email-nicolas.pitre@linaro.org> References: <1374550289-25305-1-git-send-email-nicolas.pitre@linaro.org> X-Gm-Message-State: ALoCoQmKpYayRW+iGWPx5dHDv0biCP7CXcVgqpufyoHrlIvq7CQtj8guivvZbofD6cCuq2gTGjcl X-Original-Sender: nicolas.pitre@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-transfer-encoding: 7BIT From: Lorenzo Pieralisi Per-CPU timers that are shutdown when a CPU is switched over must be disabled upon switching and reprogrammed on the inbound CPU by relying on the clock events management API. save/restore sequence is executed with irqs disabled as mandated by the clock events API. The next_event is an absolute time, hence, when the inbound CPU resumes, if the timer has expired the min delta is forced into the tick device to fire after few cycles. This patch adds switching support for clock events that are per-CPU and have to be migrated when a switch takes place; the cpumask of the clock event device is checked against the cpumask of the current cpu, and if they match, the clockevent device mode is saved and it is put in shutdown mode. Resume code reprogrammes the tick device accordingly. Tested on A15/A7 fast models and architected timers. Signed-off-by: Lorenzo Pieralisi Signed-off-by: Nicolas Pitre --- arch/arm/common/bL_switcher.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c index e63881b430..d6f7e507d9 100644 --- a/arch/arm/common/bL_switcher.c +++ b/arch/arm/common/bL_switcher.c @@ -15,7 +15,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include #include @@ -122,6 +126,8 @@ static int bL_switchpoint(unsigned long _arg) static int bL_switch_to(unsigned int new_cluster_id) { unsigned int mpidr, cpuid, clusterid, ob_cluster, ib_cluster, this_cpu; + struct tick_device *tdev; + enum clock_event_mode tdev_mode; int ret; mpidr = read_mpidr(); @@ -167,6 +173,14 @@ static int bL_switch_to(unsigned int new_cluster_id) */ arch_send_wakeup_ipi_mask(cpumask_of(this_cpu)); + tdev = tick_get_device(this_cpu); + if (tdev && !cpumask_equal(tdev->evtdev->cpumask, cpumask_of(this_cpu))) + tdev = NULL; + if (tdev) { + tdev_mode = tdev->evtdev->mode; + clockevents_set_mode(tdev->evtdev, CLOCK_EVT_MODE_SHUTDOWN); + } + ret = cpu_pm_enter(); /* we can not tolerate errors at this point */ @@ -197,6 +211,12 @@ static int bL_switch_to(unsigned int new_cluster_id) ret = cpu_pm_exit(); + if (tdev) { + clockevents_set_mode(tdev->evtdev, tdev_mode); + clockevents_program_event(tdev->evtdev, + tdev->evtdev->next_event, 1); + } + local_fiq_enable(); local_irq_enable();