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)
101 static LIST_HEAD(BusInfoList
);
102 static LIST_HEAD(DevInfoList
);
104 static VISORCHANNEL
*ControlVm_channel
;
107 u8 __iomem
*ptr
; /* pointer to base address of payload pool */
108 u64 offset
; /* offset from beginning of controlvm
109 * channel to beginning of payload * pool */
110 u32 bytes
; /* number of bytes in payload pool */
111 } CONTROLVM_PAYLOAD_INFO
;
113 /* Manages the request payload in the controlvm channel */
114 static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info
;
116 static pCHANNEL_HEADER Test_Vnic_channel
;
119 CONTROLVM_MESSAGE_HEADER Dumpcapture_header
;
120 CONTROLVM_MESSAGE_HEADER Gettextdump_header
;
121 CONTROLVM_MESSAGE_HEADER Dumpcomplete_header
;
122 BOOL Gettextdump_outstanding
;
125 atomic_t buffers_in_use
;
128 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
129 * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
131 static LIVEDUMP_INFO LiveDump_info
;
133 /* The following globals are used to handle the scenario where we are unable to
134 * offload the payload from a controlvm message due to memory requirements. In
135 * this scenario, we simply stash the controlvm message, then attempt to
136 * process it again the next time controlvm_periodic_work() runs.
138 static CONTROLVM_MESSAGE ControlVm_Pending_Msg
;
139 static BOOL ControlVm_Pending_Msg_Valid
= FALSE
;
141 /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
142 * TRANSMIT_FILE PutFile payloads.
144 static struct kmem_cache
*Putfile_buffer_list_pool
;
145 static const char Putfile_buffer_list_pool_name
[] =
146 "controlvm_putfile_buffer_list_pool";
148 /* This identifies a data buffer that has been received via a controlvm messages
149 * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
151 struct putfile_buffer_entry
{
152 struct list_head next
; /* putfile_buffer_entry list */
153 PARSER_CONTEXT
*parser_ctx
; /* points to buffer containing input data */
156 /* List of struct putfile_request *, via next_putfile_request member.
157 * Each entry in this list identifies an outstanding TRANSMIT_FILE
160 static LIST_HEAD(Putfile_request_list
);
162 /* This describes a buffer and its current state of transfer (e.g., how many
163 * bytes have already been supplied as putfile data, and how many bytes are
164 * remaining) for a putfile_request.
166 struct putfile_active_buffer
{
167 /* a payload from a controlvm message, containing a file data buffer */
168 PARSER_CONTEXT
*parser_ctx
;
169 /* points within data area of parser_ctx to next byte of data */
171 /* # bytes left from <pnext> to the end of this data buffer */
172 size_t bytes_remaining
;
175 #define PUTFILE_REQUEST_SIG 0x0906101302281211
176 /* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
177 * conversation. Structs of this type are dynamically linked into
178 * <Putfile_request_list>.
180 struct putfile_request
{
181 u64 sig
; /* PUTFILE_REQUEST_SIG */
183 /* header from original TransmitFile request */
184 CONTROLVM_MESSAGE_HEADER controlvm_header
;
185 u64 file_request_number
; /* from original TransmitFile request */
187 /* link to next struct putfile_request */
188 struct list_head next_putfile_request
;
190 /* most-recent sequence number supplied via a controlvm message */
191 u64 data_sequence_number
;
193 /* head of putfile_buffer_entry list, which describes the data to be
194 * supplied as putfile data;
195 * - this list is added to when controlvm messages come in that supply
197 * - this list is removed from via the hotplug program that is actually
198 * consuming these buffers to write as file data */
199 struct list_head input_buffer_list
;
200 spinlock_t req_list_lock
; /* lock for input_buffer_list */
202 /* waiters for input_buffer_list to go non-empty */
203 wait_queue_head_t input_buffer_wq
;
205 /* data not yet read within current putfile_buffer_entry */
206 struct putfile_active_buffer active_buf
;
208 /* <0 = failed, 0 = in-progress, >0 = successful; */
209 /* note that this must be set with req_list_lock, and if you set <0, */
210 /* it is your responsibility to also free up all of the other objects */
211 /* in this struct (like input_buffer_list, active_buf.parser_ctx) */
212 /* before releasing the lock */
213 int completion_status
;
216 static atomic_t Visorchipset_cache_buffers_in_use
= ATOMIC_INIT(0);
218 struct parahotplug_request
{
219 struct list_head list
;
221 unsigned long expiration
;
222 CONTROLVM_MESSAGE msg
;
225 static LIST_HEAD(Parahotplug_request_list
);
226 static DEFINE_SPINLOCK(Parahotplug_request_list_lock
); /* lock for above */
227 static void parahotplug_process_list(void);
229 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
230 * CONTROLVM_REPORTEVENT.
232 static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Server_Notifiers
;
233 static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Client_Notifiers
;
235 static void bus_create_response(ulong busNo
, int response
);
236 static void bus_destroy_response(ulong busNo
, int response
);
237 static void device_create_response(ulong busNo
, ulong devNo
, int response
);
238 static void device_destroy_response(ulong busNo
, ulong devNo
, int response
);
239 static void device_resume_response(ulong busNo
, ulong devNo
, int response
);
241 static VISORCHIPSET_BUSDEV_RESPONDERS BusDev_Responders
= {
242 .bus_create
= bus_create_response
,
243 .bus_destroy
= bus_destroy_response
,
244 .device_create
= device_create_response
,
245 .device_destroy
= device_destroy_response
,
246 .device_pause
= visorchipset_device_pause_response
,
247 .device_resume
= device_resume_response
,
250 /* info for /dev/visorchipset */
251 static dev_t MajorDev
= -1; /**< indicates major num for device */
253 /* prototypes for attributes */
254 static ssize_t
toolaction_show(struct device
*dev
,
255 struct device_attribute
*attr
, char *buf
);
256 static ssize_t
toolaction_store(struct device
*dev
,
257 struct device_attribute
*attr
, const char *buf
, size_t count
);
258 static DEVICE_ATTR_RW(toolaction
);
260 static ssize_t
boottotool_show(struct device
*dev
,
261 struct device_attribute
*attr
, char *buf
);
262 static ssize_t
boottotool_store(struct device
*dev
,
263 struct device_attribute
*attr
, const char *buf
, size_t count
);
264 static DEVICE_ATTR_RW(boottotool
);
266 static ssize_t
error_show(struct device
*dev
, struct device_attribute
*attr
,
268 static ssize_t
error_store(struct device
*dev
, struct device_attribute
*attr
,
269 const char *buf
, size_t count
);
270 static DEVICE_ATTR_RW(error
);
272 static ssize_t
textid_show(struct device
*dev
, struct device_attribute
*attr
,
274 static ssize_t
textid_store(struct device
*dev
, struct device_attribute
*attr
,
275 const char *buf
, size_t count
);
276 static DEVICE_ATTR_RW(textid
);
278 static ssize_t
remaining_steps_show(struct device
*dev
,
279 struct device_attribute
*attr
, char *buf
);
280 static ssize_t
remaining_steps_store(struct device
*dev
,
281 struct device_attribute
*attr
, const char *buf
, size_t count
);
282 static DEVICE_ATTR_RW(remaining_steps
);
284 static ssize_t
chipsetready_store(struct device
*dev
,
285 struct device_attribute
*attr
, const char *buf
, size_t count
);
286 static DEVICE_ATTR_WO(chipsetready
);
288 static ssize_t
devicedisabled_store(struct device
*dev
,
289 struct device_attribute
*attr
, const char *buf
, size_t count
);
290 static DEVICE_ATTR_WO(devicedisabled
);
292 static ssize_t
deviceenabled_store(struct device
*dev
,
293 struct device_attribute
*attr
, const char *buf
, size_t count
);
294 static DEVICE_ATTR_WO(deviceenabled
);
296 static struct attribute
*visorchipset_install_attrs
[] = {
297 &dev_attr_toolaction
.attr
,
298 &dev_attr_boottotool
.attr
,
299 &dev_attr_error
.attr
,
300 &dev_attr_textid
.attr
,
301 &dev_attr_remaining_steps
.attr
,
305 static struct attribute_group visorchipset_install_group
= {
307 .attrs
= visorchipset_install_attrs
310 static struct attribute
*visorchipset_guest_attrs
[] = {
311 &dev_attr_chipsetready
.attr
,
315 static struct attribute_group visorchipset_guest_group
= {
317 .attrs
= visorchipset_guest_attrs
320 static struct attribute
*visorchipset_parahotplug_attrs
[] = {
321 &dev_attr_devicedisabled
.attr
,
322 &dev_attr_deviceenabled
.attr
,
326 static struct attribute_group visorchipset_parahotplug_group
= {
327 .name
= "parahotplug",
328 .attrs
= visorchipset_parahotplug_attrs
331 static const struct attribute_group
*visorchipset_dev_groups
[] = {
332 &visorchipset_install_group
,
333 &visorchipset_guest_group
,
334 &visorchipset_parahotplug_group
,
338 /* /sys/devices/platform/visorchipset */
339 static struct platform_device Visorchipset_platform_device
= {
340 .name
= "visorchipset",
342 .dev
.groups
= visorchipset_dev_groups
,
345 /* Function prototypes */
346 static void controlvm_respond(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
);
347 static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER
*msgHdr
,
349 ULTRA_CHIPSET_FEATURE features
);
350 static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER
*
351 msgHdr
, int response
,
352 ULTRA_SEGMENT_STATE state
);
354 static ssize_t
toolaction_show(struct device
*dev
,
355 struct device_attribute
*attr
,
360 visorchannel_read(ControlVm_channel
,
361 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
362 ToolAction
), &toolAction
, sizeof(u8
));
363 return scnprintf(buf
, PAGE_SIZE
, "%u\n", toolAction
);
366 static ssize_t
toolaction_store(struct device
*dev
,
367 struct device_attribute
*attr
,
368 const char *buf
, size_t count
)
373 if (kstrtou8(buf
, 10, &toolAction
) != 0)
376 ret
= visorchannel_write(ControlVm_channel
,
377 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
, ToolAction
),
378 &toolAction
, sizeof(u8
));
386 static ssize_t
boottotool_show(struct device
*dev
,
387 struct device_attribute
*attr
,
390 ULTRA_EFI_SPAR_INDICATION efiSparIndication
;
392 visorchannel_read(ControlVm_channel
,
393 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
394 EfiSparIndication
), &efiSparIndication
,
395 sizeof(ULTRA_EFI_SPAR_INDICATION
));
396 return scnprintf(buf
, PAGE_SIZE
, "%u\n",
397 efiSparIndication
.BootToTool
);
400 static ssize_t
boottotool_store(struct device
*dev
,
401 struct device_attribute
*attr
,
402 const char *buf
, size_t count
)
405 ULTRA_EFI_SPAR_INDICATION efiSparIndication
;
407 if (kstrtoint(buf
, 10, &val
) != 0)
410 efiSparIndication
.BootToTool
= val
;
411 ret
= visorchannel_write(ControlVm_channel
,
412 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
414 &(efiSparIndication
),
415 sizeof(ULTRA_EFI_SPAR_INDICATION
));
423 static ssize_t
error_show(struct device
*dev
, struct device_attribute
*attr
,
428 visorchannel_read(ControlVm_channel
, offsetof(
429 ULTRA_CONTROLVM_CHANNEL_PROTOCOL
, InstallationError
),
430 &error
, sizeof(u32
));
431 return scnprintf(buf
, PAGE_SIZE
, "%i\n", error
);
434 static ssize_t
error_store(struct device
*dev
, struct device_attribute
*attr
,
435 const char *buf
, size_t count
)
440 if (kstrtou32(buf
, 10, &error
) != 0)
443 ret
= visorchannel_write(ControlVm_channel
,
444 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
446 &error
, sizeof(u32
));
453 static ssize_t
textid_show(struct device
*dev
, struct device_attribute
*attr
,
458 visorchannel_read(ControlVm_channel
, offsetof(
459 ULTRA_CONTROLVM_CHANNEL_PROTOCOL
, InstallationTextId
),
460 &textId
, sizeof(u32
));
461 return scnprintf(buf
, PAGE_SIZE
, "%i\n", textId
);
464 static ssize_t
textid_store(struct device
*dev
, struct device_attribute
*attr
,
465 const char *buf
, size_t count
)
470 if (kstrtou32(buf
, 10, &textId
) != 0)
473 ret
= visorchannel_write(ControlVm_channel
,
474 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
476 &textId
, sizeof(u32
));
484 static ssize_t
remaining_steps_show(struct device
*dev
,
485 struct device_attribute
*attr
, char *buf
)
489 visorchannel_read(ControlVm_channel
,
490 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
491 InstallationRemainingSteps
),
494 return scnprintf(buf
, PAGE_SIZE
, "%hu\n", remainingSteps
);
497 static ssize_t
remaining_steps_store(struct device
*dev
,
498 struct device_attribute
*attr
, const char *buf
, size_t count
)
503 if (kstrtou16(buf
, 10, &remainingSteps
) != 0)
506 ret
= visorchannel_write(ControlVm_channel
,
507 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
508 InstallationRemainingSteps
),
509 &remainingSteps
, sizeof(u16
));
520 wchar_t unicodeString
[] = { 'a', 'b', 'c', 0 };
521 char s
[sizeof(unicodeString
) * NLS_MAX_CHARSET_SIZE
];
522 wchar_t unicode2
[99];
524 /* NOTE: Either due to a bug, or feature I don't understand, the
525 * kernel utf8_mbstowcs() and utf_wcstombs() do NOT copy the
526 * trailed NUL byte!! REALLY!!!!! Arrrrgggghhhhh
529 LOGINF("sizeof(wchar_t) = %d", sizeof(wchar_t));
530 LOGINF("utf8_wcstombs=%d",
531 chrs
= utf8_wcstombs(s
, unicodeString
, sizeof(s
)));
533 s
[chrs
] = '\0'; /* GRRRRRRRR */
535 LOGINF("utf8_mbstowcs=%d", chrs
= utf8_mbstowcs(unicode2
, s
, 100));
537 unicode2
[chrs
] = 0; /* GRRRRRRRR */
538 if (memcmp(unicodeString
, unicode2
, sizeof(unicodeString
)) == 0)
539 LOGINF("strings match... good");
541 LOGINF("strings did not match!!");
546 busInfo_clear(void *v
)
548 VISORCHIPSET_BUS_INFO
*p
= (VISORCHIPSET_BUS_INFO
*) (v
);
551 visor_proc_DestroyObject(p
->procObject
);
552 p
->procObject
= NULL
;
557 kfree(p
->description
);
558 p
->description
= NULL
;
560 p
->state
.created
= 0;
561 memset(p
, 0, sizeof(VISORCHIPSET_BUS_INFO
));
565 devInfo_clear(void *v
)
567 VISORCHIPSET_DEVICE_INFO
*p
= (VISORCHIPSET_DEVICE_INFO
*) (v
);
568 p
->state
.created
= 0;
569 memset(p
, 0, sizeof(VISORCHIPSET_DEVICE_INFO
));
573 check_chipset_events(void)
577 /* Check events to determine if response should be sent */
578 for (i
= 0; i
< MAX_CHIPSET_EVENTS
; i
++)
579 send_msg
&= chipset_events
[i
];
584 clear_chipset_events(void)
587 /* Clear chipset_events */
588 for (i
= 0; i
< MAX_CHIPSET_EVENTS
; i
++)
589 chipset_events
[i
] = 0;
593 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
,
594 VISORCHIPSET_BUSDEV_RESPONDERS
*responders
,
595 ULTRA_VBUS_DEVICEINFO
*driverInfo
)
597 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
598 if (notifiers
== NULL
) {
599 memset(&BusDev_Server_Notifiers
, 0,
600 sizeof(BusDev_Server_Notifiers
));
601 serverregistered
= 0; /* clear flag */
603 BusDev_Server_Notifiers
= *notifiers
;
604 serverregistered
= 1; /* set flag */
607 *responders
= BusDev_Responders
;
609 BusDeviceInfo_Init(driverInfo
, "chipset", "visorchipset",
612 UNLOCKSEM(&NotifierLock
);
614 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server
);
617 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
,
618 VISORCHIPSET_BUSDEV_RESPONDERS
*responders
,
619 ULTRA_VBUS_DEVICEINFO
*driverInfo
)
621 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
622 if (notifiers
== NULL
) {
623 memset(&BusDev_Client_Notifiers
, 0,
624 sizeof(BusDev_Client_Notifiers
));
625 clientregistered
= 0; /* clear flag */
627 BusDev_Client_Notifiers
= *notifiers
;
628 clientregistered
= 1; /* set flag */
631 *responders
= BusDev_Responders
;
633 BusDeviceInfo_Init(driverInfo
, "chipset(bolts)", "visorchipset",
635 UNLOCKSEM(&NotifierLock
);
637 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client
);
640 cleanup_controlvm_structures(void)
642 VISORCHIPSET_BUS_INFO
*bi
, *tmp_bi
;
643 VISORCHIPSET_DEVICE_INFO
*di
, *tmp_di
;
645 list_for_each_entry_safe(bi
, tmp_bi
, &BusInfoList
, entry
) {
647 list_del(&bi
->entry
);
651 list_for_each_entry_safe(di
, tmp_di
, &DevInfoList
, entry
) {
653 list_del(&di
->entry
);
659 chipset_init(CONTROLVM_MESSAGE
*inmsg
)
661 static int chipset_inited
;
662 ULTRA_CHIPSET_FEATURE features
= 0;
663 int rc
= CONTROLVM_RESP_SUCCESS
;
665 POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
666 if (chipset_inited
) {
667 LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done.");
668 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
672 POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
674 /* Set features to indicate we support parahotplug (if Command
675 * also supports it). */
677 inmsg
->cmd
.initChipset
.
678 features
& ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG
;
680 /* Set the "reply" bit so Command knows this is a
681 * features-aware driver. */
682 features
|= ULTRA_CHIPSET_FEATURE_REPLY
;
686 cleanup_controlvm_structures();
687 if (inmsg
->hdr
.Flags
.responseExpected
)
688 controlvm_respond_chipset_init(&inmsg
->hdr
, rc
, features
);
692 controlvm_init_response(CONTROLVM_MESSAGE
*msg
,
693 CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
)
695 memset(msg
, 0, sizeof(CONTROLVM_MESSAGE
));
696 memcpy(&msg
->hdr
, msgHdr
, sizeof(CONTROLVM_MESSAGE_HEADER
));
697 msg
->hdr
.PayloadBytes
= 0;
698 msg
->hdr
.PayloadVmOffset
= 0;
699 msg
->hdr
.PayloadMaxBytes
= 0;
701 msg
->hdr
.Flags
.failed
= 1;
702 msg
->hdr
.CompletionStatus
= (u32
) (-response
);
707 controlvm_respond(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
)
709 CONTROLVM_MESSAGE outmsg
;
710 controlvm_init_response(&outmsg
, msgHdr
, response
);
711 /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
712 * back the deviceChangeState structure in the packet. */
713 if (msgHdr
->Id
== CONTROLVM_DEVICE_CHANGESTATE
714 && g_DeviceChangeStatePacket
.deviceChangeState
.busNo
==
716 && g_DeviceChangeStatePacket
.deviceChangeState
.devNo
==
718 outmsg
.cmd
= g_DeviceChangeStatePacket
;
719 if (outmsg
.hdr
.Flags
.testMessage
== 1) {
720 LOGINF("%s controlvm_msg=0x%x response=%d for test message",
721 __func__
, outmsg
.hdr
.Id
, response
);
724 if (!visorchannel_signalinsert(ControlVm_channel
,
725 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
726 LOGERR("signalinsert failed!");
732 controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
,
733 ULTRA_CHIPSET_FEATURE features
)
735 CONTROLVM_MESSAGE outmsg
;
736 controlvm_init_response(&outmsg
, msgHdr
, response
);
737 outmsg
.cmd
.initChipset
.features
= features
;
738 if (!visorchannel_signalinsert(ControlVm_channel
,
739 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
740 LOGERR("signalinsert failed!");
746 controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER
*msgHdr
,
747 int response
, ULTRA_SEGMENT_STATE state
)
749 CONTROLVM_MESSAGE outmsg
;
750 controlvm_init_response(&outmsg
, msgHdr
, response
);
751 outmsg
.cmd
.deviceChangeState
.state
= state
;
752 outmsg
.cmd
.deviceChangeState
.flags
.physicalDevice
= 1;
753 if (!visorchannel_signalinsert(ControlVm_channel
,
754 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
755 LOGERR("signalinsert failed!");
761 visorchipset_save_message(CONTROLVM_MESSAGE
*msg
, CRASH_OBJ_TYPE type
)
763 u32 localSavedCrashMsgOffset
;
764 u16 localSavedCrashMsgCount
;
766 /* get saved message count */
767 if (visorchannel_read(ControlVm_channel
,
768 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
770 &localSavedCrashMsgCount
, sizeof(u16
)) < 0) {
771 LOGERR("failed to get Saved Message Count");
772 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
773 POSTCODE_SEVERITY_ERR
);
777 if (localSavedCrashMsgCount
!= CONTROLVM_CRASHMSG_MAX
) {
778 LOGERR("Saved Message Count incorrect %d",
779 localSavedCrashMsgCount
);
780 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC
,
781 localSavedCrashMsgCount
,
782 POSTCODE_SEVERITY_ERR
);
786 /* get saved crash message offset */
787 if (visorchannel_read(ControlVm_channel
,
788 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
789 SavedCrashMsgOffset
),
790 &localSavedCrashMsgOffset
, sizeof(u32
)) < 0) {
791 LOGERR("failed to get Saved Message Offset");
792 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
793 POSTCODE_SEVERITY_ERR
);
797 if (type
== CRASH_bus
) {
798 if (visorchannel_write(ControlVm_channel
,
799 localSavedCrashMsgOffset
,
800 msg
, sizeof(CONTROLVM_MESSAGE
)) < 0) {
801 LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!");
802 POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC
,
803 POSTCODE_SEVERITY_ERR
);
807 if (visorchannel_write(ControlVm_channel
,
808 localSavedCrashMsgOffset
+
809 sizeof(CONTROLVM_MESSAGE
), msg
,
810 sizeof(CONTROLVM_MESSAGE
)) < 0) {
811 LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!");
812 POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC
,
813 POSTCODE_SEVERITY_ERR
);
818 EXPORT_SYMBOL_GPL(visorchipset_save_message
);
821 bus_responder(CONTROLVM_ID cmdId
, ulong busNo
, int response
)
823 VISORCHIPSET_BUS_INFO
*p
= NULL
;
824 BOOL need_clear
= FALSE
;
826 p
= findbus(&BusInfoList
, busNo
);
828 LOGERR("internal error busNo=%lu", busNo
);
832 if ((cmdId
== CONTROLVM_BUS_CREATE
) &&
833 (response
!= (-CONTROLVM_RESP_ERROR_ALREADY_DONE
)))
834 /* undo the row we just created... */
835 delbusdevices(&DevInfoList
, busNo
);
837 if (cmdId
== CONTROLVM_BUS_CREATE
)
838 p
->state
.created
= 1;
839 if (cmdId
== CONTROLVM_BUS_DESTROY
)
843 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
844 LOGERR("bus_responder no pending msg");
845 return; /* no controlvm response needed */
847 if (p
->pendingMsgHdr
.Id
!= (u32
) cmdId
) {
848 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
851 controlvm_respond(&p
->pendingMsgHdr
, response
);
852 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
855 delbusdevices(&DevInfoList
, busNo
);
860 device_changestate_responder(CONTROLVM_ID cmdId
,
861 ulong busNo
, ulong devNo
, int response
,
862 ULTRA_SEGMENT_STATE responseState
)
864 VISORCHIPSET_DEVICE_INFO
*p
= NULL
;
865 CONTROLVM_MESSAGE outmsg
;
867 p
= finddevice(&DevInfoList
, busNo
, devNo
);
869 LOGERR("internal error; busNo=%lu, devNo=%lu", busNo
, devNo
);
872 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
873 LOGERR("device_responder no pending msg");
874 return; /* no controlvm response needed */
876 if (p
->pendingMsgHdr
.Id
!= cmdId
) {
877 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
881 controlvm_init_response(&outmsg
, &p
->pendingMsgHdr
, response
);
883 outmsg
.cmd
.deviceChangeState
.busNo
= busNo
;
884 outmsg
.cmd
.deviceChangeState
.devNo
= devNo
;
885 outmsg
.cmd
.deviceChangeState
.state
= responseState
;
887 if (!visorchannel_signalinsert(ControlVm_channel
,
888 CONTROLVM_QUEUE_REQUEST
, &outmsg
)) {
889 LOGERR("signalinsert failed!");
893 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
897 device_responder(CONTROLVM_ID cmdId
, ulong busNo
, ulong devNo
, int response
)
899 VISORCHIPSET_DEVICE_INFO
*p
= NULL
;
900 BOOL need_clear
= FALSE
;
902 p
= finddevice(&DevInfoList
, busNo
, devNo
);
904 LOGERR("internal error; busNo=%lu, devNo=%lu", busNo
, devNo
);
908 if (cmdId
== CONTROLVM_DEVICE_CREATE
)
909 p
->state
.created
= 1;
910 if (cmdId
== CONTROLVM_DEVICE_DESTROY
)
914 if (p
->pendingMsgHdr
.Id
== CONTROLVM_INVALID
) {
915 LOGERR("device_responder no pending msg");
916 return; /* no controlvm response needed */
918 if (p
->pendingMsgHdr
.Id
!= (u32
) cmdId
) {
919 LOGERR("expected=%d, found=%d", cmdId
, p
->pendingMsgHdr
.Id
);
922 controlvm_respond(&p
->pendingMsgHdr
, response
);
923 p
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
929 bus_epilog(u32 busNo
,
930 u32 cmd
, CONTROLVM_MESSAGE_HEADER
*msgHdr
,
931 int response
, BOOL needResponse
)
933 BOOL notified
= FALSE
;
935 VISORCHIPSET_BUS_INFO
*pBusInfo
= findbus(&BusInfoList
, busNo
);
938 LOGERR("HUH? bad busNo=%d", busNo
);
942 memcpy(&pBusInfo
->pendingMsgHdr
, msgHdr
,
943 sizeof(CONTROLVM_MESSAGE_HEADER
));
945 pBusInfo
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
947 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
948 if (response
== CONTROLVM_RESP_SUCCESS
) {
950 case CONTROLVM_BUS_CREATE
:
951 /* We can't tell from the bus_create
952 * information which of our 2 bus flavors the
953 * devices on this bus will ultimately end up.
954 * FORTUNATELY, it turns out it is harmless to
955 * send the bus_create to both of them. We can
956 * narrow things down a little bit, though,
957 * because we know: - BusDev_Server can handle
958 * either server or client devices
959 * - BusDev_Client can handle ONLY client
961 if (BusDev_Server_Notifiers
.bus_create
) {
962 (*BusDev_Server_Notifiers
.bus_create
) (busNo
);
965 if ((!pBusInfo
->flags
.server
) /*client */ &&
966 BusDev_Client_Notifiers
.bus_create
) {
967 (*BusDev_Client_Notifiers
.bus_create
) (busNo
);
971 case CONTROLVM_BUS_DESTROY
:
972 if (BusDev_Server_Notifiers
.bus_destroy
) {
973 (*BusDev_Server_Notifiers
.bus_destroy
) (busNo
);
976 if ((!pBusInfo
->flags
.server
) /*client */ &&
977 BusDev_Client_Notifiers
.bus_destroy
) {
978 (*BusDev_Client_Notifiers
.bus_destroy
) (busNo
);
985 /* The callback function just called above is responsible
986 * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS
987 * function, which will call bus_responder()
991 bus_responder(cmd
, busNo
, response
);
992 UNLOCKSEM(&NotifierLock
);
996 device_epilog(u32 busNo
, u32 devNo
, ULTRA_SEGMENT_STATE state
, u32 cmd
,
997 CONTROLVM_MESSAGE_HEADER
*msgHdr
, int response
,
998 BOOL needResponse
, BOOL for_visorbus
)
1000 VISORCHIPSET_BUSDEV_NOTIFIERS
*notifiers
= NULL
;
1001 BOOL notified
= FALSE
;
1003 VISORCHIPSET_DEVICE_INFO
*pDevInfo
=
1004 finddevice(&DevInfoList
, busNo
, devNo
);
1006 "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
1011 LOGERR("HUH? bad busNo=%d, devNo=%d", busNo
, devNo
);
1015 notifiers
= &BusDev_Server_Notifiers
;
1017 notifiers
= &BusDev_Client_Notifiers
;
1019 memcpy(&pDevInfo
->pendingMsgHdr
, msgHdr
,
1020 sizeof(CONTROLVM_MESSAGE_HEADER
));
1022 pDevInfo
->pendingMsgHdr
.Id
= CONTROLVM_INVALID
;
1024 LOCKSEM_UNINTERRUPTIBLE(&NotifierLock
);
1025 if (response
>= 0) {
1027 case CONTROLVM_DEVICE_CREATE
:
1028 if (notifiers
->device_create
) {
1029 (*notifiers
->device_create
) (busNo
, devNo
);
1033 case CONTROLVM_DEVICE_CHANGESTATE
:
1034 /* ServerReady / ServerRunning / SegmentStateRunning */
1035 if (state
.Alive
== SegmentStateRunning
.Alive
&&
1036 state
.Operating
== SegmentStateRunning
.Operating
) {
1037 if (notifiers
->device_resume
) {
1038 (*notifiers
->device_resume
) (busNo
,
1043 /* ServerNotReady / ServerLost / SegmentStateStandby */
1044 else if (state
.Alive
== SegmentStateStandby
.Alive
&&
1046 SegmentStateStandby
.Operating
) {
1047 /* technically this is standby case
1048 * where server is lost
1050 if (notifiers
->device_pause
) {
1051 (*notifiers
->device_pause
) (busNo
,
1055 } else if (state
.Alive
== SegmentStatePaused
.Alive
&&
1057 SegmentStatePaused
.Operating
) {
1058 /* this is lite pause where channel is
1059 * still valid just 'pause' of it
1061 if (busNo
== g_diagpoolBusNo
1062 && devNo
== g_diagpoolDevNo
) {
1063 LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)",
1065 /* this will trigger the
1066 * diag_shutdown.sh script in
1067 * the visorchipset hotplug */
1069 (&Visorchipset_platform_device
.dev
.
1070 kobj
, KOBJ_ONLINE
, envp
);
1074 case CONTROLVM_DEVICE_DESTROY
:
1075 if (notifiers
->device_destroy
) {
1076 (*notifiers
->device_destroy
) (busNo
, devNo
);
1083 /* The callback function just called above is responsible
1084 * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS
1085 * function, which will call device_responder()
1089 device_responder(cmd
, busNo
, devNo
, response
);
1090 UNLOCKSEM(&NotifierLock
);
1094 bus_create(CONTROLVM_MESSAGE
*inmsg
)
1096 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1097 ulong busNo
= cmd
->createBus
.busNo
;
1098 int rc
= CONTROLVM_RESP_SUCCESS
;
1099 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1102 pBusInfo
= findbus(&BusInfoList
, busNo
);
1103 if (pBusInfo
&& (pBusInfo
->state
.created
== 1)) {
1104 LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu already exists",
1106 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, busNo
,
1107 POSTCODE_SEVERITY_ERR
);
1108 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1111 pBusInfo
= kzalloc(sizeof(VISORCHIPSET_BUS_INFO
), GFP_KERNEL
);
1112 if (pBusInfo
== NULL
) {
1113 LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
1115 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, busNo
,
1116 POSTCODE_SEVERITY_ERR
);
1117 rc
= -CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
1121 INIT_LIST_HEAD(&pBusInfo
->entry
);
1122 pBusInfo
->busNo
= busNo
;
1123 pBusInfo
->devNo
= cmd
->createBus
.deviceCount
;
1125 POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1127 if (inmsg
->hdr
.Flags
.testMessage
== 1)
1128 pBusInfo
->chanInfo
.addrType
= ADDRTYPE_localTest
;
1130 pBusInfo
->chanInfo
.addrType
= ADDRTYPE_localPhysical
;
1132 pBusInfo
->flags
.server
= inmsg
->hdr
.Flags
.server
;
1133 pBusInfo
->chanInfo
.channelAddr
= cmd
->createBus
.channelAddr
;
1134 pBusInfo
->chanInfo
.nChannelBytes
= cmd
->createBus
.channelBytes
;
1135 pBusInfo
->chanInfo
.channelTypeGuid
= cmd
->createBus
.busDataTypeGuid
;
1136 pBusInfo
->chanInfo
.channelInstGuid
= cmd
->createBus
.busInstGuid
;
1138 list_add(&pBusInfo
->entry
, &BusInfoList
);
1140 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1143 bus_epilog(busNo
, CONTROLVM_BUS_CREATE
, &inmsg
->hdr
,
1144 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1148 bus_destroy(CONTROLVM_MESSAGE
*inmsg
)
1150 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1151 ulong busNo
= cmd
->destroyBus
.busNo
;
1152 VISORCHIPSET_BUS_INFO
*pBusInfo
;
1153 int rc
= CONTROLVM_RESP_SUCCESS
;
1155 pBusInfo
= findbus(&BusInfoList
, busNo
);
1157 LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo
);
1158 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1161 if (pBusInfo
->state
.created
== 0) {
1162 LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed",
1164 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1169 bus_epilog(busNo
, CONTROLVM_BUS_DESTROY
, &inmsg
->hdr
,
1170 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1174 bus_configure(CONTROLVM_MESSAGE
*inmsg
, PARSER_CONTEXT
*parser_ctx
)
1176 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1177 ulong busNo
= cmd
->configureBus
.busNo
;
1178 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1179 int rc
= CONTROLVM_RESP_SUCCESS
;
1182 busNo
= cmd
->configureBus
.busNo
;
1183 POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1185 pBusInfo
= findbus(&BusInfoList
, busNo
);
1187 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid",
1189 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1190 POSTCODE_SEVERITY_ERR
);
1191 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1194 if (pBusInfo
->state
.created
== 0) {
1195 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet",
1197 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1198 POSTCODE_SEVERITY_ERR
);
1199 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1202 /* TBD - add this check to other commands also... */
1203 if (pBusInfo
->pendingMsgHdr
.Id
!= CONTROLVM_INVALID
) {
1204 LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding",
1205 busNo
, (uint
) pBusInfo
->pendingMsgHdr
.Id
);
1206 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC
, busNo
,
1207 POSTCODE_SEVERITY_ERR
);
1208 rc
= -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT
;
1212 pBusInfo
->partitionHandle
= cmd
->configureBus
.guestHandle
;
1213 pBusInfo
->partitionGuid
= parser_id_get(parser_ctx
);
1214 parser_param_start(parser_ctx
, PARSERSTRING_NAME
);
1215 pBusInfo
->name
= parser_string_get(parser_ctx
);
1217 visorchannel_uuid_id(&pBusInfo
->partitionGuid
, s
);
1218 POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC
, busNo
, POSTCODE_SEVERITY_INFO
);
1220 bus_epilog(busNo
, CONTROLVM_BUS_CONFIGURE
, &inmsg
->hdr
,
1221 rc
, inmsg
->hdr
.Flags
.responseExpected
== 1);
1225 my_device_create(CONTROLVM_MESSAGE
*inmsg
)
1227 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1228 ulong busNo
= cmd
->createDevice
.busNo
;
1229 ulong devNo
= cmd
->createDevice
.devNo
;
1230 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1231 VISORCHIPSET_BUS_INFO
*pBusInfo
= NULL
;
1232 int rc
= CONTROLVM_RESP_SUCCESS
;
1234 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1235 if (pDevInfo
&& (pDevInfo
->state
.created
== 1)) {
1236 LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu already exists",
1238 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1239 POSTCODE_SEVERITY_ERR
);
1240 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1243 pBusInfo
= findbus(&BusInfoList
, busNo
);
1245 LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range",
1247 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1248 POSTCODE_SEVERITY_ERR
);
1249 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1252 if (pBusInfo
->state
.created
== 0) {
1253 LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet",
1255 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1256 POSTCODE_SEVERITY_ERR
);
1257 rc
= -CONTROLVM_RESP_ERROR_BUS_INVALID
;
1260 pDevInfo
= kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO
), GFP_KERNEL
);
1261 if (pDevInfo
== NULL
) {
1262 LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
1264 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, devNo
, busNo
,
1265 POSTCODE_SEVERITY_ERR
);
1266 rc
= -CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
1270 INIT_LIST_HEAD(&pDevInfo
->entry
);
1271 pDevInfo
->busNo
= busNo
;
1272 pDevInfo
->devNo
= devNo
;
1273 pDevInfo
->devInstGuid
= cmd
->createDevice
.devInstGuid
;
1274 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC
, devNo
, busNo
,
1275 POSTCODE_SEVERITY_INFO
);
1277 if (inmsg
->hdr
.Flags
.testMessage
== 1)
1278 pDevInfo
->chanInfo
.addrType
= ADDRTYPE_localTest
;
1280 pDevInfo
->chanInfo
.addrType
= ADDRTYPE_localPhysical
;
1281 pDevInfo
->chanInfo
.channelAddr
= cmd
->createDevice
.channelAddr
;
1282 pDevInfo
->chanInfo
.nChannelBytes
= cmd
->createDevice
.channelBytes
;
1283 pDevInfo
->chanInfo
.channelTypeGuid
= cmd
->createDevice
.dataTypeGuid
;
1284 pDevInfo
->chanInfo
.intr
= cmd
->createDevice
.intr
;
1285 list_add(&pDevInfo
->entry
, &DevInfoList
);
1286 POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC
, devNo
, busNo
,
1287 POSTCODE_SEVERITY_INFO
);
1289 /* get the bus and devNo for DiagPool channel */
1290 if (is_diagpool_channel(pDevInfo
->chanInfo
.channelTypeGuid
)) {
1291 g_diagpoolBusNo
= busNo
;
1292 g_diagpoolDevNo
= devNo
;
1293 LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu",
1294 g_diagpoolBusNo
, g_diagpoolDevNo
);
1296 device_epilog(busNo
, devNo
, SegmentStateRunning
,
1297 CONTROLVM_DEVICE_CREATE
, &inmsg
->hdr
, rc
,
1298 inmsg
->hdr
.Flags
.responseExpected
== 1,
1299 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1303 my_device_changestate(CONTROLVM_MESSAGE
*inmsg
)
1305 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1306 ulong busNo
= cmd
->deviceChangeState
.busNo
;
1307 ulong devNo
= cmd
->deviceChangeState
.devNo
;
1308 ULTRA_SEGMENT_STATE state
= cmd
->deviceChangeState
.state
;
1309 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1310 int rc
= CONTROLVM_RESP_SUCCESS
;
1312 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1314 LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (doesn't exist)",
1316 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC
, devNo
, busNo
,
1317 POSTCODE_SEVERITY_ERR
);
1318 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1321 if (pDevInfo
->state
.created
== 0) {
1322 LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)",
1324 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC
, devNo
, busNo
,
1325 POSTCODE_SEVERITY_ERR
);
1326 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1329 if ((rc
>= CONTROLVM_RESP_SUCCESS
) && pDevInfo
)
1330 device_epilog(busNo
, devNo
, state
, CONTROLVM_DEVICE_CHANGESTATE
,
1332 inmsg
->hdr
.Flags
.responseExpected
== 1,
1333 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1337 my_device_destroy(CONTROLVM_MESSAGE
*inmsg
)
1339 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
->cmd
;
1340 ulong busNo
= cmd
->destroyDevice
.busNo
;
1341 ulong devNo
= cmd
->destroyDevice
.devNo
;
1342 VISORCHIPSET_DEVICE_INFO
*pDevInfo
= NULL
;
1343 int rc
= CONTROLVM_RESP_SUCCESS
;
1345 pDevInfo
= finddevice(&DevInfoList
, busNo
, devNo
);
1347 LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid",
1349 rc
= -CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
1352 if (pDevInfo
->state
.created
== 0) {
1353 LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed",
1355 rc
= -CONTROLVM_RESP_ERROR_ALREADY_DONE
;
1359 if ((rc
>= CONTROLVM_RESP_SUCCESS
) && pDevInfo
)
1360 device_epilog(busNo
, devNo
, SegmentStateRunning
,
1361 CONTROLVM_DEVICE_DESTROY
, &inmsg
->hdr
, rc
,
1362 inmsg
->hdr
.Flags
.responseExpected
== 1,
1363 FOR_VISORBUS(pDevInfo
->chanInfo
.channelTypeGuid
));
1366 /* When provided with the physical address of the controlvm channel
1367 * (phys_addr), the offset to the payload area we need to manage
1368 * (offset), and the size of this payload area (bytes), fills in the
1369 * CONTROLVM_PAYLOAD_INFO struct. Returns TRUE for success or FALSE
1373 initialize_controlvm_payload_info(HOSTADDRESS phys_addr
, u64 offset
, u32 bytes
,
1374 CONTROLVM_PAYLOAD_INFO
*info
)
1376 u8 __iomem
*payload
= NULL
;
1377 int rc
= CONTROLVM_RESP_SUCCESS
;
1380 LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d",
1381 __FILE__
, __LINE__
);
1382 rc
= -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID
;
1385 memset(info
, 0, sizeof(CONTROLVM_PAYLOAD_INFO
));
1386 if ((offset
== 0) || (bytes
== 0)) {
1387 LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!",
1388 (u64
) offset
, (u64
) bytes
);
1389 rc
= -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID
;
1392 payload
= ioremap_cache(phys_addr
+ offset
, bytes
);
1393 if (payload
== NULL
) {
1394 LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed",
1395 (u64
) offset
, (u64
) bytes
);
1396 rc
= -CONTROLVM_RESP_ERROR_IOREMAP_FAILED
;
1400 info
->offset
= offset
;
1401 info
->bytes
= bytes
;
1402 info
->ptr
= payload
;
1403 LOGINF("offset=%llu, bytes=%lu, ptr=%p",
1404 (u64
) (info
->offset
), (ulong
) (info
->bytes
), info
->ptr
);
1408 if (payload
!= NULL
) {
1417 destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO
*info
)
1419 if (info
->ptr
!= NULL
) {
1423 memset(info
, 0, sizeof(CONTROLVM_PAYLOAD_INFO
));
1427 initialize_controlvm_payload(void)
1429 HOSTADDRESS phys_addr
= visorchannel_get_physaddr(ControlVm_channel
);
1430 u64 payloadOffset
= 0;
1431 u32 payloadBytes
= 0;
1432 if (visorchannel_read(ControlVm_channel
,
1433 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
1434 RequestPayloadOffset
),
1435 &payloadOffset
, sizeof(payloadOffset
)) < 0) {
1436 LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
1437 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC
,
1438 POSTCODE_SEVERITY_ERR
);
1441 if (visorchannel_read(ControlVm_channel
,
1442 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
1443 RequestPayloadBytes
),
1444 &payloadBytes
, sizeof(payloadBytes
)) < 0) {
1445 LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
1446 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC
,
1447 POSTCODE_SEVERITY_ERR
);
1450 initialize_controlvm_payload_info(phys_addr
,
1451 payloadOffset
, payloadBytes
,
1452 &ControlVm_payload_info
);
1455 /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1456 * Returns CONTROLVM_RESP_xxx code.
1459 visorchipset_chipset_ready(void)
1461 kobject_uevent(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_ONLINE
);
1462 return CONTROLVM_RESP_SUCCESS
;
1464 EXPORT_SYMBOL_GPL(visorchipset_chipset_ready
);
1467 visorchipset_chipset_selftest(void)
1469 char env_selftest
[20];
1470 char *envp
[] = { env_selftest
, NULL
};
1471 sprintf(env_selftest
, "SPARSP_SELFTEST=%d", 1);
1472 kobject_uevent_env(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_CHANGE
,
1474 return CONTROLVM_RESP_SUCCESS
;
1476 EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest
);
1478 /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1479 * Returns CONTROLVM_RESP_xxx code.
1482 visorchipset_chipset_notready(void)
1484 kobject_uevent(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_OFFLINE
);
1485 return CONTROLVM_RESP_SUCCESS
;
1487 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready
);
1490 chipset_ready(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1492 int rc
= visorchipset_chipset_ready();
1493 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1495 if (msgHdr
->Flags
.responseExpected
&& !visorchipset_holdchipsetready
)
1496 controlvm_respond(msgHdr
, rc
);
1497 if (msgHdr
->Flags
.responseExpected
&& visorchipset_holdchipsetready
) {
1498 /* Send CHIPSET_READY response when all modules have been loaded
1499 * and disks mounted for the partition
1501 g_ChipSetMsgHdr
= *msgHdr
;
1502 LOGINF("Holding CHIPSET_READY response");
1507 chipset_selftest(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1509 int rc
= visorchipset_chipset_selftest();
1510 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1512 if (msgHdr
->Flags
.responseExpected
)
1513 controlvm_respond(msgHdr
, rc
);
1517 chipset_notready(CONTROLVM_MESSAGE_HEADER
*msgHdr
)
1519 int rc
= visorchipset_chipset_notready();
1520 if (rc
!= CONTROLVM_RESP_SUCCESS
)
1522 if (msgHdr
->Flags
.responseExpected
)
1523 controlvm_respond(msgHdr
, rc
);
1526 /* This is your "one-stop" shop for grabbing the next message from the
1527 * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
1530 read_controlvm_event(CONTROLVM_MESSAGE
*msg
)
1532 if (visorchannel_signalremove(ControlVm_channel
,
1533 CONTROLVM_QUEUE_EVENT
, msg
)) {
1535 if (msg
->hdr
.Flags
.testMessage
== 1) {
1536 LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg
->hdr
.Id
);
1545 * The general parahotplug flow works as follows. The visorchipset
1546 * driver receives a DEVICE_CHANGESTATE message from Command
1547 * specifying a physical device to enable or disable. The CONTROLVM
1548 * message handler calls parahotplug_process_message, which then adds
1549 * the message to a global list and kicks off a udev event which
1550 * causes a user level script to enable or disable the specified
1551 * device. The udev script then writes to
1552 * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
1553 * to get called, at which point the appropriate CONTROLVM message is
1554 * retrieved from the list and responded to.
1557 #define PARAHOTPLUG_TIMEOUT_MS 2000
1560 * Generate unique int to match an outstanding CONTROLVM message with a
1561 * udev script /proc response
1564 parahotplug_next_id(void)
1566 static atomic_t id
= ATOMIC_INIT(0);
1567 return atomic_inc_return(&id
);
1571 * Returns the time (in jiffies) when a CONTROLVM message on the list
1572 * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
1574 static unsigned long
1575 parahotplug_next_expiration(void)
1577 return jiffies
+ PARAHOTPLUG_TIMEOUT_MS
* HZ
/ 1000;
1581 * Create a parahotplug_request, which is basically a wrapper for a
1582 * CONTROLVM_MESSAGE that we can stick on a list
1584 static struct parahotplug_request
*
1585 parahotplug_request_create(CONTROLVM_MESSAGE
*msg
)
1587 struct parahotplug_request
*req
=
1588 kmalloc(sizeof(struct parahotplug_request
),
1589 GFP_KERNEL
|__GFP_NORETRY
);
1593 req
->id
= parahotplug_next_id();
1594 req
->expiration
= parahotplug_next_expiration();
1601 * Free a parahotplug_request.
1604 parahotplug_request_destroy(struct parahotplug_request
*req
)
1610 * Cause uevent to run the user level script to do the disable/enable
1611 * specified in (the CONTROLVM message in) the specified
1612 * parahotplug_request
1615 parahotplug_request_kickoff(struct parahotplug_request
*req
)
1617 CONTROLVM_MESSAGE_PACKET
*cmd
= &req
->msg
.cmd
;
1618 char env_cmd
[40], env_id
[40], env_state
[40], env_bus
[40], env_dev
[40],
1621 env_cmd
, env_id
, env_state
, env_bus
, env_dev
, env_func
, NULL
1624 sprintf(env_cmd
, "SPAR_PARAHOTPLUG=1");
1625 sprintf(env_id
, "SPAR_PARAHOTPLUG_ID=%d", req
->id
);
1626 sprintf(env_state
, "SPAR_PARAHOTPLUG_STATE=%d",
1627 cmd
->deviceChangeState
.state
.Active
);
1628 sprintf(env_bus
, "SPAR_PARAHOTPLUG_BUS=%d",
1629 cmd
->deviceChangeState
.busNo
);
1630 sprintf(env_dev
, "SPAR_PARAHOTPLUG_DEVICE=%d",
1631 cmd
->deviceChangeState
.devNo
>> 3);
1632 sprintf(env_func
, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1633 cmd
->deviceChangeState
.devNo
& 0x7);
1635 LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n",
1636 cmd
->deviceChangeState
.state
.Active
,
1637 cmd
->deviceChangeState
.busNo
, cmd
->deviceChangeState
.devNo
>> 3,
1638 cmd
->deviceChangeState
.devNo
& 7, req
->id
);
1640 kobject_uevent_env(&Visorchipset_platform_device
.dev
.kobj
, KOBJ_CHANGE
,
1645 * Remove any request from the list that's been on there too long and
1646 * respond with an error.
1649 parahotplug_process_list(void)
1651 struct list_head
*pos
= NULL
;
1652 struct list_head
*tmp
= NULL
;
1654 spin_lock(&Parahotplug_request_list_lock
);
1656 list_for_each_safe(pos
, tmp
, &Parahotplug_request_list
) {
1657 struct parahotplug_request
*req
=
1658 list_entry(pos
, struct parahotplug_request
, list
);
1659 if (time_after_eq(jiffies
, req
->expiration
)) {
1661 if (req
->msg
.hdr
.Flags
.responseExpected
)
1662 controlvm_respond_physdev_changestate(
1664 CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT
,
1665 req
->msg
.cmd
.deviceChangeState
.state
);
1666 parahotplug_request_destroy(req
);
1670 spin_unlock(&Parahotplug_request_list_lock
);
1674 * Called from the /proc handler, which means the user script has
1675 * finished the enable/disable. Find the matching identifier, and
1676 * respond to the CONTROLVM message with success.
1679 parahotplug_request_complete(int id
, u16 active
)
1681 struct list_head
*pos
= NULL
;
1682 struct list_head
*tmp
= NULL
;
1684 spin_lock(&Parahotplug_request_list_lock
);
1686 /* Look for a request matching "id". */
1687 list_for_each_safe(pos
, tmp
, &Parahotplug_request_list
) {
1688 struct parahotplug_request
*req
=
1689 list_entry(pos
, struct parahotplug_request
, list
);
1690 if (req
->id
== id
) {
1691 /* Found a match. Remove it from the list and
1695 spin_unlock(&Parahotplug_request_list_lock
);
1696 req
->msg
.cmd
.deviceChangeState
.state
.Active
= active
;
1697 if (req
->msg
.hdr
.Flags
.responseExpected
)
1698 controlvm_respond_physdev_changestate(
1699 &req
->msg
.hdr
, CONTROLVM_RESP_SUCCESS
,
1700 req
->msg
.cmd
.deviceChangeState
.state
);
1701 parahotplug_request_destroy(req
);
1706 spin_unlock(&Parahotplug_request_list_lock
);
1711 * Enables or disables a PCI device by kicking off a udev script
1714 parahotplug_process_message(CONTROLVM_MESSAGE
*inmsg
)
1716 struct parahotplug_request
*req
;
1718 req
= parahotplug_request_create(inmsg
);
1721 LOGERR("parahotplug_process_message: couldn't allocate request");
1725 if (inmsg
->cmd
.deviceChangeState
.state
.Active
) {
1726 /* For enable messages, just respond with success
1727 * right away. This is a bit of a hack, but there are
1728 * issues with the early enable messages we get (with
1729 * either the udev script not detecting that the device
1730 * is up, or not getting called at all). Fortunately
1731 * the messages that get lost don't matter anyway, as
1732 * devices are automatically enabled at
1735 parahotplug_request_kickoff(req
);
1736 controlvm_respond_physdev_changestate(&inmsg
->hdr
,
1737 CONTROLVM_RESP_SUCCESS
,
1739 deviceChangeState
.state
);
1740 parahotplug_request_destroy(req
);
1742 /* For disable messages, add the request to the
1743 * request list before kicking off the udev script. It
1744 * won't get responded to until the script has
1745 * indicated it's done.
1747 spin_lock(&Parahotplug_request_list_lock
);
1748 list_add_tail(&(req
->list
), &Parahotplug_request_list
);
1749 spin_unlock(&Parahotplug_request_list_lock
);
1751 parahotplug_request_kickoff(req
);
1755 /* Process a controlvm message.
1757 * FALSE - this function will return FALSE only in the case where the
1758 * controlvm message was NOT processed, but processing must be
1759 * retried before reading the next controlvm message; a
1760 * scenario where this can occur is when we need to throttle
1761 * the allocation of memory in which to copy out controlvm
1763 * TRUE - processing of the controlvm message completed,
1764 * either successfully or with an error.
1767 handle_command(CONTROLVM_MESSAGE inmsg
, HOSTADDRESS channel_addr
)
1769 CONTROLVM_MESSAGE_PACKET
*cmd
= &inmsg
.cmd
;
1770 u64 parametersAddr
= 0;
1771 u32 parametersBytes
= 0;
1772 PARSER_CONTEXT
*parser_ctx
= NULL
;
1773 BOOL isLocalAddr
= FALSE
;
1774 CONTROLVM_MESSAGE ackmsg
;
1776 /* create parsing context if necessary */
1777 isLocalAddr
= (inmsg
.hdr
.Flags
.testMessage
== 1);
1778 if (channel_addr
== 0) {
1779 LOGERR("HUH? channel_addr is 0!");
1782 parametersAddr
= channel_addr
+ inmsg
.hdr
.PayloadVmOffset
;
1783 parametersBytes
= inmsg
.hdr
.PayloadBytes
;
1785 /* Parameter and channel addresses within test messages actually lie
1786 * within our OS-controlled memory. We need to know that, because it
1787 * makes a difference in how we compute the virtual address.
1789 if (parametersAddr
!= 0 && parametersBytes
!= 0) {
1792 parser_init_byteStream(parametersAddr
, parametersBytes
,
1793 isLocalAddr
, &retry
);
1796 LOGWRN("throttling to copy payload");
1799 LOGWRN("parsing failed");
1800 LOGWRN("inmsg.hdr.Id=0x%lx", (ulong
) inmsg
.hdr
.Id
);
1801 LOGWRN("parametersAddr=0x%llx", (u64
) parametersAddr
);
1802 LOGWRN("parametersBytes=%lu", (ulong
) parametersBytes
);
1803 LOGWRN("isLocalAddr=%d", isLocalAddr
);
1808 controlvm_init_response(&ackmsg
, &inmsg
.hdr
,
1809 CONTROLVM_RESP_SUCCESS
);
1810 if ((ControlVm_channel
)
1812 (!visorchannel_signalinsert
1813 (ControlVm_channel
, CONTROLVM_QUEUE_ACK
, &ackmsg
)))
1814 LOGWRN("failed to send ACK failed");
1816 switch (inmsg
.hdr
.Id
) {
1817 case CONTROLVM_CHIPSET_INIT
:
1818 LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)",
1819 (ulong
) inmsg
.cmd
.initChipset
.busCount
,
1820 (ulong
) inmsg
.cmd
.initChipset
.switchCount
);
1821 chipset_init(&inmsg
);
1823 case CONTROLVM_BUS_CREATE
:
1824 LOGINF("BUS_CREATE(%lu,#devs=%lu)",
1825 (ulong
) cmd
->createBus
.busNo
,
1826 (ulong
) cmd
->createBus
.deviceCount
);
1829 case CONTROLVM_BUS_DESTROY
:
1830 LOGINF("BUS_DESTROY(%lu)", (ulong
) cmd
->destroyBus
.busNo
);
1831 bus_destroy(&inmsg
);
1833 case CONTROLVM_BUS_CONFIGURE
:
1834 LOGINF("BUS_CONFIGURE(%lu)", (ulong
) cmd
->configureBus
.busNo
);
1835 bus_configure(&inmsg
, parser_ctx
);
1837 case CONTROLVM_DEVICE_CREATE
:
1838 LOGINF("DEVICE_CREATE(%lu,%lu)",
1839 (ulong
) cmd
->createDevice
.busNo
,
1840 (ulong
) cmd
->createDevice
.devNo
);
1841 my_device_create(&inmsg
);
1843 case CONTROLVM_DEVICE_CHANGESTATE
:
1844 if (cmd
->deviceChangeState
.flags
.physicalDevice
) {
1845 LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)",
1846 (ulong
) cmd
->deviceChangeState
.busNo
,
1847 (ulong
) cmd
->deviceChangeState
.devNo
,
1848 (ulong
) cmd
->deviceChangeState
.state
.Active
);
1849 parahotplug_process_message(&inmsg
);
1851 LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)",
1852 (ulong
) cmd
->deviceChangeState
.busNo
,
1853 (ulong
) cmd
->deviceChangeState
.devNo
,
1854 (ulong
) cmd
->deviceChangeState
.state
.Alive
);
1855 /* save the hdr and cmd structures for later use */
1856 /* when sending back the response to Command */
1857 my_device_changestate(&inmsg
);
1858 g_DiagMsgHdr
= inmsg
.hdr
;
1859 g_DeviceChangeStatePacket
= inmsg
.cmd
;
1863 case CONTROLVM_DEVICE_DESTROY
:
1864 LOGINF("DEVICE_DESTROY(%lu,%lu)",
1865 (ulong
) cmd
->destroyDevice
.busNo
,
1866 (ulong
) cmd
->destroyDevice
.devNo
);
1867 my_device_destroy(&inmsg
);
1869 case CONTROLVM_DEVICE_CONFIGURE
:
1870 LOGINF("DEVICE_CONFIGURE(%lu,%lu)",
1871 (ulong
) cmd
->configureDevice
.busNo
,
1872 (ulong
) cmd
->configureDevice
.devNo
);
1873 /* no op for now, just send a respond that we passed */
1874 if (inmsg
.hdr
.Flags
.responseExpected
)
1875 controlvm_respond(&inmsg
.hdr
, CONTROLVM_RESP_SUCCESS
);
1877 case CONTROLVM_CHIPSET_READY
:
1878 LOGINF("CHIPSET_READY");
1879 chipset_ready(&inmsg
.hdr
);
1881 case CONTROLVM_CHIPSET_SELFTEST
:
1882 LOGINF("CHIPSET_SELFTEST");
1883 chipset_selftest(&inmsg
.hdr
);
1885 case CONTROLVM_CHIPSET_STOP
:
1886 LOGINF("CHIPSET_STOP");
1887 chipset_notready(&inmsg
.hdr
);
1890 LOGERR("unrecognized controlvm cmd=%d", (int) inmsg
.hdr
.Id
);
1891 if (inmsg
.hdr
.Flags
.responseExpected
)
1892 controlvm_respond(&inmsg
.hdr
,
1893 -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN
);
1897 if (parser_ctx
!= NULL
) {
1898 parser_done(parser_ctx
);
1904 static HOSTADDRESS
controlvm_get_channel_address(void)
1909 if (!VMCALL_SUCCESSFUL(Issue_VMCALL_IO_CONTROLVM_ADDR(&addr
, &size
))) {
1910 ERRDRV("%s - vmcall to determine controlvm channel addr failed",
1914 INFODRV("controlvm addr=%Lx", addr
);
1919 controlvm_periodic_work(struct work_struct
*work
)
1921 VISORCHIPSET_CHANNEL_INFO chanInfo
;
1922 CONTROLVM_MESSAGE inmsg
;
1923 BOOL gotACommand
= FALSE
;
1924 BOOL handle_command_failed
= FALSE
;
1925 static u64 Poll_Count
;
1927 /* make sure visorbus server is registered for controlvm callbacks */
1928 if (visorchipset_serverregwait
&& !serverregistered
)
1930 /* make sure visorclientbus server is regsitered for controlvm
1933 if (visorchipset_clientregwait
&& !clientregistered
)
1936 memset(&chanInfo
, 0, sizeof(VISORCHIPSET_CHANNEL_INFO
));
1939 if (Poll_Count
>= 250)
1944 /* Check events to determine if response to CHIPSET_READY
1947 if (visorchipset_holdchipsetready
1948 && (g_ChipSetMsgHdr
.Id
!= CONTROLVM_INVALID
)) {
1949 if (check_chipset_events() == 1) {
1950 LOGINF("Sending CHIPSET_READY response");
1951 controlvm_respond(&g_ChipSetMsgHdr
, 0);
1952 clear_chipset_events();
1953 memset(&g_ChipSetMsgHdr
, 0,
1954 sizeof(CONTROLVM_MESSAGE_HEADER
));
1958 while (visorchannel_signalremove(ControlVm_channel
,
1959 CONTROLVM_QUEUE_RESPONSE
,
1961 if (inmsg
.hdr
.PayloadMaxBytes
!= 0) {
1962 LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
1963 (ulong
) inmsg
.hdr
.PayloadMaxBytes
,
1964 (ulong
) inmsg
.hdr
.PayloadVmOffset
,
1969 if (ControlVm_Pending_Msg_Valid
) {
1970 /* we throttled processing of a prior
1971 * msg, so try to process it again
1972 * rather than reading a new one
1974 inmsg
= ControlVm_Pending_Msg
;
1975 ControlVm_Pending_Msg_Valid
= FALSE
;
1978 gotACommand
= read_controlvm_event(&inmsg
);
1981 handle_command_failed
= FALSE
;
1982 while (gotACommand
&& (!handle_command_failed
)) {
1983 Most_recent_message_jiffies
= jiffies
;
1984 if (handle_command(inmsg
,
1985 visorchannel_get_physaddr
1986 (ControlVm_channel
)))
1987 gotACommand
= read_controlvm_event(&inmsg
);
1989 /* this is a scenario where throttling
1990 * is required, but probably NOT an
1991 * error...; we stash the current
1992 * controlvm msg so we will attempt to
1993 * reprocess it on our next loop
1995 handle_command_failed
= TRUE
;
1996 ControlVm_Pending_Msg
= inmsg
;
1997 ControlVm_Pending_Msg_Valid
= TRUE
;
2001 /* parahotplug_worker */
2002 parahotplug_process_list();
2006 if (time_after(jiffies
,
2007 Most_recent_message_jiffies
+ (HZ
* MIN_IDLE_SECONDS
))) {
2008 /* it's been longer than MIN_IDLE_SECONDS since we
2009 * processed our last controlvm message; slow down the
2012 if (Poll_jiffies
!= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
) {
2013 LOGINF("switched to slow controlvm polling");
2014 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
;
2017 if (Poll_jiffies
!= POLLJIFFIES_CONTROLVMCHANNEL_FAST
) {
2018 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_FAST
;
2019 LOGINF("switched to fast controlvm polling");
2023 queue_delayed_work(Periodic_controlvm_workqueue
,
2024 &Periodic_controlvm_work
, Poll_jiffies
);
2028 setup_crash_devices_work_queue(struct work_struct
*work
)
2031 CONTROLVM_MESSAGE localCrashCreateBusMsg
;
2032 CONTROLVM_MESSAGE localCrashCreateDevMsg
;
2033 CONTROLVM_MESSAGE msg
;
2034 u32 localSavedCrashMsgOffset
;
2035 u16 localSavedCrashMsgCount
;
2037 /* make sure visorbus server is registered for controlvm callbacks */
2038 if (visorchipset_serverregwait
&& !serverregistered
)
2041 /* make sure visorclientbus server is regsitered for controlvm
2044 if (visorchipset_clientregwait
&& !clientregistered
)
2047 POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
2049 /* send init chipset msg */
2050 msg
.hdr
.Id
= CONTROLVM_CHIPSET_INIT
;
2051 msg
.cmd
.initChipset
.busCount
= 23;
2052 msg
.cmd
.initChipset
.switchCount
= 0;
2056 /* get saved message count */
2057 if (visorchannel_read(ControlVm_channel
,
2058 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
2059 SavedCrashMsgCount
),
2060 &localSavedCrashMsgCount
, sizeof(u16
)) < 0) {
2061 LOGERR("failed to get Saved Message Count");
2062 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
2063 POSTCODE_SEVERITY_ERR
);
2067 if (localSavedCrashMsgCount
!= CONTROLVM_CRASHMSG_MAX
) {
2068 LOGERR("Saved Message Count incorrect %d",
2069 localSavedCrashMsgCount
);
2070 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC
,
2071 localSavedCrashMsgCount
,
2072 POSTCODE_SEVERITY_ERR
);
2076 /* get saved crash message offset */
2077 if (visorchannel_read(ControlVm_channel
,
2078 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
,
2079 SavedCrashMsgOffset
),
2080 &localSavedCrashMsgOffset
, sizeof(u32
)) < 0) {
2081 LOGERR("failed to get Saved Message Offset");
2082 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC
,
2083 POSTCODE_SEVERITY_ERR
);
2087 /* read create device message for storage bus offset */
2088 if (visorchannel_read(ControlVm_channel
,
2089 localSavedCrashMsgOffset
,
2090 &localCrashCreateBusMsg
,
2091 sizeof(CONTROLVM_MESSAGE
)) < 0) {
2092 LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!");
2093 POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC
,
2094 POSTCODE_SEVERITY_ERR
);
2098 /* read create device message for storage device */
2099 if (visorchannel_read(ControlVm_channel
,
2100 localSavedCrashMsgOffset
+
2101 sizeof(CONTROLVM_MESSAGE
),
2102 &localCrashCreateDevMsg
,
2103 sizeof(CONTROLVM_MESSAGE
)) < 0) {
2104 LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!");
2105 POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC
,
2106 POSTCODE_SEVERITY_ERR
);
2110 /* reuse IOVM create bus message */
2111 if (localCrashCreateBusMsg
.cmd
.createBus
.channelAddr
!= 0)
2112 bus_create(&localCrashCreateBusMsg
);
2114 LOGERR("CrashCreateBusMsg is null, no dump will be taken");
2115 POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC
,
2116 POSTCODE_SEVERITY_ERR
);
2120 /* reuse create device message for storage device */
2121 if (localCrashCreateDevMsg
.cmd
.createDevice
.channelAddr
!= 0)
2122 my_device_create(&localCrashCreateDevMsg
);
2124 LOGERR("CrashCreateDevMsg is null, no dump will be taken");
2125 POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC
,
2126 POSTCODE_SEVERITY_ERR
);
2129 LOGINF("Bus and device ready for dumping");
2130 POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2135 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_SLOW
;
2137 queue_delayed_work(Periodic_controlvm_workqueue
,
2138 &Periodic_controlvm_work
, Poll_jiffies
);
2142 bus_create_response(ulong busNo
, int response
)
2144 bus_responder(CONTROLVM_BUS_CREATE
, busNo
, response
);
2148 bus_destroy_response(ulong busNo
, int response
)
2150 bus_responder(CONTROLVM_BUS_DESTROY
, busNo
, response
);
2154 device_create_response(ulong busNo
, ulong devNo
, int response
)
2156 device_responder(CONTROLVM_DEVICE_CREATE
, busNo
, devNo
, response
);
2160 device_destroy_response(ulong busNo
, ulong devNo
, int response
)
2162 device_responder(CONTROLVM_DEVICE_DESTROY
, busNo
, devNo
, response
);
2166 visorchipset_device_pause_response(ulong busNo
, ulong devNo
, int response
)
2169 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE
,
2170 busNo
, devNo
, response
,
2171 SegmentStateStandby
);
2173 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response
);
2176 device_resume_response(ulong busNo
, ulong devNo
, int response
)
2178 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE
,
2179 busNo
, devNo
, response
,
2180 SegmentStateRunning
);
2184 visorchipset_get_bus_info(ulong busNo
, VISORCHIPSET_BUS_INFO
*busInfo
)
2186 void *p
= findbus(&BusInfoList
, busNo
);
2188 LOGERR("(%lu) failed", busNo
);
2191 memcpy(busInfo
, p
, sizeof(VISORCHIPSET_BUS_INFO
));
2194 EXPORT_SYMBOL_GPL(visorchipset_get_bus_info
);
2197 visorchipset_set_bus_context(ulong busNo
, void *context
)
2199 VISORCHIPSET_BUS_INFO
*p
= findbus(&BusInfoList
, busNo
);
2201 LOGERR("(%lu) failed", busNo
);
2204 p
->bus_driver_context
= context
;
2207 EXPORT_SYMBOL_GPL(visorchipset_set_bus_context
);
2210 visorchipset_get_device_info(ulong busNo
, ulong devNo
,
2211 VISORCHIPSET_DEVICE_INFO
*devInfo
)
2213 void *p
= finddevice(&DevInfoList
, busNo
, devNo
);
2215 LOGERR("(%lu,%lu) failed", busNo
, devNo
);
2218 memcpy(devInfo
, p
, sizeof(VISORCHIPSET_DEVICE_INFO
));
2221 EXPORT_SYMBOL_GPL(visorchipset_get_device_info
);
2224 visorchipset_set_device_context(ulong busNo
, ulong devNo
, void *context
)
2226 VISORCHIPSET_DEVICE_INFO
*p
= finddevice(&DevInfoList
, busNo
, devNo
);
2228 LOGERR("(%lu,%lu) failed", busNo
, devNo
);
2231 p
->bus_driver_context
= context
;
2234 EXPORT_SYMBOL_GPL(visorchipset_set_device_context
);
2236 /* Generic wrapper function for allocating memory from a kmem_cache pool.
2239 visorchipset_cache_alloc(struct kmem_cache
*pool
, BOOL ok_to_block
,
2249 /* __GFP_NORETRY means "ok to fail", meaning
2250 * kmem_cache_alloc() can return NULL, implying the caller CAN
2251 * cope with failure. If you do NOT specify __GFP_NORETRY,
2252 * Linux will go to extreme measures to get memory for you
2253 * (like, invoke oom killer), which will probably cripple the
2256 gfp
|= __GFP_NORETRY
;
2257 p
= kmem_cache_alloc(pool
, gfp
);
2259 LOGERR("kmem_cache_alloc failed early @%s:%d\n", fn
, ln
);
2262 atomic_inc(&Visorchipset_cache_buffers_in_use
);
2266 /* Generic wrapper function for freeing memory from a kmem_cache pool.
2269 visorchipset_cache_free(struct kmem_cache
*pool
, void *p
, char *fn
, int ln
)
2272 LOGERR("NULL pointer @%s:%d\n", fn
, ln
);
2275 atomic_dec(&Visorchipset_cache_buffers_in_use
);
2276 kmem_cache_free(pool
, p
);
2279 static ssize_t
chipsetready_store(struct device
*dev
,
2280 struct device_attribute
*attr
, const char *buf
, size_t count
)
2284 if (sscanf(buf
, "%63s", msgtype
) != 1)
2287 if (strcmp(msgtype
, "CALLHOMEDISK_MOUNTED") == 0) {
2288 chipset_events
[0] = 1;
2290 } else if (strcmp(msgtype
, "MODULES_LOADED") == 0) {
2291 chipset_events
[1] = 1;
2297 /* The parahotplug/devicedisabled interface gets called by our support script
2298 * when an SR-IOV device has been shut down. The ID is passed to the script
2299 * and then passed back when the device has been removed.
2301 static ssize_t
devicedisabled_store(struct device
*dev
,
2302 struct device_attribute
*attr
, const char *buf
, size_t count
)
2306 if (kstrtouint(buf
, 10, &id
) != 0)
2309 parahotplug_request_complete(id
, 0);
2313 /* The parahotplug/deviceenabled interface gets called by our support script
2314 * when an SR-IOV device has been recovered. The ID is passed to the script
2315 * and then passed back when the device has been brought back up.
2317 static ssize_t
deviceenabled_store(struct device
*dev
,
2318 struct device_attribute
*attr
, const char *buf
, size_t count
)
2322 if (kstrtouint(buf
, 10, &id
) != 0)
2325 parahotplug_request_complete(id
, 1);
2330 visorchipset_init(void)
2336 if (!unisys_spar_platform
)
2339 LOGINF("chipset driver version %s loaded", VERSION
);
2340 /* process module options */
2341 POSTCODE_LINUX_2(DRIVER_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
2343 LOGINF("option - testvnic=%d", visorchipset_testvnic
);
2344 LOGINF("option - testvnicclient=%d", visorchipset_testvnicclient
);
2345 LOGINF("option - testmsg=%d", visorchipset_testmsg
);
2346 LOGINF("option - testteardown=%d", visorchipset_testteardown
);
2347 LOGINF("option - major=%d", visorchipset_major
);
2348 LOGINF("option - serverregwait=%d", visorchipset_serverregwait
);
2349 LOGINF("option - clientregwait=%d", visorchipset_clientregwait
);
2350 LOGINF("option - holdchipsetready=%d", visorchipset_holdchipsetready
);
2352 memset(&BusDev_Server_Notifiers
, 0, sizeof(BusDev_Server_Notifiers
));
2353 memset(&BusDev_Client_Notifiers
, 0, sizeof(BusDev_Client_Notifiers
));
2354 memset(&ControlVm_payload_info
, 0, sizeof(ControlVm_payload_info
));
2355 memset(&LiveDump_info
, 0, sizeof(LiveDump_info
));
2356 atomic_set(&LiveDump_info
.buffers_in_use
, 0);
2358 if (visorchipset_testvnic
) {
2359 ERRDRV("testvnic option no longer supported: (status = %d)\n",
2361 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC
, x
, DIAG_SEVERITY_ERR
);
2366 addr
= controlvm_get_channel_address();
2369 visorchannel_create_with_lock
2371 sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL
),
2372 UltraControlvmChannelProtocolGuid
);
2373 if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
2374 (visorchannel_get_header(ControlVm_channel
),
2376 LOGINF("Channel %s (ControlVm) discovered",
2377 visorchannel_id(ControlVm_channel
, s
));
2378 initialize_controlvm_payload();
2380 LOGERR("controlvm channel is invalid");
2381 visorchannel_destroy(ControlVm_channel
);
2382 ControlVm_channel
= NULL
;
2386 LOGERR("no controlvm channel discovered");
2390 MajorDev
= MKDEV(visorchipset_major
, 0);
2391 rc
= visorchipset_file_init(MajorDev
, &ControlVm_channel
);
2393 ERRDRV("visorchipset_file_init(MajorDev, &ControlVm_channel): error (status=%d)\n", rc
);
2394 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2398 memset(&g_DiagMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2400 memset(&g_ChipSetMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2402 memset(&g_DelDumpMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2404 Putfile_buffer_list_pool
=
2405 kmem_cache_create(Putfile_buffer_list_pool_name
,
2406 sizeof(struct putfile_buffer_entry
),
2407 0, SLAB_HWCACHE_ALIGN
, NULL
);
2408 if (!Putfile_buffer_list_pool
) {
2409 ERRDRV("failed to alloc Putfile_buffer_list_pool: (status=-1)\n");
2410 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2414 if (visorchipset_disable_controlvm
) {
2415 LOGINF("visorchipset_init:controlvm disabled");
2417 /* if booting in a crash kernel */
2418 if (visorchipset_crash_kernel
)
2419 INIT_DELAYED_WORK(&Periodic_controlvm_work
,
2420 setup_crash_devices_work_queue
);
2422 INIT_DELAYED_WORK(&Periodic_controlvm_work
,
2423 controlvm_periodic_work
);
2424 Periodic_controlvm_workqueue
=
2425 create_singlethread_workqueue("visorchipset_controlvm");
2427 if (Periodic_controlvm_workqueue
== NULL
) {
2428 ERRDRV("cannot create controlvm workqueue: (status=%d)\n",
2430 POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC
,
2435 Most_recent_message_jiffies
= jiffies
;
2436 Poll_jiffies
= POLLJIFFIES_CONTROLVMCHANNEL_FAST
;
2437 rc
= queue_delayed_work(Periodic_controlvm_workqueue
,
2438 &Periodic_controlvm_work
, Poll_jiffies
);
2440 ERRDRV("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies): error (status=%d)\n", rc
);
2441 POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC
,
2448 Visorchipset_platform_device
.dev
.devt
= MajorDev
;
2449 if (platform_device_register(&Visorchipset_platform_device
) < 0) {
2450 ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n");
2451 POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC
, DIAG_SEVERITY_ERR
);
2455 LOGINF("visorchipset device created");
2456 POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC
, POSTCODE_SEVERITY_INFO
);
2460 LOGERR("visorchipset_init failed");
2461 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC
, rc
,
2462 POSTCODE_SEVERITY_ERR
);
2468 visorchipset_exit(void)
2471 POSTCODE_LINUX_2(DRIVER_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2473 if (visorchipset_disable_controlvm
) {
2476 cancel_delayed_work(&Periodic_controlvm_work
);
2477 flush_workqueue(Periodic_controlvm_workqueue
);
2478 destroy_workqueue(Periodic_controlvm_workqueue
);
2479 Periodic_controlvm_workqueue
= NULL
;
2480 destroy_controlvm_payload_info(&ControlVm_payload_info
);
2482 Test_Vnic_channel
= NULL
;
2483 if (Putfile_buffer_list_pool
) {
2484 kmem_cache_destroy(Putfile_buffer_list_pool
);
2485 Putfile_buffer_list_pool
= NULL
;
2488 cleanup_controlvm_structures();
2490 memset(&g_DiagMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2492 memset(&g_ChipSetMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2494 memset(&g_DelDumpMsgHdr
, 0, sizeof(CONTROLVM_MESSAGE_HEADER
));
2496 LOGINF("Channel %s (ControlVm) disconnected",
2497 visorchannel_id(ControlVm_channel
, s
));
2498 visorchannel_destroy(ControlVm_channel
);
2500 visorchipset_file_cleanup();
2501 POSTCODE_LINUX_2(DRIVER_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
2502 LOGINF("chipset driver unloaded");
2505 module_param_named(testvnic
, visorchipset_testvnic
, int, S_IRUGO
);
2506 MODULE_PARM_DESC(visorchipset_testvnic
, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
2507 int visorchipset_testvnic
= 0;
2509 module_param_named(testvnicclient
, visorchipset_testvnicclient
, int, S_IRUGO
);
2510 MODULE_PARM_DESC(visorchipset_testvnicclient
, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
2511 int visorchipset_testvnicclient
= 0;
2513 module_param_named(testmsg
, visorchipset_testmsg
, int, S_IRUGO
);
2514 MODULE_PARM_DESC(visorchipset_testmsg
,
2515 "1 to manufacture the chipset, bus, and switch messages");
2516 int visorchipset_testmsg
= 0;
2518 module_param_named(major
, visorchipset_major
, int, S_IRUGO
);
2519 MODULE_PARM_DESC(visorchipset_major
, "major device number to use for the device node");
2520 int visorchipset_major
= 0;
2522 module_param_named(serverregwait
, visorchipset_serverregwait
, int, S_IRUGO
);
2523 MODULE_PARM_DESC(visorchipset_serverreqwait
,
2524 "1 to have the module wait for the visor bus to register");
2525 int visorchipset_serverregwait
= 0; /* default is off */
2526 module_param_named(clientregwait
, visorchipset_clientregwait
, int, S_IRUGO
);
2527 MODULE_PARM_DESC(visorchipset_clientregwait
, "1 to have the module wait for the visorclientbus to register");
2528 int visorchipset_clientregwait
= 1; /* default is on */
2529 module_param_named(testteardown
, visorchipset_testteardown
, int, S_IRUGO
);
2530 MODULE_PARM_DESC(visorchipset_testteardown
,
2531 "1 to test teardown of the chipset, bus, and switch");
2532 int visorchipset_testteardown
= 0; /* default is off */
2533 module_param_named(disable_controlvm
, visorchipset_disable_controlvm
, int,
2535 MODULE_PARM_DESC(visorchipset_disable_controlvm
,
2536 "1 to disable polling of controlVm channel");
2537 int visorchipset_disable_controlvm
= 0; /* default is off */
2538 module_param_named(crash_kernel
, visorchipset_crash_kernel
, int, S_IRUGO
);
2539 MODULE_PARM_DESC(visorchipset_crash_kernel
,
2540 "1 means we are running in crash kernel");
2541 int visorchipset_crash_kernel
= 0; /* default is running in non-crash kernel */
2542 module_param_named(holdchipsetready
, visorchipset_holdchipsetready
,
2544 MODULE_PARM_DESC(visorchipset_holdchipsetready
,
2545 "1 to hold response to CHIPSET_READY");
2546 int visorchipset_holdchipsetready
= 0; /* default is to send CHIPSET_READY
2547 * response immediately */
2548 module_init(visorchipset_init
);
2549 module_exit(visorchipset_exit
);
2551 MODULE_AUTHOR("Unisys");
2552 MODULE_LICENSE("GPL");
2553 MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
2555 MODULE_VERSION(VERSION
);