aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fault-inject.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-15 14:17:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-15 14:17:52 -0400
commit5a4179460cb50d939a2ae713cf88fcbff75f2c1c (patch)
treef41bfc36bbb14be449aaeecf01df592a5fd553f4 /lib/fault-inject.c
parent5d7cb157025b3b4852f38e6e5e97d06ef12c1d78 (diff)
parent4725fd3ce970c27a1678fb0809bfc7c2f4ac3e4f (diff)
Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6
* 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6: intel_idle: recognize Lincroft Atom Processor intel_idle: no longer EXPERIMENTAL intel_idle: disable module support intel_idle: add support for Westmere-EX intel_idle: delete power_policy modparam, and choose substate functions intel_idle: delete substates DEBUG modparam
Diffstat (limited to 'lib/fault-inject.c')
0 files changed, 0 insertions, 0 deletions
osoft.com> 2011-04-29 16:45:15 -0400 committer Greg Kroah-Hartman <gregkh@suse.de> 2011-05-03 16:31:31 -0400 Staging: hv: VMBUS is a acpi enumerated device; get irq value from bios' href='/cgit/cgit.cgi/litmus-rt-tegra.git/commit/drivers/staging/hv/vmbus_drv.c?id=b0069f43fc6bc9c91f7133922ceb4e08373ff675'>b0069f43fc6
98db4335e97


































3e7ee4902fe
98db4335e97








3e7ee4902fe
98db4335e97





90c9960e205

98db4335e97

e8e27047746
98db4335e97
3e7ee4902fe
98db4335e97
3e7ee4902fe
e8e27047746
3e7ee4902fe
98db4335e97





















































































3e7ee4902fe
454f18a963c
3e7ee4902fe



























3e7ee4902fe
793be9c76e7
adde2487d30











adde2487d30















































b7fc147bd87







e8e27047746
b7fc147bd87

e8e27047746
de632a2b5fe
b7fc147bd87
de632a2b5fe
b7fc147bd87


f1f0d67b6ea







9efd21e1f53
f1f0d67b6ea
9efd21e1f53

b14a7b3014b
0a46618d58c

f1f0d67b6ea
f1f0d67b6ea
0a46618d58c

6de925b1893
f1f0d67b6ea



c5dce3db89d







415b023ab8d
c5dce3db89d



415b023ab8d

c5dce3db89d
0a46618d58c

6de925b1893
c5dce3db89d





eb1bb259cf2






ca6887fb830
eb1bb259cf2







ca6887fb830

eb1bb259cf2



086e7a5685b





e8e27047746
086e7a5685b
e8e27047746
086e7a5685b


454f18a963c
9adcac5c168







3e7ee4902fe

adf874cb355
36199a992ab
36199a992ab
bf6506f60c4














36199a992ab


62c1059d6e2
36199a992ab




bf6506f60c4
36199a992ab





bf6506f60c4

36199a992ab
bf6506f60c4

da9fcb7260a
36199a992ab










e826f1d505d
36199a992ab












36199a992ab

480ae58db52
36199a992ab










98e087022b6
36199a992ab
36199a992ab
36199a992ab



32235b07b52
36199a992ab
36199a992ab



793be9c76e7









59c0e4f0a66
793be9c76e7

66d9229c2a0
793be9c76e7






3e189519557
90c9960e205


0686e4f4a2e
0686e4f4a2e

0686e4f4a2e
90c9960e205
9aaa995e6af
3e7ee4902fe
90c9960e205

3e7ee4902fe
6d26e38fa20

90c9960e205
0a46618d58c
d6c1c5de4e7
3e7ee4902fe

454f18a963c
59c0e4f0a66
66d9229c2a0
3e7ee4902fe
a6e4d8e3fee
9adcac5c168
d6c1c5de4e7

3e7ee4902fe
454f18a963c
3d2de267624
607c1a11d0c
3e7ee4902fe
90c9960e205
0a46618d58c
9aaa995e6af
3e7ee4902fe
9adcac5c168
3e7ee4902fe
d6c1c5de4e7
3e7ee4902fe
3e7ee4902fe
9aaa995e6af
3e7ee4902fe
800b6902fdc





90c9960e205
607c1a11d0c
9adcac5c168
d6c1c5de4e7
5d48a1c2026

