Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp983702ybm; Tue, 21 May 2019 06:59:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhBFEizpNk3XSU/OL6krO6f3mdmPmN0seGrzJUeEZw74x7m7ZuINXRKfdJ599RFAMumBbL X-Received: by 2002:a65:62d8:: with SMTP id m24mr81634345pgv.141.1558447142452; Tue, 21 May 2019 06:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558447142; cv=none; d=google.com; s=arc-20160816; b=j03DmYhKumGhe0up5v774Evy0hdUpBSGZqmCsoEaV8wf49c0hL0omdcw2WtIxhLadu izU27YeH/GQJ15AcNJafF4vdlEc0kK9l/O7qDrw5P0MF+mokhP+xLlHHQ0cD/hdCssh1 +Yd7dIWpZeVWgfDQq5WPY9Ly/Y5oMUtPp4s/uxCQEAnKP5tlNe5FXcCiZQTp+yLnEMPn YlZI7ggFDNPQe4odGKaElKszFe1n60aLJevSfZS64eCAyGOetNKXMByGIOCUtKW98Wrv WiooB0+30bwwixHTAh+vwWuU24pUIEjDMXIX8nU4aCU6ZXJ18UL6o8/8SdG74vCkkx1x FJYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bGxdsqK8S/7cb+QjUUxZRLivrCO9eXgs/x+/HNY880Q=; b=pbp6oh7BpolUHIRfgQDnru65LFdDFpJhveUKyB4w52/tAcwfgVNH4HI/c+zAUA+wWR 9mB8VotmOsXVdAeOJG8K+c1uAIl0waFvqEDuLuWQYD7EYui1R8KNLcXWp+xAak0QiFb8 YzDL2eT6EmiI28rwYZTLDWjqnxewaP+6MZKPKvw4gZuBfY45dEZvEyGbHlhRu0wdonPz 50EMGephX886HDDcNAVyG73TDRoGGs/bZ1KcXvVl1dB2ol36rm8/bJSLS+IYsUT4vuU0 ILqOtGyQ/Fu7tZ08ZxReG8jbIea7n2J2pH8AfdUBcAhdP1ruywu59t3Sc9zeAP1zgv2O 4qSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bgXxUEe1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j38si21109236plb.308.2019.05.21.06.58.47; Tue, 21 May 2019 06:59:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bgXxUEe1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbfEUN5c (ORCPT + 99 others); Tue, 21 May 2019 09:57:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEUN5b (ORCPT ); Tue, 21 May 2019 09:57:31 -0400 Received: from localhost (unknown [106.51.105.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04AC621479; Tue, 21 May 2019 13:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558447050; bh=p5zj6aoLLNC0yMiNnBSt2O1dX8e+LCMuZRJxjILAIfw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bgXxUEe1venUsogc/J7JRiQZeehTDpwIWNaoFUysa+vgHozkfEzxPdBnv6w452wux 0H8q2NuqSq+LleLgJhAoKYAypYZz7jMPws06tLgOW0oLo6LXekJc7fEvT6w7aERLGW vZS4BQBBoiOHcuGYUC16SQ5k2QBs9SkKj+R0VaS8= Date: Tue, 21 May 2019 19:27:25 +0530 From: Vinod Koul To: Long Cheng Cc: Randy Dunlap , Rob Herring , Mark Rutland , Ryder Lee , Sean Wang , Nicolas Boichat , Matthias Brugger , Dan Williams , Greg Kroah-Hartman , Jiri Slaby , Sean Wang , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, srv_heupstream@mediatek.com, Yingjoe Chen , YT Shen , Zhenbao Liu Subject: Re: [PATCH 4/4] serial: 8250-mtk: modify uart DMA rx Message-ID: <20190521135725.GN15118@vkoul-mobl> References: <1556336193-15198-1-git-send-email-long.cheng@mediatek.com> <1556336193-15198-5-git-send-email-long.cheng@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556336193-15198-5-git-send-email-long.cheng@mediatek.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27-04-19, 11:36, Long Cheng wrote: > Modify uart rx and complete for DMA. > > Signed-off-by: Long Cheng > --- > drivers/tty/serial/8250/8250_mtk.c | 53 ++++++++++++++++-------------------- > 1 file changed, 23 insertions(+), 30 deletions(-) > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > index c1fdbc0..04081a6 100644 > --- a/drivers/tty/serial/8250/8250_mtk.c > +++ b/drivers/tty/serial/8250/8250_mtk.c > @@ -30,7 +30,6 @@ > #define MTK_UART_DMA_EN_TX 0x2 > #define MTK_UART_DMA_EN_RX 0x5 > > -#define MTK_UART_TX_SIZE UART_XMIT_SIZE > #define MTK_UART_RX_SIZE 0x8000 > #define MTK_UART_TX_TRIGGER 1 > #define MTK_UART_RX_TRIGGER MTK_UART_RX_SIZE > @@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param) > struct mtk8250_data *data = up->port.private_data; > struct tty_port *tty_port = &up->port.state->port; > struct dma_tx_state state; > + int copied, cnt, tmp; > unsigned char *ptr; > - int copied; > > - dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr, > - dma->rx_size, DMA_FROM_DEVICE); > + if (data->rx_status == DMA_RX_SHUTDOWN) > + return; > > dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); > + cnt = dma->rx_size - state.residue; > + tmp = cnt; > > - if (data->rx_status == DMA_RX_SHUTDOWN) > - return; > + if ((data->rx_pos + cnt) > dma->rx_size) > + tmp = dma->rx_size - data->rx_pos; > > - if ((data->rx_pos + state.residue) <= dma->rx_size) { > - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > - copied = tty_insert_flip_string(tty_port, ptr, state.residue); > - } else { > - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > - copied = tty_insert_flip_string(tty_port, ptr, > - dma->rx_size - data->rx_pos); > + ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > + copied = tty_insert_flip_string(tty_port, ptr, tmp); > + data->rx_pos += tmp; > + > + if (cnt > tmp) { > ptr = (unsigned char *)(dma->rx_buf); > - copied += tty_insert_flip_string(tty_port, ptr, > - data->rx_pos + state.residue - dma->rx_size); > + tmp = cnt - tmp; > + copied += tty_insert_flip_string(tty_port, ptr, tmp); > + data->rx_pos = tmp; > } > + > up->port.icount.rx += copied; > > tty_flip_buffer_push(tty_port); > @@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param) > static void mtk8250_rx_dma(struct uart_8250_port *up) > { > struct uart_8250_dma *dma = up->dma; > - struct mtk8250_data *data = up->port.private_data; > struct dma_async_tx_descriptor *desc; > - struct dma_tx_state state; > > desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, > dma->rx_size, DMA_DEV_TO_MEM, > @@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up) > > dma->rx_cookie = dmaengine_submit(desc); > > - dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); > - data->rx_pos = state.residue; > - > - dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr, > - dma->rx_size, DMA_FROM_DEVICE); > - > dma_async_issue_pending(dma->rxchan); > } > > @@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up) > if (data->rx_status != DMA_RX_START) > return; > > - dma->rxconf.direction = DMA_DEV_TO_MEM; > - dma->rxconf.src_addr_width = dma->rx_size / 1024; > - dma->rxconf.src_addr = dma->rx_addr; > + dma->rxconf.direction = DMA_DEV_TO_MEM; Direction field is deprecated, please do not use this anymore... > + dma->rxconf.src_port_window_size = dma->rx_size; > + dma->rxconf.src_addr = dma->rx_addr; > > - dma->txconf.direction = DMA_MEM_TO_DEV; > - dma->txconf.dst_addr_width = MTK_UART_TX_SIZE / 1024; > - dma->txconf.dst_addr = dma->tx_addr; > + dma->txconf.direction = DMA_MEM_TO_DEV; > + dma->txconf.dst_port_window_size = UART_XMIT_SIZE; > + dma->txconf.dst_addr = dma->tx_addr; > > serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | > UART_FCR_CLEAR_XMIT); > @@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port) > * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS) > * > * We need to recalcualte the quot register, as the claculation depends > - * on the vaule in the highspeed register. > + * on the value in the highspeed register. > * > * Some baudrates are not supported by the chip, so we use the next > * lower rate supported and update termios c_flag. > -- > 1.7.9.5 -- ~Vinod