]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ASoC: mchp-i2s-mcc: Wait for RX/TX RDY only if controller is running
authorCodrin Ciubotariu <codrin.ciubotariu@microchip.com>
Tue, 20 Aug 2019 16:24:10 +0000 (19:24 +0300)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 18 Oct 2019 08:25:53 +0000 (04:25 -0400)
BugLink: https://bugs.launchpad.net/bugs/1848046
[ Upstream commit 0f6fc97501b790c971b11b52a654009d21c45238 ]

Since hw_free() can be called multiple times and not just after a stop
trigger command, we should check whether the RX or TX ready interrupt was
truly enabled previously. For this, we assure that the condition of the
wait event is always true, except when RX/TX interrupts are enabled.

Fixes: 7e0cdf545a55 ("ASoC: mchp-i2s-mcc: add driver for I2SC Multi-Channel Controller")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Link: https://lore.kernel.org/r/20190820162411.24836-3-codrin.ciubotariu@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
sound/soc/atmel/mchp-i2s-mcc.c

index 86495883ca3f1c7b1b89672ca2573c86ccf6d3ee..8272915fa09b977c5aec83ae045d02c23d267526 100644 (file)
@@ -686,22 +686,24 @@ static int mchp_i2s_mcc_hw_free(struct snd_pcm_substream *substream,
                err = wait_event_interruptible_timeout(dev->wq_txrdy,
                                                       dev->tx_rdy,
                                                       msecs_to_jiffies(500));
+               if (err == 0) {
+                       dev_warn_once(dev->dev,
+                                     "Timeout waiting for Tx ready\n");
+                       regmap_write(dev->regmap, MCHP_I2SMCC_IDRA,
+                                    MCHP_I2SMCC_INT_TXRDY_MASK(dev->channels));
+                       dev->tx_rdy = 1;
+               }
        } else {
                err = wait_event_interruptible_timeout(dev->wq_rxrdy,
                                                       dev->rx_rdy,
                                                       msecs_to_jiffies(500));
-       }
-
-       if (err == 0) {
-               u32 idra;
-
-               dev_warn_once(dev->dev, "Timeout waiting for %s\n",
-                             is_playback ? "Tx ready" : "Rx ready");
-               if (is_playback)
-                       idra = MCHP_I2SMCC_INT_TXRDY_MASK(dev->channels);
-               else
-                       idra = MCHP_I2SMCC_INT_RXRDY_MASK(dev->channels);
-               regmap_write(dev->regmap, MCHP_I2SMCC_IDRA, idra);
+               if (err == 0) {
+                       dev_warn_once(dev->dev,
+                                     "Timeout waiting for Rx ready\n");
+                       regmap_write(dev->regmap, MCHP_I2SMCC_IDRA,
+                                    MCHP_I2SMCC_INT_RXRDY_MASK(dev->channels));
+                       dev->rx_rdy = 1;
+               }
        }
 
        if (!mchp_i2s_mcc_is_running(dev)) {
@@ -809,6 +811,8 @@ static int mchp_i2s_mcc_dai_probe(struct snd_soc_dai *dai)
 
        init_waitqueue_head(&dev->wq_txrdy);
        init_waitqueue_head(&dev->wq_rxrdy);
+       dev->tx_rdy = 1;
+       dev->rx_rdy = 1;
 
        snd_soc_dai_init_dma_data(dai, &dev->playback, &dev->capture);