From: Mark Brown <broonie@kernel.org>
To: Kenneth Westfield <kwestfie@codeaurora.org>
Cc: ALSA Mailing List <alsa-devel@alsa-project.org>,
Device Tree Mailing List <devicetree@vger.kernel.org>,
MSM Mailing List <linux-arm-msm@vger.kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>, Takashi Iwai <tiwai@suse.de>,
Rob Herring <rob.herring@calxeda.com>,
Greg KH <gregkh@linuxfoundation.org>,
David Brown <davidb@codeaurora.org>,
Bryan Huntsman <bryanh@codeaurora.org>,
Banajit Goswami <bgoswami@codeaurora.org>,
Patrick Lai <plai@codeaurora.org>
Subject: Re: [PATCH 3/9] ASoC: ipq806x: add native LPAIF driver
Date: Tue, 25 Nov 2014 21:44:45 +0000 [thread overview]
Message-ID: <20141125214445.GT7712@sirena.org.uk> (raw)
In-Reply-To: <1416423169-21865-4-git-send-email-kwestfie@codeaurora.org>
[-- Attachment #1: Type: text/plain, Size: 3991 bytes --]
On Wed, Nov 19, 2014 at 10:52:43AM -0800, Kenneth Westfield wrote:
> +#define DRV_NAME "lpass-lpaif"
> +#define DRV_VERSION "1.0"
Don't add versions like this, the kernel is already more than adequately
versioned and nobody is ever going to bother to update it.
> +static int lpaif_pcm_int_enable(uint8_t dma_ch)
> +{
> + uint32_t intr_val;
> + uint32_t status_val;
> + unsigned long flags;
> +
> + if (dma_ch >= LPAIF_MAX_CHANNELS) {
> + pr_err("%s: invalid DMA channel given: %hhu\n",
> + __func__, dma_ch);
dev_err().
> +void lpaif_cfg_i2s_playback(uint8_t enable, uint32_t mode, uint32_t off)
> +{
The kernel types for fixed size unsigned integers are u8, u32 and so on.
> + if ((bit_width == 16) && (channels == 2)) {
> + cfg |= LPAIF_DMACTL_WPSCNT_MONO;
> + } else if (((bit_width == 16) && (channels == 4)) ||
switch statements please, it's both more legible and more extensible.
> +void lpaif_register_dma_irq_handler(int dma_ch,
> + irqreturn_t (*callback)(int intrsrc, void *private_data),
> + void *private_data)
> +{
> + lpaif_dai[dma_ch]->callback = callback;
> + lpaif_dai[dma_ch]->private_data = private_data;
> +}
> +
> +void lpaif_unregister_dma_irq_handler(int dma_ch)
> +{
> + lpaif_dai[dma_ch]->callback = NULL;
> + lpaif_dai[dma_ch]->private_data = NULL;
> +}
What is this doing? Linux already has a perfectly good interface for
requesting and releasing interrupts...
> +static int lpaif_dai_find_dma_channel(uint32_t intrsrc)
> +{
> + uint32_t dma_channel = 0;
> +
> + while (dma_channel < LPAIF_MAX_CHANNELS) {
> + if (intrsrc & LPAIF_PER_CH(dma_channel))
> + return dma_channel;
> +
> + dma_channel++;
> + }
A comment explaining why we can't just map directly might be helpful
here.
> +
> + return -1;
Real error codes please.
> +static irqreturn_t lpaif_dai_irq_handler(int irq, void *data)
> +{
> + unsigned long flag;
> + uint32_t intrsrc;
> + uint32_t dma_ch;
> + irqreturn_t ret = IRQ_NONE;
> +
> + spin_lock_irqsave(&lpaif_lock, flag);
> + intrsrc = readl(lpaif_dai_info.base + LPAIF_IRQ_STAT(0));
> + writel(intrsrc, lpaif_dai_info.base + LPAIF_IRQ_CLEAR(0));
> + spin_unlock_irqrestore(&lpaif_lock, flag);
This appears to be unconditionally acknowleding all interrupts, even
those we don't understand. This is bad practice - we should at least be
logging an error and ideally returning IRQ_NONE if we don't understand
the interrupt and letting the core error handling work for us. For
example it looks like this will happily and silently acknowledge both
error and underrun interrupts from the hardware.
It's also not at all obvious why we're taking this spinlock in the
interrupt handler, that's *extremely* unusual. What is being protected
- the code needs to make that clear?
> + while (intrsrc) {
> + dma_ch = lpaif_dai_find_dma_channel(intrsrc);
> + if (dma_ch != -1) {
> + if (lpaif_dai[dma_ch]->callback) {
> +
> + ret = lpaif_dai[dma_ch]->callback(intrsrc,
> + lpaif_dai[dma_ch]->private_data);
> + }
> + intrsrc &= ~LPAIF_PER_CH(dma_ch);
> + } else {
> + pr_err("%s: error getting channel\n", __func__);
> + break;
> + }
> + }
> + return ret;
> +}
This all looks like a very simple demux of a single register - don't we
have a generic irqchip that can handle it? It looks like that's what
you're trying to implement here, each DMA channel could be requesting
the three interrupts it has separately rather than open coding an
interrupt controller here.
I'm not actually immediately seeing one right now but it'd be simple to
add (or regmap-irq could do it if we used a regmap, though it assumes
threading and isn't a great fit).
> +static struct platform_driver lpass_lpaif_driver = {
> + .probe = lpaif_dai_probe,
> + .remove = lpaif_dai_remove,
> + .driver = {
> + .name = DRV_NAME,
> + .owner = THIS_MODULE,
No need for .owner on platform devices any more.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-11-25 21:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 18:52 [PATCH 0/9] ASoC: QCOM: Add support for ipq806x SOC Kenneth Westfield
2014-11-19 18:52 ` [PATCH 1/9] MAINTAINERS: Add QCOM audio ASoC maintainer Kenneth Westfield
2014-11-19 18:52 ` [PATCH 2/9] ASoC: qcom: Add device tree binding docs Kenneth Westfield
2014-11-25 21:26 ` Mark Brown
2014-11-19 18:52 ` [PATCH 3/9] ASoC: ipq806x: add native LPAIF driver Kenneth Westfield
2014-11-20 12:32 ` [alsa-devel] " Lars-Peter Clausen
2014-11-21 20:19 ` Kenneth Westfield
2014-11-25 21:44 ` Mark Brown [this message]
2014-11-19 18:52 ` [PATCH 4/9] ASoC: ipq806x: Add LPASS CPU DAI driver Kenneth Westfield
2014-11-19 21:17 ` Pierre-Louis Bossart
2014-11-21 20:23 ` [alsa-devel] " Kenneth Westfield
2014-11-20 0:20 ` Courtney Cavin
2014-11-20 12:36 ` [alsa-devel] " Lars-Peter Clausen
2014-11-25 21:53 ` Mark Brown
2014-11-19 18:52 ` [PATCH 5/9] ASoC: ipq806x: Add I2S PCM platform driver Kenneth Westfield
2014-11-19 21:10 ` [alsa-devel] " Pierre-Louis Bossart
2014-11-25 22:01 ` Mark Brown
2014-11-19 18:52 ` [PATCH 6/9] ASoC: ipq806x: Add machine driver for IPQ806X SOC Kenneth Westfield
2014-11-25 22:03 ` Mark Brown
2014-11-19 18:52 ` [PATCH 7/9] ASoC: qcom: Add ability to build QCOM drivers Kenneth Westfield
2014-11-25 22:07 ` Mark Brown
2014-11-27 1:26 ` Bryan Huntsman
2014-11-19 18:52 ` [PATCH 8/9] ASoC: Allow for building " Kenneth Westfield
2014-11-19 18:52 ` [PATCH 9/9] ARM: dts: Model IPQ LPASS audio hardware Kenneth Westfield
2014-11-19 22:54 ` Courtney Cavin
2014-11-21 20:17 ` [alsa-devel] " Kenneth Westfield
2014-11-25 22:08 ` Mark Brown
2014-11-19 20:16 ` [PATCH 0/9] ASoC: QCOM: Add support for ipq806x SOC Kumar Gala
2014-11-20 9:51 ` Mark Brown
2014-11-21 20:24 ` [alsa-devel] " Kenneth Westfield
2014-11-24 18:52 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2014-12-08 22:06 [PATCH 3/9] ASoC: ipq806x: add native LPAIF driver Kenneth Westfield
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=20141125214445.GT7712@sirena.org.uk \
--to=broonie@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=bryanh@codeaurora.org \
--cc=davidb@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kwestfie@codeaurora.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=plai@codeaurora.org \
--cc=rob.herring@calxeda.com \
--cc=tiwai@suse.de \
/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