From patchwork Mon Feb 1 20:50:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 8183631 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 619C3BEEE5 for ; Mon, 1 Feb 2016 20:51:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94F972039E for ; Mon, 1 Feb 2016 20:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5CBB20395 for ; Mon, 1 Feb 2016 20:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932443AbcBAUvM (ORCPT ); Mon, 1 Feb 2016 15:51:12 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34973 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932122AbcBAUvI (ORCPT ); Mon, 1 Feb 2016 15:51:08 -0500 Received: by mail-wm0-f66.google.com with SMTP id l66so10824508wml.2 for ; Mon, 01 Feb 2016 12:51:07 -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=j/xvikhjoSqw329E55NE5DoXl6NCNsr5ndvFzlN0pK8=; b=UXrmeEMumCL/occmDxum27/RvPm1XgOHDeTRge5+S6Zy5axU5y+vKpXyRqfBHW9yJL Mr4bS9E3ZPP9MfPWeVRAVMkghZa1tZ/b1yZaf+68rQRRPHwQbGE9ZFwm9IKXcZZOf07L XbvKgaDUSQxyOhMI/h4Q1vh9zVIdYyf+3x0jMvNnrmOt7CXw3Wu2kkPQb5MozYgwP0rs 7XI0bxdCOtzB5ADNF99wHT6C5l/8XqgFyvp2mqmhXhSyVglqn9HftElUzFpbUFOUbmix A1p/DWE9C7fgPR+RpMzUmaMLryP4iVihRVD29jNy9Y1sMcyNu6KtkRnJfd1iTm52wpdO kVhg== 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=j/xvikhjoSqw329E55NE5DoXl6NCNsr5ndvFzlN0pK8=; b=NYEpuI+DWkPLsHrX2zabTUhFI7NNQBKCjjBtDto0bDG4pFW59GNxbIccNT+tBTP/k2 B6JGs2/U9l9MA9mfnXNrIqH6+41Xo6G0OisrsK4CItoACZRc4Fb4BIayj4b0OTmvQx7+ BWLKozrsK9ySjExQZDkTUVQHsqJGeHs8tpSZ8Rf+D1elJXgr7Fc5E5QjQ86Iy7wL49a0 gJnk29YkYQvJNGViGboZ6h4OmwPslNIVAuQCdKhjQnVonPvIgIRjYPtTu5C26Y1o0VI0 xUzp3GLe/09fgDj+PzpkQnpo/XPJLfb+Fa/Pzs4BsPVnOwlfBbixLJuRPfFi7yPs4x76 DNng== X-Gm-Message-State: AG10YOTLpIsQ7P6UoEOAwmvtoueMmAMStqVBlILm4NYJPN0adut/cMaY60p5YMtDRYT8sA== X-Received: by 10.194.250.39 with SMTP id yz7mr28082347wjc.92.1454359867230; Mon, 01 Feb 2016 12:51:07 -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 w136sm13240150wmw.0.2016.02.01.12.51.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 01 Feb 2016 12:51:06 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 3/3] media: rc: nuvoton: fix locking issue when calling nvt_disable_cir To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <56AFC52F.2030301@gmail.com> Date: Mon, 1 Feb 2016 21:50:55 +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=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 nvt_disable_cir calls nvt_disable_logical_dev (that may sleep) and is called from contexts holding a spinlock. Fix this and remove the unneeded clearing of CIR_IREN as this is done in nvt_cir_disable already. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index a6ea75d..34dc1c3 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -950,6 +950,10 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data) static void nvt_disable_cir(struct nvt_dev *nvt) { + unsigned long flags; + + spin_lock_irqsave(&nvt->nvt_lock, flags); + /* disable CIR interrupts */ nvt_cir_reg_write(nvt, 0, CIR_IREN); @@ -963,6 +967,8 @@ static void nvt_disable_cir(struct nvt_dev *nvt) nvt_clear_cir_fifo(nvt); nvt_clear_tx_fifo(nvt); + spin_unlock_irqrestore(&nvt->nvt_lock, flags); + /* disable the CIR logical device */ nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR); } @@ -996,11 +1002,8 @@ static int nvt_open(struct rc_dev *dev) static void nvt_close(struct rc_dev *dev) { struct nvt_dev *nvt = dev->priv; - unsigned long flags; - spin_lock_irqsave(&nvt->nvt_lock, flags); nvt_disable_cir(nvt); - spin_unlock_irqrestore(&nvt->nvt_lock, flags); } /* Allocate memory, probe hardware, and initialize everything */ @@ -1151,13 +1154,8 @@ exit_free_dev_rdev: static void nvt_remove(struct pnp_dev *pdev) { struct nvt_dev *nvt = pnp_get_drvdata(pdev); - unsigned long flags; - spin_lock_irqsave(&nvt->nvt_lock, flags); - /* 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);