Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1709369rdb; Sat, 10 Feb 2024 13:58:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEmXEj85tdil32YaWlj+f0iWtZlTItTwdvZKQsaPeq59Qs109QDjjbarv6AXioRYHudmUY X-Received: by 2002:a05:622a:134f:b0:42b:f17f:8dcf with SMTP id w15-20020a05622a134f00b0042bf17f8dcfmr4010905qtk.51.1707602325271; Sat, 10 Feb 2024 13:58:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707602325; cv=pass; d=google.com; s=arc-20160816; b=04N5Cr91gIyg3r3xUirw5GQEdKAMTIzdVp5C+6LKZPDjGAmK6MsTZ35X38K2Mo3Ha6 FQSCfOBTUb5KY8DDzTjxaiGRNeSYIOJ2EDz61V6VB7yaCxrZM1EZEecH0dkr5hxQvZbw MxHdAnubJP84cKGg8KLxXbGbTNOAtFiNbfoYsqbLoXG2hmIjJb91ewVDUXNMaxKPXwnQ uF4aMJSH7syKfsO8DbtdyWCn6aYvTJxsAQ+C4J0Sv31O0ZXgYKsJuwJ712Bk+vfqiY8L gc1l1C3OgIF2OaN3n0AXeGTZW3g060sSyAlgNro92yjbPl5Bn1sMCqeEpYacFNzpormq LPIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ocRkW8hKMfnTmReIZpRDWQim1hibbGos+/oExgJFVwc=; fh=XzIJ969w76Q1arcUNWqadOKwWYh0wq//XOnN9V/ME1E=; b=TzF949aGCJNYDg/c6k2yEImI/Ni6ZKNx7vbOYiSjv3SKvjCDpleDfgUYsP1taQBUbW g5OFY6/RD2RxQjmiNc+XKSPFoXeOp72s6ZdLEQuf+J955x1EO5yxQ5JJbYrthRjm0TsW U08fOAxPUc8wsb+9AitrOkQOClDcRHnAATHdTTxi354TowAZC7bq8os4d09wF9ikv1Fw 7Et0HAUbAEwWeWvjTvVivs10FVc41z+i3uaMyXBOqBlpxZvbdg39B4przWpMCo0sUfq4 9pP/lVWIDrRjd9XDVWv6KZyTEVTy9aF6i21Jm9vyer3DpWa/YeN2hZyLqhEyWJpve64n 7gAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=d7e7IEk3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWEMp3tBG3AGyfCwOCYjniQZApPmR2ZfuLRYZda5Ik/OjThHxZaLKp62OYihHddZdaDrsytRf6bV+EEfEui/HfKpeCQY3qMjw2vRmtnCg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 21-20020ac84e95000000b0042c501aee3asi5385101qtp.179.2024.02.10.13.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:58:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60566-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=@gmail.com header.s=20230601 header.b=d7e7IEk3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 F38BC1C21263 for ; Sat, 10 Feb 2024 21:58:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D77C5612FC; Sat, 10 Feb 2024 21:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d7e7IEk3" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E25F612DE; Sat, 10 Feb 2024 21:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602035; cv=none; b=Znxb+DjdF+5rvXDJWy129mha3DhnXcVWAoSiL+3AlBSrf6DDpzSZvEY+hs8T+1hBMv3uwjh72eN6bBtS558o7nqe0MRqOx8mN1oWSNteNsy1IMoyRNkSMhGyM59lPQ6du23d4GpEFm4cHGcet/eQpqgLXLOMm2IeY8XgPLucClc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602035; c=relaxed/simple; bh=zEz90GX1NaC/1sawxLYuZ1ENoB1fBUSzM9OiDG4l96E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k2edn0VN9/DAS4stB7NKgYCOaE2+vZEWp6IvQnSaEyd+9Dcyxuc7ssX85bLcBW4LtJ6xdGs9EfqR1R4gLr3Gt3Vh0Af79J9X+7khuFYWL4vB42+2se8wp1ZASdMWj84x8gy51d7DGeRo8SzLGyzL4uhpf0ZEFBbuwm5bmj3JvQQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d7e7IEk3; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51185c33626so499863e87.0; Sat, 10 Feb 2024 13:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602031; x=1708206831; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ocRkW8hKMfnTmReIZpRDWQim1hibbGos+/oExgJFVwc=; b=d7e7IEk3Tb6vTzzFHVcmcu257aEaj9D4htLnGdvJ8Wvj+hBaW6B9nkJCmB3fTJCblO bzPj9HRcH9AubPJePPEeP7Y+9U3OoCLBeCXnwIGOnMEBJusvHinJkuzpWtPT9FGkoJ+b UNaKz+Dxrv9eG6PxY7orFc7A/pK7qyemwGE+7W6lqGZTQdN/CpQOjD5F7Yryr8F2jTfi Dm6G9RfZqaUSMB/36n/UW2gCMNVDkmPIGrXUhRE6sm5YtgD751jrsBeUnW/iRjF7Es2q aHuMGi12kmp3araHl3x4fAv1rH/NpnPyjlJMVtfTFcn2GuonxzqU9MVEZizjLhhHxGb/ 8+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602031; x=1708206831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocRkW8hKMfnTmReIZpRDWQim1hibbGos+/oExgJFVwc=; b=rOP8u/VJSXvI0piH4EUz1kxlbGrFnIhtZkHQ+yVdnmLvM6kojtbK3F3KNAGtwja0NV OJFTs6mLEOzmjPu9nJt9xxLG6yGidVsrQwJsipSmhnM8eCYlSRtoVaRSQ3cbUtOMLI6i +Rt58JHXaCTVG9Dm9i8vchErYo4tPKMBgcJ1Gusm/dl6HbPjAO8jwaLmTpAxpFwHScRY Mbxi/VJfuOfZ3uS+kdkD7JywfW4uFXUXxU9n/hdxEYD1dgj6wWkSsXoRgDr0oeJINZgQ 4xs7m92oNaky6PbtZEZKdvU19gFjMYD7dz0eArB6YiGrCcTwUGPg/i2iPu0AzhfuXjP6 a81w== X-Gm-Message-State: AOJu0Yw7QuFym8jw2Uga5SovWUz9Rpcuc5QkvLu7YUxmXC0kk7cu/Khn I9poc4mRanaPiCvlPuw77FegyiYSfqoRLanCxkwvSxqdMgxCa2ag X-Received: by 2002:a05:6512:12c7:b0:511:483b:91c6 with SMTP id p7-20020a05651212c700b00511483b91c6mr2449033lfg.48.1707602031347; Sat, 10 Feb 2024 13:53:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVDCEPO8lOjIT51DzfX0Xk56jKN4j7BJTCDTbbgv/kjr9jS2Qb8UI5RVlegTY1z1aNzW5zhtij26w9ska0FnNIORTgrMFUhkdeU73HoaKq7E78ssCAL+TYVFwHZgiN2tkwDETrOtNfiZASzV5TsfqGlmnm1EkJAIjsHKpHCHEmFJSNTH3YJQTXaqVcFDZgmbiN8KAy/iJ0BBT20LsojD5/AOLKs6RjivygyScMKlIgadADWQc9bblL4g4K0DBj003uq/JH6n0S+JSJxlXYUQa4dd5haNHaAW6jh3o2LeAdv/ABrNbEKfIk2r0liYQ116ziFBB7QwyCAR28+Y/ui0jW3rBCijTBvcAh2S9dKS3uwn4FabEJMxQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:51 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 19/19] hid-ft260: uart: improve write performance Date: Sat, 10 Feb 2024 23:51:47 +0200 Message-Id: <20240210215147.77629-20-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Tx performance with the current buffer size of 256 bytes is lower when the data length exceeds the xmit buf size. [134331.147978] ft260_uart_write: count: 288, len: 256 [134331.157945] ft260_uart_write: count: 32, len: 32 [134331.159977] ft260_uart_write: count: 288, len: 256 [134331.169990] ft260_uart_write: count: 32, len: 32 1. Increase the xmit buffer size to page size as used in the serial core and other tty drivers. 2. Remove the xmit buffer fulness against the watermark checking and the tty_wakeup calling in the ft260_uart_transmit_chars routine. This code is taken from other drivers, but other drivers may call the routine from the interrupt context. In our case, this condition is always True since xmit buffer filling and emptying are serialized and done synchronously. Tested with picocom ASCII file transfer by 288-byte chunks at 921600 bauds rate with above 20% performance improvement. Before: 2821.7 Kbytes transferred at 47367 CPS... Done. After: 2821.7 Kbytes transferred at 57788 CPS... Done. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 6b172bfa4f98..1188b8e09938 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -308,8 +308,7 @@ enum { #define FT260_UART_EN_PW_SAVE_BAUD (4800) #define UART_COUNT_MAX (4) /* Number of supported UARTs */ -#define XMIT_FIFO_SIZE (256) -#define TTY_WAKEUP_WATERMARK (XMIT_FIFO_SIZE / 2) +#define XMIT_FIFO_SIZE (PAGE_SIZE) static const struct hid_device_id ft260_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY, @@ -1211,7 +1210,7 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) len = kfifo_out_spinlocked(xmit, rep->data, len, &port->xmit_fifo_lock); - ret = ft260_hid_output_report(hdev, (u8 *)rep, len + sizeof(*rep)); + ret = ft260_hid_output_report(hdev, (u8 *)rep, len + 2); if (ret < 0) goto tty_out; @@ -1219,10 +1218,6 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) port->icount.tx += len; } while (data_len > 0); - len = kfifo_len(xmit); - if ((XMIT_FIFO_SIZE - len) > TTY_WAKEUP_WATERMARK) - tty_wakeup(tty); - ret = 0; tty_out: @@ -1546,7 +1541,7 @@ static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *t if (baudrate > FT260_UART_EN_PW_SAVE_BAUD) ft260_uart_wakeup_workaraund_enable(port, true); - ft260_dbg("configurd baudrate = %d", baudrate); + ft260_dbg("configured baudrate = %d", baudrate); mod_timer(&port->wakeup_timer, jiffies + msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS)); -- 2.40.1