From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79CE421ABD7 for ; Tue, 5 May 2026 00:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777940604; cv=none; b=KL4O3mSusJbEkhdBMgdwD9UMwQChRphVwIbG/MMvilDtb0e+Mlgb/SPIhncaV1as9aAeYWy8LZHX1Vtpy30KBLXk/fQ95ZEFvmK9mpyIQABATr37Cc3jKte5mxGJSMg4rij75XrZy4/9aSZYLMhMZicE+GYQyOd8ypSvanOSQTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777940604; c=relaxed/simple; bh=xbhTzoI9Yb8krsLvI17n3/N8clqfBJwRv6mertDyy2k=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Z/ghi0DRBHpDwiu+TZ3pSa4pXXXL+0WQMIGhKCfJY9TOF2S9ZPudoydk8MdLJD9ltAji3b6kBSeBIoa77I3jUB595kdRNTk6pDyLgzKTtbPzMwlR10g260nitgY2hFuLCCjvSHtfRJHAWnGYwf0KDavNtf+81s+WGLjns6LGIoE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--skhawaja.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KNH5v+3u; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--skhawaja.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KNH5v+3u" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c7977177675so1888801a12.0 for ; Mon, 04 May 2026 17:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777940602; x=1778545402; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=P7hLyOAFb/XotDLSfzs07sOc8bnqFDsHZkne19sPDsE=; b=KNH5v+3ue/JyaAGfOnUmFOK1Q3tuJbYtxiKAE3yY3Hn4iN5btSv0Gehs4a+soRto5B gOeji5UYv4PTugur/3nLxdG/SECjp5ZqEJb6xqgwATdQAiOeWLm7VTXLvJ4J6rjrfu4p RludtohadCgVENs5iCUhcSxsCwia7VSoc2IEU+TLPfZomu29BJTNHMooEw4O5qNQurUx TgkV3CCfi+9oY1Of55Aa61uEF4HBHyUWfDCCwbAtZbdOGPo4rannARM7g/9mTrC35iU1 rXJwn1EZipZSE92K2IiKn5Q2qyVuCMFedQX3SxD17HxbJW/+v/xkD67v9aoq+xTPm9rb A4Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777940602; x=1778545402; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=P7hLyOAFb/XotDLSfzs07sOc8bnqFDsHZkne19sPDsE=; b=nxVFFBX1N4HOA9QeWiJ3GNtd9fqD2gOtG6lxZX+kxUg+gOIGZQBSYZJfbMUyyG2xWr RGojNaZ73kZYaKRNzb0WYm/A7/Hg001/ra0Y1q5YPWghOTTLHwFJR2td6RimLBULDopV igb5nFbLBv0KJZTO0YfHqM1IBfHdLWusUqf1fPq9jqfEYKTYHe7OTG5w4xXURVC2swGF pSc8fS5g5cRG+X2cuJK5ExghIDsqoHDcpEDKI0t+ETl0+gw26EIxUW/mGb0DSxatefhh qegNHgtXk+CQp2Mg8KmWKzSCVdrazEPp3+Apc+W1R6FikEAOY6VXqUWD5pTuq5U0ZTYr PAdA== X-Forwarded-Encrypted: i=1; AFNElJ8swMInYQz0IprVgI1Jf10mU6v2lyY8Q4fT9sPoUVxyItRqloKtSaU36MVfwcdn8C0DSsQtYvnSBFOF1a4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyh9Ob5Y/V4jzk1V2Dkpc0JErrscY+eg44PwFVA3cFkZOpyS50V A5fSjfzMJl7yeOsoAWM9iVm2v7PjOB5a1/tom9TtQfJtZhqgvQhpuaPS2Q3jGWRvKhRsb9Q3hXA KVTsWYHtQ5VTozw== X-Received: from pfr4.prod.google.com ([2002:a05:6a00:94c4:b0:836:55e:c2f]) (user=skhawaja job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6a15:b0:3a2:cf6d:a9f7 with SMTP id adf61e73a8af0-3aa3b75b178mr909398637.36.1777940601569; Mon, 04 May 2026 17:23:21 -0700 (PDT) Date: Tue, 5 May 2026 00:23:16 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: <20260505002320.2210067-1-skhawaja@google.com> Subject: [RFC PATCH 0/4] dma-mapping: Add preservation of direct allocations From: Samiullah Khawaja To: Marek Szyprowski , Will Deacon , Jason Gunthorpe Cc: Samiullah Khawaja , Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Alexander Graf , Robin Murphy , Kevin Tian , iommu@lists.linux.dev, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Matlack , Andrew Morton , Pranjal Shrivastava , Vipin Sharma Content-Type: text/plain; charset="UTF-8" This is an RFC to discuss the preservation of DMA allocations for devices that are using direct allocation mode. Note preservation here means preservation of physical memory only using KHO. IOVAs and IOMMU mappings are out of scope. The complexity and need of this was discussed in the thread mentioned below. It was proposed to allow preservation of only a subset of allocations with minimum support. https://lore.kernel.org/all/aepfYzkI7NsVGCF0@google.com/ https://lore.kernel.org/all/aepRy7Gp7Ng85Zr7@willie-the-truck/ Note DMA allocation allows allocation from various allocators in various configurations. This RFC supports preservation with, - Direct Allocation Only. - Pages allocated through alloc_page (Buddy allocator). - No CMA support. - No DMA allocators. The changes are also pushed here: https://github.com/samikhawaja/linux/tree/dma-alloc-preserve-direct Looking forward to your feedback on this. Thanks Samiullah Khawaja (4): dma: Add DMA allocation preservation KHO ABI dma/pool: Add an API to check if DMA allocation is from pool dma-direct: Add API to preserve/restore allocations dma-mapping: Add API to preserve/restore DMA allocation include/linux/dma-direct.h | 29 ++++++ include/linux/dma-map-ops.h | 1 + include/linux/dma-mapping.h | 50 +++++++++ include/linux/kho/abi/dma_alloc.h | 30 ++++++ kernel/dma/Kconfig | 3 + kernel/dma/direct.c | 163 ++++++++++++++++++++++++++++++ kernel/dma/mapping.c | 52 ++++++++++ kernel/dma/pool.c | 13 +++ 8 files changed, 341 insertions(+) create mode 100644 include/linux/kho/abi/dma_alloc.h base-commit: 9974969c14031a097d6b45bcb7a06bb4aa525c40 prerequisite-patch-id: 41f13f37cb3b439f17dfa4e3f2d5c767aaef0346 -- 2.54.0.545.g6539524ca2-goog