Lines Matching full:ptp
44 const int slot = pt->base >> pt->ptp->shift; in nvkm_mmu_ptp_put()
45 struct nvkm_mmu_ptp *ptp = pt->ptp; in nvkm_mmu_ptp_put() local
48 * there will be now, so return PTP to the cache. in nvkm_mmu_ptp_put()
50 if (!ptp->free) in nvkm_mmu_ptp_put()
51 list_add(&ptp->head, &mmu->ptp.list); in nvkm_mmu_ptp_put()
52 ptp->free |= BIT(slot); in nvkm_mmu_ptp_put()
54 /* If there's no more sub-allocations, destroy PTP. */ in nvkm_mmu_ptp_put()
55 if (ptp->free == ptp->mask) { in nvkm_mmu_ptp_put()
56 nvkm_mmu_ptc_put(mmu, force, &ptp->pt); in nvkm_mmu_ptp_put()
57 list_del(&ptp->head); in nvkm_mmu_ptp_put()
58 kfree(ptp); in nvkm_mmu_ptp_put()
68 struct nvkm_mmu_ptp *ptp; in nvkm_mmu_ptp_get() local
74 ptp = list_first_entry_or_null(&mmu->ptp.list, typeof(*ptp), head); in nvkm_mmu_ptp_get()
75 if (!ptp) { in nvkm_mmu_ptp_get()
77 if (!(ptp = kmalloc(sizeof(*ptp), GFP_KERNEL))) { in nvkm_mmu_ptp_get()
82 ptp->pt = nvkm_mmu_ptc_get(mmu, 0x1000, 0x1000, false); in nvkm_mmu_ptp_get()
83 if (!ptp->pt) { in nvkm_mmu_ptp_get()
84 kfree(ptp); in nvkm_mmu_ptp_get()
89 ptp->shift = order_base_2(size); in nvkm_mmu_ptp_get()
90 slot = nvkm_memory_size(ptp->pt->memory) >> ptp->shift; in nvkm_mmu_ptp_get()
91 ptp->mask = (1 << slot) - 1; in nvkm_mmu_ptp_get()
92 ptp->free = ptp->mask; in nvkm_mmu_ptp_get()
93 list_add(&ptp->head, &mmu->ptp.list); in nvkm_mmu_ptp_get()
95 pt->ptp = ptp; in nvkm_mmu_ptp_get()
98 /* Sub-allocate from parent object, removing PTP from cache in nvkm_mmu_ptp_get()
101 slot = __ffs(ptp->free); in nvkm_mmu_ptp_get()
102 ptp->free &= ~BIT(slot); in nvkm_mmu_ptp_get()
103 if (!ptp->free) in nvkm_mmu_ptp_get()
104 list_del(&ptp->head); in nvkm_mmu_ptp_get()
106 pt->memory = pt->ptp->pt->memory; in nvkm_mmu_ptp_get()
107 pt->base = slot << ptp->shift; in nvkm_mmu_ptp_get()
108 pt->addr = pt->ptp->pt->addr + pt->base; in nvkm_mmu_ptp_get()
147 mutex_lock(&mmu->ptp.mutex); in nvkm_mmu_ptc_put()
149 mutex_unlock(&mmu->ptp.mutex); in nvkm_mmu_ptc_put()
175 mutex_lock(&mmu->ptp.mutex); in nvkm_mmu_ptc_get()
177 mutex_unlock(&mmu->ptp.mutex); in nvkm_mmu_ptc_get()
250 mutex_init(&mmu->ptp.mutex); in nvkm_mmu_ptc_init()
251 INIT_LIST_HEAD(&mmu->ptp.list); in nvkm_mmu_ptc_init()