From patchwork Fri Jul 27 01:14:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 143004 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp226730ljj; Thu, 26 Jul 2018 18:15:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdyJWn7jECDM2VSB0mj0/WgpqaueK7AMD1jlahohabUK55Xu80s7opoWqHzUBO9gp3MSsz0 X-Received: by 2002:a63:db05:: with SMTP id e5-v6mr3963672pgg.152.1532654105452; Thu, 26 Jul 2018 18:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532654105; cv=none; d=google.com; s=arc-20160816; b=P5y4ReaclmwJX5ITYCNhM80yhcXfNmXUnxT5mkEGJh/EvN/ESI/vTRPiO8BIUwZDj3 KNhNSY3SVDNynONyFsuL4g8qsh2HUfoGQa6xTTcdhHNArk9FhDTXMkYiAkV6F3XlqGGr FYp8uTU4DOnXHmFefbuuWrebYXzRwARI+KPOD1piFLkgXdiMBHRJI+E0AB12/SKuyswm 0TWU2yR3O3ki2vCzKZRS77wCghigF9Ae73iZY9Hc7C+AkYGBI1EsD82+YyHhO8GiDZ0b oLPbEqevbsCWKDbRsTtiyrMv9LqpLbwaVjD+KSDAK0tnruvCB3j62C+faDqY2kIBVchs LmnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=efRrGZdfogICESe8pRwKXMA+p6uXw5e0H9vrPP7sRe8=; b=Gvsda8AMBouZMcqVZB+MrY0ePWVWyODU2Iv4kzGyALcYyWygFNN14NIEuAC12BYxop Qy8ZBR4pTyFn6BC3DXQBKSmFqV+wB1MiB8sNIXi4Li3Qh0U+8kPQRhEmqOGbxsKLVCcK xcrzMmOho/uT5DQzOCNyKXmBOQjEYMlyTACwQx3MnUwZaPiWqAUPB2wbQwuGQvFwC8C8 GVS25oyqIfuQTn4iJjbP9rmGfBz/2U0I0ofoSqzTjiIf1aXiOKoq9HyGy3J30ZLvWN3t 9iHWES2mTF/C/Wx3eUcB+A/ysp6Zak3V5SPwtYilB24isJv8bY6kt1Q6yBl8uOLjnvTP tEbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=cU8RkSE6; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-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 c3-v6si2344098pld.457.2018.07.26.18.15.05; Thu, 26 Jul 2018 18:15:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=cU8RkSE6; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731936AbeG0CeZ (ORCPT + 5 others); Thu, 26 Jul 2018 22:34:25 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:54124 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731924AbeG0CeZ (ORCPT ); Thu, 26 Jul 2018 22:34:25 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id w6R1EE5L016228; Fri, 27 Jul 2018 10:14:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w6R1EE5L016228 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1532654055; bh=2H+nobouSE4XXEuL2Mtb5sevx/LzGfBfNRcc/TcAn2Y=; h=From:To:Cc:Subject:Date:From; b=cU8RkSE6MZYeExmV0B9R+T7jUIVG98xaHh+6Cm6COK6l1eWkSrSdQkw6ifTazEWlg N6j8ey7SRhgjGLXpBpVA1KpJsUlb8vMx/GVC0OeQCw3TiEi6qzHWOzpbtU3yW9c6dg 29oqN/dAc9ft5hJ1mvJpbYg3PZ0CPbu0HPlInO8PaB5UazNFcrZrPqUkUsiv2/eNHm 4ritTZR8tWqmWLvIuwmLgfW8MF8Iv87Ci7ihSWPc2TJ85fBn3Ndr+bjZBquL5wGhXv qJhNIGfOFjKGMG5ULYUmTHDUSG7p38HHYbI7Utpx9NMEsBoy+DlTddB1YbSkgl0Qso eFubLKjnocecg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Wolfram Sang , linux-mmc@vger.kernel.org, Ulf Hansson Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH] mmc: tmio: allow DMA request hook to return error status Date: Fri, 27 Jul 2018 10:14:06 +0900 Message-Id: <1532654046-11901-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org dma_request_chan() may return ERR_PTR(-EPROBE_DEFER), but tmio_mmc_request_dma() cannot propagate it since it is a void function. Change the return type to int so that the driver can retry probing later in case the DMA-engine driver is probed after the TMIO MMC driver. I moved the call for tmio_mmc_request_dma() up because it may fail now. I also removed unneeded clearing of host->chan_{tx,rx} because (struct tmio_mmc_host) is allocated by kzalloc(). Signed-off-by: Masahiro Yamada --- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 4 +++- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 14 ++++++++------ drivers/mmc/host/tmio_mmc.h | 3 +-- drivers/mmc/host/tmio_mmc_core.c | 21 ++++++++++----------- 4 files changed, 22 insertions(+), 20 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index d032bd6..f3475a5 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -230,7 +230,7 @@ static void renesas_sdhi_internal_dmac_complete_tasklet_fn(unsigned long arg) spin_unlock_irq(&host->lock); } -static void +static int renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) { @@ -245,6 +245,8 @@ renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host, tasklet_init(&host->dma_issue, renesas_sdhi_internal_dmac_issue_tasklet_fn, (unsigned long)host); + + return 0; } static void diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index 4bb46c4..3f806f5 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -359,15 +359,15 @@ static void renesas_sdhi_sys_dmac_issue_tasklet_fn(unsigned long priv) dma_async_issue_pending(chan); } -static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, - struct tmio_mmc_data *pdata) +static int renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, + struct tmio_mmc_data *pdata) { struct renesas_sdhi *priv = host_to_priv(host); /* We can only either use DMA for both Tx and Rx or not use it at all */ if (!host->pdev->dev.of_node && (!pdata->chan_priv_tx || !pdata->chan_priv_rx)) - return; + return 0; if (!host->chan_tx && !host->chan_rx) { struct resource *res = platform_get_resource(host->pdev, @@ -377,7 +377,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, int ret; if (!res) - return; + return 0; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -389,7 +389,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, host->chan_tx); if (!host->chan_tx) - return; + return 0; cfg.direction = DMA_MEM_TO_DEV; cfg.dst_addr = res->start + @@ -433,7 +433,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, renesas_sdhi_sys_dmac_enable_dma(host, true); - return; + return 0; ebouncebuf: ecfgrx: @@ -443,6 +443,8 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, ecfgtx: dma_release_channel(host->chan_tx); host->chan_tx = NULL; + + return 0; } static void renesas_sdhi_sys_dmac_release_dma(struct tmio_mmc_host *host) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index e7d6513..d8383d4 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -115,8 +115,7 @@ struct tmio_mmc_host; struct tmio_mmc_dma_ops { void (*start)(struct tmio_mmc_host *host, struct mmc_data *data); void (*enable)(struct tmio_mmc_host *host, bool enable); - void (*request)(struct tmio_mmc_host *host, - struct tmio_mmc_data *pdata); + int (*request)(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata); void (*release)(struct tmio_mmc_host *host); void (*abort)(struct tmio_mmc_host *host); void (*dataend)(struct tmio_mmc_host *host); diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 3cb554c..09c2d0c 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -65,15 +65,13 @@ static inline void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable) host->dma_ops->enable(host, enable); } -static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host, - struct tmio_mmc_data *pdata) +static inline int tmio_mmc_request_dma(struct tmio_mmc_host *host, + struct tmio_mmc_data *pdata) { - if (host->dma_ops) { - host->dma_ops->request(host, pdata); - } else { - host->chan_tx = NULL; - host->chan_rx = NULL; - } + if (host->dma_ops) + return host->dma_ops->request(host, pdata); + + return 0; } static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host) @@ -1218,6 +1216,10 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) return ret; } + ret = tmio_mmc_request_dma(_host, pdata); + if (ret) + return ret; + mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2; mmc->max_segs = pdata->max_segs ? : 32; @@ -1286,9 +1288,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) INIT_DELAYED_WORK(&_host->delayed_reset_work, tmio_mmc_reset_work); INIT_WORK(&_host->done, tmio_mmc_done_work); - /* See if we also get DMA */ - tmio_mmc_request_dma(_host, pdata); - pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_use_autosuspend(&pdev->dev);