xref: /linux/block/blk-settings.c (revision 3a02c8e8142f7f133d4c6e72bc3e1d830e6b8b9e)
186db1e29SJens Axboe /*
286db1e29SJens Axboe  * Functions related to setting various queue properties from drivers
386db1e29SJens Axboe  */
486db1e29SJens Axboe #include <linux/kernel.h>
586db1e29SJens Axboe #include <linux/module.h>
686db1e29SJens Axboe #include <linux/init.h>
786db1e29SJens Axboe #include <linux/bio.h>
886db1e29SJens Axboe #include <linux/blkdev.h>
986db1e29SJens Axboe #include <linux/bootmem.h>	/* for max_pfn/max_low_pfn */
1086db1e29SJens Axboe 
1186db1e29SJens Axboe #include "blk.h"
1286db1e29SJens Axboe 
136728cb0eSJens Axboe unsigned long blk_max_low_pfn;
1486db1e29SJens Axboe EXPORT_SYMBOL(blk_max_low_pfn);
156728cb0eSJens Axboe 
166728cb0eSJens Axboe unsigned long blk_max_pfn;
1786db1e29SJens Axboe 
1886db1e29SJens Axboe /**
1986db1e29SJens Axboe  * blk_queue_prep_rq - set a prepare_request function for queue
2086db1e29SJens Axboe  * @q:		queue
2186db1e29SJens Axboe  * @pfn:	prepare_request function
2286db1e29SJens Axboe  *
2386db1e29SJens Axboe  * It's possible for a queue to register a prepare_request callback which
2486db1e29SJens Axboe  * is invoked before the request is handed to the request_fn. The goal of
2586db1e29SJens Axboe  * the function is to prepare a request for I/O, it can be used to build a
2686db1e29SJens Axboe  * cdb from the request data for instance.
2786db1e29SJens Axboe  *
2886db1e29SJens Axboe  */
2986db1e29SJens Axboe void blk_queue_prep_rq(struct request_queue *q, prep_rq_fn *pfn)
3086db1e29SJens Axboe {
3186db1e29SJens Axboe 	q->prep_rq_fn = pfn;
3286db1e29SJens Axboe }
3386db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_prep_rq);
3486db1e29SJens Axboe 
3586db1e29SJens Axboe /**
36fb2dce86SDavid Woodhouse  * blk_queue_set_discard - set a discard_sectors function for queue
37fb2dce86SDavid Woodhouse  * @q:		queue
38fb2dce86SDavid Woodhouse  * @dfn:	prepare_discard function
39fb2dce86SDavid Woodhouse  *
40fb2dce86SDavid Woodhouse  * It's possible for a queue to register a discard callback which is used
41fb2dce86SDavid Woodhouse  * to transform a discard request into the appropriate type for the
42fb2dce86SDavid Woodhouse  * hardware. If none is registered, then discard requests are failed
43fb2dce86SDavid Woodhouse  * with %EOPNOTSUPP.
44fb2dce86SDavid Woodhouse  *
45fb2dce86SDavid Woodhouse  */
46fb2dce86SDavid Woodhouse void blk_queue_set_discard(struct request_queue *q, prepare_discard_fn *dfn)
47fb2dce86SDavid Woodhouse {
48fb2dce86SDavid Woodhouse 	q->prepare_discard_fn = dfn;
49fb2dce86SDavid Woodhouse }
50fb2dce86SDavid Woodhouse EXPORT_SYMBOL(blk_queue_set_discard);
51fb2dce86SDavid Woodhouse 
52fb2dce86SDavid Woodhouse /**
5386db1e29SJens Axboe  * blk_queue_merge_bvec - set a merge_bvec function for queue
5486db1e29SJens Axboe  * @q:		queue
5586db1e29SJens Axboe  * @mbfn:	merge_bvec_fn
5686db1e29SJens Axboe  *
5786db1e29SJens Axboe  * Usually queues have static limitations on the max sectors or segments that
5886db1e29SJens Axboe  * we can put in a request. Stacking drivers may have some settings that
5986db1e29SJens Axboe  * are dynamic, and thus we have to query the queue whether it is ok to
6086db1e29SJens Axboe  * add a new bio_vec to a bio at a given offset or not. If the block device
6186db1e29SJens Axboe  * has such limitations, it needs to register a merge_bvec_fn to control
6286db1e29SJens Axboe  * the size of bio's sent to it. Note that a block device *must* allow a
6386db1e29SJens Axboe  * single page to be added to an empty bio. The block device driver may want
6486db1e29SJens Axboe  * to use the bio_split() function to deal with these bio's. By default
6586db1e29SJens Axboe  * no merge_bvec_fn is defined for a queue, and only the fixed limits are
6686db1e29SJens Axboe  * honored.
6786db1e29SJens Axboe  */
6886db1e29SJens Axboe void blk_queue_merge_bvec(struct request_queue *q, merge_bvec_fn *mbfn)
6986db1e29SJens Axboe {
7086db1e29SJens Axboe 	q->merge_bvec_fn = mbfn;
7186db1e29SJens Axboe }
7286db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_merge_bvec);
7386db1e29SJens Axboe 
7486db1e29SJens Axboe void blk_queue_softirq_done(struct request_queue *q, softirq_done_fn *fn)
7586db1e29SJens Axboe {
7686db1e29SJens Axboe 	q->softirq_done_fn = fn;
7786db1e29SJens Axboe }
7886db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_softirq_done);
7986db1e29SJens Axboe 
80242f9dcbSJens Axboe void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout)
81242f9dcbSJens Axboe {
82242f9dcbSJens Axboe 	q->rq_timeout = timeout;
83242f9dcbSJens Axboe }
84242f9dcbSJens Axboe EXPORT_SYMBOL_GPL(blk_queue_rq_timeout);
85242f9dcbSJens Axboe 
86242f9dcbSJens Axboe void blk_queue_rq_timed_out(struct request_queue *q, rq_timed_out_fn *fn)
87242f9dcbSJens Axboe {
88242f9dcbSJens Axboe 	q->rq_timed_out_fn = fn;
89242f9dcbSJens Axboe }
90242f9dcbSJens Axboe EXPORT_SYMBOL_GPL(blk_queue_rq_timed_out);
91242f9dcbSJens Axboe 
92ef9e3facSKiyoshi Ueda void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn)
93ef9e3facSKiyoshi Ueda {
94ef9e3facSKiyoshi Ueda 	q->lld_busy_fn = fn;
95ef9e3facSKiyoshi Ueda }
96ef9e3facSKiyoshi Ueda EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
97ef9e3facSKiyoshi Ueda 
9886db1e29SJens Axboe /**
99e475bba2SMartin K. Petersen  * blk_set_default_limits - reset limits to default values
100e475bba2SMartin K. Petersen  * @limits:  the queue_limits structure to reset
101e475bba2SMartin K. Petersen  *
102e475bba2SMartin K. Petersen  * Description:
103e475bba2SMartin K. Petersen  *   Returns a queue_limit struct to its default state.  Can be used by
104e475bba2SMartin K. Petersen  *   stacking drivers like DM that stage table swaps and reuse an
105e475bba2SMartin K. Petersen  *   existing device queue.
106e475bba2SMartin K. Petersen  */
107e475bba2SMartin K. Petersen void blk_set_default_limits(struct queue_limits *lim)
108e475bba2SMartin K. Petersen {
109e475bba2SMartin K. Petersen 	lim->max_phys_segments = MAX_PHYS_SEGMENTS;
110e475bba2SMartin K. Petersen 	lim->max_hw_segments = MAX_HW_SEGMENTS;
111e475bba2SMartin K. Petersen 	lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
112e475bba2SMartin K. Petersen 	lim->max_segment_size = MAX_SEGMENT_SIZE;
113e475bba2SMartin K. Petersen 	lim->max_sectors = lim->max_hw_sectors = SAFE_MAX_SECTORS;
114e475bba2SMartin K. Petersen 	lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
115*3a02c8e8SMartin K. Petersen 	lim->bounce_pfn = (unsigned long)(BLK_BOUNCE_ANY >> PAGE_SHIFT);
116e475bba2SMartin K. Petersen 	lim->alignment_offset = 0;
117e475bba2SMartin K. Petersen 	lim->io_opt = 0;
118e475bba2SMartin K. Petersen 	lim->misaligned = 0;
119e475bba2SMartin K. Petersen 	lim->no_cluster = 0;
120e475bba2SMartin K. Petersen }
121e475bba2SMartin K. Petersen EXPORT_SYMBOL(blk_set_default_limits);
122e475bba2SMartin K. Petersen 
123e475bba2SMartin K. Petersen /**
12486db1e29SJens Axboe  * blk_queue_make_request - define an alternate make_request function for a device
12586db1e29SJens Axboe  * @q:  the request queue for the device to be affected
12686db1e29SJens Axboe  * @mfn: the alternate make_request function
12786db1e29SJens Axboe  *
12886db1e29SJens Axboe  * Description:
12986db1e29SJens Axboe  *    The normal way for &struct bios to be passed to a device
13086db1e29SJens Axboe  *    driver is for them to be collected into requests on a request
13186db1e29SJens Axboe  *    queue, and then to allow the device driver to select requests
13286db1e29SJens Axboe  *    off that queue when it is ready.  This works well for many block
13386db1e29SJens Axboe  *    devices. However some block devices (typically virtual devices
13486db1e29SJens Axboe  *    such as md or lvm) do not benefit from the processing on the
13586db1e29SJens Axboe  *    request queue, and are served best by having the requests passed
13686db1e29SJens Axboe  *    directly to them.  This can be achieved by providing a function
13786db1e29SJens Axboe  *    to blk_queue_make_request().
13886db1e29SJens Axboe  *
13986db1e29SJens Axboe  * Caveat:
14086db1e29SJens Axboe  *    The driver that does this *must* be able to deal appropriately
14186db1e29SJens Axboe  *    with buffers in "highmemory". This can be accomplished by either calling
14286db1e29SJens Axboe  *    __bio_kmap_atomic() to get a temporary kernel mapping, or by calling
14386db1e29SJens Axboe  *    blk_queue_bounce() to create a buffer in normal memory.
14486db1e29SJens Axboe  **/
14586db1e29SJens Axboe void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn)
14686db1e29SJens Axboe {
14786db1e29SJens Axboe 	/*
14886db1e29SJens Axboe 	 * set defaults
14986db1e29SJens Axboe 	 */
15086db1e29SJens Axboe 	q->nr_requests = BLKDEV_MAX_RQ;
1510e435ac2SMilan Broz 
15286db1e29SJens Axboe 	q->make_request_fn = mfn;
15386db1e29SJens Axboe 	blk_queue_dma_alignment(q, 511);
15486db1e29SJens Axboe 	blk_queue_congestion_threshold(q);
15586db1e29SJens Axboe 	q->nr_batching = BLK_BATCH_REQ;
15686db1e29SJens Axboe 
15786db1e29SJens Axboe 	q->unplug_thresh = 4;		/* hmm */
15886db1e29SJens Axboe 	q->unplug_delay = (3 * HZ) / 1000;	/* 3 milliseconds */
15986db1e29SJens Axboe 	if (q->unplug_delay == 0)
16086db1e29SJens Axboe 		q->unplug_delay = 1;
16186db1e29SJens Axboe 
16286db1e29SJens Axboe 	q->unplug_timer.function = blk_unplug_timeout;
16386db1e29SJens Axboe 	q->unplug_timer.data = (unsigned long)q;
16486db1e29SJens Axboe 
165e475bba2SMartin K. Petersen 	blk_set_default_limits(&q->limits);
166e475bba2SMartin K. Petersen 
16786db1e29SJens Axboe 	/*
16886db1e29SJens Axboe 	 * by default assume old behaviour and bounce for any highmem page
16986db1e29SJens Axboe 	 */
17086db1e29SJens Axboe 	blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
17186db1e29SJens Axboe }
17286db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_make_request);
17386db1e29SJens Axboe 
17486db1e29SJens Axboe /**
17586db1e29SJens Axboe  * blk_queue_bounce_limit - set bounce buffer limit for queue
17686db1e29SJens Axboe  * @q: the request queue for the device
177cd0aca2dSTejun Heo  * @dma_mask: the maximum address the device can handle
17886db1e29SJens Axboe  *
17986db1e29SJens Axboe  * Description:
18086db1e29SJens Axboe  *    Different hardware can have different requirements as to what pages
18186db1e29SJens Axboe  *    it can do I/O directly to. A low level driver can call
18286db1e29SJens Axboe  *    blk_queue_bounce_limit to have lower memory pages allocated as bounce
183cd0aca2dSTejun Heo  *    buffers for doing I/O to pages residing above @dma_mask.
18486db1e29SJens Axboe  **/
185cd0aca2dSTejun Heo void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask)
18686db1e29SJens Axboe {
187cd0aca2dSTejun Heo 	unsigned long b_pfn = dma_mask >> PAGE_SHIFT;
18886db1e29SJens Axboe 	int dma = 0;
18986db1e29SJens Axboe 
19086db1e29SJens Axboe 	q->bounce_gfp = GFP_NOIO;
19186db1e29SJens Axboe #if BITS_PER_LONG == 64
192cd0aca2dSTejun Heo 	/*
193cd0aca2dSTejun Heo 	 * Assume anything <= 4GB can be handled by IOMMU.  Actually
194cd0aca2dSTejun Heo 	 * some IOMMUs can handle everything, but I don't know of a
195cd0aca2dSTejun Heo 	 * way to test this here.
196cd0aca2dSTejun Heo 	 */
197cd0aca2dSTejun Heo 	if (b_pfn < (min_t(u64, 0xffffffffUL, BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
19886db1e29SJens Axboe 		dma = 1;
199025146e1SMartin K. Petersen 	q->limits.bounce_pfn = max_low_pfn;
20086db1e29SJens Axboe #else
2016728cb0eSJens Axboe 	if (b_pfn < blk_max_low_pfn)
20286db1e29SJens Axboe 		dma = 1;
203025146e1SMartin K. Petersen 	q->limits.bounce_pfn = b_pfn;
20486db1e29SJens Axboe #endif
20586db1e29SJens Axboe 	if (dma) {
20686db1e29SJens Axboe 		init_emergency_isa_pool();
20786db1e29SJens Axboe 		q->bounce_gfp = GFP_NOIO | GFP_DMA;
208025146e1SMartin K. Petersen 		q->limits.bounce_pfn = b_pfn;
20986db1e29SJens Axboe 	}
21086db1e29SJens Axboe }
21186db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_bounce_limit);
21286db1e29SJens Axboe 
21386db1e29SJens Axboe /**
21486db1e29SJens Axboe  * blk_queue_max_sectors - set max sectors for a request for this queue
21586db1e29SJens Axboe  * @q:  the request queue for the device
21686db1e29SJens Axboe  * @max_sectors:  max sectors in the usual 512b unit
21786db1e29SJens Axboe  *
21886db1e29SJens Axboe  * Description:
21986db1e29SJens Axboe  *    Enables a low level driver to set an upper limit on the size of
22086db1e29SJens Axboe  *    received requests.
22186db1e29SJens Axboe  **/
22286db1e29SJens Axboe void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors)
22386db1e29SJens Axboe {
22486db1e29SJens Axboe 	if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
22586db1e29SJens Axboe 		max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
22624c03d47SHarvey Harrison 		printk(KERN_INFO "%s: set to minimum %d\n",
22724c03d47SHarvey Harrison 		       __func__, max_sectors);
22886db1e29SJens Axboe 	}
22986db1e29SJens Axboe 
23086db1e29SJens Axboe 	if (BLK_DEF_MAX_SECTORS > max_sectors)
231025146e1SMartin K. Petersen 		q->limits.max_hw_sectors = q->limits.max_sectors = max_sectors;
23286db1e29SJens Axboe 	else {
233025146e1SMartin K. Petersen 		q->limits.max_sectors = BLK_DEF_MAX_SECTORS;
234025146e1SMartin K. Petersen 		q->limits.max_hw_sectors = max_sectors;
23586db1e29SJens Axboe 	}
23686db1e29SJens Axboe }
23786db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_max_sectors);
23886db1e29SJens Axboe 
239ae03bf63SMartin K. Petersen void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_sectors)
240ae03bf63SMartin K. Petersen {
241ae03bf63SMartin K. Petersen 	if (BLK_DEF_MAX_SECTORS > max_sectors)
242025146e1SMartin K. Petersen 		q->limits.max_hw_sectors = BLK_DEF_MAX_SECTORS;
243ae03bf63SMartin K. Petersen 	else
244025146e1SMartin K. Petersen 		q->limits.max_hw_sectors = max_sectors;
245ae03bf63SMartin K. Petersen }
246ae03bf63SMartin K. Petersen EXPORT_SYMBOL(blk_queue_max_hw_sectors);
247ae03bf63SMartin K. Petersen 
24886db1e29SJens Axboe /**
24986db1e29SJens Axboe  * blk_queue_max_phys_segments - set max phys segments for a request for this queue
25086db1e29SJens Axboe  * @q:  the request queue for the device
25186db1e29SJens Axboe  * @max_segments:  max number of segments
25286db1e29SJens Axboe  *
25386db1e29SJens Axboe  * Description:
25486db1e29SJens Axboe  *    Enables a low level driver to set an upper limit on the number of
25586db1e29SJens Axboe  *    physical data segments in a request.  This would be the largest sized
25686db1e29SJens Axboe  *    scatter list the driver could handle.
25786db1e29SJens Axboe  **/
25886db1e29SJens Axboe void blk_queue_max_phys_segments(struct request_queue *q,
25986db1e29SJens Axboe 				 unsigned short max_segments)
26086db1e29SJens Axboe {
26186db1e29SJens Axboe 	if (!max_segments) {
26286db1e29SJens Axboe 		max_segments = 1;
26324c03d47SHarvey Harrison 		printk(KERN_INFO "%s: set to minimum %d\n",
26424c03d47SHarvey Harrison 		       __func__, max_segments);
26586db1e29SJens Axboe 	}
26686db1e29SJens Axboe 
267025146e1SMartin K. Petersen 	q->limits.max_phys_segments = max_segments;
26886db1e29SJens Axboe }
26986db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_max_phys_segments);
27086db1e29SJens Axboe 
27186db1e29SJens Axboe /**
27286db1e29SJens Axboe  * blk_queue_max_hw_segments - set max hw segments for a request for this queue
27386db1e29SJens Axboe  * @q:  the request queue for the device
27486db1e29SJens Axboe  * @max_segments:  max number of segments
27586db1e29SJens Axboe  *
27686db1e29SJens Axboe  * Description:
27786db1e29SJens Axboe  *    Enables a low level driver to set an upper limit on the number of
27886db1e29SJens Axboe  *    hw data segments in a request.  This would be the largest number of
279710027a4SRandy Dunlap  *    address/length pairs the host adapter can actually give at once
28086db1e29SJens Axboe  *    to the device.
28186db1e29SJens Axboe  **/
28286db1e29SJens Axboe void blk_queue_max_hw_segments(struct request_queue *q,
28386db1e29SJens Axboe 			       unsigned short max_segments)
28486db1e29SJens Axboe {
28586db1e29SJens Axboe 	if (!max_segments) {
28686db1e29SJens Axboe 		max_segments = 1;
28724c03d47SHarvey Harrison 		printk(KERN_INFO "%s: set to minimum %d\n",
28824c03d47SHarvey Harrison 		       __func__, max_segments);
28986db1e29SJens Axboe 	}
29086db1e29SJens Axboe 
291025146e1SMartin K. Petersen 	q->limits.max_hw_segments = max_segments;
29286db1e29SJens Axboe }
29386db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_max_hw_segments);
29486db1e29SJens Axboe 
29586db1e29SJens Axboe /**
29686db1e29SJens Axboe  * blk_queue_max_segment_size - set max segment size for blk_rq_map_sg
29786db1e29SJens Axboe  * @q:  the request queue for the device
29886db1e29SJens Axboe  * @max_size:  max size of segment in bytes
29986db1e29SJens Axboe  *
30086db1e29SJens Axboe  * Description:
30186db1e29SJens Axboe  *    Enables a low level driver to set an upper limit on the size of a
30286db1e29SJens Axboe  *    coalesced segment
30386db1e29SJens Axboe  **/
30486db1e29SJens Axboe void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
30586db1e29SJens Axboe {
30686db1e29SJens Axboe 	if (max_size < PAGE_CACHE_SIZE) {
30786db1e29SJens Axboe 		max_size = PAGE_CACHE_SIZE;
30824c03d47SHarvey Harrison 		printk(KERN_INFO "%s: set to minimum %d\n",
30924c03d47SHarvey Harrison 		       __func__, max_size);
31086db1e29SJens Axboe 	}
31186db1e29SJens Axboe 
312025146e1SMartin K. Petersen 	q->limits.max_segment_size = max_size;
31386db1e29SJens Axboe }
31486db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_max_segment_size);
31586db1e29SJens Axboe 
31686db1e29SJens Axboe /**
317e1defc4fSMartin K. Petersen  * blk_queue_logical_block_size - set logical block size for the queue
31886db1e29SJens Axboe  * @q:  the request queue for the device
319e1defc4fSMartin K. Petersen  * @size:  the logical block size, in bytes
32086db1e29SJens Axboe  *
32186db1e29SJens Axboe  * Description:
322e1defc4fSMartin K. Petersen  *   This should be set to the lowest possible block size that the
323e1defc4fSMartin K. Petersen  *   storage device can address.  The default of 512 covers most
324e1defc4fSMartin K. Petersen  *   hardware.
32586db1e29SJens Axboe  **/
326e1defc4fSMartin K. Petersen void blk_queue_logical_block_size(struct request_queue *q, unsigned short size)
32786db1e29SJens Axboe {
328025146e1SMartin K. Petersen 	q->limits.logical_block_size = size;
329c72758f3SMartin K. Petersen 
330c72758f3SMartin K. Petersen 	if (q->limits.physical_block_size < size)
331c72758f3SMartin K. Petersen 		q->limits.physical_block_size = size;
332c72758f3SMartin K. Petersen 
333c72758f3SMartin K. Petersen 	if (q->limits.io_min < q->limits.physical_block_size)
334c72758f3SMartin K. Petersen 		q->limits.io_min = q->limits.physical_block_size;
33586db1e29SJens Axboe }
336e1defc4fSMartin K. Petersen EXPORT_SYMBOL(blk_queue_logical_block_size);
33786db1e29SJens Axboe 
338c72758f3SMartin K. Petersen /**
339c72758f3SMartin K. Petersen  * blk_queue_physical_block_size - set physical block size for the queue
340c72758f3SMartin K. Petersen  * @q:  the request queue for the device
341c72758f3SMartin K. Petersen  * @size:  the physical block size, in bytes
342c72758f3SMartin K. Petersen  *
343c72758f3SMartin K. Petersen  * Description:
344c72758f3SMartin K. Petersen  *   This should be set to the lowest possible sector size that the
345c72758f3SMartin K. Petersen  *   hardware can operate on without reverting to read-modify-write
346c72758f3SMartin K. Petersen  *   operations.
347c72758f3SMartin K. Petersen  */
348c72758f3SMartin K. Petersen void blk_queue_physical_block_size(struct request_queue *q, unsigned short size)
349c72758f3SMartin K. Petersen {
350c72758f3SMartin K. Petersen 	q->limits.physical_block_size = size;
351c72758f3SMartin K. Petersen 
352c72758f3SMartin K. Petersen 	if (q->limits.physical_block_size < q->limits.logical_block_size)
353c72758f3SMartin K. Petersen 		q->limits.physical_block_size = q->limits.logical_block_size;
354c72758f3SMartin K. Petersen 
355c72758f3SMartin K. Petersen 	if (q->limits.io_min < q->limits.physical_block_size)
356c72758f3SMartin K. Petersen 		q->limits.io_min = q->limits.physical_block_size;
357c72758f3SMartin K. Petersen }
358c72758f3SMartin K. Petersen EXPORT_SYMBOL(blk_queue_physical_block_size);
359c72758f3SMartin K. Petersen 
360c72758f3SMartin K. Petersen /**
361c72758f3SMartin K. Petersen  * blk_queue_alignment_offset - set physical block alignment offset
362c72758f3SMartin K. Petersen  * @q:	the request queue for the device
3638ebf9756SRandy Dunlap  * @offset: alignment offset in bytes
364c72758f3SMartin K. Petersen  *
365c72758f3SMartin K. Petersen  * Description:
366c72758f3SMartin K. Petersen  *   Some devices are naturally misaligned to compensate for things like
367c72758f3SMartin K. Petersen  *   the legacy DOS partition table 63-sector offset.  Low-level drivers
368c72758f3SMartin K. Petersen  *   should call this function for devices whose first sector is not
369c72758f3SMartin K. Petersen  *   naturally aligned.
370c72758f3SMartin K. Petersen  */
371c72758f3SMartin K. Petersen void blk_queue_alignment_offset(struct request_queue *q, unsigned int offset)
372c72758f3SMartin K. Petersen {
373c72758f3SMartin K. Petersen 	q->limits.alignment_offset =
374c72758f3SMartin K. Petersen 		offset & (q->limits.physical_block_size - 1);
375c72758f3SMartin K. Petersen 	q->limits.misaligned = 0;
376c72758f3SMartin K. Petersen }
377c72758f3SMartin K. Petersen EXPORT_SYMBOL(blk_queue_alignment_offset);
378c72758f3SMartin K. Petersen 
379c72758f3SMartin K. Petersen /**
380c72758f3SMartin K. Petersen  * blk_queue_io_min - set minimum request size for the queue
381c72758f3SMartin K. Petersen  * @q:	the request queue for the device
3828ebf9756SRandy Dunlap  * @min:  smallest I/O size in bytes
383c72758f3SMartin K. Petersen  *
384c72758f3SMartin K. Petersen  * Description:
385c72758f3SMartin K. Petersen  *   Some devices have an internal block size bigger than the reported
386c72758f3SMartin K. Petersen  *   hardware sector size.  This function can be used to signal the
387c72758f3SMartin K. Petersen  *   smallest I/O the device can perform without incurring a performance
388c72758f3SMartin K. Petersen  *   penalty.
389c72758f3SMartin K. Petersen  */
390c72758f3SMartin K. Petersen void blk_queue_io_min(struct request_queue *q, unsigned int min)
391c72758f3SMartin K. Petersen {
392c72758f3SMartin K. Petersen 	q->limits.io_min = min;
393c72758f3SMartin K. Petersen 
394c72758f3SMartin K. Petersen 	if (q->limits.io_min < q->limits.logical_block_size)
395c72758f3SMartin K. Petersen 		q->limits.io_min = q->limits.logical_block_size;
396c72758f3SMartin K. Petersen 
397c72758f3SMartin K. Petersen 	if (q->limits.io_min < q->limits.physical_block_size)
398c72758f3SMartin K. Petersen 		q->limits.io_min = q->limits.physical_block_size;
399c72758f3SMartin K. Petersen }
400c72758f3SMartin K. Petersen EXPORT_SYMBOL(blk_queue_io_min);
401c72758f3SMartin K. Petersen 
402c72758f3SMartin K. Petersen /**
403c72758f3SMartin K. Petersen  * blk_queue_io_opt - set optimal request size for the queue
404c72758f3SMartin K. Petersen  * @q:	the request queue for the device
4058ebf9756SRandy Dunlap  * @opt:  optimal request size in bytes
406c72758f3SMartin K. Petersen  *
407c72758f3SMartin K. Petersen  * Description:
408c72758f3SMartin K. Petersen  *   Drivers can call this function to set the preferred I/O request
409c72758f3SMartin K. Petersen  *   size for devices that report such a value.
410c72758f3SMartin K. Petersen  */
411c72758f3SMartin K. Petersen void blk_queue_io_opt(struct request_queue *q, unsigned int opt)
412c72758f3SMartin K. Petersen {
413c72758f3SMartin K. Petersen 	q->limits.io_opt = opt;
414c72758f3SMartin K. Petersen }
415c72758f3SMartin K. Petersen EXPORT_SYMBOL(blk_queue_io_opt);
416c72758f3SMartin K. Petersen 
41786db1e29SJens Axboe /*
41886db1e29SJens Axboe  * Returns the minimum that is _not_ zero, unless both are zero.
41986db1e29SJens Axboe  */
42086db1e29SJens Axboe #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
42186db1e29SJens Axboe 
42286db1e29SJens Axboe /**
42386db1e29SJens Axboe  * blk_queue_stack_limits - inherit underlying queue limits for stacked drivers
42486db1e29SJens Axboe  * @t:	the stacking driver (top)
42586db1e29SJens Axboe  * @b:  the underlying device (bottom)
42686db1e29SJens Axboe  **/
42786db1e29SJens Axboe void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
42886db1e29SJens Axboe {
42986db1e29SJens Axboe 	/* zero is "infinity" */
430025146e1SMartin K. Petersen 	t->limits.max_sectors = min_not_zero(queue_max_sectors(t),
431025146e1SMartin K. Petersen 					     queue_max_sectors(b));
43286db1e29SJens Axboe 
433025146e1SMartin K. Petersen 	t->limits.max_hw_sectors = min_not_zero(queue_max_hw_sectors(t),
434025146e1SMartin K. Petersen 						queue_max_hw_sectors(b));
435025146e1SMartin K. Petersen 
436025146e1SMartin K. Petersen 	t->limits.seg_boundary_mask = min_not_zero(queue_segment_boundary(t),
437025146e1SMartin K. Petersen 						   queue_segment_boundary(b));
438025146e1SMartin K. Petersen 
439025146e1SMartin K. Petersen 	t->limits.max_phys_segments = min_not_zero(queue_max_phys_segments(t),
440025146e1SMartin K. Petersen 						   queue_max_phys_segments(b));
441025146e1SMartin K. Petersen 
442025146e1SMartin K. Petersen 	t->limits.max_hw_segments = min_not_zero(queue_max_hw_segments(t),
443025146e1SMartin K. Petersen 						 queue_max_hw_segments(b));
444025146e1SMartin K. Petersen 
445025146e1SMartin K. Petersen 	t->limits.max_segment_size = min_not_zero(queue_max_segment_size(t),
446025146e1SMartin K. Petersen 						  queue_max_segment_size(b));
447025146e1SMartin K. Petersen 
448025146e1SMartin K. Petersen 	t->limits.logical_block_size = max(queue_logical_block_size(t),
449025146e1SMartin K. Petersen 					   queue_logical_block_size(b));
450025146e1SMartin K. Petersen 
451e7e72bf6SNeil Brown 	if (!t->queue_lock)
452e7e72bf6SNeil Brown 		WARN_ON_ONCE(1);
453e7e72bf6SNeil Brown 	else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
454e7e72bf6SNeil Brown 		unsigned long flags;
455e7e72bf6SNeil Brown 		spin_lock_irqsave(t->queue_lock, flags);
45675ad23bcSNick Piggin 		queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
457e7e72bf6SNeil Brown 		spin_unlock_irqrestore(t->queue_lock, flags);
458e7e72bf6SNeil Brown 	}
45986db1e29SJens Axboe }
46086db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_stack_limits);
46186db1e29SJens Axboe 
46286db1e29SJens Axboe /**
463c72758f3SMartin K. Petersen  * blk_stack_limits - adjust queue_limits for stacked devices
464c72758f3SMartin K. Petersen  * @t:	the stacking driver limits (top)
46577634f33SMartin K. Petersen  * @b:  the underlying queue limits (bottom)
466c72758f3SMartin K. Petersen  * @offset:  offset to beginning of data within component device
467c72758f3SMartin K. Petersen  *
468c72758f3SMartin K. Petersen  * Description:
469c72758f3SMartin K. Petersen  *    Merges two queue_limit structs.  Returns 0 if alignment didn't
470c72758f3SMartin K. Petersen  *    change.  Returns -1 if adding the bottom device caused
471c72758f3SMartin K. Petersen  *    misalignment.
472c72758f3SMartin K. Petersen  */
473c72758f3SMartin K. Petersen int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
474c72758f3SMartin K. Petersen 		     sector_t offset)
475c72758f3SMartin K. Petersen {
476c72758f3SMartin K. Petersen 	t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
477c72758f3SMartin K. Petersen 	t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
47877634f33SMartin K. Petersen 	t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn);
479c72758f3SMartin K. Petersen 
480c72758f3SMartin K. Petersen 	t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask,
481c72758f3SMartin K. Petersen 					    b->seg_boundary_mask);
482c72758f3SMartin K. Petersen 
483c72758f3SMartin K. Petersen 	t->max_phys_segments = min_not_zero(t->max_phys_segments,
484c72758f3SMartin K. Petersen 					    b->max_phys_segments);
485c72758f3SMartin K. Petersen 
486c72758f3SMartin K. Petersen 	t->max_hw_segments = min_not_zero(t->max_hw_segments,
487c72758f3SMartin K. Petersen 					  b->max_hw_segments);
488c72758f3SMartin K. Petersen 
489c72758f3SMartin K. Petersen 	t->max_segment_size = min_not_zero(t->max_segment_size,
490c72758f3SMartin K. Petersen 					   b->max_segment_size);
491c72758f3SMartin K. Petersen 
492c72758f3SMartin K. Petersen 	t->logical_block_size = max(t->logical_block_size,
493c72758f3SMartin K. Petersen 				    b->logical_block_size);
494c72758f3SMartin K. Petersen 
495c72758f3SMartin K. Petersen 	t->physical_block_size = max(t->physical_block_size,
496c72758f3SMartin K. Petersen 				     b->physical_block_size);
497c72758f3SMartin K. Petersen 
498c72758f3SMartin K. Petersen 	t->io_min = max(t->io_min, b->io_min);
499c72758f3SMartin K. Petersen 	t->no_cluster |= b->no_cluster;
500c72758f3SMartin K. Petersen 
501c72758f3SMartin K. Petersen 	/* Bottom device offset aligned? */
502c72758f3SMartin K. Petersen 	if (offset &&
503c72758f3SMartin K. Petersen 	    (offset & (b->physical_block_size - 1)) != b->alignment_offset) {
504c72758f3SMartin K. Petersen 		t->misaligned = 1;
505c72758f3SMartin K. Petersen 		return -1;
506c72758f3SMartin K. Petersen 	}
507c72758f3SMartin K. Petersen 
508c72758f3SMartin K. Petersen 	/* If top has no alignment offset, inherit from bottom */
509c72758f3SMartin K. Petersen 	if (!t->alignment_offset)
510c72758f3SMartin K. Petersen 		t->alignment_offset =
511c72758f3SMartin K. Petersen 			b->alignment_offset & (b->physical_block_size - 1);
512c72758f3SMartin K. Petersen 
513c72758f3SMartin K. Petersen 	/* Top device aligned on logical block boundary? */
514c72758f3SMartin K. Petersen 	if (t->alignment_offset & (t->logical_block_size - 1)) {
515c72758f3SMartin K. Petersen 		t->misaligned = 1;
516c72758f3SMartin K. Petersen 		return -1;
517c72758f3SMartin K. Petersen 	}
518c72758f3SMartin K. Petersen 
519c72758f3SMartin K. Petersen 	return 0;
520c72758f3SMartin K. Petersen }
5215d85d324SMike Snitzer EXPORT_SYMBOL(blk_stack_limits);
522c72758f3SMartin K. Petersen 
523c72758f3SMartin K. Petersen /**
524c72758f3SMartin K. Petersen  * disk_stack_limits - adjust queue limits for stacked drivers
52577634f33SMartin K. Petersen  * @disk:  MD/DM gendisk (top)
526c72758f3SMartin K. Petersen  * @bdev:  the underlying block device (bottom)
527c72758f3SMartin K. Petersen  * @offset:  offset to beginning of data within component device
528c72758f3SMartin K. Petersen  *
529c72758f3SMartin K. Petersen  * Description:
530c72758f3SMartin K. Petersen  *    Merges the limits for two queues.  Returns 0 if alignment
531c72758f3SMartin K. Petersen  *    didn't change.  Returns -1 if adding the bottom device caused
532c72758f3SMartin K. Petersen  *    misalignment.
533c72758f3SMartin K. Petersen  */
534c72758f3SMartin K. Petersen void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
535c72758f3SMartin K. Petersen 		       sector_t offset)
536c72758f3SMartin K. Petersen {
537c72758f3SMartin K. Petersen 	struct request_queue *t = disk->queue;
538c72758f3SMartin K. Petersen 	struct request_queue *b = bdev_get_queue(bdev);
539c72758f3SMartin K. Petersen 
540c72758f3SMartin K. Petersen 	offset += get_start_sect(bdev) << 9;
541c72758f3SMartin K. Petersen 
542c72758f3SMartin K. Petersen 	if (blk_stack_limits(&t->limits, &b->limits, offset) < 0) {
543c72758f3SMartin K. Petersen 		char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];
544c72758f3SMartin K. Petersen 
545c72758f3SMartin K. Petersen 		disk_name(disk, 0, top);
546c72758f3SMartin K. Petersen 		bdevname(bdev, bottom);
547c72758f3SMartin K. Petersen 
548c72758f3SMartin K. Petersen 		printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
549c72758f3SMartin K. Petersen 		       top, bottom);
550c72758f3SMartin K. Petersen 	}
551c72758f3SMartin K. Petersen 
552c72758f3SMartin K. Petersen 	if (!t->queue_lock)
553c72758f3SMartin K. Petersen 		WARN_ON_ONCE(1);
554c72758f3SMartin K. Petersen 	else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
555c72758f3SMartin K. Petersen 		unsigned long flags;
556c72758f3SMartin K. Petersen 
557c72758f3SMartin K. Petersen 		spin_lock_irqsave(t->queue_lock, flags);
558c72758f3SMartin K. Petersen 		if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags))
559c72758f3SMartin K. Petersen 			queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
560c72758f3SMartin K. Petersen 		spin_unlock_irqrestore(t->queue_lock, flags);
561c72758f3SMartin K. Petersen 	}
562c72758f3SMartin K. Petersen }
563c72758f3SMartin K. Petersen EXPORT_SYMBOL(disk_stack_limits);
564c72758f3SMartin K. Petersen 
565c72758f3SMartin K. Petersen /**
566e3790c7dSTejun Heo  * blk_queue_dma_pad - set pad mask
567e3790c7dSTejun Heo  * @q:     the request queue for the device
568e3790c7dSTejun Heo  * @mask:  pad mask
569e3790c7dSTejun Heo  *
57027f8221aSFUJITA Tomonori  * Set dma pad mask.
571e3790c7dSTejun Heo  *
57227f8221aSFUJITA Tomonori  * Appending pad buffer to a request modifies the last entry of a
57327f8221aSFUJITA Tomonori  * scatter list such that it includes the pad buffer.
574e3790c7dSTejun Heo  **/
575e3790c7dSTejun Heo void blk_queue_dma_pad(struct request_queue *q, unsigned int mask)
576e3790c7dSTejun Heo {
577e3790c7dSTejun Heo 	q->dma_pad_mask = mask;
578e3790c7dSTejun Heo }
579e3790c7dSTejun Heo EXPORT_SYMBOL(blk_queue_dma_pad);
580e3790c7dSTejun Heo 
581e3790c7dSTejun Heo /**
58227f8221aSFUJITA Tomonori  * blk_queue_update_dma_pad - update pad mask
58327f8221aSFUJITA Tomonori  * @q:     the request queue for the device
58427f8221aSFUJITA Tomonori  * @mask:  pad mask
58527f8221aSFUJITA Tomonori  *
58627f8221aSFUJITA Tomonori  * Update dma pad mask.
58727f8221aSFUJITA Tomonori  *
58827f8221aSFUJITA Tomonori  * Appending pad buffer to a request modifies the last entry of a
58927f8221aSFUJITA Tomonori  * scatter list such that it includes the pad buffer.
59027f8221aSFUJITA Tomonori  **/
59127f8221aSFUJITA Tomonori void blk_queue_update_dma_pad(struct request_queue *q, unsigned int mask)
59227f8221aSFUJITA Tomonori {
59327f8221aSFUJITA Tomonori 	if (mask > q->dma_pad_mask)
59427f8221aSFUJITA Tomonori 		q->dma_pad_mask = mask;
59527f8221aSFUJITA Tomonori }
59627f8221aSFUJITA Tomonori EXPORT_SYMBOL(blk_queue_update_dma_pad);
59727f8221aSFUJITA Tomonori 
59827f8221aSFUJITA Tomonori /**
59986db1e29SJens Axboe  * blk_queue_dma_drain - Set up a drain buffer for excess dma.
60086db1e29SJens Axboe  * @q:  the request queue for the device
6012fb98e84STejun Heo  * @dma_drain_needed: fn which returns non-zero if drain is necessary
60286db1e29SJens Axboe  * @buf:	physically contiguous buffer
60386db1e29SJens Axboe  * @size:	size of the buffer in bytes
60486db1e29SJens Axboe  *
60586db1e29SJens Axboe  * Some devices have excess DMA problems and can't simply discard (or
60686db1e29SJens Axboe  * zero fill) the unwanted piece of the transfer.  They have to have a
60786db1e29SJens Axboe  * real area of memory to transfer it into.  The use case for this is
60886db1e29SJens Axboe  * ATAPI devices in DMA mode.  If the packet command causes a transfer
60986db1e29SJens Axboe  * bigger than the transfer size some HBAs will lock up if there
61086db1e29SJens Axboe  * aren't DMA elements to contain the excess transfer.  What this API
61186db1e29SJens Axboe  * does is adjust the queue so that the buf is always appended
61286db1e29SJens Axboe  * silently to the scatterlist.
61386db1e29SJens Axboe  *
61486db1e29SJens Axboe  * Note: This routine adjusts max_hw_segments to make room for
61586db1e29SJens Axboe  * appending the drain buffer.  If you call
61686db1e29SJens Axboe  * blk_queue_max_hw_segments() or blk_queue_max_phys_segments() after
61786db1e29SJens Axboe  * calling this routine, you must set the limit to one fewer than your
61886db1e29SJens Axboe  * device can support otherwise there won't be room for the drain
61986db1e29SJens Axboe  * buffer.
62086db1e29SJens Axboe  */
621448da4d2SHarvey Harrison int blk_queue_dma_drain(struct request_queue *q,
6222fb98e84STejun Heo 			       dma_drain_needed_fn *dma_drain_needed,
6232fb98e84STejun Heo 			       void *buf, unsigned int size)
62486db1e29SJens Axboe {
625ae03bf63SMartin K. Petersen 	if (queue_max_hw_segments(q) < 2 || queue_max_phys_segments(q) < 2)
62686db1e29SJens Axboe 		return -EINVAL;
62786db1e29SJens Axboe 	/* make room for appending the drain */
628ae03bf63SMartin K. Petersen 	blk_queue_max_hw_segments(q, queue_max_hw_segments(q) - 1);
629ae03bf63SMartin K. Petersen 	blk_queue_max_phys_segments(q, queue_max_phys_segments(q) - 1);
6302fb98e84STejun Heo 	q->dma_drain_needed = dma_drain_needed;
63186db1e29SJens Axboe 	q->dma_drain_buffer = buf;
63286db1e29SJens Axboe 	q->dma_drain_size = size;
63386db1e29SJens Axboe 
63486db1e29SJens Axboe 	return 0;
63586db1e29SJens Axboe }
63686db1e29SJens Axboe EXPORT_SYMBOL_GPL(blk_queue_dma_drain);
63786db1e29SJens Axboe 
63886db1e29SJens Axboe /**
63986db1e29SJens Axboe  * blk_queue_segment_boundary - set boundary rules for segment merging
64086db1e29SJens Axboe  * @q:  the request queue for the device
64186db1e29SJens Axboe  * @mask:  the memory boundary mask
64286db1e29SJens Axboe  **/
64386db1e29SJens Axboe void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
64486db1e29SJens Axboe {
64586db1e29SJens Axboe 	if (mask < PAGE_CACHE_SIZE - 1) {
64686db1e29SJens Axboe 		mask = PAGE_CACHE_SIZE - 1;
64724c03d47SHarvey Harrison 		printk(KERN_INFO "%s: set to minimum %lx\n",
64824c03d47SHarvey Harrison 		       __func__, mask);
64986db1e29SJens Axboe 	}
65086db1e29SJens Axboe 
651025146e1SMartin K. Petersen 	q->limits.seg_boundary_mask = mask;
65286db1e29SJens Axboe }
65386db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_segment_boundary);
65486db1e29SJens Axboe 
65586db1e29SJens Axboe /**
65686db1e29SJens Axboe  * blk_queue_dma_alignment - set dma length and memory alignment
65786db1e29SJens Axboe  * @q:     the request queue for the device
65886db1e29SJens Axboe  * @mask:  alignment mask
65986db1e29SJens Axboe  *
66086db1e29SJens Axboe  * description:
661710027a4SRandy Dunlap  *    set required memory and length alignment for direct dma transactions.
6628feb4d20SAlan Cox  *    this is used when building direct io requests for the queue.
66386db1e29SJens Axboe  *
66486db1e29SJens Axboe  **/
66586db1e29SJens Axboe void blk_queue_dma_alignment(struct request_queue *q, int mask)
66686db1e29SJens Axboe {
66786db1e29SJens Axboe 	q->dma_alignment = mask;
66886db1e29SJens Axboe }
66986db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_dma_alignment);
67086db1e29SJens Axboe 
67186db1e29SJens Axboe /**
67286db1e29SJens Axboe  * blk_queue_update_dma_alignment - update dma length and memory alignment
67386db1e29SJens Axboe  * @q:     the request queue for the device
67486db1e29SJens Axboe  * @mask:  alignment mask
67586db1e29SJens Axboe  *
67686db1e29SJens Axboe  * description:
677710027a4SRandy Dunlap  *    update required memory and length alignment for direct dma transactions.
67886db1e29SJens Axboe  *    If the requested alignment is larger than the current alignment, then
67986db1e29SJens Axboe  *    the current queue alignment is updated to the new value, otherwise it
68086db1e29SJens Axboe  *    is left alone.  The design of this is to allow multiple objects
68186db1e29SJens Axboe  *    (driver, device, transport etc) to set their respective
68286db1e29SJens Axboe  *    alignments without having them interfere.
68386db1e29SJens Axboe  *
68486db1e29SJens Axboe  **/
68586db1e29SJens Axboe void blk_queue_update_dma_alignment(struct request_queue *q, int mask)
68686db1e29SJens Axboe {
68786db1e29SJens Axboe 	BUG_ON(mask > PAGE_SIZE);
68886db1e29SJens Axboe 
68986db1e29SJens Axboe 	if (mask > q->dma_alignment)
69086db1e29SJens Axboe 		q->dma_alignment = mask;
69186db1e29SJens Axboe }
69286db1e29SJens Axboe EXPORT_SYMBOL(blk_queue_update_dma_alignment);
69386db1e29SJens Axboe 
694aeb3d3a8SHarvey Harrison static int __init blk_settings_init(void)
69586db1e29SJens Axboe {
69686db1e29SJens Axboe 	blk_max_low_pfn = max_low_pfn - 1;
69786db1e29SJens Axboe 	blk_max_pfn = max_pfn - 1;
69886db1e29SJens Axboe 	return 0;
69986db1e29SJens Axboe }
70086db1e29SJens Axboe subsys_initcall(blk_settings_init);
701