From nobody Fri Dec 19 07:47:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D11EC6FA82 for ; Tue, 13 Sep 2022 14:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232704AbiIMOLm (ORCPT ); Tue, 13 Sep 2022 10:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232754AbiIMOKR (ORCPT ); Tue, 13 Sep 2022 10:10:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D85A265E; Tue, 13 Sep 2022 07:09:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id DBD83CE1271; Tue, 13 Sep 2022 14:09:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E50B6C433B5; Tue, 13 Sep 2022 14:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078167; bh=mvwsHrLNf7H9ACenmnm4IYVA2zqJfnuZXGMlcGru+I0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UrwFtcPQUNM404Z53HTAnoZ5lSfJlQkyv0wLn7wTEin5x+J5TAILKi3ryvTjIGu9O gQHq9DdIOPw5nSSb9BvgSs1hnVZLY3mJYHR35VFiFU1PhxKr9ThIlEAiNp5WDj5nHJ UShOm45d5lg3y6YC0nJb1HTGVgCKE699/amuprFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikhail Gavrilov , Takashi Iwai Subject: [PATCH 5.19 037/192] ALSA: hda: Once again fix regression of page allocations with IOMMU Date: Tue, 13 Sep 2022 16:02:23 +0200 Message-Id: <20220913140411.766265237@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140410.043243217@linuxfoundation.org> References: <20220913140410.043243217@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Takashi Iwai commit 37137ec26c2c03039d8064c00f6eae176841ee0d upstream. 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 allocatio= ns again") Reported-by: Mikhail Gavrilov Tested-by: Mikhail Gavrilov Cc: Link: https://lore.kernel.org/r/CABXGCsO+kB2t5QyHY-rUe76npr1m0-5JOtt8g8SiHU= o34ur7Ww@mail.gmail.com Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216112 Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216363 Link: https://lore.kernel.org/r/20220906090319.23358-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/memalloc.c | 9 +++++++-- sound/pci/hda/hda_intel.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -535,10 +535,13 @@ static void *snd_dma_noncontig_alloc(str dmab->dev.need_sync =3D dma_need_sync(dmab->dev.dev, sg_dma_address(sgt->sgl)); p =3D dma_vmap_noncontiguous(dmab->dev.dev, size, sgt); - if (p) + if (p) { dmab->private_data =3D sgt; - else + /* store the first page address for convenience */ + dmab->addr =3D snd_sgbuf_get_addr(dmab, 0); + } else { dma_free_noncontiguous(dmab->dev.dev, size, sgt, dmab->dev.dir); + } return p; } =20 @@ -772,6 +775,8 @@ static void *snd_dma_sg_fallback_alloc(s if (!p) goto error; dmab->private_data =3D sgbuf; + /* store the first page address for convenience */ + dmab->addr =3D snd_sgbuf_get_addr(dmab, 0); return p; =20 error: --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1817,7 +1817,7 @@ static int azx_create(struct snd_card *c =20 /* use the non-cached pages in non-snoop mode */ if (!azx_snoop(chip)) - azx_bus(chip)->dma_type =3D SNDRV_DMA_TYPE_DEV_WC; + azx_bus(chip)->dma_type =3D SNDRV_DMA_TYPE_DEV_WC_SG; =20 if (chip->driver_type =3D=3D AZX_DRIVER_NVIDIA) { dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");