This is a note to let you know that I've just added the patch titled driver core: add a min_align_mask field to struct device_dma_parameters to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: driver-core-add-a-min_align_mask-field-to-struct-device_dma_parameters.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Wed May 5 09:27:45 AM CEST 2021 From: Jianxiong Gao <jxgao@xxxxxxxxxx> Date: Thu, 29 Apr 2021 17:33:07 +0000 Subject: driver core: add a min_align_mask field to struct device_dma_parameters To: stable@xxxxxxxxxxxxxxx, hch@xxxxxx, marcorr@xxxxxxxxxx, sashal@xxxxxxxxxx Cc: Jianxiong Gao <jxgao@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Message-ID: <20210429173315.1252465-2-jxgao@xxxxxxxxxx> From: Jianxiong Gao <jxgao@xxxxxxxxxx> commit: 36950f2da1ea4cb683be174f6f581e25b2d33e71 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@xxxxxxxxxx> Signed-off-by: Christoph Hellwig <hch@xxxxxx> Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- include/linux/device.h | 1 + include/linux/dma-mapping.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) --- 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; }; --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -500,6 +500,22 @@ static inline int dma_set_seg_boundary(s 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 Patches currently in stable-queue which might be from jxgao@xxxxxxxxxx are queue-5.10/swiotlb-respect-min_align_mask.patch queue-5.10/swiotlb-factor-out-a-nr_slots-helper.patch queue-5.10/swiotlb-add-a-io_tlb_size-define.patch queue-5.10/swiotlb-clean-up-swiotlb_tbl_unmap_single.patch queue-5.10/swiotlb-factor-out-an-io_tlb_offset-helper.patch queue-5.10/swiotlb-don-t-modify-orig_addr-in-swiotlb_tbl_sync_single.patch queue-5.10/swiotlb-refactor-swiotlb_tbl_map_single.patch queue-5.10/driver-core-add-a-min_align_mask-field-to-struct-device_dma_parameters.patch queue-5.10/nvme-pci-set-min_align_mask.patch