ALSA: hda - Fix race condition between HDA driver and runtime PM
PATCH v2 1/1 ALSA: hda - Fix race condition between HDA driver and runtime PM
Don't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel 0000:00:1b.0: CORB reset timeout#2, CORBRP = 65535 snd_hda_intel 0000:00:1b.0: no codecs initialized
Debugged and root-cause found by [email protected]
v2: remove unnecessary extra check for chip init (libin)
--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +3 -1
@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ; chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)return 0 ;if (!power_save_controller || !azx_has_pm_runtime (chip) || -azx_bus (chip)->codec_powered) + bus->codec_powered || !bus->chip_init)return -EBUSY ;return 0 ;
Signature · 1 line
1.9.3
Hi Ullysses,
Quoted 31 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 12:20 PM
To: [email protected]; [email protected]
Cc: Lee, Zhuo-hao; Yang, Libin; Eoff, Ullysses A
Subject: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMDon't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel0000:00:1b.0: CORB reset timeout#2, CORBRP = 65535snd_hda_intel0000:00:1b.0: no codecs initializedDebugged and root-cause found by [email protected]
v2: remove unnecessary extra check for chip init (libin)
Signed-off-by U. Artie Eoff <[email protected]>--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)sound/pci/hda/hda_intel.c +0
-0@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device · line 1029
Quoted 10 lines
sound/pci/hda/hda_intel.c +2
-0struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ; chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)
I mean we don't need '!chip->running' either. Otherwise, initialization may be interrupted.
Quoted 10 lines
sound/pci/hda/hda_intel.c +1
-1return 0 ;if (!power_save_controller || !azx_has_pm_runtime (chip) || -azx_bus (chip)->codec_powered) + bus->codec_powered || !bus->chip_init)return -EBUSY ;return 0;
--
1.9.3
Quoted 48 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:20 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMHi Ullysses,
Quoted 37 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 12:20 PM
To: [email protected]; [email protected]
Cc: Lee, Zhuo-hao; Yang, Libin; Eoff, Ullysses A
Subject: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMDon't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel0000:00:1b.0: CORB reset timeout#2, CORBRP = 65535snd_hda_intel0000:00:1b.0: no codecs initializedDebugged and root-cause found by [email protected]
v2: remove unnecessary extra check for chip init (libin)
Signed-off-by U. Artie Eoff <[email protected]>--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)sound/pci/hda/hda_intel.c +1
-0@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ;
Quoted 7 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device *dev) · line 1028
Quoted 4 lines
sound/pci/hda/hda_intel.c +1
-0chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)I mean we don't need '!chip->running' either. Otherwise, initialization may be interrupted.
!chip->running condition comes from patch 1/2 and is needed to avoid race with async probe. Are you saying we don't need patch 1/2?
Quoted 11 lines
Quoted 11 lines
sound/pci/hda/hda_intel.c +1
-1return 0 ;if (!power_save_controller || !azx_has_pm_runtime (chip) || -azx_bus (chip)->codec_powered) + bus->codec_powered || !bus->chip_init)return -EBUSY ;return 0;
--
1.9.3
Hi Ullysses,
Quoted 68 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 1:27 PM
To: Yang, Libin; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMQuoted 6 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:20 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDAdriver and runtime PM
Quoted 10 lines
Hi Ullysses,
Quoted 6 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 12:20 PM
To: [email protected]; [email protected]
Cc: Lee, Zhuo-hao; Yang, Libin; Eoff, Ullysses A
Subject: [PATCH v2] ALSA: hda - Fix race condition between HDAdriver
Quoted 6 lines
Quoted 6 lines
and runtime PM
Don't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel0000:00:1b.0: CORB reset timeout#2, CORBRP =65535
Quoted 11 lines
Quoted 11 lines
snd_hda_intel0000:00:1b.0: no codecs initializedDebugged and root-cause found by [email protected]
v2: remove unnecessary extra check for chip init (libin)
Signed-off-by U. Artie Eoff <[email protected]>--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 5 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct
Quoted 5 lines
sound/pci/hda/hda_intel.c +0
-0@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(structdevice
Quoted 9 lines
Quoted 9 lines
sound/pci/hda/hda_intel.c +1
-0*dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ;Quoted 7 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device *dev) · line 1028
Quoted 4 lines
sound/pci/hda/hda_intel.c +1
-0chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)I mean we don't need '!chip->running' either. Otherwise, initialization may be interrupted.
Quoted 3 lines
!chip->running condition comes from patch 1/2 and is needed to avoid race with async probe. Are you saying we don't need patch 1/2?
Do you mean removing patch 1/2 will cause race?
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
sound/pci/hda/hda_intel.c +1
-1return 0 ;if (!power_save_controller || !azx_has_pm_runtime (chip) || -azx_bus (chip)->codec_powered) + bus->codec_powered || !bus->chip_init)return -EBUSY ;return 0;
--
1.9.3
Quoted 77 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:30 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMHi Ullysses,
Quoted 68 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 1:27 PM
To: Yang, Libin; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMQuoted 6 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:20 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDAdriver and runtime PM
Quoted 10 lines
Hi Ullysses,
Quoted 6 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 12:20 PM
To: [email protected]; [email protected]
Cc: Lee, Zhuo-hao; Yang, Libin; Eoff, Ullysses A
Subject: [PATCH v2] ALSA: hda - Fix race condition between HDAdriver
Quoted 6 lines
Quoted 6 lines
and runtime PM
Don't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel0000:00:1b.0: CORB reset timeout#2, CORBRP =65535
Quoted 11 lines
Quoted 11 lines
snd_hda_intel0000:00:1b.0: no codecs initializedDebugged and root-cause found by [email protected]
v2: remove unnecessary extra check for chip init (libin)
Signed-off-by U. Artie Eoff <[email protected]>--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 5 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct
Quoted 5 lines
sound/pci/hda/hda_intel.c +0
-0@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(structdevice
Quoted 16 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device *dev) · line 1028
Quoted 13 lines
sound/pci/hda/hda_intel.c +2
-0*dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ; chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)I mean we don't need '!chip->running' either. Otherwise, initialization may be interrupted.
Quoted 5 lines
Quoted 3 lines
!chip->running condition comes from patch 1/2 and is needed to avoid race with async probe. Are you saying we don't need patch 1/2?
Do you mean removing patch 1/2 will cause race?
Yes. PM ops could trigger before azx_probe_continue finishes which results in a NULL deref kernel crash.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
sound/pci/hda/hda_intel.c +1
-1return 0 ;if (!power_save_controller || !azx_has_pm_runtime (chip) || -azx_bus (chip)->codec_powered) + bus->codec_powered || !bus->chip_init)return -EBUSY ;return 0;
--
1.9.3
Quoted 90 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 1:38 PM
To: Yang, Libin; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDA driver and runtime PMQuoted 6 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:30 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition between HDAdriver and runtime PM
Quoted 9 lines
Hi Ullysses,
Quoted 6 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 1:27 PM
To: Yang, Libin; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition betweenHDA
Quoted 9 lines
Quoted 9 lines
driver and runtime PM
Quoted 6 lines
-----Original Message-----
From: Yang, Libin
Sent: Monday, July 27, 2015 10:20 PM
To: Eoff, Ullysses A; [email protected]; [email protected]
Cc: Lee, Zhuo-hao
Subject: RE: [PATCH v2] ALSA: hda - Fix race condition betweenHDA
Quoted 11 lines
Quoted 11 lines
driver and runtime PM
Quoted 10 lines
Hi Ullysses,
Quoted 6 lines
-----Original Message-----
From: Eoff, Ullysses A
Sent: Tuesday, July 28, 2015 12:20 PM
To: [email protected]; [email protected]
Cc: Lee, Zhuo-hao; Yang, Libin; Eoff, Ullysses A
Subject: [PATCH v2] ALSA: hda - Fix race condition betweenHDA
Quoted 12 lines
Quoted 12 lines
driver
Quoted 6 lines
Quoted 6 lines
and runtime PM
Don't execute runtime suspend if HDA is not finished initializing. Otherwise, the following errors can occur in hda:
snd_hda_intel0000:00:1b.0: CORB reset timeout#2, CORBRP =65535
Quoted 4 lines
Quoted 4 lines
snd_hda_intel0000:00:1b.0: no codecs initializedDebugged and root-cause found by [email protected]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
v2: remove unnecessary extra check for chip init (libin)
Signed-off-by U. Artie Eoff <[email protected]>--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/sound/pci/hda/hda_intel.cQuoted 22 lines
Quoted 22 lines
Quoted 4 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct
Quoted 4 lines
index
b729b25a6ad6..15d4e28fc64e100644sound/pci/hda/hda_intel.c +0
-0@@ -1017,17 +1017,19 @@ static int azx_runtime_idle(structdevice
Quoted 16 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device *dev) · line 1028
Quoted 13 lines
sound/pci/hda/hda_intel.c +2
-0*dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip;struct hda_intel *hda; +struct hdac_bus *bus;if (!card)return 0 ; chip = card->private_data; hda = container_of(chip, struct hda_intel, chip); + bus =azx_bus (chip);if (chip->disabled || hda->init_failed || !chip->running)I mean we don't need '!chip->running' either. Otherwise, initialization may be interrupted.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
!chip->running condition comes from patch 1/2 and is needed to avoid race with async probe. Are you saying we don't need patch 1/2?
Do you mean removing patch 1/2 will cause race?
Yes. PM ops could trigger before
azx_probe_continuefinishes which results in a NULL deref kernel crash.
If so, agree with Takashi's comment's on the first patch, we can return -EBUSY for this case.
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
sound/pci/hda/hda_intel.c static int azx_runtime_idle(struct device *dev)
Quoted 7 lines
sound/pci/hda/hda_intel.c +0
-0return 0 ; if (!power_save_controller|| !azx_has_pm_runtime(chip) || > > > > - azx_bus(chip)->codec_powered) > > > > + bus->codec_powered || !bus->chip_init) > > > > return -EBUSY;Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
sound/pci/hda/hda_intel.c +0
-1return 0 ; --1.9.3