Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4636300yba; Mon, 20 May 2019 00:39:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOyRwpBAptNkwxoBH1k24++h9jv45IMvwbIp0THL34muA3eweMUpwKUmHhXwTni7PiHGAF X-Received: by 2002:a65:610a:: with SMTP id z10mr74203742pgu.54.1558337967077; Mon, 20 May 2019 00:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558337967; cv=none; d=google.com; s=arc-20160816; b=J6vW3yLAW3BelkQKLXfW5vX4/GqVV5jreTfjMPcFlDrTiN90XwwcQOexGpmU043US4 zfcJ2QOl2vzMpph/XSXI03vOzOqqRtrPrW7c+HhoPCzKYJ5nA/JtCxGYoDOTyvj31jh5 3Xg/8WI0kA9bfs47X+zdpkJvRKDFBOffvyrT8bhzNBC9fSASrWjwk4vY+oWtQPNDpQSz kybmpw3FBR8u85s2odfAbt1Gen+rPAF0KLHctPUJfPj25LBwLbSS1MF1DiyA0+ijGCgn GdgKAz3Yn+899yDXuzt1AjTtGbut385GU1TNBeo78XSZDfrKK+Sv5jqVEqKBr/an7HaZ qKrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ZzFqnIOsi8p6z+3XrmxUiH+3WXG0rfBF0N579QptVnw=; b=D0LPthoPz8rYFtLT1H96T0ShtbUv1fli3aVgp8IlZzZY/RyxXHLxQW+7lWgqwKVlG0 3oXzLhfU7HmUFeUmYO5OCKRFiA7b1B2MwBRKSFmyB1HvpaJ0sZp5F+yk1sagmMbOUoyk lgt4GDt7SjDVuwNktpMDgAfwjXzWs68yOth5Yik568ghVfnK8rpVtlc+OrlPyYzfKfgA ZB7NPNC/HMD4Lk0aBPM3lniqpm858YH7C7/hCnNIgUTmOe8TaI5TmE79hThy3AdZeQPF pmHfnCDuDUKIeL3ha1N1hOTBsarzuNp7ntJetWgE7B0pQOOBPbLFsH+O81oH7FifQYca sg3Q== 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 p24si16738455plr.269.2019.05.20.00.39.10; Mon, 20 May 2019 00:39:27 -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; 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 S1730323AbfETHh5 (ORCPT + 99 others); Mon, 20 May 2019 03:37:57 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:43088 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbfETHh5 (ORCPT ); Mon, 20 May 2019 03:37:57 -0400 Received: by mail-vs1-f66.google.com with SMTP id d128so8304606vsc.10; Mon, 20 May 2019 00:37:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZzFqnIOsi8p6z+3XrmxUiH+3WXG0rfBF0N579QptVnw=; b=XHlzanKfUZa49Qnj7RTchm/p+lSZvbWxzVhVGdoDtEEfmSlQnhMxXxtEMjbfIpOfQJ cPK3Sf6EWE72eSHCTDJD6hWY/CC1gFkRNFwoWOhgUP69M3n6lJdCcyqc6QWN3h4fqxzg IJnJM3S478GUZq1QwJn/TmjlJuAjz6tNiBm4VandNuz2qfnek2vSW4L2nvDLELzMFDrg qMg4C5Bvpj9+QDDQq/GeZDCXxqyJB+HrTModIDBUeXKSBkWyhagZoBSQqPNsdJJYtTm/ K0ZV4Wi/EhAmQu9a6Ker0LLJUSr0cPbxo0wPo4yBm6Rc9tG0JUzYXF2WQFxDnhxarntK qpnw== X-Gm-Message-State: APjAAAVFF04Nikw+/bnoHdVrVEO8xI2dnLQZXfuQYLo1/G7rilI4cDES 249i1nOnYzyG0CH4W4SCNyuI+U+QtHE/oICDB4o= X-Received: by 2002:a67:fdd4:: with SMTP id l20mr28417242vsq.63.1558337876203; Mon, 20 May 2019 00:37:56 -0700 (PDT) MIME-Version: 1.0 References: <20190504004258.23574-1-erosca@de.adit-jv.com> <20190504004258.23574-3-erosca@de.adit-jv.com> <20190506194233.GA32430@vmlxhi-102.adit-jv.com> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 20 May 2019 09:37:43 +0200 Message-ID: Subject: Re: [PATCH 2/6] Revert "arm64: dts: renesas: r8a7796: Enable DMA for SCIF2" To: Yoshihiro Shimoda Cc: "REE erosca@DE.ADIT-JV.COM" , Eugeniu Rosca , Geert Uytterhoeven , Simon Horman , Chris Brandt , Wolfram Sang , Ulrich Hecht , Greg Kroah-Hartman , "George G . Davis" , Andy Lowe , Linux-Renesas , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Magnus Damm , Rob Herring , Mark Rutland , Michael Rodin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shimoda-san, Thanks for your analysis! On Mon, May 20, 2019 at 4:18 AM Yoshihiro Shimoda wrote: > > From: Eugeniu Rosca, Sent: Tuesday, May 7, 2019 4:43 AM > > > > > [0] v5.0-rc6 commit 97f26702bc95b5 ("arm64: dts: renesas: r8a7796: Enable DMA for SCIF2") > > > > [1] v4.14.106 commit 703db5d1b1759f ("arm64: dts: renesas: r8a7796: Enable DMA for SCIF2") > > > > [2] scif (DEBUG) and rcar-dmac logs: > > > > https://gist.github.com/erosca/132cce76a619724a9e4fa61d1db88c66 > > > Enabling DEBUG in drivers/dma/sh/rcar-dmac.c, I can notice that one of > > the symptoms is a NULL dst_addr revealed by: > > > > rcar-dmac e7300000.dma-controller: chan0: queue chunk (____ptrval____): 0@0xffff800639eb8090 -> 0x0000000000000000 > > > > In working scenarios, dst_addr is never zero. Does it give any hints? > > Thank you for the report! It's very helpful to me. > I think we should fix the sh-sci driver at least. > > According to the [2] log above, > > [ 4.379716] sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 0...0, cookie 126 > > This "0...0" means the s->tx_dma_len on the sci_dma_tx_work_fn will be zero. And, How can this happen? schedule_work(&s->work_tx) is called only if !uart_circ_empty(), and while holding the port lock? So the circular buffer must be made empty in between the call to schedule_work() and the work function sci_dma_tx_work_fn() being called. I think this can happen if uart_flush_buffer() is called at the right moment? > > rcar-dmac e7300000.dma-controller: chan0: queue chunk (____ptrval____): 0@0xffff800639eb8090 -> 0x0000000000000000 > > This means the chunk->dst_addr is not set to the "dst_addr" for SCIF because the len on rcar_dmac_chan_prep_sg is zero. > So, I'm thinking: > - we have to fix the sh_sci driver to avoid "tx_dma_len = 0" transferring. That sounds like just a simple check for !s->tx_dma_len in sci_dma_tx_work_fn(), to return early, _and_ reset s->cookie_tx to -EINVAL. However, uart_flush_buffer() may still be called in between the check and the calls to dmaengine_prep_slave_single() / dma_sync_single_for_device(), clearing s->tx_dma_len again. Unless something has changed recently, these two calls cannot be moved inside the spinlock-protected section? Using a cached value of s->tx_dma_len for the dmaengine calls might work, though. > and > > - also we have to fix the rcar-dmac driver to avoid this issue because the DMA Engine API > guide doesn't prevent the len = 0. I guess returning an error makes most sense? Else we have to fix it deeper into the driver, where handling becomes more complex. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds