Skip to content

Commit 61f3cca

Browse files
Sukadev Bhattiprolumpe
authored andcommitted
powerpc/vas: Define vas_win_id()
Define an interface to return a system-wide unique id for a given VAS window. The vas_win_id() will be used in a follow-on patch to generate an unique handle for a user space receive window. Applications can use this handle to pair send and receive windows for fast thread-wakeup. The hardware refers to this system-wide unique id as a Partition Send Window ID which is expected to be used during fault handling. Hence the "pswid" in the function names. Signed-off-by: Sukadev Bhattiprolu <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 5676be2 commit 61f3cca

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

arch/powerpc/include/asm/vas.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ int vas_copy_crb(void *crb, int offset);
167167
*/
168168
int vas_paste_crb(struct vas_window *win, int offset, bool re);
169169

170+
/*
171+
* Return a system-wide unique id for the VAS window @win.
172+
*/
173+
extern u32 vas_win_id(struct vas_window *win);
174+
170175
/*
171176
* Return the power bus paste address associated with @win so the caller
172177
* can map that address into their address space.

arch/powerpc/platforms/powernv/vas-window.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,3 +1235,12 @@ int vas_win_close(struct vas_window *window)
12351235
return 0;
12361236
}
12371237
EXPORT_SYMBOL_GPL(vas_win_close);
1238+
1239+
/*
1240+
* Return a system-wide unique window id for the window @win.
1241+
*/
1242+
u32 vas_win_id(struct vas_window *win)
1243+
{
1244+
return encode_pswid(win->vinst->vas_id, win->winid);
1245+
}
1246+
EXPORT_SYMBOL_GPL(vas_win_id);

arch/powerpc/platforms/powernv/vas.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,32 @@ static inline u64 read_hvwc_reg(struct vas_window *win,
447447
return in_be64(win->hvwc_map+reg);
448448
}
449449

450+
/*
451+
* Encode/decode the Partition Send Window ID (PSWID) for a window in
452+
* a way that we can uniquely identify any window in the system. i.e.
453+
* we should be able to locate the 'struct vas_window' given the PSWID.
454+
*
455+
* Bits Usage
456+
* 0:7 VAS id (8 bits)
457+
* 8:15 Unused, 0 (3 bits)
458+
* 16:31 Window id (16 bits)
459+
*/
460+
static inline u32 encode_pswid(int vasid, int winid)
461+
{
462+
u32 pswid = 0;
463+
464+
pswid |= vasid << (31 - 7);
465+
pswid |= winid;
466+
467+
return pswid;
468+
}
469+
470+
static inline void decode_pswid(u32 pswid, int *vasid, int *winid)
471+
{
472+
if (vasid)
473+
*vasid = pswid >> (31 - 7) & 0xFF;
474+
475+
if (winid)
476+
*winid = pswid & 0xFFFF;
477+
}
450478
#endif /* _VAS_H */

0 commit comments

Comments
 (0)