From: Vinod Koul <vinod.koul@intel.com>
To: Peter Griffin <peter.griffin@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com,
maxime.coquelin@st.com, patrice.chotard@st.com,
lee.jones@linaro.org, dmaengine@vger.kernel.org,
devicetree@vger.kernel.org, arnd@arndb.de, broonie@kernel.org,
ludovic.barre@st.com
Subject: Re: [PATCH 04/18] dmaengine: st_fdma: Add xp70 firmware loading mechanism.
Date: Thu, 12 May 2016 11:10:20 +0530 [thread overview]
Message-ID: <20160512054020.GW2274@localhost> (raw)
In-Reply-To: <20160511075740.GB25540@griffinp-ThinkPad-X1-Carbon-2nd>
On Wed, May 11, 2016 at 08:57:40AM +0100, Peter Griffin wrote:
> > Above two seem to be generic code and should be moved to core, this way
> > other drivers using ELF firmware binaries can reuse...
>
> Do you mean add to dmaengine.c?
Nope this is not specfic to dmaengine. Perhaps drivers/base/..
> Certainly st_fdma_elf_sanity_check is fairly generic. st_fdma_elf_load_segments
> is less so, especially st_fdma_seg_to_mem().
>
> >
> > > @@ -738,6 +925,15 @@ static int st_fdma_slave_config(struct dma_chan *chan,
> > > struct dma_slave_config *slave_cfg)
> > > {
> > > struct st_fdma_chan *fchan = to_st_fdma_chan(chan);
> > > + int ret;
> > > +
> > > + if (!atomic_read(&fchan->fdev->fw_loaded)) {
> > > + ret = st_fdma_get_fw(fchan->fdev);
> >
> > this seems quite an odd place to load firmware, can you explain why
> >
>
> Good question :) I've been round the houses a bit on the firmware loading.
>
> I will try and document here what I've tried and the different advantages /
> disadvantages I've encountered.
Per Linus, driver should load firmware on first open. So either you should
do it while channel allocation or first descriptor allocation.
>
> In V3 patches, I used the device_config() hook. This can sleep (I think..it isn't
> documented here [1]). This hook happens very close to the dma starting and the
> rootfs / firmware is likely to be present. However I've sinced learnt that it
> doesn't get called in the memcpy case so is not a sufficient solution.
>
> In part putting it here was to try and get firmware loading out of probe() based
> on your feedback to v1 [2].
>
> In V1 patches: - I was using request_firmware_nowait() in probe() in conjunction with
> the CONFIG_FW_LOADER_USER_HELPER kernel option. I've since also learnt that this
> kernel option is deprecated and shouldn't be used.
I think nowait version is better. Why do you need
CONFIG_FW_LOADER_USER_HELPER?
> Your feedback in v1 was to move firmware loading to device open [2]. However
> what classes is device open in the dmaengine context is not obvious.
channel allocation or descriptor allocation
>
> ===
>
> device_alloc_chan_resources() hook
>
> This is probably the hook closest to a device open in dmaengine context.
> This hook can sleep so request_firmware can be called. However if all drivers
> are built-in firmware loading still fails as ALSA drivers calls
> devm_snd_dmaengine_pcm_register() which requests dma channels during *its* probe().
> This happens way before the rootfs is present and thus firmware loading still
> fails, and is still being done indirectly from a probe() anyway.
>
> I had some discussion with Mark and Arnd on IRC, about the possibility of ALSA
> not rquesting DMA channels during their probe(). Marks opinion I believe was
> this wasn't a good solution as ALSA would be presenting devices to userspace
> that potentially don't exist & can't work.
Hmmm, there are two parts, one is requesting the firmware and second is the
loading part.
Since descriptor allocation is atomic in nature, I think we should load the
firmware using nowait version and if you can atomically copy then do so at
first descriptor allocation. If not then you should copy in nowait handler
> ===
>
> *_prep_*() hooks
>
> + Always get called before a DMA is started
>
> - *prep* hooks can be called from atomic context so can't sleep [1] and can't use
> request_firmware().
> - I tried using request_firmwqare_nowait() with GFP_ATOMIC flag firmware. This
> half works but firmware loading doesn't complete before the DMA is started which
> means it often fails on the first DMA attempt.
>
> ===
>
> Suggested solution for v4 patches: -
>
> Both Arnd, Mark and Lee initial suggestion on irc was that if the device is useless
> without firmware, and the firmware isn't available then the driver should call
> request_firmware() in probe() and -EPROBE_DEFER if not available.
>
> This solution works well, in both the built-in and modules case. As the deffered
> fdma driver re-probes after the rootfs has been mounted when the firmware is
> available. The other ALSA depedencies then also re-probe and everything works
> nicely (and you can be assured that the devices will actually work at this point).
>
> This fdma driver and the ALSA ones will be enabled in multi_v7_defconfig as modules,
> so it is only likely to be used as a module. However using -EPROBE_DEFER
> mechanism, has the nice quality that if it is compiled as built-in you still end
> up with a working system (albeit with a longer boot time).
I think that makes sense, relying on deferred probing seems a better way to
manage
>
> Failing that the only other solution I can see is extending the dmaengine API to
> provide another hook which can sleep, and must be called before a DMA
> transation is started. Note that firmware isn't actually *required* until we
> start the dma transaction, but the device is useless without this firmware. In fact
> its "registers" are really just offsets into its DMEM so in theory even the
> registers are totally firmware dependent.
>
> Also I notice the only other dmaengine driver imx-sdma.c using firmware calls
> request_firmware_nowait from its probe().
>
> Are you happy with my proposed solutiion for v4? If not how would you like me to
> implement this?
>
> regards,
>
> Peter.
>
> [1] https://www.kernel.org/doc/Documentation/dmaengine/provider.txt
>
> [2] https://lkml.org/lkml/2015/10/13/278
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
~Vinod
next prev parent reply other threads:[~2016-05-12 5:40 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 11:04 [PATCH 00/18] Add support for FDMA DMA controller found on STi chipsets Peter Griffin
2016-04-21 11:04 ` [PATCH 01/18] dmaengine: st_fdma: Add STMicroelectronics FDMA DT binding documentation Peter Griffin
[not found] ` <1461236675-10176-2-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-21 11:25 ` Arnd Bergmann
2016-04-26 12:00 ` Peter Griffin
2016-04-21 11:04 ` [PATCH 02/18] dmaengine: st_fdma: Add STMicroelectronics FDMA driver header file Peter Griffin
[not found] ` <1461236675-10176-3-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-21 11:20 ` Arnd Bergmann
2016-04-21 11:04 ` [PATCH 03/18] dmaengine: st_fdma: Add STMicroelectronics FDMA engine driver support Peter Griffin
2016-04-21 11:24 ` Arnd Bergmann
2016-04-21 11:26 ` Appana Durga Kedareswara Rao
[not found] ` <C246CAC1457055469EF09E3A7AC4E11A4A57989B-4lKfpRxZ5enZMOc0yg5rMog+Gb3gawCHQz34XiSyOiE@public.gmane.org>
2016-04-21 14:58 ` Peter Griffin
2016-04-25 9:04 ` Lee Jones
2016-04-26 16:56 ` Vinod Koul
2016-04-27 12:59 ` Peter Griffin
2016-05-02 9:30 ` Vinod Koul
2016-05-09 17:30 ` Peter Griffin
2016-04-21 11:04 ` [PATCH 04/18] dmaengine: st_fdma: Add xp70 firmware loading mechanism Peter Griffin
[not found] ` <1461236675-10176-5-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-26 17:00 ` Vinod Koul
2016-05-11 7:57 ` Peter Griffin
2016-05-12 5:40 ` Vinod Koul [this message]
2016-04-21 11:04 ` [PATCH 05/18] dmaengine: st_fdma: Add fdma suspend and resume callbacks Peter Griffin
2016-04-21 11:04 ` [PATCH 06/18] ARM: STi: DT: STiH407: Add FDMA driver dt nodes Peter Griffin
[not found] ` <1461236675-10176-1-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-21 11:04 ` [PATCH 07/18] MAINTAINERS: Add FDMA driver files to STi section Peter Griffin
2016-04-21 11:04 ` [PATCH 08/18] ARM: multi_v7_defconfig: Enable STi FDMA driver Peter Griffin
2016-04-21 11:25 ` Arnd Bergmann
2016-04-26 10:42 ` Peter Griffin
2016-04-21 11:04 ` [PATCH 09/18] ASoC: sti: Update DT example to match the driver code Peter Griffin
2016-04-21 11:27 ` Arnd Bergmann
2016-04-26 10:11 ` Peter Griffin
2016-04-26 10:58 ` Arnd Bergmann
2016-04-26 11:15 ` Peter Griffin
2016-04-26 11:44 ` Arnd Bergmann
2016-05-04 7:52 ` Arnaud Pouliquen
2016-05-04 9:05 ` Arnd Bergmann
[not found] ` <1461236675-10176-10-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-21 15:57 ` Mark Brown
[not found] ` <20160421155753.GS3217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-04-26 11:02 ` Peter Griffin
2016-05-03 15:46 ` Arnaud Pouliquen
2016-04-21 11:04 ` [PATCH 10/18] ASoC: sti: Update example to include assigned-clocks and mclk-fs Peter Griffin
[not found] ` <1461236675-10176-11-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-21 15:49 ` Mark Brown
[not found] ` <20160421154933.GR3217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-04-26 11:52 ` Peter Griffin
2016-04-26 14:23 ` Mark Brown
2016-04-26 14:51 ` Peter Griffin
2016-04-26 15:03 ` Mark Brown
[not found] ` <20160426150319.GY3217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-04-26 16:14 ` Peter Griffin
2016-04-26 16:41 ` Mark Brown
[not found] ` <20160426164104.GC3217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-04-26 17:49 ` Peter Griffin
2016-04-21 11:04 ` [PATCH 11/18] ARM: multi_v7_defconfig: Enable STi and simple-card drivers Peter Griffin
2016-04-21 11:04 ` [PATCH 12/18] ARM: DT: STiH407: Add i2s_out pinctrl configuration Peter Griffin
2016-04-21 11:04 ` [PATCH 13/18] ARM: DT: STiH407: Add i2s_in " Peter Griffin
2016-04-21 11:04 ` [PATCH 14/18] ARM: DT: STiH407: Add spdif_out pinctrl config Peter Griffin
2016-04-21 11:04 ` [PATCH 15/18] ARM: STi: DT: STiH407: Add sti-sasg-codec dt node Peter Griffin
2016-04-21 11:04 ` [PATCH 16/18] ARM: STi: DT: STiH407: Add uniperif player dt nodes Peter Griffin
2016-04-21 11:04 ` [PATCH 17/18] ARM: STi: DT: STiH407: Add uniperif reader " Peter Griffin
2016-04-21 11:04 ` [PATCH 18/18] ARM: DT: STi: stihxxx-b2120: Add DT nodes for STi audio card Peter Griffin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160512054020.GW2274@localhost \
--to=vinod.koul@intel.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.barre@st.com \
--cc=maxime.coquelin@st.com \
--cc=patrice.chotard@st.com \
--cc=peter.griffin@linaro.org \
--cc=srinivas.kandagatla@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).