Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3179322imw; Mon, 11 Jul 2022 03:40:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ujfgQKCiO4j1S4N+bvVecOdBLyz4+8NLAiwgX+/Z3HU6+ORXb6P3pO4MIaX0MvrstBARq0 X-Received: by 2002:a50:fc83:0:b0:43a:742e:5e42 with SMTP id f3-20020a50fc83000000b0043a742e5e42mr23294608edq.118.1657536034917; Mon, 11 Jul 2022 03:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536034; cv=none; d=google.com; s=arc-20160816; b=zlJBUWPNvtoifTwsmwO+dIlyhYe1+Ap/wK3hD9tzN8UqR+OSifV/lYJcOH29YdMSZp pj+9Gbu2nDyJcPMXoXjUekdh/vNqt1rXj53ygSvZeXP32FP7uLh34Kjq9f4p6FK9fnzL ufF4R7diICzpECT3hthfXPWrpcxp3nn3rLFU6IEgAw0s7TZwLJaH1S+aQ/VYw4gtyMLe y+37VWQMBtPp2cfSIJuYb+T+xOmo0/XRZFCMdAu4m5K0HK+g+iA7jARglPLSIT2f1+bo SUtvCq6r9HzXFhDlnkPA8B9jw4oT3y9rnrpAmQ8xJjAfvNqOQ+6iP4EYUut7YWVhL72d tByg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qafb59fpMPwiE0fO/t2LDgww+olIYdFiVPsJefQTTg8=; b=dxcijad0tbzk3YzQOgkTuufC43W7c7lg4Mg6sd7FRh7Rd0E3xyudReD46ba5uHvM3E /TP0KJwBMOh/j7P7sUvUFZ9ACE5PqHEJTSMar07RmOp1F6aQDlGj8oLT4woQ+UeliZVK A3NQyNv80a1PdJM5IQOPS0uwx6zqT2r+PwVvRqRnbBcuo04YIGW0uEUMb7CrjAxfPNiC +OlVAAeEcWRRy6+kCDztNt+y2digWFXz2MZca5wIjpVtld46NLPYcxqHkwda24E3F9om LHgCP44V82BhcVFQdTl3uTJDcKBQhyoZ7kYjOBB5MTSvFyhxltd1cIaJ+5+UIzk4oB9o wi5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xAKViFAe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a05640235ca00b0043a992a782dsi11926494edc.450.2022.07.11.03.40.10; Mon, 11 Jul 2022 03:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xAKViFAe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232258AbiGKJ0D (ORCPT + 99 others); Mon, 11 Jul 2022 05:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232334AbiGKJYa (ORCPT ); Mon, 11 Jul 2022 05:24:30 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3B7240B8; Mon, 11 Jul 2022 02:14:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1969CCE1259; Mon, 11 Jul 2022 09:14:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0A78C34115; Mon, 11 Jul 2022 09:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530870; bh=TRtp90YBaVG03YygRHmLfEk23dEDAC+1e/I54l6MBK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xAKViFAe3ccsJ0IfM7Aqkor+bOR0L63uoStpXfNM2vao5MsB473nk0daYxLr0LwWl yKK41+SvQtxlxcI0mSM9RmjFdUnhUoRu3VXZRpIFTWZzPtT1suZStsmbVCHNbYo9q6 zzgYgmVWFBkAR4mnCjxuTaFknb6Nfx4ELiW8Gka0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Kopp , Marc Kleine-Budde Subject: [PATCH 5.18 014/112] can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register Date: Mon, 11 Jul 2022 11:06:14 +0200 Message-Id: <20220711090549.963890864@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090549.543317027@linuxfoundation.org> References: <20220711090549.543317027@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Kopp commit e3d4ee7d5f7f5256dfe89219afcc7a2d553b731f upstream. The mcp251xfd compatible chips have an erratum ([1], [2]), where the received CRC doesn't match the calculated CRC. In commit c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") the following workaround was implementierend. - If a CRC read error on the TBC register is detected and the first byte is 0x00 or 0x80, the most significant bit of the first byte is flipped and the CRC is calculated again. - If the CRC now matches, the _original_ data is passed to the reader. For now we assume transferred data was OK. New investigations and simulations indicate that the CRC send by the device is calculated on correct data, and the data is incorrectly received by the SPI host controller. Use flipped instead of original data and update workaround description in mcp251xfd_regmap_crc_read(). [1] mcp2517fd: DS80000792C: "Incorrect CRC for certain READ_CRC commands" [2] mcp2518fd: DS80000789C: "Incorrect CRC for certain READ_CRC commands" Link: https://lore.kernel.org/all/DM4PR11MB53901D49578FE265B239E55AFB7C9@DM4PR11MB5390.namprd11.prod.outlook.com Fixes: c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") Cc: stable@vger.kernel.org Signed-off-by: Thomas Kopp [mkl: split into 2 patches, update patch description and documentation] Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c @@ -343,9 +343,8 @@ mcp251xfd_regmap_crc_read(void *context, * * If the highest bit in the lowest byte is flipped * the transferred CRC matches the calculated one. We - * assume for now the CRC calculation in the chip - * works on wrong data and the transferred data is - * correct. + * assume for now the CRC operates on the correct + * data. */ if (reg == MCP251XFD_REG_TBC && ((buf_rx->data[0] & 0xf8) == 0x0 || @@ -359,10 +358,8 @@ mcp251xfd_regmap_crc_read(void *context, val_len); if (!err) { /* If CRC is now correct, assume - * transferred data was OK, flip bit - * back to original value. + * flipped data is OK. */ - buf_rx->data[0] ^= 0x80; goto out; } }