Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3050087rwb; Mon, 5 Sep 2022 05:51:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR4/3Ijfpg2NIgeUTQnr26HZP9HSKN/OSUmNtDhI4IPWJLpWuEzvsuSQHe6DZX0djD7qd6X2 X-Received: by 2002:a17:903:2284:b0:174:5588:13b1 with SMTP id b4-20020a170903228400b00174558813b1mr45064032plh.120.1662382296676; Mon, 05 Sep 2022 05:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662382296; cv=none; d=google.com; s=arc-20160816; b=Oo9pdFd4x1mqu224wZjIQAzpVUcJH1IlY/JDMv0GfXAoCR6PH53IwaCy8Ue7vRKsns nEJKkA2fkr/g0JFniAKkdP314g4HbMocdA4zFgM7I/Ywf2+X1ecmSn099WNO3h8c6WSv 6mHYmHo9NJQKWg+eH5M1JVDJmy34H+0t8ewRz8GC3nZCyHEuZ9R/VFtMlmZXltE2aFWV WUOTeWJ+FqbnnjRflCvrs2Y3H73opGwBV9kkt9+asqu2ga29U49PWGAqRil/JPZ0rpDy WP2UiwZ9pq3l1kb6t7lN+32MTmAQ/KHEpVUsvkgMwSuKU18Mj+BZR7eSHpGof/pWi/7J YhmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=R4M7Gfp3ULBZggWLo8mojaVJIBZ+WLvXUjQCIr0zMxE=; b=u0Ea8eyhpyK5zWkk114b1Cf4wu17gfYi3FYsQcwJaZXON9DZDhOHZG4vdc+TiFk02X 04X8fYrmZH6InQGVPqcRjDDBRpFleU8diQFhYtPggfdccM4+F9QK4HYMpiGLCs+eR4Nu jtII2v+4hMNPfsG9VsWGFtn3CzEZ+KDUwqduHLAI18UX+EdxGyOGowKj9imG8m4GqoBr IhWMPHMlP2XhPherzGDxCl67Uef+I2k93RS1w6psD9vb5diEf/RfXbKiemfUW+h82/YE 3mFr0MHWvxmIXArBv4wz2amT1DlLf4magNmxKyvinS3SspNc7Dl5pRFEhPd5UKkPum3m 6KmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vpEwmThv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=d+G748j3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a634801000000b00415fcde211asi10561931pga.556.2022.09.05.05.51.18; Mon, 05 Sep 2022 05:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vpEwmThv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=d+G748j3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235598AbiIEMtJ (ORCPT + 99 others); Mon, 5 Sep 2022 08:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234228AbiIEMtH (ORCPT ); Mon, 5 Sep 2022 08:49:07 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0786E1FB; Mon, 5 Sep 2022 05:49:06 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B065E388A0; Mon, 5 Sep 2022 12:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662382144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R4M7Gfp3ULBZggWLo8mojaVJIBZ+WLvXUjQCIr0zMxE=; b=vpEwmThvhZkMfOTkBel1SM5l543iK03L30ldcjElcqS1G50Wk4OrVdKqgHfXQesnSYXCZ3 QuF471iMZI//6YseFrXUeGsO8tSzu38gY/HAlm3ukY7S241mcbCCgSsAvjUTBeQaJnKp3M yUFo+58fUqYYBXUerPFgnQsP0N7ukC8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662382144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R4M7Gfp3ULBZggWLo8mojaVJIBZ+WLvXUjQCIr0zMxE=; b=d+G748j3ueBj4OyFmdCoqK83vteex2i5HucxmvOMSueLGZhGplhoB4jOWr4YuV2K6uu12g NmlWUJL1k3QQRYBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 944E313A66; Mon, 5 Sep 2022 12:49:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CAmGI0DwFWNADQAAMHmgww (envelope-from ); Mon, 05 Sep 2022 12:49:04 +0000 Date: Mon, 05 Sep 2022 14:49:03 +0200 Message-ID: <87o7vuj8ao.wl-tiwai@suse.de> From: Takashi Iwai To: Mikhail Gavrilov Cc: Linux List Kernel Mailing , linux-sound@vger.kernel.org Subject: Re: [BUG] commit a8d302a0b77057568350fe0123e639d02dba0745 cause IO_PAGE_FAULT and a lot of errors In-Reply-To: <874jxml7a4.wl-tiwai@suse.de> References: <87ilm3vbzq.wl-tiwai@suse.de> <875yi3froa.wl-tiwai@suse.de> <874jxml7a4.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 05 Sep 2022 07:28:03 +0200, Takashi Iwai wrote: > > On Mon, 05 Sep 2022 00:40:48 +0200, > Mikhail Gavrilov wrote: > > > > On Sun, Sep 4, 2022 at 1:51 PM Takashi Iwai wrote: > > > Also, please check the patch below instead of the previous one, too. > > > If this one works, it'd be a better choice. > > > > > > > I compiled the kernel only with the second patch. > > I confirm that patch fixed the described problem. > > No new problems were noticed during the day, thanks. > > > > Tested-by: Mikhail Gavrilov > > Awesome. > > Could you try the below one instead? It's a simplified version and > applies the workaround more consistently. Once after it's confirmed > to work, I'm going to submit a proper patch and merge for the next 6.0 > PR. Even a simpler one below with a proper changelog. Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: hda: Once again fix regression of page allocations with IOMMU The last fix for trying to recover the regression on AMD platforms, unfortunately, leaded to yet another regression: it turned out that IOMMUs don't like the usage of raw page allocations. This is yet another attempt for addressing the log saga; at this time, we re-use the existing buffer allocation mechanism with SG-pages although we require only single pages. The SG buffer allocation itself was confirmed to work for stream buffers, so it's relatively easy to adapt for other places. The only problem is: although the HD-audio code is accessing the address directly via dmab->address field, SG-pages don't set up it. For the ease of adaption, we now set up the dmab->addr field from the address of the first page as default, so that it can run with the HD-audio driver code as-is without the excessive call of snd_sgbuf_get_addr() multiple times; that's the only change in the memalloc helper side. The rest is nothing but a flip of the dma_type field in the HD-audio side. Fixes: a8d302a0b770 ("ALSA: memalloc: Revive x86-specific WC page allocations again") Reported-by: Mikhail Gavrilov Cc: Link: https://lore.kernel.org/r/CABXGCsO+kB2t5QyHY-rUe76npr1m0-5JOtt8g8SiHUo34ur7Ww@mail.gmail.com Link: https://bugzilla.kernel.org/show_bug.cgi?id=216112 Link: https://bugzilla.kernel.org/show_bug.cgi?id=216363 Signed-off-by: Takashi Iwai --- sound/core/memalloc.c | 9 +++++++-- sound/pci/hda/hda_intel.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 39561faef6e9..2c11413bea61 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -558,10 +558,13 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size) dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, sg_dma_address(sgt->sgl)); p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt); - if (p) + if (p) { dmab->private_data = sgt; - else + /* store the first page address for convenience */ + dmab->addr = snd_sgbuf_get_addr(dmab, 0); + } else { dma_free_noncontiguous(dmab->dev.dev, size, sgt, dmab->dev.dir); + } return p; } @@ -763,6 +766,8 @@ static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size) if (!p) goto error; dmab->private_data = sgbuf; + /* store the first page address for convenience */ + dmab->addr = snd_sgbuf_get_addr(dmab, 0); return p; error: diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index bf9df9bc8f1b..7e605ce43f41 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1810,7 +1810,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, /* use the non-cached pages in non-snoop mode */ if (!azx_snoop(chip)) - azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; + azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG; if (chip->driver_type == AZX_DRIVER_NVIDIA) { dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); -- 2.35.3