Received: by 10.223.185.111 with SMTP id b44csp90646wrg; Fri, 9 Mar 2018 01:31:32 -0800 (PST) X-Google-Smtp-Source: AG47ELt8kx36zXQsg/hixjk/pbuBTSZRynMZJT0ISV8ey3XcdBuLFtJqu5Sssh3SMmbjJ9azeymr X-Received: by 2002:a17:902:2de4:: with SMTP id p91-v6mr27278858plb.405.1520587892681; Fri, 09 Mar 2018 01:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520587892; cv=none; d=google.com; s=arc-20160816; b=BUo2Qj6uvi/XxzbD3eioIlFk47Ot3XjT1L43yWvh4HJCLhVZenIpIuCWg7aZUhuiqa gZsEmSbBP8LF8wn7k1OMms7EvDaChcAac9q5cpPQG4eSc5Z/RTd/afA6cjiAEHZ6Uccu c78eq1BtLUjLlhkZIYQI5M/WyeCcy47S1c2KrNnpV1Qt6x07GpsahhF0LOv/qlEKYlDl aEYQ/icmVCQaicaHQ68bKXtridTLWGtm9KwSfuLGGlsVbD0fURoBrxzeGOfTZCu+/Dl5 VC1lLD2yjtBZ791EfG3d2HMrIp575RuG8Dz3TpX12gVDzgIjVUoqj29PYwu4XrA70pb0 VjsA== 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=6vWe1cVBvNz4tI+j+7OBmpLtRhJHdq+P4NYan8736j0=; b=tvZ8uOi9L99RCwtDc0gl/ziHwRJi/ldP8aBf8pExZczoRjxaiW6XhekjQwbT5Wdvj5 fdYQ4sZ8wv6xvrXbNL3BkaqBs9vvhFG3WA7Nd8FGbdl1BYCyTrnKGS2VQc7AwDIJgB9E A/lyBeU5el9RiMUIjNCrI854jBOdh9+bgF2+8eNI6nSy+d6l8SP41Vx6Tnv1XSyN50BP C44cQX5IQjsqGQiss2DamjRubL6UvGz/qZ1PmE9n+9zFyfPTmglQK+9XQ0zNuJ2lIAV8 LoKBLi8ER5CUAbO2WVKyhK/Vr2R/LmTfaag/w0LdVmSBT08Z70zaXYKe8abyuL2b9xT/ pv7A== 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 p10si471719pgr.426.2018.03.09.01.31.18; Fri, 09 Mar 2018 01:31:32 -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 S1751200AbeCIJa0 (ORCPT + 99 others); Fri, 9 Mar 2018 04:30:26 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:40109 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbeCIJaY (ORCPT ); Fri, 9 Mar 2018 04:30:24 -0500 Received: from mail-pl0-f70.google.com ([209.85.160.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1euEM2-0005FK-J5 for linux-kernel@vger.kernel.org; Fri, 09 Mar 2018 09:30:22 +0000 Received: by mail-pl0-f70.google.com with SMTP id o61-v6so4268671pld.5 for ; Fri, 09 Mar 2018 01:30:22 -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=6vWe1cVBvNz4tI+j+7OBmpLtRhJHdq+P4NYan8736j0=; b=n1HLuk6BSBkW57feZ48Gx61px7ckqdFsQmNerAU4oOnWWcXFX+lZFZkpmz5BDv+3zE Ze5j1I3o5orQW+Vtl5jGGnLf4sHHezjUxshBUwGKfr68Ajo4rXcOFHsSmMDzessLWb0e vZqZLqXQdplZITIKmrIvqYUkwImIqzlDwk/Un3fnb/j9QDkqwsBjhCVAVCISkkY8Pm8s raPaWD9kHktKmva+tPy33ED0p+9IH7W3zgCVu2cbedRdQvKZrmTQs1Xf/hpezzwC8lHJ aou8qZEjHy8L4/fqQtCX6GAx0LnS+jC0I5BoLGNL6AFS8UjejinwRoQ+izcvYknAoazi aEgg== X-Gm-Message-State: APf1xPDBScVSsvovMAxRg+42zVTVgQM3zu8EWTdqGJCQQci8L9feR0VP xdveBJ+MDqoNwyvlogRvcl4+tbiVp/eT+Wyv7HIWJRArFtuwMiulEsBFZp6QOZ++rEmoyWS4cfT +/9+m/uHAi89KrFg5m5/tDzTSQGhJdF7KW3GEAxTfAw== X-Received: by 10.99.155.1 with SMTP id r1mr24249285pgd.422.1520587821201; Fri, 09 Mar 2018 01:30:21 -0800 (PST) X-Received: by 10.99.155.1 with SMTP id r1mr24249266pgd.422.1520587820784; Fri, 09 Mar 2018 01:30:20 -0800 (PST) Received: from [10.101.46.95] ([175.41.48.77]) by smtp.gmail.com with ESMTPSA id k73sm2097753pfk.54.2018.03.09.01.30.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 01:30:20 -0800 (PST) Content-Type: text/plain; charset=utf-8; delsp=yes; format=flowed Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.15\)) Subject: Re: [PATCH v2 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics From: Kai Heng Feng In-Reply-To: <20180309090223.xb55ltac4pfesdrh@pali> Date: Fri, 9 Mar 2018 17:30:15 +0800 Cc: mjg59@srcf.ucam.org, dvhart@infradead.org, andy@infradead.org, Mario Limonciello , tiwai@suse.com, platform-driver-x86@vger.kernel.org, Linux Kernel Mailing List , alsa-devel@alsa-project.org Content-Transfer-Encoding: 8bit Message-Id: <723DA929-C9FA-4F69-8D3A-03D8A75D09A6@canonical.com> References: <20180308091023.9061-1-kai.heng.feng@canonical.com> <20180308091023.9061-3-kai.heng.feng@canonical.com> <20180309090223.xb55ltac4pfesdrh@pali> To: =?utf-8?Q?Pali_Roh=C3=A1r?= 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 9, 2018, at 5:02 PM, Pali Rohár wrote: > > On Thursday 08 March 2018 17:10:23 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! >> >> Since the discrete audio controller isn't useful when SG enabled, we >> should just disable the device. >> >> 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; > > Are you sure that you want to do this check unconditionally on all > machines which have enabled CONFIG_DELL_LAPTOP? > > Subvendor ID_DELL for dell specific code is not suspicious, but ID_ATI > is. What would happen if ATI vendor changes to NVIDIA or other which is > not related to Dell? We only check it when it's both ATI and DELL, otherwise just return false? The platform does have a NVIDIA variant, but the discrete NVIDIA have a audio controller, hence it doesn't have the issue. The issue only happens to AMD/ATI configs with "Switchable Graphics" option. > > Interesting question would be, how handle this situation Windows? I don't know how this platform handles this on Windows, I guess we need Mario to shed some lights here. Kai-Heng > >> + 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); > > -- > Pali Rohár > pali.rohar@gmail.com