Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.infradead.org/users/willy/linux-nvme

Pull NVMe update from Matthew Wilcox:
"Mostly bugfixes again for the NVMe driver. I'd like to call out the
exported tracepoint in the block layer; I believe Keith has cleared
this with Jens.

We've had a few reports from people who're really pounding on NVMe
devices at scale, hence the timeout changes (and new module
parameters), hotplug cpu deadlock, tracepoints, and minor performance
tweaks"

[ Jens hadn't seen that tracepoint thing, but is ok with it - it will
end up going away when mq conversion happens ]

* git://git.infradead.org/users/willy/linux-nvme: (22 commits)
NVMe: Fix START_STOP_UNIT Scsi->NVMe translation.
NVMe: Use Log Page constants in SCSI emulation
NVMe: Define Log Page constants
NVMe: Fix hot cpu notification dead lock
NVMe: Rename io_timeout to nvme_io_timeout
NVMe: Use last bytes of f/w rev SCSI Inquiry
NVMe: Adhere to request queue block accounting enable/disable
NVMe: Fix nvme get/put queue semantics
NVMe: Delete NVME_GET_FEAT_TEMP_THRESH
NVMe: Make admin timeout a module parameter
NVMe: Make iod bio timeout a parameter
NVMe: Prevent possible NULL pointer dereference
NVMe: Fix the buffer size passed in GetLogPage(CDW10.NUMD)
NVMe: Update data structures for NVMe 1.2
NVMe: Enable BUILD_BUG_ON checks
NVMe: Update namespace and controller identify structures to the 1.1a spec
NVMe: Flush with data support
NVMe: Configure support for block flush
NVMe: Add tracepoints
NVMe: Protect against badly formatted CQEs
...

