All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-03 14:13 ` Paul Cercueil
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Cercueil @ 2020-07-03 14:13 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Noralf Trønnes, dri-devel, Sam Ravnborg, Paul Cercueil, stable

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: <stable@vger.kernel.org> # 4.10
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 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 = chunk;
+		tr.len = chunk * 2;
 		len -= chunk;
 
 		ret = spi_sync(spi, &m);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-03 14:13 ` Paul Cercueil
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Cercueil @ 2020-07-03 14:13 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Sam Ravnborg, stable, dri-devel

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: <stable@vger.kernel.org> # 4.10
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 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 = chunk;
+		tr.len = chunk * 2;
 		len -= chunk;
 
 		ret = spi_sync(spi, &m);
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
  2020-07-03 14:13 ` Paul Cercueil
@ 2020-07-03 14:23   ` Sam Ravnborg
  -1 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-03 14:23 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Noralf Trønnes, dri-devel,
	stable

On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> 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: <stable@vger.kernel.org> # 4.10
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

As discussed on irc this looks correct to me too.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>


I will apply later, but let's wait and see if Noralf or others
have any feedback first.

	Sam

> ---
>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> -- 
> 2.27.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-03 14:23   ` Sam Ravnborg
  0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-03 14:23 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Thomas Zimmermann, David Airlie, dri-devel, stable

On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> 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: <stable@vger.kernel.org> # 4.10
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

As discussed on irc this looks correct to me too.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>


I will apply later, but let's wait and see if Noralf or others
have any feedback first.

	Sam

> ---
>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> -- 
> 2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
  2020-07-03 14:13 ` Paul Cercueil
@ 2020-07-03 14:26   ` Sam Ravnborg
  -1 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-03 14:26 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Noralf Trønnes, dri-devel,
	stable

On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> 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: <stable@vger.kernel.org> # 4.10
"dim fixes 02dd95fe3169" provides the following output:
Fixes: 02dd95fe3169 ("drm/tinydrm: Add MIPI DBI support")
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: David Lechner <david@lechnology.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.11+

I assume the "Cc: <stable@vger.kernel.org> # 4.11+" is more correct?

	Sam


> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> -- 
> 2.27.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-03 14:26   ` Sam Ravnborg
  0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-03 14:26 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Thomas Zimmermann, David Airlie, dri-devel, stable

On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> 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: <stable@vger.kernel.org> # 4.10
"dim fixes 02dd95fe3169" provides the following output:
Fixes: 02dd95fe3169 ("drm/tinydrm: Add MIPI DBI support")
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: David Lechner <david@lechnology.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.11+

I assume the "Cc: <stable@vger.kernel.org> # 4.11+" is more correct?

	Sam


> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> -- 
> 2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
  2020-07-03 14:13 ` Paul Cercueil
@ 2020-07-05 15:58   ` Noralf Trønnes
  -1 siblings, 0 replies; 12+ messages in thread
From: Noralf Trønnes @ 2020-07-05 15:58 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, Sam Ravnborg, stable



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: <stable@vger.kernel.org> # 4.10

The code was moved to drm_mipi_dbi.c in 5.4 so this patch won't apply
before that.

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---

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?

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>

>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-05 15:58   ` Noralf Trønnes
  0 siblings, 0 replies; 12+ messages in thread
From: Noralf Trønnes @ 2020-07-05 15:58 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: Sam Ravnborg, stable, dri-devel



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: <stable@vger.kernel.org> # 4.10

The code was moved to drm_mipi_dbi.c in 5.4 so this patch won't apply
before that.

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---

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?

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>

>  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 = chunk;
> +		tr.len = chunk * 2;
>  		len -= chunk;
>  
>  		ret = spi_sync(spi, &m);
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
  2020-07-05 15:58   ` Noralf Trønnes
