[bug report] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR

Dan Carpenter dan.carpenter at oracle.com
Fri Sep 16 07:38:09 PDT 2022


Hello Judy Hsiao,

The patch fbb0ec656ee5: "ASoC: rockchip: i2s: use
regmap_read_poll_timeout to poll I2S_CLR" from Sep 14, 2022, leads to
the following Smatch static checker warning:

	sound/soc/rockchip/rockchip_i2s.c:165 rockchip_snd_txctrl()
	warn: sleeping in atomic context

sound/soc/rockchip/rockchip_i2s.c
    126 static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
    127 {
    128         unsigned int val = 0;
    129         int ret = 0;
    130 
    131         spin_lock(&i2s->lock);
                ^^^^^^^^^^^^^^^^^^^^^
Holding a spin lock.

    132         if (on) {
    133                 ret = regmap_update_bits(i2s->regmap, I2S_DMACR,
    134                                          I2S_DMACR_TDE_ENABLE,
    135                                          I2S_DMACR_TDE_ENABLE);
    136                 if (ret < 0)
    137                         goto end;
    138                 ret = regmap_update_bits(i2s->regmap, I2S_XFER,
    139                                          I2S_XFER_TXS_START | I2S_XFER_RXS_START,
    140                                          I2S_XFER_TXS_START | I2S_XFER_RXS_START);
    141                 if (ret < 0)
    142                         goto end;
    143                 i2s->tx_start = true;
    144         } else {
    145                 i2s->tx_start = false;
    146 
    147                 ret = regmap_update_bits(i2s->regmap, I2S_DMACR,
    148                                          I2S_DMACR_TDE_ENABLE,
    149                                          I2S_DMACR_TDE_DISABLE);
    150                 if (ret < 0)
    151                         goto end;
    152 
    153                 if (!i2s->rx_start) {
    154                         ret = regmap_update_bits(i2s->regmap, I2S_XFER,
    155                                                  I2S_XFER_TXS_START | I2S_XFER_RXS_START,
    156                                                  I2S_XFER_TXS_STOP | I2S_XFER_RXS_STOP);
    157                         if (ret < 0)
    158                                 goto end;
    159                         udelay(150);
    160                         ret = regmap_update_bits(i2s->regmap, I2S_CLR,
    161                                                  I2S_CLR_TXC | I2S_CLR_RXC,
    162                                                  I2S_CLR_TXC | I2S_CLR_RXC);
    163                         if (ret < 0)
    164                                 goto end;
--> 165                         ret = regmap_read_poll_timeout(i2s->regmap,
    166                                                        I2S_CLR,
    167                                                        val,
    168                                                        val != 0,
    169                                                        20,
                                                               ^^
    170                                                        200);
                                                               ^^^
If the sleep_us or timeout_us values are non-zero then it can sleep so
it's a sleeping in atomic bug.

    171                         if (ret < 0)
    172                                 dev_warn(i2s->dev, "fail to clear: %d\n", ret);
    173                 }
    174         }
    175 end:
    176         spin_unlock(&i2s->lock);
    177         if (ret < 0)
    178                 dev_err(i2s->dev, "lrclk update failed\n");
    179 
    180         return ret;
    181 }

regards,
dan carpenter



More information about the Linux-rockchip mailing list