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
20 #include <linux/kernel.h>
21 #include <linux/highmem.h>
22 #ifdef CONFIG_MODVERSIONS
23 #include <config/modversions.h>
25 #include <linux/module.h>
26 #include <linux/debugfs.h>
28 #include <linux/types.h>
29 #include <linux/uuid.h>
31 #include <linux/version.h>
33 #include "diagnostics/appos_subsystems.h"
35 #include "vbuschannel.h"
37 #include <linux/proc_fs.h>
38 #include <linux/uaccess.h> /* for copy_from_user */
39 #include <linux/ctype.h> /* for toupper */
40 #include <linux/list.h>
43 #include "visorchipset.h"
45 #include "guestlinuxdebug.h"
47 #define SET_PROC_OWNER(x, y)
49 #define POLLJIFFIES_NORMAL 1
50 /* Choose whether or not you want to wakeup the request-polling thread
51 * after an IO termination:
52 * this is shorter than using __FILE__ (full path name) in
53 * debug/info/error messages
55 #define CURRENT_FILE_PC UISLIB_PC_uislib_c
56 #define __MYFILE__ "uislib.c"
58 /* global function pointers that act as callback functions into virtpcimod */
59 int (*virt_control_chan_func
)(struct guest_msgs
*);
61 static int debug_buf_valid
;
62 static char *debug_buf
; /* Note this MUST be global,
63 * because the contents must */
64 static unsigned int chipset_inited
;
66 #define WAIT_ON_CALLBACK(handle) \
73 static struct bus_info
*bus_list
;
74 static rwlock_t bus_list_lock
;
75 static int bus_list_count
; /* number of buses in the list */
76 static int max_bus_count
; /* maximum number of buses expected */
77 static u64 phys_data_chan
;
78 static int platform_no
;
80 static struct uisthread_info incoming_ti
;
81 static BOOL incoming_started
= FALSE
;
82 static LIST_HEAD(poll_dev_chan
);
83 static unsigned long long tot_moved_to_tail_cnt
;
84 static unsigned long long tot_wait_cnt
;
85 static unsigned long long tot_wakeup_cnt
;
86 static unsigned long long tot_schedule_cnt
;
87 static int en_smart_wakeup
= 1;
88 static DEFINE_SEMAPHORE(poll_dev_lock
); /* unlocked */
89 static DECLARE_WAIT_QUEUE_HEAD(poll_dev_wake_q
);
90 static int poll_dev_start
;
92 #define CALLHOME_PROC_ENTRY_FN "callhome"
93 #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled"
95 #define DIR_DEBUGFS_ENTRY "uislib"
96 static struct dentry
*dir_debugfs
;
98 #define PLATFORMNUMBER_DEBUGFS_ENTRY_FN "platform"
99 static struct dentry
*platformnumber_debugfs_read
;
101 #define CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN "cycles_before_wait"
102 static struct dentry
*cycles_before_wait_debugfs_read
;
104 #define SMART_WAKEUP_DEBUGFS_ENTRY_FN "smart_wakeup"
105 static struct dentry
*smart_wakeup_debugfs_entry
;
107 #define INFO_DEBUGFS_ENTRY_FN "info"
108 static struct dentry
*info_debugfs_entry
;
110 static unsigned long long cycles_before_wait
, wait_cycles
;
112 /*****************************************************/
113 /* local functions */
114 /*****************************************************/
116 static ssize_t
info_debugfs_read(struct file
*file
, char __user
*buf
,
117 size_t len
, loff_t
*offset
);
118 static const struct file_operations debugfs_info_fops
= {
119 .read
= info_debugfs_read
,
123 init_msg_header(struct controlvm_message
*msg
, u32 id
, uint rsp
, uint svr
)
125 memset(msg
, 0, sizeof(struct controlvm_message
));
127 msg
->hdr
.flags
.response_expected
= rsp
;
128 msg
->hdr
.flags
.server
= svr
;
131 static __iomem
void *init_vbus_channel(u64 ch_addr
, u32 ch_bytes
)
133 void __iomem
*ch
= uislib_ioremap_cache(ch_addr
, ch_bytes
);
138 if (!SPAR_VBUS_CHANNEL_OK_CLIENT(ch
)) {
146 create_bus(struct controlvm_message
*msg
, char *buf
)
148 u32 bus_no
, dev_count
;
149 struct bus_info
*tmp
, *bus
;
152 if (max_bus_count
== bus_list_count
) {
153 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, max_bus_count
,
154 POSTCODE_SEVERITY_ERR
);
155 return CONTROLVM_RESP_ERROR_MAX_BUSES
;
158 bus_no
= msg
->cmd
.create_bus
.bus_no
;
159 dev_count
= msg
->cmd
.create_bus
.dev_count
;
161 POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC
, bus_no
, dev_count
,
162 POSTCODE_SEVERITY_INFO
);
165 sizeof(struct bus_info
) +
166 (dev_count
* sizeof(struct device_info
*));
167 bus
= kzalloc(size
, GFP_ATOMIC
);
169 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, bus_no
,
170 POSTCODE_SEVERITY_ERR
);
171 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
174 /* Currently by default, the bus Number is the GuestHandle.
175 * Configure Bus message can override this.
177 if (msg
->hdr
.flags
.test_message
) {
178 /* This implies we're the IOVM so set guest handle to 0... */
179 bus
->guest_handle
= 0;
180 bus
->bus_no
= bus_no
;
183 bus
->bus_no
= bus_no
;
184 bus
->guest_handle
= bus_no
;
186 sprintf(bus
->name
, "%d", (int)bus
->bus_no
);
187 bus
->device_count
= dev_count
;
189 (struct device_info
**)((char *)bus
+ sizeof(struct bus_info
));
190 bus
->bus_inst_uuid
= msg
->cmd
.create_bus
.bus_inst_uuid
;
191 bus
->bus_channel_bytes
= 0;
192 bus
->bus_channel
= NULL
;
194 /* add bus to our bus list - but check for duplicates first */
195 read_lock(&bus_list_lock
);
196 for (tmp
= bus_list
; tmp
; tmp
= tmp
->next
) {
197 if (tmp
->bus_no
== bus
->bus_no
)
200 read_unlock(&bus_list_lock
);
202 /* found a bus already in the list with same bus_no -
205 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, bus
->bus_no
,
206 POSTCODE_SEVERITY_ERR
);
208 return CONTROLVM_RESP_ERROR_ALREADY_DONE
;
210 if ((msg
->cmd
.create_bus
.channel_addr
!= 0) &&
211 (msg
->cmd
.create_bus
.channel_bytes
!= 0)) {
212 bus
->bus_channel_bytes
= msg
->cmd
.create_bus
.channel_bytes
;
214 init_vbus_channel(msg
->cmd
.create_bus
.channel_addr
,
215 msg
->cmd
.create_bus
.channel_bytes
);
217 /* the msg is bound for virtpci; send guest_msgs struct to callback */
218 if (!msg
->hdr
.flags
.server
) {
219 struct guest_msgs cmd
;
221 cmd
.msgtype
= GUEST_ADD_VBUS
;
222 cmd
.add_vbus
.bus_no
= bus_no
;
223 cmd
.add_vbus
.chanptr
= bus
->bus_channel
;
224 cmd
.add_vbus
.dev_count
= dev_count
;
225 cmd
.add_vbus
.bus_uuid
= msg
->cmd
.create_bus
.bus_data_type_uuid
;
226 cmd
.add_vbus
.instance_uuid
= msg
->cmd
.create_bus
.bus_inst_uuid
;
227 if (!virt_control_chan_func
) {
228 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, bus
->bus_no
,
229 POSTCODE_SEVERITY_ERR
);
231 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
233 if (!virt_control_chan_func(&cmd
)) {
234 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, bus
->bus_no
,
235 POSTCODE_SEVERITY_ERR
);
238 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
242 /* add bus at the head of our list */
243 write_lock(&bus_list_lock
);
247 bus
->next
= bus_list
;
251 write_unlock(&bus_list_lock
);
253 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC
, bus
->bus_no
,
254 POSTCODE_SEVERITY_INFO
);
255 return CONTROLVM_RESP_SUCCESS
;
259 destroy_bus(struct controlvm_message
*msg
, char *buf
)
262 struct bus_info
*bus
, *prev
= NULL
;
263 struct guest_msgs cmd
;
266 bus_no
= msg
->cmd
.destroy_bus
.bus_no
;
268 read_lock(&bus_list_lock
);
272 if (bus
->bus_no
== bus_no
)
279 read_unlock(&bus_list_lock
);
280 return CONTROLVM_RESP_ERROR_ALREADY_DONE
;
283 /* verify that this bus has no devices. */
284 for (i
= 0; i
< bus
->device_count
; i
++) {
285 if (bus
->device
[i
] != NULL
) {
286 read_unlock(&bus_list_lock
);
287 return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED
;
290 read_unlock(&bus_list_lock
);
292 if (msg
->hdr
.flags
.server
)
295 /* client messages require us to call the virtpci callback associated
297 cmd
.msgtype
= GUEST_DEL_VBUS
;
298 cmd
.del_vbus
.bus_no
= bus_no
;
299 if (!virt_control_chan_func
)
300 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
302 if (!virt_control_chan_func(&cmd
))
303 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
305 /* finally, remove the bus from the list */
307 write_lock(&bus_list_lock
);
308 if (prev
) /* not at head */
309 prev
->next
= bus
->next
;
311 bus_list
= bus
->next
;
313 write_unlock(&bus_list_lock
);
315 if (bus
->bus_channel
) {
316 uislib_iounmap(bus
->bus_channel
);
317 bus
->bus_channel
= NULL
;
321 return CONTROLVM_RESP_SUCCESS
;
324 static int create_device(struct controlvm_message
*msg
, char *buf
)
326 struct device_info
*dev
;
327 struct bus_info
*bus
;
328 struct guest_msgs cmd
;
330 int result
= CONTROLVM_RESP_SUCCESS
;
331 u64 min_size
= MIN_IO_CHANNEL_SIZE
;
332 struct req_handler_info
*req_handler
;
334 bus_no
= msg
->cmd
.create_device
.bus_no
;
335 dev_no
= msg
->cmd
.create_device
.dev_no
;
337 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC
, dev_no
, bus_no
,
338 POSTCODE_SEVERITY_INFO
);
340 dev
= kzalloc(sizeof(*dev
), GFP_ATOMIC
);
342 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
, bus_no
,
343 POSTCODE_SEVERITY_ERR
);
344 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED
;
347 dev
->channel_uuid
= msg
->cmd
.create_device
.data_type_uuid
;
348 dev
->intr
= msg
->cmd
.create_device
.intr
;
349 dev
->channel_addr
= msg
->cmd
.create_device
.channel_addr
;
350 dev
->bus_no
= bus_no
;
351 dev
->dev_no
= dev_no
;
352 sema_init(&dev
->interrupt_callback_lock
, 1); /* unlocked */
353 sprintf(dev
->devid
, "vbus%u:dev%u", (unsigned)bus_no
, (unsigned)dev_no
);
354 /* map the channel memory for the device. */
355 if (msg
->hdr
.flags
.test_message
) {
356 dev
->chanptr
= (void __iomem
*)__va(dev
->channel_addr
);
358 req_handler
= req_handler_find(dev
->channel_uuid
);
360 /* generic service handler registered for this
363 min_size
= req_handler
->min_channel_bytes
;
364 if (min_size
> msg
->cmd
.create_device
.channel_bytes
) {
365 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
366 bus_no
, POSTCODE_SEVERITY_ERR
);
367 result
= CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL
;
371 uislib_ioremap_cache(dev
->channel_addr
,
372 msg
->cmd
.create_device
.channel_bytes
);
374 result
= CONTROLVM_RESP_ERROR_IOREMAP_FAILED
;
375 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
376 bus_no
, POSTCODE_SEVERITY_ERR
);
380 dev
->instance_uuid
= msg
->cmd
.create_device
.dev_inst_uuid
;
381 dev
->channel_bytes
= msg
->cmd
.create_device
.channel_bytes
;
383 read_lock(&bus_list_lock
);
384 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
385 if (bus
->bus_no
!= bus_no
)
387 /* make sure the device number is valid */
388 if (dev_no
>= bus
->device_count
) {
389 result
= CONTROLVM_RESP_ERROR_MAX_DEVICES
;
390 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
391 bus_no
, POSTCODE_SEVERITY_ERR
);
392 read_unlock(&bus_list_lock
);
395 /* make sure this device is not already set */
396 if (bus
->device
[dev_no
]) {
397 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
,
399 POSTCODE_SEVERITY_ERR
);
400 result
= CONTROLVM_RESP_ERROR_ALREADY_DONE
;
401 read_unlock(&bus_list_lock
);
404 read_unlock(&bus_list_lock
);
405 /* the msg is bound for virtpci; send
406 * guest_msgs struct to callback
408 if (msg
->hdr
.flags
.server
) {
409 bus
->device
[dev_no
] = dev
;
410 POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC
, dev_no
,
411 bus_no
, POSTCODE_SEVERITY_INFO
);
412 return CONTROLVM_RESP_SUCCESS
;
414 if (uuid_le_cmp(dev
->channel_uuid
,
415 spar_vhba_channel_protocol_uuid
) == 0) {
416 wait_for_valid_guid(&((struct channel_header __iomem
*)
417 (dev
->chanptr
))->chtype
);
418 if (!SPAR_VHBA_CHANNEL_OK_CLIENT(dev
->chanptr
)) {
419 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
,
421 POSTCODE_SEVERITY_ERR
);
422 result
= CONTROLVM_RESP_ERROR_CHANNEL_INVALID
;
425 cmd
.msgtype
= GUEST_ADD_VHBA
;
426 cmd
.add_vhba
.chanptr
= dev
->chanptr
;
427 cmd
.add_vhba
.bus_no
= bus_no
;
428 cmd
.add_vhba
.device_no
= dev_no
;
429 cmd
.add_vhba
.instance_uuid
= dev
->instance_uuid
;
430 cmd
.add_vhba
.intr
= dev
->intr
;
431 } else if (uuid_le_cmp(dev
->channel_uuid
,
432 spar_vnic_channel_protocol_uuid
) == 0) {
433 wait_for_valid_guid(&((struct channel_header __iomem
*)
434 (dev
->chanptr
))->chtype
);
435 if (!SPAR_VNIC_CHANNEL_OK_CLIENT(dev
->chanptr
)) {
436 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
,
438 POSTCODE_SEVERITY_ERR
);
439 result
= CONTROLVM_RESP_ERROR_CHANNEL_INVALID
;
442 cmd
.msgtype
= GUEST_ADD_VNIC
;
443 cmd
.add_vnic
.chanptr
= dev
->chanptr
;
444 cmd
.add_vnic
.bus_no
= bus_no
;
445 cmd
.add_vnic
.device_no
= dev_no
;
446 cmd
.add_vnic
.instance_uuid
= dev
->instance_uuid
;
447 cmd
.add_vhba
.intr
= dev
->intr
;
449 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
450 bus_no
, POSTCODE_SEVERITY_ERR
);
451 result
= CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN
;
455 if (!virt_control_chan_func
) {
456 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
457 bus_no
, POSTCODE_SEVERITY_ERR
);
458 result
= CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
462 if (!virt_control_chan_func(&cmd
)) {
463 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
,
464 bus_no
, POSTCODE_SEVERITY_ERR
);
466 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
470 bus
->device
[dev_no
] = dev
;
471 POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC
, dev_no
,
472 bus_no
, POSTCODE_SEVERITY_INFO
);
473 return CONTROLVM_RESP_SUCCESS
;
475 read_unlock(&bus_list_lock
);
477 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC
, dev_no
, bus_no
,
478 POSTCODE_SEVERITY_ERR
);
479 result
= CONTROLVM_RESP_ERROR_BUS_INVALID
;
482 if (!msg
->hdr
.flags
.test_message
) {
483 uislib_iounmap(dev
->chanptr
);
491 static int pause_device(struct controlvm_message
*msg
)
494 struct bus_info
*bus
;
495 struct device_info
*dev
;
496 struct guest_msgs cmd
;
497 int retval
= CONTROLVM_RESP_SUCCESS
;
499 bus_no
= msg
->cmd
.device_change_state
.bus_no
;
500 dev_no
= msg
->cmd
.device_change_state
.dev_no
;
502 read_lock(&bus_list_lock
);
503 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
504 if (bus
->bus_no
== bus_no
) {
505 /* make sure the device number is valid */
506 if (dev_no
>= bus
->device_count
) {
507 retval
= CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
509 /* make sure this device exists */
510 dev
= bus
->device
[dev_no
];
513 CONTROLVM_RESP_ERROR_ALREADY_DONE
;
520 retval
= CONTROLVM_RESP_ERROR_BUS_INVALID
;
522 read_unlock(&bus_list_lock
);
523 if (retval
== CONTROLVM_RESP_SUCCESS
) {
524 /* the msg is bound for virtpci; send
525 * guest_msgs struct to callback
527 if (uuid_le_cmp(dev
->channel_uuid
,
528 spar_vhba_channel_protocol_uuid
) == 0) {
529 cmd
.msgtype
= GUEST_PAUSE_VHBA
;
530 cmd
.pause_vhba
.chanptr
= dev
->chanptr
;
531 } else if (uuid_le_cmp(dev
->channel_uuid
,
532 spar_vnic_channel_protocol_uuid
) == 0) {
533 cmd
.msgtype
= GUEST_PAUSE_VNIC
;
534 cmd
.pause_vnic
.chanptr
= dev
->chanptr
;
536 return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN
;
538 if (!virt_control_chan_func
) {
539 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
541 if (!virt_control_chan_func(&cmd
)) {
543 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
549 static int resume_device(struct controlvm_message
*msg
)
552 struct bus_info
*bus
;
553 struct device_info
*dev
;
554 struct guest_msgs cmd
;
555 int retval
= CONTROLVM_RESP_SUCCESS
;
557 bus_no
= msg
->cmd
.device_change_state
.bus_no
;
558 dev_no
= msg
->cmd
.device_change_state
.dev_no
;
560 read_lock(&bus_list_lock
);
561 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
562 if (bus
->bus_no
== bus_no
) {
563 /* make sure the device number is valid */
564 if (dev_no
>= bus
->device_count
) {
565 retval
= CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
567 /* make sure this device exists */
568 dev
= bus
->device
[dev_no
];
571 CONTROLVM_RESP_ERROR_ALREADY_DONE
;
579 retval
= CONTROLVM_RESP_ERROR_BUS_INVALID
;
581 read_unlock(&bus_list_lock
);
582 /* the msg is bound for virtpci; send
583 * guest_msgs struct to callback
585 if (retval
== CONTROLVM_RESP_SUCCESS
) {
586 if (uuid_le_cmp(dev
->channel_uuid
,
587 spar_vhba_channel_protocol_uuid
) == 0) {
588 cmd
.msgtype
= GUEST_RESUME_VHBA
;
589 cmd
.resume_vhba
.chanptr
= dev
->chanptr
;
590 } else if (uuid_le_cmp(dev
->channel_uuid
,
591 spar_vnic_channel_protocol_uuid
) == 0) {
592 cmd
.msgtype
= GUEST_RESUME_VNIC
;
593 cmd
.resume_vnic
.chanptr
= dev
->chanptr
;
595 return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN
;
597 if (!virt_control_chan_func
) {
598 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
600 if (!virt_control_chan_func(&cmd
)) {
602 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
608 static int destroy_device(struct controlvm_message
*msg
, char *buf
)
611 struct bus_info
*bus
;
612 struct device_info
*dev
;
613 struct guest_msgs cmd
;
614 int retval
= CONTROLVM_RESP_SUCCESS
;
616 bus_no
= msg
->cmd
.destroy_device
.bus_no
;
617 dev_no
= msg
->cmd
.destroy_device
.bus_no
;
619 read_lock(&bus_list_lock
);
620 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
621 if (bus
->bus_no
== bus_no
) {
622 /* make sure the device number is valid */
623 if (dev_no
>= bus
->device_count
) {
624 retval
= CONTROLVM_RESP_ERROR_DEVICE_INVALID
;
626 /* make sure this device exists */
627 dev
= bus
->device
[dev_no
];
630 CONTROLVM_RESP_ERROR_ALREADY_DONE
;
638 retval
= CONTROLVM_RESP_ERROR_BUS_INVALID
;
639 read_unlock(&bus_list_lock
);
640 if (retval
== CONTROLVM_RESP_SUCCESS
) {
641 /* the msg is bound for virtpci; send
642 * guest_msgs struct to callback
644 if (uuid_le_cmp(dev
->channel_uuid
,
645 spar_vhba_channel_protocol_uuid
) == 0) {
646 cmd
.msgtype
= GUEST_DEL_VHBA
;
647 cmd
.del_vhba
.chanptr
= dev
->chanptr
;
648 } else if (uuid_le_cmp(dev
->channel_uuid
,
649 spar_vnic_channel_protocol_uuid
) == 0) {
650 cmd
.msgtype
= GUEST_DEL_VNIC
;
651 cmd
.del_vnic
.chanptr
= dev
->chanptr
;
654 CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN
;
656 if (!virt_control_chan_func
) {
658 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE
;
660 if (!virt_control_chan_func(&cmd
)) {
662 CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR
;
664 /* you must disable channel interrupts BEFORE you unmap the channel,
665 * because if you unmap first, there may still be some activity going
666 * on which accesses the channel and you will get a "unable to handle
667 * kernel paging request"
670 uislib_disable_channel_interrupts(bus_no
, dev_no
);
672 /* unmap the channel memory for the device. */
673 if (!msg
->hdr
.flags
.test_message
) {
674 uislib_iounmap(dev
->chanptr
);
677 bus
->device
[dev_no
] = NULL
;
683 init_chipset(struct controlvm_message
*msg
, char *buf
)
685 POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
687 max_bus_count
= msg
->cmd
.init_chipset
.bus_count
;
688 platform_no
= msg
->cmd
.init_chipset
.platform_number
;
691 /* We need to make sure we have our functions registered
692 * before processing messages. If we are a test vehicle the
693 * test_message for init_chipset will be set. We can ignore the
694 * waits for the callbacks, since this will be manually entered
695 * from a user. If no test_message is set, we will wait for the
698 if (!msg
->hdr
.flags
.test_message
)
699 WAIT_ON_CALLBACK(virt_control_chan_func
);
702 POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC
, POSTCODE_SEVERITY_INFO
);
704 return CONTROLVM_RESP_SUCCESS
;
707 static int delete_bus_glue(u32 bus_no
)
709 struct controlvm_message msg
;
711 init_msg_header(&msg
, CONTROLVM_BUS_DESTROY
, 0, 0);
712 msg
.cmd
.destroy_bus
.bus_no
= bus_no
;
713 if (destroy_bus(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
)
718 static int delete_device_glue(u32 bus_no
, u32 dev_no
)
720 struct controlvm_message msg
;
722 init_msg_header(&msg
, CONTROLVM_DEVICE_DESTROY
, 0, 0);
723 msg
.cmd
.destroy_device
.bus_no
= bus_no
;
724 msg
.cmd
.destroy_device
.dev_no
= dev_no
;
725 if (destroy_device(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
)
731 uislib_client_inject_add_bus(u32 bus_no
, uuid_le inst_uuid
,
732 u64 channel_addr
, ulong n_channel_bytes
)
734 struct controlvm_message msg
;
736 /* step 0: init the chipset */
737 POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC
, bus_no
, POSTCODE_SEVERITY_INFO
);
739 if (!chipset_inited
) {
740 /* step: initialize the chipset */
741 init_msg_header(&msg
, CONTROLVM_CHIPSET_INIT
, 0, 0);
742 /* this change is needed so that console will come up
743 * OK even when the bus 0 create comes in late. If the
744 * bus 0 create is the first create, then the add_vnic
745 * will work fine, but if the bus 0 create arrives
746 * after number 4, then the add_vnic will fail, and the
747 * ultraboot will fail.
749 msg
.cmd
.init_chipset
.bus_count
= 23;
750 msg
.cmd
.init_chipset
.switch_count
= 0;
751 if (init_chipset(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
)
753 POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC
, bus_no
,
754 POSTCODE_SEVERITY_INFO
);
757 /* step 1: create a bus */
758 POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC
, bus_no
,
759 POSTCODE_SEVERITY_WARNING
);
760 init_msg_header(&msg
, CONTROLVM_BUS_CREATE
, 0, 0);
761 msg
.cmd
.create_bus
.bus_no
= bus_no
;
762 msg
.cmd
.create_bus
.dev_count
= 23; /* devNo+1; */
763 msg
.cmd
.create_bus
.channel_addr
= channel_addr
;
764 msg
.cmd
.create_bus
.channel_bytes
= n_channel_bytes
;
765 if (create_bus(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
) {
766 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC
, bus_no
,
767 POSTCODE_SEVERITY_ERR
);
770 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC
, bus_no
, POSTCODE_SEVERITY_INFO
);
774 EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus
);
777 uislib_client_inject_del_bus(u32 bus_no
)
779 return delete_bus_glue(bus_no
);
781 EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus
);
784 uislib_client_inject_pause_vhba(u32 bus_no
, u32 dev_no
)
786 struct controlvm_message msg
;
789 init_msg_header(&msg
, CONTROLVM_DEVICE_CHANGESTATE
, 0, 0);
790 msg
.cmd
.device_change_state
.bus_no
= bus_no
;
791 msg
.cmd
.device_change_state
.dev_no
= dev_no
;
792 msg
.cmd
.device_change_state
.state
= segment_state_standby
;
793 rc
= pause_device(&msg
);
794 if (rc
!= CONTROLVM_RESP_SUCCESS
)
798 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba
);
801 uislib_client_inject_resume_vhba(u32 bus_no
, u32 dev_no
)
803 struct controlvm_message msg
;
806 init_msg_header(&msg
, CONTROLVM_DEVICE_CHANGESTATE
, 0, 0);
807 msg
.cmd
.device_change_state
.bus_no
= bus_no
;
808 msg
.cmd
.device_change_state
.dev_no
= dev_no
;
809 msg
.cmd
.device_change_state
.state
= segment_state_running
;
810 rc
= resume_device(&msg
);
811 if (rc
!= CONTROLVM_RESP_SUCCESS
)
815 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba
);
818 uislib_client_inject_add_vhba(u32 bus_no
, u32 dev_no
,
819 u64 phys_chan_addr
, u32 chan_bytes
,
820 int is_test_addr
, uuid_le inst_uuid
,
821 struct irq_info
*intr
)
823 struct controlvm_message msg
;
825 /* chipset init'ed with bus bus has been previously created -
826 * Verify it still exists step 2: create the VHBA device on the
829 POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC
, dev_no
, bus_no
,
830 POSTCODE_SEVERITY_INFO
);
832 init_msg_header(&msg
, CONTROLVM_DEVICE_CREATE
, 0, 0);
834 /* signify that the physical channel address does NOT
835 * need to be ioremap()ed
837 msg
.hdr
.flags
.test_message
= 1;
838 msg
.cmd
.create_device
.bus_no
= bus_no
;
839 msg
.cmd
.create_device
.dev_no
= dev_no
;
840 msg
.cmd
.create_device
.dev_inst_uuid
= inst_uuid
;
842 msg
.cmd
.create_device
.intr
= *intr
;
844 memset(&msg
.cmd
.create_device
.intr
, 0,
845 sizeof(struct irq_info
));
846 msg
.cmd
.create_device
.channel_addr
= phys_chan_addr
;
847 if (chan_bytes
< MIN_IO_CHANNEL_SIZE
) {
848 POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC
, chan_bytes
,
849 MIN_IO_CHANNEL_SIZE
, POSTCODE_SEVERITY_ERR
);
852 msg
.cmd
.create_device
.channel_bytes
= chan_bytes
;
853 msg
.cmd
.create_device
.data_type_uuid
= spar_vhba_channel_protocol_uuid
;
854 if (create_device(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
) {
855 POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC
, dev_no
, bus_no
,
856 POSTCODE_SEVERITY_ERR
);
859 POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC
, dev_no
, bus_no
,
860 POSTCODE_SEVERITY_INFO
);
863 EXPORT_SYMBOL_GPL(uislib_client_inject_add_vhba
);
866 uislib_client_inject_del_vhba(u32 bus_no
, u32 dev_no
)
868 return delete_device_glue(bus_no
, dev_no
);
870 EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba
);
873 uislib_client_inject_add_vnic(u32 bus_no
, u32 dev_no
,
874 u64 phys_chan_addr
, u32 chan_bytes
,
875 int is_test_addr
, uuid_le inst_uuid
,
876 struct irq_info
*intr
)
878 struct controlvm_message msg
;
880 /* chipset init'ed with bus bus has been previously created -
881 * Verify it still exists step 2: create the VNIC device on the
884 POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC
, dev_no
, bus_no
,
885 POSTCODE_SEVERITY_INFO
);
887 init_msg_header(&msg
, CONTROLVM_DEVICE_CREATE
, 0, 0);
889 /* signify that the physical channel address does NOT
890 * need to be ioremap()ed
892 msg
.hdr
.flags
.test_message
= 1;
893 msg
.cmd
.create_device
.bus_no
= bus_no
;
894 msg
.cmd
.create_device
.dev_no
= dev_no
;
895 msg
.cmd
.create_device
.dev_inst_uuid
= inst_uuid
;
897 msg
.cmd
.create_device
.intr
= *intr
;
899 memset(&msg
.cmd
.create_device
.intr
, 0,
900 sizeof(struct irq_info
));
901 msg
.cmd
.create_device
.channel_addr
= phys_chan_addr
;
902 if (chan_bytes
< MIN_IO_CHANNEL_SIZE
) {
903 POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC
, chan_bytes
,
904 MIN_IO_CHANNEL_SIZE
, POSTCODE_SEVERITY_ERR
);
907 msg
.cmd
.create_device
.channel_bytes
= chan_bytes
;
908 msg
.cmd
.create_device
.data_type_uuid
= spar_vnic_channel_protocol_uuid
;
909 if (create_device(&msg
, NULL
) != CONTROLVM_RESP_SUCCESS
) {
910 POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC
, dev_no
, bus_no
,
911 POSTCODE_SEVERITY_ERR
);
915 POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC
, dev_no
, bus_no
,
916 POSTCODE_SEVERITY_INFO
);
919 EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic
);
922 uislib_client_inject_pause_vnic(u32 bus_no
, u32 dev_no
)
924 struct controlvm_message msg
;
927 init_msg_header(&msg
, CONTROLVM_DEVICE_CHANGESTATE
, 0, 0);
928 msg
.cmd
.device_change_state
.bus_no
= bus_no
;
929 msg
.cmd
.device_change_state
.dev_no
= dev_no
;
930 msg
.cmd
.device_change_state
.state
= segment_state_standby
;
931 rc
= pause_device(&msg
);
932 if (rc
!= CONTROLVM_RESP_SUCCESS
) {
937 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic
);
940 uislib_client_inject_resume_vnic(u32 bus_no
, u32 dev_no
)
942 struct controlvm_message msg
;
945 init_msg_header(&msg
, CONTROLVM_DEVICE_CHANGESTATE
, 0, 0);
946 msg
.cmd
.device_change_state
.bus_no
= bus_no
;
947 msg
.cmd
.device_change_state
.dev_no
= dev_no
;
948 msg
.cmd
.device_change_state
.state
= segment_state_running
;
949 rc
= resume_device(&msg
);
950 if (rc
!= CONTROLVM_RESP_SUCCESS
)
954 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic
);
957 uislib_client_inject_del_vnic(u32 bus_no
, u32 dev_no
)
959 return delete_device_glue(bus_no
, dev_no
);
961 EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic
);
964 uislib_cache_alloc(struct kmem_cache
*cur_pool
, char *fn
, int ln
)
966 /* __GFP_NORETRY means "ok to fail", meaning kmalloc() can
967 * return NULL. If you do NOT specify __GFP_NORETRY, Linux
968 * will go to extreme measures to get memory for you (like,
969 * invoke oom killer), which will probably cripple the system.
971 void *p
= kmem_cache_alloc(cur_pool
, GFP_ATOMIC
| __GFP_NORETRY
);
977 EXPORT_SYMBOL_GPL(uislib_cache_alloc
);
980 uislib_cache_free(struct kmem_cache
*cur_pool
, void *p
, char *fn
, int ln
)
984 kmem_cache_free(cur_pool
, p
);
986 EXPORT_SYMBOL_GPL(uislib_cache_free
);
988 /*****************************************************/
989 /* proc filesystem callback functions */
990 /*****************************************************/
992 #define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \
993 buff_len, __VA_ARGS__)
996 info_debugfs_read_helper(char **buff
, int *buff_len
)
999 struct bus_info
*bus
;
1001 if (PLINE("\nBuses:\n") < 0)
1004 read_lock(&bus_list_lock
);
1005 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
1006 if (PLINE(" bus=0x%p, busNo=%d, deviceCount=%d\n",
1007 bus
, bus
->bus_no
, bus
->device_count
) < 0)
1008 goto err_done_unlock
;
1010 if (PLINE(" Devices:\n") < 0)
1011 goto err_done_unlock
;
1013 for (i
= 0; i
< bus
->device_count
; i
++) {
1014 if (bus
->device
[i
]) {
1015 if (PLINE(" busNo %d, device[%i]: 0x%p, chanptr=0x%p, swtch=0x%p\n",
1016 bus
->bus_no
, i
, bus
->device
[i
],
1017 bus
->device
[i
]->chanptr
,
1018 bus
->device
[i
]->swtch
) < 0)
1019 goto err_done_unlock
;
1021 if (PLINE(" first_busy_cnt=%llu, moved_to_tail_cnt=%llu, last_on_list_cnt=%llu\n",
1022 bus
->device
[i
]->first_busy_cnt
,
1023 bus
->device
[i
]->moved_to_tail_cnt
,
1024 bus
->device
[i
]->last_on_list_cnt
) < 0)
1025 goto err_done_unlock
;
1029 read_unlock(&bus_list_lock
);
1031 if (PLINE("UisUtils_Registered_Services: %d\n",
1032 atomic_read(&uisutils_registered_services
)) < 0)
1034 if (PLINE("cycles_before_wait %llu wait_cycles:%llu\n",
1035 cycles_before_wait
, wait_cycles
) < 0)
1037 if (PLINE("tot_wakeup_cnt %llu:tot_wait_cnt %llu:tot_schedule_cnt %llu\n",
1038 tot_wakeup_cnt
, tot_wait_cnt
, tot_schedule_cnt
) < 0)
1040 if (PLINE("en_smart_wakeup %d\n", en_smart_wakeup
) < 0)
1042 if (PLINE("tot_moved_to_tail_cnt %llu\n", tot_moved_to_tail_cnt
) < 0)
1048 read_unlock(&bus_list_lock
);
1053 static ssize_t
info_debugfs_read(struct file
*file
, char __user
*buf
,
1054 size_t len
, loff_t
*offset
)
1057 int total_bytes
= 0;
1058 int remaining_bytes
= PROC_READ_BUFFER_SIZE
;
1061 if (debug_buf
== NULL
) {
1062 debug_buf
= vmalloc(PROC_READ_BUFFER_SIZE
);
1064 if (debug_buf
== NULL
)
1070 if ((*offset
== 0) || (!debug_buf_valid
)) {
1071 /* if the read fails, then -1 will be returned */
1072 total_bytes
= info_debugfs_read_helper(&temp
, &remaining_bytes
);
1073 debug_buf_valid
= 1;
1075 total_bytes
= strlen(debug_buf
);
1078 return simple_read_from_buffer(buf
, len
, offset
,
1079 debug_buf
, total_bytes
);
1082 static struct device_info
*find_dev(u32 bus_no
, u32 dev_no
)
1084 struct bus_info
*bus
;
1085 struct device_info
*dev
= NULL
;
1087 read_lock(&bus_list_lock
);
1088 for (bus
= bus_list
; bus
; bus
= bus
->next
) {
1089 if (bus
->bus_no
== bus_no
) {
1090 /* make sure the device number is valid */
1091 if (dev_no
>= bus
->device_count
)
1093 dev
= bus
->device
[dev_no
];
1097 read_unlock(&bus_list_lock
);
1101 /* This thread calls the "interrupt" function for each device that has
1102 * enabled such using uislib_enable_channel_interrupts(). The "interrupt"
1103 * function typically reads and processes the devices's channel input
1104 * queue. This thread repeatedly does this, until the thread is told to stop
1105 * (via uisthread_stop()). Sleeping rules:
1106 * - If we have called the "interrupt" function for all devices, and all of
1107 * them have reported "nothing processed" (returned 0), then we will go to
1108 * sleep for a maximum of POLLJIFFIES_NORMAL jiffies.
1109 * - If anyone calls uislib_force_channel_interrupt(), the above jiffy
1110 * sleep will be interrupted, and we will resume calling the "interrupt"
1111 * function for all devices.
1112 * - The list of devices is dynamically re-ordered in order to
1113 * attempt to preserve fairness. Whenever we spin thru the list of
1114 * devices and call the dev->interrupt() function, if we find
1115 * devices which report that there is still more work to do, the
1116 * the first such device we find is moved to the end of the device
1117 * list. This ensures that extremely busy devices don't starve out
1121 static int process_incoming(void *v
)
1123 unsigned long long cur_cycles
, old_cycles
, idle_cycles
, delta_cycles
;
1124 struct list_head
*new_tail
= NULL
;
1127 UIS_DAEMONIZE("dev_incoming");
1128 for (i
= 0; i
< 16; i
++) {
1129 old_cycles
= get_cycles();
1130 wait_event_timeout(poll_dev_wake_q
,
1131 0, POLLJIFFIES_NORMAL
);
1132 cur_cycles
= get_cycles();
1133 if (wait_cycles
== 0) {
1134 wait_cycles
= (cur_cycles
- old_cycles
);
1136 if (wait_cycles
< (cur_cycles
- old_cycles
))
1137 wait_cycles
= (cur_cycles
- old_cycles
);
1140 cycles_before_wait
= wait_cycles
;
1144 struct list_head
*lelt
, *tmp
;
1145 struct device_info
*dev
= NULL
;
1147 /* poll each channel for input */
1148 down(&poll_dev_lock
);
1150 list_for_each_safe(lelt
, tmp
, &poll_dev_chan
) {
1153 dev
= list_entry(lelt
, struct device_info
,
1154 list_polling_device_channels
);
1155 down(&dev
->interrupt_callback_lock
);
1157 rc
= dev
->interrupt(dev
->interrupt_context
);
1160 up(&dev
->interrupt_callback_lock
);
1162 /* dev->interrupt returned, but there
1163 * is still more work to do.
1164 * Reschedule work to occur as soon as
1167 if (new_tail
== NULL
) {
1168 dev
->first_busy_cnt
++;
1174 dev
->moved_to_tail_cnt
++;
1176 dev
->last_on_list_cnt
++;
1180 if (kthread_should_stop())
1183 if (new_tail
!= NULL
) {
1184 tot_moved_to_tail_cnt
++;
1185 list_move_tail(new_tail
, &poll_dev_chan
);
1188 cur_cycles
= get_cycles();
1189 delta_cycles
= cur_cycles
- old_cycles
;
1190 old_cycles
= cur_cycles
;
1192 /* At this point, we have scanned thru all of the
1193 * channels, and at least one of the following is true:
1194 * - there is no input waiting on any of the channels
1195 * - we have received a signal to stop this thread
1197 if (kthread_should_stop())
1199 if (en_smart_wakeup
== 0xFF) {
1202 /* wait for POLLJIFFIES_NORMAL jiffies, or until
1203 * someone wakes up poll_dev_wake_q,
1204 * whichever comes first only do a wait when we have
1205 * been idle for cycles_before_wait cycles.
1207 if (idle_cycles
> cycles_before_wait
) {
1210 wait_event_timeout(poll_dev_wake_q
,
1212 POLLJIFFIES_NORMAL
);
1217 idle_cycles
= idle_cycles
+ delta_cycles
;
1220 complete_and_exit(&incoming_ti
.has_stopped
, 0);
1224 initialize_incoming_thread(void)
1226 if (incoming_started
)
1228 if (!uisthread_start(&incoming_ti
,
1229 &process_incoming
, NULL
, "dev_incoming")) {
1232 incoming_started
= TRUE
;
1236 /* Add a new device/channel to the list being processed by
1237 * process_incoming().
1238 * <interrupt> - indicates the function to call periodically.
1239 * <interrupt_context> - indicates the data to pass to the <interrupt>
1243 uislib_enable_channel_interrupts(u32 bus_no
, u32 dev_no
,
1244 int (*interrupt
)(void *),
1245 void *interrupt_context
)
1247 struct device_info
*dev
;
1249 dev
= find_dev(bus_no
, dev_no
);
1253 down(&poll_dev_lock
);
1254 initialize_incoming_thread();
1255 dev
->interrupt
= interrupt
;
1256 dev
->interrupt_context
= interrupt_context
;
1257 dev
->polling
= TRUE
;
1258 list_add_tail(&dev
->list_polling_device_channels
,
1262 EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts
);
1264 /* Remove a device/channel from the list being processed by
1265 * process_incoming().
1268 uislib_disable_channel_interrupts(u32 bus_no
, u32 dev_no
)
1270 struct device_info
*dev
;
1272 dev
= find_dev(bus_no
, dev_no
);
1275 down(&poll_dev_lock
);
1276 list_del(&dev
->list_polling_device_channels
);
1277 dev
->polling
= FALSE
;
1278 dev
->interrupt
= NULL
;
1281 EXPORT_SYMBOL_GPL(uislib_disable_channel_interrupts
);
1284 do_wakeup_polling_device_channels(struct work_struct
*dummy
)
1286 if (!poll_dev_start
) {
1288 wake_up(&poll_dev_wake_q
);
1292 static DECLARE_WORK(work_wakeup_polling_device_channels
,
1293 do_wakeup_polling_device_channels
);
1295 /* Call this function when you want to send a hint to process_incoming() that
1296 * your device might have more requests.
1299 uislib_force_channel_interrupt(u32 bus_no
, u32 dev_no
)
1301 if (en_smart_wakeup
== 0)
1305 /* The point of using schedule_work() instead of just doing
1306 * the work inline is to force a slight delay before waking up
1307 * the process_incoming() thread.
1310 schedule_work(&work_wakeup_polling_device_channels
);
1312 EXPORT_SYMBOL_GPL(uislib_force_channel_interrupt
);
1314 /*****************************************************/
1315 /* Module Init & Exit functions */
1316 /*****************************************************/
1319 uislib_mod_init(void)
1321 if (!unisys_spar_platform
)
1324 /* initialize global pointers to NULL */
1328 rwlock_init(&bus_list_lock
);
1329 virt_control_chan_func
= NULL
;
1331 /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and
1332 * then map this physical address to a virtual address. */
1333 POSTCODE_LINUX_2(DRIVER_ENTRY_PC
, POSTCODE_SEVERITY_INFO
);
1335 dir_debugfs
= debugfs_create_dir(DIR_DEBUGFS_ENTRY
, NULL
);
1337 info_debugfs_entry
= debugfs_create_file(
1338 INFO_DEBUGFS_ENTRY_FN
, 0444, dir_debugfs
, NULL
,
1339 &debugfs_info_fops
);
1341 platformnumber_debugfs_read
= debugfs_create_u32(
1342 PLATFORMNUMBER_DEBUGFS_ENTRY_FN
, 0444, dir_debugfs
,
1345 cycles_before_wait_debugfs_read
= debugfs_create_u64(
1346 CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN
, 0666, dir_debugfs
,
1347 &cycles_before_wait
);
1349 smart_wakeup_debugfs_entry
= debugfs_create_bool(
1350 SMART_WAKEUP_DEBUGFS_ENTRY_FN
, 0666, dir_debugfs
,
1354 POSTCODE_LINUX_3(DRIVER_EXIT_PC
, 0, POSTCODE_SEVERITY_INFO
);
1359 uislib_mod_exit(void)
1366 debugfs_remove(info_debugfs_entry
);
1367 debugfs_remove(smart_wakeup_debugfs_entry
);
1368 debugfs_remove(cycles_before_wait_debugfs_read
);
1369 debugfs_remove(platformnumber_debugfs_read
);
1370 debugfs_remove(dir_debugfs
);
1373 module_init(uislib_mod_init
);
1374 module_exit(uislib_mod_exit
);
1376 MODULE_LICENSE("GPL");
1377 MODULE_AUTHOR("Usha Srinivasan");
1378 MODULE_ALIAS("uislib");
1379 /* this is extracted during depmod and kept in modules.dep */