diff mbox

[v4,3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics

Message ID 20180420094432.13133-3-kai.heng.feng@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kai-Heng Feng April 20, 2018, 9:44 a.m. UTC
Some Dell platforms (Preicsion 7510/7710/7520/7720) have a BIOS option
"Switchable Graphics" (SG).

When SG is enabled, we have:
00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)
00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc.  [AMD/ATI] Ellesmere [Polaris10]
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

The Intel Audio outputs all the sound, including HDMI audio. The audio
controller comes with AMD graphics doesn't get used.

When SG is disabled, we have:
00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc.  [AMD/ATI] Ellesmere [Polaris10]
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]

Now it's a typical discrete-only system. HDMI audio comes from AMD audio
controller, others from Intel audio controller.

When SG is enabled, the unused AMD audio contoller still exposes its
sysfs, so userspace still opens the control file and stream. If
userspace tries to output sound through the stream, it hangs the system.

Since the discrete audio controller isn't useful when SG is enabled, we
should just disable the device.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v4: Change the commit message to clarify there's no more runtime pm
    warning.
    Also skip the check for thunderbolt attached devices.

v3: Simplify dell_switchable_gfx_is_enabled() by returning bool instead
    of error code.
    Use DMI_DEV_TYPE_OEM_STRING to match Dell System.

v2: Mario suggested to squash the HDA part into the same series.

 sound/pci/hda/hda_intel.c | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

Comments

Takashi Iwai April 20, 2018, 12:10 p.m. UTC | #1
On Fri, 20 Apr 2018 11:44:32 +0200,
Kai-Heng Feng wrote:
> 
> Now it's a typical discrete-only system. HDMI audio comes from AMD audio
> controller, others from Intel audio controller.
> 
> When SG is enabled, the unused AMD audio contoller still exposes its
> sysfs, so userspace still opens the control file and stream. If
> userspace tries to output sound through the stream, it hangs the system.

Hm, could you give more information about how it hangs?


> @@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
>  	}
>  }
>  
> +#if IS_ENABLED(CONFIG_DELL_LAPTOP)

This should be IS_REACHABLE(), as both dell-laptop and HD-audio are
tristate.

> +static bool check_dell_switchable_gfx(struct pci_dev *pdev)

I'd remove "_dell" word here.  Such a check would be likely needed for
other vendors, and it's quite possible that the function will be
extended to cover a wider DMI table.


thanks,

Takashi
Kai-Heng Feng April 23, 2018, 8:04 a.m. UTC | #2
> On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
>
> On Fri, 20 Apr 2018 11:44:32 +0200,
> Kai-Heng Feng wrote:
>> Now it's a typical discrete-only system. HDMI audio comes from AMD audio
>> controller, others from Intel audio controller.
>>
>> When SG is enabled, the unused AMD audio contoller still exposes its
>> sysfs, so userspace still opens the control file and stream. If
>> userspace tries to output sound through the stream, it hangs the system.
>
> Hm, could you give more information about how it hangs?

Well, I should say "it hangs the userspace process" instead.

$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
...and it just stopped. Can't Ctrl+C to break it.

>
>
>> @@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
>>  	}
>>  }
>>
>> +#if IS_ENABLED(CONFIG_DELL_LAPTOP)
>
> This should be IS_REACHABLE(), as both dell-laptop and HD-audio are
> tristate.

Thanks, will update in next version.

>
>> +static bool check_dell_switchable_gfx(struct pci_dev *pdev)
>
> I'd remove "_dell" word here.  Such a check would be likely needed for
> other vendors, and it's quite possible that the function will be
> extended to cover a wider DMI table.

Makes sense. Will also update this one.

Kai-Heng

>
>
> thanks,
>
> Takashi
Pali Rohár April 23, 2018, 8:08 a.m. UTC | #3
On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
> 
> 
> > On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > 
> > On Fri, 20 Apr 2018 11:44:32 +0200,
> > Kai-Heng Feng wrote:
> > > Now it's a typical discrete-only system. HDMI audio comes from AMD audio
> > > controller, others from Intel audio controller.
> > > 
> > > When SG is enabled, the unused AMD audio contoller still exposes its
> > > sysfs, so userspace still opens the control file and stream. If
> > > userspace tries to output sound through the stream, it hangs the system.
> > 
> > Hm, could you give more information about how it hangs?
> 
> Well, I should say "it hangs the userspace process" instead.
> 
> $ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
> ...and it just stopped. Can't Ctrl+C to break it.

