Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp755632imm; Thu, 5 Jul 2018 08:21:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWOgfPfdCPTgX0EDRqnK6GMMNmeMj5EJqHqIgmgGEO9ZZFwdO87gujyWqEeMOWKNEw3thd X-Received: by 2002:a63:ad46:: with SMTP id y6-v6mr6070702pgo.144.1530804078712; Thu, 05 Jul 2018 08:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530804078; cv=none; d=google.com; s=arc-20160816; b=SCxjWKgndgOY948Ki8MU+yBANV+w9S7ItK5IZSseMihzzUzdpkc7f69xmkt3lCJuqT s2CNgEoErRHusYBQb07vv1abL8XWBBjqmdgdXJ9KrceTdYB5HtjD2L7RUrl+1BIbAK6x 9oOMxi3G+FGg4rGRID3sbqlGKT1/GmmyKVB73a4VbkkbLipnnmWQpLwYQuGbFd8sr5XG VlLBjEmHdIuhGhJtv4Yt2Up1jEmCPTFzEmAMXNYZ5rZLxwUaqQ5rz55mzh1aeTFy9NyD wbmpQahy/JbjZY/17r5ehbcSlgvBkWj7bXWDVyl7Su8S7apiaGOsGx3W9IAFwyoNsuF5 2oKQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=I3R+5e5unJC1fsWWBxGs2NDQTZikP3mj0LzyrRQJMBw=; b=lLKVFXIbL8DGOYVNrVVKCPHOIVnQQ4FDv4YulZgySEVXXpwce3PbrcDfGFOu+cgp4Y CC2euo+cGXByxhI3vuDfNGewfsWLR74Jt46UkEnJqQt7pWar2gzrRgQ0tNx0fFQ11VL7 m3ZTvkHEfaHBNP4L6Ae0aTniVTYaf4X26HG18HwVM36HAEel/3jBN6Nt2nYfCaWVyD8Z NjOtek5R4fvmUIqoQOrY6+sw1B4KDgGMhGEQyEJ6mgmBkNPwfnZlobm6zhoo3xA6jjh+ TRWEfjIyhRsMTm8zGS2aNDC3wY1JDpE/m9Ix0icbj2noxScSwKBm5o2hHuKYY7tq7n9/ w7ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RwJWm1dj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si5761243pga.413.2018.07.05.08.21.02; Thu, 05 Jul 2018 08:21:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=RwJWm1dj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754340AbeGEPRu (ORCPT + 99 others); Thu, 5 Jul 2018 11:17:50 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:36444 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754037AbeGEPRr (ORCPT ); Thu, 5 Jul 2018 11:17:47 -0400 Received: by mail-io0-f195.google.com with SMTP id k3-v6so8075470iog.3 for ; Thu, 05 Jul 2018 08:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=I3R+5e5unJC1fsWWBxGs2NDQTZikP3mj0LzyrRQJMBw=; b=RwJWm1djCx+h7rhC/K4OBmAaArrJ098wOPeYe3pwcUCq6T+tv9yvo+JZ8iqBEiv+AW gSYP9uRpvpx4gjTxyL+5uAz6GrgPNUKc8X1RMKiaZebV+2Sop7e3w9oU17PSEOvVqU4y zL84rFI8pE6AkJcdZx4d51nminUPoFIn8gTtI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=I3R+5e5unJC1fsWWBxGs2NDQTZikP3mj0LzyrRQJMBw=; b=iSZ5ciI0PsDh0/Pi1Az5LkyctIt3+2yW5NU+5ApJHf9+u11y05j5uqI7l8clKfc6Up ixE7O4TYDfrZf+yD2wAo4hPJshCZtcQ5hf/nYHY7eE4bIl58Rm5NwduAMfiu/MGFUdnT LhZqBMaUiJF94edMoTCMkxsRkeWWfkzHkaZcbywyXimvvmKNsXcW3YC73LjeHEIkXMPe 4a4EqINoaMv5iTZLxOKoMawyVSgPZOIjP1c9q8ygk95cemlO48ZWiui4YMiPsLu2kdUx AU1OwdQ2jfR4z7rmgx9G1KYkAjLNfbBeEZmIw1LH7RVJEA8cD17Wj+t720ROQpJY0n3F Nb9A== X-Gm-Message-State: AOUpUlGHqFSddyM0mH8LGXRJlZ9dmXpeBpgLT4dByA0ARijFCvXVoPu8 CY2bLrtrHwyh45WMBiPFDE0JbpcQk5g3nf/3y7ossA== X-Received: by 2002:a6b:144c:: with SMTP id 73-v6mr5241401iou.218.1530803867286; Thu, 05 Jul 2018 08:17:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:818f:0:0:0:0:0 with HTTP; Thu, 5 Jul 2018 08:17:46 -0700 (PDT) In-Reply-To: <1528809280-31116-2-git-send-email-ludovic.Barre@st.com> References: <1528809280-31116-1-git-send-email-ludovic.Barre@st.com> <1528809280-31116-2-git-send-email-ludovic.Barre@st.com> From: Ulf Hansson Date: Thu, 5 Jul 2018 17:17:46 +0200 Message-ID: Subject: Re: [PATCH 01/19] mmc: mmci: regroup and define dma operations To: Ludovic Barre Cc: Rob Herring , Maxime Coquelin , Alexandre Torgue , Gerald Baeza , Linux ARM , Linux Kernel Mailing List , devicetree@vger.kernel.org, "linux-mmc@vger.kernel.org" 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 On 12 June 2018 at 15:14, Ludovic Barre wrote: > From: Ludovic Barre > > Prepare mmci driver to manage dma interface by new property. > This patch defines and regroups dma operations for mmci drivers. > mmci_dma_XX prototypes are added to call member of mmci_dma_ops > if not null. Based on legacy need, a mmci dma interface has been > defined with: > -mmci_dma_setup > -mmci_dma_release > -mmci_dma_pre_req > -mmci_dma_start > -mmci_dma_finalize > -mmci_dma_post_req > -mmci_dma_error > -mmci_dma_get_next_data As I suggested for one of the other patches, I would rather turn core mmci functions into library functions, which can be either invoked from variant callbacks or assigned directly to them. In other words, I would leave the functions that you move in this patch to stay in mmci.c. Although some needs to be re-factored and we also needs to make some of them available to be called from another file, hence the functions needs to be shared via mmci.h rather than being declared static. Let me take a concrete example on how I would move forward, hopefully that explains it a bit better. Please see below. [...] > -/* > - * All the DMA operation mode stuff goes inside this ifdef. > - * This assumes that you have a generic DMA device interface, > - * no custom DMA interfaces are supported. > - */ > -#ifdef CONFIG_DMA_ENGINE > -static void mmci_dma_setup(struct mmci_host *host) > -{ > - const char *rxname, *txname; > - struct variant_data *variant = host->variant; > - > - host->dma_rx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "rx"); > - host->dma_tx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "tx"); > - > - /* initialize pre request cookie */ > - host->next_data.cookie = 1; > - > - /* > - * If only an RX channel is specified, the driver will > - * attempt to use it bidirectionally, however if it is > - * is specified but cannot be located, DMA will be disabled. > - */ > - if (host->dma_rx_channel && !host->dma_tx_channel) > - host->dma_tx_channel = host->dma_rx_channel; > - > - if (host->dma_rx_channel) > - rxname = dma_chan_name(host->dma_rx_channel); > - else > - rxname = "none"; > - > - if (host->dma_tx_channel) > - txname = dma_chan_name(host->dma_tx_channel); > - else > - txname = "none"; > - > - dev_info(mmc_dev(host->mmc), "DMA channels RX %s, TX %s\n", > - rxname, txname); > - > - /* > - * Limit the maximum segment size in any SG entry according to > - * the parameters of the DMA engine device. > - */ > - if (host->dma_tx_channel) { > - struct device *dev = host->dma_tx_channel->device->dev; > - unsigned int max_seg_size = dma_get_max_seg_size(dev); > - > - if (max_seg_size < host->mmc->max_seg_size) > - host->mmc->max_seg_size = max_seg_size; > - } > - if (host->dma_rx_channel) { > - struct device *dev = host->dma_rx_channel->device->dev; > - unsigned int max_seg_size = dma_get_max_seg_size(dev); > - > - if (max_seg_size < host->mmc->max_seg_size) > - host->mmc->max_seg_size = max_seg_size; > - } Everything above shall be left as generic library function, mmci_dma_setup() and I would share it via mmci.h and thus change it from being static. > - > - if (variant->qcom_dml && host->dma_rx_channel && host->dma_tx_channel) > - if (dml_hw_init(host, host->mmc->parent->of_node)) > - variant->qcom_dml = false; This piece of code, should be made specific to the qcom variant and managed though a "mmci_host_ops" callback. The corresponding code in that callback would then start by invoking mmci_dma_setup(), before it continues with the qcom specific operations. For legacy variants, the corresponding callback would be set directly to mmci_dma_setup() and called through the callback from mmci.c when needed. There is no need to have a separate file for DMA for the legacy variants, I think. [...] Kind regards Uffe