Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1060924ybl; Wed, 14 Aug 2019 10:05:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfUNKqW/f+ju8CyhAF83BOSXowxGH/2n1DutS7RdyuYID/+n6RFD7m+H4uumd/Uq/Dmgc2 X-Received: by 2002:a17:902:ea:: with SMTP id a97mr411116pla.182.1565802326091; Wed, 14 Aug 2019 10:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802326; cv=none; d=google.com; s=arc-20160816; b=uZQigBMo/Gs1j81jF8Zx1wicJ+Up9dQe5s0x5xg0trfAHN4f23sPR7wtc73ZmQvkcz /GO/rRz1WjSLvwOqpC1Mj1rXSmWomjm6hDKrAp1LtYRFECVKXYAr1gckectMrPLMxG5R CbH/dPk5FYaakPfq9sCbeKYD9HLkxPkwd4sa21x8+ZHcJce/wNV8jgvOh4ol0KQTcmE/ n06A65mNV5Usi+92ZnhhZfFst/SFN4kvKPlUM4yn6lZPNEzAloLHl+G8utZ8VzH9Wc1W ZtRQW0Bp2OzpTgMmNOz7r4n5cVNM+0lG+tAvNminntKYfwkX/StdI8TF4eNViOdVgPZD XP4A== 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=fpLNjj+rZoAP29FdHP4rptAMnVfvOcmWy59C9Hz03BY=; b=DwCO758l0R5UGyK8Y1m5J7qcFcOVPCDVmd3NGCZ+uv86yVm9VXSvrx9aBLQ8E+o/Ls N6z074yLW1e0kxap1Tomo9BhoIooAz4uLkr518SvfhsOAhednsqBZBQNz9ou43XqaLN1 C2Be7Lv5/+PoaFbu12l/Jr3LKcy610yo1sejV2gmQtm0LxR3N0rp+ymRxgNNIpdkmG9N fC5D89tdxRUOXONw0nJTRGkszDjzr2PEX8gTdwpXb59PuyZK5wx0VU88NNKmhZcKiyEp RKihWKMO11mVlLkKkiRwqkmdVsphyGj4kH0n3HBRGk9EhZrmr+pN8QEqpeMlfk7iLLY6 kC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eQscw1jc; 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 e23si159279pgv.528.2019.08.14.10.05.09; Wed, 14 Aug 2019 10:05:26 -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=eQscw1jc; 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 S1729071AbfHNRDy (ORCPT + 99 others); Wed, 14 Aug 2019 13:03:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:52572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbfHNRDv (ORCPT ); Wed, 14 Aug 2019 13:03:51 -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 D75FA21880; Wed, 14 Aug 2019 17:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802230; bh=i4JaZPlAIAKbDEgv0AxRQX0K70BEiDs/vRW6yvhAZHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQscw1jcIPBxslH845euSM/WiIdfJYRm/XXS09Vp6qonnV18OIzorEjKT/LtUBNJr mn6MGHrvT2fJNsm3IOTSxeEozbLhBw0Y/yp/TweN+JS0SgcfMfgGKxuQKXssWTHRfV 1KX9jbRurv5OUqZcLJ+vhL4aDXOrjIKIfppaxQdc= 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 5.2 045/144] can: rcar_canfd: fix possible IRQ storm on high load Date: Wed, 14 Aug 2019 19:00:01 +0200 Message-Id: <20190814165801.712085039@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 @@ -1508,10 +1508,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; }