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"
28 #include "controlvmcompletionstatus.h"
29 #include "guestlinuxdebug.h"
31 #include <linux/nls.h>
32 #include <linux/netdevice.h>
33 #include <linux/platform_device.h>
34 #include <linux/uuid.h>
36 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
37 #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for
38 * vnic loopback test */
39 #define TEST_VNIC_SWITCHNO 1
40 #define TEST_VNIC_BUSNO 9
42 #define MAX_NAME_SIZE 128
43 #define MAX_IP_SIZE 50
44 #define MAXOUTSTANDINGCHANNELCOMMAND 256
45 #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1
46 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
48 /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
49 * we switch to slow polling mode. As soon as we get a controlvm
50 * message, we switch back to fast polling mode.
52 #define MIN_IDLE_SECONDS 10
53 static ulong Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_FAST
;
54 static ulong Most_recent_message_jiffies
; /* when we got our last
55 * controlvm message */
65 static int serverregistered
;
66 static int clientregistered
;
68 #define MAX_CHIPSET_EVENTS 2
69 static U8 chipset_events
[MAX_CHIPSET_EVENTS
] = { 0, 0 };
71 static struct delayed_work Periodic_controlvm_work
;
72 static struct workqueue_struct
*Periodic_controlvm_workqueue
;
73 static DEFINE_SEMAPHORE(NotifierLock
);
76 CONTROLVM_MESSAGE message
;
80 static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr
;
81 static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr
;
82 static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr
;
83 static const uuid_le UltraDiagPoolChannelProtocolGuid
=
84 ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID
;
85 /* 0xffffff is an invalid Bus/Device number */
86 static ulong g_diagpoolBusNo
= 0xffffff;
87 static ulong g_diagpoolDevNo
= 0xffffff;
88 static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket
;
90 /* Only VNIC and VHBA channels are sent to visorclientbus (aka
93 #define FOR_VISORHACKBUS(channel_type_guid) \
94 (((uuid_le_cmp(channel_type_guid, UltraVnicChannelProtocolGuid) == 0)\
95 || (uuid_le_cmp(channel_type_guid, UltraVhbaChannelProtocolGuid) == 0)))
96 #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
98 #define is_diagpool_channel(channel_type_guid) \
99 (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0)
104 PARTPROP_description
,
107 /* add new properties above, but don't forget to change
108 * InitPartitionProperties() and show_partition_property() also...
111 } PARTITION_property
;
112 static const char *PartitionTypeNames
[] = { "partition", NULL
};
114 static char *PartitionPropertyNames
[PARTPROP_last
+ 1];
116 InitPartitionProperties(void)
118 char **p
= PartitionPropertyNames
;
119 p
[PARTPROP_invalid
] = "";
120 p
[PARTPROP_name
] = "name";
121 p
[PARTPROP_description
] = "description";
122 p
[PARTPROP_handle
] = "handle";
123 p
[PARTPROP_busNumber
] = "busNumber";
124 p
[PARTPROP_last
] = NULL
;
127 static MYPROCTYPE
*PartitionType
;
129 #define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
130 static struct proc_dir_entry
*diag_proc_dir
;
132 #define VISORCHIPSET_CHIPSET_PROC_ENTRY_FN "chipsetready"
133 static struct proc_dir_entry
*chipset_proc_dir
;
135 #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
136 static struct proc_dir_entry
*parahotplug_proc_dir
;
138 static LIST_HEAD(BusInfoList
);
139 static LIST_HEAD(DevInfoList
);
141 static struct proc_dir_entry
*ProcDir
;
142 static VISORCHANNEL
*ControlVm_channel
;
144 static ssize_t
visorchipset_proc_read_writeonly(struct file
*file
,
146 size_t len
, loff_t
*offset
);
149 U8 __iomem
*ptr
; /* pointer to base address of payload pool */
150 U64 offset
; /* offset from beginning of controlvm
151 * channel to beginning of payload * pool */
152 U32 bytes
; /* number of bytes in payload pool */
153 } CONTROLVM_PAYLOAD_INFO
;
155 /* Manages the request payload in the controlvm channel */
156 static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info
;
158 static pCHANNEL_HEADER Test_Vnic_channel
;
161 CONTROLVM_MESSAGE_HEADER Dumpcapture_header
;
162 CONTROLVM_MESSAGE_HEADER Gettextdump_header
;
163 CONTROLVM_MESSAGE_HEADER Dumpcomplete_header
;
164 BOOL Gettextdump_outstanding
;
167 atomic_t buffers_in_use
;
170 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
171 * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
173 static LIVEDUMP_INFO LiveDump_info
;
175 /* The following globals are used to handle the scenario where we are unable to
176 * offload the payload from a controlvm message due to memory requirements. In
177 * this scenario, we simply stash the controlvm message, then attempt to
178 * process it again the next time controlvm_periodic_work() runs.
180 static CONTROLVM_MESSAGE ControlVm_Pending_Msg
;
181 static BOOL ControlVm_Pending_Msg_Valid
= FALSE
;
183 /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
184 * TRANSMIT_FILE PutFile payloads.
186 static struct kmem_cache
*Putfile_buffer_list_pool
;
187 static const char Putfile_buffer_list_pool_name
[] =
188 "controlvm_putfile_buffer_list_pool";
190 /* This identifies a data buffer that has been received via a controlvm messages
191 * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
193 struct putfile_buffer_entry
{
194 struct list_head next
; /* putfile_buffer_entry list */
195 PARSER_CONTEXT
*parser_ctx
; /* points to buffer containing input data */
198 /* List of struct putfile_request *, via next_putfile_request member.
199 * Each entry in this list identifies an outstanding TRANSMIT_FILE
202 static LIST_HEAD(Putfile_request_list
);
204 /* This describes a buffer and its current state of transfer (e.g., how many
205 * bytes have already been supplied as putfile data, and how many bytes are
206 * remaining) for a putfile_request.
208 struct putfile_active_buffer
{
209 /* a payload from a controlvm message, containing a file data buffer */
210 PARSER_CONTEXT
*parser_ctx
;
211 /* points within data area of parser_ctx to next byte of data */
213 /* # bytes left from <pnext> to the end of this data buffer */
214 size_t bytes_remaining
;
217 #define PUTFILE_REQUEST_SIG 0x0906101302281211
218 /* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
219 * conversation. Structs of this type are dynamically linked into
220 * <Putfile_request_list>.
222 struct putfile_request
{
223 u64 sig
; /* PUTFILE_REQUEST_SIG */
225 /* header from original TransmitFile request */
226 CONTROLVM_MESSAGE_HEADER controlvm_header
;
227 u64 file_request_number
; /* from original TransmitFile request */
229 /* link to next struct putfile_request */
230 struct list_head next_putfile_request
;
232 /* most-recent sequence number supplied via a controlvm message */
233 u64 data_sequence_number
;
235 /* head of putfile_buffer_entry list, which describes the data to be
236 * supplied as putfile data;
237 * - this list is added to when controlvm messages come in that supply
239 * - this list is removed from via the hotplug program that is actually
240 * consuming these buffers to write as file data */
241 struct list_head input_buffer_list
;
242 spinlock_t req_list_lock
; /* lock for input_buffer_list */
244 /* waiters for input_buffer_list to go non-empty */
245 wait_queue_head_t input_buffer_wq
;
247 /* data not yet read within current putfile_buffer_entry */
248 struct putfile_active_buffer active_buf
;
250 /* <0 = failed, 0 = in-progress, >0 = successful; */
251 /* note that this must be set with req_list_lock, and if you set <0, */
252 /* it is your responsibility to also free up all of the other objects */
253 /* in this struct (like input_buffer_list, active_buf.parser_ctx) */
254 /* before releasing the lock */
255 int completion_status
;
258 static atomic_t Visorchipset_cache_buffers_in_use
= ATOMIC_INIT(0);
260 struct parahotplug_request
{
261 struct list_head list
;
263 unsigned long expiration
;
264 CONTROLVM_MESSAGE msg
;
267 static LIST_HEAD(Parahotplug_request_list
);
268 static DEFINE_SPINLOCK(Parahotplug_request_list_lock
); /* lock for above */
269 static void parahotplug_process_list(void);
271 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
272 * CONTROLVM_REPORTEVENT.
274 static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Server_Notifiers
;
275 static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Client_Notifiers
;
277 static void bus_create_response(ulong busNo
, int response
);
278 static void bus_destroy_response(ulong busNo
, int response
);
279 static void device_create_response(ulong busNo
, ulong devNo
, int response
);
280 static void device_destroy_response(ulong busNo
, ulong devNo
, int response
);
281 static void device_resume_response(ulong busNo
, ulong devNo
, int response
);
283 static VISORCHIPSET_BUSDEV_RESPONDERS BusDev_Responders
= {
284 .bus_create
= bus_create_response
,
285 .bus_destroy
= bus_destroy_response
,
286 .device_create
= device_create_response
,
287 .device_destroy
= device_destroy_response
,
288 .device_pause
= visorchipset_device_pause_response
,
289 .device_resume
= device_resume_response
,
292 /* info for /dev/visorchipset */
293 static dev_t MajorDev
= -1; /**< indicates major num for device */
295 /* prototypes for attributes */
296 static ssize_t
toolaction_show(struct device
*dev
,
297 struct device_attribute
*attr
, char *buf
);
298 static ssize_t
toolaction_store(struct device
*dev
,
299 struct device_attribute
*attr
, const char *buf
, size_t count
);
300 static DEVICE_ATTR_RW(toolaction
);
302 static ssize_t
boottotool_show(struct device
*dev
,
303 struct device_attribute
*attr
, char *buf
);
304 static ssize_t
boottotool_store(struct device
*dev
,
305 struct device_attribute
*attr
, const char *buf
, size_t count
);
306 static DEVICE_ATTR_RW(boottotool
);
308 static ssize_t
error_show(struct device
*dev
, struct device_attribute
*attr
,
310 static ssize_t
error_store(struct device
*dev
, struct device_attribute
*attr
,
311 const char *buf
, size_t count
);
312 static DEVICE_ATTR_RW(error
);
314 static ssize_t
textid_show(struct device
*dev
, struct device_attribute
*attr
,
316 static ssize_t
textid_store(struct device
*dev
, struct device_attribute
*attr
,
317 const char *buf
, size_t count
);
318 static DEVICE_ATTR_RW(textid
);
320 static ssize_t
remaining_steps_show(struct device
*dev
,
321 struct device_attribute
*attr
, char *buf
);
322 static ssize_t
remaining_steps_store(struct device
*dev
,
323 struct device_attribute
*attr
, const char *buf
, size_t count
);
324 static DEVICE_ATTR_RW(remaining_steps
);
326 static struct attribute
*visorchipset_install_attrs
[] = {
327 &dev_attr_toolaction
.attr
,
328 &dev_attr_boottotool
.attr
,
329 &dev_attr_error
.attr
,
330 &dev_attr_textid
.attr
,
331 &dev_attr_remaining_steps
.attr
,
335 static struct attribute_group visorchipset_install_group
= {
337 .attrs
= visorchipset_install_attrs
340 static const struct attribute_group
*visorchipset_dev_groups
[] = {
341 &visorchipset_install_group
,
345 /* /sys/devices/platform/visorchipset */
346 static struct platform_device Visorchipset_platform_device
= {
347 .name
= "visorchipset",
349 .dev
.groups
= visorchipset_dev_groups
,
352 /* Function prototypes */
353 static void controlvm_respond(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
);
354 static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER
*msgHdr
,
356 ULTRA_CHIPSET_FEATURE features
);
357 static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER
*
358 msgHdr
, int response
,
359 ULTRA_SEGMENT_STATE state
);
361 ssize_t
toolaction_show(struct device
*dev
, struct device_attribute
*attr
,
366 visorchannel_read(ControlVm_channel
,
367 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
368 ToolAction
), &toolAction
, sizeof(U8
));
369 return scnprintf(buf
, PAGE_SIZE
, "%u\n", toolAction
);
372 ssize_t
toolaction_store(struct device
*dev
, struct device_attribute
*attr
,
373 const char *buf
, size_t count
)
377 if (sscanf(buf
, "%hhu\n", &toolAction
) == 1) {
378 if (visorchannel_write(ControlVm_channel
,
379 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
381 &toolAction
, sizeof(U8
)) < 0)
389 ssize_t
boottotool_show(struct device
*dev
, struct device_attribute
*attr
,
392 ULTRA_EFI_SPAR_INDICATION efiSparIndication
;
394 visorchannel_read(ControlVm_channel
,
395 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
396 EfiSparIndication
), &efiSparIndication
,
397 sizeof(ULTRA_EFI_SPAR_INDICATION
));
398 return scnprintf(buf
, PAGE_SIZE
, "%u\n",
399 efiSparIndication
.BootToTool
);
402 ssize_t
boottotool_store(struct device
*dev
, struct device_attribute
*attr
,
403 const char *buf
, size_t count
)
406 ULTRA_EFI_SPAR_INDICATION efiSparIndication
;
408 if (sscanf(buf
, "%u\n", &val
) == 1) {
409 efiSparIndication
.BootToTool
= val
;
410 if (visorchannel_write(ControlVm_channel
,
411 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
413 &(efiSparIndication
),
414 sizeof(ULTRA_EFI_SPAR_INDICATION
)) < 0)
422 static ssize_t
error_show(struct device
*dev
, struct device_attribute
*attr
,
427 visorchannel_read(ControlVm_channel
, offsetof(
428 ULTRA_CONTROLVM_CHANNEL_PROTOCOL
, InstallationError
),
429 &error
, sizeof(u32
));
430 return scnprintf(buf
, PAGE_SIZE
, "%i\n", error
);
433 static ssize_t
error_store(struct device
*dev
, struct device_attribute
*attr
,
434 const char *buf
, size_t count
)
438 if (sscanf(buf
, "%i\n", &error
) == 1) {
439 if (visorchannel_write(ControlVm_channel
,
440 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
442 &error
, sizeof(u32
)) == 1) {
449 static ssize_t
textid_show(struct device
*dev
, struct device_attribute
*attr
,
454 visorchannel_read(ControlVm_channel
, offsetof(
455 ULTRA_CONTROLVM_CHANNEL_PROTOCOL
, InstallationTextId
),
456 &textId
, sizeof(u32
));
457 return scnprintf(buf
, PAGE_SIZE
, "%i\n", textId
);
460 static ssize_t
textid_store(struct device
*dev
, struct device_attribute
*attr
,
461 const char *buf
, size_t count
)
465 if (sscanf(buf
, "%i\n", &textId
) == 1) {
466 if (visorchannel_write(ControlVm_channel
,
467 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
469 &textId
, sizeof(u32
)) == 1) {
477 static ssize_t
remaining_steps_show(struct device
*dev
,
478 struct device_attribute
*attr
, char *buf
)
482 visorchannel_read(ControlVm_channel
,
483 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
484 InstallationRemainingSteps
),
487 return scnprintf(buf
, PAGE_SIZE
, "%hu\n", remainingSteps
);
490 static ssize_t
remaining_steps_store(struct device
*dev
,
491 struct device_attribute
*attr
, const char *buf
, size_t count
)
495 if (sscanf(buf
, "%hu\n", &remainingSteps
) == 1) {
496 if (visorchannel_write(ControlVm_channel
,
497 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
498 InstallationRemainingSteps
),
499 &remainingSteps
, sizeof(u16
)) == 1) {
507 show_partition_property(struct seq_file
*f
, void *ctx
, int property
)
509 VISORCHIPSET_BUS_INFO
*info
= (VISORCHIPSET_BUS_INFO
*) (ctx
);
513 seq_printf(f
, "%s\n", NONULLSTR(info
->name
));
515 case PARTPROP_description
:
516 seq_printf(f
, "%s\n", NONULLSTR(info
->description
));
518 case PARTPROP_handle
:
519 seq_printf(f
, "0x%-16.16Lx\n", info
->partitionHandle
);
521 case PARTPROP_busNumber
:
522 seq_printf(f
, "%d\n", info
->busNo
);
525 seq_printf(f
, "(%d??)\n", property
);
533 if (ProcDir
== NULL
) {
534 ProcDir
= proc_mkdir(MYDRVNAME
, NULL
);
535 if (ProcDir
== NULL
) {
536 LOGERR("failed to create /proc directory %s",
538 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC
,
539 POSTCODE_SEVERITY_ERR
);
548 remove_proc_entry(MYDRVNAME
, NULL
);
556 wchar_t unicodeString
[] = { 'a', 'b', 'c', 0 };
557 char s
[sizeof(unicodeString
) * NLS_MAX_CHARSET_SIZE
];
558 wchar_t unicode2
[99];
560 /* NOTE: Either due to a bug, or feature I don't understand, the
561 * kernel utf8_mbstowcs() and utf_wcstombs() do NOT copy the
562 * trailed NUL byte!! REALLY!!!!! Arrrrgggghhhhh
565 LOGINF("sizeof(wchar_t) = %d", sizeof(wchar_t));
566 LOGINF("utf8_wcstombs=%d",
567 chrs
= utf8_wcstombs(s
, unicodeString
, sizeof(s
)));
569 s
[chrs
] = '\0'; /* GRRRRRRRR */
571 LOGINF("utf8_mbstowcs=%d", chrs
= utf8_mbstowcs(unicode2
, s
, 100));
573 unicode2
[chrs
] = 0; /* GRRRRRRRR */
574 if (memcmp(unicodeString
, unicode2
, sizeof(unicodeString
)) == 0)
575 LOGINF("strings match... good");
577 LOGINF("strings did not match!!");
582 busInfo_clear(void *v
)
584 VISORCHIPSET_BUS_INFO
*p
= (VISORCHIPSET_BUS_INFO
*) (v
);
587 visor_proc_DestroyObject(p
->procObject
);
588 p
->procObject
= NULL
;
593 kfree(p
->description
);
594 p
->description
= NULL
;
596 p
->state
.created
= 0;
597 memset(p
, 0, sizeof(VISORCHIPSET_BUS_INFO
));
601 devInfo_clear(void *v
)
603 VISORCHIPSET_DEVICE_INFO
*p
= (VISORCHIPSET_DEVICE_INFO
*) (v
);
604 p
->state
.created
= 0;
605 memset(p
, 0, sizeof(VISORCHIPSET_DEVICE_INFO
));
609 check_chipset_events(void)
613 /* Check events to determine if response should be sent */
614 for (i
= 0; i
< MAX_CHIPSET_EVENTS
; i
++)
615 send_msg
&= chipset_events
[i
];
620 clear_chipset_events(void)
623 /* Clear chipset_events */
624 for (i
= 0; i
< MAX_CHIPSET_EVENTS
; i
++)
625 chipset_events
[i
] = 0;
629 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
,
630 VISORCHIPSET_BUSDEV_RESPONDERS
*responders
,
631 ULTRA_VBUS_DEVICEINFO
*driverInfo
)
633 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
634 if (notifiers
== NULL
) {
635 memset(&BusDev_Server_Notifiers
, 0,
636 sizeof(BusDev_Server_Notifiers
));
637 serverregistered
= 0; /* clear flag */
639 BusDev_Server_Notifiers
= *notifiers
;
640 serverregistered
= 1; /* set flag */
643 *responders
= BusDev_Responders
;
645 BusDeviceInfo_Init(driverInfo
, "chipset", "visorchipset",
648 UNLOCKSEM(&NotifierLock
);
650 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server
);
653 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
,
654 VISORCHIPSET_BUSDEV_RESPONDERS
*responders
,
655 ULTRA_VBUS_DEVICEINFO
*driverInfo
)
657 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
658 if (notifiers
== NULL
) {
659 memset(&BusDev_Client_Notifiers
, 0,
660 sizeof(BusDev_Client_Notifiers
));
661 clientregistered
= 0; /* clear flag */
663 BusDev_Client_Notifiers
= *notifiers
;
664 clientregistered
= 1; /* set flag */
667 *responders
= BusDev_Responders
;
669 BusDeviceInfo_Init(driverInfo
, "chipset(bolts)", "visorchipset",
671 UNLOCKSEM(&NotifierLock
);
673 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client
);
676 cleanup_controlvm_structures(void)
678 VISORCHIPSET_BUS_INFO
*bi
, *tmp_bi
;
679 VISORCHIPSET_DEVICE_INFO
*di
, *tmp_di
;
681 list_for_each_entry_safe(bi
, tmp_bi
, &BusInfoList
, entry
) {
683 list_del(&bi
->entry
);
687 list_for_each_entry_safe(di
, tmp_di
, &DevInfoList
, entry
) {
689 list_del(&di
->entry
);
695 chipset_init(CONTROLVM_MESSAGE
*inmsg
)
697 static int chipset_inited
;
698 ULTRA_CHIPSET_FEATURE features
= 0;
699 int rc
= CONTROLVM_RESP_SUCCESS
;
701 POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
702 if (chipset_inited
) {
703 LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done.");
704 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
708 POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
710 /* Set features to indicate we support parahotplug (if Command
711 * also supports it). */
713 inmsg
->cmd
.initChipset
.
714 features
& ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG
;
716 /* Set the "reply" bit so Command knows this is a
717 * features-aware driver. */
718 features
|= ULTRA_CHIPSET_FEATURE_REPLY
;
722 cleanup_controlvm_structures();
723 if (inmsg
->hdr
.Flags
.responseExpected
)
724 controlvm_respond_chipset_init(&inmsg
->hdr
, rc
, features
);
728 controlvm_init_response(CONTROLVM_MESSAGE
*msg
,
729 CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
)
731 memset(msg
, 0, sizeof(CONTROLVM_MESSAGE
));
732 memcpy(&msg
->hdr
, msgHdr
, sizeof(CONTROLVM_MESSAGE_HEADER
));
733 msg
->hdr
.PayloadBytes
= 0;
734 msg
->hdr
.PayloadVmOffset
= 0;
735 msg
->hdr
.PayloadMaxBytes
= 0;
737 msg
->hdr
.Flags
.failed
= 1;
738 msg
->hdr
.CompletionStatus
= (U32
) (-response
);
743 controlvm_respond(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
)
745 CONTROLVM_MESSAGE outmsg
;
746 controlvm_init_response(&outmsg
, msgHdr
, response
);
747 /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
748 * back the deviceChangeState structure in the packet. */
749 if (msgHdr
->Id
== CONTROLVM_DEVICE_CHANGESTATE
750 && g_DeviceChangeStatePacket
.deviceChangeState
.busNo
==
752 && g_DeviceChangeStatePacket
.deviceChangeState
.devNo
==
754 outmsg
.cmd
= g_DeviceChangeStatePacket
;
755 if (outmsg
.hdr
.Flags
.testMessage
== 1) {
756 LOGINF("%s controlvm_msg=0x%x response=%d for test message",
757 __func__
, outmsg
.hdr
.Id
, response
);
760 if (!visorchannel_signalinsert(ControlVm_channel
,
761 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
762 LOGERR("signalinsert failed!");
768 controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
,
769 ULTRA_CHIPSET_FEATURE features
)
771 CONTROLVM_MESSAGE outmsg
;
772 controlvm_init_response(&outmsg
, msgHdr
, response
);
773 outmsg
.cmd
.initChipset
.features
= features
;
774 if (!visorchannel_signalinsert(ControlVm_channel
,
775 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
776 LOGERR("signalinsert failed!");
782 controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER
*msgHdr
,
783 int response
, ULTRA_SEGMENT_STATE state
)
785 CONTROLVM_MESSAGE outmsg
;
786 controlvm_init_response(&outmsg
, msgHdr
, response
);
787 outmsg
.cmd
.deviceChangeState
.state
= state
;
788 outmsg
.cmd
.deviceChangeState
.flags
.physicalDevice
= 1;
789 if (!visorchannel_signalinsert(ControlVm_channel
,
790 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
791 LOGERR("signalinsert failed!");
797 visorchipset_save_message(CONTROLVM_MESSAGE
*msg
, CRASH_OBJ_TYPE type
)
799 U32 localSavedCrashMsgOffset
;
800 U16 localSavedCrashMsgCount
;
802 /* get saved message count */
803 if (visorchannel_read(ControlVm_channel
,
804 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
806 &localSavedCrashMsgCount
, sizeof(U16
)) < 0) {
807 LOGERR("failed to get Saved Message Count");
808 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
809 POSTCODE_SEVERITY_ERR
);
813 if (localSavedCrashMsgCount
!= CONTROLVM_CRASHMSG_MAX
) {
814 LOGERR("Saved Message Count incorrect %d",
815 localSavedCrashMsgCount
);
816 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC
,
817 localSavedCrashMsgCount
,
818 POSTCODE_SEVERITY_ERR
);
822 /* get saved crash message offset */
823 if (visorchannel_read(ControlVm_channel
,
824 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
825 SavedCrashMsgOffset
),
826 &localSavedCrashMsgOffset
, sizeof(U32
)) < 0) {
827 LOGERR("failed to get Saved Message Offset");
828 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
829 POSTCODE_SEVERITY_ERR
);
833 if (type
== CRASH_bus
) {
834 if (visorchannel_write(ControlVm_channel
,
835 localSavedCrashMsgOffset
,
836 msg
, sizeof(CONTROLVM_MESSAGE
)) < 0) {
837 LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!");
838 POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC
,
839 POSTCODE_SEVERITY_ERR
);
843 if (visorchannel_write(ControlVm_channel
,
844 localSavedCrashMsgOffset
+
845 sizeof(CONTROLVM_MESSAGE
), msg
,
846 sizeof(CONTROLVM_MESSAGE
)) < 0) {
847 LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!");
848 POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC
,
849 POSTCODE_SEVERITY_ERR
);
854 EXPORT_SYMBOL_GPL(visorchipset_save_message
);
857 bus_responder(CONTROLVM_ID cmdId
, ulong busNo
, int response
)
859 VISORCHIPSET_BUS_INFO
*p
= NULL
;
860 BOOL need_clear
= FALSE
;
862 p
= findbus(&BusInfoList
, busNo
);
864 LOGERR("internal error busNo=%lu", busNo
);
868 if ((cmdId
== CONTROLVM_BUS_CREATE
) &&
869 (response
!= (-CONTROLVM_RESP_ERROR_ALREADY_DONE
)))
870 /* undo the row we just created... */
871 delbusdevices(&DevInfoList
, busNo
);
873 if (cmdId
== CONTROLVM_BUS_CREATE
)
874 p
->state
.created
= 1;
875 if (cmdId
== CONTROLVM_BUS_DESTROY
)
879 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
880 LOGERR("bus_responder no pending msg");
881 return; /* no controlvm response needed */
883 if (p
->pendingMsgHdr
.Id
!= (U32
) cmdId
) {
884 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
887 controlvm_respond(&p
->pendingMsgHdr
, response
);
888 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
891 delbusdevices(&DevInfoList
, busNo
);
896 device_changestate_responder(CONTROLVM_ID cmdId
,
897 ulong busNo
, ulong devNo
, int response
,
898 ULTRA_SEGMENT_STATE responseState
)
900 VISORCHIPSET_DEVICE_INFO
*p
= NULL
;
901 CONTROLVM_MESSAGE outmsg
;
903 p
= finddevice(&DevInfoList
, busNo
, devNo
);
905 LOGERR("internal error; busNo=%lu, devNo=%lu", busNo
, devNo
);
908 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
909 LOGERR("device_responder no pending msg");
910 return; /* no controlvm response needed */
912 if (p
->pendingMsgHdr
.Id
!= cmdId
) {
913 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
917 controlvm_init_response(&outmsg
, &p
->pendingMsgHdr
, response
);
919 outmsg
.cmd
.deviceChangeState
.busNo
= busNo
;
920 outmsg
.cmd
.deviceChangeState
.devNo
= devNo
;
921 outmsg
.cmd
.deviceChangeState
.state
= responseState
;
923 if (!visorchannel_signalinsert(ControlVm_channel
,
924 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
925 LOGERR("signalinsert failed!");
929 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
933 device_responder(CONTROLVM_ID cmdId
, ulong busNo
, ulong devNo
, int response
)
935 VISORCHIPSET_DEVICE_INFO
*p
= NULL
;
936 BOOL need_clear
= FALSE
;
938 p
= finddevice(&DevInfoList
, busNo
, devNo
);
940 LOGERR("internal error; busNo=%lu, devNo=%lu", busNo
, devNo
);
944 if (cmdId
== CONTROLVM_DEVICE_CREATE
)
945 p
->state
.created
= 1;
946 if (cmdId
== CONTROLVM_DEVICE_DESTROY
)
950 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
951 LOGERR("device_responder no pending msg");
952 return; /* no controlvm response needed */
954 if (p
->pendingMsgHdr
.Id
!= (U32
) cmdId
) {
955 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
958 controlvm_respond(&p
->pendingMsgHdr
, response
);
959 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
965 bus_epilog(U32 busNo
,
966 U32 cmd
, CONTROLVM_MESSAGE_HEADER
*msgHdr
,
967 int response
, BOOL needResponse
)
969 BOOL notified
= FALSE
;
971 VISORCHIPSET_BUS_INFO
*pBusInfo
= findbus(&BusInfoList
, busNo
);
974 LOGERR("HUH? bad busNo=%d", busNo
);
978 memcpy(&pBusInfo
->pendingMsgHdr
, msgHdr
,
979 sizeof(CONTROLVM_MESSAGE_HEADER
));
981 pBusInfo
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
983 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
984 if (response
== CONTROLVM_RESP_SUCCESS
) {
986 case CONTROLVM_BUS_CREATE
:
987 /* We can't tell from the bus_create
988 * information which of our 2 bus flavors the
989 * devices on this bus will ultimately end up.
990 * FORTUNATELY, it turns out it is harmless to
991 * send the bus_create to both of them. We can
992 * narrow things down a little bit, though,
993 * because we know: - BusDev_Server can handle
994 * either server or client devices
995 * - BusDev_Client can handle ONLY client
997 if (BusDev_Server_Notifiers
.bus_create
) {
998 (*BusDev_Server_Notifiers
.bus_create
) (busNo
);
1001 if ((!pBusInfo
->flags
.server
) /*client */ &&
1002 BusDev_Client_Notifiers
.bus_create
) {
1003 (*BusDev_Client_Notifiers
.bus_create
) (busNo
);
1007 case CONTROLVM_BUS_DESTROY
:
1008 if (BusDev_Server_Notifiers
.bus_destroy
) {
1009 (*BusDev_Server_Notifiers
.bus_destroy
) (busNo
);
1012 if ((!pBusInfo
->flags
.server
) /*client */ &&
1013 BusDev_Client_Notifiers
.bus_destroy
) {
1014 (*BusDev_Client_Notifiers
.bus_destroy
) (busNo
);
1021 /* The callback function just called above is responsible
1022 * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS
1023 * function, which will call bus_responder()
1027 bus_responder(cmd
, busNo
, response
);
1028 UNLOCKSEM(&NotifierLock
);
1032 device_epilog(U32 busNo
, U32 devNo
, ULTRA_SEGMENT_STATE state
, U32 cmd
,
1033 CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
,
1034 BOOL needResponse
, BOOL for_visorbus
)
1036 VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
= NULL
;
1037 BOOL notified
= FALSE
;
1039 VISORCHIPSET_DEVICE_INFO
*pDevInfo
=
1040 finddevice(&DevInfoList
, busNo
, devNo
);
1042 "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
1047 LOGERR("HUH? bad busNo=%d, devNo=%d", busNo
, devNo
);
1051 notifiers
= &BusDev_Server_Notifiers
;
1053 notifiers
= &BusDev_Client_Notifiers
;
1055 memcpy(&pDevInfo
->pendingMsgHdr
, msgHdr
,
1056 sizeof(CONTROLVM_MESSAGE_HEADER
));
1058 pDevInfo
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
1060 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
1061 if (response
>= 0) {
1063 case CONTROLVM_DEVICE_CREATE
:
1064 if (notifiers
->device_create
) {
1065 (*notifiers
->device_create
) (busNo
, devNo
);
1069 case CONTROLVM_DEVICE_CHANGESTATE
:
1070 /* ServerReady / ServerRunning / SegmentStateRunning */
1071 if (state
.Alive
== SegmentStateRunning
.Alive
&&
1072 state
.Operating
== SegmentStateRunning
.Operating
) {
1073 if (notifiers
->device_resume
) {
1074 (*notifiers
->device_resume
) (busNo
,
1079 /* ServerNotReady / ServerLost / SegmentStateStandby */
1080 else if (state
.Alive
== SegmentStateStandby
.Alive
&&
1082 SegmentStateStandby
.Operating
) {
1083 /* technically this is standby case
1084 * where server is lost
1086 if (notifiers
->device_pause
) {
1087 (*notifiers
->device_pause
) (busNo
,
1091 } else if (state
.Alive
== SegmentStatePaused
.Alive
&&
1093 SegmentStatePaused
.Operating
) {
1094 /* this is lite pause where channel is
1095 * still valid just 'pause' of it
1097 if (busNo
== g_diagpoolBusNo
1098 && devNo
== g_diagpoolDevNo
) {
1099 LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)",
1101 /* this will trigger the
1102 * diag_shutdown.sh script in
1103 * the visorchipset hotplug */
1105 (&Visorchipset_platform_device
.dev
.
1106 kobj
, KOBJ_ONLINE
, envp
);
1110 case CONTROLVM_DEVICE_DESTROY
:
1111 if (notifiers
->device_destroy
) {
1112 (*notifiers
->device_destroy
) (busNo
, devNo
);
1119 /* The callback function just called above is responsible
1120 * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS
1121 * function, which will call device_responder()
1125 device_responder(cmd
, busNo
, devNo
, response
);
1126 UNLOCKSEM(&NotifierLock
);
1130 bus_create(CONTROLVM_MESSAGE
*inmsg
)
1132 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1133 ulong busNo
= cmd
->createBus
.busNo
;
1134 int rc
= CONTROLVM_RESP_SUCCESS
;
1135 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1138 pBusInfo
= findbus(&BusInfoList
, busNo
);
1139 if (pBusInfo
&& (pBusInfo
->state
.created
== 1)) {
1140 LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu already exists",
1142 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, busNo
,
1143 POSTCODE_SEVERITY_ERR
);
1144 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1147 pBusInfo
= kzalloc(sizeof(VISORCHIPSET_BUS_INFO
), GFP_KERNEL
);
1148 if (pBusInfo
== NULL
) {
1149 LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
1151 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, busNo
,
1152 POSTCODE_SEVERITY_ERR
);
1153 rc
= -CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
1157 INIT_LIST_HEAD(&pBusInfo
->entry
);
1158 pBusInfo
->busNo
= busNo
;
1159 pBusInfo
->devNo
= cmd
->createBus
.deviceCount
;
1161 POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1163 if (inmsg
->hdr
.Flags
.testMessage
== 1)
1164 pBusInfo
->chanInfo
.addrType
= ADDRTYPE_localTest
;
1166 pBusInfo
->chanInfo
.addrType
= ADDRTYPE_localPhysical
;
1168 pBusInfo
->flags
.server
= inmsg
->hdr
.Flags
.server
;
1169 pBusInfo
->chanInfo
.channelAddr
= cmd
->createBus
.channelAddr
;
1170 pBusInfo
->chanInfo
.nChannelBytes
= cmd
->createBus
.channelBytes
;
1171 pBusInfo
->chanInfo
.channelTypeGuid
= cmd
->createBus
.busDataTypeGuid
;
1172 pBusInfo
->chanInfo
.channelInstGuid
= cmd
->createBus
.busInstGuid
;
1174 list_add(&pBusInfo
->entry
, &BusInfoList
);
1176 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1179 bus_epilog(busNo
, CONTROLVM_BUS_CREATE
, &inmsg
->hdr
,
1180 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1184 bus_destroy(CONTROLVM_MESSAGE
*inmsg
)
1186 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1187 ulong busNo
= cmd
->destroyBus
.busNo
;
1188 VISORCHIPSET_BUS_INFO
*pBusInfo
;
1189 int rc
= CONTROLVM_RESP_SUCCESS
;
1191 pBusInfo
= findbus(&BusInfoList
, busNo
);
1193 LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo
);
1194 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1197 if (pBusInfo
->state
.created
== 0) {
1198 LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed",
1200 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1205 bus_epilog(busNo
, CONTROLVM_BUS_DESTROY
, &inmsg
->hdr
,
1206 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1210 bus_configure(CONTROLVM_MESSAGE
*inmsg
, PARSER_CONTEXT
*parser_ctx
)
1212 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1213 ulong busNo
= cmd
->configureBus
.busNo
;
1214 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1215 int rc
= CONTROLVM_RESP_SUCCESS
;
1218 busNo
= cmd
->configureBus
.busNo
;
1219 POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1221 pBusInfo
= findbus(&BusInfoList
, busNo
);
1223 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid",
1225 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1226 POSTCODE_SEVERITY_ERR
);
1227 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1230 if (pBusInfo
->state
.created
== 0) {
1231 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet",
1233 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1234 POSTCODE_SEVERITY_ERR
);
1235 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1238 /* TBD - add this check to other commands also... */
1239 if (pBusInfo
->pendingMsgHdr
.Id
!= CONTROLVM_INVALID
) {
1240 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding",
1241 busNo
, (uint
) pBusInfo
->pendingMsgHdr
.Id
);
1242 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1243 POSTCODE_SEVERITY_ERR
);
1244 rc
= -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT
;
1248 pBusInfo
->partitionHandle
= cmd
->configureBus
.guestHandle
;
1249 pBusInfo
->partitionGuid
= parser_id_get(parser_ctx
);
1250 parser_param_start(parser_ctx
, PARSERSTRING_NAME
);
1251 pBusInfo
->name
= parser_string_get(parser_ctx
);
1253 visorchannel_uuid_id(&pBusInfo
->partitionGuid
, s
);
1254 pBusInfo
->procObject
=
1255 visor_proc_CreateObject(PartitionType
, s
, (void *) (pBusInfo
));
1256 if (pBusInfo
->procObject
== NULL
) {
1257 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: busNo=%lu failed to create /proc entry",
1259 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1260 POSTCODE_SEVERITY_ERR
);
1261 rc
= -CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
1264 POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1266 bus_epilog(busNo
, CONTROLVM_BUS_CONFIGURE
, &inmsg
->hdr
,
1267 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1271 my_device_create(CONTROLVM_MESSAGE
*inmsg
)
1273 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1274 ulong busNo
= cmd
->createDevice
.busNo
;
1275 ulong devNo
= cmd
->createDevice
.devNo
;
1276 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1277 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1278 int rc
= CONTROLVM_RESP_SUCCESS
;
1280 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1281 if (pDevInfo
&& (pDevInfo
->state
.created
== 1)) {
1282 LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu already exists",
1284 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1285 POSTCODE_SEVERITY_ERR
);
1286 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1289 pBusInfo
= findbus(&BusInfoList
, busNo
);
1291 LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range",
1293 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1294 POSTCODE_SEVERITY_ERR
);
1295 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1298 if (pBusInfo
->state
.created
== 0) {
1299 LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet",
1301 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1302 POSTCODE_SEVERITY_ERR
);
1303 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1306 pDevInfo
= kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO
), GFP_KERNEL
);
1307 if (pDevInfo
== NULL
) {
1308 LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
1310 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1311 POSTCODE_SEVERITY_ERR
);
1312 rc
= -CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
1316 INIT_LIST_HEAD(&pDevInfo
->entry
);
1317 pDevInfo
->busNo
= busNo
;
1318 pDevInfo
->devNo
= devNo
;
1319 pDevInfo
->devInstGuid
= cmd
->createDevice
.devInstGuid
;
1320 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC
, devNo
, busNo
,
1321 POSTCODE_SEVERITY_INFO
);
1323 if (inmsg
->hdr
.Flags
.testMessage
== 1)
1324 pDevInfo
->chanInfo
.addrType
= ADDRTYPE_localTest
;
1326 pDevInfo
->chanInfo
.addrType
= ADDRTYPE_localPhysical
;
1327 pDevInfo
->chanInfo
.channelAddr
= cmd
->createDevice
.channelAddr
;
1328 pDevInfo
->chanInfo
.nChannelBytes
= cmd
->createDevice
.channelBytes
;
1329 pDevInfo
->chanInfo
.channelTypeGuid
= cmd
->createDevice
.dataTypeGuid
;
1330 pDevInfo
->chanInfo
.intr
= cmd
->createDevice
.intr
;
1331 list_add(&pDevInfo
->entry
, &DevInfoList
);
1332 POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC
, devNo
, busNo
,
1333 POSTCODE_SEVERITY_INFO
);
1335 /* get the bus and devNo for DiagPool channel */
1336 if (is_diagpool_channel(pDevInfo
->chanInfo
.channelTypeGuid
)) {
1337 g_diagpoolBusNo
= busNo
;
1338 g_diagpoolDevNo
= devNo
;
1339 LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu",
1340 g_diagpoolBusNo
, g_diagpoolDevNo
);
1342 device_epilog(busNo
, devNo
, SegmentStateRunning
,
1343 CONTROLVM_DEVICE_CREATE
, &inmsg
->hdr
, rc
,
1344 inmsg
->hdr
.Flags
.responseExpected
== 1,
1345 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1349 my_device_changestate(CONTROLVM_MESSAGE
*inmsg
)
1351 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1352 ulong busNo
= cmd
->deviceChangeState
.busNo
;
1353 ulong devNo
= cmd
->deviceChangeState
.devNo
;
1354 ULTRA_SEGMENT_STATE state
= cmd
->deviceChangeState
.state
;
1355 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1356 int rc
= CONTROLVM_RESP_SUCCESS
;
1358 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1360 LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (doesn't exist)",
1362 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC
, devNo
, busNo
,
1363 POSTCODE_SEVERITY_ERR
);
1364 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1367 if (pDevInfo
->state
.created
== 0) {
1368 LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)",
1370 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC
, devNo
, busNo
,
1371 POSTCODE_SEVERITY_ERR
);
1372 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1375 if ((rc
>= CONTROLVM_RESP_SUCCESS
) && pDevInfo
)
1376 device_epilog(busNo
, devNo
, state
, CONTROLVM_DEVICE_CHANGESTATE
,
1378 inmsg
->hdr
.Flags
.responseExpected
== 1,
1379 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1383 my_device_destroy(CONTROLVM_MESSAGE
*inmsg
)
1385 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1386 ulong busNo
= cmd
->destroyDevice
.busNo
;
1387 ulong devNo
= cmd
->destroyDevice
.devNo
;
1388 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1389 int rc
= CONTROLVM_RESP_SUCCESS
;
1391 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1393 LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid",
1395 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1398 if (pDevInfo
->state
.created
== 0) {
1399 LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed",
1401 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1405 if ((rc
>= CONTROLVM_RESP_SUCCESS
) && pDevInfo
)
1406 device_epilog(busNo
, devNo
, SegmentStateRunning
,
1407 CONTROLVM_DEVICE_DESTROY
, &inmsg
->hdr
, rc
,
1408 inmsg
->hdr
.Flags
.responseExpected
== 1,
1409 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1412 /* When provided with the physical address of the controlvm channel
1413 * (phys_addr), the offset to the payload area we need to manage
1414 * (offset), and the size of this payload area (bytes), fills in the
1415 * CONTROLVM_PAYLOAD_INFO struct. Returns TRUE for success or FALSE
1419 initialize_controlvm_payload_info(HOSTADDRESS phys_addr
, U64 offset
, U32 bytes
,
1420 CONTROLVM_PAYLOAD_INFO
*info
)
1422 U8 __iomem
*payload
= NULL
;
1423 int rc
= CONTROLVM_RESP_SUCCESS
;
1426 LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d",
1427 __FILE__
, __LINE__
);
1428 rc
= -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID
;
1431 memset(info
, 0, sizeof(CONTROLVM_PAYLOAD_INFO
));
1432 if ((offset
== 0) || (bytes
== 0)) {
1433 LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!",
1434 (u64
) offset
, (u64
) bytes
);
1435 rc
= -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID
;
1438 payload
= ioremap_cache(phys_addr
+ offset
, bytes
);
1439 if (payload
== NULL
) {
1440 LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed",
1441 (u64
) offset
, (u64
) bytes
);
1442 rc
= -CONTROLVM_RESP_ERROR_IOREMAP_FAILED
;
1446 info
->offset
= offset
;
1447 info
->bytes
= bytes
;
1448 info
->ptr
= payload
;
1449 LOGINF("offset=%llu, bytes=%lu, ptr=%p",
1450 (u64
) (info
->offset
), (ulong
) (info
->bytes
), info
->ptr
);
1454 if (payload
!= NULL
) {
1463 destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO
*info
)
1465 if (info
->ptr
!= NULL
) {
1469 memset(info
, 0, sizeof(CONTROLVM_PAYLOAD_INFO
));
1473 initialize_controlvm_payload(void)
1475 HOSTADDRESS phys_addr
= visorchannel_get_physaddr(ControlVm_channel
);
1476 U64 payloadOffset
= 0;
1477 U32 payloadBytes
= 0;
1478 if (visorchannel_read(ControlVm_channel
,
1479 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
1480 RequestPayloadOffset
),
1481 &payloadOffset
, sizeof(payloadOffset
)) < 0) {
1482 LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
1483 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC
,
1484 POSTCODE_SEVERITY_ERR
);
1487 if (visorchannel_read(ControlVm_channel
,
1488 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
1489 RequestPayloadBytes
),
1490 &payloadBytes
, sizeof(payloadBytes
)) < 0) {
1491 LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
1492 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC
,
1493 POSTCODE_SEVERITY_ERR
);
1496 initialize_controlvm_payload_info(phys_addr
,
1497 payloadOffset
, payloadBytes
,
1498 &ControlVm_payload_info
);
1501 /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1502 * Returns CONTROLVM_RESP_xxx code.
1505 visorchipset_chipset_ready(void)
1507 kobject_uevent(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_ONLINE
);
1508 return CONTROLVM_RESP_SUCCESS
;
1510 EXPORT_SYMBOL_GPL(visorchipset_chipset_ready
);
1513 visorchipset_chipset_selftest(void)
1515 char env_selftest
[20];
1516 char *envp
[] = { env_selftest
, NULL
};
1517 sprintf(env_selftest
, "SPARSP_SELFTEST=%d", 1);
1518 kobject_uevent_env(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_CHANGE
,
1520 return CONTROLVM_RESP_SUCCESS
;
1522 EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest
);
1524 /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1525 * Returns CONTROLVM_RESP_xxx code.
1528 visorchipset_chipset_notready(void)
1530 kobject_uevent(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_OFFLINE
);
1531 return CONTROLVM_RESP_SUCCESS
;
1533 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready
);
1536 chipset_ready(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1538 int rc
= visorchipset_chipset_ready();
1539 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1541 if (msgHdr
->Flags
.responseExpected
&& !visorchipset_holdchipsetready
)
1542 controlvm_respond(msgHdr
, rc
);
1543 if (msgHdr
->Flags
.responseExpected
&& visorchipset_holdchipsetready
) {
1544 /* Send CHIPSET_READY response when all modules have been loaded
1545 * and disks mounted for the partition
1547 g_ChipSetMsgHdr
= *msgHdr
;
1548 LOGINF("Holding CHIPSET_READY response");
1553 chipset_selftest(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1555 int rc
= visorchipset_chipset_selftest();
1556 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1558 if (msgHdr
->Flags
.responseExpected
)
1559 controlvm_respond(msgHdr
, rc
);
1563 chipset_notready(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1565 int rc
= visorchipset_chipset_notready();
1566 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1568 if (msgHdr
->Flags
.responseExpected
)
1569 controlvm_respond(msgHdr
, rc
);
1572 /* This is your "one-stop" shop for grabbing the next message from the
1573 * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
1576 read_controlvm_event(CONTROLVM_MESSAGE
*msg
)
1578 if (visorchannel_signalremove(ControlVm_channel
,
1579 CONTROLVM_QUEUE_EVENT
, msg
)) {
1581 if (msg
->hdr
.Flags
.testMessage
== 1) {
1582 LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg
->hdr
.Id
);
1591 * The general parahotplug flow works as follows. The visorchipset
1592 * driver receives a DEVICE_CHANGESTATE message from Command
1593 * specifying a physical device to enable or disable. The CONTROLVM
1594 * message handler calls parahotplug_process_message, which then adds
1595 * the message to a global list and kicks off a udev event which
1596 * causes a user level script to enable or disable the specified
1597 * device. The udev script then writes to
1598 * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
1599 * to get called, at which point the appropriate CONTROLVM message is
1600 * retrieved from the list and responded to.
1603 #define PARAHOTPLUG_TIMEOUT_MS 2000
1606 * Generate unique int to match an outstanding CONTROLVM message with a
1607 * udev script /proc response
1610 parahotplug_next_id(void)
1612 static atomic_t id
= ATOMIC_INIT(0);
1613 return atomic_inc_return(&id
);
1617 * Returns the time (in jiffies) when a CONTROLVM message on the list
1618 * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
1620 static unsigned long
1621 parahotplug_next_expiration(void)
1623 return jiffies
+ PARAHOTPLUG_TIMEOUT_MS
* HZ
/ 1000;
1627 * Create a parahotplug_request, which is basically a wrapper for a
1628 * CONTROLVM_MESSAGE that we can stick on a list
1630 static struct parahotplug_request
*
1631 parahotplug_request_create(CONTROLVM_MESSAGE
*msg
)
1633 struct parahotplug_request
*req
=
1634 kmalloc(sizeof(struct parahotplug_request
),
1635 GFP_KERNEL
|__GFP_NORETRY
);
1639 req
->id
= parahotplug_next_id();
1640 req
->expiration
= parahotplug_next_expiration();
1647 * Free a parahotplug_request.
1650 parahotplug_request_destroy(struct parahotplug_request
*req
)
1656 * Cause uevent to run the user level script to do the disable/enable
1657 * specified in (the CONTROLVM message in) the specified
1658 * parahotplug_request
1661 parahotplug_request_kickoff(struct parahotplug_request
*req
)
1663 CONTROLVM_MESSAGE_PACKET
*cmd
= &req
->msg
.cmd
;
1664 char env_cmd
[40], env_id
[40], env_state
[40], env_bus
[40], env_dev
[40],
1667 env_cmd
, env_id
, env_state
, env_bus
, env_dev
, env_func
, NULL
1670 sprintf(env_cmd
, "SPAR_PARAHOTPLUG=1");
1671 sprintf(env_id
, "SPAR_PARAHOTPLUG_ID=%d", req
->id
);
1672 sprintf(env_state
, "SPAR_PARAHOTPLUG_STATE=%d",
1673 cmd
->deviceChangeState
.state
.Active
);
1674 sprintf(env_bus
, "SPAR_PARAHOTPLUG_BUS=%d",
1675 cmd
->deviceChangeState
.busNo
);
1676 sprintf(env_dev
, "SPAR_PARAHOTPLUG_DEVICE=%d",
1677 cmd
->deviceChangeState
.devNo
>> 3);
1678 sprintf(env_func
, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1679 cmd
->deviceChangeState
.devNo
& 0x7);
1681 LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n",
1682 cmd
->deviceChangeState
.state
.Active
,
1683 cmd
->deviceChangeState
.busNo
, cmd
->deviceChangeState
.devNo
>> 3,
1684 cmd
->deviceChangeState
.devNo
& 7, req
->id
);
1686 kobject_uevent_env(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_CHANGE
,
1691 * Remove any request from the list that's been on there too long and
1692 * respond with an error.
1695 parahotplug_process_list(void)
1697 struct list_head
*pos
= NULL
;
1698 struct list_head
*tmp
= NULL
;
1700 spin_lock(&Parahotplug_request_list_lock
);
1702 list_for_each_safe(pos
, tmp
, &Parahotplug_request_list
) {
1703 struct parahotplug_request
*req
=
1704 list_entry(pos
, struct parahotplug_request
, list
);
1705 if (time_after_eq(jiffies
, req
->expiration
)) {
1707 if (req
->msg
.hdr
.Flags
.responseExpected
)
1708 controlvm_respond_physdev_changestate(
1710 CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT
,
1711 req
->msg
.cmd
.deviceChangeState
.state
);
1712 parahotplug_request_destroy(req
);
1716 spin_unlock(&Parahotplug_request_list_lock
);
1720 * Called from the /proc handler, which means the user script has
1721 * finished the enable/disable. Find the matching identifier, and
1722 * respond to the CONTROLVM message with success.
1725 parahotplug_request_complete(int id
, U16 active
)
1727 struct list_head
*pos
= NULL
;
1728 struct list_head
*tmp
= NULL
;
1730 spin_lock(&Parahotplug_request_list_lock
);
1732 /* Look for a request matching "id". */
1733 list_for_each_safe(pos
, tmp
, &Parahotplug_request_list
) {
1734 struct parahotplug_request
*req
=
1735 list_entry(pos
, struct parahotplug_request
, list
);
1736 if (req
->id
== id
) {
1737 /* Found a match. Remove it from the list and
1741 spin_unlock(&Parahotplug_request_list_lock
);
1742 req
->msg
.cmd
.deviceChangeState
.state
.Active
= active
;
1743 if (req
->msg
.hdr
.Flags
.responseExpected
)
1744 controlvm_respond_physdev_changestate(
1745 &req
->msg
.hdr
, CONTROLVM_RESP_SUCCESS
,
1746 req
->msg
.cmd
.deviceChangeState
.state
);
1747 parahotplug_request_destroy(req
);
1752 spin_unlock(&Parahotplug_request_list_lock
);
1757 * Enables or disables a PCI device by kicking off a udev script
1760 parahotplug_process_message(CONTROLVM_MESSAGE
*inmsg
)
1762 struct parahotplug_request
*req
;
1764 req
= parahotplug_request_create(inmsg
);
1767 LOGERR("parahotplug_process_message: couldn't allocate request");
1771 if (inmsg
->cmd
.deviceChangeState
.state
.Active
) {
1772 /* For enable messages, just respond with success
1773 * right away. This is a bit of a hack, but there are
1774 * issues with the early enable messages we get (with
1775 * either the udev script not detecting that the device
1776 * is up, or not getting called at all). Fortunately
1777 * the messages that get lost don't matter anyway, as
1778 * devices are automatically enabled at
1781 parahotplug_request_kickoff(req
);
1782 controlvm_respond_physdev_changestate(&inmsg
->hdr
,
1783 CONTROLVM_RESP_SUCCESS
,
1785 deviceChangeState
.state
);
1786 parahotplug_request_destroy(req
);
1788 /* For disable messages, add the request to the
1789 * request list before kicking off the udev script. It
1790 * won't get responded to until the script has
1791 * indicated it's done.
1793 spin_lock(&Parahotplug_request_list_lock
);
1794 list_add_tail(&(req
->list
), &Parahotplug_request_list
);
1795 spin_unlock(&Parahotplug_request_list_lock
);
1797 parahotplug_request_kickoff(req
);
1802 * Gets called when the udev script writes to
1803 * /proc/visorchipset/parahotplug. Expects input in the form of "<id>
1804 * <active>" where <id> is the identifier passed to the script that
1805 * matches a request on the request list, and <active> is 0 or 1
1806 * indicating whether the device is now enabled or not.
1809 parahotplug_proc_write(struct file
*file
, const char __user
*buffer
,
1810 size_t count
, loff_t
*ppos
)
1816 if (count
> sizeof(buf
) - 1) {
1817 LOGERR("parahotplug_proc_write: count (%d) exceeds size of buffer (%d)",
1818 (int) count
, (int) sizeof(buf
));
1821 if (copy_from_user(buf
, buffer
, count
)) {
1822 LOGERR("parahotplug_proc_write: copy_from_user failed");
1827 if (sscanf(buf
, "%u %hu", &id
, &active
) != 2) {
1832 if (active
!= 1 && active
!= 0) {
1833 LOGERR("parahotplug_proc_write: invalid active field");
1837 parahotplug_request_complete((int) id
, (U16
) active
);
1842 static const struct file_operations parahotplug_proc_fops
= {
1843 .owner
= THIS_MODULE
,
1844 .read
= visorchipset_proc_read_writeonly
,
1845 .write
= parahotplug_proc_write
,
1848 /* Process a controlvm message.
1850 * FALSE - this function will return FALSE only in the case where the
1851 * controlvm message was NOT processed, but processing must be
1852 * retried before reading the next controlvm message; a
1853 * scenario where this can occur is when we need to throttle
1854 * the allocation of memory in which to copy out controlvm
1856 * TRUE - processing of the controlvm message completed,
1857 * either successfully or with an error.
1860 handle_command(CONTROLVM_MESSAGE inmsg
, HOSTADDRESS channel_addr
)
1862 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
.cmd
;
1863 U64 parametersAddr
= 0;
1864 U32 parametersBytes
= 0;
1865 PARSER_CONTEXT
*parser_ctx
= NULL
;
1866 BOOL isLocalAddr
= FALSE
;
1867 CONTROLVM_MESSAGE ackmsg
;
1869 /* create parsing context if necessary */
1870 isLocalAddr
= (inmsg
.hdr
.Flags
.testMessage
== 1);
1871 if (channel_addr
== 0) {
1872 LOGERR("HUH? channel_addr is 0!");
1875 parametersAddr
= channel_addr
+ inmsg
.hdr
.PayloadVmOffset
;
1876 parametersBytes
= inmsg
.hdr
.PayloadBytes
;
1878 /* Parameter and channel addresses within test messages actually lie
1879 * within our OS-controlled memory. We need to know that, because it
1880 * makes a difference in how we compute the virtual address.
1882 if (parametersAddr
!= 0 && parametersBytes
!= 0) {
1885 parser_init_byteStream(parametersAddr
, parametersBytes
,
1886 isLocalAddr
, &retry
);
1889 LOGWRN("throttling to copy payload");
1892 LOGWRN("parsing failed");
1893 LOGWRN("inmsg.hdr.Id=0x%lx", (ulong
) inmsg
.hdr
.Id
);
1894 LOGWRN("parametersAddr=0x%llx", (u64
) parametersAddr
);
1895 LOGWRN("parametersBytes=%lu", (ulong
) parametersBytes
);
1896 LOGWRN("isLocalAddr=%d", isLocalAddr
);
1901 controlvm_init_response(&ackmsg
, &inmsg
.hdr
,
1902 CONTROLVM_RESP_SUCCESS
);
1903 if ((ControlVm_channel
)
1905 (!visorchannel_signalinsert
1906 (ControlVm_channel
, CONTROLVM_QUEUE_ACK
, &ackmsg
)))
1907 LOGWRN("failed to send ACK failed");
1909 switch (inmsg
.hdr
.Id
) {
1910 case CONTROLVM_CHIPSET_INIT
:
1911 LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)",
1912 (ulong
) inmsg
.cmd
.initChipset
.busCount
,
1913 (ulong
) inmsg
.cmd
.initChipset
.switchCount
);
1914 chipset_init(&inmsg
);
1916 case CONTROLVM_BUS_CREATE
:
1917 LOGINF("BUS_CREATE(%lu,#devs=%lu)",
1918 (ulong
) cmd
->createBus
.busNo
,
1919 (ulong
) cmd
->createBus
.deviceCount
);
1922 case CONTROLVM_BUS_DESTROY
:
1923 LOGINF("BUS_DESTROY(%lu)", (ulong
) cmd
->destroyBus
.busNo
);
1924 bus_destroy(&inmsg
);
1926 case CONTROLVM_BUS_CONFIGURE
:
1927 LOGINF("BUS_CONFIGURE(%lu)", (ulong
) cmd
->configureBus
.busNo
);
1928 bus_configure(&inmsg
, parser_ctx
);
1930 case CONTROLVM_DEVICE_CREATE
:
1931 LOGINF("DEVICE_CREATE(%lu,%lu)",
1932 (ulong
) cmd
->createDevice
.busNo
,
1933 (ulong
) cmd
->createDevice
.devNo
);
1934 my_device_create(&inmsg
);
1936 case CONTROLVM_DEVICE_CHANGESTATE
:
1937 if (cmd
->deviceChangeState
.flags
.physicalDevice
) {
1938 LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)",
1939 (ulong
) cmd
->deviceChangeState
.busNo
,
1940 (ulong
) cmd
->deviceChangeState
.devNo
,
1941 (ulong
) cmd
->deviceChangeState
.state
.Active
);
1942 parahotplug_process_message(&inmsg
);
1944 LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)",
1945 (ulong
) cmd
->deviceChangeState
.busNo
,
1946 (ulong
) cmd
->deviceChangeState
.devNo
,
1947 (ulong
) cmd
->deviceChangeState
.state
.Alive
);
1948 /* save the hdr and cmd structures for later use */
1949 /* when sending back the response to Command */
1950 my_device_changestate(&inmsg
);
1951 g_DiagMsgHdr
= inmsg
.hdr
;
1952 g_DeviceChangeStatePacket
= inmsg
.cmd
;
1956 case CONTROLVM_DEVICE_DESTROY
:
1957 LOGINF("DEVICE_DESTROY(%lu,%lu)",
1958 (ulong
) cmd
->destroyDevice
.busNo
,
1959 (ulong
) cmd
->destroyDevice
.devNo
);
1960 my_device_destroy(&inmsg
);
1962 case CONTROLVM_DEVICE_CONFIGURE
:
1963 LOGINF("DEVICE_CONFIGURE(%lu,%lu)",
1964 (ulong
) cmd
->configureDevice
.busNo
,
1965 (ulong
) cmd
->configureDevice
.devNo
);
1966 /* no op for now, just send a respond that we passed */
1967 if (inmsg
.hdr
.Flags
.responseExpected
)
1968 controlvm_respond(&inmsg
.hdr
, CONTROLVM_RESP_SUCCESS
);
1970 case CONTROLVM_CHIPSET_READY
:
1971 LOGINF("CHIPSET_READY");
1972 chipset_ready(&inmsg
.hdr
);
1974 case CONTROLVM_CHIPSET_SELFTEST
:
1975 LOGINF("CHIPSET_SELFTEST");
1976 chipset_selftest(&inmsg
.hdr
);
1978 case CONTROLVM_CHIPSET_STOP
:
1979 LOGINF("CHIPSET_STOP");
1980 chipset_notready(&inmsg
.hdr
);
1983 LOGERR("unrecognized controlvm cmd=%d", (int) inmsg
.hdr
.Id
);
1984 if (inmsg
.hdr
.Flags
.responseExpected
)
1985 controlvm_respond(&inmsg
.hdr
,
1986 -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN
);
1990 if (parser_ctx
!= NULL
) {
1991 parser_done(parser_ctx
);
1997 HOSTADDRESS
controlvm_get_channel_address(void)
2002 if (!VMCALL_SUCCESSFUL(Issue_VMCALL_IO_CONTROLVM_ADDR(&addr
, &size
))) {
2003 ERRDRV("%s - vmcall to determine controlvm channel addr failed",
2007 INFODRV("controlvm addr=%Lx", addr
);
2012 controlvm_periodic_work(struct work_struct
*work
)
2014 VISORCHIPSET_CHANNEL_INFO chanInfo
;
2015 CONTROLVM_MESSAGE inmsg
;
2016 BOOL gotACommand
= FALSE
;
2017 BOOL handle_command_failed
= FALSE
;
2018 static U64 Poll_Count
;
2020 /* make sure visorbus server is registered for controlvm callbacks */
2021 if (visorchipset_serverregwait
&& !serverregistered
)
2023 /* make sure visorclientbus server is regsitered for controlvm
2026 if (visorchipset_clientregwait
&& !clientregistered
)
2029 memset(&chanInfo
, 0, sizeof(VISORCHIPSET_CHANNEL_INFO
));
2032 if (Poll_Count
>= 250)
2037 /* Check events to determine if response to CHIPSET_READY
2040 if (visorchipset_holdchipsetready
2041 && (g_ChipSetMsgHdr
.Id
!= CONTROLVM_INVALID
)) {
2042 if (check_chipset_events() == 1) {
2043 LOGINF("Sending CHIPSET_READY response");
2044 controlvm_respond(&g_ChipSetMsgHdr
, 0);
2045 clear_chipset_events();
2046 memset(&g_ChipSetMsgHdr
, 0,
2047 sizeof(CONTROLVM_MESSAGE_HEADER
));
2051 while (visorchannel_signalremove(ControlVm_channel
,
2052 CONTROLVM_QUEUE_RESPONSE
,
2054 if (inmsg
.hdr
.PayloadMaxBytes
!= 0) {
2055 LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
2056 (ulong
) inmsg
.hdr
.PayloadMaxBytes
,
2057 (ulong
) inmsg
.hdr
.PayloadVmOffset
,
2062 if (ControlVm_Pending_Msg_Valid
) {
2063 /* we throttled processing of a prior
2064 * msg, so try to process it again
2065 * rather than reading a new one
2067 inmsg
= ControlVm_Pending_Msg
;
2068 ControlVm_Pending_Msg_Valid
= FALSE
;
2071 gotACommand
= read_controlvm_event(&inmsg
);
2074 handle_command_failed
= FALSE
;
2075 while (gotACommand
&& (!handle_command_failed
)) {
2076 Most_recent_message_jiffies
= jiffies
;
2077 if (handle_command(inmsg
,
2078 visorchannel_get_physaddr
2079 (ControlVm_channel
)))
2080 gotACommand
= read_controlvm_event(&inmsg
);
2082 /* this is a scenario where throttling
2083 * is required, but probably NOT an
2084 * error...; we stash the current
2085 * controlvm msg so we will attempt to
2086 * reprocess it on our next loop
2088 handle_command_failed
= TRUE
;
2089 ControlVm_Pending_Msg
= inmsg
;
2090 ControlVm_Pending_Msg_Valid
= TRUE
;
2094 /* parahotplug_worker */
2095 parahotplug_process_list();
2099 if (time_after(jiffies
,
2100 Most_recent_message_jiffies
+ (HZ
* MIN_IDLE_SECONDS
))) {
2101 /* it's been longer than MIN_IDLE_SECONDS since we
2102 * processed our last controlvm message; slow down the
2105 if (Poll_jiffies
!= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
) {
2106 LOGINF("switched to slow controlvm polling");
2107 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
;
2110 if (Poll_jiffies
!= POLLJIFFIES_CONTROLVMCHANNEL_FAST
) {
2111 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_FAST
;
2112 LOGINF("switched to fast controlvm polling");
2116 queue_delayed_work(Periodic_controlvm_workqueue
,
2117 &Periodic_controlvm_work
, Poll_jiffies
);
2121 setup_crash_devices_work_queue(struct work_struct
*work
)
2124 CONTROLVM_MESSAGE localCrashCreateBusMsg
;
2125 CONTROLVM_MESSAGE localCrashCreateDevMsg
;
2126 CONTROLVM_MESSAGE msg
;
2127 U32 localSavedCrashMsgOffset
;
2128 U16 localSavedCrashMsgCount
;
2130 /* make sure visorbus server is registered for controlvm callbacks */
2131 if (visorchipset_serverregwait
&& !serverregistered
)
2134 /* make sure visorclientbus server is regsitered for controlvm
2137 if (visorchipset_clientregwait
&& !clientregistered
)
2140 POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
2142 /* send init chipset msg */
2143 msg
.hdr
.Id
= CONTROLVM_CHIPSET_INIT
;
2144 msg
.cmd
.initChipset
.busCount
= 23;
2145 msg
.cmd
.initChipset
.switchCount
= 0;
2149 /* get saved message count */
2150 if (visorchannel_read(ControlVm_channel
,
2151 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
2152 SavedCrashMsgCount
),
2153 &localSavedCrashMsgCount
, sizeof(U16
)) < 0) {
2154 LOGERR("failed to get Saved Message Count");
2155 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
2156 POSTCODE_SEVERITY_ERR
);
2160 if (localSavedCrashMsgCount
!= CONTROLVM_CRASHMSG_MAX
) {
2161 LOGERR("Saved Message Count incorrect %d",
2162 localSavedCrashMsgCount
);
2163 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC
,
2164 localSavedCrashMsgCount
,
2165 POSTCODE_SEVERITY_ERR
);
2169 /* get saved crash message offset */
2170 if (visorchannel_read(ControlVm_channel
,
2171 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
2172 SavedCrashMsgOffset
),
2173 &localSavedCrashMsgOffset
, sizeof(U32
)) < 0) {
2174 LOGERR("failed to get Saved Message Offset");
2175 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
2176 POSTCODE_SEVERITY_ERR
);
2180 /* read create device message for storage bus offset */
2181 if (visorchannel_read(ControlVm_channel
,
2182 localSavedCrashMsgOffset
,
2183 &localCrashCreateBusMsg
,
2184 sizeof(CONTROLVM_MESSAGE
)) < 0) {
2185 LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!");
2186 POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC
,
2187 POSTCODE_SEVERITY_ERR
);
2191 /* read create device message for storage device */
2192 if (visorchannel_read(ControlVm_channel
,
2193 localSavedCrashMsgOffset
+
2194 sizeof(CONTROLVM_MESSAGE
),
2195 &localCrashCreateDevMsg
,
2196 sizeof(CONTROLVM_MESSAGE
)) < 0) {
2197 LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!");
2198 POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC
,
2199 POSTCODE_SEVERITY_ERR
);
2203 /* reuse IOVM create bus message */
2204 if (localCrashCreateBusMsg
.cmd
.createBus
.channelAddr
!= 0)
2205 bus_create(&localCrashCreateBusMsg
);
2207 LOGERR("CrashCreateBusMsg is null, no dump will be taken");
2208 POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC
,
2209 POSTCODE_SEVERITY_ERR
);
2213 /* reuse create device message for storage device */
2214 if (localCrashCreateDevMsg
.cmd
.createDevice
.channelAddr
!= 0)
2215 my_device_create(&localCrashCreateDevMsg
);
2217 LOGERR("CrashCreateDevMsg is null, no dump will be taken");
2218 POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC
,
2219 POSTCODE_SEVERITY_ERR
);
2222 LOGINF("Bus and device ready for dumping");
2223 POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2228 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
;
2230 queue_delayed_work(Periodic_controlvm_workqueue
,
2231 &Periodic_controlvm_work
, Poll_jiffies
);
2235 bus_create_response(ulong busNo
, int response
)
2237 bus_responder(CONTROLVM_BUS_CREATE
, busNo
, response
);
2241 bus_destroy_response(ulong busNo
, int response
)
2243 bus_responder(CONTROLVM_BUS_DESTROY
, busNo
, response
);
2247 device_create_response(ulong busNo
, ulong devNo
, int response
)
2249 device_responder(CONTROLVM_DEVICE_CREATE
, busNo
, devNo
, response
);
2253 device_destroy_response(ulong busNo
, ulong devNo
, int response
)
2255 device_responder(CONTROLVM_DEVICE_DESTROY
, busNo
, devNo
, response
);
2259 visorchipset_device_pause_response(ulong busNo
, ulong devNo
, int response
)
2262 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE
,
2263 busNo
, devNo
, response
,
2264 SegmentStateStandby
);
2266 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response
);
2269 device_resume_response(ulong busNo
, ulong devNo
, int response
)
2271 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE
,
2272 busNo
, devNo
, response
,
2273 SegmentStateRunning
);
2277 visorchipset_get_bus_info(ulong busNo
, VISORCHIPSET_BUS_INFO
*busInfo
)
2279 void *p
= findbus(&BusInfoList
, busNo
);
2281 LOGERR("(%lu) failed", busNo
);
2284 memcpy(busInfo
, p
, sizeof(VISORCHIPSET_BUS_INFO
));
2287 EXPORT_SYMBOL_GPL(visorchipset_get_bus_info
);
2290 visorchipset_set_bus_context(ulong busNo
, void *context
)
2292 VISORCHIPSET_BUS_INFO
*p
= findbus(&BusInfoList
, busNo
);
2294 LOGERR("(%lu) failed", busNo
);
2297 p
->bus_driver_context
= context
;
2300 EXPORT_SYMBOL_GPL(visorchipset_set_bus_context
);
2303 visorchipset_get_device_info(ulong busNo
, ulong devNo
,
2304 VISORCHIPSET_DEVICE_INFO
*devInfo
)
2306 void *p
= finddevice(&DevInfoList
, busNo
, devNo
);
2308 LOGERR("(%lu,%lu) failed", busNo
, devNo
);
2311 memcpy(devInfo
, p
, sizeof(VISORCHIPSET_DEVICE_INFO
));
2314 EXPORT_SYMBOL_GPL(visorchipset_get_device_info
);
2317 visorchipset_set_device_context(ulong busNo
, ulong devNo
, void *context
)
2319 VISORCHIPSET_DEVICE_INFO
*p
= finddevice(&DevInfoList
, busNo
, devNo
);
2321 LOGERR("(%lu,%lu) failed", busNo
, devNo
);
2324 p
->bus_driver_context
= context
;
2327 EXPORT_SYMBOL_GPL(visorchipset_set_device_context
);
2329 /* Generic wrapper function for allocating memory from a kmem_cache pool.
2332 visorchipset_cache_alloc(struct kmem_cache
*pool
, BOOL ok_to_block
,
2342 /* __GFP_NORETRY means "ok to fail", meaning
2343 * kmem_cache_alloc() can return NULL, implying the caller CAN
2344 * cope with failure. If you do NOT specify __GFP_NORETRY,
2345 * Linux will go to extreme measures to get memory for you
2346 * (like, invoke oom killer), which will probably cripple the
2349 gfp
|= __GFP_NORETRY
;
2350 p
= kmem_cache_alloc(pool
, gfp
);
2352 LOGERR("kmem_cache_alloc failed early @%s:%d\n", fn
, ln
);
2355 atomic_inc(&Visorchipset_cache_buffers_in_use
);
2359 /* Generic wrapper function for freeing memory from a kmem_cache pool.
2362 visorchipset_cache_free(struct kmem_cache
*pool
, void *p
, char *fn
, int ln
)
2365 LOGERR("NULL pointer @%s:%d\n", fn
, ln
);
2368 atomic_dec(&Visorchipset_cache_buffers_in_use
);
2369 kmem_cache_free(pool
, p
);
2372 #define gettoken(bufp) strsep(bufp, " -\t\n")
2375 chipset_proc_write(struct file
*file
, const char __user
*buffer
,
2376 size_t count
, loff_t
*ppos
)
2381 if (count
> sizeof(buf
) - 1) {
2382 LOGERR("chipset_proc_write: count (%d) exceeds size of buffer (%d)",
2383 (int) count
, (int) sizeof(buffer
));
2386 if (copy_from_user(buf
, buffer
, count
)) {
2387 LOGERR("chipset_proc_write: copy_from_user failed");
2393 token
= gettoken(&p
);
2395 if (strcmp(token
, "CALLHOMEDISK_MOUNTED") == 0) {
2396 token
= gettoken(&p
);
2397 /* The Call Home Disk has been mounted */
2398 if (strcmp(token
, "0") == 0)
2399 chipset_events
[0] = 1;
2400 } else if (strcmp(token
, "MODULES_LOADED") == 0) {
2401 token
= gettoken(&p
);
2402 /* All modules for the partition have been loaded */
2403 if (strcmp(token
, "0") == 0)
2404 chipset_events
[1] = 1;
2405 } else if (token
== NULL
) {
2406 /* No event specified */
2407 LOGERR("No event was specified to send CHIPSET_READY response");
2410 /* Unsupported event specified */
2411 LOGERR("%s is an invalid event for sending CHIPSET_READY response", token
);
2419 visorchipset_proc_read_writeonly(struct file
*file
, char __user
*buf
,
2420 size_t len
, loff_t
*offset
)
2425 static const struct file_operations chipset_proc_fops
= {
2426 .owner
= THIS_MODULE
,
2427 .read
= visorchipset_proc_read_writeonly
,
2428 .write
= chipset_proc_write
,
2432 visorchipset_init(void)
2438 if (!unisys_spar_platform
)
2441 LOGINF("chipset driver version %s loaded", VERSION
);
2442 /* process module options */
2443 POSTCODE_LINUX_2(DRIVER_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
2445 LOGINF("option - testvnic=%d", visorchipset_testvnic
);
2446 LOGINF("option - testvnicclient=%d", visorchipset_testvnicclient
);
2447 LOGINF("option - testmsg=%d", visorchipset_testmsg
);
2448 LOGINF("option - testteardown=%d", visorchipset_testteardown
);
2449 LOGINF("option - major=%d", visorchipset_major
);
2450 LOGINF("option - serverregwait=%d", visorchipset_serverregwait
);
2451 LOGINF("option - clientregwait=%d", visorchipset_clientregwait
);
2452 LOGINF("option - holdchipsetready=%d", visorchipset_holdchipsetready
);
2454 memset(&BusDev_Server_Notifiers
, 0, sizeof(BusDev_Server_Notifiers
));
2455 memset(&BusDev_Client_Notifiers
, 0, sizeof(BusDev_Client_Notifiers
));
2456 memset(&ControlVm_payload_info
, 0, sizeof(ControlVm_payload_info
));
2457 memset(&LiveDump_info
, 0, sizeof(LiveDump_info
));
2458 atomic_set(&LiveDump_info
.buffers_in_use
, 0);
2460 if (visorchipset_testvnic
) {
2461 ERRDRV("testvnic option no longer supported: (status = %d)\n",
2463 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC
, x
, DIAG_SEVERITY_ERR
);
2468 addr
= controlvm_get_channel_address();
2471 visorchannel_create_with_lock
2473 sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
),
2474 UltraControlvmChannelProtocolGuid
);
2475 if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
2476 (visorchannel_get_header(ControlVm_channel
),
2478 LOGINF("Channel %s (ControlVm) discovered",
2479 visorchannel_id(ControlVm_channel
, s
));
2480 initialize_controlvm_payload();
2482 LOGERR("controlvm channel is invalid");
2483 visorchannel_destroy(ControlVm_channel
);
2484 ControlVm_channel
= NULL
;
2488 LOGERR("no controlvm channel discovered");
2492 MajorDev
= MKDEV(visorchipset_major
, 0);
2493 rc
= visorchipset_file_init(MajorDev
, &ControlVm_channel
);
2495 ERRDRV("visorchipset_file_init(MajorDev, &ControlVm_channel): error (status=%d)\n", rc
);
2496 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2501 memset(PartitionPropertyNames
, 0, sizeof(PartitionPropertyNames
));
2502 InitPartitionProperties();
2504 PartitionType
= visor_proc_CreateType(ProcDir
, PartitionTypeNames
,
2506 PartitionPropertyNames
,
2507 &show_partition_property
);
2509 memset(&g_DiagMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2511 chipset_proc_dir
= proc_create(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN
,
2512 0644, ProcDir
, &chipset_proc_fops
);
2513 memset(&g_ChipSetMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2515 parahotplug_proc_dir
=
2516 proc_create(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN
, 0200,
2517 ProcDir
, ¶hotplug_proc_fops
);
2518 memset(&g_DelDumpMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2520 Putfile_buffer_list_pool
=
2521 kmem_cache_create(Putfile_buffer_list_pool_name
,
2522 sizeof(struct putfile_buffer_entry
),
2523 0, SLAB_HWCACHE_ALIGN
, NULL
);
2524 if (!Putfile_buffer_list_pool
) {
2525 ERRDRV("failed to alloc Putfile_buffer_list_pool: (status=-1)\n");
2526 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2530 if (visorchipset_disable_controlvm
) {
2531 LOGINF("visorchipset_init:controlvm disabled");
2533 /* if booting in a crash kernel */
2534 if (visorchipset_crash_kernel
)
2535 INIT_DELAYED_WORK(&Periodic_controlvm_work
,
2536 setup_crash_devices_work_queue
);
2538 INIT_DELAYED_WORK(&Periodic_controlvm_work
,
2539 controlvm_periodic_work
);
2540 Periodic_controlvm_workqueue
=
2541 create_singlethread_workqueue("visorchipset_controlvm");
2543 if (Periodic_controlvm_workqueue
== NULL
) {
2544 ERRDRV("cannot create controlvm workqueue: (status=%d)\n",
2546 POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC
,
2551 Most_recent_message_jiffies
= jiffies
;
2552 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_FAST
;
2553 rc
= queue_delayed_work(Periodic_controlvm_workqueue
,
2554 &Periodic_controlvm_work
, Poll_jiffies
);
2556 ERRDRV("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies): error (status=%d)\n", rc
);
2557 POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC
,
2564 Visorchipset_platform_device
.dev
.devt
= MajorDev
;
2565 if (platform_device_register(&Visorchipset_platform_device
) < 0) {
2566 ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n");
2567 POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2571 LOGINF("visorchipset device created");
2572 POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC
, POSTCODE_SEVERITY_INFO
);
2576 LOGERR("visorchipset_init failed");
2577 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC
, rc
,
2578 POSTCODE_SEVERITY_ERR
);
2584 visorchipset_exit(void)
2587 POSTCODE_LINUX_2(DRIVER_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2589 if (visorchipset_disable_controlvm
) {
2592 cancel_delayed_work(&Periodic_controlvm_work
);
2593 flush_workqueue(Periodic_controlvm_workqueue
);
2594 destroy_workqueue(Periodic_controlvm_workqueue
);
2595 Periodic_controlvm_workqueue
= NULL
;
2596 destroy_controlvm_payload_info(&ControlVm_payload_info
);
2598 Test_Vnic_channel
= NULL
;
2599 if (Putfile_buffer_list_pool
) {
2600 kmem_cache_destroy(Putfile_buffer_list_pool
);
2601 Putfile_buffer_list_pool
= NULL
;
2604 cleanup_controlvm_structures();
2606 if (PartitionType
) {
2607 visor_proc_DestroyType(PartitionType
);
2608 PartitionType
= NULL
;
2610 if (diag_proc_dir
) {
2611 remove_proc_entry(VISORCHIPSET_DIAG_PROC_ENTRY_FN
, ProcDir
);
2612 diag_proc_dir
= NULL
;
2614 memset(&g_DiagMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2616 if (chipset_proc_dir
) {
2617 remove_proc_entry(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN
, ProcDir
);
2618 chipset_proc_dir
= NULL
;
2620 memset(&g_ChipSetMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2622 if (parahotplug_proc_dir
) {
2623 remove_proc_entry(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN
,
2625 parahotplug_proc_dir
= NULL
;
2628 memset(&g_DelDumpMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2631 LOGINF("Channel %s (ControlVm) disconnected",
2632 visorchannel_id(ControlVm_channel
, s
));
2633 visorchannel_destroy(ControlVm_channel
);
2635 visorchipset_file_cleanup();
2636 POSTCODE_LINUX_2(DRIVER_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2637 LOGINF("chipset driver unloaded");
2640 module_param_named(testvnic
, visorchipset_testvnic
, int, S_IRUGO
);
2641 MODULE_PARM_DESC(visorchipset_testvnic
, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
2642 int visorchipset_testvnic
= 0;
2644 module_param_named(testvnicclient
, visorchipset_testvnicclient
, int, S_IRUGO
);
2645 MODULE_PARM_DESC(visorchipset_testvnicclient
, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
2646 int visorchipset_testvnicclient
= 0;
2648 module_param_named(testmsg
, visorchipset_testmsg
, int, S_IRUGO
);
2649 MODULE_PARM_DESC(visorchipset_testmsg
,
2650 "1 to manufacture the chipset, bus, and switch messages");
2651 int visorchipset_testmsg
= 0;
2653 module_param_named(major
, visorchipset_major
, int, S_IRUGO
);
2654 MODULE_PARM_DESC(visorchipset_major
, "major device number to use for the device node");
2655 int visorchipset_major
= 0;
2657 module_param_named(serverregwait
, visorchipset_serverregwait
, int, S_IRUGO
);
2658 MODULE_PARM_DESC(visorchipset_serverreqwait
,
2659 "1 to have the module wait for the visor bus to register");
2660 int visorchipset_serverregwait
= 0; /* default is off */
2661 module_param_named(clientregwait
, visorchipset_clientregwait
, int, S_IRUGO
);
2662 MODULE_PARM_DESC(visorchipset_clientregwait
, "1 to have the module wait for the visorclientbus to register");
2663 int visorchipset_clientregwait
= 1; /* default is on */
2664 module_param_named(testteardown
, visorchipset_testteardown
, int, S_IRUGO
);
2665 MODULE_PARM_DESC(visorchipset_testteardown
,
2666 "1 to test teardown of the chipset, bus, and switch");
2667 int visorchipset_testteardown
= 0; /* default is off */
2668 module_param_named(disable_controlvm
, visorchipset_disable_controlvm
, int,
2670 MODULE_PARM_DESC(visorchipset_disable_controlvm
,
2671 "1 to disable polling of controlVm channel");
2672 int visorchipset_disable_controlvm
= 0; /* default is off */
2673 module_param_named(crash_kernel
, visorchipset_crash_kernel
, int, S_IRUGO
);
2674 MODULE_PARM_DESC(visorchipset_crash_kernel
,
2675 "1 means we are running in crash kernel");
2676 int visorchipset_crash_kernel
= 0; /* default is running in non-crash kernel */
2677 module_param_named(holdchipsetready
, visorchipset_holdchipsetready
,
2679 MODULE_PARM_DESC(visorchipset_holdchipsetready
,
2680 "1 to hold response to CHIPSET_READY");
2681 int visorchipset_holdchipsetready
= 0; /* default is to send CHIPSET_READY
2682 * response immediately */
2683 module_init(visorchipset_init
);
2684 module_exit(visorchipset_exit
);
2686 MODULE_AUTHOR("Unisys");
2687 MODULE_LICENSE("GPL");
2688 MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
2690 MODULE_VERSION(VERSION
);