Commit 7bc6f71b authored by Haren Myneni's avatar Haren Myneni Committed by Michael Ellerman

powerpc/vas: Define and use common vas_window struct

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: default avatarHaren Myneni <haren@linux.ibm.com>
Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1698c35c158dfe52c6d2166667823d3d4a463353.camel@linux.ibm.com
parent 3b267973
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include <asm/icswx.h> #include <asm/icswx.h>
#include <uapi/asm/vas-api.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 * Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25
* (Local FIFO Size Register) of the VAS workbook. * (Local FIFO Size Register) of the VAS workbook.
...@@ -63,6 +61,18 @@ struct vas_user_win_ref { ...@@ -63,6 +61,18 @@ struct vas_user_win_ref {
struct mm_struct *mm; /* Linux process mm_struct */ 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 * User space window operations used for powernv and powerVM
*/ */
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/vas.h>
#include "vas.h" #include "vas.h"
static struct dentry *vas_debugfs; static struct dentry *vas_debugfs;
...@@ -28,7 +29,7 @@ static char *cop_to_str(int cop) ...@@ -28,7 +29,7 @@ static char *cop_to_str(int cop)
static int info_show(struct seq_file *s, void *private) 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); mutex_lock(&vas_mutex);
...@@ -36,9 +37,9 @@ static int info_show(struct seq_file *s, void *private) ...@@ -36,9 +37,9 @@ static int info_show(struct seq_file *s, void *private)
if (!window->hvwc_map) if (!window->hvwc_map)
goto unlock; 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"); 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: unlock:
mutex_unlock(&vas_mutex); mutex_unlock(&vas_mutex);
...@@ -47,7 +48,7 @@ static int info_show(struct seq_file *s, void *private) ...@@ -47,7 +48,7 @@ static int info_show(struct seq_file *s, void *private)
DEFINE_SHOW_ATTRIBUTE(info); 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) char *name, u32 reg)
{ {
seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name); seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);
...@@ -55,7 +56,7 @@ static inline void print_reg(struct seq_file *s, struct vas_window *win, ...@@ -55,7 +56,7 @@ static inline void print_reg(struct seq_file *s, struct vas_window *win,
static int hvwc_show(struct seq_file *s, void *private) 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); mutex_lock(&vas_mutex);
...@@ -103,8 +104,10 @@ static int hvwc_show(struct seq_file *s, void *private) ...@@ -103,8 +104,10 @@ static int hvwc_show(struct seq_file *s, void *private)
DEFINE_SHOW_ATTRIBUTE(hvwc); 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) { if (window->dbgdir) {
debugfs_remove_recursive(window->dbgdir); debugfs_remove_recursive(window->dbgdir);
kfree(window->dbgname); kfree(window->dbgname);
...@@ -113,21 +116,21 @@ void vas_window_free_dbgdir(struct vas_window *window) ...@@ -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; struct dentry *d;
if (!window->vinst->dbgdir) if (!window->vinst->dbgdir)
return; return;
window->dbgname = kzalloc(16, GFP_KERNEL); window->vas_win.dbgname = kzalloc(16, GFP_KERNEL);
if (!window->dbgname) if (!window->vas_win.dbgname)
return; 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); d = debugfs_create_dir(window->vas_win.dbgname, window->vinst->dbgdir);
window->dbgdir = d; window->vas_win.dbgdir = d;
debugfs_create_file("info", 0444, d, window, &info_fops); debugfs_create_file("info", 0444, d, window, &info_fops);
debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops); debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
......
...@@ -68,7 +68,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data) ...@@ -68,7 +68,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data)
struct vas_instance *vinst = data; struct vas_instance *vinst = data;
struct coprocessor_request_block *crb, *entry; struct coprocessor_request_block *crb, *entry;
struct coprocessor_request_block buf; struct coprocessor_request_block buf;
struct vas_window *window; struct pnv_vas_window *window;
unsigned long flags; unsigned long flags;
void *fifo; void *fifo;
...@@ -153,7 +153,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data) ...@@ -153,7 +153,7 @@ irqreturn_t vas_fault_thread_fn(int irq, void *data)
* NX sees faults only with user space windows. * NX sees faults only with user space windows.
*/ */
if (window->user_win) if (window->user_win)
vas_update_csb(crb, &window->task_ref); vas_update_csb(crb, &window->vas_win.task_ref);
else else
WARN_ON_ONCE(!window->user_win); WARN_ON_ONCE(!window->user_win);
...@@ -199,6 +199,7 @@ irqreturn_t vas_fault_handler(int irq, void *dev_id) ...@@ -199,6 +199,7 @@ irqreturn_t vas_fault_handler(int irq, void *dev_id)
int vas_setup_fault_window(struct vas_instance *vinst) int vas_setup_fault_window(struct vas_instance *vinst)
{ {
struct vas_rx_win_attr attr; struct vas_rx_win_attr attr;
struct vas_window *win;
vinst->fault_fifo_size = VAS_FAULT_WIN_FIFO_SIZE; vinst->fault_fifo_size = VAS_FAULT_WIN_FIFO_SIZE;
vinst->fault_fifo = kzalloc(vinst->fault_fifo_size, GFP_KERNEL); vinst->fault_fifo = kzalloc(vinst->fault_fifo_size, GFP_KERNEL);
...@@ -227,18 +228,17 @@ int vas_setup_fault_window(struct vas_instance *vinst) ...@@ -227,18 +228,17 @@ int vas_setup_fault_window(struct vas_instance *vinst)
attr.lnotify_pid = mfspr(SPRN_PID); attr.lnotify_pid = mfspr(SPRN_PID);
attr.lnotify_tid = mfspr(SPRN_PID); attr.lnotify_tid = mfspr(SPRN_PID);
vinst->fault_win = vas_rx_win_open(vinst->vas_id, VAS_COP_TYPE_FAULT, win = vas_rx_win_open(vinst->vas_id, VAS_COP_TYPE_FAULT, &attr);
&attr); if (IS_ERR(win)) {
pr_err("VAS: Error %ld opening FaultWin\n", PTR_ERR(win));
if (IS_ERR(vinst->fault_win)) {
pr_err("VAS: Error %ld opening FaultWin\n",
PTR_ERR(vinst->fault_win));
kfree(vinst->fault_fifo); 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", 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); attr.lnotify_pid, attr.lnotify_tid);
return 0; return 0;
......
...@@ -80,7 +80,7 @@ TRACE_EVENT( vas_tx_win_open, ...@@ -80,7 +80,7 @@ TRACE_EVENT( vas_tx_win_open,
TRACE_EVENT( vas_paste_crb, TRACE_EVENT( vas_paste_crb,
TP_PROTO(struct task_struct *tsk, TP_PROTO(struct task_struct *tsk,
struct vas_window *win), struct pnv_vas_window *win),
TP_ARGS(tsk, win), TP_ARGS(tsk, win),
...@@ -96,7 +96,7 @@ TRACE_EVENT( vas_paste_crb, ...@@ -96,7 +96,7 @@ TRACE_EVENT( vas_paste_crb,
TP_fast_assign( TP_fast_assign(
__entry->pid = tsk->pid; __entry->pid = tsk->pid;
__entry->vasid = win->vinst->vas_id; __entry->vasid = win->vinst->vas_id;
__entry->winid = win->winid; __entry->winid = win->vas_win.winid;
__entry->paste_kaddr = (unsigned long)win->paste_kaddr __entry->paste_kaddr = (unsigned long)win->paste_kaddr
), ),
......
This diff is collapsed.
...@@ -334,11 +334,11 @@ struct vas_instance { ...@@ -334,11 +334,11 @@ struct vas_instance {
int fifo_in_progress; /* To wake up thread or return IRQ_HANDLED */ int fifo_in_progress; /* To wake up thread or return IRQ_HANDLED */
spinlock_t fault_lock; /* Protects fifo_in_progress update */ spinlock_t fault_lock; /* Protects fifo_in_progress update */
void *fault_fifo; void *fault_fifo;
struct vas_window *fault_win; /* Fault window */ struct pnv_vas_window *fault_win; /* Fault window */
struct mutex mutex; struct mutex mutex;
struct vas_window *rxwin[VAS_COP_TYPE_MAX]; struct pnv_vas_window *rxwin[VAS_COP_TYPE_MAX];
struct vas_window *windows[VAS_WINDOWS_PER_CHIP]; struct pnv_vas_window *windows[VAS_WINDOWS_PER_CHIP];
char *name; char *name;
char *dbgname; char *dbgname;
...@@ -346,30 +346,24 @@ struct vas_instance { ...@@ -346,30 +346,24 @@ struct vas_instance {
}; };
/* /*
* In-kernel state a VAS window. One per window. * In-kernel state a VAS window on PowerNV. One per window.
*/ */
struct vas_window { struct pnv_vas_window {
struct vas_window vas_win;
/* Fields common to send and receive windows */ /* Fields common to send and receive windows */
struct vas_instance *vinst; struct vas_instance *vinst;
int winid;
bool tx_win; /* True if send window */ bool tx_win; /* True if send window */
bool nx_win; /* True if NX window */ bool nx_win; /* True if NX window */
bool user_win; /* True if user space window */ bool user_win; /* True if user space window */
void *hvwc_map; /* HV window context */ void *hvwc_map; /* HV window context */
void *uwc_map; /* OS/User window context */ void *uwc_map; /* OS/User window context */
int wcreds_max; /* Window credits */
struct vas_user_win_ref task_ref;
char *dbgname;
struct dentry *dbgdir;
/* Fields applicable only to send windows */ /* Fields applicable only to send windows */
void *paste_kaddr; void *paste_kaddr;
char *paste_addr_name; char *paste_addr_name;
struct vas_window *rxwin; struct pnv_vas_window *rxwin;
/* Feilds applicable only to receive windows */ /* Fields applicable only to receive windows */
enum vas_cop_type cop;
atomic_t num_txwins; atomic_t num_txwins;
}; };
...@@ -428,15 +422,15 @@ extern struct mutex vas_mutex; ...@@ -428,15 +422,15 @@ extern struct mutex vas_mutex;
extern struct vas_instance *find_vas_instance(int vasid); extern struct vas_instance *find_vas_instance(int vasid);
extern void vas_init_dbgdir(void); extern void vas_init_dbgdir(void);
extern void vas_instance_init_dbgdir(struct vas_instance *vinst); extern void vas_instance_init_dbgdir(struct vas_instance *vinst);
extern void vas_window_init_dbgdir(struct vas_window *win); extern void vas_window_init_dbgdir(struct pnv_vas_window *win);
extern void vas_window_free_dbgdir(struct vas_window *win); extern void vas_window_free_dbgdir(struct pnv_vas_window *win);
extern int vas_setup_fault_window(struct vas_instance *vinst); extern int vas_setup_fault_window(struct vas_instance *vinst);
extern irqreturn_t vas_fault_thread_fn(int irq, void *data); extern irqreturn_t vas_fault_thread_fn(int irq, void *data);
extern irqreturn_t vas_fault_handler(int irq, void *dev_id); extern irqreturn_t vas_fault_handler(int irq, void *dev_id);
extern void vas_return_credit(struct vas_window *window, bool tx); extern void vas_return_credit(struct pnv_vas_window *window, bool tx);
extern struct vas_window *vas_pswid_to_window(struct vas_instance *vinst, extern struct pnv_vas_window *vas_pswid_to_window(struct vas_instance *vinst,
uint32_t pswid); uint32_t pswid);
extern void vas_win_paste_addr(struct vas_window *window, u64 *addr, extern void vas_win_paste_addr(struct pnv_vas_window *window, u64 *addr,
int *len); int *len);
static inline int vas_window_pid(struct vas_window *window) static inline int vas_window_pid(struct vas_window *window)
...@@ -444,16 +438,16 @@ static inline int vas_window_pid(struct vas_window *window) ...@@ -444,16 +438,16 @@ static inline int vas_window_pid(struct vas_window *window)
return pid_vnr(window->task_ref.pid); return pid_vnr(window->task_ref.pid);
} }
static inline void vas_log_write(struct vas_window *win, char *name, static inline void vas_log_write(struct pnv_vas_window *win, char *name,
void *regptr, u64 val) void *regptr, u64 val)
{ {
if (val) if (val)
pr_debug("%swin #%d: %s reg %p, val 0x%016llx\n", pr_debug("%swin #%d: %s reg %p, val 0x%016llx\n",
win->tx_win ? "Tx" : "Rx", win->winid, name, win->tx_win ? "Tx" : "Rx", win->vas_win.winid,
regptr, val); name, regptr, val);
} }
static inline void write_uwc_reg(struct vas_window *win, char *name, static inline void write_uwc_reg(struct pnv_vas_window *win, char *name,
s32 reg, u64 val) s32 reg, u64 val)
{ {
void *regptr; void *regptr;
...@@ -464,7 +458,7 @@ static inline void write_uwc_reg(struct vas_window *win, char *name, ...@@ -464,7 +458,7 @@ static inline void write_uwc_reg(struct vas_window *win, char *name,
out_be64(regptr, val); out_be64(regptr, val);
} }
static inline void write_hvwc_reg(struct vas_window *win, char *name, static inline void write_hvwc_reg(struct pnv_vas_window *win, char *name,
s32 reg, u64 val) s32 reg, u64 val)
{ {
void *regptr; void *regptr;
...@@ -475,7 +469,7 @@ static inline void write_hvwc_reg(struct vas_window *win, char *name, ...@@ -475,7 +469,7 @@ static inline void write_hvwc_reg(struct vas_window *win, char *name,
out_be64(regptr, val); out_be64(regptr, val);
} }
static inline u64 read_hvwc_reg(struct vas_window *win, static inline u64 read_hvwc_reg(struct pnv_vas_window *win,
char *name __maybe_unused, s32 reg) char *name __maybe_unused, s32 reg)
{ {
return in_be64(win->hvwc_map+reg); return in_be64(win->hvwc_map+reg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment