powerpc/vas: Fix order of cleanup in debugfs dir
PATCH RESEND 1/4 powerpc/vas: Fix order of cleanup in debugfs dir
Fix the order of cleanup to ensure we free the name buffer in case of an error creating 'hvwc' or 'info' files.
--- arch/powerpc/platforms/powernv/vas-debug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/vas-debug.c +4 -4
@@ -166,13 +166,13 @@ void vas_window_init_dbgdir(struct vas_window *window)return ; -free_name: -kfree (window->dbgname); - window->dbgname =NULL ; - remove_dir:debugfs_remove_recursive (window->dbgdir); window->dbgdir =NULL ; + +free_name: +kfree (window->dbgname); + window->dbgname =NULL ; }void vas_instance_init_dbgdir (struct vas_instance *vinst)
Signature · 1 line
2.7.4
PATCH 2/4 powerpc/vas: Fix cleanup when VAS is not configured
When VAS is not configured in the system, make sure to remove the VAS debugfs directory and unregister the platform driver.
--- arch/powerpc/platforms/powernv/vas-debug.c | 5 +++++ arch/powerpc/platforms/powernv/vas.c | 5 ++++- arch/powerpc/platforms/powernv/vas.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/vas-debug.c +5 -0
@@ -207,3 +207,8 @@ void vas_init_dbgdir(void)if (IS_ERR (vas_debugfs)) vas_debugfs =NULL ; } + +void vas_cleanup_dbgdir (void ) +{ +debugfs_remove_recursive (vas_debugfs); +}
arch/powerpc/platforms/powernv/vas.c +4 -1
@@ -169,8 +169,11 @@ static int __init vas_init(void) found++; } -if (!found) +if (!found) { +platform_driver_unregister (&vas_driver); +vas_cleanup_dbgdir ();return -ENODEV ; + }pr_devel ("Found %d instances\n" , found);
arch/powerpc/platforms/powernv/vas.h +1 -0
@@ -406,6 +406,7 @@ extern struct mutex vas_mutex;extern struct vas_instance *find_vas_instance (int vasid);extern void vas_init_dbgdir (void ); +extern void vas_cleanup_dbgdir (void );extern void vas_instance_init_dbgdir (struct vas_instance *vinst);extern void vas_window_init_dbgdir (struct vas_window *win);extern void vas_window_free_dbgdir (struct vas_window *win);
Signature · 1 line
2.7.4
Michael Ellerman
reviewerRe: [PATCH 2/4] powerpc/vas: Fix cleanup when VAS is not configured
Quoted 4 lines · Sukadev Bhattiprolu
When VAS is not configured in the system, make sure to remove the VAS debugfs directory and unregister the platform driver.
Signed-off-by Sukadev Bhattiprolu <[email protected]>
...
Quoted 5 lines
arch/powerpc/platforms/powernv/vas.c +0
-0
arch/powerpc/platforms/powernv/vas.c static int __init vas_init(void) · line 176
Quoted 9 lines
arch/powerpc/platforms/powernv/vas.c +4
-1@@ -169,8 +169,11 @@ static int __init vas_init(void) found++; } -if (!found) +if (!found) { +platform_driver_unregister (&vas_driver); +vas_cleanup_dbgdir ();return -ENODEV ; + }
The better patch would be to move the call to vas_init_dbgdir() down here, where we know we have successfully registered the driver.
cheers
Re: [PATCH 2/4] powerpc/vas: Fix cleanup when VAS is not configured
Quoted 15 lines · Michael Ellerman [[email protected]] wrote:
Quoted 4 lines · Sukadev Bhattiprolu
When VAS is not configured in the system, make sure to remove the VAS debugfs directory and unregister the platform driver.
Signed-off-by Sukadev Bhattiprolu <[email protected]>...
Quoted 8 lines
arch/powerpc/platforms/powernv/vas.c +0
-0@@ -169,8 +169,11 @@ static int __init vas_init(void) found++; }
Quoted 9 lines
arch/powerpc/platforms/powernv/vas.c static int __init vas_init(void) · line 176
Quoted 6 lines
arch/powerpc/platforms/powernv/vas.c +4
-1-if (!found) +if (!found) { +platform_driver_unregister (&vas_driver); +vas_cleanup_dbgdir ();return -ENODEV ; + }The better patch would be to move the call to
vas_init_dbgdir()down here, where we know we have successfully registered the driver.
Well, when VAS is configured, init_vas_instance() expects the top level "vas" debugfs dir to already be setup.
We could have each init_vas_instance() assume it is the first and unconditionally call vas_init_dbgdir(). vas_init_dbgdir() could make sure to initialize only once.
Or, we could make a separate pass countng "ibm,vas" nodes. If there are none, skip both steps (dbgdir and registering platform driver).
Sukadev
Michael Ellerman
reviewerRe: [PATCH 2/4] powerpc/vas: Fix cleanup when VAS is not configured
Quoted 26 lines · Sukadev Bhattiprolu
Quoted 15 lines · Michael Ellerman [[email protected]] wrote:
Quoted 4 lines · Sukadev Bhattiprolu
When VAS is not configured in the system, make sure to remove the VAS debugfs directory and unregister the platform driver.
Signed-off-by Sukadev Bhattiprolu <[email protected]>...
Quoted 8 lines
arch/powerpc/platforms/powernv/vas.c +0
-0@@ -169,8 +169,11 @@ static int __init vas_init(void) found++; }Quoted 9 lines
arch/powerpc/platforms/powernv/vas.c static int __init vas_init(void) · line 176
Quoted 6 lines
arch/powerpc/platforms/powernv/vas.c +4
-1-if (!found) +if (!found) { +platform_driver_unregister (&vas_driver); +vas_cleanup_dbgdir ();return -ENODEV ; + }The better patch would be to move the call to
vas_init_dbgdir()down here, where we know we have successfully registered the driver.
Quoted 2 lines
Well, when VAS is configured,
init_vas_instance()expects the top level "vas" debugfs dir to already be setup.
OK.
Quoted 3 lines
We could have each
init_vas_instance()assume it is the first and unconditionally callvas_init_dbgdir().vas_init_dbgdir()could make sure to initialize only once.
Yeah that looks like a good solution.
cheers
PATCH RESEND 3/4 powerpc/vas: Remove a stray line in Makefile
In reply to Sukadev BhattiproluRemove a bogus line from arch/powerpc/platforms/powernv/Makefile that was added by commit ece4e51 ("powerpc/vas: Export HVWC to debugfs").
--- arch/powerpc/platforms/powernv/Makefile | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/platforms/powernv/Makefile +0 -1
@@ -16,5 +16,4 @@ obj-$(CONFIG_OPAL_PRD) += opal-prd.o obj-$(CONFIG_PERF_EVENTS) += opal-imc.o obj-$(CONFIG_PPC_MEMTRACE) += memtrace.o obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o vas-debug.o -obj-$(CONFIG_PPC_FTW) += nx-ftw.o obj-$(CONFIG_OCXL_BASE) += ocxl.o
Signature · 1 line
2.7.4
PATCH 4/4 powerpc/vas: Add a couple of trace points
In reply to Sukadev BhattiproluAdd a couple of trace points in the VAS driver
---
Changelog [v2]
- Make TRACE_INCLUDE_PATH relative to <trace/define_trace.h>
--- arch/powerpc/platforms/powernv/vas-trace.h | 112 ++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/vas-window.c | 9 +++ 2 files changed, 121 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/vas-trace.h
arch/powerpc/platforms/powernv/vas-trace.h new file +112 -0
@@ -0,0 +1,112 @@ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM vas + +#if !defined(_VAS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) + +#define _VAS_TRACE_H +#include <linux/tracepoint.h> +#include <linux/sched.h> +#include <asm/vas.h> + +TRACE_EVENT ( vas_rx_win_open, + + TP_PROTO(struct task_struct *tsk, + int vasid, + int cop, + struct vas_rx_win_attr *rxattr), + +TP_ARGS (tsk, vasid, cop, rxattr), + +TP_STRUCT__entry ( + __field(struct task_struct *, tsk) + __field(int, pid) + __field(int, cop) + __field(int, vasid) + __field(struct vas_rx_win_attr *, rxattr) + __field(int, lnotify_lpid) + __field(int, lnotify_pid) +__field (int, lnotify_tid) + ), + +TP_fast_assign ( + __entry->pid = tsk->pid; + __entry->vasid = vasid; + __entry->cop = cop; + __entry->lnotify_lpid = rxattr->lnotify_lpid; + __entry->lnotify_pid = rxattr->lnotify_pid; + __entry->lnotify_tid = rxattr->lnotify_tid; + ), + +TP_printk ("pid=%d, vasid=%d, cop=%d, lpid=%d, pid=%d, tid=%d" , + __entry->pid, __entry->vasid, __entry->cop, + __entry->lnotify_lpid, __entry->lnotify_pid, + __entry->lnotify_tid) +); + +TRACE_EVENT ( vas_tx_win_open, + + TP_PROTO(struct task_struct *tsk, + int vasid, + int cop, + struct vas_tx_win_attr *txattr), + +TP_ARGS (tsk, vasid, cop, txattr), + +TP_STRUCT__entry ( + __field(struct task_struct *, tsk) + __field(int, pid) + __field(int, cop) + __field(int, vasid) + __field(struct vas_tx_win_attr *, txattr) + __field(int, lpid) +__field (int, pidr) + ), + +TP_fast_assign ( + __entry->pid = tsk->pid; + __entry->vasid = vasid; + __entry->cop = cop; + __entry->lpid = txattr->lpid; + __entry->pidr = txattr->pidr; + ), + +TP_printk ("pid=%d, vasid=%d, cop=%d, lpid=%d, pidr=%d" , + __entry->pid, __entry->vasid, __entry->cop, + __entry->lpid, __entry->pidr) +); + +TRACE_EVENT ( vas_paste_crb, + + TP_PROTO(struct task_struct *tsk, + struct vas_window *win), + +TP_ARGS (tsk, win), + +TP_STRUCT__entry ( + __field(struct task_struct *, tsk) + __field(struct vas_window *, win) + __field(int, pid) + __field(int, vasid) + __field(int, winid) + __field(unsigned long, paste_kaddr) + ), + +TP_fast_assign ( + __entry->pid = tsk->pid; + __entry->vasid = win->vinst->vas_id; + __entry->winid = win->winid; + __entry->paste_kaddr = (unsigned long )win->paste_kaddr + ), + +TP_printk ("pid=%d, vasid=%d, winid=%d, paste_kaddr=0x%016lx\n" , + __entry->pid, __entry->vasid, __entry->winid, + __entry->paste_kaddr) +); + +#endif /* _VAS_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../arch/powerpc/platforms/powernv +#define TRACE_INCLUDE_FILE vas-trace +#include <trace/define_trace.h>
arch/powerpc/platforms/powernv/vas-window.c +9 -0
@@ -21,6 +21,9 @@#include "vas.h" #include "copy-paste.h" +#define CREATE_TRACE_POINTS +#include "vas-trace.h" +/* * Compute the paste address region for the window @window using the * ->paste_base_addr and ->paste_win_id_shift we got from device tree.
@@ -880,6 +883,8 @@ struct vas_window *vas_rx_win_open(int vasid, enum vas_cop_type cop,struct vas_winctx winctx;struct vas_instance *vinst; +trace_vas_rx_win_open (current, vasid, cop, rxattr); +if (!rx_win_args_valid (cop, rxattr))return ERR_PTR (-EINVAL );
@@ -1008,6 +1013,8 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,struct vas_winctx winctx;struct vas_instance *vinst; +trace_vas_tx_win_open (current, vasid, cop, attr); +if (!tx_win_args_valid (cop, attr))return ERR_PTR (-EINVAL );
@@ -1100,6 +1107,8 @@ int vas_paste_crb(struct vas_window *txwin, int offset, bool re)void *addr;uint64_t val; +trace_vas_paste_crb (current, txwin); +/* * Only NX windows are supported for now and hardware assumes * report-enable flag is set for NX windows. Ensure software
Signature · 1 line
2.7.4
Michael Ellerman
AppliedRe: [4/4] powerpc/vas: Add a couple of trace points
Quoted 3 lines · Sukadev Bhattiprolu
Add a couple of trace points in the VAS driver
Signed-off-by Sukadev Bhattiprolu <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/007bb7d6c77ef2243dabf9c4132afa
cheers