Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1864458rwb; Fri, 19 Aug 2022 10:39:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5eMkGggFCAwMSHETTCnn2cNERfo+U5n47YRKEijz+m3ip872saF/wzq0widm28uSA5XAY2 X-Received: by 2002:a63:1202:0:b0:427:7f15:4711 with SMTP id h2-20020a631202000000b004277f154711mr7071404pgl.550.1660930768765; Fri, 19 Aug 2022 10:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930768; cv=none; d=google.com; s=arc-20160816; b=KT0n0JsSVC/wt1yjsY/0sTdw5r1WccJpJZIJS9x6Wlr0ZixZbRbiu/7mdIwQ60s9G0 DW+VUaPaYITBynmqRV10cWfVyeIzenXE+I74eeql60c/3ZrSFgUy2qEWLkf8WuLCvSOW opW59o0bW4zKMkvyhOxV6cczXn2hz0FIFIGLife23FH2WjGD8qm55eAe6s9i3XiYMxkS GTgbIfSx3iS2EXxWFnJETPFEMwZ9SytAG806sMbFadbnhmnDqIj9zVBhXpuqs2Qg08Ef Sa+7djTis2cNSnHdAAm53b1nAucRrybSXJFeo2qq1p9XVeGy0JwHVnQF21cleD6jo7zV R2bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3nSK4Eu4v8y0VQHWQ1lyxG8g/TofnW+JyPbXKDiVu7M=; b=z4dcRB3TqVMN0o0OqoYeUuP2c/X/DFj/ABj5h/JZQH2MveTPgQOPk0b8JeJoRVpSus t+y4IgOLstRM0oS/cj+qOCALRBeZxylNjuW0ojVxzIJwzmItdlC/IWn308VnVHDvSmKD sD/BBSNUAT7s6fqlfRrX2FivBCCG6TMVhpiihuUSA8q9bn5HtwbaNbeorTgx5xw+VVUg l1tvVdlfgCauemoLq5s5wUeIUflU72c/rS/N7JsNU+5kDziJX2DfGjpKm4AymxH3c/Co fy9BYt8OqJk7FxvHL+P1CYX4Hev94Sr1Ak70Q5nPbOJpO130kYco8+wiVrcvdt7DCSzv vUrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wq1/7Jpn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170903231100b00170c27c2b6asi2980900plh.114.2022.08.19.10.39.17; Fri, 19 Aug 2022 10:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wq1/7Jpn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351331AbiHSQFM (ORCPT + 99 others); Fri, 19 Aug 2022 12:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351450AbiHSQBl (ORCPT ); Fri, 19 Aug 2022 12:01:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86BEF10AE1A; Fri, 19 Aug 2022 08:53:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9955CB82816; Fri, 19 Aug 2022 15:53:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9C83C433D6; Fri, 19 Aug 2022 15:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924414; bh=jf8Sd1limL+roBuK7Uscg4a20NxbVJNZTR5nepUuyeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wq1/7Jpnv+C+rwp6mxFeX60AFydMsCD4w9XFkLdJo55mD4tIeD8Vhz5hzPfGPtC/d dxeACnZrziPaEwNXagPf/CHhJMpalIF9vSpSrr86OW/nPgWwf5EbIRNKIIx+CEudUM iCG1riHrCmulsbhWXh+341/3n23mXAGvSHIpvfkQ= 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.10 163/545] drm/mipi-dbi: align max_chunk to 2 in spi_transfer Date: Fri, 19 Aug 2022 17:38:53 +0200 Message-Id: <20220819153836.656237907@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 = 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 Signed-off-by: Noralf Trønnes 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 230c4fd7131c..9f132229aed1 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -1137,6 +1137,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.35.1