Commit 5ab17a24 authored by Kaike Wan's avatar Kaike Wan Committed by Jason Gunthorpe

IB/hfi1: Remove kobj from hfi1_devdata

The field kobj was added to hfi1_devdata structure to manage the life time
of the hfi1_devdata structure for PSM accesses:

commit e11ffbd5 ("IB/hfi1: Do not free hfi1 cdev parent structure early")

Later another mechanism user_refcount/user_comp was introduced to provide
the same functionality:

commit acd7c8fe ("IB/hfi1: Fix an Oops on pci device force remove")

This patch will remove this kobj field, as it is no longer needed.

Link: https://lore.kernel.org/r/20200316210500.7753.4145.stgit@awfm-01.aw.intel.comReviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent d61ba1b9
...@@ -209,7 +209,6 @@ static int hfi1_file_open(struct inode *inode, struct file *fp) ...@@ -209,7 +209,6 @@ static int hfi1_file_open(struct inode *inode, struct file *fp)
fd->mm = current->mm; fd->mm = current->mm;
mmgrab(fd->mm); mmgrab(fd->mm);
fd->dd = dd; fd->dd = dd;
kobject_get(&fd->dd->kobj);
fp->private_data = fd; fp->private_data = fd;
return 0; return 0;
nomem: nomem:
...@@ -713,7 +712,6 @@ static int hfi1_file_close(struct inode *inode, struct file *fp) ...@@ -713,7 +712,6 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)
deallocate_ctxt(uctxt); deallocate_ctxt(uctxt);
done: done:
mmdrop(fdata->mm); mmdrop(fdata->mm);
kobject_put(&dd->kobj);
if (atomic_dec_and_test(&dd->user_refcount)) if (atomic_dec_and_test(&dd->user_refcount))
complete(&dd->user_comp); complete(&dd->user_comp);
...@@ -1696,7 +1694,7 @@ static int user_add(struct hfi1_devdata *dd) ...@@ -1696,7 +1694,7 @@ static int user_add(struct hfi1_devdata *dd)
snprintf(name, sizeof(name), "%s_%d", class_name(), dd->unit); snprintf(name, sizeof(name), "%s_%d", class_name(), dd->unit);
ret = hfi1_cdev_init(dd->unit, name, &hfi1_file_ops, ret = hfi1_cdev_init(dd->unit, name, &hfi1_file_ops,
&dd->user_cdev, &dd->user_device, &dd->user_cdev, &dd->user_device,
true, &dd->kobj); true, &dd->verbs_dev.rdi.ibdev.dev.kobj);
if (ret) if (ret)
user_remove(dd); user_remove(dd);
......
...@@ -1413,8 +1413,6 @@ struct hfi1_devdata { ...@@ -1413,8 +1413,6 @@ struct hfi1_devdata {
bool aspm_enabled; /* ASPM state: enabled/disabled */ bool aspm_enabled; /* ASPM state: enabled/disabled */
struct rhashtable *sdma_rht; struct rhashtable *sdma_rht;
struct kobject kobj;
/* vnic data */ /* vnic data */
struct hfi1_vnic_data vnic; struct hfi1_vnic_data vnic;
/* Lock to protect IRQ SRC register access */ /* Lock to protect IRQ SRC register access */
......
...@@ -1198,13 +1198,13 @@ static void finalize_asic_data(struct hfi1_devdata *dd, ...@@ -1198,13 +1198,13 @@ static void finalize_asic_data(struct hfi1_devdata *dd,
} }
/** /**
* hfi1_clean_devdata - cleans up per-unit data structure * hfi1_free_devdata - cleans up and frees per-unit data structure
* @dd: pointer to a valid devdata structure * @dd: pointer to a valid devdata structure
* *
* It cleans up all data structures set up by * It cleans up and frees all data structures set up by
* by hfi1_alloc_devdata(). * by hfi1_alloc_devdata().
*/ */
static void hfi1_clean_devdata(struct hfi1_devdata *dd) void hfi1_free_devdata(struct hfi1_devdata *dd)
{ {
struct hfi1_asic_data *ad; struct hfi1_asic_data *ad;
unsigned long flags; unsigned long flags;
...@@ -1231,23 +1231,6 @@ static void hfi1_clean_devdata(struct hfi1_devdata *dd) ...@@ -1231,23 +1231,6 @@ static void hfi1_clean_devdata(struct hfi1_devdata *dd)
rvt_dealloc_device(&dd->verbs_dev.rdi); rvt_dealloc_device(&dd->verbs_dev.rdi);
} }
static void __hfi1_free_devdata(struct kobject *kobj)
{
struct hfi1_devdata *dd =
container_of(kobj, struct hfi1_devdata, kobj);
hfi1_clean_devdata(dd);
}
static struct kobj_type hfi1_devdata_type = {
.release = __hfi1_free_devdata,
};
void hfi1_free_devdata(struct hfi1_devdata *dd)
{
kobject_put(&dd->kobj);
}
/** /**
* hfi1_alloc_devdata - Allocate our primary per-unit data structure. * hfi1_alloc_devdata - Allocate our primary per-unit data structure.
* @pdev: Valid PCI device * @pdev: Valid PCI device
...@@ -1333,11 +1316,10 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, ...@@ -1333,11 +1316,10 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev,
goto bail; goto bail;
} }
kobject_init(&dd->kobj, &hfi1_devdata_type);
return dd; return dd;
bail: bail:
hfi1_clean_devdata(dd); hfi1_free_devdata(dd);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
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