Skip to content

Commit dba9b7b

Browse files
committed
ALSA: hda - Fix doubly initialization of i915 component
In the commit fcc88d9 ("ALSA: hda - Bind with i915 component before codec binding"), the binding with i915 audio component is moved to be performed always at probing the controller. This fixed the potential problems on IVB, but now it brought another issue on HSW and BDW. These two platforms give two individual HD-audio controllers, one for the analog codec on PCH and another for HDMI over gfx. Since I decided to take a lazy path to check only AZX_DRIVER_PCH type in the commit above, now both controllers try to bind with i915, and you see a kernel WARNING. This patch tries to address it again properly. Now a new DCAPS bit, AZX_DCAPS_I915_COMPONENT, is introduced for indicating the binding with i915 component in addition to the existing I915_POWERWELL bit flag. Each PCI entry has to give this new flag if it requires the binding with i915 component. For HSW/BDW PCH (i.e. the ones defined by AZX_DCAPS_INTEL_PCH) doesn't contain AZX_DCAPS_I915_COMPONENT bit while others have it. While we're at it, add parentheses around the bit flag check for avoiding possible compiler warnings, too. The bug was spotted by Intel CI tests. Fixes: fcc88d9 ("ALSA: hda - Bind with i915 component before codec binding") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196219 Reported-by: Martin Peres <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent a5a041b commit dba9b7b

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

sound/pci/hda/hda_controller.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
#define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */
3333
#define AZX_DCAPS_SNOOP_MASK (3 << 10) /* snoop type mask */
3434
#define AZX_DCAPS_SNOOP_OFF (1 << 12) /* snoop default off */
35-
/* 13 unused */
35+
#ifdef CONFIG_SND_HDA_I915
36+
#define AZX_DCAPS_I915_COMPONENT (1 << 13) /* bind with i915 gfx */
37+
#else
38+
#define AZX_DCAPS_I915_COMPONENT 0 /* NOP */
39+
#endif
3640
/* 14 unused */
3741
#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
3842
#define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */

sound/pci/hda/hda_intel.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -293,38 +293,43 @@ enum {
293293
(AZX_DCAPS_NO_ALIGN_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
294294
AZX_DCAPS_SNOOP_TYPE(SCH))
295295

296-
/* PCH up to IVB; no runtime PM */
296+
/* PCH up to IVB; no runtime PM; bind with i915 gfx */
297297
#define AZX_DCAPS_INTEL_PCH_NOPM \
298-
(AZX_DCAPS_INTEL_PCH_BASE)
298+
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_I915_COMPONENT)
299299

300300
/* PCH for HSW/BDW; with runtime PM */
301+
/* no i915 binding for this as HSW/BDW has another controller for HDMI */
301302
#define AZX_DCAPS_INTEL_PCH \
302303
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME)
303304

304305
/* HSW HDMI */
305306
#define AZX_DCAPS_INTEL_HASWELL \
306307
(/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_COUNT_LPIB_DELAY |\
307-
AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
308-
AZX_DCAPS_SNOOP_TYPE(SCH))
308+
AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\
309+
AZX_DCAPS_I915_POWERWELL | AZX_DCAPS_SNOOP_TYPE(SCH))
309310

310311
/* Broadwell HDMI can't use position buffer reliably, force to use LPIB */
311312
#define AZX_DCAPS_INTEL_BROADWELL \
312313
(/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_POSFIX_LPIB |\
313-
AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
314-
AZX_DCAPS_SNOOP_TYPE(SCH))
314+
AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\
315+
AZX_DCAPS_I915_POWERWELL | AZX_DCAPS_SNOOP_TYPE(SCH))
315316

316317
#define AZX_DCAPS_INTEL_BAYTRAIL \
317-
(AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_I915_POWERWELL)
318+
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_I915_COMPONENT |\
319+
AZX_DCAPS_I915_POWERWELL)
318320

319321
#define AZX_DCAPS_INTEL_BRASWELL \
320-
(AZX_DCAPS_INTEL_PCH | AZX_DCAPS_I915_POWERWELL)
322+
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME |\
323+
AZX_DCAPS_I915_COMPONENT | AZX_DCAPS_I915_POWERWELL)
321324

322325
#define AZX_DCAPS_INTEL_SKYLAKE \
323-
(AZX_DCAPS_INTEL_PCH | AZX_DCAPS_SEPARATE_STREAM_TAG |\
326+
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME |\
327+
AZX_DCAPS_SEPARATE_STREAM_TAG | AZX_DCAPS_I915_COMPONENT |\
324328
AZX_DCAPS_I915_POWERWELL)
325329

326330
#define AZX_DCAPS_INTEL_BROXTON \
327-
(AZX_DCAPS_INTEL_PCH | AZX_DCAPS_SEPARATE_STREAM_TAG |\
331+
(AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME |\
332+
AZX_DCAPS_SEPARATE_STREAM_TAG | AZX_DCAPS_I915_COMPONENT |\
328333
AZX_DCAPS_I915_POWERWELL)
329334

330335
/* quirks for ATI SB / AMD Hudson */
@@ -1008,7 +1013,7 @@ static int azx_suspend(struct device *dev)
10081013

10091014
if (chip->msi)
10101015
pci_disable_msi(chip->pci);
1011-
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL
1016+
if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
10121017
&& hda->need_i915_power)
10131018
snd_hdac_display_power(bus, false);
10141019

@@ -1114,7 +1119,7 @@ static int azx_runtime_suspend(struct device *dev)
11141119
azx_stop_chip(chip);
11151120
azx_enter_link_reset(chip);
11161121
azx_clear_irq_pending(chip);
1117-
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL
1122+
if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
11181123
&& hda->need_i915_power)
11191124
snd_hdac_display_power(azx_bus(chip), false);
11201125

@@ -1380,8 +1385,7 @@ static int azx_free(struct azx *chip)
13801385
if (hda->need_i915_power)
13811386
snd_hdac_display_power(bus, false);
13821387
}
1383-
if (chip->driver_type == AZX_DRIVER_PCH ||
1384-
(chip->driver_caps & AZX_DCAPS_I915_POWERWELL))
1388+
if (chip->driver_type & AZX_DCAPS_I915_COMPONENT)
13851389
snd_hdac_i915_exit(bus);
13861390
kfree(hda);
13871391

@@ -2199,8 +2203,7 @@ static int azx_probe_continue(struct azx *chip)
21992203
hda->probe_continued = 1;
22002204

22012205
/* bind with i915 if needed */
2202-
if (chip->driver_type == AZX_DRIVER_PCH ||
2203-
(chip->driver_caps & AZX_DCAPS_I915_POWERWELL)) {
2206+
if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) {
22042207
err = snd_hdac_i915_init(bus);
22052208
if (err < 0) {
22062209
/* if the controller is bound only with HDMI/DP
@@ -2214,7 +2217,8 @@ static int azx_probe_continue(struct azx *chip)
22142217
goto out_free;
22152218
} else {
22162219
/* don't bother any longer */
2217-
chip->driver_caps &= ~AZX_DCAPS_I915_POWERWELL;
2220+
chip->driver_caps &=
2221+
~(AZX_DCAPS_I915_COMPONENT | AZX_DCAPS_I915_POWERWELL);
22182222
}
22192223
}
22202224
}
@@ -2279,7 +2283,7 @@ static int azx_probe_continue(struct azx *chip)
22792283
pm_runtime_put_autosuspend(&pci->dev);
22802284

22812285
out_free:
2282-
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL
2286+
if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
22832287
&& !hda->need_i915_power)
22842288
snd_hdac_display_power(bus, false);
22852289

0 commit comments

Comments
 (0)