So userspace process cannot be killed at all? Then it is different bug
in kernel and disabling pci device is just a workaround. Not a real fix.

I would propose to find out what happen and why it cannot be killed
(probably it stuck somewhere in kernel) and fix it properly.

> > 
> > 
> > > @@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
> > >  	}
> > >  }
> > > 
> > > +#if IS_ENABLED(CONFIG_DELL_LAPTOP)
> > 
> > This should be IS_REACHABLE(), as both dell-laptop and HD-audio are
> > tristate.
> 
> Thanks, will update in next version.
> 
> > 
> > > +static bool check_dell_switchable_gfx(struct pci_dev *pdev)
> > 
> > I'd remove "_dell" word here.  Such a check would be likely needed for
> > other vendors, and it's quite possible that the function will be
> > extended to cover a wider DMI table.
> 
> Makes sense. Will also update this one.
> 
> Kai-Heng
> 
> > 
> > 
> > thanks,
> > 
> > Takashi
Kai-Heng Feng April 23, 2018, 8:18 a.m. UTC | #4
> On Apr 23, 2018, at 4:08 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
>
> On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
>>> On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
>>>
>>> On Fri, 20 Apr 2018 11:44:32 +0200,
>>> Kai-Heng Feng wrote:
>>>> Now it's a typical discrete-only system. HDMI audio comes from AMD audio
>>>> controller, others from Intel audio controller.
>>>>
>>>> When SG is enabled, the unused AMD audio contoller still exposes its
>>>> sysfs, so userspace still opens the control file and stream. If
>>>> userspace tries to output sound through the stream, it hangs the system.
>>>
>>> Hm, could you give more information about how it hangs?
>>
>> Well, I should say "it hangs the userspace process" instead.
>>
>> $ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
>> ...and it just stopped. Can't Ctrl+C to break it.
>
> So userspace process cannot be killed at all? Then it is different bug
> in kernel and disabling pci device is just a workaround. Not a real fix.
>
> I would propose to find out what happen and why it cannot be killed
> (probably it stuck somewhere in kernel) and fix it properly.

That's because the audio device got runtime suspended by the graphics.

In this case, if we really want to use the the discrete audio, then we also  
need to wake up the graphics.
The discrete audio is totally useless when SG is enabled, so my approach is  
just to disable it.

Kai-Heng

>
>>>> @@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
>>>>  	}
>>>>  }
>>>>
>>>> +#if IS_ENABLED(CONFIG_DELL_LAPTOP)
>>>
>>> This should be IS_REACHABLE(), as both dell-laptop and HD-audio are
>>> tristate.
>>
>> Thanks, will update in next version.
>>
>>>> +static bool check_dell_switchable_gfx(struct pci_dev *pdev)
>>>
>>> I'd remove "_dell" word here.  Such a check would be likely needed for
>>> other vendors, and it's quite possible that the function will be
>>> extended to cover a wider DMI table.
>>
>> Makes sense. Will also update this one.
>>
>> Kai-Heng
>>
>>> thanks,
>>>
>>> Takashi
>
> -- 
> Pali Rohár
> pali.rohar@gmail.com
Pali Rohár April 23, 2018, 8:29 a.m. UTC | #5
On Monday 23 April 2018 16:18:35 Kai Heng Feng wrote:
> 
> 
> > On Apr 23, 2018, at 4:08 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
> > 
> > On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
> > > > On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > > > 
> > > > On Fri, 20 Apr 2018 11:44:32 +0200,
> > > > Kai-Heng Feng wrote:
> > > > > Now it's a typical discrete-only system. HDMI audio comes from AMD audio
> > > > > controller, others from Intel audio controller.
> > > > > 
> > > > > When SG is enabled, the unused AMD audio contoller still exposes its
> > > > > sysfs, so userspace still opens the control file and stream. If
> > > > > userspace tries to output sound through the stream, it hangs the system.
> > > > 
> > > > Hm, could you give more information about how it hangs?
> > > 
> > > Well, I should say "it hangs the userspace process" instead.
> > > 
> > > $ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
> > > ...and it just stopped. Can't Ctrl+C to break it.
> > 
> > So userspace process cannot be killed at all? Then it is different bug
> > in kernel and disabling pci device is just a workaround. Not a real fix.
> > 
> > I would propose to find out what happen and why it cannot be killed
> > (probably it stuck somewhere in kernel) and fix it properly.
> 
> That's because the audio device got runtime suspended by the graphics.
> 
> In this case, if we really want to use the the discrete audio, then we also
> need to wake up the graphics.
> The discrete audio is totally useless when SG is enabled, so my approach is
> just to disable it.

