diff options
Diffstat (limited to 'drivers/staging/unisys/common-spar/include')
9 files changed, 100 insertions, 64 deletions
diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 15a8d6b35da..c25dfbf7f6b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -16,6 +16,8 @@ #ifndef __CHANNEL_H__ #define __CHANNEL_H__ +#include <linux/types.h> +#include <linux/io.h> #include <linux/uuid.h> /* @@ -30,8 +32,6 @@ */ #define __SUPERVISOR_CHANNEL_H__ -#include "commontypes.h" - #define SIGNATURE_16(A, B) ((A) | (B<<8)) #define SIGNATURE_32(A, B, C, D) \ (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16)) @@ -50,6 +50,37 @@ #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') +#define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \ + lin, logCtx) \ + do { \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d\n", \ + chName, &chType, field, \ + &expected, &actual, \ + fil, lin); \ + } while (0) +#define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \ + lin, logCtx) \ + do { \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \ + chName, &chType, field, \ + (unsigned long)expected, (unsigned long)actual, \ + fil, lin); \ + } while (0) + +#define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \ + lin, logCtx) \ + do { \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \ + chName, &chType, field, \ + (unsigned long long)expected, \ + (unsigned long long)actual, \ + fil, lin); \ + } while (0) + +#define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \ + LineNumber, Str, args...) \ + pr_info(Str, ## args) + typedef enum { CHANNELSRV_UNINITIALIZED = 0, /* channel is in an undefined state */ CHANNELSRV_READY = 1 /* channel has been initialized by server */ @@ -157,7 +188,7 @@ ULTRA_CHANNELCLI_STRING(u32 v) PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ writel(newstate, &((CHANNEL_HEADER __iomem *) \ (pChan))->CliStateOS); \ - MEMORYBARRIER; \ + mb(); /* required for channel synch */ \ } while (0) #define ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(pChan, chanId, logCtx) \ @@ -316,17 +347,21 @@ ULTRA_check_channel_client(void __iomem *pChannel, u64 expectedSignature, char *fileName, int lineNumber, void *logCtx) { - if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) + if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) { + uuid_le guid; + + memcpy_fromio(&guid, + &((CHANNEL_HEADER __iomem *)(pChannel))->Type, + sizeof(guid)); /* caller wants us to verify type GUID */ - if (uuid_le_cmp((((CHANNEL_HEADER __iomem *)(pChannel))->Type), - expectedTypeGuid) != 0) { + if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { CHANNEL_GUID_MISMATCH(expectedTypeGuid, channelName, "type", expectedTypeGuid, - ((CHANNEL_HEADER __iomem *) - (pChannel))->Type, fileName, + guid, fileName, lineNumber, logCtx); return 0; } + } if (expectedMinBytes > 0) /* caller wants us to verify * channel size */ if (readq(&((CHANNEL_HEADER __iomem *) @@ -399,6 +434,7 @@ PathName_Last_N_Nodes(u8 *s, unsigned int n) { u8 *p = s; unsigned int node_count = 0; + while (*p != '\0') { if ((*p == '/') || (*p == '\\')) node_count++; @@ -458,7 +494,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, CHANNELCLI_OWNED, PathName_Last_N_Nodes((u8 *) file, 4), line); writel(CHANNELCLI_OWNED, &pChan->CliStateOS); - MEMORYBARRIER; + mb(); /* required for channel synch */ } if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED) { if (readb(&pChan->CliErrorOS) != 0) { @@ -502,7 +538,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, return 0; } writel(CHANNELCLI_BUSY, &pChan->CliStateOS); - MEMORYBARRIER; + mb(); /* required for channel synch */ if (readl(&pChan->CliStateBoot) == CHANNELCLI_BUSY) { if ((readb(&pChan->CliErrorOS) & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) { @@ -521,7 +557,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, } /* reset busy */ writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); - MEMORYBARRIER; + mb(); /* required for channel synch */ return 0; } if (readb(&pChan->CliErrorOS) != 0) { @@ -542,6 +578,7 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, void *logCtx, char *file, int line, char *func) { CHANNEL_HEADER __iomem *pChan = pChannel; + if (readb(&pChan->CliErrorOS) != 0) { /* we are in an error msg throttling state; come out of it */ UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index b0a49e0c37a..fd4726e754e 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -25,7 +25,7 @@ #ifndef _CONTROL_FRAMEWORK_H_ #define _CONTROL_FRAMEWORK_H_ -#include "commontypes.h" +#include <linux/types.h> #include "channel.h" #define ULTRA_MEMORY_COUNT_Ki 1024 diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 153f57ce908..d08c198e0de 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -17,9 +17,11 @@ #define __CONTROLVMCHANNEL_H__ #include <linux/uuid.h> -#include "commontypes.h" #include "channel.h" #include "controlframework.h" + +typedef u64 GUEST_PHYSICAL_ADDRESS; + enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE, TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE }; diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index c01649a985c..9912e51b89b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -33,7 +33,7 @@ #ifndef _DIAG_CHANNEL_H_ #define _DIAG_CHANNEL_H_ -#include "commontypes.h" +#include <linux/uuid.h> #include "channel.h" /* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */ diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 24e11858e0e..b1dd73d1f42 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -31,7 +31,6 @@ #include <linux/uuid.h> -#include "commontypes.h" #include "vmcallinterface.h" #define _ULTRA_CONTROLVM_CHANNEL_INLINE_ @@ -711,24 +710,24 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ /* define offsets to members of struct uiscmdrsp */ -#define OFFSET_CMDTYPE OFFSETOF(struct uiscmdrsp, cmdtype) -#define OFFSET_SCSI OFFSETOF(struct uiscmdrsp, scsi) -#define OFFSET_NET OFFSETOF(struct uiscmdrsp, net) -#define OFFSET_SCSITASKMGMT OFFSETOF(struct uiscmdrsp, scsitaskmgmt) -#define OFFSET_NEXT OFFSETOF(struct uiscmdrsp, next) +#define OFFSET_CMDTYPE offsetof(struct uiscmdrsp, cmdtype) +#define OFFSET_SCSI offsetof(struct uiscmdrsp, scsi) +#define OFFSET_NET offsetof(struct uiscmdrsp, net) +#define OFFSET_SCSITASKMGMT offsetof(struct uiscmdrsp, scsitaskmgmt) +#define OFFSET_NEXT offsetof(struct uiscmdrsp, next) /* define offsets to members of struct uiscmdrsp_net */ -#define OFFSET_TYPE OFFSETOF(struct uiscmdrsp_net, type) -#define OFFSET_BUF OFFSETOF(struct uiscmdrsp_net, buf) -#define OFFSET_XMT OFFSETOF(struct uiscmdrsp_net, xmt) -#define OFFSET_XMT_DONE_RESULT OFFSETOF(struct uiscmdrsp_net, xmtdone) -#define OFFSET_RCVPOST OFFSETOF(struct uiscmdrsp_net, rcvpost) -#define OFFSET_RCV_DONE_LEN OFFSETOF(struct uiscmdrsp_net, rcv) -#define OFFSET_ENBDIS OFFSETOF(struct uiscmdrsp_net, enbdis) +#define OFFSET_TYPE offsetof(struct uiscmdrsp_net, type) +#define OFFSET_BUF offsetof(struct uiscmdrsp_net, buf) +#define OFFSET_XMT offsetof(struct uiscmdrsp_net, xmt) +#define OFFSET_XMT_DONE_RESULT offsetof(struct uiscmdrsp_net, xmtdone) +#define OFFSET_RCVPOST offsetof(struct uiscmdrsp_net, rcvpost) +#define OFFSET_RCV_DONE_LEN offsetof(struct uiscmdrsp_net, rcv) +#define OFFSET_ENBDIS offsetof(struct uiscmdrsp_net, enbdis) /* define offsets to members of struct net_pkt_rcvpost */ -#define OFFSET_TOTALLEN OFFSETOF(struct net_pkt_rcvpost, totallen) -#define OFFSET_FRAG OFFSETOF(struct net_pkt_rcvpost, frag) +#define OFFSET_TOTALLEN offsetof(struct net_pkt_rcvpost, totallen) +#define OFFSET_FRAG offsetof(struct net_pkt_rcvpost, frag) /* * INLINE functions for initializing and accessing I/O data channels @@ -753,7 +752,7 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { do { \ x->cmdQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size); \ x->cmdQ.oSignalBase = SIZEOF_PROTOCOL - \ - OFFSETOF(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ + offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ x->cmdQ.SignalSize = SIZEOF_CMDRSP; \ x->cmdQ.MaxSignalSlots = \ QSLOTSFROMBYTES(x->ChannelHeader.Size); \ @@ -761,21 +760,21 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { x->rspQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size); \ x->rspQ.oSignalBase = \ (SIZEOF_PROTOCOL + x->cmdQ.Size) - \ - OFFSETOF(ULTRA_IO_CHANNEL_PROTOCOL, rspQ); \ + offsetof(ULTRA_IO_CHANNEL_PROTOCOL, rspQ); \ x->rspQ.SignalSize = SIZEOF_CMDRSP; \ x->rspQ.MaxSignalSlots = \ QSLOTSFROMBYTES(x->ChannelHeader.Size); \ x->rspQ.MaxSignals = x->rspQ.MaxSignalSlots - 1; \ x->ChannelHeader.oChannelSpace = \ - OFFSETOF(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ + offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ } while (0) #define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \ do { \ if (clientStr) { \ chan->ChannelHeader.oClientString = \ - OFFSETOF(type, clientString); \ - MEMCPY(chan->clientString, clientStr, \ + offsetof(type, clientString); \ + memcpy(chan->clientString, clientStr, \ MINNUM(clientStrLen, \ (u32) (MAX_CLIENTSTRING_LEN - 1))); \ chan->clientString[MINNUM(clientStrLen, \ @@ -791,11 +790,11 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { #define ULTRA_IO_CHANNEL_SERVER_READY(x, chanId, logCtx) \ ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, CHANNELSRV_READY, \ - logCtx); + logCtx) #define ULTRA_IO_CHANNEL_SERVER_NOTREADY(x, chanId, logCtx) \ ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, \ - CHANNELSRV_UNINITIALIZED, logCtx); + CHANNELSRV_UNINITIALIZED, logCtx) static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, struct vhba_wwnn *wwnn, @@ -846,7 +845,7 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, x->ChannelHeader.Size = COVER(bytes, 4096); x->ChannelHeader.Type = UltraVnicChannelProtocolGuid; x->ChannelHeader.ZoneGuid = NULL_UUID_LE; - MEMCPY(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); + memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); x->vnic.num_rcv_bufs = num_rcv_bufs; x->vnic.mtu = mtu; x->vnic.zoneGuid = zoneGuid; @@ -882,7 +881,7 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, /* returns next non-zero index on success or zero on failure (i.e. out of * room) */ -static INLINE u16 +static inline u16 add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used * to add entries */ u16 inp_off, /* input - specifies the off to be used diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 8facb51143a..1231c454176 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -24,7 +24,6 @@ * the client devices and client drivers for the server end to see. */ #include <linux/uuid.h> -#include "commontypes.h" #include "vbusdeviceinfo.h" #include "channel.h" diff --git a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h b/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h index db77d6f626a..f74f5d8c282 100644 --- a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h +++ b/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h @@ -62,14 +62,16 @@ * DEVICE_CREATE, * DEVICE_DESTROY */ /* Unable to invoke VIRTPCI callback */ -#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR 605 /* BUS_CREATE, - * BUS_DESTROY, - * DEVICE_CREATE, - * DEVICE_DESTROY */ +#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR 605 + /* BUS_CREATE, + * BUS_DESTROY, + * DEVICE_CREATE, + * DEVICE_DESTROY */ /* VIRTPCI Callback returned error */ -#define CONTROLVM_RESP_ERROR_GENERIC_DRIVER_CALLBACK_ERROR 606 /* SWITCH_ATTACHEXTPORT, - * SWITCH_DETACHEXTPORT - * DEVICE_CONFIGURE */ +#define CONTROLVM_RESP_ERROR_GENERIC_DRIVER_CALLBACK_ERROR 606 + /* SWITCH_ATTACHEXTPORT, + * SWITCH_DETACHEXTPORT + * DEVICE_CONFIGURE */ /* generic device callback returned error */ /* Bus Related------------------------------------------------------[700-799] */ diff --git a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h b/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h index fe9598c941a..57dd93e0cc8 100644 --- a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h +++ b/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h @@ -19,16 +19,14 @@ __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx, unsigned long reg_ecx) { unsigned long result = 0; - unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx; + cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); - if (cpuid_ecx & 0x80000000) { - __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : - "a"(tuple), "b"(reg_ebx), "c"(reg_ecx) - ); - } else { - result = -1; - } + if (!(cpuid_ecx & 0x80000000)) + return -1; + + __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : + "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); return result; } @@ -39,15 +37,13 @@ __unisys_extended_vmcall_gnuc(unsigned long long tuple, unsigned long long reg_edx) { unsigned long result = 0; - unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx; + cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); - if (cpuid_ecx & 0x80000000) { - __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : - "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), - "d"(reg_edx)); - } else { - result = -1; - } + if (!(cpuid_ecx & 0x80000000)) + return -1; + + __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : + "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx)); return result; - } +} diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index 5e0d98cd422..3bbdc2bb7eb 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -16,7 +16,7 @@ #ifndef __VBUSDEVICEINFO_H__ #define __VBUSDEVICEINFO_H__ -#include "commontypes.h" +#include <linux/types.h> #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ @@ -54,6 +54,7 @@ vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax) { int chars = 0; int nonprintable_streak = 0; + while (srcmax > 0) { if ((*src >= ' ') && (*src < 0x7f)) { if (nonprintable_streak) { |