[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200618160941.879717-3-jonathan.lemon@gmail.com>
Date: Thu, 18 Jun 2020 09:09:22 -0700
From: Jonathan Lemon <jonathan.lemon@...il.com>
To: <netdev@...r.kernel.org>
CC: <kernel-team@...com>, <axboe@...nel.dk>
Subject: [RFC PATCH 02/21] mm: Allow DMA mapping of pages which are not online
Change the system RAM check from 'valid' to 'online', so dummy
pages which refer to external DMA resources can be mapped.
Signed-off-by: Jonathan Lemon <jonathan.lemon@...il.com>
---
include/linux/dma-mapping.h | 4 ++--
include/linux/mmzone.h | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 78f677cf45ab..fb142a01d1ba 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -348,8 +348,8 @@ static inline dma_addr_t dma_map_resource(struct device *dev,
BUG_ON(!valid_dma_direction(dir));
- /* Don't allow RAM to be mapped */
- if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr))))
+ /* Don't allow online RAM to be mapped */
+ if (WARN_ON_ONCE(pfn_online(PHYS_PFN(phys_addr))))
return DMA_MAPPING_ERROR;
if (dma_is_direct(ops))
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index c4c37fd12104..9a9fe5704f97 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1348,6 +1348,13 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr)
return -1;
}
+static inline int pfn_online(unsigned long pfn)
+{
+ if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+ return 0;
+ return online_section(__nr_to_section(pfn_to_section_nr(pfn)));
+}
+
/*
* These are _only_ used during initialisation, therefore they
* can use __initdata ... They could have names to indicate
--
2.24.1
Powered by blists - more mailing lists