History

block: add a helper function to merge the segments

This patch adds a helper function whether a queue can merge the segments by the DMA MAP layer (e.g. via IOMMU).

Yoshihiro Shimoda committed 7 years ago

Commit 45147fb1 parent db914272 files · +25 −0Browse files

Unified · Split

2 files
  1. block/blk-settings.c +23 −0
  2. include/linux/blkdev.h +2 −0
block/blk-settings.c+23−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/lcm.h>
1313 #include <linux/jiffies.h>
1414 #include <linux/gfp.h>
15+#include <linux/dma-mapping.h>
1516
1617 #include "blk.h"
1718 #include "blk-wbt.h"
@@ -832,6 +833,28 @@ void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua) · 814 unmodified lines
832833 }
833834 EXPORT_SYMBOL_GPL(blk_queue_write_cache);
834835
836+/**
837+ * blk_queue_can_use_dma_map_merging - configure queue for merging segments.
838+ * @q: the request queue for the device
839+ * @dev: the device pointer for dma
840+ *
841+ * Tell the block layer about merging the segments by dma map of @q.
842+ */
843+bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
844+ struct device *dev)
845+{
846+ unsigned long boundary = dma_get_merge_boundary(dev);
847+
848+ if (!boundary)
849+ return false;
850+
851+ /* No need to update max_segment_size. see blk_queue_virt_boundary() */
852+ blk_queue_virt_boundary(q, boundary);
853+
854+ return true;
855+}
856+EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
857+
835858 static int __init blk_settings_init(void)
836859 {
837860 blk_max_low_pfn = max_low_pfn - 1;
include/linux/blkdev.h+2−0
@@ -1085,6 +1085,8 @@ extern void blk_queue_dma_alignment(struct request_queue *, int); · 1084 unmodified lines
10851085 extern void blk_queue_update_dma_alignment(struct request_queue *, int);
10861086 extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
10871087 extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);
1088+extern bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
1089+ struct device *dev);
10881090
10891091 /*
10901092 * Number of physical segments as sent to the device.