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 driver update from Matthew Wilcox:
"These patches have mostly been baking for a few months; sorry I didn't
get them in during the merge window. They're all bug fixes, except
for the addition of the SMART log and the addition to MAINTAINERS."

* git://git.infradead.org/users/willy/linux-nvme:
NVMe: Add namespaces with no LBA range feature
MAINTAINERS: Add entry for the NVMe driver
NVMe: Initialize iod nents to 0
NVMe: Define SMART log
NVMe: Add result to nvme_get_features
NVMe: Set result from user admin command
NVMe: End queued bio requests when freeing queue
NVMe: Free cmdid on nvme_submit_bio error

+60 -9
+8
MAINTAINERS
··· 5641 5641 F: drivers/video/riva/ 5642 5642 F: drivers/video/nvidia/ 5643 5643 5644 + NVM EXPRESS DRIVER 5645 + M: Matthew Wilcox <willy@linux.intel.com> 5646 + L: linux-nvme@lists.infradead.org 5647 + T: git git://git.infradead.org/users/willy/linux-nvme.git 5648 + S: Supported 5649 + F: drivers/block/nvme.c 5650 + F: include/linux/nvme.h 5651 + 5644 5652 OMAP SUPPORT 5645 5653 M: Tony Lindgren <tony@atomide.com> 5646 5654 L: linux-omap@vger.kernel.org
+24 -9
drivers/block/nvme.c
··· 135 135 BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != 4096); 136 136 BUILD_BUG_ON(sizeof(struct nvme_id_ns) != 4096); 137 137 BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64); 138 + BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512); 138 139 } 139 140 140 141 typedef void (*nvme_completion_fn)(struct nvme_dev *, void *, ··· 238 237 *fn = special_completion; 239 238 return CMD_CTX_INVALID; 240 239 } 241 - *fn = info[cmdid].fn; 240 + if (fn) 241 + *fn = info[cmdid].fn; 242 242 ctx = info[cmdid].ctx; 243 243 info[cmdid].fn = special_completion; 244 244 info[cmdid].ctx = CMD_CTX_COMPLETED; ··· 337 335 iod->offset = offsetof(struct nvme_iod, sg[nseg]); 338 336 iod->npages = -1; 339 337 iod->length = nbytes; 338 + iod->nents = 0; 340 339 } 341 340 342 341 return iod; ··· 378 375 struct bio *bio = iod->private; 379 376 u16 status = le16_to_cpup(&cqe->status) >> 1; 380 377 381 - dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents, 378 + if (iod->nents) 379 + dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents, 382 380 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 383 381 nvme_free_iod(dev, iod); 384 382 if (status) { ··· 593 589 594 590 result = nvme_map_bio(nvmeq->q_dmadev, iod, bio, dma_dir, psegs); 595 591 if (result < 0) 596 - goto free_iod; 592 + goto free_cmdid; 597 593 length = result; 598 594 599 595 cmnd->rw.command_id = cmdid; ··· 613 609 614 610 return 0; 615 611 612 + free_cmdid: 613 + free_cmdid(nvmeq, cmdid, NULL); 616 614 free_iod: 617 615 nvme_free_iod(nvmeq->dev, iod); 618 616 nomem: ··· 841 835 return nvme_submit_admin_cmd(dev, &c, NULL); 842 836 } 843 837 844 - static int nvme_get_features(struct nvme_dev *dev, unsigned fid, 845 - unsigned nsid, dma_addr_t dma_addr) 838 + static int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid, 839 + dma_addr_t dma_addr, u32 *result) 846 840 { 847 841 struct nvme_command c; 848 842 ··· 852 846 c.features.prp1 = cpu_to_le64(dma_addr); 853 847 c.features.fid = cpu_to_le32(fid); 854 848 855 - return nvme_submit_admin_cmd(dev, &c, NULL); 849 + return nvme_submit_admin_cmd(dev, &c, result); 856 850 } 857 851 858 852 static int nvme_set_features(struct nvme_dev *dev, unsigned fid, ··· 912 906 913 907 spin_lock_irq(&nvmeq->q_lock); 914 908 nvme_cancel_ios(nvmeq, false); 909 + while (bio_list_peek(&nvmeq->sq_cong)) { 910 + struct bio *bio = bio_list_pop(&nvmeq->sq_cong); 911 + bio_endio(bio, -EIO); 912 + } 915 913 spin_unlock_irq(&nvmeq->q_lock); 916 914 917 915 irq_set_affinity_hint(vector, NULL); ··· 1240 1230 if (length != cmd.data_len) 1241 1231 status = -ENOMEM; 1242 1232 else 1243 - status = nvme_submit_admin_cmd(dev, &c, NULL); 1233 + status = nvme_submit_admin_cmd(dev, &c, &cmd.result); 1244 1234 1245 1235 if (cmd.data_len) { 1246 1236 nvme_unmap_user_pages(dev, cmd.opcode & 1, iod); 1247 1237 nvme_free_iod(dev, iod); 1248 1238 } 1239 + 1240 + if (!status && copy_to_user(&ucmd->result, &cmd.result, 1241 + sizeof(cmd.result))) 1242 + status = -EFAULT; 1243 + 1249 1244 return status; 1250 1245 } 1251 1246 ··· 1538 1523 continue; 1539 1524 1540 1525 res = nvme_get_features(dev, NVME_FEAT_LBA_RANGE, i, 1541 - dma_addr + 4096); 1526 + dma_addr + 4096, NULL); 1542 1527 if (res) 1543 - continue; 1528 + memset(mem + 4096, 0, 4096); 1544 1529 1545 1530 ns = nvme_alloc_ns(dev, i, mem, mem + 4096); 1546 1531 if (ns)
+28
include/linux/nvme.h
··· 137 137 NVME_LBAF_RP_DEGRADED = 3, 138 138 }; 139 139 140 + struct nvme_smart_log { 141 + __u8 critical_warning; 142 + __u8 temperature[2]; 143 + __u8 avail_spare; 144 + __u8 spare_thresh; 145 + __u8 percent_used; 146 + __u8 rsvd6[26]; 147 + __u8 data_units_read[16]; 148 + __u8 data_units_written[16]; 149 + __u8 host_reads[16]; 150 + __u8 host_writes[16]; 151 + __u8 ctrl_busy_time[16]; 152 + __u8 power_cycles[16]; 153 + __u8 power_on_hours[16]; 154 + __u8 unsafe_shutdowns[16]; 155 + __u8 media_errors[16]; 156 + __u8 num_err_log_entries[16]; 157 + __u8 rsvd192[320]; 158 + }; 159 + 160 + enum { 161 + NVME_SMART_CRIT_SPARE = 1 << 0, 162 + NVME_SMART_CRIT_TEMPERATURE = 1 << 1, 163 + NVME_SMART_CRIT_RELIABILITY = 1 << 2, 164 + NVME_SMART_CRIT_MEDIA = 1 << 3, 165 + NVME_SMART_CRIT_VOLATILE_MEMORY = 1 << 4, 166 + }; 167 + 140 168 struct nvme_lba_range_type { 141 169 __u8 type; 142 170 __u8 attributes;