From mboxrd@z Thu Jan 1 00:00:00 1970 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 2BCFDEB64D7 for ; Fri, 16 Jun 2023 16:18:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344976AbjFPQR7 (ORCPT ); Fri, 16 Jun 2023 12:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345019AbjFPQRk (ORCPT ); Fri, 16 Jun 2023 12:17:40 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1066C46AD for ; Fri, 16 Jun 2023 09:15:39 -0700 (PDT) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686932138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5F/RWcmHXxlm2EZb3KACT2rj6ZLFMEn3BsMLoTGYuJU=; b=k+BZxRHU/qUDi2X382+shZi7QedN/LrX4yIogLVF7XFERCsvNtWGSKqpirfyqXZLwmHsI4 wAh21QaCznq5A07tcugVgw5qWi685loVochVk+d2iJbHv5FxlX+zuO9ChhmKIGtTS8gL7e pfGKgjVrcCBB6PLUNYNKE1H8rT27biZMpzWjaqlJTitN+DhJMVYLl7FfaIqQx77uEvijhT aiSBBpPjvTYdgaG+5/E4YVaH8a2a78HetByjvGWIAJuczwmIN3FZpDJ0tLbxJfzWE1UeaL zjpsLw0BL4fk0YEEJzqj2SeCOrUx3v9mjg3L0hpX351Wq2Kz/mk0RWURZI94yQ== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 1E078240007; Fri, 16 Jun 2023 16:15:37 +0000 (UTC) Date: Fri, 16 Jun 2023 18:15:35 +0200 From: Miquel Raynal To: Mark Brown Cc: Tudor Ambarus , linux-spi@vger.kernel.org, Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni Subject: Re: [PATCH] spi: atmel: Prevent false timeouts on long transfers Message-ID: <20230616181535.032bf9de@xps-13> In-Reply-To: <89439569-4fc3-4f5e-9392-4ed92ecb62e5@sirena.org.uk> References: <20230616141225.2790073-1-miquel.raynal@bootlin.com> <89439569-4fc3-4f5e-9392-4ed92ecb62e5@sirena.org.uk> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Hi Mark, broonie@kernel.org wrote on Fri, 16 Jun 2023 15:20:27 +0100: > On Fri, Jun 16, 2023 at 04:12:25PM +0200, Miquel Raynal wrote: >=20 > > -#define SPI_DMA_TIMEOUT (msecs_to_jiffies(1000)) > > +#define SPI_DMA_MIN_TIMEOUT (msecs_to_jiffies(1000)) > > +#define SPI_DMA_TIMEOUT_PER_10K (msecs_to_jiffies(4)) =20 >=20 > Given that we know the bus speed can't we just calculate this like other > drivers do (we should probably add a helper TBH)? I agree we should probably have some kind of easy-to-use helper to derive a decent timeout value. How do sound the heuristics proposed here to you ? That would be: timeout =3D 1s + 4ms/10k Thanks, Miqu=C3=A8l