| 300 | } |
| 301 | |
| 302 | static void |
| 303 | msgring_process(void * arg) |
| 304 | { |
| 305 | volatile struct msgring_thread *mthd; |
| 306 | struct thread *td; |
| 307 | uint32_t mflags, msgstatus1; |
| 308 | int hwtid, nmsgs; |
| 309 | |
| 310 | hwtid = (intptr_t)arg; |
| 311 | mthd = &msgring_threads[hwtid]; |
| 312 | td = mthd->thread; |
| 313 | KASSERT(curthread == td, |
| 314 | ("%s:msg_ithread and proc linkage out of sync", __func__)); |
| 315 | |
| 316 | /* First bind this thread to the right CPU */ |
| 317 | thread_lock(td); |
| 318 | sched_bind(td, xlp_hwtid_to_cpuid[hwtid]); |
| 319 | thread_unlock(td); |
| 320 | |
| 321 | if (hwtid != nlm_cpuid()) |
| 322 | printf("Misscheduled hwtid %d != cpuid %d\n", hwtid, |
| 323 | nlm_cpuid()); |
| 324 | |
| 325 | xlp_discard_msg_vc(0xf); |
| 326 | xlp_msgring_cpu_init(nlm_nodeid(), nlm_cpuid(), CMS_DEFAULT_CREDIT); |
| 327 | if (polled == 0) { |
| 328 | mflags = nlm_save_flags_cop2(); |
| 329 | nlm_fmn_cpu_init(IRQ_MSGRING, 0, 0, 0, 0, 0); |
| 330 | nlm_restore_flags(mflags); |
| 331 | xlp_cms_enable_intr(nlm_nodeid(), nlm_cpuid(), 0x2, 0); |
| 332 | /* clear pending interrupts. |
| 333 | * they will get re-raised if still valid */ |
| 334 | nlm_write_c0_eirr(1ULL << IRQ_MSGRING); |
| 335 | } |
| 336 | |
| 337 | /* start processing messages */ |
| 338 | for (;;) { |
| 339 | atomic_store_rel_int(&mthd->needed, 0); |
| 340 | nmsgs = xlp_handle_msg_vc(0xf, 0); |
| 341 | |
| 342 | /* sleep */ |
| 343 | if (polled == 0) { |
| 344 | /* clear VC-pend bits */ |
| 345 | mflags = nlm_save_flags_cop2(); |
| 346 | msgstatus1 = nlm_read_c2_msgstatus1(); |
| 347 | msgstatus1 |= (0xf << 16); |
| 348 | nlm_write_c2_msgstatus1(msgstatus1); |
| 349 | nlm_restore_flags(mflags); |
| 350 | |
| 351 | thread_lock(td); |
| 352 | if (mthd->needed) { |
| 353 | thread_unlock(td); |
| 354 | continue; |
| 355 | } |
| 356 | sched_class(td, PRI_ITHD); |
| 357 | TD_SET_IWAIT(td); |
| 358 | mi_switch(SW_VOL); |
| 359 | } else |
nothing calls this directly
no test coverage detected