From patchwork Tue Dec 20 08:20:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13077622 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A8469C4332F for ; Tue, 20 Dec 2022 08:21:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B1F3823BF; Tue, 20 Dec 2022 09:20:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B1F3823BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1671524508; bh=nq4LE6LqT7Ymuul6LdxDch/EKGqv4oIltSA8VD2bjG0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=L4OSlqLVzCn7P51HnmMNelvPf9XGEslfNB6d6cAZpY1sKnIF8qOkBxbpL2oVOybS/ Pzy+0bjvOqKVwyppUv6z7p+RNQwEf7lz1HZS1ocuE5xrlkFJEv9I8WGzp/fpmNYsSC jZAV5nroEERPavduoo5iFFbSvK/IE7j9eDrim3V4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 21F4FF80496; Tue, 20 Dec 2022 09:20:35 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74453F8032B; Tue, 20 Dec 2022 09:20:30 +0100 (CET) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C5569F8018A for ; Tue, 20 Dec 2022 09:20:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C5569F8018A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pZZqAkka DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=VHs0G2aC0Lau8WEEFjp3imT8ZHxZW8dUlQGHCb9Fikw=; b=pZZqAkkaYtdoP9XWW7DyFAkmVH LgaXjFNCPGIfxxBIMTpHXVkgSUSpvONTxfsPWoj8CuCtzoabAiDZflEl8XTEZS51iPmzX4nkeZGn+ 9tmKxqwZPiNVLKwg9RqgYNJM/xpwcO1DjlBP7oc42o7XNbU8T72/k0H7IbmbUSPqiTINtIq6egJsC kaI6saujDqqnZ9I3zFV/mO2pgJho2A/VhIT4T0OsRxJ7eBYm+KLiV6HJ7UUnU3Gn3tcIriU2vdnYU wYabUhFhipbRNolwCnSLDOw9br1+8CIi76btUcgF2fMzVS0H3+Wz0XshmsjhBK15EKhmiPHfG6zY5 H5VkHw0w==; Received: from [2001:4bb8:199:7829:c604:55b0:ed6a:61ce] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7XrC-00BuKQ-TA; Tue, 20 Dec 2022 08:20:15 +0000 From: Christoph Hellwig To: iommu@lists.linux.dev Subject: [PATCH 1/2] ALSA: memalloc: don't use GFP_COMP for non-coherent dma allocations Date: Tue, 20 Dec 2022 09:20:08 +0100 Message-Id: <20221220082009.569785-2-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221220082009.569785-1-hch@lst.de> References: <20221220082009.569785-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, Kai Vehmanen , Takashi Iwai , Mikhail Gavrilov , Robin Murphy , Marek Szyprowski Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" While not quite as bogus as for the dma-coherent allocations that were fixed earlier, GFP_COMP for these allocations has no benefits for the dma-direct case, and can't be supported at all by dma dma-iommu backend which splits up allocations into smaller orders. Due to an oversight in ffcb75458460 that flag stopped being cleared for all dma allocations, but only got rejected for coherent ones. Start fixing this by not requesting __GFP_COMP in the sound code, which is the only place that did this. Fixes: ffcb75458460 ("dma-mapping: reject __GFP_COMP in dma_alloc_attrs") Reported-by: Mikhail Gavrilov Reported-by: Kai Vehmanen Signed-off-by: Christoph Hellwig --- sound/core/memalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 3cf5a87d69eaf3..81025f50a54229 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -542,7 +542,7 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size) void *p; sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, - DEFAULT_GFP | __GFP_COMP, 0); + DEFAULT_GFP, 0); #ifdef CONFIG_SND_DMA_SGBUF if (!sgt && !get_dma_ops(dmab->dev.dev)) { if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) @@ -820,7 +820,7 @@ static void *snd_dma_noncoherent_alloc(struct snd_dma_buffer *dmab, size_t size) void *p; p = dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr, - dmab->dev.dir, DEFAULT_GFP | __GFP_COMP); + dmab->dev.dir, DEFAULT_GFP); if (p) dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->addr); return p; From patchwork Tue Dec 20 08:20:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13077623 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 42ECDC10F1E for ; Tue, 20 Dec 2022 08:22:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6A74A22F9; Tue, 20 Dec 2022 09:21:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6A74A22F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1671524535; bh=SANHKh3TzoKuEuZH5dOy28cmtrxG56qHODuKENvW5v4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=HZRmy14L6tSpuIrDRjXDDl9jHWT6HKM0KQpwc412nfIgNlZZQ8QutmYWjw7m3rKDW aIVuR7WRXr9r//VRBPJsWyX4Tsfp44l0iw9bVFKh4cOztKCZfydLslnfMhocaYlGvS hDXE94BdVOXYhLlJP3MUK3+OPqCo5aKxIDg+T0Mg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D8E3FF804B0; Tue, 20 Dec 2022 09:20:35 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 49830F8032B; Tue, 20 Dec 2022 09:20:32 +0100 (CET) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 99E27F8018A for ; Tue, 20 Dec 2022 09:20:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 99E27F8018A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hvoB7RCr DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=cA0uvbQLIkf8Hh0wtILMN1D9yegrDmrjgvNGFHvuKz0=; b=hvoB7RCrA4P6IviJWysH9ahDds Lvb0cOoelZXw0CLXWCB4GmV7Hir+3IeQHy0cy8aRtaD9JyME+M8nu4ZZIJzJkkXHIxwbkLi8om2Qj g96u0rWaW5lz6Lrokfxyu2H3e/0GcdZ6dJKK74j0Co8wqgUphmiykGhQhGw9jVAAdJRDicqGKorKP RleDQOyTAoeWj4ZD9uE9DgiW9VMCf94c0O+SPmUthe0eMAIBSm8v18ThWAglClWY0ji1JW48ljBI9 fUpAbzxG9ZSeAT0iunNd28UzBLYUbaAMudaT29y9WsF2AanC+apl7k1K0YTeew2jtXphgLNwsAThg WWHpbgAg==; Received: from [2001:4bb8:199:7829:c604:55b0:ed6a:61ce] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7XrG-00BuLq-03; Tue, 20 Dec 2022 08:20:18 +0000 From: Christoph Hellwig To: iommu@lists.linux.dev Subject: [PATCH 2/2] dma-mapping: reject GFP_COMP for noncohernt allocaions Date: Tue, 20 Dec 2022 09:20:09 +0100 Message-Id: <20221220082009.569785-3-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221220082009.569785-1-hch@lst.de> References: <20221220082009.569785-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, Kai Vehmanen , Takashi Iwai , Mikhail Gavrilov , Robin Murphy , Marek Szyprowski Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" While not quite as bogus as for the dma-coherent allocations that were fixed earlier, GFP_COMP for these allocations has no benefits for the dma-direct case, and can't be supported at all by dma dma-iommu backend which splits up allocations into smaller orders. Due to an oversight in ffcb75458460 that flag stopped being cleared for all dma allocations, but only got rejected for coherent ones, so fix up these callers to not allow __GFP_COMP as well after the sound code has been fixed to not ask for it. Fixes: ffcb75458460 ("dma-mapping: reject __GFP_COMP in dma_alloc_attrs") Reported-by: Mikhail Gavrilov Reported-by: Kai Vehmanen Signed-off-by: Christoph Hellwig Tested-by: Kai Vehmanen Tested-by: Mikhail Gavrilov --- kernel/dma/mapping.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index c026a5a5e0466e..68106e3791f6c3 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -560,6 +560,8 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size, return NULL; if (WARN_ON_ONCE(gfp & (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM))) return NULL; + if (WARN_ON_ONCE(gfp & __GFP_COMP)) + return NULL; size = PAGE_ALIGN(size); if (dma_alloc_direct(dev, ops)) @@ -645,6 +647,8 @@ struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size, if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES)) return NULL; + if (WARN_ON_ONCE(gfp & __GFP_COMP)) + return NULL; if (ops && ops->alloc_noncontiguous) sgt = ops->alloc_noncontiguous(dev, size, dir, gfp, attrs);