Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1951138ybz; Thu, 30 Apr 2020 08:17:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJ+6IIiuhw/GZPOm/5KBKxOyQm0fc3f0zUPRnujKr9jTv20IUiFTd+zRfeZuG6Zo4WQrxy3 X-Received: by 2002:a17:907:42d6:: with SMTP id ng6mr3062550ejb.265.1588259830553; Thu, 30 Apr 2020 08:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588259830; cv=none; d=google.com; s=arc-20160816; b=Ievlt0ZmnFZV9TK0Q9pssP2LZOj4i/prqwKZOgy3mW2etrpt528L1jYyBzI+MUBf7c 7dd2P6oJMXGUu3GwAVcgCvQyYrM1k3pYS+MGTZqb3fag/sArdqKs1ThTiGz6tOYnsfPd 5Fdv5w0kN8qPLfUOezhmjSAOgg12LkhPFO88DTahU0El2RfFKl5S94ZqziczJM0dlJFC p9x5QBrY7ltkQa3atPY0Jikd81WL0mrzWrB+/xgpqNvsywgaK0/wwYERPEmU8XTOn/zd HvEbMO3g+a0xTyYQ7+tSiqiYPqAYXT0LhU/Z0YhIjKv5JTj06+MNxai1r7Buu6yzlMDp GZ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=0ECx5A4Cex4rV3xHV+xfmBlwhs0d+4MGmQIhlCfjKoM=; b=l1p58KzPQk5ArvsRgmkB9fflOmnwpnJUQni23JhPYliKoiUjOHPolU892627E5Nqjk ZmPpY/Al4ILbcinwTYk25D6wMWQlEfiY5ddI0h58aqpnUaEV2MCvjNkNSoWAjfjPYIdH 7J6/744iLN8KEpBkFkdBfUDh/1bz6t1Cvn5Y1Ze07Z7iAwN57fEQMkaXlh7hl7fLDrm2 XX5tKNVN5Q4i8yea7ydxAXlMXiRdl74fgNCNwaAS3vFXMI0qh/xxeomDk+k5YaL3gq4Z pBELsU1AMZiKe/kvvuXKjJ4k4mfgvneO1ZVBhEbCFg8hweT27+D1cMlki+HUUANoUh3G 4LSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si5170595edx.30.2020.04.30.08.16.45; Thu, 30 Apr 2020 08:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbgD3PPB (ORCPT + 99 others); Thu, 30 Apr 2020 11:15:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:48064 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgD3PO7 (ORCPT ); Thu, 30 Apr 2020 11:14:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4D3B8AE39; Thu, 30 Apr 2020 15:14:56 +0000 (UTC) Date: Thu, 30 Apr 2020 17:14:56 +0200 Message-ID: From: Takashi Iwai To: Alex Deucher Cc: Nicholas Johnson , "Zhou, David(ChunMing)" , "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" , "amd-gfx@lists.freedesktop.org" , Takashi Iwai , Lukas Wunner , "Deucher, Alexander" , "Koenig, Christian" Subject: Re: [PATCH 0/1] Fiji GPU audio register timeout when in BACO state In-Reply-To: References: 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/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Apr 2020 18:19:57 +0200, Alex Deucher wrote: > > On Wed, Apr 29, 2020 at 12:05 PM Takashi Iwai wrote: > > Well, but the code path there is the runtime PM resume of the audio > > device and it means that GPU must have been runtime-resumed again > > beforehand via the device link. So, it should have worked from the > > beginning but in reality not -- that is, apparently some inconsistency > > is found in the initial attempt of the runtime resume... > > Yeah, it should be covered, but I wonder if there is something in the > ELD update sequence that needs to call pm_runtime_get_sync()? The ELD > sequence on AMD GPUs doesn't work the same as on other vendors. The > GPU driver has a backdoor into the HDA device's verbs to set update > the audio state rather than doing it via an ELD buffer update. We > still update the ELD buffer for consistency. Maybe when the GPU > driver sets the audio state at monitor detection time that triggers an > interrupt or something on the HDA side which races with the CPU and > the power down of the GPU. That still seems unlikely though since the > runtime pm on the GPU side defaults to a 5 second suspend timer. I'm not sure whether it's the race between runtime suspend of GPU vs runtime resume of audio. My wild guess is rather that it's the timing GPU notifies to the audio; then the audio driver notifies to user-space and user-space opens the stream, which in turn invokes the runtime resume of GPU. But in GPU side, it's still under processing, so it proceeds before the GPU finishes its initialization job. Nicholas, could you try the patch below and see whether the problem still appears? The patch artificially delays the notification and ELD update for 300msec. If this works, it means the timing problem. thanks, Takashi --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -767,6 +767,7 @@ static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, if (pin_idx < 0) return; mutex_lock(&spec->pcm_lock); + get_pin(spec, pin_idx)->repoll_count = 1; hdmi_present_sense(get_pin(spec, pin_idx), 1); mutex_unlock(&spec->pcm_lock); } @@ -1647,7 +1648,10 @@ static void sync_eld_via_acomp(struct hda_codec *codec, per_pin->dev_id, &eld->monitor_present, eld->eld_buffer, ELD_MAX_SIZE); eld->eld_valid = (eld->eld_size > 0); - update_eld(codec, per_pin, eld, 0); + if (per_pin->repoll_count) + schedule_delayed_work(&per_pin->work, msecs_to_jiffies(300)); + else + update_eld(codec, per_pin, eld, 0); mutex_unlock(&per_pin->lock); } @@ -1669,6 +1673,11 @@ static void hdmi_repoll_eld(struct work_struct *work) struct hdmi_spec *spec = codec->spec; struct hda_jack_tbl *jack; + if (codec_has_acomp(codec)) { + per_pin->repoll_count = 0; + goto check; + } + jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, per_pin->dev_id); if (jack) @@ -1677,6 +1686,7 @@ static void hdmi_repoll_eld(struct work_struct *work) if (per_pin->repoll_count++ > 6) per_pin->repoll_count = 0; + check: mutex_lock(&spec->pcm_lock); hdmi_present_sense(per_pin, per_pin->repoll_count); mutex_unlock(&spec->pcm_lock);