aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Gurtovoy <maxg@mellanox.com>2017-07-29 18:45:08 -0400
committerChristoph Hellwig <hch@lst.de>2017-08-10 05:19:06 -0400
commit1c78f7735b2bdd0afbe5d14c5c8b6d8d381b6f13 (patch)
tree2cf63efdbc0ca6650fd61081161a92557b8948b8
parent507384209371fc25cab203b95e7bdf50e58b47d5 (diff)
nvme-pci: fix CMB sysfs file removal in reset path
Currently we create the sysfs entry even if we fail mapping it. In that case, the unmapping will not remove the sysfs created file. There is no good reason to create a sysfs entry for a non working CMB and show his characteristics. Fixes: f63572dff ("nvme: unmap CMB and remove sysfs file in reset path") Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Stephen Bates <sbates@raithlin.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/pci.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index cd888a47d0fc..74a124a06264 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1558,11 +1558,9 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
1558 if (dev->cmb) { 1558 if (dev->cmb) {
1559 iounmap(dev->cmb); 1559 iounmap(dev->cmb);
1560 dev->cmb = NULL; 1560 dev->cmb = NULL;
1561 if (dev->cmbsz) { 1561 sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
1562 sysfs_remove_file_from_group(&dev->ctrl.device->kobj, 1562 &dev_attr_cmb.attr, NULL);
1563 &dev_attr_cmb.attr, NULL); 1563 dev->cmbsz = 0;
1564 dev->cmbsz = 0;
1565 }
1566 } 1564 }
1567} 1565}
1568 1566
@@ -1953,16 +1951,14 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1953 1951
1954 /* 1952 /*
1955 * CMBs can currently only exist on >=1.2 PCIe devices. We only 1953 * CMBs can currently only exist on >=1.2 PCIe devices. We only
1956 * populate sysfs if a CMB is implemented. Note that we add the 1954 * populate sysfs if a CMB is implemented. Since nvme_dev_attrs_group
1957 * CMB attribute to the nvme_ctrl kobj which removes the need to remove 1955 * has no name we can pass NULL as final argument to
1958 * it on exit. Since nvme_dev_attrs_group has no name we can pass 1956 * sysfs_add_file_to_group.
1959 * NULL as final argument to sysfs_add_file_to_group.
1960 */ 1957 */
1961 1958
1962 if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) { 1959 if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) {
1963 dev->cmb = nvme_map_cmb(dev); 1960 dev->cmb = nvme_map_cmb(dev);
1964 1961 if (dev->cmb) {
1965 if (dev->cmbsz) {
1966 if (sysfs_add_file_to_group(&dev->ctrl.device->kobj, 1962 if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
1967 &dev_attr_cmb.attr, NULL)) 1963 &dev_attr_cmb.attr, NULL))
1968 dev_warn(dev->ctrl.device, 1964 dev_warn(dev->ctrl.device,