diff options
Diffstat (limited to 'drivers/staging/unisys')
38 files changed, 643 insertions, 955 deletions
diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index b9bf8e81677c..b4bdee4b575b 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -73,9 +73,9 @@ visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal) */ psignal = (char __iomem *)pqhdr + readq(&pqhdr->oSignalBase) + (head * readl(&pqhdr->SignalSize)); - MEMCPY_TOIO(psignal, pSignal, readl(&pqhdr->SignalSize)); + memcpy_toio(psignal, pSignal, readl(&pqhdr->SignalSize)); - VolatileBarrier(); + mb(); /* channel synch */ writel(head, &pqhdr->Head); writeq(readq(&pqhdr->NumSignalsSent) + 1, &pqhdr->NumSignalsSent); @@ -126,9 +126,9 @@ visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal) /* copy signal from tail location to the area pointed to by pSignal */ psource = (char __iomem *) pqhdr + readq(&pqhdr->oSignalBase) + (tail * readl(&pqhdr->SignalSize)); - MEMCPY_FROMIO(pSignal, psource, readl(&pqhdr->SignalSize)); + memcpy_fromio(pSignal, psource, readl(&pqhdr->SignalSize)); - VolatileBarrier(); + mb(); /* channel synch */ writel(tail, &pqhdr->Tail); writeq(readq(&pqhdr->NumSignalsReceived) + 1, @@ -183,10 +183,10 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal) psource = (char *) pqhdr + pqhdr->oSignalBase + (tail * pqhdr->SignalSize); - MEMCPY((char *) pSignal + (pqhdr->SignalSize * signalCount), + memcpy((char *) pSignal + (pqhdr->SignalSize * signalCount), psource, pqhdr->SignalSize); - VolatileBarrier(); + mb(); /* channel synch */ pqhdr->Tail = tail; signalCount++; diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index 7f36d9adac55..d54c5d635a94 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -25,7 +25,7 @@ #include "channel.h" #include "chanstub.h" -#include "timskmodutils.h" +#include "timskmod.h" #include "version.h" static __init int @@ -47,6 +47,7 @@ SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, { unsigned char result; unsigned long flags; + spin_lock_irqsave(lock, flags); result = visor_signal_insert(pChannel, Queue, pSignal); spin_unlock_irqrestore(lock, flags); @@ -58,6 +59,7 @@ SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal, spinlock_t *lock) { unsigned char result; + spin_lock(lock); result = visor_signal_remove(pChannel, Queue, pSignal); spin_unlock(lock); diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 15a8d6b35dac..c25dfbf7f6bc 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 b0a49e0c37a2..fd4726e754ea 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 153f57ce908f..d08c198e0de3 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 c01649a985c7..9912e51b89b5 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 24e11858e0ee..b1dd73d1f42c 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 8facb51143ae..1231c454176f 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 db77d6f626a1..f74f5d8c2820 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 fe9598c941a6..57dd93e0cc83 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 5e0d98cd422e..3bbdc2bb7ebf 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) { diff --git a/drivers/staging/unisys/include/commontypes.h b/drivers/staging/unisys/include/commontypes.h deleted file mode 100644 index 4311e9f6200f..000000000000 --- a/drivers/staging/unisys/include/commontypes.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2010 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -#ifndef _COMMONTYPES_H_ -#define _COMMONTYPES_H_ - -/* define the following to prevent include nesting in kernel header files of - * similar abbreviated content */ -#define _SUPERVISOR_COMMONTYPES_H_ - -#include <linux/types.h> -#include <linux/version.h> -#include <linux/io.h> -#include <linux/uuid.h> - -typedef u64 GUEST_PHYSICAL_ADDRESS; - -#define INLINE inline -#define OFFSETOF offsetof - -#define MEMORYBARRIER mb() -#define MEMCPY(dest, src, len) memcpy(dest, src, len) -#define MEMCPY_TOIO(dest, src, len) memcpy_toio(dest, src, len) -#define MEMCPY_FROMIO(dest, src, len) memcpy_fromio(dest, src, len) - -#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) - -#define VolatileBarrier() MEMORYBARRIER - -#endif - diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h index 8728e4c7bf6b..957a627d0527 100644 --- a/drivers/staging/unisys/include/guestlinuxdebug.h +++ b/drivers/staging/unisys/include/guestlinuxdebug.h @@ -21,10 +21,9 @@ * regarding adding additional structure and functionality to linux * ISSUE_IO_VMCALL_POSTCODE_SEVERITY */ - /******* INFO ON ISSUE_POSTCODE_LINUX() BELOW *******/ #include "vmcallinterface.h" -typedef enum { /* POSTCODE driver identifier tuples */ +enum driver_pc { /* POSTCODE driver identifier tuples */ /* visorchipset driver files */ VISOR_CHIPSET_PC = 0xA0, VISOR_CHIPSET_PC_controlvm_c = 0xA1, @@ -59,9 +58,9 @@ typedef enum { /* POSTCODE driver identifier tuples */ UISLIB_PC_uisqueue_c = 0xD2, UISLIB_PC_uisthread_c = 0xD3, UISLIB_PC_uisutils_c = 0xD4, -} DRIVER_PC; +}; -typedef enum { /* POSTCODE event identifier tuples */ +enum event_pc { /* POSTCODE event identifier tuples */ ATTACH_PORT_ENTRY_PC = 0x001, ATTACH_PORT_FAILURE_PC = 0x002, ATTACH_PORT_SUCCESS_PC = 0x003, @@ -129,7 +128,7 @@ typedef enum { /* POSTCODE event identifier tuples */ SAVE_MSG_BUS_FAILURE_PC = 0x0D9, SAVE_MSG_DEV_FAILURE_PC = 0x0DA, CALLHOME_INIT_FAILURE_PC = 0x0DB -} EVENT_PC; +}; #ifdef __GNUC__ @@ -173,7 +172,6 @@ do { \ #define POSTCODE_LINUX_3(EVENT_PC, pc32bit, severity) \ POSTCODE_LINUX_A(CURRENT_FILE_PC, EVENT_PC, pc32bit, severity) - #define POSTCODE_LINUX_4(EVENT_PC, pc16bit1, pc16bit2, severity) \ POSTCODE_LINUX_B(CURRENT_FILE_PC, EVENT_PC, pc16bit1, \ pc16bit2, severity) diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 418ba634e1a2..26ec10bdfe65 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -20,21 +20,19 @@ #include "timskmod.h" - - /* PERIODIC_WORK an opaque structure to users. * Fields are declared only in the implementation .c files. */ -typedef struct PERIODIC_WORK_Tag PERIODIC_WORK; +struct periodic_work; -PERIODIC_WORK *visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam); -void visor_periodic_work_destroy(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_nextperiod(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_start(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work); +struct periodic_work *visor_periodic_work_create(ulong jiffy_interval, + struct workqueue_struct *workqueue, + void (*workfunc)(void *), + void *workfuncarg, + const char *devnam); +void visor_periodic_work_destroy(struct periodic_work *pw); +BOOL visor_periodic_work_nextperiod(struct periodic_work *pw); +BOOL visor_periodic_work_start(struct periodic_work *pw); +BOOL visor_periodic_work_stop(struct periodic_work *pw); #endif diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index ecf1a6fac7a1..b14494ff6c1b 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -62,8 +62,6 @@ #if !defined SUCCESS #define SUCCESS 0 #endif -#define FAILURE (-1) -#define DRIVERNAMEMAX 50 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0) @@ -71,57 +69,6 @@ #define HOSTADDRESS unsigned long long #endif -typedef long VMMIO; /**< Virtual MMIO address (returned from ioremap), which - * is a virtual address pointer to a memory-mapped region. - * These are declared as "long" instead of u32* to force you to - * use readb()/writeb()/memcpy_fromio()/etc to access them. - * (On x86 we could probably get away with treating them as - * pointers.) - */ -typedef long VMMIO8; /**< #VMMIO pointing to 8-bit data */ -typedef long VMMIO16;/**< #VMMIO pointing to 16-bit data */ -typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ - -#define LOCKSEM(sem) down_interruptible(sem) -#define LOCKSEM_UNINTERRUPTIBLE(sem) down(sem) -#define UNLOCKSEM(sem) up(sem) - -/** lock read/write semaphore for reading. - Note that all read/write semaphores are of the "uninterruptible" variety. - @param sem (rw_semaphore *) points to semaphore to lock - */ -#define LOCKREADSEM(sem) down_read(sem) - -/** unlock read/write semaphore for reading. - Note that all read/write semaphores are of the "uninterruptible" variety. - @param sem (rw_semaphore *) points to semaphore to unlock - */ -#define UNLOCKREADSEM(sem) up_read(sem) - -/** lock read/write semaphore for writing. - Note that all read/write semaphores are of the "uninterruptible" variety. - @param sem (rw_semaphore *) points to semaphore to lock - */ -#define LOCKWRITESEM(sem) down_write(sem) - -/** unlock read/write semaphore for writing. - Note that all read/write semaphores are of the "uninterruptible" variety. - @param sem (rw_semaphore *) points to semaphore to unlock - */ -#define UNLOCKWRITESEM(sem) up_write(sem) - -#ifdef ENABLE_RETURN_TRACE -#define RETTRACE(x) \ - do { \ - if (1) { \ - INFODRV("RET 0x%lx in %s", \ - (ulong)(x), __func__); \ - } \ - } while (0) -#else -#define RETTRACE(x) -#endif - /** Try to evaulate the provided expression, and do a RETINT(x) iff * the expression evaluates to < 0. * @param x the expression to try @@ -167,7 +114,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ #define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args) #define DEBUGDEV(devname, fmt, args...) DBGINFDEV(devname, fmt, ## args) - /* @} */ /** Verifies the consistency of your PRIVATEDEVICEDATA structure using @@ -192,94 +138,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \ ((fd)->sig2 == fd)) -/** Locks dd->lockDev if you havn't already locked it */ -#define LOCKDEV(dd) \ - { \ - if (!lockedDev) { \ - spin_lock(&dd->lockDev); \ - lockedDev = TRUE; \ - } \ - } - -/** Unlocks dd->lockDev if you previously locked it */ -#define UNLOCKDEV(dd) \ - { \ - if (lockedDev) { \ - spin_unlock(&dd->lockDev); \ - lockedDev = FALSE; \ - } \ - } - -/** Locks dd->lockDevISR if you havn't already locked it */ -#define LOCKDEVISR(dd) \ - { \ - if (!lockedDevISR) { \ - spin_lock_irqsave(&dd->lockDevISR, flags); \ - lockedDevISR = TRUE; \ - } \ - } - -/** Unlocks dd->lockDevISR if you previously locked it */ -#define UNLOCKDEVISR(dd) \ - { \ - if (lockedDevISR) { \ - spin_unlock_irqrestore(&dd->lockDevISR, flags); \ - lockedDevISR = FALSE; \ - } \ - } - -/** Locks LockGlobalISR if you havn't already locked it */ -#define LOCKGLOBALISR \ - { \ - if (!lockedGlobalISR) { \ - spin_lock_irqsave(&LockGlobalISR, flags); \ - lockedGlobalISR = TRUE; \ - } \ - } - -/** Unlocks LockGlobalISR if you previously locked it */ -#define UNLOCKGLOBALISR \ - { \ - if (lockedGlobalISR) { \ - spin_unlock_irqrestore(&LockGlobalISR, flags); \ - lockedGlobalISR = FALSE; \ - } \ - } - -/** Locks LockGlobal if you havn't already locked it */ -#define LOCKGLOBAL \ - { \ - if (!lockedGlobal) { \ - spin_lock(&LockGlobal); \ - lockedGlobal = TRUE; \ - } \ - } - -/** Unlocks LockGlobal if you previously locked it */ -#define UNLOCKGLOBAL \ - { \ - if (lockedGlobal) { \ - spin_unlock(&LockGlobal); \ - lockedGlobal = FALSE; \ - } \ - } - -/** Use this at the beginning of functions where you intend to - * use #LOCKDEV/#UNLOCKDEV, #LOCKDEVISR/#UNLOCKDEVISR, - * #LOCKGLOBAL/#UNLOCKGLOBAL, #LOCKGLOBALISR/#UNLOCKGLOBALISR. - * - * Note that __attribute__((unused)) is how you tell GNU C to suppress - * any warning messages about the variable being unused. - */ -#define LOCKPREAMBLE \ - ulong flags __attribute__((unused)) = 0; \ - BOOL lockedDev __attribute__((unused)) = FALSE; \ - BOOL lockedDevISR __attribute__((unused)) = FALSE; \ - BOOL lockedGlobal __attribute__((unused)) = FALSE; \ - BOOL lockedGlobalISR __attribute__((unused)) = FALSE - - - /** Sleep for an indicated number of seconds (for use in kernel mode). * @param x the number of seconds to sleep. */ @@ -297,13 +155,14 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ } while (0) #ifndef max -#define max(a, b) (((a) > (b)) ? (a):(b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) #endif static inline struct cdev *cdev_alloc_init(struct module *owner, const struct file_operations *fops) { struct cdev *cdev = NULL; + cdev = cdev_alloc(); if (!cdev) return NULL; @@ -319,6 +178,6 @@ static inline struct cdev *cdev_alloc_init(struct module *owner, return cdev; } -#include "timskmodutils.h" +extern int unisys_spar_platform; #endif diff --git a/drivers/staging/unisys/include/timskmodutils.h b/drivers/staging/unisys/include/timskmodutils.h deleted file mode 100644 index c316c94ea194..000000000000 --- a/drivers/staging/unisys/include/timskmodutils.h +++ /dev/null @@ -1,77 +0,0 @@ -/* timskmodutils.h - * - * Copyright (C) 2010 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -#ifndef __TIMSKMODUTILS_H__ -#define __TIMSKMODUTILS_H__ - -#include "timskmod.h" - -void *kmalloc_kernel(size_t siz); -void myprintk(const char *myDrvName, const char *devname, - const char *template, ...); - -/*--------------------------------* - *--- GENERAL MESSAGEQ STUFF ---* - *--------------------------------*/ - -struct MessageQEntry; - -/** the data structure used to hold an arbitrary data item that you want - * to place on a #MESSAGEQ. Declare and initialize as follows: - * - * This structure should be considered opaque; the client using it should - * never access the fields directly. - * Refer to these functions for more info: - * - * @ingroup messageq - */ -typedef struct MessageQEntry { - void *data; - struct MessageQEntry *qNext; - struct MessageQEntry *qPrev; -} MESSAGEQENTRY; - -/** the data structure used to hold a FIFO queue of #MESSAGEQENTRY<b></b>s. - * Declare and initialize as follows: - * @code - * MESSAGEQ myQueue; - * @endcode - * This structure should be considered opaque; the client using it should - * never access the fields directly. - * Refer to these functions for more info: - * - * @ingroup messageq - */ -typedef struct MessageQ { - MESSAGEQENTRY *qHead; - MESSAGEQENTRY *qTail; - struct semaphore nQEntries; - spinlock_t queueLock; -} MESSAGEQ; - -char *cyclesToSeconds(u64 cycles, u64 cyclesPerSecond, - char *buf, size_t bufsize); -char *cyclesToIterationSeconds(u64 cycles, u64 cyclesPerSecond, - u64 iterations, char *buf, size_t bufsize); -char *cyclesToSomethingsPerSecond(u64 cycles, u64 cyclesPerSecond, - u64 somethings, char *buf, size_t bufsize); -struct seq_file *visor_seq_file_new_buffer(void *buf, size_t buf_size); -void visor_seq_file_done_buffer(struct seq_file *m); - -extern int unisys_spar_platform; - -#endif diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index a2abfa8c82fd..5178270b98d1 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -48,13 +48,13 @@ struct uisqueue_info { u64 non_empty_wakeup_cnt; struct { - SIGNAL_QUEUE_HEADER Reserved1; /* */ - SIGNAL_QUEUE_HEADER Reserved2; /* */ + SIGNAL_QUEUE_HEADER reserved1; /* */ + SIGNAL_QUEUE_HEADER reserved2; /* */ } safe_uis_queue; unsigned int (*send_int_if_needed)(struct uisqueue_info *info, unsigned int whichcqueue, - unsigned char issueInterruptIfEmpty, - u64 interruptHandle, + unsigned char issue_irq_if_empty, + u64 irq_handle, unsigned char io_termination); }; @@ -76,25 +76,19 @@ struct uisqueue_info { ".previous\n" \ "661:\n\tlock; " -unsigned long long uisqueue_InterlockedOr(unsigned long long __iomem *Target, - unsigned long long Set); -unsigned long long uisqueue_InterlockedAnd(unsigned long long __iomem *Target, - unsigned long long Set); - -unsigned int uisqueue_send_int_if_needed(struct uisqueue_info *pqueueinfo, - unsigned int whichqueue, - unsigned char issueInterruptIfEmpty, - u64 interruptHandle, - unsigned char io_termination); +unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt, + unsigned long long set); +unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt, + unsigned long long set); int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, struct uiscmdrsp *cmdrsp, unsigned int queue, void *insertlock, - unsigned char issueInterruptIfEmpty, - u64 interruptHandle, + unsigned char issue_irq_if_empty, + u64 irq_handle, char oktowait, - u8 *channelId); + u8 *channel_id); /* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue * and copies it to the area pointed by cmdrsp param. @@ -135,17 +129,17 @@ struct extport_info { struct device_info { void __iomem *chanptr; - u64 channelAddr; - u64 channelBytes; - uuid_le channelTypeGuid; - uuid_le devInstGuid; + u64 channel_addr; + u64 channel_bytes; + uuid_le channel_uuid; + uuid_le instance_uuid; struct InterruptInfo intr; struct switch_info *swtch; char devid[30]; /* "vbus<busno>:dev<devno>" */ u16 polling; struct semaphore interrupt_callback_lock; - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; int (*interrupt)(void *); void *interrupt_context; void *private_data; @@ -176,8 +170,8 @@ struct bus_info { * by IOVM; 0 otherwise... */ }; -#define DEDICATED_SWITCH(pSwitch) ((pSwitch->extPortCount == 1) && \ - (pSwitch->intPortCount == 1)) +#define DEDICATED_SWITCH(s) ((s->extPortCount == 1) && \ + (s->intPortCount == 1)) struct sn_list_entry { struct uisscsi_dest pdest; /* scsi bus, target, lun for @@ -189,7 +183,7 @@ struct sn_list_entry { struct sn_list_entry *next; }; -struct networkPolicy { +struct network_policy { u32 promiscuous:1; u32 macassign:1; u32 peerforwarding:1; @@ -229,10 +223,10 @@ typedef enum { struct add_virt_iopart { void *chanptr; /* pointer to data channel */ - u64 guestHandle; /* used to convert guest physical + u64 guest_handle; /* used to convert guest physical * address to real physical address * for DMA, for ex. */ - u64 recvBusInterruptHandle; /* used to register to receive + u64 recv_bus_irq_handle; /* used to register to receive * bus level interrupts. */ struct InterruptInfo intr; /* contains recv & send * interrupt info */ @@ -247,12 +241,12 @@ struct add_virt_iopart { * switch to which the vnic is * connected */ - u8 useG2GCopy; /* Used to determine if a virtual HBA + u8 use_g2g_copy; /* Used to determine if a virtual HBA * needs to use G2G copy. */ - u8 Filler[7]; + u8 filler[7]; - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; char *params; ulong params_bytes; @@ -265,21 +259,21 @@ struct add_vdisk_iopart { struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */ u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */ u32 serlen; /* length of serial num */ - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; }; struct del_vdisk_iopart { void *chanptr; /* pointer to data channel */ struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; }; struct del_virt_iopart { void *chanptr; /* pointer to data channel */ - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; }; struct det_virt_iopart { /* detach internal port */ @@ -322,7 +316,7 @@ struct io_msgs { struct det_virt_iopart det_intport; struct add_switch_iopart add_switch; struct del_switch_iopart del_switch; - struct extport_info *extPort; /* for attach or detach + struct extport_info *ext_port; /* for attach or detach * pnic/generic delete all * vhbas/allvnics need no * parameters */ @@ -362,7 +356,7 @@ struct add_vbus_guestpart { }; struct del_vbus_guestpart { - u32 busNo; /* bus number to be deleted */ + u32 bus_no; /* bus number to be deleted */ /* once we start using the bus's channel, add can dump busNo * into the channel header and then delete will need only one * parameter, chanptr. */ @@ -370,9 +364,9 @@ struct del_vbus_guestpart { struct add_virt_guestpart { void __iomem *chanptr; /* pointer to data channel */ - u32 busNo; /* bus number for the operation */ - u32 deviceNo; /* number of device on the bus */ - uuid_le devInstGuid; /* instance guid for device */ + u32 bus_no; /* bus number for the operation */ + u32 device_no; /* number of device on the bus */ + uuid_le instance_uuid; /* instance guid for device */ struct InterruptInfo intr; /* recv/send interrupt info */ /* recvInterruptHandle contains info needed in order to * register to receive interrupts on the data channel. @@ -395,8 +389,8 @@ struct del_virt_guestpart { }; struct init_chipset_guestpart { - u32 busCount; /* indicates the max number of busses */ - u32 switchCount; /* indicates the max number of switches */ + u32 bus_count; /* indicates the max number of busses */ + u32 switch_count; /* indicates the max number of switches */ }; struct guest_msgs { @@ -423,19 +417,4 @@ struct guest_msgs { }; -#ifndef __xg -#define __xg(x) ((volatile long *)(x)) -#endif - -/* -* Below code is a copy of Linux kernel's cmpxchg function located at -* this place -* http://tcsxeon:8080/source/xref/00trunk-AppOS-linux/include/asm-x86/cmpxchg_64.h#84 -* Reason for creating our own version of cmpxchg along with -* UISLIB_LOCK_PREFIX is to make the operation atomic even for non SMP -* guests. -*/ - -#define uislibcmpxchg64(p, o, n, s) cmpxchg(p, o, n) - #endif /* __UISQUEUE_H__ */ diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h index 26837771b43f..aa86ade7cb13 100644 --- a/drivers/staging/unisys/include/uisthread.h +++ b/drivers/staging/unisys/include/uisthread.h @@ -19,11 +19,9 @@ /* Unisys thread utilities header */ /*****************************************************************************/ - #ifndef __UISTHREAD_H__ #define __UISTHREAD_H__ - #include "linux/completion.h" struct uisthread_info { @@ -33,7 +31,6 @@ struct uisthread_info { struct completion has_stopped; }; - /* returns 0 for failure, 1 for success */ int uisthread_start( struct uisthread_info *thrinfo, diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index a1c193c5827e..74e7cf65502c 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -84,6 +84,7 @@ static inline void __iomem * dbg_ioremap_cache(u64 addr, unsigned long size, char *file, int line) { void __iomem *new; + new = ioremap_cache(addr, size); return new; } @@ -94,6 +95,7 @@ static inline void * dbg_ioremap(u64 addr, unsigned long size, char *file, int line) { void *new; + new = ioremap(addr, size); return new; } @@ -112,7 +114,7 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, char *format, ...); int uisctrl_register_req_handler(int type, void *fptr, - ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo); + ULTRA_VBUS_DEVICEINFO *chipset_driver_info); int uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, const char *switch_type_name, int (*fptr)(struct io_msgs *), @@ -220,7 +222,7 @@ unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, struct phys_info frags[]); static inline unsigned int -Issue_VMCALL_IO_CONTROLVM_ADDR(u64 *ControlAddress, u32 *ControlBytes) +issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) { VMCALL_IO_CONTROLVM_ADDR_PARAMS params; int result = VMCALL_SUCCESS; @@ -229,13 +231,13 @@ Issue_VMCALL_IO_CONTROLVM_ADDR(u64 *ControlAddress, u32 *ControlBytes) physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) { - *ControlAddress = params.ChannelAddress; - *ControlBytes = params.ChannelBytes; + *control_addr = params.ChannelAddress; + *control_bytes = params.ChannelBytes; } return result; } -static inline unsigned int Issue_VMCALL_IO_DIAG_ADDR(u64 *DiagChannelAddress) +static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr) { VMCALL_IO_DIAG_ADDR_PARAMS params; int result = VMCALL_SUCCESS; @@ -244,12 +246,11 @@ static inline unsigned int Issue_VMCALL_IO_DIAG_ADDR(u64 *DiagChannelAddress) physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) - *DiagChannelAddress = params.ChannelAddress; + *diag_channel_addr = params.ChannelAddress; return result; } -static inline unsigned int -Issue_VMCALL_IO_VISORSERIAL_ADDR(u64 *DiagChannelAddress) +static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr) { VMCALL_IO_VISORSERIAL_ADDR_PARAMS params; int result = VMCALL_SUCCESS; @@ -258,11 +259,11 @@ Issue_VMCALL_IO_VISORSERIAL_ADDR(u64 *DiagChannelAddress) physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) - *DiagChannelAddress = params.ChannelAddress; + *channel_addr = params.ChannelAddress; return result; } -static inline s64 Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(void) +static inline s64 issue_vmcall_query_guest_virtual_time_offset(void) { u64 result = VMCALL_SUCCESS; u64 physaddr = 0; @@ -272,7 +273,7 @@ static inline s64 Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(void) return result; } -static inline s64 Issue_VMCALL_MEASUREMENT_DO_NOTHING(void) +static inline s64 issue_vmcall_measurement_do_nothing(void) { u64 result = VMCALL_SUCCESS; u64 physaddr = 0; @@ -289,7 +290,7 @@ struct log_info_t { unsigned long long min_delta[64]; }; -static inline int Issue_VMCALL_UPDATE_PHYSICAL_TIME(u64 adjustment) +static inline int issue_vmcall_update_physical_time(u64 adjustment) { int result = VMCALL_SUCCESS; @@ -297,21 +298,20 @@ static inline int Issue_VMCALL_UPDATE_PHYSICAL_TIME(u64 adjustment) return result; } -static inline unsigned int -Issue_VMCALL_CHANNEL_MISMATCH(const char *ChannelName, - const char *ItemName, - u32 SourceLineNumber, const char *path_n_fn) +static inline unsigned int issue_vmcall_channel_mismatch(const char *chname, + const char *item_name, u32 line_no, + const char *path_n_fn) { VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS params; int result = VMCALL_SUCCESS; u64 physaddr; char *last_slash = NULL; - strlcpy(params.ChannelName, ChannelName, + strlcpy(params.ChannelName, chname, lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ChannelName)); - strlcpy(params.ItemName, ItemName, + strlcpy(params.ItemName, item_name, lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ItemName)); - params.SourceLineNumber = SourceLineNumber; + params.SourceLineNumber = line_no; last_slash = strrchr(path_n_fn, '/'); if (last_slash != NULL) { @@ -330,7 +330,7 @@ Issue_VMCALL_CHANNEL_MISMATCH(const char *ChannelName, return result; } -static inline unsigned int Issue_VMCALL_FATAL_BYE_BYE(void) +static inline unsigned int issue_vmcall_fatal(void) { int result = VMCALL_SUCCESS; u64 physaddr = 0; @@ -347,10 +347,10 @@ void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln); #define UISCACHEFREE(cur_pool, p) \ uislib_cache_free(cur_pool, p, __FILE__, __LINE__) -void uislib_enable_channel_interrupts(u32 busNo, u32 devNo, +void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, int (*interrupt)(void *), void *interrupt_context); -void uislib_disable_channel_interrupts(u32 busNo, u32 devNo); -void uislib_force_channel_interrupt(u32 busNo, u32 devNo); +void uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no); +void uislib_force_channel_interrupt(u32 bus_no, u32 dev_no); #endif /* __UISUTILS__H__ */ diff --git a/drivers/staging/unisys/include/uniklog.h b/drivers/staging/unisys/include/uniklog.h index 6178cc46f7c1..ecd1bdb6d097 100644 --- a/drivers/staging/unisys/include/uniklog.h +++ b/drivers/staging/unisys/include/uniklog.h @@ -23,7 +23,6 @@ #ifndef __UNIKLOG_H__ #define __UNIKLOG_H__ - #include <linux/printk.h> /* @@ -122,7 +121,6 @@ } \ } while (0) - /* * # LOGERR * diff --git a/drivers/staging/unisys/include/vbushelper.h b/drivers/staging/unisys/include/vbushelper.h index ed943759634a..1bde549ec0df 100644 --- a/drivers/staging/unisys/include/vbushelper.h +++ b/drivers/staging/unisys/include/vbushelper.h @@ -1,6 +1,6 @@ /* vbushelper.h * - * Copyright © 2011 - 2013 UNISYS CORPORATION + * Copyright (C) 2011 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -25,20 +25,22 @@ #define TARGET_HOSTNAME "linuxguest" -static inline void -BusDeviceInfo_Init(ULTRA_VBUS_DEVICEINFO *pBusDeviceInfo, - const char *deviceType, const char *driverName, - const char *ver, const char *verTag) +static inline void bus_device_info_init( + ULTRA_VBUS_DEVICEINFO * bus_device_info_ptr, + const char *dev_type, const char *drv_name, + const char *ver, const char *ver_tag) { - memset(pBusDeviceInfo, 0, sizeof(ULTRA_VBUS_DEVICEINFO)); - snprintf(pBusDeviceInfo->devType, sizeof(pBusDeviceInfo->devType), - "%s", (deviceType) ? deviceType : "unknownType"); - snprintf(pBusDeviceInfo->drvName, sizeof(pBusDeviceInfo->drvName), - "%s", (driverName) ? driverName : "unknownDriver"); - snprintf(pBusDeviceInfo->infoStrings, - sizeof(pBusDeviceInfo->infoStrings), "%s\t%s\t%s", + memset(bus_device_info_ptr, 0, sizeof(ULTRA_VBUS_DEVICEINFO)); + snprintf(bus_device_info_ptr->devType, + sizeof(bus_device_info_ptr->devType), + "%s", (dev_type) ? dev_type : "unknownType"); + snprintf(bus_device_info_ptr->drvName, + sizeof(bus_device_info_ptr->drvName), + "%s", (drv_name) ? drv_name : "unknownDriver"); + snprintf(bus_device_info_ptr->infoStrings, + sizeof(bus_device_info_ptr->infoStrings), "%s\t%s\t%s", (ver) ? ver : "unknownVer", - (verTag) ? verTag : "unknownVerTag", + (ver_tag) ? ver_tag : "unknownVerTag", TARGET_HOSTNAME); } diff --git a/drivers/staging/unisys/uislib/Kconfig b/drivers/staging/unisys/uislib/Kconfig index 8d87d9c81c66..6b134e267904 100644 --- a/drivers/staging/unisys/uislib/Kconfig +++ b/drivers/staging/unisys/uislib/Kconfig @@ -4,7 +4,7 @@ config UNISYS_UISLIB tristate "Unisys uislib driver" - depends on UNISYSSPAR && UNISYS_VISORCHIPSET && UNISYS_CHANNELSTUB + depends on UNISYSSPAR && UNISYS_VISORCHIPSET && UNISYS_CHANNELSTUB && HAS_IOMEM ---help--- If you say Y here, you will enable the Unisys uislib driver. diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 63c91cd6fdcc..706f1c0c2c6e 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -25,7 +25,8 @@ #include <linux/module.h> #include <linux/debugfs.h> -#include "commontypes.h" +#include <linux/types.h> +#include <linux/uuid.h> #include <linux/version.h> #include "uniklog.h" @@ -133,6 +134,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes) { void __iomem *rc = NULL; void __iomem *pChan = uislib_ioremap_cache(channelAddr, channelBytes); + if (!pChan) { LOGERR("CONTROLVM_BUS_CREATE error: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", (unsigned long long) channelAddr, @@ -229,6 +231,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) /* the msg is bound for virtpci; send guest_msgs struct to callback */ if (!msg->hdr.Flags.server) { struct guest_msgs cmd; + cmd.msgtype = GUEST_ADD_VBUS; cmd.add_vbus.busNo = busNo; cmd.add_vbus.chanptr = bus->pBusChannel; @@ -273,52 +276,19 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) { int i; struct bus_info *bus, *prev = NULL; + struct guest_msgs cmd; u32 busNo; busNo = msg->cmd.destroyBus.busNo; - /* find and delete the bus */ read_lock(&BusListLock); - for (bus = BusListHead; bus; prev = bus, bus = bus->next) { - if (bus->busNo == busNo) { - /* found the bus - ensure that all device - * slots are NULL - */ - for (i = 0; i < bus->deviceCount; i++) { - if (bus->device[i] != NULL) { - LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.", - i, busNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED; - } - } - read_unlock(&BusListLock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (!msg->hdr.Flags.server) { - struct guest_msgs cmd; - cmd.msgtype = GUEST_DEL_VBUS; - cmd.del_vbus.busNo = busNo; - if (!VirtControlChanFunc) { - LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered."); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - if (!VirtControlChanFunc(&cmd)) { - LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error."); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } - } - /* remove the bus from the list */ - write_lock(&BusListLock); - if (prev) /* not at head */ - prev->next = bus->next; - else - BusListHead = bus->next; - BusListCount--; - write_unlock(&BusListLock); + + bus = BusListHead; + while (bus) { + if (bus->busNo == busNo) break; - } + prev = bus; + bus = bus->next; } if (!bus) { @@ -327,6 +297,44 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) read_unlock(&BusListLock); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } + + /* verify that this bus has no devices. */ + for (i = 0; i < bus->deviceCount; i++) { + if (bus->device[i] != NULL) { + LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.", + i, busNo); + read_unlock(&BusListLock); + return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED; + } + } + read_unlock(&BusListLock); + + if (msg->hdr.Flags.server) + goto remove; + + /* client messages require us to call the virtpci callback associated + with this bus. */ + cmd.msgtype = GUEST_DEL_VBUS; + cmd.del_vbus.bus_no = busNo; + if (!VirtControlChanFunc) { + LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered."); + return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; + } + if (!VirtControlChanFunc(&cmd)) { + LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error."); + return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + } + + /* finally, remove the bus from the list */ +remove: + write_lock(&BusListLock); + if (prev) /* not at head */ + prev->next = bus->next; + else + BusListHead = bus->next; + BusListCount--; + write_unlock(&BusListLock); + if (bus->pBusChannel) { uislib_iounmap(bus->pBusChannel); bus->pBusChannel = NULL; @@ -360,18 +368,18 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; } - dev->channelTypeGuid = msg->cmd.createDevice.dataTypeGuid; + dev->channel_uuid = msg->cmd.createDevice.dataTypeGuid; dev->intr = msg->cmd.createDevice.intr; - dev->channelAddr = msg->cmd.createDevice.channelAddr; - dev->busNo = busNo; - dev->devNo = devNo; + dev->channel_addr = msg->cmd.createDevice.channelAddr; + dev->bus_no = busNo; + dev->dev_no = devNo; sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ sprintf(dev->devid, "vbus%u:dev%u", (unsigned) busNo, (unsigned) devNo); /* map the channel memory for the device. */ if (msg->hdr.Flags.testMessage) - dev->chanptr = (void __iomem *)__va(dev->channelAddr); + dev->chanptr = (void __iomem *)__va(dev->channel_addr); else { - pReqHandler = ReqHandlerFind(dev->channelTypeGuid); + pReqHandler = ReqHandlerFind(dev->channel_uuid); if (pReqHandler) /* generic service handler registered for this * channel @@ -387,11 +395,11 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) goto Away; } dev->chanptr = - uislib_ioremap_cache(dev->channelAddr, + uislib_ioremap_cache(dev->channel_addr, msg->cmd.createDevice.channelBytes); if (!dev->chanptr) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", - dev->channelAddr, + dev->channel_addr, msg->cmd.createDevice.channelBytes); result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED; POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, @@ -399,8 +407,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) goto Away; } } - dev->devInstGuid = msg->cmd.createDevice.devInstGuid; - dev->channelBytes = msg->cmd.createDevice.channelBytes; + dev->instance_uuid = msg->cmd.createDevice.devInstGuid; + dev->channel_bytes = msg->cmd.createDevice.channelBytes; read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { @@ -433,7 +441,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) */ if (!msg->hdr.Flags.server) { struct guest_msgs cmd; - if (!uuid_le_cmp(dev->channelTypeGuid, + + if (!uuid_le_cmp(dev->channel_uuid, UltraVhbaChannelProtocolGuid)) { wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> @@ -452,13 +461,13 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } cmd.msgtype = GUEST_ADD_VHBA; cmd.add_vhba.chanptr = dev->chanptr; - cmd.add_vhba.busNo = busNo; - cmd.add_vhba.deviceNo = devNo; - cmd.add_vhba.devInstGuid = - dev->devInstGuid; + cmd.add_vhba.bus_no = busNo; + cmd.add_vhba.device_no = devNo; + cmd.add_vhba.instance_uuid = + dev->instance_uuid; cmd.add_vhba.intr = dev->intr; } else - if (!uuid_le_cmp(dev->channelTypeGuid, + if (!uuid_le_cmp(dev->channel_uuid, UltraVnicChannelProtocolGuid)) { wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> @@ -477,10 +486,10 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } cmd.msgtype = GUEST_ADD_VNIC; cmd.add_vnic.chanptr = dev->chanptr; - cmd.add_vnic.busNo = busNo; - cmd.add_vnic.deviceNo = devNo; - cmd.add_vnic.devInstGuid = - dev->devInstGuid; + cmd.add_vnic.bus_no = busNo; + cmd.add_vnic.device_no = devNo; + cmd.add_vnic.instance_uuid = + dev->instance_uuid; cmd.add_vhba.intr = dev->intr; } else { LOGERR("CONTROLVM_DEVICE_CREATE Failed: unknown channelTypeGuid.\n"); @@ -539,6 +548,7 @@ pause_device(CONTROLVM_MESSAGE *msg) struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; + int retval = CONTROLVM_RESP_SUCCESS; busNo = msg->cmd.deviceChangeState.busNo; devNo = msg->cmd.deviceChangeState.devNo; @@ -550,58 +560,53 @@ pause_device(CONTROLVM_MESSAGE *msg) if (devNo >= bus->deviceCount) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).", devNo, bus->deviceCount); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } - /* make sure this device exists */ - dev = bus->device[devNo]; - if (!dev) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.", - devNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - read_unlock(&BusListLock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVhbaChannelProtocolGuid)) { - cmd.msgtype = GUEST_PAUSE_VHBA; - cmd.pause_vhba.chanptr = dev->chanptr; - } else - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVnicChannelProtocolGuid)) { - cmd.msgtype = GUEST_PAUSE_VNIC; - cmd.pause_vnic.chanptr = dev->chanptr; + retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n"); - return - CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - - if (!VirtControlChanFunc) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - - if (!VirtControlChanFunc(&cmd)) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error."); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + /* make sure this device exists */ + dev = bus->device[devNo]; + if (!dev) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.", + devNo); + retval = + CONTROLVM_RESP_ERROR_ALREADY_DONE; + } } break; } } - if (!bus) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: bus %d does not exist", busNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_BUS_INVALID; + retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - - return CONTROLVM_RESP_SUCCESS; + read_unlock(&BusListLock); + if (retval == CONTROLVM_RESP_SUCCESS) { + /* the msg is bound for virtpci; send + * guest_msgs struct to callback + */ + if (!uuid_le_cmp(dev->channel_uuid, + UltraVhbaChannelProtocolGuid)) { + cmd.msgtype = GUEST_PAUSE_VHBA; + cmd.pause_vhba.chanptr = dev->chanptr; + } else if (!uuid_le_cmp(dev->channel_uuid, + UltraVnicChannelProtocolGuid)) { + cmd.msgtype = GUEST_PAUSE_VNIC; + cmd.pause_vnic.chanptr = dev->chanptr; + } else { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n"); + return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; + } + if (!VirtControlChanFunc) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); + return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; + } + if (!VirtControlChanFunc(&cmd)) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error."); + return + CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + } + } + return retval; } static int @@ -611,6 +616,7 @@ resume_device(CONTROLVM_MESSAGE *msg) struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; + int retval = CONTROLVM_RESP_SUCCESS; busNo = msg->cmd.deviceChangeState.busNo; devNo = msg->cmd.deviceChangeState.devNo; @@ -622,45 +628,16 @@ resume_device(CONTROLVM_MESSAGE *msg) if (devNo >= bus->deviceCount) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).", devNo, bus->deviceCount); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } - /* make sure this device exists */ - dev = bus->device[devNo]; - if (!dev) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.", - devNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - read_unlock(&BusListLock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVhbaChannelProtocolGuid)) { - cmd.msgtype = GUEST_RESUME_VHBA; - cmd.resume_vhba.chanptr = dev->chanptr; - } else - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVnicChannelProtocolGuid)) { - cmd.msgtype = GUEST_RESUME_VNIC; - cmd.resume_vnic.chanptr = dev->chanptr; + retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n"); - return - CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - - if (!VirtControlChanFunc) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - - if (!VirtControlChanFunc(&cmd)) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error."); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + /* make sure this device exists */ + dev = bus->device[devNo]; + if (!dev) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.", + devNo); + retval = + CONTROLVM_RESP_ERROR_ALREADY_DONE; + } } break; } @@ -669,11 +646,36 @@ resume_device(CONTROLVM_MESSAGE *msg) if (!bus) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: bus %d does not exist", busNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_BUS_INVALID; + retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - - return CONTROLVM_RESP_SUCCESS; + read_unlock(&BusListLock); + /* the msg is bound for virtpci; send + * guest_msgs struct to callback + */ + if (retval == CONTROLVM_RESP_SUCCESS) { + if (!uuid_le_cmp(dev->channel_uuid, + UltraVhbaChannelProtocolGuid)) { + cmd.msgtype = GUEST_RESUME_VHBA; + cmd.resume_vhba.chanptr = dev->chanptr; + } else if (!uuid_le_cmp(dev->channel_uuid, + UltraVnicChannelProtocolGuid)) { + cmd.msgtype = GUEST_RESUME_VNIC; + cmd.resume_vnic.chanptr = dev->chanptr; + } else { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n"); + return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; + } + if (!VirtControlChanFunc) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); + return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; + } + if (!VirtControlChanFunc(&cmd)) { + LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error."); + return + CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + } + } + return retval; } static int @@ -683,6 +685,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; + int retval = CONTROLVM_RESP_SUCCESS; busNo = msg->cmd.destroyDevice.busNo; devNo = msg->cmd.destroyDevice.devNo; @@ -694,63 +697,18 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) /* make sure the device number is valid */ if (devNo >= bus->deviceCount) { LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).", - devNo, bus->deviceCount); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } - /* make sure this device exists */ - dev = bus->device[devNo]; - if (!dev) { - LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.", - devNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - read_unlock(&BusListLock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVhbaChannelProtocolGuid)) { - cmd.msgtype = GUEST_DEL_VHBA; - cmd.del_vhba.chanptr = dev->chanptr; - } else - if (!uuid_le_cmp(dev->channelTypeGuid, - UltraVnicChannelProtocolGuid)) { - cmd.msgtype = GUEST_DEL_VNIC; - cmd.del_vnic.chanptr = dev->chanptr; + devNo, bus->deviceCount); + retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { - LOGERR("CONTROLVM_DEVICE_DESTROY Failed: unknown channelTypeGuid.\n"); - return - CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - - if (!VirtControlChanFunc) { - LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered."); - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - - if (!VirtControlChanFunc(&cmd)) { - LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error."); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } -/* you must disable channel interrupts BEFORE you unmap the channel, - * because if you unmap first, there may still be some activity going - * on which accesses the channel and you will get a "unable to handle - * kernel paging request" - */ - if (dev->polling) { - LOGINF("calling uislib_disable_channel_interrupts"); - uislib_disable_channel_interrupts(busNo, devNo); - } - /* unmap the channel memory for the device. */ - if (!msg->hdr.Flags.testMessage) { - LOGINF("destroy_device, doing iounmap"); - uislib_iounmap(dev->chanptr); + /* make sure this device exists */ + dev = bus->device[devNo]; + if (!dev) { + LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.", + devNo); + retval = + CONTROLVM_RESP_ERROR_ALREADY_DONE; + } } - kfree(dev); - bus->device[devNo] = NULL; break; } } @@ -758,11 +716,54 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) if (!bus) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: bus %d does not exist", busNo); - read_unlock(&BusListLock); - return CONTROLVM_RESP_ERROR_BUS_INVALID; + retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - - return CONTROLVM_RESP_SUCCESS; + read_unlock(&BusListLock); + if (retval == CONTROLVM_RESP_SUCCESS) { + /* the msg is bound for virtpci; send + * guest_msgs struct to callback + */ + if (!uuid_le_cmp(dev->channel_uuid, + UltraVhbaChannelProtocolGuid)) { + cmd.msgtype = GUEST_DEL_VHBA; + cmd.del_vhba.chanptr = dev->chanptr; + } else if (!uuid_le_cmp(dev->channel_uuid, + UltraVnicChannelProtocolGuid)) { + cmd.msgtype = GUEST_DEL_VNIC; + cmd.del_vnic.chanptr = dev->chanptr; + } else { + LOGERR("CONTROLVM_DEVICE_DESTROY Failed: unknown channelTypeGuid.\n"); + return + CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; + } + if (!VirtControlChanFunc) { + LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered."); + return + CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; + } + if (!VirtControlChanFunc(&cmd)) { + LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error."); + return + CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + } +/* you must disable channel interrupts BEFORE you unmap the channel, + * because if you unmap first, there may still be some activity going + * on which accesses the channel and you will get a "unable to handle + * kernel paging request" + */ + if (dev->polling) { + LOGINF("calling uislib_disable_channel_interrupts"); + uislib_disable_channel_interrupts(busNo, devNo); + } + /* unmap the channel memory for the device. */ + if (!msg->hdr.Flags.testMessage) { + LOGINF("destroy_device, doing iounmap"); + uislib_iounmap(dev->chanptr); + } + kfree(dev); + bus->device[devNo] = NULL; + } + return retval; } static int @@ -1164,6 +1165,7 @@ uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln) * invoke oom killer), which will probably cripple the system. */ void *p = kmem_cache_alloc(cur_pool, GFP_ATOMIC | __GFP_NORETRY); + if (p == NULL) { LOGERR("uislib_malloc failed to alloc uiscmdrsp @%s:%d", fn, ln); @@ -1339,6 +1341,7 @@ Process_Incoming(void *v) unsigned long long cur_cycles, old_cycles, idle_cycles, delta_cycles; struct list_head *new_tail = NULL; int i; + UIS_DAEMONIZE("dev_incoming"); for (i = 0; i < 16; i++) { old_cycles = get_cycles(); @@ -1361,18 +1364,19 @@ Process_Incoming(void *v) struct device_info *dev = NULL; /* poll each channel for input */ - LOCKSEM_UNINTERRUPTIBLE(&Lock_Polling_Device_Channels); + down(&Lock_Polling_Device_Channels); new_tail = NULL; list_for_each_safe(lelt, tmp, &List_Polling_Device_Channels) { int rc = 0; + dev = list_entry(lelt, struct device_info, list_polling_device_channels); - LOCKSEM_UNINTERRUPTIBLE(&dev->interrupt_callback_lock); + down(&dev->interrupt_callback_lock); if (dev->interrupt) rc = dev->interrupt(dev->interrupt_context); else continue; - UNLOCKSEM(&dev->interrupt_callback_lock); + up(&dev->interrupt_callback_lock); if (rc) { /* dev->interrupt returned, but there * is still more work to do. @@ -1399,7 +1403,7 @@ Process_Incoming(void *v) tot_moved_to_tail_cnt++; list_move_tail(new_tail, &List_Polling_Device_Channels); } - UNLOCKSEM(&Lock_Polling_Device_Channels); + up(&Lock_Polling_Device_Channels); cur_cycles = get_cycles(); delta_cycles = cur_cycles - old_cycles; old_cycles = cur_cycles; @@ -1458,25 +1462,26 @@ Initialize_incoming_thread(void) * function. */ void -uislib_enable_channel_interrupts(u32 busNo, u32 devNo, +uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, int (*interrupt)(void *), void *interrupt_context) { struct device_info *dev; - dev = find_dev(busNo, devNo); + + dev = find_dev(bus_no, dev_no); if (!dev) { - LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (busNo), - (int) (devNo)); + LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (bus_no), + (int) (dev_no)); return; } - LOCKSEM_UNINTERRUPTIBLE(&Lock_Polling_Device_Channels); + down(&Lock_Polling_Device_Channels); Initialize_incoming_thread(); dev->interrupt = interrupt; dev->interrupt_context = interrupt_context; dev->polling = TRUE; list_add_tail(&(dev->list_polling_device_channels), &List_Polling_Device_Channels); - UNLOCKSEM(&Lock_Polling_Device_Channels); + up(&Lock_Polling_Device_Channels); } EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts); @@ -1484,20 +1489,21 @@ EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts); * Process_Incoming(). */ void -uislib_disable_channel_interrupts(u32 busNo, u32 devNo) +uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no) { struct device_info *dev; - dev = find_dev(busNo, devNo); + + dev = find_dev(bus_no, dev_no); if (!dev) { - LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (busNo), - (int) (devNo)); + LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (bus_no), + (int) (dev_no)); return; } - LOCKSEM_UNINTERRUPTIBLE(&Lock_Polling_Device_Channels); + down(&Lock_Polling_Device_Channels); list_del(&dev->list_polling_device_channels); dev->polling = FALSE; dev->interrupt = NULL; - UNLOCKSEM(&Lock_Polling_Device_Channels); + up(&Lock_Polling_Device_Channels); } EXPORT_SYMBOL_GPL(uislib_disable_channel_interrupts); @@ -1517,7 +1523,7 @@ static DECLARE_WORK(Work_wakeup_polling_device_channels, * your device might have more requests. */ void -uislib_force_channel_interrupt(u32 busNo, u32 devNo) +uislib_force_channel_interrupt(u32 bus_no, u32 dev_no) { if (en_smart_wakeup == 0) return; @@ -1612,7 +1618,6 @@ uislib_mod_exit(void) debugfs_remove(dir_debugfs); DBGINF("goodbye.\n"); - return; } module_init(uislib_mod_init); diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 84eafca5e45c..44208841bd5a 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -34,42 +34,40 @@ /* Exported functions */ /*****************************************************/ unsigned long long -uisqueue_InterlockedOr(unsigned long long __iomem *Target, - unsigned long long Set) +uisqueue_interlocked_or(unsigned long long __iomem *tgt, + unsigned long long set) { unsigned long long i; unsigned long long j; - j = readq(Target); + j = readq(tgt); do { i = j; - j = uislibcmpxchg64((__force unsigned long long *)Target, - i, i | Set, sizeof(*(Target))); + j = cmpxchg((__force unsigned long long *)tgt, i, i | set); } while (i != j); return j; } -EXPORT_SYMBOL_GPL(uisqueue_InterlockedOr); +EXPORT_SYMBOL_GPL(uisqueue_interlocked_or); unsigned long long -uisqueue_InterlockedAnd(unsigned long long __iomem *Target, - unsigned long long Set) +uisqueue_interlocked_and(unsigned long long __iomem *tgt, + unsigned long long set) { unsigned long long i; unsigned long long j; - j = readq(Target); + j = readq(tgt); do { i = j; - j = uislibcmpxchg64((__force unsigned long long *)Target, - i, i & Set, sizeof(*(Target))); + j = cmpxchg((__force unsigned long long *)tgt, i, i & set); } while (i != j); return j; } -EXPORT_SYMBOL_GPL(uisqueue_InterlockedAnd); +EXPORT_SYMBOL_GPL(uisqueue_interlocked_and); static u8 do_locked_client_insert(struct uisqueue_info *queueinfo, @@ -80,41 +78,18 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, u64 interruptHandle, u8 *channelId) { unsigned long flags; - unsigned char queueWasEmpty; - unsigned int locked = 0; - unsigned int acquired = 0; u8 rc = 0; spin_lock_irqsave(lock, flags); - locked = 1; - if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(queueinfo->chan, channelId, NULL)) - goto Away; - - acquired = 1; - - queueWasEmpty = visor_signalqueue_empty(queueinfo->chan, whichqueue); - if (!visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) - goto Away; - ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, NULL); - acquired = 0; - spin_unlock_irqrestore(lock, flags); - locked = 0; - - queueinfo->packets_sent++; - - rc = 1; -Away: - if (acquired) { - ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, - NULL); - acquired = 0; + goto unlock; + if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) { + queueinfo->packets_sent++; + rc = 1; } - if (locked) { - spin_unlock_irqrestore((spinlock_t *) lock, flags); - locked = 0; - } - + ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, NULL); +unlock: + spin_unlock_irqrestore((spinlock_t *)lock, flags); return rc; } @@ -123,14 +98,14 @@ uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, struct uiscmdrsp *cmdrsp, unsigned int whichqueue, void *insertlock, - unsigned char issueInterruptIfEmpty, - u64 interruptHandle, - char oktowait, u8 *channelId) + unsigned char issue_irq_if_empty, + u64 irq_handle, + char oktowait, u8 *channel_id) { while (!do_locked_client_insert(queueinfo, whichqueue, cmdrsp, (spinlock_t *) insertlock, - issueInterruptIfEmpty, - interruptHandle, channelId)) { + issue_irq_if_empty, + irq_handle, channel_id)) { if (oktowait != OK_TO_WAIT) { LOGERR("****FAILED visor_signal_insert failed; cannot wait; insert aborted\n"); return 0; /* failed to queue */ diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c index c93ab04c3cfc..c0fc812f751e 100644 --- a/drivers/staging/unisys/uislib/uisthread.c +++ b/drivers/staging/unisys/uislib/uisthread.c @@ -62,6 +62,7 @@ uisthread_stop(struct uisthread_info *thrinfo) { int ret; int stopped = 0; + if (thrinfo->id == 0) return; /* thread not running */ diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index ee26e009b400..8ff6d26ff00b 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -17,7 +17,8 @@ #include <linux/string.h> #include <linux/slab.h> -#include <commontypes.h> +#include <linux/types.h> +#include <linux/uuid.h> #include <linux/spinlock.h> #include <linux/list.h> #include "uniklog.h" @@ -74,7 +75,7 @@ EXPORT_SYMBOL_GPL(uisutil_add_proc_line_ex); int uisctrl_register_req_handler(int type, void *fptr, - ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo) + ULTRA_VBUS_DEVICEINFO *chipset_driver_info) { LOGINF("type = %d, fptr = 0x%p.\n", type, fptr); @@ -95,8 +96,8 @@ uisctrl_register_req_handler(int type, void *fptr, LOGERR("invalid type %d.\n", type); return 0; } - if (chipset_DriverInfo) - BusDeviceInfo_Init(chipset_DriverInfo, "chipset", "uislib", + if (chipset_driver_info) + bus_device_info_init(chipset_driver_info, "chipset", "uislib", VERSION, NULL); return 1; @@ -117,6 +118,7 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, { ReqHandlerInfo_t *pReqHandlerInfo; int rc = 0; /* assume failure */ + LOGINF("type=%pUL, controlfunc=0x%p.\n", &switchTypeGuid, controlfunc); if (!controlfunc) { @@ -148,7 +150,7 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, Away: if (rc) { if (chipset_DriverInfo) - BusDeviceInfo_Init(chipset_DriverInfo, "chipset", + bus_device_info_init(chipset_DriverInfo, "chipset", "uislib", VERSION, NULL); } else LOGERR("failed to register type %pUL.\n", &switchTypeGuid); @@ -161,6 +163,7 @@ int uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid) { int rc = 0; /* assume failure */ + LOGINF("type=%pUL.\n", &switchTypeGuid); if (ReqHandlerDel(switchTypeGuid) < 0) { LOGERR("failed to remove %pUL from server list\n", @@ -226,38 +229,41 @@ uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, void *skb_in, offset += size; count++; } - if (numfrags) { - if ((count + numfrags) > frags_max) { - LOGERR("**** FAILED %s frags array too small: max:%d count+nr_frags:%d\n", - calling_ctx, frags_max, count + numfrags); - return -1; /* failure */ - } + if (!numfrags) + goto dolist; - for (ii = 0; ii < numfrags; ii++) { - count = add_physinfo_entries(page_to_pfn(skb_frag_page(&skb_shinfo(skb)->frags[ii])), /* pfn */ - skb_shinfo(skb)->frags[ii]. - page_offset, - skb_shinfo(skb)->frags[ii]. - size, count, frags_max, - frags); - if (count == 0) { - LOGERR("**** FAILED to add physinfo entries\n"); - return -1; /* failure */ - } + if ((count + numfrags) > frags_max) { + LOGERR("**** FAILED %s frags array too small: max:%d count+nr_frags:%d\n", + calling_ctx, frags_max, count + numfrags); + return -1; /* failure */ + } + + for (ii = 0; ii < numfrags; ii++) { + count = add_physinfo_entries(page_to_pfn( + skb_frag_page(&skb_shinfo(skb)->frags[ii])), + skb_shinfo(skb)->frags[ii]. + page_offset, + skb_shinfo(skb)->frags[ii]. + size, count, frags_max, + frags); + if (count == 0) { + LOGERR("**** FAILED to add physinfo entries\n"); + return -1; /* failure */ } } - if (skb_shinfo(skb)->frag_list) { + +dolist: if (skb_shinfo(skb)->frag_list) { struct sk_buff *skbinlist; int c; + for (skbinlist = skb_shinfo(skb)->frag_list; skbinlist; skbinlist = skbinlist->next) { c = uisutil_copy_fragsinfo_from_skb("recursive", - skbinlist, - skbinlist->len - - skbinlist->data_len, - frags_max - count, - &frags[count]); + skbinlist, + skbinlist->len - skbinlist->data_len, + frags_max - count, + &frags[count]); if (c == -1) { LOGERR("**** FAILED recursive call failed\n"); return -1; @@ -306,6 +312,7 @@ ReqHandlerFind(uuid_le switchTypeGuid) { struct list_head *lelt, *tmp; ReqHandlerInfo_t *entry = NULL; + spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, ReqHandlerInfo_t, list_link); @@ -324,6 +331,7 @@ ReqHandlerDel(uuid_le switchTypeGuid) struct list_head *lelt, *tmp; ReqHandlerInfo_t *entry = NULL; int rc = -1; + spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, ReqHandlerInfo_t, list_link); diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 049eeab08bac..938e2c82c1ab 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -436,7 +436,7 @@ virthba_ISR(int irq, void *dev_id) 0)) { virthbainfo->interrupts_disabled++; mask = ~ULTRA_CHANNEL_ENABLE_INTS; - rc1 = uisqueue_InterlockedAnd(virthbainfo->flags_addr, mask); + rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask); } if (visor_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) { virthbainfo->interrupts_notme++; @@ -517,7 +517,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) (unsigned short) (virtpcidev->scsi.max.max_io_size / PAGE_SIZE); if (scsihost->sg_tablesize > MAX_PHYS_INFO) scsihost->sg_tablesize = MAX_PHYS_INFO; - LOGINF("scsihost->max_channel=%u, max_id=%u, max_lun=%u, cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n", + LOGINF("scsihost->max_channel=%u, max_id=%u, max_lun=%llu, cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n", scsihost->max_channel, scsihost->max_id, scsihost->max_lun, scsihost->cmd_per_lun, scsihost->max_sectors, scsihost->sg_tablesize); @@ -627,9 +627,9 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) virthbainfo->interrupt_vector); mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_InterlockedAnd(Features_addr, mask); + uisqueue_interlocked_and(Features_addr, mask); mask = ULTRA_IO_DRIVER_ENABLES_INTS; - uisqueue_InterlockedOr(Features_addr, mask); + uisqueue_interlocked_or(Features_addr, mask); rsltq_wait_usecs = 4000000; } @@ -746,7 +746,7 @@ forward_taskmgmt_command(TASK_MGMT_TYPES tasktype, struct scsi_device *scsidev) int notifyresult = 0xffff; wait_queue_head_t notifyevent; - LOGINF("TaskMgmt:%d %d:%d:%d\n", tasktype, + LOGINF("TaskMgmt:%d %d:%d:%llu\n", tasktype, scsidev->channel, scsidev->id, scsidev->lun); if (virthbainfo->serverdown || virthbainfo->serverchangingstate) { @@ -1105,7 +1105,6 @@ virthba_slave_destroy(struct scsi_device *scsidev) return; } } - return; } /*****************************************************/ @@ -1139,7 +1138,7 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { atomic_inc(&vdisk->error_count); - LOGERR("SCSICMD ****FAILED scsicmd:0x%p op:0x%x <%d:%d:%d:%d> 0x%x-0x%x-0x%x-0x%x-0x%x.\n", + LOGERR("SCSICMD ****FAILED scsicmd:0x%p op:0x%x <%d:%d:%d:%llu> 0x%x-0x%x-0x%x-0x%x-0x%x.\n", scsicmd, cmdrsp->scsi.cmnd[0], scsidev->host->host_no, scsidev->id, scsidev->channel, scsidev->lun, @@ -1148,7 +1147,7 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) sd->AdditionalSenseCodeQualifier); if (atomic_read(&vdisk->error_count) == VIRTHBA_ERROR_COUNT) { - LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%d>\n", + LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%llu>\n", scsidev->host->host_no, scsidev->id, scsidev->channel, scsidev->lun); } @@ -1354,7 +1353,7 @@ process_incoming_rsps(void *v) atomic_set(&virthbainfo->interrupt_rcvd, 0); /* drain queue */ drain_queue(virthbainfo, dc, cmdrsp); - rc1 = uisqueue_InterlockedOr(virthbainfo->flags_addr, mask); + rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask); if (dc->threadinfo.should_stop) break; } @@ -1458,16 +1457,16 @@ static ssize_t enable_ints_write(struct file *file, if (new_value == 1) { mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_InterlockedAnd(Features_addr, mask); + uisqueue_interlocked_and(Features_addr, mask); mask = ULTRA_IO_DRIVER_ENABLES_INTS; - uisqueue_InterlockedOr(Features_addr, mask); + uisqueue_interlocked_or(Features_addr, mask); rsltq_wait_usecs = 4000000; } else { mask = ~(ULTRA_IO_DRIVER_ENABLES_INTS | ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_InterlockedAnd(Features_addr, mask); + uisqueue_interlocked_and(Features_addr, mask); mask = ULTRA_IO_CHANNEL_IS_POLLING; - uisqueue_InterlockedOr(Features_addr, mask); + uisqueue_interlocked_or(Features_addr, mask); rsltq_wait_usecs = 4000; } } diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index d9443a968ddf..ee9f8260cd15 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -24,9 +24,11 @@ #include "uniklog.h" #include "diagnostics/appos_subsystems.h" #include "uisutils.h" -#include "commontypes.h" #include "vbuschannel.h" #include "vbushelper.h" +#include <linux/types.h> +#include <linux/io.h> +#include <linux/uuid.h> #include <linux/module.h> #include <linux/init.h> #include <linux/pci.h> @@ -39,7 +41,7 @@ #include <linux/debugfs.h> #include "version.h" #include "guestlinuxdebug.h" -#include "timskmodutils.h" +#include "timskmod.h" struct driver_private { struct kobject kobj; @@ -172,6 +174,7 @@ static inline int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem *chanptr) { int count = 120; + while (count > 0) { if (ULTRA_CHANNEL_SERVER_READY(&chanptr->ChannelHeader)) @@ -187,6 +190,7 @@ static int write_vbus_chpInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, ULTRA_VBUS_DEVICEINFO *info) { int off; + if (!chan) { LOGERR("vbus channel not present"); return -1; @@ -205,6 +209,7 @@ static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, ULTRA_VBUS_DEVICEINFO *info) { int off; + if (!chan) { LOGERR("vbus channel not present"); return -1; @@ -226,6 +231,7 @@ write_vbus_devInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, ULTRA_VBUS_DEVICEINFO *info, int devix) { int off; + if (!chan) { LOGERR("vbus channel not present"); return -1; @@ -249,6 +255,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams) { int ret; struct device *vbus; + vbus = kzalloc(sizeof(struct device), GFP_ATOMIC); POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); @@ -326,7 +333,7 @@ static int add_vhba(struct add_virt_guestpart *addparams) GET_SCSIADAPINFO_FROM_CHANPTR(addparams->chanptr); - GET_BUS_DEV(addparams->busNo); + GET_BUS_DEV(addparams->bus_no); LOGINF("Adding vhba wwnn:%x:%x config:%d-%d-%d-%d chanptr:%p\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2, @@ -383,7 +390,7 @@ add_vnic(struct add_virt_guestpart *addparams) GET_NETADAPINFO_FROM_CHANPTR(addparams->chanptr); - GET_BUS_DEV(addparams->busNo); + GET_BUS_DEV(addparams->bus_no); LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], @@ -410,12 +417,12 @@ delete_vbus(struct del_vbus_guestpart *delparams) struct device *vbus; unsigned char busid[BUS_ID_SIZE]; - GET_BUS_DEV(delparams->busNo); + GET_BUS_DEV(delparams->bus_no); /* ensure that bus has no devices? -- TBD */ LOGINF("Deleting %s\n", BUS_ID(vbus)); if (delete_vbus_device(vbus, NULL)) return 0; /* failure */ - LOGINF("Deleted vbus %d\n", delparams->busNo); + LOGINF("Deleted vbus %d\n", delparams->bus_no); return 1; } @@ -613,7 +620,7 @@ static int delete_all_virt(VIRTPCI_DEV_TYPE devtype, struct del_vbus_guestpart * unsigned char busid[BUS_ID_SIZE]; struct device *vbus; - GET_BUS_DEV(delparams->busNo); + GET_BUS_DEV(delparams->bus_no); if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) { LOGERR("**** FAILED to delete all devices; devtype:%d not vhba:%d or vnic:%d\n", @@ -785,7 +792,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, stype = "unknown"; break; } - BusDeviceInfo_Init(&devInfo, stype, + bus_device_info_init(&devInfo, stype, virtpcidrv->name, virtpcidrv->version, virtpcidrv->vertag); @@ -854,6 +861,7 @@ static int virtpci_device_remove(struct device *dev_) */ struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev_); struct virtpci_driver *virtpcidrv = virtpcidev->mydriver; + LOGINF("In virtpci_device_remove bus_id:%s dev_:%p virtpcidev:%p dev->driver:%p drivername:%s\n", BUS_ID(dev_), dev_, virtpcidev, dev_->driver, dev_->driver->name); /* VERBOSE/DEBUG */ @@ -931,8 +939,8 @@ static int virtpci_device_add(struct device *parentbus, int devtype, virtpcidev->net = *net; } virtpcidev->vendor = PCI_VENDOR_ID_UNISYS; - virtpcidev->busNo = addparams->busNo; - virtpcidev->deviceNo = addparams->deviceNo; + virtpcidev->busNo = addparams->bus_no; + virtpcidev->deviceNo = addparams->device_no; virtpcidev->queueinfo.chan = addparams->chanptr; virtpcidev->queueinfo.send_int_if_needed = NULL; @@ -949,7 +957,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, virtpcidev->generic_dev.release = virtpci_device_release; dev_set_name(&virtpcidev->generic_dev, "%x:%x", - addparams->busNo, addparams->deviceNo); + addparams->bus_no, addparams->device_no); /* add the vhba/vnic to virtpci device list - but check for * duplicate wwnn/macaddr first @@ -1047,7 +1055,8 @@ static int virtpci_device_add(struct device *parentbus, int devtype, LOGINF("Added %s:%d:%d &virtpcidev->generic_dev:%p\n", (devtype == VIRTHBA_TYPE) ? "virthba" : "virtnic", - addparams->busNo, addparams->deviceNo, &virtpcidev->generic_dev); + addparams->bus_no, addparams->device_no, + &virtpcidev->generic_dev); POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); return 1; } @@ -1306,6 +1315,7 @@ static ssize_t virtpci_driver_attr_show(struct kobject *kobj, struct driver_private *dprivate = to_driver(kobj); struct device_driver *driver; + if (dprivate != NULL) driver = dprivate->driver; else @@ -1328,6 +1338,7 @@ static ssize_t virtpci_driver_attr_store(struct kobject *kobj, struct driver_private *dprivate = to_driver(kobj); struct device_driver *driver; + if (dprivate != NULL) driver = dprivate->driver; else @@ -1504,7 +1515,7 @@ static int __init virtpci_mod_init(void) return ret; } DBGINF("bus_register successful\n"); - BusDeviceInfo_Init(&Bus_DriverInfo, "clientbus", "virtpci", + bus_device_info_init(&Bus_DriverInfo, "clientbus", "virtpci", VERSION, NULL); /* create a root bus used to parent all the virtpci buses. */ diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index aa17a842381b..9a4d7b6755d1 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -20,7 +20,6 @@ #include <linux/uuid.h> -#include "commontypes.h" #include "memregion.h" #include "channel.h" #ifndef HOSTADDRESS diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 62ec9280cb3a..01a44c553500 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -257,6 +257,7 @@ visorchannel_clear(VISORCHANNEL *channel, ulong offset, u8 ch, ulong nbytes) while (nbytes > 0) { ulong thisbytes = bufsize; int x = -1; + if (nbytes < thisbytes) thisbytes = nbytes; x = visor_memregion_write(channel->memregion, offset + written, @@ -424,7 +425,7 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) /* For each data field in SIGNAL_QUEUE_HEADER that was modified, * update host memory. */ - MEMORYBARRIER; + mb(); /* required for channel synch */ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) { ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n", rc); @@ -477,7 +478,7 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) /* For each data field in SIGNAL_QUEUE_HEADER that was modified, * update host memory. */ - MEMORYBARRIER; + mb(); /* required for channel synch */ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) { ERRDRV("visor_memregion_write of Head failed: (status=%d)\n", rc); @@ -520,6 +521,7 @@ int visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) { SIGNAL_QUEUE_HEADER sig_hdr; + if (!sig_read_header(channel, queue, &sig_hdr)) return 0; return (int) sig_hdr.MaxSignals; @@ -612,6 +614,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, else for (i = 0; i < nQueues; i++) { SIGNAL_QUEUE_HEADER q; + errcode = visorchannel_read(channel, off + phdr->oChannelSpace + (i * sizeof(q)), diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig index 7ca2fbca9d57..e86836f84243 100644 --- a/drivers/staging/unisys/visorchipset/Kconfig +++ b/drivers/staging/unisys/visorchipset/Kconfig @@ -4,7 +4,7 @@ config UNISYS_VISORCHIPSET tristate "Unisys visorchipset driver" - depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL + depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && HAS_IOMEM ---help--- If you say Y here, you will enable the Unisys visorchipset driver. diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index bf2e546d76bf..3321764069de 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -192,11 +192,12 @@ visorchipset_ioctl(struct inode *inode, struct file *file, int rc = SUCCESS; s64 adjustment; s64 vrtc_offset; + DBGINF("entered visorchipset_ioctl, cmd=%d", cmd); switch (cmd) { case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET: /* get the physical rtc offset */ - vrtc_offset = Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(); + vrtc_offset = issue_vmcall_query_guest_virtual_time_offset(); if (copy_to_user ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) { rc = -EFAULT; @@ -213,7 +214,7 @@ visorchipset_ioctl(struct inode *inode, struct file *file, } DBGINF("insde visorchipset_ioctl, cmd=%d, adjustment=%lld", cmd, adjustment); - rc = Issue_VMCALL_UPDATE_PHYSICAL_TIME(adjustment); + rc = issue_vmcall_update_physical_time(adjustment); break; default: LOGERR("visorchipset_ioctl received invalid command"); diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index 86fa2949dc4e..661aaae9b154 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -84,6 +84,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, ctx->byte_stream = FALSE; if (isLocal) { void *p; + if (addr > virt_to_phys(high_memory - 1)) { ERRDRV("%s - bad local address (0x%-16.16Lx for %lu)", __func__, @@ -257,6 +258,7 @@ static int string_length_no_trail(char *s, int len) { int i = len - 1; + while (i >= 0) { if (!isspace(s[i])) return i + 1; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index fe3c0127d255..e5df39554a1a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -58,8 +58,7 @@ NONULLSTR(char *s) { if (s) return s; - else - return ""; + return ""; } static int serverregistered; @@ -379,8 +378,7 @@ static ssize_t toolaction_store(struct device *dev, if (ret) return ret; - else - return count; + return count; } static ssize_t boottotool_show(struct device *dev, @@ -416,8 +414,7 @@ static ssize_t boottotool_store(struct device *dev, if (ret) return ret; - else - return count; + return count; } static ssize_t error_show(struct device *dev, struct device_attribute *attr, @@ -446,8 +443,7 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, &error, sizeof(u32)); if (ret) return ret; - else - return count; + return count; } static ssize_t textid_show(struct device *dev, struct device_attribute *attr, @@ -476,8 +472,7 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr, &textId, sizeof(u32)); if (ret) return ret; - else - return count; + return count; } @@ -509,8 +504,7 @@ static ssize_t remaining_steps_store(struct device *dev, &remainingSteps, sizeof(u16)); if (ret) return ret; - else - return count; + return count; } #if 0 @@ -565,6 +559,7 @@ static void devInfo_clear(void *v) { VISORCHIPSET_DEVICE_INFO *p = (VISORCHIPSET_DEVICE_INFO *) (v); + p->state.created = 0; memset(p, 0, sizeof(VISORCHIPSET_DEVICE_INFO)); } @@ -594,7 +589,7 @@ visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, ULTRA_VBUS_DEVICEINFO *driverInfo) { - LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); + down(&NotifierLock); if (notifiers == NULL) { memset(&BusDev_Server_Notifiers, 0, sizeof(BusDev_Server_Notifiers)); @@ -606,10 +601,10 @@ visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, if (responders) *responders = BusDev_Responders; if (driverInfo) - BusDeviceInfo_Init(driverInfo, "chipset", "visorchipset", + bus_device_info_init(driverInfo, "chipset", "visorchipset", VERSION, NULL); - UNLOCKSEM(&NotifierLock); + up(&NotifierLock); } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); @@ -618,7 +613,7 @@ visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, ULTRA_VBUS_DEVICEINFO *driverInfo) { - LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); + down(&NotifierLock); if (notifiers == NULL) { memset(&BusDev_Client_Notifiers, 0, sizeof(BusDev_Client_Notifiers)); @@ -630,9 +625,9 @@ visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, if (responders) *responders = BusDev_Responders; if (driverInfo) - BusDeviceInfo_Init(driverInfo, "chipset(bolts)", "visorchipset", + bus_device_info_init(driverInfo, "chipset(bolts)", "visorchipset", VERSION, NULL); - UNLOCKSEM(&NotifierLock); + up(&NotifierLock); } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); @@ -707,6 +702,7 @@ static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) { CONTROLVM_MESSAGE outmsg; + controlvm_init_response(&outmsg, msgHdr, response); /* For DiagPool channel DEVICE_CHANGESTATE, we need to send * back the deviceChangeState structure in the packet. */ @@ -733,6 +729,7 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, ULTRA_CHIPSET_FEATURE features) { CONTROLVM_MESSAGE outmsg; + controlvm_init_response(&outmsg, msgHdr, response); outmsg.cmd.initChipset.features = features; if (!visorchannel_signalinsert(ControlVm_channel, @@ -747,6 +744,7 @@ controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, ULTRA_SEGMENT_STATE state) { CONTROLVM_MESSAGE outmsg; + controlvm_init_response(&outmsg, msgHdr, response); outmsg.cmd.deviceChangeState.state = state; outmsg.cmd.deviceChangeState.flags.physicalDevice = 1; @@ -944,7 +942,7 @@ bus_epilog(u32 busNo, } else pBusInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; - LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); + down(&NotifierLock); if (response == CONTROLVM_RESP_SUCCESS) { switch (cmd) { case CONTROLVM_BUS_CREATE: @@ -989,7 +987,7 @@ bus_epilog(u32 busNo, ; else bus_responder(cmd, busNo, response); - UNLOCKSEM(&NotifierLock); + up(&NotifierLock); } static void @@ -1021,7 +1019,7 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd, } else pDevInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; - LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); + down(&NotifierLock); if (response >= 0) { switch (cmd) { case CONTROLVM_DEVICE_CREATE: @@ -1087,7 +1085,7 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd, ; else device_responder(cmd, busNo, devNo, response); - UNLOCKSEM(&NotifierLock); + up(&NotifierLock); } static void @@ -1429,6 +1427,7 @@ initialize_controlvm_payload(void) HOSTADDRESS phys_addr = visorchannel_get_physaddr(ControlVm_channel); u64 payloadOffset = 0; u32 payloadBytes = 0; + if (visorchannel_read(ControlVm_channel, offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, RequestPayloadOffset), @@ -1468,6 +1467,7 @@ visorchipset_chipset_selftest(void) { char env_selftest[20]; char *envp[] = { env_selftest, NULL }; + sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, envp); @@ -1490,6 +1490,7 @@ static void chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr) { int rc = visorchipset_chipset_ready(); + if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; if (msgHdr->Flags.responseExpected && !visorchipset_holdchipsetready) @@ -1507,6 +1508,7 @@ static void chipset_selftest(CONTROLVM_MESSAGE_HEADER *msgHdr) { int rc = visorchipset_chipset_selftest(); + if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; if (msgHdr->Flags.responseExpected) @@ -1517,6 +1519,7 @@ static void chipset_notready(CONTROLVM_MESSAGE_HEADER *msgHdr) { int rc = visorchipset_chipset_notready(); + if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; if (msgHdr->Flags.responseExpected) @@ -1535,8 +1538,8 @@ read_controlvm_event(CONTROLVM_MESSAGE *msg) if (msg->hdr.Flags.testMessage == 1) { LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg->hdr.Id); return FALSE; - } else - return TRUE; + } + return TRUE; } return FALSE; } @@ -1564,6 +1567,7 @@ static int parahotplug_next_id(void) { static atomic_t id = ATOMIC_INIT(0); + return atomic_inc_return(&id); } @@ -1788,6 +1792,7 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) */ if (parametersAddr != 0 && parametersBytes != 0) { BOOL retry = FALSE; + parser_ctx = parser_init_byteStream(parametersAddr, parametersBytes, isLocalAddr, &retry); @@ -1906,7 +1911,7 @@ static HOSTADDRESS controlvm_get_channel_address(void) u64 addr = 0; u32 size = 0; - if (!VMCALL_SUCCESSFUL(Issue_VMCALL_IO_CONTROLVM_ADDR(&addr, &size))) { + if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size))) { ERRDRV("%s - vmcall to determine controlvm channel addr failed", __func__); return 0; @@ -2184,6 +2189,7 @@ BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo) { void *p = findbus(&BusInfoList, busNo); + if (!p) { LOGERR("(%lu) failed", busNo); return FALSE; @@ -2197,6 +2203,7 @@ BOOL visorchipset_set_bus_context(ulong busNo, void *context) { VISORCHIPSET_BUS_INFO *p = findbus(&BusInfoList, busNo); + if (!p) { LOGERR("(%lu) failed", busNo); return FALSE; @@ -2211,6 +2218,7 @@ visorchipset_get_device_info(ulong busNo, ulong devNo, VISORCHIPSET_DEVICE_INFO *devInfo) { void *p = finddevice(&DevInfoList, busNo, devNo); + if (!p) { LOGERR("(%lu,%lu) failed", busNo, devNo); return FALSE; @@ -2224,6 +2232,7 @@ BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context) { VISORCHIPSET_DEVICE_INFO *p = finddevice(&DevInfoList, busNo, devNo); + if (!p) { LOGERR("(%lu,%lu) failed", busNo, devNo); return FALSE; @@ -2290,8 +2299,8 @@ static ssize_t chipsetready_store(struct device *dev, } else if (strcmp(msgtype, "MODULES_LOADED") == 0) { chipset_events[1] = 1; return count; - } else - return -EINVAL; + } + return -EINVAL; } /* The parahotplug/devicedisabled interface gets called by our support script @@ -2468,6 +2477,7 @@ static void visorchipset_exit(void) { char s[99]; + POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); if (visorchipset_disable_controlvm) { diff --git a/drivers/staging/unisys/visorutil/Kconfig b/drivers/staging/unisys/visorutil/Kconfig index 4ff61a7c506b..74b474eac252 100644 --- a/drivers/staging/unisys/visorutil/Kconfig +++ b/drivers/staging/unisys/visorutil/Kconfig @@ -4,7 +4,7 @@ config UNISYS_VISORUTIL tristate "Unisys visorutil driver" - depends on UNISYSSPAR + depends on UNISYSSPAR && HAS_IOMEM ---help--- If you say Y here, you will enable the Unisys visorutil driver. diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 38a60ce8c27c..3dd1c04d0e14 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -27,7 +27,7 @@ -struct PERIODIC_WORK_Tag { +struct periodic_work { rwlock_t lock; struct delayed_work work; void (*workfunc)(void *); @@ -43,42 +43,41 @@ struct PERIODIC_WORK_Tag { static void periodic_work_func(struct work_struct *work) { - PERIODIC_WORK *periodic_work = - container_of(work, struct PERIODIC_WORK_Tag, work.work); - (*periodic_work->workfunc)(periodic_work->workfuncarg); + struct periodic_work *pw; + + pw = container_of(work, struct periodic_work, work.work); + (*pw->workfunc)(pw->workfuncarg); } -PERIODIC_WORK *visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam) +struct periodic_work *visor_periodic_work_create(ulong jiffy_interval, + struct workqueue_struct *workqueue, + void (*workfunc)(void *), + void *workfuncarg, + const char *devnam) { - PERIODIC_WORK *periodic_work = kzalloc(sizeof(PERIODIC_WORK), - GFP_KERNEL | __GFP_NORETRY); - if (periodic_work == NULL) { - ERRDRV("periodic_work allocation failed "); + struct periodic_work *pw; + + pw = kzalloc(sizeof(*pw), GFP_KERNEL | __GFP_NORETRY); + if (!pw) return NULL; - } - rwlock_init(&periodic_work->lock); - periodic_work->jiffy_interval = jiffy_interval; - periodic_work->workqueue = workqueue; - periodic_work->workfunc = workfunc; - periodic_work->workfuncarg = workfuncarg; - periodic_work->devnam = devnam; - return periodic_work; + + rwlock_init(&pw->lock); + pw->jiffy_interval = jiffy_interval; + pw->workqueue = workqueue; + pw->workfunc = workfunc; + pw->workfuncarg = workfuncarg; + pw->devnam = devnam; + return pw; } EXPORT_SYMBOL_GPL(visor_periodic_work_create); -void visor_periodic_work_destroy(PERIODIC_WORK *periodic_work) +void visor_periodic_work_destroy(struct periodic_work *pw) { - if (periodic_work == NULL) - return; - kfree(periodic_work); + kfree(pw); } EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); @@ -89,27 +88,26 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); * If this function returns FALSE, there was a failure and the * periodic work is no longer scheduled */ -BOOL visor_periodic_work_nextperiod(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_nextperiod(struct periodic_work *pw) { BOOL rc = FALSE; - write_lock(&periodic_work->lock); - if (periodic_work->want_to_stop) { - periodic_work->is_scheduled = FALSE; - periodic_work->want_to_stop = FALSE; + write_lock(&pw->lock); + if (pw->want_to_stop) { + pw->is_scheduled = FALSE; + pw->want_to_stop = FALSE; rc = TRUE; /* yes, TRUE; see visor_periodic_work_stop() */ - goto Away; - } else if (queue_delayed_work(periodic_work->workqueue, - &periodic_work->work, - periodic_work->jiffy_interval) < 0) { - ERRDEV(periodic_work->devnam, "queue_delayed_work failed!"); - periodic_work->is_scheduled = FALSE; + goto unlock; + } else if (queue_delayed_work(pw->workqueue, &pw->work, + pw->jiffy_interval) < 0) { + ERRDEV(pw->devnam, "queue_delayed_work failed!"); + pw->is_scheduled = FALSE; rc = FALSE; - goto Away; + goto unlock; } rc = TRUE; -Away: - write_unlock(&periodic_work->lock); +unlock: + write_unlock(&pw->lock); return rc; } EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); @@ -120,34 +118,32 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); * If this function returns FALSE, then no work was started * (either because it was already started, or because of a failure). */ -BOOL visor_periodic_work_start(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_start(struct periodic_work *pw) { BOOL rc = FALSE; - write_lock(&periodic_work->lock); - if (periodic_work->is_scheduled) { + write_lock(&pw->lock); + if (pw->is_scheduled) { rc = FALSE; - goto Away; + goto unlock; } - if (periodic_work->want_to_stop) { - ERRDEV(periodic_work->devnam, + if (pw->want_to_stop) { + ERRDEV(pw->devnam, "dev_start_periodic_work failed!"); rc = FALSE; - goto Away; + goto unlock; } - INIT_DELAYED_WORK(&periodic_work->work, &periodic_work_func); - if (queue_delayed_work(periodic_work->workqueue, - &periodic_work->work, - periodic_work->jiffy_interval) < 0) { - ERRDEV(periodic_work->devnam, - "%s queue_delayed_work failed!", __func__); + INIT_DELAYED_WORK(&pw->work, &periodic_work_func); + if (queue_delayed_work(pw->workqueue, &pw->work, + pw->jiffy_interval) < 0) { + ERRDEV(pw->devnam, "%s queue_delayed_work failed!", __func__); rc = FALSE; - goto Away; + goto unlock; } - periodic_work->is_scheduled = TRUE; + pw->is_scheduled = TRUE; rc = TRUE; -Away: - write_unlock(&periodic_work->lock); +unlock: + write_unlock(&pw->lock); return rc; } @@ -190,21 +186,20 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_start); * this deadlock, you will get hung up in an infinite loop saying * "waiting for delayed work...". */ -BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_stop(struct periodic_work *pw) { BOOL stopped_something = FALSE; - write_lock(&periodic_work->lock); - stopped_something = periodic_work->is_scheduled && - (!periodic_work->want_to_stop); - while (periodic_work->is_scheduled) { - periodic_work->want_to_stop = TRUE; - if (cancel_delayed_work(&periodic_work->work)) { + write_lock(&pw->lock); + stopped_something = pw->is_scheduled && (!pw->want_to_stop); + while (pw->is_scheduled) { + pw->want_to_stop = TRUE; + if (cancel_delayed_work(&pw->work)) { /* We get here if the delayed work was pending as * delayed work, but was NOT run. */ - ASSERT(periodic_work->is_scheduled); - periodic_work->is_scheduled = FALSE; + ASSERT(pw->is_scheduled); + pw->is_scheduled = FALSE; } else { /* If we get here, either the delayed work: * - was run, OR, @@ -216,9 +211,9 @@ BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) * explains the loop... */ } - if (periodic_work->is_scheduled) { - write_unlock(&periodic_work->lock); - WARNDEV(periodic_work->devnam, + if (pw->is_scheduled) { + write_unlock(&pw->lock); + WARNDEV(pw->devnam, "waiting for delayed work..."); /* We rely on the delayed work function running here, * and eventually calling @@ -227,11 +222,11 @@ BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) * subsequently clear is_scheduled. */ SLEEPJIFFIES(10); - write_lock(&periodic_work->lock); + write_lock(&pw->lock); } else - periodic_work->want_to_stop = FALSE; + pw->want_to_stop = FALSE; } - write_unlock(&periodic_work->lock); + write_unlock(&pw->lock); return stopped_something; } EXPORT_SYMBOL_GPL(visor_periodic_work_stop); diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index 5c8c95c51519..c476036f7382 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c @@ -250,9 +250,8 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, } strcpy(obj->name, name); obj->procDir = createProcDir(obj->name, type->procDir); - if (obj->procDir == NULL) { + if (obj->procDir == NULL) goto Away; - } } obj->procDirPropertyContexts = kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 10d77cb6ee97..d6815f9e1337 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -46,46 +46,6 @@ void *kmalloc_kernel(size_t siz) return kmalloc(siz, GFP_KERNEL | __GFP_NORETRY); } -/* Use these handy-dandy seq_file_xxx functions if you want to call some - * functions that write stuff into a seq_file, but you actually just want - * to dump that output into a buffer. Use them as follows: - * - call visor_seq_file_new_buffer to create the seq_file (you supply the buf) - * - call whatever functions you want that take a seq_file as an argument - * (the buf you supplied will get the output data) - * - call visor_seq_file_done_buffer to dispose of your seq_file - */ -struct seq_file *visor_seq_file_new_buffer(void *buf, size_t buf_size) -{ - struct seq_file *rc = NULL; - struct seq_file *m = kmalloc_kernel(sizeof(struct seq_file)); - - if (m == NULL) { - rc = NULL; - goto Away; - } - memset(m, 0, sizeof(struct seq_file)); - m->buf = buf; - m->size = buf_size; - rc = m; -Away: - if (rc == NULL) { - visor_seq_file_done_buffer(m); - m = NULL; - } - return rc; -} -EXPORT_SYMBOL_GPL(visor_seq_file_new_buffer); - - - -void visor_seq_file_done_buffer(struct seq_file *m) -{ - if (!m) - return; - kfree(m); -} -EXPORT_SYMBOL_GPL(visor_seq_file_done_buffer); - static __init uint32_t visorutil_spar_detect(void) { |