Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp636909rdb; Thu, 21 Dec 2023 23:38:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZatZy3ejBxNWzG6ik2yVL2EO5CFI5OsULdz9VVVifm+/MCA/fsGCSqDWI3g6PPB0CWX1/ X-Received: by 2002:a05:620a:4513:b0:781:2c62:496c with SMTP id t19-20020a05620a451300b007812c62496cmr652897qkp.100.1703230696162; Thu, 21 Dec 2023 23:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703230696; cv=none; d=google.com; s=arc-20160816; b=br7O0+6EvJsIN/H/o28gCU2Vp8twllfzmhY8xLKjoTfUA6v15bDFseIzoB/fj9ywPS 6qIL/f9BCgu5J1gLJgpWP1+NHo2wTP6suKQAH6vmI2fsoHy9dCZqirlOXT7RxA7uvmQ5 mzNIn2KSUDvAaUmu+94Euz+9qorOLk6/Obkad4NUc6b03jP9pW3wv9mAP82X00RB5bkk 1YmkFGMic+uNHxDL5o/ZO88KgQeVYRxzRw2Zo1hTtFl1+8KlTzPEFfWXdO6DJIQJmYrI yzqdvs+r4LTPfYwDaMfDmTRf00wfSi7BPT4I+Ggs0XtYOtU1vb71V6AulL9w/fn2SbYZ N1aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cae/FJnayHg64Oh6InK+iMFOgnFR3ykNfa62V/1pNqU=; fh=0fWnsLZCb655Onk6oNT2V8bKrgliM9zWiV79DwSSsBM=; b=jyv05ZPMeTP4Tox0X4DNoa+YhHpxu2Hv2Ivl6h0KfbbFXvy6MqmZzGyYQlrKD90eKc BDFXcN1tKweA0EIgFSoM/boDt2HF9QV+7J91Je9vEP1DsyCgV+HGIOXoKH/zNsFj2BJ5 hqrH5dsa/Rgf5R2PTXTusQsZGbrBet+bIbljhNR8lB6WZvM/Ja+Sg6liv0kBK1DSt26E pyJRkGZnEFeg1m+mT0/noEgCcxG0hA6wijSFG33zbQi7nu3LEXxO19uza03rhVD1o2hd 0xScfb5JhoxzMKssXimWCu6Bn71OhP4OiGFpGckqlkRv7nROjlZlIn0mQ0ZMlqYPCvkU 1NCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gehealthcare.com header.s=outbound header.b=lOrveDNO; spf=pass (google.com: domain of linux-kernel+bounces-9456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9456-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gehealthcare.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h15-20020a05620a13ef00b0077d7cf26bc9si3564512qkl.564.2023.12.21.23.38.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:38:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gehealthcare.com header.s=outbound header.b=lOrveDNO; spf=pass (google.com: domain of linux-kernel+bounces-9456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9456-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gehealthcare.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9991C1C251AE for ; Fri, 22 Dec 2023 07:38:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC0D9947A; Fri, 22 Dec 2023 07:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gehealthcare.com header.i=@gehealthcare.com header.b="lOrveDNO" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-00176a03.pphosted.com (mx0b-00176a03.pphosted.com [67.231.157.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BB6D9449; Fri, 22 Dec 2023 07:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gehealthcare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gehealthcare.com Received: from pps.filterd (m0048204.ppops.net [127.0.0.1]) by m0048204.ppops.net-00176a03. (8.17.1.19/8.17.1.19) with ESMTP id 3BLM4PMe020515; Fri, 22 Dec 2023 01:02:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gehealthcare.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=outbound; bh=cae/FJnayHg64Oh6InK+iMFOgnFR3ykNfa62V/1pNqU=; b=lOrveDNOO5+KXQ4CzJp9kGgUM2HtYeyJE9Deqrku7N8A+wJ2bYjwSve6lZQA2y4oRVDh gOKfuw9LVXDCcH7xAuREx9BDlHzpugYw3GBFpxYVFHu2EpmeMDaQ1Wezcd60n/CgGVDQ f/CUQfkpiAKPFlA/hL8R0SAi6y2YHYohe4/YUgCCCI6VC9Ji8auqcwTlNg3mhKERWLU0 Q0CZa8IkeQaADGDziybOXsOKPOdaLPuO/oIK3QyBOB10u7BXCL7AybTATORjtV0qIzvS 1XmcS6VDc7W00XG2AapoNgXa8E0R40Qe5LEWm/+prMenY5UBqD3KupcymGI9oJRjDbxd Rw== Date: Fri, 22 Dec 2023 08:02:09 +0200 From: Ian Ray To: Uwe Kleine-K??nig Cc: Greg Kroah-Hartman , Sebastian Reichel , linux-serial@vger.kernel.org, Jiri Slaby , Fabio Estevam , Sascha Hauer , linux-kernel@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , kernel@collabora.com, Shawn Guo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, nandor.han@gehealthcare.com, ian.ray@gehealthcare.com Subject: Re: EXT: Re: [PATCHv4] serial: imx: Add DMA buffer configuration via sysfs Message-ID: References: <20210305115058.92284-1-sebastian.reichel@collabora.com> <20210305124252.c3ffgca6wjqpkn45@earth.universe> <20210405214446.zhidvtvahcfp4wxa@earth.universe> <20231208090205.ioc76sych3snjiwb@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231208090205.ioc76sych3snjiwb@pengutronix.de> X-Proofpoint-ORIG-GUID: 3xXqT6o-a7pCZ-sMkpaAQs4cXCbxLnzf X-Proofpoint-GUID: 3xXqT6o-a7pCZ-sMkpaAQs4cXCbxLnzf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-22_02,2023-12-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 impostorscore=0 mlxlogscore=966 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 clxscore=1015 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312220040 On Fri, Dec 08, 2023 at 10:02:05AM +0100, Uwe Kleine-K??nig wrote: > be safe. > > Hello Greg, > > [Cc += 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 > > > > > > > > > > > > In order to optimize serial communication (performance/throughput VS > > > > > > latency), we may need to tweak DMA period number and size. This adds > > > > > > sysfs attributes to configure those values before initialising DMA. > > > > > > 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: > > > > > > > > > > > > /sys/class/tty/ttymxc*/dma_buffer_size > > > > > > /sys/class/tty/ttymxc*/dma_buffer_count > > > > > > > > > > Ick no. Custom sysfs attributes for things like serial ports are crazy. > > > > > > > > > > > This is mainly needed for GEHC CS ONE (arch/arm/boot/dts/imx53-ppd.dts), > > > > > > which has multiple microcontrollers connected via UART controlling. 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 needs > > > > > > 1024 byte / 19200 baud = 53.333ms, which is way too long (note: Worst > > > > > > Case would be remote processor sending data with short pauses <= 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. > > > > > > > > > > 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. This > > > > > hardware should not force a user to manually tune it to get it to work > > > > > properly, this isn't the 1990's anymore :( > > > > > > > > > > Please never force a user to choose stuff like this, they never will > > > > > know what to do. > > > > > > > > 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: > > > > > > > > https://lore.kernel.org/linux-serial/20170629182618.jpahpmuq364ldcv2@pengutronix.de/ > > > > > > > > From downstream POV this can be done either by adding a DT property > > > > to the UART node, or by adding a udev rule. > > > > > > > > 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. > > > > > > ping? It's not very nice to get a rejected in cycles :( > > > > 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. Continuing here (see also [1]). [1] https://lore.kernel.org/lkml/ZXr55QV4tnCz8GtI@4600ffe2ac4f/ > > 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 This might be too magical. The algorithm would likely lose data before it "warms up" and that would be unacceptable to our application. > - sysfs property > - further discussion > - dt property > - custom ioctl - sysctl Given the description [2] "configure kernel parameters at runtime" this approach would appear to meet our needs. I have not looked into this in any detail yet -- but would like to get upstream feedback. [2] https://man7.org/linux/man-pages/man8/sysctl.8.html > > 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? We spent a significant amount of time analysing and profiling our application. DMA is absolutely required in order to avoid dropping data. This is especially true for the 4M baud UART. This section quoted from the original patch V4 [3]. [3] https://lore.kernel.org/lkml/20210305115058.92284-1-sebastian.reichel@collabora.com/ > The same device also has another microcontroller with a 4M baud UART > connection exchanging lots of data. For this the same mechanism can > be used to increase the buffer size (downstream uses 4K instead of > the default 1K) with potentially slightly reduced buffer count. At > this baud rate latency is not an issue (4096 byte / 4M baud = 0.977 ms). > Before increasing the default buffer count from 4 to 16 in 76c38d30fee7, > this was required to avoid data loss. With the changed default it's > a performance optimization. Note: Quite a lot has change since we submitted this patch -- GE HealthCare has spun-off from GE, and Sebastian is no longer working on the project. Many thanks, Ian > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-K?nig | > Industrial Linux Solutions | https://www.pengutronix.de/ |