From 26b70a6c718a6129de006e980bc98aab74a75136 Mon Sep 17 00:00:00 2001 From: Allen Pais Date: Fri, 5 May 2017 11:21:32 +0530 Subject: [PATCH] sparc64: Add DAX hypervisor services This provides the HV API for coprocessor services which is needed to support a device driver for the DAX. Orabug: 25996411 Reviewed-by: Bob Picco Signed-off-by: Sanath Kumar Signed-off-by: Rob Gardner Signed-off-by: Allen Pais --- arch/sparc/include/asm/hypervisor.h | 84 +++++++++++++++++++++++++++++ arch/sparc/kernel/hvapi.c | 1 + arch/sparc/kernel/hvcalls.S | 20 +++++++ arch/sparc/kernel/sparc_ksyms_64.c | 1 + 4 files changed, 106 insertions(+) diff --git a/arch/sparc/include/asm/hypervisor.h b/arch/sparc/include/asm/hypervisor.h index b77770d1f292..795aabb23f6e 100644 --- a/arch/sparc/include/asm/hypervisor.h +++ b/arch/sparc/include/asm/hypervisor.h @@ -936,6 +936,89 @@ extern unsigned long sun4v_mmu_unmap_perm_addr(unsigned long vaddr, */ #define HV_FAST_MEM_SYNC 0x32 +/* Coprocessor services + * + * M7 and later processors provide an on-chip coprocessor which + * accelerates database operations, and is known internally as + * DAX. + */ + +/* dax_ccb_submit() + * TRAP: HV_FAST_TRAP + * FUNCTION: HV_DAX_CCB_SUBMIT + * ARG0: address of CCB array + * ARG1: size (in bytes) of CCB array being submitted + * ARG2: flags + * ARG3: virtual queue token + * RET0: status (success or error code) + * RET1 size (in bytes) of CCB array that was accepted (might be less than arg1) + * RET2 Identifies the VA in question when status is ENOMAP or ENOACCESS + * RET3 (if using virtual message queues) new virtual queue token + * + * ERRORS: EWOULDBLOCK etc + * ENOTSUPPORTED etc + * + * Details. + */ + +#define HV_DAX_CCB_SUBMIT 0x34 +#ifndef __ASSEMBLY__ +unsigned long sun4v_dax_ccb_submit(void *ccb, int len, long flags, long vq_token, long *submitted_len, long *error_va); +#endif +/* flags (ARG2) */ +#define HV_DAX_MESSAGE_CMD (0) +#define HV_DAX_VIRTUAL_MESSAGE_CMD (1) +#define HV_DAX_QUERY_CMD (2) +#define HV_DAX_ARG0_TYPE_REAL (0 << 4) +#define HV_DAX_ARG0_TYPE_PRIMARY (1 << 4) +#define HV_DAX_ARG0_TYPE_SECONDARY (2 << 4) +#define HV_DAX_ARG0_TYPE_NUCLEUS (3 << 4) +#define HV_DAX_ARG0_PRIVILEGED (1 << 6) +#define HV_DAX_ALL_OR_NOTHING (1 << 7) +#define HV_DAX_CCB_VA_REJECT (0 << 12) +#define HV_DAX_CCB_VA_SECONDARY (2 << 12) +#define HV_DAX_CCB_VA_NUCLEUS (3 << 12) +#define HV_DAX_CCB_VA_PRIVILEGED (1 << 14) + +/* dax_ccb_info() + * TRAP: HV_FAST_TRAP + * FUNCTION: HV_DAX_CCB_INFO + * ARG0: real address of CCB completion area + * RET0: status (success or error code) + * RET1 CCB state + * RET2 queue position + * + * ERRORS: EWOULDBLOCK etc + * ENOTSUPPORTED etc + * + * Details. + */ + +#define HV_DAX_CCB_INFO 0x35 +#define HV_DAX_STATE_COMPLETED 0 +#define HV_DAX_STATE_PENDING 1 +#define HV_DAX_STATE_INPROGRESS 2 +#define HV_DAX_STATE_NOTFOUND 3 + +/* dax_ccb_kill() + * TRAP: HV_FAST_TRAP + * FUNCTION: HV_DAX_CCB_KILL + * ARG0: real address of CCB completion area + * RET0: status (success or error code) + * RET1 CCB kill status + * + * ERRORS: EWOULDBLOCK etc + * ENOTSUPPORTED etc + * + * Details. + */ + +#define HV_DAX_CCB_KILL 0x36 +#define HV_DAX_KILL_COMPLETED 0 +#define HV_DAX_KILL_DEQUEUED 1 +#define HV_DAX_KILL_KILLED 2 +#define HV_DAX_KILL_NOTFOUND 3 + /* Time of day services. * * The hypervisor maintains the time of day on a per-domain basis. @@ -3689,6 +3772,7 @@ struct hv_pci_priq_intx_info { #define HV_GRP_SDIO 0x0108 #define HV_GRP_SDIO_ERR 0x0109 #define HV_GRP_REBOOT_DATA 0x0110 +#define HV_GRP_M7_DAX 0x0113 #define HV_GRP_M7_PERF 0x0114 #define HV_GRP_PRIQ 0x011b #define HV_GRP_PRIQ_PCI 0x011c diff --git a/arch/sparc/kernel/hvapi.c b/arch/sparc/kernel/hvapi.c index 18e59ecca0f2..6f07c609e457 100644 --- a/arch/sparc/kernel/hvapi.c +++ b/arch/sparc/kernel/hvapi.c @@ -39,6 +39,7 @@ static struct api_info api_table[] = { { .group = HV_GRP_SDIO, }, { .group = HV_GRP_SDIO_ERR, }, { .group = HV_GRP_REBOOT_DATA, }, + { .group = HV_GRP_M7_DAX, }, { .group = HV_GRP_PRIQ, }, { .group = HV_GRP_PRIQ_PCI, }, { .group = HV_GRP_NIAG_PERF, .flags = FLAG_PRE_API }, diff --git a/arch/sparc/kernel/hvcalls.S b/arch/sparc/kernel/hvcalls.S index 775aaa4365ff..cbf9cc002419 100644 --- a/arch/sparc/kernel/hvcalls.S +++ b/arch/sparc/kernel/hvcalls.S @@ -216,6 +216,26 @@ ENTRY(sun4v_set_version) stx %o1, [%o4] ENDPROC(sun4v_set_version) + /* %o0: address of CCB array + * %o1: size (in bytes) of CCB array + * %o2: flags + * %o3: virtual queue token + * + * returns: + * %o0: status + * %o1: size (in bytes) of the CCB array that was accepted + * %o2: error address + * %o3: new virtual queue token + */ +ENTRY(sun4v_dax_ccb_submit) + mov %o5, %g1 + mov HV_DAX_CCB_SUBMIT, %o5 + ta HV_FAST_TRAP + stx %o1, [%o4] + retl + stx %o2, [%g1] +ENDPROC(sun4v_dax_ccb_submit) + /* %o0: pointer to unsigned long time * * returns %o0: status diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c index 9e034f29dcc5..9a623004efe6 100644 --- a/arch/sparc/kernel/sparc_ksyms_64.c +++ b/arch/sparc/kernel/sparc_ksyms_64.c @@ -38,6 +38,7 @@ EXPORT_SYMBOL(sun4v_niagara_setperf); EXPORT_SYMBOL(sun4v_niagara2_getperf); EXPORT_SYMBOL(sun4v_niagara2_setperf); EXPORT_SYMBOL(sun4v_mach_set_watchdog); +EXPORT_SYMBOL(sun4v_dax_ccb_submit); /* from hweight.S */ EXPORT_SYMBOL(__arch_hweight8); -- 2.50.1