Received: by 10.192.165.148 with SMTP id m20csp3453121imm; Mon, 23 Apr 2018 06:53:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx49+bFrhBignF67RqYhICUwATTwqQUsFdKo3ByqbADysikgIPi9BB0+Q+y5EOLxiqaXf88Qv X-Received: by 10.98.131.69 with SMTP id h66mr10213386pfe.0.1524491639650; Mon, 23 Apr 2018 06:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524491639; cv=none; d=google.com; s=arc-20160816; b=tGC+wKPVaQ8GJ52kAFN7AuGB8Mfa1rQokQAnSVqJqpJe0DqB/g9Gyhf/P9gj2d0sLS kFXej2VmTtWQjWFFJgNnYyn/QR/dK9Ny9O/GZPtVYwUW3/9WKv9PuxXp7ooV88x7kCNe OKhNHKm9H+UA5P6pSXR9JPzHzNyVbBg/c4U3RENg8RFc0Mhk1r59lS4jr9O13nPJ2W/D +SMxFTO6om88DIKjuLznIp5UmAbRVGYUm5EWniXS8P0YJyC52Oqwjyz/x+t45rTP1FAX yW9tQgQ9HNG4Ztt2ArVN1joVmdB9Q0BxHWcz0sSLfkK3VDPd96ObFecyHJ3Hl9NtzRLk DyUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=vAZPD5iVX3RAczWiNioM8Wk+66HMHuTtgGrxwzTOdds=; b=hY6T9Qr3uzCYzumRzCoXbvkfsuBoBhz4mJk97cbHjRFYBHepmtUiNb4pZzXsCkgcWq pE99XSpNf9v9grABR8Z1GMBiR2IQnCdkyA3i6cM81cYHjbTtuqduDeoNF+YY/alQSUfO enHlf3JvB0/RGDjAkNVgqsNtsIBtv2mDzsVGybhJDGhpOaPVTrfwl3Ka16mCPfi8/v8c 8qCPZwsVvCWHf/y0thKQAEC11+EvE4rR1Bcmjx+N7KP2x9CDH9aUwFgXxpP4qHJHKI/3 B4RIp4B/xUUxoH3/NjLdKk9Lo8fFC4j4FRXl+tLvG0/Dhs/EPujcVfbvoZykCNW7ZQNr WVwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SPVQWws9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si10828814pff.43.2018.04.23.06.53.44; Mon, 23 Apr 2018 06:53:59 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SPVQWws9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755275AbeDWNwX (ORCPT + 99 others); Mon, 23 Apr 2018 09:52:23 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:46517 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754981AbeDWNwT (ORCPT ); Mon, 23 Apr 2018 09:52:19 -0400 Received: by mail-qt0-f195.google.com with SMTP id h4-v6so17664925qtn.13; Mon, 23 Apr 2018 06:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vAZPD5iVX3RAczWiNioM8Wk+66HMHuTtgGrxwzTOdds=; b=SPVQWws9uHm9FnHJ5QkrujpNMIGtPbCjb8Brf3u7P/yAmZRKwSliRzcpXgAz2xNtKT 8nCXwVS4VwiILr4hpUhZbGHiuzojVM4Xq5zsbooeZ3oh8gPWeh+Fq4u0N2TYpAqTEO3/ 8voqAOdpHhA5W46FuIop4THKRft9b8hDmarQJN2VOeqihz+I/Z0Wi7Wxef9vxLfqiHx1 ytrO37EXlHVW2MozKXCnu7COVcvyK6JlNzexYmxkQ3E5fL7PRAvRm3MOIeaTMDW1Gi5G 5eC3H7LcLV1Xdkr46uxfRzyF0iUmDM/rb9QPkVOljSqYmBgHoc52EeBjrIeyxxCJNu8S OCwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vAZPD5iVX3RAczWiNioM8Wk+66HMHuTtgGrxwzTOdds=; b=Ze4knXQsEvQV/h6RBTGPLVgHxmttS3oysZl0d1Gl6EendpDcoXDV/Ghnwp/iN6QQ2j vQiUtifrmvrcfszqOHMcyLlVsr21Y3b3V16BMTwboAzSkXLfVJuu0Mn/3IDmY9eWKzWf AJ8y8iP9rEcCAnGsTnwqSkAu/owsowIlSaWoJw1vBXFyehrReHlaNVex+darB6zGJeIp L2ei69YB2KvGmPHkO5a95mXb/sRd3Wcqvw46BmyWMoYd4Jn8q0eMBTfNajY4UtaAh7tB ft7ctjvftlaBTnCT5qeWQRN8O3oriC0bgXXBiUWjzZUZ2ZcSii30MoLjmB9ADfh3c+87 PH1Q== X-Gm-Message-State: ALQs6tCwTR6kAD6JDJMgxvsA6iBqBA+bujTWcJS+ZFMZGQo7kYHX+ba6 1WgTaiyf6dCLtoKfiEjRTJszJy5FaqN9ZiV4arY= X-Received: by 10.12.178.194 with SMTP id d2mr213745qvf.16.1524491539167; Mon, 23 Apr 2018 06:52:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.144.102 with HTTP; Mon, 23 Apr 2018 06:52:18 -0700 (PDT) In-Reply-To: <20180420094432.13133-3-kai.heng.feng@canonical.com> References: <20180420094432.13133-1-kai.heng.feng@canonical.com> <20180420094432.13133-3-kai.heng.feng@canonical.com> From: Andy Shevchenko Date: Mon, 23 Apr 2018 16:52:18 +0300 Message-ID: Subject: Re: [PATCH v4 3/3] ALSA: hda: Disabled unused audio controller for Dell platforms with Switchable Graphics To: Kai-Heng Feng Cc: Matthew Garrett , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Darren Hart , Andy Shevchenko , Mario Limonciello , Takashi Iwai , Platform Driver , Linux Kernel Mailing List , ALSA Development Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 12:44 PM, 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 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 -- With Best Regards, Andy Shevchenko