From: Don Zickus <dzickus@xxxxxxxxxx> This patch handles the first round of conversion of the initial vmchannel command to use/allocate a struct visor_device instead of the _info struct. This is accomplished by using the find_device_by_id function implemented in an earlier patch. Most of the conversion is straight forward. Notable differences: - visor_device allocation happens here instead of visorbus_main.c -> just easier to initialize the data than pass it along. - visor channel allocation happens here instead of later -> the channel info is in inmsg, use it now as opposed to passing it along (visor channel deletion is broken because my brain melted on trying to understand the proper cleanup path) - device_creation bus and dev lookups could be better -> I hacked up an initial implementation to get me going, in retrospect we could probably use for_each_child_device or something. Add that to the TODO list. :-) Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx> Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx> --- drivers/staging/unisys/visorbus/visorchipset.c | 121 +++++++++++++------------ 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 42bf02a..c8f8b56 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1197,9 +1197,10 @@ bus_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; + struct visorchannel *visorchannel; - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, 0, NULL); if (bus_info && (bus_info->state.created == 1)) { POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1214,29 +1215,27 @@ bus_create(struct controlvm_message *inmsg) goto cleanup; } - INIT_LIST_HEAD(&bus_info->entry); - bus_info->bus_no = bus_no; + bus_info->chipset_bus_no = bus_no; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.flags.test_message == 1) - bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; - else - bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; - - 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; - bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; - - list_add(&bus_info->entry, &bus_info_list); + visorchannel = visorchannel_create(cmd->create_bus.channel_addr, + cmd->create_bus.channel_bytes, + GFP_KERNEL, + cmd->create_bus.bus_data_type_uuid); + if (!visorchannel) { + rc = -ENOMEM; + /*TODO free bus_info*/ + goto cleanup; + } + bus_info->visorchannel = visorchannel; + bus_info->type = cmd->create_bus.bus_data_type_uuid; + bus_info->inst = cmd->create_bus.bus_inst_uuid; POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); cleanup: - bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr, + bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1245,16 +1244,16 @@ bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->destroy_bus.bus_no; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, 0, NULL); if (!bus_info) rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; else if (bus_info->state.created == 0) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr, + bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1264,15 +1263,14 @@ bus_configure(struct controlvm_message *inmsg, { struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - char s[99]; bus_no = cmd->configure_bus.bus_no; POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, 0, NULL); if (!bus_info) { POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1286,16 +1284,16 @@ bus_configure(struct controlvm_message *inmsg, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; } else { - bus_info->partition_handle = cmd->configure_bus.guest_handle; + visorchannel_set_clientpartition(bus_info->visorchannel, + 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(&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, + bus_epilog(bus_info, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1305,28 +1303,30 @@ my_device_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; - struct visorchipset_device_info *dev_info; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; + struct visor_device *dev_info = NULL; + struct visorchannel *visorchannel; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); - if (dev_info && (dev_info->state.created == 1)) { + bus_info = visorbus_get_device_by_id(bus_no, 0, NULL); + if (!bus_info) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); - rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; goto cleanup; } - bus_info = bus_find(&bus_info_list, bus_no); - if (!bus_info) { + 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 cleanup; } - if (bus_info->state.created == 0) { + + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); + 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_BUS_INVALID; + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; goto cleanup; } dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); @@ -1337,33 +1337,38 @@ my_device_create(struct controlvm_message *inmsg) goto cleanup; } - 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; + INIT_LIST_HEAD(&dev_info->list_all); + dev_info->chipset_bus_no = bus_no; + dev_info->chipset_dev_no = dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.flags.test_message == 1) - dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; - else - 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; - dev_info->chan_info.intr = cmd->create_device.intr; - list_add(&dev_info->entry, &dev_info_list); + visorchannel = visorchannel_create(cmd->create_device.channel_addr, + cmd->create_device.channel_bytes, + GFP_KERNEL, + cmd->create_device.data_type_uuid); + if (!visorchannel) { + rc = -ENOMEM; + /*TODO free dev_info*/ + goto cleanup; + } + dev_info->visorchannel = visorchannel; + dev_info->type = cmd->create_device.data_type_uuid; + dev_info->inst = cmd->create_device.dev_inst_uuid; + dev_info->intr = cmd->create_device.intr; + + /* not sure where the best place to set the 'parent' */ + dev_info->device.parent = &bus_info->device; POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); cleanup: /* get the bus and devNo for DiagPool channel */ if (dev_info && - is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) { + is_diagpool_channel(cmd->create_device.data_type_uuid)) { g_diagpool_bus_no = bus_no; g_diagpool_dev_no = dev_no; } - device_epilog(bus_no, dev_no, segment_state_running, + device_epilog(dev_info, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } @@ -1375,10 +1380,10 @@ my_device_changestate(struct controlvm_message *inmsg) u32 bus_no = cmd->device_change_state.bus_no; u32 dev_no = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; - struct visorchipset_device_info *dev_info; + struct visor_device *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); if (!dev_info) { POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1389,7 +1394,7 @@ my_device_changestate(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; } if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) - device_epilog(bus_no, dev_no, state, + device_epilog(dev_info, state, CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } @@ -1400,17 +1405,17 @@ my_device_destroy(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->destroy_device.bus_no; u32 dev_no = cmd->destroy_device.dev_no; - struct visorchipset_device_info *dev_info; + struct visor_device *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); if (!dev_info) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; else if (dev_info->state.created == 0) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) - device_epilog(bus_no, dev_no, segment_state_running, + device_epilog(dev_info, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } -- 2.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel