From patchwork Fri Nov 24 16:24:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10074375 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA17E6056E for ; Fri, 24 Nov 2017 16:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3EC2A1E9 for ; Fri, 24 Nov 2017 16:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B22642A2D3; Fri, 24 Nov 2017 16:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 662A52A1EB for ; Fri, 24 Nov 2017 16:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753707AbdKXQgY (ORCPT ); Fri, 24 Nov 2017 11:36:24 -0500 Received: from condef-10.nifty.com ([202.248.20.75]:40086 "EHLO condef-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753672AbdKXQgW (ORCPT ); Fri, 24 Nov 2017 11:36:22 -0500 Received: from conuserg-11.nifty.com ([10.126.8.74])by condef-10.nifty.com with ESMTP id vAOGQ6ss010471 for ; Sat, 25 Nov 2017 01:26:09 +0900 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vAOGP9W3007100; Sat, 25 Nov 2017 01:25:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vAOGP9W3007100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511540724; bh=8C+zOhnbQeTYvpea7T5tGqAWNkgTREME6b/JsxyFNTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u4TGr6fsJMVEyzotJiclYDMGgsBO+Y+XliUbzzw62IY0HaiqQT8U98Kzo1FVYxLtQ cB/Sepjy2QY0MZLjImYze58W7R8QmJwopqy6Zf7sAr3zWyoL042a3LLa1dw8lXQnY4 xrisL1AxVD97aNVqHJnUsQFLko8+3odjfIf8RNr69GYBkKOv8KKpAMDvHoOk42NXiN D7loL091kESR85dwAt3Cs7MSQUkHztSXbZI1H2Su1FmcD8UKb6j2zUI4G/3RU5xSIU bljgPMpi00nWRuYt3NnOL4Dunk+QwaIjEK3kjxF22rFBAr6AMtmzwoYbZREPXOD10+ CodV/apTPGgkA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 17/22] mmc: tmio: move TMIO_MASK_{READOP, WRITEOP} handling to correct place Date: Sat, 25 Nov 2017 01:24:52 +0900 Message-Id: <1511540697-27387-18-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> References: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver was largely extended by Renesas, but actually used by several SoC vendors. The current code does not work for UniPhier SoCs at least. The DMA mode for UniPhier SoCs failed with the following error message: PIO IRQ in DMA mode! For UniPhier SoCs, the TMIO_MASK_{READOP,WRITEOP} are asserted in the DMA mode as well. In fact, the code is very strange. The TMIO_MASK_{READOP,WRITEOP} IRQs are set as follows: /* 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 whether DMA is used or not. tmio_mmc_cmd_irq() enables TMIO_MASK_{READOP,WRITEOP}, but never disables them. This does not take care of a case where ->force_pio is set, but unset later. After all, the correct place to handle those flags is just before starting the data transfer. Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mmc/host/tmio_mmc_core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 7d169ed..345e379 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -621,15 +621,19 @@ 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); @@ -1285,12 +1289,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)