aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card/queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/card/queue.c')
-rw-r--r--drivers/mmc/card/queue.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 3dee97e7d16..5c8f037dca6 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -142,12 +142,19 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
142 bouncesz = host->max_req_size; 142 bouncesz = host->max_req_size;
143 if (bouncesz > host->max_seg_size) 143 if (bouncesz > host->max_seg_size)
144 bouncesz = host->max_seg_size; 144 bouncesz = host->max_seg_size;
145 if (bouncesz > (host->max_blk_count * 512))
146 bouncesz = host->max_blk_count * 512;
147
148 if (bouncesz > 512) {
149 mq->bounce_buf = kmalloc(bouncesz, GFP_KERNEL);
150 if (!mq->bounce_buf) {
151 printk(KERN_WARNING "%s: unable to "
152 "allocate bounce buffer\n",
153 mmc_card_name(card));
154 }
155 }
145 156
146 mq->bounce_buf = kmalloc(bouncesz, GFP_KERNEL); 157 if (mq->bounce_buf) {
147 if (!mq->bounce_buf) {
148 printk(KERN_WARNING "%s: unable to allocate "
149 "bounce buffer\n", mmc_card_name(card));
150 } else {
151 blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY); 158 blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY);
152 blk_queue_max_sectors(mq->queue, bouncesz / 512); 159 blk_queue_max_sectors(mq->queue, bouncesz / 512);
153 blk_queue_max_phys_segments(mq->queue, bouncesz / 512); 160 blk_queue_max_phys_segments(mq->queue, bouncesz / 512);
@@ -175,7 +182,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
175 182
176 if (!mq->bounce_buf) { 183 if (!mq->bounce_buf) {
177 blk_queue_bounce_limit(mq->queue, limit); 184 blk_queue_bounce_limit(mq->queue, limit);
178 blk_queue_max_sectors(mq->queue, host->max_req_size / 512); 185 blk_queue_max_sectors(mq->queue,
186 min(host->max_blk_count, host->max_req_size / 512));
179 blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); 187 blk_queue_max_phys_segments(mq->queue, host->max_phys_segs);
180 blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); 188 blk_queue_max_hw_segments(mq->queue, host->max_hw_segs);
181 blk_queue_max_segment_size(mq->queue, host->max_seg_size); 189 blk_queue_max_segment_size(mq->queue, host->max_seg_size);