800b6902fdc
2d6e882bada
8b5d6d3bd3e
d6c1c5de4e7
3e7ee4902fe

90c9960e205
3e189519557
c643269d672
3e189519557
3e189519557





90c9960e205
c643269d672
3e7ee4902fe
5d48a1c2026
3e7ee4902fe
0a46618d58c
3e7ee4902fe
454f18a963c
9adcac5c168
3e7ee4902fe
c643269d672
3e7ee4902fe
2d6e882bada
3e7ee4902fe
5d48a1c2026
3e7ee4902fe
3e7ee4902fe

90c9960e205
3e189519557
06de23f7882
3e189519557
3e189519557




90c9960e205
06de23f7882
3e7ee4902fe
0a46618d58c
3e7ee4902fe
06de23f7882
3e7ee4902fe
3e7ee4902fe
3e7ee4902fe

3e189519557
3e189519557

90c9960e205
89733aa9cca


3e7ee4902fe
3d3b5518a35
3e7ee4902fe
454f18a963c
6bad88dac0e

0a46618d58c
3e7ee4902fe


cae5b843c82
ca623ad3558

90c9960e205
3e7ee4902fe
3e7ee4902fe
3e7ee4902fe


3e189519557
e13a0b5a4b2
90c9960e205
3ca07cb06d3
3e7ee4902fe
90c9960e205
6bad88dac0e
f4888417083
3e7ee4902fe
1bb40a25b26
6bad88dac0e
90c9960e205
3e7ee4902fe
454f18a963c
9adcac5c168
607c1a11d0c
6bad88dac0e
3e7ee4902fe
90c9960e205



6bad88dac0e
3e7ee4902fe
3e7ee4902fe
0a46618d58c
3e7ee4902fe
0a46618d58c

3e7ee4902fe
3e7ee4902fe


3e189519557


90c9960e205
9d8bd71ad4f
3e7ee4902fe
90c9960e205



6bad88dac0e
3e7ee4902fe
0a46618d58c

3e7ee4902fe

3e7ee4902fe
b0069f43fc6





















607c1a11d0c

b0069f43fc6













9d7b18d1844
b0069f43fc6











9a775dbd4e8




9a775dbd4e8
15f0beb1693
9a775dbd4e8




607c1a11d0c
1168ac22314
71a6655dedc
b0069f43fc6






0246604ce03

b0069f43fc6





2da9e1d6d4a
b0069f43fc6


91fd799eb12



1168ac22314

1168ac22314
90c9960e205
26c14cc1192
13399cbaab4
3e7ee4902fe
607c1a11d0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
  

















                                                                               
                                         
  
   

                                           





                            
                      
                      
                       

                          
                             

                   
                         
 
 
                                        
 
                                     
                                       
 




                                                                
                                     
               


































                                                                             
 








                                                                           
 





                                                               

                                                                        

                                                
                                                            
                                          
 
                                                               
 
                                               
 





















































































                                                                                
 
                                                                         



























                                                                              
 
 











                                                                             















































                                                                  







                                                                              
                                                               

                                   
                                                     
                                                
                          
 


                     







                                                            
                                                                  
 

                                      
                             

                                                                   
 
                

                                                       
                              



                   







                                                    
                                                                  



                                                          

                                               
                        

                                                                
                                      





                 






                                                       
                                                                  







                                                  

                                   



               





                                                                          
                                                               
 
                      


 
                          







                                               

  
                                          
 
 














                                                               


                                                                         
                                                




                                                                 
                                           





                                                             

                                                                
                                         

                                                                    
                                                                            










                                                                    
                         












                                                                  

                             
                             










                                                                  
                                                   
                           
 



                                                                             
                                                                             
                           



                   









                                                       
                                                   

                                                       
                                                     






                                   
  


                                                            
                                             

                                               
                                     
   
                                  
 

                            
 

                                                                   
                       
                                                                            
                           

         
                                        
                                                    
                                                    
 
                                             
                                    

                           
 
                                        
                                                             
                                                  
 
                       
                                                    
                                
 
                                        
 
                           
         
 
                                   
 





                                                       
                  
                                           
                                        
                           

         
 
                               
 
                 

 
   
                                                                  
                                                                
  





                                                                             
   
                                                          
 
                
 
                                                                   
 
                                            
                           
 
                                   
 
                               
 
                   
 

                                           
   
                                                                      
                                                                   
  




                                                                            
   
                                                             
 
                                                                     
 
                               
 
 

                                             
  

                                                                       
   


                                                                          
 
                                           
 
                                           

                                                                         
                                                                              


                            
                                            

                                                                          
                                       
 
 


                                
  
                                                          
   
                                                                   
 
                    
 
                                                    
 
                                                                          
                                                             
                                                     
 
                                                
                                                                      
                                                            
                                                                
 



                                                                               
                                                         
 
                
                                                            
            

                                                             
 


                   


                                                                    
   
                                                                
 



                                                                              
                                               
 

                                                 

 
 





















                                                                             

                             













                                                              
                     











                                                 




                                                                              
   
                                                              




                                                                       
                                    
 
                






                                      

                                                           





                                          
                                                               


                               



                                                               

 
 
                      
                               
                                                   
 
                          
/*
 * Copyright (c) 2009, Microsoft Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 * Authors:
 *   Haiyang Zhang <haiyangz@microsoft.com>
 *   Hank Janssen  <hjanssen@microsoft.com>
 *   K. Y. Srinivasan <kys@microsoft.com>
 *
 */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/sysctl.h>
