Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2206041rdb; Fri, 8 Dec 2023 01:02:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmOgOtFo3H0/Mu0XjcLVXD2FwBugvaS0CsX8ZXHywqX8SwXT0etBaapKZ4AvNoUZ31dmSX X-Received: by 2002:a05:6a00:464b:b0:68f:a92a:8509 with SMTP id kp11-20020a056a00464b00b0068fa92a8509mr880462pfb.7.1702026165790; Fri, 08 Dec 2023 01:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702026165; cv=none; d=google.com; s=arc-20160816; b=XglLEe+XenfYZ/kMgScMKxID0d4H97LiqXQjeo9cFncAuIl9I22odoqwUcNr1JTJQ6 JVYEQsIVlrBERZOkZ9MJyiFIlHxKas9ihse5LnYbDDKKENsopWIewWJFtbvAlK4HAJyk SfdJyxP22q+u1NePEHEFy02uk+k73wn6cTg8slNHannEdJBxlVrB68x3a2KTeyPdtK28 83LQ8Ixx3MupTJZeHJM/jx+wwyDJBqtYSfUqbCGhDodSK5wde5n7itOvguenLQGz/x06 M7KGWJvvfQg+C+M+zUkvyCSZ6NT+00c0OG9I2gW/HptqaETX1gzpowqCjvMf/FecIVzf /M6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=4rYAp75a6S/g3H1VlCQMT9VWwasJ0T8QuF6DDave0m0=; fh=gUnIiL8ljugzZK/8YCjkWONeCLC4H7lqZDJEZgGlwI8=; b=hisQ+guyHOZKK8RfrqywDoQxb1RQJwq+RP+wt1IXQ1AclHZfC2SsxiPGp35S6+V/R1 7BptFtAHbQ2sTtYZlPP6OpV0mKfUxgtGD4kb+1HfXsvr9TtMhPN45x1EgGo8tK7U1Gob NMbljMtiu2Qyt6IX7eihWvHgrJ7/SlAt1xPaNFAjpqPxYfTxMn4nUCJ5HaHzLx7GGLQu nlbmlyppS+BqHwKDhLLgbhuaEG5ghqJ4Cb/B/uYKMS3Lbr1KE8pY+qJvw3RU9x8OVgUN s/Nv6yKIUMNmFR+l5PKtZ1Ia7HxQXCASYOFDWETW9KD7ArhVJg/gON5LHCwIz3DzkOZm zkKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bx2-20020a056a02050200b005c1739564f7si1225338pgb.351.2023.12.08.01.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 01:02:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CC26C8183F29; Fri, 8 Dec 2023 01:02:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235774AbjLHJCX (ORCPT + 99 others); Fri, 8 Dec 2023 04:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235771AbjLHJCU (ORCPT ); Fri, 8 Dec 2023 04:02:20 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D5851703 for ; Fri, 8 Dec 2023 01:02:25 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rBWkJ-0003GX-Cl; Fri, 08 Dec 2023 10:02:07 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBWkH-00ENT4-HR; Fri, 08 Dec 2023 10:02:05 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rBWkH-00GLAI-7q; Fri, 08 Dec 2023 10:02:05 +0100 Date: Fri, 8 Dec 2023 10:02:05 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Greg Kroah-Hartman Cc: Sebastian Reichel , linux-serial@vger.kernel.org, Jiri Slaby , Fabio Estevam , Sascha Hauer , linux-kernel@vger.kernel.org, Ian Ray , NXP Linux Team , Pengutronix Kernel Team , kernel@collabora.com, Shawn Guo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org Subject: Re: [PATCHv4] serial: imx: Add DMA buffer configuration via sysfs Message-ID: <20231208090205.ioc76sych3snjiwb@pengutronix.de> References: <20210305115058.92284-1-sebastian.reichel@collabora.com> <20210305124252.c3ffgca6wjqpkn45@earth.universe> <20210405214446.zhidvtvahcfp4wxa@earth.universe> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ff53tonb2aszag6u" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 01:02:43 -0800 (PST) --ff53tonb2aszag6u Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Greg, [Cc +=3D dt maintainers] On Tue, Apr 06, 2021 at 09:13:04AM +0200, Greg Kroah-Hartman wrote: > On Mon, Apr 05, 2021 at 11:44:46PM +0200, Sebastian Reichel wrote: > > On Fri, Mar 05, 2021 at 01:42:52PM +0100, Sebastian Reichel wrote: > > > On Fri, Mar 05, 2021 at 01:06:12PM +0100, Greg Kroah-Hartman wrote: > > > > On Fri, Mar 05, 2021 at 12:50:58PM +0100, Sebastian Reichel wrote: > > > > > From: Fabien Lahoudere > > > > >=20 > > > > > In order to optimize serial communication (performance/throughput= VS > > > > > latency), we may need to tweak DMA period number and size. This a= dds > > > > > sysfs attributes to configure those values before initialising DM= A. > > > > > The defaults will stay the same as before (16 buffers with a size= of > > > > > 1024 bytes). Afterwards the values can be read/write with the > > > > > following sysfs files: > > > > >=20 > > > > > /sys/class/tty/ttymxc*/dma_buffer_size > > > > > /sys/class/tty/ttymxc*/dma_buffer_count > > > >=20 > > > > Ick no. Custom sysfs attributes for things like serial ports are c= razy. > > > >=20 > > > > > This is mainly needed for GEHC CS ONE (arch/arm/boot/dts/imx53-pp= d.dts), > > > > > which has multiple microcontrollers connected via UART controllin= g. One > > > > > of the UARTs is connected to an on-board microcontroller at 19200= baud, > > > > > which constantly pushes critical data (so aging character detect > > > > > interrupt will never trigger). This data must be processed at 50-= 200 Hz, > > > > > so UART should return data in less than 5-20ms. With 1024 byte DMA > > > > > buffer (and a constant data stream) the read operation instead ne= eds > > > > > 1024 byte / 19200 baud =3D 53.333ms, which is way too long (note:= Worst > > > > > Case would be remote processor sending data with short pauses <= =3D 7 > > > > > characters, which would further increase this number). The current > > > > > downstream kernel instead configures 24 bytes resulting in 1.25ms, > > > > > but that is obviously not sensible for normal UART use cases and = cannot > > > > > be used as new default. > > > >=20 > > > > Why can't this be a device tree attribute? Why does this have to be= a > > > > sysfs thing that no one will know how to tune and set over time. T= his > > > > hardware should not force a user to manually tune it to get it to w= ork > > > > properly, this isn't the 1990's anymore :( > > > >=20 > > > > Please never force a user to choose stuff like this, they never will > > > > know what to do. > > >=20 > > > This used to be a DT attribute in PATCHv1. It has been moved over to > > > sysfs since PATCHv2, since it does not describe the hardware, but > > > configuration. Unfortunately lore.kernel.org does not have the full > > > thread, but this is the discussion: > > >=20 > > > https://lore.kernel.org/linux-serial/20170629182618.jpahpmuq364ldcv2@= pengutronix.de/ > > >=20 > > > From downstream POV this can be done either by adding a DT property > > > to the UART node, or by adding a udev rule. > > >=20 > > > From my POV there is not a huge difference. In both cases we will > > > be bound by an ABI afterwards, in both cases people will usually > > > stick to the default value and in both cases people that do deviate > > > from the default probably ran into problems and started to look > > > for a solution. > >=20 > > ping? It's not very nice to get a rejected in cycles :( >=20 > I recommend working with the DT people here, as custom sysfs attributes > for things like this that are really just describing the hardware is > crazy. I was one who expressed concerns in the earlier rounds that dt isn't the right place for this. dt is about hardware description, but choosing a good value for the dma buffer size is driver tuning and depends on the individual requirements. (latency, throughput, memory consumption, robustness under system load). I can even imagine use cases where the settings should be changed dynamically, which cannot (easily) be done using dt. While I see your point that a driver specific sysfs property is unusual/strange/whatever every downside you mentioned also applies to a dt property (or a custom ioctl). Among the solutions I can imagine, my preference order is: - automatic tuning - sysfs property - further discussion - dt property - custom ioctl I wonder if there is a sensible way to implement a automatic tuning. In the use case mentioned in the commit log, Sebastian's need is low latency for a constantly sending microcontroller on the other side. Is it sensible to make the used dma buffers smaller if we have a certain throughput? Or is that too magic and doomed to fail covering most use cases? If that doesn't work, I support Sebastian's approach to do that in a sysfs property. Sebastian, have you evaluated just not using dma for these UARTs? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --ff53tonb2aszag6u Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmVy24wACgkQj4D7WH0S /k7+ggf+Mcv56tDH2NcnNQ7qncn8ZtwodtWIarYf4MDerc7cZntyFdkGOLbJ8CdE cCulj6BnK1Yjl9nCz4tYqd6XY0SoDIR5mFdudhQU5ViQTTt9ohYT6pjqeL1F2dVc ozhSFoFasBucM1QVIoZR5sgXWQR0mUoPWpY11YFYbjNzC4ZGA4R9Ill3P8iFLMQR d7e/M2jBKIR+0XlHO+m4s3zy/oTxh7ZXj4IcBQqhlnfaz+A8vUJutMZ/kDCcVAvH k4AhpafOEU3IeH3OJEXPs9Q9MfUzCBGfgCNCI7YX5qrzx3tmGNQg/EWw2V7P2npz 9nWpionkSNv4oKH2RT7cjG2Ad+JljA== =iVEI -----END PGP SIGNATURE----- --ff53tonb2aszag6u--