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
12#include <linux/lcm.h>12#include <linux/lcm.h>
13#include <linux/jiffies.h>13#include <linux/jiffies.h>
14#include <linux/gfp.h>14#include <linux/gfp.h>
15#include <linux/dma-mapping.h>
15 16
16#include "blk.h"17#include "blk.h"
17#include "blk-wbt.h"18#include "blk-wbt.h"
@@ -832,6 +833,28 @@ void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua) · 814 unmodified lines
832}833}
833EXPORT_SYMBOL_GPL(blk_queue_write_cache);834EXPORT_SYMBOL_GPL(blk_queue_write_cache);
834 835
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 */
843bool 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}
856EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
857
835static int __init blk_settings_init(void)858static int __init blk_settings_init(void)
836{859{
837 blk_max_low_pfn = max_low_pfn - 1;860 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
1085extern void blk_queue_update_dma_alignment(struct request_queue *, int);1085extern void blk_queue_update_dma_alignment(struct request_queue *, int);
1086extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);1086extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
1087extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);1087extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);
1088extern bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
1089 struct device *dev);
1088 1090
1089/*1091/*
1090 * Number of physical segments as sent to the device.1092 * Number of physical segments as sent to the device.