| .. | .. |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | /** |
|---|
| 52 | 52 | * rvt_alloc_pd - allocate a protection domain |
|---|
| 53 | | - * @ibdev: ib device |
|---|
| 54 | | - * @context: optional user context |
|---|
| 53 | + * @ibpd: PD |
|---|
| 55 | 54 | * @udata: optional user data |
|---|
| 56 | 55 | * |
|---|
| 57 | 56 | * Allocate and keep track of a PD. |
|---|
| 58 | 57 | * |
|---|
| 59 | 58 | * Return: 0 on success |
|---|
| 60 | 59 | */ |
|---|
| 61 | | -struct ib_pd *rvt_alloc_pd(struct ib_device *ibdev, |
|---|
| 62 | | - struct ib_ucontext *context, |
|---|
| 63 | | - struct ib_udata *udata) |
|---|
| 60 | +int rvt_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) |
|---|
| 64 | 61 | { |
|---|
| 62 | + struct ib_device *ibdev = ibpd->device; |
|---|
| 65 | 63 | struct rvt_dev_info *dev = ib_to_rvt(ibdev); |
|---|
| 66 | | - struct rvt_pd *pd; |
|---|
| 67 | | - struct ib_pd *ret; |
|---|
| 64 | + struct rvt_pd *pd = ibpd_to_rvtpd(ibpd); |
|---|
| 65 | + int ret = 0; |
|---|
| 68 | 66 | |
|---|
| 69 | | - pd = kmalloc(sizeof(*pd), GFP_KERNEL); |
|---|
| 70 | | - if (!pd) { |
|---|
| 71 | | - ret = ERR_PTR(-ENOMEM); |
|---|
| 72 | | - goto bail; |
|---|
| 73 | | - } |
|---|
| 74 | 67 | /* |
|---|
| 75 | 68 | * While we could continue allocating protecetion domains, being |
|---|
| 76 | 69 | * constrained only by system resources. The IBTA spec defines that |
|---|
| .. | .. |
|---|
| 81 | 74 | spin_lock(&dev->n_pds_lock); |
|---|
| 82 | 75 | if (dev->n_pds_allocated == dev->dparms.props.max_pd) { |
|---|
| 83 | 76 | spin_unlock(&dev->n_pds_lock); |
|---|
| 84 | | - kfree(pd); |
|---|
| 85 | | - ret = ERR_PTR(-ENOMEM); |
|---|
| 77 | + ret = -ENOMEM; |
|---|
| 86 | 78 | goto bail; |
|---|
| 87 | 79 | } |
|---|
| 88 | 80 | |
|---|
| .. | .. |
|---|
| 92 | 84 | /* ib_alloc_pd() will initialize pd->ibpd. */ |
|---|
| 93 | 85 | pd->user = !!udata; |
|---|
| 94 | 86 | |
|---|
| 95 | | - ret = &pd->ibpd; |
|---|
| 96 | | - |
|---|
| 97 | 87 | bail: |
|---|
| 98 | 88 | return ret; |
|---|
| 99 | 89 | } |
|---|
| .. | .. |
|---|
| 101 | 91 | /** |
|---|
| 102 | 92 | * rvt_dealloc_pd - Free PD |
|---|
| 103 | 93 | * @ibpd: Free up PD |
|---|
| 94 | + * @udata: Valid user data or NULL for kernel object |
|---|
| 104 | 95 | * |
|---|
| 105 | 96 | * Return: always 0 |
|---|
| 106 | 97 | */ |
|---|
| 107 | | -int rvt_dealloc_pd(struct ib_pd *ibpd) |
|---|
| 98 | +int rvt_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) |
|---|
| 108 | 99 | { |
|---|
| 109 | | - struct rvt_pd *pd = ibpd_to_rvtpd(ibpd); |
|---|
| 110 | 100 | struct rvt_dev_info *dev = ib_to_rvt(ibpd->device); |
|---|
| 111 | 101 | |
|---|
| 112 | 102 | spin_lock(&dev->n_pds_lock); |
|---|
| 113 | 103 | dev->n_pds_allocated--; |
|---|
| 114 | 104 | spin_unlock(&dev->n_pds_lock); |
|---|
| 115 | | - |
|---|
| 116 | | - kfree(pd); |
|---|
| 117 | | - |
|---|
| 118 | 105 | return 0; |
|---|
| 119 | 106 | } |
|---|