Lines Matching full:window
27 * Compute the paste address region for the window @window using the
30 void vas_win_paste_addr(struct pnv_vas_window *window, u64 *addr, int *len) in vas_win_paste_addr() argument
35 base = window->vinst->paste_base_addr; in vas_win_paste_addr()
36 shift = window->vinst->paste_win_id_shift; in vas_win_paste_addr()
37 winid = window->vas_win.winid; in vas_win_paste_addr()
46 static inline void get_hvwc_mmio_bar(struct pnv_vas_window *window, in get_hvwc_mmio_bar() argument
51 pbaddr = window->vinst->hvwc_bar_start; in get_hvwc_mmio_bar()
52 *start = pbaddr + window->vas_win.winid * VAS_HVWC_SIZE; in get_hvwc_mmio_bar()
56 static inline void get_uwc_mmio_bar(struct pnv_vas_window *window, in get_uwc_mmio_bar() argument
61 pbaddr = window->vinst->uwc_bar_start; in get_uwc_mmio_bar()
62 *start = pbaddr + window->vas_win.winid * VAS_UWC_SIZE; in get_uwc_mmio_bar()
67 * Map the paste bus address of the given send window into kernel address
78 name = kasprintf(GFP_KERNEL, "window-v%d-w%d", txwin->vinst->vas_id, in map_paste_region()
134 * Unmap the paste address region for a window.
136 static void unmap_paste_region(struct pnv_vas_window *window) in unmap_paste_region() argument
141 if (window->paste_kaddr) { in unmap_paste_region()
142 vas_win_paste_addr(window, &busaddr_start, &len); in unmap_paste_region()
143 unmap_region(window->paste_kaddr, busaddr_start, len); in unmap_paste_region()
144 window->paste_kaddr = NULL; in unmap_paste_region()
145 kfree(window->paste_addr_name); in unmap_paste_region()
146 window->paste_addr_name = NULL; in unmap_paste_region()
151 * Unmap the MMIO regions for a window. Hold the vas_mutex so we don't
152 * unmap when the window's debugfs dir is in use. This serializes close
153 * of a window even on another VAS instance but since its not a critical
157 static void unmap_winctx_mmio_bars(struct pnv_vas_window *window) in unmap_winctx_mmio_bars() argument
166 hvwc_map = window->hvwc_map; in unmap_winctx_mmio_bars()
167 window->hvwc_map = NULL; in unmap_winctx_mmio_bars()
169 uwc_map = window->uwc_map; in unmap_winctx_mmio_bars()
170 window->uwc_map = NULL; in unmap_winctx_mmio_bars()
175 get_hvwc_mmio_bar(window, &busaddr_start, &len); in unmap_winctx_mmio_bars()
180 get_uwc_mmio_bar(window, &busaddr_start, &len); in unmap_winctx_mmio_bars()
186 * Find the Hypervisor Window Context (HVWC) MMIO Base Address Region and the
187 * OS/User Window Context (UWC) MMIO Base Address Region for the given window.
188 * Map these bus addresses and save the mapped kernel addresses in @window.
190 static int map_winctx_mmio_bars(struct pnv_vas_window *window) in map_winctx_mmio_bars() argument
195 get_hvwc_mmio_bar(window, &start, &len); in map_winctx_mmio_bars()
196 window->hvwc_map = map_mmio_region("HVWCM_Window", start, len); in map_winctx_mmio_bars()
198 get_uwc_mmio_bar(window, &start, &len); in map_winctx_mmio_bars()
199 window->uwc_map = map_mmio_region("UWCM_Window", start, len); in map_winctx_mmio_bars()
201 if (!window->hvwc_map || !window->uwc_map) { in map_winctx_mmio_bars()
202 unmap_winctx_mmio_bars(window); in map_winctx_mmio_bars()
210 * Reset all valid registers in the HV and OS/User Window Contexts for
211 * the window identified by @window.
213 * NOTE: We cannot really use a for loop to reset window context. Not all
214 * offsets in a window context are valid registers and the valid
218 static void reset_window_regs(struct pnv_vas_window *window) in reset_window_regs() argument
220 write_hvwc_reg(window, VREG(LPID), 0ULL); in reset_window_regs()
221 write_hvwc_reg(window, VREG(PID), 0ULL); in reset_window_regs()
222 write_hvwc_reg(window, VREG(XLATE_MSR), 0ULL); in reset_window_regs()
223 write_hvwc_reg(window, VREG(XLATE_LPCR), 0ULL); in reset_window_regs()
224 write_hvwc_reg(window, VREG(XLATE_CTL), 0ULL); in reset_window_regs()
225 write_hvwc_reg(window, VREG(AMR), 0ULL); in reset_window_regs()
226 write_hvwc_reg(window, VREG(SEIDR), 0ULL); in reset_window_regs()
227 write_hvwc_reg(window, VREG(FAULT_TX_WIN), 0ULL); in reset_window_regs()
228 write_hvwc_reg(window, VREG(OSU_INTR_SRC_RA), 0ULL); in reset_window_regs()
229 write_hvwc_reg(window, VREG(HV_INTR_SRC_RA), 0ULL); in reset_window_regs()
230 write_hvwc_reg(window, VREG(PSWID), 0ULL); in reset_window_regs()
231 write_hvwc_reg(window, VREG(LFIFO_BAR), 0ULL); in reset_window_regs()
232 write_hvwc_reg(window, VREG(LDATA_STAMP_CTL), 0ULL); in reset_window_regs()
233 write_hvwc_reg(window, VREG(LDMA_CACHE_CTL), 0ULL); in reset_window_regs()
234 write_hvwc_reg(window, VREG(LRFIFO_PUSH), 0ULL); in reset_window_regs()
235 write_hvwc_reg(window, VREG(CURR_MSG_COUNT), 0ULL); in reset_window_regs()
236 write_hvwc_reg(window, VREG(LNOTIFY_AFTER_COUNT), 0ULL); in reset_window_regs()
237 write_hvwc_reg(window, VREG(LRX_WCRED), 0ULL); in reset_window_regs()
238 write_hvwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in reset_window_regs()
239 write_hvwc_reg(window, VREG(TX_WCRED), 0ULL); in reset_window_regs()
240 write_hvwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in reset_window_regs()
241 write_hvwc_reg(window, VREG(LFIFO_SIZE), 0ULL); in reset_window_regs()
242 write_hvwc_reg(window, VREG(WINCTL), 0ULL); in reset_window_regs()
243 write_hvwc_reg(window, VREG(WIN_STATUS), 0ULL); in reset_window_regs()
244 write_hvwc_reg(window, VREG(WIN_CTX_CACHING_CTL), 0ULL); in reset_window_regs()
245 write_hvwc_reg(window, VREG(TX_RSVD_BUF_COUNT), 0ULL); in reset_window_regs()
246 write_hvwc_reg(window, VREG(LRFIFO_WIN_PTR), 0ULL); in reset_window_regs()
247 write_hvwc_reg(window, VREG(LNOTIFY_CTL), 0ULL); in reset_window_regs()
248 write_hvwc_reg(window, VREG(LNOTIFY_PID), 0ULL); in reset_window_regs()
249 write_hvwc_reg(window, VREG(LNOTIFY_LPID), 0ULL); in reset_window_regs()
250 write_hvwc_reg(window, VREG(LNOTIFY_TID), 0ULL); in reset_window_regs()
251 write_hvwc_reg(window, VREG(LNOTIFY_SCOPE), 0ULL); in reset_window_regs()
252 write_hvwc_reg(window, VREG(NX_UTIL_ADDER), 0ULL); in reset_window_regs()
257 * The send and receive window credit adder registers are also in reset_window_regs()
259 * need to initialize from the OS/User Window Context, so skip in reset_window_regs()
262 * write_uwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in reset_window_regs()
263 * write_uwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in reset_window_regs()
268 * Initialize window context registers related to Address Translation.
274 static void init_xlate_regs(struct pnv_vas_window *window, bool user_win) in init_xlate_regs() argument
289 write_hvwc_reg(window, VREG(XLATE_MSR), val); in init_xlate_regs()
304 write_hvwc_reg(window, VREG(XLATE_LPCR), val); in init_xlate_regs()
315 write_hvwc_reg(window, VREG(XLATE_CTL), val); in init_xlate_regs()
322 write_hvwc_reg(window, VREG(AMR), val); in init_xlate_regs()
326 write_hvwc_reg(window, VREG(SEIDR), val); in init_xlate_regs()
330 * Initialize Reserved Send Buffer Count for the send window. It involves
347 * Initialize window context registers for a receive window.
348 * Except for caching control and marking window open, the registers
349 * are initialized in the order listed in Section 3.1.4 (Window Context
361 static void init_winctx_regs(struct pnv_vas_window *window, in init_winctx_regs() argument
367 reset_window_regs(window); in init_winctx_regs()
371 write_hvwc_reg(window, VREG(LPID), val); in init_winctx_regs()
375 write_hvwc_reg(window, VREG(PID), val); in init_winctx_regs()
377 init_xlate_regs(window, winctx->user_win); in init_winctx_regs()
381 write_hvwc_reg(window, VREG(FAULT_TX_WIN), val); in init_winctx_regs()
384 write_hvwc_reg(window, VREG(OSU_INTR_SRC_RA), 0ULL); in init_winctx_regs()
388 write_hvwc_reg(window, VREG(HV_INTR_SRC_RA), val); in init_winctx_regs()
392 write_hvwc_reg(window, VREG(PSWID), val); in init_winctx_regs()
394 write_hvwc_reg(window, VREG(SPARE1), 0ULL); in init_winctx_regs()
395 write_hvwc_reg(window, VREG(SPARE2), 0ULL); in init_winctx_regs()
396 write_hvwc_reg(window, VREG(SPARE3), 0ULL); in init_winctx_regs()
409 write_hvwc_reg(window, VREG(LFIFO_BAR), val); in init_winctx_regs()
413 write_hvwc_reg(window, VREG(LDATA_STAMP_CTL), val); in init_winctx_regs()
418 write_hvwc_reg(window, VREG(LDMA_CACHE_CTL), val); in init_winctx_regs()
420 write_hvwc_reg(window, VREG(LRFIFO_PUSH), 0ULL); in init_winctx_regs()
421 write_hvwc_reg(window, VREG(CURR_MSG_COUNT), 0ULL); in init_winctx_regs()
422 write_hvwc_reg(window, VREG(LNOTIFY_AFTER_COUNT), 0ULL); in init_winctx_regs()
426 write_hvwc_reg(window, VREG(LRX_WCRED), val); in init_winctx_regs()
430 write_hvwc_reg(window, VREG(TX_WCRED), val); in init_winctx_regs()
432 write_hvwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in init_winctx_regs()
433 write_hvwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in init_winctx_regs()
439 write_hvwc_reg(window, VREG(LFIFO_SIZE), val); in init_winctx_regs()
441 /* Update window control and caching control registers last so in init_winctx_regs()
442 * we mark the window open only after fully initializing it and in init_winctx_regs()
446 write_hvwc_reg(window, VREG(WIN_STATUS), 0ULL); in init_winctx_regs()
448 init_rsvd_tx_buf_count(window, winctx); in init_winctx_regs()
450 /* for a send window, point to the matching receive window */ in init_winctx_regs()
453 write_hvwc_reg(window, VREG(LRFIFO_WIN_PTR), val); in init_winctx_regs()
455 write_hvwc_reg(window, VREG(SPARE4), 0ULL); in init_winctx_regs()
462 write_hvwc_reg(window, VREG(LNOTIFY_CTL), val); in init_winctx_regs()
466 write_hvwc_reg(window, VREG(LNOTIFY_PID), val); in init_winctx_regs()
470 write_hvwc_reg(window, VREG(LNOTIFY_LPID), val); in init_winctx_regs()
474 write_hvwc_reg(window, VREG(LNOTIFY_TID), val); in init_winctx_regs()
479 write_hvwc_reg(window, VREG(LNOTIFY_SCOPE), val); in init_winctx_regs()
483 write_hvwc_reg(window, VREG(SPARE5), 0ULL); in init_winctx_regs()
484 write_hvwc_reg(window, VREG(NX_UTIL_ADDER), 0ULL); in init_winctx_regs()
485 write_hvwc_reg(window, VREG(SPARE6), 0ULL); in init_winctx_regs()
487 /* Finally, push window context to memory and... */ in init_winctx_regs()
490 write_hvwc_reg(window, VREG(WIN_CTX_CACHING_CTL), val); in init_winctx_regs()
492 /* ... mark the window open for business */ in init_winctx_regs()
503 write_hvwc_reg(window, VREG(WINCTL), val); in init_winctx_regs()
523 static void vas_window_free(struct pnv_vas_window *window) in vas_window_free() argument
525 struct vas_instance *vinst = window->vinst; in vas_window_free()
526 int winid = window->vas_win.winid; in vas_window_free()
528 unmap_winctx_mmio_bars(window); in vas_window_free()
530 vas_window_free_dbgdir(window); in vas_window_free()
532 kfree(window); in vas_window_free()
540 struct pnv_vas_window *window; in vas_window_alloc() local
546 window = kzalloc(sizeof(*window), GFP_KERNEL); in vas_window_alloc()
547 if (!window) in vas_window_alloc()
550 window->vinst = vinst; in vas_window_alloc()
551 window->vas_win.winid = winid; in vas_window_alloc()
553 if (map_winctx_mmio_bars(window)) in vas_window_alloc()
556 vas_window_init_dbgdir(window); in vas_window_alloc()
558 return window; in vas_window_alloc()
561 kfree(window); in vas_window_alloc()
568 /* Better not be a send window! */ in put_rx_win()
575 * Find the user space receive window given the @pswid.
578 * - The window must refer to an OPEN, FTW, RECEIVE window.
602 * Get the VAS receive window associated with NX engine identified
630 * looking up a window by its id. It is used to look up send windows
636 * entries and is used to look up a receive window by its
639 * Here, we save @window in the ->windows[] table. If it is a receive
640 * window, we also save the window in the ->rxwin[] table.
643 struct pnv_vas_window *window) in set_vinst_win() argument
645 int id = window->vas_win.winid; in set_vinst_win()
650 * There should only be one receive window for a coprocessor type in set_vinst_win()
651 * unless its a user (FTW) window. in set_vinst_win()
653 if (!window->user_win && !window->tx_win) { in set_vinst_win()
654 WARN_ON_ONCE(vinst->rxwin[window->vas_win.cop]); in set_vinst_win()
655 vinst->rxwin[window->vas_win.cop] = window; in set_vinst_win()
659 vinst->windows[id] = window; in set_vinst_win()
665 * Clear this window from the table(s) of windows for this VAS instance.
668 static void clear_vinst_win(struct pnv_vas_window *window) in clear_vinst_win() argument
670 int id = window->vas_win.winid; in clear_vinst_win()
671 struct vas_instance *vinst = window->vinst; in clear_vinst_win()
675 if (!window->user_win && !window->tx_win) { in clear_vinst_win()
676 WARN_ON_ONCE(!vinst->rxwin[window->vas_win.cop]); in clear_vinst_win()
677 vinst->rxwin[window->vas_win.cop] = NULL; in clear_vinst_win()
680 WARN_ON_ONCE(vinst->windows[id] != window); in clear_vinst_win()
780 /* cannot be fault or user window if it is nx */ in rx_win_args_valid()
791 /* cannot be both fault and user window */ in rx_win_args_valid()
810 /* Rx window must be one of NX or Fault or User window. */ in rx_win_args_valid()
874 pr_devel("Unable to allocate memory for Rx window\n"); in vas_rx_win_open()
953 * IRQ and fault window setup is successful. Set fault window in init_winctx_for_txwin()
954 * for the send window so that ready to handle faults. in init_winctx_for_txwin()
1011 * receive window (applicable only to FTW windows), use the vasid in vas_tx_win_open()
1012 * from that receive window. in vas_tx_win_open()
1047 * If its a kernel send window, map the window address into the in vas_tx_win_open()
1049 * mmap() to map the window into their address space. in vas_tx_win_open()
1062 * Interrupt handler or fault window setup failed. Means in vas_tx_win_open()
1064 * opening for user space tx window. in vas_tx_win_open()
1143 * If credit checking is enabled for this window, poll for the return
1144 * of window credits (i.e for NX engines to process any outstanding CRBs).
1146 * window, we should not have to wait for too long.
1155 static void poll_window_credits(struct pnv_vas_window *window) in poll_window_credits() argument
1161 val = read_hvwc_reg(window, VREG(WINCTL)); in poll_window_credits()
1162 if (window->tx_win) in poll_window_credits()
1170 if (window->tx_win) { in poll_window_credits()
1171 val = read_hvwc_reg(window, VREG(TX_WCRED)); in poll_window_credits()
1174 val = read_hvwc_reg(window, VREG(LRX_WCRED)); in poll_window_credits()
1181 * TODO: Scan fault FIFO and invalidate CRBs points to this window in poll_window_credits()
1185 if (creds < window->vas_win.wcreds_max) { in poll_window_credits()
1191 * Process can not close send window until all credits are in poll_window_credits()
1195 …pr_warn_ratelimited("VAS: pid %d stuck. Waiting for credits returned for Window(%d). creds %d, Ret… in poll_window_credits()
1196 vas_window_pid(&window->vas_win), in poll_window_credits()
1197 window->vas_win.winid, in poll_window_credits()
1205 * Wait for the window to go to "not-busy" state. It should only take a
1206 * short time to queue a CRB, so window should not be busy for too long.
1209 static void poll_window_busy_state(struct pnv_vas_window *window) in poll_window_busy_state() argument
1216 val = read_hvwc_reg(window, VREG(WIN_STATUS)); in poll_window_busy_state()
1228 pr_warn_ratelimited("VAS: pid %d stuck. Window (ID=%d) is in busy state. Retries %d\n", in poll_window_busy_state()
1229 vas_window_pid(&window->vas_win), in poll_window_busy_state()
1230 window->vas_win.winid, count); in poll_window_busy_state()
1237 * Have the hardware cast a window out of cache and wait for it to
1240 * NOTE: It can take a relatively long time to cast the window context
1243 * - we clear the "Pin Window" bit (so hardware is free to evict)
1245 * - we re-initialize the window context when it is reassigned.
1250 * job to a worker thread, so the window close can proceed quickly.
1252 static void poll_window_castout(struct pnv_vas_window *window) in poll_window_castout() argument
1258 * Unpin and close a window so no new requests are accepted and the
1259 * hardware can evict this window from cache if necessary.
1261 static void unpin_close_window(struct pnv_vas_window *window) in unpin_close_window() argument
1265 val = read_hvwc_reg(window, VREG(WINCTL)); in unpin_close_window()
1268 write_hvwc_reg(window, VREG(WINCTL), val); in unpin_close_window()
1272 * Close a window.
1274 * See Section 1.12.1 of VAS workbook v1.05 for details on closing window:
1276 * - Poll for the "Window Busy" bit to be cleared
1277 * - Clear the Open/Enable bit for the Window.
1278 * - Poll for return of window Credits (implies FIFO empty for Rx win?)
1279 * - Unpin and cast window context out of cache
1285 struct pnv_vas_window *window; in vas_win_close() local
1290 window = container_of(vwin, struct pnv_vas_window, vas_win); in vas_win_close()
1292 if (!window->tx_win && atomic_read(&window->num_txwins) != 0) { in vas_win_close()
1293 pr_devel("Attempting to close an active Rx window!\n"); in vas_win_close()
1298 unmap_paste_region(window); in vas_win_close()
1300 poll_window_busy_state(window); in vas_win_close()
1302 unpin_close_window(window); in vas_win_close()
1304 poll_window_credits(window); in vas_win_close()
1306 clear_vinst_win(window); in vas_win_close()
1308 poll_window_castout(window); in vas_win_close()
1310 /* if send window, drop reference to matching receive window */ in vas_win_close()
1311 if (window->tx_win) { in vas_win_close()
1312 if (window->user_win) { in vas_win_close()
1316 put_rx_win(window->rxwin); in vas_win_close()
1319 vas_window_free(window); in vas_win_close()
1326 * Return credit for the given window.
1327 * Send windows and fault window uses credit mechanism as follows:
1330 * - The default number of credits available for each send window is
1337 * credit on the specific send window after processing the fault CRB.
1339 * Fault window:
1344 * - The kernel with return credit on fault window after reading entry
1347 void vas_return_credit(struct pnv_vas_window *window, bool tx) in vas_return_credit() argument
1352 if (tx) { /* send window */ in vas_return_credit()
1354 write_hvwc_reg(window, VREG(TX_WCRED_ADDER), val); in vas_return_credit()
1357 write_hvwc_reg(window, VREG(LRX_WCRED_ADDER), val); in vas_return_credit()
1364 struct pnv_vas_window *window; in vas_pswid_to_window() local
1378 * If application closes the window before the hardware in vas_pswid_to_window()
1380 * for the pending requests. so the window must be active in vas_pswid_to_window()
1386 window = vinst->windows[winid]; in vas_pswid_to_window()
1388 if (!window) { in vas_pswid_to_window()
1389 pr_err("PSWID decode: Could not find window for winid %d pswid %d vinst 0x%p\n", in vas_pswid_to_window()
1395 * Do some sanity checks on the decoded window. Window should be in vas_pswid_to_window()
1396 * NX GZIP user send window. FTW windows should not incur faults in vas_pswid_to_window()
1400 if (!window->tx_win || !window->user_win || !window->nx_win || in vas_pswid_to_window()
1401 window->vas_win.cop == VAS_COP_TYPE_FAULT || in vas_pswid_to_window()
1402 window->vas_win.cop == VAS_COP_TYPE_FTW) { in vas_pswid_to_window()
1404 winid, window->tx_win, window->user_win, in vas_pswid_to_window()
1405 window->nx_win, window->vas_win.cop); in vas_pswid_to_window()
1409 return window; in vas_pswid_to_window()