Skip to content

Commit

Permalink
powerpc/vas: Define and use common vas_window struct
Browse files Browse the repository at this point in the history
Many elements in vas_struct are used on PowerNV and PowerVM
platforms. vas_window is used for both TX and RX windows on
PowerNV and for TX windows on PowerVM. So some elements are
specific to these platforms.

So this patch defines common vas_window and platform
specific window structs (pnv_vas_window on PowerNV). Also adds
the corresponding changes in PowerNV vas code.

Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1698c35c158dfe52c6d2166667823d3d4a463353.camel@linux.ibm.com
  • Loading branch information
Haren Myneni authored and Michael Ellerman committed Jun 20, 2021
1 parent 3b26797 commit 7bc6f71
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 126 deletions.
14 changes: 12 additions & 2 deletions arch/powerpc/include/asm/vas.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <asm/icswx.h>
#include <uapi/asm/vas-api.h>

struct vas_window;

/*
* Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25
* (Local FIFO Size Register) of the VAS workbook.
Expand Down Expand Up @@ -63,6 +61,18 @@ struct vas_user_win_ref {
struct mm_struct *mm; /* Linux process mm_struct */
};

/*
* Common VAS window struct on PowerNV and PowerVM
*/
struct vas_window {
u32 winid;
u32 wcreds_max; /* Window credits */
enum vas_cop_type cop;
struct vas_user_win_ref task_ref;
char *dbgname;
struct dentry *dbgdir;
};

/*
* User space window operations used for powernv and powerVM
*/
Expand Down
27 changes: 15 additions & 12 deletions arch/powerpc/platforms/powernv/vas-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/slab.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <asm/vas.h>
#include "vas.h"

static struct dentry *vas_debugfs;
Expand All @@ -28,17 +29,17 @@ static char *cop_to_str(int cop)

static int info_show(struct seq_file *s, void *private)
{
struct vas_window *window = s->private;
struct pnv_vas_window *window = s->private;

mutex_lock(&vas_mutex);

/* ensure window is not unmapped */
if (!window->hvwc_map)
goto unlock;

seq_printf(s, "Type: %s, %s\n", cop_to_str(window->cop),
seq_printf(s, "Type: %s, %s\n", cop_to_str(window->vas_win.cop),
window->tx_win ? "Send" : "Receive");
seq_printf(s, "Pid : %d\n", vas_window_pid(window));
seq_printf(s, "Pid : %d\n", vas_window_pid(&window->vas_win));

unlock:
mutex_unlock(&vas_mutex);
Expand All @@ -47,15 +48,15 @@ static int info_show(struct seq_file *s, void *private)

DEFINE_SHOW_ATTRIBUTE(info);

static inline void print_reg(struct seq_file *s, struct vas_window *win,
static inline void print_reg(struct seq_file *s, struct pnv_vas_window *win,
char *name, u32 reg)
{
seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);
}

static int hvwc_show(struct seq_file *s, void *private)
{
struct vas_window *window = s->private;
struct pnv_vas_window *window = s->private;

mutex_lock(&vas_mutex);

Expand Down Expand Up @@ -103,8 +104,10 @@ static int hvwc_show(struct seq_file *s, void *private)

DEFINE_SHOW_ATTRIBUTE(hvwc);

void vas_window_free_dbgdir(struct vas_window *window)
void vas_window_free_dbgdir(struct pnv_vas_window *pnv_win)
{
struct vas_window *window = &pnv_win->vas_win;

if (window->dbgdir) {
debugfs_remove_recursive(window->dbgdir);
kfree(window->dbgname);
Expand All @@ -113,21 +116,21 @@ void vas_window_free_dbgdir(struct vas_window *window)
}
}

void vas_window_init_dbgdir(struct vas_window *window)
void vas_window_init_dbgdir(struct pnv_vas_window *window)
{
struct dentry *d;

if (!window->vinst->dbgdir)
return;

window->dbgname = kzalloc(16, GFP_KERNEL);
if (!window->dbgname)
window->vas_win.dbgname = kzalloc(16, GFP_KERNEL);
if (!window->vas_win.dbgname)
return;

snprintf(window->dbgname, 16, "w%d", window->winid);
snprintf(window->vas_win.dbgname, 16, "w%d", window->vas_win.winid);

d = debugfs_create_dir(window->dbgname, window->vinst->dbgdir);
window->dbgdir = d;
d = debugfs_create_dir(window->vas_win.dbgname, window->vinst->dbgdir);
window->vas_win.dbgdir = d;

debugfs_create_file("info", 0444, d, window, &info_fops);
debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
Expand Down
20 changes: 10 additions & 10 deletions arch/powerpc/platforms/powernv/vas-fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data)
struct vas_instance *vinst = data;
struct coprocessor_request_block *crb, *entry;
struct coprocessor_request_block buf;
struct vas_window *window;
struct pnv_vas_window *window;
unsigned long flags;
void *fifo;

Expand Down Expand Up @@ -153,7 +153,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data)
* NX sees faults only with user space windows.
*/
if (window->user_win)
vas_update_csb(crb, &window->task_ref);
vas_update_csb(crb, &window->vas_win.task_ref);
else
WARN_ON_ONCE(!window->user_win);

Expand Down Expand Up @@ -199,6 +199,7 @@ irqreturn_t vas_fault_handler(int irq, void *dev_id)
int vas_setup_fault_window(struct vas_instance *vinst)
{
struct vas_rx_win_attr attr;
struct vas_window *win;

vinst->fault_fifo_size = VAS_FAULT_WIN_FIFO_SIZE;
vinst->fault_fifo = kzalloc(vinst->fault_fifo_size, GFP_KERNEL);
Expand Down Expand Up @@ -227,18 +228,17 @@ int vas_setup_fault_window(struct vas_instance *vinst)
attr.lnotify_pid = mfspr(SPRN_PID);
attr.lnotify_tid = mfspr(SPRN_PID);

vinst->fault_win = vas_rx_win_open(vinst->vas_id, VAS_COP_TYPE_FAULT,
&attr);

if (IS_ERR(vinst->fault_win)) {
pr_err("VAS: Error %ld opening FaultWin\n",
PTR_ERR(vinst->fault_win));
win = vas_rx_win_open(vinst->vas_id, VAS_COP_TYPE_FAULT, &attr);
if (IS_ERR(win)) {
pr_err("VAS: Error %ld opening FaultWin\n", PTR_ERR(win));
kfree(vinst->fault_fifo);
return PTR_ERR(vinst->fault_win);
return PTR_ERR(win);
}

vinst->fault_win = container_of(win, struct pnv_vas_window, vas_win);

pr_devel("VAS: Created FaultWin %d, LPID/PID/TID [%d/%d/%d]\n",
vinst->fault_win->winid, attr.lnotify_lpid,
vinst->fault_win->vas_win.winid, attr.lnotify_lpid,
attr.lnotify_pid, attr.lnotify_tid);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/powernv/vas-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ TRACE_EVENT( vas_tx_win_open,
TRACE_EVENT( vas_paste_crb,

TP_PROTO(struct task_struct *tsk,
struct vas_window *win),
struct pnv_vas_window *win),

TP_ARGS(tsk, win),

Expand All @@ -96,7 +96,7 @@ TRACE_EVENT( vas_paste_crb,
TP_fast_assign(
__entry->pid = tsk->pid;
__entry->vasid = win->vinst->vas_id;
__entry->winid = win->winid;
__entry->winid = win->vas_win.winid;
__entry->paste_kaddr = (unsigned long)win->paste_kaddr
),

Expand Down
Loading

0 comments on commit 7bc6f71

Please sign in to comment.