I'm not saying that disabling PCI should not be done.

I'm saying that if userspace process which opened that audio device
cannot be killed, then you found different kernel bug and that should be
fixed.

> Kai-Heng
> 
> > 
> > > > > @@ -1627,6 +1629,42 @@ static void check_msi(struct azx *chip)
> > > > >  	}
> > > > >  }
> > > > > 
> > > > > +#if IS_ENABLED(CONFIG_DELL_LAPTOP)
> > > > 
> > > > This should be IS_REACHABLE(), as both dell-laptop and HD-audio are
> > > > tristate.
> > > 
> > > Thanks, will update in next version.
> > > 
> > > > > +static bool check_dell_switchable_gfx(struct pci_dev *pdev)
> > > > 
> > > > I'd remove "_dell" word here.  Such a check would be likely needed for
> > > > other vendors, and it's quite possible that the function will be
> > > > extended to cover a wider DMI table.
> > > 
> > > Makes sense. Will also update this one.
> > > 
> > > Kai-Heng
> > > 
> > > > thanks,
> > > > 
> > > > Takashi
> > 
> > -- 
> > Pali Rohár
> > pali.rohar@gmail.com
Andy Shevchenko April 23, 2018, 1:52 p.m. UTC | #6
On Fri, Apr 20, 2018 at 12:44 PM, Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
> Some Dell platforms (Preicsion 7510/7710/7520/7720) have a BIOS option
> "Switchable Graphics" (SG).
>
> When SG is enabled, we have:
> 00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)
> 00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)
> 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc.  [AMD/ATI] Ellesmere [Polaris10]
> 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]
>
> The Intel Audio outputs all the sound, including HDMI audio. The audio
> controller comes with AMD graphics doesn't get used.
>
> When SG is disabled, we have:
> 00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)
> 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc.  [AMD/ATI] Ellesmere [Polaris10]
> 01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580]
>
> Now it's a typical discrete-only system. HDMI audio comes from AMD audio
> controller, others from Intel audio controller.
>
> When SG is enabled, the unused AMD audio contoller still exposes its
> sysfs, so userspace still opens the control file and stream. If
> userspace tries to output sound through the stream, it hangs the system.
>
> Since the discrete audio controller isn't useful when SG is enabled, we
> should just disable the device.

> +static bool check_dell_switchable_gfx(struct pci_dev *pdev)

Yeah, as following existing naming scheme in the driver
(check_hdmi_disabled(), for example)
I would rather call it similar:

check_switchable_gfx_enabled()

> +{
> +       bool (*dell_switchable_gfx_is_enabled_func)(void);
> +       bool enabled;
> +
> +       /* Thunderbolt devices won't be switchable */
> +       if (pci_is_thunderbolt_attached(pdev))
> +               return false;
> +
> +       /* Only check for Dell laptops and AIOs */

> +       if (!dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL) ||
> +           !(dmi_match(DMI_CHASSIS_TYPE, "10") ||
> +             dmi_match(DMI_CHASSIS_TYPE, "13")) ||

Can't we do it in more flexible way, i.e. using struct dmi_system_id
table and dmi_check_system() ?

> +           !(pdev->vendor == PCI_VENDOR_ID_ATI ||
> +             pdev->vendor == PCI_VENDOR_ID_NVIDIA))
> +               return false;

I would rather split DMI and PCI checks.

> +
> +       dell_switchable_gfx_is_enabled_func =
> +               symbol_request(dell_switchable_gfx_is_enabled);
> +       if (!dell_switchable_gfx_is_enabled_func)
> +               return false;
> +
> +       enabled = dell_switchable_gfx_is_enabled_func();
> +
> +       symbol_put(dell_switchable_gfx_is_enabled);
> +
> +       return enabled;
> +}
> +#else
> +static bool check_dell_switchable_gfx(struct pci_dev *pdev)

inline

