From: Mark Brown <broonie@kernel.org>
To: Kenneth Westfield <kwestfie@codeaurora.org>
Cc: Takashi Iwai <tiwai@suse.de>, Liam Girdwood <lgirdwood@gmail.com>,
David Brown <davidb@codeaurora.org>,
Bryan Huntsman <bryanh@codeaurora.org>,
Greg KH <gregkh@linuxfoundation.org>,
Banajit Goswami <bgoswami@codeaurora.org>,
Patrick Lai <plai@codeaurora.org>,
ALSA Mailing List <alsa-devel@alsa-project.org>,
MSM Mailing List <linux-arm-msm@vger.kernel.org>,
Device Tree Mailing List <devicetree@vger.kernel.org>
Subject: Re: [Patch V3 07/10] ASoC: ipq806x: Add I2S PCM platform driver
Date: Fri, 26 Dec 2014 17:03:40 +0000 [thread overview]
Message-ID: <20141226170340.GH17800@sirena.org.uk> (raw)
In-Reply-To: <1419439330-2303-8-git-send-email-kwestfie@codeaurora.org>
[-- Attachment #1: Type: text/plain, Size: 3561 bytes --]
On Wed, Dec 24, 2014 at 08:42:07AM -0800, Kenneth Westfield wrote:
> +static inline u32 lpass_lpaif_int_retrieve(struct snd_soc_platform *platform)
> +{
> + struct lpass_mi2s_data *drvdata =
> + snd_soc_platform_get_drvdata(platform);
> + u32 status_offset = LPAIF_DMAIRQ_STAT(LPAIF_IRQ_RECV_HOST);
> + u32 clear_offset = LPAIF_DMAIRQ_CLEAR(LPAIF_IRQ_RECV_HOST);
> + u32 chan_bitmask = LPAIF_DMAIRQ_ALL(LPAIF_DMA_RD_CH_MI2S);
> + u32 value;
> +
> + value = readl(drvdata->base + status_offset);
> + value &= chan_bitmask;
> + writel(value, drvdata->base + clear_offset);
> +
> + return value;
> +}
More of these tiny inline functions in this driver, and in this case
there's a definite readability problem since this is not just
"retrieve", it's reading and acking the interrupts which means that...
> +static irqreturn_t lpass_pcm_mi2s_irq(int irq, void *data)
> +{
> + struct snd_pcm_substream *substream = data;
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
> + struct lpass_mi2s_data *drvdata =
> + snd_soc_platform_get_drvdata(soc_runtime->platform);
> + u32 xrun_bitmask = LPAIF_DMAIRQ_XRUN(LPAIF_DMA_RD_CH_MI2S);
> + u32 period_bitmask = LPAIF_DMAIRQ_PER(LPAIF_DMA_RD_CH_MI2S);
> + u32 error_bitmask = LPAIF_DMAIRQ_ERR(LPAIF_DMA_RD_CH_MI2S);
> + u32 pending;
> + irqreturn_t ret = IRQ_NONE;
> +
> + pending = lpass_lpaif_int_retrieve(soc_runtime->platform);
> +
> + if (unlikely(pending & xrun_bitmask) && snd_pcm_running(substream)) {
> + dev_warn(soc_runtime->dev, "%s: xrun warning\n", __func__);
> + snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
> + pending &= ~xrun_bitmask;
> + ret = IRQ_HANDLED;
> + }
...all this code working out if we actually handled an interrupt might
be lying.
> + if (pending & period_bitmask) {
> + if (++drvdata->period_index >= runtime->periods)
> + drvdata->period_index = 0;
> + snd_pcm_period_elapsed(substream);
> + pending &= ~period_bitmask;
> + ret = IRQ_HANDLED;
> + }
If we miss an interrupt then...
> +static snd_pcm_uframes_t lpass_pcm_mi2s_pointer(
> + struct snd_pcm_substream *substream)
> +{
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
> + struct lpass_mi2s_data *drvdata =
> + snd_soc_platform_get_drvdata(soc_runtime->platform);
> + snd_pcm_uframes_t offset;
> +
> + offset = drvdata->period_index * runtime->period_size;
> +
> + return offset >= (runtime->buffer_size) ? 0 : offset;
> +}
...this will be broken. Why is the pointer operation not reading from
the hardware?
> +static struct snd_pcm_ops lpass_pcm_mi2s_soc_ops = {
> + .open = lpass_pcm_mi2s_open,
> + .hw_params = lpass_pcm_mi2s_hw_params,
> + .hw_free = lpass_pcm_mi2s_hw_free,
> + .prepare = lpass_pcm_mi2s_prepare,
> + .mmap = lpass_pcm_mi2s_mmap,
> + .pointer = lpass_pcm_mi2s_pointer,
> + .ioctl = snd_pcm_lib_ioctl,
> +};
Again the start and stopn are misplaced and should be in the trigger
like with other drivers.
> +static void lpass_pcm_mi2s_soc_free(struct snd_pcm *pcm)
> +{
> + struct snd_pcm_substream *substream =
> + pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
> + struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
> + struct lpass_mi2s_data *drvdata =
> + snd_soc_platform_get_drvdata(soc_runtime->platform);
> +
> + lpass_pcm_mi2s_free_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK);
> +
> + disable_irq(drvdata->irqnum);
> + free_irq(drvdata->irqnum, NULL);
This is weird, why the manual disable_irq()?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-12-26 17:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-24 16:42 [Patch V3 00/10] ASoC: QCOM: Add support for ipq806x SOC Kenneth Westfield
[not found] ` <1419439330-2303-1-git-send-email-kwestfie-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-12-24 16:42 ` [Patch V3 01/10] MAINTAINERS: Add QCOM audio ASoC maintainer Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 02/10] ASoC: qcom: Document MAX98357A bindings Kenneth Westfield
2014-12-29 16:07 ` Mark Brown
2014-12-24 16:42 ` [Patch V3 03/10] ASoC: qcom: Document LPASS CPU bindings Kenneth Westfield
2014-12-26 16:43 ` Mark Brown
2014-12-24 16:42 ` [Patch V3 04/10] ASoC: codec: Add MAX98357A codec driver Kenneth Westfield
2014-12-26 16:44 ` Mark Brown
2014-12-24 16:42 ` [Patch V3 05/10] ASoC: ipq806x: add LPASS header files Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 06/10] ASoC: ipq806x: Add LPASS CPU DAI driver Kenneth Westfield
2014-12-26 16:56 ` Mark Brown
2014-12-24 16:42 ` [Patch V3 07/10] ASoC: ipq806x: Add I2S PCM platform driver Kenneth Westfield
2014-12-26 17:03 ` Mark Brown [this message]
2014-12-24 16:42 ` [Patch V3 08/10] ASoC: qcom: Add ability to build QCOM drivers Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 09/10] ASoC: Allow for building " Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 10/10] ARM: dts: Model IPQ LPASS audio hardware 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=20141226170340.GH17800@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=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;
as well as URLs for NNTP newsgroup(s).