Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1220485pxb; Sat, 16 Apr 2022 02:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9x3I9ZT9Ti8KSzczBNTLdUyOI9L+pmBVtSit5Iyy0JQnEs+pUqb2Xd/Ed2SJ+bvU4cQO/ X-Received: by 2002:a17:90b:3b50:b0:1ce:6254:2cb8 with SMTP id ot16-20020a17090b3b5000b001ce62542cb8mr8254840pjb.239.1650099784007; Sat, 16 Apr 2022 02:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650099784; cv=none; d=google.com; s=arc-20160816; b=LUQRG9Shs1ul2oHpjFkByxCdwy5mZ4OSzGvzmnc8UZigFLX3+FwIyZfFwPhenb42Pm LU923LKiH/8m9agNOPe+ahPV3ntOO/bBHCOZljcTt7hkKgFHXm6+O9XlsiR2S/N3Xj0+ 5ZumD+nezILyR+kDWGNhuVV3gtsSgE3XyHCLqEF01M0o4wG49208WqRqp9rF4kigF0Rl ZSmMgsjWUC1E1sWVYSBLoyp95oP8GM8VIXcOvG6dTyS5wFgym4HTpa9AnS5XeWAwDPa4 crRSIUW0Kbj8AIjdTLf2173FQ4tUYQHYiwBSB2z7ULMmN/L40FLk5zo5/bRHHcCu/dRA V/XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=zo2kez9Tmm6A4y3mcmFjr5uk6/P/xlgMUWSYGBYBkEE=; b=r8k8hNrwNDB6TjKgpB9cx8vH5Wn3c75+pP30xdKRJGUfm1tecNsc9hKmb92q5IAD3Y hr/vi7jZMJwNFWWMY8MTzBoDqxdRRiuIMZxdy0fqYuu58ubru/p1cY9UgEbMkDnLaf6K uITmoQ4UqPhmF/sDTz9Dl4O70NKK5sdSLC2cFxGUMkuXjsC0APEvPk69VkFDFFEU2WaF p64/B7GJgpdVKs3gdbVJ7mv0VIS1LZKJN+/2aqHhi/+uj1ixIhph8LJyA1zifLW+pKUb 867DvAqp/3cU56MCtirZG7+omfjPQzfI0DiXJgfaNihjRZRL1jFYfc12iUWHFLHRspdj H0Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tronnes.org header.s=ds202112 header.b=RBsoPUaT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=tronnes.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a17090a430300b001cb8978ee7csi6068427pjg.42.2022.04.16.02.02.50; Sat, 16 Apr 2022 02:03:03 -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=fail header.i=@tronnes.org header.s=ds202112 header.b=RBsoPUaT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=tronnes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbiDPIYb (ORCPT + 99 others); Sat, 16 Apr 2022 04:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiDPIY3 (ORCPT ); Sat, 16 Apr 2022 04:24:29 -0400 Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC014186D6 for ; Sat, 16 Apr 2022 01:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org ; s=ds202112; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zo2kez9Tmm6A4y3mcmFjr5uk6/P/xlgMUWSYGBYBkEE=; b=RBsoPUaTWVZ/aw+h4s2eUIX4Di +6ArJacLiSudfTSWv7rJbxmw5NeEW7DyPbS7Lb4EBz/5SYhteQXabFxq2ejFmOkznXP9w4bbwfBHO OxXa03Ko3lXRAdpNVVnUX38KEprpAdQNco5ogEeyjh/6oK/0ChmK/AbF0fFLtPwA8ZBLX1+hp4PN2 kmpaEw9sbTRafDx8TEndmzG33tjmdFBMqGcMf1U9sRY+7ak3eIUuL8de2g2agmpovEYeXR8owsybZ /Xva4hxa0Msxq9QusegW9GMjj5DPwHRRYekgHF3Qpebo0vmYZHJOkLgxYXFdTgDHKVLOUxtrIjmjb m/NBE2Ag==; Received: from [2a01:799:961:d200:9146:d5a0:be36:3d08] (port=62077) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfdgp-0005St-Tm; Sat, 16 Apr 2022 10:21:55 +0200 Message-ID: Date: Sat, 16 Apr 2022 10:21:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] drm/mipi-dbi: Fix max_chunk calculation in spi_transfer To: Yunhao Tian Cc: Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= References: <20220308015611.3007395-1-t123yh.xyz@gmail.com> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= In-Reply-To: <20220308015611.3007395-1-t123yh.xyz@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, 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 Den 08.03.2022 02.56, 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 clamps max_chunk to the word size, preventing I think align is a better word here than clamp. > the transfer from being rejected. > > Signed-off-by: Yunhao Tian > --- > drivers/gpu/drm/drm_mipi_dbi.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c > index 71b646c4131f..440dc9fec6cc 100644 > --- a/drivers/gpu/drm/drm_mipi_dbi.c > +++ b/drivers/gpu/drm/drm_mipi_dbi.c > @@ -1182,6 +1182,15 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, > struct spi_message m; > size_t chunk; > int ret; > + int w_size; > + > + if (bpw <= 8) > + w_size = 1; > + else if (bpw <= 16) > + w_size = 2; > + else > + w_size = 4; > + max_chunk -= (max_chunk % w_size); mipi_dbi_spi_transfer() is only called with bpw= 8 or 16, so I think this can be simplified to: max_chunk = ALIGN_DOWN(max_chunk, 2); We might shorten the max transfer by one byte when bpw=8, but that doesn't matter. A short comment explaining why we need this would be nice. Please add a fixes tag so the patch is backported to the stable kernels: Fixes: d23d4d4dac01 ("drm/tinydrm: Move tinydrm_spi_transfer()") Noralf. > > spi_message_init_with_transfers(&m, &tr, 1); >