From patchwork Thu Jul 16 10:58:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51145 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 87DE722A8A for ; Thu, 16 Jul 2015 10:59:18 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf17411525lbv.3 for ; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=AaKOwrYvdGMwCHf69GZmD1G5uOaOlyfjnqybqUcEr6Y=; b=Jy30U2QanlXZ07TKGcBeBI/BNFwgY1KtTLCIaThy+RWTsbGaGwvlRLyiqdMDNFedRt k0FwPLOpTvNj8sBN3xm6dVgRWBVeNXMSD2VT8B/D8n1QecpVLUPX/k3kb8KgGPrcdQv7 Tmrspicct0uGzG8orgBAM09IVf+BYudGO5/9eKqpbJ0goRgpZM1hMXQLgQUIyMi1hJCa WPxcLWCNsWI7XuGfgHX2spSBh+ICJ6sxdHNw4Zoah4O22m92/5WQdk/ls19UDcubVPWD MqCN7Xv2xZXewn8CGiNI1tqisi9yB72wCVZSBsUpBuqdKurnwyx8HrcJfXlbwHy7pyA6 KRWA== X-Gm-Message-State: ALoCoQnOnXl8ZT9PQPLgDSReG77RvoRUFpeRP3SQqI13CIvixi9CF2I9shxsWDrPNeqDbsaeLd5h X-Received: by 10.112.28.111 with SMTP id a15mr4624605lbh.21.1437044357515; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.169 with SMTP id l9ls356918lah.52.gmail; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) X-Received: by 10.152.234.200 with SMTP id ug8mr8561424lac.63.1437044357338; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id x5si6611213laj.129.2015.07.16.03.59.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 03:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbyj8 with SMTP id yj8so41396668lbb.0 for ; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr8766386laj.88.1437044357222; Thu, 16 Jul 2015 03:59:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp175288lbb; Thu, 16 Jul 2015 03:59:16 -0700 (PDT) X-Received: by 10.70.126.33 with SMTP id mv1mr17616578pdb.64.1437044355360; Thu, 16 Jul 2015 03:59:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gf2si12393584pbd.94.2015.07.16.03.59.13; Thu, 16 Jul 2015 03:59:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754154AbbGPK7L (ORCPT + 26 others); Thu, 16 Jul 2015 06:59:11 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:35424 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbbGPK7H (ORCPT ); Thu, 16 Jul 2015 06:59:07 -0400 Received: by pactm7 with SMTP id tm7so41406479pac.2 for ; Thu, 16 Jul 2015 03:59:06 -0700 (PDT) X-Received: by 10.70.48.229 with SMTP id p5mr17788197pdn.78.1437044346729; Thu, 16 Jul 2015 03:59:06 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id j4sm2036681pdp.36.2015.07.16.03.59.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 03:59:05 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner , Ingo Molnar Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, Viresh Kumar , Jiang Liu , Borislav Petkov , David Rientjes , Bandan Das Subject: [PATCH 1/5] x86/apic: Migrate to new 'set-state' interface Date: Thu, 16 Jul 2015 16:28:44 +0530 Message-Id: <1896ac5989d27f2ac37f4786af9bd537e1921b83.1437042675.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Migrate apic driver to the new 'set-state' interface provided by clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. We weren't doing anything while switching to resume mode and so that callback isn't implemented. Signed-off-by: Viresh Kumar --- arch/x86/kernel/apic/apic.c | 86 +++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index dcb52850a28f..ecd6705c9f4b 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -462,40 +462,53 @@ static int lapic_next_deadline(unsigned long delta, return 0; } -/* - * Setup the lapic timer in periodic or oneshot mode - */ -static void lapic_timer_setup(enum clock_event_mode mode, - struct clock_event_device *evt) +static int lapic_timer_shutdown(struct clock_event_device *evt) { unsigned long flags; unsigned int v; /* Lapic used as dummy for broadcast ? */ if (evt->features & CLOCK_EVT_FEAT_DUMMY) - return; + return 0; local_irq_save(flags); - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - case CLOCK_EVT_MODE_ONESHOT: - __setup_APIC_LVTT(lapic_timer_frequency, - mode != CLOCK_EVT_MODE_PERIODIC, 1); - break; - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - v = apic_read(APIC_LVTT); - v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR); - apic_write(APIC_LVTT, v); - apic_write(APIC_TMICT, 0); - break; - case CLOCK_EVT_MODE_RESUME: - /* Nothing to do here */ - break; - } + v = apic_read(APIC_LVTT); + v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR); + apic_write(APIC_LVTT, v); + apic_write(APIC_TMICT, 0); + + local_irq_restore(flags); + + return 0; +} + +static inline int +lapic_timer_set_periodic_oneshot(struct clock_event_device *evt, bool oneshot) +{ + unsigned long flags; + + /* Lapic used as dummy for broadcast ? */ + if (evt->features & CLOCK_EVT_FEAT_DUMMY) + return 0; + + local_irq_save(flags); + + __setup_APIC_LVTT(lapic_timer_frequency, oneshot, 1); local_irq_restore(flags); + + return 0; +} + +static int lapic_timer_set_periodic(struct clock_event_device *evt) +{ + return lapic_timer_set_periodic_oneshot(evt, false); +} + +static int lapic_timer_set_oneshot(struct clock_event_device *evt) +{ + return lapic_timer_set_periodic_oneshot(evt, true); } /* @@ -513,15 +526,18 @@ static void lapic_timer_broadcast(const struct cpumask *mask) * The local apic timer can be used for any function which is CPU local. */ static struct clock_event_device lapic_clockevent = { - .name = "lapic", - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT - | CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY, - .shift = 32, - .set_mode = lapic_timer_setup, - .set_next_event = lapic_next_event, - .broadcast = lapic_timer_broadcast, - .rating = 100, - .irq = -1, + .name = "lapic", + .features = CLOCK_EVT_FEAT_PERIODIC | + CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP + | CLOCK_EVT_FEAT_DUMMY, + .shift = 32, + .set_state_shutdown = lapic_timer_shutdown, + .set_state_periodic = lapic_timer_set_periodic, + .set_state_oneshot = lapic_timer_set_oneshot, + .set_next_event = lapic_next_event, + .broadcast = lapic_timer_broadcast, + .rating = 100, + .irq = -1, }; static DEFINE_PER_CPU(struct clock_event_device, lapic_events); @@ -778,7 +794,7 @@ static int __init calibrate_APIC_clock(void) * Setup the apic timer manually */ levt->event_handler = lapic_cal_handler; - lapic_timer_setup(CLOCK_EVT_MODE_PERIODIC, levt); + lapic_timer_set_periodic(levt); lapic_cal_loops = -1; /* Let the interrupts run */ @@ -788,7 +804,7 @@ static int __init calibrate_APIC_clock(void) cpu_relax(); /* Stop the lapic timer */ - lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, levt); + lapic_timer_shutdown(levt); /* Jiffies delta */ deltaj = lapic_cal_j2 - lapic_cal_j1; @@ -878,7 +894,7 @@ static void local_apic_timer_interrupt(void) if (!evt->event_handler) { pr_warning("Spurious LAPIC timer interrupt on cpu %d\n", cpu); /* Switch it off */ - lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt); + lapic_timer_shutdown(evt); return; }