Message ID | 1518234567-24869-2-git-send-email-sukadev@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [RESEND,1/4] powerpc/vas: Fix order of cleanup in debugfs dir | expand |
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> writes: > 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 <sukadev@linux.vnet.ibm.com> ... > diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c > index aebbe95..f83e27d8 100644 > --- a/arch/powerpc/platforms/powernv/vas.c > +++ b/arch/powerpc/platforms/powernv/vas.c > @@ -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
Michael Ellerman [mpe@ellerman.id.au] wrote: > Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> writes: > > > 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 <sukadev@linux.vnet.ibm.com> > ... > > diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c > > index aebbe95..f83e27d8 100644 > > --- a/arch/powerpc/platforms/powernv/vas.c > > +++ b/arch/powerpc/platforms/powernv/vas.c > > @@ -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. 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
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> writes: > Michael Ellerman [mpe@ellerman.id.au] wrote: >> Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> writes: >> >> > 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 <sukadev@linux.vnet.ibm.com> >> ... >> > diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c >> > index aebbe95..f83e27d8 100644 >> > --- a/arch/powerpc/platforms/powernv/vas.c >> > +++ b/arch/powerpc/platforms/powernv/vas.c >> > @@ -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. > > Well, when VAS is configured, init_vas_instance() expects the top level > "vas" debugfs dir to already be setup. OK. > 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. Yeah that looks like a good solution. cheers
diff --git a/arch/powerpc/platforms/powernv/vas-debug.c b/arch/powerpc/platforms/powernv/vas-debug.c index b4de4c6..e6e4067 100644 --- a/arch/powerpc/platforms/powernv/vas-debug.c +++ b/arch/powerpc/platforms/powernv/vas-debug.c @@ -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); +} diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c index aebbe95..f83e27d8 100644 --- a/arch/powerpc/platforms/powernv/vas.c +++ b/arch/powerpc/platforms/powernv/vas.c @@ -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); diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h index ae0100f..2645613 100644 --- a/arch/powerpc/platforms/powernv/vas.h +++ b/arch/powerpc/platforms/powernv/vas.h @@ -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);
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 <sukadev@linux.vnet.ibm.com> --- 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(-)