devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/14] Revert "powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions"
@ 2019-11-27  1:03 Haren Myneni
  2019-11-27  8:28 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Haren Myneni @ 2019-11-27  1:03 UTC (permalink / raw)
  To: linuxppc-dev, devicetree, mpe, npiggin, mikey, herbert; +Cc: sukadev, hbabu


This reverts commit 452d23c0f6bd97f2fd8a9691fee79b76040a0feb.

User space send windows (NX GZIP compression) need vas_win_paste_addr()
to mmap window paste address and vas_win_id() to get window ID when
window address is given.

Added vas_win_id() and vas_win_paste_addr() with:
commit 61f3cca8cda97 ("powerpc/vas: Define vas_win_id()")
commit 5676be2fb7035 ("powerpc/vas: Define vas_win_paste_addr()")

Signed-off-by:Haren Myneni <haren@us.ibm.com>
---
 arch/powerpc/include/asm/vas.h              | 10 ++++++++++
 arch/powerpc/platforms/powernv/vas-window.c | 19 +++++++++++++++++++
 arch/powerpc/platforms/powernv/vas.h        | 20 ++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index f93e6b0..da0b198 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -163,4 +163,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
  */
 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.
+ */
+extern u64 vas_win_paste_addr(struct vas_window *win);
 #endif /* __ASM_POWERPC_VAS_H */
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index 0c0d27d..ea5ca02 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -40,6 +40,16 @@ static void compute_paste_address(struct vas_window *window, u64 *addr, int *len
 	pr_debug("Txwin #%d: Paste addr 0x%llx\n", winid, *addr);
 }
 
+u64 vas_win_paste_addr(struct vas_window *win)
+{
+	u64 addr;
+
+	compute_paste_address(win, &addr, NULL);
+
+	return addr;
+}
+EXPORT_SYMBOL(vas_win_paste_addr);
+
 static inline void get_hvwc_mmio_bar(struct vas_window *window,
 			u64 *start, int *len)
 {
@@ -1254,3 +1264,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);
diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h
index 5574aec..9cc5251 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -444,6 +444,26 @@ 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)
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 02/14] Revert "powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions"
  2019-11-27  1:03 [PATCH 02/14] Revert "powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions" Haren Myneni
@ 2019-11-27  8:28 ` Christoph Hellwig
       [not found]   ` <OF14D260BC.48F4C927-ON002584BF.00332A80-882584BF.00335313@notes.na.collabserv.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2019-11-27  8:28 UTC (permalink / raw)
  To: Haren Myneni
  Cc: linuxppc-dev, devicetree, mpe, npiggin, mikey, herbert, sukadev

On Tue, Nov 26, 2019 at 05:03:27PM -0800, Haren Myneni wrote:
> 
> This reverts commit 452d23c0f6bd97f2fd8a9691fee79b76040a0feb.
> 
> User space send windows (NX GZIP compression) need vas_win_paste_addr()
> to mmap window paste address and vas_win_id() to get window ID when
> window address is given.

Even with your full series applied vas_win_paste_addr is entirely
unused, and vas_win_id is only used once in the same file it is defined.

So instead of this patch you should just open code vas_win_id in
init_winctx_for_txwin.

> +static inline u32 encode_pswid(int vasid, int winid)
> +{
> +	u32 pswid = 0;
> +
> +	pswid |= vasid << (31 - 7);
> +	pswid |= winid;
> +
> +	return pswid;

This can be simplified down to:

	return (u32)winid | (vasid << (31 - 7));

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 02/14] Revert "powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions"
       [not found]   ` <OF14D260BC.48F4C927-ON002584BF.00332A80-882584BF.00335313@notes.na.collabserv.com>
@ 2019-11-27  9:31     ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-11-27  9:31 UTC (permalink / raw)
  To: Haren Myneni
  Cc: Christoph Hellwig, devicetree, Haren Myneni, herbert,
	linuxppc-dev, Linuxppc-dev, mikey, npiggin, sukadev

On Wed, Nov 27, 2019 at 01:20:36AM -0800, Haren Myneni wrote:
> Thanks for the review.
> vas_win_paste_addr() will be used in NX compression driver and planning to
> post this series soon. Can I add this change later as part of this series?

Please only add core functionality and exports with the actual users.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-27  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27  1:03 [PATCH 02/14] Revert "powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions" Haren Myneni
2019-11-27  8:28 ` Christoph Hellwig
     [not found]   ` <OF14D260BC.48F4C927-ON002584BF.00332A80-882584BF.00335313@notes.na.collabserv.com>
2019-11-27  9:31     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).