Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sameer Pujar <spujar@nvidia.com>
To: perex@perex.cz, tiwai@suse.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, Sameer Pujar <spujar@nvidia.com>
Subject: [PATCH 6/7] ALSA: hda/tegra: fix kernel panic
Date: Mon, 21 Jan 2019 23:11:36 +0530	[thread overview]
Message-ID: <1548092497-5459-7-git-send-email-spujar@nvidia.com> (raw)
In-Reply-To: <1548092497-5459-1-git-send-email-spujar@nvidia.com>

Kernel panic is seen during device boot. It appears that before the
probe completes, runtime callbacks happen and the device setup is not
done yet. This could be initiated from framework through exposed
callbacks. This issue can be fixed by having a flag to indicate
completion of device probe. Hence 'probed' flag is introduced to notify
completion of probe and runtime callbacks can check this flag before
doing any device access.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
---
 sound/pci/hda/hda_tegra.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 5546e29..80c4042 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -76,6 +76,7 @@ struct hda_tegra {
 	struct clk *hda2hdmi_clk;
 	void __iomem *regs;
 	struct work_struct probe_work;
+	bool probed;
 };
 
 #ifdef CONFIG_PM
@@ -265,9 +266,11 @@ static int hda_tegra_runtime_suspend(struct device *dev)
 	struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
 	struct hdac_bus *bus = azx_bus(chip);
 
-	azx_stop_chip(chip);
-	synchronize_irq(bus->irq);
-	azx_enter_link_reset(chip);
+	if (hda->probed) {
+		azx_stop_chip(chip);
+		synchronize_irq(bus->irq);
+		azx_enter_link_reset(chip);
+	}
 	hda_tegra_disable_clocks(hda);
 
 	return 0;
@@ -283,8 +286,10 @@ static int hda_tegra_runtime_resume(struct device *dev)
 	rc = hda_tegra_enable_clocks(hda);
 	if (rc != 0)
 		return rc;
-	hda_tegra_init(hda);
-	azx_init_chip(chip, 1);
+	if (hda->probed) {
+		hda_tegra_init(hda);
+		azx_init_chip(chip, 1);
+	}
 
 	return 0;
 }
@@ -527,6 +532,7 @@ static int hda_tegra_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	hda->dev = &pdev->dev;
 	chip = &hda->chip;
+	hda->probed = false;
 
 	err = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			   THIS_MODULE, 0, &card);
@@ -585,6 +591,7 @@ static void hda_tegra_probe_work(struct work_struct *work)
 		goto out_free;
 
 	chip->running = 1;
+	hda->probed = true;
 	snd_hda_set_power_save(&chip->bus, power_save * 1000);
 
  out_free:
-- 
2.7.4


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

  parent reply	other threads:[~2019-01-21 17:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 17:41 [PATCH 0/7] Runtime PM support (hda/tegra) Sameer Pujar
2019-01-21 17:41 ` [PATCH 1/7] ALSA: hda/tegra: runtime power management support Sameer Pujar
2019-01-21 17:41 ` [PATCH 2/7] ALSA: hda/tegra: get clock handles early in probe Sameer Pujar
2019-01-21 17:41 ` [PATCH 3/7] ALSA: hda/tegra: add runtime PM callbacks Sameer Pujar
2019-01-21 17:41 ` [PATCH 4/7] ALSA: hda/tegra: remove redundant clock enable API Sameer Pujar
2019-01-21 17:41 ` [PATCH 5/7] ALSA: hda/tegra: implement runtime suspend/resume Sameer Pujar
2019-01-21 17:41 ` Sameer Pujar [this message]
2019-01-21 21:28   ` [PATCH 6/7] ALSA: hda/tegra: fix kernel panic Takashi Iwai
2019-01-22  3:41     ` Sameer Pujar
2019-01-22  6:24       ` Takashi Iwai
2019-01-21 17:41 ` [PATCH 7/7] ALSA: hda/tegra: add driver flag for runtime PM Sameer Pujar
2019-01-21 21:31   ` Takashi Iwai
2019-01-22  2:04     ` Sameer Pujar
2019-01-22  6:31       ` Takashi Iwai

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=1548092497-5459-7-git-send-email-spujar@nvidia.com \
    --to=spujar@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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