[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210201183017.3339130-2-jxgao@google.com>
Date: Mon, 1 Feb 2021 10:30:15 -0800
From: Jianxiong Gao <jxgao@...gle.com>
To: jxgao@...gle.com, erdemaktas@...gle.com, marcorr@...gle.com,
hch@....de, m.szyprowski@...sung.com, robin.murphy@....com,
gregkh@...uxfoundation.org, saravanak@...gle.com,
heikki.krogerus@...ux.intel.com, rafael.j.wysocki@...el.com,
andriy.shevchenko@...ux.intel.com, dan.j.williams@...el.com,
bgolaszewski@...libre.com, jroedel@...e.de,
iommu@...ts.linux-foundation.org, konrad.wilk@...cle.com,
kbusch@...nel.org, axboe@...com, sagi@...mberg.me,
linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH V2 1/3] Adding page_offset_mask to device_dma_parameters
Some devices rely on the address offset in a page to function
correctly (NVMe driver as an example). These devices may use
a different page size than the Linux kernel. The address offset
has to be preserved upon mapping, and in order to do so, we
need to record the page_offset_mask first.
Signed-off-by: Jianxiong Gao <jxgao@...gle.com>
---
include/linux/device.h | 1 +
include/linux/dma-mapping.h | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 1779f90eeb4c..7960bf516dd7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -291,6 +291,7 @@ struct device_dma_parameters {
* sg limitations.
*/
unsigned int max_segment_size;
+ unsigned int min_align_mask;
unsigned long segment_boundary_mask;
};
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 2e49996a8f39..27ec3cab8cbd 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -500,6 +500,23 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
return -EIO;
}
+static inline unsigned int dma_get_min_align_mask(struct device *dev)
+{
+ if (dev->dma_parms)
+ return dev->dma_parms->min_align_mask;
+ return 0;
+}
+
+static inline int dma_set_min_align_mask(struct device *dev,
+ unsigned int min_align_mask)
+{
+ if (dev->dma_parms) {
+ dev->dma_parms->min_align_mask = min_align_mask;
+ return 0;
+ }
+ return -EIO;
+}
+
static inline int dma_get_cache_alignment(void)
{
#ifdef ARCH_DMA_MINALIGN
--
2.27.0
Powered by blists - more mailing lists