Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp853710ybi; Fri, 12 Jul 2019 05:45:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOC+qlB1GevPrc9T7WCCyu4C9YhP/xitAlQi05qhbXx83kXTLTG0UWBElxi7mDEtCsjHQo X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr11194333plm.306.1562935502177; Fri, 12 Jul 2019 05:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935502; cv=none; d=google.com; s=arc-20160816; b=hjeTXhjD8qIWAbqtmzHGWaJePCIUk3Z5Ooh4kMhuxbD52xE1N6CRXQyWivNOG13aJX KV5JO/rTl5enI0LAki5pSZ1qdsKrrG2DweYmRyhYUeYs5m5bu5Zr+hos6JA2cYysibfl DGWbIqZpGEj0KBaWwsqU6eBuSTrzbvqjwWfivUbbfT3Gkcw7vOcPKT3mSTXlgUduTi0R zFRGuuz3kH6hSVj9IRsicu1NH6unJXF/zl1ICvHO/cPU9h81xap9bBWIyWT03V7VZrVn 8ffHLg0Zhx/s0OWMRyUN8ytjloS+t5aK5ss7srJmWIvYqT2s/TDdSVEs4EU+u/waP6x7 AXpQ== 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=EHVg8pAR7a883g9Y/sFN834y1FfbiWBHDmXBi8H7ntc=; b=ck0M+zm+whQy4djtZBSUDNKxVkN4j8ITa0ggvooEa5fazUKLfUIXbPMxEE2L+QHnRQ 5naFUv/FnWJEq2MelV3Frn0K86inuBV+Pq+We0JyAgVDrjRF/v3l2+083kGufZG4qE+f fuuLfnhTnQEM7ntV4nVEqEY1oqQf0nLwggJDpMkA0p1XjOILHUauZxHRcXsuZ6dfpgZH SH/kA6QypkNZRNlSsHMGT/l9Dcot1OdjJkFA8Cy3PuPHgAWuZKB7JsG2fhJ0jYhHopGA +M3KoZxSr9iy3vwvTSCZiscRKCU/gSBeGGZQaZuFPwpvl0y+/iFUPQCMjhfptIk0QLec +g+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DlydkyRm; 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 e5si4076942pgc.29.2019.07.12.05.44.46; Fri, 12 Jul 2019 05:45:02 -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=DlydkyRm; 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 S1727309AbfGLMUZ (ORCPT + 99 others); Fri, 12 Jul 2019 08:20:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727287AbfGLMUV (ORCPT ); Fri, 12 Jul 2019 08:20:21 -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 8E4E421670; Fri, 12 Jul 2019 12:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934020; bh=sQda5X8OhbphEM0HiM52nsxQoiE6xU95ggq+w19wymY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DlydkyRmopPahId5CwqEYkOWIs/PlIvlf0PLRN9nE01KuZPgboqBLJoFIdUiT8Y9q kuBT1btEL7c4xexNcmdN2v4nGCVtvJibe3ZSH++wm4fswb8bCwux1AAnsI5wME5MNs IOSOXTH45R+9pC05ptloBbwDsuOtycyVDUmTAIEg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugen Hristev , Ludovic Desroches , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 4.19 20/91] can: m_can: implement errata "Needless activation of MRAF irq" Date: Fri, 12 Jul 2019 14:18:23 +0200 Message-Id: <20190712121622.472929950@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@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 [ Upstream commit 3e82f2f34c930a2a0a9e69fdc2de2f2f1388b442 ] During frame reception while the MCAN is in Error Passive state and the Receive Error Counter has thevalue MCAN_ECR.REC = 127, it may happen that MCAN_IR.MRAF is set although there was no Message RAM access failure. If MCAN_IR.MRAF is enabled, an interrupt to the Host CPU is generated. Work around: The Message RAM Access Failure interrupt routine needs to check whether MCAN_ECR.RP = '1' and MCAN_ECR.REC = '127'. In this case, reset MCAN_IR.MRAF. No further action is required. This affects versions older than 3.2.0 Errata explained on Sama5d2 SoC which includes this hardware block: http://ww1.microchip.com/downloads/en/DeviceDoc/SAMA5D2-Family-Silicon-Errata-and-Data-Sheet-Clarification-DS80000803B.pdf chapter 6.2 Reproducibility: If 2 devices with m_can are connected back to back, configuring different bitrate on them will lead to interrupt storm on the receiving side, with error "Message RAM access failure occurred". Another way is to have a bad hardware connection. Bad wire connection can lead to this issue as well. This patch fixes the issue according to provided workaround. Signed-off-by: Eugen Hristev Reviewed-by: Ludovic Desroches Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/m_can/m_can.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 9b449400376b..deb274a19ba0 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -822,6 +822,27 @@ static int m_can_poll(struct napi_struct *napi, int quota) if (!irqstatus) goto end; + /* Errata workaround for issue "Needless activation of MRAF irq" + * During frame reception while the MCAN is in Error Passive state + * and the Receive Error Counter has the value MCAN_ECR.REC = 127, + * it may happen that MCAN_IR.MRAF is set although there was no + * Message RAM access failure. + * If MCAN_IR.MRAF is enabled, an interrupt to the Host CPU is generated + * The Message RAM Access Failure interrupt routine needs to check + * whether MCAN_ECR.RP = ’1’ and MCAN_ECR.REC = 127. + * In this case, reset MCAN_IR.MRAF. No further action is required. + */ + if ((priv->version <= 31) && (irqstatus & IR_MRAF) && + (m_can_read(priv, M_CAN_ECR) & ECR_RP)) { + struct can_berr_counter bec; + + __m_can_get_berr_counter(dev, &bec); + if (bec.rxerr == 127) { + m_can_write(priv, M_CAN_IR, IR_MRAF); + irqstatus &= ~IR_MRAF; + } + } + psr = m_can_read(priv, M_CAN_PSR); if (irqstatus & IR_ERR_STATE) work_done += m_can_handle_state_errors(dev, psr); -- 2.20.1