linux/arch/powerpc/platforms
Haren Myneni 0cf72f7f14 powerpc/pseries/vas: Migration suspend waits for no in-progress open windows
The hypervisor returns migration failure if all VAS windows are not
closed. During pre-migration stage, vas_migration_handler() sets
migration_in_progress flag and closes all windows from the list.
The allocate VAS window routine checks the migration flag, setup
the window and then add it to the list. So there is possibility of
the migration handler missing the window that is still in the
process of setup.

t1: Allocate and open VAS	t2: Migration event
    window

lock vas_pseries_mutex
If migration_in_progress set
  unlock vas_pseries_mutex
  return
open window HCALL
unlock vas_pseries_mutex
Modify window HCALL		lock vas_pseries_mutex
setup window			migration_in_progress=true
				Closes all windows from the list
				// May miss windows that are
				// not in the list
				unlock vas_pseries_mutex
lock vas_pseries_mutex		return
if nr_closed_windows == 0
  // No DLPAR CPU or migration
  add window to the list
  // Window will be added to the
  // list after the setup is completed
  unlock vas_pseries_mutex
  return
unlock vas_pseries_mutex
Close VAS window
// due to DLPAR CPU or migration
return -EBUSY

This patch resolves the issue with the following steps:
- Set the migration_in_progress flag without holding mutex.
- Introduce nr_open_wins_progress counter in VAS capabilities
  struct
- This counter tracks the number of open windows are still in
  progress
- The allocate setup window thread closes windows if the migration
  is set and decrements nr_open_window_progress counter
- The migration handler waits for no in-progress open windows.

The code flow with the fix is as follows:

t1: Allocate and open VAS       t2: Migration event
    window

lock vas_pseries_mutex
If migration_in_progress set
   unlock vas_pseries_mutex
   return
open window HCALL
nr_open_wins_progress++
// Window opened, but not
// added to the list yet
unlock vas_pseries_mutex
Modify window HCALL		migration_in_progress=true
setup window			lock vas_pseries_mutex
				Closes all windows from the list
				While nr_open_wins_progress {
				    unlock vas_pseries_mutex
lock vas_pseries_mutex		    sleep
if nr_closed_windows == 0	    // Wait if any open window in
or migration is not started	    // progress. The open window
   // No DLPAR CPU or migration	    // thread closes the window without
   add window to the list	    // adding to the list and return if
   nr_open_wins_progress--	    // the migration is in progress.
   unlock vas_pseries_mutex
   return
Close VAS window
nr_open_wins_progress--
unlock vas_pseries_mutex
return -EBUSY			    lock vas_pseries_mutex
				}
				unlock vas_pseries_mutex
				return

Fixes: 37e6764895 ("powerpc/pseries/vas: Add VAS migration handler")
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231125235104.3405008-1-haren@linux.ibm.com
2023-12-13 22:01:47 +11:00
..
4xx powerpc: Use NULL instead of 0 for null pointers 2023-10-19 17:12:47 +11:00
8xx powerpc: Untangle fixmap.h and pgtable.h and mmu.h 2023-10-19 17:12:44 +11:00
40x powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
44x powerpc/4xx: Remove pika_dtm_[un]register_shutdown() to fix no previous prototype 2023-08-18 17:03:14 +10:00
52xx powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
82xx powerpc/82xx: Select FSL_SOC 2023-09-18 12:23:48 +10:00
83xx powerpc: Untangle fixmap.h and pgtable.h and mmu.h 2023-10-19 17:12:44 +11:00
85xx powerpc updates for 6.6 2023-08-31 12:43:10 -07:00
86xx powerpc: address missing-prototypes warnings 2023-08-02 22:22:19 +10:00
512x powerpc/512x: Make mpc512x_select_reset_compat() static 2023-08-18 17:02:40 +10:00
amigaone powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
book3s powerpc/vas: Limit open window failure messages in log bufffer 2023-10-20 17:10:03 +11:00
cell vfs-6.7.ctime 2023-10-30 09:47:13 -10:00
chrp powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
embedded6xx powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
maple powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
microwatt powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
pasemi powerpc: address missing-prototypes warnings 2023-08-02 22:22:19 +10:00
powermac powerpc: Annotate endianness of various variables and functions 2023-10-19 17:12:47 +11:00
powernv powerpc/fadump: Annotate endianness cast with __force 2023-10-19 17:16:20 +11:00
ps3 powerpc/ps3: refactor strncpy usage 2023-08-18 11:48:42 +10:00
pseries powerpc/pseries/vas: Migration suspend waits for no in-progress open windows 2023-12-13 22:01:47 +11:00
fsl_uli1575.c powerpc/fsl_uli1575: Mark uli_exclude_device() as static 2023-04-20 10:20:50 +10:00
Kconfig powerpc/82xx: Remove CONFIG_8260 and CONFIG_8272 2023-08-18 17:03:14 +10:00
Kconfig.cputype powerpc updates for 6.6 2023-08-31 12:43:10 -07:00
Makefile powerpc: Add Microwatt platform 2021-06-21 21:15:26 +10:00