From: Don Zickus Date: Mon, 1 Jun 2015 17:00:26 +0000 (-0400) Subject: staging: unisys: Move channel creation up the stack X-Git-Tag: v4.2-rc1~88^2~366 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b32c4997c03d9d1fcfc1c6771f70d7526ffdbbe4;p=platform%2Fkernel%2Flinux-exynos.git staging: unisys: Move channel creation up the stack Instead of creating a channel struct to temporarily hold the channel info and passing it through multiple functions until the device is created, just create the channel from the start. This allows us to remove the channel_info struct. I noticed 'chan_info.addr_type' was not being used, so I just deleted it. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 00f9a146806c..fccf4df1e9b4 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1010,11 +1010,9 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); static int create_visor_device(struct visorbus_devdata *devdata, struct visorchipset_device_info *dev_info, - struct visorchipset_channel_info chan_info, u64 partition_handle) { int rc = -1; - struct visorchannel *visorchannel = NULL; struct visor_device *dev = NULL; bool gotten = false, registered1 = false, registered2 = false; u32 chipset_bus_no = dev_info->bus_no; @@ -1022,16 +1020,6 @@ create_visor_device(struct visorbus_devdata *devdata, POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, POSTCODE_SEVERITY_INFO); - /* prepare chan_hdr (abstraction to read/write channel memory) */ - visorchannel = visorchannel_create(chan_info.channel_addr, - chan_info.n_channel_bytes, - GFP_KERNEL, - chan_info.channel_type_uuid); - if (!visorchannel) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, - DIAG_SEVERITY_ERR); - goto away; - } dev = kmalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, @@ -1040,9 +1028,8 @@ create_visor_device(struct visorbus_devdata *devdata, } memset(dev, 0, sizeof(struct visor_device)); - dev->visorchannel = visorchannel; - dev->channel_type_guid = chan_info.channel_type_uuid; - dev->channel_bytes = chan_info.n_channel_bytes; + dev->visorchannel = dev_info->visorchannel; + dev->channel_type_guid = dev_info->channel_type_guid; dev->chipset_bus_no = chipset_bus_no; dev->chipset_dev_no = chipset_dev_no; dev->device.parent = &devdata->dev; @@ -1114,8 +1101,6 @@ away: unregister_devmajorminor_attributes(dev); if (gotten) put_device(&dev->device); - if (visorchannel) - visorchannel_destroy(visorchannel); kfree(dev); } else { total_devices_created++; @@ -1134,7 +1119,7 @@ remove_visor_device(struct visor_device *dev) } static struct visor_device * -find_visor_device_by_channel(u64 channel_physaddr) +find_visor_device_by_channel(struct visorchannel *channel) { struct list_head *listentry, *listtmp; @@ -1142,8 +1127,7 @@ find_visor_device_by_channel(u64 channel_physaddr) struct visor_device *dev = list_entry(listentry, struct visor_device, list_all); - if (visorchannel_get_physaddr(dev->visorchannel) == - channel_physaddr) + if (dev->visorchannel == channel) return dev; } return NULL; @@ -1363,41 +1347,23 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) goto away; } devdata->devno = id; - if ((bus_info->chan_info.channel_addr > 0) && - (bus_info->chan_info.n_channel_bytes > 0)) { - u64 channel_addr = bus_info->chan_info.channel_addr; - unsigned long n_channel_bytes = - (unsigned long) - bus_info->chan_info.n_channel_bytes; - uuid_le channel_type_guid = - bus_info->chan_info.channel_type_uuid; - - devdata->chan = visorchannel_create(channel_addr, - n_channel_bytes, - GFP_KERNEL, - channel_type_guid); - if (!devdata->chan) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr, - POSTCODE_SEVERITY_ERR); - } else { - if (bus_info->flags.server) { - init_vbus_channel(devdata->chan); - } else { - if (get_vbus_header_info(devdata->chan, - &devdata-> - vbus_hdr_info) >= 0) { - devdata->vbus_valid = true; - write_vbus_chp_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &chipset_driverinfo - ); - write_vbus_bus_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &clientbus_driverinfo); - } - } + devdata->chan = bus_info->visorchannel; + if (bus_info->flags.server) { + init_vbus_channel(devdata->chan); + } else { + if (get_vbus_header_info(devdata->chan, + &devdata-> + vbus_hdr_info) >= 0) { + devdata->vbus_valid = true; + write_vbus_chp_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &chipset_driverinfo + ); + write_vbus_bus_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &clientbus_driverinfo); } } bus_count++; @@ -1468,7 +1434,7 @@ remove_all_visor_devices(void) } static bool entered_testing_mode; -static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST]; +static struct visorchannel *test_channel_infos[MAXDEVICETEST]; static unsigned long test_bus_nos[MAXDEVICETEST]; static unsigned long test_dev_nos[MAXDEVICETEST]; @@ -1538,7 +1504,7 @@ chipset_device_create(struct visorchipset_device_info *dev_info) if (visorbus_devicetest) if (total_devices_created < MAXDEVICETEST) { test_channel_infos[total_devices_created] = - dev_info->chan_info; + dev_info->visorchannel; test_bus_nos[total_devices_created] = bus_no; test_dev_nos[total_devices_created] = dev_no; } @@ -1552,9 +1518,7 @@ away: return; } devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); - rc = create_visor_device(devdata, dev_info, - dev_info->chan_info, - bus_info.partition_handle); + rc = create_visor_device(devdata, dev_info, bus_info.partition_handle); POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (rc < 0) @@ -1570,7 +1534,7 @@ chipset_device_destroy(struct visorchipset_device_info *dev_info) if (entered_testing_mode) return; - dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->visorchannel); if (!dev) goto away; rc = 0; @@ -1650,7 +1614,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, if (!notify_func) goto away; - dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->visorchannel); if (!dev) goto away; diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 81e4e8c24191..912b6cdfb299 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -40,17 +40,6 @@ enum visorchipset_addresstype { ADDRTYPE_LOCALTEST, }; -/** Attributes for a particular Supervisor channel. - */ -struct visorchipset_channel_info { - enum visorchipset_addresstype addr_type; - u64 channel_addr; - struct irq_info intr; - u64 n_channel_bytes; - uuid_le channel_type_uuid; - uuid_le channel_inst_uuid; -}; - /** Attributes for a particular Supervisor device. * Any visorchipset client can query these attributes using * visorchipset_get_client_device_info() or @@ -62,7 +51,8 @@ struct visorchipset_device_info { u32 dev_no; uuid_le dev_inst_uuid; struct visorchipset_state state; - struct visorchipset_channel_info chan_info; + struct visorchannel *visorchannel; + uuid_le channel_type_guid; u32 reserved1; /* control_vm_id */ u64 reserved2; u32 switch_no; /* when devState.attached==1 */ @@ -82,7 +72,7 @@ struct visorchipset_bus_info { struct list_head entry; u32 bus_no; struct visorchipset_state state; - struct visorchipset_channel_info chan_info; + struct visorchannel *visorchannel; uuid_le partition_uuid; u64 partition_handle; u8 *name; /* UTF8 */ diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 9bbc0804f878..3d0866148870 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1197,6 +1197,7 @@ bus_create(struct controlvm_message *inmsg) u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; struct visorchipset_bus_info *bus_info; + struct visorchannel *visorchannel; bus_info = bus_find(&bus_info_list, bus_no); if (bus_info && (bus_info->state.created == 1)) { @@ -1218,18 +1219,22 @@ bus_create(struct controlvm_message *inmsg) 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; + visorchannel = visorchannel_create(cmd->create_bus.channel_addr, + cmd->create_bus.channel_bytes, + GFP_KERNEL, + cmd->create_bus.bus_data_type_uuid); + + if (!visorchannel) { + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, + POSTCODE_SEVERITY_ERR); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + kfree(bus_info); + bus_info = NULL; + goto cleanup; + } + bus_info->visorchannel = visorchannel; list_add(&bus_info->entry, &bus_info_list); POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); @@ -1285,7 +1290,8 @@ 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); @@ -1306,6 +1312,7 @@ my_device_create(struct controlvm_message *inmsg) u32 dev_no = cmd->create_device.dev_no; struct visorchipset_device_info *dev_info; struct visorchipset_bus_info *bus_info; + struct visorchannel *visorchannel; int rc = CONTROLVM_RESP_SUCCESS; dev_info = device_find(&dev_info_list, bus_no, dev_no); @@ -1343,21 +1350,28 @@ my_device_create(struct controlvm_message *inmsg) 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; + visorchannel = visorchannel_create(cmd->create_device.channel_addr, + cmd->create_device.channel_bytes, + GFP_KERNEL, + cmd->create_device.data_type_uuid); + + if (!visorchannel) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, + POSTCODE_SEVERITY_ERR); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + kfree(dev_info); + dev_info = NULL; + goto cleanup; + } + dev_info->visorchannel = visorchannel; + dev_info->channel_type_guid = cmd->create_device.data_type_uuid; list_add(&dev_info->entry, &dev_info_list); 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; }