diff options
Diffstat (limited to 'drivers/nvme/host/pci.c')
| -rw-r--r-- | drivers/nvme/host/pci.c | 38 | 
1 files changed, 23 insertions, 15 deletions
| diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index fed803232edc..40c7581caeb0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -263,7 +263,7 @@ static void nvme_dbbuf_set(struct nvme_dev *dev)  	c.dbbuf.prp2 = cpu_to_le64(dev->dbbuf_eis_dma_addr);  	if (nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0)) { -		dev_warn(dev->dev, "unable to set dbbuf\n"); +		dev_warn(dev->ctrl.device, "unable to set dbbuf\n");  		/* Free memory and continue on */  		nvme_dbbuf_dma_free(dev);  	} @@ -1367,7 +1367,7 @@ static bool nvme_should_reset(struct nvme_dev *dev, u32 csts)  	bool nssro = dev->subsystem && (csts & NVME_CSTS_NSSRO);  	/* If there is a reset ongoing, we shouldn't reset again. */ -	if (work_busy(&dev->reset_work)) +	if (dev->ctrl.state == NVME_CTRL_RESETTING)  		return false;  	/* We shouldn't reset unless the controller is on fatal error state @@ -1394,11 +1394,11 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)  	result = pci_read_config_word(to_pci_dev(dev->dev), PCI_STATUS,  				      &pci_status);  	if (result == PCIBIOS_SUCCESSFUL) -		dev_warn(dev->dev, +		dev_warn(dev->ctrl.device,  			 "controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n",  			 csts, pci_status);  	else -		dev_warn(dev->dev, +		dev_warn(dev->ctrl.device,  			 "controller is down; will reset: CSTS=0x%x, PCI_STATUS read failed (%d)\n",  			 csts, result);  } @@ -1506,6 +1506,11 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)  	if (dev->cmb) {  		iounmap(dev->cmb);  		dev->cmb = NULL; +		if (dev->cmbsz) { +			sysfs_remove_file_from_group(&dev->ctrl.device->kobj, +						     &dev_attr_cmb.attr, NULL); +			dev->cmbsz = 0; +		}  	}  } @@ -1735,8 +1740,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)  	 */  	if (pdev->vendor == PCI_VENDOR_ID_APPLE && pdev->device == 0x2001) {  		dev->q_depth = 2; -		dev_warn(dev->dev, "detected Apple NVMe controller, set " -			"queue depth=%u to work around controller resets\n", +		dev_warn(dev->ctrl.device, "detected Apple NVMe controller, " +			"set queue depth=%u to work around controller resets\n",  			dev->q_depth);  	} @@ -1754,7 +1759,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)  		if (dev->cmbsz) {  			if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,  						    &dev_attr_cmb.attr, NULL)) -				dev_warn(dev->dev, +				dev_warn(dev->ctrl.device,  					 "failed to add sysfs attribute for CMB\n");  		}  	} @@ -1779,6 +1784,7 @@ static void nvme_pci_disable(struct nvme_dev *dev)  {  	struct pci_dev *pdev = to_pci_dev(dev->dev); +	nvme_release_cmb(dev);  	pci_free_irq_vectors(pdev);  	if (pci_is_enabled(pdev)) { @@ -1799,7 +1805,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)  	if (pci_is_enabled(pdev)) {  		u32 csts = readl(dev->bar + NVME_REG_CSTS); -		if (dev->ctrl.state == NVME_CTRL_LIVE) +		if (dev->ctrl.state == NVME_CTRL_LIVE || +		    dev->ctrl.state == NVME_CTRL_RESETTING)  			nvme_start_freeze(&dev->ctrl);  		dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) ||  			pdev->error_state  != pci_channel_io_normal); @@ -1897,7 +1904,7 @@ static void nvme_reset_work(struct work_struct *work)  	bool was_suspend = !!(dev->ctrl.ctrl_config & NVME_CC_SHN_NORMAL);  	int result = -ENODEV; -	if (WARN_ON(dev->ctrl.state == NVME_CTRL_RESETTING)) +	if (WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING))  		goto out;  	/* @@ -1907,9 +1914,6 @@ static void nvme_reset_work(struct work_struct *work)  	if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)  		nvme_dev_disable(dev, false); -	if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) -		goto out; -  	result = nvme_pci_enable(dev);  	if (result)  		goto out; @@ -2003,8 +2007,8 @@ static int nvme_reset(struct nvme_dev *dev)  {  	if (!dev->ctrl.admin_q || blk_queue_dying(dev->ctrl.admin_q))  		return -ENODEV; -	if (work_busy(&dev->reset_work)) -		return -ENODEV; +	if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) +		return -EBUSY;  	if (!queue_work(nvme_workq, &dev->reset_work))  		return -EBUSY;  	return 0; @@ -2041,6 +2045,7 @@ static int nvme_pci_reset_ctrl(struct nvme_ctrl *ctrl)  static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {  	.name			= "pcie",  	.module			= THIS_MODULE, +	.flags			= NVME_F_METADATA_SUPPORTED,  	.reg_read32		= nvme_pci_reg_read32,  	.reg_write32		= nvme_pci_reg_write32,  	.reg_read64		= nvme_pci_reg_read64, @@ -2129,6 +2134,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)  	if (result)  		goto release_pools; +	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING);  	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));  	queue_work(nvme_workq, &dev->reset_work); @@ -2172,6 +2178,7 @@ static void nvme_remove(struct pci_dev *pdev)  	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING); +	cancel_work_sync(&dev->reset_work);  	pci_set_drvdata(pdev, NULL);  	if (!pci_device_is_present(pdev)) { @@ -2184,7 +2191,6 @@ static void nvme_remove(struct pci_dev *pdev)  	nvme_dev_disable(dev, true);  	nvme_dev_remove_admin(dev);  	nvme_free_queues(dev, 0); -	nvme_release_cmb(dev);  	nvme_release_prp_pools(dev);  	nvme_dev_unmap(dev);  	nvme_put_ctrl(&dev->ctrl); @@ -2288,6 +2294,8 @@ static const struct pci_device_id nvme_id_table[] = {  	{ PCI_VDEVICE(INTEL, 0x0a54),  		.driver_data = NVME_QUIRK_STRIPE_SIZE |  				NVME_QUIRK_DEALLOCATE_ZEROES, }, +	{ PCI_VDEVICE(INTEL, 0xf1a5),	/* Intel 600P/P3100 */ +		.driver_data = NVME_QUIRK_NO_DEEPEST_PS },  	{ PCI_VDEVICE(INTEL, 0x5845),	/* Qemu emulated controller */  		.driver_data = NVME_QUIRK_IDENTIFY_CNS, },  	{ PCI_DEVICE(0x1c58, 0x0003),	/* HGST adapter */ | 
