diff options
Diffstat (limited to 'drivers/staging/unisys/visorbus/visorchipset.c')
-rw-r--r-- | drivers/staging/unisys/visorbus/visorchipset.c | 298 |
1 files changed, 69 insertions, 229 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 27ecf6fb49fd..fed554a43151 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -27,8 +27,8 @@ static const guid_t visor_vhba_channel_guid = VISOR_VHBA_CHANNEL_GUID; static const guid_t visor_siovm_guid = VISOR_SIOVM_GUID; static const guid_t visor_controlvm_channel_guid = VISOR_CONTROLVM_CHANNEL_GUID; -#define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 -#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 +#define POLLJIFFIES_CONTROLVM_FAST 1 +#define POLLJIFFIES_CONTROLVM_SLOW 100 #define MAX_CONTROLVM_PAYLOAD_BYTES (1024 * 128) @@ -128,7 +128,6 @@ static ssize_t toolaction_show(struct device *dev, &tool_action, sizeof(u8)); if (err) return err; - return sprintf(buf, "%u\n", tool_action); } @@ -141,7 +140,6 @@ static ssize_t toolaction_store(struct device *dev, if (kstrtou8(buf, 10, &tool_action)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, tool_action), @@ -178,7 +176,6 @@ static ssize_t boottotool_store(struct device *dev, if (kstrtoint(buf, 10, &val)) return -EINVAL; - efi_visor_indication.boot_to_tool = val; err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -214,7 +211,6 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, if (kstrtou32(buf, 10, &error)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_error), @@ -237,7 +233,6 @@ static ssize_t textid_show(struct device *dev, struct device_attribute *attr, &text_id, sizeof(u32)); if (err) return err; - return sprintf(buf, "%u\n", text_id); } @@ -249,7 +244,6 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr, if (kstrtou32(buf, 10, &text_id)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_text_id), @@ -272,7 +266,6 @@ static ssize_t remaining_steps_show(struct device *dev, &remaining_steps, sizeof(u16)); if (err) return err; - return sprintf(buf, "%hu\n", remaining_steps); } @@ -285,7 +278,6 @@ static ssize_t remaining_steps_store(struct device *dev, if (kstrtou16(buf, 10, &remaining_steps)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_remaining_steps), @@ -296,43 +288,6 @@ static ssize_t remaining_steps_store(struct device *dev, } static DEVICE_ATTR_RW(remaining_steps); -struct visor_busdev { - u32 bus_no; - u32 dev_no; -}; - -static int match_visorbus_dev_by_id(struct device *dev, void *data) -{ - struct visor_device *vdev = to_visor_device(dev); - struct visor_busdev *id = data; - - if ((vdev->chipset_bus_no == id->bus_no) && - (vdev->chipset_dev_no == id->dev_no)) - return 1; - - return 0; -} - -struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, - struct visor_device *from) -{ - struct device *dev; - struct device *dev_start = NULL; - struct visor_device *vdev = NULL; - struct visor_busdev id = { - .bus_no = bus_no, - .dev_no = dev_no - }; - - if (from) - dev_start = &from->device; - dev = bus_find_device(&visorbus_type, dev_start, (void *)&id, - match_visorbus_dev_by_id); - if (dev) - vdev = to_visor_device(dev); - return vdev; -} - static void controlvm_init_response(struct controlvm_message *msg, struct controlvm_message_header *msg_hdr, int response) @@ -374,18 +329,13 @@ static int chipset_init(struct controlvm_message *inmsg) goto out_respond; } chipset_inited = 1; - /* * Set features to indicate we support parahotplug (if Command also - * supports it). + * supports it). Set the "reply" bit so Command knows this is a + * features-aware driver. */ features = inmsg->cmd.init_chipset.features & VISOR_CHIPSET_FEATURE_PARA_HOTPLUG; - - /* - * Set the "reply" bit so Command knows this is a features-aware - * driver. - */ features |= VISOR_CHIPSET_FEATURE_REPLY; out_respond: @@ -396,20 +346,17 @@ out_respond: } static int controlvm_respond(struct controlvm_message_header *msg_hdr, - int response, - struct visor_segment_state *state) + int response, struct visor_segment_state *state) { struct controlvm_message outmsg; controlvm_init_response(&outmsg, msg_hdr, response); if (outmsg.hdr.flags.test_message == 1) return -EINVAL; - if (state) { outmsg.cmd.device_change_state.state = *state; outmsg.cmd.device_change_state.flags.phys_device = 1; } - return visorchannel_signalinsert(chipset_dev->controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg); } @@ -435,13 +382,11 @@ static int save_crash_message(struct controlvm_message *msg, "failed to read message count\n"); return err; } - if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { dev_err(&chipset_dev->acpi_device->dev, "invalid number of messages\n"); return -EIO; } - err = visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, saved_crash_message_offset), @@ -451,13 +396,11 @@ static int save_crash_message(struct controlvm_message *msg, "failed to read offset\n"); return err; } - switch (cr_type) { case CRASH_DEV: local_crash_msg_offset += sizeof(struct controlvm_message); err = visorchannel_write(chipset_dev->controlvm_channel, - local_crash_msg_offset, - msg, + local_crash_msg_offset, msg, sizeof(struct controlvm_message)); if (err) { dev_err(&chipset_dev->acpi_device->dev, @@ -467,8 +410,7 @@ static int save_crash_message(struct controlvm_message *msg, break; case CRASH_BUS: err = visorchannel_write(chipset_dev->controlvm_channel, - local_crash_msg_offset, - msg, + local_crash_msg_offset, msg, sizeof(struct controlvm_message)); if (err) { dev_err(&chipset_dev->acpi_device->dev, @@ -488,33 +430,25 @@ static int controlvm_responder(enum controlvm_id cmd_id, struct controlvm_message_header *pending_msg_hdr, int response) { - if (!pending_msg_hdr) - return -EIO; - if (pending_msg_hdr->id != (u32)cmd_id) return -EINVAL; return controlvm_respond(pending_msg_hdr, response, NULL); } -static int device_changestate_responder( - enum controlvm_id cmd_id, - struct visor_device *p, int response, - struct visor_segment_state response_state) +static int device_changestate_responder(enum controlvm_id cmd_id, + struct visor_device *p, int response, + struct visor_segment_state state) { struct controlvm_message outmsg; - if (!p->pending_msg_hdr) - return -EIO; if (p->pending_msg_hdr->id != cmd_id) return -EINVAL; controlvm_init_response(&outmsg, p->pending_msg_hdr, response); - outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no; outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no; - outmsg.cmd.device_change_state.state = response_state; - + outmsg.cmd.device_change_state.state = state; return visorchannel_signalinsert(chipset_dev->controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg); } @@ -522,64 +456,55 @@ static int device_changestate_responder( static int visorbus_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->create_bus.bus_no; struct visor_device *bus_info; struct visorchannel *visorchannel; int err; bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); - if (bus_info && (bus_info->state.created == 1)) { + if (bus_info && bus_info->state.created == 1) { dev_err(&chipset_dev->acpi_device->dev, "failed %s: already exists\n", __func__); err = -EEXIST; goto err_respond; } - bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL); if (!bus_info) { err = -ENOMEM; goto err_respond; } - INIT_LIST_HEAD(&bus_info->list_all); bus_info->chipset_bus_no = bus_no; bus_info->chipset_dev_no = BUS_ROOT_DEVICE; - if (guid_equal(&cmd->create_bus.bus_inst_guid, &visor_siovm_guid)) { err = save_crash_message(inmsg, CRASH_BUS); if (err) goto err_free_bus_info; } - if (inmsg->hdr.flags.response_expected == 1) { - pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), - GFP_KERNEL); + pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_free_bus_info; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); bus_info->pending_msg_hdr = pmsg_hdr; } - visorchannel = visorchannel_create(cmd->create_bus.channel_addr, GFP_KERNEL, - &cmd->create_bus.bus_data_type_guid); + &cmd->create_bus.bus_data_type_guid, + false); if (!visorchannel) { err = -ENOMEM; goto err_free_pending_msg; } - bus_info->visorchannel = visorchannel; - /* Response will be handled by visorbus_create_instance on success */ err = visorbus_create_instance(bus_info); if (err) goto err_destroy_channel; - return 0; err_destroy_channel: @@ -599,9 +524,8 @@ err_respond: static int visorbus_destroy(struct controlvm_message *inmsg) { - struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; - u32 bus_no = cmd->destroy_bus.bus_no; + struct controlvm_message_header *pmsg_hdr; + u32 bus_no = inmsg->cmd.destroy_bus.bus_no; struct visor_device *bus_info; int err; @@ -625,12 +549,10 @@ static int visorbus_destroy(struct controlvm_message *inmsg) err = -ENOMEM; goto err_respond; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); bus_info->pending_msg_hdr = pmsg_hdr; } - /* Response will be handled by visorbus_remove_instance */ visorbus_remove_instance(bus_info); return 0; @@ -646,51 +568,33 @@ static const guid_t *parser_id_get(struct parser_context *ctx) return &ctx->data.id; } -static void *parser_string_get(struct parser_context *ctx) +static void *parser_string_get(u8 *pscan, int nscan) { - u8 *pscan; - unsigned long nscan; int value_length; void *value; - int i; - pscan = ctx->curr; - if (!pscan) - return NULL; - nscan = ctx->bytes_remaining; if (nscan == 0) return NULL; - for (i = 0, value_length = -1; i < nscan; i++) - if (pscan[i] == '\0') { - value_length = i; - break; - } - /* '\0' was not included in the length */ - if (value_length < 0) - value_length = nscan; - - value = kmalloc(value_length + 1, GFP_KERNEL); + value_length = strnlen(pscan, nscan); + value = kzalloc(value_length + 1, GFP_KERNEL); if (!value) return NULL; if (value_length > 0) memcpy(value, pscan, value_length); - ((u8 *)(value))[value_length] = '\0'; return value; } static void *parser_name_get(struct parser_context *ctx) { - struct visor_controlvm_parameters_header *phdr = NULL; + struct visor_controlvm_parameters_header *phdr; phdr = &ctx->data; - if (phdr->name_offset + phdr->name_length > ctx->param_bytes) return NULL; - ctx->curr = (char *)&phdr + phdr->name_offset; ctx->bytes_remaining = phdr->name_length; - return parser_string_get(ctx); + return parser_string_get(ctx->curr, phdr->name_length); } static int visorbus_configure(struct controlvm_message *inmsg, @@ -715,20 +619,16 @@ static int visorbus_configure(struct controlvm_message *inmsg, err = -EIO; goto err_respond; } - - err = visorchannel_set_clientpartition - (bus_info->visorchannel, - cmd->configure_bus.guest_handle); + err = visorchannel_set_clientpartition(bus_info->visorchannel, + cmd->configure_bus.guest_handle); if (err) goto err_respond; - if (parser_ctx) { const guid_t *partition_guid = parser_id_get(parser_ctx); guid_copy(&bus_info->partition_guid, partition_guid); bus_info->name = parser_name_get(parser_ctx); } - if (inmsg->hdr.flags.response_expected == 1) controlvm_responder(inmsg->hdr.id, &inmsg->hdr, err); return 0; @@ -744,10 +644,10 @@ err_respond: static int visorbus_device_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; - struct visor_device *dev_info = NULL; + struct visor_device *dev_info; struct visor_device *bus_info; struct visorchannel *visorchannel; int err; @@ -765,9 +665,8 @@ static int visorbus_device_create(struct controlvm_message *inmsg) err = -EINVAL; goto err_respond; } - dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); - if (dev_info && (dev_info->state.created == 1)) { + if (dev_info && dev_info->state.created == 1) { dev_err(&chipset_dev->acpi_device->dev, "failed to get bus by id: %d/%d\n", bus_no, dev_no); err = -EEXIST; @@ -779,16 +678,14 @@ static int visorbus_device_create(struct controlvm_message *inmsg) err = -ENOMEM; goto err_respond; } - dev_info->chipset_bus_no = bus_no; dev_info->chipset_dev_no = dev_no; guid_copy(&dev_info->inst, &cmd->create_device.dev_inst_guid); dev_info->device.parent = &bus_info->device; - - visorchannel = - visorchannel_create_with_lock(cmd->create_device.channel_addr, - GFP_KERNEL, - &cmd->create_device.data_type_guid); + visorchannel = visorchannel_create(cmd->create_device.channel_addr, + GFP_KERNEL, + &cmd->create_device.data_type_guid, + true); if (!visorchannel) { dev_err(&chipset_dev->acpi_device->dev, "failed to create visorchannel: %d/%d\n", @@ -797,20 +694,20 @@ static int visorbus_device_create(struct controlvm_message *inmsg) goto err_free_dev_info; } dev_info->visorchannel = visorchannel; - guid_copy(&dev_info->channel_type_guid, &cmd->create_device.data_type_guid); - if (guid_equal(&cmd->create_device.data_type_guid, &visor_vhba_channel_guid)) { + guid_copy(&dev_info->channel_type_guid, + &cmd->create_device.data_type_guid); + if (guid_equal(&cmd->create_device.data_type_guid, + &visor_vhba_channel_guid)) { err = save_crash_message(inmsg, CRASH_DEV); if (err) goto err_destroy_visorchannel; } - if (inmsg->hdr.flags.response_expected == 1) { pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_destroy_visorchannel; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; @@ -837,7 +734,7 @@ err_respond: static int visorbus_device_changestate(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->device_change_state.bus_no; u32 dev_no = cmd->device_change_state.dev_no; struct visor_segment_state state = cmd->device_change_state.state; @@ -858,18 +755,17 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg) err = -EIO; goto err_respond; } + if (inmsg->hdr.flags.response_expected == 1) { pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_respond; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; } - if (state.alive == segment_state_running.alive && state.operating == segment_state_running.operating) /* Response will be sent from visorchipset_device_resume */ @@ -884,7 +780,6 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg) err = visorchipset_device_pause(dev_info); if (err) goto err_respond; - return 0; err_respond: @@ -897,7 +792,7 @@ err_respond: static int visorbus_device_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->destroy_device.bus_no; u32 dev_no = cmd->destroy_device.dev_no; struct visor_device *dev_info; @@ -928,7 +823,6 @@ static int visorbus_device_destroy(struct controlvm_message *inmsg) sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; } - kfree(dev_info->name); remove_visor_device(dev_info); return 0; @@ -995,11 +889,9 @@ static struct parahotplug_request *parahotplug_request_create( req = kmalloc(sizeof(*req), GFP_KERNEL); if (!req) return NULL; - req->id = parahotplug_next_id(); req->expiration = parahotplug_next_expiration(); req->msg = *msg; - return req; } @@ -1031,13 +923,12 @@ static int parahotplug_request_complete(int id, u16 active) { struct list_head *pos; struct list_head *tmp; + struct parahotplug_request *req; spin_lock(¶hotplug_request_list_lock); - /* Look for a request matching "id". */ list_for_each_safe(pos, tmp, ¶hotplug_request_list) { - struct parahotplug_request *req = - list_entry(pos, struct parahotplug_request, list); + req = list_entry(pos, struct parahotplug_request, list); if (req->id == id) { /* * Found a match. Remove it from the list and @@ -1054,7 +945,6 @@ static int parahotplug_request_complete(int id, u16 active) return 0; } } - spin_unlock(¶hotplug_request_list_lock); return -EINVAL; } @@ -1081,7 +971,6 @@ static ssize_t devicedisabled_store(struct device *dev, if (kstrtouint(buf, 10, &id)) return -EINVAL; - err = parahotplug_request_complete(id, 0); if (err < 0) return err; @@ -1110,7 +999,6 @@ static ssize_t deviceenabled_store(struct device *dev, if (kstrtouint(buf, 10, &id)) return -EINVAL; - parahotplug_request_complete(id, 1); return count; } @@ -1158,9 +1046,9 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req) { struct controlvm_message_packet *cmd = &req->msg.cmd; char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40], - env_func[40]; - char *envp[] = { - env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL + env_func[40]; + char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev, + env_func, NULL }; sprintf(env_cmd, "VISOR_PARAHOTPLUG=1"); @@ -1173,7 +1061,6 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req) cmd->device_change_state.dev_no >> 3); sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d", cmd->device_change_state.dev_no & 0x7); - return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, KOBJ_CHANGE, envp); } @@ -1191,7 +1078,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) req = parahotplug_request_create(inmsg); if (!req) return -ENOMEM; - /* * For enable messages, just respond with success right away, we don't * need to wait to see if the enable was successful. @@ -1205,7 +1091,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) parahotplug_request_destroy(req); return 0; } - /* * For disable messages, add the request to the request list before * kicking off the udev script. It won't get responded to until the @@ -1214,7 +1099,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) spin_lock(¶hotplug_request_list_lock); list_add_tail(&req->list, ¶hotplug_request_list); spin_unlock(¶hotplug_request_list_lock); - err = parahotplug_request_kickoff(req); if (err) goto err_respond; @@ -1237,12 +1121,9 @@ static int chipset_ready_uevent(struct controlvm_message_header *msg_hdr) { int res; - res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, - KOBJ_ONLINE); - + res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, KOBJ_ONLINE); if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1262,10 +1143,8 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); res = kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, KOBJ_CHANGE, envp); - if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1279,11 +1158,10 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) static int chipset_notready_uevent(struct controlvm_message_header *msg_hdr) { int res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, - KOBJ_OFFLINE); + KOBJ_OFFLINE); if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1296,17 +1174,15 @@ static int unisys_vmcall(unsigned long tuple, unsigned long param) reg_ebx = param & 0xFFFFFFFF; reg_ecx = param >> 32; - cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); if (!(cpuid_ecx & 0x80000000)) return -EPERM; - __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : - "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); + "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); if (result) goto error; - return 0; + /* Need to convert from VMCALL error codes to Linux */ error: switch (result) { @@ -1330,8 +1206,8 @@ static int controlvm_channel_create(struct visorchipset_device *dev) if (err) return err; addr = dev->controlvm_params.address; - chan = visorchannel_create_with_lock(addr, GFP_KERNEL, - &visor_controlvm_channel_guid); + chan = visorchannel_create(addr, GFP_KERNEL, + &visor_controlvm_channel_guid, true); if (!chan) return -ENOMEM; dev->controlvm_channel = chan; @@ -1350,9 +1226,7 @@ static void setup_crash_devices_work_queue(struct work_struct *work) msg.hdr.id = CONTROLVM_CHIPSET_INIT; msg.cmd.init_chipset.bus_count = 23; msg.cmd.init_chipset.switch_count = 0; - chipset_init(&msg); - /* get saved message count */ if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -1362,13 +1236,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { - dev_err(&chipset_dev->acpi_device->dev, - "invalid count\n"); + dev_err(&chipset_dev->acpi_device->dev, "invalid count\n"); return; } - /* get saved crash message offset */ if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -1378,7 +1249,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* read create device message for storage bus offset */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset, @@ -1388,7 +1258,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* read create device message for storage device */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset + @@ -1399,7 +1268,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* reuse IOVM create bus message */ if (!local_crash_bus_msg.cmd.create_bus.channel_addr) { dev_err(&chipset_dev->acpi_device->dev, @@ -1407,7 +1275,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) return; } visorbus_create(&local_crash_bus_msg); - /* reuse create device message for storage device */ if (!local_crash_dev_msg.cmd.create_device.channel_addr) { dev_err(&chipset_dev->acpi_device->dev, @@ -1420,8 +1287,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work) void visorbus_response(struct visor_device *bus_info, int response, int controlvm_id) { - controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response); + if (!bus_info->pending_msg_hdr) + return; + controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response); kfree(bus_info->pending_msg_hdr); bus_info->pending_msg_hdr = NULL; } @@ -1430,9 +1299,11 @@ void visorbus_device_changestate_response(struct visor_device *dev_info, int response, struct visor_segment_state state) { - device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - dev_info, response, state); + if (!dev_info->pending_msg_hdr) + return; + device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info, + response, state); kfree(dev_info->pending_msg_hdr); dev_info->pending_msg_hdr = NULL; } @@ -1451,12 +1322,11 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, void *mapping; *retry = false; - /* alloc an extra byte to ensure payload is \0 terminated */ allocbytes = bytes + 1 + (sizeof(struct parser_context) - sizeof(struct visor_controlvm_parameters_header)); - if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) - > MAX_CONTROLVM_PAYLOAD_BYTES) { + if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) > + MAX_CONTROLVM_PAYLOAD_BYTES) { *retry = true; return NULL; } @@ -1465,7 +1335,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, *retry = true; return NULL; } - ctx->allocbytes = allocbytes; ctx->param_bytes = bytes; mapping = memremap(addr, bytes, MEMREMAP_WB); @@ -1475,7 +1344,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, memunmap(mapping); ctx->byte_stream = true; chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes; - return ctx; err_finish_ctx: @@ -1508,14 +1376,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) /* create parsing context if necessary */ 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 (parm_bytes) { - bool retry = false; + bool retry; parser_ctx = parser_init_stream(parm_addr, parm_bytes, &retry); if (!parser_ctx && retry) @@ -1526,7 +1393,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) CONTROLVM_QUEUE_ACK, &ackmsg); if (err) return err; - switch (inmsg.hdr.id) { case CONTROLVM_CHIPSET_INIT: err = chipset_init(&inmsg); @@ -1580,7 +1446,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) -CONTROLVM_RESP_ID_UNKNOWN, NULL); break; } - if (parser_ctx) { parser_done(parser_ctx); parser_ctx = NULL; @@ -1599,14 +1464,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) static int read_controlvm_event(struct controlvm_message *msg) { int err = visorchannel_signalremove(chipset_dev->controlvm_channel, - CONTROLVM_QUEUE_EVENT, msg); + CONTROLVM_QUEUE_EVENT, msg); + if (err) return err; - /* got a message */ if (msg->hdr.flags.test_message == 1) return -EINVAL; - return 0; } @@ -1620,14 +1484,12 @@ static void parahotplug_process_list(void) struct list_head *tmp; spin_lock(¶hotplug_request_list_lock); - 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)) continue; - list_del(pos); if (req->msg.hdr.flags.response_expected) controlvm_respond( @@ -1636,7 +1498,6 @@ static void parahotplug_process_list(void) &req->msg.cmd.device_change_state.state); parahotplug_request_destroy(req); } - spin_unlock(¶hotplug_request_list_lock); } @@ -1652,10 +1513,8 @@ static void controlvm_periodic_work(struct work_struct *work) CONTROLVM_QUEUE_RESPONSE, &inmsg); } while ((!err) && (++count < CONTROLVM_MESSAGE_MAX)); - if (err != -EAGAIN) goto schedule_out; - if (chipset_dev->controlvm_pending_msg_valid) { /* * we throttled processing of a prior msg, so try to process @@ -1667,7 +1526,6 @@ static void controlvm_periodic_work(struct work_struct *work) } else { err = read_controlvm_event(&inmsg); } - while (!err) { chipset_dev->most_recent_message_jiffies = jiffies; err = handle_command(inmsg, @@ -1681,7 +1539,6 @@ static void controlvm_periodic_work(struct work_struct *work) err = read_controlvm_event(&inmsg); } - /* parahotplug_worker */ parahotplug_process_list(); @@ -1697,17 +1554,12 @@ schedule_out: * it's been longer than MIN_IDLE_SECONDS since we processed * our last controlvm message; slow down the polling */ - if (chipset_dev->poll_jiffies != - POLLJIFFIES_CONTROLVMCHANNEL_SLOW) - chipset_dev->poll_jiffies = - POLLJIFFIES_CONTROLVMCHANNEL_SLOW; + if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_SLOW) + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_SLOW; } else { - if (chipset_dev->poll_jiffies != - POLLJIFFIES_CONTROLVMCHANNEL_FAST) - chipset_dev->poll_jiffies = - POLLJIFFIES_CONTROLVMCHANNEL_FAST; + if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_FAST) + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; } - schedule_delayed_work(&chipset_dev->periodic_controlvm_work, chipset_dev->poll_jiffies); } @@ -1720,20 +1572,16 @@ static int visorchipset_init(struct acpi_device *acpi_device) chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL); if (!chipset_dev) goto error; - err = controlvm_channel_create(chipset_dev); if (err) goto error_free_chipset_dev; - acpi_device->driver_data = chipset_dev; chipset_dev->acpi_device = acpi_device; - chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; err = sysfs_create_groups(&chipset_dev->acpi_device->dev.kobj, visorchipset_dev_groups); if (err < 0) goto error_destroy_channel; - controlvm_channel = chipset_dev->controlvm_channel; if (!visor_check_channel(visorchannel_get_header(controlvm_channel), &chipset_dev->acpi_device->dev, @@ -1743,7 +1591,6 @@ static int visorchipset_init(struct acpi_device *acpi_device) VISOR_CONTROLVM_CHANNEL_VERSIONID, VISOR_CHANNEL_SIGNATURE)) goto error_delete_groups; - /* if booting in a crash kernel */ if (is_kdump_kernel()) INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, @@ -1751,16 +1598,13 @@ static int visorchipset_init(struct acpi_device *acpi_device) else INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, controlvm_periodic_work); - chipset_dev->most_recent_message_jiffies = jiffies; - chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; schedule_delayed_work(&chipset_dev->periodic_controlvm_work, chipset_dev->poll_jiffies); - err = visorbus_init(); if (err < 0) goto error_cancel_work; - return 0; error_cancel_work: @@ -1787,10 +1631,8 @@ static int visorchipset_exit(struct acpi_device *acpi_device) cancel_delayed_work_sync(&chipset_dev->periodic_controlvm_work); sysfs_remove_groups(&chipset_dev->acpi_device->dev.kobj, visorchipset_dev_groups); - visorchannel_destroy(chipset_dev->controlvm_channel); kfree(chipset_dev); - return 0; } @@ -1832,11 +1674,9 @@ static int __init init_unisys(void) if (!visorutil_spar_detect()) return -ENODEV; - result = acpi_bus_register_driver(&unisys_acpi_driver); if (result) return -ENODEV; - pr_info("Unisys Visorchipset Driver Loaded.\n"); return 0; }; |