Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp226948ybz; Wed, 15 Apr 2020 07:39:44 -0700 (PDT) X-Google-Smtp-Source: APiQypLOFtK37nBLzXRAM05oAD9PgnBbi7QKg/K9Y6H85F3uqjNT1ce36CpaiBXRFV6CofbaCx4C X-Received: by 2002:a05:6402:310b:: with SMTP id dc11mr1155771edb.143.1586961584266; Wed, 15 Apr 2020 07:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586961584; cv=none; d=google.com; s=arc-20160816; b=Byl96RsGc4QmmKjcM4KuOMKOvRgSo9AwaxCGwwWdUFqUP0vZQ65xrE08g2cUSXIUJ9 UP8c4SEjgNdQogDSlhS8sRcU7FYkxMUNCUNpI2EY0x1SrYiAlEVzl+3MMKYhBEXx7n9J 7z3q2HvUxgWruMZp+vKX+4R2b9Jj68vyDf5M5q1uFB/5OfWwqXmedADqFtt3wvh7DcCQ zZuTmvOaxClis2E9rM/bfbYHbOUNM8RZy/XJbPNcOK/fmoRyxMK0O0kbqBG+bMMirYbB qMuzkh0m7ZeQyRXvixqMK9LPc8icGdxCRfjYOJMUsIjt4LpXS09eHbX95QyuffrW68Te OsgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=9sAv1VN5EHJYZMrc5W3hn8v84B5WLiBXmj1ZlRYwv5k=; b=L9DKeGcSj/iVzkcR5OvSzbk0umbdnsVZF4/PsePySp1d46UDEA32wt6cq0Y0Ic4T1l p4JH6URb+lEHBgCvz6AY2BcS3e5r/KcRo/lnU5XA58pZKK30nVMD7lP96MlfoJuReMJM RvCYjwkGuHWHk543RoOckbkASOriLbQL36mwbwLozyk+bCdVPKsf0sswL0oQqdGP37Nu 3am5yJH+9ljyrFOb+HABDpQzPG+2yj8gTMXZgKmUrmhQxdIDNZCVAKJcyg6MvpVpG3CB M8FI0zwtBIMKNRX4+05B8yPzHigspOxIiOK5buvY3JkgVo8Fv/FRu6U1hsqBweFW41yT Sp4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LJKP9ekR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si9917690edy.397.2020.04.15.07.39.20; Wed, 15 Apr 2020 07:39:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LJKP9ekR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634543AbgDOAE4 (ORCPT + 99 others); Tue, 14 Apr 2020 20:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbgDOAEw (ORCPT ); Tue, 14 Apr 2020 20:04:52 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83261C061A0C for ; Tue, 14 Apr 2020 17:04:52 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id t4so565627plq.12 for ; Tue, 14 Apr 2020 17:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=9sAv1VN5EHJYZMrc5W3hn8v84B5WLiBXmj1ZlRYwv5k=; b=LJKP9ekRVjrczRzWFYpENLjwjVXF3zdmaqJ/JFc1pSY2R3iC/CByObkBIDxDA+K26e 80PmMHYhalYwRWIxUwy0R/+9A/CybyFDb3fQ8mgmD56W5RXgIGgWnO52OJKFEPRnjdY4 /MAGh+KOfUIR4fdxE6TD8dSFKUARBFfJz2NITB0tFq3rHU01NLecmmjlPWGFPzLlx5bK pAuB5BcQr3XKZE/Rwt0+P7Wimj1ykmlIBN/AjkKd7m3upkM2uQGfKexQaooLHSmC4W0V SWx0SW6syfH9MiCSM/REU1Int4BqdM2tlulRJ6/ro822O0LXAEeU9iJX11yi0TtGM46x fXpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=9sAv1VN5EHJYZMrc5W3hn8v84B5WLiBXmj1ZlRYwv5k=; b=B6Wf9cNxWDsqmdLTPOBOzYGzdRrwEzmdeno5AVgp1zqdxBpLlo2owLXs0u1sEPN1YK eDRkPtCTHQiwRAntUhnbnClaIrKGaaslqAPFZkU/z1oi+KRGkgnpXqaDPfES8wVZWXBJ mZXdkyL9HqUZu92PYxh9wa5nNy8Kiy4paUAEq9yUub+miXlm50LF8yvpBxHBFddbCsSN eYM12XOZqCiEKLwdlSXn0D0NHTPB5n9a9Swny7ejOG+nC2sY9USJEBqcUEecCZ5fI14I JRHMOZYax4iFI4L1ogo+ZwEs4ur5I+tC+pl/fyyTzA9acWa4mG4JX5MTT5IPXFdrtjh3 5HCQ== X-Gm-Message-State: AGi0PubvdEGO9G/RqV7Dh6IJVWixwdwXcngQ2zvgM80gYYNxtI/QsMn6 Iw3gvQz/+512cikKMuYk6qcIBw== X-Received: by 2002:a17:902:968a:: with SMTP id n10mr2231605plp.96.1586909091613; Tue, 14 Apr 2020 17:04:51 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id g22sm5108300pju.21.2020.04.14.17.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 17:04:51 -0700 (PDT) Date: Tue, 14 Apr 2020 17:04:50 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig , Tom Lendacky cc: Brijesh Singh , Jon Grimm , Joerg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Subject: [patch 0/7] unencrypted atomic DMA pools with dynamic expansion Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org set_memory_decrypted() may block so it is not possible to do non-blocking allocations through the DMA API for devices that required unencrypted memory. The solution is to expand the atomic DMA pools for the various possible gfp requirements as a means to prevent an unnecessary depletion of lowmem. These atomic pools are separated from the remap code and can be selected for configurations that need them outside the scope of CONFIG_DMA_DIRECT_REMAP, such as CONFIG_AMD_MEM_ENCRYPT. These atomic DMA pools are kept unencrypted so they can immediately be used for non-blocking allocations. Since the need for this type of memory depends on the kernel config and devices being used, these pools are also dynamically expandable. The sizes of the various atomic DMA pools is exported through debugfs at /sys/kernel/debug/dma_pools. This patchset is based on latest Linus HEAD: commit 8632e9b5645bbc2331d21d892b0d6961c1a08429 Merge: 6cc9306b8fc0 f3a99e761efa Author: Linus Torvalds Date: Tue Apr 14 11:58:04 2020 -0700 Merge tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux --- arch/x86/Kconfig | 1 + drivers/iommu/dma-iommu.c | 5 +- include/linux/dma-direct.h | 2 + include/linux/dma-mapping.h | 6 +- kernel/dma/Kconfig | 6 +- kernel/dma/Makefile | 1 + kernel/dma/direct.c | 56 ++++++-- kernel/dma/pool.c | 275 ++++++++++++++++++++++++++++++++++++ kernel/dma/remap.c | 114 --------------- 9 files changed, 334 insertions(+), 132 deletions(-) create mode 100644 kernel/dma/pool.c