#include <linux/pci.h>
#include <linux/dmi.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <acpi/acpi_bus.h>
#include <linux/completion.h>

#include "hyperv.h"
#include "hyperv_vmbus.h"


static struct acpi_device  *hv_acpi_dev;

static struct tasklet_struct msg_dpc;
static struct tasklet_struct event_dpc;

unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
EXPORT_SYMBOL(vmbus_loglevel);
	/* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
	/* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */

static struct completion probe_event;
static int irq;

static void get_channel_info(struct hv_device *device,
			     struct hv_device_info *info)
{
	struct vmbus_channel_debug_info debug_info;

	if (!device->channel)
		return;

	vmbus_get_debug_info(device->channel, &debug_info);

	info->chn_id = debug_info.relid;
	info->chn_state = debug_info.state;
	memcpy(&info->chn_type, &debug_info.interfacetype,
	       sizeof(struct hv_guid));
	memcpy(&info->chn_instance, &debug_info.interface_instance,
	       sizeof(struct hv_guid));

	info->monitor_id = debug_info.monitorid;

	info->server_monitor_pending = debug_info.servermonitor_pending;
	info->server_monitor_latency = debug_info.servermonitor_latency;
	info->server_monitor_conn_id = debug_info.servermonitor_connectionid;

	info->client_monitor_pending = debug_info.clientmonitor_pending;
	info->client_monitor_latency = debug_info.clientmonitor_latency;
	info->client_monitor_conn_id = debug_info.clientmonitor_connectionid;

	info->inbound.int_mask = debug_info.inbound.current_interrupt_mask;
	info->inbound.read_idx = debug_info.inbound.current_read_index;
	info->inbound.write_idx = debug_info.inbound.current_write_index;
	info->inbound.bytes_avail_toread =
		debug_info.inbound.bytes_avail_toread;
	info->inbound.bytes_avail_towrite =
		debug_info.inbound.bytes_avail_towrite;

	info->outbound.int_mask =
		debug_info.outbound.current_interrupt_mask;
	info->outbound.read_idx = debug_info.outbound.current_read_index;
	info->outbound.write_idx = debug_info.outbound.current_write_index;
	info->outbound.bytes_avail_toread =
		debug_info.outbound.bytes_avail_toread;
	info->outbound.bytes_avail_towrite =
		debug_info.outbound.bytes_avail_towrite;
}

/*
 * vmbus_show_device_attr - Show the device attribute in sysfs.
 *
 * This is invoked when user does a
 * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
 */
