diff options
Diffstat (limited to 'drivers/staging/unisys/visorchipset/visorchipset_main.c')
-rw-r--r-- | drivers/staging/unisys/visorchipset/visorchipset_main.c | 1485 |
1 files changed, 621 insertions, 864 deletions
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index f606ee9..f2663d2c 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -22,7 +22,6 @@ #include "periodic_work.h" #include "file.h" #include "parser.h" -#include "uniklog.h" #include "uisutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" @@ -49,8 +48,8 @@ * message, we switch back to fast polling mode. */ #define MIN_IDLE_SECONDS 10 -static ulong Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; -static ulong Most_recent_message_jiffies; /* when we got our last +static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; +static ulong most_recent_message_jiffies; /* when we got our last * controlvm message */ static inline char * NONULLSTR(char *s) @@ -66,83 +65,74 @@ static int clientregistered; #define MAX_CHIPSET_EVENTS 2 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 }; -static struct delayed_work Periodic_controlvm_work; -static struct workqueue_struct *Periodic_controlvm_workqueue; -static DEFINE_SEMAPHORE(NotifierLock); +static struct delayed_work periodic_controlvm_work; +static struct workqueue_struct *periodic_controlvm_workqueue; +static DEFINE_SEMAPHORE(notifier_lock); -typedef struct { - struct controlvm_message message; - unsigned int crc; -} MESSAGE_ENVELOPE; - -static struct controlvm_message_header g_DiagMsgHdr; -static struct controlvm_message_header g_ChipSetMsgHdr; -static struct controlvm_message_header g_DelDumpMsgHdr; -static const uuid_le UltraDiagPoolChannelProtocolGuid = +static struct controlvm_message_header g_diag_msg_hdr; +static struct controlvm_message_header g_chipset_msg_hdr; +static struct controlvm_message_header g_del_dump_msg_hdr; +static const uuid_le spar_diag_pool_channel_protocol_uuid = SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; /* 0xffffff is an invalid Bus/Device number */ -static ulong g_diagpoolBusNo = 0xffffff; -static ulong g_diagpoolDevNo = 0xffffff; -static struct controlvm_message_packet g_DeviceChangeStatePacket; +static ulong g_diagpool_bus_no = 0xffffff; +static ulong g_diagpool_dev_no = 0xffffff; +static struct controlvm_message_packet g_devicechangestate_packet; /* Only VNIC and VHBA channels are sent to visorclientbus (aka * "visorhackbus") */ #define FOR_VISORHACKBUS(channel_type_guid) \ (((uuid_le_cmp(channel_type_guid,\ - spar_vnic_channel_protocol_uuid) == 0)\ - || (uuid_le_cmp(channel_type_guid,\ + spar_vnic_channel_protocol_uuid) == 0) ||\ + (uuid_le_cmp(channel_type_guid,\ spar_vhba_channel_protocol_uuid) == 0))) #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid))) #define is_diagpool_channel(channel_type_guid) \ - (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0) + (uuid_le_cmp(channel_type_guid,\ + spar_diag_pool_channel_protocol_uuid) == 0) -static LIST_HEAD(BusInfoList); -static LIST_HEAD(DevInfoList); +static LIST_HEAD(bus_info_list); +static LIST_HEAD(dev_info_list); -static struct visorchannel *ControlVm_channel; +static struct visorchannel *controlvm_channel; -typedef struct { +/* Manages the request payload in the controlvm channel */ +static struct controlvm_payload_info { u8 __iomem *ptr; /* pointer to base address of payload pool */ u64 offset; /* offset from beginning of controlvm * channel to beginning of payload * pool */ u32 bytes; /* number of bytes in payload pool */ -} CONTROLVM_PAYLOAD_INFO; - -/* Manages the request payload in the controlvm channel */ -static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info; +} controlvm_payload_info; -static struct channel_header *Test_Vnic_channel; - -typedef struct { - struct controlvm_message_header Dumpcapture_header; - struct controlvm_message_header Gettextdump_header; - struct controlvm_message_header Dumpcomplete_header; - BOOL Gettextdump_outstanding; +/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / + * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation. + */ +static struct livedump_info { + struct controlvm_message_header dumpcapture_header; + struct controlvm_message_header gettextdump_header; + struct controlvm_message_header dumpcomplete_header; + BOOL gettextdump_outstanding; u32 crc32; ulong length; atomic_t buffers_in_use; ulong destination; -} LIVEDUMP_INFO; -/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / - * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation. - */ -static LIVEDUMP_INFO LiveDump_info; +} livedump_info; /* The following globals are used to handle the scenario where we are unable to * offload the payload from a controlvm message due to memory requirements. In * this scenario, we simply stash the controlvm message, then attempt to * process it again the next time controlvm_periodic_work() runs. */ -static struct controlvm_message ControlVm_Pending_Msg; -static BOOL ControlVm_Pending_Msg_Valid = FALSE; +static struct controlvm_message controlvm_pending_msg; +static BOOL controlvm_pending_msg_valid = FALSE; /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming) * TRANSMIT_FILE PutFile payloads. */ -static struct kmem_cache *Putfile_buffer_list_pool; -static const char Putfile_buffer_list_pool_name[] = +static struct kmem_cache *putfile_buffer_list_pool; +static const char putfile_buffer_list_pool_name[] = "controlvm_putfile_buffer_list_pool"; /* This identifies a data buffer that has been received via a controlvm messages @@ -150,14 +140,14 @@ static const char Putfile_buffer_list_pool_name[] = */ struct putfile_buffer_entry { struct list_head next; /* putfile_buffer_entry list */ - PARSER_CONTEXT *parser_ctx; /* points to buffer containing input data */ + struct parser_context *parser_ctx; /* points to input data buffer */ }; /* List of struct putfile_request *, via next_putfile_request member. * Each entry in this list identifies an outstanding TRANSMIT_FILE * conversation. */ -static LIST_HEAD(Putfile_request_list); +static LIST_HEAD(putfile_request_list); /* This describes a buffer and its current state of transfer (e.g., how many * bytes have already been supplied as putfile data, and how many bytes are @@ -165,7 +155,7 @@ static LIST_HEAD(Putfile_request_list); */ struct putfile_active_buffer { /* a payload from a controlvm message, containing a file data buffer */ - PARSER_CONTEXT *parser_ctx; + struct parser_context *parser_ctx; /* points within data area of parser_ctx to next byte of data */ u8 *pnext; /* # bytes left from <pnext> to the end of this data buffer */ @@ -213,7 +203,7 @@ struct putfile_request { int completion_status; }; -static atomic_t Visorchipset_cache_buffers_in_use = ATOMIC_INIT(0); +static atomic_t visorchipset_cache_buffers_in_use = ATOMIC_INIT(0); struct parahotplug_request { struct list_head list; @@ -222,23 +212,23 @@ struct parahotplug_request { struct controlvm_message msg; }; -static LIST_HEAD(Parahotplug_request_list); -static DEFINE_SPINLOCK(Parahotplug_request_list_lock); /* lock for above */ +static LIST_HEAD(parahotplug_request_list); +static DEFINE_SPINLOCK(parahotplug_request_list_lock); /* lock for above */ static void parahotplug_process_list(void); /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / * CONTROLVM_REPORTEVENT. */ -static struct visorchipset_busdev_notifiers BusDev_Server_Notifiers; -static struct visorchipset_busdev_notifiers BusDev_Client_Notifiers; +static struct visorchipset_busdev_notifiers busdev_server_notifiers; +static struct visorchipset_busdev_notifiers busdev_client_notifiers; -static void bus_create_response(ulong busNo, int response); -static void bus_destroy_response(ulong busNo, int response); -static void device_create_response(ulong busNo, ulong devNo, int response); -static void device_destroy_response(ulong busNo, ulong devNo, int response); -static void device_resume_response(ulong busNo, ulong devNo, int response); +static void bus_create_response(ulong bus_no, int response); +static void bus_destroy_response(ulong bus_no, int response); +static void device_create_response(ulong bus_no, ulong dev_no, int response); +static void device_destroy_response(ulong bus_no, ulong dev_no, int response); +static void device_resume_response(ulong bus_no, ulong dev_no, int response); -static struct visorchipset_busdev_responders BusDev_Responders = { +static struct visorchipset_busdev_responders busdev_responders = { .bus_create = bus_create_response, .bus_destroy = bus_destroy_response, .device_create = device_create_response, @@ -248,49 +238,55 @@ static struct visorchipset_busdev_responders BusDev_Responders = { }; /* info for /dev/visorchipset */ -static dev_t MajorDev = -1; /**< indicates major num for device */ +static dev_t major_dev = -1; /**< indicates major num for device */ /* prototypes for attributes */ static ssize_t toolaction_show(struct device *dev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); static ssize_t toolaction_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); static DEVICE_ATTR_RW(toolaction); static ssize_t boottotool_show(struct device *dev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); static ssize_t boottotool_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, const char *buf, + size_t count); static DEVICE_ATTR_RW(boottotool); static ssize_t error_show(struct device *dev, struct device_attribute *attr, - char *buf); + char *buf); static ssize_t error_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count); + const char *buf, size_t count); static DEVICE_ATTR_RW(error); static ssize_t textid_show(struct device *dev, struct device_attribute *attr, - char *buf); + char *buf); static ssize_t textid_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count); + const char *buf, size_t count); static DEVICE_ATTR_RW(textid); static ssize_t remaining_steps_show(struct device *dev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); static ssize_t remaining_steps_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); static DEVICE_ATTR_RW(remaining_steps); static ssize_t chipsetready_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); static DEVICE_ATTR_WO(chipsetready); static ssize_t devicedisabled_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); static DEVICE_ATTR_WO(devicedisabled); static ssize_t deviceenabled_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); static DEVICE_ATTR_WO(deviceenabled); static struct attribute *visorchipset_install_attrs[] = { @@ -336,47 +332,48 @@ static const struct attribute_group *visorchipset_dev_groups[] = { }; /* /sys/devices/platform/visorchipset */ -static struct platform_device Visorchipset_platform_device = { +static struct platform_device visorchipset_platform_device = { .name = "visorchipset", .id = -1, .dev.groups = visorchipset_dev_groups, }; /* Function prototypes */ -static void controlvm_respond(struct controlvm_message_header *msgHdr, +static void controlvm_respond(struct controlvm_message_header *msg_hdr, int response); static void controlvm_respond_chipset_init( - struct controlvm_message_header *msgHdr, int response, + struct controlvm_message_header *msg_hdr, int response, enum ultra_chipset_feature features); static void controlvm_respond_physdev_changestate( - struct controlvm_message_header *msgHdr, int response, + struct controlvm_message_header *msg_hdr, int response, struct spar_segment_state state); static ssize_t toolaction_show(struct device *dev, struct device_attribute *attr, char *buf) { - u8 toolAction; + u8 tool_action; - visorchannel_read(ControlVm_channel, + visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, - tool_action), &toolAction, sizeof(u8)); - return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction); + tool_action), &tool_action, sizeof(u8)); + return scnprintf(buf, PAGE_SIZE, "%u\n", tool_action); } static ssize_t toolaction_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - u8 toolAction; + u8 tool_action; int ret; - if (kstrtou8(buf, 10, &toolAction) != 0) + if (kstrtou8(buf, 10, &tool_action) != 0) return -EINVAL; - ret = visorchannel_write(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, tool_action), - &toolAction, sizeof(u8)); + ret = visorchannel_write(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + tool_action), + &tool_action, sizeof(u8)); if (ret) return ret; @@ -387,14 +384,14 @@ static ssize_t boottotool_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct efi_spar_indication efiSparIndication; + struct efi_spar_indication efi_spar_indication; - visorchannel_read(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, - efi_spar_ind), &efiSparIndication, - sizeof(struct efi_spar_indication)); + visorchannel_read(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + efi_spar_ind), &efi_spar_indication, + sizeof(struct efi_spar_indication)); return scnprintf(buf, PAGE_SIZE, "%u\n", - efiSparIndication.boot_to_tool); + efi_spar_indication.boot_to_tool); } static ssize_t boottotool_store(struct device *dev, @@ -402,17 +399,16 @@ static ssize_t boottotool_store(struct device *dev, const char *buf, size_t count) { int val, ret; - struct efi_spar_indication efiSparIndication; + struct efi_spar_indication efi_spar_indication; if (kstrtoint(buf, 10, &val) != 0) return -EINVAL; - efiSparIndication.boot_to_tool = val; - ret = visorchannel_write(ControlVm_channel, + efi_spar_indication.boot_to_tool = val; + ret = visorchannel_write(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, - efi_spar_ind), - &(efiSparIndication), - sizeof(struct efi_spar_indication)); + efi_spar_ind), &(efi_spar_indication), + sizeof(struct efi_spar_indication)); if (ret) return ret; @@ -420,18 +416,19 @@ static ssize_t boottotool_store(struct device *dev, } static ssize_t error_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { u32 error; - visorchannel_read(ControlVm_channel, offsetof( - struct spar_controlvm_channel_protocol, installation_error), - &error, sizeof(u32)); + visorchannel_read(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_error), + &error, sizeof(u32)); return scnprintf(buf, PAGE_SIZE, "%i\n", error); } static ssize_t error_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { u32 error; int ret; @@ -439,114 +436,81 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, if (kstrtou32(buf, 10, &error) != 0) return -EINVAL; - ret = visorchannel_write(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, - installation_error), - &error, sizeof(u32)); + ret = visorchannel_write(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_error), + &error, sizeof(u32)); if (ret) return ret; return count; } static ssize_t textid_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { - u32 textId; + u32 text_id; - visorchannel_read(ControlVm_channel, offsetof( - struct spar_controlvm_channel_protocol, installation_text_id), - &textId, sizeof(u32)); - return scnprintf(buf, PAGE_SIZE, "%i\n", textId); + visorchannel_read(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_text_id), + &text_id, sizeof(u32)); + return scnprintf(buf, PAGE_SIZE, "%i\n", text_id); } static ssize_t textid_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { - u32 textId; + u32 text_id; int ret; - if (kstrtou32(buf, 10, &textId) != 0) + if (kstrtou32(buf, 10, &text_id) != 0) return -EINVAL; - ret = visorchannel_write(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, - installation_text_id), - &textId, sizeof(u32)); + ret = visorchannel_write(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_text_id), + &text_id, sizeof(u32)); if (ret) return ret; return count; } - static ssize_t remaining_steps_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { - u16 remainingSteps; + u16 remaining_steps; - visorchannel_read(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, - installation_remaining_steps), - &remainingSteps, - sizeof(u16)); - return scnprintf(buf, PAGE_SIZE, "%hu\n", remainingSteps); + visorchannel_read(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_remaining_steps), + &remaining_steps, sizeof(u16)); + return scnprintf(buf, PAGE_SIZE, "%hu\n", remaining_steps); } static ssize_t remaining_steps_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - u16 remainingSteps; + u16 remaining_steps; int ret; - if (kstrtou16(buf, 10, &remainingSteps) != 0) + if (kstrtou16(buf, 10, &remaining_steps) != 0) return -EINVAL; - ret = visorchannel_write(ControlVm_channel, - offsetof(struct spar_controlvm_channel_protocol, - installation_remaining_steps), - &remainingSteps, sizeof(u16)); + ret = visorchannel_write(controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + installation_remaining_steps), + &remaining_steps, sizeof(u16)); if (ret) return ret; return count; } -#if 0 -static void -testUnicode(void) -{ - wchar_t unicodeString[] = { 'a', 'b', 'c', 0 }; - char s[sizeof(unicodeString) * NLS_MAX_CHARSET_SIZE]; - wchar_t unicode2[99]; - - /* NOTE: Either due to a bug, or feature I don't understand, the - * kernel utf8_mbstowcs() and utf_wcstombs() do NOT copy the - * trailed NUL byte!! REALLY!!!!! Arrrrgggghhhhh - */ - - LOGINF("sizeof(wchar_t) = %d", sizeof(wchar_t)); - LOGINF("utf8_wcstombs=%d", - chrs = utf8_wcstombs(s, unicodeString, sizeof(s))); - if (chrs >= 0) - s[chrs] = '\0'; /* GRRRRRRRR */ - LOGINF("s='%s'", s); - LOGINF("utf8_mbstowcs=%d", chrs = utf8_mbstowcs(unicode2, s, 100)); - if (chrs >= 0) - unicode2[chrs] = 0; /* GRRRRRRRR */ - if (memcmp(unicodeString, unicode2, sizeof(unicodeString)) == 0) - LOGINF("strings match... good"); - else - LOGINF("strings did not match!!"); -} -#endif - static void -busInfo_clear(void *v) +bus_info_clear(void *v) { struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v); - if (p->proc_object) { - visor_proc_DestroyObject(p->proc_object); - p->proc_object = NULL; - } kfree(p->name); p->name = NULL; @@ -558,7 +522,7 @@ busInfo_clear(void *v) } static void -devInfo_clear(void *v) +dev_info_clear(void *v) { struct visorchipset_device_info *p = (struct visorchipset_device_info *)(v); @@ -593,22 +557,22 @@ visorchipset_register_busdev_server( struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info) { - down(&NotifierLock); - if (notifiers == NULL) { - memset(&BusDev_Server_Notifiers, 0, - sizeof(BusDev_Server_Notifiers)); + down(¬ifier_lock); + if (!notifiers) { + memset(&busdev_server_notifiers, 0, + sizeof(busdev_server_notifiers)); serverregistered = 0; /* clear flag */ } else { - BusDev_Server_Notifiers = *notifiers; + busdev_server_notifiers = *notifiers; serverregistered = 1; /* set flag */ } if (responders) - *responders = BusDev_Responders; + *responders = busdev_responders; if (driver_info) bus_device_info_init(driver_info, "chipset", "visorchipset", - VERSION, NULL); + VERSION, NULL); - up(&NotifierLock); + up(¬ifier_lock); } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); @@ -618,21 +582,21 @@ visorchipset_register_busdev_client( struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info) { - down(&NotifierLock); - if (notifiers == NULL) { - memset(&BusDev_Client_Notifiers, 0, - sizeof(BusDev_Client_Notifiers)); + down(¬ifier_lock); + if (!notifiers) { + memset(&busdev_client_notifiers, 0, + sizeof(busdev_client_notifiers)); clientregistered = 0; /* clear flag */ } else { - BusDev_Client_Notifiers = *notifiers; + busdev_client_notifiers = *notifiers; clientregistered = 1; /* set flag */ } if (responders) - *responders = BusDev_Responders; + *responders = busdev_responders; if (driver_info) bus_device_info_init(driver_info, "chipset(bolts)", "visorchipset", VERSION, NULL); - up(&NotifierLock); + up(¬ifier_lock); } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); @@ -642,14 +606,14 @@ cleanup_controlvm_structures(void) struct visorchipset_bus_info *bi, *tmp_bi; struct visorchipset_device_info *di, *tmp_di; - list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) { - busInfo_clear(bi); + list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) { + bus_info_clear(bi); list_del(&bi->entry); kfree(bi); } - list_for_each_entry_safe(di, tmp_di, &DevInfoList, entry) { - devInfo_clear(di); + list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) { + dev_info_clear(di); list_del(&di->entry); kfree(di); } @@ -664,9 +628,8 @@ chipset_init(struct controlvm_message *inmsg) POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (chipset_inited) { - LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done."); rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - goto Away; + goto cleanup; } chipset_inited = 1; POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -681,7 +644,7 @@ chipset_init(struct controlvm_message *inmsg) * features-aware driver. */ features |= ULTRA_CHIPSET_FEATURE_REPLY; -Away: +cleanup: if (rc < 0) cleanup_controlvm_structures(); if (inmsg->hdr.flags.response_expected) @@ -690,10 +653,10 @@ Away: static void controlvm_init_response(struct controlvm_message *msg, - struct controlvm_message_header *msgHdr, int response) + struct controlvm_message_header *msg_hdr, int response) { memset(msg, 0, sizeof(struct controlvm_message)); - memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header)); + memcpy(&msg->hdr, msg_hdr, sizeof(struct controlvm_message_header)); msg->hdr.payload_bytes = 0; msg->hdr.payload_vm_offset = 0; msg->hdr.payload_max_bytes = 0; @@ -704,59 +667,54 @@ controlvm_init_response(struct controlvm_message *msg, } static void -controlvm_respond(struct controlvm_message_header *msgHdr, int response) +controlvm_respond(struct controlvm_message_header *msg_hdr, int response) { struct controlvm_message outmsg; - controlvm_init_response(&outmsg, msgHdr, response); + controlvm_init_response(&outmsg, msg_hdr, response); /* For DiagPool channel DEVICE_CHANGESTATE, we need to send * back the deviceChangeState structure in the packet. */ - if (msgHdr->id == CONTROLVM_DEVICE_CHANGESTATE - && g_DeviceChangeStatePacket.device_change_state.bus_no == - g_diagpoolBusNo - && g_DeviceChangeStatePacket.device_change_state.dev_no == - g_diagpoolDevNo) - outmsg.cmd = g_DeviceChangeStatePacket; - if (outmsg.hdr.flags.test_message == 1) { - LOGINF("%s controlvm_msg=0x%x response=%d for test message", - __func__, outmsg.hdr.id, response); + if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE && + g_devicechangestate_packet.device_change_state.bus_no == + g_diagpool_bus_no && + g_devicechangestate_packet.device_change_state.dev_no == + g_diagpool_dev_no) + outmsg.cmd = g_devicechangestate_packet; + if (outmsg.hdr.flags.test_message == 1) return; - } - if (!visorchannel_signalinsert(ControlVm_channel, + + if (!visorchannel_signalinsert(controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { - LOGERR("signalinsert failed!"); return; } } static void -controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr, +controlvm_respond_chipset_init(struct controlvm_message_header *msg_hdr, int response, enum ultra_chipset_feature features) { struct controlvm_message outmsg; - controlvm_init_response(&outmsg, msgHdr, response); + controlvm_init_response(&outmsg, msg_hdr, response); outmsg.cmd.init_chipset.features = features; - if (!visorchannel_signalinsert(ControlVm_channel, + if (!visorchannel_signalinsert(controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { - LOGERR("signalinsert failed!"); return; } } static void controlvm_respond_physdev_changestate( - struct controlvm_message_header *msgHdr, int response, + struct controlvm_message_header *msg_hdr, int response, struct spar_segment_state state) { struct controlvm_message outmsg; - controlvm_init_response(&outmsg, msgHdr, response); + controlvm_init_response(&outmsg, msg_hdr, response); outmsg.cmd.device_change_state.state = state; outmsg.cmd.device_change_state.flags.phys_device = 1; - if (!visorchannel_signalinsert(ControlVm_channel, + if (!visorchannel_signalinsert(controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { - LOGERR("signalinsert failed!"); return; } } @@ -765,56 +723,50 @@ void visorchipset_save_message(struct controlvm_message *msg, enum crash_obj_type type) { - u32 localSavedCrashMsgOffset; - u16 localSavedCrashMsgCount; + u32 crash_msg_offset; + u16 crash_msg_count; /* get saved message count */ - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, saved_crash_message_count), - &localSavedCrashMsgCount, sizeof(u16)) < 0) { - LOGERR("failed to get Saved Message Count"); + &crash_msg_count, sizeof(u16)) < 0) { POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } - if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) { - LOGERR("Saved Message Count incorrect %d", - localSavedCrashMsgCount); + if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) { POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC, - localSavedCrashMsgCount, + crash_msg_count, POSTCODE_SEVERITY_ERR); return; } /* get saved crash message offset */ - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, saved_crash_message_offset), - &localSavedCrashMsgOffset, sizeof(u32)) < 0) { - LOGERR("failed to get Saved Message Offset"); + &crash_msg_offset, sizeof(u32)) < 0) { POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } if (type == CRASH_BUS) { - if (visorchannel_write(ControlVm_channel, - localSavedCrashMsgOffset, + if (visorchannel_write(controlvm_channel, + crash_msg_offset, msg, sizeof(struct controlvm_message)) < 0) { - LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!"); POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } } else { - if (visorchannel_write(ControlVm_channel, - localSavedCrashMsgOffset + + if (visorchannel_write(controlvm_channel, + crash_msg_offset + sizeof(struct controlvm_message), msg, sizeof(struct controlvm_message)) < 0) { - LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!"); POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; @@ -824,134 +776,118 @@ visorchipset_save_message(struct controlvm_message *msg, EXPORT_SYMBOL_GPL(visorchipset_save_message); static void -bus_responder(enum controlvm_id cmdId, ulong busNo, int response) +bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response) { struct visorchipset_bus_info *p = NULL; BOOL need_clear = FALSE; - p = findbus(&BusInfoList, busNo); - if (!p) { - LOGERR("internal error busNo=%lu", busNo); + p = findbus(&bus_info_list, bus_no); + if (!p) return; - } + if (response < 0) { - if ((cmdId == CONTROLVM_BUS_CREATE) && + if ((cmd_id == CONTROLVM_BUS_CREATE) && (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE))) /* undo the row we just created... */ - delbusdevices(&DevInfoList, busNo); + delbusdevices(&dev_info_list, bus_no); } else { - if (cmdId == CONTROLVM_BUS_CREATE) + if (cmd_id == CONTROLVM_BUS_CREATE) p->state.created = 1; - if (cmdId == CONTROLVM_BUS_DESTROY) + if (cmd_id == CONTROLVM_BUS_DESTROY) need_clear = TRUE; } - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { - LOGERR("bus_responder no pending msg"); + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) return; /* no controlvm response needed */ - } - if (p->pending_msg_hdr.id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); + if (p->pending_msg_hdr.id != (u32)cmd_id) return; - } controlvm_respond(&p->pending_msg_hdr, response); p->pending_msg_hdr.id = CONTROLVM_INVALID; if (need_clear) { - busInfo_clear(p); - delbusdevices(&DevInfoList, busNo); + bus_info_clear(p); + delbusdevices(&dev_info_list, bus_no); } } static void -device_changestate_responder(enum controlvm_id cmdId, - ulong busNo, ulong devNo, int response, - struct spar_segment_state responseState) +device_changestate_responder(enum controlvm_id cmd_id, + ulong bus_no, ulong dev_no, int response, + struct spar_segment_state response_state) { struct visorchipset_device_info *p = NULL; struct controlvm_message outmsg; - p = finddevice(&DevInfoList, busNo, devNo); - if (!p) { - LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); + p = finddevice(&dev_info_list, bus_no, dev_no); + if (!p) return; - } - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { - LOGERR("device_responder no pending msg"); + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) return; /* no controlvm response needed */ - } - if (p->pending_msg_hdr.id != cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); + if (p->pending_msg_hdr.id != cmd_id) return; - } controlvm_init_response(&outmsg, &p->pending_msg_hdr, response); - outmsg.cmd.device_change_state.bus_no = busNo; - outmsg.cmd.device_change_state.dev_no = devNo; - outmsg.cmd.device_change_state.state = responseState; + outmsg.cmd.device_change_state.bus_no = bus_no; + outmsg.cmd.device_change_state.dev_no = dev_no; + outmsg.cmd.device_change_state.state = response_state; - if (!visorchannel_signalinsert(ControlVm_channel, - CONTROLVM_QUEUE_REQUEST, &outmsg)) { - LOGERR("signalinsert failed!"); + if (!visorchannel_signalinsert(controlvm_channel, + CONTROLVM_QUEUE_REQUEST, &outmsg)) return; - } p->pending_msg_hdr.id = CONTROLVM_INVALID; } static void -device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, +device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no, int response) { struct visorchipset_device_info *p = NULL; BOOL need_clear = FALSE; - p = finddevice(&DevInfoList, busNo, devNo); - if (!p) { - LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); + p = finddevice(&dev_info_list, bus_no, dev_no); + if (!p) return; - } if (response >= 0) { - if (cmdId == CONTROLVM_DEVICE_CREATE) + if (cmd_id == CONTROLVM_DEVICE_CREATE) p->state.created = 1; - if (cmdId == CONTROLVM_DEVICE_DESTROY) + if (cmd_id == CONTROLVM_DEVICE_DESTROY) need_clear = TRUE; } - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { - LOGERR("device_responder no pending msg"); + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) return; /* no controlvm response needed */ - } - if (p->pending_msg_hdr.id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); + + if (p->pending_msg_hdr.id != (u32)cmd_id) return; - } + controlvm_respond(&p->pending_msg_hdr, response); p->pending_msg_hdr.id = CONTROLVM_INVALID; if (need_clear) - devInfo_clear(p); + dev_info_clear(p); } static void -bus_epilog(u32 busNo, - u32 cmd, struct controlvm_message_header *msgHdr, - int response, BOOL needResponse) +bus_epilog(u32 bus_no, + u32 cmd, struct controlvm_message_header *msg_hdr, + int response, BOOL need_response) { BOOL notified = FALSE; - struct visorchipset_bus_info *pBusInfo = findbus(&BusInfoList, busNo); + struct visorchipset_bus_info *bus_info = findbus(&bus_info_list, + bus_no); - if (!pBusInfo) { - LOGERR("HUH? bad busNo=%d", busNo); + if (!bus_info) return; - } - if (needResponse) { - memcpy(&pBusInfo->pending_msg_hdr, msgHdr, + + if (need_response) { + memcpy(&bus_info->pending_msg_hdr, msg_hdr, sizeof(struct controlvm_message_header)); - } else - pBusInfo->pending_msg_hdr.id = CONTROLVM_INVALID; + } else { + bus_info->pending_msg_hdr.id = CONTROLVM_INVALID; + } - down(&NotifierLock); + down(¬ifier_lock); if (response == CONTROLVM_RESP_SUCCESS) { switch (cmd) { case CONTROLVM_BUS_CREATE: @@ -965,24 +901,24 @@ bus_epilog(u32 busNo, * either server or client devices * - BusDev_Client can handle ONLY client * devices */ - if (BusDev_Server_Notifiers.bus_create) { - (*BusDev_Server_Notifiers.bus_create) (busNo); + if (busdev_server_notifiers.bus_create) { + (*busdev_server_notifiers.bus_create) (bus_no); notified = TRUE; } - if ((!pBusInfo->flags.server) /*client */ && - BusDev_Client_Notifiers.bus_create) { - (*BusDev_Client_Notifiers.bus_create) (busNo); + if ((!bus_info->flags.server) /*client */ && + busdev_client_notifiers.bus_create) { + (*busdev_client_notifiers.bus_create) (bus_no); notified = TRUE; } break; case CONTROLVM_BUS_DESTROY: - if (BusDev_Server_Notifiers.bus_destroy) { - (*BusDev_Server_Notifiers.bus_destroy) (busNo); + if (busdev_server_notifiers.bus_destroy) { + (*busdev_server_notifiers.bus_destroy) (bus_no); notified = TRUE; } - if ((!pBusInfo->flags.server) /*client */ && - BusDev_Client_Notifiers.bus_destroy) { - (*BusDev_Client_Notifiers.bus_destroy) (busNo); + if ((!bus_info->flags.server) /*client */ && + busdev_client_notifiers.bus_destroy) { + (*busdev_client_notifiers.bus_destroy) (bus_no); notified = TRUE; } break; @@ -995,45 +931,45 @@ bus_epilog(u32 busNo, */ ; else - bus_responder(cmd, busNo, response); - up(&NotifierLock); + bus_responder(cmd, bus_no, response); + up(¬ifier_lock); } static void -device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, - struct controlvm_message_header *msgHdr, int response, - BOOL needResponse, BOOL for_visorbus) +device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, + struct controlvm_message_header *msg_hdr, int response, + BOOL need_response, BOOL for_visorbus) { struct visorchipset_busdev_notifiers *notifiers = NULL; BOOL notified = FALSE; - struct visorchipset_device_info *pDevInfo = - finddevice(&DevInfoList, busNo, devNo); + struct visorchipset_device_info *dev_info = + finddevice(&dev_info_list, bus_no, dev_no); char *envp[] = { "SPARSP_DIAGPOOL_PAUSED_STATE = 1", NULL }; - if (!pDevInfo) { - LOGERR("HUH? bad busNo=%d, devNo=%d", busNo, devNo); + if (!dev_info) return; - } + if (for_visorbus) - notifiers = &BusDev_Server_Notifiers; + notifiers = &busdev_server_notifiers; else - notifiers = &BusDev_Client_Notifiers; - if (needResponse) { - memcpy(&pDevInfo->pending_msg_hdr, msgHdr, + notifiers = &busdev_client_notifiers; + if (need_response) { + memcpy(&dev_info->pending_msg_hdr, msg_hdr, sizeof(struct controlvm_message_header)); - } else - pDevInfo->pending_msg_hdr.id = CONTROLVM_INVALID; + } else { + dev_info->pending_msg_hdr.id = CONTROLVM_INVALID; + } - down(&NotifierLock); + down(¬ifier_lock); if (response >= 0) { switch (cmd) { case CONTROLVM_DEVICE_CREATE: if (notifiers->device_create) { - (*notifiers->device_create) (busNo, devNo); + (*notifiers->device_create) (bus_no, dev_no); notified = TRUE; } break; @@ -1043,8 +979,8 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, state.operating == segment_state_running.operating) { if (notifiers->device_resume) { - (*notifiers->device_resume) (busNo, - devNo); + (*notifiers->device_resume) (bus_no, + dev_no); notified = TRUE; } } @@ -1056,8 +992,8 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, * where server is lost */ if (notifiers->device_pause) { - (*notifiers->device_pause) (busNo, - devNo); + (*notifiers->device_pause) (bus_no, + dev_no); notified = TRUE; } } else if (state.alive == segment_state_paused.alive && @@ -1066,22 +1002,20 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, /* this is lite pause where channel is * still valid just 'pause' of it */ - if (busNo == g_diagpoolBusNo - && devNo == g_diagpoolDevNo) { - LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)", - busNo, devNo); + if (bus_no == g_diagpool_bus_no && + dev_no == g_diagpool_dev_no) { /* this will trigger the * diag_shutdown.sh script in * the visorchipset hotplug */ kobject_uevent_env - (&Visorchipset_platform_device.dev. + (&visorchipset_platform_device.dev. kobj, KOBJ_ONLINE, envp); } } break; case CONTROLVM_DEVICE_DESTROY: if (notifiers->device_destroy) { - (*notifiers->device_destroy) (busNo, devNo); + (*notifiers->device_destroy) (bus_no, dev_no); notified = TRUE; } break; @@ -1094,62 +1028,57 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, */ ; else - device_responder(cmd, busNo, devNo, response); - up(&NotifierLock); + device_responder(cmd, bus_no, dev_no, response); + up(¬ifier_lock); } static void bus_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->create_bus.bus_no; + ulong bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; - struct visorchipset_bus_info *pBusInfo = NULL; - + struct visorchipset_bus_info *bus_info = NULL; - pBusInfo = findbus(&BusInfoList, busNo); - if (pBusInfo && (pBusInfo->state.created == 1)) { - LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu already exists", - busNo); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, + bus_info = findbus(&bus_info_list, bus_no); + if (bus_info && (bus_info->state.created == 1)) { + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - goto Away; + goto cleanup; } - pBusInfo = kzalloc(sizeof(struct visorchipset_bus_info), GFP_KERNEL); - if (pBusInfo == NULL) { - LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed", - busNo); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, + bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL); + if (!bus_info) { + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; - goto Away; + goto cleanup; } - INIT_LIST_HEAD(&pBusInfo->entry); - pBusInfo->bus_no = busNo; - pBusInfo->dev_no = cmd->create_bus.dev_count; + INIT_LIST_HEAD(&bus_info->entry); + bus_info->bus_no = bus_no; + bus_info->dev_no = cmd->create_bus.dev_count; - POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); + POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST; + bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; else - pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; + bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; - pBusInfo->flags.server = inmsg->hdr.flags.server; - pBusInfo->chan_info.channel_addr = cmd->create_bus.channel_addr; - pBusInfo->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes; - pBusInfo->chan_info.channel_type_uuid = + bus_info->flags.server = inmsg->hdr.flags.server; + bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr; + bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes; + bus_info->chan_info.channel_type_uuid = cmd->create_bus.bus_data_type_uuid; - pBusInfo->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; + bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; - list_add(&pBusInfo->entry, &BusInfoList); + list_add(&bus_info->entry, &bus_info_list); - POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); + POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); -Away: - bus_epilog(busNo, CONTROLVM_BUS_CREATE, &inmsg->hdr, +cleanup: + bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1157,76 +1086,58 @@ static void bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->destroy_bus.bus_no; - struct visorchipset_bus_info *pBusInfo; + ulong bus_no = cmd->destroy_bus.bus_no; + struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - pBusInfo = findbus(&BusInfoList, busNo); - if (!pBusInfo) { - LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo); + bus_info = findbus(&bus_info_list, bus_no); + if (!bus_info) rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - goto Away; - } - if (pBusInfo->state.created == 0) { - LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed", - busNo); + else if (bus_info->state.created == 0) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - goto Away; - } -Away: - bus_epilog(busNo, CONTROLVM_BUS_DESTROY, &inmsg->hdr, + bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } static void -bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx) +bus_configure(struct controlvm_message *inmsg, + struct parser_context *parser_ctx) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->configure_bus.bus_no; - struct visorchipset_bus_info *pBusInfo = NULL; + ulong bus_no = cmd->configure_bus.bus_no; + struct visorchipset_bus_info *bus_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; char s[99]; - busNo = cmd->configure_bus.bus_no; - POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); + bus_no = cmd->configure_bus.bus_no; + POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no, + POSTCODE_SEVERITY_INFO); - pBusInfo = findbus(&BusInfoList, busNo); - if (!pBusInfo) { - LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid", - busNo); - POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, + bus_info = findbus(&bus_info_list, bus_no); + if (!bus_info) { + POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - goto Away; - } - if (pBusInfo->state.created == 0) { - LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet", - busNo); - POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, + } else if (bus_info->state.created == 0) { + POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - goto Away; - } - /* TBD - add this check to other commands also... */ - if (pBusInfo->pending_msg_hdr.id != CONTROLVM_INVALID) { - LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding", - busNo, (uint) pBusInfo->pending_msg_hdr.id); - POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, + } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) { + POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; - goto Away; - } - - pBusInfo->partition_handle = cmd->configure_bus.guest_handle; - pBusInfo->partition_uuid = parser_id_get(parser_ctx); - parser_param_start(parser_ctx, PARSERSTRING_NAME); - pBusInfo->name = parser_string_get(parser_ctx); + } else { + bus_info->partition_handle = cmd->configure_bus.guest_handle; + bus_info->partition_uuid = parser_id_get(parser_ctx); + parser_param_start(parser_ctx, PARSERSTRING_NAME); + bus_info->name = parser_string_get(parser_ctx); - visorchannel_uuid_id(&pBusInfo->partition_uuid, s); - POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); -Away: - bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, + visorchannel_uuid_id(&bus_info->partition_uuid, s); + POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no, + POSTCODE_SEVERITY_INFO); + } + bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1234,191 +1145,158 @@ static void my_device_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->create_device.bus_no; - ulong devNo = cmd->create_device.dev_no; - struct visorchipset_device_info *pDevInfo = NULL; - struct visorchipset_bus_info *pBusInfo = NULL; + ulong bus_no = cmd->create_device.bus_no; + ulong dev_no = cmd->create_device.dev_no; + struct visorchipset_device_info *dev_info = NULL; + struct visorchipset_bus_info *bus_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; - pDevInfo = finddevice(&DevInfoList, busNo, devNo); - if (pDevInfo && (pDevInfo->state.created == 1)) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu already exists", - busNo, devNo); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + dev_info = finddevice(&dev_info_list, bus_no, dev_no); + if (dev_info && (dev_info->state.created == 1)) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - goto Away; + goto cleanup; } - pBusInfo = findbus(&BusInfoList, busNo); - if (!pBusInfo) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range", - busNo); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + bus_info = findbus(&bus_info_list, bus_no); + if (!bus_info) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - goto Away; + goto cleanup; } - if (pBusInfo->state.created == 0) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet", - busNo); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + if (bus_info->state.created == 0) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - goto Away; + goto cleanup; } - pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL); - if (pDevInfo == NULL) { - LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", - busNo, devNo); - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, + dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); + if (!dev_info) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; - goto Away; + goto cleanup; } - INIT_LIST_HEAD(&pDevInfo->entry); - pDevInfo->bus_no = busNo; - pDevInfo->dev_no = devNo; - pDevInfo->dev_inst_uuid = cmd->create_device.dev_inst_uuid; - POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, + INIT_LIST_HEAD(&dev_info->entry); + dev_info->bus_no = bus_no; + dev_info->dev_no = dev_no; + dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid; + POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST; + dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; else - pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; - pDevInfo->chan_info.channel_addr = cmd->create_device.channel_addr; - pDevInfo->chan_info.n_channel_bytes = cmd->create_device.channel_bytes; - pDevInfo->chan_info.channel_type_uuid = + dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; + dev_info->chan_info.channel_addr = cmd->create_device.channel_addr; + dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes; + dev_info->chan_info.channel_type_uuid = cmd->create_device.data_type_uuid; - pDevInfo->chan_info.intr = cmd->create_device.intr; - list_add(&pDevInfo->entry, &DevInfoList); - POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, + dev_info->chan_info.intr = cmd->create_device.intr; + list_add(&dev_info->entry, &dev_info_list); + POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); -Away: +cleanup: /* get the bus and devNo for DiagPool channel */ - if (pDevInfo && - is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) { - g_diagpoolBusNo = busNo; - g_diagpoolDevNo = devNo; - LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", - g_diagpoolBusNo, g_diagpoolDevNo); - } - device_epilog(busNo, devNo, segment_state_running, + if (dev_info && + is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) { + g_diagpool_bus_no = bus_no; + g_diagpool_dev_no = dev_no; + } + device_epilog(bus_no, dev_no, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(pDevInfo->chan_info.channel_type_uuid)); + FOR_VISORBUS(dev_info->chan_info.channel_type_uuid)); } static void my_device_changestate(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->device_change_state.bus_no; - ulong devNo = cmd->device_change_state.dev_no; + ulong bus_no = cmd->device_change_state.bus_no; + ulong dev_no = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; - struct visorchipset_device_info *pDevInfo = NULL; + struct visorchipset_device_info *dev_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; - pDevInfo = finddevice(&DevInfoList, busNo, devNo); - if (!pDevInfo) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (doesn't exist)", - busNo, devNo); - POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, + dev_info = finddevice(&dev_info_list, bus_no, dev_no); + if (!dev_info) { + POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; - goto Away; - } - if (pDevInfo->state.created == 0) { - LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)", - busNo, devNo); - POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, + } else if (dev_info->state.created == 0) { + POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; } -Away: - if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) - device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE, - &inmsg->hdr, rc, + if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) + device_epilog(bus_no, dev_no, state, + CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS( - pDevInfo->chan_info.channel_type_uuid)); + dev_info->chan_info.channel_type_uuid)); } static void my_device_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->destroy_device.bus_no; - ulong devNo = cmd->destroy_device.dev_no; - struct visorchipset_device_info *pDevInfo = NULL; + ulong bus_no = cmd->destroy_device.bus_no; + ulong dev_no = cmd->destroy_device.dev_no; + struct visorchipset_device_info *dev_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; - pDevInfo = finddevice(&DevInfoList, busNo, devNo); - if (!pDevInfo) { - LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid", - busNo, devNo); + dev_info = finddevice(&dev_info_list, bus_no, dev_no); + if (!dev_info) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; - goto Away; - } - if (pDevInfo->state.created == 0) { - LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed", - busNo, devNo); + else if (dev_info->state.created == 0) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - } -Away: - if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) - device_epilog(busNo, devNo, segment_state_running, + if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) + device_epilog(bus_no, dev_no, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS( - pDevInfo->chan_info.channel_type_uuid)); + dev_info->chan_info.channel_type_uuid)); } /* When provided with the physical address of the controlvm channel * (phys_addr), the offset to the payload area we need to manage * (offset), and the size of this payload area (bytes), fills in the - * CONTROLVM_PAYLOAD_INFO struct. Returns TRUE for success or FALSE + * controlvm_payload_info struct. Returns TRUE for success or FALSE * for failure. */ static int initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes, - CONTROLVM_PAYLOAD_INFO *info) + struct controlvm_payload_info *info) { u8 __iomem *payload = NULL; int rc = CONTROLVM_RESP_SUCCESS; - if (info == NULL) { - LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d", - __FILE__, __LINE__); + if (!info) { rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; - goto Away; + goto cleanup; } - memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); + memset(info, 0, sizeof(struct controlvm_payload_info)); if ((offset == 0) || (bytes == 0)) { - LOGERR("CONTROLVM_PAYLOAD_INIT Failed: request_payload_offset=%llu request_payload_bytes=%llu!", - (u64) offset, (u64) bytes); rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; - goto Away; + goto cleanup; } payload = ioremap_cache(phys_addr + offset, bytes); - if (payload == NULL) { - LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed", - (u64) offset, (u64) bytes); + if (!payload) { rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED; - goto Away; + goto cleanup; } info->offset = offset; info->bytes = bytes; info->ptr = payload; - LOGINF("offset=%llu, bytes=%lu, ptr=%p", - (u64) (info->offset), (ulong) (info->bytes), info->ptr); -Away: +cleanup: if (rc < 0) { - if (payload != NULL) { + if (payload) { iounmap(payload); payload = NULL; } @@ -1427,43 +1305,41 @@ Away: } static void -destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO *info) +destroy_controlvm_payload_info(struct controlvm_payload_info *info) { - if (info->ptr != NULL) { + if (info->ptr) { iounmap(info->ptr); info->ptr = NULL; } - memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); + memset(info, 0, sizeof(struct controlvm_payload_info)); } static void initialize_controlvm_payload(void) { - HOSTADDRESS phys_addr = visorchannel_get_physaddr(ControlVm_channel); - u64 payloadOffset = 0; - u32 payloadBytes = 0; + HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel); + u64 payload_offset = 0; + u32 payload_bytes = 0; - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, request_payload_offset), - &payloadOffset, sizeof(payloadOffset)) < 0) { - LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); + &payload_offset, sizeof(payload_offset)) < 0) { POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, request_payload_bytes), - &payloadBytes, sizeof(payloadBytes)) < 0) { - LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); + &payload_bytes, sizeof(payload_bytes)) < 0) { POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } initialize_controlvm_payload_info(phys_addr, - payloadOffset, payloadBytes, - &ControlVm_payload_info); + payload_offset, payload_bytes, + &controlvm_payload_info); } /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset. @@ -1472,7 +1348,7 @@ initialize_controlvm_payload(void) int visorchipset_chipset_ready(void) { - kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_ONLINE); + kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE); return CONTROLVM_RESP_SUCCESS; } EXPORT_SYMBOL_GPL(visorchipset_chipset_ready); @@ -1484,7 +1360,7 @@ visorchipset_chipset_selftest(void) char *envp[] = { env_selftest, NULL }; sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); - kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, + kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, envp); return CONTROLVM_RESP_SUCCESS; } @@ -1496,49 +1372,48 @@ EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest); int visorchipset_chipset_notready(void) { - kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE); + kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE); return CONTROLVM_RESP_SUCCESS; } EXPORT_SYMBOL_GPL(visorchipset_chipset_notready); static void -chipset_ready(struct controlvm_message_header *msgHdr) +chipset_ready(struct controlvm_message_header *msg_hdr) { int rc = visorchipset_chipset_ready(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->flags.response_expected && !visorchipset_holdchipsetready) - controlvm_respond(msgHdr, rc); - if (msgHdr->flags.response_expected && visorchipset_holdchipsetready) { + if (msg_hdr->flags.response_expected && !visorchipset_holdchipsetready) + controlvm_respond(msg_hdr, rc); + if (msg_hdr->flags.response_expected && visorchipset_holdchipsetready) { /* Send CHIPSET_READY response when all modules have been loaded * and disks mounted for the partition */ - g_ChipSetMsgHdr = *msgHdr; - LOGINF("Holding CHIPSET_READY response"); + g_chipset_msg_hdr = *msg_hdr; } } static void -chipset_selftest(struct controlvm_message_header *msgHdr) +chipset_selftest(struct controlvm_message_header *msg_hdr) { int rc = visorchipset_chipset_selftest(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->flags.response_expected) - controlvm_respond(msgHdr, rc); + if (msg_hdr->flags.response_expected) + controlvm_respond(msg_hdr, rc); } static void -chipset_notready(struct controlvm_message_header *msgHdr) +chipset_notready(struct controlvm_message_header *msg_hdr) { int rc = visorchipset_chipset_notready(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->flags.response_expected) - controlvm_respond(msgHdr, rc); + if (msg_hdr->flags.response_expected) + controlvm_respond(msg_hdr, rc); } /* This is your "one-stop" shop for grabbing the next message from the @@ -1547,14 +1422,11 @@ chipset_notready(struct controlvm_message_header *msgHdr) static BOOL read_controlvm_event(struct controlvm_message *msg) { - if (visorchannel_signalremove(ControlVm_channel, + if (visorchannel_signalremove(controlvm_channel, CONTROLVM_QUEUE_EVENT, msg)) { /* got a message */ - if (msg->hdr.flags.test_message == 1) { - LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", - msg->hdr.id); + if (msg->hdr.flags.test_message == 1) return FALSE; - } return TRUE; } return FALSE; @@ -1604,10 +1476,10 @@ parahotplug_next_expiration(void) static struct parahotplug_request * parahotplug_request_create(struct controlvm_message *msg) { - struct parahotplug_request *req = - kmalloc(sizeof(struct parahotplug_request), - GFP_KERNEL|__GFP_NORETRY); - if (req == NULL) + struct parahotplug_request *req; + + req = kmalloc(sizeof(*req), GFP_KERNEL | __GFP_NORETRY); + if (!req) return NULL; req->id = parahotplug_next_id(); @@ -1652,13 +1524,7 @@ parahotplug_request_kickoff(struct parahotplug_request *req) sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d", cmd->device_change_state.dev_no & 0x7); - LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n", - cmd->device_change_state.state.active, - cmd->device_change_state.bus_no, - cmd->device_change_state.dev_no >> 3, - cmd->device_change_state.dev_no & 7, req->id); - - kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, + kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, envp); } @@ -1672,23 +1538,25 @@ parahotplug_process_list(void) struct list_head *pos = NULL; struct list_head *tmp = NULL; - spin_lock(&Parahotplug_request_list_lock); + spin_lock(¶hotplug_request_list_lock); - list_for_each_safe(pos, tmp, &Parahotplug_request_list) { + list_for_each_safe(pos, tmp, ¶hotplug_request_list) { struct parahotplug_request *req = list_entry(pos, struct parahotplug_request, list); - if (time_after_eq(jiffies, req->expiration)) { - list_del(pos); - if (req->msg.hdr.flags.response_expected) - controlvm_respond_physdev_changestate( - &req->msg.hdr, - CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT, - req->msg.cmd.device_change_state.state); - parahotplug_request_destroy(req); - } + + if (!time_after_eq(jiffies, req->expiration)) + continue; + + list_del(pos); + if (req->msg.hdr.flags.response_expected) + controlvm_respond_physdev_changestate( + &req->msg.hdr, + CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT, + req->msg.cmd.device_change_state.state); + parahotplug_request_destroy(req); } - spin_unlock(&Parahotplug_request_list_lock); + spin_unlock(¶hotplug_request_list_lock); } /* @@ -1702,10 +1570,10 @@ parahotplug_request_complete(int id, u16 active) struct list_head *pos = NULL; struct list_head *tmp = NULL; - spin_lock(&Parahotplug_request_list_lock); + spin_lock(¶hotplug_request_list_lock); /* Look for a request matching "id". */ - list_for_each_safe(pos, tmp, &Parahotplug_request_list) { + list_for_each_safe(pos, tmp, ¶hotplug_request_list) { struct parahotplug_request *req = list_entry(pos, struct parahotplug_request, list); if (req->id == id) { @@ -1713,7 +1581,7 @@ parahotplug_request_complete(int id, u16 active) * respond. */ list_del(pos); - spin_unlock(&Parahotplug_request_list_lock); + spin_unlock(¶hotplug_request_list_lock); req->msg.cmd.device_change_state.state.active = active; if (req->msg.hdr.flags.response_expected) controlvm_respond_physdev_changestate( @@ -1724,7 +1592,7 @@ parahotplug_request_complete(int id, u16 active) } } - spin_unlock(&Parahotplug_request_list_lock); + spin_unlock(¶hotplug_request_list_lock); return -1; } @@ -1738,10 +1606,8 @@ parahotplug_process_message(struct controlvm_message *inmsg) req = parahotplug_request_create(inmsg); - if (req == NULL) { - LOGERR("parahotplug_process_message: couldn't allocate request"); + if (!req) return; - } if (inmsg->cmd.device_change_state.state.active) { /* For enable messages, just respond with success @@ -1755,8 +1621,8 @@ parahotplug_process_message(struct controlvm_message *inmsg) */ parahotplug_request_kickoff(req); controlvm_respond_physdev_changestate(&inmsg->hdr, - CONTROLVM_RESP_SUCCESS, inmsg->cmd. - device_change_state.state); + CONTROLVM_RESP_SUCCESS, + inmsg->cmd.device_change_state.state); parahotplug_request_destroy(req); } else { /* For disable messages, add the request to the @@ -1764,9 +1630,9 @@ parahotplug_process_message(struct controlvm_message *inmsg) * won't get responded to until the script has * indicated it's done. */ - spin_lock(&Parahotplug_request_list_lock); - list_add_tail(&(req->list), &Parahotplug_request_list); - spin_unlock(&Parahotplug_request_list_lock); + spin_lock(¶hotplug_request_list_lock); + list_add_tail(&req->list, ¶hotplug_request_list); + spin_unlock(¶hotplug_request_list_lock); parahotplug_request_kickoff(req); } @@ -1787,135 +1653,94 @@ static BOOL handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) { struct controlvm_message_packet *cmd = &inmsg.cmd; - u64 parametersAddr = 0; - u32 parametersBytes = 0; - PARSER_CONTEXT *parser_ctx = NULL; - BOOL isLocalAddr = FALSE; + u64 parm_addr = 0; + u32 parm_bytes = 0; + struct parser_context *parser_ctx = NULL; + bool local_addr = false; struct controlvm_message ackmsg; /* create parsing context if necessary */ - isLocalAddr = (inmsg.hdr.flags.test_message == 1); - if (channel_addr == 0) { - LOGERR("HUH? channel_addr is 0!"); + local_addr = (inmsg.hdr.flags.test_message == 1); + if (channel_addr == 0) return TRUE; - } - parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset; - parametersBytes = inmsg.hdr.payload_bytes; + parm_addr = channel_addr + inmsg.hdr.payload_vm_offset; + parm_bytes = inmsg.hdr.payload_bytes; /* Parameter and channel addresses within test messages actually lie * within our OS-controlled memory. We need to know that, because it * makes a difference in how we compute the virtual address. */ - if (parametersAddr != 0 && parametersBytes != 0) { + if (parm_addr != 0 && parm_bytes != 0) { BOOL retry = FALSE; parser_ctx = - parser_init_byteStream(parametersAddr, parametersBytes, - isLocalAddr, &retry); - if (!parser_ctx) { - if (retry) { - LOGWRN("throttling to copy payload"); - return FALSE; - } - LOGWRN("parsing failed"); - LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.id); - LOGWRN("parametersAddr=0x%llx", (u64) parametersAddr); - LOGWRN("parametersBytes=%lu", (ulong) parametersBytes); - LOGWRN("isLocalAddr=%d", isLocalAddr); - } + parser_init_byte_stream(parm_addr, parm_bytes, + local_addr, &retry); + if (!parser_ctx && retry) + return FALSE; } - if (!isLocalAddr) { + if (!local_addr) { controlvm_init_response(&ackmsg, &inmsg.hdr, CONTROLVM_RESP_SUCCESS); - if ((ControlVm_channel) - && - (!visorchannel_signalinsert - (ControlVm_channel, CONTROLVM_QUEUE_ACK, &ackmsg))) - LOGWRN("failed to send ACK failed"); + if (controlvm_channel) + visorchannel_signalinsert(controlvm_channel, + CONTROLVM_QUEUE_ACK, + &ackmsg); } switch (inmsg.hdr.id) { case CONTROLVM_CHIPSET_INIT: - LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)", - (ulong) inmsg.cmd.init_chipset.bus_count, - (ulong) inmsg.cmd.init_chipset.switch_count); chipset_init(&inmsg); break; case CONTROLVM_BUS_CREATE: - LOGINF("BUS_CREATE(%lu,#devs=%lu)", - (ulong) cmd->create_bus.bus_no, - (ulong) cmd->create_bus.dev_count); bus_create(&inmsg); break; case CONTROLVM_BUS_DESTROY: - LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroy_bus.bus_no); bus_destroy(&inmsg); break; case CONTROLVM_BUS_CONFIGURE: - LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configure_bus.bus_no); bus_configure(&inmsg, parser_ctx); break; case CONTROLVM_DEVICE_CREATE: - LOGINF("DEVICE_CREATE(%lu,%lu)", - (ulong) cmd->create_device.bus_no, - (ulong) cmd->create_device.dev_no); my_device_create(&inmsg); break; case CONTROLVM_DEVICE_CHANGESTATE: if (cmd->device_change_state.flags.phys_device) { - LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)", - (ulong) cmd->device_change_state.bus_no, - (ulong) cmd->device_change_state.dev_no, - (ulong) cmd->device_change_state.state.active); parahotplug_process_message(&inmsg); } else { - LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)", - (ulong) cmd->device_change_state.bus_no, - (ulong) cmd->device_change_state.dev_no, - (ulong) cmd->device_change_state.state.alive); /* save the hdr and cmd structures for later use */ /* when sending back the response to Command */ my_device_changestate(&inmsg); - g_DiagMsgHdr = inmsg.hdr; - g_DeviceChangeStatePacket = inmsg.cmd; + g_diag_msg_hdr = inmsg.hdr; + g_devicechangestate_packet = inmsg.cmd; break; } break; case CONTROLVM_DEVICE_DESTROY: - LOGINF("DEVICE_DESTROY(%lu,%lu)", - (ulong) cmd->destroy_device.bus_no, - (ulong) cmd->destroy_device.dev_no); my_device_destroy(&inmsg); break; case CONTROLVM_DEVICE_CONFIGURE: - LOGINF("DEVICE_CONFIGURE(%lu,%lu)", - (ulong) cmd->configure_device.bus_no, - (ulong) cmd->configure_device.dev_no); /* no op for now, just send a respond that we passed */ if (inmsg.hdr.flags.response_expected) controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); break; case CONTROLVM_CHIPSET_READY: - LOGINF("CHIPSET_READY"); chipset_ready(&inmsg.hdr); break; case CONTROLVM_CHIPSET_SELFTEST: - LOGINF("CHIPSET_SELFTEST"); chipset_selftest(&inmsg.hdr); break; case CONTROLVM_CHIPSET_STOP: - LOGINF("CHIPSET_STOP"); chipset_notready(&inmsg.hdr); break; default: - LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.id); if (inmsg.hdr.flags.response_expected) controlvm_respond(&inmsg.hdr, - -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN); + -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN); break; } - if (parser_ctx != NULL) { + if (parser_ctx) { parser_done(parser_ctx); parser_ctx = NULL; } @@ -1927,12 +1752,9 @@ static HOSTADDRESS controlvm_get_channel_address(void) u64 addr = 0; u32 size = 0; - if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size))) { - ERRDRV("%s - vmcall to determine controlvm channel addr failed", - __func__); + if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size))) return 0; - } - INFODRV("controlvm addr=%Lx", addr); + return addr; } @@ -1940,69 +1762,63 @@ static void controlvm_periodic_work(struct work_struct *work) { struct controlvm_message inmsg; - BOOL gotACommand = FALSE; + BOOL got_command = FALSE; BOOL handle_command_failed = FALSE; - static u64 Poll_Count; + static u64 poll_count; /* make sure visorbus server is registered for controlvm callbacks */ if (visorchipset_serverregwait && !serverregistered) - goto Away; + goto cleanup; /* make sure visorclientbus server is regsitered for controlvm * callbacks */ if (visorchipset_clientregwait && !clientregistered) - goto Away; + goto cleanup; - Poll_Count++; - if (Poll_Count >= 250) + poll_count++; + if (poll_count >= 250) ; /* keep going */ else - goto Away; + goto cleanup; /* Check events to determine if response to CHIPSET_READY * should be sent */ - if (visorchipset_holdchipsetready - && (g_ChipSetMsgHdr.id != CONTROLVM_INVALID)) { + if (visorchipset_holdchipsetready && + (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) { if (check_chipset_events() == 1) { - LOGINF("Sending CHIPSET_READY response"); - controlvm_respond(&g_ChipSetMsgHdr, 0); + controlvm_respond(&g_chipset_msg_hdr, 0); clear_chipset_events(); - memset(&g_ChipSetMsgHdr, 0, + memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); } } - while (visorchannel_signalremove(ControlVm_channel, + while (visorchannel_signalremove(controlvm_channel, CONTROLVM_QUEUE_RESPONSE, - &inmsg)) { - if (inmsg.hdr.payload_max_bytes != 0) { - LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.", - (ulong) inmsg.hdr.payload_max_bytes, - (ulong) inmsg.hdr.payload_vm_offset, - inmsg.hdr.id); - } - } - if (!gotACommand) { - if (ControlVm_Pending_Msg_Valid) { + &inmsg)) + ; + if (!got_command) { + if (controlvm_pending_msg_valid) { /* we throttled processing of a prior * msg, so try to process it again * rather than reading a new one */ - inmsg = ControlVm_Pending_Msg; - ControlVm_Pending_Msg_Valid = FALSE; - gotACommand = TRUE; - } else - gotACommand = read_controlvm_event(&inmsg); + inmsg = controlvm_pending_msg; + controlvm_pending_msg_valid = FALSE; + got_command = true; + } else { + got_command = read_controlvm_event(&inmsg); + } } handle_command_failed = FALSE; - while (gotACommand && (!handle_command_failed)) { - Most_recent_message_jiffies = jiffies; + while (got_command && (!handle_command_failed)) { + most_recent_message_jiffies = jiffies; if (handle_command(inmsg, visorchannel_get_physaddr - (ControlVm_channel))) - gotACommand = read_controlvm_event(&inmsg); + (controlvm_channel))) + got_command = read_controlvm_event(&inmsg); else { /* this is a scenario where throttling * is required, but probably NOT an @@ -2011,56 +1827,51 @@ controlvm_periodic_work(struct work_struct *work) * reprocess it on our next loop */ handle_command_failed = TRUE; - ControlVm_Pending_Msg = inmsg; - ControlVm_Pending_Msg_Valid = TRUE; + controlvm_pending_msg = inmsg; + controlvm_pending_msg_valid = TRUE; } } /* parahotplug_worker */ parahotplug_process_list(); -Away: +cleanup: if (time_after(jiffies, - Most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) { + most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) { /* it's been longer than MIN_IDLE_SECONDS since we * processed our last controlvm message; slow down the * polling */ - if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW) { - LOGINF("switched to slow controlvm polling"); - Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; - } + if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW) + poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; } else { - if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST) { - Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - LOGINF("switched to fast controlvm polling"); - } + if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST) + poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; } - queue_delayed_work(Periodic_controlvm_workqueue, - &Periodic_controlvm_work, Poll_jiffies); + queue_delayed_work(periodic_controlvm_workqueue, + &periodic_controlvm_work, poll_jiffies); } static void setup_crash_devices_work_queue(struct work_struct *work) { - - struct controlvm_message localCrashCreateBusMsg; - struct controlvm_message localCrashCreateDevMsg; + struct controlvm_message local_crash_bus_msg; + struct controlvm_message local_crash_dev_msg; struct controlvm_message msg; - u32 localSavedCrashMsgOffset; - u16 localSavedCrashMsgCount; + u32 local_crash_msg_offset; + u16 local_crash_msg_count; /* make sure visorbus server is registered for controlvm callbacks */ if (visorchipset_serverregwait && !serverregistered) - goto Away; + goto cleanup; /* make sure visorclientbus server is regsitered for controlvm * callbacks */ if (visorchipset_clientregwait && !clientregistered) - goto Away; + goto cleanup; POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO); @@ -2072,118 +1883,108 @@ setup_crash_devices_work_queue(struct work_struct *work) chipset_init(&msg); /* get saved message count */ - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, saved_crash_message_count), - &localSavedCrashMsgCount, sizeof(u16)) < 0) { - LOGERR("failed to get Saved Message Count"); + &local_crash_msg_count, sizeof(u16)) < 0) { POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } - if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) { - LOGERR("Saved Message Count incorrect %d", - localSavedCrashMsgCount); + if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC, - localSavedCrashMsgCount, + local_crash_msg_count, POSTCODE_SEVERITY_ERR); return; } /* get saved crash message offset */ - if (visorchannel_read(ControlVm_channel, + if (visorchannel_read(controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, saved_crash_message_offset), - &localSavedCrashMsgOffset, sizeof(u32)) < 0) { - LOGERR("failed to get Saved Message Offset"); + &local_crash_msg_offset, sizeof(u32)) < 0) { POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } /* read create device message for storage bus offset */ - if (visorchannel_read(ControlVm_channel, - localSavedCrashMsgOffset, - &localCrashCreateBusMsg, + if (visorchannel_read(controlvm_channel, + local_crash_msg_offset, + &local_crash_bus_msg, sizeof(struct controlvm_message)) < 0) { - LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!"); POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC, POSTCODE_SEVERITY_ERR); return; } /* read create device message for storage device */ - if (visorchannel_read(ControlVm_channel, - localSavedCrashMsgOffset + + if (visorchannel_read(controlvm_channel, + local_crash_msg_offset + sizeof(struct controlvm_message), - &localCrashCreateDevMsg, + &local_crash_dev_msg, sizeof(struct controlvm_message)) < 0) { - LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!"); POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC, POSTCODE_SEVERITY_ERR); return; } /* reuse IOVM create bus message */ - if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0) - bus_create(&localCrashCreateBusMsg); - else { - LOGERR("CrashCreateBusMsg is null, no dump will be taken"); + if (local_crash_bus_msg.cmd.create_bus.channel_addr != 0) { + bus_create(&local_crash_bus_msg); + } else { POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } /* reuse create device message for storage device */ - if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0) - my_device_create(&localCrashCreateDevMsg); - else { - LOGERR("CrashCreateDevMsg is null, no dump will be taken"); + if (local_crash_dev_msg.cmd.create_device.channel_addr != 0) { + my_device_create(&local_crash_dev_msg); + } else { POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC, POSTCODE_SEVERITY_ERR); return; } - LOGINF("Bus and device ready for dumping"); POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO); return; -Away: +cleanup: - Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; + poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; - queue_delayed_work(Periodic_controlvm_workqueue, - &Periodic_controlvm_work, Poll_jiffies); + queue_delayed_work(periodic_controlvm_workqueue, + &periodic_controlvm_work, poll_jiffies); } static void -bus_create_response(ulong busNo, int response) +bus_create_response(ulong bus_no, int response) { - bus_responder(CONTROLVM_BUS_CREATE, busNo, response); + bus_responder(CONTROLVM_BUS_CREATE, bus_no, response); } static void -bus_destroy_response(ulong busNo, int response) +bus_destroy_response(ulong bus_no, int response) { - bus_responder(CONTROLVM_BUS_DESTROY, busNo, response); + bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response); } static void -device_create_response(ulong busNo, ulong devNo, int response) +device_create_response(ulong bus_no, ulong dev_no, int response) { - device_responder(CONTROLVM_DEVICE_CREATE, busNo, devNo, response); + device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response); } static void -device_destroy_response(ulong busNo, ulong devNo, int response) +device_destroy_response(ulong bus_no, ulong dev_no, int response) { - device_responder(CONTROLVM_DEVICE_DESTROY, busNo, devNo, response); + device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response); } void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response) { - device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, bus_no, dev_no, response, segment_state_standby); @@ -2191,22 +1992,20 @@ visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response) EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); static void -device_resume_response(ulong busNo, ulong devNo, int response) +device_resume_response(ulong bus_no, ulong dev_no, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - busNo, devNo, response, + bus_no, dev_no, response, segment_state_running); } BOOL visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) { - void *p = findbus(&BusInfoList, bus_no); + void *p = findbus(&bus_info_list, bus_no); - if (!p) { - LOGERR("(%lu) failed", bus_no); + if (!p) return FALSE; - } memcpy(bus_info, p, sizeof(struct visorchipset_bus_info)); return TRUE; } @@ -2215,12 +2014,10 @@ EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); BOOL visorchipset_set_bus_context(ulong bus_no, void *context) { - struct visorchipset_bus_info *p = findbus(&BusInfoList, bus_no); + struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no); - if (!p) { - LOGERR("(%lu) failed", bus_no); + if (!p) return FALSE; - } p->bus_driver_context = context; return TRUE; } @@ -2230,12 +2027,10 @@ BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info) { - void *p = finddevice(&DevInfoList, bus_no, dev_no); + void *p = finddevice(&dev_info_list, bus_no, dev_no); - if (!p) { - LOGERR("(%lu,%lu) failed", bus_no, dev_no); + if (!p) return FALSE; - } memcpy(dev_info, p, sizeof(struct visorchipset_device_info)); return TRUE; } @@ -2245,12 +2040,10 @@ BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context) { struct visorchipset_device_info *p = - finddevice(&DevInfoList, bus_no, dev_no); + finddevice(&dev_info_list, bus_no, dev_no); - if (!p) { - LOGERR("(%lu,%lu) failed", bus_no, dev_no); + if (!p) return FALSE; - } p->bus_driver_context = context; return TRUE; } @@ -2278,11 +2071,10 @@ visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, */ gfp |= __GFP_NORETRY; p = kmem_cache_alloc(pool, gfp); - if (!p) { - LOGERR("kmem_cache_alloc failed early @%s:%d\n", fn, ln); + if (!p) return NULL; - } - atomic_inc(&Visorchipset_cache_buffers_in_use); + + atomic_inc(&visorchipset_cache_buffers_in_use); return p; } @@ -2291,16 +2083,16 @@ visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, void visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln) { - if (!p) { - LOGERR("NULL pointer @%s:%d\n", fn, ln); + if (!p) return; - } - atomic_dec(&Visorchipset_cache_buffers_in_use); + + atomic_dec(&visorchipset_cache_buffers_in_use); kmem_cache_free(pool, p); } static ssize_t chipsetready_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { char msgtype[64]; @@ -2322,7 +2114,8 @@ static ssize_t chipsetready_store(struct device *dev, * and then passed back when the device has been removed. */ static ssize_t devicedisabled_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { uint id; @@ -2338,7 +2131,8 @@ static ssize_t devicedisabled_store(struct device *dev, * and then passed back when the device has been brought back up. */ static ssize_t deviceenabled_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { uint id; @@ -2353,133 +2147,102 @@ static int __init visorchipset_init(void) { int rc = 0, x = 0; - char s[64]; HOSTADDRESS addr; if (!unisys_spar_platform) return -ENODEV; - LOGINF("chipset driver version %s loaded", VERSION); - /* process module options */ - POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); - - LOGINF("option - testvnic=%d", visorchipset_testvnic); - LOGINF("option - testvnicclient=%d", visorchipset_testvnicclient); - LOGINF("option - testmsg=%d", visorchipset_testmsg); - LOGINF("option - testteardown=%d", visorchipset_testteardown); - LOGINF("option - major=%d", visorchipset_major); - LOGINF("option - serverregwait=%d", visorchipset_serverregwait); - LOGINF("option - clientregwait=%d", visorchipset_clientregwait); - LOGINF("option - holdchipsetready=%d", visorchipset_holdchipsetready); - - memset(&BusDev_Server_Notifiers, 0, sizeof(BusDev_Server_Notifiers)); - memset(&BusDev_Client_Notifiers, 0, sizeof(BusDev_Client_Notifiers)); - memset(&ControlVm_payload_info, 0, sizeof(ControlVm_payload_info)); - memset(&LiveDump_info, 0, sizeof(LiveDump_info)); - atomic_set(&LiveDump_info.buffers_in_use, 0); + memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers)); + memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers)); + memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); + memset(&livedump_info, 0, sizeof(livedump_info)); + atomic_set(&livedump_info.buffers_in_use, 0); if (visorchipset_testvnic) { - ERRDRV("testvnic option no longer supported: (status = %d)\n", - x); POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR); rc = x; - goto Away; + goto cleanup; } addr = controlvm_get_channel_address(); if (addr != 0) { - ControlVm_channel = + controlvm_channel = visorchannel_create_with_lock (addr, sizeof(struct spar_controlvm_channel_protocol), spar_controlvm_channel_protocol_uuid); if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( - visorchannel_get_header(ControlVm_channel))) { - LOGINF("Channel %s (ControlVm) discovered", - visorchannel_id(ControlVm_channel, s)); + visorchannel_get_header(controlvm_channel))) { initialize_controlvm_payload(); } else { - LOGERR("controlvm channel is invalid"); - visorchannel_destroy(ControlVm_channel); - ControlVm_channel = NULL; + visorchannel_destroy(controlvm_channel); + controlvm_channel = NULL; return -ENODEV; } } else { - LOGERR("no controlvm channel discovered"); return -ENODEV; } - MajorDev = MKDEV(visorchipset_major, 0); - rc = visorchipset_file_init(MajorDev, &ControlVm_channel); + major_dev = MKDEV(visorchipset_major, 0); + rc = visorchipset_file_init(major_dev, &controlvm_channel); if (rc < 0) { - ERRDRV("visorchipset_file_init(MajorDev, &ControlVm_channel): error (status=%d)\n", rc); POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); - goto Away; + goto cleanup; } - memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); - Putfile_buffer_list_pool = - kmem_cache_create(Putfile_buffer_list_pool_name, + putfile_buffer_list_pool = + kmem_cache_create(putfile_buffer_list_pool_name, sizeof(struct putfile_buffer_entry), 0, SLAB_HWCACHE_ALIGN, NULL); - if (!Putfile_buffer_list_pool) { - ERRDRV("failed to alloc Putfile_buffer_list_pool: (status=-1)\n"); + if (!putfile_buffer_list_pool) { POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); rc = -1; - goto Away; + goto cleanup; } - if (visorchipset_disable_controlvm) { - LOGINF("visorchipset_init:controlvm disabled"); - } else { + if (!visorchipset_disable_controlvm) { /* if booting in a crash kernel */ if (visorchipset_crash_kernel) - INIT_DELAYED_WORK(&Periodic_controlvm_work, + INIT_DELAYED_WORK(&periodic_controlvm_work, setup_crash_devices_work_queue); else - INIT_DELAYED_WORK(&Periodic_controlvm_work, + INIT_DELAYED_WORK(&periodic_controlvm_work, controlvm_periodic_work); - Periodic_controlvm_workqueue = + periodic_controlvm_workqueue = create_singlethread_workqueue("visorchipset_controlvm"); - if (Periodic_controlvm_workqueue == NULL) { - ERRDRV("cannot create controlvm workqueue: (status=%d)\n", - -ENOMEM); + if (!periodic_controlvm_workqueue) { POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC, DIAG_SEVERITY_ERR); rc = -ENOMEM; - goto Away; + goto cleanup; } - Most_recent_message_jiffies = jiffies; - Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - rc = queue_delayed_work(Periodic_controlvm_workqueue, - &Periodic_controlvm_work, Poll_jiffies); + most_recent_message_jiffies = jiffies; + poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; + rc = queue_delayed_work(periodic_controlvm_workqueue, + &periodic_controlvm_work, poll_jiffies); if (rc < 0) { - ERRDRV("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies): error (status=%d)\n", rc); POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC, DIAG_SEVERITY_ERR); - goto Away; + goto cleanup; } - } - Visorchipset_platform_device.dev.devt = MajorDev; - if (platform_device_register(&Visorchipset_platform_device) < 0) { - ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n"); + visorchipset_platform_device.dev.devt = major_dev; + if (platform_device_register(&visorchipset_platform_device) < 0) { POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR); rc = -1; - goto Away; + goto cleanup; } - LOGINF("visorchipset device created"); POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO); rc = 0; -Away: +cleanup: if (rc) { - LOGERR("visorchipset_init failed"); POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc, POSTCODE_SEVERITY_ERR); } @@ -2489,40 +2252,34 @@ Away: static void visorchipset_exit(void) { - char s[99]; - POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); if (visorchipset_disable_controlvm) { ; } else { - cancel_delayed_work(&Periodic_controlvm_work); - flush_workqueue(Periodic_controlvm_workqueue); - destroy_workqueue(Periodic_controlvm_workqueue); - Periodic_controlvm_workqueue = NULL; - destroy_controlvm_payload_info(&ControlVm_payload_info); + cancel_delayed_work(&periodic_controlvm_work); + flush_workqueue(periodic_controlvm_workqueue); + destroy_workqueue(periodic_controlvm_workqueue); + periodic_controlvm_workqueue = NULL; + destroy_controlvm_payload_info(&controlvm_payload_info); } - Test_Vnic_channel = NULL; - if (Putfile_buffer_list_pool) { - kmem_cache_destroy(Putfile_buffer_list_pool); - Putfile_buffer_list_pool = NULL; + if (putfile_buffer_list_pool) { + kmem_cache_destroy(putfile_buffer_list_pool); + putfile_buffer_list_pool = NULL; } cleanup_controlvm_structures(); - memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header)); + memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); - LOGINF("Channel %s (ControlVm) disconnected", - visorchannel_id(ControlVm_channel, s)); - visorchannel_destroy(ControlVm_channel); + visorchannel_destroy(controlvm_channel); - visorchipset_file_cleanup(); + visorchipset_file_cleanup(visorchipset_platform_device.dev.devt); POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); - LOGINF("chipset driver unloaded"); } module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO); |