Commit 1c78f773 authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Christoph Hellwig

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: f63572df ("nvme: unmap CMB and remove sysfs file in reset path")
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarStephen Bates <sbates@raithlin.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 50738420
...@@ -1558,12 +1558,10 @@ static inline void nvme_release_cmb(struct nvme_dev *dev) ...@@ -1558,12 +1558,10 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
if (dev->cmb) { if (dev->cmb) {
iounmap(dev->cmb); iounmap(dev->cmb);
dev->cmb = NULL; dev->cmb = NULL;
if (dev->cmbsz) {
sysfs_remove_file_from_group(&dev->ctrl.device->kobj, sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
&dev_attr_cmb.attr, NULL); &dev_attr_cmb.attr, NULL);
dev->cmbsz = 0; dev->cmbsz = 0;
} }
}
} }
static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits) static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
...@@ -1953,16 +1951,14 @@ static int nvme_pci_enable(struct nvme_dev *dev) ...@@ -1953,16 +1951,14 @@ static int nvme_pci_enable(struct nvme_dev *dev)
/* /*
* CMBs can currently only exist on >=1.2 PCIe devices. We only * CMBs can currently only exist on >=1.2 PCIe devices. We only
* populate sysfs if a CMB is implemented. Note that we add the * populate sysfs if a CMB is implemented. Since nvme_dev_attrs_group
* CMB attribute to the nvme_ctrl kobj which removes the need to remove * has no name we can pass NULL as final argument to
* it on exit. Since nvme_dev_attrs_group has no name we can pass * sysfs_add_file_to_group.
* NULL as final argument to sysfs_add_file_to_group.
*/ */
if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) { if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) {
dev->cmb = nvme_map_cmb(dev); dev->cmb = nvme_map_cmb(dev);
if (dev->cmb) {
if (dev->cmbsz) {
if (sysfs_add_file_to_group(&dev->ctrl.device->kobj, if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
&dev_attr_cmb.attr, NULL)) &dev_attr_cmb.attr, NULL))
dev_warn(dev->ctrl.device, dev_warn(dev->ctrl.device,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment