diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 4 | ||||
-rw-r--r-- | drivers/block/aoe/aoecmd.c | 2 | ||||
-rw-r--r-- | drivers/block/aoe/aoedev.c | 4 | ||||
-rw-r--r-- | drivers/block/cciss.c | 2 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 2 | ||||
-rw-r--r-- | drivers/block/floppy.c | 87 | ||||
-rw-r--r-- | drivers/block/lguest_blk.c | 36 | ||||
-rw-r--r-- | drivers/block/loop.c | 4 | ||||
-rw-r--r-- | drivers/block/nbd.c | 59 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 25 | ||||
-rw-r--r-- | drivers/block/ps3disk.c | 42 | ||||
-rw-r--r-- | drivers/block/rd.c | 4 | ||||
-rw-r--r-- | drivers/block/umem.c | 238 | ||||
-rw-r--r-- | drivers/block/umem.h | 133 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 32 | ||||
-rw-r--r-- | drivers/block/xsysace.c | 274 |
16 files changed, 601 insertions, 347 deletions
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 007faaf008e7..b1d00ef6659c 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -138,7 +138,7 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio) | |||
138 | buf = mempool_alloc(d->bufpool, GFP_NOIO); | 138 | buf = mempool_alloc(d->bufpool, GFP_NOIO); |
139 | if (buf == NULL) { | 139 | if (buf == NULL) { |
140 | printk(KERN_INFO "aoe: buf allocation failure\n"); | 140 | printk(KERN_INFO "aoe: buf allocation failure\n"); |
141 | bio_endio(bio, bio->bi_size, -ENOMEM); | 141 | bio_endio(bio, -ENOMEM); |
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | memset(buf, 0, sizeof(*buf)); | 144 | memset(buf, 0, sizeof(*buf)); |
@@ -159,7 +159,7 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio) | |||
159 | d->aoemajor, d->aoeminor); | 159 | d->aoemajor, d->aoeminor); |
160 | spin_unlock_irqrestore(&d->lock, flags); | 160 | spin_unlock_irqrestore(&d->lock, flags); |
161 | mempool_free(buf, d->bufpool); | 161 | mempool_free(buf, d->bufpool); |
162 | bio_endio(bio, bio->bi_size, -ENXIO); | 162 | bio_endio(bio, -ENXIO); |
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 30394f78cac2..99672017ca56 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -653,7 +653,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) | |||
653 | disk_stat_add(disk, sectors[rw], n_sect); | 653 | disk_stat_add(disk, sectors[rw], n_sect); |
654 | disk_stat_add(disk, io_ticks, duration); | 654 | disk_stat_add(disk, io_ticks, duration); |
655 | n = (buf->flags & BUFFL_FAIL) ? -EIO : 0; | 655 | n = (buf->flags & BUFFL_FAIL) ? -EIO : 0; |
656 | bio_endio(buf->bio, buf->bio->bi_size, n); | 656 | bio_endio(buf->bio, n); |
657 | mempool_free(buf, d->bufpool); | 657 | mempool_free(buf, d->bufpool); |
658 | } | 658 | } |
659 | } | 659 | } |
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 05a97197c918..51f50710e5fc 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c | |||
@@ -119,7 +119,7 @@ aoedev_downdev(struct aoedev *d) | |||
119 | bio = buf->bio; | 119 | bio = buf->bio; |
120 | if (--buf->nframesout == 0) { | 120 | if (--buf->nframesout == 0) { |
121 | mempool_free(buf, d->bufpool); | 121 | mempool_free(buf, d->bufpool); |
122 | bio_endio(bio, bio->bi_size, -EIO); | 122 | bio_endio(bio, -EIO); |
123 | } | 123 | } |
124 | skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0; | 124 | skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0; |
125 | } | 125 | } |
@@ -130,7 +130,7 @@ aoedev_downdev(struct aoedev *d) | |||
130 | list_del(d->bufq.next); | 130 | list_del(d->bufq.next); |
131 | bio = buf->bio; | 131 | bio = buf->bio; |
132 | mempool_free(buf, d->bufpool); | 132 | mempool_free(buf, d->bufpool); |
133 | bio_endio(bio, bio->bi_size, -EIO); | 133 | bio_endio(bio, -EIO); |
134 | } | 134 | } |
135 | 135 | ||
136 | if (d->gd) | 136 | if (d->gd) |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 084358a828e9..28d145756f6c 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1194,7 +1194,7 @@ static inline void complete_buffers(struct bio *bio, int status) | |||
1194 | int nr_sectors = bio_sectors(bio); | 1194 | int nr_sectors = bio_sectors(bio); |
1195 | 1195 | ||
1196 | bio->bi_next = NULL; | 1196 | bio->bi_next = NULL; |
1197 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); | 1197 | bio_endio(bio, status ? 0 : -EIO); |
1198 | bio = xbh; | 1198 | bio = xbh; |
1199 | } | 1199 | } |
1200 | } | 1200 | } |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index eb9799acf65b..3853c9a38d6a 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -987,7 +987,7 @@ static inline void complete_buffers(struct bio *bio, int ok) | |||
987 | xbh = bio->bi_next; | 987 | xbh = bio->bi_next; |
988 | bio->bi_next = NULL; | 988 | bio->bi_next = NULL; |
989 | 989 | ||
990 | bio_endio(bio, nr_sectors << 9, ok ? 0 : -EIO); | 990 | bio_endio(bio, ok ? 0 : -EIO); |
991 | 991 | ||
992 | bio = xbh; | 992 | bio = xbh; |
993 | } | 993 | } |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 085b7794fb3e..80483aac4cc9 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -2437,22 +2437,19 @@ static void rw_interrupt(void) | |||
2437 | /* Compute maximal contiguous buffer size. */ | 2437 | /* Compute maximal contiguous buffer size. */ |
2438 | static int buffer_chain_size(void) | 2438 | static int buffer_chain_size(void) |
2439 | { | 2439 | { |
2440 | struct bio *bio; | ||
2441 | struct bio_vec *bv; | 2440 | struct bio_vec *bv; |
2442 | int size, i; | 2441 | int size; |
2442 | struct req_iterator iter; | ||
2443 | char *base; | 2443 | char *base; |
2444 | 2444 | ||
2445 | base = bio_data(current_req->bio); | 2445 | base = bio_data(current_req->bio); |
2446 | size = 0; | 2446 | size = 0; |
2447 | 2447 | ||
2448 | rq_for_each_bio(bio, current_req) { | 2448 | rq_for_each_segment(bv, current_req, iter) { |
2449 | bio_for_each_segment(bv, bio, i) { | 2449 | if (page_address(bv->bv_page) + bv->bv_offset != base + size) |
2450 | if (page_address(bv->bv_page) + bv->bv_offset != | 2450 | break; |
2451 | base + size) | ||
2452 | break; | ||
2453 | 2451 | ||
2454 | size += bv->bv_len; | 2452 | size += bv->bv_len; |
2455 | } | ||
2456 | } | 2453 | } |
2457 | 2454 | ||
2458 | return size >> 9; | 2455 | return size >> 9; |
@@ -2479,9 +2476,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2479 | { | 2476 | { |
2480 | int remaining; /* number of transferred 512-byte sectors */ | 2477 | int remaining; /* number of transferred 512-byte sectors */ |
2481 | struct bio_vec *bv; | 2478 | struct bio_vec *bv; |
2482 | struct bio *bio; | ||
2483 | char *buffer, *dma_buffer; | 2479 | char *buffer, *dma_buffer; |
2484 | int size, i; | 2480 | int size; |
2481 | struct req_iterator iter; | ||
2485 | 2482 | ||
2486 | max_sector = transfer_size(ssize, | 2483 | max_sector = transfer_size(ssize, |
2487 | min(max_sector, max_sector_2), | 2484 | min(max_sector, max_sector_2), |
@@ -2514,43 +2511,41 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2514 | 2511 | ||
2515 | size = current_req->current_nr_sectors << 9; | 2512 | size = current_req->current_nr_sectors << 9; |
2516 | 2513 | ||
2517 | rq_for_each_bio(bio, current_req) { | 2514 | rq_for_each_segment(bv, current_req, iter) { |
2518 | bio_for_each_segment(bv, bio, i) { | 2515 | if (!remaining) |
2519 | if (!remaining) | 2516 | break; |
2520 | break; | ||
2521 | 2517 | ||
2522 | size = bv->bv_len; | 2518 | size = bv->bv_len; |
2523 | SUPBOUND(size, remaining); | 2519 | SUPBOUND(size, remaining); |
2524 | 2520 | ||
2525 | buffer = page_address(bv->bv_page) + bv->bv_offset; | 2521 | buffer = page_address(bv->bv_page) + bv->bv_offset; |
2526 | #ifdef FLOPPY_SANITY_CHECK | 2522 | #ifdef FLOPPY_SANITY_CHECK |
2527 | if (dma_buffer + size > | 2523 | if (dma_buffer + size > |
2528 | floppy_track_buffer + (max_buffer_sectors << 10) || | 2524 | floppy_track_buffer + (max_buffer_sectors << 10) || |
2529 | dma_buffer < floppy_track_buffer) { | 2525 | dma_buffer < floppy_track_buffer) { |
2530 | DPRINT("buffer overrun in copy buffer %d\n", | 2526 | DPRINT("buffer overrun in copy buffer %d\n", |
2531 | (int)((floppy_track_buffer - | 2527 | (int)((floppy_track_buffer - |
2532 | dma_buffer) >> 9)); | 2528 | dma_buffer) >> 9)); |
2533 | printk("fsector_t=%d buffer_min=%d\n", | 2529 | printk("fsector_t=%d buffer_min=%d\n", |
2534 | fsector_t, buffer_min); | 2530 | fsector_t, buffer_min); |
2535 | printk("current_count_sectors=%ld\n", | 2531 | printk("current_count_sectors=%ld\n", |
2536 | current_count_sectors); | 2532 | current_count_sectors); |
2537 | if (CT(COMMAND) == FD_READ) | ||
2538 | printk("read\n"); | ||
2539 | if (CT(COMMAND) == FD_WRITE) | ||
2540 | printk("write\n"); | ||
2541 | break; | ||
2542 | } | ||
2543 | if (((unsigned long)buffer) % 512) | ||
2544 | DPRINT("%p buffer not aligned\n", buffer); | ||
2545 | #endif | ||
2546 | if (CT(COMMAND) == FD_READ) | 2533 | if (CT(COMMAND) == FD_READ) |
2547 | memcpy(buffer, dma_buffer, size); | 2534 | printk("read\n"); |
2548 | else | 2535 | if (CT(COMMAND) == FD_WRITE) |
2549 | memcpy(dma_buffer, buffer, size); | 2536 | printk("write\n"); |
2550 | 2537 | break; | |
2551 | remaining -= size; | ||
2552 | dma_buffer += size; | ||
2553 | } | 2538 | } |
2539 | if (((unsigned long)buffer) % 512) | ||
2540 | DPRINT("%p buffer not aligned\n", buffer); | ||
2541 | #endif | ||
2542 | if (CT(COMMAND) == FD_READ) | ||
2543 | memcpy(buffer, dma_buffer, size); | ||
2544 | else | ||
2545 | memcpy(dma_buffer, buffer, size); | ||
2546 | |||
2547 | remaining -= size; | ||
2548 | dma_buffer += size; | ||
2554 | } | 2549 | } |
2555 | #ifdef FLOPPY_SANITY_CHECK | 2550 | #ifdef FLOPPY_SANITY_CHECK |
2556 | if (remaining) { | 2551 | if (remaining) { |
@@ -3815,14 +3810,10 @@ static int check_floppy_change(struct gendisk *disk) | |||
3815 | * a disk in the drive, and whether that disk is writable. | 3810 | * a disk in the drive, and whether that disk is writable. |
3816 | */ | 3811 | */ |
3817 | 3812 | ||
3818 | static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done, | 3813 | static void floppy_rb0_complete(struct bio *bio, |
3819 | int err) | 3814 | int err) |
3820 | { | 3815 | { |
3821 | if (bio->bi_size) | ||
3822 | return 1; | ||
3823 | |||
3824 | complete((struct completion *)bio->bi_private); | 3816 | complete((struct completion *)bio->bi_private); |
3825 | return 0; | ||
3826 | } | 3817 | } |
3827 | 3818 | ||
3828 | static int __floppy_read_block_0(struct block_device *bdev) | 3819 | static int __floppy_read_block_0(struct block_device *bdev) |
diff --git a/drivers/block/lguest_blk.c b/drivers/block/lguest_blk.c index 160cf14431ac..fa8e42341b87 100644 --- a/drivers/block/lguest_blk.c +++ b/drivers/block/lguest_blk.c | |||
@@ -142,25 +142,23 @@ static irqreturn_t lgb_irq(int irq, void *_bd) | |||
142 | * return the total length. */ | 142 | * return the total length. */ |
143 | static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) | 143 | static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) |
144 | { | 144 | { |
145 | unsigned int i = 0, idx, len = 0; | 145 | unsigned int i = 0, len = 0; |
146 | struct bio *bio; | 146 | struct req_iterator iter; |
147 | 147 | struct bio_vec *bvec; | |
148 | rq_for_each_bio(bio, req) { | 148 | |
149 | struct bio_vec *bvec; | 149 | rq_for_each_segment(bvec, req, iter) { |
150 | bio_for_each_segment(bvec, bio, idx) { | 150 | /* We told the block layer not to give us too many. */ |
151 | /* We told the block layer not to give us too many. */ | 151 | BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); |
152 | BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); | 152 | /* If we had a zero-length segment, it would look like |
153 | /* If we had a zero-length segment, it would look like | 153 | * the end of the data referred to by the "struct |
154 | * the end of the data referred to by the "struct | 154 | * lguest_dma", so make sure that doesn't happen. */ |
155 | * lguest_dma", so make sure that doesn't happen. */ | 155 | BUG_ON(!bvec->bv_len); |
156 | BUG_ON(!bvec->bv_len); | 156 | /* Convert page & offset to a physical address */ |
157 | /* Convert page & offset to a physical address */ | 157 | dma->addr[i] = page_to_phys(bvec->bv_page) |
158 | dma->addr[i] = page_to_phys(bvec->bv_page) | 158 | + bvec->bv_offset; |
159 | + bvec->bv_offset; | 159 | dma->len[i] = bvec->bv_len; |
160 | dma->len[i] = bvec->bv_len; | 160 | len += bvec->bv_len; |
161 | len += bvec->bv_len; | 161 | i++; |
162 | i++; | ||
163 | } | ||
164 | } | 162 | } |
165 | /* If the array isn't full, we mark the end with a 0 length */ | 163 | /* If the array isn't full, we mark the end with a 0 length */ |
166 | if (i < LGUEST_MAX_DMA_SECTIONS) | 164 | if (i < LGUEST_MAX_DMA_SECTIONS) |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 9f015fce4135..b9233a06934c 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -551,7 +551,7 @@ static int loop_make_request(struct request_queue *q, struct bio *old_bio) | |||
551 | 551 | ||
552 | out: | 552 | out: |
553 | spin_unlock_irq(&lo->lo_lock); | 553 | spin_unlock_irq(&lo->lo_lock); |
554 | bio_io_error(old_bio, old_bio->bi_size); | 554 | bio_io_error(old_bio); |
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
@@ -580,7 +580,7 @@ static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio) | |||
580 | bio_put(bio); | 580 | bio_put(bio); |
581 | } else { | 581 | } else { |
582 | int ret = do_bio_filebacked(lo, bio); | 582 | int ret = do_bio_filebacked(lo, bio); |
583 | bio_endio(bio, bio->bi_size, ret); | 583 | bio_endio(bio, ret); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index be92c658f06e..be5ec3a9b1fc 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -180,7 +180,7 @@ static inline int sock_send_bvec(struct socket *sock, struct bio_vec *bvec, | |||
180 | 180 | ||
181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) | 181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) |
182 | { | 182 | { |
183 | int result, i, flags; | 183 | int result, flags; |
184 | struct nbd_request request; | 184 | struct nbd_request request; |
185 | unsigned long size = req->nr_sectors << 9; | 185 | unsigned long size = req->nr_sectors << 9; |
186 | struct socket *sock = lo->sock; | 186 | struct socket *sock = lo->sock; |
@@ -205,27 +205,23 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
205 | } | 205 | } |
206 | 206 | ||
207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { | 207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { |
208 | struct bio *bio; | 208 | struct req_iterator iter; |
209 | struct bio_vec *bvec; | ||
209 | /* | 210 | /* |
210 | * we are really probing at internals to determine | 211 | * we are really probing at internals to determine |
211 | * whether to set MSG_MORE or not... | 212 | * whether to set MSG_MORE or not... |
212 | */ | 213 | */ |
213 | rq_for_each_bio(bio, req) { | 214 | rq_for_each_segment(bvec, req, iter) { |
214 | struct bio_vec *bvec; | 215 | flags = 0; |
215 | bio_for_each_segment(bvec, bio, i) { | 216 | if (!rq_iter_last(req, iter)) |
216 | flags = 0; | 217 | flags = MSG_MORE; |
217 | if ((i < (bio->bi_vcnt - 1)) || bio->bi_next) | 218 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", |
218 | flags = MSG_MORE; | 219 | lo->disk->disk_name, req, bvec->bv_len); |
219 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", | 220 | result = sock_send_bvec(sock, bvec, flags); |
220 | lo->disk->disk_name, req, | 221 | if (result <= 0) { |
221 | bvec->bv_len); | 222 | printk(KERN_ERR "%s: Send data failed (result %d)\n", |
222 | result = sock_send_bvec(sock, bvec, flags); | 223 | lo->disk->disk_name, result); |
223 | if (result <= 0) { | 224 | goto error_out; |
224 | printk(KERN_ERR "%s: Send data failed (result %d)\n", | ||
225 | lo->disk->disk_name, | ||
226 | result); | ||
227 | goto error_out; | ||
228 | } | ||
229 | } | 225 | } |
230 | } | 226 | } |
231 | } | 227 | } |
@@ -321,22 +317,19 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
321 | dprintk(DBG_RX, "%s: request %p: got reply\n", | 317 | dprintk(DBG_RX, "%s: request %p: got reply\n", |
322 | lo->disk->disk_name, req); | 318 | lo->disk->disk_name, req); |
323 | if (nbd_cmd(req) == NBD_CMD_READ) { | 319 | if (nbd_cmd(req) == NBD_CMD_READ) { |
324 | int i; | 320 | struct req_iterator iter; |
325 | struct bio *bio; | 321 | struct bio_vec *bvec; |
326 | rq_for_each_bio(bio, req) { | 322 | |
327 | struct bio_vec *bvec; | 323 | rq_for_each_segment(bvec, req, iter) { |
328 | bio_for_each_segment(bvec, bio, i) { | 324 | result = sock_recv_bvec(sock, bvec); |
329 | result = sock_recv_bvec(sock, bvec); | 325 | if (result <= 0) { |
330 | if (result <= 0) { | 326 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", |
331 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", | 327 | lo->disk->disk_name, result); |
332 | lo->disk->disk_name, | 328 | req->errors++; |
333 | result); | 329 | return req; |
334 | req->errors++; | ||
335 | return req; | ||
336 | } | ||
337 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", | ||
338 | lo->disk->disk_name, req, bvec->bv_len); | ||
339 | } | 330 | } |
331 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", | ||
332 | lo->disk->disk_name, req, bvec->bv_len); | ||
340 | } | 333 | } |
341 | } | 334 | } |
342 | return req; | 335 | return req; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index fadbfd880bab..540bf3676985 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -1058,15 +1058,12 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec) | |||
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err) | 1061 | static void pkt_end_io_read(struct bio *bio, int err) |
1062 | { | 1062 | { |
1063 | struct packet_data *pkt = bio->bi_private; | 1063 | struct packet_data *pkt = bio->bi_private; |
1064 | struct pktcdvd_device *pd = pkt->pd; | 1064 | struct pktcdvd_device *pd = pkt->pd; |
1065 | BUG_ON(!pd); | 1065 | BUG_ON(!pd); |
1066 | 1066 | ||
1067 | if (bio->bi_size) | ||
1068 | return 1; | ||
1069 | |||
1070 | VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio, | 1067 | VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio, |
1071 | (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err); | 1068 | (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err); |
1072 | 1069 | ||
@@ -1077,19 +1074,14 @@ static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err) | |||
1077 | wake_up(&pd->wqueue); | 1074 | wake_up(&pd->wqueue); |
1078 | } | 1075 | } |
1079 | pkt_bio_finished(pd); | 1076 | pkt_bio_finished(pd); |
1080 | |||
1081 | return 0; | ||
1082 | } | 1077 | } |
1083 | 1078 | ||
1084 | static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int err) | 1079 | static void pkt_end_io_packet_write(struct bio *bio, int err) |
1085 | { | 1080 | { |
1086 | struct packet_data *pkt = bio->bi_private; | 1081 | struct packet_data *pkt = bio->bi_private; |
1087 | struct pktcdvd_device *pd = pkt->pd; | 1082 | struct pktcdvd_device *pd = pkt->pd; |
1088 | BUG_ON(!pd); | 1083 | BUG_ON(!pd); |
1089 | 1084 | ||
1090 | if (bio->bi_size) | ||
1091 | return 1; | ||
1092 | |||
1093 | VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err); | 1085 | VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err); |
1094 | 1086 | ||
1095 | pd->stats.pkt_ended++; | 1087 | pd->stats.pkt_ended++; |
@@ -1098,7 +1090,6 @@ static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int | |||
1098 | atomic_dec(&pkt->io_wait); | 1090 | atomic_dec(&pkt->io_wait); |
1099 | atomic_inc(&pkt->run_sm); | 1091 | atomic_inc(&pkt->run_sm); |
1100 | wake_up(&pd->wqueue); | 1092 | wake_up(&pd->wqueue); |
1101 | return 0; | ||
1102 | } | 1093 | } |
1103 | 1094 | ||
1104 | /* | 1095 | /* |
@@ -1470,7 +1461,7 @@ static void pkt_finish_packet(struct packet_data *pkt, int uptodate) | |||
1470 | while (bio) { | 1461 | while (bio) { |
1471 | next = bio->bi_next; | 1462 | next = bio->bi_next; |
1472 | bio->bi_next = NULL; | 1463 | bio->bi_next = NULL; |
1473 | bio_endio(bio, bio->bi_size, uptodate ? 0 : -EIO); | 1464 | bio_endio(bio, uptodate ? 0 : -EIO); |
1474 | bio = next; | 1465 | bio = next; |
1475 | } | 1466 | } |
1476 | pkt->orig_bios = pkt->orig_bios_tail = NULL; | 1467 | pkt->orig_bios = pkt->orig_bios_tail = NULL; |
@@ -2462,19 +2453,15 @@ static int pkt_close(struct inode *inode, struct file *file) | |||
2462 | } | 2453 | } |
2463 | 2454 | ||
2464 | 2455 | ||
2465 | static int pkt_end_io_read_cloned(struct bio *bio, unsigned int bytes_done, int err) | 2456 | static void pkt_end_io_read_cloned(struct bio *bio, int err) |
2466 | { | 2457 | { |
2467 | struct packet_stacked_data *psd = bio->bi_private; | 2458 | struct packet_stacked_data *psd = bio->bi_private; |
2468 | struct pktcdvd_device *pd = psd->pd; | 2459 | struct pktcdvd_device *pd = psd->pd; |
2469 | 2460 | ||
2470 | if (bio->bi_size) | ||
2471 | return 1; | ||
2472 | |||
2473 | bio_put(bio); | 2461 | bio_put(bio); |
2474 | bio_endio(psd->bio, psd->bio->bi_size, err); | 2462 | bio_endio(psd->bio, err); |
2475 | mempool_free(psd, psd_pool); | 2463 | mempool_free(psd, psd_pool); |
2476 | pkt_bio_finished(pd); | 2464 | pkt_bio_finished(pd); |
2477 | return 0; | ||
2478 | } | 2465 | } |
2479 | 2466 | ||
2480 | static int pkt_make_request(struct request_queue *q, struct bio *bio) | 2467 | static int pkt_make_request(struct request_queue *q, struct bio *bio) |
@@ -2620,7 +2607,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2620 | } | 2607 | } |
2621 | return 0; | 2608 | return 0; |
2622 | end_io: | 2609 | end_io: |
2623 | bio_io_error(bio, bio->bi_size); | 2610 | bio_io_error(bio); |
2624 | return 0; | 2611 | return 0; |
2625 | } | 2612 | } |
2626 | 2613 | ||
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index aa8b890c80d7..06d0552cf49c 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -91,30 +91,29 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev, | |||
91 | struct request *req, int gather) | 91 | struct request *req, int gather) |
92 | { | 92 | { |
93 | unsigned int offset = 0; | 93 | unsigned int offset = 0; |
94 | struct bio *bio; | 94 | struct req_iterator iter; |
95 | sector_t sector; | ||
96 | struct bio_vec *bvec; | 95 | struct bio_vec *bvec; |
97 | unsigned int i = 0, j; | 96 | unsigned int i = 0; |
98 | size_t size; | 97 | size_t size; |
99 | void *buf; | 98 | void *buf; |
100 | 99 | ||
101 | rq_for_each_bio(bio, req) { | 100 | rq_for_each_segment(bvec, req, iter) { |
102 | sector = bio->bi_sector; | 101 | unsigned long flags; |
103 | dev_dbg(&dev->sbd.core, | 102 | dev_dbg(&dev->sbd.core, |
104 | "%s:%u: bio %u: %u segs %u sectors from %lu\n", | 103 | "%s:%u: bio %u: %u segs %u sectors from %lu\n", |
105 | __func__, __LINE__, i, bio_segments(bio), | 104 | __func__, __LINE__, i, bio_segments(iter.bio), |
106 | bio_sectors(bio), sector); | 105 | bio_sectors(iter.bio), |
107 | bio_for_each_segment(bvec, bio, j) { | 106 | (unsigned long)iter.bio->bi_sector); |
108 | size = bvec->bv_len; | 107 | |
109 | buf = __bio_kmap_atomic(bio, j, KM_IRQ0); | 108 | size = bvec->bv_len; |
110 | if (gather) | 109 | buf = bvec_kmap_irq(bvec, &flags); |
111 | memcpy(dev->bounce_buf+offset, buf, size); | 110 | if (gather) |
112 | else | 111 | memcpy(dev->bounce_buf+offset, buf, size); |
113 | memcpy(buf, dev->bounce_buf+offset, size); | 112 | else |
114 | offset += size; | 113 | memcpy(buf, dev->bounce_buf+offset, size); |
115 | flush_kernel_dcache_page(bio_iovec_idx(bio, j)->bv_page); | 114 | offset += size; |
116 | __bio_kunmap_atomic(bio, KM_IRQ0); | 115 | flush_kernel_dcache_page(bvec->bv_page); |
117 | } | 116 | bvec_kunmap_irq(bvec, &flags); |
118 | i++; | 117 | i++; |
119 | } | 118 | } |
120 | } | 119 | } |
@@ -130,12 +129,13 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev, | |||
130 | 129 | ||
131 | #ifdef DEBUG | 130 | #ifdef DEBUG |
132 | unsigned int n = 0; | 131 | unsigned int n = 0; |
133 | struct bio *bio; | 132 | struct bio_vec *bv; |
133 | struct req_iterator iter; | ||
134 | 134 | ||
135 | rq_for_each_bio(bio, req) | 135 | rq_for_each_segment(bv, req, iter) |
136 | n++; | 136 | n++; |
137 | dev_dbg(&dev->sbd.core, | 137 | dev_dbg(&dev->sbd.core, |
138 | "%s:%u: %s req has %u bios for %lu sectors %lu hard sectors\n", | 138 | "%s:%u: %s req has %u bvecs for %lu sectors %lu hard sectors\n", |
139 | __func__, __LINE__, op, n, req->nr_sectors, | 139 | __func__, __LINE__, op, n, req->nr_sectors, |
140 | req->hard_nr_sectors); | 140 | req->hard_nr_sectors); |
141 | #endif | 141 | #endif |
diff --git a/drivers/block/rd.c b/drivers/block/rd.c index 65150b548f3a..701ea77f62e9 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c | |||
@@ -287,10 +287,10 @@ static int rd_make_request(struct request_queue *q, struct bio *bio) | |||
287 | if (ret) | 287 | if (ret) |
288 | goto fail; | 288 | goto fail; |
289 | 289 | ||
290 | bio_endio(bio, bio->bi_size, 0); | 290 | bio_endio(bio, 0); |
291 | return 0; | 291 | return 0; |
292 | fail: | 292 | fail: |
293 | bio_io_error(bio, bio->bi_size); | 293 | bio_io_error(bio); |
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | 296 | ||
diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 6b7c02d6360d..99806f9ee4ce 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #include <linux/fcntl.h> /* O_ACCMODE */ | 52 | #include <linux/fcntl.h> /* O_ACCMODE */ |
53 | #include <linux/hdreg.h> /* HDIO_GETGEO */ | 53 | #include <linux/hdreg.h> /* HDIO_GETGEO */ |
54 | 54 | ||
55 | #include <linux/umem.h> | 55 | #include "umem.h" |
56 | 56 | ||
57 | #include <asm/uaccess.h> | 57 | #include <asm/uaccess.h> |
58 | #include <asm/io.h> | 58 | #include <asm/io.h> |
@@ -67,9 +67,10 @@ | |||
67 | * Version Information | 67 | * Version Information |
68 | */ | 68 | */ |
69 | 69 | ||
70 | #define DRIVER_VERSION "v2.3" | 70 | #define DRIVER_NAME "umem" |
71 | #define DRIVER_AUTHOR "San Mehat, Johannes Erdfelt, NeilBrown" | 71 | #define DRIVER_VERSION "v2.3" |
72 | #define DRIVER_DESC "Micro Memory(tm) PCI memory board block driver" | 72 | #define DRIVER_AUTHOR "San Mehat, Johannes Erdfelt, NeilBrown" |
73 | #define DRIVER_DESC "Micro Memory(tm) PCI memory board block driver" | ||
73 | 74 | ||
74 | static int debug; | 75 | static int debug; |
75 | /* #define HW_TRACE(x) writeb(x,cards[0].csr_remap + MEMCTRLSTATUS_MAGIC) */ | 76 | /* #define HW_TRACE(x) writeb(x,cards[0].csr_remap + MEMCTRLSTATUS_MAGIC) */ |
@@ -97,15 +98,9 @@ static int major_nr; | |||
97 | #include <linux/blkpg.h> | 98 | #include <linux/blkpg.h> |
98 | 99 | ||
99 | struct cardinfo { | 100 | struct cardinfo { |
100 | int card_number; | ||
101 | struct pci_dev *dev; | 101 | struct pci_dev *dev; |
102 | 102 | ||
103 | int irq; | ||
104 | |||
105 | unsigned long csr_base; | ||
106 | unsigned char __iomem *csr_remap; | 103 | unsigned char __iomem *csr_remap; |
107 | unsigned long csr_len; | ||
108 | unsigned int win_size; /* PCI window size */ | ||
109 | unsigned int mm_size; /* size in kbytes */ | 104 | unsigned int mm_size; /* size in kbytes */ |
110 | 105 | ||
111 | unsigned int init_size; /* initial segment, in sectors, | 106 | unsigned int init_size; /* initial segment, in sectors, |
@@ -113,6 +108,8 @@ struct cardinfo { | |||
113 | * have been written | 108 | * have been written |
114 | */ | 109 | */ |
115 | struct bio *bio, *currentbio, **biotail; | 110 | struct bio *bio, *currentbio, **biotail; |
111 | int current_idx; | ||
112 | sector_t current_sector; | ||
116 | 113 | ||
117 | struct request_queue *queue; | 114 | struct request_queue *queue; |
118 | 115 | ||
@@ -121,6 +118,7 @@ struct cardinfo { | |||
121 | struct mm_dma_desc *desc; | 118 | struct mm_dma_desc *desc; |
122 | int cnt, headcnt; | 119 | int cnt, headcnt; |
123 | struct bio *bio, **biotail; | 120 | struct bio *bio, **biotail; |
121 | int idx; | ||
124 | } mm_pages[2]; | 122 | } mm_pages[2]; |
125 | #define DESC_PER_PAGE ((PAGE_SIZE*2)/sizeof(struct mm_dma_desc)) | 123 | #define DESC_PER_PAGE ((PAGE_SIZE*2)/sizeof(struct mm_dma_desc)) |
126 | 124 | ||
@@ -233,7 +231,7 @@ static void dump_regs(struct cardinfo *card) | |||
233 | */ | 231 | */ |
234 | static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) | 232 | static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) |
235 | { | 233 | { |
236 | printk(KERN_DEBUG "MM%d*: DMAstat - ", card->card_number); | 234 | dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - "); |
237 | if (dmastat & DMASCR_ANY_ERR) | 235 | if (dmastat & DMASCR_ANY_ERR) |
238 | printk("ANY_ERR "); | 236 | printk("ANY_ERR "); |
239 | if (dmastat & DMASCR_MBE_ERR) | 237 | if (dmastat & DMASCR_MBE_ERR) |
@@ -295,7 +293,7 @@ static void mm_start_io(struct cardinfo *card) | |||
295 | desc->control_bits &= ~cpu_to_le32(DMASCR_CHAIN_EN); | 293 | desc->control_bits &= ~cpu_to_le32(DMASCR_CHAIN_EN); |
296 | desc->sem_control_bits = desc->control_bits; | 294 | desc->sem_control_bits = desc->control_bits; |
297 | 295 | ||
298 | 296 | ||
299 | if (debug & DEBUG_LED_ON_TRANSFER) | 297 | if (debug & DEBUG_LED_ON_TRANSFER) |
300 | set_led(card, LED_REMOVE, LED_ON); | 298 | set_led(card, LED_REMOVE, LED_ON); |
301 | 299 | ||
@@ -329,7 +327,7 @@ static int add_bio(struct cardinfo *card); | |||
329 | 327 | ||
330 | static void activate(struct cardinfo *card) | 328 | static void activate(struct cardinfo *card) |
331 | { | 329 | { |
332 | /* if No page is Active, and Ready is | 330 | /* if No page is Active, and Ready is |
333 | * not empty, then switch Ready page | 331 | * not empty, then switch Ready page |
334 | * to active and start IO. | 332 | * to active and start IO. |
335 | * Then add any bh's that are available to Ready | 333 | * Then add any bh's that are available to Ready |
@@ -368,7 +366,7 @@ static void mm_unplug_device(struct request_queue *q) | |||
368 | spin_unlock_irqrestore(&card->lock, flags); | 366 | spin_unlock_irqrestore(&card->lock, flags); |
369 | } | 367 | } |
370 | 368 | ||
371 | /* | 369 | /* |
372 | * If there is room on Ready page, take | 370 | * If there is room on Ready page, take |
373 | * one bh off list and add it. | 371 | * one bh off list and add it. |
374 | * return 1 if there was room, else 0. | 372 | * return 1 if there was room, else 0. |
@@ -380,12 +378,16 @@ static int add_bio(struct cardinfo *card) | |||
380 | dma_addr_t dma_handle; | 378 | dma_addr_t dma_handle; |
381 | int offset; | 379 | int offset; |
382 | struct bio *bio; | 380 | struct bio *bio; |
381 | struct bio_vec *vec; | ||
382 | int idx; | ||
383 | int rw; | 383 | int rw; |
384 | int len; | 384 | int len; |
385 | 385 | ||
386 | bio = card->currentbio; | 386 | bio = card->currentbio; |
387 | if (!bio && card->bio) { | 387 | if (!bio && card->bio) { |
388 | card->currentbio = card->bio; | 388 | card->currentbio = card->bio; |
389 | card->current_idx = card->bio->bi_idx; | ||
390 | card->current_sector = card->bio->bi_sector; | ||
389 | card->bio = card->bio->bi_next; | 391 | card->bio = card->bio->bi_next; |
390 | if (card->bio == NULL) | 392 | if (card->bio == NULL) |
391 | card->biotail = &card->bio; | 393 | card->biotail = &card->bio; |
@@ -394,15 +396,17 @@ static int add_bio(struct cardinfo *card) | |||
394 | } | 396 | } |
395 | if (!bio) | 397 | if (!bio) |
396 | return 0; | 398 | return 0; |
399 | idx = card->current_idx; | ||
397 | 400 | ||
398 | rw = bio_rw(bio); | 401 | rw = bio_rw(bio); |
399 | if (card->mm_pages[card->Ready].cnt >= DESC_PER_PAGE) | 402 | if (card->mm_pages[card->Ready].cnt >= DESC_PER_PAGE) |
400 | return 0; | 403 | return 0; |
401 | 404 | ||
402 | len = bio_iovec(bio)->bv_len; | 405 | vec = bio_iovec_idx(bio, idx); |
403 | dma_handle = pci_map_page(card->dev, | 406 | len = vec->bv_len; |
404 | bio_page(bio), | 407 | dma_handle = pci_map_page(card->dev, |
405 | bio_offset(bio), | 408 | vec->bv_page, |
409 | vec->bv_offset, | ||
406 | len, | 410 | len, |
407 | (rw==READ) ? | 411 | (rw==READ) ? |
408 | PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); | 412 | PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); |
@@ -410,6 +414,8 @@ static int add_bio(struct cardinfo *card) | |||
410 | p = &card->mm_pages[card->Ready]; | 414 | p = &card->mm_pages[card->Ready]; |
411 | desc = &p->desc[p->cnt]; | 415 | desc = &p->desc[p->cnt]; |
412 | p->cnt++; | 416 | p->cnt++; |
417 | if (p->bio == NULL) | ||
418 | p->idx = idx; | ||
413 | if ((p->biotail) != &bio->bi_next) { | 419 | if ((p->biotail) != &bio->bi_next) { |
414 | *(p->biotail) = bio; | 420 | *(p->biotail) = bio; |
415 | p->biotail = &(bio->bi_next); | 421 | p->biotail = &(bio->bi_next); |
@@ -419,7 +425,7 @@ static int add_bio(struct cardinfo *card) | |||
419 | desc->data_dma_handle = dma_handle; | 425 | desc->data_dma_handle = dma_handle; |
420 | 426 | ||
421 | desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle); | 427 | desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle); |
422 | desc->local_addr= cpu_to_le64(bio->bi_sector << 9); | 428 | desc->local_addr = cpu_to_le64(card->current_sector << 9); |
423 | desc->transfer_size = cpu_to_le32(len); | 429 | desc->transfer_size = cpu_to_le32(len); |
424 | offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc)); | 430 | offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc)); |
425 | desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset)); | 431 | desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset)); |
@@ -435,10 +441,10 @@ static int add_bio(struct cardinfo *card) | |||
435 | desc->control_bits |= cpu_to_le32(DMASCR_TRANSFER_READ); | 441 | desc->control_bits |= cpu_to_le32(DMASCR_TRANSFER_READ); |
436 | desc->sem_control_bits = desc->control_bits; | 442 | desc->sem_control_bits = desc->control_bits; |
437 | 443 | ||
438 | bio->bi_sector += (len>>9); | 444 | card->current_sector += (len >> 9); |
439 | bio->bi_size -= len; | 445 | idx++; |
440 | bio->bi_idx++; | 446 | card->current_idx = idx; |
441 | if (bio->bi_idx >= bio->bi_vcnt) | 447 | if (idx >= bio->bi_vcnt) |
442 | card->currentbio = NULL; | 448 | card->currentbio = NULL; |
443 | 449 | ||
444 | return 1; | 450 | return 1; |
@@ -461,7 +467,7 @@ static void process_page(unsigned long data) | |||
461 | if (card->Active < 0) | 467 | if (card->Active < 0) |
462 | goto out_unlock; | 468 | goto out_unlock; |
463 | page = &card->mm_pages[card->Active]; | 469 | page = &card->mm_pages[card->Active]; |
464 | 470 | ||
465 | while (page->headcnt < page->cnt) { | 471 | while (page->headcnt < page->cnt) { |
466 | struct bio *bio = page->bio; | 472 | struct bio *bio = page->bio; |
467 | struct mm_dma_desc *desc = &page->desc[page->headcnt]; | 473 | struct mm_dma_desc *desc = &page->desc[page->headcnt]; |
@@ -471,32 +477,34 @@ static void process_page(unsigned long data) | |||
471 | 477 | ||
472 | if (!(control & DMASCR_DMA_COMPLETE)) { | 478 | if (!(control & DMASCR_DMA_COMPLETE)) { |
473 | control = dma_status; | 479 | control = dma_status; |
474 | last=1; | 480 | last=1; |
475 | } | 481 | } |
476 | page->headcnt++; | 482 | page->headcnt++; |
477 | idx = bio->bi_phys_segments; | 483 | idx = page->idx; |
478 | bio->bi_phys_segments++; | 484 | page->idx++; |
479 | if (bio->bi_phys_segments >= bio->bi_vcnt) | 485 | if (page->idx >= bio->bi_vcnt) { |
480 | page->bio = bio->bi_next; | 486 | page->bio = bio->bi_next; |
487 | page->idx = page->bio->bi_idx; | ||
488 | } | ||
481 | 489 | ||
482 | pci_unmap_page(card->dev, desc->data_dma_handle, | 490 | pci_unmap_page(card->dev, desc->data_dma_handle, |
483 | bio_iovec_idx(bio,idx)->bv_len, | 491 | bio_iovec_idx(bio,idx)->bv_len, |
484 | (control& DMASCR_TRANSFER_READ) ? | 492 | (control& DMASCR_TRANSFER_READ) ? |
485 | PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 493 | PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); |
486 | if (control & DMASCR_HARD_ERROR) { | 494 | if (control & DMASCR_HARD_ERROR) { |
487 | /* error */ | 495 | /* error */ |
488 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | 496 | clear_bit(BIO_UPTODATE, &bio->bi_flags); |
489 | printk(KERN_WARNING "MM%d: I/O error on sector %d/%d\n", | 497 | dev_printk(KERN_WARNING, &card->dev->dev, |
490 | card->card_number, | 498 | "I/O error on sector %d/%d\n", |
491 | le32_to_cpu(desc->local_addr)>>9, | 499 | le32_to_cpu(desc->local_addr)>>9, |
492 | le32_to_cpu(desc->transfer_size)); | 500 | le32_to_cpu(desc->transfer_size)); |
493 | dump_dmastat(card, control); | 501 | dump_dmastat(card, control); |
494 | } else if (test_bit(BIO_RW, &bio->bi_rw) && | 502 | } else if (test_bit(BIO_RW, &bio->bi_rw) && |
495 | le32_to_cpu(desc->local_addr)>>9 == card->init_size) { | 503 | le32_to_cpu(desc->local_addr)>>9 == card->init_size) { |
496 | card->init_size += le32_to_cpu(desc->transfer_size)>>9; | 504 | card->init_size += le32_to_cpu(desc->transfer_size)>>9; |
497 | if (card->init_size>>1 >= card->mm_size) { | 505 | if (card->init_size>>1 >= card->mm_size) { |
498 | printk(KERN_INFO "MM%d: memory now initialised\n", | 506 | dev_printk(KERN_INFO, &card->dev->dev, |
499 | card->card_number); | 507 | "memory now initialised\n"); |
500 | set_userbit(card, MEMORY_INITIALIZED, 1); | 508 | set_userbit(card, MEMORY_INITIALIZED, 1); |
501 | } | 509 | } |
502 | } | 510 | } |
@@ -532,7 +540,7 @@ static void process_page(unsigned long data) | |||
532 | 540 | ||
533 | return_bio = bio->bi_next; | 541 | return_bio = bio->bi_next; |
534 | bio->bi_next = NULL; | 542 | bio->bi_next = NULL; |
535 | bio_endio(bio, bio->bi_size, 0); | 543 | bio_endio(bio, 0); |
536 | } | 544 | } |
537 | } | 545 | } |
538 | 546 | ||
@@ -547,7 +555,6 @@ static int mm_make_request(struct request_queue *q, struct bio *bio) | |||
547 | pr_debug("mm_make_request %llu %u\n", | 555 | pr_debug("mm_make_request %llu %u\n", |
548 | (unsigned long long)bio->bi_sector, bio->bi_size); | 556 | (unsigned long long)bio->bi_sector, bio->bi_size); |
549 | 557 | ||
550 | bio->bi_phys_segments = bio->bi_idx; /* count of completed segments*/ | ||
551 | spin_lock_irq(&card->lock); | 558 | spin_lock_irq(&card->lock); |
552 | *card->biotail = bio; | 559 | *card->biotail = bio; |
553 | bio->bi_next = NULL; | 560 | bio->bi_next = NULL; |
@@ -585,7 +592,7 @@ HW_TRACE(0x30); | |||
585 | else | 592 | else |
586 | writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, | 593 | writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, |
587 | card->csr_remap+ DMA_STATUS_CTRL + 2); | 594 | card->csr_remap+ DMA_STATUS_CTRL + 2); |
588 | 595 | ||
589 | /* log errors and clear interrupt status */ | 596 | /* log errors and clear interrupt status */ |
590 | if (dma_status & DMASCR_ANY_ERR) { | 597 | if (dma_status & DMASCR_ANY_ERR) { |
591 | unsigned int data_log1, data_log2; | 598 | unsigned int data_log1, data_log2; |
@@ -606,46 +613,51 @@ HW_TRACE(0x30); | |||
606 | dump_dmastat(card, dma_status); | 613 | dump_dmastat(card, dma_status); |
607 | 614 | ||
608 | if (stat & 0x01) | 615 | if (stat & 0x01) |
609 | printk(KERN_ERR "MM%d*: Memory access error detected (err count %d)\n", | 616 | dev_printk(KERN_ERR, &card->dev->dev, |
610 | card->card_number, count); | 617 | "Memory access error detected (err count %d)\n", |
618 | count); | ||
611 | if (stat & 0x02) | 619 | if (stat & 0x02) |
612 | printk(KERN_ERR "MM%d*: Multi-bit EDC error\n", | 620 | dev_printk(KERN_ERR, &card->dev->dev, |
613 | card->card_number); | 621 | "Multi-bit EDC error\n"); |
614 | 622 | ||
615 | printk(KERN_ERR "MM%d*: Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n", | 623 | dev_printk(KERN_ERR, &card->dev->dev, |
616 | card->card_number, addr_log2, addr_log1, data_log2, data_log1); | 624 | "Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n", |
617 | printk(KERN_ERR "MM%d*: Fault Check 0x%02x, Fault Syndrome 0x%02x\n", | 625 | addr_log2, addr_log1, data_log2, data_log1); |
618 | card->card_number, check, syndrome); | 626 | dev_printk(KERN_ERR, &card->dev->dev, |
627 | "Fault Check 0x%02x, Fault Syndrome 0x%02x\n", | ||
628 | check, syndrome); | ||
619 | 629 | ||
620 | writeb(0, card->csr_remap + ERROR_COUNT); | 630 | writeb(0, card->csr_remap + ERROR_COUNT); |
621 | } | 631 | } |
622 | 632 | ||
623 | if (dma_status & DMASCR_PARITY_ERR_REP) { | 633 | if (dma_status & DMASCR_PARITY_ERR_REP) { |
624 | printk(KERN_ERR "MM%d*: PARITY ERROR REPORTED\n", card->card_number); | 634 | dev_printk(KERN_ERR, &card->dev->dev, |
635 | "PARITY ERROR REPORTED\n"); | ||
625 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 636 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
626 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 637 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
627 | } | 638 | } |
628 | 639 | ||
629 | if (dma_status & DMASCR_PARITY_ERR_DET) { | 640 | if (dma_status & DMASCR_PARITY_ERR_DET) { |
630 | printk(KERN_ERR "MM%d*: PARITY ERROR DETECTED\n", card->card_number); | 641 | dev_printk(KERN_ERR, &card->dev->dev, |
642 | "PARITY ERROR DETECTED\n"); | ||
631 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 643 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
632 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 644 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
633 | } | 645 | } |
634 | 646 | ||
635 | if (dma_status & DMASCR_SYSTEM_ERR_SIG) { | 647 | if (dma_status & DMASCR_SYSTEM_ERR_SIG) { |
636 | printk(KERN_ERR "MM%d*: SYSTEM ERROR\n", card->card_number); | 648 | dev_printk(KERN_ERR, &card->dev->dev, "SYSTEM ERROR\n"); |
637 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 649 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
638 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 650 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
639 | } | 651 | } |
640 | 652 | ||
641 | if (dma_status & DMASCR_TARGET_ABT) { | 653 | if (dma_status & DMASCR_TARGET_ABT) { |
642 | printk(KERN_ERR "MM%d*: TARGET ABORT\n", card->card_number); | 654 | dev_printk(KERN_ERR, &card->dev->dev, "TARGET ABORT\n"); |
643 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 655 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
644 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 656 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
645 | } | 657 | } |
646 | 658 | ||
647 | if (dma_status & DMASCR_MASTER_ABT) { | 659 | if (dma_status & DMASCR_MASTER_ABT) { |
648 | printk(KERN_ERR "MM%d*: MASTER ABORT\n", card->card_number); | 660 | dev_printk(KERN_ERR, &card->dev->dev, "MASTER ABORT\n"); |
649 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 661 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
650 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 662 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
651 | } | 663 | } |
@@ -656,7 +668,7 @@ HW_TRACE(0x30); | |||
656 | 668 | ||
657 | HW_TRACE(0x36); | 669 | HW_TRACE(0x36); |
658 | 670 | ||
659 | return IRQ_HANDLED; | 671 | return IRQ_HANDLED; |
660 | } | 672 | } |
661 | /* | 673 | /* |
662 | ----------------------------------------------------------------------------------- | 674 | ----------------------------------------------------------------------------------- |
@@ -696,20 +708,20 @@ static int check_battery(struct cardinfo *card, int battery, int status) | |||
696 | card->battery[battery].last_change = jiffies; | 708 | card->battery[battery].last_change = jiffies; |
697 | 709 | ||
698 | if (card->battery[battery].good) { | 710 | if (card->battery[battery].good) { |
699 | printk(KERN_ERR "MM%d: Battery %d now good\n", | 711 | dev_printk(KERN_ERR, &card->dev->dev, |
700 | card->card_number, battery + 1); | 712 | "Battery %d now good\n", battery + 1); |
701 | card->battery[battery].warned = 0; | 713 | card->battery[battery].warned = 0; |
702 | } else | 714 | } else |
703 | printk(KERN_ERR "MM%d: Battery %d now FAILED\n", | 715 | dev_printk(KERN_ERR, &card->dev->dev, |
704 | card->card_number, battery + 1); | 716 | "Battery %d now FAILED\n", battery + 1); |
705 | 717 | ||
706 | return 1; | 718 | return 1; |
707 | } else if (!card->battery[battery].good && | 719 | } else if (!card->battery[battery].good && |
708 | !card->battery[battery].warned && | 720 | !card->battery[battery].warned && |
709 | time_after_eq(jiffies, card->battery[battery].last_change + | 721 | time_after_eq(jiffies, card->battery[battery].last_change + |
710 | (HZ * 60 * 60 * 5))) { | 722 | (HZ * 60 * 60 * 5))) { |
711 | printk(KERN_ERR "MM%d: Battery %d still FAILED after 5 hours\n", | 723 | dev_printk(KERN_ERR, &card->dev->dev, |
712 | card->card_number, battery + 1); | 724 | "Battery %d still FAILED after 5 hours\n", battery + 1); |
713 | card->battery[battery].warned = 1; | 725 | card->battery[battery].warned = 1; |
714 | 726 | ||
715 | return 1; | 727 | return 1; |
@@ -733,8 +745,8 @@ static void check_batteries(struct cardinfo *card) | |||
733 | 745 | ||
734 | status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); | 746 | status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); |
735 | if (debug & DEBUG_BATTERY_POLLING) | 747 | if (debug & DEBUG_BATTERY_POLLING) |
736 | printk(KERN_DEBUG "MM%d: checking battery status, 1 = %s, 2 = %s\n", | 748 | dev_printk(KERN_DEBUG, &card->dev->dev, |
737 | card->card_number, | 749 | "checking battery status, 1 = %s, 2 = %s\n", |
738 | (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK", | 750 | (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK", |
739 | (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK"); | 751 | (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK"); |
740 | 752 | ||
@@ -749,7 +761,7 @@ static void check_all_batteries(unsigned long ptr) | |||
749 | { | 761 | { |
750 | int i; | 762 | int i; |
751 | 763 | ||
752 | for (i = 0; i < num_cards; i++) | 764 | for (i = 0; i < num_cards; i++) |
753 | if (!(cards[i].flags & UM_FLAG_NO_BATT)) { | 765 | if (!(cards[i].flags & UM_FLAG_NO_BATT)) { |
754 | struct cardinfo *card = &cards[i]; | 766 | struct cardinfo *card = &cards[i]; |
755 | spin_lock_bh(&card->lock); | 767 | spin_lock_bh(&card->lock); |
@@ -853,45 +865,56 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
853 | unsigned char mem_present; | 865 | unsigned char mem_present; |
854 | unsigned char batt_status; | 866 | unsigned char batt_status; |
855 | unsigned int saved_bar, data; | 867 | unsigned int saved_bar, data; |
868 | unsigned long csr_base; | ||
869 | unsigned long csr_len; | ||
856 | int magic_number; | 870 | int magic_number; |
871 | static int printed_version; | ||
857 | 872 | ||
858 | if (pci_enable_device(dev) < 0) | 873 | if (!printed_version++) |
859 | return -ENODEV; | 874 | printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); |
875 | |||
876 | ret = pci_enable_device(dev); | ||
877 | if (ret) | ||
878 | return ret; | ||
860 | 879 | ||
861 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF8); | 880 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF8); |
862 | pci_set_master(dev); | 881 | pci_set_master(dev); |
863 | 882 | ||
864 | card->dev = dev; | 883 | card->dev = dev; |
865 | card->card_number = num_cards; | ||
866 | 884 | ||
867 | card->csr_base = pci_resource_start(dev, 0); | 885 | csr_base = pci_resource_start(dev, 0); |
868 | card->csr_len = pci_resource_len(dev, 0); | 886 | csr_len = pci_resource_len(dev, 0); |
887 | if (!csr_base || !csr_len) | ||
888 | return -ENODEV; | ||
869 | 889 | ||
870 | printk(KERN_INFO "Micro Memory(tm) controller #%d found at %02x:%02x (PCI Mem Module (Battery Backup))\n", | 890 | dev_printk(KERN_INFO, &dev->dev, |
871 | card->card_number, dev->bus->number, dev->devfn); | 891 | "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); |
872 | 892 | ||
873 | if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && | 893 | if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && |
874 | pci_set_dma_mask(dev, DMA_32BIT_MASK)) { | 894 | pci_set_dma_mask(dev, DMA_32BIT_MASK)) { |
875 | printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); | 895 | dev_printk(KERN_WARNING, &dev->dev, "NO suitable DMA found\n"); |
876 | return -ENOMEM; | 896 | return -ENOMEM; |
877 | } | 897 | } |
878 | if (!request_mem_region(card->csr_base, card->csr_len, "Micro Memory")) { | ||
879 | printk(KERN_ERR "MM%d: Unable to request memory region\n", card->card_number); | ||
880 | ret = -ENOMEM; | ||
881 | 898 | ||
899 | ret = pci_request_regions(dev, DRIVER_NAME); | ||
900 | if (ret) { | ||
901 | dev_printk(KERN_ERR, &card->dev->dev, | ||
902 | "Unable to request memory region\n"); | ||
882 | goto failed_req_csr; | 903 | goto failed_req_csr; |
883 | } | 904 | } |
884 | 905 | ||
885 | card->csr_remap = ioremap_nocache(card->csr_base, card->csr_len); | 906 | card->csr_remap = ioremap_nocache(csr_base, csr_len); |
886 | if (!card->csr_remap) { | 907 | if (!card->csr_remap) { |
887 | printk(KERN_ERR "MM%d: Unable to remap memory region\n", card->card_number); | 908 | dev_printk(KERN_ERR, &card->dev->dev, |
909 | "Unable to remap memory region\n"); | ||
888 | ret = -ENOMEM; | 910 | ret = -ENOMEM; |
889 | 911 | ||
890 | goto failed_remap_csr; | 912 | goto failed_remap_csr; |
891 | } | 913 | } |
892 | 914 | ||
893 | printk(KERN_INFO "MM%d: CSR 0x%08lx -> 0x%p (0x%lx)\n", card->card_number, | 915 | dev_printk(KERN_INFO, &card->dev->dev, |
894 | card->csr_base, card->csr_remap, card->csr_len); | 916 | "CSR 0x%08lx -> 0x%p (0x%lx)\n", |
917 | csr_base, card->csr_remap, csr_len); | ||
895 | 918 | ||
896 | switch(card->dev->device) { | 919 | switch(card->dev->device) { |
897 | case 0x5415: | 920 | case 0x5415: |
@@ -915,7 +938,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
915 | } | 938 | } |
916 | 939 | ||
917 | if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { | 940 | if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { |
918 | printk(KERN_ERR "MM%d: Magic number invalid\n", card->card_number); | 941 | dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n"); |
919 | ret = -ENOMEM; | 942 | ret = -ENOMEM; |
920 | goto failed_magic; | 943 | goto failed_magic; |
921 | } | 944 | } |
@@ -928,7 +951,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
928 | &card->mm_pages[1].page_dma); | 951 | &card->mm_pages[1].page_dma); |
929 | if (card->mm_pages[0].desc == NULL || | 952 | if (card->mm_pages[0].desc == NULL || |
930 | card->mm_pages[1].desc == NULL) { | 953 | card->mm_pages[1].desc == NULL) { |
931 | printk(KERN_ERR "MM%d: alloc failed\n", card->card_number); | 954 | dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); |
932 | goto failed_alloc; | 955 | goto failed_alloc; |
933 | } | 956 | } |
934 | reset_page(&card->mm_pages[0]); | 957 | reset_page(&card->mm_pages[0]); |
@@ -949,7 +972,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
949 | tasklet_init(&card->tasklet, process_page, (unsigned long)card); | 972 | tasklet_init(&card->tasklet, process_page, (unsigned long)card); |
950 | 973 | ||
951 | card->check_batteries = 0; | 974 | card->check_batteries = 0; |
952 | 975 | ||
953 | mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY); | 976 | mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY); |
954 | switch (mem_present) { | 977 | switch (mem_present) { |
955 | case MEM_128_MB: | 978 | case MEM_128_MB: |
@@ -982,12 +1005,13 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
982 | card->battery[1].good = !(batt_status & BATTERY_2_FAILURE); | 1005 | card->battery[1].good = !(batt_status & BATTERY_2_FAILURE); |
983 | card->battery[0].last_change = card->battery[1].last_change = jiffies; | 1006 | card->battery[0].last_change = card->battery[1].last_change = jiffies; |
984 | 1007 | ||
985 | if (card->flags & UM_FLAG_NO_BATT) | 1008 | if (card->flags & UM_FLAG_NO_BATT) |
986 | printk(KERN_INFO "MM%d: Size %d KB\n", | 1009 | dev_printk(KERN_INFO, &card->dev->dev, |
987 | card->card_number, card->mm_size); | 1010 | "Size %d KB\n", card->mm_size); |
988 | else { | 1011 | else { |
989 | printk(KERN_INFO "MM%d: Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", | 1012 | dev_printk(KERN_INFO, &card->dev->dev, |
990 | card->card_number, card->mm_size, | 1013 | "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", |
1014 | card->mm_size, | ||
991 | (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), | 1015 | (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), |
992 | card->battery[0].good ? "OK" : "FAILURE", | 1016 | card->battery[0].good ? "OK" : "FAILURE", |
993 | (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), | 1017 | (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), |
@@ -1005,19 +1029,16 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
1005 | data = ~data; | 1029 | data = ~data; |
1006 | data += 1; | 1030 | data += 1; |
1007 | 1031 | ||
1008 | card->win_size = data; | 1032 | if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME, card)) { |
1009 | 1033 | dev_printk(KERN_ERR, &card->dev->dev, | |
1010 | 1034 | "Unable to allocate IRQ\n"); | |
1011 | if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, "pci-umem", card)) { | ||
1012 | printk(KERN_ERR "MM%d: Unable to allocate IRQ\n", card->card_number); | ||
1013 | ret = -ENODEV; | 1035 | ret = -ENODEV; |
1014 | 1036 | ||
1015 | goto failed_req_irq; | 1037 | goto failed_req_irq; |
1016 | } | 1038 | } |
1017 | 1039 | ||
1018 | card->irq = dev->irq; | 1040 | dev_printk(KERN_INFO, &card->dev->dev, |
1019 | printk(KERN_INFO "MM%d: Window size %d bytes, IRQ %d\n", card->card_number, | 1041 | "Window size %d bytes, IRQ %d\n", data, dev->irq); |
1020 | card->win_size, card->irq); | ||
1021 | 1042 | ||
1022 | spin_lock_init(&card->lock); | 1043 | spin_lock_init(&card->lock); |
1023 | 1044 | ||
@@ -1037,10 +1058,12 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
1037 | num_cards++; | 1058 | num_cards++; |
1038 | 1059 | ||
1039 | if (!get_userbit(card, MEMORY_INITIALIZED)) { | 1060 | if (!get_userbit(card, MEMORY_INITIALIZED)) { |
1040 | printk(KERN_INFO "MM%d: memory NOT initialized. Consider over-writing whole device.\n", card->card_number); | 1061 | dev_printk(KERN_INFO, &card->dev->dev, |
1062 | "memory NOT initialized. Consider over-writing whole device.\n"); | ||
1041 | card->init_size = 0; | 1063 | card->init_size = 0; |
1042 | } else { | 1064 | } else { |
1043 | printk(KERN_INFO "MM%d: memory already initialized\n", card->card_number); | 1065 | dev_printk(KERN_INFO, &card->dev->dev, |
1066 | "memory already initialized\n"); | ||
1044 | card->init_size = card->mm_size; | 1067 | card->init_size = card->mm_size; |
1045 | } | 1068 | } |
1046 | 1069 | ||
@@ -1062,7 +1085,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
1062 | failed_magic: | 1085 | failed_magic: |
1063 | iounmap(card->csr_remap); | 1086 | iounmap(card->csr_remap); |
1064 | failed_remap_csr: | 1087 | failed_remap_csr: |
1065 | release_mem_region(card->csr_base, card->csr_len); | 1088 | pci_release_regions(dev); |
1066 | failed_req_csr: | 1089 | failed_req_csr: |
1067 | 1090 | ||
1068 | return ret; | 1091 | return ret; |
@@ -1077,9 +1100,8 @@ static void mm_pci_remove(struct pci_dev *dev) | |||
1077 | struct cardinfo *card = pci_get_drvdata(dev); | 1100 | struct cardinfo *card = pci_get_drvdata(dev); |
1078 | 1101 | ||
1079 | tasklet_kill(&card->tasklet); | 1102 | tasklet_kill(&card->tasklet); |
1103 | free_irq(dev->irq, card); | ||
1080 | iounmap(card->csr_remap); | 1104 | iounmap(card->csr_remap); |
1081 | release_mem_region(card->csr_base, card->csr_len); | ||
1082 | free_irq(card->irq, card); | ||
1083 | 1105 | ||
1084 | if (card->mm_pages[0].desc) | 1106 | if (card->mm_pages[0].desc) |
1085 | pci_free_consistent(card->dev, PAGE_SIZE*2, | 1107 | pci_free_consistent(card->dev, PAGE_SIZE*2, |
@@ -1090,6 +1112,9 @@ static void mm_pci_remove(struct pci_dev *dev) | |||
1090 | card->mm_pages[1].desc, | 1112 | card->mm_pages[1].desc, |
1091 | card->mm_pages[1].page_dma); | 1113 | card->mm_pages[1].page_dma); |
1092 | blk_cleanup_queue(card->queue); | 1114 | blk_cleanup_queue(card->queue); |
1115 | |||
1116 | pci_release_regions(dev); | ||
1117 | pci_disable_device(dev); | ||
1093 | } | 1118 | } |
1094 | 1119 | ||
1095 | static const struct pci_device_id mm_pci_ids[] = { | 1120 | static const struct pci_device_id mm_pci_ids[] = { |
@@ -1109,11 +1134,12 @@ static const struct pci_device_id mm_pci_ids[] = { | |||
1109 | MODULE_DEVICE_TABLE(pci, mm_pci_ids); | 1134 | MODULE_DEVICE_TABLE(pci, mm_pci_ids); |
1110 | 1135 | ||
1111 | static struct pci_driver mm_pci_driver = { | 1136 | static struct pci_driver mm_pci_driver = { |
1112 | .name = "umem", | 1137 | .name = DRIVER_NAME, |
1113 | .id_table = mm_pci_ids, | 1138 | .id_table = mm_pci_ids, |
1114 | .probe = mm_pci_probe, | 1139 | .probe = mm_pci_probe, |
1115 | .remove = mm_pci_remove, | 1140 | .remove = mm_pci_remove, |
1116 | }; | 1141 | }; |
1142 | |||
1117 | /* | 1143 | /* |
1118 | ----------------------------------------------------------------------------------- | 1144 | ----------------------------------------------------------------------------------- |
1119 | -- mm_init | 1145 | -- mm_init |
@@ -1125,13 +1151,11 @@ static int __init mm_init(void) | |||
1125 | int retval, i; | 1151 | int retval, i; |
1126 | int err; | 1152 | int err; |
1127 | 1153 | ||
1128 | printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); | ||
1129 | |||
1130 | retval = pci_register_driver(&mm_pci_driver); | 1154 | retval = pci_register_driver(&mm_pci_driver); |
1131 | if (retval) | 1155 | if (retval) |
1132 | return -ENOMEM; | 1156 | return -ENOMEM; |
1133 | 1157 | ||
1134 | err = major_nr = register_blkdev(0, "umem"); | 1158 | err = major_nr = register_blkdev(0, DRIVER_NAME); |
1135 | if (err < 0) { | 1159 | if (err < 0) { |
1136 | pci_unregister_driver(&mm_pci_driver); | 1160 | pci_unregister_driver(&mm_pci_driver); |
1137 | return -EIO; | 1161 | return -EIO; |
@@ -1157,13 +1181,13 @@ static int __init mm_init(void) | |||
1157 | } | 1181 | } |
1158 | 1182 | ||
1159 | init_battery_timer(); | 1183 | init_battery_timer(); |
1160 | printk("MM: desc_per_page = %ld\n", DESC_PER_PAGE); | 1184 | printk(KERN_INFO "MM: desc_per_page = %ld\n", DESC_PER_PAGE); |
1161 | /* printk("mm_init: Done. 10-19-01 9:00\n"); */ | 1185 | /* printk("mm_init: Done. 10-19-01 9:00\n"); */ |
1162 | return 0; | 1186 | return 0; |
1163 | 1187 | ||
1164 | out: | 1188 | out: |
1165 | pci_unregister_driver(&mm_pci_driver); | 1189 | pci_unregister_driver(&mm_pci_driver); |
1166 | unregister_blkdev(major_nr, "umem"); | 1190 | unregister_blkdev(major_nr, DRIVER_NAME); |
1167 | while (i--) | 1191 | while (i--) |
1168 | put_disk(mm_gendisk[i]); | 1192 | put_disk(mm_gendisk[i]); |
1169 | return -ENOMEM; | 1193 | return -ENOMEM; |
@@ -1186,7 +1210,7 @@ static void __exit mm_cleanup(void) | |||
1186 | 1210 | ||
1187 | pci_unregister_driver(&mm_pci_driver); | 1211 | pci_unregister_driver(&mm_pci_driver); |
1188 | 1212 | ||
1189 | unregister_blkdev(major_nr, "umem"); | 1213 | unregister_blkdev(major_nr, DRIVER_NAME); |
1190 | } | 1214 | } |
1191 | 1215 | ||
1192 | module_init(mm_init); | 1216 | module_init(mm_init); |
diff --git a/drivers/block/umem.h b/drivers/block/umem.h new file mode 100644 index 000000000000..375c68974c9a --- /dev/null +++ b/drivers/block/umem.h | |||
@@ -0,0 +1,133 @@ | |||
1 | |||
2 | /* | ||
3 | * This file contains defines for the | ||
4 | * Micro Memory MM5415 | ||
5 | * family PCI Memory Module with Battery Backup. | ||
6 | * | ||
7 | * Copyright Micro Memory INC 2001. All rights reserved. | ||
8 | * Release under the terms of the GNU GENERAL PUBLIC LICENSE version 2. | ||
9 | * See the file COPYING. | ||
10 | */ | ||
11 | |||
12 | #ifndef _DRIVERS_BLOCK_MM_H | ||
13 | #define _DRIVERS_BLOCK_MM_H | ||
14 | |||
15 | |||
16 | #define IRQ_TIMEOUT (1 * HZ) | ||
17 | |||
18 | /* CSR register definition */ | ||
19 | #define MEMCTRLSTATUS_MAGIC 0x00 | ||
20 | #define MM_MAGIC_VALUE (unsigned char)0x59 | ||
21 | |||
22 | #define MEMCTRLSTATUS_BATTERY 0x04 | ||
23 | #define BATTERY_1_DISABLED 0x01 | ||
24 | #define BATTERY_1_FAILURE 0x02 | ||
25 | #define BATTERY_2_DISABLED 0x04 | ||
26 | #define BATTERY_2_FAILURE 0x08 | ||
27 | |||
28 | #define MEMCTRLSTATUS_MEMORY 0x07 | ||
29 | #define MEM_128_MB 0xfe | ||
30 | #define MEM_256_MB 0xfc | ||
31 | #define MEM_512_MB 0xf8 | ||
32 | #define MEM_1_GB 0xf0 | ||
33 | #define MEM_2_GB 0xe0 | ||
34 | |||
35 | #define MEMCTRLCMD_LEDCTRL 0x08 | ||
36 | #define LED_REMOVE 2 | ||
37 | #define LED_FAULT 4 | ||
38 | #define LED_POWER 6 | ||
39 | #define LED_FLIP 255 | ||
40 | #define LED_OFF 0x00 | ||
41 | #define LED_ON 0x01 | ||
42 | #define LED_FLASH_3_5 0x02 | ||
43 | #define LED_FLASH_7_0 0x03 | ||
44 | #define LED_POWER_ON 0x00 | ||
45 | #define LED_POWER_OFF 0x01 | ||
46 | #define USER_BIT1 0x01 | ||
47 | #define USER_BIT2 0x02 | ||
48 | |||
49 | #define MEMORY_INITIALIZED USER_BIT1 | ||
50 | |||
51 | #define MEMCTRLCMD_ERRCTRL 0x0C | ||
52 | #define EDC_NONE_DEFAULT 0x00 | ||
53 | #define EDC_NONE 0x01 | ||
54 | #define EDC_STORE_READ 0x02 | ||
55 | #define EDC_STORE_CORRECT 0x03 | ||
56 | |||
57 | #define MEMCTRLCMD_ERRCNT 0x0D | ||
58 | #define MEMCTRLCMD_ERRSTATUS 0x0E | ||
59 | |||
60 | #define ERROR_DATA_LOG 0x20 | ||
61 | #define ERROR_ADDR_LOG 0x28 | ||
62 | #define ERROR_COUNT 0x3D | ||
63 | #define ERROR_SYNDROME 0x3E | ||
64 | #define ERROR_CHECK 0x3F | ||
65 | |||
66 | #define DMA_PCI_ADDR 0x40 | ||
67 | #define DMA_LOCAL_ADDR 0x48 | ||
68 | #define DMA_TRANSFER_SIZE 0x50 | ||
69 | #define DMA_DESCRIPTOR_ADDR 0x58 | ||
70 | #define DMA_SEMAPHORE_ADDR 0x60 | ||
71 | #define DMA_STATUS_CTRL 0x68 | ||
72 | #define DMASCR_GO 0x00001 | ||
73 | #define DMASCR_TRANSFER_READ 0x00002 | ||
74 | #define DMASCR_CHAIN_EN 0x00004 | ||
75 | #define DMASCR_SEM_EN 0x00010 | ||
76 | #define DMASCR_DMA_COMP_EN 0x00020 | ||
77 | #define DMASCR_CHAIN_COMP_EN 0x00040 | ||
78 | #define DMASCR_ERR_INT_EN 0x00080 | ||
79 | #define DMASCR_PARITY_INT_EN 0x00100 | ||
80 | #define DMASCR_ANY_ERR 0x00800 | ||
81 | #define DMASCR_MBE_ERR 0x01000 | ||
82 | #define DMASCR_PARITY_ERR_REP 0x02000 | ||
83 | #define DMASCR_PARITY_ERR_DET 0x04000 | ||
84 | #define DMASCR_SYSTEM_ERR_SIG 0x08000 | ||
85 | #define DMASCR_TARGET_ABT 0x10000 | ||
86 | #define DMASCR_MASTER_ABT 0x20000 | ||
87 | #define DMASCR_DMA_COMPLETE 0x40000 | ||
88 | #define DMASCR_CHAIN_COMPLETE 0x80000 | ||
89 | |||
90 | /* | ||
91 | 3.SOME PCs HAVE HOST BRIDGES WHICH APPARENTLY DO NOT CORRECTLY HANDLE | ||
92 | READ-LINE (0xE) OR READ-MULTIPLE (0xC) PCI COMMAND CODES DURING DMA | ||
93 | TRANSFERS. IN OTHER SYSTEMS THESE COMMAND CODES WILL CAUSE THE HOST BRIDGE | ||
94 | TO ALLOW LONGER BURSTS DURING DMA READ OPERATIONS. THE UPPER FOUR BITS | ||
95 | (31..28) OF THE DMA CSR HAVE BEEN MADE PROGRAMMABLE, SO THAT EITHER A 0x6, | ||
96 | AN 0xE OR A 0xC CAN BE WRITTEN TO THEM TO SET THE COMMAND CODE USED DURING | ||
97 | DMA READ OPERATIONS. | ||
98 | */ | ||
99 | #define DMASCR_READ 0x60000000 | ||
100 | #define DMASCR_READLINE 0xE0000000 | ||
101 | #define DMASCR_READMULTI 0xC0000000 | ||
102 | |||
103 | |||
104 | #define DMASCR_ERROR_MASK (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR | DMASCR_ANY_ERR) | ||
105 | #define DMASCR_HARD_ERROR (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR) | ||
106 | |||
107 | #define WINDOWMAP_WINNUM 0x7B | ||
108 | |||
109 | #define DMA_READ_FROM_HOST 0 | ||
110 | #define DMA_WRITE_TO_HOST 1 | ||
111 | |||
112 | struct mm_dma_desc { | ||
113 | __le64 pci_addr; | ||
114 | __le64 local_addr; | ||
115 | __le32 transfer_size; | ||
116 | u32 zero1; | ||
117 | __le64 next_desc_addr; | ||
118 | __le64 sem_addr; | ||
119 | __le32 control_bits; | ||
120 | u32 zero2; | ||
121 | |||
122 | dma_addr_t data_dma_handle; | ||
123 | |||
124 | /* Copy of the bits */ | ||
125 | __le64 sem_control_bits; | ||
126 | } __attribute__((aligned(8))); | ||
127 | |||
128 | /* bits for card->flags */ | ||
129 | #define UM_FLAG_DMA_IN_REGS 1 | ||
130 | #define UM_FLAG_NO_BYTE_STATUS 2 | ||
131 | #define UM_FLAG_NO_BATTREG 4 | ||
132 | #define UM_FLAG_NO_BATT 8 | ||
133 | #endif | ||
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 964e51634f2d..2bdebcb3ff16 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -150,9 +150,8 @@ static int blkif_queue_request(struct request *req) | |||
150 | struct blkfront_info *info = req->rq_disk->private_data; | 150 | struct blkfront_info *info = req->rq_disk->private_data; |
151 | unsigned long buffer_mfn; | 151 | unsigned long buffer_mfn; |
152 | struct blkif_request *ring_req; | 152 | struct blkif_request *ring_req; |
153 | struct bio *bio; | 153 | struct req_iterator iter; |
154 | struct bio_vec *bvec; | 154 | struct bio_vec *bvec; |
155 | int idx; | ||
156 | unsigned long id; | 155 | unsigned long id; |
157 | unsigned int fsect, lsect; | 156 | unsigned int fsect, lsect; |
158 | int ref; | 157 | int ref; |
@@ -186,34 +185,31 @@ static int blkif_queue_request(struct request *req) | |||
186 | ring_req->operation = BLKIF_OP_WRITE_BARRIER; | 185 | ring_req->operation = BLKIF_OP_WRITE_BARRIER; |
187 | 186 | ||
188 | ring_req->nr_segments = 0; | 187 | ring_req->nr_segments = 0; |
189 | rq_for_each_bio (bio, req) { | 188 | rq_for_each_segment(bvec, req, iter) { |
190 | bio_for_each_segment (bvec, bio, idx) { | 189 | BUG_ON(ring_req->nr_segments == BLKIF_MAX_SEGMENTS_PER_REQUEST); |
191 | BUG_ON(ring_req->nr_segments | 190 | buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); |
192 | == BLKIF_MAX_SEGMENTS_PER_REQUEST); | 191 | fsect = bvec->bv_offset >> 9; |
193 | buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); | 192 | lsect = fsect + (bvec->bv_len >> 9) - 1; |
194 | fsect = bvec->bv_offset >> 9; | 193 | /* install a grant reference. */ |
195 | lsect = fsect + (bvec->bv_len >> 9) - 1; | 194 | ref = gnttab_claim_grant_reference(&gref_head); |
196 | /* install a grant reference. */ | 195 | BUG_ON(ref == -ENOSPC); |
197 | ref = gnttab_claim_grant_reference(&gref_head); | 196 | |
198 | BUG_ON(ref == -ENOSPC); | 197 | gnttab_grant_foreign_access_ref( |
199 | |||
200 | gnttab_grant_foreign_access_ref( | ||
201 | ref, | 198 | ref, |
202 | info->xbdev->otherend_id, | 199 | info->xbdev->otherend_id, |
203 | buffer_mfn, | 200 | buffer_mfn, |
204 | rq_data_dir(req) ); | 201 | rq_data_dir(req) ); |
205 | 202 | ||
206 | info->shadow[id].frame[ring_req->nr_segments] = | 203 | info->shadow[id].frame[ring_req->nr_segments] = |
207 | mfn_to_pfn(buffer_mfn); | 204 | mfn_to_pfn(buffer_mfn); |
208 | 205 | ||
209 | ring_req->seg[ring_req->nr_segments] = | 206 | ring_req->seg[ring_req->nr_segments] = |
210 | (struct blkif_request_segment) { | 207 | (struct blkif_request_segment) { |
211 | .gref = ref, | 208 | .gref = ref, |
212 | .first_sect = fsect, | 209 | .first_sect = fsect, |
213 | .last_sect = lsect }; | 210 | .last_sect = lsect }; |
214 | 211 | ||
215 | ring_req->nr_segments++; | 212 | ring_req->nr_segments++; |
216 | } | ||
217 | } | 213 | } |
218 | 214 | ||
219 | info->ring.req_prod_pvt++; | 215 | info->ring.req_prod_pvt++; |
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 3ede0b63da13..9e7652dcde6c 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c | |||
@@ -91,6 +91,10 @@ | |||
91 | #include <linux/blkdev.h> | 91 | #include <linux/blkdev.h> |
92 | #include <linux/hdreg.h> | 92 | #include <linux/hdreg.h> |
93 | #include <linux/platform_device.h> | 93 | #include <linux/platform_device.h> |
94 | #if defined(CONFIG_OF) | ||
95 | #include <linux/of_device.h> | ||
96 | #include <linux/of_platform.h> | ||
97 | #endif | ||
94 | 98 | ||
95 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | 99 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); |
96 | MODULE_DESCRIPTION("Xilinx SystemACE device driver"); | 100 | MODULE_DESCRIPTION("Xilinx SystemACE device driver"); |
@@ -158,6 +162,9 @@ MODULE_LICENSE("GPL"); | |||
158 | #define ACE_FIFO_SIZE (32) | 162 | #define ACE_FIFO_SIZE (32) |
159 | #define ACE_BUF_PER_SECTOR (ACE_SECTOR_SIZE / ACE_FIFO_SIZE) | 163 | #define ACE_BUF_PER_SECTOR (ACE_SECTOR_SIZE / ACE_FIFO_SIZE) |
160 | 164 | ||
165 | #define ACE_BUS_WIDTH_8 0 | ||
166 | #define ACE_BUS_WIDTH_16 1 | ||
167 | |||
161 | struct ace_reg_ops; | 168 | struct ace_reg_ops; |
162 | 169 | ||
163 | struct ace_device { | 170 | struct ace_device { |
@@ -188,7 +195,7 @@ struct ace_device { | |||
188 | 195 | ||
189 | /* Details of hardware device */ | 196 | /* Details of hardware device */ |
190 | unsigned long physaddr; | 197 | unsigned long physaddr; |
191 | void *baseaddr; | 198 | void __iomem *baseaddr; |
192 | int irq; | 199 | int irq; |
193 | int bus_width; /* 0 := 8 bit; 1 := 16 bit */ | 200 | int bus_width; /* 0 := 8 bit; 1 := 16 bit */ |
194 | struct ace_reg_ops *reg_ops; | 201 | struct ace_reg_ops *reg_ops; |
@@ -220,20 +227,20 @@ struct ace_reg_ops { | |||
220 | /* 8 Bit bus width */ | 227 | /* 8 Bit bus width */ |
221 | static u16 ace_in_8(struct ace_device *ace, int reg) | 228 | static u16 ace_in_8(struct ace_device *ace, int reg) |
222 | { | 229 | { |
223 | void *r = ace->baseaddr + reg; | 230 | void __iomem *r = ace->baseaddr + reg; |
224 | return in_8(r) | (in_8(r + 1) << 8); | 231 | return in_8(r) | (in_8(r + 1) << 8); |
225 | } | 232 | } |
226 | 233 | ||
227 | static void ace_out_8(struct ace_device *ace, int reg, u16 val) | 234 | static void ace_out_8(struct ace_device *ace, int reg, u16 val) |
228 | { | 235 | { |
229 | void *r = ace->baseaddr + reg; | 236 | void __iomem *r = ace->baseaddr + reg; |
230 | out_8(r, val); | 237 | out_8(r, val); |
231 | out_8(r + 1, val >> 8); | 238 | out_8(r + 1, val >> 8); |
232 | } | 239 | } |
233 | 240 | ||
234 | static void ace_datain_8(struct ace_device *ace) | 241 | static void ace_datain_8(struct ace_device *ace) |
235 | { | 242 | { |
236 | void *r = ace->baseaddr + 0x40; | 243 | void __iomem *r = ace->baseaddr + 0x40; |
237 | u8 *dst = ace->data_ptr; | 244 | u8 *dst = ace->data_ptr; |
238 | int i = ACE_FIFO_SIZE; | 245 | int i = ACE_FIFO_SIZE; |
239 | while (i--) | 246 | while (i--) |
@@ -243,7 +250,7 @@ static void ace_datain_8(struct ace_device *ace) | |||
243 | 250 | ||
244 | static void ace_dataout_8(struct ace_device *ace) | 251 | static void ace_dataout_8(struct ace_device *ace) |
245 | { | 252 | { |
246 | void *r = ace->baseaddr + 0x40; | 253 | void __iomem *r = ace->baseaddr + 0x40; |
247 | u8 *src = ace->data_ptr; | 254 | u8 *src = ace->data_ptr; |
248 | int i = ACE_FIFO_SIZE; | 255 | int i = ACE_FIFO_SIZE; |
249 | while (i--) | 256 | while (i--) |
@@ -931,9 +938,11 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
931 | { | 938 | { |
932 | u16 version; | 939 | u16 version; |
933 | u16 val; | 940 | u16 val; |
934 | |||
935 | int rc; | 941 | int rc; |
936 | 942 | ||
943 | dev_dbg(ace->dev, "ace_setup(ace=0x%p)\n", ace); | ||
944 | dev_dbg(ace->dev, "physaddr=0x%lx irq=%i\n", ace->physaddr, ace->irq); | ||
945 | |||
937 | spin_lock_init(&ace->lock); | 946 | spin_lock_init(&ace->lock); |
938 | init_completion(&ace->id_completion); | 947 | init_completion(&ace->id_completion); |
939 | 948 | ||
@@ -944,15 +953,6 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
944 | if (!ace->baseaddr) | 953 | if (!ace->baseaddr) |
945 | goto err_ioremap; | 954 | goto err_ioremap; |
946 | 955 | ||
947 | if (ace->irq != NO_IRQ) { | ||
948 | rc = request_irq(ace->irq, ace_interrupt, 0, "systemace", ace); | ||
949 | if (rc) { | ||
950 | /* Failure - fall back to polled mode */ | ||
951 | dev_err(ace->dev, "request_irq failed\n"); | ||
952 | ace->irq = NO_IRQ; | ||
953 | } | ||
954 | } | ||
955 | |||
956 | /* | 956 | /* |
957 | * Initialize the state machine tasklet and stall timer | 957 | * Initialize the state machine tasklet and stall timer |
958 | */ | 958 | */ |
@@ -982,7 +982,7 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
982 | snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a'); | 982 | snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a'); |
983 | 983 | ||
984 | /* set bus width */ | 984 | /* set bus width */ |
985 | if (ace->bus_width == 1) { | 985 | if (ace->bus_width == ACE_BUS_WIDTH_16) { |
986 | /* 0x0101 should work regardless of endianess */ | 986 | /* 0x0101 should work regardless of endianess */ |
987 | ace_out_le16(ace, ACE_BUSMODE, 0x0101); | 987 | ace_out_le16(ace, ACE_BUSMODE, 0x0101); |
988 | 988 | ||
@@ -1005,6 +1005,16 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
1005 | ace_out(ace, ACE_CTRL, ACE_CTRL_FORCECFGMODE | | 1005 | ace_out(ace, ACE_CTRL, ACE_CTRL_FORCECFGMODE | |
1006 | ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ); | 1006 | ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ); |
1007 | 1007 | ||
1008 | /* Now we can hook up the irq handler */ | ||
1009 | if (ace->irq != NO_IRQ) { | ||
1010 | rc = request_irq(ace->irq, ace_interrupt, 0, "systemace", ace); | ||
1011 | if (rc) { | ||
1012 | /* Failure - fall back to polled mode */ | ||
1013 | dev_err(ace->dev, "request_irq failed\n"); | ||
1014 | ace->irq = NO_IRQ; | ||
1015 | } | ||
1016 | } | ||
1017 | |||
1008 | /* Enable interrupts */ | 1018 | /* Enable interrupts */ |
1009 | val = ace_in(ace, ACE_CTRL); | 1019 | val = ace_in(ace, ACE_CTRL); |
1010 | val |= ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ; | 1020 | val |= ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ; |
@@ -1024,16 +1034,14 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
1024 | 1034 | ||
1025 | return 0; | 1035 | return 0; |
1026 | 1036 | ||
1027 | err_read: | 1037 | err_read: |
1028 | put_disk(ace->gd); | 1038 | put_disk(ace->gd); |
1029 | err_alloc_disk: | 1039 | err_alloc_disk: |
1030 | blk_cleanup_queue(ace->queue); | 1040 | blk_cleanup_queue(ace->queue); |
1031 | err_blk_initq: | 1041 | err_blk_initq: |
1032 | iounmap(ace->baseaddr); | 1042 | iounmap(ace->baseaddr); |
1033 | if (ace->irq != NO_IRQ) | 1043 | err_ioremap: |
1034 | free_irq(ace->irq, ace); | 1044 | dev_info(ace->dev, "xsysace: error initializing device at 0x%lx\n", |
1035 | err_ioremap: | ||
1036 | printk(KERN_INFO "xsysace: error initializing device at 0x%lx\n", | ||
1037 | ace->physaddr); | 1045 | ace->physaddr); |
1038 | return -ENOMEM; | 1046 | return -ENOMEM; |
1039 | } | 1047 | } |
@@ -1056,98 +1064,222 @@ static void __devexit ace_teardown(struct ace_device *ace) | |||
1056 | iounmap(ace->baseaddr); | 1064 | iounmap(ace->baseaddr); |
1057 | } | 1065 | } |
1058 | 1066 | ||
1059 | /* --------------------------------------------------------------------- | 1067 | static int __devinit |
1060 | * Platform Bus Support | 1068 | ace_alloc(struct device *dev, int id, unsigned long physaddr, |
1061 | */ | 1069 | int irq, int bus_width) |
1062 | |||
1063 | static int __devinit ace_probe(struct device *device) | ||
1064 | { | 1070 | { |
1065 | struct platform_device *dev = to_platform_device(device); | ||
1066 | struct ace_device *ace; | 1071 | struct ace_device *ace; |
1067 | int i; | 1072 | int rc; |
1073 | dev_dbg(dev, "ace_alloc(%p)\n", dev); | ||
1068 | 1074 | ||
1069 | dev_dbg(device, "ace_probe(%p)\n", device); | 1075 | if (!physaddr) { |
1076 | rc = -ENODEV; | ||
1077 | goto err_noreg; | ||
1078 | } | ||
1070 | 1079 | ||
1071 | /* | 1080 | /* Allocate and initialize the ace device structure */ |
1072 | * Allocate the ace device structure | ||
1073 | */ | ||
1074 | ace = kzalloc(sizeof(struct ace_device), GFP_KERNEL); | 1081 | ace = kzalloc(sizeof(struct ace_device), GFP_KERNEL); |
1075 | if (!ace) | 1082 | if (!ace) { |
1083 | rc = -ENOMEM; | ||
1076 | goto err_alloc; | 1084 | goto err_alloc; |
1077 | |||
1078 | ace->dev = device; | ||
1079 | ace->id = dev->id; | ||
1080 | ace->irq = NO_IRQ; | ||
1081 | |||
1082 | for (i = 0; i < dev->num_resources; i++) { | ||
1083 | if (dev->resource[i].flags & IORESOURCE_MEM) | ||
1084 | ace->physaddr = dev->resource[i].start; | ||
1085 | if (dev->resource[i].flags & IORESOURCE_IRQ) | ||
1086 | ace->irq = dev->resource[i].start; | ||
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | /* FIXME: Should get bus_width from the platform_device struct */ | 1087 | ace->dev = dev; |
1090 | ace->bus_width = 1; | 1088 | ace->id = id; |
1091 | 1089 | ace->physaddr = physaddr; | |
1092 | dev_set_drvdata(&dev->dev, ace); | 1090 | ace->irq = irq; |
1091 | ace->bus_width = bus_width; | ||
1093 | 1092 | ||
1094 | /* Call the bus-independant setup code */ | 1093 | /* Call the setup code */ |
1095 | if (ace_setup(ace) != 0) | 1094 | rc = ace_setup(ace); |
1095 | if (rc) | ||
1096 | goto err_setup; | 1096 | goto err_setup; |
1097 | 1097 | ||
1098 | dev_set_drvdata(dev, ace); | ||
1098 | return 0; | 1099 | return 0; |
1099 | 1100 | ||
1100 | err_setup: | 1101 | err_setup: |
1101 | dev_set_drvdata(&dev->dev, NULL); | 1102 | dev_set_drvdata(dev, NULL); |
1102 | kfree(ace); | 1103 | kfree(ace); |
1103 | err_alloc: | 1104 | err_alloc: |
1104 | printk(KERN_ERR "xsysace: could not initialize device\n"); | 1105 | err_noreg: |
1105 | return -ENOMEM; | 1106 | dev_err(dev, "could not initialize device, err=%i\n", rc); |
1107 | return rc; | ||
1106 | } | 1108 | } |
1107 | 1109 | ||
1108 | /* | 1110 | static void __devexit ace_free(struct device *dev) |
1109 | * Platform bus remove() method | ||
1110 | */ | ||
1111 | static int __devexit ace_remove(struct device *device) | ||
1112 | { | 1111 | { |
1113 | struct ace_device *ace = dev_get_drvdata(device); | 1112 | struct ace_device *ace = dev_get_drvdata(dev); |
1114 | 1113 | dev_dbg(dev, "ace_free(%p)\n", dev); | |
1115 | dev_dbg(device, "ace_remove(%p)\n", device); | ||
1116 | 1114 | ||
1117 | if (ace) { | 1115 | if (ace) { |
1118 | ace_teardown(ace); | 1116 | ace_teardown(ace); |
1117 | dev_set_drvdata(dev, NULL); | ||
1119 | kfree(ace); | 1118 | kfree(ace); |
1120 | } | 1119 | } |
1120 | } | ||
1121 | |||
1122 | /* --------------------------------------------------------------------- | ||
1123 | * Platform Bus Support | ||
1124 | */ | ||
1125 | |||
1126 | static int __devinit ace_probe(struct platform_device *dev) | ||
1127 | { | ||
1128 | unsigned long physaddr = 0; | ||
1129 | int bus_width = ACE_BUS_WIDTH_16; /* FIXME: should not be hard coded */ | ||
1130 | int id = dev->id; | ||
1131 | int irq = NO_IRQ; | ||
1132 | int i; | ||
1121 | 1133 | ||
1134 | dev_dbg(&dev->dev, "ace_probe(%p)\n", dev); | ||
1135 | |||
1136 | for (i = 0; i < dev->num_resources; i++) { | ||
1137 | if (dev->resource[i].flags & IORESOURCE_MEM) | ||
1138 | physaddr = dev->resource[i].start; | ||
1139 | if (dev->resource[i].flags & IORESOURCE_IRQ) | ||
1140 | irq = dev->resource[i].start; | ||
1141 | } | ||
1142 | |||
1143 | /* Call the bus-independant setup code */ | ||
1144 | return ace_alloc(&dev->dev, id, physaddr, irq, bus_width); | ||
1145 | } | ||
1146 | |||
1147 | /* | ||
1148 | * Platform bus remove() method | ||
1149 | */ | ||
1150 | static int __devexit ace_remove(struct platform_device *dev) | ||
1151 | { | ||
1152 | ace_free(&dev->dev); | ||
1122 | return 0; | 1153 | return 0; |
1123 | } | 1154 | } |
1124 | 1155 | ||
1125 | static struct device_driver ace_driver = { | 1156 | static struct platform_driver ace_platform_driver = { |
1126 | .name = "xsysace", | ||
1127 | .bus = &platform_bus_type, | ||
1128 | .probe = ace_probe, | 1157 | .probe = ace_probe, |
1129 | .remove = __devexit_p(ace_remove), | 1158 | .remove = __devexit_p(ace_remove), |
1159 | .driver = { | ||
1160 | .owner = THIS_MODULE, | ||
1161 | .name = "xsysace", | ||
1162 | }, | ||
1163 | }; | ||
1164 | |||
1165 | /* --------------------------------------------------------------------- | ||
1166 | * OF_Platform Bus Support | ||
1167 | */ | ||
1168 | |||
1169 | #if defined(CONFIG_OF) | ||
1170 | static int __devinit | ||
1171 | ace_of_probe(struct of_device *op, const struct of_device_id *match) | ||
1172 | { | ||
1173 | struct resource res; | ||
1174 | unsigned long physaddr; | ||
1175 | const u32 *id; | ||
1176 | int irq, bus_width, rc; | ||
1177 | |||
1178 | dev_dbg(&op->dev, "ace_of_probe(%p, %p)\n", op, match); | ||
1179 | |||
1180 | /* device id */ | ||
1181 | id = of_get_property(op->node, "port-number", NULL); | ||
1182 | |||
1183 | /* physaddr */ | ||
1184 | rc = of_address_to_resource(op->node, 0, &res); | ||
1185 | if (rc) { | ||
1186 | dev_err(&op->dev, "invalid address\n"); | ||
1187 | return rc; | ||
1188 | } | ||
1189 | physaddr = res.start; | ||
1190 | |||
1191 | /* irq */ | ||
1192 | irq = irq_of_parse_and_map(op->node, 0); | ||
1193 | |||
1194 | /* bus width */ | ||
1195 | bus_width = ACE_BUS_WIDTH_16; | ||
1196 | if (of_find_property(op->node, "8-bit", NULL)) | ||
1197 | bus_width = ACE_BUS_WIDTH_8; | ||
1198 | |||
1199 | /* Call the bus-independant setup code */ | ||
1200 | return ace_alloc(&op->dev, id ? *id : 0, physaddr, irq, bus_width); | ||
1201 | } | ||
1202 | |||
1203 | static int __devexit ace_of_remove(struct of_device *op) | ||
1204 | { | ||
1205 | ace_free(&op->dev); | ||
1206 | return 0; | ||
1207 | } | ||
1208 | |||
1209 | /* Match table for of_platform binding */ | ||
1210 | static struct of_device_id __devinit ace_of_match[] = { | ||
1211 | { .compatible = "xilinx,xsysace", }, | ||
1212 | {}, | ||
1213 | }; | ||
1214 | MODULE_DEVICE_TABLE(of, ace_of_match); | ||
1215 | |||
1216 | static struct of_platform_driver ace_of_driver = { | ||
1217 | .owner = THIS_MODULE, | ||
1218 | .name = "xsysace", | ||
1219 | .match_table = ace_of_match, | ||
1220 | .probe = ace_of_probe, | ||
1221 | .remove = __devexit_p(ace_of_remove), | ||
1222 | .driver = { | ||
1223 | .name = "xsysace", | ||
1224 | }, | ||
1130 | }; | 1225 | }; |
1131 | 1226 | ||
1227 | /* Registration helpers to keep the number of #ifdefs to a minimum */ | ||
1228 | static inline int __init ace_of_register(void) | ||
1229 | { | ||
1230 | pr_debug("xsysace: registering OF binding\n"); | ||
1231 | return of_register_platform_driver(&ace_of_driver); | ||
1232 | } | ||
1233 | |||
1234 | static inline void __exit ace_of_unregister(void) | ||
1235 | { | ||
1236 | of_unregister_platform_driver(&ace_of_driver); | ||
1237 | } | ||
1238 | #else /* CONFIG_OF */ | ||
1239 | /* CONFIG_OF not enabled; do nothing helpers */ | ||
1240 | static inline int __init ace_of_register(void) { return 0; } | ||
1241 | static inline void __exit ace_of_unregister(void) { } | ||
1242 | #endif /* CONFIG_OF */ | ||
1243 | |||
1132 | /* --------------------------------------------------------------------- | 1244 | /* --------------------------------------------------------------------- |
1133 | * Module init/exit routines | 1245 | * Module init/exit routines |
1134 | */ | 1246 | */ |
1135 | static int __init ace_init(void) | 1247 | static int __init ace_init(void) |
1136 | { | 1248 | { |
1249 | int rc; | ||
1250 | |||
1137 | ace_major = register_blkdev(ace_major, "xsysace"); | 1251 | ace_major = register_blkdev(ace_major, "xsysace"); |
1138 | if (ace_major <= 0) { | 1252 | if (ace_major <= 0) { |
1139 | printk(KERN_WARNING "xsysace: register_blkdev() failed\n"); | 1253 | rc = -ENOMEM; |
1140 | return ace_major; | 1254 | goto err_blk; |
1141 | } | 1255 | } |
1142 | 1256 | ||
1143 | pr_debug("Registering Xilinx SystemACE driver, major=%i\n", ace_major); | 1257 | rc = ace_of_register(); |
1144 | return driver_register(&ace_driver); | 1258 | if (rc) |
1259 | goto err_of; | ||
1260 | |||
1261 | pr_debug("xsysace: registering platform binding\n"); | ||
1262 | rc = platform_driver_register(&ace_platform_driver); | ||
1263 | if (rc) | ||
1264 | goto err_plat; | ||
1265 | |||
1266 | pr_info("Xilinx SystemACE device driver, major=%i\n", ace_major); | ||
1267 | return 0; | ||
1268 | |||
1269 | err_plat: | ||
1270 | ace_of_unregister(); | ||
1271 | err_of: | ||
1272 | unregister_blkdev(ace_major, "xsysace"); | ||
1273 | err_blk: | ||
1274 | printk(KERN_ERR "xsysace: registration failed; err=%i\n", rc); | ||
1275 | return rc; | ||
1145 | } | 1276 | } |
1146 | 1277 | ||
1147 | static void __exit ace_exit(void) | 1278 | static void __exit ace_exit(void) |
1148 | { | 1279 | { |
1149 | pr_debug("Unregistering Xilinx SystemACE driver\n"); | 1280 | pr_debug("Unregistering Xilinx SystemACE driver\n"); |
1150 | driver_unregister(&ace_driver); | 1281 | platform_driver_unregister(&ace_platform_driver); |
1282 | ace_of_unregister(); | ||
1151 | unregister_blkdev(ace_major, "xsysace"); | 1283 | unregister_blkdev(ace_major, "xsysace"); |
1152 | } | 1284 | } |
1153 | 1285 | ||