From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4654C3AA9CA; Sat, 17 Oct 2026 16:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792255748; cv=none; b=YDMt9xsDw9UyQ517CWcEy35+CQoU1u7diM1udqcpdxvCDCk9Q0/UX7AhqIKHWhiX6DDn9r6Pd+UJzC4IjPiai5LMizxMR4FHXEDzA1M0GjIkYXUtnyB51rjUdqOmTezROfiN/nuw3TBLBcIJBctv5vL/iVr0RRdNR29l4YIUSyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792255748; c=relaxed/simple; bh=f4FTi7tyY75HZYzPFUTlqu/2v4wpaUHdnQ87aVEVEIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NbwOECdzV4LznlXEK1l9cnx/IDrnVBNCnRpOxmBLNhWJWgKkxF/KcFD3cF4U/zV/WBJbEC95dKASwoQ9gn81eXzjlHb9Vwj3NC2k++QCfrjpfAttVdAyDRD+NNB/aPqXmsSCyOUDu7NEnBMQG/cSIsqdiJgCwzXYmmq/RnkAVCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xRfaIcf3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xRfaIcf3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56CD81F000C4; Sat, 17 Oct 2026 16:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792255746; bh=m4WAIk84+ggiverZ8prB2x+VB0UeU//zLLBhrseCVK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xRfaIcf3RcUFFi3a2Fmz7H468dmwk+CfD/D0Lrk8m78E32pnCQpCP5OKWGUcMZDMi Bz6bhHIF++3usiaQ69Mnuk34LTUc4zb3R1UWcUogRHAewBMkBfUwR0vBHIjOEedq56 8iArKH5iPf6tIL6FqwBAGvHwKwElmyq3ssnIEJr0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Robin Murphy , Greg Ungerer , Sasha Levin Subject: [PATCH 6.6 0001/1674] dma-direct: simplify the use atomic pool logic in dma_direct_alloc Date: Sat, 17 Oct 2026 17:37:53 +0200 Message-ID: <20261017160431.176835792@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Hellwig [ Upstream commit b1da46d70e5427a9ba5eae28bcca29a20e68a442 ] The logic in dma_direct_alloc when to use the atomic pool vs remapping grew a bit unreadable. Consolidate it into a single check, and clean up the set_uncached vs remap logic a bit as well. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy Reviewed-by: Greg Ungerer Tested-by: Greg Ungerer Signed-off-by: Sasha Levin --- kernel/dma/direct.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 91915d351e123..25d4d8710f6c0 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -234,27 +234,22 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_handle); /* - * Otherwise remap if the architecture is asking for it. But - * given that remapping memory is a blocking operation we'll - * instead have to dip into the atomic pools. + * Otherwise we require the architecture to either be able to + * mark arbitrary parts of the kernel direct mapping uncached, + * or remapped it uncached. */ + set_uncached = IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED); remap = IS_ENABLED(CONFIG_DMA_DIRECT_REMAP); - if (remap) { - if (dma_direct_use_pool(dev, gfp)) - return dma_direct_alloc_from_pool(dev, size, - dma_handle, gfp); - } else { - if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED)) - return NULL; - set_uncached = true; - } + if (!set_uncached && !remap) + return NULL; } /* - * Decrypting memory may block, so allocate the memory from the atomic - * pools if we can't block. + * Remapping or decrypting memory may block, allocate the memory from + * the atomic pools instead if we aren't allowed block. */ - if (force_dma_unencrypted(dev) && dma_direct_use_pool(dev, gfp)) + if ((remap || force_dma_unencrypted(dev)) && + dma_direct_use_pool(dev, gfp)) return dma_direct_alloc_from_pool(dev, size, dma_handle, gfp); /* we always manually zero the memory once we are done */ -- 2.53.0