diff options
Diffstat (limited to 'drivers/staging/unisys')
28 files changed, 1013 insertions, 1350 deletions
diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index ac080c9dcf46..19fcb3465509 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -12,7 +12,6 @@ if UNISYSSPAR source "drivers/staging/unisys/visorutil/Kconfig" source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" -source "drivers/staging/unisys/channels/Kconfig" source "drivers/staging/unisys/uislib/Kconfig" source "drivers/staging/unisys/virtpci/Kconfig" source "drivers/staging/unisys/virthba/Kconfig" diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index b988d6940aae..68b9925e7d5e 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -4,7 +4,6 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ -obj-$(CONFIG_UNISYS_CHANNELSTUB) += channels/ obj-$(CONFIG_UNISYS_UISLIB) += uislib/ obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci/ obj-$(CONFIG_UNISYS_VIRTHBA) += virthba/ diff --git a/drivers/staging/unisys/channels/Kconfig b/drivers/staging/unisys/channels/Kconfig deleted file mode 100644 index 179c6cea2824..000000000000 --- a/drivers/staging/unisys/channels/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -# -# Unisys channels configuration -# - -config UNISYS_CHANNELSTUB - tristate "Unisys channelstub driver" - depends on UNISYSSPAR && UNISYS_VISORUTIL - ---help--- - If you say Y here, you will enable the Unisys channels driver. - diff --git a/drivers/staging/unisys/channels/Makefile b/drivers/staging/unisys/channels/Makefile deleted file mode 100644 index adc184206035..000000000000 --- a/drivers/staging/unisys/channels/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# Makefile for Unisys channelstub -# - -obj-$(CONFIG_UNISYS_CHANNELSTUB) += visorchannelstub.o - -visorchannelstub-y := channel.o chanstub.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c deleted file mode 100644 index 74cc4d6b515f..000000000000 --- a/drivers/staging/unisys/channels/channel.c +++ /dev/null @@ -1,219 +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. - */ - -#include <linux/kernel.h> -#ifdef CONFIG_MODVERSIONS -#include <config/modversions.h> -#endif -#include <linux/module.h> -#include <linux/init.h> /* for module_init and module_exit */ -#include <linux/slab.h> /* for memcpy */ -#include <linux/types.h> - -/* Implementation of exported functions for Supervisor channels */ -#include "channel.h" - -/* - * Routine Description: - * Tries to insert the prebuilt signal pointed to by pSignal into the nth - * Queue of the Channel pointed to by pChannel - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to the signal - * - * Assumptions: - * - pChannel, Queue and pSignal are valid. - * - If insertion fails due to a full queue, the caller will determine the - * retry policy (e.g. wait & try again, report an error, etc.). - * - * Return value: - * 1 if the insertion succeeds, 0 if the queue was full. - */ -unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, - void *sig) -{ - void __iomem *psignal; - unsigned int head, tail, nof; - - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) - ((char __iomem *)ch + readq(&ch->ch_space_offset)) - + queue; - - /* capture current head and tail */ - head = readl(&pqhdr->head); - tail = readl(&pqhdr->tail); - - /* queue is full if (head + 1) % n equals tail */ - if (((head + 1) % readl(&pqhdr->max_slots)) == tail) { - nof = readq(&pqhdr->num_overflows) + 1; - writeq(nof, &pqhdr->num_overflows); - return 0; - } - - /* increment the head index */ - head = (head + 1) % readl(&pqhdr->max_slots); - - /* copy signal to the head location from the area pointed to - * by pSignal - */ - psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + - (head * readl(&pqhdr->signal_size)); - memcpy_toio(psignal, sig, readl(&pqhdr->signal_size)); - - mb(); /* channel synch */ - writel(head, &pqhdr->head); - - writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); - return 1; -} -EXPORT_SYMBOL_GPL(spar_signal_insert); - -/* - * Routine Description: - * Removes one signal from Channel pChannel's nth Queue at the - * time of the call and copies it into the memory pointed to by - * pSignal. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to where the signals are to be copied - * - * Assumptions: - * - pChannel and Queue are valid. - * - pSignal points to a memory area large enough to hold queue's SignalSize - * - * Return value: - * 1 if the removal succeeds, 0 if the queue was empty. - */ -unsigned char -spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) -{ - void __iomem *psource; - unsigned int head, tail; - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *)((char __iomem *)ch + - readq(&ch->ch_space_offset)) + queue; - - /* capture current head and tail */ - head = readl(&pqhdr->head); - tail = readl(&pqhdr->tail); - - /* queue is empty if the head index equals the tail index */ - if (head == tail) { - writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty); - return 0; - } - - /* advance past the 'empty' front slot */ - tail = (tail + 1) % readl(&pqhdr->max_slots); - - /* copy signal from tail location to the area pointed to by pSignal */ - psource = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + - (tail * readl(&pqhdr->signal_size)); - memcpy_fromio(sig, psource, readl(&pqhdr->signal_size)); - - mb(); /* channel synch */ - writel(tail, &pqhdr->tail); - - writeq(readq(&pqhdr->num_received) + 1, - &pqhdr->num_received); - return 1; -} -EXPORT_SYMBOL_GPL(spar_signal_remove); - -/* - * Routine Description: - * Removes all signals present in Channel pChannel's nth Queue at the - * time of the call and copies them into the memory pointed to by - * pSignal. Returns the # of signals copied as the value of the routine. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to where the signals are to be copied - * - * Assumptions: - * - pChannel and Queue are valid. - * - pSignal points to a memory area large enough to hold Queue's MaxSignals - * # of signals, each of which is Queue's SignalSize. - * - * Return value: - * # of signals copied. - */ -unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, - void *sig) -{ - void *psource; - unsigned int head, tail, count = 0; - struct signal_queue_header *pqhdr = - (struct signal_queue_header *)((char *)ch + - ch->ch_space_offset) + queue; - - /* capture current head and tail */ - head = pqhdr->head; - tail = pqhdr->tail; - - /* queue is empty if the head index equals the tail index */ - if (head == tail) - return 0; - - while (head != tail) { - /* advance past the 'empty' front slot */ - tail = (tail + 1) % pqhdr->max_slots; - - /* copy signal from tail location to the area pointed - * to by pSignal - */ - psource = - (char *)pqhdr + pqhdr->sig_base_offset + - (tail * pqhdr->signal_size); - memcpy((char *)sig + (pqhdr->signal_size * count), - psource, pqhdr->signal_size); - - mb(); /* channel synch */ - pqhdr->tail = tail; - - count++; - pqhdr->num_received++; - } - - return count; -} - -/* - * Routine Description: - * Determine whether a signal queue is empty. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * - * Return value: - * 1 if the signal queue is empty, 0 otherwise. - */ -unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, - u32 queue) -{ - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *)((char __iomem *)ch + - readq(&ch->ch_space_offset)) + queue; - return readl(&pqhdr->head) == readl(&pqhdr->tail); -} -EXPORT_SYMBOL_GPL(spar_signalqueue_empty); - diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c deleted file mode 100644 index b6fd126f16f1..000000000000 --- a/drivers/staging/unisys/channels/chanstub.c +++ /dev/null @@ -1,75 +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. - */ - -#define EXPORT_SYMTAB -#include <linux/kernel.h> -#ifdef CONFIG_MODVERSIONS -#include <config/modversions.h> -#endif -#include <linux/module.h> -#include <linux/init.h> /* for module_init and module_exit */ -#include <linux/slab.h> /* for memcpy */ -#include <linux/types.h> - -#include "channel.h" -#include "chanstub.h" -#include "timskmod.h" -#include "version.h" - -static __init int -channel_mod_init(void) -{ - if (!unisys_spar_platform) - return -ENODEV; - return 0; -} - -static __exit void -channel_mod_exit(void) -{ -} - -unsigned char -SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue, - void *pSignal, spinlock_t *lock) -{ - unsigned char result; - unsigned long flags; - - spin_lock_irqsave(lock, flags); - result = spar_signal_insert(pChannel, Queue, pSignal); - spin_unlock_irqrestore(lock, flags); - return result; -} - -unsigned char -SignalRemove_withLock(struct channel_header __iomem *pChannel, u32 Queue, - void *pSignal, spinlock_t *lock) -{ - unsigned char result; - - spin_lock(lock); - result = spar_signal_remove(pChannel, Queue, pSignal); - spin_unlock(lock); - return result; -} - -module_init(channel_mod_init); -module_exit(channel_mod_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Bryan Glaudel"); -MODULE_ALIAS("uischan"); - /* this is extracted during depmod and kept in modules.dep */ diff --git a/drivers/staging/unisys/channels/chanstub.h b/drivers/staging/unisys/channels/chanstub.h deleted file mode 100644 index 1531759a1b31..000000000000 --- a/drivers/staging/unisys/channels/chanstub.h +++ /dev/null @@ -1,23 +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 __CHANSTUB_H__ -#define __CHANSTUB_H__ -unsigned char SignalInsert_withLock(struct channel_header __iomem *pChannel, - u32 Queue, void *pSignal, spinlock_t *lock); -unsigned char SignalRemove_withLock(struct channel_header __iomem *pChannel, - u32 Queue, void *pSignal, spinlock_t *lock); - -#endif diff --git a/drivers/staging/unisys/common-spar/include/version.h b/drivers/staging/unisys/common-spar/include/version.h index f25208fc3ed1..83d1da7a2f81 100644 --- a/drivers/staging/unisys/common-spar/include/version.h +++ b/drivers/staging/unisys/common-spar/include/version.h @@ -30,7 +30,6 @@ #define SPARVER4 "0" #define VERSION SPARVER1 "." SPARVER2 "." SPARVER3 "." SPARVER4 -#define VERSIONDATE __DATE__ /* Here are various version forms needed in Windows environments. */ diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index cff7983dab85..4019a0d63645 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -133,7 +133,7 @@ * x - the number of seconds to sleep. */ #define SLEEP(x) \ - do { current->state = TASK_INTERRUPTIBLE; \ + do { __set_current_state(TASK_INTERRUPTIBLE); \ schedule_timeout((x)*HZ); \ } while (0) @@ -141,7 +141,7 @@ * x - the number of jiffies to sleep. */ #define SLEEPJIFFIES(x) \ - do { current->state = TASK_INTERRUPTIBLE; \ + do { __set_current_state(TASK_INTERRUPTIBLE); \ schedule_timeout(x); \ } while (0) diff --git a/drivers/staging/unisys/uislib/Kconfig b/drivers/staging/unisys/uislib/Kconfig index 6b134e267904..a712eb82224a 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 && HAS_IOMEM + depends on UNISYSSPAR && UNISYS_VISORCHIPSET && 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 7c87452a9f14..a9eeddeba735 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -41,7 +41,6 @@ #include "sparstop.h" #include "visorchipset.h" -#include "chanstub.h" #include "version.h" #include "guestlinuxdebug.h" @@ -59,8 +58,8 @@ /* global function pointers that act as callback functions into virtpcimod */ int (*virt_control_chan_func)(struct guest_msgs *); -static int ProcReadBufferValid; -static char *ProcReadBuffer; /* Note this MUST be global, +static int debug_buf_valid; +static char *debug_buf; /* Note this MUST be global, * because the contents must */ static unsigned int chipset_inited; @@ -71,24 +70,24 @@ static unsigned int chipset_inited; UIS_THREAD_WAIT; \ } while (1) -static struct bus_info *BusListHead; -static rwlock_t BusListLock; -static int BusListCount; /* number of buses in the list */ -static int MaxBusCount; /* maximum number of buses expected */ -static u64 PhysicalDataChan; -static int PlatformNumber; +static struct bus_info *bus_list; +static rwlock_t bus_list_lock; +static int bus_list_count; /* number of buses in the list */ +static int max_bus_count; /* maximum number of buses expected */ +static u64 phys_data_chan; +static int platform_no; -static struct uisthread_info Incoming_ThreadInfo; -static BOOL Incoming_Thread_Started = FALSE; -static LIST_HEAD(List_Polling_Device_Channels); +static struct uisthread_info incoming_ti; +static BOOL incoming_started = FALSE; +static LIST_HEAD(poll_dev_chan); static unsigned long long tot_moved_to_tail_cnt; static unsigned long long tot_wait_cnt; static unsigned long long tot_wakeup_cnt; static unsigned long long tot_schedule_cnt; static int en_smart_wakeup = 1; -static DEFINE_SEMAPHORE(Lock_Polling_Device_Channels); /* unlocked */ -static DECLARE_WAIT_QUEUE_HEAD(Wakeup_Polling_Device_Channels); -static int Go_Polling_Device_Channels; +static DEFINE_SEMAPHORE(poll_dev_lock); /* unlocked */ +static DECLARE_WAIT_QUEUE_HEAD(poll_dev_wake_q); +static int poll_dev_start; #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" @@ -115,7 +114,7 @@ static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); + size_t len, loff_t *offset); static const struct file_operations debugfs_info_fops = { .read = info_debugfs_read, }; @@ -129,58 +128,52 @@ init_msg_header(struct controlvm_message *msg, u32 id, uint rsp, uint svr) msg->hdr.flags.server = svr; } -static __iomem void * -init_vbus_channel(u64 channelAddr, u32 channelBytes) +static __iomem void *init_vbus_channel(u64 ch_addr, u32 ch_bytes) { - void __iomem *rc = NULL; - void __iomem *pChan = uislib_ioremap_cache(channelAddr, channelBytes); + void __iomem *ch = uislib_ioremap_cache(ch_addr, ch_bytes); - if (!pChan) { + if (!ch) { LOGERR("CONTROLVM_BUS_CREATE error: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", - (unsigned long long) channelAddr, - (unsigned long long) channelBytes); - rc = NULL; - goto Away; + (unsigned long long)ch_addr, + (unsigned long long)ch_bytes); + return NULL; } - if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan)) { + if (!SPAR_VBUS_CHANNEL_OK_CLIENT(ch)) { ERRDRV("%s channel cannot be used", __func__); - uislib_iounmap(pChan); - rc = NULL; - goto Away; + uislib_iounmap(ch); + return NULL; } - rc = pChan; -Away: - return rc; + return ch; } static int create_bus(struct controlvm_message *msg, char *buf) { - u32 busNo, deviceCount; + u32 bus_no, dev_count; struct bus_info *tmp, *bus; size_t size; - if (MaxBusCount == BusListCount) { + if (max_bus_count == bus_list_count) { LOGERR("CONTROLVM_BUS_CREATE Failed: max buses:%d already created\n", - MaxBusCount); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, MaxBusCount, + max_bus_count); + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, max_bus_count, POSTCODE_SEVERITY_ERR); return CONTROLVM_RESP_ERROR_MAX_BUSES; } - busNo = msg->cmd.create_bus.bus_no; - deviceCount = msg->cmd.create_bus.dev_count; + bus_no = msg->cmd.create_bus.bus_no; + dev_count = msg->cmd.create_bus.dev_count; - POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, busNo, deviceCount, + POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, bus_no, dev_count, POSTCODE_SEVERITY_INFO); size = sizeof(struct bus_info) + - (deviceCount * sizeof(struct device_info *)); + (dev_count * sizeof(struct device_info *)); bus = kzalloc(size, GFP_ATOMIC); if (!bus) { LOGERR("CONTROLVM_BUS_CREATE Failed: kmalloc for bus failed.\n"); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; } @@ -191,27 +184,29 @@ create_bus(struct controlvm_message *msg, char *buf) if (msg->hdr.flags.test_message) { /* This implies we're the IOVM so set guest handle to 0... */ bus->guest_handle = 0; - bus->bus_no = busNo; + bus->bus_no = bus_no; bus->local_vnic = 1; - } else - bus->bus_no = bus->guest_handle = busNo; - sprintf(bus->name, "%d", (int) bus->bus_no); - bus->device_count = deviceCount; + } else { + bus->bus_no = bus_no; + bus->guest_handle = bus_no; + } + sprintf(bus->name, "%d", (int)bus->bus_no); + bus->device_count = dev_count; bus->device = - (struct device_info **) ((char *) bus + sizeof(struct bus_info)); + (struct device_info **)((char *)bus + sizeof(struct bus_info)); bus->bus_inst_uuid = msg->cmd.create_bus.bus_inst_uuid; bus->bus_channel_bytes = 0; bus->bus_channel = NULL; /* add bus to our bus list - but check for duplicates first */ - read_lock(&BusListLock); - for (tmp = BusListHead; tmp; tmp = tmp->next) { + read_lock(&bus_list_lock); + for (tmp = bus_list; tmp; tmp = tmp->next) { if (tmp->bus_no == bus->bus_no) break; } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); if (tmp) { - /* found a bus already in the list with same busNo - + /* found a bus already in the list with same bus_no - * reject add */ LOGERR("CONTROLVM_BUS_CREATE Failed: bus %d already exists.\n", @@ -221,8 +216,8 @@ create_bus(struct controlvm_message *msg, char *buf) kfree(bus); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } - if ((msg->cmd.create_bus.channel_addr != 0) - && (msg->cmd.create_bus.channel_bytes != 0)) { + if ((msg->cmd.create_bus.channel_addr != 0) && + (msg->cmd.create_bus.channel_bytes != 0)) { bus->bus_channel_bytes = msg->cmd.create_bus.channel_bytes; bus->bus_channel = init_vbus_channel(msg->cmd.create_bus.channel_addr, @@ -233,9 +228,9 @@ create_bus(struct controlvm_message *msg, char *buf) struct guest_msgs cmd; cmd.msgtype = GUEST_ADD_VBUS; - cmd.add_vbus.bus_no = busNo; + cmd.add_vbus.bus_no = bus_no; cmd.add_vbus.chanptr = bus->bus_channel; - cmd.add_vbus.dev_count = deviceCount; + cmd.add_vbus.dev_count = dev_count; cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid; cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid; if (!virt_control_chan_func) { @@ -256,15 +251,15 @@ create_bus(struct controlvm_message *msg, char *buf) } /* add bus at the head of our list */ - write_lock(&BusListLock); - if (!BusListHead) - BusListHead = bus; - else { - bus->next = BusListHead; - BusListHead = bus; + write_lock(&bus_list_lock); + if (!bus_list) { + bus_list = bus; + } else { + bus->next = bus_list; + bus_list = bus; } - BusListCount++; - write_unlock(&BusListLock); + bus_list_count++; + write_unlock(&bus_list_lock); POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->bus_no, POSTCODE_SEVERITY_INFO); @@ -277,15 +272,15 @@ destroy_bus(struct controlvm_message *msg, char *buf) int i; struct bus_info *bus, *prev = NULL; struct guest_msgs cmd; - u32 busNo; + u32 bus_no; - busNo = msg->cmd.destroy_bus.bus_no; + bus_no = msg->cmd.destroy_bus.bus_no; - read_lock(&BusListLock); + read_lock(&bus_list_lock); - bus = BusListHead; + bus = bus_list; while (bus) { - if (bus->bus_no == busNo) + if (bus->bus_no == bus_no) break; prev = bus; bus = bus->next; @@ -293,8 +288,8 @@ destroy_bus(struct controlvm_message *msg, char *buf) if (!bus) { LOGERR("CONTROLVM_BUS_DESTROY Failed: failed to find bus %d.\n", - busNo); - read_unlock(&BusListLock); + bus_no); + read_unlock(&bus_list_lock); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } @@ -302,12 +297,12 @@ destroy_bus(struct controlvm_message *msg, char *buf) for (i = 0; i < bus->device_count; i++) { if (bus->device[i] != NULL) { LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.", - i, busNo); - read_unlock(&BusListLock); + i, bus_no); + read_unlock(&bus_list_lock); return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED; } } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); if (msg->hdr.flags.server) goto remove; @@ -315,7 +310,7 @@ destroy_bus(struct controlvm_message *msg, char *buf) /* client messages require us to call the virtpci callback associated with this bus. */ cmd.msgtype = GUEST_DEL_VBUS; - cmd.del_vbus.bus_no = busNo; + cmd.del_vbus.bus_no = bus_no; if (!virt_control_chan_func) { LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; @@ -327,13 +322,13 @@ destroy_bus(struct controlvm_message *msg, char *buf) /* finally, remove the bus from the list */ remove: - write_lock(&BusListLock); + write_lock(&bus_list_lock); if (prev) /* not at head */ prev->next = bus->next; else - BusListHead = bus->next; - BusListCount--; - write_unlock(&BusListLock); + bus_list = bus->next; + bus_list_count--; + write_unlock(&bus_list_lock); if (bus->bus_channel) { uislib_iounmap(bus->bus_channel); @@ -344,26 +339,26 @@ remove: return CONTROLVM_RESP_SUCCESS; } -static int -create_device(struct controlvm_message *msg, char *buf) +static int create_device(struct controlvm_message *msg, char *buf) { struct device_info *dev; struct bus_info *bus; - u32 busNo, devNo; + struct guest_msgs cmd; + u32 bus_no, dev_no; int result = CONTROLVM_RESP_SUCCESS; - u64 minSize = MIN_IO_CHANNEL_SIZE; - struct req_handler_info *pReqHandler; + u64 min_size = MIN_IO_CHANNEL_SIZE; + struct req_handler_info *req_handler; - busNo = msg->cmd.create_device.bus_no; - devNo = msg->cmd.create_device.dev_no; + bus_no = msg->cmd.create_device.bus_no; + dev_no = msg->cmd.create_device.dev_no; - POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, + POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - dev = kzalloc(sizeof(struct device_info), GFP_ATOMIC); + dev = kzalloc(sizeof(*dev), GFP_ATOMIC); if (!dev) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: kmalloc for dev failed.\n"); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; } @@ -371,169 +366,157 @@ create_device(struct controlvm_message *msg, char *buf) dev->channel_uuid = msg->cmd.create_device.data_type_uuid; dev->intr = msg->cmd.create_device.intr; dev->channel_addr = msg->cmd.create_device.channel_addr; - dev->bus_no = busNo; - dev->dev_no = devNo; + dev->bus_no = bus_no; + dev->dev_no = dev_no; sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ - sprintf(dev->devid, "vbus%u:dev%u", (unsigned) busNo, (unsigned) devNo); + sprintf(dev->devid, "vbus%u:dev%u", (unsigned)bus_no, (unsigned)dev_no); /* map the channel memory for the device. */ - if (msg->hdr.flags.test_message) + if (msg->hdr.flags.test_message) { dev->chanptr = (void __iomem *)__va(dev->channel_addr); - else { - pReqHandler = req_handler_find(dev->channel_uuid); - if (pReqHandler) + } else { + req_handler = req_handler_find(dev->channel_uuid); + if (req_handler) /* generic service handler registered for this * channel */ - minSize = pReqHandler->min_channel_bytes; - if (minSize > msg->cmd.create_device.channel_bytes) { + min_size = req_handler->min_channel_bytes; + if (min_size > msg->cmd.create_device.channel_bytes) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: channel size is too small, channel size:0x%lx, required size:0x%lx", - (ulong) msg->cmd.create_device.channel_bytes, - (ulong) minSize); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, - POSTCODE_SEVERITY_ERR); + (ulong)msg->cmd.create_device.channel_bytes, + (ulong)min_size); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); result = CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL; - goto Away; + goto cleanup; } dev->chanptr = uislib_ioremap_cache(dev->channel_addr, msg->cmd.create_device.channel_bytes); if (!dev->chanptr) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", - dev->channel_addr, - msg->cmd.create_device.channel_bytes); + dev->channel_addr, + msg->cmd.create_device.channel_bytes); result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED; - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, - POSTCODE_SEVERITY_ERR); - goto Away; + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); + goto cleanup; } } dev->instance_uuid = msg->cmd.create_device.dev_inst_uuid; dev->channel_bytes = msg->cmd.create_device.channel_bytes; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - if (bus->bus_no == busNo) { - /* make sure the device number is valid */ - if (devNo >= bus->device_count) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: device (%d) >= deviceCount (%d).", - devNo, bus->device_count); - result = CONTROLVM_RESP_ERROR_MAX_DEVICES; + read_lock(&bus_list_lock); + for (bus = bus_list; bus; bus = bus->next) { + if (bus->bus_no != bus_no) + continue; + /* make sure the device number is valid */ + if (dev_no >= bus->device_count) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: device (%d) >= deviceCount (%d).", + dev_no, bus->device_count); + result = CONTROLVM_RESP_ERROR_MAX_DEVICES; + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); + read_unlock(&bus_list_lock); + goto cleanup; + } + /* make sure this device is not already set */ + if (bus->device[dev_no]) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: device %d is already exists.", + dev_no); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, + dev_no, bus_no, + POSTCODE_SEVERITY_ERR); + result = CONTROLVM_RESP_ERROR_ALREADY_DONE; + read_unlock(&bus_list_lock); + goto cleanup; + } + read_unlock(&bus_list_lock); + /* the msg is bound for virtpci; send + * guest_msgs struct to callback + */ + if (msg->hdr.flags.server) { + bus->device[dev_no] = dev; + POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, + bus_no, POSTCODE_SEVERITY_INFO); + return CONTROLVM_RESP_SUCCESS; + } + if (uuid_le_cmp(dev->channel_uuid, + spar_vhba_channel_protocol_uuid) == 0) { + wait_for_valid_guid(&((struct channel_header __iomem *) + (dev->chanptr))->chtype); + if (!SPAR_VHBA_CHANNEL_OK_CLIENT(dev->chanptr)) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", + dev_no); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, - devNo, busNo, + dev_no, bus_no, POSTCODE_SEVERITY_ERR); - read_unlock(&BusListLock); - goto Away; + result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; + goto cleanup; } - /* make sure this device is not already set */ - if (bus->device[devNo]) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: device %d is already exists.", - devNo); + cmd.msgtype = GUEST_ADD_VHBA; + cmd.add_vhba.chanptr = dev->chanptr; + cmd.add_vhba.bus_no = bus_no; + cmd.add_vhba.device_no = dev_no; + cmd.add_vhba.instance_uuid = dev->instance_uuid; + cmd.add_vhba.intr = dev->intr; + } else if (uuid_le_cmp(dev->channel_uuid, + spar_vnic_channel_protocol_uuid) == 0) { + wait_for_valid_guid(&((struct channel_header __iomem *) + (dev->chanptr))->chtype); + if (!SPAR_VNIC_CHANNEL_OK_CLIENT(dev->chanptr)) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", + dev_no); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, - devNo, busNo, + dev_no, bus_no, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_ALREADY_DONE; - read_unlock(&BusListLock); - goto Away; + result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; + goto cleanup; } - read_unlock(&BusListLock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (!msg->hdr.flags.server) { - struct guest_msgs cmd; - - if (!uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid)) { - wait_for_valid_guid(&(( - struct channel_header - __iomem *) (dev-> - chanptr))-> - chtype); - if (!SPAR_VHBA_CHANNEL_OK_CLIENT - (dev->chanptr)) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", - devNo); - POSTCODE_LINUX_4 - (DEVICE_CREATE_FAILURE_PC, - devNo, busNo, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; - goto Away; - } - cmd.msgtype = GUEST_ADD_VHBA; - cmd.add_vhba.chanptr = dev->chanptr; - 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->channel_uuid, - spar_vnic_channel_protocol_uuid)) { - wait_for_valid_guid(&(( - struct channel_header - __iomem *) (dev-> - chanptr))-> - chtype); - if (!SPAR_VNIC_CHANNEL_OK_CLIENT - (dev->chanptr)) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", - devNo); - POSTCODE_LINUX_4 - (DEVICE_CREATE_FAILURE_PC, - devNo, busNo, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; - goto Away; - } - cmd.msgtype = GUEST_ADD_VNIC; - cmd.add_vnic.chanptr = dev->chanptr; - 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"); - POSTCODE_LINUX_4 - (DEVICE_CREATE_FAILURE_PC, devNo, - busNo, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - goto Away; - } + cmd.msgtype = GUEST_ADD_VNIC; + cmd.add_vnic.chanptr = dev->chanptr; + cmd.add_vnic.bus_no = bus_no; + cmd.add_vnic.device_no = dev_no; + cmd.add_vnic.instance_uuid = dev->instance_uuid; + cmd.add_vhba.intr = dev->intr; + } else { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: unknown channelTypeGuid.\n"); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); + result = CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; + goto cleanup; + } - if (!virt_control_chan_func) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci callback not registered."); - POSTCODE_LINUX_4 - (DEVICE_CREATE_FAILURE_PC, devNo, - busNo, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - goto Away; - } + if (!virt_control_chan_func) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci callback not registered."); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); + result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; + goto cleanup; + } - if (!virt_control_chan_func(&cmd)) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci GUEST_ADD_[VHBA||VNIC] returned error."); - POSTCODE_LINUX_4 - (DEVICE_CREATE_FAILURE_PC, devNo, - busNo, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - goto Away; - } - } - bus->device[devNo] = dev; - POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, devNo, busNo, - POSTCODE_SEVERITY_INFO); - return CONTROLVM_RESP_SUCCESS; + if (!virt_control_chan_func(&cmd)) { + LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci GUEST_ADD_[VHBA||VNIC] returned error."); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, + bus_no, POSTCODE_SEVERITY_ERR); + result = + CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; + goto cleanup; } + + bus->device[dev_no] = dev; + POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, + bus_no, POSTCODE_SEVERITY_INFO); + return CONTROLVM_RESP_SUCCESS; } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); - LOGERR("CONTROLVM_DEVICE_CREATE Failed: failed to find bus %d.", busNo); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + LOGERR("CONTROLVM_DEVICE_CREATE Failed: failed to find bus %d.", + bus_no); + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); result = CONTROLVM_RESP_ERROR_BUS_INVALID; -Away: +cleanup: if (!msg->hdr.flags.test_message) { uislib_iounmap(dev->chanptr); dev->chanptr = NULL; @@ -543,32 +526,31 @@ Away: return result; } -static int -pause_device(struct controlvm_message *msg) +static int pause_device(struct controlvm_message *msg) { - u32 busNo, devNo; + u32 bus_no, dev_no; struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.device_change_state.bus_no; - devNo = msg->cmd.device_change_state.dev_no; + bus_no = msg->cmd.device_change_state.bus_no; + dev_no = msg->cmd.device_change_state.dev_no; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - if (bus->bus_no == busNo) { + read_lock(&bus_list_lock); + for (bus = bus_list; bus; bus = bus->next) { + if (bus->bus_no == bus_no) { /* make sure the device number is valid */ - if (devNo >= bus->device_count) { + if (dev_no >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).", - devNo, bus->device_count); + dev_no, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ - dev = bus->device[devNo]; + dev = bus->device[dev_no]; if (!dev) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.", - devNo); + dev_no); retval = CONTROLVM_RESP_ERROR_ALREADY_DONE; } @@ -578,20 +560,20 @@ pause_device(struct controlvm_message *msg) } if (!bus) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: bus %d does not exist", - busNo); + bus_no); retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); if (retval == CONTROLVM_RESP_SUCCESS) { /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid)) { + if (uuid_le_cmp(dev->channel_uuid, + spar_vhba_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_PAUSE_VHBA; cmd.pause_vhba.chanptr = dev->chanptr; - } else if (!uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid)) { + } else if (uuid_le_cmp(dev->channel_uuid, + spar_vnic_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_PAUSE_VNIC; cmd.pause_vnic.chanptr = dev->chanptr; } else { @@ -611,32 +593,31 @@ pause_device(struct controlvm_message *msg) return retval; } -static int -resume_device(struct controlvm_message *msg) +static int resume_device(struct controlvm_message *msg) { - u32 busNo, devNo; + u32 bus_no, dev_no; struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.device_change_state.bus_no; - devNo = msg->cmd.device_change_state.dev_no; + bus_no = msg->cmd.device_change_state.bus_no; + dev_no = msg->cmd.device_change_state.dev_no; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - if (bus->bus_no == busNo) { + read_lock(&bus_list_lock); + for (bus = bus_list; bus; bus = bus->next) { + if (bus->bus_no == bus_no) { /* make sure the device number is valid */ - if (devNo >= bus->device_count) { + if (dev_no >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).", - devNo, bus->device_count); + dev_no, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ - dev = bus->device[devNo]; + dev = bus->device[dev_no]; if (!dev) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.", - devNo); + dev_no); retval = CONTROLVM_RESP_ERROR_ALREADY_DONE; } @@ -647,20 +628,20 @@ resume_device(struct controlvm_message *msg) if (!bus) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: bus %d does not exist", - busNo); + bus_no); retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); /* the msg is bound for virtpci; send * guest_msgs struct to callback */ if (retval == CONTROLVM_RESP_SUCCESS) { - if (!uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid)) { + if (uuid_le_cmp(dev->channel_uuid, + spar_vhba_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_RESUME_VHBA; cmd.resume_vhba.chanptr = dev->chanptr; - } else if (!uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid)) { + } else if (uuid_le_cmp(dev->channel_uuid, + spar_vnic_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_RESUME_VNIC; cmd.resume_vnic.chanptr = dev->chanptr; } else { @@ -680,33 +661,33 @@ resume_device(struct controlvm_message *msg) return retval; } -static int -destroy_device(struct controlvm_message *msg, char *buf) +static int destroy_device(struct controlvm_message *msg, char *buf) { - u32 busNo, devNo; + u32 bus_no, dev_no; struct bus_info *bus; struct device_info *dev; struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.destroy_device.bus_no; - devNo = msg->cmd.destroy_device.bus_no; + bus_no = msg->cmd.destroy_device.bus_no; + dev_no = msg->cmd.destroy_device.bus_no; - read_lock(&BusListLock); - LOGINF("destroy_device called for busNo=%u, devNo=%u", busNo, devNo); - for (bus = BusListHead; bus; bus = bus->next) { - if (bus->bus_no == busNo) { + read_lock(&bus_list_lock); + LOGINF("destroy_device called for bus_no=%u, dev_no=%u", bus_no, + dev_no); + for (bus = bus_list; bus; bus = bus->next) { + if (bus->bus_no == bus_no) { /* make sure the device number is valid */ - if (devNo >= bus->device_count) { - LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).", - devNo, bus->device_count); + if (dev_no >= bus->device_count) { + LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device(%d) >= device_count(%d).", + dev_no, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ - dev = bus->device[devNo]; + dev = bus->device[dev_no]; if (!dev) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.", - devNo); + dev_no); retval = CONTROLVM_RESP_ERROR_ALREADY_DONE; } @@ -717,20 +698,20 @@ destroy_device(struct controlvm_message *msg, char *buf) if (!bus) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: bus %d does not exist", - busNo); + bus_no); retval = CONTROLVM_RESP_ERROR_BUS_INVALID; } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); if (retval == CONTROLVM_RESP_SUCCESS) { /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid)) { + if (uuid_le_cmp(dev->channel_uuid, + spar_vhba_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_DEL_VHBA; cmd.del_vhba.chanptr = dev->chanptr; - } else if (!uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid)) { + } else if (uuid_le_cmp(dev->channel_uuid, + spar_vnic_channel_protocol_uuid) == 0) { cmd.msgtype = GUEST_DEL_VNIC; cmd.del_vnic.chanptr = dev->chanptr; } else { @@ -739,7 +720,7 @@ destroy_device(struct controlvm_message *msg, char *buf) CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; } if (!virt_control_chan_func) { - LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered."); + LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } @@ -755,7 +736,7 @@ destroy_device(struct controlvm_message *msg, char *buf) */ if (dev->polling) { LOGINF("calling uislib_disable_channel_interrupts"); - uislib_disable_channel_interrupts(busNo, devNo); + uislib_disable_channel_interrupts(bus_no, dev_no); } /* unmap the channel memory for the device. */ if (!msg->hdr.flags.test_message) { @@ -763,7 +744,7 @@ destroy_device(struct controlvm_message *msg, char *buf) uislib_iounmap(dev->chanptr); } kfree(dev); - bus->device[devNo] = NULL; + bus->device[dev_no] = NULL; } return retval; } @@ -773,9 +754,9 @@ init_chipset(struct controlvm_message *msg, char *buf) { POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); - MaxBusCount = msg->cmd.init_chipset.bus_count; - PlatformNumber = msg->cmd.init_chipset.platform_number; - PhysicalDataChan = 0; + max_bus_count = msg->cmd.init_chipset.bus_count; + platform_no = msg->cmd.init_chipset.platform_number; + phys_data_chan = 0; /* We need to make sure we have our functions registered * before processing messages. If we are a test vehicle the @@ -793,31 +774,29 @@ init_chipset(struct controlvm_message *msg, char *buf) return CONTROLVM_RESP_SUCCESS; } -static int -delete_bus_glue(u32 busNo) +static int delete_bus_glue(u32 bus_no) { struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.cmd.destroy_bus.bus_no = busNo; + msg.cmd.destroy_bus.bus_no = bus_no; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("destroy_bus failed. busNo=0x%x\n", busNo); + LOGERR("destroy_bus failed. bus_no=0x%x\n", bus_no); return 0; } return 1; } -static int -delete_device_glue(u32 busNo, u32 devNo) +static int delete_device_glue(u32 bus_no, u32 dev_no) { struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); - msg.cmd.destroy_device.bus_no = busNo; - msg.cmd.destroy_device.dev_no = devNo; + msg.cmd.destroy_device.bus_no = bus_no; + msg.cmd.destroy_device.dev_no = dev_no; if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("destroy_device failed. busNo=0x%x devNo=0x%x\n", busNo, - devNo); + LOGERR("destroy_device failed. bus_no=0x%x dev_no=0x%x\n", + bus_no, dev_no); return 0; } return 1; @@ -874,7 +853,6 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, } EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus); - int uislib_client_inject_del_bus(u32 bus_no) { @@ -919,7 +897,6 @@ uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) return rc; } return 0; - } EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba); @@ -956,7 +933,7 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, msg.cmd.create_device.channel_addr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", - chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); + chan_bytes, (unsigned int)MIN_IO_CHANNEL_SIZE); POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, chan_bytes, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; @@ -1015,7 +992,7 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, msg.cmd.create_device.channel_addr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", - chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); + chan_bytes, (unsigned int)MIN_IO_CHANNEL_SIZE); POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, chan_bytes, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; @@ -1072,7 +1049,6 @@ uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) return -1; } return 0; - } EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic); @@ -1129,14 +1105,12 @@ info_debugfs_read_helper(char **buff, int *buff_len) if (PLINE("\nBuses:\n") < 0) goto err_done; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - + read_lock(&bus_list_lock); + for (bus = bus_list; bus; bus = bus->next) { if (PLINE(" bus=0x%p, busNo=%d, deviceCount=%d\n", bus, bus->bus_no, bus->device_count) < 0) goto err_done_unlock; - if (PLINE(" Devices:\n") < 0) goto err_done_unlock; @@ -1156,7 +1130,7 @@ info_debugfs_read_helper(char **buff, int *buff_len) } } } - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); if (PLINE("UisUtils_Registered_Services: %d\n", atomic_read(&uisutils_registered_services)) < 0) @@ -1175,70 +1149,68 @@ info_debugfs_read_helper(char **buff, int *buff_len) return tot; err_done_unlock: - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); err_done: return -1; } -static ssize_t -info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) +static ssize_t info_debugfs_read(struct file *file, char __user *buf, + size_t len, loff_t *offset) { char *temp; - int totalBytes = 0; + int total_bytes = 0; int remaining_bytes = PROC_READ_BUFFER_SIZE; /* *start = buf; */ - if (ProcReadBuffer == NULL) { - DBGINF("ProcReadBuffer == NULL; allocating buffer.\n."); - ProcReadBuffer = vmalloc(PROC_READ_BUFFER_SIZE); + if (debug_buf == NULL) { + DBGINF("debug_buf == NULL; allocating buffer.\n."); + debug_buf = vmalloc(PROC_READ_BUFFER_SIZE); - if (ProcReadBuffer == NULL) { + if (debug_buf == NULL) { LOGERR("failed to allocate buffer to provide proc data.\n"); return -ENOMEM; } } - temp = ProcReadBuffer; + temp = debug_buf; - if ((*offset == 0) || (!ProcReadBufferValid)) { + if ((*offset == 0) || (!debug_buf_valid)) { DBGINF("calling info_debugfs_read_helper.\n"); /* if the read fails, then -1 will be returned */ - totalBytes = info_debugfs_read_helper(&temp, &remaining_bytes); - ProcReadBufferValid = 1; - } else - totalBytes = strlen(ProcReadBuffer); + total_bytes = info_debugfs_read_helper(&temp, &remaining_bytes); + debug_buf_valid = 1; + } else { + total_bytes = strlen(debug_buf); + } return simple_read_from_buffer(buf, len, offset, - ProcReadBuffer, totalBytes); + debug_buf, total_bytes); } -static struct device_info * -find_dev(u32 busNo, u32 devNo) +static struct device_info *find_dev(u32 bus_no, u32 dev_no) { struct bus_info *bus; struct device_info *dev = NULL; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - if (bus->bus_no == busNo) { + read_lock(&bus_list_lock); + for (bus = bus_list; bus; bus = bus->next) { + if (bus->bus_no == bus_no) { /* make sure the device number is valid */ - if (devNo >= bus->device_count) { - LOGERR("%s bad busNo, devNo=%d,%d", + if (dev_no >= bus->device_count) { + LOGERR("%s bad bus_no, dev_no=%d,%d", __func__, - (int) (busNo), (int) (devNo)); - goto Away; + (int)bus_no, (int)dev_no); + break; } - dev = bus->device[devNo]; + dev = bus->device[dev_no]; if (!dev) - LOGERR("%s bad busNo, devNo=%d,%d", + LOGERR("%s bad bus_no, dev_no=%d,%d", __func__, - (int) (busNo), (int) (devNo)); - goto Away; + (int)bus_no, (int)dev_no); + break; } } -Away: - read_unlock(&BusListLock); + read_unlock(&bus_list_lock); return dev; } @@ -1262,8 +1234,7 @@ Away: * less-busy ones. * */ -static int -Process_Incoming(void *v) +static int process_incoming(void *v) { unsigned long long cur_cycles, old_cycles, idle_cycles, delta_cycles; struct list_head *new_tail = NULL; @@ -1272,7 +1243,7 @@ Process_Incoming(void *v) UIS_DAEMONIZE("dev_incoming"); for (i = 0; i < 16; i++) { old_cycles = get_cycles(); - wait_event_timeout(Wakeup_Polling_Device_Channels, + wait_event_timeout(poll_dev_wake_q, 0, POLLJIFFIES_NORMAL); cur_cycles = get_cycles(); if (wait_cycles == 0) { @@ -1285,15 +1256,15 @@ Process_Incoming(void *v) LOGINF("wait_cycles=%llu", wait_cycles); cycles_before_wait = wait_cycles; idle_cycles = 0; - Go_Polling_Device_Channels = 0; + poll_dev_start = 0; while (1) { struct list_head *lelt, *tmp; struct device_info *dev = NULL; /* poll each channel for input */ - down(&Lock_Polling_Device_Channels); + down(&poll_dev_lock); new_tail = NULL; - list_for_each_safe(lelt, tmp, &List_Polling_Device_Channels) { + list_for_each_safe(lelt, tmp, &poll_dev_chan) { int rc = 0; dev = list_entry(lelt, struct device_info, @@ -1315,22 +1286,22 @@ Process_Incoming(void *v) if (! (list_is_last (lelt, - &List_Polling_Device_Channels))) { + &poll_dev_chan))) { new_tail = lelt; dev->moved_to_tail_cnt++; - } else + } else { dev->last_on_list_cnt++; + } } - } - if (Incoming_ThreadInfo.should_stop) + if (incoming_ti.should_stop) break; } if (new_tail != NULL) { tot_moved_to_tail_cnt++; - list_move_tail(new_tail, &List_Polling_Device_Channels); + list_move_tail(new_tail, &poll_dev_chan); } - up(&Lock_Polling_Device_Channels); + up(&poll_dev_lock); cur_cycles = get_cycles(); delta_cycles = cur_cycles - old_cycles; old_cycles = cur_cycles; @@ -1340,24 +1311,24 @@ Process_Incoming(void *v) * - there is no input waiting on any of the channels * - we have received a signal to stop this thread */ - if (Incoming_ThreadInfo.should_stop) + if (incoming_ti.should_stop) break; if (en_smart_wakeup == 0xFF) { LOGINF("en_smart_wakeup set to 0xff, to force exiting process_incoming"); break; } /* wait for POLLJIFFIES_NORMAL jiffies, or until - * someone wakes up Wakeup_Polling_Device_Channels, + * someone wakes up poll_dev_wake_q, * whichever comes first only do a wait when we have * been idle for cycles_before_wait cycles. */ if (idle_cycles > cycles_before_wait) { - Go_Polling_Device_Channels = 0; + poll_dev_start = 0; tot_wait_cnt++; - wait_event_timeout(Wakeup_Polling_Device_Channels, - Go_Polling_Device_Channels, + wait_event_timeout(poll_dev_wake_q, + poll_dev_start, POLLJIFFIES_NORMAL); - Go_Polling_Device_Channels = 1; + poll_dev_start = 1; } else { tot_schedule_cnt++; schedule(); @@ -1365,25 +1336,25 @@ Process_Incoming(void *v) } } DBGINF("exiting.\n"); - complete_and_exit(&Incoming_ThreadInfo.has_stopped, 0); + complete_and_exit(&incoming_ti.has_stopped, 0); } static BOOL -Initialize_incoming_thread(void) +initialize_incoming_thread(void) { - if (Incoming_Thread_Started) + if (incoming_started) return TRUE; - if (!uisthread_start(&Incoming_ThreadInfo, - &Process_Incoming, NULL, "dev_incoming")) { - LOGERR("uisthread_start Initialize_incoming_thread ****FAILED"); + if (!uisthread_start(&incoming_ti, + &process_incoming, NULL, "dev_incoming")) { + LOGERR("uisthread_start initialize_incoming_thread ****FAILED"); return FALSE; } - Incoming_Thread_Started = TRUE; + incoming_started = TRUE; return TRUE; } /* Add a new device/channel to the list being processed by - * Process_Incoming(). + * process_incoming(). * <interrupt> - indicates the function to call periodically. * <interrupt_context> - indicates the data to pass to the <interrupt> * function. @@ -1397,23 +1368,23 @@ uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, dev = find_dev(bus_no, dev_no); if (!dev) { - LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (bus_no), - (int) (dev_no)); + LOGERR("%s busNo=%d, devNo=%d", __func__, (int)(bus_no), + (int)(dev_no)); return; } - down(&Lock_Polling_Device_Channels); - Initialize_incoming_thread(); + down(&poll_dev_lock); + 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); - up(&Lock_Polling_Device_Channels); + list_add_tail(&dev->list_polling_device_channels, + &poll_dev_chan); + up(&poll_dev_lock); } EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts); /* Remove a device/channel from the list being processed by - * Process_Incoming(). + * process_incoming(). */ void uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no) @@ -1422,31 +1393,31 @@ uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no) dev = find_dev(bus_no, dev_no); if (!dev) { - LOGERR("%s busNo=%d, devNo=%d", __func__, (int) (bus_no), - (int) (dev_no)); + LOGERR("%s busNo=%d, devNo=%d", __func__, (int)(bus_no), + (int)(dev_no)); return; } - down(&Lock_Polling_Device_Channels); + down(&poll_dev_lock); list_del(&dev->list_polling_device_channels); dev->polling = FALSE; dev->interrupt = NULL; - up(&Lock_Polling_Device_Channels); + up(&poll_dev_lock); } EXPORT_SYMBOL_GPL(uislib_disable_channel_interrupts); static void do_wakeup_polling_device_channels(struct work_struct *dummy) { - if (!Go_Polling_Device_Channels) { - Go_Polling_Device_Channels = 1; - wake_up(&Wakeup_Polling_Device_Channels); + if (!poll_dev_start) { + poll_dev_start = 1; + wake_up(&poll_dev_wake_q); } } -static DECLARE_WORK(Work_wakeup_polling_device_channels, +static DECLARE_WORK(work_wakeup_polling_device_channels, do_wakeup_polling_device_channels); -/* Call this function when you want to send a hint to Process_Incoming() that +/* Call this function when you want to send a hint to process_incoming() that * your device might have more requests. */ void @@ -1454,14 +1425,14 @@ uislib_force_channel_interrupt(u32 bus_no, u32 dev_no) { if (en_smart_wakeup == 0) return; - if (Go_Polling_Device_Channels) + if (poll_dev_start) return; /* The point of using schedule_work() instead of just doing * the work inline is to force a slight delay before waking up - * the Process_Incoming() thread. + * the process_incoming() thread. */ tot_wakeup_cnt++; - schedule_work(&Work_wakeup_polling_device_channels); + schedule_work(&work_wakeup_polling_device_channels); } EXPORT_SYMBOL_GPL(uislib_force_channel_interrupt); @@ -1472,35 +1443,35 @@ EXPORT_SYMBOL_GPL(uislib_force_channel_interrupt); static int __init uislib_mod_init(void) { - if (!unisys_spar_platform) return -ENODEV; LOGINF("MONITORAPIS"); LOGINF("sizeof(struct uiscmdrsp):%lu bytes\n", - (ulong) sizeof(struct uiscmdrsp)); + (ulong)sizeof(struct uiscmdrsp)); LOGINF("sizeof(struct phys_info):%lu\n", - (ulong) sizeof(struct phys_info)); + (ulong)sizeof(struct phys_info)); LOGINF("sizeof(uiscmdrsp_scsi):%lu\n", - (ulong) sizeof(struct uiscmdrsp_scsi)); + (ulong)sizeof(struct uiscmdrsp_scsi)); LOGINF("sizeof(uiscmdrsp_net):%lu\n", - (ulong) sizeof(struct uiscmdrsp_net)); + (ulong)sizeof(struct uiscmdrsp_net)); LOGINF("sizeof(CONTROLVM_MESSAGE):%lu bytes\n", - (ulong) sizeof(struct controlvm_message)); + (ulong)sizeof(struct controlvm_message)); LOGINF("sizeof(struct spar_controlvm_channel_protocol):%lu bytes\n", - (ulong) sizeof(struct spar_controlvm_channel_protocol)); + (ulong)sizeof(struct spar_controlvm_channel_protocol)); LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n", - (ulong) sizeof(struct channel_header)); + (ulong)sizeof(struct channel_header)); LOGINF("sizeof(struct spar_io_channel_protocol):%lu bytes\n", - (ulong) sizeof(struct spar_io_channel_protocol)); + (ulong)sizeof(struct spar_io_channel_protocol)); LOGINF("SIZEOF_CMDRSP:%lu bytes\n", SIZEOF_CMDRSP); LOGINF("SIZEOF_PROTOCOL:%lu bytes\n", SIZEOF_PROTOCOL); /* initialize global pointers to NULL */ - BusListHead = NULL; - BusListCount = MaxBusCount = 0; - rwlock_init(&BusListLock); + bus_list = NULL; + bus_list_count = 0; + max_bus_count = 0; + rwlock_init(&bus_list_lock); virt_control_chan_func = NULL; /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and @@ -1515,7 +1486,7 @@ uislib_mod_init(void) platformnumber_debugfs_read = debugfs_create_u32( PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, - &PlatformNumber); + &platform_no); cycles_before_wait_debugfs_read = debugfs_create_u64( CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, @@ -1533,9 +1504,9 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (ProcReadBuffer) { - vfree(ProcReadBuffer); - ProcReadBuffer = NULL; + if (debug_buf) { + vfree(debug_buf); + debug_buf = NULL; } debugfs_remove(info_debugfs_entry); diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index f9f8442d58c5..71bb7b608e9a 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -21,8 +21,6 @@ #include "uisutils.h" -#include "chanstub.h" - /* this is shorter than using __FILE__ (full path name) in * debug/info/error messages */ #define CURRENT_FILE_PC UISLIB_PC_uisqueue_c @@ -33,9 +31,202 @@ /*****************************************************/ /* Exported functions */ /*****************************************************/ + +/* + * Routine Description: + * Tries to insert the prebuilt signal pointed to by pSignal into the nth + * Queue of the Channel pointed to by pChannel + * + * Parameters: + * pChannel: (IN) points to the IO Channel + * Queue: (IN) nth Queue of the IO Channel + * pSignal: (IN) pointer to the signal + * + * Assumptions: + * - pChannel, Queue and pSignal are valid. + * - If insertion fails due to a full queue, the caller will determine the + * retry policy (e.g. wait & try again, report an error, etc.). + * + * Return value: + * 1 if the insertion succeeds, 0 if the queue was full. + */ +unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, + void *sig) +{ + void __iomem *psignal; + unsigned int head, tail, nof; + + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *) + ((char __iomem *)ch + readq(&ch->ch_space_offset)) + + queue; + + /* capture current head and tail */ + head = readl(&pqhdr->head); + tail = readl(&pqhdr->tail); + + /* queue is full if (head + 1) % n equals tail */ + if (((head + 1) % readl(&pqhdr->max_slots)) == tail) { + nof = readq(&pqhdr->num_overflows) + 1; + writeq(nof, &pqhdr->num_overflows); + return 0; + } + + /* increment the head index */ + head = (head + 1) % readl(&pqhdr->max_slots); + + /* copy signal to the head location from the area pointed to + * by pSignal + */ + psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + + (head * readl(&pqhdr->signal_size)); + memcpy_toio(psignal, sig, readl(&pqhdr->signal_size)); + + mb(); /* channel synch */ + writel(head, &pqhdr->head); + + writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); + return 1; +} +EXPORT_SYMBOL_GPL(spar_signal_insert); + +/* + * Routine Description: + * Removes one signal from Channel pChannel's nth Queue at the + * time of the call and copies it into the memory pointed to by + * pSignal. + * + * Parameters: + * pChannel: (IN) points to the IO Channel + * Queue: (IN) nth Queue of the IO Channel + * pSignal: (IN) pointer to where the signals are to be copied + * + * Assumptions: + * - pChannel and Queue are valid. + * - pSignal points to a memory area large enough to hold queue's SignalSize + * + * Return value: + * 1 if the removal succeeds, 0 if the queue was empty. + */ +unsigned char +spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) +{ + void __iomem *psource; + unsigned int head, tail; + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *)((char __iomem *)ch + + readq(&ch->ch_space_offset)) + queue; + + /* capture current head and tail */ + head = readl(&pqhdr->head); + tail = readl(&pqhdr->tail); + + /* queue is empty if the head index equals the tail index */ + if (head == tail) { + writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty); + return 0; + } + + /* advance past the 'empty' front slot */ + tail = (tail + 1) % readl(&pqhdr->max_slots); + + /* copy signal from tail location to the area pointed to by pSignal */ + psource = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + + (tail * readl(&pqhdr->signal_size)); + memcpy_fromio(sig, psource, readl(&pqhdr->signal_size)); + + mb(); /* channel synch */ + writel(tail, &pqhdr->tail); + + writeq(readq(&pqhdr->num_received) + 1, + &pqhdr->num_received); + return 1; +} +EXPORT_SYMBOL_GPL(spar_signal_remove); + +/* + * Routine Description: + * Removes all signals present in Channel pChannel's nth Queue at the + * time of the call and copies them into the memory pointed to by + * pSignal. Returns the # of signals copied as the value of the routine. + * + * Parameters: + * pChannel: (IN) points to the IO Channel + * Queue: (IN) nth Queue of the IO Channel + * pSignal: (IN) pointer to where the signals are to be copied + * + * Assumptions: + * - pChannel and Queue are valid. + * - pSignal points to a memory area large enough to hold Queue's MaxSignals + * # of signals, each of which is Queue's SignalSize. + * + * Return value: + * # of signals copied. + */ +unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, + void *sig) +{ + void *psource; + unsigned int head, tail, count = 0; + struct signal_queue_header *pqhdr = + (struct signal_queue_header *)((char *)ch + + ch->ch_space_offset) + queue; + + /* capture current head and tail */ + head = pqhdr->head; + tail = pqhdr->tail; + + /* queue is empty if the head index equals the tail index */ + if (head == tail) + return 0; + + while (head != tail) { + /* advance past the 'empty' front slot */ + tail = (tail + 1) % pqhdr->max_slots; + + /* copy signal from tail location to the area pointed + * to by pSignal + */ + psource = + (char *)pqhdr + pqhdr->sig_base_offset + + (tail * pqhdr->signal_size); + memcpy((char *)sig + (pqhdr->signal_size * count), + psource, pqhdr->signal_size); + + mb(); /* channel synch */ + pqhdr->tail = tail; + + count++; + pqhdr->num_received++; + } + + return count; +} + +/* + * Routine Description: + * Determine whether a signal queue is empty. + * + * Parameters: + * pChannel: (IN) points to the IO Channel + * Queue: (IN) nth Queue of the IO Channel + * + * Return value: + * 1 if the signal queue is empty, 0 otherwise. + */ +unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, + u32 queue) +{ + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *)((char __iomem *)ch + + readq(&ch->ch_space_offset)) + queue; + return readl(&pqhdr->head) == readl(&pqhdr->tail); +} +EXPORT_SYMBOL_GPL(spar_signalqueue_empty); + unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt, - unsigned long long set) + unsigned long long set) { unsigned long long i; unsigned long long j; @@ -53,7 +244,7 @@ EXPORT_SYMBOL_GPL(uisqueue_interlocked_or); unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt, - unsigned long long set) + unsigned long long set) { unsigned long long i; unsigned long long j; @@ -72,22 +263,21 @@ EXPORT_SYMBOL_GPL(uisqueue_interlocked_and); static u8 do_locked_client_insert(struct uisqueue_info *queueinfo, unsigned int whichqueue, - void *pSignal, + void *signal, spinlock_t *lock, - unsigned char issueInterruptIfEmpty, - u64 interruptHandle, u8 *channelId) + u8 *channel_id) { unsigned long flags; u8 rc = 0; spin_lock_irqsave(lock, flags); - if (!spar_channel_client_acquire_os(queueinfo->chan, channelId)) + if (!spar_channel_client_acquire_os(queueinfo->chan, channel_id)) goto unlock; - if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) { + if (spar_signal_insert(queueinfo->chan, whichqueue, signal)) { queueinfo->packets_sent++; rc = 1; } - spar_channel_client_release_os(queueinfo->chan, channelId); + spar_channel_client_release_os(queueinfo->chan, channel_id); unlock: spin_unlock_irqrestore((spinlock_t *)lock, flags); return rc; @@ -103,9 +293,8 @@ uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, char oktowait, u8 *channel_id) { while (!do_locked_client_insert(queueinfo, whichqueue, cmdrsp, - (spinlock_t *) insertlock, - issue_irq_if_empty, - irq_handle, channel_id)) { + (spinlock_t *)insertlock, + 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 c0fc812f751e..25adf1a7307c 100644 --- a/drivers/staging/unisys/uislib/uisthread.c +++ b/drivers/staging/unisys/uislib/uisthread.c @@ -53,7 +53,6 @@ uisthread_start(struct uisthread_info *thrinfo, wake_up_process(thrinfo->task); LOGINF("started thread pid:%d\n", thrinfo->id); return 1; - } EXPORT_SYMBOL_GPL(uisthread_start); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 4a5b86773927..31318d246252 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -42,14 +42,13 @@ atomic_t uisutils_registered_services = ATOMIC_INIT(0); * uisctrl_register_req_handler() or * uisctrl_register_req_handler_ex() */ - /*****************************************************/ /* Utility functions */ /*****************************************************/ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, - char *format, ...) + char *format, ...) { va_list args; int len; @@ -57,6 +56,7 @@ uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, DBGINF("buffer = 0x%p : *buffer = 0x%p.\n", buffer, *buffer); va_start(args, format); len = vsnprintf(*buffer, *buffer_remaining, format, args); + va_end(args); if (len >= *buffer_remaining) { *buffer += *buffer_remaining; *total += *buffer_remaining; @@ -96,7 +96,7 @@ uisctrl_register_req_handler(int type, void *fptr, } if (chipset_driver_info) bus_device_info_init(chipset_driver_info, "chipset", "uislib", - VERSION, NULL); + VERSION, NULL); return 1; } @@ -113,66 +113,57 @@ uisctrl_register_req_handler_ex(uuid_le switch_uuid, u32 client_str_len, u64 bytes), struct ultra_vbus_deviceinfo *chipset_driver_info) { - struct req_handler_info *pReqHandlerInfo; - int rc = 0; /* assume failure */ + struct req_handler_info *req_handler; LOGINF("type=%pUL, controlfunc=0x%p.\n", &switch_uuid, controlfunc); if (!controlfunc) { LOGERR("%pUL: controlfunc must be supplied\n", &switch_uuid); - goto Away; + return 0; } if (!server_channel_ok) { LOGERR("%pUL: Server_Channel_Ok must be supplied\n", &switch_uuid); - goto Away; + return 0; } if (!server_channel_init) { LOGERR("%pUL: Server_Channel_Init must be supplied\n", &switch_uuid); - goto Away; + return 0; } - pReqHandlerInfo = req_handler_add(switch_uuid, - switch_type_name, - controlfunc, - min_channel_bytes, - server_channel_ok, server_channel_init); - if (!pReqHandlerInfo) { + req_handler = req_handler_add(switch_uuid, + switch_type_name, + controlfunc, + min_channel_bytes, + server_channel_ok, server_channel_init); + if (!req_handler) { LOGERR("failed to add %pUL to server list\n", &switch_uuid); - goto Away; + return 0; } atomic_inc(&uisutils_registered_services); - rc = 1; /* success */ -Away: - if (rc) { - if (chipset_driver_info) - bus_device_info_init(chipset_driver_info, "chipset", - "uislib", VERSION, NULL); - } else - LOGERR("failed to register type %pUL.\n", &switch_uuid); + if (chipset_driver_info) { + bus_device_info_init(chipset_driver_info, "chipset", + "uislib", VERSION, NULL); + return 1; + } - return rc; + LOGERR("failed to register type %pUL.\n", &switch_uuid); + return 0; } EXPORT_SYMBOL_GPL(uisctrl_register_req_handler_ex); int uisctrl_unregister_req_handler_ex(uuid_le switch_uuid) { - int rc = 0; /* assume failure */ - LOGINF("type=%pUL.\n", &switch_uuid); if (req_handler_del(switch_uuid) < 0) { LOGERR("failed to remove %pUL from server list\n", - &switch_uuid); - goto Away; + &switch_uuid); + return 0; } atomic_dec(&uisutils_registered_services); - rc = 1; /* success */ -Away: - if (!rc) - LOGERR("failed to unregister type %pUL.\n", &switch_uuid); - return rc; + return 1; } EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex); @@ -214,10 +205,10 @@ uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, void *skb_in, frags[count].pi_pfn = page_to_pfn(virt_to_page(skb->data + offset)); frags[count].pi_off = - (unsigned long) (skb->data + offset) & PI_PAGE_MASK; + (unsigned long)(skb->data + offset) & PI_PAGE_MASK; size = min(firstfraglen, - (unsigned int) (PI_PAGE_SIZE - frags[count].pi_off)); + (unsigned int)(PI_PAGE_SIZE - frags[count].pi_off)); /* can take smallest of firstfraglen(what's left) OR * bytes left in the page */ @@ -231,7 +222,7 @@ uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, void *skb_in, 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); + calling_ctx, frags_max, count + numfrags); return -1; /* failure */ } @@ -255,7 +246,6 @@ dolist: if (skb_shinfo(skb)->frag_list) { for (skbinlist = skb_shinfo(skb)->frag_list; skbinlist; skbinlist = skbinlist->next) { - c = uisutil_copy_fragsinfo_from_skb("recursive", skbinlist, skbinlist->len - skbinlist->data_len, @@ -272,17 +262,18 @@ dolist: if (skb_shinfo(skb)->frag_list) { } EXPORT_SYMBOL_GPL(uisutil_copy_fragsinfo_from_skb); -static LIST_HEAD(ReqHandlerInfo_list); /* list of struct req_handler_info */ -static DEFINE_SPINLOCK(ReqHandlerInfo_list_lock); +static LIST_HEAD(req_handler_info_list); /* list of struct req_handler_info */ +static DEFINE_SPINLOCK(req_handler_info_list_lock); struct req_handler_info * req_handler_add(uuid_le switch_uuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, - int (*Server_Channel_Ok)(unsigned long channelBytes), - int (*Server_Channel_Init) - (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes)) + int (*server_channel_ok)(unsigned long channel_bytes), + int (*server_channel_init) + (void *x, unsigned char *clientstr, u32 clientstr_len, + u64 bytes)) { struct req_handler_info *rc = NULL; @@ -292,14 +283,14 @@ req_handler_add(uuid_le switch_uuid, rc->switch_uuid = switch_uuid; rc->controlfunc = controlfunc; rc->min_channel_bytes = min_channel_bytes; - rc->server_channel_ok = Server_Channel_Ok; - rc->server_channel_init = Server_Channel_Init; + rc->server_channel_ok = server_channel_ok; + rc->server_channel_init = server_channel_init; if (switch_type_name) strncpy(rc->switch_type_name, switch_type_name, sizeof(rc->switch_type_name) - 1); - spin_lock(&ReqHandlerInfo_list_lock); - list_add_tail(&(rc->list_link), &ReqHandlerInfo_list); - spin_unlock(&ReqHandlerInfo_list_lock); + spin_lock(&req_handler_info_list_lock); + list_add_tail(&rc->list_link, &req_handler_info_list); + spin_unlock(&req_handler_info_list_lock); return rc; } @@ -310,15 +301,15 @@ req_handler_find(uuid_le switch_uuid) struct list_head *lelt, *tmp; struct req_handler_info *entry = NULL; - spin_lock(&ReqHandlerInfo_list_lock); - list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { + spin_lock(&req_handler_info_list_lock); + list_for_each_safe(lelt, tmp, &req_handler_info_list) { entry = list_entry(lelt, struct req_handler_info, list_link); if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) { - spin_unlock(&ReqHandlerInfo_list_lock); + spin_unlock(&req_handler_info_list_lock); return entry; } } - spin_unlock(&ReqHandlerInfo_list_lock); + spin_unlock(&req_handler_info_list_lock); return NULL; } @@ -329,8 +320,8 @@ req_handler_del(uuid_le switch_uuid) struct req_handler_info *entry = NULL; int rc = -1; - spin_lock(&ReqHandlerInfo_list_lock); - list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { + spin_lock(&req_handler_info_list_lock); + list_for_each_safe(lelt, tmp, &req_handler_info_list) { entry = list_entry(lelt, struct req_handler_info, list_link); if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) { list_del(lelt); @@ -338,6 +329,6 @@ req_handler_del(uuid_le switch_uuid) rc++; } } - spin_unlock(&ReqHandlerInfo_list_lock); + spin_unlock(&req_handler_info_list_lock); return rc; } diff --git a/drivers/staging/unisys/virthba/Kconfig b/drivers/staging/unisys/virthba/Kconfig index c0d7986e78cb..9af98fc7acbc 100644 --- a/drivers/staging/unisys/virthba/Kconfig +++ b/drivers/staging/unisys/virthba/Kconfig @@ -4,7 +4,7 @@ config UNISYS_VIRTHBA tristate "Unisys virthba driver" - depends on UNISYSSPAR && UNISYS_VISORCHIPSET && UNISYS_CHANNELSTUB && UNISYS_UISLIB && UNISYS_VIRTPCI && SCSI + depends on UNISYSSPAR && UNISYS_VISORCHIPSET && UNISYS_UISLIB && UNISYS_VIRTPCI && SCSI ---help--- If you say Y here, you will enable the Unisys virthba driver. diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index d7a629b5f111..e6ecea560495 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -85,7 +85,8 @@ static int virthba_host_reset_handler(struct scsi_cmnd *scsicmd); static const char *virthba_get_info(struct Scsi_Host *shp); static int virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg); static int virthba_queue_command_lck(struct scsi_cmnd *scsicmd, - void (*virthba_cmnd_done)(struct scsi_cmnd *)); + void (*virthba_cmnd_done) + (struct scsi_cmnd *)); static const struct x86_cpu_id unisys_spar_ids[] = { { X86_VENDOR_INTEL, 6, 62, X86_FEATURE_ANY }, @@ -107,19 +108,20 @@ static void virthba_slave_destroy(struct scsi_device *scsidev); static int process_incoming_rsps(void *); static int virthba_serverup(struct virtpci_dev *virtpcidev); static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state); -static void doDiskAddRemove(struct work_struct *work); +static void do_disk_add_remove(struct work_struct *work); static void virthba_serverdown_complete(struct work_struct *work); static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); + size_t len, loff_t *offset); static ssize_t enable_ints_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos); + const char __user *buffer, size_t count, + loff_t *ppos); /*****************************************************/ /* Globals */ /*****************************************************/ static int rsltq_wait_usecs = 4000; /* Default 4ms */ -static unsigned int MaxBuffLen; +static unsigned int max_buff_len; /* Module options */ static char *virthba_options = "NONE"; @@ -165,6 +167,7 @@ struct virtdisk_info { atomic_t error_count; struct virtdisk_info *next; }; + /* Each Scsi_Host has a host_data area that contains this struct. */ struct virthba_info { struct Scsi_Host *scsihost; @@ -193,7 +196,7 @@ struct virthba_info { struct virtdisk_info head; }; -/* Work Data for DARWorkQ */ +/* Work Data for dar_work_queue */ struct diskaddremove { u8 add; /* 0-remove, 1-add */ struct Scsi_Host *shost; /* Scsi Host for this virthba instance */ @@ -244,7 +247,7 @@ static const struct file_operations debugfs_enable_ints_fops = { #define VIRTHBASOPENMAX 1 /* array of open devices maintained by open() and close(); */ -static struct virthba_devices_open VirtHbasOpen[VIRTHBASOPENMAX]; +static struct virthba_devices_open virthbas_open[VIRTHBASOPENMAX]; static struct dentry *virthba_debugfs_dir; /*****************************************************/ @@ -260,7 +263,7 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char cmdtype, void *new) insert_location = vhbainfo->nextinsert; while (vhbainfo->pending[insert_location].sent != NULL) { insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS; - if (insert_location == (int) vhbainfo->nextinsert) { + if (insert_location == (int)vhbainfo->nextinsert) { LOGERR("Queue should be full. insert_location<<%d>> Unable to find open slot for pending commands.\n", insert_location); spin_unlock_irqrestore(&vhbainfo->privlock, flags); @@ -289,7 +292,7 @@ add_scsipending_entry_with_wait(struct virthba_info *vhbainfo, char cmdtype, insert_location = add_scsipending_entry(vhbainfo, cmdtype, new); } - return (unsigned int) insert_location; + return (unsigned int)insert_location; } static void * @@ -300,13 +303,13 @@ del_scsipending_entry(struct virthba_info *vhbainfo, uintptr_t del) if (del >= MAX_PENDING_REQUESTS) { LOGERR("Invalid queue position <<%lu>> given to delete. MAX_PENDING_REQUESTS <<%d>>\n", - (unsigned long) del, MAX_PENDING_REQUESTS); + (unsigned long)del, MAX_PENDING_REQUESTS); } else { spin_lock_irqsave(&vhbainfo->privlock, flags); if (vhbainfo->pending[del].sent == NULL) LOGERR("Deleting already cleared queue entry at <<%lu>>.\n", - (unsigned long) del); + (unsigned long)del); sent = vhbainfo->pending[del].sent; @@ -318,30 +321,30 @@ del_scsipending_entry(struct virthba_info *vhbainfo, uintptr_t del) return sent; } -/* DARWorkQ (Disk Add/Remove) */ -static struct work_struct DARWorkQ; -static struct diskaddremove *DARWorkQHead; -static spinlock_t DARWorkQLock; -static unsigned short DARWorkQSched; +/* dar_work_queue (Disk Add/Remove) */ +static struct work_struct dar_work_queue; +static struct diskaddremove *dar_work_queue_head; +static spinlock_t dar_work_queue_lock; +static unsigned short dar_work_queue_sched; #define QUEUE_DISKADDREMOVE(dar) { \ - spin_lock_irqsave(&DARWorkQLock, flags); \ - if (!DARWorkQHead) { \ - DARWorkQHead = dar; \ + spin_lock_irqsave(&dar_work_queue_lock, flags); \ + if (!dar_work_queue_head) { \ + dar_work_queue_head = dar; \ dar->next = NULL; \ } \ else { \ - dar->next = DARWorkQHead; \ - DARWorkQHead = dar; \ + dar->next = dar_work_queue_head; \ + dar_work_queue_head = dar; \ } \ - if (!DARWorkQSched) { \ - schedule_work(&DARWorkQ); \ - DARWorkQSched = 1; \ + if (!dar_work_queue_sched) { \ + schedule_work(&dar_work_queue); \ + dar_work_queue_sched = 1; \ } \ - spin_unlock_irqrestore(&DARWorkQLock, flags); \ + spin_unlock_irqrestore(&dar_work_queue_lock, flags); \ } static inline void -SendDiskAddRemove(struct diskaddremove *dar) +send_disk_add_remove(struct diskaddremove *dar) { struct scsi_device *sdev; int error; @@ -365,31 +368,31 @@ SendDiskAddRemove(struct diskaddremove *dar) } /*****************************************************/ -/* DARWorkQ Handler Thread */ +/* dar_work_queue Handler Thread */ /*****************************************************/ static void -doDiskAddRemove(struct work_struct *work) +do_disk_add_remove(struct work_struct *work) { struct diskaddremove *dar; struct diskaddremove *tmphead; int i = 0; unsigned long flags; - spin_lock_irqsave(&DARWorkQLock, flags); - tmphead = DARWorkQHead; - DARWorkQHead = NULL; - DARWorkQSched = 0; - spin_unlock_irqrestore(&DARWorkQLock, flags); + spin_lock_irqsave(&dar_work_queue_lock, flags); + tmphead = dar_work_queue_head; + dar_work_queue_head = NULL; + dar_work_queue_sched = 0; + spin_unlock_irqrestore(&dar_work_queue_lock, flags); while (tmphead) { dar = tmphead; tmphead = dar->next; - SendDiskAddRemove(dar); + send_disk_add_remove(dar); i++; } } /*****************************************************/ -/* Routine to add entry to DARWorkQ */ +/* Routine to add entry to dar_work_queue */ /*****************************************************/ static void process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp) @@ -397,7 +400,7 @@ process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp) struct diskaddremove *dar; unsigned long flags; - dar = kzalloc(sizeof(struct diskaddremove), GFP_ATOMIC); + dar = kzalloc(sizeof(*dar), GFP_ATOMIC); if (dar) { dar->add = cmdrsp->disknotify.add; dar->shost = shost; @@ -416,10 +419,10 @@ process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp) /* Probe Remove Functions */ /*****************************************************/ static irqreturn_t -virthba_ISR(int irq, void *dev_id) +virthba_isr(int irq, void *dev_id) { - struct virthba_info *virthbainfo = (struct virthba_info *) dev_id; - struct channel_header __iomem *pChannelHeader; + struct virthba_info *virthbainfo = (struct virthba_info *)dev_id; + struct channel_header __iomem *channel_header; struct signal_queue_header __iomem *pqhdr; u64 mask; unsigned long long rc1; @@ -427,23 +430,23 @@ virthba_ISR(int irq, void *dev_id) if (virthbainfo == NULL) return IRQ_NONE; virthbainfo->interrupts_rcvd++; - pChannelHeader = virthbainfo->chinfo.queueinfo->chan; - if (((readq(&pChannelHeader->features) - & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) - && ((readq(&pChannelHeader->features) & + channel_header = virthbainfo->chinfo.queueinfo->chan; + if (((readq(&channel_header->features) + & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) && + ((readq(&channel_header->features) & ULTRA_IO_DRIVER_DISABLES_INTS) != 0)) { virthbainfo->interrupts_disabled++; mask = ~ULTRA_CHANNEL_ENABLE_INTS; rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask); } - if (spar_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) { + if (spar_signalqueue_empty(channel_header, IOCHAN_FROM_IOPART)) { virthbainfo->interrupts_notme++; return IRQ_NONE; } pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *) pChannelHeader + - readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; + ((char __iomem *)channel_header + + readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART; writeq(readq(&pqhdr->num_irq_received) + 1, &pqhdr->num_irq_received); atomic_set(&virthbainfo->interrupt_rcvd, 1); @@ -459,8 +462,8 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) struct virthba_info *virthbainfo; int rsp; int i; - irq_handler_t handler = virthba_ISR; - struct channel_header __iomem *pChannelHeader; + irq_handler_t handler = virthba_isr; + struct channel_header __iomem *channel_header; struct signal_queue_header __iomem *pqhdr; u64 mask; @@ -476,7 +479,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) * instance - this virthba that has just been created is an * instance of a scsi host adapter. This scsi_host_alloc * function allocates a new Scsi_Host struct & performs basic - * initializatoin. The host is not published to the scsi + * initialization. The host is not published to the scsi * midlayer until scsi_add_host is called. */ DBGINF("calling scsi_host_alloc.\n"); @@ -501,19 +504,19 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) * the max-channel value. */ LOGINF("virtpcidev->scsi.max.max_channel=%u, max_id=%u, max_lun=%u, cmd_per_lun=%u, max_io_size=%u\n", - (unsigned) virtpcidev->scsi.max.max_channel - 1, - (unsigned) virtpcidev->scsi.max.max_id, - (unsigned) virtpcidev->scsi.max.max_lun, - (unsigned) virtpcidev->scsi.max.cmd_per_lun, - (unsigned) virtpcidev->scsi.max.max_io_size); - scsihost->max_channel = (unsigned) virtpcidev->scsi.max.max_channel; - scsihost->max_id = (unsigned) virtpcidev->scsi.max.max_id; - scsihost->max_lun = (unsigned) virtpcidev->scsi.max.max_lun; - scsihost->cmd_per_lun = (unsigned) virtpcidev->scsi.max.cmd_per_lun; + (unsigned)virtpcidev->scsi.max.max_channel - 1, + (unsigned)virtpcidev->scsi.max.max_id, + (unsigned)virtpcidev->scsi.max.max_lun, + (unsigned)virtpcidev->scsi.max.cmd_per_lun, + (unsigned)virtpcidev->scsi.max.max_io_size); + scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel; + scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id; + scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun; + scsihost->cmd_per_lun = (unsigned)virtpcidev->scsi.max.cmd_per_lun; scsihost->max_sectors = - (unsigned short) (virtpcidev->scsi.max.max_io_size >> 9); + (unsigned short)(virtpcidev->scsi.max.max_io_size >> 9); scsihost->sg_tablesize = - (unsigned short) (virtpcidev->scsi.max.max_io_size / PAGE_SIZE); + (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=%llu, cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n", @@ -544,11 +547,11 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) return -ENODEV; } - virthbainfo = (struct virthba_info *) scsihost->hostdata; + virthbainfo = (struct virthba_info *)scsihost->hostdata; memset(virthbainfo, 0, sizeof(struct virthba_info)); for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (VirtHbasOpen[i].virthbainfo == NULL) { - VirtHbasOpen[i].virthbainfo = virthbainfo; + if (virthbas_open[i].virthbainfo == NULL) { + virthbas_open[i].virthbainfo = virthbainfo; break; } } @@ -584,10 +587,10 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) DBGINF("starting rsp thread -- queueinfo: 0x%p, threadinfo: 0x%p.\n", virthbainfo->chinfo.queueinfo, &virthbainfo->chinfo.threadinfo); - pChannelHeader = virthbainfo->chinfo.queueinfo->chan; + channel_header = virthbainfo->chinfo.queueinfo->chan; pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *)pChannelHeader + - readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; + ((char __iomem *)channel_header + + readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART; virthbainfo->flags_addr = &pqhdr->features; if (!uisthread_start(&virthbainfo->chinfo.threadinfo, @@ -646,11 +649,11 @@ virthba_remove(struct virtpci_dev *virtpcidev) { struct virthba_info *virthbainfo; struct Scsi_Host *scsihost = - (struct Scsi_Host *) virtpcidev->scsi.scsihost; + (struct Scsi_Host *)virtpcidev->scsi.scsihost; LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, virtpcidev->device_no); - virthbainfo = (struct virthba_info *) scsihost->hostdata; + virthbainfo = (struct virthba_info *)scsihost->hostdata; if (virthbainfo->interrupt_vector != -1) free_irq(virthbainfo->interrupt_vector, virthbainfo); LOGINF("Removing virtpcidev: 0x%p, virthbainfo: 0x%p\n", virtpcidev, @@ -679,7 +682,7 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, { struct uiscmdrsp *cmdrsp; struct virthba_info *virthbainfo = - (struct virthba_info *) scsihost->hostdata; + (struct virthba_info *)scsihost->hostdata; int notifyresult = 0xffff; wait_queue_head_t notifyevent; @@ -706,8 +709,8 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, /* specify the event that has to be triggered when this cmd is * complete */ - cmdrsp->vdiskmgmt.notify = (void *) ¬ifyevent; - cmdrsp->vdiskmgmt.notifyresult = (void *) ¬ifyresult; + cmdrsp->vdiskmgmt.notify = (void *)¬ifyevent; + cmdrsp->vdiskmgmt.notifyresult = (void *)¬ifyresult; /* save destination */ cmdrsp->vdiskmgmt.vdisktype = vdiskcmdtype; @@ -715,14 +718,14 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, cmdrsp->vdiskmgmt.vdest.id = vdest->id; cmdrsp->vdiskmgmt.vdest.lun = vdest->lun; cmdrsp->vdiskmgmt.scsicmd = - (void *) (uintptr_t) + (void *)(uintptr_t) add_scsipending_entry_with_wait(virthbainfo, CMD_VDISKMGMT_TYPE, - (void *) cmdrsp); + (void *)cmdrsp); uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo, cmdrsp, IOCHAN_TO_IOPART, &virthbainfo->chinfo.insertlock, - DONT_ISSUE_INTERRUPT, (u64) NULL, + DONT_ISSUE_INTERRUPT, (u64)NULL, OK_TO_WAIT, "vhba"); LOGINF("VdiskMgmt waiting on event notifyevent=0x%p\n", cmdrsp->scsitaskmgmt.notify); @@ -742,7 +745,7 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype, { struct uiscmdrsp *cmdrsp; struct virthba_info *virthbainfo = - (struct virthba_info *) scsidev->host->hostdata; + (struct virthba_info *)scsidev->host->hostdata; int notifyresult = 0xffff; wait_queue_head_t notifyevent; @@ -767,8 +770,8 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype, cmdrsp->cmdtype = CMD_SCSITASKMGMT_TYPE; /* specify the event that has to be triggered when this */ /* cmd is complete */ - cmdrsp->scsitaskmgmt.notify = (void *) ¬ifyevent; - cmdrsp->scsitaskmgmt.notifyresult = (void *) ¬ifyresult; + cmdrsp->scsitaskmgmt.notify = (void *)¬ifyevent; + cmdrsp->scsitaskmgmt.notifyresult = (void *)¬ifyresult; /* save destination */ cmdrsp->scsitaskmgmt.tasktype = tasktype; @@ -776,15 +779,15 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype, cmdrsp->scsitaskmgmt.vdest.id = scsidev->id; cmdrsp->scsitaskmgmt.vdest.lun = scsidev->lun; cmdrsp->scsitaskmgmt.scsicmd = - (void *) (uintptr_t) + (void *)(uintptr_t) add_scsipending_entry_with_wait(virthbainfo, CMD_SCSITASKMGMT_TYPE, - (void *) cmdrsp); + (void *)cmdrsp); uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo, cmdrsp, IOCHAN_TO_IOPART, &virthbainfo->chinfo.insertlock, - DONT_ISSUE_INTERRUPT, (u64) NULL, + DONT_ISSUE_INTERRUPT, (u64)NULL, OK_TO_WAIT, "vhba"); LOGINF("TaskMgmt waiting on event notifyevent=0x%p\n", cmdrsp->scsitaskmgmt.notify); @@ -805,11 +808,11 @@ virthba_abort_handler(struct scsi_cmnd *scsicmd) struct virtdisk_info *vdisk; scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *) scsidev->host->hostdata)->head; + for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) - && (scsidev->id == vdisk->id) - && (scsidev->lun == vdisk->lun)) { + if ((scsidev->channel == vdisk->channel) && + (scsidev->id == vdisk->id) && + (scsidev->lun == vdisk->lun)) { if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { atomic_inc(&vdisk->error_count); @@ -831,11 +834,11 @@ virthba_bus_reset_handler(struct scsi_cmnd *scsicmd) struct virtdisk_info *vdisk; scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *) scsidev->host->hostdata)->head; + for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) - && (scsidev->id == vdisk->id) - && (scsidev->lun == vdisk->lun)) { + if ((scsidev->channel == vdisk->channel) && + (scsidev->id == vdisk->id) && + (scsidev->lun == vdisk->lun)) { if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { atomic_inc(&vdisk->error_count); @@ -857,11 +860,11 @@ virthba_device_reset_handler(struct scsi_cmnd *scsicmd) struct virtdisk_info *vdisk; scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *) scsidev->host->hostdata)->head; + for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) - && (scsidev->id == vdisk->id) - && (scsidev->lun == vdisk->lun)) { + if ((scsidev->channel == vdisk->channel) && + (scsidev->id == vdisk->id) && + (scsidev->lun == vdisk->lun)) { if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { atomic_inc(&vdisk->error_count); @@ -915,7 +918,7 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, struct uiscmdrsp *cmdrsp; unsigned int i; struct virthba_info *virthbainfo = - (struct virthba_info *) scsihost->hostdata; + (struct virthba_info *)scsihost->hostdata; struct scatterlist *sg = NULL; struct scatterlist *sgl = NULL; int sg_failed = 0; @@ -940,9 +943,9 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, * will return the scsicmd pointer for completion */ insert_location = - add_scsipending_entry(virthbainfo, CMD_SCSI_TYPE, (void *) scsicmd); + add_scsipending_entry(virthbainfo, CMD_SCSI_TYPE, (void *)scsicmd); if (insert_location != -1) { - cmdrsp->scsi.scsicmd = (void *) (uintptr_t) insert_location; + cmdrsp->scsi.scsicmd = (void *)(uintptr_t)insert_location; } else { LOGERR("Queue is full. Returning busy.\n"); kfree(cmdrsp); @@ -961,13 +964,13 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, cmdrsp->scsi.bufflen = scsi_bufflen(scsicmd); /* keep track of the max buffer length so far. */ - if (cmdrsp->scsi.bufflen > MaxBuffLen) - MaxBuffLen = cmdrsp->scsi.bufflen; + if (cmdrsp->scsi.bufflen > max_buff_len) + max_buff_len = cmdrsp->scsi.bufflen; if (scsi_sg_count(scsicmd) > MAX_PHYS_INFO) { LOGERR("scsicmd use_sg:%d greater than MAX:%d\n", scsi_sg_count(scsicmd), MAX_PHYS_INFO); - del_scsipending_entry(virthbainfo, (uintptr_t) insert_location); + del_scsipending_entry(virthbainfo, (uintptr_t)insert_location); kfree(cmdrsp); return 1; /* reject the command */ } @@ -989,22 +992,21 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, sgl = scsi_sglist(scsicmd); for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) { - cmdrsp->scsi.gpi_list[i].address = sg_phys(sg); cmdrsp->scsi.gpi_list[i].length = sg->length; if ((i != 0) && (sg->offset != 0)) LOGINF("Offset on a sg_entry other than zero =<<%d>>.\n", - sg->offset); + sg->offset); } if (sg_failed) { LOGERR("Start sg_list dump (entries %d, bufflen %d)...\n", - scsi_sg_count(scsicmd), cmdrsp->scsi.bufflen); + scsi_sg_count(scsicmd), cmdrsp->scsi.bufflen); for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) { LOGERR(" Entry(%d): page->[0x%p], phys->[0x%Lx], off(%d), len(%d)\n", - i, sg_page(sg), - (unsigned long long) sg_phys(sg), - sg->offset, sg->length); + i, sg_page(sg), + (unsigned long long)sg_phys(sg), + sg->offset, sg->length); } LOGERR("Done sg_list dump.\n"); /* BUG(); ***** For now, let it fail in uissd @@ -1022,12 +1024,12 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, &virthbainfo->chinfo. insertlock, DONT_ISSUE_INTERRUPT, - (u64) NULL, DONT_WAIT, "vhba"); + (u64)NULL, DONT_WAIT, "vhba"); if (i == 0) { /* queue must be full - and we said don't wait - return busy */ LOGERR("uisqueue_put_cmdrsp_with_lock ****FAILED\n"); kfree(cmdrsp); - del_scsipending_entry(virthbainfo, (uintptr_t) insert_location); + del_scsipending_entry(virthbainfo, (uintptr_t)insert_location); return SCSI_MLQUEUE_DEVICE_BUSY; } @@ -1047,9 +1049,9 @@ virthba_slave_alloc(struct scsi_device *scsidev) struct virtdisk_info *vdisk; struct virtdisk_info *tmpvdisk; struct virthba_info *virthbainfo; - struct Scsi_Host *scsihost = (struct Scsi_Host *) scsidev->host; + struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host; - virthbainfo = (struct virthba_info *) scsihost->hostdata; + virthbainfo = (struct virthba_info *)scsihost->hostdata; if (!virthbainfo) { LOGERR("Could not find virthba_info for scsihost\n"); return 0; /* even though we errored, treat as success */ @@ -1061,7 +1063,7 @@ virthba_slave_alloc(struct scsi_device *scsidev) (vdisk->next->lun == scsidev->lun)) return 0; } - tmpvdisk = kzalloc(sizeof(struct virtdisk_info), GFP_ATOMIC); + tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC); if (!tmpvdisk) { /* error allocating */ LOGERR("Could not allocate memory for disk\n"); return 0; @@ -1089,9 +1091,9 @@ virthba_slave_destroy(struct scsi_device *scsidev) */ struct virtdisk_info *vdisk, *delvdisk; struct virthba_info *virthbainfo; - struct Scsi_Host *scsihost = (struct Scsi_Host *) scsidev->host; + struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host; - virthbainfo = (struct virthba_info *) scsihost->hostdata; + virthbainfo = (struct virthba_info *)scsihost->hostdata; if (!virthbainfo) LOGERR("Could not find virthba_info for scsihost\n"); for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) { @@ -1120,7 +1122,7 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) scsidev = scsicmd->device; memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE); - sd = (struct sense_data *) scsicmd->sense_buffer; + sd = (struct sense_data *)scsicmd->sense_buffer; /* Do not log errors for disk-not-present inquiries */ if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && @@ -1129,11 +1131,11 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) return; /* Okay see what our error_count is here.... */ - for (vdisk = &((struct virthba_info *) scsidev->host->hostdata)->head; + for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel != vdisk->channel) - || (scsidev->id != vdisk->id) - || (scsidev->lun != vdisk->lun)) + if ((scsidev->channel != vdisk->channel) || + (scsidev->id != vdisk->id) || + (scsidev->lun != vdisk->lun)) continue; if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { @@ -1148,8 +1150,8 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) if (atomic_read(&vdisk->error_count) == VIRTHBA_ERROR_COUNT) { LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%llu>\n", - scsidev->host->host_no, scsidev->id, - scsidev->channel, scsidev->lun); + scsidev->host->host_no, scsidev->id, + scsidev->channel, scsidev->lun); } atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); } @@ -1169,8 +1171,8 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) struct virtdisk_info *vdisk; scsidev = scsicmd->device; - if ((cmdrsp->scsi.cmnd[0] == INQUIRY) - && (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) { + if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && + (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) { if (cmdrsp->scsi.no_disk_result == 0) return; @@ -1198,21 +1200,20 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) sg = scsi_sglist(scsicmd); for (i = 0; i < scsi_sg_count(scsicmd); i++) { DBGVER("copying OUT OF buf into 0x%p %d\n", - sg_page(sg + i), sg[i].length); + sg_page(sg + i), sg[i].length); thispage_orig = kmap_atomic(sg_page(sg + i)); - thispage = (void *) ((unsigned long)thispage_orig | + thispage = (void *)((unsigned long)thispage_orig | sg[i].offset); memcpy(thispage, buf + bufind, sg[i].length); kunmap_atomic(thispage_orig); bufind += sg[i].length; } } else { - vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; for ( ; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel != vdisk->channel) - || (scsidev->id != vdisk->id) - || (scsidev->lun != vdisk->lun)) + if ((scsidev->channel != vdisk->channel) || + (scsidev->id != vdisk->id) || + (scsidev->lun != vdisk->lun)) continue; if (atomic_read(&vdisk->ios_threshold) > 0) { @@ -1249,8 +1250,8 @@ complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp) { /* copy the result of the taskmgmt and */ /* wake up the error handler that is waiting for this */ - *(int *) cmdrsp->vdiskmgmt.notifyresult = cmdrsp->vdiskmgmt.result; - wake_up_all((wait_queue_head_t *) cmdrsp->vdiskmgmt.notify); + *(int *)cmdrsp->vdiskmgmt.notifyresult = cmdrsp->vdiskmgmt.result; + wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify); LOGINF("set notify result to %d\n", cmdrsp->vdiskmgmt.result); } @@ -1259,15 +1260,15 @@ complete_taskmgmt_command(struct uiscmdrsp *cmdrsp) { /* copy the result of the taskmgmt and */ /* wake up the error handler that is waiting for this */ - *(int *) cmdrsp->scsitaskmgmt.notifyresult = + *(int *)cmdrsp->scsitaskmgmt.notifyresult = cmdrsp->scsitaskmgmt.result; - wake_up_all((wait_queue_head_t *) cmdrsp->scsitaskmgmt.notify); + wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify); LOGINF("set notify result to %d\n", cmdrsp->scsitaskmgmt.result); } static void drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, - struct uiscmdrsp *cmdrsp) + struct uiscmdrsp *cmdrsp) { unsigned long flags; int qrslt = 0; @@ -1277,7 +1278,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, while (1) { spin_lock_irqsave(&virthbainfo->chinfo.insertlock, flags); if (!spar_channel_client_acquire_os(dc->queueinfo->chan, - "vhba")) { + "vhba")) { spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags); virthbainfo->acquire_failed_cnt++; @@ -1294,14 +1295,15 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, * deletion */ scsicmd = del_scsipending_entry(virthbainfo, - (uintptr_t) cmdrsp->scsi.scsicmd); + (uintptr_t) + cmdrsp->scsi.scsicmd); if (!scsicmd) break; /* complete the orig cmd */ complete_scsi_command(cmdrsp, scsicmd); } else if (cmdrsp->cmdtype == CMD_SCSITASKMGMT_TYPE) { if (!del_scsipending_entry(virthbainfo, - (uintptr_t) cmdrsp->scsitaskmgmt.scsicmd)) + (uintptr_t)cmdrsp->scsitaskmgmt.scsicmd)) break; complete_taskmgmt_command(cmdrsp); } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) { @@ -1313,7 +1315,8 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, process_disk_notify(shost, cmdrsp); } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) { if (!del_scsipending_entry(virthbainfo, - (uintptr_t) cmdrsp->vdiskmgmt.scsicmd)) + (uintptr_t) + cmdrsp->vdiskmgmt.scsicmd)) break; complete_vdiskmgmt_command(cmdrsp); } else @@ -1347,7 +1350,7 @@ process_incoming_rsps(void *v) while (1) { wait_event_interruptible_timeout(virthbainfo->rsp_queue, (atomic_read(&virthbainfo->interrupt_rcvd) == 1), - usecs_to_jiffies(rsltq_wait_usecs)); + usecs_to_jiffies(rsltq_wait_usecs)); atomic_set(&virthbainfo->interrupt_rcvd, 0); /* drain queue */ drain_queue(virthbainfo, dc, cmdrsp); @@ -1367,7 +1370,7 @@ process_incoming_rsps(void *v) /*****************************************************/ static ssize_t info_debugfs_read(struct file *file, - char __user *buf, size_t len, loff_t *offset) + char __user *buf, size_t len, loff_t *offset) { ssize_t bytes_read = 0; int str_pos = 0; @@ -1383,13 +1386,14 @@ static ssize_t info_debugfs_read(struct file *file, return -ENOMEM; for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (VirtHbasOpen[i].virthbainfo == NULL) + if (virthbas_open[i].virthbainfo == NULL) continue; - virthbainfo = VirtHbasOpen[i].virthbainfo; + virthbainfo = virthbas_open[i].virthbainfo; str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "MaxBuffLen:%u\n", MaxBuffLen); + len - str_pos, "max_buff_len:%u\n", + max_buff_len); str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\nvirthba result queue poll wait:%d usecs.\n", @@ -1418,14 +1422,14 @@ static ssize_t info_debugfs_read(struct file *file, return bytes_read; } -static ssize_t enable_ints_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) +static ssize_t enable_ints_write(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) { char buf[4]; int i, new_value; struct virthba_info *virthbainfo; - u64 __iomem *Features_addr; + u64 __iomem *features_addr; u64 mask; if (count >= ARRAY_SIZE(buf)) @@ -1434,37 +1438,37 @@ static ssize_t enable_ints_write(struct file *file, buf[count] = '\0'; if (copy_from_user(buf, buffer, count)) { LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n", - (int) count, buf, count); + (int)count, buf, count); return -EFAULT; } - i = kstrtoint(buf, 10 , &new_value); + i = kstrtoint(buf, 10, &new_value); if (i != 0) { LOGERR("Failed to scan value for enable_ints, buf<<%.*s>>", - (int) count, buf); + (int)count, buf); return -EFAULT; } /* set all counts to new_value usually 0 */ for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (VirtHbasOpen[i].virthbainfo != NULL) { - virthbainfo = VirtHbasOpen[i].virthbainfo; - Features_addr = + if (virthbas_open[i].virthbainfo != NULL) { + virthbainfo = virthbas_open[i].virthbainfo; + features_addr = &virthbainfo->chinfo.queueinfo->chan->features; if (new_value == 1) { mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_interlocked_and(Features_addr, mask); + uisqueue_interlocked_and(features_addr, mask); mask = ULTRA_IO_DRIVER_ENABLES_INTS; - uisqueue_interlocked_or(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_interlocked_and(Features_addr, mask); + uisqueue_interlocked_and(features_addr, mask); mask = ULTRA_IO_CHANNEL_IS_POLLING; - uisqueue_interlocked_or(Features_addr, mask); + uisqueue_interlocked_or(features_addr, mask); rsltq_wait_usecs = 4000; } } @@ -1477,7 +1481,7 @@ static int virthba_serverup(struct virtpci_dev *virtpcidev) { struct virthba_info *virthbainfo = - (struct virthba_info *) ((struct Scsi_Host *) virtpcidev->scsi. + (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi. scsihost)->hostdata; DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, @@ -1535,26 +1539,26 @@ virthba_serverdown_complete(struct work_struct *work) /* Fail Commands that weren't completed */ spin_lock_irqsave(&virthbainfo->privlock, flags); for (i = 0; i < MAX_PENDING_REQUESTS; i++) { - pendingdel = &(virthbainfo->pending[i]); + pendingdel = &virthbainfo->pending[i]; switch (pendingdel->cmdtype) { case CMD_SCSI_TYPE: - scsicmd = (struct scsi_cmnd *) pendingdel->sent; + scsicmd = (struct scsi_cmnd *)pendingdel->sent; scsicmd->result = (DID_RESET << 16); if (scsicmd->scsi_done) scsicmd->scsi_done(scsicmd); break; case CMD_SCSITASKMGMT_TYPE: - cmdrsp = (struct uiscmdrsp *) pendingdel->sent; + cmdrsp = (struct uiscmdrsp *)pendingdel->sent; DBGINF("cmdrsp=0x%x, notify=0x%x\n", cmdrsp, cmdrsp->scsitaskmgmt.notify); - *(int *) cmdrsp->scsitaskmgmt.notifyresult = + *(int *)cmdrsp->scsitaskmgmt.notifyresult = TASK_MGMT_FAILED; wake_up_all((wait_queue_head_t *) cmdrsp->scsitaskmgmt.notify); break; case CMD_VDISKMGMT_TYPE: - cmdrsp = (struct uiscmdrsp *) pendingdel->sent; - *(int *) cmdrsp->vdiskmgmt.notifyresult = + cmdrsp = (struct uiscmdrsp *)pendingdel->sent; + *(int *)cmdrsp->vdiskmgmt.notifyresult = VDISK_MGMT_FAILED; wake_up_all((wait_queue_head_t *) cmdrsp->vdiskmgmt.notify); @@ -1584,8 +1588,10 @@ virthba_serverdown_complete(struct work_struct *work) static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state) { + int stat = 1; + struct virthba_info *virthbainfo = - (struct virthba_info *) ((struct Scsi_Host *) virtpcidev->scsi. + (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi. scsihost)->hostdata; DBGINF("virthba_serverdown"); @@ -1598,11 +1604,12 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state) &virthbainfo->serverdown_completion); } else if (virthbainfo->serverchangingstate) { LOGERR("Server already processing change state message\n"); - return 0; - } else + stat = 0; + } else { LOGERR("Server already down, but another server down message received."); + } - return 1; + return stat; } /*****************************************************/ @@ -1655,23 +1662,22 @@ virthba_mod_init(void) POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error, POSTCODE_SEVERITY_ERR); } else { - /* create the debugfs directories and entries */ virthba_debugfs_dir = debugfs_create_dir("virthba", NULL); debugfs_create_file("info", S_IRUSR, virthba_debugfs_dir, - NULL, &debugfs_info_fops); + NULL, &debugfs_info_fops); debugfs_create_u32("rqwait_usecs", S_IRUSR | S_IWUSR, - virthba_debugfs_dir, &rsltq_wait_usecs); + virthba_debugfs_dir, &rsltq_wait_usecs); debugfs_create_file("enable_ints", S_IWUSR, - virthba_debugfs_dir, NULL, - &debugfs_enable_ints_fops); - /* Initialize DARWorkQ */ - INIT_WORK(&DARWorkQ, doDiskAddRemove); - spin_lock_init(&DARWorkQLock); + virthba_debugfs_dir, NULL, + &debugfs_enable_ints_fops); + /* Initialize dar_work_queue */ + INIT_WORK(&dar_work_queue, do_disk_add_remove); + spin_lock_init(&dar_work_queue_lock); /* clear out array */ for (i = 0; i < VIRTHBASOPENMAX; i++) - VirtHbasOpen[i].virthbainfo = NULL; + virthbas_open[i].virthbainfo = NULL; /* Initialize the serverdown workqueue */ virthba_serverdown_workqueue = create_singlethread_workqueue("virthba_serverdown"); @@ -1746,7 +1752,6 @@ virthba_mod_exit(void) debugfs_remove_recursive(virthba_debugfs_dir); LOGINF("Leaving virthba_mod_exit\n"); - } /* specify function to be run at module insertion time */ diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 39b828dce503..8fdfd6f3605f 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -104,8 +104,6 @@ static ssize_t virtpci_driver_attr_store(struct kobject *kobj, const char *buf, size_t count); static int virtpci_bus_match(struct device *dev, struct device_driver *drv); static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env); -static int virtpci_device_suspend(struct device *dev, pm_message_t state); -static int virtpci_device_resume(struct device *dev); static int virtpci_device_probe(struct device *dev); static int virtpci_device_remove(struct device *dev); @@ -128,8 +126,6 @@ static struct bus_type virtpci_bus_type = { .name = "uisvirtpci", .match = virtpci_bus_match, .uevent = virtpci_uevent, - .suspend = virtpci_device_suspend, - .resume = virtpci_device_resume, }; static struct device virtpci_rootbus_device = { @@ -279,9 +275,9 @@ static int add_vbus(struct add_vbus_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; } - write_vbus_chp_info(vbus->platform_data /* chanptr */ , + write_vbus_chp_info(vbus->platform_data /* chanptr */, &chipset_driver_info); - write_vbus_bus_info(vbus->platform_data /* chanptr */ , + write_vbus_bus_info(vbus->platform_data /* chanptr */, &bus_driver_info); LOGINF("Added vbus %d; device %s created successfully\n", addparams->bus_no, BUS_ID(vbus)); @@ -466,7 +462,7 @@ static int pause_vhba(struct pause_virt_guestpart *pauseparams) GET_SCSIADAPINFO_FROM_CHANPTR(pauseparams->chanptr); LOGINF("Pausing vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2); - i = virtpci_device_serverdown(NULL /*no parent bus */ , VIRTHBA_TYPE, + i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTHBA_TYPE, &scsi.wwnn, NULL); if (i) LOGINF("Paused vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, @@ -487,7 +483,7 @@ static int pause_vnic(struct pause_virt_guestpart *pauseparams) LOGINF("Pausing vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]); - i = virtpci_device_serverdown(NULL /*no parent bus */ , VIRTNIC_TYPE, + i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTNIC_TYPE, NULL, net.mac_addr); if (i) { LOGINF(" Paused vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -508,7 +504,7 @@ static int resume_vhba(struct resume_virt_guestpart *resumeparams) GET_SCSIADAPINFO_FROM_CHANPTR(resumeparams->chanptr); LOGINF("Resuming vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2); - i = virtpci_device_serverup(NULL /*no parent bus */ , VIRTHBA_TYPE, + i = virtpci_device_serverup(NULL /*no parent bus */, VIRTHBA_TYPE, &scsi.wwnn, NULL); if (i) LOGINF("Resumed vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, @@ -530,7 +526,7 @@ resume_vnic(struct resume_virt_guestpart *resumeparams) LOGINF("Resuming vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]); - i = virtpci_device_serverup(NULL /*no parent bus */ , VIRTNIC_TYPE, + i = virtpci_device_serverup(NULL /*no parent bus */, VIRTNIC_TYPE, NULL, net.mac_addr); if (i) { LOGINF(" Resumed vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -551,7 +547,7 @@ static int delete_vhba(struct del_virt_guestpart *delparams) GET_SCSIADAPINFO_FROM_CHANPTR(delparams->chanptr); LOGINF("Deleting vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2); - i = virtpci_device_del(NULL /*no parent bus */ , VIRTHBA_TYPE, + i = virtpci_device_del(NULL /*no parent bus */, VIRTHBA_TYPE, &scsi.wwnn, NULL); if (i) { LOGINF("Deleted vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, @@ -574,7 +570,7 @@ static int delete_vnic(struct del_virt_guestpart *delparams) LOGINF("Deleting vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]); - i = virtpci_device_del(NULL /*no parent bus */ , VIRTNIC_TYPE, NULL, + i = virtpci_device_del(NULL /*no parent bus */, VIRTNIC_TYPE, NULL, net.mac_addr); if (i) { LOGINF("Deleted vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -757,18 +753,6 @@ static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } -static int virtpci_device_suspend(struct device *dev, pm_message_t state) -{ - DBGINF("In virtpci_device_suspend -NYI ****\n"); - return 0; -} - -static int virtpci_device_resume(struct device *dev) -{ - DBGINF("In virtpci_device_resume -NYI ****\n"); - return 0; -} - /* For a child device just created on a client bus, fill in * information about the driver that is controlling this device into * the appropriate slot within the vbus channel of the bus @@ -1338,18 +1322,13 @@ static ssize_t virtpci_driver_attr_show(struct kobject *kobj, ssize_t ret = 0; struct driver_private *dprivate = to_driver(kobj); - struct device_driver *driver; + struct device_driver *driver = dprivate->driver; - if (dprivate != NULL) - driver = dprivate->driver; - else - driver = NULL; + DBGINF("In virtpci_driver_attr_show driver->name:%s\n", driver->name); + + if (dattr->show) + ret = dattr->show(driver, buf); - DBGINF("In virtpci_driver_attr_show driver->name:%s\n", driver->name); - if (driver) { - if (dattr->show) - ret = dattr->show(driver, buf); - } return ret; } @@ -1361,19 +1340,13 @@ static ssize_t virtpci_driver_attr_store(struct kobject *kobj, ssize_t ret = 0; struct driver_private *dprivate = to_driver(kobj); - struct device_driver *driver; - - if (dprivate != NULL) - driver = dprivate->driver; - else - driver = NULL; + struct device_driver *driver = dprivate->driver; DBGINF("In virtpci_driver_attr_store driver->name:%s\n", driver->name); - if (driver) { - if (dattr->store) - ret = dattr->store(driver, buf, count); - } + if (dattr->store) + ret = dattr->store(driver, buf, count); + return ret; } diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index 5061edff959a..63f1b9760373 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -29,49 +29,48 @@ #define BOOL int #endif -/* VISORCHANNEL is an opaque structure to users. - * Fields are declared only in the implementation .c files. - */ -typedef struct VISORCHANNEL_Tag VISORCHANNEL; - /* Note that for visorchannel_create() and visorchannel_create_overlapped(), - * <channelBytes> and <guid> arguments may be 0 if we are a channel CLIENT. + * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT. * In this case, the values can simply be read from the channel header. */ -VISORCHANNEL *visorchannel_create(HOSTADDRESS physaddr, - ulong channelBytes, uuid_le guid); -VISORCHANNEL *visorchannel_create_overlapped(ulong channelBytes, - VISORCHANNEL *parent, ulong off, - uuid_le guid); -VISORCHANNEL *visorchannel_create_with_lock(HOSTADDRESS physaddr, - ulong channelBytes, uuid_le guid); -VISORCHANNEL *visorchannel_create_overlapped_with_lock(ulong channelBytes, - VISORCHANNEL *parent, - ulong off, uuid_le guid); -void visorchannel_destroy(VISORCHANNEL *channel); -int visorchannel_read(VISORCHANNEL *channel, ulong offset, +struct visorchannel *visorchannel_create(HOSTADDRESS physaddr, + ulong channel_bytes, uuid_le guid); +struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes, + struct visorchannel *parent, + ulong off, uuid_le guid); +struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr, + ulong channel_bytes, + uuid_le guid); +struct visorchannel *visorchannel_create_overlapped_with_lock( + ulong channel_bytes, + struct visorchannel *parent, + ulong off, uuid_le guid); +void visorchannel_destroy(struct visorchannel *channel); +int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes); -int visorchannel_write(VISORCHANNEL *channel, ulong offset, +int visorchannel_write(struct visorchannel *channel, ulong offset, void *local, ulong nbytes); -int visorchannel_clear(VISORCHANNEL *channel, ulong offset, +int visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, ulong nbytes); -BOOL visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg); -BOOL visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg); -int visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue); -int visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue); - -HOSTADDRESS visorchannel_get_physaddr(VISORCHANNEL *channel); -ulong visorchannel_get_nbytes(VISORCHANNEL *channel); -char *visorchannel_id(VISORCHANNEL *channel, char *s); -char *visorchannel_zoneid(VISORCHANNEL *channel, char *s); -u64 visorchannel_get_clientpartition(VISORCHANNEL *channel); -uuid_le visorchannel_get_uuid(VISORCHANNEL *channel); -struct memregion *visorchannel_get_memregion(VISORCHANNEL *channel); +BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue, + void *msg); +BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue, + void *msg); +int visorchannel_signalqueue_slots_avail(struct visorchannel *channel, + u32 queue); +int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue); +HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel); +ulong visorchannel_get_nbytes(struct visorchannel *channel); +char *visorchannel_id(struct visorchannel *channel, char *s); +char *visorchannel_zoneid(struct visorchannel *channel, char *s); +u64 visorchannel_get_clientpartition(struct visorchannel *channel); +uuid_le visorchannel_get_uuid(struct visorchannel *channel); +struct memregion *visorchannel_get_memregion(struct visorchannel *channel); char *visorchannel_uuid_id(uuid_le *guid, char *s); -void visorchannel_debug(VISORCHANNEL *channel, int nQueues, +void visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off); -void visorchannel_dump_section(VISORCHANNEL *chan, char *s, +void visorchannel_dump_section(struct visorchannel *chan, char *s, int off, int len, struct seq_file *seq); -void __iomem *visorchannel_get_header(VISORCHANNEL *channel); +void __iomem *visorchannel_get_header(struct visorchannel *channel); #endif diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 36559d5fa673..0188ef866fdd 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -28,14 +28,15 @@ #define MYDRVNAME "visorchannel" -struct VISORCHANNEL_Tag { +struct visorchannel { struct memregion *memregion; /* from visor_memregion_create() */ struct channel_header chan_hdr; uuid_le guid; ulong size; - BOOL needs_lock; - spinlock_t insert_lock; - spinlock_t remove_lock; + BOOL needs_lock; /* channel creator knows if more than one + * thread will be inserting or removing */ + spinlock_t insert_lock; /* protect head writes in chan_hdr */ + spinlock_t remove_lock; /* protect tail writes in chan_hdr */ struct { struct signal_queue_header req_queue; @@ -45,18 +46,18 @@ struct VISORCHANNEL_Tag { } safe_uis_queue; }; -/* Creates the VISORCHANNEL abstraction for a data area in memory, but does - * NOT modify this data area. +/* Creates the struct visorchannel abstraction for a data area in memory, + * but does NOT modify this data area. */ -static VISORCHANNEL * -visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, - VISORCHANNEL *parent, ulong off, uuid_le guid, +static struct visorchannel * +visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, + struct visorchannel *parent, ulong off, uuid_le guid, BOOL needs_lock) { - VISORCHANNEL *p = NULL; + struct visorchannel *p = NULL; void *rc = NULL; - p = kmalloc(sizeof(VISORCHANNEL), GFP_KERNEL|__GFP_NORETRY); + p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY); if (p == NULL) { ERRDRV("allocation failed: (status=0)\n"); rc = NULL; @@ -87,18 +88,18 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, rc = NULL; goto cleanup; } - if (channelBytes == 0) + if (channel_bytes == 0) /* we had better be a CLIENT of this channel */ - channelBytes = (ulong)p->chan_hdr.size; + channel_bytes = (ulong)p->chan_hdr.size; if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) /* we had better be a CLIENT of this channel */ guid = p->chan_hdr.chtype; - if (visor_memregion_resize(p->memregion, channelBytes) < 0) { + if (visor_memregion_resize(p->memregion, channel_bytes) < 0) { ERRDRV("visor_memregion_resize failed: (status=0)\n"); rc = NULL; goto cleanup; } - p->size = channelBytes; + p->size = channel_bytes; p->guid = guid; rc = p; @@ -113,44 +114,45 @@ cleanup: return rc; } -VISORCHANNEL * -visorchannel_create(HOSTADDRESS physaddr, ulong channelBytes, uuid_le guid) +struct visorchannel * +visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { - return visorchannel_create_guts(physaddr, channelBytes, NULL, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid, FALSE); } EXPORT_SYMBOL_GPL(visorchannel_create); -VISORCHANNEL * -visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channelBytes, +struct visorchannel * +visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { - return visorchannel_create_guts(physaddr, channelBytes, NULL, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid, TRUE); } EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); -VISORCHANNEL * -visorchannel_create_overlapped(ulong channelBytes, - VISORCHANNEL *parent, ulong off, uuid_le guid) +struct visorchannel * +visorchannel_create_overlapped(ulong channel_bytes, + struct visorchannel *parent, ulong off, + uuid_le guid) { - return visorchannel_create_guts(0, channelBytes, parent, off, guid, + return visorchannel_create_guts(0, channel_bytes, parent, off, guid, FALSE); } EXPORT_SYMBOL_GPL(visorchannel_create_overlapped); -VISORCHANNEL * -visorchannel_create_overlapped_with_lock(ulong channelBytes, - VISORCHANNEL *parent, ulong off, +struct visorchannel * +visorchannel_create_overlapped_with_lock(ulong channel_bytes, + struct visorchannel *parent, ulong off, uuid_le guid) { - return visorchannel_create_guts(0, channelBytes, parent, off, guid, + return visorchannel_create_guts(0, channel_bytes, parent, off, guid, TRUE); } EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock); void -visorchannel_destroy(VISORCHANNEL *channel) +visorchannel_destroy(struct visorchannel *channel) { if (channel == NULL) return; @@ -163,14 +165,14 @@ visorchannel_destroy(VISORCHANNEL *channel) EXPORT_SYMBOL_GPL(visorchannel_destroy); HOSTADDRESS -visorchannel_get_physaddr(VISORCHANNEL *channel) +visorchannel_get_physaddr(struct visorchannel *channel) { return visor_memregion_get_physaddr(channel->memregion); } EXPORT_SYMBOL_GPL(visorchannel_get_physaddr); ulong -visorchannel_get_nbytes(VISORCHANNEL *channel) +visorchannel_get_nbytes(struct visorchannel *channel) { return channel->size; } @@ -185,42 +187,42 @@ visorchannel_uuid_id(uuid_le *guid, char *s) EXPORT_SYMBOL_GPL(visorchannel_uuid_id); char * -visorchannel_id(VISORCHANNEL *channel, char *s) +visorchannel_id(struct visorchannel *channel, char *s) { return visorchannel_uuid_id(&channel->guid, s); } EXPORT_SYMBOL_GPL(visorchannel_id); char * -visorchannel_zoneid(VISORCHANNEL *channel, char *s) +visorchannel_zoneid(struct visorchannel *channel, char *s) { return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s); } EXPORT_SYMBOL_GPL(visorchannel_zoneid); HOSTADDRESS -visorchannel_get_clientpartition(VISORCHANNEL *channel) +visorchannel_get_clientpartition(struct visorchannel *channel) { return channel->chan_hdr.partition_handle; } EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition); uuid_le -visorchannel_get_uuid(VISORCHANNEL *channel) +visorchannel_get_uuid(struct visorchannel *channel) { return channel->guid; } EXPORT_SYMBOL_GPL(visorchannel_get_uuid); struct memregion * -visorchannel_get_memregion(VISORCHANNEL *channel) +visorchannel_get_memregion(struct visorchannel *channel) { return channel->memregion; } EXPORT_SYMBOL_GPL(visorchannel_get_memregion); int -visorchannel_read(VISORCHANNEL *channel, ulong offset, +visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { int rc = visor_memregion_read(channel->memregion, offset, @@ -235,7 +237,7 @@ visorchannel_read(VISORCHANNEL *channel, ulong offset, EXPORT_SYMBOL_GPL(visorchannel_read); int -visorchannel_write(VISORCHANNEL *channel, ulong offset, +visorchannel_write(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { if (offset == 0 && nbytes >= sizeof(struct channel_header)) @@ -246,7 +248,8 @@ visorchannel_write(VISORCHANNEL *channel, ulong offset, EXPORT_SYMBOL_GPL(visorchannel_write); int -visorchannel_clear(VISORCHANNEL *channel, ulong offset, u8 ch, ulong nbytes) +visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, + ulong nbytes) { int rc = -1; int bufsize = 65536; @@ -285,7 +288,7 @@ cleanup: EXPORT_SYMBOL_GPL(visorchannel_clear); void __iomem * -visorchannel_get_header(VISORCHANNEL *channel) +visorchannel_get_header(struct visorchannel *channel) { return (void __iomem *)&channel->chan_hdr; } @@ -316,7 +319,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); sizeof((sig_hdr)->FIELD)) >= 0) static BOOL -sig_read_header(VISORCHANNEL *channel, u32 queue, +sig_read_header(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr) { BOOL rc = FALSE; @@ -344,7 +347,7 @@ cleanup: } static BOOL -sig_do_data(VISORCHANNEL *channel, u32 queue, +sig_do_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data, BOOL is_write) { @@ -373,14 +376,14 @@ cleanup: } static inline BOOL -sig_read_data(VISORCHANNEL *channel, u32 queue, +sig_read_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE); } static inline BOOL -sig_write_data(VISORCHANNEL *channel, u32 queue, +sig_write_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE); @@ -408,27 +411,21 @@ safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, return 1; } /* end safe_sig_queue_validate */ -BOOL -visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) +static BOOL +signalremove_inner(struct visorchannel *channel, u32 queue, void *msg) { - BOOL rc = FALSE; struct signal_queue_header sig_hdr; - if (channel->needs_lock) - spin_lock(&channel->remove_lock); - if (!sig_read_header(channel, queue, &sig_hdr)) { - rc = FALSE; - goto cleanup; - } - if (sig_hdr.head == sig_hdr.tail) { - rc = FALSE; /* no signals to remove */ - goto cleanup; + return FALSE; } + if (sig_hdr.head == sig_hdr.tail) + return FALSE; /* no signals to remove */ + sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) { - ERRDRV("sig_read_data failed: (status=%d)\n", rc); - goto cleanup; + ERRDRV("sig_read_data failed\n"); + return FALSE; } sig_hdr.num_received++; @@ -437,53 +434,54 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) */ 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); - goto cleanup; + ERRDRV("visor_memregion_write of Tail failed\n"); + return FALSE; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) { - ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", - rc); - goto cleanup; + ERRDRV("visor_memregion_write of NumSignalsReceived failed\n"); + return FALSE; } - rc = TRUE; -cleanup: - if (channel->needs_lock) + return TRUE; +} + +BOOL +visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg) +{ + BOOL rc; + + if (channel->needs_lock) { + spin_lock(&channel->remove_lock); + rc = signalremove_inner(channel, queue, msg); spin_unlock(&channel->remove_lock); + } else { + rc = signalremove_inner(channel, queue, msg); + } return rc; } EXPORT_SYMBOL_GPL(visorchannel_signalremove); -BOOL -visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) +static BOOL +signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) { - BOOL rc = FALSE; struct signal_queue_header sig_hdr; - if (channel->needs_lock) - spin_lock(&channel->insert_lock); - if (!sig_read_header(channel, queue, &sig_hdr)) { - rc = FALSE; - goto cleanup; + return FALSE; } sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); if (sig_hdr.head == sig_hdr.tail) { sig_hdr.num_overflows++; - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) { - ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", - rc); - goto cleanup; - } - rc = FALSE; - goto cleanup; + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) + ERRDRV("visor_memregion_write of NumOverflows failed\n"); + + return FALSE; } if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) { - ERRDRV("sig_write_data failed: (status=%d)\n", rc); - goto cleanup; + ERRDRV("sig_write_data failed\n"); + return FALSE; } sig_hdr.num_sent++; @@ -492,26 +490,36 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) */ 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); - goto cleanup; + ERRDRV("visor_memregion_write of Head failed\n"); + return FALSE; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) { - ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", - rc); - goto cleanup; + ERRDRV("visor_memregion_write of NumSignalsSent failed\n"); + return FALSE; } - rc = TRUE; -cleanup: - if (channel->needs_lock) + + return TRUE; +} + +BOOL +visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg) +{ + BOOL rc; + + if (channel->needs_lock) { + spin_lock(&channel->insert_lock); + rc = signalinsert_inner(channel, queue, msg); spin_unlock(&channel->insert_lock); + } else { + rc = signalinsert_inner(channel, queue, msg); + } return rc; } EXPORT_SYMBOL_GPL(visorchannel_signalinsert); int -visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) +visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue) { struct signal_queue_header sig_hdr; u32 slots_avail, slots_used; @@ -530,7 +538,7 @@ visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail); int -visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) +visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue) { struct signal_queue_header sig_hdr; @@ -565,7 +573,7 @@ sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq) } void -visorchannel_debug(VISORCHANNEL *channel, int nQueues, +visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off) { HOSTADDRESS addr = 0; @@ -625,7 +633,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, if ((phdr->ch_space_offset == 0) || (errcode < 0)) ; else - for (i = 0; i < nQueues; i++) { + for (i = 0; i < num_queues; i++) { struct signal_queue_header q; errcode = visorchannel_read(channel, @@ -647,7 +655,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, EXPORT_SYMBOL_GPL(visorchannel_debug); void -visorchannel_dump_section(VISORCHANNEL *chan, char *s, +visorchannel_dump_section(struct visorchannel *chan, char *s, int off, int len, struct seq_file *seq) { char *buf, *tbuf, *fmtbuf; diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 373fa36b7119..e51fd4e3fa2d 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -28,85 +28,75 @@ #define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c -static struct cdev Cdev; -static VISORCHANNEL **PControlVm_channel; -static dev_t MajorDev = -1; /**< indicates major num for device */ -static BOOL Registered = FALSE; +static struct cdev file_cdev; +static struct visorchannel **file_controlvm_channel; +static dev_t majordev = -1; /**< indicates major num for device */ +static BOOL registered = FALSE; static int visorchipset_open(struct inode *inode, struct file *file); static int visorchipset_release(struct inode *inode, struct file *file); static int visorchipset_mmap(struct file *file, struct vm_area_struct *vma); -#ifdef HAVE_UNLOCKED_IOCTL long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -#else -int visorchipset_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg); -#endif static const struct file_operations visorchipset_fops = { .owner = THIS_MODULE, .open = visorchipset_open, .read = NULL, .write = NULL, -#ifdef HAVE_UNLOCKED_IOCTL .unlocked_ioctl = visorchipset_ioctl, -#else - .ioctl = visorchipset_ioctl, -#endif .release = visorchipset_release, .mmap = visorchipset_mmap, }; int -visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel) +visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) { - int rc = -1; + int rc = 0; - PControlVm_channel = pControlVm_channel; - MajorDev = majorDev; - cdev_init(&Cdev, &visorchipset_fops); - Cdev.owner = THIS_MODULE; - if (MAJOR(MajorDev) == 0) { + file_controlvm_channel = controlvm_channel; + majordev = major_dev; + cdev_init(&file_cdev, &visorchipset_fops); + file_cdev.owner = THIS_MODULE; + if (MAJOR(majordev) == 0) { /* dynamic major device number registration required */ - if (alloc_chrdev_region(&MajorDev, 0, 1, MYDRVNAME) < 0) { + if (alloc_chrdev_region(&majordev, 0, 1, MYDRVNAME) < 0) { ERRDRV("Unable to allocate+register char device %s", MYDRVNAME); - goto Away; + return -1; } - Registered = TRUE; - INFODRV("New major number %d registered\n", MAJOR(MajorDev)); + registered = TRUE; + INFODRV("New major number %d registered\n", MAJOR(majordev)); } else { /* static major device number registration required */ - if (register_chrdev_region(MajorDev, 1, MYDRVNAME) < 0) { + if (register_chrdev_region(majordev, 1, MYDRVNAME) < 0) { ERRDRV("Unable to register char device %s", MYDRVNAME); - goto Away; + return -1; } - Registered = TRUE; - INFODRV("Static major number %d registered\n", MAJOR(MajorDev)); + registered = TRUE; + INFODRV("Static major number %d registered\n", MAJOR(majordev)); } - if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) { + rc = cdev_add(&file_cdev, MKDEV(MAJOR(majordev), 0), 1); + if (rc < 0) { ERRDRV("failed to create char device: (status=%d)\n", rc); - goto Away; + return -1; } INFODRV("Registered char device for %s (major=%d)", - MYDRVNAME, MAJOR(MajorDev)); - rc = 0; -Away: - return rc; + MYDRVNAME, MAJOR(majordev)); + return 0; } void visorchipset_file_cleanup(void) { - if (Cdev.ops != NULL) - cdev_del(&Cdev); - Cdev.ops = NULL; - if (Registered) { - if (MAJOR(MajorDev) >= 0) { - unregister_chrdev_region(MajorDev, 1); - MajorDev = MKDEV(0, 0); + if (file_cdev.ops != NULL) + cdev_del(&file_cdev); + file_cdev.ops = NULL; + if (registered) { + if (MAJOR(majordev) >= 0) { + unregister_chrdev_region(majordev, 1); + majordev = MKDEV(0, 0); } - Registered = FALSE; + registered = FALSE; } } @@ -114,17 +104,12 @@ static int visorchipset_open(struct inode *inode, struct file *file) { unsigned minor_number = iminor(inode); - int rc = -ENODEV; DEBUGDRV("%s", __func__); if (minor_number != 0) - goto Away; + return -ENODEV; file->private_data = NULL; - rc = 0; -Away: - if (rc < 0) - ERRDRV("%s minor=%d failed", __func__, minor_number); - return rc; + return 0; } static int @@ -137,7 +122,7 @@ visorchipset_release(struct inode *inode, struct file *file) static int visorchipset_mmap(struct file *file, struct vm_area_struct *vma) { - ulong physAddr = 0; + ulong physaddr = 0; ulong offset = vma->vm_pgoff << PAGE_SHIFT; GUEST_PHYSICAL_ADDRESS addr = 0; @@ -150,11 +135,11 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) switch (offset) { case VISORCHIPSET_MMAP_CONTROLCHANOFFSET: vma->vm_flags |= VM_IO; - if (*PControlVm_channel == NULL) { + if (*file_controlvm_channel == NULL) { ERRDRV("%s no controlvm channel yet", __func__); return -ENXIO; } - visorchannel_read(*PControlVm_channel, + visorchannel_read(*file_controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, gp_control_channel), &addr, sizeof(addr)); @@ -162,10 +147,10 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) ERRDRV("%s control channel address is 0", __func__); return -ENXIO; } - physAddr = (ulong) (addr); - DEBUGDRV("mapping physical address = 0x%lx", physAddr); + physaddr = (ulong)addr; + DEBUGDRV("mapping physical address = 0x%lx", physaddr); if (remap_pfn_range(vma, vma->vm_start, - physAddr >> PAGE_SHIFT, + physaddr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, /*pgprot_noncached */ (vma->vm_page_prot))) { @@ -180,16 +165,8 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) return 0; } -#ifdef HAVE_UNLOCKED_IOCTL -long -visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -#else -int -visorchipset_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -#endif +long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int rc = SUCCESS; s64 adjustment; s64 vrtc_offset; @@ -200,28 +177,21 @@ visorchipset_ioctl(struct inode *inode, struct file *file, vrtc_offset = issue_vmcall_query_guest_virtual_time_offset(); if (copy_to_user ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) { - rc = -EFAULT; - goto Away; + return -EFAULT; } DBGINF("insde visorchipset_ioctl, cmd=%d, vrtc_offset=%lld", cmd, vrtc_offset); - break; + return SUCCESS; case VMCALL_UPDATE_PHYSICAL_TIME: if (copy_from_user (&adjustment, (void __user *)arg, sizeof(adjustment))) { - rc = -EFAULT; - goto Away; + return -EFAULT; } DBGINF("insde visorchipset_ioctl, cmd=%d, adjustment=%lld", cmd, adjustment); - rc = issue_vmcall_update_physical_time(adjustment); - break; + return issue_vmcall_update_physical_time(adjustment); default: LOGERR("visorchipset_ioctl received invalid command"); - rc = -EFAULT; - break; + return -EFAULT; } -Away: - DBGINF("exiting %d!", rc); - return rc; } diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h index 21bb906242e1..dc7a19556b3f 100644 --- a/drivers/staging/unisys/visorchipset/file.h +++ b/drivers/staging/unisys/visorchipset/file.h @@ -20,7 +20,8 @@ #include "globals.h" -int visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel); +int visorchipset_file_init(dev_t majorDev, + struct visorchannel **pControlVm_channel); void visorchipset_file_cleanup(void); #endif diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h index 0fe14599f185..a1d35d4bef2e 100644 --- a/drivers/staging/unisys/visorchipset/globals.h +++ b/drivers/staging/unisys/visorchipset/globals.h @@ -15,7 +15,6 @@ * details. */ - #ifndef __VISORCHIPSET_GLOBALS_H__ #define __VISORCHIPSET_GLOBALS_H__ @@ -28,7 +27,6 @@ #define MYDRVNAME "visorchipset" - /* module parameters */ extern int visorchipset_testvnic; diff --git a/drivers/staging/unisys/visorchipset/testing.h b/drivers/staging/unisys/visorchipset/testing.h deleted file mode 100644 index 573aa8b5ba6a..000000000000 --- a/drivers/staging/unisys/visorchipset/testing.h +++ /dev/null @@ -1,43 +0,0 @@ -/* testing.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 __VISORCHIPSET_TESTING_H__ -#define __VISORCHIPSET_TESTING_H__ - -#define VISORCHIPSET_TEST_PROC -#include <linux/uuid.h> -#include "globals.h" -#include "controlvmchannel.h" - -void test_produce_test_message(struct controlvm_message *msg, - int isLocalTestAddr); -BOOL test_consume_test_message(struct controlvm_message *msg); -void test_manufacture_vnic_client_add(void *p); -void test_manufacture_vnic_client_add_phys(HOSTADDRESS addr); -void test_manufacture_preamble_messages(void); -void test_manufacture_device_attach(ulong busNo, ulong devNo); -void test_manufacture_device_add(ulong busNo, ulong devNo, uuid_le dataTypeGuid, - void *pChannel); -void test_manufacture_add_bus(ulong busNo, ulong maxDevices, - uuid_le id, u8 *name, BOOL isServer); -void test_manufacture_device_destroy(ulong busNo, ulong devNo); -void test_manufacture_bus_destroy(ulong busNo); -void test_manufacture_detach_externalPort(ulong switchNo, ulong externalPortNo); -void test_manufacture_detach_internalPort(ulong switchNo, ulong internalPortNo); -void test_cleanup(void); - -#endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 46dad63fa2c8..98f3ba4c13ac 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -158,61 +158,6 @@ findbus(struct list_head *list, u32 bus_no) return NULL; } -/** Attributes for a particular Supervisor switch. - */ -struct visorchipset_switch_info { - u32 switch_no; - struct visorchipset_state state; - uuid_le switch_type_uuid; - u8 *authservice1; - u8 *authservice2; - u8 *authservice3; - u8 *security_context; - u64 reserved; - u32 reserved2; /* control_vm_id */ - struct device dev; - BOOL dev_exists; - struct controlvm_message_header pending_msg_hdr; -}; - -/** Attributes for a particular Supervisor external port, which is connected - * to a specific switch. - */ -struct visorchipset_externalport_info { - u32 switch_no; - u32 external_port_no; - struct visorchipset_state state; - uuid_le network_zone_uuid; - int pd_port; - u8 *ip; - u8 *ip_netmask; - u8 *ip_broadcast; - u8 *ip_network; - u8 *ip_gateway; - u8 *ip_dns; - u64 reserved1; - u32 reserved2; /* control_vm_id */ - struct device dev; - BOOL dev_exists; - struct controlvm_message_header pending_msg_hdr; -}; - -/** Attributes for a particular Supervisor internal port, which is how a - * device connects to a particular switch. - */ -struct visorchipset_internalport_info { - u32 switch_no; - u32 internal_port_no; - struct visorchipset_state state; - u32 bus_no; /* valid only when state.attached == 1 */ - u32 dev_no; /* valid only when state.attached == 1 */ - u64 reserved1; - u32 reserved2; /* CONTROLVM_ID */ - struct controlvm_message_header pending_msg_hdr; - MYPROCOBJECT *proc_object; - -}; - /* These functions will be called from within visorchipset when certain * events happen. (The implementation of these functions is outside of * visorchipset.) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 7e6be32cf7bb..f606ee9e0de9 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -20,7 +20,6 @@ #include "procobjecttree.h" #include "visorchannel.h" #include "periodic_work.h" -#include "testing.h" #include "file.h" #include "parser.h" #include "uniklog.h" @@ -102,7 +101,7 @@ static struct controlvm_message_packet g_DeviceChangeStatePacket; static LIST_HEAD(BusInfoList); static LIST_HEAD(DevInfoList); -static VISORCHANNEL *ControlVm_channel; +static struct visorchannel *ControlVm_channel; typedef struct { u8 __iomem *ptr; /* pointer to base address of payload pool */ @@ -1595,7 +1594,7 @@ parahotplug_next_id(void) static unsigned long parahotplug_next_expiration(void) { - return jiffies + PARAHOTPLUG_TIMEOUT_MS * HZ / 1000; + return jiffies + msecs_to_jiffies(PARAHOTPLUG_TIMEOUT_MS); } /* diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h index 06ba5b7e4254..6cf6eccb3f4a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h +++ b/drivers/staging/unisys/visorchipset/visorchipset_umode.h @@ -26,8 +26,6 @@ #ifndef __VISORCHIPSET_UMODE_H #define __VISORCHIPSET_UMODE_H - - /** The user-mode program can access the control channel buffer directly * via this memory map. */ diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index 1ce7003c3a90..ac7acb7c5b79 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -28,7 +28,7 @@ struct charqueue { int alloc_size; int nslots; - spinlock_t lock; + spinlock_t lock; /* read/write lock for this structure */ int head, tail; unsigned char buf[0]; }; diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index 195772d22c9e..82279ca5fbe1 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c @@ -25,12 +25,12 @@ * need in order to call the callback function that supplies the /proc read * info for that file. */ -typedef struct { +struct proc_dir_entry_context { void (*show_property)(struct seq_file *, void *, int); MYPROCOBJECT *procObject; int propertyIndex; -} PROCDIRENTRYCONTEXT; +}; /** This describes the attributes of a tree rooted at * <procDirRoot>/<name[0]>/<name[1]>/... @@ -86,7 +86,7 @@ struct MYPROCOBJECT_Tag { /** this is a holding area for the context information that is needed * to run the /proc callback function */ - PROCDIRENTRYCONTEXT *procDirPropertyContexts; + struct proc_dir_entry_context *procDirPropertyContexts; }; @@ -254,15 +254,16 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, goto Away; } obj->procDirPropertyContexts = - kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), + kzalloc((type->nProperties + 1) * + sizeof(struct proc_dir_entry_context), GFP_KERNEL | __GFP_NORETRY); if (obj->procDirPropertyContexts == NULL) { ERRDRV("out of memory\n"); goto Away; } - obj->procDirProperties = - kzalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *), - GFP_KERNEL | __GFP_NORETRY); + obj->procDirProperties = kzalloc((type->nProperties + 1) * + sizeof(struct proc_dir_entry *), + GFP_KERNEL | __GFP_NORETRY); if (obj->procDirProperties == NULL) { ERRDRV("out of memory\n"); goto Away; @@ -276,8 +277,8 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, /* only create properties that have names */ obj->procDirProperties[i] = createProcFile(type->propertyNames[i], - obj->procDir, &proc_fops, - &obj->procDirPropertyContexts[i]); + obj->procDir, &proc_fops, + &obj->procDirPropertyContexts[i]); if (obj->procDirProperties[i] == NULL) { rc = NULL; goto Away; @@ -340,7 +341,7 @@ EXPORT_SYMBOL_GPL(visor_proc_DestroyObject); static int seq_show(struct seq_file *seq, void *offset) { - PROCDIRENTRYCONTEXT *ctx = (PROCDIRENTRYCONTEXT *)(seq->private); + struct proc_dir_entry_context *ctx = seq->private; if (ctx == NULL) { ERRDRV("I don't have a freakin' clue..."); |