From patchwork Sun Sep 24 18:41:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 114136 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1805959qgf; Sun, 24 Sep 2017 11:43:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC+cHNiiW8r0j7+AcA52QikQoxXu+rad864zGeDqfehXNvo9fZBxnc6Q8W8jmgu/NT70YnU X-Received: by 10.84.254.70 with SMTP id a6mr5260942pln.71.1506278584187; Sun, 24 Sep 2017 11:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506278584; cv=none; d=google.com; s=arc-20160816; b=pHrkyZcOoFlg8siUzg8GWWj+ZmlcahFToF/biUUPht9B1I9si0swVU8uRWjZIwe35D MdaTFW2Kucj9A9/qvha0eFAa6xKTUbPjOPJ6hR08yb5cx3j8pHFr634/x9moTR22On2D dw95NLPqL1LpqvFJTLgPo+BzkrluwfMf4pXbS+3tD4arhtrSFv6QM0k30sGk6lAjxYnk hGijyZ1kvIjMj0X5/gnqLQB+/sV0baho6Kgr0k6H0ryERQ8+gJkB7RVynfe/oRg8DS4V MJF6JOYWKxtQEYdVLlKoPP0KIXYMJco4hQOtCvbcq4yunmHnY/pR/ZB7ymdmMlQc909z R9ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:dkim-signature :dkim-signature:from:dkim-signature:arc-authentication-results; bh=t5rmPww2Lkgxv9Cxka3gBmkOP6pbpJcnvIljvMJ87Ck=; b=fRYSnmidtFoAvZhPIWDmUKjYGwuVUgJhZ0oTFCqqqjlrw59lhhkIu1Qj0r3xMiHiZR fkaJcijzNGD5sCYubCrJgjewic3Ns4my+lhr320mWrOJdVASHIa5O8ObyNVjvOP7lOB8 JrbI3wueLhBDe/dKWBt2IoRD1jhecvYxhN/8u2wTVkgXUQEnDk3Gpl99onOx9hdfN6Id 02ECM/kd5m1QAAqqyfml7BzdH8bTwlNW/AGL7iEzN/pJLfq4JkdaUElJozSw5kGInKFZ tOZ+N1xrsRP/5e7uqqSCZHFbh+dludTRIxddjuQ3740Plfa/MB36HDsElmCoVMFYIw5f YaLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=m3yMN+8Z; dkim=fail header.i=@verizon.com header.s=corp header.b=qCkDy0zi; dkim=fail header.i=@verizon.com header.s=corp header.b=M/CDTpuu; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si3003187pgs.34.2017.09.24.11.43.03; Sun, 24 Sep 2017 11:43:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=m3yMN+8Z; dkim=fail header.i=@verizon.com header.s=corp header.b=qCkDy0zi; dkim=fail header.i=@verizon.com header.s=corp header.b=M/CDTpuu; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752864AbdIXSnD (ORCPT + 8 others); Sun, 24 Sep 2017 14:43:03 -0400 Received: from omzsmtpe02.verizonbusiness.com ([199.249.25.209]:24044 "EHLO omzsmtpe02.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752803AbdIXSmz (ORCPT ); Sun, 24 Sep 2017 14:42:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278575; x=1537814575; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=iniMhNTvFQYnIkM2zSS3udLL1OwO9VyK+jucFiTa/yE=; b=m3yMN+8Z/BTEUCD4oMrAXKOG+ewu8iHFzbrDHQp3ZZFAAkZC/hMOs5+N A26jshrDjFKLl3+AAZA0p7PEbGQvbI/OgIe13EkMh6deYhPRA2wbh19Zx QxNefNZ66Znvwrot3zg8lu1IX5lWJ1oAWQG6YmOSBzQLVMMm02AhAFNPg 4=; Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by omzsmtpe02.verizonbusiness.com with ESMTP; 24 Sep 2017 18:42:52 +0000 From: "Levin, Alexander (Sasha Levin)" Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi01.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Sep 2017 18:42:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278558; x=1537814558; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=iniMhNTvFQYnIkM2zSS3udLL1OwO9VyK+jucFiTa/yE=; b=qCkDy0ziGmZd0+fkOkHIZbW854hsqcXXJvBLmhbaZhHNXKd/QP5+8SsW bwnSN1D5fXM0N4wG6TQmCT9G/ry3pUBWAnt26cPE2cx2V0NT4OVFLMAfx XWcQ4iHrrrScdwU9xU8G0z9chAKhjdd1UkEP4HQaITzAL7jVC/6qNKypR I=; Received: from ranger.odc.vzwcorp.com (HELO mercury.verizonwireless.com) ([10.255.240.27]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Sep 2017 14:42:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278559; x=1537814559; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=iniMhNTvFQYnIkM2zSS3udLL1OwO9VyK+jucFiTa/yE=; b=M/CDTpuuYlZqkrc9Oc5s/+n814IuZrHIj0r+9t9RqgaUNxgFVefBRHta bnxH5i63dEWoAWwsHcAsvheZJL1B901onl1m6eBoWjmxp9QrJCx0ipl2s nNnEs1UVhEv6AxTJazUziGZ63LQE+6EfF0Q+RQ/czSUyzh9ngx9V9eRFt M=; X-Host: ranger.odc.vzwcorp.com Received: from casac1exh001.uswin.ad.vzwcorp.com ([10.11.218.43]) by mercury.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 24 Sep 2017 18:42:39 +0000 Received: from scwexch01apd.uswin.ad.vzwcorp.com (153.114.130.20) by CASAC1EXH001.uswin.ad.vzwcorp.com (10.11.218.43) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 24 Sep 2017 11:42:36 -0700 Received: from OMZP1LUMXCA11.uswin.ad.vzwcorp.com (144.8.22.186) by scwexch01apd.uswin.ad.vzwcorp.com (153.114.130.20) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 24 Sep 2017 11:42:36 -0700 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA11.uswin.ad.vzwcorp.com (144.8.22.186) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 24 Sep 2017 13:42:34 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Sun, 24 Sep 2017 13:42:34 -0500 To: "gregkh@linuxfoundation.org" CC: "stable@vger.kernel.org" Subject: [GIT PULL for-4.9 44/96] ASoC: dapm: handle probe deferrals Thread-Topic: [GIT PULL for-4.9 44/96] ASoC: dapm: handle probe deferrals Thread-Index: AQHTNWTHv+hDuwcbAES8ya9zawYKaQ== Date: Sun, 24 Sep 2017 18:41:47 +0000 Message-ID: <20170924184130.29445-45-alexander.levin@verizon.com> References: <20170924184130.29445-1-alexander.levin@verizon.com> In-Reply-To: <20170924184130.29445-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Linus Walleij [ Upstream commit 37e1df8c95e2c8a57c77eafc097648f6e40a60ff ] This starts to handle probe deferrals on regulators and clocks on the ASoC DAPM. I came to this patch after audio stopped working on Ux500 ages ago and I finally looked into it to see what is wrong. I had messages like this in the console since a while back: ab8500-codec.0: ASoC: Failed to request audioclk: -517 ab8500-codec.0: ASoC: Failed to create DAPM control audioclk ab8500-codec.0: Failed to create new controls -12 snd-soc-mop500.0: ASoC: failed to instantiate card -12 snd-soc-mop500.0: Error: snd_soc_register_card failed (-12)! snd-soc-mop500: probe of snd-soc-mop500.0 failed with error -12 Apparently because the widget table for the codec looks like this (sound/soc/codecs/ab8500-codec.c): static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = { /* Clocks */ SND_SOC_DAPM_CLOCK_SUPPLY("audioclk"), /* Regulators */ SND_SOC_DAPM_REGULATOR_SUPPLY("V-AUD", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC1", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC2", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("V-DMIC", 0, 0), So when we call snd_soc_register_codec() and any of these widgets get a deferred probe we do not get an -EPROBE_DEFER (-517) back as we should and instead we just fail. Apparently the code assumes that clocks and regulators must be available at this point and not defer. After this patch it rather looks like this: ab8500-codec.0: Failed to create new controls -517 snd-soc-mop500.0: ASoC: failed to instantiate card -517 snd-soc-mop500.0: Error: snd_soc_register_card failed (-517)! (...) abx500-clk.0: registered clocks for ab850x snd-soc-mop500.0: ab8500-codec-dai.0 <-> ux500-msp-i2s.1 mapping ok snd-soc-mop500.0: ab8500-codec-dai.1 <-> ux500-msp-i2s.3 mapping ok I'm pretty happy about the patch as it it, but I'm a bit uncertain on how to proceed: there are a lot of users of the external functions snd_soc_dapm_new_control() (111 sites) and that will now return an occassional error pointer, which is not handled in the calling sites. I want an indication from the maintainers whether I should just go in and augment all these call sites, or if deferred probe is frowned upon when it leads to this much overhead. Signed-off-by: Linus Walleij Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-dapm.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/soc-topology.c | 9 +++++++++ 2 files changed, 51 insertions(+) -- 2.11.0 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 3bbe32ee4630..411f7574dd0b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -358,6 +358,10 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, snd_soc_dapm_new_control_unlocked(widget->dapm, &template); kfree(name); + if (IS_ERR(data->widget)) { + ret = PTR_ERR(data->widget); + goto err_data; + } if (!data->widget) { ret = -ENOMEM; goto err_data; @@ -392,6 +396,10 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, data->widget = snd_soc_dapm_new_control_unlocked( widget->dapm, &template); kfree(name); + if (IS_ERR(data->widget)) { + ret = PTR_ERR(data->widget); + goto err_data; + } if (!data->widget) { ret = -ENOMEM; goto err_data; @@ -3311,11 +3319,22 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); w = snd_soc_dapm_new_control_unlocked(dapm, widget); + /* Do not nag about probe deferrals */ + if (IS_ERR(w)) { + int ret = PTR_ERR(w); + + if (ret != -EPROBE_DEFER) + dev_err(dapm->dev, + "ASoC: Failed to create DAPM control %s (%d)\n", + widget->name, ret); + goto out_unlock; + } if (!w) dev_err(dapm->dev, "ASoC: Failed to create DAPM control %s\n", widget->name); +out_unlock: mutex_unlock(&dapm->card->dapm_mutex); return w; } @@ -3338,6 +3357,8 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, w->regulator = devm_regulator_get(dapm->dev, w->name); if (IS_ERR(w->regulator)) { ret = PTR_ERR(w->regulator); + if (ret == -EPROBE_DEFER) + return ERR_PTR(ret); dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n", w->name, ret); return NULL; @@ -3356,6 +3377,8 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, w->clk = devm_clk_get(dapm->dev, w->name); if (IS_ERR(w->clk)) { ret = PTR_ERR(w->clk); + if (ret == -EPROBE_DEFER) + return ERR_PTR(ret); dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n", w->name, ret); return NULL; @@ -3474,6 +3497,16 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); for (i = 0; i < num; i++) { w = snd_soc_dapm_new_control_unlocked(dapm, widget); + if (IS_ERR(w)) { + ret = PTR_ERR(w); + /* Do not nag about probe deferrals */ + if (ret == -EPROBE_DEFER) + break; + dev_err(dapm->dev, + "ASoC: Failed to create DAPM control %s (%d)\n", + widget->name, ret); + break; + } if (!w) { dev_err(dapm->dev, "ASoC: Failed to create DAPM control %s\n", @@ -3750,6 +3783,15 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card, dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name); w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); + if (IS_ERR(w)) { + ret = PTR_ERR(w); + /* Do not nag about probe deferrals */ + if (ret != -EPROBE_DEFER) + dev_err(card->dev, + "ASoC: Failed to create %s widget (%d)\n", + link_name, ret); + goto outfree_kcontrol_news; + } if (!w) { dev_err(card->dev, "ASoC: Failed to create %s widget\n", link_name); diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 6b05047a4134..8a758c994506 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1473,6 +1473,15 @@ widget: widget = snd_soc_dapm_new_control(dapm, &template); else widget = snd_soc_dapm_new_control_unlocked(dapm, &template); + if (IS_ERR(widget)) { + ret = PTR_ERR(widget); + /* Do not nag about probe deferrals */ + if (ret != -EPROBE_DEFER) + dev_err(tplg->dev, + "ASoC: failed to create widget %s controls (%d)\n", + w->name, ret); + goto hdr_err; + } if (widget == NULL) { dev_err(tplg->dev, "ASoC: failed to create widget %s controls\n", w->name);