@ 2020-07-06 23:49     ` Paul Cercueil
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Cercueil @ 2020-07-06 23:49 UTC (permalink / raw)
  To: Noralf Trønnes
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, dri-devel, Sam Ravnborg, stable

Hi Noralf,

Le dim. 5 juil. 2020 à 17:58, Noralf Trønnes <noralf@tronnes.org> a 
écrit :
> 
> 
> 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: <stable@vger.kernel.org> # 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 <paul@crapouillou.net>
>>  ---
> 
> 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ønnes <noralf@tronnes.org>
> 
>>   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 = chunk;
>>  +		tr.len = chunk * 2;
>>   		len -= chunk;
>> 
>>   		ret = spi_sync(spi, &m);
>> 



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-06 23:49     ` Paul Cercueil
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Cercueil @ 2020-07-06 23:49 UTC (permalink / raw)
  To: Noralf Trønnes
  Cc: Thomas Zimmermann, David Airlie, dri-devel, stable, Sam Ravnborg

Hi Noralf,

Le dim. 5 juil. 2020 à 17:58, Noralf Trønnes <noralf@tronnes.org> a 
écrit :
> 
> 
> 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: <stable@vger.kernel.org> # 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 <paul@crapouillou.net>
>>  ---
> 
> 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ønnes <noralf@tronnes.org>
> 
>>   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 = chunk;
>>  +		tr.len = chunk * 2;
>>   		len -= chunk;
>> 
>>   		ret = spi_sync(spi, &m);
>> 


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
  2020-07-03 14:23   ` Sam Ravnborg
@ 2020-07-27 18:36     ` Sam Ravnborg
  -1 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-27 18:36 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Thomas Zimmermann, David Airlie, dri-devel, stable

Hi Paul.

On Fri, Jul 03, 2020 at 04:23:57PM +0200, Sam Ravnborg wrote:
> On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> > 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: <stable@vger.kernel.org> # 4.10
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> 
> As discussed on irc this looks correct to me too.
> 
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
> 
> I will apply later, but let's wait and see if Noralf or others
> have any feedback first.
I finally went back to this patch, I missed it yesterday.
Applied to drm-misc-fixes with a stable 5.4+ tag.

	Sam

> > ---
> >  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 = chunk;
> > +		tr.len = chunk * 2;
> >  		len -= chunk;
> >  
> >  		ret = spi_sync(spi, &m);
> > -- 
> > 2.27.0
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer
@ 2020-07-27 18:36     ` Sam Ravnborg
  0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2020-07-27 18:36 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: David Airlie, stable, dri-devel, Thomas Zimmermann

Hi Paul.

On Fri, Jul 03, 2020 at 04:23:57PM +0200, Sam Ravnborg wrote:
> On Fri, Jul 03, 2020 at 04:13:41PM +0200, Paul Cercueil wrote:
> > 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: <stable@vger.kernel.org> # 4.10
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> 
> As discussed on irc this looks correct to me too.
> 
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
> 
> I will apply later, but let's wait and see if Noralf or others
> have any feedback first.
I finally went back to this patch, I missed it yesterday.
Applied to drm-misc-fixes with a stable 5.4+ tag.

	Sam

> > ---
> >  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 = chunk;
> > +		tr.len = chunk * 2;
> >  		len -= chunk;
> >  
> >  		ret = spi_sync(spi, &m);
> > -- 
> > 2.27.0
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-07-27 18:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 14:13 [PATCH] drm/dbi: Fix SPI Type 1 (9-bit) transfer Paul Cercueil
2020-07-03 14:13 ` Paul Cercueil
2020-07-03 14:23 ` Sam Ravnborg
2020-07-03 14:23   ` Sam Ravnborg
2020-07-27 18:36   ` Sam Ravnborg
2020-07-27 18:36     ` Sam Ravnborg
2020-07-03 14:26 ` Sam Ravnborg
2020-07-03 14:26   ` Sam Ravnborg
2020-07-05 15:58 ` Noralf Trønnes
2020-07-05 15:58   ` Noralf Trønnes
2020-07-06 23:49   ` Paul Cercueil
2020-07-06 23:49     ` Paul Cercueil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.