zoukankan      html  css  js  c++  java
  • linux kernel 5.12.5支持NVMe1.4 CMB功能

    在最新的kernel 5.12.5终于看到对NVMe 1.4协议的CMB支持了,喜大普奔!散花散花!
    NVMe 1.4协议的CMB功能变化太大了,增加了CMBS,CRE,CMBMSC,CMBSTS。看起来终于像一个像样的功能了。
    kernel驱动一直跟不上,这次驱动更新终于更新到这一块了,不枉我天天在我的dnvme驱动上修修补补。。。
    PMR也抓紧跟上。。。

    static void nvme_map_cmb(struct nvme_dev *dev)
    {
    	u64 size, offset;
    	resource_size_t bar_size;
    	struct pci_dev *pdev = to_pci_dev(dev->dev);
    	int bar;
    
    	if (dev->cmb_size)
    		return;
    
    	if (NVME_CAP_CMBS(dev->ctrl.cap))
    		writel(NVME_CMBMSC_CRE, dev->bar + NVME_REG_CMBMSC);
    
    	dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ);
    	if (!dev->cmbsz)
    		return;
    	dev->cmbloc = readl(dev->bar + NVME_REG_CMBLOC);
    
    	size = nvme_cmb_size_unit(dev) * nvme_cmb_size(dev);
    	offset = nvme_cmb_size_unit(dev) * NVME_CMB_OFST(dev->cmbloc);
    	bar = NVME_CMB_BIR(dev->cmbloc);
    	bar_size = pci_resource_len(pdev, bar);
    
    	if (offset > bar_size)
    		return;
    
    	/*
    	 * Tell the controller about the host side address mapping the CMB,
    	 * and enable CMB decoding for the NVMe 1.4+ scheme:
    	 */
    	if (NVME_CAP_CMBS(dev->ctrl.cap)) {
    		hi_lo_writeq(NVME_CMBMSC_CRE | NVME_CMBMSC_CMSE |
    			     (pci_bus_address(pdev, bar) + offset),
    			     dev->bar + NVME_REG_CMBMSC);
    	}
    
    	/*
    	 * Controllers may support a CMB size larger than their BAR,
    	 * for example, due to being behind a bridge. Reduce the CMB to
    	 * the reported size of the BAR
    	 */
    	if (size > bar_size - offset)
    		size = bar_size - offset;
    
    	if (pci_p2pdma_add_resource(pdev, bar, size, offset)) {
    		dev_warn(dev->ctrl.device,
    			 "failed to register the CMB
    ");
    		return;
    	}
    
    	dev->cmb_size = size;
    	dev->cmb_use_sqes = use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS);
    
    	if ((dev->cmbsz & (NVME_CMBSZ_WDS | NVME_CMBSZ_RDS)) ==
    			(NVME_CMBSZ_WDS | NVME_CMBSZ_RDS))
    		pci_p2pmem_publish(pdev, true);
    
    	if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
    				    &dev_attr_cmb.attr, NULL))
    		dev_warn(dev->ctrl.device,
    			 "failed to add sysfs attribute for CMB
    ");
    }
    
    
  • 相关阅读:
    Lua学习笔记(二):基本语法
    Lua学习笔记(一):搭建开发环境
    C#学习笔记(十六):Attribute
    [U3D Demo] 手机FPS射击游戏
    C#学习笔记(十五):预处理指令
    js 树菜单 ztree
    jquery flexslider 轮播插件
    浏览器 本地预览图片 window.url.createobjecturl
    mouseover mouseenter mouseout mouseleave
    jquery checkbox问题
  • 原文地址:https://www.cnblogs.com/spfanlost/p/14800568.html
Copyright © 2011-2022 走看看