Received: by 10.223.185.116 with SMTP id b49csp6150454wrg; Thu, 8 Mar 2018 02:40:01 -0800 (PST) X-Google-Smtp-Source: AG47ELu2cEnObRz+dzGtdQW9i49/SKV6xngdbuzW4UT/zZuyC+Shqc+8lW9DY8gM4r4AzqFUghaf X-Received: by 2002:a17:902:6985:: with SMTP id l5-v6mr24223773plk.14.1520505600995; Thu, 08 Mar 2018 02:40:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520505600; cv=none; d=google.com; s=arc-20160816; b=PhhNPPjG43mk1J2pj4c7TA33EsZryy0U0g0oGlWC670bI9GTD/xCSpIqGDB6l1C1Fl whiZFZP3Q2gHywOntGKmcxc+zJzdkOePkqr0MTiiXd6tQUg+lnuqe65l7cAcKhTgW4OQ Eu2a0GZ8g3epMy4cQeI1a2xMZ+Fx9OGKqf7sm0Lk/E6LHLPnI2Z/q4f9DADUfNKUU/r+ Sz/jhh2vqd2AK8fYRuUc8FkjULQlMuu+14uNkmv+GOJWtNdB0b/SrNrhFHDB+gf9E5WG EiziXPAO9v/fGBLwsIyIopQMIaCLzK9sHMbpROqdbMzoaW0PVqLWT0GKLKaqS8/AwAuH fmsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=RUQSl4QQxywAPj14cZkCy8hEsOELGKKDvU7MOLCVfWU=; b=0zqVEwPRzVh9iOyDA8uBSsJKdvnXt0F46Ac9cFLaR8pJZo+m4FNgBYXmxl1g9OcVQ4 jSuqL9xXwAbq5NRgbX/1K93S6OPI8SmGuH9uMAY55MzgupbXXAage/QaJS9/8qhps0w9 FKvgEix0td92gWVke5eJzEmzj8+Un1yI1+tX6AD2yJ94sJkDFRWFlFzlI+QAi5oTrXJI iTa/EQla36qbrcxCd1493SES91ivldo/RpSdzS0KBAryyOaCbXFYXQ7REoSgN6KzuO39 7FxRs7SiQIEaoriufo9aRzVIFuxd24A9FieM3ML5zfj+4W4bPgLc7p4eKSqtj5G1JIGV q1aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65si15748132pfj.354.2018.03.08.02.39.46; Thu, 08 Mar 2018 02:40:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965585AbeCHKiz (ORCPT + 99 others); Thu, 8 Mar 2018 05:38:55 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:47693 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934957AbeCHKix (ORCPT ); Thu, 8 Mar 2018 05:38:53 -0500 Received: from mail-pl0-f69.google.com ([209.85.160.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1etswm-0000GZ-1D for linux-kernel@vger.kernel.org; Thu, 08 Mar 2018 10:38:52 +0000 Received: by mail-pl0-f69.google.com with SMTP id z3-v6so2638231pln.23 for ; Thu, 08 Mar 2018 02:38:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RUQSl4QQxywAPj14cZkCy8hEsOELGKKDvU7MOLCVfWU=; b=TqyM+gEST1PwZB+U6nnoORcJgbdPZd07faurhhL2GX2z8HoFAmyXk1LmPTjuvaRgwa MFkJO/ujPuGhoRwkle75f2Wt/rXXFx2AmXLdA/ld6Iqc8ZjqOJj9pu2ny3Cg/1c2bXKi 5SPCM/VIt2Udqq11GhOp8e5E7PN2kUxs5tTiXYJm6oiKgz7jNsCAdVZXiKYI2jQQgDzD zn9b3VbRrGLJwSg5A+mf4BRxrUKrdp+v7L2CT8mMBJNS+H749NlbYXw450xLvXi0qXLE Cpd5A7OeaC8rJgdiJKyAOFG6bc9cDabk5f6wmNF9I6ui82ye3H0ZFD+rRSdmaU5eET78 maLg== X-Gm-Message-State: APf1xPAfAlZGALgLvl6LXD2bjlo4lkvuhmvB6/KUjhsxz0vJqv/i65rS EbM+XASnaFKjmaF+PamDhblex13HQNJB2WzDI8zXMBRcs07TqnRh8nbCnM8M1+YQqXE9A5T/t2/ zDL/f6WpT3mAmZePyw/yj0Wdcno/3464v/qp4ZUNqNw== X-Received: by 2002:a17:902:bd05:: with SMTP id p5-v6mr23443023pls.137.1520505530630; Thu, 08 Mar 2018 02:38:50 -0800 (PST) X-Received: by 2002:a17:902:bd05:: with SMTP id p5-v6mr23443008pls.137.1520505530050; Thu, 08 Mar 2018 02:38:50 -0800 (PST) Received: from [10.101.46.95] ([175.41.48.77]) by smtp.gmail.com with ESMTPSA id v144sm9390410pgb.63.2018.03.08.02.38.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 02:38:49 -0800 (PST) Content-Type: text/plain; charset=us-ascii; delsp=yes; format=flowed Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.15\)) Subject: Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics From: Kai Heng Feng In-Reply-To: <20180308093848.GA24068@wunner.de> Date: Thu, 8 Mar 2018 18:38:45 +0800 Cc: mjg59@srcf.ucam.org, pali.rohar@gmail.com, dvhart@infradead.org, andy@infradead.org, Mario Limonciello , tiwai@suse.com, alsa-devel@alsa-project.org, Linux Kernel Mailing List , platform-driver-x86@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <1A1B9259-DC5B-4C1A-96BD-7FCACDBFFBB3@canonical.com> References: <20180308091023.9061-1-kai.heng.feng@canonical.com> <20180308091023.9061-3-kai.heng.feng@canonical.com> <20180308093848.GA24068@wunner.de> To: Lukas Wunner X-Mailer: Apple Mail (2.3445.6.15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 8, 2018, at 5:38 PM, Lukas Wunner wrote: > > On Thu, Mar 08, 2018 at 05:10:23PM +0800, Kai-Heng Feng 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 controller still exposes its >> sysfs, so userspace still opens the control file and stream. If >> userspace tries to output sound through the stream, it hangs when >> runtime suspend kicks in: >> [ 12.796265] snd_hda_intel 0000:01:00.1: Disabling via vga_switcheroo >> [ 12.796367] snd_hda_intel 0000:01:00.1: Cannot lock devices! > > This should be fixed by the following series: > https://lists.freedesktop.org/archives/dri-devel/2018-March/168012.html > > Please verify that by testing the series on the machine in question. > I'm hoping to get those patches in for 4.17. I suspect that your > patch may not be necessary then. I no longer see the warning message with your patch. Thanks! > > >> Since the discrete audio controller isn't useful when SG enabled, we >> should just disable the device. > > I don't quite follow, when SG is enabled but hda_intel doesn't bind > to the AMD audio device, how are you going to stream audio to > external displays? Are external DP/HDMI ports muxed to the integrated > GPU when SG is enabled? Yes. It's a muxed port. The can directly output via integrated Intel GPU when SG is enabled. The discrete audio controller never gets used when SG is enabled. The unused discrete audio controller still gets opened by userspace: # lsof /dev/snd/controlC1 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME pulseaudi 965 gdm 18u CHR 116,2 0t0 17913 /dev/snd/controlC1 pulseaudi 1423 u 17u CHR 116,2 0t0 17913 /dev/snd/controlC1 pulseaudi 1423 u 24u CHR 116,2 0t0 17913 /dev/snd/controlC1 Also pcms: # ls /dev/snd/pcmC1* /dev/snd/pcmC1D10p /dev/snd/pcmC1D11p /dev/snd/pcmC1D3p /dev/snd/pcmC1D7p /dev/snd/pcmC1D8p /dev/snd/pcmC1D9p So I think my patch is still needed. > > Thanks, > > Lukas > >> Signed-off-by: Kai-Heng Feng >> --- >> v2: Mario suggested to squash the HDA part into the same series. >> >> sound/pci/hda/hda_intel.c | 35 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 35 insertions(+) >> >> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c >> index 96143df19b21..8e3e8b88624a 100644 >> --- a/sound/pci/hda/hda_intel.c >> +++ b/sound/pci/hda/hda_intel.c >> @@ -49,6 +49,7 @@ >> #include >> #include >> #include >> +#include >> >> #ifdef CONFIG_X86 >> /* for snoop control */ >> @@ -1620,6 +1621,35 @@ static void check_msi(struct azx *chip) >> } >> } >> >> +#if IS_ENABLED(CONFIG_DELL_LAPTOP) >> +static bool check_dell_switchable_gfx(struct pci_dev *pdev) >> +{ >> + static int (*dell_switchable_gfx_enabled_func)(bool *); >> + bool enabled; >> + int err; >> + >> + if (pdev->vendor != PCI_VENDOR_ID_ATI || >> + pdev->subsystem_vendor != PCI_VENDOR_ID_DELL) >> + return false; >> + >> + dell_switchable_gfx_enabled_func = >> + symbol_request(dell_switchable_gfx_enabled); >> + if (!dell_switchable_gfx_enabled_func) >> + return false; >> + >> + err = dell_switchable_gfx_enabled_func(&enabled); >> + >> + symbol_put(dell_switchable_gfx_enabled); >> + >> + return !err ? enabled : false; >> +} >> +#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) >> { >> @@ -1702,6 +1732,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); >> -- >> 2.15.1 >> >> _______________________________________________ >> Alsa-devel mailing list >> Alsa-devel@alsa-project.org >> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel