3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
19 #include "visorchipset.h"
20 #include "procobjecttree.h"
21 #include "visorchannel.h"
22 #include "periodic_work.h"
26 #include "controlvmcompletionstatus.h"
27 #include "guestlinuxdebug.h"
29 #include <linux/nls.h>
30 #include <linux/netdevice.h>
31 #include <linux/platform_device.h>
32 #include <linux/uuid.h>
34 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
35 #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for
36 * vnic loopback test */
37 #define TEST_VNIC_SWITCHNO 1
38 #define TEST_VNIC_BUSNO 9
40 #define MAX_NAME_SIZE 128
41 #define MAX_IP_SIZE 50
42 #define MAXOUTSTANDINGCHANNELCOMMAND 256
43 #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1
44 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
46 /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
47 * we switch to slow polling mode. As soon as we get a controlvm
48 * message, we switch back to fast polling mode.
50 #define MIN_IDLE_SECONDS 10
51 static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
52 static ulong most_recent_message_jiffies; /* when we got our last
53 * controlvm message */
62 static int serverregistered;
63 static int clientregistered;
65 #define MAX_CHIPSET_EVENTS 2
66 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
68 static struct delayed_work periodic_controlvm_work;
69 static struct workqueue_struct *periodic_controlvm_workqueue;
70 static DEFINE_SEMAPHORE(notifier_lock);
72 static struct controlvm_message_header g_diag_msg_hdr;
73 static struct controlvm_message_header g_chipset_msg_hdr;
74 static struct controlvm_message_header g_del_dump_msg_hdr;
75 static const uuid_le spar_diag_pool_channel_protocol_uuid =
76 SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
77 /* 0xffffff is an invalid Bus/Device number */
78 static ulong g_diagpool_bus_no = 0xffffff;
79 static ulong g_diagpool_dev_no = 0xffffff;
80 static struct controlvm_message_packet g_devicechangestate_packet;
82 /* Only VNIC and VHBA channels are sent to visorclientbus (aka
85 #define FOR_VISORHACKBUS(channel_type_guid) \
86 (((uuid_le_cmp(channel_type_guid,\
87 spar_vnic_channel_protocol_uuid) == 0) ||\
88 (uuid_le_cmp(channel_type_guid,\
89 spar_vhba_channel_protocol_uuid) == 0)))
90 #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
92 #define is_diagpool_channel(channel_type_guid) \
93 (uuid_le_cmp(channel_type_guid,\
94 spar_diag_pool_channel_protocol_uuid) == 0)
96 static LIST_HEAD(bus_info_list);
97 static LIST_HEAD(dev_info_list);
99 static struct visorchannel *controlvm_channel;
101 /* Manages the request payload in the controlvm channel */
102 static struct controlvm_payload_info {
103 u8 __iomem *ptr; /* pointer to base address of payload pool */
104 u64 offset; /* offset from beginning of controlvm
105 * channel to beginning of payload * pool */
106 u32 bytes; /* number of bytes in payload pool */
107 } controlvm_payload_info;
109 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
110 * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
112 static struct livedump_info {
113 struct controlvm_message_header dumpcapture_header;
114 struct controlvm_message_header gettextdump_header;
115 struct controlvm_message_header dumpcomplete_header;
116 BOOL gettextdump_outstanding;
119 atomic_t buffers_in_use;
123 /* The following globals are used to handle the scenario where we are unable to
124 * offload the payload from a controlvm message due to memory requirements. In
125 * this scenario, we simply stash the controlvm message, then attempt to
126 * process it again the next time controlvm_periodic_work() runs.
128 static struct controlvm_message ControlVm_Pending_Msg;
129 static BOOL ControlVm_Pending_Msg_Valid = FALSE;
131 /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
132 * TRANSMIT_FILE PutFile payloads.
134 static struct kmem_cache *Putfile_buffer_list_pool;
135 static const char Putfile_buffer_list_pool_name[] =
136 "controlvm_putfile_buffer_list_pool";
138 /* This identifies a data buffer that has been received via a controlvm messages
139 * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
141 struct putfile_buffer_entry {
142 struct list_head next; /* putfile_buffer_entry list */
143 struct parser_context *parser_ctx; /* points to input data buffer */
146 /* List of struct putfile_request *, via next_putfile_request member.
147 * Each entry in this list identifies an outstanding TRANSMIT_FILE
150 static LIST_HEAD(Putfile_request_list);
152 /* This describes a buffer and its current state of transfer (e.g., how many
153 * bytes have already been supplied as putfile data, and how many bytes are
154 * remaining) for a putfile_request.
156 struct putfile_active_buffer {
157 /* a payload from a controlvm message, containing a file data buffer */
158 struct parser_context *parser_ctx;
159 /* points within data area of parser_ctx to next byte of data */
161 /* # bytes left from <pnext> to the end of this data buffer */
162 size_t bytes_remaining;
165 #define PUTFILE_REQUEST_SIG 0x0906101302281211
166 /* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
167 * conversation. Structs of this type are dynamically linked into
168 * <Putfile_request_list>.
170 struct putfile_request {
171 u64 sig; /* PUTFILE_REQUEST_SIG */
173 /* header from original TransmitFile request */
174 struct controlvm_message_header controlvm_header;
175 u64 file_request_number; /* from original TransmitFile request */
177 /* link to next struct putfile_request */
178 struct list_head next_putfile_request;
180 /* most-recent sequence number supplied via a controlvm message */
181 u64 data_sequence_number;
183 /* head of putfile_buffer_entry list, which describes the data to be
184 * supplied as putfile data;
185 * - this list is added to when controlvm messages come in that supply
187 * - this list is removed from via the hotplug program that is actually
188 * consuming these buffers to write as file data */
189 struct list_head input_buffer_list;
190 spinlock_t req_list_lock; /* lock for input_buffer_list */
192 /* waiters for input_buffer_list to go non-empty */
193 wait_queue_head_t input_buffer_wq;
195 /* data not yet read within current putfile_buffer_entry */
196 struct putfile_active_buffer active_buf;
198 /* <0 = failed, 0 = in-progress, >0 = successful; */
199 /* note that this must be set with req_list_lock, and if you set <0, */
200 /* it is your responsibility to also free up all of the other objects */
201 /* in this struct (like input_buffer_list, active_buf.parser_ctx) */
202 /* before releasing the lock */
203 int completion_status;
206 static atomic_t Visorchipset_cache_buffers_in_use = ATOMIC_INIT(0);
208 struct parahotplug_request {
209 struct list_head list;
211 unsigned long expiration;
212 struct controlvm_message msg;
215 static LIST_HEAD(Parahotplug_request_list);
216 static DEFINE_SPINLOCK(Parahotplug_request_list_lock); /* lock for above */
217 static void parahotplug_process_list(void);
219 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
220 * CONTROLVM_REPORTEVENT.
222 static struct visorchipset_busdev_notifiers BusDev_Server_Notifiers;
223 static struct visorchipset_busdev_notifiers BusDev_Client_Notifiers;
225 static void bus_create_response(ulong busNo, int response);
226 static void bus_destroy_response(ulong busNo, int response);
227 static void device_create_response(ulong busNo, ulong devNo, int response);
228 static void device_destroy_response(ulong busNo, ulong devNo, int response);
229 static void device_resume_response(ulong busNo, ulong devNo, int response);
231 static struct visorchipset_busdev_responders BusDev_Responders = {
232 .bus_create = bus_create_response,
233 .bus_destroy = bus_destroy_response,
234 .device_create = device_create_response,
235 .device_destroy = device_destroy_response,
236 .device_pause = visorchipset_device_pause_response,
237 .device_resume = device_resume_response,
240 /* info for /dev/visorchipset */
241 static dev_t MajorDev = -1; /**< indicates major num for device */
243 /* prototypes for attributes */
244 static ssize_t toolaction_show(struct device *dev,
245 struct device_attribute *attr, char *buf);
246 static ssize_t toolaction_store(struct device *dev,
247 struct device_attribute *attr, const char *buf, size_t count);
248 static DEVICE_ATTR_RW(toolaction);
250 static ssize_t boottotool_show(struct device *dev,
251 struct device_attribute *attr, char *buf);
252 static ssize_t boottotool_store(struct device *dev,
253 struct device_attribute *attr, const char *buf, size_t count);
254 static DEVICE_ATTR_RW(boottotool);
256 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
258 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
259 const char *buf, size_t count);
260 static DEVICE_ATTR_RW(error);
262 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
264 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
265 const char *buf, size_t count);
266 static DEVICE_ATTR_RW(textid);
268 static ssize_t remaining_steps_show(struct device *dev,
269 struct device_attribute *attr, char *buf);
270 static ssize_t remaining_steps_store(struct device *dev,
271 struct device_attribute *attr, const char *buf, size_t count);
272 static DEVICE_ATTR_RW(remaining_steps);
274 static ssize_t chipsetready_store(struct device *dev,
275 struct device_attribute *attr, const char *buf, size_t count);
276 static DEVICE_ATTR_WO(chipsetready);
278 static ssize_t devicedisabled_store(struct device *dev,
279 struct device_attribute *attr, const char *buf, size_t count);
280 static DEVICE_ATTR_WO(devicedisabled);
282 static ssize_t deviceenabled_store(struct device *dev,
283 struct device_attribute *attr, const char *buf, size_t count);
284 static DEVICE_ATTR_WO(deviceenabled);
286 static struct attribute *visorchipset_install_attrs[] = {
287 &dev_attr_toolaction.attr,
288 &dev_attr_boottotool.attr,
289 &dev_attr_error.attr,
290 &dev_attr_textid.attr,
291 &dev_attr_remaining_steps.attr,
295 static struct attribute_group visorchipset_install_group = {
297 .attrs = visorchipset_install_attrs
300 static struct attribute *visorchipset_guest_attrs[] = {
301 &dev_attr_chipsetready.attr,
305 static struct attribute_group visorchipset_guest_group = {
307 .attrs = visorchipset_guest_attrs
310 static struct attribute *visorchipset_parahotplug_attrs[] = {
311 &dev_attr_devicedisabled.attr,
312 &dev_attr_deviceenabled.attr,
316 static struct attribute_group visorchipset_parahotplug_group = {
317 .name = "parahotplug",
318 .attrs = visorchipset_parahotplug_attrs
321 static const struct attribute_group *visorchipset_dev_groups[] = {
322 &visorchipset_install_group,
323 &visorchipset_guest_group,
324 &visorchipset_parahotplug_group,
328 /* /sys/devices/platform/visorchipset */
329 static struct platform_device Visorchipset_platform_device = {
330 .name = "visorchipset",
332 .dev.groups = visorchipset_dev_groups,
335 /* Function prototypes */
336 static void controlvm_respond(struct controlvm_message_header *msgHdr,
338 static void controlvm_respond_chipset_init(
339 struct controlvm_message_header *msgHdr, int response,
340 enum ultra_chipset_feature features);
341 static void controlvm_respond_physdev_changestate(
342 struct controlvm_message_header *msgHdr, int response,
343 struct spar_segment_state state);
345 static ssize_t toolaction_show(struct device *dev,
346 struct device_attribute *attr,
351 visorchannel_read(controlvm_channel,
352 offsetof(struct spar_controlvm_channel_protocol,
353 tool_action), &toolAction, sizeof(u8));
354 return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
357 static ssize_t toolaction_store(struct device *dev,
358 struct device_attribute *attr,
359 const char *buf, size_t count)
364 if (kstrtou8(buf, 10, &toolAction) != 0)
367 ret = visorchannel_write(controlvm_channel,
368 offsetof(struct spar_controlvm_channel_protocol, tool_action),
369 &toolAction, sizeof(u8));
376 static ssize_t boottotool_show(struct device *dev,
377 struct device_attribute *attr,
380 struct efi_spar_indication efiSparIndication;
382 visorchannel_read(controlvm_channel,
383 offsetof(struct spar_controlvm_channel_protocol,
384 efi_spar_ind), &efiSparIndication,
385 sizeof(struct efi_spar_indication));
386 return scnprintf(buf, PAGE_SIZE, "%u\n",
387 efiSparIndication.boot_to_tool);
390 static ssize_t boottotool_store(struct device *dev,
391 struct device_attribute *attr,
392 const char *buf, size_t count)
395 struct efi_spar_indication efiSparIndication;
397 if (kstrtoint(buf, 10, &val) != 0)
400 efiSparIndication.boot_to_tool = val;
401 ret = visorchannel_write(controlvm_channel,
402 offsetof(struct spar_controlvm_channel_protocol,
404 &(efiSparIndication),
405 sizeof(struct efi_spar_indication));
412 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
417 visorchannel_read(controlvm_channel, offsetof(
418 struct spar_controlvm_channel_protocol, installation_error),
419 &error, sizeof(u32));
420 return scnprintf(buf, PAGE_SIZE, "%i\n", error);
423 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
424 const char *buf, size_t count)
429 if (kstrtou32(buf, 10, &error) != 0)
432 ret = visorchannel_write(controlvm_channel,
433 offsetof(struct spar_controlvm_channel_protocol,
435 &error, sizeof(u32));
441 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
446 visorchannel_read(controlvm_channel, offsetof(
447 struct spar_controlvm_channel_protocol, installation_text_id),
448 &textId, sizeof(u32));
449 return scnprintf(buf, PAGE_SIZE, "%i\n", textId);
452 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
453 const char *buf, size_t count)
458 if (kstrtou32(buf, 10, &textId) != 0)
461 ret = visorchannel_write(controlvm_channel,
462 offsetof(struct spar_controlvm_channel_protocol,
463 installation_text_id),
464 &textId, sizeof(u32));
470 static ssize_t remaining_steps_show(struct device *dev,
471 struct device_attribute *attr, char *buf)
475 visorchannel_read(controlvm_channel,
476 offsetof(struct spar_controlvm_channel_protocol,
477 installation_remaining_steps),
480 return scnprintf(buf, PAGE_SIZE, "%hu\n", remainingSteps);
483 static ssize_t remaining_steps_store(struct device *dev,
484 struct device_attribute *attr, const char *buf, size_t count)
489 if (kstrtou16(buf, 10, &remainingSteps) != 0)
492 ret = visorchannel_write(controlvm_channel,
493 offsetof(struct spar_controlvm_channel_protocol,
494 installation_remaining_steps),
495 &remainingSteps, sizeof(u16));
502 bus_info_clear(void *v)
504 struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v);
509 kfree(p->description);
510 p->description = NULL;
512 p->state.created = 0;
513 memset(p, 0, sizeof(struct visorchipset_bus_info));
517 dev_info_clear(void *v)
519 struct visorchipset_device_info *p =
520 (struct visorchipset_device_info *)(v);
522 p->state.created = 0;
523 memset(p, 0, sizeof(struct visorchipset_device_info));
527 check_chipset_events(void)
531 /* Check events to determine if response should be sent */
532 for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
533 send_msg &= chipset_events[i];
538 clear_chipset_events(void)
541 /* Clear chipset_events */
542 for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
543 chipset_events[i] = 0;
547 visorchipset_register_busdev_server(
548 struct visorchipset_busdev_notifiers *notifiers,
549 struct visorchipset_busdev_responders *responders,
550 struct ultra_vbus_deviceinfo *driver_info)
552 down(¬ifier_lock);
554 memset(&BusDev_Server_Notifiers, 0,
555 sizeof(BusDev_Server_Notifiers));
556 serverregistered = 0; /* clear flag */
558 BusDev_Server_Notifiers = *notifiers;
559 serverregistered = 1; /* set flag */
562 *responders = BusDev_Responders;
564 bus_device_info_init(driver_info, "chipset", "visorchipset",
569 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
572 visorchipset_register_busdev_client(
573 struct visorchipset_busdev_notifiers *notifiers,
574 struct visorchipset_busdev_responders *responders,
575 struct ultra_vbus_deviceinfo *driver_info)
577 down(¬ifier_lock);
579 memset(&BusDev_Client_Notifiers, 0,
580 sizeof(BusDev_Client_Notifiers));
581 clientregistered = 0; /* clear flag */
583 BusDev_Client_Notifiers = *notifiers;
584 clientregistered = 1; /* set flag */
587 *responders = BusDev_Responders;
589 bus_device_info_init(driver_info, "chipset(bolts)",
590 "visorchipset", VERSION, NULL);
593 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
596 cleanup_controlvm_structures(void)
598 struct visorchipset_bus_info *bi, *tmp_bi;
599 struct visorchipset_device_info *di, *tmp_di;
601 list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
603 list_del(&bi->entry);
607 list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
609 list_del(&di->entry);
615 chipset_init(struct controlvm_message *inmsg)
617 static int chipset_inited;
618 enum ultra_chipset_feature features = 0;
619 int rc = CONTROLVM_RESP_SUCCESS;
621 POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
622 if (chipset_inited) {
623 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
627 POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
629 /* Set features to indicate we support parahotplug (if Command
630 * also supports it). */
632 inmsg->cmd.init_chipset.
633 features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG;
635 /* Set the "reply" bit so Command knows this is a
636 * features-aware driver. */
637 features |= ULTRA_CHIPSET_FEATURE_REPLY;
641 cleanup_controlvm_structures();
642 if (inmsg->hdr.flags.response_expected)
643 controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
647 controlvm_init_response(struct controlvm_message *msg,
648 struct controlvm_message_header *msgHdr, int response)
650 memset(msg, 0, sizeof(struct controlvm_message));
651 memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header));
652 msg->hdr.payload_bytes = 0;
653 msg->hdr.payload_vm_offset = 0;
654 msg->hdr.payload_max_bytes = 0;
656 msg->hdr.flags.failed = 1;
657 msg->hdr.completion_status = (u32) (-response);
662 controlvm_respond(struct controlvm_message_header *msgHdr, int response)
664 struct controlvm_message outmsg;
666 controlvm_init_response(&outmsg, msgHdr, response);
667 /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
668 * back the deviceChangeState structure in the packet. */
669 if (msgHdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
670 g_devicechangestate_packet.device_change_state.bus_no ==
672 g_devicechangestate_packet.device_change_state.dev_no ==
674 outmsg.cmd = g_devicechangestate_packet;
675 if (outmsg.hdr.flags.test_message == 1)
678 if (!visorchannel_signalinsert(controlvm_channel,
679 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
685 controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr,
687 enum ultra_chipset_feature features)
689 struct controlvm_message outmsg;
691 controlvm_init_response(&outmsg, msgHdr, response);
692 outmsg.cmd.init_chipset.features = features;
693 if (!visorchannel_signalinsert(controlvm_channel,
694 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
699 static void controlvm_respond_physdev_changestate(
700 struct controlvm_message_header *msgHdr, int response,
701 struct spar_segment_state state)
703 struct controlvm_message outmsg;
705 controlvm_init_response(&outmsg, msgHdr, response);
706 outmsg.cmd.device_change_state.state = state;
707 outmsg.cmd.device_change_state.flags.phys_device = 1;
708 if (!visorchannel_signalinsert(controlvm_channel,
709 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
715 visorchipset_save_message(struct controlvm_message *msg,
716 enum crash_obj_type type)
718 u32 crash_msg_offset;
721 /* get saved message count */
722 if (visorchannel_read(controlvm_channel,
723 offsetof(struct spar_controlvm_channel_protocol,
724 saved_crash_message_count),
725 &crash_msg_count, sizeof(u16)) < 0) {
726 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
727 POSTCODE_SEVERITY_ERR);
731 if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
732 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
734 POSTCODE_SEVERITY_ERR);
738 /* get saved crash message offset */
739 if (visorchannel_read(controlvm_channel,
740 offsetof(struct spar_controlvm_channel_protocol,
741 saved_crash_message_offset),
742 &crash_msg_offset, sizeof(u32)) < 0) {
743 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
744 POSTCODE_SEVERITY_ERR);
748 if (type == CRASH_BUS) {
749 if (visorchannel_write(controlvm_channel,
752 sizeof(struct controlvm_message)) < 0) {
753 POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
754 POSTCODE_SEVERITY_ERR);
758 if (visorchannel_write(controlvm_channel,
760 sizeof(struct controlvm_message), msg,
761 sizeof(struct controlvm_message)) < 0) {
762 POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
763 POSTCODE_SEVERITY_ERR);
768 EXPORT_SYMBOL_GPL(visorchipset_save_message);
771 bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response)
773 struct visorchipset_bus_info *p = NULL;
774 BOOL need_clear = FALSE;
776 p = findbus(&bus_info_list, bus_no);
781 if ((cmd_id == CONTROLVM_BUS_CREATE) &&
782 (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
783 /* undo the row we just created... */
784 delbusdevices(&dev_info_list, bus_no);
786 if (cmd_id == CONTROLVM_BUS_CREATE)
787 p->state.created = 1;
788 if (cmd_id == CONTROLVM_BUS_DESTROY)
792 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
793 return; /* no controlvm response needed */
794 if (p->pending_msg_hdr.id != (u32)cmd_id)
796 controlvm_respond(&p->pending_msg_hdr, response);
797 p->pending_msg_hdr.id = CONTROLVM_INVALID;
800 delbusdevices(&dev_info_list, bus_no);
805 device_changestate_responder(enum controlvm_id cmd_id,
806 ulong bus_no, ulong dev_no, int response,
807 struct spar_segment_state response_state)
809 struct visorchipset_device_info *p = NULL;
810 struct controlvm_message outmsg;
812 p = finddevice(&dev_info_list, bus_no, dev_no);
815 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
816 return; /* no controlvm response needed */
817 if (p->pending_msg_hdr.id != cmd_id)
820 controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
822 outmsg.cmd.device_change_state.bus_no = bus_no;
823 outmsg.cmd.device_change_state.dev_no = dev_no;
824 outmsg.cmd.device_change_state.state = response_state;
826 if (!visorchannel_signalinsert(controlvm_channel,
827 CONTROLVM_QUEUE_REQUEST, &outmsg))
830 p->pending_msg_hdr.id = CONTROLVM_INVALID;
834 device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no,
837 struct visorchipset_device_info *p = NULL;
838 BOOL need_clear = FALSE;
840 p = finddevice(&dev_info_list, bus_no, dev_no);
844 if (cmd_id == CONTROLVM_DEVICE_CREATE)
845 p->state.created = 1;
846 if (cmd_id == CONTROLVM_DEVICE_DESTROY)
850 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
851 return; /* no controlvm response needed */
853 if (p->pending_msg_hdr.id != (u32)cmd_id)
856 controlvm_respond(&p->pending_msg_hdr, response);
857 p->pending_msg_hdr.id = CONTROLVM_INVALID;
863 bus_epilog(u32 bus_no,
864 u32 cmd, struct controlvm_message_header *msg_hdr,
865 int response, BOOL need_response)
867 BOOL notified = FALSE;
869 struct visorchipset_bus_info *bus_info = findbus(&bus_info_list,
876 memcpy(&bus_info->pending_msg_hdr, msg_hdr,
877 sizeof(struct controlvm_message_header));
879 bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
882 down(¬ifier_lock);
883 if (response == CONTROLVM_RESP_SUCCESS) {
885 case CONTROLVM_BUS_CREATE:
886 /* We can't tell from the bus_create
887 * information which of our 2 bus flavors the
888 * devices on this bus will ultimately end up.
889 * FORTUNATELY, it turns out it is harmless to
890 * send the bus_create to both of them. We can
891 * narrow things down a little bit, though,
892 * because we know: - BusDev_Server can handle
893 * either server or client devices
894 * - BusDev_Client can handle ONLY client
896 if (BusDev_Server_Notifiers.bus_create) {
897 (*BusDev_Server_Notifiers.bus_create) (bus_no);
900 if ((!bus_info->flags.server) /*client */ &&
901 BusDev_Client_Notifiers.bus_create) {
902 (*BusDev_Client_Notifiers.bus_create) (bus_no);
906 case CONTROLVM_BUS_DESTROY:
907 if (BusDev_Server_Notifiers.bus_destroy) {
908 (*BusDev_Server_Notifiers.bus_destroy) (bus_no);
911 if ((!bus_info->flags.server) /*client */ &&
912 BusDev_Client_Notifiers.bus_destroy) {
913 (*BusDev_Client_Notifiers.bus_destroy) (bus_no);
920 /* The callback function just called above is responsible
921 * for calling the appropriate visorchipset_busdev_responders
922 * function, which will call bus_responder()
926 bus_responder(cmd, bus_no, response);
931 device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
932 struct controlvm_message_header *msg_hdr, int response,
933 BOOL need_response, BOOL for_visorbus)
935 struct visorchipset_busdev_notifiers *notifiers = NULL;
936 BOOL notified = FALSE;
938 struct visorchipset_device_info *dev_info =
939 finddevice(&dev_info_list, bus_no, dev_no);
941 "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
949 notifiers = &BusDev_Server_Notifiers;
951 notifiers = &BusDev_Client_Notifiers;
953 memcpy(&dev_info->pending_msg_hdr, msg_hdr,
954 sizeof(struct controlvm_message_header));
956 dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
959 down(¬ifier_lock);
962 case CONTROLVM_DEVICE_CREATE:
963 if (notifiers->device_create) {
964 (*notifiers->device_create) (bus_no, dev_no);
968 case CONTROLVM_DEVICE_CHANGESTATE:
969 /* ServerReady / ServerRunning / SegmentStateRunning */
970 if (state.alive == segment_state_running.alive &&
972 segment_state_running.operating) {
973 if (notifiers->device_resume) {
974 (*notifiers->device_resume) (bus_no,
979 /* ServerNotReady / ServerLost / SegmentStateStandby */
980 else if (state.alive == segment_state_standby.alive &&
982 segment_state_standby.operating) {
983 /* technically this is standby case
984 * where server is lost
986 if (notifiers->device_pause) {
987 (*notifiers->device_pause) (bus_no,
991 } else if (state.alive == segment_state_paused.alive &&
993 segment_state_paused.operating) {
994 /* this is lite pause where channel is
995 * still valid just 'pause' of it
997 if (bus_no == g_diagpool_bus_no &&
998 dev_no == g_diagpool_dev_no) {
999 /* this will trigger the
1000 * diag_shutdown.sh script in
1001 * the visorchipset hotplug */
1003 (&Visorchipset_platform_device.dev.
1004 kobj, KOBJ_ONLINE, envp);
1008 case CONTROLVM_DEVICE_DESTROY:
1009 if (notifiers->device_destroy) {
1010 (*notifiers->device_destroy) (bus_no, dev_no);
1017 /* The callback function just called above is responsible
1018 * for calling the appropriate visorchipset_busdev_responders
1019 * function, which will call device_responder()
1023 device_responder(cmd, bus_no, dev_no, response);
1028 bus_create(struct controlvm_message *inmsg)
1030 struct controlvm_message_packet *cmd = &inmsg->cmd;
1031 ulong bus_no = cmd->create_bus.bus_no;
1032 int rc = CONTROLVM_RESP_SUCCESS;
1033 struct visorchipset_bus_info *bus_info = NULL;
1035 bus_info = findbus(&bus_info_list, bus_no);
1036 if (bus_info && (bus_info->state.created == 1)) {
1037 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
1038 POSTCODE_SEVERITY_ERR);
1039 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1042 bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
1044 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
1045 POSTCODE_SEVERITY_ERR);
1046 rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
1050 INIT_LIST_HEAD(&bus_info->entry);
1051 bus_info->bus_no = bus_no;
1052 bus_info->dev_no = cmd->create_bus.dev_count;
1054 POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
1056 if (inmsg->hdr.flags.test_message == 1)
1057 bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
1059 bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
1061 bus_info->flags.server = inmsg->hdr.flags.server;
1062 bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
1063 bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
1064 bus_info->chan_info.channel_type_uuid =
1065 cmd->create_bus.bus_data_type_uuid;
1066 bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
1068 list_add(&bus_info->entry, &bus_info_list);
1070 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
1073 bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
1074 rc, inmsg->hdr.flags.response_expected == 1);
1078 bus_destroy(struct controlvm_message *inmsg)
1080 struct controlvm_message_packet *cmd = &inmsg->cmd;
1081 ulong bus_no = cmd->destroy_bus.bus_no;
1082 struct visorchipset_bus_info *bus_info;
1083 int rc = CONTROLVM_RESP_SUCCESS;
1085 bus_info = findbus(&bus_info_list, bus_no);
1087 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1088 else if (bus_info->state.created == 0)
1089 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1091 bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
1092 rc, inmsg->hdr.flags.response_expected == 1);
1096 bus_configure(struct controlvm_message *inmsg,
1097 struct parser_context *parser_ctx)
1099 struct controlvm_message_packet *cmd = &inmsg->cmd;
1100 ulong bus_no = cmd->configure_bus.bus_no;
1101 struct visorchipset_bus_info *bus_info = NULL;
1102 int rc = CONTROLVM_RESP_SUCCESS;
1105 bus_no = cmd->configure_bus.bus_no;
1106 POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
1107 POSTCODE_SEVERITY_INFO);
1109 bus_info = findbus(&bus_info_list, bus_no);
1111 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1112 POSTCODE_SEVERITY_ERR);
1113 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1114 } else if (bus_info->state.created == 0) {
1115 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1116 POSTCODE_SEVERITY_ERR);
1117 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1118 } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
1119 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1120 POSTCODE_SEVERITY_ERR);
1121 rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
1123 bus_info->partition_handle = cmd->configure_bus.guest_handle;
1124 bus_info->partition_uuid = parser_id_get(parser_ctx);
1125 parser_param_start(parser_ctx, PARSERSTRING_NAME);
1126 bus_info->name = parser_string_get(parser_ctx);
1128 visorchannel_uuid_id(&bus_info->partition_uuid, s);
1129 POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
1130 POSTCODE_SEVERITY_INFO);
1132 bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
1133 rc, inmsg->hdr.flags.response_expected == 1);
1137 my_device_create(struct controlvm_message *inmsg)
1139 struct controlvm_message_packet *cmd = &inmsg->cmd;
1140 ulong bus_no = cmd->create_device.bus_no;
1141 ulong dev_no = cmd->create_device.dev_no;
1142 struct visorchipset_device_info *dev_info = NULL;
1143 struct visorchipset_bus_info *bus_info = NULL;
1144 int rc = CONTROLVM_RESP_SUCCESS;
1146 dev_info = finddevice(&dev_info_list, bus_no, dev_no);
1147 if (dev_info && (dev_info->state.created == 1)) {
1148 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1149 POSTCODE_SEVERITY_ERR);
1150 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1153 bus_info = findbus(&bus_info_list, bus_no);
1155 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1156 POSTCODE_SEVERITY_ERR);
1157 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1160 if (bus_info->state.created == 0) {
1161 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1162 POSTCODE_SEVERITY_ERR);
1163 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1166 dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
1168 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1169 POSTCODE_SEVERITY_ERR);
1170 rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
1174 INIT_LIST_HEAD(&dev_info->entry);
1175 dev_info->bus_no = bus_no;
1176 dev_info->dev_no = dev_no;
1177 dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
1178 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
1179 POSTCODE_SEVERITY_INFO);
1181 if (inmsg->hdr.flags.test_message == 1)
1182 dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
1184 dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
1185 dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
1186 dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
1187 dev_info->chan_info.channel_type_uuid =
1188 cmd->create_device.data_type_uuid;
1189 dev_info->chan_info.intr = cmd->create_device.intr;
1190 list_add(&dev_info->entry, &dev_info_list);
1191 POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
1192 POSTCODE_SEVERITY_INFO);
1194 /* get the bus and devNo for DiagPool channel */
1196 is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
1197 g_diagpool_bus_no = bus_no;
1198 g_diagpool_dev_no = dev_no;
1200 device_epilog(bus_no, dev_no, segment_state_running,
1201 CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
1202 inmsg->hdr.flags.response_expected == 1,
1203 FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
1207 my_device_changestate(struct controlvm_message *inmsg)
1209 struct controlvm_message_packet *cmd = &inmsg->cmd;
1210 ulong bus_no = cmd->device_change_state.bus_no;
1211 ulong dev_no = cmd->device_change_state.dev_no;
1212 struct spar_segment_state state = cmd->device_change_state.state;
1213 struct visorchipset_device_info *dev_info = NULL;
1214 int rc = CONTROLVM_RESP_SUCCESS;
1216 dev_info = finddevice(&dev_info_list, bus_no, dev_no);
1218 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
1219 POSTCODE_SEVERITY_ERR);
1220 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1221 } else if (dev_info->state.created == 0) {
1222 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
1223 POSTCODE_SEVERITY_ERR);
1224 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1226 if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
1227 device_epilog(bus_no, dev_no, state,
1228 CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
1229 inmsg->hdr.flags.response_expected == 1,
1231 dev_info->chan_info.channel_type_uuid));
1235 my_device_destroy(struct controlvm_message *inmsg)
1237 struct controlvm_message_packet *cmd = &inmsg->cmd;
1238 ulong busNo = cmd->destroy_device.bus_no;
1239 ulong devNo = cmd->destroy_device.dev_no;
1240 struct visorchipset_device_info *pDevInfo = NULL;
1241 int rc = CONTROLVM_RESP_SUCCESS;
1243 pDevInfo = finddevice(&dev_info_list, busNo, devNo);
1245 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1248 if (pDevInfo->state.created == 0)
1249 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1252 if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo)
1253 device_epilog(busNo, devNo, segment_state_running,
1254 CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
1255 inmsg->hdr.flags.response_expected == 1,
1257 pDevInfo->chan_info.channel_type_uuid));
1260 /* When provided with the physical address of the controlvm channel
1261 * (phys_addr), the offset to the payload area we need to manage
1262 * (offset), and the size of this payload area (bytes), fills in the
1263 * controlvm_payload_info struct. Returns TRUE for success or FALSE
1267 initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
1268 struct controlvm_payload_info *info)
1270 u8 __iomem *payload = NULL;
1271 int rc = CONTROLVM_RESP_SUCCESS;
1274 rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
1277 memset(info, 0, sizeof(struct controlvm_payload_info));
1278 if ((offset == 0) || (bytes == 0)) {
1279 rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
1282 payload = ioremap_cache(phys_addr + offset, bytes);
1284 rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
1288 info->offset = offset;
1289 info->bytes = bytes;
1290 info->ptr = payload;
1294 if (payload != NULL) {
1303 destroy_controlvm_payload_info(struct controlvm_payload_info *info)
1305 if (info->ptr != NULL) {
1309 memset(info, 0, sizeof(struct controlvm_payload_info));
1313 initialize_controlvm_payload(void)
1315 HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
1316 u64 payloadOffset = 0;
1317 u32 payloadBytes = 0;
1319 if (visorchannel_read(controlvm_channel,
1320 offsetof(struct spar_controlvm_channel_protocol,
1321 request_payload_offset),
1322 &payloadOffset, sizeof(payloadOffset)) < 0) {
1323 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
1324 POSTCODE_SEVERITY_ERR);
1327 if (visorchannel_read(controlvm_channel,
1328 offsetof(struct spar_controlvm_channel_protocol,
1329 request_payload_bytes),
1330 &payloadBytes, sizeof(payloadBytes)) < 0) {
1331 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
1332 POSTCODE_SEVERITY_ERR);
1335 initialize_controlvm_payload_info(phys_addr,
1336 payloadOffset, payloadBytes,
1337 &controlvm_payload_info);
1340 /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1341 * Returns CONTROLVM_RESP_xxx code.
1344 visorchipset_chipset_ready(void)
1346 kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
1347 return CONTROLVM_RESP_SUCCESS;
1349 EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
1352 visorchipset_chipset_selftest(void)
1354 char env_selftest[20];
1355 char *envp[] = { env_selftest, NULL };
1357 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
1358 kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1360 return CONTROLVM_RESP_SUCCESS;
1362 EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
1364 /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1365 * Returns CONTROLVM_RESP_xxx code.
1368 visorchipset_chipset_notready(void)
1370 kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
1371 return CONTROLVM_RESP_SUCCESS;
1373 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
1376 chipset_ready(struct controlvm_message_header *msgHdr)
1378 int rc = visorchipset_chipset_ready();
1380 if (rc != CONTROLVM_RESP_SUCCESS)
1382 if (msgHdr->flags.response_expected && !visorchipset_holdchipsetready)
1383 controlvm_respond(msgHdr, rc);
1384 if (msgHdr->flags.response_expected && visorchipset_holdchipsetready) {
1385 /* Send CHIPSET_READY response when all modules have been loaded
1386 * and disks mounted for the partition
1388 g_chipset_msg_hdr = *msgHdr;
1393 chipset_selftest(struct controlvm_message_header *msgHdr)
1395 int rc = visorchipset_chipset_selftest();
1397 if (rc != CONTROLVM_RESP_SUCCESS)
1399 if (msgHdr->flags.response_expected)
1400 controlvm_respond(msgHdr, rc);
1404 chipset_notready(struct controlvm_message_header *msgHdr)
1406 int rc = visorchipset_chipset_notready();
1408 if (rc != CONTROLVM_RESP_SUCCESS)
1410 if (msgHdr->flags.response_expected)
1411 controlvm_respond(msgHdr, rc);
1414 /* This is your "one-stop" shop for grabbing the next message from the
1415 * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
1418 read_controlvm_event(struct controlvm_message *msg)
1420 if (visorchannel_signalremove(controlvm_channel,
1421 CONTROLVM_QUEUE_EVENT, msg)) {
1423 if (msg->hdr.flags.test_message == 1)
1431 * The general parahotplug flow works as follows. The visorchipset
1432 * driver receives a DEVICE_CHANGESTATE message from Command
1433 * specifying a physical device to enable or disable. The CONTROLVM
1434 * message handler calls parahotplug_process_message, which then adds
1435 * the message to a global list and kicks off a udev event which
1436 * causes a user level script to enable or disable the specified
1437 * device. The udev script then writes to
1438 * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
1439 * to get called, at which point the appropriate CONTROLVM message is
1440 * retrieved from the list and responded to.
1443 #define PARAHOTPLUG_TIMEOUT_MS 2000
1446 * Generate unique int to match an outstanding CONTROLVM message with a
1447 * udev script /proc response
1450 parahotplug_next_id(void)
1452 static atomic_t id = ATOMIC_INIT(0);
1454 return atomic_inc_return(&id);
1458 * Returns the time (in jiffies) when a CONTROLVM message on the list
1459 * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
1461 static unsigned long
1462 parahotplug_next_expiration(void)
1464 return jiffies + msecs_to_jiffies(PARAHOTPLUG_TIMEOUT_MS);
1468 * Create a parahotplug_request, which is basically a wrapper for a
1469 * CONTROLVM_MESSAGE that we can stick on a list
1471 static struct parahotplug_request *
1472 parahotplug_request_create(struct controlvm_message *msg)
1474 struct parahotplug_request *req;
1476 req = kmalloc(sizeof(*req), GFP_KERNEL|__GFP_NORETRY);
1480 req->id = parahotplug_next_id();
1481 req->expiration = parahotplug_next_expiration();
1488 * Free a parahotplug_request.
1491 parahotplug_request_destroy(struct parahotplug_request *req)
1497 * Cause uevent to run the user level script to do the disable/enable
1498 * specified in (the CONTROLVM message in) the specified
1499 * parahotplug_request
1502 parahotplug_request_kickoff(struct parahotplug_request *req)
1504 struct controlvm_message_packet *cmd = &req->msg.cmd;
1505 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
1508 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
1511 sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
1512 sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
1513 sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
1514 cmd->device_change_state.state.active);
1515 sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
1516 cmd->device_change_state.bus_no);
1517 sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
1518 cmd->device_change_state.dev_no >> 3);
1519 sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1520 cmd->device_change_state.dev_no & 0x7);
1522 kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1527 * Remove any request from the list that's been on there too long and
1528 * respond with an error.
1531 parahotplug_process_list(void)
1533 struct list_head *pos = NULL;
1534 struct list_head *tmp = NULL;
1536 spin_lock(&Parahotplug_request_list_lock);
1538 list_for_each_safe(pos, tmp, &Parahotplug_request_list) {
1539 struct parahotplug_request *req =
1540 list_entry(pos, struct parahotplug_request, list);
1541 if (time_after_eq(jiffies, req->expiration)) {
1543 if (req->msg.hdr.flags.response_expected)
1544 controlvm_respond_physdev_changestate(
1546 CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
1547 req->msg.cmd.device_change_state.state);
1548 parahotplug_request_destroy(req);
1552 spin_unlock(&Parahotplug_request_list_lock);
1556 * Called from the /proc handler, which means the user script has
1557 * finished the enable/disable. Find the matching identifier, and
1558 * respond to the CONTROLVM message with success.
1561 parahotplug_request_complete(int id, u16 active)
1563 struct list_head *pos = NULL;
1564 struct list_head *tmp = NULL;
1566 spin_lock(&Parahotplug_request_list_lock);
1568 /* Look for a request matching "id". */
1569 list_for_each_safe(pos, tmp, &Parahotplug_request_list) {
1570 struct parahotplug_request *req =
1571 list_entry(pos, struct parahotplug_request, list);
1572 if (req->id == id) {
1573 /* Found a match. Remove it from the list and
1577 spin_unlock(&Parahotplug_request_list_lock);
1578 req->msg.cmd.device_change_state.state.active = active;
1579 if (req->msg.hdr.flags.response_expected)
1580 controlvm_respond_physdev_changestate(
1581 &req->msg.hdr, CONTROLVM_RESP_SUCCESS,
1582 req->msg.cmd.device_change_state.state);
1583 parahotplug_request_destroy(req);
1588 spin_unlock(&Parahotplug_request_list_lock);
1593 * Enables or disables a PCI device by kicking off a udev script
1596 parahotplug_process_message(struct controlvm_message *inmsg)
1598 struct parahotplug_request *req;
1600 req = parahotplug_request_create(inmsg);
1605 if (inmsg->cmd.device_change_state.state.active) {
1606 /* For enable messages, just respond with success
1607 * right away. This is a bit of a hack, but there are
1608 * issues with the early enable messages we get (with
1609 * either the udev script not detecting that the device
1610 * is up, or not getting called at all). Fortunately
1611 * the messages that get lost don't matter anyway, as
1612 * devices are automatically enabled at
1615 parahotplug_request_kickoff(req);
1616 controlvm_respond_physdev_changestate(&inmsg->hdr,
1617 CONTROLVM_RESP_SUCCESS, inmsg->cmd.
1618 device_change_state.state);
1619 parahotplug_request_destroy(req);
1621 /* For disable messages, add the request to the
1622 * request list before kicking off the udev script. It
1623 * won't get responded to until the script has
1624 * indicated it's done.
1626 spin_lock(&Parahotplug_request_list_lock);
1627 list_add_tail(&(req->list), &Parahotplug_request_list);
1628 spin_unlock(&Parahotplug_request_list_lock);
1630 parahotplug_request_kickoff(req);
1634 /* Process a controlvm message.
1636 * FALSE - this function will return FALSE only in the case where the
1637 * controlvm message was NOT processed, but processing must be
1638 * retried before reading the next controlvm message; a
1639 * scenario where this can occur is when we need to throttle
1640 * the allocation of memory in which to copy out controlvm
1642 * TRUE - processing of the controlvm message completed,
1643 * either successfully or with an error.
1646 handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
1648 struct controlvm_message_packet *cmd = &inmsg.cmd;
1649 u64 parametersAddr = 0;
1650 u32 parametersBytes = 0;
1651 struct parser_context *parser_ctx = NULL;
1652 BOOL isLocalAddr = FALSE;
1653 struct controlvm_message ackmsg;
1655 /* create parsing context if necessary */
1656 isLocalAddr = (inmsg.hdr.flags.test_message == 1);
1657 if (channel_addr == 0)
1659 parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset;
1660 parametersBytes = inmsg.hdr.payload_bytes;
1662 /* Parameter and channel addresses within test messages actually lie
1663 * within our OS-controlled memory. We need to know that, because it
1664 * makes a difference in how we compute the virtual address.
1666 if (parametersAddr != 0 && parametersBytes != 0) {
1670 parser_init_byte_stream(parametersAddr, parametersBytes,
1671 isLocalAddr, &retry);
1672 if (!parser_ctx && retry)
1677 controlvm_init_response(&ackmsg, &inmsg.hdr,
1678 CONTROLVM_RESP_SUCCESS);
1679 if (controlvm_channel)
1680 visorchannel_signalinsert(controlvm_channel,
1681 CONTROLVM_QUEUE_ACK,
1684 switch (inmsg.hdr.id) {
1685 case CONTROLVM_CHIPSET_INIT:
1686 chipset_init(&inmsg);
1688 case CONTROLVM_BUS_CREATE:
1691 case CONTROLVM_BUS_DESTROY:
1692 bus_destroy(&inmsg);
1694 case CONTROLVM_BUS_CONFIGURE:
1695 bus_configure(&inmsg, parser_ctx);
1697 case CONTROLVM_DEVICE_CREATE:
1698 my_device_create(&inmsg);
1700 case CONTROLVM_DEVICE_CHANGESTATE:
1701 if (cmd->device_change_state.flags.phys_device) {
1702 parahotplug_process_message(&inmsg);
1704 /* save the hdr and cmd structures for later use */
1705 /* when sending back the response to Command */
1706 my_device_changestate(&inmsg);
1707 g_diag_msg_hdr = inmsg.hdr;
1708 g_devicechangestate_packet = inmsg.cmd;
1712 case CONTROLVM_DEVICE_DESTROY:
1713 my_device_destroy(&inmsg);
1715 case CONTROLVM_DEVICE_CONFIGURE:
1716 /* no op for now, just send a respond that we passed */
1717 if (inmsg.hdr.flags.response_expected)
1718 controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
1720 case CONTROLVM_CHIPSET_READY:
1721 chipset_ready(&inmsg.hdr);
1723 case CONTROLVM_CHIPSET_SELFTEST:
1724 chipset_selftest(&inmsg.hdr);
1726 case CONTROLVM_CHIPSET_STOP:
1727 chipset_notready(&inmsg.hdr);
1730 if (inmsg.hdr.flags.response_expected)
1731 controlvm_respond(&inmsg.hdr,
1732 -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
1737 parser_done(parser_ctx);
1743 static HOSTADDRESS controlvm_get_channel_address(void)
1748 if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size)))
1755 controlvm_periodic_work(struct work_struct *work)
1757 struct controlvm_message inmsg;
1758 BOOL gotACommand = FALSE;
1759 BOOL handle_command_failed = FALSE;
1760 static u64 Poll_Count;
1762 /* make sure visorbus server is registered for controlvm callbacks */
1763 if (visorchipset_serverregwait && !serverregistered)
1765 /* make sure visorclientbus server is regsitered for controlvm
1768 if (visorchipset_clientregwait && !clientregistered)
1772 if (Poll_Count >= 250)
1777 /* Check events to determine if response to CHIPSET_READY
1780 if (visorchipset_holdchipsetready &&
1781 (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) {
1782 if (check_chipset_events() == 1) {
1783 controlvm_respond(&g_chipset_msg_hdr, 0);
1784 clear_chipset_events();
1785 memset(&g_chipset_msg_hdr, 0,
1786 sizeof(struct controlvm_message_header));
1790 while (visorchannel_signalremove(controlvm_channel,
1791 CONTROLVM_QUEUE_RESPONSE,
1795 if (ControlVm_Pending_Msg_Valid) {
1796 /* we throttled processing of a prior
1797 * msg, so try to process it again
1798 * rather than reading a new one
1800 inmsg = ControlVm_Pending_Msg;
1801 ControlVm_Pending_Msg_Valid = FALSE;
1804 gotACommand = read_controlvm_event(&inmsg);
1808 handle_command_failed = FALSE;
1809 while (gotACommand && (!handle_command_failed)) {
1810 most_recent_message_jiffies = jiffies;
1811 if (handle_command(inmsg,
1812 visorchannel_get_physaddr
1813 (controlvm_channel)))
1814 gotACommand = read_controlvm_event(&inmsg);
1816 /* this is a scenario where throttling
1817 * is required, but probably NOT an
1818 * error...; we stash the current
1819 * controlvm msg so we will attempt to
1820 * reprocess it on our next loop
1822 handle_command_failed = TRUE;
1823 ControlVm_Pending_Msg = inmsg;
1824 ControlVm_Pending_Msg_Valid = TRUE;
1828 /* parahotplug_worker */
1829 parahotplug_process_list();
1833 if (time_after(jiffies,
1834 most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
1835 /* it's been longer than MIN_IDLE_SECONDS since we
1836 * processed our last controlvm message; slow down the
1839 if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW)
1840 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
1842 if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST)
1843 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
1846 queue_delayed_work(periodic_controlvm_workqueue,
1847 &periodic_controlvm_work, poll_jiffies);
1851 setup_crash_devices_work_queue(struct work_struct *work)
1853 struct controlvm_message localCrashCreateBusMsg;
1854 struct controlvm_message localCrashCreateDevMsg;
1855 struct controlvm_message msg;
1856 u32 localSavedCrashMsgOffset;
1857 u16 localSavedCrashMsgCount;
1859 /* make sure visorbus server is registered for controlvm callbacks */
1860 if (visorchipset_serverregwait && !serverregistered)
1863 /* make sure visorclientbus server is regsitered for controlvm
1866 if (visorchipset_clientregwait && !clientregistered)
1869 POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
1871 /* send init chipset msg */
1872 msg.hdr.id = CONTROLVM_CHIPSET_INIT;
1873 msg.cmd.init_chipset.bus_count = 23;
1874 msg.cmd.init_chipset.switch_count = 0;
1878 /* get saved message count */
1879 if (visorchannel_read(controlvm_channel,
1880 offsetof(struct spar_controlvm_channel_protocol,
1881 saved_crash_message_count),
1882 &localSavedCrashMsgCount, sizeof(u16)) < 0) {
1883 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
1884 POSTCODE_SEVERITY_ERR);
1888 if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) {
1889 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
1890 localSavedCrashMsgCount,
1891 POSTCODE_SEVERITY_ERR);
1895 /* get saved crash message offset */
1896 if (visorchannel_read(controlvm_channel,
1897 offsetof(struct spar_controlvm_channel_protocol,
1898 saved_crash_message_offset),
1899 &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
1900 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
1901 POSTCODE_SEVERITY_ERR);
1905 /* read create device message for storage bus offset */
1906 if (visorchannel_read(controlvm_channel,
1907 localSavedCrashMsgOffset,
1908 &localCrashCreateBusMsg,
1909 sizeof(struct controlvm_message)) < 0) {
1910 POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
1911 POSTCODE_SEVERITY_ERR);
1915 /* read create device message for storage device */
1916 if (visorchannel_read(controlvm_channel,
1917 localSavedCrashMsgOffset +
1918 sizeof(struct controlvm_message),
1919 &localCrashCreateDevMsg,
1920 sizeof(struct controlvm_message)) < 0) {
1921 POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
1922 POSTCODE_SEVERITY_ERR);
1926 /* reuse IOVM create bus message */
1927 if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0) {
1928 bus_create(&localCrashCreateBusMsg);
1930 POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
1931 POSTCODE_SEVERITY_ERR);
1935 /* reuse create device message for storage device */
1936 if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0) {
1937 my_device_create(&localCrashCreateDevMsg);
1939 POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
1940 POSTCODE_SEVERITY_ERR);
1943 POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO);
1948 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
1950 queue_delayed_work(periodic_controlvm_workqueue,
1951 &periodic_controlvm_work, poll_jiffies);
1955 bus_create_response(ulong busNo, int response)
1957 bus_responder(CONTROLVM_BUS_CREATE, busNo, response);
1961 bus_destroy_response(ulong busNo, int response)
1963 bus_responder(CONTROLVM_BUS_DESTROY, busNo, response);
1967 device_create_response(ulong busNo, ulong devNo, int response)
1969 device_responder(CONTROLVM_DEVICE_CREATE, busNo, devNo, response);
1973 device_destroy_response(ulong busNo, ulong devNo, int response)
1975 device_responder(CONTROLVM_DEVICE_DESTROY, busNo, devNo, response);
1979 visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response)
1981 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
1982 bus_no, dev_no, response,
1983 segment_state_standby);
1985 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
1988 device_resume_response(ulong busNo, ulong devNo, int response)
1990 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
1991 busNo, devNo, response,
1992 segment_state_running);
1996 visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info)
1998 void *p = findbus(&bus_info_list, bus_no);
2002 memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
2005 EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
2008 visorchipset_set_bus_context(ulong bus_no, void *context)
2010 struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no);
2014 p->bus_driver_context = context;
2017 EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
2020 visorchipset_get_device_info(ulong bus_no, ulong dev_no,
2021 struct visorchipset_device_info *dev_info)
2023 void *p = finddevice(&dev_info_list, bus_no, dev_no);
2027 memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
2030 EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
2033 visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context)
2035 struct visorchipset_device_info *p =
2036 finddevice(&dev_info_list, bus_no, dev_no);
2040 p->bus_driver_context = context;
2043 EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
2045 /* Generic wrapper function for allocating memory from a kmem_cache pool.
2048 visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block,
2058 /* __GFP_NORETRY means "ok to fail", meaning
2059 * kmem_cache_alloc() can return NULL, implying the caller CAN
2060 * cope with failure. If you do NOT specify __GFP_NORETRY,
2061 * Linux will go to extreme measures to get memory for you
2062 * (like, invoke oom killer), which will probably cripple the
2065 gfp |= __GFP_NORETRY;
2066 p = kmem_cache_alloc(pool, gfp);
2070 atomic_inc(&Visorchipset_cache_buffers_in_use);
2074 /* Generic wrapper function for freeing memory from a kmem_cache pool.
2077 visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
2082 atomic_dec(&Visorchipset_cache_buffers_in_use);
2083 kmem_cache_free(pool, p);
2086 static ssize_t chipsetready_store(struct device *dev,
2087 struct device_attribute *attr, const char *buf, size_t count)
2091 if (sscanf(buf, "%63s", msgtype) != 1)
2094 if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0) {
2095 chipset_events[0] = 1;
2097 } else if (strcmp(msgtype, "MODULES_LOADED") == 0) {
2098 chipset_events[1] = 1;
2104 /* The parahotplug/devicedisabled interface gets called by our support script
2105 * when an SR-IOV device has been shut down. The ID is passed to the script
2106 * and then passed back when the device has been removed.
2108 static ssize_t devicedisabled_store(struct device *dev,
2109 struct device_attribute *attr, const char *buf, size_t count)
2113 if (kstrtouint(buf, 10, &id) != 0)
2116 parahotplug_request_complete(id, 0);
2120 /* The parahotplug/deviceenabled interface gets called by our support script
2121 * when an SR-IOV device has been recovered. The ID is passed to the script
2122 * and then passed back when the device has been brought back up.
2124 static ssize_t deviceenabled_store(struct device *dev,
2125 struct device_attribute *attr, const char *buf, size_t count)
2129 if (kstrtouint(buf, 10, &id) != 0)
2132 parahotplug_request_complete(id, 1);
2137 visorchipset_init(void)
2142 if (!unisys_spar_platform)
2145 memset(&BusDev_Server_Notifiers, 0, sizeof(BusDev_Server_Notifiers));
2146 memset(&BusDev_Client_Notifiers, 0, sizeof(BusDev_Client_Notifiers));
2147 memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
2148 memset(&livedump_info, 0, sizeof(livedump_info));
2149 atomic_set(&livedump_info.buffers_in_use, 0);
2151 if (visorchipset_testvnic) {
2152 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
2157 addr = controlvm_get_channel_address();
2160 visorchannel_create_with_lock
2162 sizeof(struct spar_controlvm_channel_protocol),
2163 spar_controlvm_channel_protocol_uuid);
2164 if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
2165 visorchannel_get_header(controlvm_channel))) {
2166 initialize_controlvm_payload();
2168 visorchannel_destroy(controlvm_channel);
2169 controlvm_channel = NULL;
2176 MajorDev = MKDEV(visorchipset_major, 0);
2177 rc = visorchipset_file_init(MajorDev, &controlvm_channel);
2179 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
2183 memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
2185 memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
2187 memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
2189 Putfile_buffer_list_pool =
2190 kmem_cache_create(Putfile_buffer_list_pool_name,
2191 sizeof(struct putfile_buffer_entry),
2192 0, SLAB_HWCACHE_ALIGN, NULL);
2193 if (!Putfile_buffer_list_pool) {
2194 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
2198 if (!visorchipset_disable_controlvm) {
2199 /* if booting in a crash kernel */
2200 if (visorchipset_crash_kernel)
2201 INIT_DELAYED_WORK(&periodic_controlvm_work,
2202 setup_crash_devices_work_queue);
2204 INIT_DELAYED_WORK(&periodic_controlvm_work,
2205 controlvm_periodic_work);
2206 periodic_controlvm_workqueue =
2207 create_singlethread_workqueue("visorchipset_controlvm");
2209 if (!periodic_controlvm_workqueue) {
2210 POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
2215 most_recent_message_jiffies = jiffies;
2216 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
2217 rc = queue_delayed_work(periodic_controlvm_workqueue,
2218 &periodic_controlvm_work, poll_jiffies);
2220 POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
2226 Visorchipset_platform_device.dev.devt = MajorDev;
2227 if (platform_device_register(&Visorchipset_platform_device) < 0) {
2228 POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
2232 POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
2236 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
2237 POSTCODE_SEVERITY_ERR);
2243 visorchipset_exit(void)
2245 POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
2247 if (visorchipset_disable_controlvm) {
2250 cancel_delayed_work(&periodic_controlvm_work);
2251 flush_workqueue(periodic_controlvm_workqueue);
2252 destroy_workqueue(periodic_controlvm_workqueue);
2253 periodic_controlvm_workqueue = NULL;
2254 destroy_controlvm_payload_info(&controlvm_payload_info);
2256 if (Putfile_buffer_list_pool) {
2257 kmem_cache_destroy(Putfile_buffer_list_pool);
2258 Putfile_buffer_list_pool = NULL;
2261 cleanup_controlvm_structures();
2263 memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
2265 memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
2267 memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
2269 visorchannel_destroy(controlvm_channel);
2271 visorchipset_file_cleanup();
2272 POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
2275 module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
2276 MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
2277 int visorchipset_testvnic = 0;
2279 module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
2280 MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
2281 int visorchipset_testvnicclient = 0;
2283 module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
2284 MODULE_PARM_DESC(visorchipset_testmsg,
2285 "1 to manufacture the chipset, bus, and switch messages");
2286 int visorchipset_testmsg = 0;
2288 module_param_named(major, visorchipset_major, int, S_IRUGO);
2289 MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node");
2290 int visorchipset_major = 0;
2292 module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
2293 MODULE_PARM_DESC(visorchipset_serverreqwait,
2294 "1 to have the module wait for the visor bus to register");
2295 int visorchipset_serverregwait = 0; /* default is off */
2296 module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
2297 MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
2298 int visorchipset_clientregwait = 1; /* default is on */
2299 module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
2300 MODULE_PARM_DESC(visorchipset_testteardown,
2301 "1 to test teardown of the chipset, bus, and switch");
2302 int visorchipset_testteardown = 0; /* default is off */
2303 module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
2305 MODULE_PARM_DESC(visorchipset_disable_controlvm,
2306 "1 to disable polling of controlVm channel");
2307 int visorchipset_disable_controlvm = 0; /* default is off */
2308 module_param_named(crash_kernel, visorchipset_crash_kernel, int, S_IRUGO);
2309 MODULE_PARM_DESC(visorchipset_crash_kernel,
2310 "1 means we are running in crash kernel");
2311 int visorchipset_crash_kernel = 0; /* default is running in non-crash kernel */
2312 module_param_named(holdchipsetready, visorchipset_holdchipsetready,
2314 MODULE_PARM_DESC(visorchipset_holdchipsetready,
2315 "1 to hold response to CHIPSET_READY");
2316 int visorchipset_holdchipsetready = 0; /* default is to send CHIPSET_READY
2317 * response immediately */
2318 module_init(visorchipset_init);
2319 module_exit(visorchipset_exit);
2321 MODULE_AUTHOR("Unisys");
2322 MODULE_LICENSE("GPL");
2323 MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
2325 MODULE_VERSION(VERSION);