From patchwork Mon Nov 7 10:21:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 16356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1962627wru; Mon, 7 Nov 2022 02:23:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM73+ytFQXu8rMQnrnqbTqlFF6kDOuuJGDa49lt24TI2dx7z1fGB7/WGGtC6SsjrXikheQD+ X-Received: by 2002:a17:906:dac9:b0:780:ab6f:591f with SMTP id xi9-20020a170906dac900b00780ab6f591fmr47195999ejb.77.1667816635753; Mon, 07 Nov 2022 02:23:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667816635; cv=none; d=google.com; s=arc-20160816; b=Ix0gZGHE5ShOeHNdPlzYFKzgjvt9aPt+F6nQciP4t9TAECTwhF8K14fvfXK5PQAy1r R8FeVnaEIUddeDJRu6AVAAWLRMU/KtEKdnQhOrdIWBc+sfBsBfx433ooSQ0v6MSJRIlW oWv9XJpK1+Es/OQaAYPxsIlaYm53yWBKf+c2f7mNb80VkzndyxayuDWOE5Kgkibwm/l3 6ffsfWGo2HnFAcmAuS4+Nqq8Y2ee+4+tJidowfc3vt/wmbRMHTQt5QMU9qiVJWdnwfaM g8hr8ArgWjHcXvqDRhlDGizMHqa+fBmTSzKA4GbJiZxRcLkCOfgKXX2sUh1wT+Tx1bq6 sPRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4UHq0EIXDGIpt/xsKRa929ecL/CK6fqz3KiACXsiVLw=; b=Kl+tyEXlSsVOaDssY4omMz8mqCWqBTuE+Gi/Z/ngOfUm/HprM3NjKxbl6AiH/eiLf1 yn+IpUSoyR1Mu7dcmal3b+cb9NIQMJ92PTL0OnAU9X9MWNPBZybcthtpWYpNrowqD4Jv HRlnoIXAUEYO2WSomIX5JG5D2KsLYw2pdC8qLJBB1NPSnaXHsHVmm4gh6qnf6IpV702Y vAQ0CIxF4yms5b0N2UM9dmmgN3pD+4drl94l07i17PJXCYLVaA+C1Np61Fp1JGTH2ZnO fMDp9OdxfknDBiVvQsbdVoiMDqPH0PvgpbfQDcT11u4eat8I3WnOzBRuc5l1CPtTjWSe +JMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ajm/VtNK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs8-20020a1709072d0800b007ae0e8f5993si9973910ejc.252.2022.11.07.02.23.32; Mon, 07 Nov 2022 02:23:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ajm/VtNK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiKGKWM (ORCPT + 99 others); Mon, 7 Nov 2022 05:22:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbiKGKVw (ORCPT ); Mon, 7 Nov 2022 05:21:52 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0433018E36; Mon, 7 Nov 2022 02:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667816499; x=1699352499; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=86H81jTk5MeGGr4bfjg6h5GLTuAz4tzPfCa+h/HeqSM=; b=Ajm/VtNK0dgsKTDcGVG9hGscy3xT2aJKNr13HxjMwp61x8+5qIB4sSjR iSxJiE54+joW8RzxSe4MO8x5WoyEJqCSj3+12wWbsd7S/00FstHBsT/6h 1jb4Gis8b1NLO+Ol4kaVLXrBEt0x1KpMbM1MNHXn22SW0pBrNEk5er0Nn PiiSti2212B002jeMsNpkErKOw4kxzGB8bx2vO76GF2Uy7QPA+wA63fKN uHnox2Yrvx42yHbc3JEQj59btWttoLzfxpaLyH+nKxYJGw4rcN8psoekc +wbtkW7Ymp8nIHQa9R7IQ7BZhtsByP6hH2jFTbdhsmcv9hW4X6O/PPh3y g==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="293724142" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="293724142" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 02:21:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="965100338" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="965100338" Received: from gschoede-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.46.211]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 02:21:36 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Gilles BULOZ Subject: [PATCH 1/1] serial: 8250_dma: Rearm DMA Rx if more data is pending Date: Mon, 7 Nov 2022 12:21:26 +0200 Message-Id: <20221107102126.56481-1-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748832496677850272?= X-GMAIL-MSGID: =?utf-8?q?1748832496677850272?= When DMA Rx completes, the current behavior is to just exit the DMA completion handler without future actions. If the transfer is still on-going, UART will trigger an interrupt and that eventually rearms the DMA Rx. The extra interrupt round-trip has an inherent latency cost that increases the risk of FIFO overrun. In such situations, the latency margin tends to already be less due to FIFO not being empty. Add check into DMA Rx completion handler to detect if LSR has DR (Data Ready) still set. DR indicates there will be more characters pending and DMA Rx can be rearmed right away to handle them. Cc: Gilles BULOZ Signed-off-by: Ilpo Järvinen Reviewed-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_dma.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index b85c82616e8c..37d6af2ec427 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -38,9 +38,8 @@ static void __dma_tx_complete(void *param) spin_unlock_irqrestore(&p->port.lock, flags); } -static void __dma_rx_complete(void *param) +static void __dma_rx_complete(struct uart_8250_port *p) { - struct uart_8250_port *p = param; struct uart_8250_dma *dma = p->dma; struct tty_port *tty_port = &p->port.state->port; struct dma_tx_state state; @@ -57,6 +56,20 @@ static void __dma_rx_complete(void *param) tty_flip_buffer_push(tty_port); } +static void dma_rx_complete(void *param) +{ + struct uart_8250_port *p = param; + struct uart_8250_dma *dma = p->dma; + unsigned long flags; + + __dma_rx_complete(p); + + spin_lock_irqsave(&p->port.lock, flags); + if (!dma->rx_running && (serial_lsr_in(p) & UART_LSR_DR)) + p->dma->rx_dma(p); + spin_unlock_irqrestore(&p->port.lock, flags); +} + int serial8250_tx_dma(struct uart_8250_port *p) { struct uart_8250_dma *dma = p->dma; @@ -130,7 +143,7 @@ int serial8250_rx_dma(struct uart_8250_port *p) return -EBUSY; dma->rx_running = 1; - desc->callback = __dma_rx_complete; + desc->callback = dma_rx_complete; desc->callback_param = p; dma->rx_cookie = dmaengine_submit(desc);