From patchwork Sat Feb 10 21:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 199312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1668795dyd; Sat, 10 Feb 2024 13:58:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9uQ3emZz+v79mJAMuz+t/tGY2+rV7iA5zGX2DCsDFD1HGPdc4Kkv2fvp+dODDNABgzT8A X-Received: by 2002:a05:622a:1b8d:b0:42c:31cf:d6fd with SMTP id bp13-20020a05622a1b8d00b0042c31cfd6fdmr4074026qtb.6.1707602339069; Sat, 10 Feb 2024 13:58:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707602339; cv=pass; d=google.com; s=arc-20160816; b=wB5AtEVMWtmouozuoL+vsJ8WZVrsrtKGhptw+FZWLqGdpik0+vz/pRtaO6Blf8ss/d 622y+w2qYHAVN+uCeyg9nFgtuGbPThSTz4a46Pt0GDf4SFGc7RhCIRwsVafXouE0pIiG 2OXIPBPCJSErB6Ua5E3IwwMZE2FFkO7IBxMNI8gUEmsQ5S4+RnXUZJbO0QPXAcI3/1jc Fh1vpJgwhdW3/nMm/BCTo/CbY4F9XfLKT5xmfeDrcSITgaJYeMOve/7pybPw+MklWjU2 WiNAK2MZdLBiAzt4EGvbdGm1tnKj6dAktJK+Wk/CKUNuE70FlIde1EfQwFqx7gu+aRi2 LKLw== 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=qdj7qBldEuW5O7QzN2CcVbHvr478z2ViieOIAcFtfSQ=; b=k77u+k33IR5XdBgoKxX3bPta6S8EMhsmNQeczLRtn+8vVJ7JdIXHBWq7PSaIFwTR9j XSWJK+tAMpxYQXjQXgiJ6eOYz6U+jjQkekoaJRjNkeMONctH7bnr4vLV/7h7M81/zp9u 2Mgxo1aeQXYQTPi1gRqIcD+/qo5wfnzuh54uxyI7cGILzTh6H/BBtv/+eKs9E7FXYqu7 y4pCvfDtw6BYEASPlyk2/fisWHJ1X52Z7r3m03dhABwPYeyALWd858sSaYzrOH4jpaBN Xmjxs9oWfpMuoCmVp18ySPK+KqFJ+Slo+5FH0gj3XoqXdDFIG0ShqLyEzT8GhPstPXNZ OmRA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60566-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUhB4zHJmThB3FelUVsCSkQO6ypaugcpBTYbXD7qjsz+NGuhmeGO5mJSEaSLuINWc5ubNW1jvbqulh//JcK3WFeu+VsxA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p24-20020ac87418000000b0042c58607bf2si544302qtq.214.2024.02.10.13.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:58:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60566-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60566-ouuuleilei=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 C954C1C212D5 for ; Sat, 10 Feb 2024 21:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2F7961677; Sat, 10 Feb 2024 21:53:57 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790550830316347628 X-GMAIL-MSGID: 1790550830316347628 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));