From patchwork Wed Jan 17 16:28:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124864 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp108230lja; Wed, 17 Jan 2018 08:43:42 -0800 (PST) X-Google-Smtp-Source: ACJfBoug8Y1rC/TfmCNWTFxs7YxoSp3h94iU50ec282GLkITGia8COU/Rpq6FktK2yRRC4z5jRjn X-Received: by 10.98.242.77 with SMTP id y13mr13033019pfl.156.1516207421950; Wed, 17 Jan 2018 08:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207421; cv=none; d=google.com; s=arc-20160816; b=WYCSFPbQJtsl+QWP4KvWQ7dU21tF7Kil2ETvGVVMLU0hs9O+HpISiP6Xli3aSv0t+2 0mVltQrLB5D15QYoSVeNt7zD7U3sgTmWXYnhz2JZB14vR460o1MPAbnpu/UHhGTAq9XJ GUJgN1H6TOc8D96xIXYG1qFM8/cVxzSyNKwzXylJPjwQbgyuj+68zSbBnHbikZmA7ov7 AfbvAnmWArI8JgdPN0Xs5vGf0FXwgGi8vpvbKoTaatNMEwJt5XGMdEJDYn9coTG/KTu+ 5p4n3sr4xB9ip+u61UoKqoV/HOR1mXgB++CJFNyY2ULd9edboYoZmMmzl3VqiDrP9PDG KhIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=6S1mqYtI8L2M0uD0p0SGl3YFaHBOIXEJ15OmOIXni5A=; b=HQO5T2JLcHYKQvmhq9QOvC52bzEJg7UMf4/uFoeHSmgzfk0xL3p6hbI32OynO3zBM9 DVfyt4tzVgG9mE0SQT6STcVCJU9BlK5fCkpI/iSvmJsxHx4aODw1TSzvg4BbmWSggjIq xTm5j7VXRkEKAj6MwRsz3pnZxEsHTsGZkMVM4ErW4s9blMCdKfqiyd/wbaC6wOoLH8Nl stFI3TwT1GJ802X+vCau3TK4DnJOdSO9dVF4dtyPXqXQsrjcIo3dgSClxcWo1CSIHcRm 2xoe7yW025vx/9FLgG247i3PJMNk4Cohf4A3vwVTuevx60KwBRb3z6hUarrcBU6IUKqp KwCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=asgRqcwu; 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 f5si4701255plj.125.2018.01.17.08.43.41; Wed, 17 Jan 2018 08:43:41 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=asgRqcwu; 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 S1754076AbeAQQnk (ORCPT + 28 others); Wed, 17 Jan 2018 11:43:40 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36669 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753778AbeAQQ3b (ORCPT ); Wed, 17 Jan 2018 11:29:31 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-08.nifty.com with ESMTP id w0HGSIL0014790; Thu, 18 Jan 2018 01:28:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIL0014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206512; bh=6S1mqYtI8L2M0uD0p0SGl3YFaHBOIXEJ15OmOIXni5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=asgRqcwub+fBQ5z7PmUHsOzdZ/hrpMu3i7DqJ6kLq7ZYzcKF/qDH4pjyFpGxzzVQX 4005refgIP5hyd9A9BQrE4eLSxw9GwZgxvCpCbpI3i+1za/wLTZEzFMTY/JKbS1yWi enSMhxXmk8pF/2M9hBRz65EgntHKPgIdWzantTmN/K7p5D/GveaVodM3S88q+Dy02s hAEsxemWZTZkppo95HODSR7RIc5IQ1b0+chTGqFOAdJkgqJtgWyJYeO43pQFtmajDM p/fAUFoAMSk05O8+JC+vPNdp/oLEkLbRpya5dr/OaHbN4Cwya1GdOZE7ipB+0WJ4EI cHbPEHoyTLwzw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Ulf Magnusson , Geert Uytterhoeven , Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 14/16] mmc: tmio: move TMIO_MASK_{READOP, WRITEOP} handling to correct place Date: Thu, 18 Jan 2018 01:28:14 +0900 Message-Id: <1516206496-16612-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> References: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As far as I tested the IP on UniPhier SoCs, TMIO_STAT_{RXRDY,TXRQ} are asserted for DMA mode as well as for PIO. I need to disable the those IRQs in dma_ops->start hook, otherwise the DMA transfer fails with the following error message: PIO IRQ in DMA mode! Renesas chips are the same cases since I see their dma_ops->start hooks explicitly clear TMIO_STAT_{RXRDY,TXRQ} (with nice comment!). If we do this sanity check in TMIO MMC core, RXRDY/TXRQ handling should be entirely moved to the core. tmio_mmc_cmd_irq() will be a suitable place to disable them. The probe function sets TMIO_MASK_{READOP,WRITEOP} but this is odd. /* Unmask the IRQs we want to know about */ if (!_host->chan_rx) irq_mask |= TMIO_MASK_READOP; if (!_host->chan_tx) irq_mask |= TMIO_MASK_WRITEOP; At this point, _host->{chan_rx,chan_tx} are _always_ NULL because tmio_mmc_request_dma() is called after this code. Consequently, TMIO_MASK_{READOP,WRITEOP} are set here whether DMA is used or not. Remove this pointless code. Signed-off-by: Masahiro Yamada --- Changes in v3: - Remove the first paragraph of git-log - Clean up renesas drivers too Changes in v2: - Newly added drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 ------ drivers/mmc/host/renesas_sdhi_sys_dmac.c | 4 ---- drivers/mmc/host/tmio_mmc_core.c | 20 ++++++++++---------- 3 files changed, 10 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index 0d1f95e..693ad49 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -145,7 +145,6 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, u32 dtran_mode = DTRAN_MODE_BUS_WID_TH | DTRAN_MODE_ADDR_MODE; enum dma_data_direction dir; int ret; - u32 irq_mask; /* This DMAC cannot handle if sg_len is not 1 */ WARN_ON(host->sg_len > 1); @@ -157,11 +156,9 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, if (data->flags & MMC_DATA_READ) { dtran_mode |= DTRAN_MODE_CH_NUM_CH1; dir = DMA_FROM_DEVICE; - irq_mask = TMIO_STAT_RXRDY; } else { dtran_mode |= DTRAN_MODE_CH_NUM_CH0; dir = DMA_TO_DEVICE; - irq_mask = TMIO_STAT_TXRQ; } ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir); @@ -170,9 +167,6 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, renesas_sdhi_internal_dmac_enable_dma(host, true); - /* disable PIO irqs to avoid "PIO IRQ in DMA mode!" */ - tmio_mmc_disable_mmc_irqs(host, irq_mask); - /* set dma parameters */ renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_MODE, dtran_mode); diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index afdb66b..393df17 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -205,8 +205,6 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host) return; } - tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_RXRDY); - /* The only sg element can be unaligned, use our bounce buffer then */ if (!aligned) { sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); @@ -280,8 +278,6 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) return; } - tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_TXRQ); - /* The only sg element can be unaligned, use our bounce buffer then */ if (!aligned) { unsigned long flags; diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 0e3dc8c..731552a 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -621,15 +621,21 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host, unsigned int stat) */ if (host->data && (!cmd->error || cmd->error == -EILSEQ)) { if (host->data->flags & MMC_DATA_READ) { - if (host->force_pio || !host->chan_rx) + if (host->force_pio || !host->chan_rx) { tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_READOP); - else + } else { + tmio_mmc_disable_mmc_irqs(host, + TMIO_MASK_READOP); tasklet_schedule(&host->dma_issue); + } } else { - if (host->force_pio || !host->chan_tx) + if (host->force_pio || !host->chan_tx) { tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_WRITEOP); - else + } else { + tmio_mmc_disable_mmc_irqs(host, + TMIO_MASK_WRITEOP); tasklet_schedule(&host->dma_issue); + } } } else { schedule_work(&host->done); @@ -1287,12 +1293,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK); tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL); - /* Unmask the IRQs we want to know about */ - if (!_host->chan_rx) - irq_mask |= TMIO_MASK_READOP; - if (!_host->chan_tx) - irq_mask |= TMIO_MASK_WRITEOP; - _host->sdcard_irq_mask &= ~irq_mask; if (_host->native_hotplug)