summaryrefslogtreecommitdiffstats
path: root/fs/Kconfig
blob: 011f43365d7b1e536586a8a4243262aa3aa60baf (plain) (blame)
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
#
# File system configuration
#

menu "File systems"

# Use unaligned word dcache accesses
config DCACHE_WORD_ACCESS
       bool

if BLOCK

source "fs/ext2/Kconfig"
source "fs/ext3/Kconfig"
source "fs/ext4/Kconfig"
source "fs/jbd/Kconfig"
source "fs/jbd2/Kconfig"

config FS_MBCACHE
# Meta block cache for Extended Attributes (ext2/ext3/ext4)
	tristate
	default y if EXT2_FS=y && EXT2_FS_XATTR
	default y if EXT3_FS=y && EXT3_FS_XATTR
	default y if EXT4_FS=y
	default m if EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4_FS

source "fs/reiserfs/Kconfig"
source "fs/jfs/Kconfig"

source "fs/xfs/Kconfig"
source "fs/gfs2/Kconfig"
source "fs/ocfs2/Kconfig"
source "fs/btrfs/Kconfig"
source "fs/nilfs2/Kconfig"
source "fs/f2fs/Kconfig"

config FS_DAX
	bool "Direct Access (DAX) support"
	depends on MMU
	depends on !(ARM || MIPS || SPARC)
	help
	  Direct Access (DAX) can be used on memory-backed block devices.
	  If the block device supports DAX and the filesystem supports DAX,
	  then you can avoid using the pagecache to buffer I/Os.  Turning
	  on this option will compile in support for DAX; you will need to
	  mount the filesystem using the -o dax option.

	  If you do not have a block device that is capable of using this,
	  or if unsure, say N.  Saying Y will increase the size of the kernel
	  by about 5kB.

endif # BLOCK

# Posix ACL utility routines
#
# Note: Posix ACLs can be implemented without these helpers.  Never use
# this symbol for ifdefs in core code.
#
config FS_POSIX_ACL
	def_bool n

config EXPORTFS
	tristate

config FILE_LOCKING
	bool "Enable POSIX file locking API" if EXPERT
	default y
	help
	  This option enables standard file locking support, required
          for filesystems like NFS and for the flock() system
          call. Disabling this option saves about 11k.

source "fs/notify/Kconfig"

source "fs/quota/Kconfig"

source "fs/autofs4/Kconfig"
source "fs/fuse/Kconfig"
source "fs/overlayfs/Kconfig"

menu "Caches"

source "fs/fscache/Kconfig"
source "fs/cachefiles/Kconfig"

endmenu

if BLOCK
menu "CD-ROM/DVD Filesystems"

source "fs/isofs/Kconfig"
source "fs/udf/Kconfig"

endmenu
endif # BLOCK

if BLOCK
menu "DOS/FAT/NT Filesystems"

source "fs/fat/Kconfig"
source "fs/ntfs/Kconfig"

endmenu
endif # BLOCK

menu "Pseudo filesystems"

source "fs/proc/Kconfig"
source "fs/kernfs/Kconfig"
source "fs/sysfs/Kconfig"

config TMPFS
	bool "Tmpfs virtual memory file system support (former shm fs)"
	depends on SHMEM
	help
	  Tmpfs is a file system which keeps all files in virtual memory.

	  Everything in tmpfs is temporary in the sense that no files will be
	  created on your hard drive. The files live in memory and swap
	  space. If you unmount a tmpfs instance, everything stored therein is
	  lost.

	  See <file:Documentation/filesystems/tmpfs.txt> for details.

config TMPFS_POSIX_ACL
	bool "Tmpfs POSIX Access Control Lists"
	depends on TMPFS
	select TMPFS_XATTR
	select FS_POSIX_ACL
	help
	  POSIX Access Control Lists (ACLs) support additional access rights
	  for users and groups beyond the standard owner/group/world scheme,
	  and this option selects support for ACLs specifically for tmpfs
	  filesystems.

	  If you've selected TMPFS, it's possible that you'll also need
	  this option as there are a number of Linux distros that require
	  POSIX ACL support under /dev for certain features to work properly.
	  For example, some distros need this feature for ALSA-related /dev
	  files for sound to work properly.  In short, if you're not sure,
	  say Y.

	  To learn more about Access Control Lists, visit the POSIX ACLs for
	  Linux website <http://acl.bestbits.at/>.

