[alsa-devel] [PATCH v2] ASoC: sgtl5000: defer the probe if clock is not found
It's not always the case that clock is already available when sgtl5000 get probed at the first time, e.g. the clock is provided by CPU DAI which may be probed after sgtl5000. So let's defer the probe when devm_clk_get() call fails and give it chance to try later.
It fixes the regression on imx28 since commit 9e13f34 (ASoC: sgtl5000: Let the codec acquire its clock).
[ 1.927637] sgtl5000 0-000a: Failed to get mclock: -2 [ 1.934280] sgtl5000: probe of 0-000a failed with error -2 [ 1.945906] mxs-sgtl5000 sound.13: ASoC: CODEC (null) not registered [ 1.953787] mxs-sgtl5000 sound.13: snd_soc_register_card failed (-517) [ 1.960865] platform sound.13: Driver mxs-sgtl5000 requests probe deferral
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- Changes since v1: * Not use ternary operator.
Mark,
I'm still not going to fix this regression during -rc at clock core level with the risk of breaking clock API users and being yelled by clock maintainer.
Shawn
sound/soc/codecs/sgtl5000.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index d441559..f5ec35b 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1527,6 +1527,9 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, if (IS_ERR(sgtl5000->mclk)) { ret = PTR_ERR(sgtl5000->mclk); dev_err(&client->dev, "Failed to get mclock: %d\n", ret); + /* Defer the probe to see if the clk will be provided later */ + if (ret == -ENOENT) + return -EPROBE_DEFER; return ret; }
On Tue, Jul 16, 2013 at 09:17:27AM +0800, Shawn Guo wrote:
It fixes the regression on imx28 since commit 9e13f34 (ASoC: sgtl5000: Let the codec acquire its clock).
Looking at the code the race has always been there, the same issue exists in the old code in the machine driver. But I guess there may have been some (surprising given that we now wait for an I2C device to be registered) reordering.
I'm still not going to fix this regression during -rc at clock core level with the risk of breaking clock API users and being yelled by clock maintainer.
I'd be much happier with this if there were at least some effort being made to discuss the issue at a generic level. If we were adding a new API for deferring clocks (which was the suggestion) then there'd be no risk to existing users...
/* Defer the probe to see if the clk will be provided later */
if (ret == -ENOENT)
return -EPROBE_DEFER;
What's magic about -ENOENT here?
On Tue, Jul 16, 2013 at 09:17:27AM +0800, Shawn Guo wrote:
It's not always the case that clock is already available when sgtl5000 get probed at the first time, e.g. the clock is provided by CPU DAI which may be probed after sgtl5000. So let's defer the probe when devm_clk_get() call fails and give it chance to try later.
Meh, I went ahead and applied this but I'm not happy - there's been a lot of problems with this code recently and this issue isn't being discussed at the right level but there's users. So please look into a more general solution in the clock API.
participants (2)
-
Mark Brown
-
Shawn Guo