Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp33114imu; Thu, 10 Jan 2019 17:22:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7pJ+3iAjeU1m65AOMVuEfO5CUQDzm4it4GWTk748/nXRQIqoj8yuH8dtaRNpWl8bLVpcZ+ X-Received: by 2002:a17:902:4a0c:: with SMTP id w12mr12741745pld.8.1547169726276; Thu, 10 Jan 2019 17:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547169726; cv=none; d=google.com; s=arc-20160816; b=HlLNidv7fVwTOZmZUgeY3/DAlMqlQiCW4Z/acTZ+269mmcZcrPkBj1q+BFy1Bvpats 34MRsvr+tDhKijjNRVLnPyBSs1Ri9cf3pHWz+ph8qwzQ+KvP3OYal0Tpc4He+eKAXoMK HPUbsxDoigXp5dZR1YrCE0Enwx98snwNg1w1nqrP77l0fYTtaBJC9u9qKIOqT1rMxc9R DzMHcRkzJkkpkTFx9Y7suY7ANVcCnc1dhiB36/N4el6LEtYSZMq87tANqR4ZEc+dBj7a tRD1T1BzJr+v7Qy7T36rZ/HlWH6JhcN0fPRmpXnlbisd8cuLwQghF3WZVYI7B2zAi319 9UOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=JiVDzBR2f50ZU+P0RSDjroF9Yigvnjd8lyMcrYE7J8o=; b=LrQR9f5bpr2vP7t2Bo12/xghNZDI9AMo0iB++sH6JUEx59XCH1p2VSjyICUUdGNb6e ulZXvoC+0O1z5cCj6h8c68n3ikJNE33f1HiLwCLQpWnVuCZ2VsrTd2NpU1Mzmx0AkeAN m31t9/6WMiY7pvAqbgnn2ybQqnw+N9Gp5anoOFudhM3MYZi76CWX/gEm001Sp3eDQEaq iIkWlVVX1oPfiHi9TF2428wgH/tJ4bwruf+sz7SkBEVhrvdDfIBxVAnDwAUbX+uFWSBq 5OTSbWRs8I+IEFiAsGtlZSVv5hZoXiCCBBIeGMIlsum0HJCBDMPMBodsr36SYajY0/5S z6/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65si13174443pfb.194.2019.01.10.17.21.50; Thu, 10 Jan 2019 17:22:06 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729273AbfAKBSw (ORCPT + 99 others); Thu, 10 Jan 2019 20:18:52 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:46734 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726369AbfAKBSv (ORCPT ); Thu, 10 Jan 2019 20:18:51 -0500 X-UUID: a40104ff98954846a198be59a53b4740-20190111 X-UUID: a40104ff98954846a198be59a53b4740-20190111 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1260820821; Fri, 11 Jan 2019 09:18:46 +0800 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 11 Jan 2019 09:18:45 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 11 Jan 2019 09:18:44 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 11 Jan 2019 09:18:43 +0800 Message-ID: <1547169522.3831.47.camel@mhfsdcap03> Subject: Re: [PATCH v9 1/2] dmaengine: 8250_mtk_dma: add MediaTek uart DMA support From: Long Cheng To: Vinod Koul CC: Randy Dunlap , Rob Herring , Mark Rutland , Ryder Lee , "Sean Wang" , Nicolas Boichat , Matthias Brugger , Dan Williams , Greg Kroah-Hartman , Jiri Slaby , Sean Wang , , , , , , , , Yingjoe Chen , "YT Shen" , Zhenbao Liu , "Long Cheng" Date: Fri, 11 Jan 2019 09:18:42 +0800 In-Reply-To: <1547116431.3831.43.camel@mhfsdcap03> References: <1546395178-8880-1-git-send-email-long.cheng@mediatek.com> <1546395178-8880-2-git-send-email-long.cheng@mediatek.com> <20190104171953.GQ13372@vkoul-mobl.Dlink> <1547116431.3831.43.camel@mhfsdcap03> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-01-10 at 18:33 +0800, Long Cheng wrote: fix spell error > On Fri, 2019-01-04 at 22:49 +0530, Vinod Koul wrote: > > On 02-01-19, 10:12, Long Cheng wrote: > > > In DMA engine framework, add 8250 uart dma to support MediaTek uart. > > > If MediaTek uart enabled(SERIAL_8250_MT6577), and want to improve > > > the performance, can enable the function. > > > > Is the DMA controller UART specific, can it work with other controllers > > as well, if so you should get rid of uart name in patch > > > > I don't know that it can work or not on other controller. but it's for > MediaTek SOC > > > > +#define MTK_UART_APDMA_CHANNELS (CONFIG_SERIAL_8250_NR_UARTS * 2) > > > > Why are the channels not coming from DT? > > > > i will using dma-requests install of it. > i will using 'dma-requests' instead of it. > > > + > > > +#define VFF_EN_B BIT(0) > > > +#define VFF_STOP_B BIT(0) > > > +#define VFF_FLUSH_B BIT(0) > > > +#define VFF_4G_SUPPORT_B BIT(0) > > > +#define VFF_RX_INT_EN0_B BIT(0) /*rx valid size >= vff thre*/ > > > +#define VFF_RX_INT_EN1_B BIT(1) > > > +#define VFF_TX_INT_EN_B BIT(0) /*tx left size >= vff thre*/ > > > > space around /* space */ also run checkpatch to check for style errors > > > > ok. > > > > +static void mtk_uart_apdma_start_tx(struct mtk_chan *c) > > > +{ > > > + unsigned int len, send, left, wpt, d_wpt, tmp; > > > + int ret; > > > + > > > + left = mtk_uart_apdma_read(c, VFF_LEFT_SIZE); > > > + if (!left) { > > > + mtk_uart_apdma_write(c, VFF_INT_EN, VFF_TX_INT_EN_B); > > > + return; > > > + } > > > + > > > + /* Wait 1sec for flush, can't sleep*/ > > > + ret = readx_poll_timeout(readl, c->base + VFF_FLUSH, tmp, > > > + tmp != VFF_FLUSH_B, 0, 1000000); > > > + if (ret) > > > + dev_warn(c->vc.chan.device->dev, "tx: fail, debug=0x%x\n", > > > + mtk_uart_apdma_read(c, VFF_DEBUG_STATUS)); > > > + > > > + send = min_t(unsigned int, left, c->desc->avail_len); > > > + wpt = mtk_uart_apdma_read(c, VFF_WPT); > > > + len = mtk_uart_apdma_read(c, VFF_LEN); > > > + > > > + d_wpt = wpt + send; > > > + if ((d_wpt & VFF_RING_SIZE) >= len) { > > > + d_wpt = d_wpt - len; > > > + d_wpt = d_wpt ^ VFF_RING_WRAP; > > > + } > > > + mtk_uart_apdma_write(c, VFF_WPT, d_wpt); > > > + > > > + c->desc->avail_len -= send; > > > + > > > + mtk_uart_apdma_write(c, VFF_INT_EN, VFF_TX_INT_EN_B); > > > + if (mtk_uart_apdma_read(c, VFF_FLUSH) == 0U) > > > + mtk_uart_apdma_write(c, VFF_FLUSH, VFF_FLUSH_B); > > > +} > > > + > > > +static void mtk_uart_apdma_start_rx(struct mtk_chan *c) > > > +{ > > > + struct mtk_uart_apdma_desc *d = c->desc; > > > + unsigned int len, wg, rg, cnt; > > > + > > > + if ((mtk_uart_apdma_read(c, VFF_VALID_SIZE) == 0U) || > > > + !d || !vchan_next_desc(&c->vc)) > > > + return; > > > + > > > + len = mtk_uart_apdma_read(c, VFF_LEN); > > > + rg = mtk_uart_apdma_read(c, VFF_RPT); > > > + wg = mtk_uart_apdma_read(c, VFF_WPT); > > > + if ((rg ^ wg) & VFF_RING_WRAP) > > > + cnt = (wg & VFF_RING_SIZE) + len - (rg & VFF_RING_SIZE); > > > + else > > > + cnt = (wg & VFF_RING_SIZE) - (rg & VFF_RING_SIZE); > > > + > > > + c->rx_status = cnt; > > > + mtk_uart_apdma_write(c, VFF_RPT, wg); > > > + > > > + list_del(&d->vd.node); > > > + vchan_cookie_complete(&d->vd); > > > +} > > > > this looks odd, why do you have different rx and tx start routines? > > > > Would you like explain it in more detail? thanks. > In tx function, will wait the last data flush done. and the count the > size that send. > In Rx function, will count the size that receive. > Any way, in rx / tx, need andle WPT or RPT. > Any way, in rx / tx, need handle WPT or RPT. > > > +static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan) > > > +{ > > > + struct mtk_uart_apdmadev *mtkd = to_mtk_uart_apdma_dev(chan->device); > > > + struct mtk_chan *c = to_mtk_uart_apdma_chan(chan); > > > + u32 tmp; > > > + int ret; > > > + > > > + pm_runtime_get_sync(mtkd->ddev.dev); > > > + > > > + mtk_uart_apdma_write(c, VFF_ADDR, 0); > > > + mtk_uart_apdma_write(c, VFF_THRE, 0); > > > + mtk_uart_apdma_write(c, VFF_LEN, 0); > > > + mtk_uart_apdma_write(c, VFF_RST, VFF_WARM_RST_B); > > > + > > > + ret = readx_poll_timeout(readl, c->base + VFF_EN, tmp, > > > + tmp == 0, 10, 100); > > > + if (ret) { > > > + dev_err(chan->device->dev, "dma reset: fail, timeout\n"); > > > + return ret; > > > + } > > > > register read does reset? > > > > 'mtk_uart_apdma_write(c, VFF_RST, VFF_WARM_RST_B);' is reset. resd just > poll reset done. > > > > + > > > + if (!c->requested) { > > > + c->requested = true; > > > + ret = request_irq(mtkd->dma_irq[chan->chan_id], > > > + mtk_uart_apdma_irq_handler, IRQF_TRIGGER_NONE, > > > + KBUILD_MODNAME, chan); > > > > why is the irq not requested in driver probe? > > > > I have explained in below, > http://lists.infradead.org/pipermail/linux-mediatek/2018-December/016418.html > > > > +static enum dma_status mtk_uart_apdma_tx_status(struct dma_chan *chan, > > > + dma_cookie_t cookie, > > > + struct dma_tx_state *txstate) > > > +{ > > > + struct mtk_chan *c = to_mtk_uart_apdma_chan(chan); > > > + enum dma_status ret; > > > + unsigned long flags; > > > + > > > + if (!txstate) > > > + return DMA_ERROR; > > > + > > > + ret = dma_cookie_status(chan, cookie, txstate); > > > + spin_lock_irqsave(&c->vc.lock, flags); > > > + if (ret == DMA_IN_PROGRESS) { > > > + c->rx_status = mtk_uart_apdma_read(c, VFF_RPT) & VFF_RING_SIZE; > > > + dma_set_residue(txstate, c->rx_status); > > > + } else if (ret == DMA_COMPLETE && c->cfg.direction == DMA_DEV_TO_MEM) { > > > > why set reside when it is complete? also reside can be null, that should > > be checked as well > > > In different status, set different reside. > > > > +static struct dma_async_tx_descriptor *mtk_uart_apdma_prep_slave_sg > > > + (struct dma_chan *chan, struct scatterlist *sgl, > > > + unsigned int sglen, enum dma_transfer_direction dir, > > > + unsigned long tx_flags, void *context) > > > +{ > > > + struct mtk_chan *c = to_mtk_uart_apdma_chan(chan); > > > + struct mtk_uart_apdma_desc *d; > > > + > > > + if ((dir != DMA_DEV_TO_MEM) && > > > + (dir != DMA_MEM_TO_DEV)) { > > > + dev_err(chan->device->dev, "bad direction\n"); > > > + return NULL; > > > + } > > > > we have a macro for this > > Thanks for your suggestion. i will modify it. > > > > > + > > > + /* Now allocate and setup the descriptor */ > > > + d = kzalloc(sizeof(*d), GFP_ATOMIC); > > > + if (!d) > > > + return NULL; > > > + > > > + /* sglen is 1 */ > > > > ? > > > > > +static int mtk_uart_apdma_slave_config(struct dma_chan *chan, > > > + struct dma_slave_config *cfg) > > > +{ > > > + struct mtk_chan *c = to_mtk_uart_apdma_chan(chan); > > > + struct mtk_uart_apdmadev *mtkd = > > > + to_mtk_uart_apdma_dev(c->vc.chan.device); > > > + > > > + c->cfg = *cfg; > > > + > > > + if (cfg->direction == DMA_DEV_TO_MEM) { > > > > fg->direction is deprecated, in fact I have removed all users recently, > > please do not use this > > You will remove 'direction' in 'struct dma_slave_config'? if remove, how > do confirm direction? > > > > > > + unsigned int rx_len = cfg->src_addr_width * 1024; > > > + > > > + mtk_uart_apdma_write(c, VFF_ADDR, cfg->src_addr); > > > + mtk_uart_apdma_write(c, VFF_LEN, rx_len); > > > + mtk_uart_apdma_write(c, VFF_THRE, VFF_RX_THRE(rx_len)); > > > + mtk_uart_apdma_write(c, VFF_INT_EN, > > > + VFF_RX_INT_EN0_B | VFF_RX_INT_EN1_B); > > > + mtk_uart_apdma_write(c, VFF_RPT, 0); > > > + mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_RX_INT_FLAG_CLR_B); > > > + mtk_uart_apdma_write(c, VFF_EN, VFF_EN_B); > > > > why are we writing this here, we are supposed to do that when txn > > starts! > > > > also you can review the link > http://lists.infradead.org/pipermail/linux-mediatek/2018-December/016418.html > > > > +static int mtk_uart_apdma_device_resume(struct dma_chan *chan) > > > +{ > > > + /* just for check caps pass */ > > > + return 0; > > > +} > > > > if you do not support this please remove this! > > > > > +static void mtk_uart_apdma_free(struct mtk_uart_apdmadev *mtkd) > > > +{ > > > + while (list_empty(&mtkd->ddev.channels) == 0) { > > > + struct mtk_chan *c = list_first_entry(&mtkd->ddev.channels, > > > + struct mtk_chan, vc.chan.device_node); > > > + > > > + list_del(&c->vc.chan.device_node); > > > + tasklet_kill(&c->vc.task); > > > + } > > > +} > > > + > > > +static const struct of_device_id mtk_uart_apdma_match[] = { > > > + { .compatible = "mediatek,mt6577-uart-dma", }, > > > > where is the binding document for ediatek,mt6577-uart-dma ?? > > > > http://lists.infradead.org/pipermail/linux-mediatek/2018-December/016154.html >