Message ID | 20190226164530.31476.26502.stgit@scvm10.sc.intel.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | bc5add09764c123f58942a37c8335247e683d234 |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | Driver fixes | expand |
On 2/26/2019 11:45 AM, Dennis Dalessandro wrote: > struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt); > diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c > index 7841a0a..2cc5164 100644 > --- a/drivers/infiniband/hw/hfi1/init.c > +++ b/drivers/infiniband/hw/hfi1/init.c > @@ -214,12 +214,12 @@ static void hfi1_rcd_free(struct kref *kref) > struct hfi1_ctxtdata *rcd = > container_of(kref, struct hfi1_ctxtdata, kref); > > - hfi1_free_ctxtdata(rcd->dd, rcd); > - > spin_lock_irqsave(&rcd->dd->uctxt_lock, flags); > rcd->dd->rcd[rcd->ctxt] = NULL; > spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags); > > + hfi1_free_ctxtdata(rcd->dd, rcd); > + > kfree(rcd); > } > Whoops, hold off on pulling this one just yet. We need to take a closer look at the above hunk. -Denny
On Tue, Feb 26, 2019 at 12:15:59PM -0500, Dennis Dalessandro wrote: > On 2/26/2019 11:45 AM, Dennis Dalessandro wrote: > > struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt); > > diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c > > index 7841a0a..2cc5164 100644 > > +++ b/drivers/infiniband/hw/hfi1/init.c > > @@ -214,12 +214,12 @@ static void hfi1_rcd_free(struct kref *kref) > > struct hfi1_ctxtdata *rcd = > > container_of(kref, struct hfi1_ctxtdata, kref); > > - hfi1_free_ctxtdata(rcd->dd, rcd); > > - > > spin_lock_irqsave(&rcd->dd->uctxt_lock, flags); > > rcd->dd->rcd[rcd->ctxt] = NULL; > > spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags); > > + hfi1_free_ctxtdata(rcd->dd, rcd); > > + > > kfree(rcd); > > } > Whoops, hold off on pulling this one just yet. We need to take a closer look > at the above hunk. Oh, okay.. Please resend it Jason
On 3/4/2019 3:41 PM, Jason Gunthorpe wrote: > On Tue, Feb 26, 2019 at 12:15:59PM -0500, Dennis Dalessandro wrote: >> On 2/26/2019 11:45 AM, Dennis Dalessandro wrote: >>> struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt); >>> diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c >>> index 7841a0a..2cc5164 100644 >>> +++ b/drivers/infiniband/hw/hfi1/init.c >>> @@ -214,12 +214,12 @@ static void hfi1_rcd_free(struct kref *kref) >>> struct hfi1_ctxtdata *rcd = >>> container_of(kref, struct hfi1_ctxtdata, kref); >>> - hfi1_free_ctxtdata(rcd->dd, rcd); >>> - >>> spin_lock_irqsave(&rcd->dd->uctxt_lock, flags); >>> rcd->dd->rcd[rcd->ctxt] = NULL; >>> spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags); >>> + hfi1_free_ctxtdata(rcd->dd, rcd); >>> + >>> kfree(rcd); >>> } >> Whoops, hold off on pulling this one just yet. We need to take a closer look >> at the above hunk. > > Oh, okay.. Please resend it We've talked it over, it is OK to take after all. Just needed to be sure and folks were on vacation last week. If you still have the patch it's good to go, if not I'll tack it on my next submit as well. -Denny
On Tue, Mar 05, 2019 at 10:30:39AM -0500, Dennis Dalessandro wrote: > On 3/4/2019 3:41 PM, Jason Gunthorpe wrote: > > On Tue, Feb 26, 2019 at 12:15:59PM -0500, Dennis Dalessandro wrote: > > > On 2/26/2019 11:45 AM, Dennis Dalessandro wrote: > > > > struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt); > > > > diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c > > > > index 7841a0a..2cc5164 100644 > > > > +++ b/drivers/infiniband/hw/hfi1/init.c > > > > @@ -214,12 +214,12 @@ static void hfi1_rcd_free(struct kref *kref) > > > > struct hfi1_ctxtdata *rcd = > > > > container_of(kref, struct hfi1_ctxtdata, kref); > > > > - hfi1_free_ctxtdata(rcd->dd, rcd); > > > > - > > > > spin_lock_irqsave(&rcd->dd->uctxt_lock, flags); > > > > rcd->dd->rcd[rcd->ctxt] = NULL; > > > > spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags); > > > > + hfi1_free_ctxtdata(rcd->dd, rcd); > > > > + > > > > kfree(rcd); > > > > } > > > Whoops, hold off on pulling this one just yet. We need to take a closer look > > > at the above hunk. > > > > Oh, okay.. Please resend it > > We've talked it over, it is OK to take after all. Just needed to be sure and > folks were on vacation last week. If you still have the patch it's good to > go, if not I'll tack it on my next submit as well. Okay I grabbed the old one Jason
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h index 6582184..048b5d7 100644 --- a/drivers/infiniband/hw/hfi1/hfi.h +++ b/drivers/infiniband/hw/hfi1/hfi.h @@ -1455,7 +1455,7 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd, struct hfi1_devdata *dd, u8 hw_pidx, u8 port); void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd); int hfi1_rcd_put(struct hfi1_ctxtdata *rcd); -void hfi1_rcd_get(struct hfi1_ctxtdata *rcd); +int hfi1_rcd_get(struct hfi1_ctxtdata *rcd); struct hfi1_ctxtdata *hfi1_rcd_get_by_index_safe(struct hfi1_devdata *dd, u16 ctxt); struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt); diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c index 7841a0a..2cc5164 100644 --- a/drivers/infiniband/hw/hfi1/init.c +++ b/drivers/infiniband/hw/hfi1/init.c @@ -214,12 +214,12 @@ static void hfi1_rcd_free(struct kref *kref) struct hfi1_ctxtdata *rcd = container_of(kref, struct hfi1_ctxtdata, kref); - hfi1_free_ctxtdata(rcd->dd, rcd); - spin_lock_irqsave(&rcd->dd->uctxt_lock, flags); rcd->dd->rcd[rcd->ctxt] = NULL; spin_unlock_irqrestore(&rcd->dd->uctxt_lock, flags); + hfi1_free_ctxtdata(rcd->dd, rcd); + kfree(rcd); } @@ -242,10 +242,13 @@ int hfi1_rcd_put(struct hfi1_ctxtdata *rcd) * @rcd: pointer to an initialized rcd data structure * * Use this to get a reference after the init. + * + * Return : reflect kref_get_unless_zero(), which returns non-zero on + * increment, otherwise 0. */ -void hfi1_rcd_get(struct hfi1_ctxtdata *rcd) +int hfi1_rcd_get(struct hfi1_ctxtdata *rcd) { - kref_get(&rcd->kref); + return kref_get_unless_zero(&rcd->kref); } /** @@ -325,7 +328,8 @@ struct hfi1_ctxtdata *hfi1_rcd_get_by_index(struct hfi1_devdata *dd, u16 ctxt) spin_lock_irqsave(&dd->uctxt_lock, flags); if (dd->rcd[ctxt]) { rcd = dd->rcd[ctxt]; - hfi1_rcd_get(rcd); + if (!hfi1_rcd_get(rcd)) + rcd = NULL; } spin_unlock_irqrestore(&dd->uctxt_lock, flags);