Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1071208ybl; Wed, 14 Aug 2019 10:13:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHZLZYRW1OjRqSGf3ylaU5UatbTlbSK7RZ/71WmEDmbuZEYlIyV1EJIPQVtVWBJxavfehf X-Received: by 2002:a17:902:b193:: with SMTP id s19mr445611plr.258.1565802829323; Wed, 14 Aug 2019 10:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802829; cv=none; d=google.com; s=arc-20160816; b=CDIC3rSdrOs9VrqJQCizUBkjh2JL8kpbyZ0glccLcc90M8VPP3cnWoyzsKXPRIDwzs HEIh/AkdJ34KQ1A1oNrFKEOl34MkeWmuFw22y61kyoTeUtT8v3CbBOiiO/CBnDgJ0LPI x3+gkCraTcpTR3HS8OLNEIGGMXTxJAp5gAe+YPbRLcZz3Fg3WwjfQsR5nq3tBrSVNAyB 0iGdhBhtCX+VUHve7hWg72eWCiCvomGqP5If6cQOsRahjgtJj5G5/PQH429lPsG3FGzA ciz8zbC4UiOYOeZs83gHzRsGO3BawQdteAvmmGbMmBNRbNa2CuKPD2yMnY7OvgBk1prU cPOA== 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=PQlcU1Kv5M7GjnZw6IFFdkcjfle+Yx5aPVoREjJSB1NZtxmaonumu6unDkl4cKqBBY 3bEhruBNWiPAKJiiFvVE4QPOXcE1rRlUBm/liJfDY2ZZk0cTa/PjyW26XDiu9UxEMk1q INsFK/GsNudundhEnyCmLyf+W/amNicMGg+LA+IT9ZySRpZnVDuvyq3Qe2oWqAYcDtjM CGxediC+DeKCAiyRFoYvPOMY0fzvhE7r4sWJFY7kXKK7ME4959s8l0D5lGbTcKASWjC/ 81W45+vIsRfr6b+z9Y9oCFog0yX9pzfSbROlN+DkFX4gz5+ePkXYGqSePlgTenotwA8K XhnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vp1bTkLG; 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 q10si84655pfc.85.2019.08.14.10.13.33; Wed, 14 Aug 2019 10:13:49 -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=Vp1bTkLG; 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 S1730385AbfHNRNC (ORCPT + 99 others); Wed, 14 Aug 2019 13:13:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730473AbfHNRNA (ORCPT ); Wed, 14 Aug 2019 13:13:00 -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 068D02084D; Wed, 14 Aug 2019 17:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802779; bh=ZOosVN0Ic6Q88AcFPeEupioIcmxpjRiFLM8kbGNB5nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vp1bTkLGdd8DXcVgpXQxSF9fMG29wD1I+ZDTqWrmjPOe7B59mKw5a89i8mp8V42wU oOiLV7jDOvtV/FHzHtnm0B5whBmTWnt1P5/KCN/qU74IhF87ktklxNa97m/KBuJLo5 eyTw+qqIf6oo/fjXFdNNN7MQL/kTBdHNU95i/EUg= 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.14 23/69] can: rcar_canfd: fix possible IRQ storm on high load Date: Wed, 14 Aug 2019 19:01:21 +0200 Message-Id: <20190814165747.089684743@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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; }