Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1081677ybl; Wed, 14 Aug 2019 10:23:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqysUIlSy+HaSYqjs9DX/xYDNzhgIxusoiB6ezi325pq3T5O49Jx1LYXmBR+NLkGl1maYIsx X-Received: by 2002:a63:4c5a:: with SMTP id m26mr246991pgl.270.1565803432163; Wed, 14 Aug 2019 10:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803432; cv=none; d=google.com; s=arc-20160816; b=xQaxBzf6k3G7QzjNGghldzhY2bDQ/xIi1v10QhXdWwDLA9y4UYx38pk60BfAv84jr/ v4wa6EOGbHuiom95a22ftoeB/YBJgvO4ux8JgD9kEoc4WeD2UCaPJp9f0o/tWoum2HI8 3WrY75qFatoYFkP00+61G5a2RDjHnE8jQMwz/TWNVgxziLzTgoL39PE/JNElPeV+sA6a cL4in96QiflanMDiUhlr5i5RfQ3K7RQ/5V95xQY2IU2OLkwmc3QKQ7Tv4eLCIrNmuJUv W1ubAd3ARx2c9PcJYn3ovyNaYN9v94O0Mly6H6Vly+ote4nDHExI1Q7LfEPlKZCvm+1v nCFQ== 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=64FWy8R/0K+5u/7JipOzgrrADsxSWgfPeTyeHmM9/yA=; b=KBOv+jwTFQvmjoKwS4WARYgBNupVhN4+i7SckayjQy3EfwepHuTXcHUsiIBom1JjuG wnvIPRaC1GQE25Yf+n55i9BGE/xhXO5Xieek2vkQUn/3F+8tSTL7bSb3UecGXR+AKWn4 xsqoBI+Kuqo03G+oqUfUNGDLeswpihJ6zauSs7Z16KRujbHA9kvGi+jGA1q5GlzA3Fe/ n7ac63hkgCGRtJYwvqakkhVphhBFBrJhJx6Vll9/5t2gXgf6j+b/YyGjJEvQh6QFmBt7 OA3USGwcIjLwRPeBMAP8FOBuv3lgrbi4X++ZfTRHGfTGGlEmc3f76gwqTvBmt3Q8s1Mp A4ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c5fWbNoC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21si192549pgd.223.2019.08.14.10.23.35; Wed, 14 Aug 2019 10:23:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c5fWbNoC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729039AbfHNRVs (ORCPT + 99 others); Wed, 14 Aug 2019 13:21:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730314AbfHNRJ1 (ORCPT ); Wed, 14 Aug 2019 13:09:27 -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 869CA2133F; Wed, 14 Aug 2019 17:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802567; bh=ZOosVN0Ic6Q88AcFPeEupioIcmxpjRiFLM8kbGNB5nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5fWbNoCc7gP+hGtJCYc0+HIEoZ6aCWYK4NqznkGPOwThydJUa9sxDI3j5SbFpT79 G80MPgWAs3sBULuMAl59Yzz1ZrJrthSme+5zizqV8xxDmRWfV2YoKn/MYYjXILXcd0 ugk2vxGqr2w1qkNCVPy76L6fINuV1lDmxRti+IBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikita Yushchenko , Marc Kleine-Budde Subject: [PATCH 4.19 31/91] can: rcar_canfd: fix possible IRQ storm on high load Date: Wed, 14 Aug 2019 19:00:54 +0200 Message-Id: <20190814165751.018391194@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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: Nikita Yushchenko commit d4b890aec4bea7334ca2ca56fd3b12fb48a00cd1 upstream. We have observed rcar_canfd driver entering IRQ storm under high load, with following scenario: - rcar_canfd_global_interrupt() in entered due to Rx available, - napi_schedule_prep() is called, and sets NAPIF_STATE_SCHED in state - Rx fifo interrupts are masked, - rcar_canfd_global_interrupt() is entered again, this time due to error interrupt (e.g. due to overflow), - since scheduled napi poller has not yet executed, condition for calling napi_schedule_prep() from rcar_canfd_global_interrupt() remains true, thus napi_schedule_prep() gets called and sets NAPIF_STATE_MISSED flag in state, - later, napi poller function rcar_canfd_rx_poll() gets executed, and calls napi_complete_done(), - due to NAPIF_STATE_MISSED flag in state, this call does not clear NAPIF_STATE_SCHED flag from state, - on return from napi_complete_done(), rcar_canfd_rx_poll() unmasks Rx interrutps, - Rx interrupt happens, rcar_canfd_global_interrupt() gets called and calls napi_schedule_prep(), - since NAPIF_STATE_SCHED is set in state at this time, this call returns false, - due to that false return, rcar_canfd_global_interrupt() returns without masking Rx interrupt - and this results into IRQ storm: unmasked Rx interrupt happens again and again is misprocessed in the same way. This patch fixes that scenario by unmasking Rx interrupts only when napi_complete_done() returns true, which means it has cleared NAPIF_STATE_SCHED in state. Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver") Signed-off-by: Nikita Yushchenko Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/rcar/rcar_canfd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1512,10 +1512,11 @@ static int rcar_canfd_rx_poll(struct nap /* All packets processed */ if (num_pkts < quota) { - napi_complete_done(napi, num_pkts); - /* Enable Rx FIFO interrupts */ - rcar_canfd_set_bit(priv->base, RCANFD_RFCC(ridx), - RCANFD_RFCC_RFIE); + if (napi_complete_done(napi, num_pkts)) { + /* Enable Rx FIFO interrupts */ + rcar_canfd_set_bit(priv->base, RCANFD_RFCC(ridx), + RCANFD_RFCC_RFIE); + } } return num_pkts; }