[PATCH] ps3: disable display flipping during mode changes
[powerpc.git] / drivers / mmc / mmc_queue.c
index 4e6a534..c27e426 100644 (file)
@@ -78,8 +78,10 @@ static int mmc_queue_thread(void *d)
                spin_unlock_irq(q->queue_lock);
 
                if (!req) {
-                       if (kthread_should_stop())
+                       if (kthread_should_stop()) {
+                               set_current_state(TASK_RUNNING);
                                break;
+                       }
                        up(&mq->thread_sem);
                        schedule();
                        down(&mq->thread_sem);
@@ -103,6 +105,19 @@ static int mmc_queue_thread(void *d)
 static void mmc_request(request_queue_t *q)
 {
        struct mmc_queue *mq = q->queuedata;
+       struct request *req;
+       int ret;
+
+       if (!mq) {
+               printk(KERN_ERR "MMC: killing requests for dead queue\n");
+               while ((req = elv_next_request(q)) != NULL) {
+                       do {
+                               ret = end_that_request_chunk(req, 0,
+                                       req->current_nr_sectors << 9);
+                       } while (ret);
+               }
+               return;
+       }
 
        if (!mq->req)
                wake_up_process(mq->thread);
@@ -122,8 +137,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
        u64 limit = BLK_BOUNCE_HIGH;
        int ret;
 
-       if (host->dev->dma_mask && *host->dev->dma_mask)
-               limit = *host->dev->dma_mask;
+       if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
+               limit = *mmc_dev(host)->dma_mask;
 
        mq->card = card;
        mq->queue = blk_init_queue(mmc_request, lock);
@@ -132,7 +147,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
 
        blk_queue_prep_rq(mq->queue, mmc_prep_request);
        blk_queue_bounce_limit(mq->queue, limit);
-       blk_queue_max_sectors(mq->queue, host->max_sectors);
+       blk_queue_max_sectors(mq->queue, host->max_req_size / 512);
        blk_queue_max_phys_segments(mq->queue, host->max_phys_segs);
        blk_queue_max_hw_segments(mq->queue, host->max_hw_segs);
        blk_queue_max_segment_size(mq->queue, host->max_seg_size);
@@ -168,6 +183,15 @@ EXPORT_SYMBOL(mmc_init_queue);
 
 void mmc_cleanup_queue(struct mmc_queue *mq)
 {
+       request_queue_t *q = mq->queue;
+       unsigned long flags;
+
+       /* Mark that we should start throwing out stragglers */
+       spin_lock_irqsave(q->queue_lock, flags);
+       q->queuedata = NULL;
+       spin_unlock_irqrestore(q->queue_lock, flags);
+
+       /* Then terminate our worker thread */
        kthread_stop(mq->thread);
 
        kfree(mq->sg);