All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jianxiong Gao <jxgao@google.com>
To: stable@vger.kernel.org
Cc: Jianxiong Gao <jxgao@google.com>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 5.4 1/8] driver core: add a min_align_mask field to struct device_dma_parameters
Date: Mon,  5 Apr 2021 20:51:02 +0000	[thread overview]
Message-ID: <20210405205109.1700468-2-jxgao@google.com> (raw)
In-Reply-To: <20210405205109.1700468-1-jxgao@google.com>

'commit 36950f2da1ea ("driver core: add a min_align_mask field to struct 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@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/device.h      |  1 +
 include/linux/dma-mapping.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 297239a08bb7..2d30a6d7249e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -993,6 +993,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 4a1c4fca475a..c996cd2e72f8 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -747,6 +747,22 @@ 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 (WARN_ON_ONCE(!dev->dma_parms))
+		return -EIO;
+	dev->dma_parms->min_align_mask = min_align_mask;
+	return 0;
+}
+
 static inline int dma_get_cache_alignment(void)
 {
 #ifdef ARCH_DMA_MINALIGN
-- 
2.27.0


  reply	other threads:[~2021-04-05 20:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 20:51 [PATCH 5.4 0/8] preserve DMA offsets when using swiotlb Jianxiong Gao
2021-04-05 20:51 ` Jianxiong Gao [this message]
2021-04-05 20:51 ` [PATCH 5.4 2/8] swiotlb: factor out an io_tlb_offset helper Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 3/8] swiotlb: factor out a nr_slots helper Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 4/8] swiotlb: clean up swiotlb_tbl_unmap_single Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 5/8] swiotlb: refactor swiotlb_tbl_map_single Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 6/8] swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 7/8] swiotlb: respect min_align_mask Jianxiong Gao
2021-04-05 20:51 ` [PATCH 5.4 8/8] nvme-pci: set min_align_mask Jianxiong Gao
2021-04-06 16:10 ` [PATCH 5.4 0/8] preserve DMA offsets when using swiotlb Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210405205109.1700468-2-jxgao@google.com \
    --to=jxgao@google.com \
    --cc=hch@lst.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.