From nobody Fri Sep 5 20:23:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6BE1C49EC1 for ; Tue, 23 Aug 2022 11:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357773AbiHWL0r (ORCPT ); Tue, 23 Aug 2022 07:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357527AbiHWLRk (ORCPT ); Tue, 23 Aug 2022 07:17:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86E2E6717D; Tue, 23 Aug 2022 02:21:23 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 225AF6121F; Tue, 23 Aug 2022 09:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16835C433C1; Tue, 23 Aug 2022 09:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246482; bh=t95JfVAsbvjZQPz/fb5tjYrWHwt5ViVfGfVIPpXnKwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RmEoAiVYFRX/8MXqrUgiA9v4tcxeAfSnhKDakY577BgCUaoA0NiQzl832ZY8z4e1t w8sCNSFGLFnxL8BBY0rJI1QQvJ8qy318vq68PxSzB0KVklvUysB39jTTatGiEDA907 Gynr/Jm5z3SBryDW7woXnqAEgTj+WZzwnGSZ+GWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunhao Tian , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Sasha Levin Subject: [PATCH 5.4 097/389] drm/mipi-dbi: align max_chunk to 2 in spi_transfer Date: Tue, 23 Aug 2022 10:22:55 +0200 Message-Id: <20220823080119.662538583@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunhao Tian [ Upstream commit 435c249008cba04ed6a7975e9411f3b934620204 ] 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 =3D 65535, bpw =3D 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 Signed-off-by: Noralf Tr=C3=B8nnes Link: https://patchwork.freedesktop.org/patch/msgid/20220510030219.2486687-= 1-t123yh.xyz@gmail.com Signed-off-by: Sasha Levin --- 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 4042f5b39765..2a7ef1051b39 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -1156,6 +1156,13 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u3= 2 speed_hz, size_t chunk; int ret; =20 + /* 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 =3D ALIGN_DOWN(max_chunk, 2); + spi_message_init_with_transfers(&m, &tr, 1); =20 while (len) { --=20 2.35.1