Lines Matching refs:vio_cmo
90 struct vio_cmo { struct
102 } vio_cmo; argument
153 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_alloc()
160 if (vio_cmo.spare >= VIO_CMO_MIN_ENT) in vio_cmo_alloc()
161 excess_free = vio_cmo.excess.free; in vio_cmo_alloc()
165 vio_cmo.curr += size; in vio_cmo_alloc()
166 if (vio_cmo.curr > vio_cmo.high) in vio_cmo_alloc()
167 vio_cmo.high = vio_cmo.curr; in vio_cmo_alloc()
170 vio_cmo.excess.free -= size; in vio_cmo_alloc()
174 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_alloc()
199 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_dealloc()
200 vio_cmo.curr -= size; in vio_cmo_dealloc()
213 spare_needed = VIO_CMO_MIN_ENT - vio_cmo.spare; in vio_cmo_dealloc()
221 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
222 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
223 vio_cmo.spare += tmp; in vio_cmo_dealloc()
238 vio_cmo.spare += tmp; in vio_cmo_dealloc()
250 if (excess_freed && (vio_cmo.desired > vio_cmo.reserve.size)) { in vio_cmo_dealloc()
251 tmp = min(excess_freed, (vio_cmo.desired - vio_cmo.reserve.size)); in vio_cmo_dealloc()
253 vio_cmo.excess.size -= tmp; in vio_cmo_dealloc()
254 vio_cmo.reserve.size += tmp; in vio_cmo_dealloc()
261 vio_cmo.excess.free += excess_freed; in vio_cmo_dealloc()
264 schedule_delayed_work(&vio_cmo.balance_q, VIO_CMO_BALANCE_DELAY); in vio_cmo_dealloc()
265 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_dealloc()
286 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
289 if (new_entitlement > vio_cmo.entitled) { in vio_cmo_entitlement_update()
290 delta = new_entitlement - vio_cmo.entitled; in vio_cmo_entitlement_update()
293 if (vio_cmo.spare < VIO_CMO_MIN_ENT) { in vio_cmo_entitlement_update()
294 tmp = min(delta, (VIO_CMO_MIN_ENT - vio_cmo.spare)); in vio_cmo_entitlement_update()
295 vio_cmo.spare += tmp; in vio_cmo_entitlement_update()
296 vio_cmo.reserve.size += tmp; in vio_cmo_entitlement_update()
301 vio_cmo.entitled += delta; in vio_cmo_entitlement_update()
302 vio_cmo.excess.size += delta; in vio_cmo_entitlement_update()
303 vio_cmo.excess.free += delta; in vio_cmo_entitlement_update()
309 delta = vio_cmo.entitled - new_entitlement; in vio_cmo_entitlement_update()
310 avail = vio_cmo.excess.free; in vio_cmo_entitlement_update()
316 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
329 vio_cmo.entitled -= delta; in vio_cmo_entitlement_update()
332 tmp = min(vio_cmo.excess.free, delta); in vio_cmo_entitlement_update()
333 vio_cmo.excess.size -= tmp; in vio_cmo_entitlement_update()
334 vio_cmo.excess.free -= tmp; in vio_cmo_entitlement_update()
341 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_entitlement_update()
356 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
361 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_entitlement_update()
362 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_entitlement_update()
389 struct vio_cmo *cmo; in vio_cmo_balance()
396 cmo = container_of(work, struct vio_cmo, balance_q.work); in vio_cmo_balance()
398 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_balance()
412 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
428 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
466 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) { in vio_cmo_balance()
480 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_balance()
649 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
658 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_set_dev_desired()
664 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
671 vio_cmo.desired += desired - viodev->cmo.desired; in vio_cmo_set_dev_desired()
675 vio_cmo.desired -= viodev->cmo.desired - desired; in vio_cmo_set_dev_desired()
682 vio_cmo.reserve.size -= viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
683 vio_cmo.excess.size += viodev->cmo.entitled - desired; in vio_cmo_set_dev_desired()
690 vio_cmo.excess.free += viodev->cmo.entitled - in vio_cmo_set_dev_desired()
695 schedule_delayed_work(&vio_cmo.balance_q, 0); in vio_cmo_set_dev_desired()
696 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_set_dev_desired()
762 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
763 list_add(&dev_ent->list, &vio_cmo.device_list); in vio_cmo_bus_probe()
767 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
776 if (vio_cmo.min == ((vio_cmo_num_OF_devs() + 1) * in vio_cmo_bus_probe()
780 vio_cmo.desired += (viodev->cmo.desired - in vio_cmo_bus_probe()
785 tmp = vio_cmo.spare + vio_cmo.excess.free; in vio_cmo_bus_probe()
790 size, (vio_cmo.spare + tmp)); in vio_cmo_bus_probe()
791 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
796 tmp = min(size, vio_cmo.excess.free); in vio_cmo_bus_probe()
797 vio_cmo.excess.free -= tmp; in vio_cmo_bus_probe()
798 vio_cmo.excess.size -= tmp; in vio_cmo_bus_probe()
799 vio_cmo.reserve.size += tmp; in vio_cmo_bus_probe()
802 vio_cmo.spare -= size - tmp; in vio_cmo_bus_probe()
805 vio_cmo.min += size; in vio_cmo_bus_probe()
806 vio_cmo.desired += viodev->cmo.desired; in vio_cmo_bus_probe()
808 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_probe()
828 spin_lock_irqsave(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
840 list_for_each_entry(dev_ent, &vio_cmo.device_list, list) in vio_cmo_bus_remove()
858 vio_cmo.desired -= (viodev->cmo.desired - VIO_CMO_MIN_ENT); in vio_cmo_bus_remove()
868 if (viodev->cmo.entitled && (vio_cmo.spare < VIO_CMO_MIN_ENT)) { in vio_cmo_bus_remove()
870 vio_cmo.spare)); in vio_cmo_bus_remove()
871 vio_cmo.spare += tmp; in vio_cmo_bus_remove()
876 vio_cmo.excess.size += viodev->cmo.entitled; in vio_cmo_bus_remove()
877 vio_cmo.excess.free += viodev->cmo.entitled; in vio_cmo_bus_remove()
878 vio_cmo.reserve.size -= viodev->cmo.entitled; in vio_cmo_bus_remove()
890 spin_unlock_irqrestore(&vio_cmo.lock, flags); in vio_cmo_bus_remove()
910 memset(&vio_cmo, 0, sizeof(struct vio_cmo)); in vio_cmo_bus_init()
911 spin_lock_init(&vio_cmo.lock); in vio_cmo_bus_init()
912 INIT_LIST_HEAD(&vio_cmo.device_list); in vio_cmo_bus_init()
913 INIT_DELAYED_WORK(&vio_cmo.balance_q, vio_cmo_balance); in vio_cmo_bus_init()
925 vio_cmo.entitled = 0; in vio_cmo_bus_init()
927 vio_cmo.entitled = mpp_data.entitled_mem; in vio_cmo_bus_init()
931 vio_cmo.spare = VIO_CMO_MIN_ENT; in vio_cmo_bus_init()
932 vio_cmo.reserve.size = vio_cmo.spare; in vio_cmo_bus_init()
933 vio_cmo.reserve.size += (vio_cmo_num_OF_devs() * in vio_cmo_bus_init()
935 if (vio_cmo.reserve.size > vio_cmo.entitled) { in vio_cmo_bus_init()
942 vio_cmo.excess.size = vio_cmo.entitled - vio_cmo.reserve.size; in vio_cmo_bus_init()
943 vio_cmo.excess.free = vio_cmo.excess.size; in vio_cmo_bus_init()
944 vio_cmo.min = vio_cmo.reserve.size; in vio_cmo_bus_init()
945 vio_cmo.desired = vio_cmo.reserve.size; in vio_cmo_bus_init()
1014 return sprintf(buf, "%lu\n", vio_cmo.name); \
1022 return sprintf(buf, "%lu\n", vio_cmo.name.var); \
1037 return sprintf(buf, "%lu\n", vio_cmo.high); in cmo_high_show()
1045 spin_lock_irqsave(&vio_cmo.lock, flags); in cmo_high_store()
1046 vio_cmo.high = vio_cmo.curr; in cmo_high_store()
1047 spin_unlock_irqrestore(&vio_cmo.lock, flags); in cmo_high_store()