Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1617888imm; Mon, 3 Sep 2018 05:17:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYn25VxWe1P3MkA3e6tbIciu5pBvKbwNZGXV3k9I+DchABZXAVLPHKr0p0PvWQJEKoq3Pj8 X-Received: by 2002:a62:4255:: with SMTP id p82-v6mr29158717pfa.238.1535977025304; Mon, 03 Sep 2018 05:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535977025; cv=none; d=google.com; s=arc-20160816; b=kdgfZGJxqfm/byM+C6HAeTfl70TzL8m2Z+vcLQmoE0cgO9o47UwzF6bJ434DRP7zhO lQ43jScOH5HQHbeG8sFWNS/Km+wpyhnbmkU09JXEiPTriovvbO43C6X3jDZQ+GJv0efZ pmr6Llja+wgC/RW56n9MuymPVgydfxBnoXfYQjY/Wy+lPks+SH/WHQwWqEe7lDZ16TWb ejVxH18xWThXUlVbG5i3qeRwmb167/6z7h768HgECMEWVXPLdX5ANNnabAiDWbbUbLzo 7JPKpedA5slxn+dFiaWqFu0RFSmTQyflH2mc35qAWKW32j1O6WOOMIXp6EDmUFXJOqbR dAzw== 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=aGWAvTSiVj6L6vAHu2k+auA/ADBzAGALoYfzaPu0Cpc=; b=v43JvDGZEcPcwo07zfJKR8mretQqZgg2NN1/jYXqlfogRHa73hib19J29fpHXPqUyL Ls4FgiJsfgzbs1UZRmkm+FMw9egYj7Oyo0KxAHY+lo4wY5M/2k3et1UleyotLTRFt4Wf 7YYGOR+MJWbiOLoQpEsYa44kYpPtBzTiGRMiQ6sNPHMbUwzmdFgybDhHPhCL0qe1pfes jrUyLKFdDl6eCQXVgWy3motSf3Psp9wLblCOlV3rH+U5LUFqE9XPThqMzisQfEIviI+4 pNCIR5SvzyYrTixe72xdag99XBAm7ONS3IUGm1ghIAEZs05tVRQKli3tf0Pg6+q1QRvc Zddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FQvG6hVm; 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 k190-v6si17441188pgd.80.2018.09.03.05.16.50; Mon, 03 Sep 2018 05:17:05 -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=FQvG6hVm; 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 S1727878AbeICQfU (ORCPT + 99 others); Mon, 3 Sep 2018 12:35:20 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:46927 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbeICQfU (ORCPT ); Mon, 3 Sep 2018 12:35:20 -0400 Received: by mail-io0-f195.google.com with SMTP id y12-v6so230866ioj.13 for ; Mon, 03 Sep 2018 05:15:27 -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=aGWAvTSiVj6L6vAHu2k+auA/ADBzAGALoYfzaPu0Cpc=; b=FQvG6hVmQ5HNbR0S67KqaxtQDIIyIITagGm1dFCTxcPphMmE8OmSzIov3li0mkUZ+T KalMfyDlCyQK3Dsdz+LVAm7jy7wo6GbBtnyqLDFQkvaEDdZ7UYdxSR0pNrPQ8vk1ImvF 08UJkFIEwQZ4vjbHnC8QEp0Ef/Db7Dmqho+t8= 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=aGWAvTSiVj6L6vAHu2k+auA/ADBzAGALoYfzaPu0Cpc=; b=rtfcrWDjTLWzGNGLgX79PyS05CPsDv6+tfSZtgnxvGgMuvq13ah1xNwb8pa9MqYJvk 6BvtP7Ood6Z0TD4+ICIdleb2iNfRvf2t0jutKhE4wko2opP5l+5CRPQXYnNQ4TTOUSr5 E8W1KNlh5zwLJXsdYEc2d8YUtu6gnUD1nRkyCHmADe3PtnxcUAj8Hwu2TyjEG4h+SOjq 4jXYSooa7Rzf4qz958jR+eCGJAhJdUuzBcviWlk1IPs6aKILJbOExinr3kYUsYWjhBWI HO347RaVZHNDY5ZcjtCVcVWRMtYiSTogP3WtRva2NVF3gHPm93rQy3xyYxRYovOWgeX/ RzCg== X-Gm-Message-State: APzg51BIpTbYGwvWv5K5SoyjBtwimfqeDK3daxpp6TjYqLJFpb+h5ttt LYO/YU5v4COAHkFo/VnfIF3uH9JKbWk6npJmxXeRhA== X-Received: by 2002:a6b:1416:: with SMTP id 22-v6mr18844162iou.218.1535976926738; Mon, 03 Sep 2018 05:15:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:1bd8:0:0:0:0:0 with HTTP; Mon, 3 Sep 2018 05:15:26 -0700 (PDT) In-Reply-To: <1533116221-380-5-git-send-email-ludovic.Barre@st.com> References: <1533116221-380-1-git-send-email-ludovic.Barre@st.com> <1533116221-380-5-git-send-email-ludovic.Barre@st.com> From: Ulf Hansson Date: Mon, 3 Sep 2018 14:15:26 +0200 Message-ID: Subject: Re: [PATCH 04/14] mmc: mmci: introduce dma_priv pointer to mmci_host To: Ludovic Barre Cc: Rob Herring , Maxime Coquelin , Alexandre Torgue , Gerald Baeza , Linux ARM , Linux Kernel Mailing List , DTML , "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 1 August 2018 at 11:36, Ludovic Barre wrote: > From: Ludovic Barre > > This patch introduces dma_priv pointer to define specific > needs for each dma engine. This patch is needed to prepare > sdmmc variant with internal dma which not use dmaengine API. Overall this looks good, however a couple a few things below, mostly nitpicks. > > Signed-off-by: Ludovic Barre > --- > drivers/mmc/host/mmci.c | 165 +++++++++++++++++++++++++-------------- > drivers/mmc/host/mmci.h | 20 +---- > drivers/mmc/host/mmci_qcom_dml.c | 6 +- > 3 files changed, 112 insertions(+), 79 deletions(-) > > diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c > index 8144a87..bdc48c3 100644 > --- a/drivers/mmc/host/mmci.c > +++ b/drivers/mmc/host/mmci.c > @@ -415,31 +415,57 @@ static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data) > * no custom DMA interfaces are supported. > */ > #ifdef CONFIG_DMA_ENGINE > -static void mmci_dma_setup(struct mmci_host *host) > +struct dmaengine_next { I would rather rename this struct to something along the lines of "mmci_dma_next", that should follow how most of the data structures are named in mmci. > + struct dma_async_tx_descriptor *dma_desc; > + struct dma_chan *dma_chan; For these two, I think you should remove the "dma_" prefix from their names. At least to me, it's of obvious they are about dma if they are part of a struct used (and named) used solely for that purpose. > + s32 cookie; > +}; > + > +struct dmaengine_priv { > + struct dma_chan *dma_current; > + struct dma_chan *dma_rx_channel; > + struct dma_chan *dma_tx_channel; > + struct dma_async_tx_descriptor *dma_desc_current; > + struct dmaengine_next next_data; > + bool dma_in_progress; For similar reasons as above, I suggest to rename the struct to "mmci_dma_priv" and to drop the "dma_" prefix from the variable names. > +}; > + > +#define __dmae_inprogress(dmae) ((dmae)->dma_in_progress) How about naming this to mmci_dma_inprogress() instead? BTW, in general it looks like you are a bit fond of using "__" as function name prefix for internally called functions. Please try to avoid that, but rather try to pick names that explains what the functions do. > + > +static int mmci_dma_setup(struct mmci_host *host) > { > const char *rxname, *txname; > + struct dmaengine_priv *dmae; > > - 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"); > + dmae = devm_kzalloc(mmc_dev(host->mmc), sizeof(*dmae), GFP_KERNEL); > + if (!dmae) > + return -ENOMEM; > + > + host->dma_priv = dmae; > + > + dmae->dma_rx_channel = dma_request_slave_channel(mmc_dev(host->mmc), > + "rx"); > + dmae->dma_tx_channel = dma_request_slave_channel(mmc_dev(host->mmc), > + "tx"); > > /* initialize pre request cookie */ > - host->next_data.cookie = 1; > + dmae->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 (dmae->dma_rx_channel && !dmae->dma_tx_channel) > + dmae->dma_tx_channel = dmae->dma_rx_channel; > > - if (host->dma_rx_channel) > - rxname = dma_chan_name(host->dma_rx_channel); > + if (dmae->dma_rx_channel) > + rxname = dma_chan_name(dmae->dma_rx_channel); > else > rxname = "none"; > > - if (host->dma_tx_channel) > - txname = dma_chan_name(host->dma_tx_channel); > + if (dmae->dma_tx_channel) > + txname = dma_chan_name(dmae->dma_tx_channel); > else > txname = "none"; > > @@ -450,15 +476,15 @@ static void mmci_dma_setup(struct mmci_host *host) > * 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; > + if (dmae->dma_tx_channel) { > + struct device *dev = dmae->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; > + if (dmae->dma_rx_channel) { > + struct device *dev = dmae->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) > @@ -466,7 +492,9 @@ static void mmci_dma_setup(struct mmci_host *host) > } > > if (host->ops && host->ops->dma_setup) > - host->ops->dma_setup(host); > + return host->ops->dma_setup(host); I agree that converting the ->dma_setup() callback to return an int makes sense. However, please make that a separate change and while doing that, don't forget to implement the error path, as that is missing here. > + > + return 0; > } [...] Kind regards Uffe