Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1239102pxa; Thu, 20 Aug 2020 06:29:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzj7jN+ypJDRmxmBHFg077FE4w4dZnoWDsA18g9uV8LhbScrG+HTRw+Nftveqt+Hp6dQuY X-Received: by 2002:a17:906:ae49:: with SMTP id lf9mr2589628ejb.317.1597930151621; Thu, 20 Aug 2020 06:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930151; cv=none; d=google.com; s=arc-20160816; b=wy3CwklWatHG/brKVokm5xhBveoV9ax9CaGARwsygsGV7CpjOQcuJ7VKwgfOGYyRT6 HEefCDdqfAond1bP5En2PurlCHgCWUWbYCqdvIdwoCWxGPP4nCdBjYXuBe8FaoWtxkfb QP767qNAOqhf7196awInY+zRIcixROObDeiwUxyRMZcHaAEmIctDm7V0II3cLU6bMyug 476YPkIS3m7r5ftBU+6LO8KUefMc2HaAU9Ng4TL2YjTFFsbPGKKcb1sj08fq4lIX7vM1 dfjKxYSE7nzCbWy0ep6NbuvZB5sXqyHsNXPG7uVyloXGmZmGznGy+SnHgKEBXwtdzn+7 YRQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0tIFkUaXKVC54ZJPcXQbJKRTCAVFc1XG9WeID86yMCk=; b=rJoE+52vry6AHHMgHKTLSFUmPblUb2TPS5vo6mH52v169WHE3kP2n8+uzuGLajEtXC 2eywjQbYlAJGr7dRKnMGCQL/ibEaNRSWtLs2smTuaABfhEhz7GibmZRM0rXeN8DhOcCY qZZ5MpG9fYAKatQGTwxg8J31jiNf7UVfvbTdhRdt9X/Rz7RrE3Af9y+6cg6Wi4EUdDN2 ZO8YeEQD765zqDZKsCeVgiZ3JUfrwgKutK1EujDDvH/xJQhYikBK2VQn3ZD6vzrjNCbk nvBTPocMjmI5tfxWBZVprR6xTjieMx7vyn9V6eXkjgIcSWKPwi9AVHMGOyzeMg0A+4w8 WHeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xzmsXp4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1343005edb.556.2020.08.20.06.28.47; Thu, 20 Aug 2020 06:29:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xzmsXp4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730743AbgHTNXM (ORCPT + 99 others); Thu, 20 Aug 2020 09:23:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:46214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbgHTJeH (ORCPT ); Thu, 20 Aug 2020 05:34:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3ACFF22BF5; Thu, 20 Aug 2020 09:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597916010; bh=cFSsyY+N9kTR0Cd7a0UjjTB3fTM2An8IueZiXLqrQhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xzmsXp4V+oqsi2JxURJPUnqRVKacd8JAX3eMEp4VMT5E7WU9MT+vCkHzB0uPkXqIl /go66YuWSnbz4PMLU94eRoPjjdgyoZhCVU6ScCrnOsN0+tpoXPre192X1MHVdu8HnE mSWa6C2xqs7Eq6WrhU48GDM5z4H5U6YWiQPDigd8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Lee Jones , Sasha Levin Subject: [PATCH 5.8 212/232] mfd: dln2: Run event handler loop under spinlock Date: Thu, 20 Aug 2020 11:21:03 +0200 Message-Id: <20200820091623.075137583@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 3d858942250820b9adc35f963a257481d6d4c81d ] The event handler loop must be run with interrupts disabled. Otherwise we will have a warning: [ 1970.785649] irq 31 handler lineevent_irq_handler+0x0/0x20 enabled interrupts [ 1970.792739] WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x162/0x170 [ 1970.860732] RIP: 0010:__handle_irq_event_percpu+0x162/0x170 ... [ 1970.946994] Call Trace: [ 1970.949446] [ 1970.951471] handle_irq_event_percpu+0x2c/0x80 [ 1970.955921] handle_irq_event+0x23/0x43 [ 1970.959766] handle_simple_irq+0x57/0x70 [ 1970.963695] generic_handle_irq+0x42/0x50 [ 1970.967717] dln2_rx+0xc1/0x210 [dln2] [ 1970.971479] ? usb_hcd_unmap_urb_for_dma+0xa6/0x1c0 [ 1970.976362] __usb_hcd_giveback_urb+0x77/0xe0 [ 1970.980727] usb_giveback_urb_bh+0x8e/0xe0 [ 1970.984837] tasklet_action_common.isra.0+0x4a/0xe0 ... Recently xHCI driver switched to tasklets in the commit 36dc01657b49 ("usb: host: xhci: Support running urb giveback in tasklet context"). The handle_irq_event_* functions are expected to be called with interrupts disabled and they rightfully complain here because we run in tasklet context with interrupts enabled. Use a event spinlock to protect event handler from being interrupted. Note, that there are only two users of this GPIO and ADC drivers and both of them are using generic_handle_irq() which makes above happen. Fixes: 338a12814297 ("mfd: Add support for Diolan DLN-2 devices") Signed-off-by: Andy Shevchenko Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/dln2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c index 39276fa626d2b..83e676a096dc1 100644 --- a/drivers/mfd/dln2.c +++ b/drivers/mfd/dln2.c @@ -287,7 +287,11 @@ static void dln2_rx(struct urb *urb) len = urb->actual_length - sizeof(struct dln2_header); if (handle == DLN2_HANDLE_EVENT) { + unsigned long flags; + + spin_lock_irqsave(&dln2->event_cb_lock, flags); dln2_run_event_callbacks(dln2, id, echo, data, len); + spin_unlock_irqrestore(&dln2->event_cb_lock, flags); } else { /* URB will be re-submitted in _dln2_transfer (free_rx_slot) */ if (dln2_transfer_complete(dln2, urb, handle, echo)) -- 2.25.1