+194 -110
+1
block/blk-core.c
··· 43 43 EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap); 44 44 EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap); 45 45 EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); 46 + EXPORT_TRACEPOINT_SYMBOL_GPL(block_split); 46 47 EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug); 47 48 48 49 DEFINE_IDA(blk_queue_ida);
+132 -71
drivers/block/nvme-core.c
··· 10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 12 * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program; if not, write to the Free Software Foundation, Inc., 16 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 13 */ 18 14 19 15 #include <linux/nvme.h> ··· 42 46 #include <scsi/sg.h> 43 47 #include <asm-generic/io-64-nonatomic-lo-hi.h> 44 48 45 - #define NVME_Q_DEPTH 1024 49 + #include <trace/events/block.h> 50 + 51 + #define NVME_Q_DEPTH 1024 46 52 #define SQ_SIZE(depth) (depth * sizeof(struct nvme_command)) 47 53 #define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion)) 48 - #define ADMIN_TIMEOUT (60 * HZ) 49 - #define IOD_TIMEOUT (4 * NVME_IO_TIMEOUT) 54 + #define ADMIN_TIMEOUT (admin_timeout * HZ) 55 + #define IOD_TIMEOUT (retry_time * HZ) 50 56 51 - unsigned char io_timeout = 30; 52 - module_param(io_timeout, byte, 0644); 57 + static unsigned char admin_timeout = 60; 58 + module_param(admin_timeout, byte, 0644); 59 + MODULE_PARM_DESC(admin_timeout, "timeout in seconds for admin commands"); 60 + 61 + unsigned char nvme_io_timeout = 30; 62 + module_param_named(io_timeout, nvme_io_timeout, byte, 0644); 53 63 MODULE_PARM_DESC(io_timeout, "timeout in seconds for I/O"); 64 + 65 + static unsigned char retry_time = 30; 66 + module_param(retry_time, byte, 0644); 67 + MODULE_PARM_DESC(retry_time, "time in seconds to retry failed I/O"); 54 68 55 69 static int nvme_major; 56 70 module_param(nvme_major, int, 0); ··· 73 67 static struct task_struct *nvme_thread; 74 68 static struct workqueue_struct *nvme_workq; 75 69 static wait_queue_head_t nvme_kthread_wait; 70 + static struct notifier_block nvme_nb; 76 71 77 72 static void nvme_reset_failed_dev(struct work_struct *ws); 78 73 ··· 206 199 #define CMD_CTX_CANCELLED (0x30C + CMD_CTX_BASE) 207 200 #define CMD_CTX_COMPLETED (0x310 + CMD_CTX_BASE) 208 201 #define CMD_CTX_INVALID (0x314 + CMD_CTX_BASE) 209 - #define CMD_CTX_FLUSH (0x318 + CMD_CTX_BASE) 210 - #define CMD_CTX_ABORT (0x31C + CMD_CTX_BASE) 202 + #define CMD_CTX_ABORT (0x318 + CMD_CTX_BASE) 211 203 212 204 static void special_completion(struct nvme_queue *nvmeq, void *ctx, 213 205 struct nvme_completion *cqe) 214 206 { 215 207 if (ctx == CMD_CTX_CANCELLED) 216 - return; 217 - if (ctx == CMD_CTX_FLUSH) 218 208 return; 219 209 if (ctx == CMD_CTX_ABORT) { 220 210 ++nvmeq->dev->abort_limit; ··· 251 247 void *ctx; 252 248 struct nvme_cmd_info *info = nvme_cmd_info(nvmeq); 253 249 254 - if (cmdid >= nvmeq->q_depth) { 255 - *fn = special_completion; 250 + if (cmdid >= nvmeq->q_depth || !info[cmdid].fn) { 251 + if (fn) 252 + *fn = special_completion; 256 253 return CMD_CTX_INVALID; 257 254 } 258 255 if (fn) ··· 286 281 287 282 static struct nvme_queue *get_nvmeq(struct nvme_dev *dev) __acquires(RCU) 288 283 { 284 + struct nvme_queue *nvmeq; 289 285 unsigned queue_id = get_cpu_var(*dev->io_queue); 286 + 290 287 rcu_read_lock(); 291 - return rcu_dereference(dev->queues[queue_id]); 288 + nvmeq = rcu_dereference(dev->queues[queue_id]); 289 + if (nvmeq) 290 + return nvmeq; 291 + 292 + rcu_read_unlock(); 293 + put_cpu_var(*dev->io_queue); 294 + return NULL; 292 295 } 293 296 294 297 static void put_nvmeq(struct nvme_queue *nvmeq) __releases(RCU) ··· 308 295 static struct nvme_queue *lock_nvmeq(struct nvme_dev *dev, int q_idx) 309 296 __acquires(RCU) 310 297 { 298 + struct nvme_queue *nvmeq; 299 + 311 300 rcu_read_lock(); 312 - return rcu_dereference(dev->queues[q_idx]); 301 + nvmeq = rcu_dereference(dev->queues[q_idx]); 302 + if (nvmeq) 303 + return nvmeq; 304 + 305 + rcu_read_unlock(); 306 + return NULL; 313 307 } 314 308 315 309 static void unlock_nvmeq(struct nvme_queue *nvmeq) __releases(RCU) ··· 407 387 static void nvme_start_io_acct(struct bio *bio) 408 388 { 409 389 struct gendisk *disk = bio->bi_bdev->bd_disk; 410 - const int rw = bio_data_dir(bio); 411 - int cpu = part_stat_lock(); 412 - part_round_stats(cpu, &disk->part0); 413 - part_stat_inc(cpu, &disk->part0, ios[rw]); 414 - part_stat_add(cpu, &disk->part0, sectors[rw], bio_sectors(bio)); 415 - part_inc_in_flight(&disk->part0, rw); 416 - part_stat_unlock(); 390 + if (blk_queue_io_stat(disk->queue)) { 391 + const int rw = bio_data_dir(bio); 392 + int cpu = part_stat_lock(); 393 + part_round_stats(cpu, &disk->part0); 394 + part_stat_inc(cpu, &disk->part0, ios[rw]); 395 + part_stat_add(cpu, &disk->part0, sectors[rw], 396 + bio_sectors(bio)); 397 + part_inc_in_flight(&disk->part0, rw); 398 + part_stat_unlock(); 399 + } 417 400 } 418 401 419 402 static void nvme_end_io_acct(struct bio *bio, unsigned long start_time) 420 403 { 421 404 struct gendisk *disk = bio->bi_bdev->bd_disk; 422 - const int rw = bio_data_dir(bio); 423 - unsigned long duration = jiffies - start_time; 424 - int cpu = part_stat_lock(); 425 - part_stat_add(cpu, &disk->part0, ticks[rw], duration); 426 - part_round_stats(cpu, &disk->part0); 427 - part_dec_in_flight(&disk->part0, rw); 428 - part_stat_unlock(); 405 + if (blk_queue_io_stat(disk->queue)) { 406 + const int rw = bio_data_dir(bio); 407 + unsigned long duration = jiffies - start_time; 408 + int cpu = part_stat_lock(); 409 + part_stat_add(cpu, &disk->part0, ticks[rw], duration); 410 + part_round_stats(cpu, &disk->part0); 411 + part_dec_in_flight(&disk->part0, rw); 412 + part_stat_unlock(); 413 + } 429 414 } 430 415 431 416 static void bio_completion(struct nvme_queue *nvmeq, void *ctx, ··· 439 414 struct nvme_iod *iod = ctx; 440 415 struct bio *bio = iod->private; 441 416 u16 status = le16_to_cpup(&cqe->status) >> 1; 417 + int error = 0; 442 418 443 419 if (unlikely(status)) { 444 420 if (!(status & NVME_SC_DNR || ··· 452 426 wake_up(&nvmeq->sq_full); 453 427 return; 454 428 } 429 + error = -EIO; 455 430 } 456 431 if (iod->nents) { 457 432 dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents, ··· 460 433 nvme_end_io_acct(bio, iod->start_time); 461 434 } 462 435 nvme_free_iod(nvmeq->dev, iod); 463 - if (status) 464 - bio_endio(bio, -EIO); 465 - else 466 - bio_endio(bio, 0); 436 + 437 + trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), bio, error); 438 + bio_endio(bio, error); 467 439 } 468 440 469 441 /* length is in bytes. gfp flags indicates whether we may sleep. */ ··· 551 525 if (!split) 552 526 return -ENOMEM; 553 527 528 + trace_block_split(bdev_get_queue(bio->bi_bdev), bio, 529 + split->bi_iter.bi_sector); 554 530 bio_chain(split, bio); 555 531 556 532 if (!waitqueue_active(&nvmeq->sq_full)) ··· 655 627 return 0; 656 628 } 657 629 658 - int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns) 659 - { 660 - int cmdid = alloc_cmdid(nvmeq, (void *)CMD_CTX_FLUSH, 661 - special_completion, NVME_IO_TIMEOUT); 662 - if (unlikely(cmdid < 0)) 663 - return cmdid; 664 - 665 - return nvme_submit_flush(nvmeq, ns, cmdid); 666 - } 667 - 668 630 static int nvme_submit_iod(struct nvme_queue *nvmeq, struct nvme_iod *iod) 669 631 { 670 632 struct bio *bio = iod->private; ··· 670 652 671 653 if (bio->bi_rw & REQ_DISCARD) 672 654 return nvme_submit_discard(nvmeq, ns, bio, iod, cmdid); 673 - if ((bio->bi_rw & REQ_FLUSH) && !iod->nents) 655 + if (bio->bi_rw & REQ_FLUSH) 674 656 return nvme_submit_flush(nvmeq, ns, cmdid); 675 657 676 658 control = 0; ··· 704 686 return 0; 705 687 } 706 688 689 + static int nvme_split_flush_data(struct nvme_queue *nvmeq, struct bio *bio) 690 + { 691 + struct bio *split = bio_clone(bio, GFP_ATOMIC); 692 + if (!split) 693 + return -ENOMEM; 694 + 695 + split->bi_iter.bi_size = 0; 696 + split->bi_phys_segments = 0; 697 + bio->bi_rw &= ~REQ_FLUSH; 698 + bio_chain(split, bio); 699 + 700 + if (!waitqueue_active(&nvmeq->sq_full)) 701 + add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait); 702 + bio_list_add(&nvmeq->sq_cong, split); 703 + bio_list_add(&nvmeq->sq_cong, bio); 704 + wake_up_process(nvme_thread); 705 + 706 + return 0; 707 + } 708 + 707 709 /* 708 710 * Called with local interrupts disabled and the q_lock held. May not sleep. 709 711 */ ··· 734 696 int psegs = bio_phys_segments(ns->queue, bio); 735 697 int result; 736 698 737 - if ((bio->bi_rw & REQ_FLUSH) && psegs) { 738 - result = nvme_submit_flush_data(nvmeq, ns); 739 - if (result) 740 - return result; 741 - } 699 + if ((bio->bi_rw & REQ_FLUSH) && psegs) 700 + return nvme_split_flush_data(nvmeq, bio); 742 701 743 702 iod = nvme_alloc_iod(psegs, bio->bi_iter.bi_size, GFP_ATOMIC); 744 703 if (!iod) ··· 830 795 int result = -EBUSY; 831 796 832 797 if (!nvmeq) { 833 - put_nvmeq(NULL); 834 798 bio_endio(bio, -EIO); 835 799 return; 836 800 } ··· 904 870 struct nvme_queue *nvmeq; 905 871 906 872 nvmeq = lock_nvmeq(dev, q_idx); 907 - if (!nvmeq) { 908 - unlock_nvmeq(nvmeq); 873 + if (!nvmeq) 909 874 return -ENODEV; 910 - } 911 875 912 876 cmdinfo.task = current; 913 877 cmdinfo.status = -EINTR; ··· 930 898 931 899 if (cmdinfo.status == -EINTR) { 932 900 nvmeq = lock_nvmeq(dev, q_idx); 933 - if (nvmeq) 901 + if (nvmeq) { 934 902 nvme_abort_command(nvmeq, cmdid); 935 - unlock_nvmeq(nvmeq); 903 + unlock_nvmeq(nvmeq); 904 + } 936 905 return -EINTR; 937 906 } 938 907 ··· 1391 1358 return -EINTR; 1392 1359 if (time_after(jiffies, timeout)) { 1393 1360 dev_err(&dev->pci_dev->dev, 1394 - "Device not ready; aborting initialisation\n"); 1361 + "Device not ready; aborting %s\n", enabled ? 1362 + "initialisation" : "reset"); 1395 1363 return -ENODEV; 1396 1364 } 1397 1365 } ··· 1515 1481 goto put_pages; 1516 1482 } 1517 1483 1484 + err = -ENOMEM; 1518 1485 iod = nvme_alloc_iod(count, length, GFP_KERNEL); 1486 + if (!iod) 1487 + goto put_pages; 1488 + 1519 1489 sg = iod->sg; 1520 1490 sg_init_table(sg, count); 1521 1491 for (i = 0; i < count; i++) { ··· 1532 1494 sg_mark_end(&sg[i - 1]); 1533 1495 iod->nents = count; 1534 1496 1535 - err = -ENOMEM; 1536 1497 nents = dma_map_sg(&dev->pci_dev->dev, sg, count, 1537 1498 write ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 1538 1499 if (!nents) ··· 1931 1894 blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); 1932 1895 if (dev->max_hw_sectors) 1933 1896 blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors); 1897 + if (dev->vwc & NVME_CTRL_VWC_PRESENT) 1898 + blk_queue_flush(ns->queue, REQ_FLUSH | REQ_FUA); 1934 1899 1935 1900 disk->major = nvme_major; 1936 1901 disk->first_minor = 0; ··· 2101 2062 2102 2063 status = nvme_set_features(dev, NVME_FEAT_NUM_QUEUES, q_count, 0, 2103 2064 &result); 2104 - if (status) 2105 - return status < 0 ? -EIO : -EBUSY; 2065 + if (status < 0) 2066 + return status; 2067 + if (status > 0) { 2068 + dev_err(&dev->pci_dev->dev, "Could not set queue count (%d)\n", 2069 + status); 2070 + return -EBUSY; 2071 + } 2106 2072 return min(result & 0xffff, result >> 16) + 1; 2107 2073 } 2108 2074 ··· 2116 2072 return 4096 + ((nr_io_queues + 1) * 8 * dev->db_stride); 2117 2073 } 2118 2074 2075 + static void nvme_cpu_workfn(struct work_struct *work) 2076 + { 2077 + struct nvme_dev *dev = container_of(work, struct nvme_dev, cpu_work); 2078 + if (dev->initialized) 2079 + nvme_assign_io_queues(dev); 2080 + } 2081 + 2119 2082 static int nvme_cpu_notify(struct notifier_block *self, 2120 2083 unsigned long action, void *hcpu) 2121 2084 { 2122 - struct nvme_dev *dev = container_of(self, struct nvme_dev, nb); 2085 + struct nvme_dev *dev; 2086 + 2123 2087 switch (action) { 2124 2088 case CPU_ONLINE: 2125 2089 case CPU_DEAD: 2126 - nvme_assign_io_queues(dev); 2090 + spin_lock(&dev_list_lock); 2091 + list_for_each_entry(dev, &dev_list, node) 2092 + schedule_work(&dev->cpu_work); 2093 + spin_unlock(&dev_list_lock); 2127 2094 break; 2128 2095 } 2129 2096 return NOTIFY_OK; ··· 2203 2148 nvme_free_queues(dev, nr_io_queues + 1); 2204 2149 nvme_assign_io_queues(dev); 2205 2150 2206 - dev->nb.notifier_call = &nvme_cpu_notify; 2207 - result = register_hotcpu_notifier(&dev->nb); 2208 - if (result) 2209 - goto free_queues; 2210 - 2211 2151 return 0; 2212 2152 2213 2153 free_queues: ··· 2234 2184 2235 2185 res = nvme_identify(dev, 0, 1, dma_addr); 2236 2186 if (res) { 2187 + dev_err(&pdev->dev, "Identify Controller failed (%d)\n", res); 2237 2188 res = -EIO; 2238 2189 goto out; 2239 2190 } ··· 2243 2192 nn = le32_to_cpup(&ctrl->nn); 2244 2193 dev->oncs = le16_to_cpup(&ctrl->oncs); 2245 2194 dev->abort_limit = ctrl->acl + 1; 2195 + dev->vwc = ctrl->vwc; 2246 2196 memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn)); 2247 2197 memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn)); 2248 2198 memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr)); ··· 2502 2450 int i; 2503 2451 2504 2452 dev->initialized = 0; 2505 - unregister_hotcpu_notifier(&dev->nb); 2506 - 2507 2453 nvme_dev_list_remove(dev); 2508 2454 2509 2455 if (!dev->bar || (dev->bar && readl(&dev->bar->csts) == -1)) { ··· 2772 2722 INIT_LIST_HEAD(&dev->namespaces); 2773 2723 dev->reset_workfn = nvme_reset_failed_dev; 2774 2724 INIT_WORK(&dev->reset_work, nvme_reset_workfn); 2725 + INIT_WORK(&dev->cpu_work, nvme_cpu_workfn); 2775 2726 dev->pci_dev = pdev; 2776 2727 pci_set_drvdata(pdev, dev); 2777 2728 result = nvme_set_instance(dev); ··· 2852 2801 2853 2802 pci_set_drvdata(pdev, NULL); 2854 2803 flush_work(&dev->reset_work); 2804 + flush_work(&dev->cpu_work); 2855 2805 misc_deregister(&dev->miscdev); 2856 2806 nvme_dev_remove(dev); 2857 2807 nvme_dev_shutdown(dev); ··· 2941 2889 else if (result > 0) 2942 2890 nvme_major = result; 2943 2891 2944 - result = pci_register_driver(&nvme_driver); 2892 + nvme_nb.notifier_call = &nvme_cpu_notify; 2893 + result = register_hotcpu_notifier(&nvme_nb); 2945 2894 if (result) 2946 2895 goto unregister_blkdev; 2896 + 2897 + result = pci_register_driver(&nvme_driver); 2898 + if (result) 2899 + goto unregister_hotcpu; 2947 2900 return 0; 2948 2901 2902 + unregister_hotcpu: 2903 + unregister_hotcpu_notifier(&nvme_nb); 2949 2904 unregister_blkdev: 2950 2905 unregister_blkdev(nvme_major, "nvme"); 2951 2906 kill_workq: ··· 2963 2904 static void __exit nvme_exit(void) 2964 2905 { 2965 2906 pci_unregister_driver(&nvme_driver); 2907 + unregister_hotcpu_notifier(&nvme_nb); 2966 2908 unregister_blkdev(nvme_major, "nvme"); 2967 2909 destroy_workqueue(nvme_workq); 2968 2910 BUG_ON(nvme_thread && !IS_ERR(nvme_thread)); 2911 + _nvme_check_size(); 2969 2912 } 2970 2913 2971 2914 MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");
+17 -19
drivers/block/nvme-scsi.c
··· 1 1 /* 2 2 * NVM Express device driver 3 - * Copyright (c) 2011, Intel Corporation. 3 + * Copyright (c) 2011-2014, Intel Corporation. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms and conditions of the GNU General Public License, ··· 10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 12 * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program; if not, write to the Free Software Foundation, Inc., 16 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 13 */ 18 14 19 15 /* ··· 239 243 #define READ_CAP_16_RESP_SIZE 32 240 244 241 245 /* NVMe Namespace and Command Defines */ 242 - #define NVME_GET_SMART_LOG_PAGE 0x02 243 - #define NVME_GET_FEAT_TEMP_THRESH 0x04 244 246 #define BYTES_TO_DWORDS 4 245 247 #define NVME_MAX_FIRMWARE_SLOT 7 246 248 ··· 680 686 u8 resp_data_format = 0x02; 681 687 u8 protect; 682 688 u8 cmdque = 0x01 << 1; 689 + u8 fw_offset = sizeof(dev->firmware_rev); 683 690 684 691 mem = dma_alloc_coherent(&dev->pci_dev->dev, sizeof(struct nvme_id_ns), 685 692 &dma_addr, GFP_KERNEL); ··· 716 721 inq_response[7] = cmdque; /* wbus16=0 | sync=0 | vs=0 */ 717 722 strncpy(&inq_response[8], "NVMe ", 8); 718 723 strncpy(&inq_response[16], dev->model, 16); 719 - strncpy(&inq_response[32], dev->firmware_rev, 4); 724 + 725 + while (dev->firmware_rev[fw_offset - 1] == ' ' && fw_offset > 4) 726 + fw_offset--; 727 + fw_offset -= 4; 728 + strncpy(&inq_response[32], dev->firmware_rev + fw_offset, 4); 720 729 721 730 xfer_len = min(alloc_len, STANDARD_INQUIRY_LENGTH); 722 731 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); ··· 1017 1018 c.common.opcode = nvme_admin_get_log_page; 1018 1019 c.common.nsid = cpu_to_le32(0xFFFFFFFF); 1019 1020 c.common.prp1 = cpu_to_le64(dma_addr); 1020 - c.common.cdw10[0] = cpu_to_le32(((sizeof(struct nvme_smart_log) / 1021 - BYTES_TO_DWORDS) << 16) | NVME_GET_SMART_LOG_PAGE); 1021 + c.common.cdw10[0] = cpu_to_le32((((sizeof(struct nvme_smart_log) / 1022 + BYTES_TO_DWORDS) - 1) << 16) | NVME_LOG_SMART); 1022 1023 res = nvme_submit_admin_cmd(dev, &c, NULL); 1023 1024 if (res != NVME_SC_SUCCESS) { 1024 1025 temp_c = LOG_TEMP_UNKNOWN; ··· 1085 1086 c.common.opcode = nvme_admin_get_log_page; 1086 1087 c.common.nsid = cpu_to_le32(0xFFFFFFFF); 1087 1088 c.common.prp1 = cpu_to_le64(dma_addr); 1088 - c.common.cdw10[0] = cpu_to_le32(((sizeof(struct nvme_smart_log) / 1089 - BYTES_TO_DWORDS) << 16) | NVME_GET_SMART_LOG_PAGE); 1089 + c.common.cdw10[0] = cpu_to_le32((((sizeof(struct nvme_smart_log) / 1090 + BYTES_TO_DWORDS) - 1) << 16) | NVME_LOG_SMART); 1090 1091 res = nvme_submit_admin_cmd(dev, &c, NULL); 1091 1092 if (res != NVME_SC_SUCCESS) { 1092 1093 temp_c_cur = LOG_TEMP_UNKNOWN; ··· 1476 1477 goto out_dma; 1477 1478 } 1478 1479 id_ctrl = mem; 1479 - lowest_pow_st = id_ctrl->npss - 1; 1480 + lowest_pow_st = max(POWER_STATE_0, (int)(id_ctrl->npss - 1)); 1480 1481 1481 1482 switch (pc) { 1482 1483 case NVME_POWER_STATE_START_VALID: ··· 1493 1494 break; 1494 1495 case NVME_POWER_STATE_IDLE: 1495 1496 /* Action unspecified if POWER CONDITION MODIFIER != [0,1,2] */ 1496 - /* min of desired state and (lps-1) because lps is STOP */ 1497 1497 if (pcmod == 0x0) 1498 - ps_desired = min(POWER_STATE_1, (lowest_pow_st - 1)); 1498 + ps_desired = POWER_STATE_1; 1499 1499 else if (pcmod == 0x1) 1500 - ps_desired = min(POWER_STATE_2, (lowest_pow_st - 1)); 1500 + ps_desired = POWER_STATE_2; 1501 1501 else if (pcmod == 0x2) 1502 - ps_desired = min(POWER_STATE_3, (lowest_pow_st - 1)); 1502 + ps_desired = POWER_STATE_3; 1503 1503 break; 1504 1504 case NVME_POWER_STATE_STANDBY: 1505 1505 /* Action unspecified if POWER CONDITION MODIFIER != [0,1] */ 1506 1506 if (pcmod == 0x0) 1507 - ps_desired = max(0, (lowest_pow_st - 2)); 1507 + ps_desired = max(POWER_STATE_0, (lowest_pow_st - 2)); 1508 1508 else if (pcmod == 0x1) 1509 - ps_desired = max(0, (lowest_pow_st - 1)); 1509 + ps_desired = max(POWER_STATE_0, (lowest_pow_st - 1)); 1510 1510 break; 1511 1511 case NVME_POWER_STATE_LU_CONTROL: 1512 1512 default:
+5 -9
include/linux/nvme.h
··· 1 1 /* 2 2 * Definitions for the NVM Express interface 3 - * Copyright (c) 2011-2013, Intel Corporation. 3 + * Copyright (c) 2011-2014, Intel Corporation. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms and conditions of the GNU General Public License, ··· 10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 12 * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program; if not, write to the Free Software Foundation, Inc., 16 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 13 */ 18 14 19 15 #ifndef _LINUX_NVME_H ··· 62 66 63 67 #define NVME_VS(major, minor) (major << 16 | minor) 64 68 65 - extern unsigned char io_timeout; 66 - #define NVME_IO_TIMEOUT (io_timeout * HZ) 69 + extern unsigned char nvme_io_timeout; 70 + #define NVME_IO_TIMEOUT (nvme_io_timeout * HZ) 67 71 68 72 /* 69 73 * Represents an NVM Express device. Each nvme_dev is a PCI function. ··· 90 94 struct miscdevice miscdev; 91 95 work_func_t reset_workfn; 92 96 struct work_struct reset_work; 93 - struct notifier_block nb; 97 + struct work_struct cpu_work; 94 98 char name[12]; 95 99 char serial[20]; 96 100 char model[40]; ··· 99 103 u32 stripe_size; 100 104 u16 oncs; 101 105 u16 abort_limit; 106 + u8 vwc; 102 107 u8 initialized; 103 108 }; 104 109 ··· 156 159 void nvme_unmap_user_pages(struct nvme_dev *dev, int write, 157 160 struct nvme_iod *iod); 158 161 int nvme_submit_io_cmd(struct nvme_dev *, struct nvme_command *, u32 *); 159 - int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns); 160 162 int nvme_submit_admin_cmd(struct nvme_dev *, struct nvme_command *, 161 163 u32 *result); 162 164 int nvme_identify(struct nvme_dev *, unsigned nsid, unsigned cns,
+39 -11
include/uapi/linux/nvme.h
··· 1 1 /* 2 2 * Definitions for the NVM Express interface 3 - * Copyright (c) 2011-2013, Intel Corporation. 3 + * Copyright (c) 2011-2014, Intel Corporation. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms and conditions of the GNU General Public License, ··· 10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 12 * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program; if not, write to the Free Software Foundation, Inc., 16 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 13 */ 18 14 19 15 #ifndef _UAPI_LINUX_NVME_H ··· 27 31 __u8 read_lat; 28 32 __u8 write_tput; 29 33 __u8 write_lat; 30 - __u8 rsvd16[16]; 34 + __le16 idle_power; 35 + __u8 idle_scale; 36 + __u8 rsvd19; 37 + __le16 active_power; 38 + __u8 active_work_scale; 39 + __u8 rsvd23[9]; 31 40 }; 32 41 33 42 enum { ··· 50 49 __u8 ieee[3]; 51 50 __u8 mic; 52 51 __u8 mdts; 53 - __u8 rsvd78[178]; 52 + __u16 cntlid; 53 + __u32 ver; 54 + __u8 rsvd84[172]; 54 55 __le16 oacs; 55 56 __u8 acl; 56 57 __u8 aerl; ··· 60 57 __u8 lpa; 61 58 __u8 elpe; 62 59 __u8 npss; 63 - __u8 rsvd264[248]; 60 + __u8 avscc; 61 + __u8 apsta; 62 + __le16 wctemp; 63 + __le16 cctemp; 64 + __u8 rsvd270[242]; 64 65 __u8 sqes; 65 66 __u8 cqes; 66 67 __u8 rsvd514[2]; ··· 75 68 __u8 vwc; 76 69 __le16 awun; 77 70 __le16 awupf; 78 - __u8 rsvd530[1518]; 71 + __u8 nvscc; 72 + __u8 rsvd531; 73 + __le16 acwu; 74 + __u8 rsvd534[2]; 75 + __le32 sgls; 76 + __u8 rsvd540[1508]; 79 77 struct nvme_id_power_state psd[32]; 80 78 __u8 vs[1024]; 81 79 }; ··· 89 77 NVME_CTRL_ONCS_COMPARE = 1 << 0, 90 78 NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1, 91 79 NVME_CTRL_ONCS_DSM = 1 << 2, 80 + NVME_CTRL_VWC_PRESENT = 1 << 0, 92 81 }; 93 82 94 83 struct nvme_lbaf { ··· 108 95 __u8 mc; 109 96 __u8 dpc; 110 97 __u8 dps; 111 - __u8 rsvd30[98]; 98 + __u8 nmic; 99 + __u8 rescap; 100 + __u8 fpi; 101 + __u8 rsvd33; 102 + __le16 nawun; 103 + __le16 nawupf; 104 + __le16 nacwu; 105 + __u8 rsvd40[80]; 106 + __u8 eui64[8]; 112 107 struct nvme_lbaf lbaf[16]; 113 108 __u8 rsvd192[192]; 114 109 __u8 vs[3712]; ··· 147 126 __u8 unsafe_shutdowns[16]; 148 127 __u8 media_errors[16]; 149 128 __u8 num_err_log_entries[16]; 150 - __u8 rsvd192[320]; 129 + __le32 warning_temp_time; 130 + __le32 critical_comp_time; 131 + __le16 temp_sensor[8]; 132 + __u8 rsvd216[296]; 151 133 }; 152 134 153 135 enum { ··· 306 282 NVME_FEAT_WRITE_ATOMIC = 0x0a, 307 283 NVME_FEAT_ASYNC_EVENT = 0x0b, 308 284 NVME_FEAT_SW_PROGRESS = 0x0c, 285 + NVME_LOG_ERROR = 0x01, 286 + NVME_LOG_SMART = 0x02, 287 + NVME_LOG_FW_SLOT = 0x03, 288 + NVME_LOG_RESERVATION = 0x80, 309 289 NVME_FWACT_REPL = (0 << 3), 310 290 NVME_FWACT_REPL_ACTV = (1 << 3), 311 291 NVME_FWACT_ACTV = (2 << 3),