static ssize_t vmbus_show_device_attr(struct device *dev,
				      struct device_attribute *dev_attr,
				      char *buf)
{
	struct hv_device *hv_dev = device_to_hv_device(dev);
	struct hv_device_info device_info;

	memset(&device_info, 0, sizeof(struct hv_device_info));

	get_channel_info(hv_dev, &device_info);

	if (!strcmp(dev_attr->attr.name, "class_id")) {
		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
			       device_info.chn_type.data[3],
			       device_info.chn_type.data[2],
			       device_info.chn_type.data[1],
			       device_info.chn_type.data[0],
			       device_info.chn_type.data[5],
			       device_info.chn_type.data[4],
			       device_info.chn_type.data[7],
			       device_info.chn_type.data[6],
			       device_info.chn_type.data[8],
			       device_info.chn_type.data[9],
			       device_info.chn_type.data[10],
			       device_info.chn_type.data[11],
			       device_info.chn_type.data[12],
			       device_info.chn_type.data[13],
			       device_info.chn_type.data[14],
			       device_info.chn_type.data[15]);
	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
			       device_info.chn_instance.data[3],
			       device_info.chn_instance.data[2],
			       device_info.chn_instance.data[1],
			       device_info.chn_instance.data[0],
			       device_info.chn_instance.data[5],
			       device_info.chn_instance.data[4],
			       device_info.chn_instance.data[7],
			       device_info.chn_instance.data[6],
			       device_info.chn_instance.data[8],
			       device_info.chn_instance.data[9],
			       device_info.chn_instance.data[10],
			       device_info.chn_instance.data[11],
			       device_info.chn_instance.data[12],
			       device_info.chn_instance.data[13],
			       device_info.chn_instance.data[14],
			       device_info.chn_instance.data[15]);
	} else if (!strcmp(dev_attr->attr.name, "state")) {
		return sprintf(buf, "%d\n", device_info.chn_state);
	} else if (!strcmp(dev_attr->attr.name, "id")) {
		return sprintf(buf, "%d\n", device_info.chn_id);
	} else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
		return sprintf(buf, "%d\n", device_info.outbound.int_mask);
	} else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
		return sprintf(buf, "%d\n", device_info.outbound.read_idx);
	} else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
		return sprintf(buf, "%d\n", device_info.outbound.write_idx);
	} else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
		return sprintf(buf, "%d\n",
			       device_info.outbound.bytes_avail_toread);
	} else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
		return sprintf(buf, "%d\n",
			       device_info.outbound.bytes_avail_towrite);
	} else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
		return sprintf(buf, "%d\n", device_info.inbound.int_mask);
	} else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
		return sprintf(buf, "%d\n", device_info.inbound.read_idx);
	} else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
		return sprintf(buf, "%d\n", device_info.inbound.write_idx);
	} else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
		return sprintf(buf, "%d\n",
			       device_info.inbound.bytes_avail_toread);
	} else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
		return sprintf(buf, "%d\n",
			       device_info.inbound.bytes_avail_towrite);
	} else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
		return sprintf(buf, "%d\n", device_info.monitor_id);
	} else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
		return sprintf(buf, "%d\n", device_info.server_monitor_pending);
	} else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
		return sprintf(buf, "%d\n", device_info.server_monitor_latency);
	} else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
		return sprintf(buf, "%d\n",
			       device_info.server_monitor_conn_id);
	} else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
		return sprintf(buf, "%d\n", device_info.client_monitor_pending);
	} else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
		return sprintf(buf, "%d\n", device_info.client_monitor_latency);
	} else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
		return sprintf(buf, "%d\n",
			       device_info.client_monitor_conn_id);
	} else {
		return 0;
	}
}

/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
static struct device_attribute vmbus_device_attrs[] = {
	__ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),

	__ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),

	__ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),

	__ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),

	__ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
	__ATTR_NULL
};


