]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/vas: Define vas_win_id()
authorSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Wed, 8 Nov 2017 02:23:57 +0000 (18:23 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 11 Nov 2017 22:03:10 +0000 (09:03 +1100)
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 <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/vas.h
arch/powerpc/platforms/powernv/vas-window.c
arch/powerpc/platforms/powernv/vas.h

index f98ade8a2603228faefa71322cd38c9f17d04346..771456227496c5151e08e5acfe0fb5de39a22e1f 100644 (file)
@@ -167,6 +167,11 @@ int vas_copy_crb(void *crb, int offset);
  */
 int vas_paste_crb(struct vas_window *win, int offset, bool re);
 
+/*
+ * Return a system-wide unique id for the VAS window @win.
+ */
+extern u32 vas_win_id(struct vas_window *win);
+
 /*
  * Return the power bus paste address associated with @win so the caller
  * can map that address into their address space.
index d7d06533a1e9ba05faa1fe6cf5fe611909ed8e39..82754924c2bc0f992237c330e7fc682487293282 100644 (file)
@@ -1235,3 +1235,12 @@ int vas_win_close(struct vas_window *window)
        return 0;
 }
 EXPORT_SYMBOL_GPL(vas_win_close);
+
+/*
+ * Return a system-wide unique window id for the window @win.
+ */
+u32 vas_win_id(struct vas_window *win)
+{
+       return encode_pswid(win->vinst->vas_id, win->winid);
+}
+EXPORT_SYMBOL_GPL(vas_win_id);
index 756cbc5335bcff593981182a9708e275716468ef..ae0100fd35bbb4caa976e873fb92fa35061311e9 100644 (file)
@@ -447,4 +447,32 @@ static inline u64 read_hvwc_reg(struct vas_window *win,
        return in_be64(win->hvwc_map+reg);
 }
 
+/*
+ * Encode/decode the Partition Send Window ID (PSWID) for a window in
+ * a way that we can uniquely identify any window in the system. i.e.
+ * we should be able to locate the 'struct vas_window' given the PSWID.
+ *
+ *     Bits    Usage
+ *     0:7     VAS id (8 bits)
+ *     8:15    Unused, 0 (3 bits)
+ *     16:31   Window id (16 bits)
+ */
+static inline u32 encode_pswid(int vasid, int winid)
+{
+       u32 pswid = 0;
+
+       pswid |= vasid << (31 - 7);
+       pswid |= winid;
+
+       return pswid;
+}
+
+static inline void decode_pswid(u32 pswid, int *vasid, int *winid)
+{
+       if (vasid)
+               *vasid = pswid >> (31 - 7) & 0xFF;
+
+       if (winid)
+               *winid = pswid & 0xFFFF;
+}
 #endif /* _VAS_H */