From patchwork Thu Oct 2 16:14:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 5019321 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 54BB4C11AB for ; Thu, 2 Oct 2014 16:14:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34C85201F5 for ; Thu, 2 Oct 2014 16:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B41020158 for ; Thu, 2 Oct 2014 16:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754288AbaJBQOQ (ORCPT ); Thu, 2 Oct 2014 12:14:16 -0400 Received: from sauhun.de ([89.238.76.85]:59410 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754545AbaJBQOA (ORCPT ); Thu, 2 Oct 2014 12:14:00 -0400 Received: from p4fe24c20.dip0.t-ipconnect.de ([79.226.76.32]:44086 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XZj0u-00023R-Rz; Thu, 02 Oct 2014 18:13:57 +0200 From: Wolfram Sang To: linux-sh@vger.kernel.org Cc: Wolfram Sang , Magnus Damm , Simon Horman , Laurent Pinchart , Geert Uytterhoeven , Kuninori Morimoto Subject: [PATCH] serial: sh-sci: submit rx dma the way the DMA driver can handle it Date: Thu, 2 Oct 2014 18:14:08 +0200 Message-Id: <1412266448-20266-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.0.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wolfram Sang The shdmac driver has a problem when one wants to submit two RX descriptors and then use issue_pending on both (like this driver does): Submit first desc -> channel state after: SHDMA_PM_ESTABLISHED Submit second desc -> channel state after: SHDMA_PM_PENDING PENDING here means: "Oh, we will wait until the first desc is finished and then the second desc will be grabbed from the list anyhow" However, because issue_pending does nothing for states != SHDMA_PM_ESTABLISHED, nothing ever gets active :( Since the DMA driver is probably replaced soon anyhow, I decided for the least intrusive workaround which is to use issue_pending on every RX desc. (Yes, setting s->active_rx twice is ugly). Probably not for upstream! However, this patch restores DMA capability for SCIFA on my Lager board. Sadly, not for SCIF due to interrupt problems still to be investigated. Signed-off-by: Wolfram Sang Acked-by: Simon Horman --- Some more words about the not working SCIF: Once I submit the RX descriptor, I don't get any irq anymore (which the driver needs to detect timeouts). Before that, I got them. SCIFA has a bit (SCSCR_RDRQE) to select if the interrupt should go to the CPU or DMAC and the driver handles this correctly, so DMA works again. Plain SCIF does not have such a bit. The documentation has a chapter "SCIF Interrupt Sources and the DMAC" (chapter 51.4 here in v0.9) which is a little vague to me. But from what I understand, I should get an irq along with the DMAC transferring data. The implementation of this driver shows that earlier SH hardware worked this way. However, I don't get interrupts, so the timeout mechanism fails. DMA works partly, you can receive in 32 bytes chunks only. If you are happy with that, you can also use SCIF. Good practice for your typing skills ;) So, my SCIF->SCIFA patch becomes more useful, too. drivers/tty/serial/sh-sci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index b11819bc95c4..f23b4d2ab51f 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1365,16 +1365,18 @@ static void sci_submit_rx(struct sci_port *s) } dev_warn(s->port.dev, "failed to re-start DMA, using PIO\n"); + + chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); sci_rx_dma_release(s, true); return; } + + s->active_rx = s->cookie_rx[0]; + + dma_async_issue_pending(chan); dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__, s->cookie_rx[i], i); } - - s->active_rx = s->cookie_rx[0]; - - dma_async_issue_pending(chan); } static void work_fn_rx(struct work_struct *work)