Received: by 10.213.65.68 with SMTP id h4csp1594192imn; Thu, 29 Mar 2018 07:33:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4918nidzBWR/itEhFXcPMKSZYcD1rUk0QSAUSkv+tamlCIk3DlTCgLjtbrdUGexaSlb+DSl X-Received: by 10.99.112.84 with SMTP id a20mr1380092pgn.253.1522334012748; Thu, 29 Mar 2018 07:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522334012; cv=none; d=google.com; s=arc-20160816; b=HJSg9H3ZUAKezu6fA41xG8whSc3nYRY9OvZmwY9LcHi9gwJfsm4GRLSbXXhrW2V7L5 2oAFnWp5EPzTfalxXLgcSDaan9o+clPrBA81O816Kn6uqh0RJeNHESZBYVzVRqM4JhDu 6E2QmBUXRQhFcx82lecLSdAYUAMLUDbZa8kdJgA04mRZpRTVNsloBJdREwkmNzDoWZ+5 GMqzJi0heeHbaJueni4LaMvmXs5p5nj4GIMsd9Ua3ZWQMPmroLgzexV74kWwlOqWlZWU zZWq0fRJRp2GJhQFYX4VZeqMIr5VD6OTePSfApW7jqeFIqFxt17N69CMNJp/psk4OwYr I+lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=ej2Z6z+vgzXB1yp2murIIE3z7ZFB2Rd18OQ5Mc0bEQ4=; b=eF1iVAWgMeH81R8Lqs07S2SxiPM4I8SHBBnPm7kJkfYOMRD/1phGsPDsTuXdmIdRmm DUAFadMoxRujFPbgDdUMAfrGyTRjql1BQJPy6Xt8oqQYn6p/bUd/8igniEJrUQYQGg59 t0h/p7HNMKpXb5URHWf8OITGtwTtzfcbW4sM5u/yUZCBE+ZiIKZu7gwklvoQpPU9rOzS xGe9lGEFmNpmIBZSnwtQH05Y5eatvIaVGm8TKqHcGTRSq1APQaMNkXFK51Qc00XYFTKB VQESib2oskw2bxPouz4okiUUebpCCqY7jePXvuj0fcXs6PonDj+N5dnwC9sY0f380C5Y Y0fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BtKbHyH5; 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 g3-v6si5771425plp.662.2018.03.29.07.33.15; Thu, 29 Mar 2018 07:33:32 -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=BtKbHyH5; 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 S1752021AbeC2Obf (ORCPT + 99 others); Thu, 29 Mar 2018 10:31:35 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35258 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbeC2Obd (ORCPT ); Thu, 29 Mar 2018 10:31:33 -0400 Received: by mail-wm0-f68.google.com with SMTP id r82so12101964wme.0 for ; Thu, 29 Mar 2018 07:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ej2Z6z+vgzXB1yp2murIIE3z7ZFB2Rd18OQ5Mc0bEQ4=; b=BtKbHyH5GhdCVHUsmUuCpg6tL8q0fLXgQPcnS04Qb0e9TpOB+c7ttiel1hCycFycC/ hLCsUTVTwuWQxrjYsscGEG7D3Tv922o31V9tzkfyQJbP+L8cPdgX6g6rnr949YU5KL8O i5LoGpk90cMszqZVwU+oCR5zIB0gXNiab/cAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ej2Z6z+vgzXB1yp2murIIE3z7ZFB2Rd18OQ5Mc0bEQ4=; b=QndEsAy7EsGHl0w91kI5BV0CMKo4Rz/RMzW+jpk3yv1+oAO45RToeH3KIsAR1c+gDe OPVgfJcZ7ertoME+4PvcnT1WJLolROhfW9q5kLuegD/6oQymhMgv1mcErhxwpg5tcVW3 DZDUiA3M2Kq6NbI75IXABdPGdsoH9TQvucd/VdgaQeEArOEQX2VNOVRK4z3JAUFwf1AG p75upDvnpOSr9G76IiWz5OE4lLiFvpJ0iQ3tW3ltcgoiruOdl6fIFtoII3YaPkaT/QnP R42R773C9QFGYuo7PYZdwOuMvjOR77DD/5VMEDPmB1VK7heNl5PsOjmcegtbHeQpIwE2 2kqQ== X-Gm-Message-State: AElRT7GumlwmdMAnjRD483u4d5ndfwaHhTxe0Ovi7hOYYaIr0rpAO46a gjfYbM1+cNOt3CQuwJRyTv2MPg== X-Received: by 10.28.126.11 with SMTP id z11mr2163205wmc.128.1522333891950; Thu, 29 Mar 2018 07:31:31 -0700 (PDT) Received: from dell ([2.31.163.57]) by smtp.gmail.com with ESMTPSA id v74sm1274220wmv.48.2018.03.29.07.31.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Mar 2018 07:31:31 -0700 (PDT) Date: Thu, 29 Mar 2018 15:31:29 +0100 From: Lee Jones To: Fabrice Gasnier Cc: thierry.reding@gmail.com, alexandre.torgue@st.com, benjamin.gaignard@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, mcoquelin.stm32@gmail.com, benjamin.gaignard@st.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: Re: [RESEND PATCH v2 4/8] mfd: stm32-timers: add support for dmas Message-ID: <20180329143129.xdvw6gujghkwbjtm@dell> References: <1518602679-3064-1-git-send-email-fabrice.gasnier@st.com> <1518602679-3064-5-git-send-email-fabrice.gasnier@st.com> <20180328152251.xeh72dpeflzohn4k@dell> <106ff518-4973-5d4a-b5bf-dd58cbd8439a@st.com> <20180329125912.jgasmw75qvtlszgx@dell> <12d53b2e-eec4-a498-1e1f-c217161c5086@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <12d53b2e-eec4-a498-1e1f-c217161c5086@st.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Mar 2018, Fabrice Gasnier wrote: > On 03/29/2018 02:59 PM, Lee Jones wrote: > > On Wed, 28 Mar 2018, Fabrice Gasnier wrote: > > > >> On 03/28/2018 05:22 PM, Lee Jones wrote: > >>> On Wed, 14 Feb 2018, Fabrice Gasnier wrote: > >>> > >>>> STM32 Timers can support up to 7 DMA requests: > >>>> - 4 channels, update, compare and trigger. > >>>> Optionally request part, or all DMAs from stm32-timers MFD core. > >>>> > >>>> Also add routine to implement burst reads using DMA from timer registers. > >>>> This is exported. So, it can be used by child drivers, PWM capture > >>>> for instance (but not limited to). > >>>> > >>>> Signed-off-by: Fabrice Gasnier > >>>> Reviewed-by: Benjamin Gaignard > >>>> --- > >>>> Changes in v2: > >>>> - Abstract DMA handling from child driver: move it to MFD core > >>>> - Add comments on optional dma support > >>>> --- > >>>> drivers/mfd/stm32-timers.c | 215 ++++++++++++++++++++++++++++++++++++++- > >>>> include/linux/mfd/stm32-timers.h | 27 +++++ > >>>> 2 files changed, 238 insertions(+), 4 deletions(-) > >>>> > >>>> diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c > >>>> index a6675a4..2cdad2c 100644 > >>>> --- a/drivers/mfd/stm32-timers.c > >>>> +++ b/drivers/mfd/stm32-timers.c > > > > [...] > > > >>>> + struct dma_chan *dmas[STM32_TIMERS_MAX_DMAS]; > >>>> + struct stm32_timers ddata; > >>> > >>> This looks odd to me. Why can't you expand the current ddata > >>> structure? Wouldn't it be better to create a stm32_timers_dma > >>> structure to place all this information in (except *dev, that should > >>> live in the ddata struct), then place a reference in the existing > >>> stm32_timers struct? > >> > >> Maybe I miss-understand you here, from what we discussed in V1: > >> https://lkml.org/lkml/2018/1/23/574 > >>> ... "passing in the physical address of the parent MFD into > >>> a child device doesn't quite sit right with me" > >> I introduced this private struct in MFD parent, and completely hide it > >> from the child. > >> > >> So, do you suggest to add struct definition here ? But make it part of > >> struct stm32_timers *ddata? > >> > >> And only put declaration in include/linux/mfd/stm32-timers.h: > >> + struct stm32_timers_dma; > >> > >> struct stm32_timers { > >> struct clk *clk; > >> struct regmap *regmap; > >> u32 max_arr; > >> + struct stm32_timers_dma; > >> }; > > > > Yes, that's the basic idea. > > > >> I can probably spare the *dev then... use dev->parent in child driver. > > > > What would you use dev->parent for? > > Hi Lee, > > This is to follow your sugestion to use *dev instead of *ddata when > calling stm32_timers_dma_burst_read(), the idea is to use it on child side: > stm32_timers_dma_burst_read(dev->parent,...) from pwm driver. > Then there is no need to keep *dev inside ddata struct. I'm wondering if it would be neater to us the child's *dev, then do the ->parent deference in the parent MFD (with a comment to say what you're doing of course). > > [...] > > > >>>> +static int stm32_timers_remove(struct platform_device *pdev) > >>>> +{ > >>>> + struct stm32_timers *ddata = platform_get_drvdata(pdev); > >>>> + struct stm32_timers_priv *priv = to_stm32_timers_priv(ddata); > >>>> + > >>>> + of_platform_depopulate(&pdev->dev); > >>> > >>> Why can't you continue using devm_*? > >> > >> I can use devm_of_platform_depopulate() here if you prefer, and keep > >> devm_of_platform_populate() in probe. > > > > The point of devm_* is that you don't have to call depopulate. > > > > It happens automatically once this driver is unbound. > > Ok, so to clarify, keeping devm_ here may be a bit racy: > of_platform_depopulate will happen after dma has been released (there is > no devm_ variant to release dma). > Only way to prevent race condition here, is to enforce > of_platform_depopulate() is called before dma release (e.g. in reverse > order compared to probe). > > Do you wish I add a comment about it ? Best thing to do then is keep the non-devm variant and provide a comment as to why is it not possible to use devm_*. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog