From patchwork Wed Jul 11 09:04:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 10519167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83F976032A for ; Wed, 11 Jul 2018 09:05:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 765FA28CFE for ; Wed, 11 Jul 2018 09:05:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 686F628E1E; Wed, 11 Jul 2018 09:05:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 013F128CFE for ; Wed, 11 Jul 2018 09:05:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43CF26EBB4; Wed, 11 Jul 2018 09:05:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 414996EBA5; Wed, 11 Jul 2018 09:04:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C5AFFAD3C; Wed, 11 Jul 2018 09:04:57 +0000 (UTC) Date: Wed, 11 Jul 2018 11:04:57 +0200 Message-ID: From: Takashi Iwai To: jimqu Subject: Re: =?UTF-8?B?562U5aSNOiDnrZTlpI06?= [alsa-devel] =?UTF-8?B?562U?= =?UTF-8?B?5aSNOg==?= [PATCH] vgaswitchroo: set audio client id according to bound gpu client id In-Reply-To: <1936c752-f858-2caf-35e7-98bea431fb7c@amd.com> References: <20180629080634.GA7357@wunner.de> <20180629092138.GA11849@wunner.de> <20180629111108.GA11609@wunner.de> <20180709092759.GA3649@wunner.de> <20180709155643.GE3008@phenom.ffwll.local> <733011b9-1880-76a8-d00f-076591e93c53@amd.com> <1936c752-f858-2caf-35e7-98bea431fb7c@amd.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/26 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alsa-devel@alsa-project.org" , "dri-devel@lists.freedesktop.org" , "Qu, Jim" , "amd-gfx@lists.freedesktop.org" , "Deucher, Alexander" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 11 Jul 2018 10:41:38 +0200, jimqu wrote: > > > > On 2018年07月11日 15:19, Takashi Iwai wrote: > > On Tue, 10 Jul 2018 13:21:00 +0200, > > Takashi Iwai wrote: > >>> revert the fix of amdgpu suspend issue, audio issue also can be observed. > >> Did you check the behavior with the single AMD GPU hardware? > >> If confirmed, we can forget about vga_switcheroo. > > ... and taking a look back at the recent changes, I guess it can be > > the forced runtime PM enablement, not directly with vga_switcheroo > > action itself. > > Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, > so there is no way GFX driver to control audio power. However, keep in > mind, current audio is bound to iGPU, that mean the issue should be > nothing about > vgaswtichreoo. since current audio pci bus is different from dGPU, > that means the pci_bus_set_current_state() in > vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in > vga_switcheroo_runtime_resume() could not touch the audio pci power > state from dGPU instance. > > This is a feedback got from our OEM developer, it is the overview of > audio detect process. > > > First, the kernel audio driver will be triggered to read ELD, if the > >> ELD is valid, it will report a jack event (on or available) to sound > >> core driver; the pulseaudio subscribe all jack events, if it is told > >> that the hdmi jack is plugged in (on), the pulseaudio will set this > >> port to available, then the pa-card or pa-sink has available port, it > >> can be selected (manually, some daemons or policy in > >> /usr/share/pulseaudio/alsa-mixer/) as default output card/default sink. > > If the description is correct. I think there are maybe two problems. > > 1. audio will auto power off after setup device link duo to usage_count=0. > 2. duo to audio is power down, it could not get the HDMI jack insert event. > > How do you think? > > > Jim, could you tell me which PCI devices are handled as vga_switcheroo > > audio client? The kernel should show all messages "xxx: Handle > > vga_switcheroo audio client". > > [    4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) > [    4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio > client > [    4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002) > > 01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, > Inc. [AMD/ATI] Device [1002:699f] (rev c3) > 06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, > Inc. [AMD/ATI] Device [1002:15dd] (rev d1) > 06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] > Device [1002:15de] OK this sheds a brighter light, finally. If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU. Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong. Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI. Takashi --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device) */ static struct pci_dev *get_bound_vga(struct pci_dev *pci) { + static const struct pci_device_id ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16 }, + {} + }; struct pci_dev *p; + /* check whether Intel graphics is present as primary GPU */ + if (!pci_dev_present(ids)) + return NULL; + /* check only discrete GPU */ switch (pci->vendor) { case PCI_VENDOR_ID_ATI: