Lines Matching refs:vio_cmo
87 static struct vio_cmo { struct
99 } vio_cmo; argument
150 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_alloc()
157 if (vio_cmo.spare >= VIO_CMO_MIN_ENT) in vio_cmo_alloc()
158 excess_free = vio_cmo.excess.free; in vio_cmo_alloc()
162 vio_cmo.curr += size; in vio_cmo_alloc()
163 if (vio_cmo.curr > vio_cmo.high) in vio_cmo_alloc()
164 vio_cmo.high = vio_cmo.curr; in vio_cmo_alloc()
167 vio_cmo.excess.free -= size; in vio_cmo_alloc()
171 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_alloc()
196 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_dealloc()
197 vio_cmo.curr -= size; in vio_cmo_dealloc()
210 spare_needed = VIO_CMO_MIN_ENT - vio_cmo.spare; in vio_cmo_dealloc()
218 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
219 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
220 vio_cmo.spare += tmp; in vio_cmo_dealloc()
235 vio_cmo.spare += tmp; in vio_cmo_dealloc()
247 if (excess_freed && (vio_cmo.desired > vio_cmo.reserve.size)) { in vio_cmo_dealloc()
248 tmp = min(excess_freed, (vio_cmo.desired - vio_cmo.reserve.size)); in vio_cmo_dealloc()
250 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
251 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
258 vio_cmo.excess.free += excess_freed; in vio_cmo_dealloc()
261 schedule_delayed_work(&vio_cmo.balance_q, VIO_CMO_BALANCE_DELAY); in vio_cmo_dealloc()
262 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_dealloc()
283 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
286 if (new_entitlement > vio_cmo.entitled) { in vio_cmo_entitlement_update()
287 delta = new_entitlement - vio_cmo.entitled; in vio_cmo_entitlement_update()
290 if (vio_cmo.spare < VIO_CMO_MIN_ENT) { in vio_cmo_entitlement_update()
291 tmp = min(delta, (VIO_CMO_MIN_ENT - vio_cmo.spare)); in vio_cmo_entitlement_update()
292 vio_cmo.spare += tmp; in vio_cmo_entitlement_update()
293 vio_cmo.reserve.size += tmp; in vio_cmo_entitlement_update()
298 vio_cmo.entitled += delta; in vio_cmo_entitlement_update()
299 vio_cmo.excess.size += delta; in vio_cmo_entitlement_update()
300 vio_cmo.excess.free += delta; in vio_cmo_entitlement_update()
306 delta = vio_cmo.entitled - new_entitlement; in vio_cmo_entitlement_update()
307 avail = vio_cmo.excess.free; in vio_cmo_entitlement_update()
313 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
326 vio_cmo.entitled -= delta; in vio_cmo_entitlement_update()
329 tmp = min(vio_cmo.excess.free, delta); in vio_cmo_entitlement_update()
330 vio_cmo.excess.size -= tmp; in vio_cmo_entitlement_update()
331 vio_cmo.excess.free -= tmp; in vio_cmo_entitlement_update()
338 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
353 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
358 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_entitlement_update()
359 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
386 struct vio_cmo *cmo; in vio_cmo_balance()
393 cmo = container_of(work, struct vio_cmo, balance_q.work); in vio_cmo_balance()
395 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_balance()
409 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
425 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
463 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
477 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_balance()
634 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
643 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_set_dev_desired()
649 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
656 vio_cmo.desired += desired - viodev->cmo.desired; in vio_cmo_set_dev_desired()
660 vio_cmo.desired -= viodev->cmo.desired - desired; in vio_cmo_set_dev_desired()
667 vio_cmo.reserve.size -= viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
668 vio_cmo.excess.size += viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
675 vio_cmo.excess.free += viodev->cmo.entitled - in vio_cmo_set_dev_desired()
680 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_set_dev_desired()
681 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
747 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
748 list_add(&dev_ent->list, &vio_cmo.device_list); in vio_cmo_bus_probe()
752 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
761 if (vio_cmo.min == ((vio_cmo_num_OF_devs() + 1) * in vio_cmo_bus_probe()
765 vio_cmo.desired += (viodev->cmo.desired - in vio_cmo_bus_probe()
770 tmp = vio_cmo.spare + vio_cmo.excess.free; in vio_cmo_bus_probe()
775 size, (vio_cmo.spare + tmp)); in vio_cmo_bus_probe()
776 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
781 tmp = min(size, vio_cmo.excess.free); in vio_cmo_bus_probe()
782 vio_cmo.excess.free -= tmp; in vio_cmo_bus_probe()
783 vio_cmo.excess.size -= tmp; in vio_cmo_bus_probe()
784 vio_cmo.reserve.size += tmp; in vio_cmo_bus_probe()
787 vio_cmo.spare -= size - tmp; in vio_cmo_bus_probe()
790 vio_cmo.min += size; in vio_cmo_bus_probe()
791 vio_cmo.desired += viodev->cmo.desired; in vio_cmo_bus_probe()
793 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
813 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
825 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_bus_remove()
843 vio_cmo.desired -= (viodev->cmo.desired - VIO_CMO_MIN_ENT); in vio_cmo_bus_remove()
853 if (viodev->cmo.entitled && (vio_cmo.spare < VIO_CMO_MIN_ENT)) { in vio_cmo_bus_remove()
855 vio_cmo.spare)); in vio_cmo_bus_remove()
856 vio_cmo.spare += tmp; in vio_cmo_bus_remove()
861 vio_cmo.excess.size += viodev->cmo.entitled; in vio_cmo_bus_remove()
862 vio_cmo.excess.free += viodev->cmo.entitled; in vio_cmo_bus_remove()
863 vio_cmo.reserve.size -= viodev->cmo.entitled; in vio_cmo_bus_remove()
875 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
895 memset(&vio_cmo, 0, sizeof(struct vio_cmo)); in vio_cmo_bus_init()
896 spin_lock_init(&vio_cmo.lock); in vio_cmo_bus_init()
897 INIT_LIST_HEAD(&vio_cmo.device_list); in vio_cmo_bus_init()
898 INIT_DELAYED_WORK(&vio_cmo.balance_q, vio_cmo_balance); in vio_cmo_bus_init()
910 vio_cmo.entitled = 0; in vio_cmo_bus_init()
912 vio_cmo.entitled = mpp_data.entitled_mem; in vio_cmo_bus_init()
916 vio_cmo.spare = VIO_CMO_MIN_ENT; in vio_cmo_bus_init()
917 vio_cmo.reserve.size = vio_cmo.spare; in vio_cmo_bus_init()
918 vio_cmo.reserve.size += (vio_cmo_num_OF_devs() * in vio_cmo_bus_init()
920 if (vio_cmo.reserve.size > vio_cmo.entitled) { in vio_cmo_bus_init()
927 vio_cmo.excess.size = vio_cmo.entitled - vio_cmo.reserve.size; in vio_cmo_bus_init()
928 vio_cmo.excess.free = vio_cmo.excess.size; in vio_cmo_bus_init()
929 vio_cmo.min = vio_cmo.reserve.size; in vio_cmo_bus_init()
930 vio_cmo.desired = vio_cmo.reserve.size; in vio_cmo_bus_init()
1008 return sprintf(buf, "%lu\n", vio_cmo.name); \
1017 return sprintf(buf, "%lu\n", vio_cmo.name.var); \
1032 return sprintf(buf, "%lu\n", vio_cmo.high); in cmo_high_show()
1040 spin_lock_irqsave(&vio_cmo.lock, flags); in cmo_high_store()
1041 vio_cmo.high = vio_cmo.curr; in cmo_high_store()
1042 spin_unlock_irqrestore(&vio_cmo.lock, flags); in cmo_high_store()