From patchwork Fri Nov 20 16:59:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 7670161 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5F89F9F2EC for ; Fri, 20 Nov 2015 16:59:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80F1920439 for ; Fri, 20 Nov 2015 16:59:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43573203DA for ; Fri, 20 Nov 2015 16:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162184AbbKTQ7T (ORCPT ); Fri, 20 Nov 2015 11:59:19 -0500 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35214 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161582AbbKTQ7Q (ORCPT ); Fri, 20 Nov 2015 11:59:16 -0500 Received: by padhk6 with SMTP id hk6so15687740pad.2; Fri, 20 Nov 2015 08:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NpJisKTDt4f9wKm4phKjVEETO5vTtxfT8amqSkTeNgs=; b=UGy4IQ7aHuIJlxCk1kws0UN7+NI//uBom1WO5IbJiEKqjEuFomPeO8lSoTAoaq/Zg9 E6tExhuRTAf4gDjjlTn3CJsj5yBR9JVFRvfOznWxVNwVSBr3SI4lxz9xXWMri7GEhOTy cFJkKme3gJJusbXBzE8rOH53Pze0LYYoAlyBQf5WANQrxUCI0JgoUULAW9WyclPngoty jGwl20LYP3OKxscHoR7JSoL99L3DAMbslHFYhbh+7+yqRQI00YWffoyRN7K/WzIwBFww 27MKebfspzJlCCg6wtS21+r9+Sk8QQdxzneUtS5Ymz6O0NwDvltjlJPCU69B9UH/qXGY oUBw== X-Received: by 10.67.23.229 with SMTP id id5mr20607269pad.64.1448038755718; Fri, 20 Nov 2015 08:59:15 -0800 (PST) Received: from localhost.localdomain ([115.112.130.50]) by smtp.gmail.com with ESMTPSA id qz2sm391345pab.14.2015.11.20.08.59.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Nov 2015 08:59:14 -0800 (PST) From: Anand Moon To: Guenter Roeck , Thierry Reding , Krzysztof Kozlowski , Javier Martinez Canillas , Anand Moon Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH] pwm: Avoid double mutex lock on pwm_enable Date: Fri, 20 Nov 2015 16:59:00 +0000 Message-Id: <1448038740-2811-1-git-send-email-linux.amoon@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit d1cd21427747f15920cd726f5f67a07880e7dee4 (pwm: Set enable state properly on failed call to enable) introduce double lock of mutex on pwm_enable Changes fix the following debug lock warning. [ 2.701720] WARNING: CPU: 3 PID: 0 at kernel/locking/mutex.c:526 __mutex_lock_slowpath+0x3bc/0x404() [ 2.701731] DEBUG_LOCKS_WARN_ON(in_interrupt()) [ 2.701737] Modules linked in: [ 2.701748] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.4.0-rc1-xu4f #24 [ 2.701753] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 2.701787] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 2.701808] [] (show_stack) from [] (dump_stack+0x84/0xc4) [ 2.701824] [] (dump_stack) from [] (warn_slowpath_common+0x80/0xb0) [ 2.701836] [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x30/0x40) [ 2.701849] [] (warn_slowpath_fmt) from [] (__mutex_lock_slowpath+0x3bc/0x404) [ 2.701864] [] (__mutex_lock_slowpath) from [] (mutex_lock+0xc/0x24) [ 2.701884] [] (mutex_lock) from [] (pwm_enable+0x20/0x7c) [ 2.701903] [] (pwm_enable) from [] (led_heartbeat_function+0x74/0x144) [ 2.701919] [] (led_heartbeat_function) from [] (call_timer_fn+0x24/0x98) [ 2.701932] [] (call_timer_fn) from [] (run_timer_softirq+0x160/0x21c) [ 2.701946] [] (run_timer_softirq) from [] (__do_softirq+0x110/0x228) [ 2.701959] [] (__do_softirq) from [] (irq_exit+0xc0/0xfc) [ 2.701976] [] (irq_exit) from [] (__handle_domain_irq+0x80/0xec) [ 2.701990] [] (__handle_domain_irq) from [] (gic_handle_irq+0x54/0x94) [ 2.702001] [] (gic_handle_irq) from [] (__irq_svc+0x54/0x90) [ 2.702008] Exception stack(0xee8bdf88 to 0xee8bdfd0) [ 2.702019] df80: 00000001 00000000 00000000 c001b720 ee8bc000 c0573354 [ 2.702031] dfa0: 00000000 00000000 ee8bdfe0 c07f92e4 c08004b4 c08004bc f0806640 ee8bdfd8 [ 2.702039] dfc0: c0010180 c0010184 60000013 ffffffff [ 2.702053] [] (__irq_svc) from [] (arch_cpu_idle+0x38/0x3c) [ 2.702073] [] (arch_cpu_idle) from [] (cpu_startup_entry+0x1ec/0x270) [ 2.702086] [] (cpu_startup_entry) from [<4000956c>] (0x4000956c) [ 2.702093] ---[ end trace 539af70491f4f1a9 ]--- Signed-off-by: Anand Moon --- drivers/pwm/core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index d24ca5f..b8f035a 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -506,16 +506,12 @@ int pwm_enable(struct pwm_device *pwm) if (!pwm) return -EINVAL; - mutex_lock(&pwm->lock); - if (!test_and_set_bit(PWMF_ENABLED, &pwm->flags)) { err = pwm->chip->ops->enable(pwm->chip, pwm); if (err) clear_bit(PWMF_ENABLED, &pwm->flags); } - mutex_unlock(&pwm->lock); - return err; } EXPORT_SYMBOL_GPL(pwm_enable);