From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80667C433DF for ; Mon, 6 Jul 2020 23:50:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 502EB205CB for ; Mon, 6 Jul 2020 23:50:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="gEAErzWQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726729AbgGFXuN (ORCPT ); Mon, 6 Jul 2020 19:50:13 -0400 Received: from crapouillou.net ([89.234.176.41]:53578 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgGFXuN (ORCPT ); Mon, 6 Jul 2020 19:50:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1594079410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NboD0HuCCOCTz3ZvzoSX9hS0Fzn/G2ArNDsjnk2M+qY=; b=gEAErzWQGyz4moVpKPHo4splZgegEadql6JwC2qaisrd0+qP+TPB2uI3F+nrFS7tqOgfAR MtIT8xWuXZn+f7qSfOMDFerYQy0QG8yZv9gR8Pf+u1KyyrmsfVEQS6PQh+vQvoioabP88Q RNGME1GfxlfaYnyFzs/iaQfnFYjzESg= Date: Tue, 07 Jul 2020 01:49:59 +0200 From: Paul Cercueil Subject: Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer To: Noralf =?iso-8859-1?q?Tr=F8nnes?= Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Sam Ravnborg , stable@vger.kernel.org Message-Id: In-Reply-To: <0dda6b3f-ea8c-6a7e-5c7c-f26874b825c8@tronnes.org> References: <20200703141341.1266263-1-paul@crapouillou.net> <0dda6b3f-ea8c-6a7e-5c7c-f26874b825c8@tronnes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Hi Noralf, Le dim. 5 juil. 2020 =E0 17:58, Noralf Tr=F8nnes a=20 =E9crit : >=20 >=20 > Den 03.07.2020 16.13, skrev Paul Cercueil: >> The function mipi_dbi_spi1_transfer() will transfer its payload as=20 >> 9-bit >> data, the 9th (MSB) bit being the data/command bit. In order to do=20 >> that, >> it unpacks the 8-bit values into 16-bit values, then sets the 9th=20 >> bit if >> the byte corresponds to data, clears it otherwise. The 7 MSB are >> padding. The array of now 16-bit values is then passed to the SPI=20 >> core >> for transfer. >>=20 >> This function was broken since its introduction, as the length of=20 >> the >> SPI transfer was set to the payload size before its conversion, but=20 >> the >> payload doubled in size due to the 8-bit -> 16-bit conversion. >>=20 >> Fixes: 02dd95fe3169 ("drm/tinydrm: Add MIPI DBI support") >> Cc: # 4.10 >=20 > The code was moved to drm_mipi_dbi.c in 5.4 so this patch won't apply > before that. I believe I can submit a patch for pre-5.4 too. >> Signed-off-by: Paul Cercueil >> --- >=20 > Thanks for fixing this, clearly I didn't test this. Probably because=20 > the > aux spi ip block on the Raspberry Pi that can do 9 bit didn't have a > driver at the time. Did you actually test this or was it spotted=20 > reading > the code? I did test it on hardware, yes - that's how I spotted the bug. -Paul > Reviewed-by: Noralf Tr=F8nnes >=20 >> drivers/gpu/drm/drm_mipi_dbi.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >>=20 >> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c=20 >> b/drivers/gpu/drm/drm_mipi_dbi.c >> index bb27c82757f1..bf7888ad9ad4 100644 >> --- a/drivers/gpu/drm/drm_mipi_dbi.c >> +++ b/drivers/gpu/drm/drm_mipi_dbi.c >> @@ -923,7 +923,7 @@ static int mipi_dbi_spi1_transfer(struct=20 >> mipi_dbi *dbi, int dc, >> } >> } >>=20 >> - tr.len =3D chunk; >> + tr.len =3D chunk * 2; >> len -=3D chunk; >>=20 >> ret =3D spi_sync(spi, &m); >>=20 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 604E3C433E0 for ; Tue, 7 Jul 2020 07:27:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29C002065D for ; Tue, 7 Jul 2020 07:27:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="gEAErzWQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29C002065D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 125B66E5D2; Tue, 7 Jul 2020 07:27:08 +0000 (UTC) Received: from crapouillou.net (crapouillou.net [89.234.176.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id D23AC6E48F for ; Mon, 6 Jul 2020 23:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1594079410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NboD0HuCCOCTz3ZvzoSX9hS0Fzn/G2ArNDsjnk2M+qY=; b=gEAErzWQGyz4moVpKPHo4splZgegEadql6JwC2qaisrd0+qP+TPB2uI3F+nrFS7tqOgfAR MtIT8xWuXZn+f7qSfOMDFerYQy0QG8yZv9gR8Pf+u1KyyrmsfVEQS6PQh+vQvoioabP88Q RNGME1GfxlfaYnyFzs/iaQfnFYjzESg= Date: Tue, 07 Jul 2020 01:49:59 +0200 From: Paul Cercueil Subject: Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer To: Noralf =?iso-8859-1?q?Tr=F8nnes?= Message-Id: In-Reply-To: <0dda6b3f-ea8c-6a7e-5c7c-f26874b825c8@tronnes.org> References: <20200703141341.1266263-1-paul@crapouillou.net> <0dda6b3f-ea8c-6a7e-5c7c-f26874b825c8@tronnes.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 07 Jul 2020 07:26:57 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , David Airlie , dri-devel@lists.freedesktop.org, stable@vger.kernel.org, Sam Ravnborg Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Noralf, Le dim. 5 juil. 2020 =E0 17:58, Noralf Tr=F8nnes a = =E9crit : > = > = > Den 03.07.2020 16.13, skrev Paul Cercueil: >> The function mipi_dbi_spi1_transfer() will transfer its payload as = >> 9-bit >> data, the 9th (MSB) bit being the data/command bit. In order to do = >> that, >> it unpacks the 8-bit values into 16-bit values, then sets the 9th = >> bit if >> the byte corresponds to data, clears it otherwise. The 7 MSB are >> padding. The array of now 16-bit values is then passed to the SPI = >> core >> for transfer. >> = >> This function was broken since its introduction, as the length of = >> the >> SPI transfer was set to the payload size before its conversion, but = >> the >> payload doubled in size due to the 8-bit -> 16-bit conversion. >> = >> Fixes: 02dd95fe3169 ("drm/tinydrm: Add MIPI DBI support") >> Cc: # 4.10 > = > The code was moved to drm_mipi_dbi.c in 5.4 so this patch won't apply > before that. I believe I can submit a patch for pre-5.4 too. >> Signed-off-by: Paul Cercueil >> --- > = > Thanks for fixing this, clearly I didn't test this. Probably because = > the > aux spi ip block on the Raspberry Pi that can do 9 bit didn't have a > driver at the time. Did you actually test this or was it spotted = > reading > the code? I did test it on hardware, yes - that's how I spotted the bug. -Paul > Reviewed-by: Noralf Tr=F8nnes > = >> drivers/gpu/drm/drm_mipi_dbi.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> = >> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c = >> b/drivers/gpu/drm/drm_mipi_dbi.c >> index bb27c82757f1..bf7888ad9ad4 100644 >> --- a/drivers/gpu/drm/drm_mipi_dbi.c >> +++ b/drivers/gpu/drm/drm_mipi_dbi.c >> @@ -923,7 +923,7 @@ static int mipi_dbi_spi1_transfer(struct = >> mipi_dbi *dbi, int dc, >> } >> } >> = >> - tr.len =3D chunk; >> + tr.len =3D chunk * 2; >> len -=3D chunk; >> = >> ret =3D spi_sync(spi, &m); >> = _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel