• Home
  • Raw
  • Download

Lines Matching full:window

28  * Compute the paste address region for the window @window using the
31 static void compute_paste_address(struct vas_window *window, u64 *addr, int *len) in compute_paste_address() argument
36 base = window->vinst->paste_base_addr; in compute_paste_address()
37 shift = window->vinst->paste_win_id_shift; in compute_paste_address()
38 winid = window->winid; in compute_paste_address()
57 static inline void get_hvwc_mmio_bar(struct vas_window *window, in get_hvwc_mmio_bar() argument
62 pbaddr = window->vinst->hvwc_bar_start; in get_hvwc_mmio_bar()
63 *start = pbaddr + window->winid * VAS_HVWC_SIZE; in get_hvwc_mmio_bar()
67 static inline void get_uwc_mmio_bar(struct vas_window *window, in get_uwc_mmio_bar() argument
72 pbaddr = window->vinst->uwc_bar_start; in get_uwc_mmio_bar()
73 *start = pbaddr + window->winid * VAS_UWC_SIZE; in get_uwc_mmio_bar()
78 * Map the paste bus address of the given send window into kernel address
89 name = kasprintf(GFP_KERNEL, "window-v%d-w%d", txwin->vinst->vas_id, in map_paste_region()
145 * Unmap the paste address region for a window.
147 static void unmap_paste_region(struct vas_window *window) in unmap_paste_region() argument
152 if (window->paste_kaddr) { in unmap_paste_region()
153 compute_paste_address(window, &busaddr_start, &len); in unmap_paste_region()
154 unmap_region(window->paste_kaddr, busaddr_start, len); in unmap_paste_region()
155 window->paste_kaddr = NULL; in unmap_paste_region()
156 kfree(window->paste_addr_name); in unmap_paste_region()
157 window->paste_addr_name = NULL; in unmap_paste_region()
162 * Unmap the MMIO regions for a window. Hold the vas_mutex so we don't
163 * unmap when the window's debugfs dir is in use. This serializes close
164 * of a window even on another VAS instance but since its not a critical
168 static void unmap_winctx_mmio_bars(struct vas_window *window) in unmap_winctx_mmio_bars() argument
177 hvwc_map = window->hvwc_map; in unmap_winctx_mmio_bars()
178 window->hvwc_map = NULL; in unmap_winctx_mmio_bars()
180 uwc_map = window->uwc_map; in unmap_winctx_mmio_bars()
181 window->uwc_map = NULL; in unmap_winctx_mmio_bars()
186 get_hvwc_mmio_bar(window, &busaddr_start, &len); in unmap_winctx_mmio_bars()
191 get_uwc_mmio_bar(window, &busaddr_start, &len); in unmap_winctx_mmio_bars()
197 * Find the Hypervisor Window Context (HVWC) MMIO Base Address Region and the
198 * OS/User Window Context (UWC) MMIO Base Address Region for the given window.
199 * Map these bus addresses and save the mapped kernel addresses in @window.
201 int map_winctx_mmio_bars(struct vas_window *window) in map_winctx_mmio_bars() argument
206 get_hvwc_mmio_bar(window, &start, &len); in map_winctx_mmio_bars()
207 window->hvwc_map = map_mmio_region("HVWCM_Window", start, len); in map_winctx_mmio_bars()
209 get_uwc_mmio_bar(window, &start, &len); in map_winctx_mmio_bars()
210 window->uwc_map = map_mmio_region("UWCM_Window", start, len); in map_winctx_mmio_bars()
212 if (!window->hvwc_map || !window->uwc_map) { in map_winctx_mmio_bars()
213 unmap_winctx_mmio_bars(window); in map_winctx_mmio_bars()
221 * Reset all valid registers in the HV and OS/User Window Contexts for
222 * the window identified by @window.
224 * NOTE: We cannot really use a for loop to reset window context. Not all
225 * offsets in a window context are valid registers and the valid
229 void reset_window_regs(struct vas_window *window) in reset_window_regs() argument
231 write_hvwc_reg(window, VREG(LPID), 0ULL); in reset_window_regs()
232 write_hvwc_reg(window, VREG(PID), 0ULL); in reset_window_regs()
233 write_hvwc_reg(window, VREG(XLATE_MSR), 0ULL); in reset_window_regs()
234 write_hvwc_reg(window, VREG(XLATE_LPCR), 0ULL); in reset_window_regs()
235 write_hvwc_reg(window, VREG(XLATE_CTL), 0ULL); in reset_window_regs()
236 write_hvwc_reg(window, VREG(AMR), 0ULL); in reset_window_regs()
237 write_hvwc_reg(window, VREG(SEIDR), 0ULL); in reset_window_regs()
238 write_hvwc_reg(window, VREG(FAULT_TX_WIN), 0ULL); in reset_window_regs()
239 write_hvwc_reg(window, VREG(OSU_INTR_SRC_RA), 0ULL); in reset_window_regs()
240 write_hvwc_reg(window, VREG(HV_INTR_SRC_RA), 0ULL); in reset_window_regs()
241 write_hvwc_reg(window, VREG(PSWID), 0ULL); in reset_window_regs()
242 write_hvwc_reg(window, VREG(LFIFO_BAR), 0ULL); in reset_window_regs()
243 write_hvwc_reg(window, VREG(LDATA_STAMP_CTL), 0ULL); in reset_window_regs()
244 write_hvwc_reg(window, VREG(LDMA_CACHE_CTL), 0ULL); in reset_window_regs()
245 write_hvwc_reg(window, VREG(LRFIFO_PUSH), 0ULL); in reset_window_regs()
246 write_hvwc_reg(window, VREG(CURR_MSG_COUNT), 0ULL); in reset_window_regs()
247 write_hvwc_reg(window, VREG(LNOTIFY_AFTER_COUNT), 0ULL); in reset_window_regs()
248 write_hvwc_reg(window, VREG(LRX_WCRED), 0ULL); in reset_window_regs()
249 write_hvwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in reset_window_regs()
250 write_hvwc_reg(window, VREG(TX_WCRED), 0ULL); in reset_window_regs()
251 write_hvwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in reset_window_regs()
252 write_hvwc_reg(window, VREG(LFIFO_SIZE), 0ULL); in reset_window_regs()
253 write_hvwc_reg(window, VREG(WINCTL), 0ULL); in reset_window_regs()
254 write_hvwc_reg(window, VREG(WIN_STATUS), 0ULL); in reset_window_regs()
255 write_hvwc_reg(window, VREG(WIN_CTX_CACHING_CTL), 0ULL); in reset_window_regs()
256 write_hvwc_reg(window, VREG(TX_RSVD_BUF_COUNT), 0ULL); in reset_window_regs()
257 write_hvwc_reg(window, VREG(LRFIFO_WIN_PTR), 0ULL); in reset_window_regs()
258 write_hvwc_reg(window, VREG(LNOTIFY_CTL), 0ULL); in reset_window_regs()
259 write_hvwc_reg(window, VREG(LNOTIFY_PID), 0ULL); in reset_window_regs()
260 write_hvwc_reg(window, VREG(LNOTIFY_LPID), 0ULL); in reset_window_regs()
261 write_hvwc_reg(window, VREG(LNOTIFY_TID), 0ULL); in reset_window_regs()
262 write_hvwc_reg(window, VREG(LNOTIFY_SCOPE), 0ULL); in reset_window_regs()
263 write_hvwc_reg(window, VREG(NX_UTIL_ADDER), 0ULL); in reset_window_regs()
268 * The send and receive window credit adder registers are also in reset_window_regs()
270 * need to initialize from the OS/User Window Context, so skip in reset_window_regs()
273 * write_uwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in reset_window_regs()
274 * write_uwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in reset_window_regs()
279 * Initialize window context registers related to Address Translation.
285 static void init_xlate_regs(struct vas_window *window, bool user_win) in init_xlate_regs() argument
300 write_hvwc_reg(window, VREG(XLATE_MSR), val); in init_xlate_regs()
315 write_hvwc_reg(window, VREG(XLATE_LPCR), val); in init_xlate_regs()
326 write_hvwc_reg(window, VREG(XLATE_CTL), val); in init_xlate_regs()
333 write_hvwc_reg(window, VREG(AMR), val); in init_xlate_regs()
337 write_hvwc_reg(window, VREG(SEIDR), val); in init_xlate_regs()
341 * Initialize Reserved Send Buffer Count for the send window. It involves
358 * Initialize window context registers for a receive window.
359 * Except for caching control and marking window open, the registers
360 * are initialized in the order listed in Section 3.1.4 (Window Context
372 int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx) in init_winctx_regs() argument
377 reset_window_regs(window); in init_winctx_regs()
381 write_hvwc_reg(window, VREG(LPID), val); in init_winctx_regs()
385 write_hvwc_reg(window, VREG(PID), val); in init_winctx_regs()
387 init_xlate_regs(window, winctx->user_win); in init_winctx_regs()
391 write_hvwc_reg(window, VREG(FAULT_TX_WIN), val); in init_winctx_regs()
394 write_hvwc_reg(window, VREG(OSU_INTR_SRC_RA), 0ULL); in init_winctx_regs()
398 write_hvwc_reg(window, VREG(HV_INTR_SRC_RA), val); in init_winctx_regs()
402 write_hvwc_reg(window, VREG(PSWID), val); in init_winctx_regs()
404 write_hvwc_reg(window, VREG(SPARE1), 0ULL); in init_winctx_regs()
405 write_hvwc_reg(window, VREG(SPARE2), 0ULL); in init_winctx_regs()
406 write_hvwc_reg(window, VREG(SPARE3), 0ULL); in init_winctx_regs()
419 write_hvwc_reg(window, VREG(LFIFO_BAR), val); in init_winctx_regs()
423 write_hvwc_reg(window, VREG(LDATA_STAMP_CTL), val); in init_winctx_regs()
428 write_hvwc_reg(window, VREG(LDMA_CACHE_CTL), val); in init_winctx_regs()
430 write_hvwc_reg(window, VREG(LRFIFO_PUSH), 0ULL); in init_winctx_regs()
431 write_hvwc_reg(window, VREG(CURR_MSG_COUNT), 0ULL); in init_winctx_regs()
432 write_hvwc_reg(window, VREG(LNOTIFY_AFTER_COUNT), 0ULL); in init_winctx_regs()
436 write_hvwc_reg(window, VREG(LRX_WCRED), val); in init_winctx_regs()
440 write_hvwc_reg(window, VREG(TX_WCRED), val); in init_winctx_regs()
442 write_hvwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); in init_winctx_regs()
443 write_hvwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); in init_winctx_regs()
449 write_hvwc_reg(window, VREG(LFIFO_SIZE), val); in init_winctx_regs()
451 /* Update window control and caching control registers last so in init_winctx_regs()
452 * we mark the window open only after fully initializing it and in init_winctx_regs()
456 write_hvwc_reg(window, VREG(WIN_STATUS), 0ULL); in init_winctx_regs()
458 init_rsvd_tx_buf_count(window, winctx); in init_winctx_regs()
460 /* for a send window, point to the matching receive window */ in init_winctx_regs()
463 write_hvwc_reg(window, VREG(LRFIFO_WIN_PTR), val); in init_winctx_regs()
465 write_hvwc_reg(window, VREG(SPARE4), 0ULL); in init_winctx_regs()
472 write_hvwc_reg(window, VREG(LNOTIFY_CTL), val); in init_winctx_regs()
476 write_hvwc_reg(window, VREG(LNOTIFY_PID), val); in init_winctx_regs()
480 write_hvwc_reg(window, VREG(LNOTIFY_LPID), val); in init_winctx_regs()
484 write_hvwc_reg(window, VREG(LNOTIFY_TID), val); in init_winctx_regs()
489 write_hvwc_reg(window, VREG(LNOTIFY_SCOPE), val); in init_winctx_regs()
493 write_hvwc_reg(window, VREG(SPARE5), 0ULL); in init_winctx_regs()
494 write_hvwc_reg(window, VREG(NX_UTIL_ADDER), 0ULL); in init_winctx_regs()
495 write_hvwc_reg(window, VREG(SPARE6), 0ULL); in init_winctx_regs()
497 /* Finally, push window context to memory and... */ in init_winctx_regs()
500 write_hvwc_reg(window, VREG(WIN_CTX_CACHING_CTL), val); in init_winctx_regs()
502 /* ... mark the window open for business */ in init_winctx_regs()
513 write_hvwc_reg(window, VREG(WINCTL), val); in init_winctx_regs()
535 static void vas_window_free(struct vas_window *window) in vas_window_free() argument
537 int winid = window->winid; in vas_window_free()
538 struct vas_instance *vinst = window->vinst; in vas_window_free()
540 unmap_winctx_mmio_bars(window); in vas_window_free()
542 vas_window_free_dbgdir(window); in vas_window_free()
544 kfree(window); in vas_window_free()
552 struct vas_window *window; in vas_window_alloc() local
558 window = kzalloc(sizeof(*window), GFP_KERNEL); in vas_window_alloc()
559 if (!window) in vas_window_alloc()
562 window->vinst = vinst; in vas_window_alloc()
563 window->winid = winid; in vas_window_alloc()
565 if (map_winctx_mmio_bars(window)) in vas_window_alloc()
568 vas_window_init_dbgdir(window); in vas_window_alloc()
570 return window; in vas_window_alloc()
573 kfree(window); in vas_window_alloc()
580 /* Better not be a send window! */ in put_rx_win()
587 * Find the user space receive window given the @pswid.
590 * - The window must refer to an OPEN, FTW, RECEIVE window.
613 * Get the VAS receive window associated with NX engine identified
641 * looking up a window by its id. It is used to look up send windows
647 * entries and is used to look up a receive window by its
650 * Here, we save @window in the ->windows[] table. If it is a receive
651 * window, we also save the window in the ->rxwin[] table.
654 struct vas_window *window) in set_vinst_win() argument
656 int id = window->winid; in set_vinst_win()
661 * There should only be one receive window for a coprocessor type in set_vinst_win()
662 * unless its a user (FTW) window. in set_vinst_win()
664 if (!window->user_win && !window->tx_win) { in set_vinst_win()
665 WARN_ON_ONCE(vinst->rxwin[window->cop]); in set_vinst_win()
666 vinst->rxwin[window->cop] = window; in set_vinst_win()
670 vinst->windows[id] = window; in set_vinst_win()
676 * Clear this window from the table(s) of windows for this VAS instance.
679 static void clear_vinst_win(struct vas_window *window) in clear_vinst_win() argument
681 int id = window->winid; in clear_vinst_win()
682 struct vas_instance *vinst = window->vinst; in clear_vinst_win()
686 if (!window->user_win && !window->tx_win) { in clear_vinst_win()
687 WARN_ON_ONCE(!vinst->rxwin[window->cop]); in clear_vinst_win()
688 vinst->rxwin[window->cop] = NULL; in clear_vinst_win()
691 WARN_ON_ONCE(vinst->windows[id] != window); in clear_vinst_win()
789 /* cannot be fault or user window if it is nx */ in rx_win_args_valid()
800 /* cannot be both fault and user window */ in rx_win_args_valid()
819 /* Rx window must be one of NX or Fault or User window. */ in rx_win_args_valid()
882 pr_devel("Unable to allocate memory for Rx window\n"); in vas_rx_win_open()
1005 * receive window (applicable only to FTW windows), use the vasid in vas_tx_win_open()
1006 * from that receive window. in vas_tx_win_open()
1042 * If its a kernel send window, map the window address into the in vas_tx_win_open()
1044 * mmap() to map the window into their address space. in vas_tx_win_open()
1129 * If credit checking is enabled for this window, poll for the return
1130 * of window credits (i.e for NX engines to process any outstanding CRBs).
1132 * window, we should not have to wait for too long.
1141 static void poll_window_credits(struct vas_window *window) in poll_window_credits() argument
1146 val = read_hvwc_reg(window, VREG(WINCTL)); in poll_window_credits()
1147 if (window->tx_win) in poll_window_credits()
1155 if (window->tx_win) { in poll_window_credits()
1156 val = read_hvwc_reg(window, VREG(TX_WCRED)); in poll_window_credits()
1159 val = read_hvwc_reg(window, VREG(LRX_WCRED)); in poll_window_credits()
1163 if (creds < window->wcreds_max) { in poll_window_credits()
1172 * Wait for the window to go to "not-busy" state. It should only take a
1173 * short time to queue a CRB, so window should not be busy for too long.
1176 static void poll_window_busy_state(struct vas_window *window) in poll_window_busy_state() argument
1182 val = read_hvwc_reg(window, VREG(WIN_STATUS)); in poll_window_busy_state()
1193 * Have the hardware cast a window out of cache and wait for it to
1196 * NOTE: It can take a relatively long time to cast the window context
1199 * - we clear the "Pin Window" bit (so hardware is free to evict)
1201 * - we re-initialize the window context when it is reassigned.
1206 * job to a worker thread, so the window close can proceed quickly.
1208 static void poll_window_castout(struct vas_window *window) in poll_window_castout() argument
1214 * Unpin and close a window so no new requests are accepted and the
1215 * hardware can evict this window from cache if necessary.
1217 static void unpin_close_window(struct vas_window *window) in unpin_close_window() argument
1221 val = read_hvwc_reg(window, VREG(WINCTL)); in unpin_close_window()
1224 write_hvwc_reg(window, VREG(WINCTL), val); in unpin_close_window()
1228 * Close a window.
1230 * See Section 1.12.1 of VAS workbook v1.05 for details on closing window:
1232 * - Poll for the "Window Busy" bit to be cleared
1233 * - Clear the Open/Enable bit for the Window.
1234 * - Poll for return of window Credits (implies FIFO empty for Rx win?)
1235 * - Unpin and cast window context out of cache
1239 int vas_win_close(struct vas_window *window) in vas_win_close() argument
1241 if (!window) in vas_win_close()
1244 if (!window->tx_win && atomic_read(&window->num_txwins) != 0) { in vas_win_close()
1245 pr_devel("Attempting to close an active Rx window!\n"); in vas_win_close()
1250 unmap_paste_region(window); in vas_win_close()
1252 clear_vinst_win(window); in vas_win_close()
1254 poll_window_busy_state(window); in vas_win_close()
1256 unpin_close_window(window); in vas_win_close()
1258 poll_window_credits(window); in vas_win_close()
1260 poll_window_castout(window); in vas_win_close()
1262 /* if send window, drop reference to matching receive window */ in vas_win_close()
1263 if (window->tx_win) in vas_win_close()
1264 put_rx_win(window->rxwin); in vas_win_close()
1266 vas_window_free(window); in vas_win_close()
1273 * Return a system-wide unique window id for the window @win.