config TMPFS_XATTR
	bool "Tmpfs extended attributes"
	depends on TMPFS
	default n
	help
	  Extended attributes are name:value pairs associated with inodes by
	  the kernel or by users (see the attr(5) manual page, or visit
	  <http://acl.bestbits.at/> for details).

	  Currently this enables support for the trusted.* and
	  security.* namespaces.

	  You need this for POSIX ACL support on tmpfs.

	  If unsure, say N.

config HUGETLBFS
	bool "HugeTLB file system support"
	depends on X86 || IA64 || SPARC64 || (S390 && 64BIT) || \
		   SYS_SUPPORTS_HUGETLBFS || BROKEN
	help
	  hugetlbfs is a filesystem backing for HugeTLB pages, based on
	  ramfs. For architectures that support it, say Y here and read
	  <file:Documentation/vm/hugetlbpage.txt> for details.

	  If unsure, say N.

config HUGETLB_PAGE
	def_bool HUGETLBFS

source "fs/configfs/Kconfig"
source "fs/efivarfs/Kconfig"

endmenu

menuconfig MISC_FILESYSTEMS
	bool "Miscellaneous filesystems"
	default y
	---help---
	  Say Y here to get to see options for various miscellaneous
	  filesystems, such as filesystems that came from other
	  operating systems.

	  This option alone does not add any kernel code.

	  If you say N, all options in this submenu will be skipped and
	  disabled; if unsure, say Y here.

if MISC_FILESYSTEMS

source "fs/adfs/Kconfig"
source "fs/affs/Kconfig"
source "fs/ecryptfs/Kconfig"
source "fs/hfs/Kconfig"
source "fs/hfsplus/Kconfig"
source "fs/befs/Kconfig"
source "fs/bfs/Kconfig"
source "fs/efs/Kconfig"
source "fs/jffs2/Kconfig"
# UBIFS File system configuration
source "fs/ubifs/Kconfig"
source "fs/logfs/Kconfig"
source "fs/cramfs/Kconfig"
source "fs/squashfs/Kconfig"
source "fs/freevxfs/Kconfig"
source "fs/minix/Kconfig"
source "fs/omfs/Kconfig"
source "fs/hpfs/Kconfig"
source "fs/qnx4/Kconfig"
source "fs/qnx6/Kconfig"
source "fs/romfs/Kconfig"
source "fs/pstore/Kconfig"
source "fs/sysv/Kconfig"
source "fs/ufs/Kconfig"
source "fs/exofs/Kconfig"

endif # MISC_FILESYSTEMS

source "fs/exofs/Kconfig.ore"

menuconfig NETWORK_FILESYSTEMS
	bool "Network File Systems"
	default y
	depends on NET
	---help---
	  Say Y here to get to see options for network filesystems and
	  filesystem-related networking code, such as NFS daemon and
	  RPCSEC security modules.

	  This option alone does not add any kernel code.

	  If you say N, all options in this submenu will be skipped and
	  disabled; if unsure, say Y here.

if NETWORK_FILESYSTEMS

source "fs/nfs/Kconfig"
source "fs/nfsd/Kconfig"

config GRACE_PERIOD
	tristate

config LOCKD
	tristate
	depends on FILE_LOCKING
	select GRACE_PERIOD

config LOCKD_V4
	bool
	depends on NFSD_V3 || NFS_V3
	depends on FILE_LOCKING
	default y

config NFS_ACL_SUPPORT
	tristate
	select FS_POSIX_ACL

config NFS_COMMON
	bool
	depends on NFSD || NFS_FS || LOCKD
	default y

source "net/sunrpc/Kconfig"
source "fs/ceph/Kconfig"
source "fs/cifs/Kconfig"
source "fs/ncpfs/Kconfig"
source "fs/coda/Kconfig"
source "fs/afs/Kconfig"
source "fs/9p/Kconfig"

endif # NETWORK_FILESYSTEMS

source "fs/nls/Kconfig"
source "fs/dlm/Kconfig"

endmenu
title='author Martin Schwidefsky 2009-08-18 17:09:42 +0200 committer Thomas Gleixner 2009-08-19 12:00:56 +0200 clocksource: Avoid clocksource watchdog circular locking dependency' href='/openslx/kernel-qcow2-linux.git/commit/kernel/time/clocksource.c?id=01548f4d3e8e94caf323a4f664eb347fd34a34ab'>01548f4d3e8e ^
d0981a1b21a0 ^
c55c87c892c1 ^
5d8b34fdcb38 ^
35c35d1afa8f ^
5d8b34fdcb38 ^

35c35d1afa8f ^
5d8b34fdcb38 ^
01548f4d3e8e ^








7285dd7fd375 ^
5d8b34fdcb38 ^
5d8b34fdcb38 ^
c55c87c892c1 ^
54a6bc0b071c ^

5d8b34fdcb38 ^

7285dd7fd375 ^




























5d8b34fdcb38 ^

c55c87c892c1 ^
5d8b34fdcb38 ^

c55c87c892c1 ^
5d8b34fdcb38 ^

fb63a0ebe615 ^

5d8b34fdcb38 ^
8e19608e8b5c ^
155ec60226ae ^

5d8b34fdcb38 ^

c55c87c892c1 ^


01548f4d3e8e ^
54a6bc0b071c ^

c55c87c892c1 ^
01548f4d3e8e ^
c55c87c892c1 ^
8e19608e8b5c ^
b52f52a093bb ^
8cf4e750f845 ^


b52f52a093bb ^



8cf4e750f845 ^
155ec60226ae ^

8cf4e750f845 ^















5d8b34fdcb38 ^


c55c87c892c1 ^








fb63a0ebe615 ^
5d8b34fdcb38 ^

0f8e8ef7c204 ^
fb63a0ebe615 ^



















0f8e8ef7c204 ^







b52f52a093bb ^

0f8e8ef7c204 ^

7b7422a566aa ^












0f8e8ef7c204 ^

b52f52a093bb ^

fb63a0ebe615 ^
5d8b34fdcb38 ^
5d8b34fdcb38 ^



fb63a0ebe615 ^
5d8b34fdcb38 ^
fb63a0ebe615 ^
948ac6d71cf8 ^
fb63a0ebe615 ^
948ac6d71cf8 ^
5d8b34fdcb38 ^
fb63a0ebe615 ^
5d8b34fdcb38 ^
5d8b34fdcb38 ^
5d8b34fdcb38 ^
0f8e8ef7c204 ^
5d8b34fdcb38 ^

fb63a0ebe615 ^

5d8b34fdcb38 ^

fb63a0ebe615 ^



























01548f4d3e8e ^
c55c87c892c1 ^


6ea41d252f35 ^
c55c87c892c1 ^
d0981a1b21a0 ^
c55c87c892c1 ^



6ea41d252f35 ^
c55c87c892c1 ^


6ea41d252f35 ^




d0981a1b21a0 ^
6ea41d252f35 ^
d0981a1b21a0 ^
01548f4d3e8e ^
c55c87c892c1 ^

fb63a0ebe615 ^


5d8b34fdcb38 ^



b52f52a093bb ^
fb63a0ebe615 ^
b52f52a093bb ^
54a6bc0b071c ^
fb63a0ebe615 ^

5d8b34fdcb38 ^
734efb467b31 ^
c54a42b19fba ^











b52f52a093bb ^



2e1975868ac9 ^
b52f52a093bb ^
75c5158f70c0 ^
b52f52a093bb ^
17622339af25 ^
b52f52a093bb ^

b52f52a093bb ^


7c3078b63788 ^


7b7422a566aa ^

7c3078b63788 ^





734efb467b31 ^
98962465ed9e ^







































592913ecb87a ^
734efb467b31 ^
734efb467b31 ^
f1b82746c1e9 ^
734efb467b31 ^
75c5158f70c0 ^
734efb467b31 ^
92c7e00254b2 ^

734efb467b31 ^
f1b82746c1e9 ^
734efb467b31 ^
f1b82746c1e9 ^
5d8b34fdcb38 ^
75c5158f70c0 ^
f1b82746c1e9 ^























75c5158f70c0 ^




f1b82746c1e9 ^
734efb467b31 ^
592913ecb87a ^
54a6bc0b071c ^




75c5158f70c0 ^








ad6759fbf35d ^



75c5158f70c0 ^
54a6bc0b071c ^





e6c733050faa ^
75c5158f70c0 ^
e6c733050faa ^
75c5158f70c0 ^



92c7e00254b2 ^

734efb467b31 ^
f1b82746c1e9 ^
734efb467b31 ^
f1b82746c1e9 ^

92c7e00254b2 ^
f1b82746c1e9 ^
92c7e00254b2 ^
f1b82746c1e9 ^


734efb467b31 ^

d7e81c269db8 ^













852db46d55e8 ^
d7e81c269db8 ^



852db46d55e8 ^
d7e81c269db8 ^

852db46d55e8 ^
d7e81c269db8 ^
852db46d55e8 ^
d7e81c269db8 ^
d7e81c269db8 ^









852db46d55e8 ^


















d7e81c269db8 ^
852db46d55e8 ^
d7e81c269db8 ^









734efb467b31 ^
a275254975a2 ^
734efb467b31 ^



f1b82746c1e9 ^
734efb467b31 ^
98962465ed9e ^


75c5158f70c0 ^
f1b82746c1e9 ^

fb63a0ebe615 ^
75c5158f70c0 ^
f1b82746c1e9 ^
734efb467b31 ^
a275254975a2 ^
734efb467b31 ^
d0981a1b21a0 ^







734efb467b31 ^
92c7e00254b2 ^
734efb467b31 ^
92c7e00254b2 ^
734efb467b31 ^
75c5158f70c0 ^
d0981a1b21a0 ^
75c5158f70c0 ^
734efb467b31 ^
fb63a0ebe615 ^
734efb467b31 ^
4713e22ce81e ^




75c5158f70c0 ^
fb63a0ebe615 ^
4713e22ce81e ^
f1b82746c1e9 ^
75c5158f70c0 ^
4713e22ce81e ^
fb63a0ebe615 ^
4713e22ce81e ^
2b0137001de6 ^
734efb467b31 ^







4a0b2b4dbe13 ^

734efb467b31 ^
5e2cb1018a8a ^
734efb467b31 ^
75c5158f70c0 ^
5e2cb1018a8a ^
75c5158f70c0 ^
734efb467b31 ^
5e2cb1018a8a ^
734efb467b31 ^








b71a8eb0fa64 ^
734efb467b31 ^

4a0b2b4dbe13 ^
734efb467b31 ^


92c7e00254b2 ^
734efb467b31 ^






734efb467b31 ^
75c5158f70c0 ^
734efb467b31 ^
92c7e00254b2 ^

734efb467b31 ^
f1b82746c1e9 ^
734efb467b31 ^
75c5158f70c0 ^
734efb467b31 ^











4a0b2b4dbe13 ^


734efb467b31 ^
2e1975868ac9 ^
5e2cb1018a8a ^
734efb467b31 ^
75c5158f70c0 ^
2e1975868ac9 ^
cd6d95d8449b ^





3f68535adad8 ^
5e2cb1018a8a ^

734efb467b31 ^
75c5158f70c0 ^
734efb467b31 ^
5e2cb1018a8a ^

734efb467b31 ^
5e2cb1018a8a ^
734efb467b31 ^




4f95f81a4862 ^
f5f1a24a2caa ^
734efb467b31 ^
4f95f81a4862 ^
f5f1a24a2caa ^
734efb467b31 ^

af5ca3f4ec5c ^
734efb467b31 ^






ad596171ed63 ^
734efb467b31 ^
















2b0137001de6 ^
734efb467b31 ^









75c5158f70c0 ^
734efb467b31 ^

75c5158f70c0 ^
734efb467b31 ^













5d0cf410e94b ^






734efb467b31 ^



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
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913






















                                                                       





                              
                                                                               
                       
                          
 







                                                    
                                    










































                                                                            
                                    




















                                                                             
                                        
 




















































                                                                                  

                                           
                                       

                                                    

                                                                           


                                               
                                            
                                   
                                       
                              
                            
 
                                  

                                                                


                                        
                                                              

                                      
                            
 
                                                    
                                                                            
 
  
                                      

                                   
                                              
 








                                                                     
                                                          
 
                                                                            
                                           

                                              

 




























                                                                         

                                                    
                               

                                 
                     

                                  

                              
 
                                         

                                                                              

                              


                                                          
                                                        

                                                              
                                 
                 
 
                                     
 


                                                           



                                            
                                                                        

                                                                            















                                                                             


                 








                                                                         
    

                                    
 



















                                                                           







                                                        

                                             

                            












                                                                      

                                                      

 
                                                                
 



                                                   
                                                        
                                                       
                                                    
                
                                       
                                                           
                                                                 
                                             
                                                                 
                                      
                                                   
                                                     

                 

                                                              

                                                      



























                                                                               
                                                   


                                     
                            
 
                                       



                                                                  
                                                          


                                                              




                                                               
                                                   
         
                                         
                 

 


                                                                



                                                         
 
                                                                           
                                                        
                                                                        

                                        
 
   











                                                                



                                                 
                               
 
                                                        
                               
                                       

                                      


   


                                                                      

                                                                    





                                      
   







































                                                                               
                                      
 
   
                                                             
  
                                                             
  

                                                                   
   
                                    
 
                                      
 
                                                               























                                                                             




                                                                              
 
 
                                           




                                               








                                                                



                                                       
                             





                                                                     
                                       
                             
                                         



                                      

                                           
   
                                                       
 

                                                    
 
                                                         
                                                              


                                              

 













                                                                     
                                                                         



                                                                          
                                                                    

                                                       
                                                                              
   
                                                                                
 









                                                                


















                                                                             
 
                                                     









                                                
   
                                                          



                                                        
                                                
 


                                                                    
                                       

                                
                                         
                                         
                 
 
                                    
 







                                                                           
   
                                                                            
   
                                                                  
 
                                       
                                                
                                         
 
                                         
 




                                                           
                                       
                                         
                            
                             
                                         
 
                                      
 
                   







                                                                            

                                                                         
 
                          
 
                                       
                                                                         
                                         
 
                     








                                                                             
                         

                                                                 
                                                                        


                                                                        
 






                                                            
 
                                       
 

                                                  
                                 
                             
 
                                         











                                                                              


                                                                
 
                                
                          
 
                                       
                                                           





                                                                      
                                                      

                                                                              
         
                                         
 

                                                                             
 
                     




                    
                                                                              
                                               
 
                                               
                                                            

                                                   
                              






                                               
                                              
















                                                                 
                         









                                                      
                                       

                                                                   
                                         













                                                                       






                                                             



                                              
/*
 * linux/kernel/time/clocksource.c
 *
 * This file contains the functions which manage clocksource drivers.
 *
 * Copyright (C) 2004, 2005 IBM, John Stultz (johnstul@us.ibm.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * TODO WishList:
 *   o Allow clocksource drivers to be unregistered
 */

#include <linux/clocksource.h>
#include <linux/sysdev.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h> /* for spin_unlock_irq() using preempt_count() m68k */
#include <linux/tick.h>
#include <linux/kthread.h>

void timecounter_init(struct timecounter *tc,
		      const struct cyclecounter *cc,
		      u64 start_tstamp)
{
	tc->cc = cc;
	tc->cycle_last = cc->read(cc);
	tc->nsec = start_tstamp;
}
EXPORT_SYMBOL_GPL(timecounter_init);

/**
 * timecounter_read_delta - get nanoseconds since last call of this function
 * @tc:         Pointer to time counter
 *
 * When the underlying cycle counter runs over, this will be handled
 * correctly as long as it does not run over more than once between
 * calls.
 *
 * The first call to this function for a new time counter initializes
 * the time tracking and returns an undefined result.
 */
static u64 timecounter_read_delta(struct timecounter *tc)
{
	cycle_t cycle_now, cycle_delta;
	u64 ns_offset;

	/* read cycle counter: */
	cycle_now = tc->cc->read(tc->cc);

	/* calculate the delta since the last timecounter_read_delta(): */
	cycle_delta = (cycle_now - tc->cycle_last) & tc->cc->mask;

	/* convert to nanoseconds: */
	ns_offset = cyclecounter_cyc2ns(tc->cc, cycle_delta);

	/* update time stamp of timecounter_read_delta() call: */
	tc->cycle_last = cycle_now;

	return ns_offset;
}

u64 timecounter_read(struct timecounter *tc)
{
	u64 nsec;

	/* increment time by nanoseconds since last call */
	nsec = timecounter_read_delta(tc);
	nsec += tc->nsec;
	tc->nsec = nsec;

	return nsec;
}
EXPORT_SYMBOL_GPL(timecounter_read);

u64 timecounter_cyc2time(struct timecounter *tc,
			 cycle_t cycle_tstamp)
{
	u64 cycle_delta = (cycle_tstamp - tc->cycle_last) & tc->cc->mask;
	u64 nsec;

	/*
	 * Instead of always treating cycle_tstamp as more recent
	 * than tc->cycle_last, detect when it is too far in the
	 * future and treat it as old time stamp instead.
	 */
	if (cycle_delta > tc->cc->mask / 2) {
		cycle_delta = (tc->cycle_last - cycle_tstamp) & tc->cc->mask;
		nsec = tc->nsec - cyclecounter_cyc2ns(tc->cc, cycle_delta);
	} else {
		nsec = cyclecounter_cyc2ns(tc->cc, cycle_delta) + tc->nsec;
	}

	return nsec;
}
EXPORT_SYMBOL_GPL(timecounter_cyc2time);

/**
 * clocks_calc_mult_shift - calculate mult/shift factors for scaled math of clocks
 * @mult:	pointer to mult variable
 * @shift:	pointer to shift variable
 * @from:	frequency to convert from
 * @to:		frequency to convert to
 * @minsec:	guaranteed runtime conversion range in seconds
 *
 * The function evaluates the shift/mult pair for the scaled math
 * operations of clocksources and clockevents.
 *
 * @to and @from are frequency values in HZ. For clock sources @to is
 * NSEC_PER_SEC == 1GHz and @from is the counter frequency. For clock
 * event @to is the counter frequency and @from is NSEC_PER_SEC.
 *
 * The @minsec conversion range argument controls the time frame in
 * seconds which must be covered by the runtime conversion with the
 * calculated mult and shift factors. This guarantees that no 64bit
 * overflow happens when the input value of the conversion is
 * multiplied with the calculated mult factor. Larger ranges may
 * reduce the conversion accuracy by chosing smaller mult and shift
 * factors.
 */
void
clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
{
	u64 tmp;
	u32 sft, sftacc= 32;

	/*
	 * Calculate the shift factor which is limiting the conversion
	 * range:
	 */
	tmp = ((u64)minsec * from) >> 32;
	while (tmp) {
		tmp >>=1;
		sftacc--;
	}

	/*
	 * Find the conversion shift/mult pair which has the best
	 * accuracy and fits the maxsec conversion range:
	 */
	for (sft = 32; sft > 0; sft--) {
		tmp = (u64) to << sft;
		do_div(tmp, from);
		if ((tmp >> sftacc) == 0)
			break;
	}
	*mult = tmp;
	*shift = sft;
}

/*[Clocksource internal variables]---------
 * curr_clocksource:
 *	currently selected clocksource.
 * clocksource_list:
 *	linked list with the registered clocksources
 * clocksource_mutex:
 *	protects manipulations to curr_clocksource and the clocksource_list
 * override_name:
 *	Name of the user-specified clocksource.
 */
static struct clocksource *curr_clocksource;
static LIST_HEAD(clocksource_list);
static DEFINE_MUTEX(clocksource_mutex);
static char override_name[32];
static int finished_booting;

#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
static void clocksource_watchdog_work(struct work_struct *work);

static LIST_HEAD(watchdog_list);
static struct clocksource *watchdog;
static struct timer_list watchdog_timer;
static DECLARE_WORK(watchdog_work, clocksource_watchdog_work);
static DEFINE_SPINLOCK(watchdog_lock);
static cycle_t watchdog_last;
static int watchdog_running;

static int clocksource_watchdog_kthread(void *data);
static void __clocksource_change_rating(struct clocksource *cs, int rating);

/*
 * Interval: 0.5sec Threshold: 0.0625s
 */
#define WATCHDOG_INTERVAL (HZ >> 1)
#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4)

static void clocksource_watchdog_work(struct work_struct *work)
{
	/*
	 * If kthread_run fails the next watchdog scan over the
	 * watchdog_list will find the unstable clock again.
	 */
	kthread_run(clocksource_watchdog_kthread, NULL, "kwatchdog");
}

static void __clocksource_unstable(struct clocksource *cs)
{
	cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
	cs->flags |= CLOCK_SOURCE_UNSTABLE;
	if (finished_booting)
		schedule_work(&watchdog_work);
}

static void clocksource_unstable(struct clocksource *cs, int64_t delta)
{
	printk(KERN_WARNING "Clocksource %s unstable (delta = %Ld ns)\n",
	       cs->name, delta);
	__clocksource_unstable(cs);
}

/**
 * clocksource_mark_unstable - mark clocksource unstable via watchdog
 * @cs:		clocksource to be marked unstable
 *
 * This function is called instead of clocksource_change_rating from
 * cpu hotplug code to avoid a deadlock between the clocksource mutex
 * and the cpu hotplug mutex. It defers the update of the clocksource
 * to the watchdog thread.
 */
void clocksource_mark_unstable(struct clocksource *cs)
{
	unsigned long flags;

	spin_lock_irqsave(&watchdog_lock, flags);
	if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) {
		if (list_empty(&cs->wd_list))
			list_add(&cs->wd_list, &watchdog_list);
		__clocksource_unstable(cs);
	}
	spin_unlock_irqrestore(&watchdog_lock, flags);