drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / block / blk-core.c
index 45f3a51f6b56f3ddd50cc0016b4b3662f9e85783..25cc9f9fa16464a7f94ae24453d040fca73f0fdd 100644 (file)
@@ -45,6 +45,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);
 
 DEFINE_IDA(blk_queue_ida);
 
+int trap_non_toi_io;
+EXPORT_SYMBOL_GPL(trap_non_toi_io);
+
 /*
  * For the allocated request tables
  */
@@ -645,10 +648,12 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
        __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags);
 
        if (blkcg_init_queue(q))
-               goto fail_id;
+               goto fail_bdi;
 
        return q;
 
+fail_bdi:
+       bdi_destroy(&q->backing_dev_info);
 fail_id:
        ida_simple_remove(&blk_queue_ida, q->id);
 fail_q:
@@ -739,9 +744,17 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn,
 
        q->sg_reserved_size = INT_MAX;
 
+       /* Protect q->elevator from elevator_change */
+       mutex_lock(&q->sysfs_lock);
+
        /* init elevator */
-       if (elevator_init(q, NULL))
+       if (elevator_init(q, NULL)) {
+               mutex_unlock(&q->sysfs_lock);
                return NULL;
+       }
+
+       mutex_unlock(&q->sysfs_lock);
+
        return q;
 }
 EXPORT_SYMBOL(blk_init_allocated_queue);
@@ -1850,6 +1863,9 @@ void submit_bio(int rw, struct bio *bio)
 {
        bio->bi_rw |= rw;
 
+       if (unlikely(trap_non_toi_io))
+               BUG_ON(!(bio->bi_flags & BIO_TOI));
+
        /*
         * If it's a regular read/write or a barrier with data attached,
         * go through the normal accounting stuff before submission.
@@ -1866,6 +1882,43 @@ void submit_bio(int rw, struct bio *bio)
                        count_vm_events(PGPGOUT, count);
                } else {
                        task_io_account_read(bio->bi_size);
+#if defined(FEATURE_STORAGE_PID_LOGGER)              
+                        {
+                           int i;
+                           struct bio_vec *bvec;
+
+                           //printk(KERN_INFO"submit_bio size:%d", bio->bi_size);
+                          bio_for_each_segment(bvec, bio, i)
+                           {
+                             struct page_pid_logger *tmp_logger;
+                             extern unsigned char *page_logger;
+                             extern spinlock_t g_locker;
+                             unsigned long flags;
+                             //printk(KERN_INFO"submit_bio bvec:%p size:%d", bvec, bio->bi_size);
+                             if( page_logger && bvec->bv_page) {
+                                unsigned long page_index;
+                        //#if defined(CONFIG_FLATMEM)
+                                //page_index = (unsigned long)((bvec->bv_page) - mem_map) ;
+                                //#else
+                                page_index = (unsigned long)(__page_to_pfn(bvec->bv_page))- PHYS_PFN_OFFSET;
+                                //#endif
+                                //printk(KERN_INFO"hank:submit_bio page_index:%lu", page_index);
+                                tmp_logger =((struct page_pid_logger *)page_logger) + page_index;
+                                spin_lock_irqsave(&g_locker, flags);
+                                if( page_index < num_physpages) {
+                                   if( tmp_logger->pid1 == 0XFFFF && tmp_logger->pid2 != current->pid)
+                                       tmp_logger->pid1 = current->pid;
+                                   else if( tmp_logger->pid1 != current->pid )
+                                       tmp_logger->pid2 = current->pid;
+                                }
+                                spin_unlock_irqrestore(&g_locker, flags);
+                                //printk(KERN_INFO"hank tmp logger pid1:%u pid2:%u pfn:%d \n", tmp_logger->pid1, tmp_logger->pid2, (unsigned long)((page) - mem_map) );
+                             }
+
+
+                           }
+                        }
+#endif
                        count_vm_events(PGPGIN, count);
                }
 
@@ -2289,7 +2342,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
        if (!req->bio)
                return false;
 
-       trace_block_rq_complete(req->q, req);
+       trace_block_rq_complete(req->q, req, nr_bytes);
 
        /*
         * For fs requests, rq is just carrier of independent bio's
@@ -3087,6 +3140,9 @@ int blk_pre_runtime_suspend(struct request_queue *q)
 {
        int ret = 0;
 
+       if (!q->dev)
+               return ret;
+
        spin_lock_irq(q->queue_lock);
        if (q->nr_pending) {
                ret = -EBUSY;
@@ -3114,6 +3170,9 @@ EXPORT_SYMBOL(blk_pre_runtime_suspend);
  */
 void blk_post_runtime_suspend(struct request_queue *q, int err)
 {
+       if (!q->dev)
+               return;
+
        spin_lock_irq(q->queue_lock);
        if (!err) {
                q->rpm_status = RPM_SUSPENDED;
@@ -3138,6 +3197,9 @@ EXPORT_SYMBOL(blk_post_runtime_suspend);
  */
 void blk_pre_runtime_resume(struct request_queue *q)
 {
+       if (!q->dev)
+               return;
+
        spin_lock_irq(q->queue_lock);
        q->rpm_status = RPM_RESUMING;
        spin_unlock_irq(q->queue_lock);
@@ -3160,6 +3222,9 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
  */
 void blk_post_runtime_resume(struct request_queue *q, int err)
 {
+       if (!q->dev)
+               return;
+
        spin_lock_irq(q->queue_lock);
        if (!err) {
                q->rpm_status = RPM_ACTIVE;