Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3646117imm; Wed, 5 Sep 2018 03:45:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZIs+Gcba9gxZUVlb6/fqct3LHWulP3EuVFRuYEM5J0dGMI4aO+/S65O5IKlQ7OFe7jbHkH X-Received: by 2002:a63:c608:: with SMTP id w8-v6mr36129510pgg.16.1536144342606; Wed, 05 Sep 2018 03:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536144342; cv=none; d=google.com; s=arc-20160816; b=Mc2U9eSEVafNuJhMzVhe2vT6WV5QHguS6MyYi8JG72WAs6VYX6WCz05hOpy9DX58vK aEFPb3NAnwKeSTnV6eUWKSXa9JlSJ2ljMfUzLTmuq3aCzLXh7p6OHHwsZTl8ycXh6XJw Al1fxw0QyLMz5CfRxK9sdd14yw8UMD318sWAU0hSPRiCXoLZ9tlHQssGymv9g8+P5aEj 5KLS172SiqXSVZGrjDtJnyUAfB5rTOdJ/pTf/vW949gk3kHLJ+fesKyQsecKoK4lHcWA XHbctA+kmj30agHqlygDKF0L9GyYFvW8kNyqe6BVCprLXX26nUJomdkskJX/lNhGzjMI ja7A== 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; bh=MOqtys68aikvUfdhExivNVmFR1GMtTIRn9oHCu3f1mE=; b=uoyWDJdvvekE7lZ29nfi4YiVm/2/hcd2MeFPvlqJKQwJJPIOrgIT+qBVhPnXnaKWs7 lEgaBRoiFj/LXELywOzQAdJ7+ux1CoAIuRQano33uD6aJ0ASjlQNYW96L2/9Y7rdmn1p LaJ/K+3RNRcNBCKjo59Pk/5ec5SGUdayiToNwE1JWnwSsFS1+jdLQJ4JQ2sfjxxQGllm 07b3fajC6smpbITdsxBz6wJVWo3f7T8wkWJUknJJRBXkC1ZGKOyVXppXj+m2Q9x/GGx5 2AzWFfS+IYXQMFeKX1Nh+Z1MZpmjEpL2aLl74h63PHagPWIkCn1uSLGtd9WZ/rNgoE2/ Yyng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NFzEpAaz; 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 e14-v6si1561535pfi.184.2018.09.05.03.45.27; Wed, 05 Sep 2018 03:45:42 -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=NFzEpAaz; 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 S1727714AbeIEPNc (ORCPT + 99 others); Wed, 5 Sep 2018 11:13:32 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:40220 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727201AbeIEPNc (ORCPT ); Wed, 5 Sep 2018 11:13:32 -0400 Received: by mail-io0-f195.google.com with SMTP id l14-v6so5535280iob.7 for ; Wed, 05 Sep 2018 03:43:52 -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=MOqtys68aikvUfdhExivNVmFR1GMtTIRn9oHCu3f1mE=; b=NFzEpAazIP9Mu9X+OW7gfPdpjEVeGEjFhnWwuGOlcIpbwsqpVMHa76Kl2urU8SPIw7 GKaKwVjDeFYITTlb4E2CSsQMwIPQSO8+qgCeB2cWak6FDFDs290Ta9SR81xxScJ04QrO JCFknmrdnsTeyVrrr45oqsBZ0lsBS6Agj6eHU= 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=MOqtys68aikvUfdhExivNVmFR1GMtTIRn9oHCu3f1mE=; b=Naxcc307uYqOQx4m8XJMhDRjMbhjKdw3IYtSNUjzkxU7KxQHqlPXI3khVvyo/uJ8JV 7SxpLgqXdMkKa0jbWP62zDd9kwyQEfLdRJaqObByoyhg5BkWIutZkcL8LeGj6LCyltgp gXA6Xe3FyiwBlSzK8vN+Kov7zV7YnCOBMr95NwrR/e6zvJAOh694Ul11l90BHpxj712j CSC1HjXGJ7P8iHihT4sRXjatB8fy60Guf+/nVy2KRaK4M8rZA5ucPiY0On9adqiQloFG ldESgzzhfWHQElF5WFfHgPMpei3dR+i36IkLuM7neIh43UWh9sYXyd0RcMeFOs3Urtsm 7UuA== X-Gm-Message-State: APzg51CkoFeUe6ctVfNW5PGO2eIoha3gdnAOKGqkURRwgWknTMCxkZ/d FbyzQD+hLK0xSnIUUM55p0Y1aHuqW3tbYvKD2QkVaw== X-Received: by 2002:a6b:e317:: with SMTP id u23-v6mr7139243ioc.131.1536144232294; Wed, 05 Sep 2018 03:43:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:4f9a:0:0:0:0:0 with HTTP; Wed, 5 Sep 2018 03:43:51 -0700 (PDT) In-Reply-To: <5e9e5114-40d0-d178-4fdc-edfd5963c170@st.com> References: <1533116221-380-1-git-send-email-ludovic.Barre@st.com> <5e9e5114-40d0-d178-4fdc-edfd5963c170@st.com> From: Ulf Hansson Date: Wed, 5 Sep 2018 12:43:51 +0200 Message-ID: Subject: Re: [PATCH 00/14] mmc: mmci: prepare dma callbacks with mmci_host_ops 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 5 September 2018 at 11:13, Ludovic BARRE wrote: > > > On 09/04/2018 12:00 PM, Ulf Hansson wrote: >> >> On 1 August 2018 at 11:36, Ludovic Barre wrote: >>> >>> From: Ludovic Barre >>> >>> This patch series prepares and adds callbacks for dma transfert at >>> mmci_host_ops. This series is composed of 3 parts: >>> -Internalize specific needs of legacy dmaengine. >>> -Create and setup dma_priv pointer >>> -Create generic callbacks which share some features >>> (like cookie...) and call specific needs >> >> >> I have now reviewed part of this series and provided you with some >> comments, but will stop at this point. > > > thanks for your review > >> >> Overall, the comments are about renaming and picking better function >> names. Those comments should be easy to address in a new version. > > > yes, there is no problem for the naming, I will change following your > recommendations. > >> >> However, the other more important point is the number of variant >> callbacks you are adding. It's of course a balance to pick the right >> level, to get both flexibility but also to avoid open coding. In the >> end we don't want to get too many callbacks, but then it's better to >> share common mmci code for variants, through mmci.h. >> >> Finally, I would like to see a patch on top adding the support for the >> new ST variant, so I can see how the callbacks and changes really are >> being used. Can you please add that? >> > > yes, I prepare a patch with sdmmc variant to show how callbacks are used. > > About comment on patch 07/14: >> So, having callbacks for dealing with dma_map|unmap() kind of >> operations, becomes rather fine-grained and not very flexible. >> Instead, what do you think of allowing the variant init function to >> dynamically assign the ->pre_req() and the ->post_req() callbacks in >> the struct mmc_host_ops. Common mmci functions to manage these >> operations can instead be shared via mmci.h and called by the >> variants. > > I think we have the same goal or idea, regroup the common needs to avoid > too much specific drift. > > I will try to describe the functions which are commons and the link to > specific mmci_host_ops callbacks. > > (I use function names of this series, but it's just for this example) > > commons function used by mmci core: > -mmci_pre_request: > check data and cookie, call common mmci_validate_data > and mmci_prepare_data. > > -mmci_post_request: > check data and cookie then call common mmci_unprepare_data > > -mmci_validate_data: > check the common constraint of variants, call specific > validate_data if defined. > > -mmci_prepare_data: > setup common next cookie, call specific prepare data if defined > > -mmci_unprepare_data: > clear the common cookie, call specific unprepare data if defined > > -mmci_get_next_data: > check cookie, call specific get_next_data if defined > > -mmci_dma_setup: > initialize common next_cookie, call specific dma_setup if defined > > -mmci_dma_release > just call dma_release if defined > > -mmci_dma_start > call common prepare data if not yet done (by next) > call specific dma_start > write common registers to start transfer and setup mmci mask > > -mmci_dma_finalize: > just call dma_finalize if defined > > -mmci_dma_error > just call dma_error if defined > > mmci_host_ops specific: > struct mmci_host_ops > validate_data: could be use to check specific constraint of variant. > sdmmc has constraints on base & size for each element > excepted the last element which has no constraint on > size. > prepare_data: specific needs to prepare current or next data request. > mmci: dma_map_sg on channel, use dmaengine api > "dmaengine_prep_slave_sg" to queue a transfer > sdmmc: dma_map_sg on sdmmc device and prepare the link > list of internal dma > > unprepare_data: specific needs to unprepare the data of request > mmci: dma_unmap_sg on channel, use dmaengine api to > terminate transfert. > sdmmc: just unmap on sdmmc device. > > get_next_data: manage specific needs to move on next data > mmci: get next dmaengine descriptor and channel > sdmmc: today, nothing > > dma_setup: setup specific need if you use a Direct Memory Access > mmci: use dmaengine api to request slave channel. > sdmmc: alloc memory for link list, and define specific > mmc->max_segs and mmc->max_seg_size. > > dma_release: release specific resource if you use a Direct Memory > access. > mmci: use dmaengine api to release channel > sdmmc: nothing > > dma_start: set specific needs to start dma request > mmci: use dmaengine api to submit and pending a dma > transfert. > sdmmc: set specific sdmmc registers to start an internal > dma transfert > > dma_finalize: set specific needs to finalize a request > mmci: specific check on fifo status and > channel/descriptor management. > sdmmc: just clear a specific register of sdmmc > > dma_error: specific error management. > mmci: dmaengine api to terminate a transfer > sdmmc: nothing Ludo, thanks for the detailed explanation and summary! Following this, it looks like it makes sense to keep the callbacks as on the level you have suggested. At least, I don't want to delay you from getting this upstream, by just giving some vague ideas of how to change the number of callbacks. So, I am fine if you stick to the existing approach! Then, if we later on realizes that it makes sense to share more common code through mmci.h, to get rid of some callback, we can always do that on top. [...] Kind regards Uffe