Lines Matching refs:vio_cmo

89 static struct vio_cmo {  struct
101 } vio_cmo; argument
152 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_alloc()
159 if (vio_cmo.spare >= VIO_CMO_MIN_ENT) in vio_cmo_alloc()
160 excess_free = vio_cmo.excess.free; in vio_cmo_alloc()
164 vio_cmo.curr += size; in vio_cmo_alloc()
165 if (vio_cmo.curr > vio_cmo.high) in vio_cmo_alloc()
166 vio_cmo.high = vio_cmo.curr; in vio_cmo_alloc()
169 vio_cmo.excess.free -= size; in vio_cmo_alloc()
173 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_alloc()
198 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_dealloc()
199 vio_cmo.curr -= size; in vio_cmo_dealloc()
212 spare_needed = VIO_CMO_MIN_ENT - vio_cmo.spare; in vio_cmo_dealloc()
220 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
221 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
222 vio_cmo.spare += tmp; in vio_cmo_dealloc()
237 vio_cmo.spare += tmp; in vio_cmo_dealloc()
249 if (excess_freed && (vio_cmo.desired > vio_cmo.reserve.size)) { in vio_cmo_dealloc()
250 tmp = min(excess_freed, (vio_cmo.desired - vio_cmo.reserve.size)); in vio_cmo_dealloc()
252 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
253 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
260 vio_cmo.excess.free += excess_freed; in vio_cmo_dealloc()
263 schedule_delayed_work(&vio_cmo.balance_q, VIO_CMO_BALANCE_DELAY); in vio_cmo_dealloc()
264 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_dealloc()
285 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
288 if (new_entitlement > vio_cmo.entitled) { in vio_cmo_entitlement_update()
289 delta = new_entitlement - vio_cmo.entitled; in vio_cmo_entitlement_update()
292 if (vio_cmo.spare < VIO_CMO_MIN_ENT) { in vio_cmo_entitlement_update()
293 tmp = min(delta, (VIO_CMO_MIN_ENT - vio_cmo.spare)); in vio_cmo_entitlement_update()
294 vio_cmo.spare += tmp; in vio_cmo_entitlement_update()
295 vio_cmo.reserve.size += tmp; in vio_cmo_entitlement_update()
300 vio_cmo.entitled += delta; in vio_cmo_entitlement_update()
301 vio_cmo.excess.size += delta; in vio_cmo_entitlement_update()
302 vio_cmo.excess.free += delta; in vio_cmo_entitlement_update()
308 delta = vio_cmo.entitled - new_entitlement; in vio_cmo_entitlement_update()
309 avail = vio_cmo.excess.free; in vio_cmo_entitlement_update()
315 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
328 vio_cmo.entitled -= delta; in vio_cmo_entitlement_update()
331 tmp = min(vio_cmo.excess.free, delta); in vio_cmo_entitlement_update()
332 vio_cmo.excess.size -= tmp; in vio_cmo_entitlement_update()
333 vio_cmo.excess.free -= tmp; in vio_cmo_entitlement_update()
340 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
355 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
360 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_entitlement_update()
361 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
388 struct vio_cmo *cmo; in vio_cmo_balance()
395 cmo = container_of(work, struct vio_cmo, balance_q.work); in vio_cmo_balance()
397 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_balance()
411 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
427 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
465 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
479 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_balance()
637 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
646 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_set_dev_desired()
652 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
659 vio_cmo.desired += desired - viodev->cmo.desired; in vio_cmo_set_dev_desired()
663 vio_cmo.desired -= viodev->cmo.desired - desired; in vio_cmo_set_dev_desired()
670 vio_cmo.reserve.size -= viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
671 vio_cmo.excess.size += viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
678 vio_cmo.excess.free += viodev->cmo.entitled - in vio_cmo_set_dev_desired()
683 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_set_dev_desired()
684 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
750 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
751 list_add(&dev_ent->list, &vio_cmo.device_list); in vio_cmo_bus_probe()
755 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
764 if (vio_cmo.min == ((vio_cmo_num_OF_devs() + 1) * in vio_cmo_bus_probe()
768 vio_cmo.desired += (viodev->cmo.desired - in vio_cmo_bus_probe()
773 tmp = vio_cmo.spare + vio_cmo.excess.free; in vio_cmo_bus_probe()
778 size, (vio_cmo.spare + tmp)); in vio_cmo_bus_probe()
779 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
784 tmp = min(size, vio_cmo.excess.free); in vio_cmo_bus_probe()
785 vio_cmo.excess.free -= tmp; in vio_cmo_bus_probe()
786 vio_cmo.excess.size -= tmp; in vio_cmo_bus_probe()
787 vio_cmo.reserve.size += tmp; in vio_cmo_bus_probe()
790 vio_cmo.spare -= size - tmp; in vio_cmo_bus_probe()
793 vio_cmo.min += size; in vio_cmo_bus_probe()
794 vio_cmo.desired += viodev->cmo.desired; in vio_cmo_bus_probe()
796 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
816 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
828 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_bus_remove()
846 vio_cmo.desired -= (viodev->cmo.desired - VIO_CMO_MIN_ENT); in vio_cmo_bus_remove()
856 if (viodev->cmo.entitled && (vio_cmo.spare < VIO_CMO_MIN_ENT)) { in vio_cmo_bus_remove()
858 vio_cmo.spare)); in vio_cmo_bus_remove()
859 vio_cmo.spare += tmp; in vio_cmo_bus_remove()
864 vio_cmo.excess.size += viodev->cmo.entitled; in vio_cmo_bus_remove()
865 vio_cmo.excess.free += viodev->cmo.entitled; in vio_cmo_bus_remove()
866 vio_cmo.reserve.size -= viodev->cmo.entitled; in vio_cmo_bus_remove()
878 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
898 memset(&vio_cmo, 0, sizeof(struct vio_cmo)); in vio_cmo_bus_init()
899 spin_lock_init(&vio_cmo.lock); in vio_cmo_bus_init()
900 INIT_LIST_HEAD(&vio_cmo.device_list); in vio_cmo_bus_init()
901 INIT_DELAYED_WORK(&vio_cmo.balance_q, vio_cmo_balance); in vio_cmo_bus_init()
913 vio_cmo.entitled = 0; in vio_cmo_bus_init()
915 vio_cmo.entitled = mpp_data.entitled_mem; in vio_cmo_bus_init()
919 vio_cmo.spare = VIO_CMO_MIN_ENT; in vio_cmo_bus_init()
920 vio_cmo.reserve.size = vio_cmo.spare; in vio_cmo_bus_init()
921 vio_cmo.reserve.size += (vio_cmo_num_OF_devs() * in vio_cmo_bus_init()
923 if (vio_cmo.reserve.size > vio_cmo.entitled) { in vio_cmo_bus_init()
930 vio_cmo.excess.size = vio_cmo.entitled - vio_cmo.reserve.size; in vio_cmo_bus_init()
931 vio_cmo.excess.free = vio_cmo.excess.size; in vio_cmo_bus_init()
932 vio_cmo.min = vio_cmo.reserve.size; in vio_cmo_bus_init()
933 vio_cmo.desired = vio_cmo.reserve.size; in vio_cmo_bus_init()
1011 return sprintf(buf, "%lu\n", vio_cmo.name); \
1020 return sprintf(buf, "%lu\n", vio_cmo.name.var); \
1035 return sprintf(buf, "%lu\n", vio_cmo.high); in cmo_high_show()
1043 spin_lock_irqsave(&vio_cmo.lock, flags); in cmo_high_store()
1044 vio_cmo.high = vio_cmo.curr; in cmo_high_store()
1045 spin_unlock_irqrestore(&vio_cmo.lock, flags); in cmo_high_store()