/*
 * vmbus_uevent - add uevent for our device
 *
 * This routine is invoked when a device is added or removed on the vmbus to
 * generate a uevent to udev in the userspace. The udev will then look at its
 * rule and the uevent generated here to load the appropriate driver
 */
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
{
	struct hv_device *dev = device_to_hv_device(device);
	int ret;

	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
			     dev->dev_type.data[3],
			     dev->dev_type.data[2],
			     dev->dev_type.data[1],
			     dev->dev_type.data[0],
			     dev->dev_type.data[5],
			     dev->dev_type.data[4],
			     dev->dev_type.data[7],
			     dev->dev_type.data[6],
			     dev->dev_type.data[8],
			     dev->dev_type.data[9],
			     dev->dev_type.data[10],
			     dev->dev_type.data[11],
			     dev->dev_type.data[12],
			     dev->dev_type.data[13],
			     dev->dev_type.data[14],
			     dev->dev_type.data[15]);

	if (ret)
		return ret;

	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
			     dev->dev_instance.data[3],
			     dev->dev_instance.data[2],
			     dev->dev_instance.data[1],
			     dev->dev_instance.data[0],
			     dev->dev_instance.data[5],
			     dev->dev_instance.data[4],
			     dev->dev_instance.data[7],
			     dev->dev_instance.data[6],
			     dev->dev_instance.data[8],
			     dev->dev_instance.data[9],
			     dev->dev_instance.data[10],
			     dev->dev_instance.data[11],
			     dev->dev_instance.data[12],
			     dev->dev_instance.data[13],
			     dev->dev_instance.data[14],
			     dev->dev_instance.data[15]);
	if (ret)
		return ret;

	return 0;
}


/*
 * vmbus_match - Attempt to match the specified device to the specified driver
 */
static int vmbus_match(struct device *device, struct device_driver *driver)
{
	int match = 0;
	struct hv_driver *drv = drv_to_hv_drv(driver);
	struct hv_device *hv_dev = device_to_hv_device(device);

	/* We found our driver ? */
	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
		   sizeof(struct hv_guid)) == 0)
		match = 1;

	return match;
}

/*
 * vmbus_probe - Add the new vmbus's child device
 */
static int vmbus_probe(struct device *child_device)
{
	int ret = 0;
	struct hv_driver *drv =
			drv_to_hv_drv(child_device->driver);
	struct hv_device *dev = device_to_hv_device(child_device);

	if (drv->probe) {
		ret = drv->probe(dev);
		if (ret != 0)
			pr_err("probe failed for device %s (%d)\n",
			       dev_name(child_device), ret);

	} else {
		pr_err("probe not set for driver %s\n",
		       dev_name(child_device));
		ret = -ENODEV;
	}
	return ret;
}

/*
 * vmbus_remove - Remove a vmbus device
 */
static int vmbus_remove(struct device *child_device)
{
	int ret;
	struct hv_driver *drv;

	struct hv_device *dev = device_to_hv_device(child_device);

	if (child_device->driver) {
		drv = drv_to_hv_drv(child_device->driver);

		if (drv->remove) {
			ret = drv->remove(dev);
		} else {
			pr_err("remove not set for driver %s\n",
				dev_name(child_device));
			ret = -ENODEV;
		}
	}

	return 0;
}


/*
 * vmbus_shutdown - Shutdown a vmbus device
 */
static void vmbus_shutdown(struct device *child_device)
{
	struct hv_driver *drv;
	struct hv_device *dev = device_to_hv_device(child_device);


	/* The device may not be attached yet */
	if (!child_device->driver)
		return;

	drv = drv_to_hv_drv(child_device->driver);

	if (drv->shutdown)
		drv->shutdown(dev);

	return;
}


/*
 * vmbus_device_release - Final callback release of the vmbus child device
 */
static void vmbus_device_release(struct device *device)
{
	struct hv_device *hv_dev = device_to_hv_device(device);

	kfree(hv_dev);

}

/* The one and only one */
static struct bus_type  hv_bus = {
	.name =		"vmbus",
	.match =		vmbus_match,
	.shutdown =		vmbus_shutdown,
	.remove =		vmbus_remove,
	.probe =		vmbus_probe,
	.uevent =		vmbus_uevent,
	.dev_attrs =	vmbus_device_attrs,
};

static const char *driver_name = "hyperv";


struct onmessage_work_context {
	struct work_struct work;
	struct hv_message msg;
};

static void vmbus_onmessage_work(struct work_struct *work)
{
	struct onmessage_work_context *ctx;

	ctx = container_of(work, struct onmessage_work_context,
			   work);
	vmbus_onmessage(&ctx->msg);
	kfree(ctx);
}

/*
 * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
 */
static void vmbus_on_msg_dpc(unsigned long data)
{
	int cpu = smp_processor_id();
	void *page_addr = hv_context.synic_message_page[cpu];
	struct hv_message *msg = (struct hv_message *)page_addr +
				  VMBUS_MESSAGE_SINT;
	struct onmessage_work_context *ctx;