From patchwork Thu Sep 6 18:07:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5D9A723E41 for ; Thu, 6 Sep 2012 18:07:56 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 20F53A1877F for ; Thu, 6 Sep 2012 18:06:59 +0000 (UTC) Received: by iafj25 with SMTP id j25so2145291iaf.11 for ; Thu, 06 Sep 2012 11:07:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :content-transfer-encoding:x-content-scanned:x-cbid :x-gm-message-state; bh=BBeI32jeAmn/aHOHM+hd7Fx7FP3jjTmoqJUDo6MybMM=; b=NXGbkm8TrbjoZQB58Kn0CjEtU+gFoXBhhWoYDZdQbu444mb6BXFz8xxXq4ZF0qZqph anaAbnm6GmSL/kjc1QOtSTPd2pTC47l3neV9AedWLLBQhIVJ18PPnqozlrI3hZrcvtVz uLub5Ixigh2H80SQjiP55OutSoufMFnMQiKf2AC5Ab117lGutAnPRK9OnltJAe57lLyU DOzSdtKiofeqJzo6FhBF0FdGe7GIJ7q6nIlsCqgKOXCpNtOk+lcTFTfos2V//mmbdOpL 8hQ8IbtzvtoO1R++s0ZFl88YqCKfUsOr9M2o7u99gN8YyO3KMFsQBqH4JyklTViPsCpA f38w== Received: by 10.50.237.41 with SMTP id uz9mr4304628igc.43.1346954875318; Thu, 06 Sep 2012 11:07:55 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp334820igc; Thu, 6 Sep 2012 11:07:54 -0700 (PDT) Received: by 10.50.156.132 with SMTP id we4mr4344325igb.60.1346954874285; Thu, 06 Sep 2012 11:07:54 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id ak4si4448583icc.40.2012.09.06.11.07.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 11:07:54 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Sep 2012 14:07:53 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Sep 2012 14:07:51 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 4201438C8065; Thu, 6 Sep 2012 14:07:49 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q86I7n72124526; Thu, 6 Sep 2012 14:07:49 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q86I7mEo026276; Thu, 6 Sep 2012 15:07:48 -0300 Received: from kernel-pok.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q86I7mxo026190; Thu, 6 Sep 2012 15:07:48 -0300 From: John Stultz To: lkml Cc: John Stultz , "Rafael J. Wysocki" , Android Team , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , "Jon Medhurst (Tixy)" Subject: [PATCH] wakeup: Use irqsave/irqrestore for events_lock Date: Thu, 6 Sep 2012 14:07:37 -0400 Message-Id: <1346954857-52669-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12090618-7182-0000-0000-000002864E23 X-Gm-Message-State: ALoCoQmXTYRTN27/0CKnFjJroSmE3b+y2mRcd2E2R7sq8HuVwlFR1PpKZR5LUePxB7MzdzNS7E7G Jon Medhurst (Tixy) recently noticed a problem with the events_lock usage. One of the Android patches that uses wakeup_sources calls wakeup_source_add() with irqs disabled. However, the event_lock usage in wakeup_source_add() uses spin_lock_irq()/spin_unlock_irq(), which reenables interrupts. This results in lockdep warnings. The fix is to use spin_lock_irqsave()/spin_lock_irqrestore() instead for the events_lock. Full bug report here: https://bugs.launchpad.net/linaro-landing-team-arm/+bug/1037565 Cc: Rafael J. Wysocki Cc: Android Team Cc: Arve Hjønnevåg Cc: Jon Medhurst (Tixy) Reported-and-debugged-by: Jon Medhurst (Tixy) Signed-off-by: John Stultz --- drivers/base/power/wakeup.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index cbb463b..0e4b093 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -127,6 +127,8 @@ EXPORT_SYMBOL_GPL(wakeup_source_destroy); */ void wakeup_source_add(struct wakeup_source *ws) { + unsigned long flags; + if (WARN_ON(!ws)) return; @@ -135,9 +137,9 @@ void wakeup_source_add(struct wakeup_source *ws) ws->active = false; ws->last_time = ktime_get(); - spin_lock_irq(&events_lock); + spin_lock_irqsave(&events_lock, flags); list_add_rcu(&ws->entry, &wakeup_sources); - spin_unlock_irq(&events_lock); + spin_unlock_irqrestore(&events_lock, flags); } EXPORT_SYMBOL_GPL(wakeup_source_add); @@ -147,12 +149,14 @@ EXPORT_SYMBOL_GPL(wakeup_source_add); */ void wakeup_source_remove(struct wakeup_source *ws) { + unsigned long flags; + if (WARN_ON(!ws)) return; - spin_lock_irq(&events_lock); + spin_lock_irqsave(&events_lock, flags); list_del_rcu(&ws->entry); - spin_unlock_irq(&events_lock); + spin_unlock_irqrestore(&events_lock, flags); synchronize_rcu(); } EXPORT_SYMBOL_GPL(wakeup_source_remove); @@ -723,15 +727,16 @@ bool pm_get_wakeup_count(unsigned int *count, bool block) bool pm_save_wakeup_count(unsigned int count) { unsigned int cnt, inpr; + unsigned long flags; events_check_enabled = false; - spin_lock_irq(&events_lock); + spin_lock_irqsave(&events_lock, flags); split_counters(&cnt, &inpr); if (cnt == count && inpr == 0) { saved_count = count; events_check_enabled = true; } - spin_unlock_irq(&events_lock); + spin_unlock_irqrestore(&events_lock, flags); return events_check_enabled; }