> +{
> +       return false;
> +}
> +#endif
Lukas Wunner April 24, 2018, 9:13 p.m. UTC | #7
On Mon, Apr 23, 2018 at 04:18:35PM +0800, Kai Heng Feng wrote:
> >On Apr 23, 2018, at 4:08 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
> >On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
> >>>On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
> >>>On Fri, 20 Apr 2018 11:44:32 +0200, Kai-Heng Feng wrote:
> >>>>Now it's a typical discrete-only system. HDMI audio comes from AMD audio
> >>>>controller, others from Intel audio controller.
> >>>>
> >>>>When SG is enabled, the unused AMD audio contoller still exposes its
> >>>>sysfs, so userspace still opens the control file and stream. If
> >>>>userspace tries to output sound through the stream, it hangs the system.
> >>>
> >>>Hm, could you give more information about how it hangs?
> >>
> >>Well, I should say "it hangs the userspace process" instead.
> >>
> >>$ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
> >>...and it just stopped. Can't Ctrl+C to break it.
> >
> >So userspace process cannot be killed at all? Then it is different bug
> >in kernel and disabling pci device is just a workaround. Not a real fix.
> >
> >I would propose to find out what happen and why it cannot be killed
> >(probably it stuck somewhere in kernel) and fix it properly.
> 
> That's because the audio device got runtime suspended by the graphics.
> 
> In this case, if we really want to use the the discrete audio, then we also
> need to wake up the graphics.
> The discrete audio is totally useless when SG is enabled, so my approach is
> just to disable it.

I don't quite follow, that should be fixed by commit 07f4f97d7b4b
("vga_switcheroo: Use device link for HDA controller") which landed
in v4.17-rc1.

My understanding was that with SG enabled, the external DP/HDMI ports
are muxed to the Intel GPU, so audio can only be streamed to external
displays by the Intel HDA, not by the HDA integrated into the discrete
AMD/Nvidia GPU.  Audio streamed to the latter would essentially end up
in a blackhole.  And preventing the user from seeing such useless audio
devices was the sole purpose of this commit.  Am I missing something?

Thanks,

Lukas
Kai-Heng Feng April 26, 2018, 7:52 a.m. UTC | #8
> On Apr 25, 2018, at 5:13 AM, Lukas Wunner <lukas@wunner.de> wrote:
>
> On Mon, Apr 23, 2018 at 04:18:35PM +0800, Kai Heng Feng wrote:
>>> On Apr 23, 2018, at 4:08 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
>>> On Monday 23 April 2018 16:04:55 Kai Heng Feng wrote:
>>>>> On Apr 20, 2018, at 8:10 PM, Takashi Iwai <tiwai@suse.de> wrote:
>>>>> On Fri, 20 Apr 2018 11:44:32 +0200, Kai-Heng Feng wrote:
>>>>>> Now it's a typical discrete-only system. HDMI audio comes from AMD  
>>>>>> audio
>>>>>> controller, others from Intel audio controller.
>>>>>>
>>>>>> When SG is enabled, the unused AMD audio contoller still exposes its
>>>>>> sysfs, so userspace still opens the control file and stream. If
>>>>>> userspace tries to output sound through the stream, it hangs the  
>>>>>> system.
>>>>>
>>>>> Hm, could you give more information about how it hangs?
>>>>
>>>> Well, I should say "it hangs the userspace process" instead.
>>>>
>>>> $ speaker-test -t wav -c 2 -D hw:CARD=HDMI,DEV=3
>>>> ...and it just stopped. Can't Ctrl+C to break it.
>>>
>>> So userspace process cannot be killed at all? Then it is different bug
>>> in kernel and disabling pci device is just a workaround. Not a real fix.
>>>
>>> I would propose to find out what happen and why it cannot be killed
>>> (probably it stuck somewhere in kernel) and fix it properly.
>>
>> That's because the audio device got runtime suspended by the graphics.
>>
>> In this case, if we really want to use the the discrete audio, then we  
>> also
>> need to wake up the graphics.
>> The discrete audio is totally useless when SG is enabled, so my approach  
>> is
>> just to disable it.
>
> I don't quite follow, that should be fixed by commit 07f4f97d7b4b
> ("vga_switcheroo: Use device link for HDA controller") which landed
> in v4.17-rc1.

Looks like I hit a new bug: the discrete GFX and its audio controller never  
enters to D3.
The GFX can enter to D3 with my prosed patch.

>
> My understanding was that with SG enabled, the external DP/HDMI ports
> are muxed to the Intel GPU, so audio can only be streamed to external
> displays by the Intel HDA, not by the HDA integrated into the discrete
> AMD/Nvidia GPU.  Audio streamed to the latter would essentially end up
> in a blackhole.  And preventing the user from seeing such useless audio
> devices was the sole purpose of this commit.  Am I missing something?

