dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/mipi-dbi: align max_chunk to 2 in spi_transfer
@ 2022-05-10  3:02 Yunhao Tian
  2022-05-30 11:51 ` Noralf Trønnes
  0 siblings, 1 reply; 2+ messages in thread
From: Yunhao Tian @ 2022-05-10  3:02 UTC (permalink / raw)
  To: Noralf Trønnes
  Cc: Thomas Zimmermann, David Airlie, linux-kernel, dri-devel,
	Yunhao Tian, Sam Ravnborg, David Lechner

In __spi_validate, there's a validation that no partial transfers
are accepted (xfer->len % w_size must be zero). When
max_chunk is not a multiple of bpw (e.g. max_chunk = 65535,
bpw = 16), the transfer will be rejected.

This patch aligns max_chunk to 2 bytes (the maximum value of bpw is 16),
so that no partial transfer will occur.

Fixes: d23d4d4dac01 ("drm/tinydrm: Move tinydrm_spi_transfer()")

Signed-off-by: Yunhao Tian <t123yh.xyz@gmail.com>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 71b646c4131f..00d470ff071d 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -1183,6 +1183,13 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz,
 	size_t chunk;
 	int ret;
 
+	/* In __spi_validate, there's a validation that no partial transfers
+	 * are accepted (xfer->len % w_size must be zero).
+	 * Here we align max_chunk to multiple of 2 (16bits),
+	 * to prevent transfers from being rejected.
+	 */
+	max_chunk = ALIGN_DOWN(max_chunk, 2);
+
 	spi_message_init_with_transfers(&m, &tr, 1);
 
 	while (len) {
-- 
2.25.1


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

* Re: [PATCH v2] drm/mipi-dbi: align max_chunk to 2 in spi_transfer
  2022-05-10  3:02 [PATCH v2] drm/mipi-dbi: align max_chunk to 2 in spi_transfer Yunhao Tian
@ 2022-05-30 11:51 ` Noralf Trønnes
  0 siblings, 0 replies; 2+ messages in thread
From: Noralf Trønnes @ 2022-05-30 11:51 UTC (permalink / raw)
  To: Yunhao Tian
  Cc: David Lechner, David Airlie, linux-kernel, dri-devel,
	Thomas Zimmermann, Sam Ravnborg



Den 10.05.2022 05.02, skrev Yunhao Tian:
> In __spi_validate, there's a validation that no partial transfers
> are accepted (xfer->len % w_size must be zero). When
> max_chunk is not a multiple of bpw (e.g. max_chunk = 65535,
> bpw = 16), the transfer will be rejected.
> 
> This patch aligns max_chunk to 2 bytes (the maximum value of bpw is 16),
> so that no partial transfer will occur.
> 
> Fixes: d23d4d4dac01 ("drm/tinydrm: Move tinydrm_spi_transfer()")
> 
> Signed-off-by: Yunhao Tian <t123yh.xyz@gmail.com>
> ---

Thanks, applied to drm-misc-next.

Noralf.

>  drivers/gpu/drm/drm_mipi_dbi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
> index 71b646c4131f..00d470ff071d 100644
> --- a/drivers/gpu/drm/drm_mipi_dbi.c
> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
> @@ -1183,6 +1183,13 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz,
>  	size_t chunk;
>  	int ret;
>  
> +	/* In __spi_validate, there's a validation that no partial transfers
> +	 * are accepted (xfer->len % w_size must be zero).
> +	 * Here we align max_chunk to multiple of 2 (16bits),
> +	 * to prevent transfers from being rejected.
> +	 */
> +	max_chunk = ALIGN_DOWN(max_chunk, 2);
> +
>  	spi_message_init_with_transfers(&m, &tr, 1);
>  
>  	while (len) {

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

end of thread, other threads:[~2022-05-30 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  3:02 [PATCH v2] drm/mipi-dbi: align max_chunk to 2 in spi_transfer Yunhao Tian
2022-05-30 11:51 ` Noralf Trønnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).