From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45D9EC433C1 for ; Tue, 23 Mar 2021 11:40:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E7D561920 for ; Tue, 23 Mar 2021 11:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E7D561920 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E5B56166A; Tue, 23 Mar 2021 12:39:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E5B56166A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616499606; bh=9ib0M5C/vLgsAkWPqwmKaFkmQ9VPIza2QpWkJ1qrmNc=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CWxI5SRlpD7s1e5+BeoL6gq03KtB9IIUeASr/cEIw5O55XLgYxD3+m9E22Y77vjpx LHtYdz062pIHYSI7/w1oXwrrHqk47ec7Y0d8asvxyuQnpT2a/sYFEanjPXAH7E1ZdM vRHw/0S8GbDpc/8av9t4u4HNrSCLOKG0ECE81d/E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7674EF80257; Tue, 23 Mar 2021 12:39:15 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 32850F8025F; Tue, 23 Mar 2021 12:39:14 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 238A9F800EE for ; Tue, 23 Mar 2021 12:39:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 238A9F800EE X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DBD01AD38; Tue, 23 Mar 2021 11:39:07 +0000 (UTC) Date: Tue, 23 Mar 2021 12:39:07 +0100 Message-ID: From: Takashi Iwai To: Andrey Grodzovsky Subject: Re: Adding movable PCIe BARs support in snd_hda_intel 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=UTF-8 Content-Transfer-Encoding: 8bit Cc: "Alexander.Deucher@amd.com" , alsa-devel@alsa-project.org, Sergei Miroshnichenko , "Christian.Koenig@amd.com" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Tue, 23 Mar 2021 12:23:16 +0100, Andrey Grodzovsky wrote: > > Just an update, i found the issue which was actually to wake up the HW > before doing stop/restart (using pm_runtime_get_sync), also handled > protecting from concurrent snd_pcm_ioctls accessing the registers > while the BAR is unmapped. Can go through BAR move while aplay is > running now. > > Once again, would be happy for any comments on the code - > https://cgit.freedesktop.org/~agrodzov/linux/log/?h=yadro/pcie_hotplug/movable_bars_v9.1 Hrm, this kind of change is a bit scary; we have some mechanism to stop the HD-audio hardware operation (e.g. for loading the DSP for CA0132 codec), but it's pretty hackish and error-prone. Do we really need the BAR remap while operating the sound streaming? That is, can't we simply refuse the remap if it's in operation? If it can be refused, we may avoid a big locking or such. thanks, Takashi > > > Andrey > > On 2021-03-19 5:22 p.m., Andrey Grodzovsky wrote: > > Hi, I am working on adding AMD related drivers support for PCIe BARs > > move feature developed by Sergei > > (https://linuxplumbersconf.org/event/7/contributions/847/attachments/584/1035/lpc2020_sergmir.pdf). > > > > His feature is still not upstream, all his code and mine on top can > > be seen here - > > https://cgit.freedesktop.org/~agrodzov/linux/log/?h=yadro/pcie_hotplug/movable_bars_v9.1 > > > > I did basic implementation fro amdgpu driver and now I am doing the > > same for snd_hda_intel to support our on GPU Azalia audio > > chips. This relevant commit is here - > > https://cgit.freedesktop.org/~agrodzov/linux/commit/?h=yadro/pcie_hotplug/movable_bars_v9.1&id=7ec0f60633e898cb941cebb3cd18aae1374fc365 > > > > Any driver that wants to support movable BARs needs to implement > > rescan_prepare, rescan_done and bar_fixed callbacks where > > rescan_prepare needs to stop HW/SW and unamp all MMIO mappings and > > rescan_done needs to ioremap the BAR from it's new MMIO location and > > restart HW/SW. > > > > I am able currently to trigger BARs move by sysfs using > > "/sys/bus/pci/rescan" and the driver will go through the sequence I > > described above without hangs. Problem is that after this when i try > > to use mplayer I am getting following errors: > > > > andrey@andrey-test:~$ sudo mplayer -ao alsa:device=hw=0.3 > > Downloads/file_example_MP3_5MG.mp3 > > MPlayer 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team > > do_connect: could not connect to socket > > connect: No such file or directory > > Failed to open LIRC support. You will not be able to use your remote > > control. > > > > Playing Downloads/file_example_MP3_5MG.mp3. > > libavformat version 58.29.100 (external) > > Audio only file format detected. > > Load subtitles in Downloads/ > > ========================================================================== > > Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III > > AUDIO: 44100 Hz, 2 ch, s16le, 320.0 kbit/22.68% (ratio: 40000->176400) > > Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers > > I, II, III) > > ========================================================================== > > AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample) > > Video: no video > > Starting playback... > > A:   0.1 (00.0) of 132.0 (02:12.0) ??,?% > > Audio device got stuck! > > > > and in dmesg I see > > [  365.355518] snd_hda_codec_hdmi hdaudioC0D0: Unable to sync > > register 0x2f0d00. -5 > > > > Also I see 296.619014] snd_hda_intel 0000:0a:00.1: CORB reset > > timeout#2, CORBRP = 65535 error during the rescan_done callback > > execution > > > > I know it has to do with the move of BAR's MMIO address because when i > > disallow BAR migration by returning true from bar_fixed callback I > > have no such errors and mplayer works fine. > > > > I enabled MMIO trace and didn't see that post BAR move there is a > > wrong MMIO access - all of them are from the new MMIO base offset - > > 0xfcd80000 (trace attached including mmio trace and dmesg) > > > > I would be happy for any idea on this and any comment on the > > correctness of my sequence in the code > > > > Andrey >