forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 890e1df1bec891d9203724541e81f8fbe5183388
kernel/drivers/block/rsxx/dev.c
....@@ -1,25 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Filename: dev.c
3
-*
44 *
55 * Authors: Joshua Morris <josh.h.morris@us.ibm.com>
66 * Philip Kelleher <pjk1939@linux.vnet.ibm.com>
77 *
88 * (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
239 */
2410
2511 #include <linux/kernel.h>
....@@ -64,6 +50,8 @@
6450
6551 static struct kmem_cache *bio_meta_pool;
6652
53
+static blk_qc_t rsxx_submit_bio(struct bio *bio);
54
+
6755 /*----------------- Block Device Operations -----------------*/
6856 static int rsxx_blkdev_ioctl(struct block_device *bdev,
6957 fmode_t mode,
....@@ -106,23 +94,10 @@
10694
10795 static const struct block_device_operations rsxx_fops = {
10896 .owner = THIS_MODULE,
97
+ .submit_bio = rsxx_submit_bio,
10998 .getgeo = rsxx_getgeo,
11099 .ioctl = rsxx_blkdev_ioctl,
111100 };
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
-}
126101
127102 static void bio_dma_done_cb(struct rsxx_cardinfo *card,
128103 void *cb_data,
....@@ -135,7 +110,7 @@
135110
136111 if (atomic_dec_and_test(&meta->pending_dmas)) {
137112 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);
139114
140115 if (atomic_read(&meta->error))
141116 bio_io_error(meta->bio);
....@@ -145,13 +120,13 @@
145120 }
146121 }
147122
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)
149124 {
150
- struct rsxx_cardinfo *card = q->queuedata;
125
+ struct rsxx_cardinfo *card = bio->bi_disk->private_data;
151126 struct rsxx_bio_meta *bio_meta;
152127 blk_status_t st = BLK_STS_IOERR;
153128
154
- blk_queue_split(q, &bio);
129
+ blk_queue_split(&bio);
155130
156131 might_sleep();
157132
....@@ -181,10 +156,9 @@
181156 bio_meta->bio = bio;
182157 atomic_set(&bio_meta->error, 0);
183158 atomic_set(&bio_meta->pending_dmas, 0);
184
- bio_meta->start_time = jiffies;
185159
186160 if (!unlikely(card->halt))
187
- disk_stats_start(card, bio);
161
+ bio_meta->start_time = bio_start_io_acct(bio);
188162
189163 dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n",
190164 bio_data_dir(bio) ? 'W' : 'R', bio_meta,
....@@ -226,7 +200,7 @@
226200 set_capacity(card->gendisk, card->size8 >> 9);
227201 else
228202 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);
230204 card->bdev_attached = 1;
231205 }
232206
....@@ -262,7 +236,7 @@
262236 return -ENOMEM;
263237 }
264238
265
- card->queue = blk_alloc_queue(GFP_KERNEL);
239
+ card->queue = blk_alloc_queue(NUMA_NO_NODE);
266240 if (!card->queue) {
267241 dev_err(CARD_TO_DEV(card), "Failed queue alloc\n");
268242 unregister_blkdev(card->major, DRIVER_NAME);
....@@ -283,7 +257,6 @@
283257 blk_queue_logical_block_size(card->queue, blk_size);
284258 }
285259
286
- blk_queue_make_request(card->queue, rsxx_make_request);
287260 blk_queue_max_hw_sectors(card->queue, blkdev_max_hw_sectors);
288261 blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE);
289262
....@@ -296,8 +269,6 @@
296269 card->queue->limits.discard_granularity = RSXX_HW_BLK_SIZE;
297270 card->queue->limits.discard_alignment = RSXX_HW_BLK_SIZE;
298271 }
299
-
300
- card->queue->queuedata = card;
301272
302273 snprintf(card->gendisk->disk_name, sizeof(card->gendisk->disk_name),
303274 "rsxx%d", card->disk_id);
....@@ -319,7 +290,6 @@
319290 card->gendisk = NULL;
320291
321292 blk_cleanup_queue(card->queue);
322
- card->queue->queuedata = NULL;
323293 unregister_blkdev(card->major, DRIVER_NAME);
324294 }
325295