Yes this is the intention.

Kai-Heng

>
> Thanks,
>
> Lukas
Lukas Wunner May 2, 2018, 7:44 a.m. UTC | #9
On Thu, Apr 26, 2018 at 03:52:08PM +0800, Kai Heng Feng wrote:
> > On Apr 25, 2018, at 5:13 AM, Lukas Wunner <lukas@wunner.de> wrote:
> > On Mon, Apr 23, 2018 at 04:18:35PM +0800, Kai Heng Feng wrote:
> > > That's because the audio device got runtime suspended by the graphics.
> > >
> > > In this case, if we really want to use the the discrete audio,
> > > then we also need to wake up the graphics.
> > > The discrete audio is totally useless when SG is enabled,
> > > so my approach is just to disable it.
> >
> > I don't quite follow, that should be fixed by commit 07f4f97d7b4b
> > ("vga_switcheroo: Use device link for HDA controller") which landed
> > in v4.17-rc1.
> 
> Looks like I hit a new bug: the discrete GFX and its audio controller
> never enters to D3.
> The GFX can enter to D3 with my prosed patch.

Can you find out why?  Does the HDA controller have a codec as child
device that doesn't runtime suspend, perhaps because it failed to
initialize correctly?  If a codec device fails to runtime suspend,
the HDA controller (as parent) and by extension the GPU (via the
device link) are also kept runtime active.

Do you see anything in dmesg when the AMD HDA controller probes?
If you look in /sys/bus/pci/devices/0000:01:00.1/power/, does the
HDA controller have active kids and what is its usage count?


> > My understanding was that with SG enabled, the external DP/HDMI ports
> > are muxed to the Intel GPU, so audio can only be streamed to external
> > displays by the Intel HDA, not by the HDA integrated into the discrete
> > AMD/Nvidia GPU.  Audio streamed to the latter would essentially end up
> > in a blackhole.  And preventing the user from seeing such useless audio
> > devices was the sole purpose of this commit.  Am I missing something?
> 
> Yes this is the intention.

Could you add this information to the commit message then?

Thanks,

Lukas
diff mbox

Patch

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 7a111a1b5836..3981193c8d29 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -49,6 +49,8 @@ 
 #include <linux/clocksource.h>
 #include <linux/time.h>
 #include <linux/completion.h>
+#include <linux/dell-common.h>
+#include <linux/dmi.h>
 
 #ifdef CONFIG_X86
 /* for snoop control */
@@ -1627,6 +1629,42 @@  static void check_msi(struct azx *chip)
 	}
 }
 
+#if IS_ENABLED(CONFIG_DELL_LAPTOP)
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)
+{
+	bool (*dell_switchable_gfx_is_enabled_func)(void);
+	bool enabled;
+
+	/* Thunderbolt devices won't be switchable */
+	if (pci_is_thunderbolt_attached(pdev))
+		return false;
+
+	/* Only check for Dell laptops and AIOs */
+	if (!dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL) ||
+	    !(dmi_match(DMI_CHASSIS_TYPE, "10") ||
+	      dmi_match(DMI_CHASSIS_TYPE, "13")) ||
+	    !(pdev->vendor == PCI_VENDOR_ID_ATI ||
+	      pdev->vendor == PCI_VENDOR_ID_NVIDIA))
+		return false;
+
+	dell_switchable_gfx_is_enabled_func =
+		symbol_request(dell_switchable_gfx_is_enabled);
+	if (!dell_switchable_gfx_is_enabled_func)
+		return false;
+
+	enabled = dell_switchable_gfx_is_enabled_func();
+
+	symbol_put(dell_switchable_gfx_is_enabled);
+
+	return enabled;
+}
+#else
+static bool check_dell_switchable_gfx(struct pci_dev *pdev)
+{
+	return false;
+}
+#endif
+
 /* check the snoop mode availability */
 static void azx_check_snoop_available(struct azx *chip)
 {
@@ -1709,6 +1747,11 @@  static int azx_create(struct snd_card *card, struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
+	if (check_dell_switchable_gfx(pci)) {
+		pci_disable_device(pci);
+		return -ENODEV;
+	}
+
 	hda = kzalloc(sizeof(*hda), GFP_KERNEL);
 	if (!hda) {
 		pci_disable_device(pci);