linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 1/3] cxl: Split _CXL_LOOP_HCALL9 out into a separate macro
@ 2016-10-18  8:40 Michael Ellerman
  2016-10-18  8:40 ` [RFC PATCH 2/3] powerpc/pseries: Define & use a type for the plpar_hcall() retvals Michael Ellerman
  2016-10-18  8:40 ` [RFC PATCH 3/3] powerpc/pseries: Define & use a type for the plpar_hcall9() retvals Michael Ellerman
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Ellerman @ 2016-10-18  8:40 UTC (permalink / raw)
  To: linuxppc-dev

In a subsequent patch we want to change the type of retbuf between
plpar_hcall() and plpar_hcall9(), but we can't because _CXL_LOOP_HCALL
expects the same type for retbuf regardless of the hcall type.

So duplicate the logic in a separate macro for plpar_hcall9().

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 drivers/misc/cxl/hcalls.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/hcalls.c b/drivers/misc/cxl/hcalls.c
index d6d11f4056d7..01a8d917631c 100644
--- a/drivers/misc/cxl/hcalls.c
+++ b/drivers/misc/cxl/hcalls.c
@@ -77,8 +77,37 @@
 			msleep(delay);					\
 		}							\
 	}
+
+#define _CXL_LOOP_HCALL9(call, rc, retbuf, fn, ...)			\
+	{								\
+		unsigned int delay, total_delay = 0;			\
+		u64 token = 0;						\
+									\
+		memset(retbuf, 0, sizeof(retbuf));			\
+		while (1) {						\
+			rc = call(fn, retbuf, __VA_ARGS__, token);	\
+			token = retbuf[0];				\
+			if (rc != H_BUSY && !H_IS_LONG_BUSY(rc))	\
+				break;					\
+									\
+			if (rc == H_BUSY)				\
+				delay = 10;				\
+			else						\
+				delay = get_longbusy_msecs(rc);		\
+									\
+			total_delay += delay;				\
+			if (total_delay > CXL_HCALL_TIMEOUT) {		\
+				WARN(1, "Warning: Giving up waiting for CXL hcall " \
+				     "%#x after %u msec\n", fn, total_delay); \
+				rc = H_BUSY;				\
+				break;					\
+			}						\
+			msleep(delay);					\
+		}							\
+	}
+
 #define CXL_H_WAIT_UNTIL_DONE(...)  _CXL_LOOP_HCALL(plpar_hcall, __VA_ARGS__)
-#define CXL_H9_WAIT_UNTIL_DONE(...) _CXL_LOOP_HCALL(plpar_hcall9, __VA_ARGS__)
+#define CXL_H9_WAIT_UNTIL_DONE(...) _CXL_LOOP_HCALL9(plpar_hcall9, __VA_ARGS__)
 
 #define _PRINT_MSG(rc, format, ...)					\
 	{								\
-- 
2.7.4

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

end of thread, other threads:[~2016-10-19 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-18  8:40 [RFC PATCH 1/3] cxl: Split _CXL_LOOP_HCALL9 out into a separate macro Michael Ellerman
2016-10-18  8:40 ` [RFC PATCH 2/3] powerpc/pseries: Define & use a type for the plpar_hcall() retvals Michael Ellerman
2016-10-18 14:17   ` Balbir Singh
2016-10-19 11:47     ` Michael Ellerman
2016-10-19 13:59       ` Balbir Singh
2016-10-19 14:38         ` David Laight
2016-10-18  8:40 ` [RFC PATCH 3/3] powerpc/pseries: Define & use a type for the plpar_hcall9() retvals Michael Ellerman

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).