.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Filename: dev.c |
---|
3 | | -* |
---|
4 | 4 | * |
---|
5 | 5 | * Authors: Joshua Morris <josh.h.morris@us.ibm.com> |
---|
6 | 6 | * Philip Kelleher <pjk1939@linux.vnet.ibm.com> |
---|
7 | 7 | * |
---|
8 | 8 | * (C) Copyright 2013 IBM Corporation |
---|
9 | | -* |
---|
10 | | -* This program is free software; you can redistribute it and/or |
---|
11 | | -* modify it under the terms of the GNU General Public License as |
---|
12 | | -* published by the Free Software Foundation; either version 2 of the |
---|
13 | | -* License, or (at your option) any later version. |
---|
14 | | -* |
---|
15 | | -* This program is distributed in the hope that it will be useful, but |
---|
16 | | -* WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | | -* General Public License for more details. |
---|
19 | | -* |
---|
20 | | -* You should have received a copy of the GNU General Public License |
---|
21 | | -* along with this program; if not, write to the Free Software Foundation, |
---|
22 | | -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
23 | 9 | */ |
---|
24 | 10 | |
---|
25 | 11 | #include <linux/kernel.h> |
---|
.. | .. |
---|
64 | 50 | |
---|
65 | 51 | static struct kmem_cache *bio_meta_pool; |
---|
66 | 52 | |
---|
| 53 | +static blk_qc_t rsxx_submit_bio(struct bio *bio); |
---|
| 54 | + |
---|
67 | 55 | /*----------------- Block Device Operations -----------------*/ |
---|
68 | 56 | static int rsxx_blkdev_ioctl(struct block_device *bdev, |
---|
69 | 57 | fmode_t mode, |
---|
.. | .. |
---|
106 | 94 | |
---|
107 | 95 | static const struct block_device_operations rsxx_fops = { |
---|
108 | 96 | .owner = THIS_MODULE, |
---|
| 97 | + .submit_bio = rsxx_submit_bio, |
---|
109 | 98 | .getgeo = rsxx_getgeo, |
---|
110 | 99 | .ioctl = rsxx_blkdev_ioctl, |
---|
111 | 100 | }; |
---|
112 | | - |
---|
113 | | -static void disk_stats_start(struct rsxx_cardinfo *card, struct bio *bio) |
---|
114 | | -{ |
---|
115 | | - generic_start_io_acct(card->queue, bio_op(bio), bio_sectors(bio), |
---|
116 | | - &card->gendisk->part0); |
---|
117 | | -} |
---|
118 | | - |
---|
119 | | -static void disk_stats_complete(struct rsxx_cardinfo *card, |
---|
120 | | - struct bio *bio, |
---|
121 | | - unsigned long start_time) |
---|
122 | | -{ |
---|
123 | | - generic_end_io_acct(card->queue, bio_op(bio), |
---|
124 | | - &card->gendisk->part0, start_time); |
---|
125 | | -} |
---|
126 | 101 | |
---|
127 | 102 | static void bio_dma_done_cb(struct rsxx_cardinfo *card, |
---|
128 | 103 | void *cb_data, |
---|
.. | .. |
---|
135 | 110 | |
---|
136 | 111 | if (atomic_dec_and_test(&meta->pending_dmas)) { |
---|
137 | 112 | if (!card->eeh_state && card->gendisk) |
---|
138 | | - disk_stats_complete(card, meta->bio, meta->start_time); |
---|
| 113 | + bio_end_io_acct(meta->bio, meta->start_time); |
---|
139 | 114 | |
---|
140 | 115 | if (atomic_read(&meta->error)) |
---|
141 | 116 | bio_io_error(meta->bio); |
---|
.. | .. |
---|
145 | 120 | } |
---|
146 | 121 | } |
---|
147 | 122 | |
---|
148 | | -static blk_qc_t rsxx_make_request(struct request_queue *q, struct bio *bio) |
---|
| 123 | +static blk_qc_t rsxx_submit_bio(struct bio *bio) |
---|
149 | 124 | { |
---|
150 | | - struct rsxx_cardinfo *card = q->queuedata; |
---|
| 125 | + struct rsxx_cardinfo *card = bio->bi_disk->private_data; |
---|
151 | 126 | struct rsxx_bio_meta *bio_meta; |
---|
152 | 127 | blk_status_t st = BLK_STS_IOERR; |
---|
153 | 128 | |
---|
154 | | - blk_queue_split(q, &bio); |
---|
| 129 | + blk_queue_split(&bio); |
---|
155 | 130 | |
---|
156 | 131 | might_sleep(); |
---|
157 | 132 | |
---|
.. | .. |
---|
181 | 156 | bio_meta->bio = bio; |
---|
182 | 157 | atomic_set(&bio_meta->error, 0); |
---|
183 | 158 | atomic_set(&bio_meta->pending_dmas, 0); |
---|
184 | | - bio_meta->start_time = jiffies; |
---|
185 | 159 | |
---|
186 | 160 | if (!unlikely(card->halt)) |
---|
187 | | - disk_stats_start(card, bio); |
---|
| 161 | + bio_meta->start_time = bio_start_io_acct(bio); |
---|
188 | 162 | |
---|
189 | 163 | dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n", |
---|
190 | 164 | bio_data_dir(bio) ? 'W' : 'R', bio_meta, |
---|
.. | .. |
---|
226 | 200 | set_capacity(card->gendisk, card->size8 >> 9); |
---|
227 | 201 | else |
---|
228 | 202 | set_capacity(card->gendisk, 0); |
---|
229 | | - device_add_disk(CARD_TO_DEV(card), card->gendisk); |
---|
| 203 | + device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL); |
---|
230 | 204 | card->bdev_attached = 1; |
---|
231 | 205 | } |
---|
232 | 206 | |
---|
.. | .. |
---|
262 | 236 | return -ENOMEM; |
---|
263 | 237 | } |
---|
264 | 238 | |
---|
265 | | - card->queue = blk_alloc_queue(GFP_KERNEL); |
---|
| 239 | + card->queue = blk_alloc_queue(NUMA_NO_NODE); |
---|
266 | 240 | if (!card->queue) { |
---|
267 | 241 | dev_err(CARD_TO_DEV(card), "Failed queue alloc\n"); |
---|
268 | 242 | unregister_blkdev(card->major, DRIVER_NAME); |
---|
.. | .. |
---|
283 | 257 | blk_queue_logical_block_size(card->queue, blk_size); |
---|
284 | 258 | } |
---|
285 | 259 | |
---|
286 | | - blk_queue_make_request(card->queue, rsxx_make_request); |
---|
287 | 260 | blk_queue_max_hw_sectors(card->queue, blkdev_max_hw_sectors); |
---|
288 | 261 | blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); |
---|
289 | 262 | |
---|
.. | .. |
---|
296 | 269 | card->queue->limits.discard_granularity = RSXX_HW_BLK_SIZE; |
---|
297 | 270 | card->queue->limits.discard_alignment = RSXX_HW_BLK_SIZE; |
---|
298 | 271 | } |
---|
299 | | - |
---|
300 | | - card->queue->queuedata = card; |
---|
301 | 272 | |
---|
302 | 273 | snprintf(card->gendisk->disk_name, sizeof(card->gendisk->disk_name), |
---|
303 | 274 | "rsxx%d", card->disk_id); |
---|
.. | .. |
---|
319 | 290 | card->gendisk = NULL; |
---|
320 | 291 | |
---|
321 | 292 | blk_cleanup_queue(card->queue); |
---|
322 | | - card->queue->queuedata = NULL; |
---|
323 | 293 | unregister_blkdev(card->major, DRIVER_NAME); |
---|
324 | 294 | } |
---|
325 | 295 | |
---|