On 25.10.19 19:06, Claudio Imbrenda wrote:
Add a wrapper for the service call instruction, and use it for SCLP
interactions instead of using inline assembly everywhere.
Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>
Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>
---
lib/s390x/asm/arch_def.h | 13 +++++++++++++
lib/s390x/sclp.c | 7 +------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 96cca2e..b3caff6 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -269,4 +269,17 @@ static inline int stsi(void *addr, int fc, int sel1, int sel2)
return cc;
}
+static inline int servc(uint32_t command, unsigned long sccb)
+{
+ int cc;
+
+ asm volatile(
+ " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
+ " ipm %0\n"
+ " srl %0,28"
+ : "=&d" (cc) : "d" (command), "a" (sccb)
+ : "cc", "memory");
+ return cc;
+}
+
#endif
diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index 7798f04..e35c282 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -116,12 +116,7 @@ int sclp_service_call(unsigned int command, void *sccb)
int cc;
sclp_setup_int();
- asm volatile(
- " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
- " ipm %0\n"
- " srl %0,28"
- : "=&d" (cc) : "d" (command), "a" (__pa(sccb))
- : "cc", "memory");
+ cc = servc(command, __pa(sccb));
sclp_wait_busy();
if (cc == 3)
return -1;
I do wonder if we should really do that. Shouldn't we always set/wait if
busy (especially, if testing for an error condition that won't trigger)?
IOW, shouldn't we have a modified sclp_service_call() that returns the
CC (and also calls sclp_setup_int()/sclp_wait_busy())?
We could also simply make sclp_service_call() return the cc and handle
the cc in the existing callers.
--
Thanks,
David / dhildenb