Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1027697ybb; Wed, 8 Apr 2020 14:59:53 -0700 (PDT) X-Google-Smtp-Source: APiQypIz/0oDZgPeApZwEaH9qI3C3QdoErC8eZMeTkGDxfMd5d3kLGYFZnflCBk2bAhCAg0wrxO1 X-Received: by 2002:a05:6830:1046:: with SMTP id b6mr7744150otp.229.1586383193592; Wed, 08 Apr 2020 14:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586383193; cv=none; d=google.com; s=arc-20160816; b=PzDuaqCPsU13FUpbjb7Rklb4ZNF7LmnGddoaoQmRqOvJzxLeBiMPZ7+Qq6xW9xg1uE 0H9E5sCLln2kHCTQ+yrJ4q63SbFJOPHJx6bqVaB02Yo1W8dMVhJ40IW2L84z3xuxfoef ZlrQ9qq6veQebQz6Rsa5WtD2Pe1XmVXg7uLMUejRgRdhZPKnpK1HK9Fo8LvP+OmZdqws jGs0LNXZc5NrIUP5ZGInmDHBz6+CcFX0EladcpqVLEpATch9XTh6xdngDTuv6ePgn3kt k+s8ou4gbACAWsNz37QKN+IMmSi29osmc3g5+WjfHvfl0IfBQC+YqbTClYkRueFJ0QQy dlMA== 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:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=AEQOYfD6KlwbjpX4Ij2ibJALe8Dqd/dC0Q9YV1bU9hM=; b=nWxwhBok3mhZIKpWsP1D1OH8XJNP3wg8my8Uy//skrkuLpXVh1ayRiM/1hGnW3fRMi I8wF6d8FYYQroTKDuyQ3Wzi0TD97h5kubWuFJOq/HsQOB7a4JTX/gH7oAa8V3oFI5ClU V7a3GAEOSKUH+xICWfFbPJqZOr0j57jUMZPCFYPvsg9ZXj/Wlx7EBsTF/Q1P7EIMtlsl V5IdTa/8KSK13sAXo8/EZWPC8nXZvKXGWg+P3nPj1vxXsyJ9iKn8uHcNPhxcZoKMBnqd QGqqaHKRCNg+BZC/9teip8TBQ/iG6G+9gqC9wN01HGc92nCjDtcSuTsHnBW1RHZOroeB PNgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hlOzkl87; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f14si3098684oti.5.2020.04.08.14.59.41; Wed, 08 Apr 2020 14:59:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hlOzkl87; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730264AbgDHVVH (ORCPT + 99 others); Wed, 8 Apr 2020 17:21:07 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:40185 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730241AbgDHVVE (ORCPT ); Wed, 8 Apr 2020 17:21:04 -0400 Received: by mail-pj1-f65.google.com with SMTP id kx8so355997pjb.5 for ; Wed, 08 Apr 2020 14:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=AEQOYfD6KlwbjpX4Ij2ibJALe8Dqd/dC0Q9YV1bU9hM=; b=hlOzkl87l7nIU+B8Bum98roZyLl+ZMfJaTcRH7l/jQD6zH0udwiDBMGFstrB8ng5dY ESKBaujmUSYHqDlGCZi9sGtznbnc7plwdSbkEbKbunNkDwRbGGCqKl7WVAxMvpUuA4co vSNBNfPhXyuW7QZtSn5Hwuaphia3Y8qH1NGmpZi8hrcCraK36cefKtgFRchBtrdFW5jM DdLBpPsToRtf1raWBc/uoZxRrnB9RstWkcw5FHPtCtSQY7QWoSaalfTo096teDYbu1Kd LO5DBnriEvfsf/nnj5+xkPuFlCkzLPntys7HEo6jpLzoLxrugLLtshtfai3YL527HtMj bxvg== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=AEQOYfD6KlwbjpX4Ij2ibJALe8Dqd/dC0Q9YV1bU9hM=; b=VtF+JS3CrdypGg4E2oEOWcS7FXcTFYi7zdROYSTqTeEiFCiSRhyJzVQi7OcffGlCbD O7a+a44rIsr0KKLeJ1s7Pl3SRpZ3WIrVyrseVhkY24glFTBkDqsoruoFGqPUSOhUUZLd NL4zWtSN4Rz+7NaL70QwY3Y6s9qNh+unqhx6WE2VxSXsxZEGSzdmjJXQ+7zaBnsMz7VE 0lKxba/kToj/oZ8P2bp1p7ivFcQBrWf6gCbGHHukSgytNiWAGOGiiO9RqzNSoDA3zyPm 3J8JBFnkCNERHTg+G9z4qtfoO/2i1pqp4lMMAMdPxiJxcxB/trRC8BqcdX64RRy95fdv WStg== X-Gm-Message-State: AGi0PualBvRNzYpbd4tq189BClkjunI2GWJoD8L5t+2RvNG1lvsPKdkP 21bRPYPYY6QqiDtd6RtKTz4PjCkcR9U= X-Received: by 2002:a17:90a:aa0e:: with SMTP id k14mr7567767pjq.74.1586380862157; Wed, 08 Apr 2020 14:21:02 -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 63sm17497048pfx.132.2020.04.08.14.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:21:01 -0700 (PDT) Date: Wed, 8 Apr 2020 14:21:00 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig , Tom Lendacky cc: "Singh, Brijesh" , "Grimm, Jon" , Joerg Roedel , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" Subject: [rfc v2 0/6] unencrypted atomic DMA pools with dynamic expansion In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) 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. There are a number of changes to v1 of the patchset based on Christoph's feedback and the separation of the atomic pools out into the new kernel/dma/pool.c. NOTE! I'd like eyes from Christoph specifically on patch 4 in the series where we handle the coherent pools differently depending on CONFIG_DMA_COHERENT_POOL and/or CONFIG_DMA_DIRECT_REMAP and from Thomas on the requirement for set_memory_decrypted() for all DMA coherent pools. Why still an RFC? We are starting to aggressively test this series but since there were a number of changes that were requested for the first RFC, it would be better to have feedback and factor that into the series earlier rather than later so testing can be focused on a series that could be merged upstream. This patchset is based on latest Linus HEAD: commit ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25 Author: Hillf Danton Date: Wed Apr 8 11:59:24 2020 -0400 mm/gup: Let __get_user_pages_locked() return -EINTR for fatal signal --- 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 | 28 ++++- kernel/dma/pool.c | 224 ++++++++++++++++++++++++++++++++++++ kernel/dma/remap.c | 114 ------------------ 9 files changed, 261 insertions(+), 126 deletions(-) create mode 100644 kernel/dma/pool.c