extern struct bus_type visorbus_type;
typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
- int status);
+ int status, void *dev_info);
struct visorchipset_state {
u32 created:1;
u32 attached:1;
* fails or completes successfully.
*/
int (*pause)(struct visor_device *dev,
- visorbus_state_complete_func complete_func);
+ visorbus_state_complete_func complete_func,
+ void *dev_info);
int (*resume)(struct visor_device *dev,
- visorbus_state_complete_func complete_func);
+ visorbus_state_complete_func complete_func,
+ void *dev_info);
/** These fields are for private use by the bus driver only. */
struct device_driver driver;
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);
-static void chipset_device_resume(u32 bus_no, u32 dev_no);
+static void chipset_device_create(struct visorchipset_device_info *dev_info);
+static void chipset_device_destroy(struct visorchipset_device_info *dev_info);
+static void chipset_device_pause(struct visorchipset_device_info *dev_info);
+static void chipset_device_resume(struct visorchipset_device_info *dev_info);
/** These functions are implemented herein, and are called by the chipset
* driver to notify us about specific events.
* initialized.
*/
if (!dev->responded_to_device_create) {
+ struct visorchipset_device_info dev_info;
+
+ if (!visorchipset_get_device_info(dev->chipset_bus_no,
+ dev->chipset_dev_no,
+ &dev_info))
+ /* hmm, what to do here */
+ return rc;
+
dev->responded_to_device_create = true;
if (chipset_responders.device_create)
- (*chipset_responders.device_create)(dev->chipset_bus_no,
- dev->chipset_dev_no,
- rc);
+ (*chipset_responders.device_create)(&dev_info, rc);
}
return rc;
}
*/
static int
create_visor_device(struct visorbus_devdata *devdata,
- unsigned long chipset_bus_no, unsigned long chipset_dev_no,
+ struct visorchipset_device_info *dev_info,
struct visorchipset_channel_info chan_info,
u64 partition_handle)
{
struct visorchannel *visorchannel = NULL;
struct visor_device *dev = NULL;
bool gotten = false, registered1 = false, registered2 = false;
+ u32 chipset_bus_no = dev_info->bus_no;
+ u32 chipset_dev_no = dev_info->dev_no;
POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
POSTCODE_SEVERITY_INFO);
* (NOT bus instance). That's why we need to include the bus
* number within the name.
*/
- dev_set_name(&dev->device, "vbus%lu:dev%lu",
+ dev_set_name(&dev->device, "vbus%u:dev%u",
chipset_bus_no, chipset_dev_no);
/* device_add does this:
}
static void
-chipset_device_create(u32 bus_no, u32 dev_no)
+chipset_device_create(struct visorchipset_device_info *dev_info)
{
- struct visorchipset_device_info dev_info;
struct visorchipset_bus_info bus_info;
struct visorbus_devdata *devdata = NULL;
int rc = -1;
+ u32 bus_no = dev_info->bus_no;
+ u32 dev_no = dev_info->dev_no;
POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
POSTCODE_SEVERITY_INFO);
if (entered_testing_mode)
return;
- if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
- goto away;
if (!visorchipset_get_bus_info(bus_no, &bus_info))
goto away;
if (visorbus_devicetest)
if (total_devices_created < MAXDEVICETEST) {
test_channel_infos[total_devices_created] =
- dev_info.chan_info;
+ dev_info->chan_info;
test_bus_nos[total_devices_created] = bus_no;
test_dev_nos[total_devices_created] = dev_no;
}
return;
}
devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
- rc = create_visor_device(devdata, bus_no, dev_no,
- dev_info.chan_info, bus_info.partition_handle);
+ rc = create_visor_device(devdata, dev_info,
+ dev_info->chan_info,
+ bus_info.partition_handle);
POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
POSTCODE_SEVERITY_INFO);
if (rc < 0)
if (chipset_responders.device_create)
- (*chipset_responders.device_create)(bus_no, dev_no, rc);
+ (*chipset_responders.device_create)(dev_info, rc);
}
static void
-chipset_device_destroy(u32 bus_no, u32 dev_no)
+chipset_device_destroy(struct visorchipset_device_info *dev_info)
{
- struct visorchipset_device_info dev_info;
struct visor_device *dev;
int rc = -1;
if (entered_testing_mode)
return;
- if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
- goto away;
- dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
+ dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr);
if (!dev)
goto away;
rc = 0;
return;
if (chipset_responders.device_destroy)
- (*chipset_responders.device_destroy) (bus_no, dev_no, rc);
+ (*chipset_responders.device_destroy) (dev_info, rc);
remove_visor_device(dev);
}
* completed.
*/
static void
-pause_state_change_complete(struct visor_device *dev, int status)
+pause_state_change_complete(struct visor_device *dev, int status,
+ void *info)
{
+ struct visorchipset_device_info *dev_info = info;
+
if (!dev->pausing)
return;
/* Notify the chipset driver that the pause is complete, which
* will presumably want to send some sort of response to the
* initiator. */
- (*chipset_responders.device_pause) (dev->chipset_bus_no,
- dev->chipset_dev_no, status);
+ (*chipset_responders.device_pause) (dev_info, status);
}
/* This is the callback function specified for a function driver, to
* completed.
*/
static void
-resume_state_change_complete(struct visor_device *dev, int status)
+resume_state_change_complete(struct visor_device *dev, int status,
+ void *info)
{
+ struct visorchipset_device_info *dev_info = info;
+
if (!dev->resuming)
return;
/* Notify the chipset driver that the resume is complete,
* which will presumably want to send some sort of response to
* the initiator. */
- (*chipset_responders.device_resume) (dev->chipset_bus_no,
- dev->chipset_dev_no, status);
+ (*chipset_responders.device_resume) (dev_info, status);
}
/* Tell the subordinate function driver for a specific device to pause
* callback function.
*/
static void
-initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
+initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
+ bool is_pause)
{
- struct visorchipset_device_info dev_info;
struct visor_device *dev = NULL;
int rc = -1, x;
struct visor_driver *drv = NULL;
- void (*notify_func)(u32 bus_no, u32 dev_no, int response) = NULL;
+ void (*notify_func)(struct visorchipset_device_info *dev_info,
+ int response) = NULL;
if (is_pause)
notify_func = chipset_responders.device_pause;
if (!notify_func)
goto away;
- if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
- goto away;
-
- dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
+ dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr);
if (!dev)
goto away;
goto away;
dev->pausing = true;
- x = drv->pause(dev, pause_state_change_complete);
+ x = drv->pause(dev, pause_state_change_complete,
+ (void *)dev_info);
} else {
/* This should be done at BUS resume time, but an
* existing problem prevents us from ever getting a bus
goto away;
dev->resuming = true;
- x = drv->resume(dev, resume_state_change_complete);
+ x = drv->resume(dev, resume_state_change_complete,
+ (void *)dev_info);
}
if (x < 0) {
if (is_pause)
away:
if (rc < 0) {
if (notify_func)
- (*notify_func)(bus_no, dev_no, rc);
+ (*notify_func)(dev_info, rc);
}
}
static void
-chipset_device_pause(u32 bus_no, u32 dev_no)
+chipset_device_pause(struct visorchipset_device_info *dev_info)
{
- initiate_chipset_device_pause_resume(bus_no, dev_no, true);
+ initiate_chipset_device_pause_resume(dev_info, true);
}
static void
-chipset_device_resume(u32 bus_no, u32 dev_no)
+chipset_device_resume(struct visorchipset_device_info *dev_info)
{
- initiate_chipset_device_pause_resume(bus_no, dev_no, false);
+ initiate_chipset_device_pause_resume(dev_info, false);
}
struct channel_size_info {
struct visorchipset_busdev_notifiers {
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);
- void (*device_resume)(u32 bus_no, u32 dev_no);
+ void (*device_create)(struct visorchipset_device_info *bus_info);
+ void (*device_destroy)(struct visorchipset_device_info *bus_info);
+ void (*device_pause)(struct visorchipset_device_info *bus_info);
+ void (*device_resume)(struct visorchipset_device_info *bus_info);
};
/* These functions live inside visorchipset, and will be called to indicate
struct visorchipset_busdev_responders {
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);
- void (*device_resume)(u32 bus_no, u32 dev_no, int response);
+ void (*device_create)(struct visorchipset_device_info *p, int response);
+ void (*device_destroy)(struct visorchipset_device_info *p,
+ int response);
+ void (*device_pause)(struct visorchipset_device_info *p, int response);
+ void (*device_resume)(struct visorchipset_device_info *p, int response);
};
/** Register functions (in the bus driver) to get called by visorchipset
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 device_create_response(struct visorchipset_device_info *p,
+ int response);
+static void device_destroy_response(struct visorchipset_device_info *p,
+ int response);
+static void device_resume_response(struct visorchipset_device_info *p,
+ int response);
-static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no,
- int response);
+static void
+visorchipset_device_pause_response(struct visorchipset_device_info *p,
+ int response);
static struct visorchipset_busdev_responders busdev_responders = {
.bus_create = bus_create_response,
static void
device_changestate_responder(enum controlvm_id cmd_id,
- u32 bus_no, u32 dev_no, int response,
+ struct visorchipset_device_info *p, int response,
struct spar_segment_state response_state)
{
- struct visorchipset_device_info *p;
struct controlvm_message outmsg;
+ u32 bus_no = p->bus_no;
+ u32 dev_no = p->dev_no;
- p = device_find(&dev_info_list, bus_no, dev_no);
if (!p)
return;
if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
}
static void
-device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
+device_responder(enum controlvm_id cmd_id, struct visorchipset_device_info *p,
+ int response)
{
- struct visorchipset_device_info *p;
bool need_clear = false;
- p = device_find(&dev_info_list, bus_no, dev_no);
if (!p)
return;
if (response >= 0) {
}
static void
-device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
+device_epilog(struct visorchipset_device_info *dev_info,
+ 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;
bool notified = false;
+ u32 bus_no = dev_info->bus_no;
+ u32 dev_no = dev_info->dev_no;
- struct visorchipset_device_info *dev_info =
- device_find(&dev_info_list, bus_no, dev_no);
char *envp[] = {
"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
NULL
switch (cmd) {
case CONTROLVM_DEVICE_CREATE:
if (notifiers->device_create) {
- (*notifiers->device_create) (bus_no, dev_no);
+ (*notifiers->device_create) (dev_info);
notified = true;
}
break;
state.operating ==
segment_state_running.operating) {
if (notifiers->device_resume) {
- (*notifiers->device_resume) (bus_no,
- dev_no);
+ (*notifiers->device_resume) (dev_info);
notified = true;
}
}
* where server is lost
*/
if (notifiers->device_pause) {
- (*notifiers->device_pause) (bus_no,
- dev_no);
+ (*notifiers->device_pause) (dev_info);
notified = true;
}
} else if (state.alive == segment_state_paused.alive &&
break;
case CONTROLVM_DEVICE_DESTROY:
if (notifiers->device_destroy) {
- (*notifiers->device_destroy) (bus_no, dev_no);
+ (*notifiers->device_destroy) (dev_info);
notified = true;
}
break;
*/
;
else
- device_responder(cmd, bus_no, dev_no, response);
+ device_responder(cmd, dev_info, response);
up(¬ifier_lock);
}
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);
}
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);
}
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);
}
}
static void
-device_create_response(u32 bus_no, u32 dev_no, int response)
+device_create_response(struct visorchipset_device_info *dev_info, int response)
{
- device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
+ device_responder(CONTROLVM_DEVICE_CREATE, dev_info, response);
}
static void
-device_destroy_response(u32 bus_no, u32 dev_no, int response)
+device_destroy_response(struct visorchipset_device_info *dev_info, int response)
{
- device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
+ device_responder(CONTROLVM_DEVICE_DESTROY, dev_info, response);
}
static void
-visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
+visorchipset_device_pause_response(struct visorchipset_device_info *dev_info,
+ int response)
{
device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
- bus_no, dev_no, response,
+ dev_info, response,
segment_state_standby);
}
static void
-device_resume_response(u32 bus_no, u32 dev_no, int response)
+device_resume_response(struct visorchipset_device_info *dev_info, int response)
{
device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
- bus_no, dev_no, response,
+ dev_info, response,
segment_state_running);
}
EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
bool
-visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
+visorchipset_set_device_context(struct visorchipset_device_info *p,
+ void *context)
{
- struct visorchipset_device_info *p;
-
- p = device_find(&dev_info_list, bus_no, dev_no);
-
if (!p)
return false;
p->bus_driver_context = context;