From patchwork Mon Feb 1 20:50:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 8183621 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4F17BEEE5 for ; Mon, 1 Feb 2016 20:51:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA30B20395 for ; Mon, 1 Feb 2016 20:51:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BAE2203A0 for ; Mon, 1 Feb 2016 20:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932441AbcBAUvJ (ORCPT ); Mon, 1 Feb 2016 15:51:09 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34948 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932098AbcBAUvH (ORCPT ); Mon, 1 Feb 2016 15:51:07 -0500 Received: by mail-wm0-f66.google.com with SMTP id l66so10824320wml.2 for ; Mon, 01 Feb 2016 12:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=Y9+MZxBwWecF2rINGMoVSoxjjVMRoBxJGhC4gD1BLIE=; b=uGECt03FnaxiXlsIu43wwaFtgN/+jlmFkNIBci49U3ACJGPjmmJ1Ys87vdDvgV3jCn fJfqakRoUKgtCd+O6v50gHPJ3L7eEM5AFVnLpCXWSAg7H7ES9l2zGswzlIPb73/I43e+ 9h/myYHpch/DpHLECJjBF2ni64zoKvCJqB/eE1NRpb8Xl6rlbDulZ36f0iL9TV0mh+a0 MF6inBTNxgoteJZpbC2dDwECfnawHFjuRuhSu2Qsm3yVca78dbQ2BsynG6LCQwVmS0Or TMoM18xU43MHMA/ELNu36dXJqKg50bgyDqEDIlP6sGb/0RlqeKzPTIINTSIE4tjWv8K9 dp5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-type:content-transfer-encoding; bh=Y9+MZxBwWecF2rINGMoVSoxjjVMRoBxJGhC4gD1BLIE=; b=dbSOE/fTSLX1+HQmPvDacubuRX1ofz5XAugwraJe29lVTA8vgodA33YbUl2m+C+ql7 eZLGJgS9kE0MxRJOQqUtpeVzUCHnNMsdQ5EoWkX01VuxWbn0KZGCeozffEUsHVlwvnbK cLPH1HASHCO5yDY90/pt/lXCybVNywFTqe5RJEvH/M+mTJHE3lICC9RWjdLWSIQL6e48 edqc2L0OuHVJR+c/DgAJ6CMyIbMEv1OO4F2BTfqhk+rifAboeb5rrb0M4+uKNndOlZeO LGVdXuxTgLwWPZFOioJo9vTjC+DDIYcpTQ287hdNsWC7G3nXKS5Nhs13t1mS7q5ZrlSQ jJtA== X-Gm-Message-State: AG10YOQTY/TtyA6uQcbw2j5xFMhY6O7dD9Ot3xLzSMZzMSk4Gq/Ib+EwO4Z92b5E6G/Nzg== X-Received: by 10.194.79.37 with SMTP id g5mr26258392wjx.89.1454359866045; Mon, 01 Feb 2016 12:51:06 -0800 (PST) Received: from ?IPv6:2003:62:5f55:ba00:88d0:d301:d314:c6b6? (p200300625F55BA0088D0D301D314C6B6.dip0.t-ipconnect.de. [2003:62:5f55:ba00:88d0:d301:d314:c6b6]) by smtp.googlemail.com with ESMTPSA id cb2sm30975630wjc.16.2016.02.01.12.51.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 01 Feb 2016 12:51:05 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 2/3] media: rc: nuvoton: fix locking issue when calling nvt_enable_wake To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <56AFC512.5070509@gmail.com> Date: Mon, 1 Feb 2016 21:50:26 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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=ham 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 nvt_enable_wake calls nvt_select_logical_dev (that may sleep) and is called from contexts holding a spinlock. Fix this. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 971858a..a6ea75d 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -503,6 +503,8 @@ static void nvt_cir_wake_regs_init(struct nvt_dev *nvt) static void nvt_enable_wake(struct nvt_dev *nvt) { + unsigned long flags; + nvt_efm_enable(nvt); nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); @@ -514,12 +516,16 @@ static void nvt_enable_wake(struct nvt_dev *nvt) nvt_efm_disable(nvt); + spin_lock_irqsave(&nvt->nvt_lock, flags); + nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN | CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV | CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL, CIR_WAKE_IRCON); nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS); nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); + + spin_unlock_irqrestore(&nvt->nvt_lock, flags); } #if 0 /* Currently unused */ @@ -1151,9 +1157,10 @@ static void nvt_remove(struct pnp_dev *pdev) /* disable CIR */ nvt_cir_reg_write(nvt, 0, CIR_IREN); nvt_disable_cir(nvt); + spin_unlock_irqrestore(&nvt->nvt_lock, flags); + /* enable CIR Wake (for IR power-on) */ nvt_enable_wake(nvt); - spin_unlock_irqrestore(&nvt->nvt_lock, flags); rc_unregister_device(nvt->rdev); } @@ -1178,14 +1185,14 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state) /* disable all CIR interrupts */ nvt_cir_reg_write(nvt, 0, CIR_IREN); + spin_unlock_irqrestore(&nvt->nvt_lock, flags); + /* disable cir logical dev */ nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR); /* make sure wake is enabled */ nvt_enable_wake(nvt); - spin_unlock_irqrestore(&nvt->nvt_lock, flags); - return 0; } @@ -1204,11 +1211,8 @@ static int nvt_resume(struct pnp_dev *pdev) static void nvt_shutdown(struct pnp_dev *pdev) { struct nvt_dev *nvt = pnp_get_drvdata(pdev); - unsigned long flags; - spin_lock_irqsave(&nvt->nvt_lock, flags); nvt_enable_wake(nvt); - spin_unlock_irqrestore(&nvt->nvt_lock, flags); } static const struct pnp_device_id nvt_ids[] = {