Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp836317ybi; Fri, 12 Jul 2019 05:27:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvy2/EWHuz/oJYsklPYf02ax9DXMVLxrko4Ztjg4e0CWkbZZJ51nxVrvWzh5lgYztxqKjl X-Received: by 2002:a17:90a:2385:: with SMTP id g5mr11813533pje.12.1562934473511; Fri, 12 Jul 2019 05:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934473; cv=none; d=google.com; s=arc-20160816; b=TiOp1/BHPqbljYEVONPvnzfs6fCvFG6vEtl0VoeG3EznzJbd5NoLQVAcay+620pW2N Iq1QgEnEJZME0B4Ilgr1W5xdhwldkfEHt0Yq/G2GIxIxJ+sm3Zej8sMlaNMTWAlmZVSh hZZHX7U2/d2imIFaM8QlVO8c9WAPp+K3EajR286WKOa9CTkOyrWSZeGqjTo2KFmWAXUj s5BaLdFSxFSzGnxGzZIOt+UHMh6mkyQw0q/lQrMS90fUq3r4ENxKkKfSH9Rgt1XvkH3l lb7m18cxZ6qViZpb9S7AkpshO1zuzfTZ5wYdkYUdjla1kmYH8o+GPLKm73KpINwnwqTK CfvQ== 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=xD7HeTO9/GWe/b4GLW6f7JFdOipQmO+owQS7iy7fOa1Haw3K9dsL0flV0mltCx29B9 jD4gvBSPGMngN3LIyA40KeVMbZxd43b4d+WOF5XR9ptKKgSTDKUM0/167RtpgYu3GuNG u2ZQTUcRjZnwSlB9se6GRvzy1Tvng3b6wp7OYXcCVXrfG5w/RBOlJIG/2UxHRDGX5Q5s E9XKBMyvck9iX5YXr36ddgJONOwAMB1ENgPJDBiUsGUbGK/YXq8aSJhJgRFTskYS4jaL B2m3embLuQAtDH8LPzcZ+JMLH0qJjFqiZ8ZQ0cHt1CzswG1AhXWqn5hBUTChpSW2eueP rWig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uuMO5tMl; 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 31si7939128plc.356.2019.07.12.05.27.38; Fri, 12 Jul 2019 05:27:53 -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=uuMO5tMl; 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 S1728428AbfGLM0T (ORCPT + 99 others); Fri, 12 Jul 2019 08:26:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:37254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbfGLM0R (ORCPT ); Fri, 12 Jul 2019 08:26:17 -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 B587C216C4; Fri, 12 Jul 2019 12:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934376; bh=sQda5X8OhbphEM0HiM52nsxQoiE6xU95ggq+w19wymY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uuMO5tMl2+Yuew2JvCJdfprrNFsmt9xpNuYpUj+SpnxB4dqChskjpIaFWMD7cBKhq DAdmI1uxAa3uh+8c0PM6yzeZkDHSzsnq9rOcsGV3Bpio8hKS/NzE/MEwwvBcqIQi2B 3DO4hZK+7iC5PihrBlFpNKFRBVpa/lyV451HyHYs= 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 5.1 036/138] can: m_can: implement errata "Needless activation of MRAF irq" Date: Fri, 12 Jul 2019 14:18:20 +0200 Message-Id: <20190712121630.073815087@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@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