* [PATCH v2] drm/sun4i: Fix dsi dcs long write function
@ 2020-08-28 12:50 Ondrej Jirman
2020-08-31 12:41 ` Maxime Ripard
0 siblings, 1 reply; 2+ messages in thread
From: Ondrej Jirman @ 2020-08-28 12:50 UTC (permalink / raw)
To: linux-sunxi
Cc: Ondrej Jirman, Jernej Skrabec, Maxime Ripard, Chen-Yu Tsai,
David Airlie, Daniel Vetter,
open list:DRM DRIVERS FOR ALLWINNER A10,
moderated list:ARM/Allwinner sunXi SoC support, open list
It's writing too much data. regmap_bulk_write expects number of
register sized chunks to write, not a byte sized length of the
bounce buffer. Bounce buffer needs to be padded too, so that
regmap_bulk_write will not read past the end of the buffer.
Fixes: 133add5b5ad4 ("drm/sun4i: Add Allwinner A31 MIPI-DSI controller support")
Signed-off-by: Ondrej Jirman <megous@megous.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
v2:
- use ALIGN
- add tags
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index 7f13f4d715bf..840fad1b68dd 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -889,7 +889,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
regmap_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(0),
sun6i_dsi_dcs_build_pkt_hdr(dsi, msg));
- bounce = kzalloc(msg->tx_len + sizeof(crc), GFP_KERNEL);
+ bounce = kzalloc(ALIGN(msg->tx_len + sizeof(crc), 4), GFP_KERNEL);
if (!bounce)
return -ENOMEM;
@@ -900,7 +900,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
memcpy((u8 *)bounce + msg->tx_len, &crc, sizeof(crc));
len += sizeof(crc);
- regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, len);
+ regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, DIV_ROUND_UP(len, 4));
regmap_write(dsi->regs, SUN6I_DSI_CMD_CTL_REG, len + 4 - 1);
kfree(bounce);
--
2.28.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] drm/sun4i: Fix dsi dcs long write function
2020-08-28 12:50 [PATCH v2] drm/sun4i: Fix dsi dcs long write function Ondrej Jirman
@ 2020-08-31 12:41 ` Maxime Ripard
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2020-08-31 12:41 UTC (permalink / raw)
To: Ondrej Jirman
Cc: linux-sunxi, Jernej Skrabec, Chen-Yu Tsai, David Airlie,
Daniel Vetter, open list:DRM DRIVERS FOR ALLWINNER A10,
moderated list:ARM/Allwinner sunXi SoC support, open list
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
On Fri, Aug 28, 2020 at 02:50:32PM +0200, Ondrej Jirman wrote:
> It's writing too much data. regmap_bulk_write expects number of
> register sized chunks to write, not a byte sized length of the
> bounce buffer. Bounce buffer needs to be padded too, so that
> regmap_bulk_write will not read past the end of the buffer.
>
> Fixes: 133add5b5ad4 ("drm/sun4i: Add Allwinner A31 MIPI-DSI controller support")
> Signed-off-by: Ondrej Jirman <megous@megous.com>
> Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
Applied, thanks
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-31 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 12:50 [PATCH v2] drm/sun4i: Fix dsi dcs long write function Ondrej Jirman
2020-08-31 12:41 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®