static long long total_devices_created;
/** ever-increasing */
-static void chipset_bus_create(u32 bus_no);
-static void chipset_bus_destroy(u32 bus_no);
+static void chipset_bus_create(struct visorchipset_bus_info *bus_info);
+static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info);
static void chipset_device_create(u32 bus_no, u32 dev_no);
static void chipset_device_destroy(u32 bus_no, u32 dev_no);
static void chipset_device_pause(u32 bus_no, u32 dev_no);
/** Create a device instance for the visor bus itself.
*/
static struct visorbus_devdata *
-create_bus_instance(int id)
+create_bus_instance(struct visorchipset_bus_info *bus_info)
{
struct visorbus_devdata *rc = NULL;
struct visorbus_devdata *devdata = NULL;
- struct visorchipset_bus_info bus_info;
+ int id = bus_info->bus_no;
POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
goto away;
}
devdata->devno = id;
- if ((visorchipset_get_bus_info(id, &bus_info)) &&
- (bus_info.chan_info.channel_addr > 0) &&
- (bus_info.chan_info.n_channel_bytes > 0)) {
- u64 channel_addr = bus_info.chan_info.channel_addr;
+ 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;
+ bus_info->chan_info.n_channel_bytes;
uuid_le channel_type_guid =
- bus_info.chan_info.channel_type_uuid;
+ bus_info->chan_info.channel_type_uuid;
devdata->chan = visorchannel_create(channel_addr,
n_channel_bytes,
POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr,
POSTCODE_SEVERITY_ERR);
} else {
- if (bus_info.flags.server) {
+ if (bus_info->flags.server) {
init_vbus_channel(devdata->chan);
} else {
if (get_vbus_header_info(devdata->chan,
static unsigned long test_dev_nos[MAXDEVICETEST];
static void
-chipset_bus_create(u32 bus_no)
+chipset_bus_create(struct visorchipset_bus_info *bus_info)
{
- struct visorchipset_bus_info bus_info;
struct visorbus_devdata *devdata;
int rc = -1;
+ u32 bus_no = bus_info->bus_no;
POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
- if (!visorchipset_get_bus_info(bus_no, &bus_info))
- goto away;
- devdata = create_bus_instance(bus_no);
+ devdata = create_bus_instance(bus_info);
if (!devdata)
goto away;
- if (!visorchipset_set_bus_context(bus_no, devdata))
+ if (!visorchipset_set_bus_context(bus_info, devdata))
goto away;
POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
rc = 0;
POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no,
POSTCODE_SEVERITY_INFO);
if (chipset_responders.bus_create)
- (*chipset_responders.bus_create) (bus_no, rc);
+ (*chipset_responders.bus_create) (bus_info, rc);
}
static void
-chipset_bus_destroy(u32 bus_no)
+chipset_bus_destroy(struct visorchipset_bus_info *bus_info)
{
- struct visorchipset_bus_info bus_info;
struct visorbus_devdata *devdata;
int rc = -1;
- if (!visorchipset_get_bus_info(bus_no, &bus_info))
- goto away;
- devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+ devdata = (struct visorbus_devdata *)(bus_info->bus_driver_context);
if (!devdata)
goto away;
remove_bus_instance(devdata);
- if (!visorchipset_set_bus_context(bus_no, NULL))
+ if (!visorchipset_set_bus_context(bus_info, NULL))
goto away;
rc = 0;
away:
if (rc < 0)
return;
if (chipset_responders.bus_destroy)
- (*chipset_responders.bus_destroy)(bus_no, rc);
+ (*chipset_responders.bus_destroy)(bus_info, rc);
}
static void
* visorchipset.)
*/
struct visorchipset_busdev_notifiers {
- void (*bus_create)(u32 bus_no);
- void (*bus_destroy)(u32 bus_no);
+ void (*bus_create)(struct visorchipset_bus_info *bus_info);
+ void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
void (*device_create)(u32 bus_no, u32 dev_no);
void (*device_destroy)(u32 bus_no, u32 dev_no);
void (*device_pause)(u32 bus_no, u32 dev_no);
* -1 = it failed
*/
struct visorchipset_busdev_responders {
- void (*bus_create)(u32 bus_no, int response);
- void (*bus_destroy)(u32 bus_no, int response);
+ void (*bus_create)(struct visorchipset_bus_info *p, int response);
+ void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
void (*device_create)(u32 bus_no, u32 dev_no, int response);
void (*device_destroy)(u32 bus_no, u32 dev_no, int response);
void (*device_pause)(u32 bus_no, u32 dev_no, int response);
struct visorchipset_bus_info *bus_info);
bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
struct visorchipset_device_info *dev_info);
-bool visorchipset_set_bus_context(u32 bus_no, void *context);
+bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
+ void *context);
/* visorbus init and exit functions */
int visorbus_init(void);
*/
static struct visorchipset_busdev_notifiers busdev_notifiers;
-static void bus_create_response(u32 bus_no, int response);
-static void bus_destroy_response(u32 bus_no, int response);
+static void bus_create_response(struct visorchipset_bus_info *p, int response);
+static void bus_destroy_response(struct visorchipset_bus_info *p, int response);
static void device_create_response(u32 bus_no, u32 dev_no, int response);
static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
static void device_resume_response(u32 bus_no, u32 dev_no, int response);
};
static void
-bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
+bus_responder(enum controlvm_id cmd_id, struct visorchipset_bus_info *p,
+ int response)
{
- struct visorchipset_bus_info *p;
bool need_clear = false;
+ u32 bus_no = p->bus_no;
- p = bus_find(&bus_info_list, bus_no);
if (!p)
return;
}
static void
-bus_epilog(u32 bus_no,
+bus_epilog(struct visorchipset_bus_info *bus_info,
u32 cmd, struct controlvm_message_header *msg_hdr,
int response, bool need_response)
{
- struct visorchipset_bus_info *bus_info;
bool notified = false;
- bus_info = bus_find(&bus_info_list, bus_no);
-
if (!bus_info)
return;
switch (cmd) {
case CONTROLVM_BUS_CREATE:
if (busdev_notifiers.bus_create) {
- (*busdev_notifiers.bus_create) (bus_no);
+ (*busdev_notifiers.bus_create) (bus_info);
notified = true;
}
break;
case CONTROLVM_BUS_DESTROY:
if (busdev_notifiers.bus_destroy) {
- (*busdev_notifiers.bus_destroy) (bus_no);
+ (*busdev_notifiers.bus_destroy) (bus_info);
notified = true;
}
break;
*/
;
else
- bus_responder(cmd, bus_no, response);
+ bus_responder(cmd, bus_info, response);
up(¬ifier_lock);
}
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);
}
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);
}
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);
}
}
static void
-bus_create_response(u32 bus_no, int response)
+bus_create_response(struct visorchipset_bus_info *bus_info, int response)
{
- bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+ bus_responder(CONTROLVM_BUS_CREATE, bus_info, response);
}
static void
-bus_destroy_response(u32 bus_no, int response)
+bus_destroy_response(struct visorchipset_bus_info *bus_info, int response)
{
- bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+ bus_responder(CONTROLVM_BUS_DESTROY, bus_info, response);
}
static void
EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
bool
-visorchipset_set_bus_context(u32 bus_no, void *context)
+visorchipset_set_bus_context(struct visorchipset_bus_info *p, void *context)
{
- struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
-
if (!p)
return false;
p->bus_driver_context = context;