Searched refs:ns (Results 1 - 200 of 760) sorted by relevance

1234

/linux-4.1.27/ipc/
H A Dnamespace.c22 struct ipc_namespace *ns; create_ipc_ns() local
25 ns = kmalloc(sizeof(struct ipc_namespace), GFP_KERNEL); create_ipc_ns()
26 if (ns == NULL) create_ipc_ns()
29 err = ns_alloc_inum(&ns->ns); create_ipc_ns()
31 kfree(ns); create_ipc_ns()
34 ns->ns.ops = &ipcns_operations; create_ipc_ns()
36 atomic_set(&ns->count, 1); create_ipc_ns()
37 err = mq_init_ns(ns); create_ipc_ns()
39 ns_free_inum(&ns->ns); create_ipc_ns()
40 kfree(ns); create_ipc_ns()
45 sem_init_ns(ns); create_ipc_ns()
46 msg_init_ns(ns); create_ipc_ns()
47 shm_init_ns(ns); create_ipc_ns()
49 ns->user_ns = get_user_ns(user_ns); create_ipc_ns()
51 return ns; create_ipc_ns()
55 struct user_namespace *user_ns, struct ipc_namespace *ns) copy_ipcs()
58 return get_ipc_ns(ns); copy_ipcs()
59 return create_ipc_ns(user_ns, ns); copy_ipcs()
64 * @ns: the namespace to remove the ipcs from
70 void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, free_ipcs() argument
87 free(ns, perm); free_ipcs()
93 static void free_ipc_ns(struct ipc_namespace *ns) free_ipc_ns() argument
95 sem_exit_ns(ns); free_ipc_ns()
96 msg_exit_ns(ns); free_ipc_ns()
97 shm_exit_ns(ns); free_ipc_ns()
100 put_user_ns(ns->user_ns); free_ipc_ns()
101 ns_free_inum(&ns->ns); free_ipc_ns()
102 kfree(ns); free_ipc_ns()
107 * @ns: the namespace to put
121 void put_ipc_ns(struct ipc_namespace *ns) put_ipc_ns() argument
123 if (atomic_dec_and_lock(&ns->count, &mq_lock)) { put_ipc_ns()
124 mq_clear_sbinfo(ns); put_ipc_ns()
126 mq_put_mnt(ns); put_ipc_ns()
127 free_ipc_ns(ns); put_ipc_ns()
131 static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) to_ipc_ns() argument
133 return container_of(ns, struct ipc_namespace, ns); to_ipc_ns()
138 struct ipc_namespace *ns = NULL; ipcns_get() local
144 ns = get_ipc_ns(nsproxy->ipc_ns); ipcns_get()
147 return ns ? &ns->ns : NULL; ipcns_get()
150 static void ipcns_put(struct ns_common *ns) ipcns_put() argument
152 return put_ipc_ns(to_ipc_ns(ns)); ipcns_put()
157 struct ipc_namespace *ns = to_ipc_ns(new); ipcns_install() local
158 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || ipcns_install()
165 nsproxy->ipc_ns = get_ipc_ns(ns); ipcns_install()
54 copy_ipcs(unsigned long flags, struct user_namespace *user_ns, struct ipc_namespace *ns) copy_ipcs() argument
H A Dshm.c52 struct ipc_namespace *ns; member in struct:shm_file_data
62 #define shm_ids(ns) ((ns)->ids[IPC_SHM_IDS])
70 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
75 void shm_init_ns(struct ipc_namespace *ns) shm_init_ns() argument
77 ns->shm_ctlmax = SHMMAX; shm_init_ns()
78 ns->shm_ctlall = SHMALL; shm_init_ns()
79 ns->shm_ctlmni = SHMMNI; shm_init_ns()
80 ns->shm_rmid_forced = 0; shm_init_ns()
81 ns->shm_tot = 0; shm_init_ns()
82 ipc_init_ids(&shm_ids(ns)); shm_init_ns()
89 static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) do_shm_rmid() argument
100 shm_destroy(ns, shp); do_shm_rmid()
104 void shm_exit_ns(struct ipc_namespace *ns) shm_exit_ns() argument
106 free_ipcs(ns, &shm_ids(ns), do_shm_rmid); shm_exit_ns()
107 idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr); shm_exit_ns()
130 static inline struct shmid_kernel *shm_obtain_object(struct ipc_namespace *ns, int id) shm_obtain_object() argument
132 struct kern_ipc_perm *ipcp = ipc_obtain_object(&shm_ids(ns), id); shm_obtain_object()
140 static inline struct shmid_kernel *shm_obtain_object_check(struct ipc_namespace *ns, int id) shm_obtain_object_check() argument
142 struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&shm_ids(ns), id); shm_obtain_object_check()
154 static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) shm_lock() argument
156 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); shm_lock()
183 static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) shm_rmid() argument
186 ipc_rmid(&shm_ids(ns), &s->shm_perm); shm_rmid()
196 shp = shm_lock(sfd->ns, sfd->id); __shm_open()
222 * @ns: namespace
228 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) shm_destroy() argument
234 ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT; shm_destroy()
235 shm_rmid(ns, shp); shm_destroy()
256 static bool shm_may_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) shm_may_destroy() argument
259 (ns->shm_rmid_forced || shm_may_destroy()
274 struct ipc_namespace *ns = sfd->ns; shm_close() local
276 down_write(&shm_ids(ns).rwsem); shm_close()
278 shp = shm_lock(ns, sfd->id); shm_close()
290 if (shm_may_destroy(ns, shp)) shm_close()
291 shm_destroy(ns, shp); shm_close()
295 up_write(&shm_ids(ns).rwsem); shm_close()
298 /* Called with ns->shm_ids(ns).rwsem locked */ shm_try_destroy_orphaned()
301 struct ipc_namespace *ns = data; shm_try_destroy_orphaned() local
314 if (shm_may_destroy(ns, shp)) { shm_try_destroy_orphaned()
316 shm_destroy(ns, shp); shm_try_destroy_orphaned()
321 void shm_destroy_orphaned(struct ipc_namespace *ns) shm_destroy_orphaned() argument
323 down_write(&shm_ids(ns).rwsem); shm_destroy_orphaned()
324 if (shm_ids(ns).in_use) shm_destroy_orphaned()
325 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns); shm_destroy_orphaned()
326 up_write(&shm_ids(ns).rwsem); shm_destroy_orphaned()
332 struct ipc_namespace *ns = task->nsproxy->ipc_ns; exit_shm() local
343 if (!ns->shm_rmid_forced) { exit_shm()
344 down_read(&shm_ids(ns).rwsem); exit_shm()
352 up_read(&shm_ids(ns).rwsem); exit_shm()
361 down_write(&shm_ids(ns).rwsem); exit_shm()
365 if (shm_may_destroy(ns, shp)) { exit_shm()
367 shm_destroy(ns, shp); exit_shm()
373 up_write(&shm_ids(ns).rwsem); exit_shm()
441 put_ipc_ns(sfd->ns); shm_release()
512 * @ns: namespace
517 static int newseg(struct ipc_namespace *ns, struct ipc_params *params) newseg() argument
530 if (size < SHMMIN || size > ns->shm_ctlmax) newseg()
536 if (ns->shm_tot + numpages < ns->shm_tot || newseg()
537 ns->shm_tot + numpages > ns->shm_ctlall) newseg()
596 id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); newseg()
610 ns->shm_tot += numpages; newseg()
654 struct ipc_namespace *ns; SYSCALL_DEFINE3() local
662 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE3()
668 return ipcget(ns, &shm_ids(ns), &shm_ops, &shm_params); SYSCALL_DEFINE3()
780 static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss, shm_get_stat() argument
789 in_use = shm_ids(ns).in_use; shm_get_stat()
795 ipc = idr_find(&shm_ids(ns).ipcs_idr, next_id); shm_get_stat()
811 static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, shmctl_down() argument
824 down_write(&shm_ids(ns).rwsem); shmctl_down()
827 ipcp = ipcctl_pre_down_nolock(ns, &shm_ids(ns), shmid, cmd, shmctl_down()
844 do_shm_rmid(ns, ipcp); shmctl_down()
863 up_write(&shm_ids(ns).rwsem); shmctl_down()
867 static int shmctl_nolock(struct ipc_namespace *ns, int shmid, shmctl_nolock() argument
886 shminfo.shmmni = shminfo.shmseg = ns->shm_ctlmni; shmctl_nolock()
887 shminfo.shmmax = ns->shm_ctlmax; shmctl_nolock()
888 shminfo.shmall = ns->shm_ctlall; shmctl_nolock()
894 down_read(&shm_ids(ns).rwsem); shmctl_nolock()
895 err = ipc_get_maxid(&shm_ids(ns)); shmctl_nolock()
896 up_read(&shm_ids(ns).rwsem); shmctl_nolock()
907 down_read(&shm_ids(ns).rwsem); shmctl_nolock()
908 shm_info.used_ids = shm_ids(ns).in_use; shmctl_nolock()
909 shm_get_stat(ns, &shm_info.shm_rss, &shm_info.shm_swp); shmctl_nolock()
910 shm_info.shm_tot = ns->shm_tot; shmctl_nolock()
913 err = ipc_get_maxid(&shm_ids(ns)); shmctl_nolock()
914 up_read(&shm_ids(ns).rwsem); shmctl_nolock()
931 shp = shm_obtain_object(ns, shmid); shmctl_nolock()
938 shp = shm_obtain_object_check(ns, shmid); shmctl_nolock()
947 if (ipcperms(ns, &shp->shm_perm, S_IRUGO)) shmctl_nolock()
985 struct ipc_namespace *ns; SYSCALL_DEFINE3() local
991 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE3()
998 return shmctl_nolock(ns, shmid, cmd, version, buf); SYSCALL_DEFINE3()
1001 return shmctl_down(ns, shmid, cmd, buf, version); SYSCALL_DEFINE3()
1008 shp = shm_obtain_object_check(ns, shmid); SYSCALL_DEFINE3()
1027 if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) { SYSCALL_DEFINE3()
1097 struct ipc_namespace *ns; do_shmat() local
1142 ns = current->nsproxy->ipc_ns; do_shmat()
1144 shp = shm_obtain_object_check(ns, shmid); do_shmat()
1151 if (ipcperms(ns, &shp->shm_perm, acc_mode)) do_shmat()
1195 sfd->ns = get_ipc_ns(ns); do_shmat()
1227 down_write(&shm_ids(ns).rwsem); do_shmat()
1228 shp = shm_lock(ns, shmid); do_shmat()
1230 if (shm_may_destroy(ns, shp)) do_shmat()
1231 shm_destroy(ns, shp); do_shmat()
1234 up_write(&shm_ids(ns).rwsem); do_shmat()
H A Dutil.h25 extern void mq_clear_sbinfo(struct ipc_namespace *ns);
26 extern void mq_put_mnt(struct ipc_namespace *ns);
28 static inline void mq_clear_sbinfo(struct ipc_namespace *ns) { } mq_put_mnt() argument
29 static inline void mq_put_mnt(struct ipc_namespace *ns) { } mq_put_mnt() argument
33 void sem_init_ns(struct ipc_namespace *ns); mq_put_mnt()
34 void msg_init_ns(struct ipc_namespace *ns); mq_put_mnt()
35 void shm_init_ns(struct ipc_namespace *ns); mq_put_mnt()
37 void sem_exit_ns(struct ipc_namespace *ns); mq_put_mnt()
38 void msg_exit_ns(struct ipc_namespace *ns); mq_put_mnt()
39 void shm_exit_ns(struct ipc_namespace *ns); mq_put_mnt()
41 static inline void sem_init_ns(struct ipc_namespace *ns) { } msg_init_ns() argument
42 static inline void msg_init_ns(struct ipc_namespace *ns) { } shm_init_ns() argument
43 static inline void shm_init_ns(struct ipc_namespace *ns) { } shm_init_ns() argument
45 static inline void sem_exit_ns(struct ipc_namespace *ns) { } msg_exit_ns() argument
46 static inline void msg_exit_ns(struct ipc_namespace *ns) { } shm_exit_ns() argument
47 static inline void shm_exit_ns(struct ipc_namespace *ns) { } shm_exit_ns() argument
115 int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg);
140 struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns,
203 int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
205 void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
H A Dmsg.c75 #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS])
77 static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) msq_obtain_object() argument
79 struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id); msq_obtain_object()
87 static inline struct msg_queue *msq_obtain_object_check(struct ipc_namespace *ns, msq_obtain_object_check() argument
90 struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&msg_ids(ns), id); msq_obtain_object_check()
98 static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) msg_rmid() argument
100 ipc_rmid(&msg_ids(ns), &s->q_perm); msg_rmid()
114 * @ns: namespace
119 static int newque(struct ipc_namespace *ns, struct ipc_params *params) newque() argument
143 msq->q_qbytes = ns->msg_ctlmnb; newque()
150 id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); newque()
212 static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) freeque() argument
219 msg_rmid(ns, msq); freeque()
224 atomic_dec(&ns->msg_hdrs); freeque()
227 atomic_sub(msq->q_cbytes, &ns->msg_bytes); freeque()
243 struct ipc_namespace *ns; SYSCALL_DEFINE2() local
250 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE2()
255 return ipcget(ns, &msg_ids(ns), &msg_ops, &msg_params); SYSCALL_DEFINE2()
339 static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, msgctl_down() argument
352 down_write(&msg_ids(ns).rwsem); msgctl_down()
355 ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd, msgctl_down()
372 freeque(ns, ipcp); msgctl_down()
375 if (msqid64.msg_qbytes > ns->msg_ctlmnb && msgctl_down()
408 up_write(&msg_ids(ns).rwsem); msgctl_down()
412 static int msgctl_nolock(struct ipc_namespace *ns, int msqid, msgctl_nolock() argument
438 msginfo.msgmni = ns->msg_ctlmni; msgctl_nolock()
439 msginfo.msgmax = ns->msg_ctlmax; msgctl_nolock()
440 msginfo.msgmnb = ns->msg_ctlmnb; msgctl_nolock()
443 down_read(&msg_ids(ns).rwsem); msgctl_nolock()
445 msginfo.msgpool = msg_ids(ns).in_use; msgctl_nolock()
446 msginfo.msgmap = atomic_read(&ns->msg_hdrs); msgctl_nolock()
447 msginfo.msgtql = atomic_read(&ns->msg_bytes); msgctl_nolock()
453 max_id = ipc_get_maxid(&msg_ids(ns)); msgctl_nolock()
454 up_read(&msg_ids(ns).rwsem); msgctl_nolock()
473 msq = msq_obtain_object(ns, msqid); msgctl_nolock()
480 msq = msq_obtain_object_check(ns, msqid); msgctl_nolock()
489 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) msgctl_nolock()
525 struct ipc_namespace *ns; SYSCALL_DEFINE3() local
531 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE3()
538 return msgctl_nolock(ns, msqid, cmd, version, buf); SYSCALL_DEFINE3()
541 return msgctl_down(ns, msqid, cmd, buf, version); SYSCALL_DEFINE3()
613 struct ipc_namespace *ns; do_msgsnd() local
615 ns = current->nsproxy->ipc_ns; do_msgsnd()
617 if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0) do_msgsnd()
630 msq = msq_obtain_object_check(ns, msqid); do_msgsnd()
642 if (ipcperms(ns, &msq->q_perm, S_IWUGO)) do_msgsnd()
704 atomic_add(msgsz, &ns->msg_bytes); do_msgsnd()
705 atomic_inc(&ns->msg_hdrs); do_msgsnd()
828 struct ipc_namespace *ns; do_msgrcv() local
831 ns = current->nsproxy->ipc_ns; do_msgrcv()
839 copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax)); do_msgrcv()
846 msq = msq_obtain_object_check(ns, msqid); do_msgrcv()
857 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) do_msgrcv()
892 atomic_sub(msg->m_ts, &ns->msg_bytes); do_msgrcv()
893 atomic_dec(&ns->msg_hdrs); do_msgrcv()
993 void msg_init_ns(struct ipc_namespace *ns) msg_init_ns() argument
995 ns->msg_ctlmax = MSGMAX; msg_init_ns()
996 ns->msg_ctlmnb = MSGMNB; msg_init_ns()
997 ns->msg_ctlmni = MSGMNI; msg_init_ns()
999 atomic_set(&ns->msg_bytes, 0); msg_init_ns()
1000 atomic_set(&ns->msg_hdrs, 0); msg_init_ns()
1001 ipc_init_ids(&ns->ids[IPC_MSG_IDS]); msg_init_ns()
1005 void msg_exit_ns(struct ipc_namespace *ns) msg_exit_ns() argument
1007 free_ipcs(ns, &msg_ids(ns), freeque); msg_exit_ns()
1008 idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); msg_exit_ns()
H A Dsem.c143 #define sem_ids(ns) ((ns)->ids[IPC_SEM_IDS])
173 void sem_init_ns(struct ipc_namespace *ns) sem_init_ns() argument
175 ns->sc_semmsl = SEMMSL; sem_init_ns()
176 ns->sc_semmns = SEMMNS; sem_init_ns()
177 ns->sc_semopm = SEMOPM; sem_init_ns()
178 ns->sc_semmni = SEMMNI; sem_init_ns()
179 ns->used_sems = 0; sem_init_ns()
180 ipc_init_ids(&ns->ids[IPC_SEM_IDS]); sem_init_ns()
184 void sem_exit_ns(struct ipc_namespace *ns) sem_exit_ns() argument
186 free_ipcs(ns, &sem_ids(ns), freeary); sem_exit_ns()
187 idr_destroy(&ns->ids[IPC_SEM_IDS].ipcs_idr); sem_exit_ns()
398 static inline struct sem_array *sem_obtain_lock(struct ipc_namespace *ns, sem_obtain_lock() argument
404 ipcp = ipc_obtain_object(&sem_ids(ns), id); sem_obtain_lock()
421 static inline struct sem_array *sem_obtain_object(struct ipc_namespace *ns, int id) sem_obtain_object() argument
423 struct kern_ipc_perm *ipcp = ipc_obtain_object(&sem_ids(ns), id); sem_obtain_object()
431 static inline struct sem_array *sem_obtain_object_check(struct ipc_namespace *ns, sem_obtain_object_check() argument
434 struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&sem_ids(ns), id); sem_obtain_object_check()
448 static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) sem_rmid() argument
450 ipc_rmid(&sem_ids(ns), &s->sem_perm); sem_rmid()
489 * @ns: namespace
494 static int newary(struct ipc_namespace *ns, struct ipc_params *params) newary() argument
507 if (ns->used_sems + nsems > ns->sc_semmns) newary()
542 id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni); newary()
547 ns->used_sems += nsems; newary()
584 struct ipc_namespace *ns; SYSCALL_DEFINE3() local
592 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE3()
594 if (nsems < 0 || nsems > ns->sc_semmsl) SYSCALL_DEFINE3()
601 return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params); SYSCALL_DEFINE3()
1087 static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) freeary() argument
1130 sem_rmid(ns, sma); freeary()
1135 ns->used_sems -= sma->sem_nsems; freeary()
1178 static int semctl_nolock(struct ipc_namespace *ns, int semid, semctl_nolock() argument
1196 seminfo.semmni = ns->sc_semmni; semctl_nolock()
1197 seminfo.semmns = ns->sc_semmns; semctl_nolock()
1198 seminfo.semmsl = ns->sc_semmsl; semctl_nolock()
1199 seminfo.semopm = ns->sc_semopm; semctl_nolock()
1204 down_read(&sem_ids(ns).rwsem); semctl_nolock()
1206 seminfo.semusz = sem_ids(ns).in_use; semctl_nolock()
1207 seminfo.semaem = ns->used_sems; semctl_nolock()
1212 max_id = ipc_get_maxid(&sem_ids(ns)); semctl_nolock()
1213 up_read(&sem_ids(ns).rwsem); semctl_nolock()
1228 sma = sem_obtain_object(ns, semid); semctl_nolock()
1235 sma = sem_obtain_object_check(ns, semid); semctl_nolock()
1243 if (ipcperms(ns, &sma->sem_perm, S_IRUGO)) semctl_nolock()
1267 static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, semctl_setval() argument
1290 sma = sem_obtain_object_check(ns, semid); semctl_setval()
1302 if (ipcperms(ns, &sma->sem_perm, S_IWUGO)) { semctl_setval()
1338 static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, semctl_main() argument
1351 sma = sem_obtain_object_check(ns, semid); semctl_main()
1360 if (ipcperms(ns, &sma->sem_perm, cmd == SETALL ? S_IWUGO : S_IRUGO)) semctl_main()
1531 static int semctl_down(struct ipc_namespace *ns, int semid, semctl_down() argument
1544 down_write(&sem_ids(ns).rwsem); semctl_down()
1547 ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd, semctl_down()
1564 freeary(ns, ipcp); semctl_down()
1583 up_write(&sem_ids(ns).rwsem); semctl_down()
1590 struct ipc_namespace *ns; SYSCALL_DEFINE4() local
1597 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE4()
1604 return semctl_nolock(ns, semid, cmd, version, p); SYSCALL_DEFINE4()
1611 return semctl_main(ns, semid, semnum, cmd, p); SYSCALL_DEFINE4()
1613 return semctl_setval(ns, semid, semnum, arg); SYSCALL_DEFINE4()
1616 return semctl_down(ns, semid, cmd, version, p); SYSCALL_DEFINE4()
1679 * @ns: namespace
1688 static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid) find_alloc_undo() argument
1708 sma = sem_obtain_object_check(ns, semid); find_alloc_undo()
1803 struct ipc_namespace *ns; SYSCALL_DEFINE4() local
1806 ns = current->nsproxy->ipc_ns; SYSCALL_DEFINE4()
1810 if (nsops > ns->sc_semopm) SYSCALL_DEFINE4()
1848 un = find_alloc_undo(ns, semid); SYSCALL_DEFINE4()
1858 sma = sem_obtain_object_check(ns, semid); SYSCALL_DEFINE4()
1870 if (ipcperms(ns, &sma->sem_perm, alter ? S_IWUGO : S_IRUGO)) SYSCALL_DEFINE4()
1979 sma = sem_obtain_lock(ns, semid, sops, nsops, &locknum); SYSCALL_DEFINE4()
H A Dutil.c271 * @ns: ipc namespace
279 static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, ipcget_new() argument
285 err = ops->getnew(ns, params); ipcget_new()
292 * @ns: ipc namespace
305 static int ipc_check_perms(struct ipc_namespace *ns, ipc_check_perms() argument
312 if (ipcperms(ns, ipcp, params->flg)) ipc_check_perms()
325 * @ns: ipc namespace
337 static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, ipcget_public() argument
355 err = ops->getnew(ns, params); ipcget_public()
370 err = ipc_check_perms(ns, ipcp, ops, params); ipcget_public()
478 * @ns: ipc namespace
487 int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag) ipcperms() argument
502 !ns_capable(ns->user_ns, CAP_IPC_OWNER)) ipcperms()
632 * @ns: namespace
640 int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, ipcget() argument
644 return ipcget_new(ns, ids, ops, params); ipcget()
646 return ipcget_public(ns, ids, ops, params); ipcget()
671 * @ns: ipc namespace
687 struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, ipcctl_pre_down_nolock() argument
708 ns_capable(ns->user_ns, CAP_SYS_ADMIN)) ipcctl_pre_down_nolock()
739 struct ipc_namespace *ns; member in struct:ipc_proc_iter
786 return sysvipc_find_ipc(&iter->ns->ids[iface->ids], *pos, pos); sysvipc_proc_next()
799 ids = &iter->ns->ids[iface->ids]; sysvipc_proc_start()
830 ids = &iter->ns->ids[iface->ids]; sysvipc_proc_stop()
864 iter->ns = get_ipc_ns(current->nsproxy->ipc_ns); sysvipc_proc_open()
873 put_ipc_ns(iter->ns); sysvipc_proc_release()
H A Dmqueue.c112 struct ipc_namespace *ns; get_ns_from_inode() local
115 ns = __get_ns_from_inode(inode); get_ns_from_inode()
117 return ns; get_ns_from_inode()
309 struct ipc_namespace *ns = data; mqueue_fill_super() local
316 inode = mqueue_get_inode(sb, ns, S_IFDIR | S_ISVTX | S_IRWXUGO, NULL); mqueue_fill_super()
331 struct ipc_namespace *ns = current->nsproxy->ipc_ns; mqueue_mount() local
335 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN)) mqueue_mount()
338 data = ns; mqueue_mount()
1395 int mq_init_ns(struct ipc_namespace *ns) mq_init_ns() argument
1397 ns->mq_queues_count = 0; mq_init_ns()
1398 ns->mq_queues_max = DFLT_QUEUESMAX; mq_init_ns()
1399 ns->mq_msg_max = DFLT_MSGMAX; mq_init_ns()
1400 ns->mq_msgsize_max = DFLT_MSGSIZEMAX; mq_init_ns()
1401 ns->mq_msg_default = DFLT_MSG; mq_init_ns()
1402 ns->mq_msgsize_default = DFLT_MSGSIZE; mq_init_ns()
1404 ns->mq_mnt = kern_mount_data(&mqueue_fs_type, ns); mq_init_ns()
1405 if (IS_ERR(ns->mq_mnt)) { mq_init_ns()
1406 int err = PTR_ERR(ns->mq_mnt); mq_init_ns()
1407 ns->mq_mnt = NULL; mq_init_ns()
1413 void mq_clear_sbinfo(struct ipc_namespace *ns) mq_clear_sbinfo() argument
1415 ns->mq_mnt->mnt_sb->s_fs_info = NULL; mq_clear_sbinfo()
1418 void mq_put_mnt(struct ipc_namespace *ns) mq_put_mnt() argument
1420 kern_unmount(ns->mq_mnt); mq_put_mnt()
H A Dipc_sysctl.c55 struct ipc_namespace *ns = current->nsproxy->ipc_ns; proc_ipc_dointvec_minmax_orphans() local
60 if (ns->shm_rmid_forced) proc_ipc_dointvec_minmax_orphans()
61 shm_destroy_orphaned(ns); proc_ipc_dointvec_minmax_orphans()
/linux-4.1.27/kernel/
H A Dutsname.c31 * Clone a new ns copying an original utsname, setting refcount to 1
33 * Return ERR_PTR(-ENOMEM) on error (failure to kmalloc), new ns otherwise
38 struct uts_namespace *ns; clone_uts_ns() local
41 ns = create_uts_ns(); clone_uts_ns()
42 if (!ns) clone_uts_ns()
45 err = ns_alloc_inum(&ns->ns); clone_uts_ns()
47 kfree(ns); clone_uts_ns()
51 ns->ns.ops = &utsns_operations; clone_uts_ns()
54 memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); clone_uts_ns()
55 ns->user_ns = get_user_ns(user_ns); clone_uts_ns()
57 return ns; clone_uts_ns()
85 struct uts_namespace *ns; free_uts_ns() local
87 ns = container_of(kref, struct uts_namespace, kref); free_uts_ns()
88 put_user_ns(ns->user_ns); free_uts_ns()
89 ns_free_inum(&ns->ns); free_uts_ns()
90 kfree(ns); free_uts_ns()
93 static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) to_uts_ns() argument
95 return container_of(ns, struct uts_namespace, ns); to_uts_ns()
100 struct uts_namespace *ns = NULL; utsns_get() local
106 ns = nsproxy->uts_ns; utsns_get()
107 get_uts_ns(ns); utsns_get()
111 return ns ? &ns->ns : NULL; utsns_get()
114 static void utsns_put(struct ns_common *ns) utsns_put() argument
116 put_uts_ns(to_uts_ns(ns)); utsns_put()
121 struct uts_namespace *ns = to_uts_ns(new); utsns_install() local
123 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || utsns_install()
127 get_uts_ns(ns); utsns_install()
129 nsproxy->uts_ns = ns; utsns_install()
H A Dpid_namespace.c75 struct pid_namespace *ns = container_of(work, struct pid_namespace, proc_work); proc_cleanup_work() local
76 pid_ns_release_proc(ns); proc_cleanup_work()
85 struct pid_namespace *ns; create_pid_namespace() local
96 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); create_pid_namespace()
97 if (ns == NULL) create_pid_namespace()
100 ns->pidmap[0].page = kzalloc(PAGE_SIZE, GFP_KERNEL); create_pid_namespace()
101 if (!ns->pidmap[0].page) create_pid_namespace()
104 ns->pid_cachep = create_pid_cachep(level + 1); create_pid_namespace()
105 if (ns->pid_cachep == NULL) create_pid_namespace()
108 err = ns_alloc_inum(&ns->ns); create_pid_namespace()
111 ns->ns.ops = &pidns_operations; create_pid_namespace()
113 kref_init(&ns->kref); create_pid_namespace()
114 ns->level = level; create_pid_namespace()
115 ns->parent = get_pid_ns(parent_pid_ns); create_pid_namespace()
116 ns->user_ns = get_user_ns(user_ns); create_pid_namespace()
117 ns->nr_hashed = PIDNS_HASH_ADDING; create_pid_namespace()
118 INIT_WORK(&ns->proc_work, proc_cleanup_work); create_pid_namespace()
120 set_bit(0, ns->pidmap[0].page); create_pid_namespace()
121 atomic_set(&ns->pidmap[0].nr_free, BITS_PER_PAGE - 1); create_pid_namespace()
124 atomic_set(&ns->pidmap[i].nr_free, BITS_PER_PAGE); create_pid_namespace()
126 return ns; create_pid_namespace()
129 kfree(ns->pidmap[0].page); create_pid_namespace()
131 kmem_cache_free(pid_ns_cachep, ns); create_pid_namespace()
142 static void destroy_pid_namespace(struct pid_namespace *ns) destroy_pid_namespace() argument
146 ns_free_inum(&ns->ns); destroy_pid_namespace()
148 kfree(ns->pidmap[i].page); destroy_pid_namespace()
149 put_user_ns(ns->user_ns); destroy_pid_namespace()
150 call_rcu(&ns->rcu, delayed_free_pidns); destroy_pid_namespace()
165 struct pid_namespace *ns; free_pid_ns() local
167 ns = container_of(kref, struct pid_namespace, kref); free_pid_ns()
168 destroy_pid_namespace(ns); free_pid_ns()
171 void put_pid_ns(struct pid_namespace *ns) put_pid_ns() argument
175 while (ns != &init_pid_ns) { put_pid_ns()
176 parent = ns->parent; put_pid_ns()
177 if (!kref_put(&ns->kref, free_pid_ns)) put_pid_ns()
179 ns = parent; put_pid_ns()
248 * But this ns can also have other tasks injected by setns()+fork(). zap_pid_ns_processes()
283 * Writing directly to ns' last_pid field is OK, since this field pid_ns_ctl_handler()
337 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) to_pid_ns() argument
339 return container_of(ns, struct pid_namespace, ns); to_pid_ns()
344 struct pid_namespace *ns; pidns_get() local
347 ns = task_active_pid_ns(task); pidns_get()
348 if (ns) pidns_get()
349 get_pid_ns(ns); pidns_get()
352 return ns ? &ns->ns : NULL; pidns_get()
355 static void pidns_put(struct ns_common *ns) pidns_put() argument
357 put_pid_ns(to_pid_ns(ns)); pidns_put()
360 static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns) pidns_install() argument
363 struct pid_namespace *ancestor, *new = to_pid_ns(ns); pidns_install()
H A Dpid.c42 #define pid_hashfn(nr, ns) \
43 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
82 .ns.inum = PROC_PID_INIT_INO,
84 .ns.ops = &pidns_operations,
108 struct pidmap *map = upid->ns->pidmap + nr / BITS_PER_PAGE; free_pidmap()
239 struct pid_namespace *ns; put_pid() local
244 ns = pid->numbers[pid->level].ns; put_pid()
247 kmem_cache_free(ns->pid_cachep, pid); put_pid()
248 put_pid_ns(ns); put_pid()
268 struct pid_namespace *ns = upid->ns; free_pid() local
270 switch(--ns->nr_hashed) { free_pid()
277 wake_up_process(ns->child_reaper); free_pid()
281 WARN_ON(ns->child_reaper); free_pid()
282 ns->nr_hashed = 0; free_pid()
285 schedule_work(&ns->proc_work); free_pid()
297 struct pid *alloc_pid(struct pid_namespace *ns) alloc_pid() argument
306 pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); alloc_pid()
310 tmp = ns; alloc_pid()
311 pid->level = ns->level; alloc_pid()
312 for (i = ns->level; i >= 0; i--) { alloc_pid()
320 pid->numbers[i].ns = tmp; alloc_pid()
325 if (pid_ns_prepare_proc(ns)) alloc_pid()
329 get_pid_ns(ns); alloc_pid()
334 upid = pid->numbers + ns->level; alloc_pid()
336 if (!(ns->nr_hashed & PIDNS_HASH_ADDING)) alloc_pid()
340 &pid_hash[pid_hashfn(upid->nr, upid->ns)]); alloc_pid()
341 upid->ns->nr_hashed++; alloc_pid()
349 put_pid_ns(ns); alloc_pid()
352 while (++i <= ns->level) alloc_pid()
355 kmem_cache_free(ns->pid_cachep, pid); alloc_pid()
359 void disable_pid_allocation(struct pid_namespace *ns) disable_pid_allocation() argument
362 ns->nr_hashed &= ~PIDNS_HASH_ADDING; disable_pid_allocation()
366 struct pid *find_pid_ns(int nr, struct pid_namespace *ns) find_pid_ns() argument
371 &pid_hash[pid_hashfn(nr, ns)], pid_chain) find_pid_ns()
372 if (pnr->nr == nr && pnr->ns == ns) find_pid_ns()
374 numbers[ns->level]); find_pid_ns()
452 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns) find_task_by_pid_ns() argument
457 return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID); find_task_by_pid_ns()
501 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) pid_nr_ns() argument
506 if (pid && ns->level <= pid->level) { pid_nr_ns()
507 upid = &pid->numbers[ns->level]; pid_nr_ns()
508 if (upid->ns == ns) pid_nr_ns()
522 struct pid_namespace *ns) __task_pid_nr_ns()
527 if (!ns) __task_pid_nr_ns()
528 ns = task_active_pid_ns(current); __task_pid_nr_ns()
532 nr = pid_nr_ns(task->pids[type].pid, ns); __task_pid_nr_ns()
540 pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) task_tgid_nr_ns() argument
542 return pid_nr_ns(task_tgid(tsk), ns); task_tgid_nr_ns()
557 struct pid *find_ge_pid(int nr, struct pid_namespace *ns) find_ge_pid() argument
562 pid = find_pid_ns(nr, ns); find_ge_pid()
565 nr = next_pidmap(ns, nr); find_ge_pid()
521 __task_pid_nr_ns(struct task_struct *task, enum pid_type type, struct pid_namespace *ns) __task_pid_nr_ns() argument
H A Duser_namespace.c30 struct user_namespace *ns, int cap_setid,
61 struct user_namespace *ns, *parent_ns = new->user_ns; create_user_ns() local
86 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL); create_user_ns()
87 if (!ns) create_user_ns()
90 ret = ns_alloc_inum(&ns->ns); create_user_ns()
92 kmem_cache_free(user_ns_cachep, ns); create_user_ns()
95 ns->ns.ops = &userns_operations; create_user_ns()
97 atomic_set(&ns->count, 1); create_user_ns()
99 ns->parent = parent_ns; create_user_ns()
100 ns->level = parent_ns->level + 1; create_user_ns()
101 ns->owner = owner; create_user_ns()
102 ns->group = group; create_user_ns()
106 ns->flags = parent_ns->flags; create_user_ns()
109 set_cred_user_ns(new, ns); create_user_ns()
112 init_rwsem(&ns->persistent_keyring_register_sem); create_user_ns()
137 void free_user_ns(struct user_namespace *ns) free_user_ns() argument
142 parent = ns->parent; free_user_ns()
144 key_put(ns->persistent_keyring_register); free_user_ns()
146 ns_free_inum(&ns->ns); free_user_ns()
147 kmem_cache_free(user_ns_cachep, ns); free_user_ns()
148 ns = parent; free_user_ns()
227 * @ns: User namespace that the uid is in
238 kuid_t make_kuid(struct user_namespace *ns, uid_t uid) make_kuid() argument
241 return KUIDT_INIT(map_id_down(&ns->uid_map, uid)); make_kuid()
295 * @ns: User namespace that the gid is in
306 kgid_t make_kgid(struct user_namespace *ns, gid_t gid) make_kgid() argument
309 return KGIDT_INIT(map_id_down(&ns->gid_map, gid)); make_kgid()
362 * @ns: User namespace that the projid is in
373 kprojid_t make_kprojid(struct user_namespace *ns, projid_t projid) make_kprojid() argument
376 return KPROJIDT_INIT(map_id_down(&ns->projid_map, projid)); make_kprojid()
431 struct user_namespace *ns = seq->private; uid_m_show() local
437 if ((lower_ns == ns) && lower_ns->parent) uid_m_show()
452 struct user_namespace *ns = seq->private; gid_m_show() local
458 if ((lower_ns == ns) && lower_ns->parent) gid_m_show()
473 struct user_namespace *ns = seq->private; projid_m_show() local
479 if ((lower_ns == ns) && lower_ns->parent) projid_m_show()
506 struct user_namespace *ns = seq->private; uid_m_start() local
508 return m_start(seq, ppos, &ns->uid_map); uid_m_start()
513 struct user_namespace *ns = seq->private; gid_m_start() local
515 return m_start(seq, ppos, &ns->gid_map); gid_m_start()
520 struct user_namespace *ns = seq->private; projid_m_start() local
522 return m_start(seq, ppos, &ns->projid_map); projid_m_start()
600 struct user_namespace *ns = seq->private; map_write() local
637 if (cap_valid(cap_setid) && !file_ns_capable(file, ns, CAP_SYS_ADMIN)) map_write()
725 if (!new_idmap_permitted(file, ns, cap_setid, &new_map)) map_write()
767 struct user_namespace *ns = seq->private; proc_uid_map_write() local
770 if (!ns->parent) proc_uid_map_write()
773 if ((seq_ns != ns) && (seq_ns != ns->parent)) proc_uid_map_write()
777 &ns->uid_map, &ns->parent->uid_map); proc_uid_map_write()
784 struct user_namespace *ns = seq->private; proc_gid_map_write() local
787 if (!ns->parent) proc_gid_map_write()
790 if ((seq_ns != ns) && (seq_ns != ns->parent)) proc_gid_map_write()
794 &ns->gid_map, &ns->parent->gid_map); proc_gid_map_write()
801 struct user_namespace *ns = seq->private; proc_projid_map_write() local
804 if (!ns->parent) proc_projid_map_write()
807 if ((seq_ns != ns) && (seq_ns != ns->parent)) proc_projid_map_write()
812 &ns->projid_map, &ns->parent->projid_map); proc_projid_map_write()
816 struct user_namespace *ns, int cap_setid, new_idmap_permitted()
824 uid_eq(ns->owner, cred->euid)) { new_idmap_permitted()
827 kuid_t uid = make_kuid(ns->parent, id); new_idmap_permitted()
831 kgid_t gid = make_kgid(ns->parent, id); new_idmap_permitted()
832 if (!(ns->flags & USERNS_SETGROUPS_ALLOWED) && new_idmap_permitted()
846 if (ns_capable(ns->parent, cap_setid) && new_idmap_permitted()
847 file_ns_capable(file, ns->parent, cap_setid)) new_idmap_permitted()
855 struct user_namespace *ns = seq->private; proc_setgroups_show() local
856 unsigned long userns_flags = ACCESS_ONCE(ns->flags); proc_setgroups_show()
868 struct user_namespace *ns = seq->private; proc_setgroups_write() local
909 if (!(ns->flags & USERNS_SETGROUPS_ALLOWED)) proc_setgroups_write()
915 if (ns->gid_map.nr_extents != 0) proc_setgroups_write()
917 ns->flags &= ~USERNS_SETGROUPS_ALLOWED; proc_setgroups_write()
931 bool userns_may_setgroups(const struct user_namespace *ns) userns_may_setgroups() argument
939 allowed = ns->gid_map.nr_extents != 0; userns_may_setgroups()
941 allowed = allowed && (ns->flags & USERNS_SETGROUPS_ALLOWED); userns_may_setgroups()
947 static inline struct user_namespace *to_user_ns(struct ns_common *ns) to_user_ns() argument
949 return container_of(ns, struct user_namespace, ns); to_user_ns()
960 return user_ns ? &user_ns->ns : NULL; userns_get()
963 static void userns_put(struct ns_common *ns) userns_put() argument
965 put_user_ns(to_user_ns(ns)); userns_put()
968 static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns) userns_install() argument
970 struct user_namespace *user_ns = to_user_ns(ns); userns_install()
815 new_idmap_permitted(const struct file *file, struct user_namespace *ns, int cap_setid, struct uid_gid_map *new_map) new_idmap_permitted() argument
H A Dnsproxy.c158 void free_nsproxy(struct nsproxy *ns) free_nsproxy() argument
160 if (ns->mnt_ns) free_nsproxy()
161 put_mnt_ns(ns->mnt_ns); free_nsproxy()
162 if (ns->uts_ns) free_nsproxy()
163 put_uts_ns(ns->uts_ns); free_nsproxy()
164 if (ns->ipc_ns) free_nsproxy()
165 put_ipc_ns(ns->ipc_ns); free_nsproxy()
166 if (ns->pid_ns_for_children) free_nsproxy()
167 put_pid_ns(ns->pid_ns_for_children); free_nsproxy()
168 put_net(ns->net_ns); free_nsproxy()
169 kmem_cache_free(nsproxy_cachep, ns); free_nsproxy()
203 struct nsproxy *ns; switch_task_namespaces() local
208 ns = p->nsproxy; switch_task_namespaces()
212 if (ns && atomic_dec_and_test(&ns->count)) switch_task_namespaces()
213 free_nsproxy(ns); switch_task_namespaces()
226 struct ns_common *ns; SYSCALL_DEFINE2() local
234 ns = get_proc_ns(file_inode(file)); SYSCALL_DEFINE2()
235 if (nstype && (ns->ops->type != nstype)) SYSCALL_DEFINE2()
244 err = ns->ops->install(new_nsproxy, ns); SYSCALL_DEFINE2()
H A Dacct.c88 struct pid_namespace *ns; member in struct:bsd_acct_struct
141 static struct bsd_acct_struct *acct_get(struct pid_namespace *ns) acct_get() argument
147 res = to_acct(ACCESS_ONCE(ns->bacct)); acct_get()
159 if (res != to_acct(ACCESS_ONCE(ns->bacct))) { acct_get()
174 cmpxchg(&acct->ns->bacct, pin, NULL); acct_pin_kill()
194 struct pid_namespace *ns = task_active_pid_ns(current); acct_on() local
241 acct->ns = ns; acct_on()
249 old = xchg(&ns->bacct, &acct->pin); acct_on()
294 void acct_exit_ns(struct pid_namespace *ns) acct_exit_ns() argument
297 pin_kill(ns->bacct); acct_exit_ns()
501 struct pid_namespace *ns = acct->ns; do_acct_process() local
503 ac.ac_pid = task_tgid_nr_ns(current, ns); do_acct_process()
506 ns); do_acct_process()
570 static void slow_acct_process(struct pid_namespace *ns) slow_acct_process() argument
572 for ( ; ns; ns = ns->parent) { slow_acct_process()
573 struct bsd_acct_struct *acct = acct_get(ns); slow_acct_process()
589 struct pid_namespace *ns; acct_process() local
596 for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent) { acct_process()
597 if (ns->bacct) acct_process()
600 if (unlikely(ns)) acct_process()
601 slow_acct_process(ns); acct_process()
H A Dcapability.c285 * has_ns_capability - Does a task have a capability in a specific user ns
287 * @ns: target user namespace
296 struct user_namespace *ns, int cap) has_ns_capability()
301 ret = security_capable(__task_cred(t), ns, cap); has_ns_capability()
324 * in a specific user ns.
326 * @ns: target user namespace
336 struct user_namespace *ns, int cap) has_ns_capability_noaudit()
341 ret = security_capable_noaudit(__task_cred(t), ns, cap); has_ns_capability_noaudit()
349 * initial user ns
366 * @ns: The usernamespace we want the capability in
375 bool ns_capable(struct user_namespace *ns, int cap) ns_capable() argument
382 if (security_capable(current_cred(), ns, cap) == 0) { ns_capable()
411 * @ns: The usernamespace we want the capability in
420 bool file_ns_capable(const struct file *file, struct user_namespace *ns, file_ns_capable() argument
426 if (security_capable(file->f_cred, ns, cap) == 0) file_ns_capable()
444 struct user_namespace *ns = current_user_ns(); capable_wrt_inode_uidgid() local
446 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid) && capable_wrt_inode_uidgid()
447 kgid_has_mapping(ns, inode->i_gid); capable_wrt_inode_uidgid()
295 has_ns_capability(struct task_struct *t, struct user_namespace *ns, int cap) has_ns_capability() argument
335 has_ns_capability_noaudit(struct task_struct *t, struct user_namespace *ns, int cap) has_ns_capability_noaudit() argument
H A Ddelayacct.c54 s64 ns = ktime_get_ns() - *start; delayacct_end() local
57 if (ns > 0) { delayacct_end()
59 *total += ns; delayacct_end()
/linux-4.1.27/drivers/staging/lustre/lustre/ldlm/
H A Dldlm_resource.c159 struct ldlm_namespace *ns = m->private; lprocfs_ns_resources_seq_show() local
165 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i) lprocfs_ns_resources_seq_show()
173 struct ldlm_namespace *ns = m->private; lprocfs_ns_locks_seq_show() local
176 locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS, lprocfs_ns_locks_seq_show()
184 struct ldlm_namespace *ns = m->private; lprocfs_lru_size_seq_show() local
185 __u32 *nr = &ns->ns_max_unused; lprocfs_lru_size_seq_show()
187 if (ns_connect_lru_resize(ns)) lprocfs_lru_size_seq_show()
188 nr = &ns->ns_nr_unused; lprocfs_lru_size_seq_show()
196 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; lprocfs_lru_size_seq_write() local
209 ldlm_ns_name(ns)); lprocfs_lru_size_seq_write()
210 if (ns_connect_lru_resize(ns)) { lprocfs_lru_size_seq_write()
211 int canceled, unused = ns->ns_nr_unused; lprocfs_lru_size_seq_write()
214 canceled = ldlm_cancel_lru(ns, unused, 0, lprocfs_lru_size_seq_write()
224 tmp = ns->ns_max_unused; lprocfs_lru_size_seq_write()
225 ns->ns_max_unused = 0; lprocfs_lru_size_seq_write()
226 ldlm_cancel_lru(ns, 0, 0, LDLM_CANCEL_PASSED); lprocfs_lru_size_seq_write()
227 ns->ns_max_unused = tmp; lprocfs_lru_size_seq_write()
239 if (ns_connect_lru_resize(ns)) { lprocfs_lru_size_seq_write()
241 ns->ns_max_unused = (unsigned int)tmp; lprocfs_lru_size_seq_write()
243 if (tmp > ns->ns_nr_unused) lprocfs_lru_size_seq_write()
244 tmp = ns->ns_nr_unused; lprocfs_lru_size_seq_write()
245 tmp = ns->ns_nr_unused - tmp; lprocfs_lru_size_seq_write()
249 ldlm_ns_name(ns), ns->ns_nr_unused, lprocfs_lru_size_seq_write()
251 ldlm_cancel_lru(ns, tmp, LCF_ASYNC, LDLM_CANCEL_PASSED); lprocfs_lru_size_seq_write()
256 ldlm_ns_name(ns)); lprocfs_lru_size_seq_write()
257 ns->ns_connect_flags &= ~OBD_CONNECT_LRU_RESIZE; lprocfs_lru_size_seq_write()
262 ldlm_ns_name(ns), ns->ns_max_unused, lprocfs_lru_size_seq_write()
264 ns->ns_max_unused = (unsigned int)tmp; lprocfs_lru_size_seq_write()
265 ldlm_cancel_lru(ns, 0, LCF_ASYNC, LDLM_CANCEL_PASSED); lprocfs_lru_size_seq_write()
270 (ns->ns_orig_connect_flags & OBD_CONNECT_LRU_RESIZE)) { lprocfs_lru_size_seq_write()
273 ldlm_ns_name(ns)); lprocfs_lru_size_seq_write()
274 ns->ns_connect_flags |= OBD_CONNECT_LRU_RESIZE; lprocfs_lru_size_seq_write()
284 struct ldlm_namespace *ns = m->private; lprocfs_elc_seq_show() local
285 unsigned int supp = ns_connect_cancelset(ns); lprocfs_elc_seq_show()
294 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; lprocfs_elc_seq_write() local
303 ns->ns_connect_flags &= ~OBD_CONNECT_CANCELSET; lprocfs_elc_seq_write()
304 else if (ns->ns_orig_connect_flags & OBD_CONNECT_CANCELSET) lprocfs_elc_seq_write()
305 ns->ns_connect_flags |= OBD_CONNECT_CANCELSET; lprocfs_elc_seq_write()
310 void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) ldlm_namespace_proc_unregister() argument
312 if (ns->ns_proc_dir_entry == NULL) ldlm_namespace_proc_unregister()
314 ldlm_ns_name(ns)); ldlm_namespace_proc_unregister()
316 lprocfs_remove(&ns->ns_proc_dir_entry); ldlm_namespace_proc_unregister()
318 if (ns->ns_stats != NULL) ldlm_namespace_proc_unregister()
319 lprocfs_free_stats(&ns->ns_stats); ldlm_namespace_proc_unregister()
330 int ldlm_namespace_proc_register(struct ldlm_namespace *ns) ldlm_namespace_proc_register() argument
336 LASSERT(ns != NULL); ldlm_namespace_proc_register()
337 LASSERT(ns->ns_rs_hash != NULL); ldlm_namespace_proc_register()
339 if (ns->ns_proc_dir_entry != NULL) { ldlm_namespace_proc_register()
340 ns_pde = ns->ns_proc_dir_entry; ldlm_namespace_proc_register()
342 ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir); ldlm_namespace_proc_register()
345 ns->ns_proc_dir_entry = ns_pde; ldlm_namespace_proc_register()
348 ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); ldlm_namespace_proc_register()
349 if (ns->ns_stats == NULL) ldlm_namespace_proc_register()
352 lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS, ldlm_namespace_proc_register()
360 LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops); ldlm_namespace_proc_register()
361 LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops); ldlm_namespace_proc_register()
363 if (ns_is_client(ns)) { ldlm_namespace_proc_register()
364 LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, ldlm_namespace_proc_register()
366 LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops); ldlm_namespace_proc_register()
367 LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, ldlm_namespace_proc_register()
369 LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops); ldlm_namespace_proc_register()
371 LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit, ldlm_namespace_proc_register()
373 LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts, ldlm_namespace_proc_register()
375 LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size, ldlm_namespace_proc_register()
377 LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time, ldlm_namespace_proc_register()
379 LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks, ldlm_namespace_proc_register()
381 LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast, ldlm_namespace_proc_register()
389 #define ldlm_namespace_proc_unregister(ns) ({; })
390 #define ldlm_namespace_proc_register(ns) ({0; })
567 struct ldlm_namespace *ns = NULL; ldlm_namespace_new() local
585 CERROR("Unknown type %d for ns %s\n", ns_type, name); ldlm_namespace_new()
593 OBD_ALLOC_PTR(ns); ldlm_namespace_new()
594 if (!ns) ldlm_namespace_new()
597 ns->ns_rs_hash = cfs_hash_create(name, ldlm_namespace_new()
607 if (ns->ns_rs_hash == NULL) ldlm_namespace_new()
610 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, idx) { ldlm_namespace_new()
611 nsb = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd); ldlm_namespace_new()
613 nsb->nsb_namespace = ns; ldlm_namespace_new()
616 ns->ns_obd = obd; ldlm_namespace_new()
617 ns->ns_appetite = apt; ldlm_namespace_new()
618 ns->ns_client = client; ldlm_namespace_new()
620 INIT_LIST_HEAD(&ns->ns_list_chain); ldlm_namespace_new()
621 INIT_LIST_HEAD(&ns->ns_unused_list); ldlm_namespace_new()
622 spin_lock_init(&ns->ns_lock); ldlm_namespace_new()
623 atomic_set(&ns->ns_bref, 0); ldlm_namespace_new()
624 init_waitqueue_head(&ns->ns_waitq); ldlm_namespace_new()
626 ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES; ldlm_namespace_new()
627 ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS; ldlm_namespace_new()
628 ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS; ldlm_namespace_new()
630 ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT; ldlm_namespace_new()
631 ns->ns_nr_unused = 0; ldlm_namespace_new()
632 ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE; ldlm_namespace_new()
633 ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE; ldlm_namespace_new()
634 ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT; ldlm_namespace_new()
635 ns->ns_timeouts = 0; ldlm_namespace_new()
636 ns->ns_orig_connect_flags = 0; ldlm_namespace_new()
637 ns->ns_connect_flags = 0; ldlm_namespace_new()
638 ns->ns_stopping = 0; ldlm_namespace_new()
639 rc = ldlm_namespace_proc_register(ns); ldlm_namespace_new()
641 CERROR("Can't initialize ns proc, rc %d\n", rc); ldlm_namespace_new()
646 rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client); ldlm_namespace_new()
652 ldlm_namespace_register(ns, client); ldlm_namespace_new()
653 return ns; ldlm_namespace_new()
655 ldlm_namespace_proc_unregister(ns); ldlm_namespace_new()
656 ldlm_namespace_cleanup(ns, 0); ldlm_namespace_new()
658 cfs_hash_putref(ns->ns_rs_hash); ldlm_namespace_new()
660 OBD_FREE_PTR(ns); ldlm_namespace_new()
784 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags) ldlm_namespace_cleanup() argument
786 if (ns == NULL) { ldlm_namespace_cleanup()
787 CDEBUG(D_INFO, "NULL ns, skipping cleanup\n"); ldlm_namespace_cleanup()
791 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_clean, &flags); ldlm_namespace_cleanup()
792 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_complain, NULL); ldlm_namespace_cleanup()
802 static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) __ldlm_namespace_free() argument
805 ldlm_namespace_cleanup(ns, force ? LDLM_FL_LOCAL_ONLY : 0); __ldlm_namespace_free()
807 if (atomic_read(&ns->ns_bref) > 0) { __ldlm_namespace_free()
813 ldlm_ns_name(ns), atomic_read(&ns->ns_bref)); __ldlm_namespace_free()
818 rc = l_wait_event(ns->ns_waitq, __ldlm_namespace_free()
819 atomic_read(&ns->ns_bref) == 0, &lwi); __ldlm_namespace_free()
825 ldlm_ns_name(ns), __ldlm_namespace_free()
826 atomic_read(&ns->ns_bref), rc); __ldlm_namespace_free()
830 if (atomic_read(&ns->ns_bref)) { __ldlm_namespace_free()
832 ldlm_ns_name(ns), __ldlm_namespace_free()
833 atomic_read(&ns->ns_bref), rc); __ldlm_namespace_free()
837 ldlm_ns_name(ns)); __ldlm_namespace_free()
844 * Performs various cleanups for passed \a ns to make it drop refc and be
848 * (0) Unregister \a ns from its list to make inaccessible for potential
850 * (1) Clear all locks in \a ns.
852 void ldlm_namespace_free_prior(struct ldlm_namespace *ns, ldlm_namespace_free_prior() argument
858 if (!ns) ldlm_namespace_free_prior()
861 spin_lock(&ns->ns_lock); ldlm_namespace_free_prior()
862 ns->ns_stopping = 1; ldlm_namespace_free_prior()
863 spin_unlock(&ns->ns_lock); ldlm_namespace_free_prior()
868 rc = __ldlm_namespace_free(ns, force); ldlm_namespace_free_prior()
879 rc = __ldlm_namespace_free(ns, 1); ldlm_namespace_free_prior()
885 * Performs freeing memory structures related to \a ns. This is only done
887 * referencing \a ns and its refc == 0.
889 void ldlm_namespace_free_post(struct ldlm_namespace *ns) ldlm_namespace_free_post() argument
891 if (!ns) ldlm_namespace_free_post()
894 /* Make sure that nobody can find this ns in its list. */ ldlm_namespace_free_post()
895 ldlm_namespace_unregister(ns, ns->ns_client); ldlm_namespace_free_post()
899 ldlm_pool_fini(&ns->ns_pool); ldlm_namespace_free_post()
901 ldlm_namespace_proc_unregister(ns); ldlm_namespace_free_post()
902 cfs_hash_putref(ns->ns_rs_hash); ldlm_namespace_free_post()
903 /* Namespace \a ns should be not on list at this time, otherwise ldlm_namespace_free_post()
904 * this will cause issues related to using freed \a ns in poold ldlm_namespace_free_post()
906 LASSERT(list_empty(&ns->ns_list_chain)); ldlm_namespace_free_post()
907 OBD_FREE_PTR(ns); ldlm_namespace_free_post()
929 void ldlm_namespace_free(struct ldlm_namespace *ns, ldlm_namespace_free() argument
933 ldlm_namespace_free_prior(ns, imp, force); ldlm_namespace_free()
934 ldlm_namespace_free_post(ns); ldlm_namespace_free()
938 void ldlm_namespace_get(struct ldlm_namespace *ns) ldlm_namespace_get() argument
940 atomic_inc(&ns->ns_bref); ldlm_namespace_get()
945 int ldlm_namespace_get_return(struct ldlm_namespace *ns) ldlm_namespace_get_return() argument
947 return atomic_inc_return(&ns->ns_bref); ldlm_namespace_get_return()
950 void ldlm_namespace_put(struct ldlm_namespace *ns) ldlm_namespace_put() argument
952 if (atomic_dec_and_lock(&ns->ns_bref, &ns->ns_lock)) { ldlm_namespace_put()
953 wake_up(&ns->ns_waitq); ldlm_namespace_put()
954 spin_unlock(&ns->ns_lock); ldlm_namespace_put()
959 /** Register \a ns in the list of namespaces */ ldlm_namespace_register()
960 void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client) ldlm_namespace_register() argument
963 LASSERT(list_empty(&ns->ns_list_chain)); ldlm_namespace_register()
964 list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client)); ldlm_namespace_register()
969 /** Unregister \a ns from the list of namespaces. */ ldlm_namespace_unregister()
970 void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client) ldlm_namespace_unregister() argument
973 LASSERT(!list_empty(&ns->ns_list_chain)); ldlm_namespace_unregister()
975 * using list_empty(&ns->ns_list_chain). This is why it is ldlm_namespace_unregister()
977 list_del_init(&ns->ns_list_chain); ldlm_namespace_unregister()
983 void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns, ldlm_namespace_move_to_active_locked() argument
986 LASSERT(!list_empty(&ns->ns_list_chain)); ldlm_namespace_move_to_active_locked()
988 list_move_tail(&ns->ns_list_chain, ldlm_namespace_list(client)); ldlm_namespace_move_to_active_locked()
992 void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns, ldlm_namespace_move_to_inactive_locked() argument
995 LASSERT(!list_empty(&ns->ns_list_chain)); ldlm_namespace_move_to_inactive_locked()
997 list_move_tail(&ns->ns_list_chain, ldlm_namespace_move_to_inactive_locked()
1050 ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, ldlm_resource_get() argument
1059 LASSERT(ns != NULL); ldlm_resource_get()
1061 LASSERT(ns->ns_rs_hash != NULL); ldlm_resource_get()
1064 cfs_hash_bd_get_and_lock(ns->ns_rs_hash, (void *)name, &bd, 0); ldlm_resource_get()
1065 hnode = cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name); ldlm_resource_get()
1067 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0); ldlm_resource_get()
1070 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { ldlm_resource_get()
1083 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0); ldlm_resource_get()
1094 res->lr_ns_bucket = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd); ldlm_resource_get()
1099 cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1); ldlm_resource_get()
1101 cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name); ldlm_resource_get()
1105 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); ldlm_resource_get()
1114 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { ldlm_resource_get()
1126 cfs_hash_bd_add_locked(ns->ns_rs_hash, &bd, &res->lr_hash); ldlm_resource_get()
1128 ns_refcount = ldlm_namespace_get_return(ns); ldlm_resource_get()
1130 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); ldlm_resource_get()
1131 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { ldlm_resource_get()
1135 rc = ns->ns_lvbo->lvbo_init(res); ldlm_resource_get()
1138 ns->ns_obd->obd_name, name->name[0], ldlm_resource_get()
1158 if (ns_is_client(ns) && ns_refcount == 1) { ldlm_resource_get()
1160 ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT); ldlm_resource_get()
1208 struct ldlm_namespace *ns = ldlm_res_to_ns(res); ldlm_resource_putref() local
1215 cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd); ldlm_resource_putref()
1216 if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) { ldlm_resource_putref()
1218 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); ldlm_resource_putref()
1219 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) ldlm_resource_putref()
1220 ns->ns_lvbo->lvbo_free(res); ldlm_resource_putref()
1231 struct ldlm_namespace *ns = ldlm_res_to_ns(res); ldlm_resource_putref_locked() local
1243 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); ldlm_resource_putref_locked()
1249 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) ldlm_resource_putref_locked()
1250 ns->ns_lvbo->lvbo_free(res); ldlm_resource_putref_locked()
1253 cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1); ldlm_resource_putref_locked()
1338 struct ldlm_namespace *ns; list_for_each() local
1340 ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain); list_for_each()
1341 ldlm_namespace_dump(level, ns); list_for_each()
1365 void ldlm_namespace_dump(int level, struct ldlm_namespace *ns) ldlm_namespace_dump() argument
1371 ldlm_ns_name(ns), atomic_read(&ns->ns_bref), ldlm_namespace_dump()
1372 ns_is_client(ns) ? "client" : "server"); ldlm_namespace_dump()
1374 if (time_before(cfs_time_current(), ns->ns_next_dump)) ldlm_namespace_dump()
1377 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_namespace_dump()
1380 spin_lock(&ns->ns_lock); ldlm_namespace_dump()
1381 ns->ns_next_dump = cfs_time_shift(10); ldlm_namespace_dump()
1382 spin_unlock(&ns->ns_lock); ldlm_namespace_dump()
H A Dldlm_internal.h88 static inline int ldlm_ns_empty(struct ldlm_namespace *ns) ldlm_ns_empty() argument
90 return atomic_read(&ns->ns_bref) == 0; ldlm_ns_empty()
109 int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr,
111 int ldlm_cancel_lru_local(struct ldlm_namespace *ns,
121 void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
123 void ldlm_namespace_free_post(struct ldlm_namespace *ns);
145 ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *,
157 int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
170 int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
172 int ldlm_bl_to_thread_list(struct ldlm_namespace *ns,
177 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
197 void l_check_ns_lock(struct ldlm_namespace *ns);
198 void l_check_no_ns_lock(struct ldlm_namespace *ns);
H A Dldlm_pool.c495 * Do not cancel locks in case lru resize is disabled for this ns. ldlm_cli_pool_recalc()
531 struct ldlm_namespace *ns; ldlm_cli_pool_shrink() local
534 ns = ldlm_pl2ns(pl); ldlm_cli_pool_shrink()
537 * Do not cancel locks in case lru resize is disabled for this ns. ldlm_cli_pool_shrink()
539 if (!ns_connect_lru_resize(ns)) ldlm_cli_pool_shrink()
547 spin_lock(&ns->ns_lock); ldlm_cli_pool_shrink()
548 unused = ns->ns_nr_unused; ldlm_cli_pool_shrink()
549 spin_unlock(&ns->ns_lock); ldlm_cli_pool_shrink()
554 return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK); ldlm_cli_pool_shrink()
743 struct ldlm_namespace *ns = ldlm_pl2ns(pl); ldlm_pool_proc_init() local
753 parent_ns_proc = ns->ns_proc_dir_entry; ldlm_pool_proc_init()
756 ldlm_ns_name(ns)); ldlm_pool_proc_init()
855 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, ldlm_pool_init() argument
870 ldlm_ns_name(ns), idx); ldlm_pool_init()
1057 struct ldlm_namespace *ns; ldlm_pools_count() local
1080 ns = ldlm_namespace_first_locked(client); ldlm_pools_count()
1082 if (ns == ns_old) { ldlm_pools_count()
1087 if (ldlm_ns_empty(ns)) { ldlm_pools_count()
1088 ldlm_namespace_move_to_inactive_locked(ns, client); ldlm_pools_count()
1094 ns_old = ns; ldlm_pools_count()
1096 ldlm_namespace_get(ns); ldlm_pools_count()
1097 ldlm_namespace_move_to_active_locked(ns, client); ldlm_pools_count()
1099 total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask); ldlm_pools_count()
1100 ldlm_namespace_put(ns); ldlm_pools_count()
1111 struct ldlm_namespace *ns; ldlm_pools_scan() local
1134 ns = ldlm_namespace_first_locked(client); ldlm_pools_scan()
1135 ldlm_namespace_get(ns); ldlm_pools_scan()
1136 ldlm_namespace_move_to_active_locked(ns, client); ldlm_pools_scan()
1139 nr_locks = ldlm_pool_granted(&ns->ns_pool); ldlm_pools_scan()
1145 freed += ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask); ldlm_pools_scan()
1146 ldlm_namespace_put(ns); ldlm_pools_scan()
1185 struct ldlm_namespace *ns; ldlm_pools_recalc() local
1198 list_for_each_entry(ns, ldlm_namespace_list(client), list_for_each_entry()
1200 if (ns->ns_appetite != LDLM_NAMESPACE_MODEST) list_for_each_entry()
1203 l = ldlm_pool_granted(&ns->ns_pool); list_for_each_entry()
1212 ldlm_pool_setup(&ns->ns_pool, l); list_for_each_entry()
1230 list_for_each_entry(ns, ldlm_namespace_list(client), list_for_each_entry()
1232 if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY) list_for_each_entry()
1252 ldlm_pool_setup(&ns->ns_pool, l); list_for_each_entry()
1263 * Lock the list, get first @ns in the list, getref, move it
1265 * calling recalc under @ns lock what is really good as we get
1274 ns = ldlm_namespace_first_locked(client);
1276 if (ns_old == ns) { /* Full pass complete */
1291 if (ldlm_ns_empty(ns)) {
1292 ldlm_namespace_move_to_inactive_locked(ns, client);
1298 ns_old = ns;
1300 spin_lock(&ns->ns_lock);
1302 * skip ns which is being freed, and we don't want to increase
1305 if (ns->ns_stopping) {
1309 ldlm_namespace_get(ns);
1311 spin_unlock(&ns->ns_lock);
1313 ldlm_namespace_move_to_active_locked(ns, client);
1320 int ttime = ldlm_pool_recalc(&ns->ns_pool);
1325 ldlm_namespace_put(ns);
H A Dldlm_lock.c155 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg) ldlm_register_intent() argument
157 ns->ns_policy = arg; ldlm_register_intent()
229 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lock_remove_from_lru_nolock() local
233 LASSERT(ns->ns_nr_unused > 0); ldlm_lock_remove_from_lru_nolock()
234 ns->ns_nr_unused--; ldlm_lock_remove_from_lru_nolock()
245 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lock_remove_from_lru() local
253 spin_lock(&ns->ns_lock); ldlm_lock_remove_from_lru()
255 spin_unlock(&ns->ns_lock); ldlm_lock_remove_from_lru()
264 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lock_add_to_lru_nolock() local
269 list_add_tail(&lock->l_lru, &ns->ns_unused_list); ldlm_lock_add_to_lru_nolock()
272 LASSERT(ns->ns_nr_unused >= 0); ldlm_lock_add_to_lru_nolock()
273 ns->ns_nr_unused++; ldlm_lock_add_to_lru_nolock()
282 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lock_add_to_lru() local
284 spin_lock(&ns->ns_lock); ldlm_lock_add_to_lru()
286 spin_unlock(&ns->ns_lock); ldlm_lock_add_to_lru()
295 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lock_touch_in_lru() local
302 spin_lock(&ns->ns_lock); ldlm_lock_touch_in_lru()
307 spin_unlock(&ns->ns_lock); ldlm_lock_touch_in_lru()
484 int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, ldlm_lock_change_resource() argument
491 LASSERT(ns_is_client(ns)); ldlm_lock_change_resource()
509 newres = ldlm_resource_get(ns, NULL, new_resid, type, 1); ldlm_lock_change_resource()
792 struct ldlm_namespace *ns; ldlm_lock_decref_internal() local
796 ns = ldlm_lock_to_ns(lock); ldlm_lock_decref_internal()
825 ldlm_bl_to_thread_lock(ns, NULL, lock) != 0) ldlm_lock_decref_internal()
826 ldlm_handle_bl_callback(ns, NULL, lock); ldlm_lock_decref_internal()
827 } else if (ns_is_client(ns) && ldlm_lock_decref_internal()
846 !ns_connect_lru_resize(ns)) ldlm_lock_decref_internal()
847 ldlm_cancel_lru(ns, 0, LCF_ASYNC, 0); ldlm_lock_decref_internal()
1203 * If 'ns' is NULL, then lockh describes an existing lock that we want to look
1225 ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, ldlm_lock_match() argument
1234 if (ns == NULL) { ldlm_lock_match()
1238 ns = ldlm_lock_to_ns(old_lock); ldlm_lock_match()
1244 res = ldlm_resource_get(ns, NULL, res_id, type, 0); ldlm_lock_match()
1341 LDLM_DEBUG_NOLOCK("not matched ns %p type %u mode %u res %llu/%llu (%llu %llu)", ldlm_lock_match()
1342 ns, type, mode, res_id->name[0], ldlm_lock_match()
1490 struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, ldlm_lock_create() argument
1501 res = ldlm_resource_get(ns, NULL, res_id, type, 1); ldlm_lock_create()
1513 if (ns_is_server(ns)) ldlm_lock_create()
1557 ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, ldlm_lock_enqueue() argument
1570 && !local && ns->ns_policy) { ldlm_lock_enqueue()
1571 rc = ns->ns_policy(ns, lockp, cookie, lock->l_req_mode, *flags, ldlm_lock_enqueue()
1805 int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, ldlm_run_ast_work() argument
1847 arg->set = ptlrpc_prep_fcset(ns->ns_max_parallel_ast ? : UINT_MAX, ldlm_run_ast_work()
1885 void ldlm_reprocess_all_ns(struct ldlm_namespace *ns) ldlm_reprocess_all_ns() argument
1887 if (ns != NULL) { ldlm_reprocess_all_ns()
1888 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_reprocess_all_ns()
1952 struct ldlm_namespace *ns; ldlm_lock_cancel() local
1957 ns = ldlm_res_to_ns(res); ldlm_lock_cancel()
1981 ldlm_pool_del(&ns->ns_pool, lock); ldlm_lock_cancel()
2106 struct ldlm_namespace *ns; ldlm_lock_convert() local
2129 ns = ldlm_res_to_ns(res); ldlm_lock_convert()
2150 ldlm_pool_del(&ns->ns_pool, lock); ldlm_lock_convert()
2176 ldlm_run_ast_work(ns, &rpc_list, LDLM_WORK_CP_AST); ldlm_lock_convert()
2230 " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", _ldlm_lock_debug()
2246 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", _ldlm_lock_debug()
2266 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", _ldlm_lock_debug()
2285 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", _ldlm_lock_debug()
2304 " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", _ldlm_lock_debug()
H A Dldlm_request.c395 int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, ldlm_cli_enqueue_local() argument
414 if (unlikely(ns_is_client(ns))) { ldlm_cli_enqueue_local()
419 lock = ldlm_lock_create(ns, res_id, type, mode, &cbs, data, lvb_len, ldlm_cli_enqueue_local()
442 err = ldlm_lock_enqueue(ns, &lock, policy, flags); ldlm_cli_enqueue_local()
460 static void failed_lock_cleanup(struct ldlm_namespace *ns, failed_lock_cleanup() argument
511 struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; ldlm_cli_enqueue_fini() local
619 rc = ldlm_lock_change_resource(ns, lock, ldlm_cli_enqueue_fini()
670 rc = ldlm_lock_enqueue(ns, &lock, NULL, flags); ldlm_cli_enqueue_fini()
690 failed_lock_cleanup(ns, lock, mode); ldlm_cli_enqueue_fini()
748 struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; ldlm_prep_elc_req() local
757 if (ns_connect_cancelset(ns)) { ldlm_prep_elc_req()
762 flags = ns_connect_lru_resize(ns) ? ldlm_prep_elc_req()
764 to_free = !ns_connect_lru_resize(ns) && ldlm_prep_elc_req()
771 count += ldlm_cancel_lru_local(ns, cancels, to_free, ldlm_prep_elc_req()
787 if (ns_connect_cancelset(ns)) { ldlm_prep_elc_req()
854 struct ldlm_namespace *ns; ldlm_cli_enqueue() local
864 ns = exp->exp_obd->obd_namespace; ldlm_cli_enqueue()
879 lock = ldlm_lock_create(ns, res_id, einfo->ei_type, ldlm_cli_enqueue()
909 failed_lock_cleanup(ns, lock, einfo->ei_mode); ldlm_cli_enqueue()
1313 struct ldlm_namespace *ns; ldlm_cli_cancel() local
1342 ns = ldlm_lock_to_ns(lock); ldlm_cli_cancel()
1343 flags = ns_connect_lru_resize(ns) ? ldlm_cli_cancel()
1345 count += ldlm_cancel_lru_local(ns, &cancels, 0, avail - 1, ldlm_cli_cancel()
1408 static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, ldlm_cancel_no_wait_policy() argument
1414 ldlm_cancel_for_recovery cb = ns->ns_cancel_for_recovery; ldlm_cancel_no_wait_policy()
1444 static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, ldlm_cancel_lrur_policy() argument
1450 struct ldlm_pool *pl = &ns->ns_pool; ldlm_cancel_lrur_policy()
1483 static ldlm_policy_res_t ldlm_cancel_passed_policy(struct ldlm_namespace *ns, ldlm_cancel_passed_policy() argument
1503 static ldlm_policy_res_t ldlm_cancel_aged_policy(struct ldlm_namespace *ns, ldlm_cancel_aged_policy() argument
1511 cfs_time_add(lock->l_last_used, ns->ns_max_age))) ? ldlm_cancel_aged_policy()
1524 static ldlm_policy_res_t ldlm_cancel_default_policy(struct ldlm_namespace *ns, ldlm_cancel_default_policy() argument
1540 ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags) ldlm_cancel_lru_policy() argument
1545 if (ns_connect_lru_resize(ns)) { ldlm_cancel_lru_policy()
1594 static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, ldlm_prepare_lru_list() argument
1602 spin_lock(&ns->ns_lock); ldlm_prepare_lru_list()
1603 unused = ns->ns_nr_unused; ldlm_prepare_lru_list()
1606 if (!ns_connect_lru_resize(ns)) ldlm_prepare_lru_list()
1607 count += unused - ns->ns_max_unused; ldlm_prepare_lru_list()
1609 pf = ldlm_cancel_lru_policy(ns, flags); ldlm_prepare_lru_list()
1612 while (!list_empty(&ns->ns_unused_list)) { ldlm_prepare_lru_list()
1623 list_for_each_entry_safe(lock, next, &ns->ns_unused_list, ldlm_prepare_lru_list()
1640 if (&lock->l_lru == &ns->ns_unused_list) ldlm_prepare_lru_list()
1644 spin_unlock(&ns->ns_lock); ldlm_prepare_lru_list()
1660 result = pf(ns, lock, unused, added, count); ldlm_prepare_lru_list()
1665 spin_lock(&ns->ns_lock); ldlm_prepare_lru_list()
1672 spin_lock(&ns->ns_lock); ldlm_prepare_lru_list()
1688 spin_lock(&ns->ns_lock); ldlm_prepare_lru_list()
1718 spin_lock(&ns->ns_lock); ldlm_prepare_lru_list()
1722 spin_unlock(&ns->ns_lock); ldlm_prepare_lru_list()
1726 int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, ldlm_cancel_lru_local() argument
1732 added = ldlm_prepare_lru_list(ns, cancels, count, max, flags); ldlm_cancel_lru_local()
1746 int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_cancel_lru() argument
1755 count = ldlm_prepare_lru_list(ns, &cancels, nr, 0, flags); ldlm_cancel_lru()
1756 rc = ldlm_bl_to_thread_list(ns, NULL, &cancels, count, cancel_flags); ldlm_cancel_lru()
1881 int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, ldlm_cli_cancel_unused_resource() argument
1893 res = ldlm_resource_get(ns, NULL, res_id, 0, 0); ldlm_cli_cancel_unused_resource()
1939 int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, ldlm_cli_cancel_unused() argument
1948 if (ns == NULL) ldlm_cli_cancel_unused()
1952 return ldlm_cli_cancel_unused_resource(ns, res_id, NULL, ldlm_cli_cancel_unused()
1956 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_cli_cancel_unused()
2030 void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_namespace_foreach() argument
2039 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_namespace_foreach()
2050 int ldlm_resource_iterate(struct ldlm_namespace *ns, ldlm_resource_iterate() argument
2057 if (ns == NULL) { ldlm_resource_iterate()
2062 res = ldlm_resource_get(ns, NULL, res_id, 0, 0); ldlm_resource_iterate()
2241 static void ldlm_cancel_unused_locks_for_replay(struct ldlm_namespace *ns) ldlm_cancel_unused_locks_for_replay() argument
2247 ldlm_ns_name(ns), ns->ns_nr_unused); ldlm_cancel_unused_locks_for_replay()
2252 canceled = ldlm_cancel_lru_local(ns, &cancels, ns->ns_nr_unused, 0, ldlm_cancel_unused_locks_for_replay()
2256 canceled, ldlm_ns_name(ns)); ldlm_cancel_unused_locks_for_replay()
2261 struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; ldlm_replay_locks() local
2276 ldlm_cancel_unused_locks_for_replay(ns); ldlm_replay_locks()
2278 ldlm_namespace_foreach(ns, ldlm_chain_lock_for_replay, &list); ldlm_replay_locks()
H A Dldlm_lockd.c142 void ldlm_handle_bl_callback(struct ldlm_namespace *ns, ldlm_handle_bl_callback() argument
181 struct ldlm_namespace *ns, ldlm_handle_cp_callback()
269 rc = ldlm_lock_change_resource(ns, lock, ldlm_handle_cp_callback()
306 ldlm_run_ast_work(ns, &ast_list, LDLM_WORK_CP_AST); ldlm_handle_cp_callback()
330 struct ldlm_namespace *ns, ldlm_handle_gl_callback()
355 if (ldlm_bl_to_thread_lock(ns, NULL, lock)) ldlm_handle_gl_callback()
356 ldlm_handle_bl_callback(ns, NULL, lock); ldlm_handle_gl_callback()
405 struct ldlm_namespace *ns, init_blwi()
417 blwi->blwi_ns = ns; init_blwi()
439 static int ldlm_bl_to_thread(struct ldlm_namespace *ns, ldlm_bl_to_thread() argument
454 init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); ldlm_bl_to_thread()
464 init_blwi(&blwi, ns, ld, cancels, count, lock, cancel_flags); ldlm_bl_to_thread()
470 int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, ldlm_bl_to_thread_lock() argument
473 return ldlm_bl_to_thread(ns, ld, lock, NULL, 0, LCF_ASYNC); ldlm_bl_to_thread_lock()
476 int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, ldlm_bl_to_thread_list() argument
480 return ldlm_bl_to_thread(ns, ld, NULL, cancels, count, cancel_flags); ldlm_bl_to_thread_list()
560 struct ldlm_namespace *ns; ldlm_callback_handler() local
617 ns = req->rq_export->exp_obd->obd_namespace; ldlm_callback_handler()
618 LASSERT(ns != NULL); ldlm_callback_handler()
700 if (ldlm_bl_to_thread_lock(ns, &dlm_req->lock_desc, lock)) ldlm_callback_handler()
701 ldlm_handle_bl_callback(ns, &dlm_req->lock_desc, lock); ldlm_callback_handler()
707 ldlm_handle_cp_callback(req, ns, dlm_req, lock); ldlm_callback_handler()
712 ldlm_handle_gl_callback(req, ns, dlm_req, lock); ldlm_callback_handler()
180 ldlm_handle_cp_callback(struct ptlrpc_request *req, struct ldlm_namespace *ns, struct ldlm_request *dlm_req, struct ldlm_lock *lock) ldlm_handle_cp_callback() argument
329 ldlm_handle_gl_callback(struct ptlrpc_request *req, struct ldlm_namespace *ns, struct ldlm_request *dlm_req, struct ldlm_lock *lock) ldlm_handle_gl_callback() argument
404 init_blwi(struct ldlm_bl_work_item *blwi, struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, struct ldlm_lock *lock, ldlm_cancel_flags_t cancel_flags) init_blwi() argument
/linux-4.1.27/include/linux/
H A Dpid_namespace.h47 struct ns_common ns; member in struct:pid_namespace
55 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) get_pid_ns() argument
57 if (ns != &init_pid_ns) get_pid_ns()
58 kref_get(&ns->kref); get_pid_ns()
59 return ns; get_pid_ns()
63 struct user_namespace *user_ns, struct pid_namespace *ns);
66 extern void put_pid_ns(struct pid_namespace *ns);
71 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) get_pid_ns() argument
73 return ns; get_pid_ns()
77 struct user_namespace *user_ns, struct pid_namespace *ns) copy_pid_ns()
80 ns = ERR_PTR(-EINVAL); copy_pid_ns()
81 return ns; copy_pid_ns()
84 static inline void put_pid_ns(struct pid_namespace *ns) put_pid_ns() argument
88 static inline void zap_pid_ns_processes(struct pid_namespace *ns) zap_pid_ns_processes() argument
76 copy_pid_ns(unsigned long flags, struct user_namespace *user_ns, struct pid_namespace *ns) copy_pid_ns() argument
H A Dproc_ns.h17 void (*put)(struct ns_common *ns);
18 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
41 extern int pid_ns_prepare_proc(struct pid_namespace *ns);
42 extern void pid_ns_release_proc(struct pid_namespace *ns);
48 static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } pid_ns_release_proc() argument
49 static inline void pid_ns_release_proc(struct pid_namespace *ns) {} pid_ns_release_proc() argument
60 static inline int ns_alloc_inum(struct ns_common *ns) ns_alloc_inum() argument
62 atomic_long_set(&ns->stashed, 0); ns_alloc_inum()
63 return proc_alloc_inum(&ns->inum); ns_alloc_inum()
66 #define ns_free_inum(ns) proc_free_inum((ns)->inum)
H A Duser_namespace.h34 struct ns_common ns; member in struct:user_namespace
48 static inline struct user_namespace *get_user_ns(struct user_namespace *ns) get_user_ns() argument
50 if (ns) get_user_ns()
51 atomic_inc(&ns->count); get_user_ns()
52 return ns; get_user_ns()
57 extern void free_user_ns(struct user_namespace *ns);
59 static inline void put_user_ns(struct user_namespace *ns) put_user_ns() argument
61 if (ns && atomic_dec_and_test(&ns->count)) put_user_ns()
62 free_user_ns(ns); put_user_ns()
74 extern bool userns_may_setgroups(const struct user_namespace *ns);
77 static inline struct user_namespace *get_user_ns(struct user_namespace *ns) get_user_ns() argument
95 static inline void put_user_ns(struct user_namespace *ns) put_user_ns() argument
99 static inline bool userns_may_setgroups(const struct user_namespace *ns) userns_may_setgroups() argument
H A Dipc_namespace.h49 /* # queues in this ns, protected by mq_lock */
59 /* user_ns which owns the ipc ns */
62 struct ns_common ns; member in struct:ipc_namespace
71 extern void shm_destroy_orphaned(struct ipc_namespace *ns);
73 static inline void shm_destroy_orphaned(struct ipc_namespace *ns) {} shm_destroy_orphaned() argument
77 extern int mq_init_ns(struct ipc_namespace *ns); shm_destroy_orphaned()
112 static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; } mq_init_ns() argument
117 struct user_namespace *user_ns, struct ipc_namespace *ns); mq_init_ns()
119 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) get_ipc_ns() argument
121 if (ns) get_ipc_ns()
122 atomic_inc(&ns->count); get_ipc_ns()
123 return ns; get_ipc_ns()
126 extern void put_ipc_ns(struct ipc_namespace *ns);
129 struct user_namespace *user_ns, struct ipc_namespace *ns) copy_ipcs()
134 return ns; copy_ipcs()
137 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) get_ipc_ns() argument
139 return ns; get_ipc_ns()
142 static inline void put_ipc_ns(struct ipc_namespace *ns) put_ipc_ns() argument
128 copy_ipcs(unsigned long flags, struct user_namespace *user_ns, struct ipc_namespace *ns) copy_ipcs() argument
H A Dutsname.h27 struct ns_common ns; member in struct:uts_namespace
32 static inline void get_uts_ns(struct uts_namespace *ns) get_uts_ns() argument
34 kref_get(&ns->kref); get_uts_ns()
41 static inline void put_uts_ns(struct uts_namespace *ns) put_uts_ns() argument
43 kref_put(&ns->kref, free_uts_ns); put_uts_ns()
46 static inline void get_uts_ns(struct uts_namespace *ns) get_uts_ns() argument
50 static inline void put_uts_ns(struct uts_namespace *ns) put_uts_ns() argument
H A Dnsproxy.h68 void free_nsproxy(struct nsproxy *ns);
73 static inline void put_nsproxy(struct nsproxy *ns) put_nsproxy() argument
75 if (atomic_dec_and_test(&ns->count)) { put_nsproxy()
76 free_nsproxy(ns); put_nsproxy()
80 static inline void get_nsproxy(struct nsproxy *ns) get_nsproxy() argument
82 atomic_inc(&ns->count); get_nsproxy()
H A Dmnt_namespace.h11 extern void put_mnt_ns(struct mnt_namespace *ns);
H A Dsched_clock.h2 * sched_clock.h: support for extending counters to full 64-bit ns counter
H A Dpid.h47 * find_pid_ns() using the int nr and struct pid_namespace *ns.
53 struct pid_namespace *ns; member in struct:upid
110 extern struct pid *find_pid_ns(int nr, struct pid_namespace *ns);
120 extern struct pid *alloc_pid(struct pid_namespace *ns);
122 extern void disable_pid_allocation(struct pid_namespace *ns);
132 * the resulting NULL pid-ns.
136 struct pid_namespace *ns = NULL; ns_of_pid() local
138 ns = pid->numbers[pid->level].ns; ns_of_pid()
139 return ns; ns_of_pid()
159 * pid_nr_ns() : id seen from the ns specified.
172 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
H A Dprojid.h57 static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid) kprojid_has_mapping() argument
59 return from_kprojid(ns, projid) != (projid_t)-1; kprojid_has_mapping()
82 static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid) kprojid_has_mapping() argument
H A Duidgid.h130 static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) kuid_has_mapping() argument
132 return from_kuid(ns, uid) != (uid_t) -1; kuid_has_mapping()
135 static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) kgid_has_mapping() argument
137 return from_kgid(ns, gid) != (gid_t) -1; kgid_has_mapping()
178 static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) kuid_has_mapping() argument
183 static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) kgid_has_mapping() argument
H A Damifdreg.h44 #define ADK_PRECOMP0 (1<<13) /* 00=none, 01=140ns, 10=280ns, 11=500ns */
H A Dkernfs.h123 const void *ns; /* namespace tag */ member in struct:kernfs_node
124 unsigned int hash; /* ns + name hash */
261 * Test whether namespace filtering is enabled for the children of @ns.
275 const char *name, const void *ns);
288 void *priv, const void *ns);
295 void *priv, const void *ns,
306 const void *ns);
315 bool *new_sb_created, const void *ns);
317 struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns);
346 const void *ns) kernfs_find_and_get_ns()
367 umode_t mode, void *priv, const void *ns) kernfs_create_dir_ns()
373 void *priv, const void *ns, struct lock_class_key *key) __kernfs_create_file()
389 const char *name, const void *ns) kernfs_remove_by_name_ns()
409 bool *new_sb_created, const void *ns) kernfs_mount_ns()
434 void *priv, const void *ns) kernfs_create_file_ns()
441 return __kernfs_create_file(parent, name, mode, size, ops, priv, ns, kernfs_create_file_ns()
345 kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns) kernfs_find_and_get_ns() argument
366 kernfs_create_dir_ns(struct kernfs_node *parent, const char *name, umode_t mode, void *priv, const void *ns) kernfs_create_dir_ns() argument
371 __kernfs_create_file(struct kernfs_node *parent, const char *name, umode_t mode, loff_t size, const struct kernfs_ops *ops, void *priv, const void *ns, struct lock_class_key *key) __kernfs_create_file() argument
388 kernfs_remove_by_name_ns(struct kernfs_node *kn, const char *name, const void *ns) kernfs_remove_by_name_ns() argument
407 kernfs_mount_ns(struct file_system_type *fs_type, int flags, struct kernfs_root *root, unsigned long magic, bool *new_sb_created, const void *ns) kernfs_mount_ns() argument
432 kernfs_create_file_ns(struct kernfs_node *parent, const char *name, umode_t mode, loff_t size, const struct kernfs_ops *ops, void *priv, const void *ns) kernfs_create_file_ns() argument
H A Dnvme.h144 static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector) nvme_block_nr() argument
146 return (sector >> (ns->lba_shift - 9)); nvme_block_nr()
163 int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns);
175 int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr);
176 int nvme_sg_io32(struct nvme_ns *ns, unsigned long arg);
H A Dtime64.h177 * @ns: unsigned nanoseconds value to be added
182 static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns) timespec64_add_ns() argument
184 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns); timespec64_add_ns()
185 a->tv_nsec = ns; timespec64_add_ns()
H A Dtimecounter.h82 u64 ns = (u64) cycles; cyclecounter_cyc2ns() local
84 ns = (ns * cc->mult) + *frac; cyclecounter_cyc2ns()
85 *frac = ns & mask; cyclecounter_cyc2ns()
86 return ns >> cc->shift; cyclecounter_cyc2ns()
H A Dcapability.h211 struct user_namespace *ns, int cap);
214 struct user_namespace *ns, int cap);
216 extern bool ns_capable(struct user_namespace *ns, int cap);
223 struct user_namespace *ns, int cap) has_ns_capability()
232 struct user_namespace *ns, int cap) has_ns_capability_noaudit()
240 static inline bool ns_capable(struct user_namespace *ns, int cap) ns_capable() argument
246 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
222 has_ns_capability(struct task_struct *t, struct user_namespace *ns, int cap) has_ns_capability() argument
231 has_ns_capability_noaudit(struct task_struct *t, struct user_namespace *ns, int cap) has_ns_capability_noaudit() argument
H A Dktime.h178 s64 ns = kt.tv64; ktime_divns() local
179 u64 tmp = ns < 0 ? -ns : ns; ktime_divns()
182 return ns < 0 ? -tmp : tmp; ktime_divns()
283 static inline ktime_t ns_to_ktime(u64 ns)
287 return ktime_add_ns(ktime_zero, ns);
H A Dclocksource.h125 /* khz = cyc/(Million ns) clocksource_khz2mult()
126 * mult/2^shift = ns/cyc clocksource_khz2mult()
127 * mult = ns/cyc * 2^shift clocksource_khz2mult()
151 /* hz = cyc/(Billion ns) clocksource_hz2mult()
152 * mult/2^shift = ns/cyc clocksource_hz2mult()
153 * mult = ns/cyc * 2^shift clocksource_hz2mult()
H A Dtime.h228 * @ns: unsigned nanoseconds value to be added
233 static __always_inline void timespec_add_ns(struct timespec *a, u64 ns) timespec_add_ns() argument
235 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns); timespec_add_ns()
236 a->tv_nsec = ns; timespec_add_ns()
H A Dkobject_ns.h58 void kobj_ns_drop(enum kobj_ns_type type, void *ns);
H A Dsysfs.h206 int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
220 const void *ns);
226 const void *ns);
283 static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) sysfs_create_dir_ns() argument
318 const void *ns) sysfs_create_file_ns()
337 const void *ns) sysfs_remove_file_ns()
382 const char *new_name, const void *ns) sysfs_rename_link_ns()
316 sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr, const void *ns) sysfs_create_file_ns() argument
335 sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, const void *ns) sysfs_remove_file_ns() argument
380 sysfs_rename_link_ns(struct kobject *k, struct kobject *t, const char *old_name, const char *new_name, const void *ns) sysfs_rename_link_ns() argument
/linux-4.1.27/drivers/mtd/nand/
H A Dnandsim.c203 #define NS_IS_INITIALIZED(ns) ((ns)->geom.totsz != 0)
206 #define NS_STATUS_OK(ns) (NAND_STATUS_READY | (NAND_STATUS_WP * ((ns)->lines.wp == 0)))
209 #define NS_STATUS_FAILED(ns) (NAND_STATUS_FAIL | NS_STATUS_OK(ns))
212 #define NS_RAW_OFFSET(ns) \
213 (((ns)->regs.row * (ns)->geom.pgszoob) + (ns)->regs.column)
216 #define NS_RAW_OFFSET_OOB(ns) (NS_RAW_OFFSET(ns) + ns->geom.pgsz)
560 static void nandsim_debugfs_remove(struct nandsim *ns) nandsim_debugfs_remove() argument
563 debugfs_remove_recursive(ns->dbg.dfs_root); nandsim_debugfs_remove()
572 static int alloc_device(struct nandsim *ns) alloc_device() argument
591 ns->pages_written = vzalloc(BITS_TO_LONGS(ns->geom.pgnum) * alloc_device()
593 if (!ns->pages_written) { alloc_device()
598 ns->file_buf = kmalloc(ns->geom.pgszoob, GFP_KERNEL); alloc_device()
599 if (!ns->file_buf) { alloc_device()
604 ns->cfile = cfile; alloc_device()
608 ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); alloc_device()
609 if (!ns->pages) { alloc_device()
613 for (i = 0; i < ns->geom.pgnum; i++) { alloc_device()
614 ns->pages[i].byte = NULL; alloc_device()
616 ns->nand_pages_slab = kmem_cache_create("nandsim", alloc_device()
617 ns->geom.pgszoob, 0, 0, NULL); alloc_device()
618 if (!ns->nand_pages_slab) { alloc_device()
626 vfree(ns->pages_written); alloc_device()
635 static void free_device(struct nandsim *ns) free_device() argument
639 if (ns->cfile) { free_device()
640 kfree(ns->file_buf); free_device()
641 vfree(ns->pages_written); free_device()
642 filp_close(ns->cfile, NULL); free_device()
646 if (ns->pages) { free_device()
647 for (i = 0; i < ns->geom.pgnum; i++) { free_device()
648 if (ns->pages[i].byte) free_device()
649 kmem_cache_free(ns->nand_pages_slab, free_device()
650 ns->pages[i].byte); free_device()
652 kmem_cache_destroy(ns->nand_pages_slab); free_device()
653 vfree(ns->pages); free_device()
670 struct nandsim *ns = chip->priv; init_nandsim() local
675 if (NS_IS_INITIALIZED(ns)) { init_nandsim()
684 ns->busw = chip->options & NAND_BUSWIDTH_16 ? 16 : 8; init_nandsim()
685 ns->geom.totsz = mtd->size; init_nandsim()
686 ns->geom.pgsz = mtd->writesize; init_nandsim()
687 ns->geom.oobsz = mtd->oobsize; init_nandsim()
688 ns->geom.secsz = mtd->erasesize; init_nandsim()
689 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; init_nandsim()
690 ns->geom.pgnum = div_u64(ns->geom.totsz, ns->geom.pgsz); init_nandsim()
691 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz; init_nandsim()
692 ns->geom.secshift = ffs(ns->geom.secsz) - 1; init_nandsim()
693 ns->geom.pgshift = chip->page_shift; init_nandsim()
694 ns->geom.pgsec = ns->geom.secsz / ns->geom.pgsz; init_nandsim()
695 ns->geom.secszoob = ns->geom.secsz + ns->geom.oobsz * ns->geom.pgsec; init_nandsim()
696 ns->options = 0; init_nandsim()
698 if (ns->geom.pgsz == 512) { init_nandsim()
699 ns->options |= OPT_PAGE512; init_nandsim()
700 if (ns->busw == 8) init_nandsim()
701 ns->options |= OPT_PAGE512_8BIT; init_nandsim()
702 } else if (ns->geom.pgsz == 2048) { init_nandsim()
703 ns->options |= OPT_PAGE2048; init_nandsim()
704 } else if (ns->geom.pgsz == 4096) { init_nandsim()
705 ns->options |= OPT_PAGE4096; init_nandsim()
707 NS_ERR("init_nandsim: unknown page size %u\n", ns->geom.pgsz); init_nandsim()
711 if (ns->options & OPT_SMALLPAGE) { init_nandsim()
712 if (ns->geom.totsz <= (32 << 20)) { init_nandsim()
713 ns->geom.pgaddrbytes = 3; init_nandsim()
714 ns->geom.secaddrbytes = 2; init_nandsim()
716 ns->geom.pgaddrbytes = 4; init_nandsim()
717 ns->geom.secaddrbytes = 3; init_nandsim()
720 if (ns->geom.totsz <= (128 << 20)) { init_nandsim()
721 ns->geom.pgaddrbytes = 4; init_nandsim()
722 ns->geom.secaddrbytes = 2; init_nandsim()
724 ns->geom.pgaddrbytes = 5; init_nandsim()
725 ns->geom.secaddrbytes = 3; init_nandsim()
730 if (parts_num > ARRAY_SIZE(ns->partitions)) { init_nandsim()
735 remains = ns->geom.totsz; init_nandsim()
738 uint64_t part_sz = (uint64_t)parts[i] * ns->geom.secsz; init_nandsim()
745 ns->partitions[i].name = get_partition_name(i); init_nandsim()
746 ns->partitions[i].offset = next_offset; init_nandsim()
747 ns->partitions[i].size = part_sz; init_nandsim()
748 next_offset += ns->partitions[i].size; init_nandsim()
749 remains -= ns->partitions[i].size; init_nandsim()
751 ns->nbparts = parts_num; init_nandsim()
753 if (parts_num + 1 > ARRAY_SIZE(ns->partitions)) { init_nandsim()
758 ns->partitions[i].name = get_partition_name(i); init_nandsim()
759 ns->partitions[i].offset = next_offset; init_nandsim()
760 ns->partitions[i].size = remains; init_nandsim()
761 ns->nbparts += 1; init_nandsim()
764 if (ns->busw == 16) init_nandsim()
768 (unsigned long long)ns->geom.totsz >> 20); init_nandsim()
769 printk("page size: %u bytes\n", ns->geom.pgsz); init_nandsim()
770 printk("OOB area size: %u bytes\n", ns->geom.oobsz); init_nandsim()
771 printk("sector size: %u KiB\n", ns->geom.secsz >> 10); init_nandsim()
772 printk("pages number: %u\n", ns->geom.pgnum); init_nandsim()
773 printk("pages per sector: %u\n", ns->geom.pgsec); init_nandsim()
774 printk("bus width: %u\n", ns->busw); init_nandsim()
775 printk("bits in sector size: %u\n", ns->geom.secshift); init_nandsim()
776 printk("bits in page size: %u\n", ns->geom.pgshift); init_nandsim()
777 printk("bits in OOB size: %u\n", ffs(ns->geom.oobsz) - 1); init_nandsim()
779 (unsigned long long)ns->geom.totszoob >> 10); init_nandsim()
780 printk("page address bytes: %u\n", ns->geom.pgaddrbytes); init_nandsim()
781 printk("sector address bytes: %u\n", ns->geom.secaddrbytes); init_nandsim()
782 printk("options: %#x\n", ns->options); init_nandsim()
784 if ((ret = alloc_device(ns)) != 0) init_nandsim()
788 ns->buf.byte = kmalloc(ns->geom.pgszoob, GFP_KERNEL); init_nandsim()
789 if (!ns->buf.byte) { init_nandsim()
791 ns->geom.pgszoob); init_nandsim()
795 memset(ns->buf.byte, 0xFF, ns->geom.pgszoob); init_nandsim()
800 free_device(ns); init_nandsim()
808 static void free_nandsim(struct nandsim *ns) free_nandsim() argument
810 kfree(ns->buf.byte); free_nandsim()
811 free_device(ns); free_nandsim()
816 static int parse_badblocks(struct nandsim *ns, struct mtd_info *mtd) parse_badblocks() argument
833 offset = (loff_t)erase_block_no * ns->geom.secsz; parse_badblocks()
1177 static inline void accept_addr_byte(struct nandsim *ns, u_char bt) accept_addr_byte() argument
1181 if (ns->regs.count < (ns->geom.pgaddrbytes - ns->geom.secaddrbytes)) accept_addr_byte()
1182 ns->regs.column |= (byte << 8 * ns->regs.count); accept_addr_byte()
1184 ns->regs.row |= (byte << 8 * (ns->regs.count - accept_addr_byte()
1185 ns->geom.pgaddrbytes + accept_addr_byte()
1186 ns->geom.secaddrbytes)); accept_addr_byte()
1195 static inline void switch_to_ready_state(struct nandsim *ns, u_char status) switch_to_ready_state() argument
1199 ns->state = STATE_READY; switch_to_ready_state()
1200 ns->nxstate = STATE_UNKNOWN; switch_to_ready_state()
1201 ns->op = NULL; switch_to_ready_state()
1202 ns->npstates = 0; switch_to_ready_state()
1203 ns->stateidx = 0; switch_to_ready_state()
1204 ns->regs.num = 0; switch_to_ready_state()
1205 ns->regs.count = 0; switch_to_ready_state()
1206 ns->regs.off = 0; switch_to_ready_state()
1207 ns->regs.row = 0; switch_to_ready_state()
1208 ns->regs.column = 0; switch_to_ready_state()
1209 ns->regs.status = status; switch_to_ready_state()
1218 * correspondent states chain. In this case ns->npstates = 0;
1222 * case the ns->pstates[] array contains previous states.
1226 * ns->pstates[0], ... ns->pstates[ns->npstates], ns->state
1229 * ns->ops, ns->state, ns->nxstate are initialized, ns->npstate is
1233 * ns->pstates.
1239 * ns->pstates[0], ... ns->pstates[ns->npstates], <address input>
1254 static int find_operation(struct nandsim *ns, uint32_t flag) find_operation() argument
1263 if (!(ns->options & ops[i].reqopts)) find_operation()
1268 if (!(ops[i].states[ns->npstates] & STATE_ADDR_MASK)) find_operation()
1271 if (NS_STATE(ns->state) != NS_STATE(ops[i].states[ns->npstates])) find_operation()
1275 for (j = 0; j < ns->npstates; j++) find_operation()
1276 if (NS_STATE(ops[i].states[j]) != NS_STATE(ns->pstates[j]) find_operation()
1277 && (ns->options & ops[idx].reqopts)) { find_operation()
1290 ns->op = &ops[idx].states[0]; find_operation()
1297 * state must be the next state (ns->nxstate). find_operation()
1299 ns->stateidx = ns->npstates - 1; find_operation()
1301 ns->stateidx = ns->npstates; find_operation()
1303 ns->npstates = 0; find_operation()
1304 ns->state = ns->op[ns->stateidx]; find_operation()
1305 ns->nxstate = ns->op[ns->stateidx + 1]; find_operation()
1307 idx, get_state_name(ns->state), get_state_name(ns->nxstate)); find_operation()
1313 if (ns->npstates != 0) { find_operation()
1315 get_state_name(ns->state)); find_operation()
1316 ns->npstates = 0; find_operation()
1317 return find_operation(ns, 0); find_operation()
1321 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); find_operation()
1333 ns->pstates[ns->npstates++] = ns->state; find_operation()
1338 static void put_pages(struct nandsim *ns) put_pages() argument
1342 for (i = 0; i < ns->held_cnt; i++) put_pages()
1343 page_cache_release(ns->held_pages[i]); put_pages()
1347 static int get_pages(struct nandsim *ns, struct file *file, size_t count, loff_t pos) get_pages() argument
1357 ns->held_cnt = 0; get_pages()
1367 put_pages(ns); get_pages()
1372 ns->held_pages[ns->held_cnt++] = page; get_pages()
1391 static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) read_file() argument
1396 err = get_pages(ns, file, count, pos); read_file()
1402 put_pages(ns); read_file()
1406 static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) write_file() argument
1411 err = get_pages(ns, file, count, pos); write_file()
1417 put_pages(ns); write_file()
1424 static inline union ns_mem *NS_GET_PAGE(struct nandsim *ns) NS_GET_PAGE() argument
1426 return &(ns->pages[ns->regs.row]); NS_GET_PAGE()
1432 static inline u_char *NS_PAGE_BYTE_OFF(struct nandsim *ns) NS_PAGE_BYTE_OFF() argument
1434 return NS_GET_PAGE(ns)->byte + ns->regs.column + ns->regs.off; NS_PAGE_BYTE_OFF()
1437 static int do_read_error(struct nandsim *ns, int num) do_read_error() argument
1439 unsigned int page_no = ns->regs.row; do_read_error()
1442 prandom_bytes(ns->buf.byte, num); do_read_error()
1449 static void do_bit_flips(struct nandsim *ns, int num) do_bit_flips() argument
1457 ns->buf.byte[pos / 8] ^= (1 << (pos % 8)); do_bit_flips()
1460 pos, ns->regs.row, ns->regs.column + ns->regs.off, do_bit_flips()
1469 static void read_page(struct nandsim *ns, int num) read_page() argument
1473 if (ns->cfile) { read_page()
1474 if (!test_bit(ns->regs.row, ns->pages_written)) { read_page()
1475 NS_DBG("read_page: page %d not written\n", ns->regs.row); read_page()
1476 memset(ns->buf.byte, 0xFF, num); read_page()
1482 ns->regs.row, ns->regs.column + ns->regs.off); read_page()
1483 if (do_read_error(ns, num)) read_page()
1485 pos = (loff_t)NS_RAW_OFFSET(ns) + ns->regs.off; read_page()
1486 tx = read_file(ns, ns->cfile, ns->buf.byte, num, pos); read_page()
1488 NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); read_page()
1491 do_bit_flips(ns, num); read_page()
1496 mypage = NS_GET_PAGE(ns); read_page()
1498 NS_DBG("read_page: page %d not allocated\n", ns->regs.row); read_page()
1499 memset(ns->buf.byte, 0xFF, num); read_page()
1502 ns->regs.row, ns->regs.column + ns->regs.off); read_page()
1503 if (do_read_error(ns, num)) read_page()
1505 memcpy(ns->buf.byte, NS_PAGE_BYTE_OFF(ns), num); read_page()
1506 do_bit_flips(ns, num); read_page()
1513 static void erase_sector(struct nandsim *ns) erase_sector() argument
1518 if (ns->cfile) { erase_sector()
1519 for (i = 0; i < ns->geom.pgsec; i++) erase_sector()
1520 if (__test_and_clear_bit(ns->regs.row + i, erase_sector()
1521 ns->pages_written)) { erase_sector()
1522 NS_DBG("erase_sector: freeing page %d\n", ns->regs.row + i); erase_sector()
1527 mypage = NS_GET_PAGE(ns); erase_sector()
1528 for (i = 0; i < ns->geom.pgsec; i++) { erase_sector()
1530 NS_DBG("erase_sector: freeing page %d\n", ns->regs.row+i); erase_sector()
1531 kmem_cache_free(ns->nand_pages_slab, mypage->byte); erase_sector()
1541 static int prog_page(struct nandsim *ns, int num) prog_page() argument
1547 if (ns->cfile) { prog_page()
1552 NS_DBG("prog_page: writing page %d\n", ns->regs.row); prog_page()
1553 pg_off = ns->file_buf + ns->regs.column + ns->regs.off; prog_page()
1554 off = (loff_t)NS_RAW_OFFSET(ns) + ns->regs.off; prog_page()
1555 if (!test_bit(ns->regs.row, ns->pages_written)) { prog_page()
1557 memset(ns->file_buf, 0xff, ns->geom.pgszoob); prog_page()
1560 tx = read_file(ns, ns->cfile, pg_off, num, off); prog_page()
1562 NS_ERR("prog_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); prog_page()
1567 pg_off[i] &= ns->buf.byte[i]; prog_page()
1569 loff_t pos = (loff_t)ns->regs.row * ns->geom.pgszoob; prog_page()
1570 tx = write_file(ns, ns->cfile, ns->file_buf, ns->geom.pgszoob, pos); prog_page()
1571 if (tx != ns->geom.pgszoob) { prog_page()
1572 NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); prog_page()
1575 __set_bit(ns->regs.row, ns->pages_written); prog_page()
1577 tx = write_file(ns, ns->cfile, pg_off, num, off); prog_page()
1579 NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); prog_page()
1586 mypage = NS_GET_PAGE(ns); prog_page()
1588 NS_DBG("prog_page: allocating page %d\n", ns->regs.row); prog_page()
1595 mypage->byte = kmem_cache_alloc(ns->nand_pages_slab, GFP_NOFS); prog_page()
1597 NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row); prog_page()
1600 memset(mypage->byte, 0xFF, ns->geom.pgszoob); prog_page()
1603 pg_off = NS_PAGE_BYTE_OFF(ns); prog_page()
1605 pg_off[i] &= ns->buf.byte[i]; prog_page()
1615 static int do_state_action(struct nandsim *ns, uint32_t action) do_state_action() argument
1618 int busdiv = ns->busw == 8 ? 1 : 2; do_state_action()
1624 if (action != ACTION_SECERASE && ns->regs.row >= ns->geom.pgnum) { do_state_action()
1625 NS_WARN("do_state_action: wrong page number (%#x)\n", ns->regs.row); do_state_action()
1637 if (ns->regs.column >= (ns->geom.pgszoob - ns->regs.off)) { do_state_action()
1641 num = ns->geom.pgszoob - ns->regs.off - ns->regs.column; do_state_action()
1642 read_page(ns, num); do_state_action()
1645 num, NS_RAW_OFFSET(ns) + ns->regs.off); do_state_action()
1647 if (ns->regs.off == 0) do_state_action()
1648 NS_LOG("read page %d\n", ns->regs.row); do_state_action()
1649 else if (ns->regs.off < ns->geom.pgsz) do_state_action()
1650 NS_LOG("read page %d (second half)\n", ns->regs.row); do_state_action()
1652 NS_LOG("read OOB of page %d\n", ns->regs.row); do_state_action()
1655 NS_UDELAY(input_cycle * ns->geom.pgsz / 1000 / busdiv); do_state_action()
1664 if (ns->lines.wp) { do_state_action()
1669 if (ns->regs.row >= ns->geom.pgnum - ns->geom.pgsec do_state_action()
1670 || (ns->regs.row & ~(ns->geom.secsz - 1))) { do_state_action()
1671 NS_ERR("do_state_action: wrong sector address (%#x)\n", ns->regs.row); do_state_action()
1675 ns->regs.row = (ns->regs.row << do_state_action()
1676 8 * (ns->geom.pgaddrbytes - ns->geom.secaddrbytes)) | ns->regs.column; do_state_action()
1677 ns->regs.column = 0; do_state_action()
1679 erase_block_no = ns->regs.row >> (ns->geom.secshift - ns->geom.pgshift); do_state_action()
1682 ns->regs.row, NS_RAW_OFFSET(ns)); do_state_action()
1685 erase_sector(ns); do_state_action()
1704 if (ns->lines.wp) { do_state_action()
1709 num = ns->geom.pgszoob - ns->regs.off - ns->regs.column; do_state_action()
1710 if (num != ns->regs.count) { do_state_action()
1712 ns->regs.count, num); do_state_action()
1716 if (prog_page(ns, num) == -1) do_state_action()
1719 page_no = ns->regs.row; do_state_action()
1722 num, ns->regs.row, ns->regs.column, NS_RAW_OFFSET(ns) + ns->regs.off); do_state_action()
1723 NS_LOG("programm page %d\n", ns->regs.row); do_state_action()
1726 NS_UDELAY(output_cycle * ns->geom.pgsz / 1000 / busdiv); do_state_action()
1737 ns->regs.off = 0; do_state_action()
1741 if (!(ns->options & OPT_PAGE512_8BIT)) { do_state_action()
1746 NS_DBG("do_state_action: set internal offset to %d\n", ns->geom.pgsz/2); do_state_action()
1747 ns->regs.off = ns->geom.pgsz/2; do_state_action()
1751 NS_DBG("do_state_action: set internal offset to %d\n", ns->geom.pgsz); do_state_action()
1752 ns->regs.off = ns->geom.pgsz; do_state_action()
1765 static void switch_state(struct nandsim *ns) switch_state() argument
1767 if (ns->op) { switch_state()
1773 ns->stateidx += 1; switch_state()
1774 ns->state = ns->nxstate; switch_state()
1775 ns->nxstate = ns->op[ns->stateidx + 1]; switch_state()
1779 get_state_name(ns->state), get_state_name(ns->nxstate)); switch_state()
1782 if ((ns->state & ACTION_MASK) && do_state_action(ns, ns->state) < 0) { switch_state()
1783 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); switch_state()
1797 ns->state = get_state_by_command(ns->regs.command); switch_state()
1801 if (find_operation(ns, 0) != 0) switch_state()
1804 if ((ns->state & ACTION_MASK) && do_state_action(ns, ns->state) < 0) { switch_state()
1805 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); switch_state()
1811 if ((ns->nxstate & STATE_ADDR_MASK) && ns->busw == 16) { switch_state()
1813 ns->regs.column <<= 1; switch_state()
1816 if (NS_STATE(ns->nxstate) == STATE_READY) { switch_state()
1821 u_char status = NS_STATUS_OK(ns); switch_state()
1824 if ((ns->state & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK)) switch_state()
1825 && ns->regs.count != ns->regs.num) { switch_state()
1827 ns->regs.num - ns->regs.count); switch_state()
1828 status = NS_STATUS_FAILED(ns); switch_state()
1833 switch_to_ready_state(ns, status); switch_state()
1836 } else if (ns->nxstate & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK)) { switch_state()
1841 ns->state = ns->nxstate; switch_state()
1842 ns->nxstate = ns->op[++ns->stateidx + 1]; switch_state()
1843 ns->regs.num = ns->regs.count = 0; switch_state()
1847 get_state_name(ns->state), get_state_name(ns->nxstate)); switch_state()
1853 switch (NS_STATE(ns->state)) { switch_state()
1856 ns->regs.num = ns->geom.pgszoob - ns->regs.off - ns->regs.column; switch_state()
1860 ns->regs.num = ns->geom.idbytes; switch_state()
1864 ns->regs.count = ns->regs.num = 0; switch_state()
1871 } else if (ns->nxstate & STATE_ADDR_MASK) { switch_state()
1877 ns->regs.count = 0; switch_state()
1879 switch (NS_STATE(ns->nxstate)) { switch_state()
1881 ns->regs.num = ns->geom.pgaddrbytes; switch_state()
1885 ns->regs.num = ns->geom.secaddrbytes; switch_state()
1889 ns->regs.num = 1; switch_state()
1894 ns->regs.num = ns->geom.pgaddrbytes - ns->geom.secaddrbytes; switch_state()
1905 ns->regs.num = 0; switch_state()
1906 ns->regs.count = 0; switch_state()
1912 struct nandsim *ns = ((struct nand_chip *)mtd->priv)->priv; ns_nand_read_byte() local
1916 if (!ns->lines.ce) { ns_nand_read_byte()
1920 if (ns->lines.ale || ns->lines.cle) { ns_nand_read_byte()
1924 if (!(ns->state & STATE_DATAOUT_MASK)) { ns_nand_read_byte()
1926 "return %#x\n", get_state_name(ns->state), (uint)outb); ns_nand_read_byte()
1931 if (NS_STATE(ns->state) == STATE_DATAOUT_STATUS) { ns_nand_read_byte()
1932 NS_DBG("read_byte: return %#x status\n", ns->regs.status); ns_nand_read_byte()
1933 return ns->regs.status; ns_nand_read_byte()
1937 if (ns->regs.count == ns->regs.num) { ns_nand_read_byte()
1942 switch (NS_STATE(ns->state)) { ns_nand_read_byte()
1944 if (ns->busw == 8) { ns_nand_read_byte()
1945 outb = ns->buf.byte[ns->regs.count]; ns_nand_read_byte()
1946 ns->regs.count += 1; ns_nand_read_byte()
1948 outb = (u_char)cpu_to_le16(ns->buf.word[ns->regs.count >> 1]); ns_nand_read_byte()
1949 ns->regs.count += 2; ns_nand_read_byte()
1953 NS_DBG("read_byte: read ID byte %d, total = %d\n", ns->regs.count, ns->regs.num); ns_nand_read_byte()
1954 outb = ns->ids[ns->regs.count]; ns_nand_read_byte()
1955 ns->regs.count += 1; ns_nand_read_byte()
1961 if (ns->regs.count == ns->regs.num) { ns_nand_read_byte()
1964 if (NS_STATE(ns->nxstate) == STATE_READY) ns_nand_read_byte()
1965 switch_state(ns); ns_nand_read_byte()
1973 struct nandsim *ns = ((struct nand_chip *)mtd->priv)->priv; ns_nand_write_byte() local
1976 if (!ns->lines.ce) { ns_nand_write_byte()
1980 if (ns->lines.ale && ns->lines.cle) { ns_nand_write_byte()
1985 if (ns->lines.cle == 1) { ns_nand_write_byte()
1992 switch_to_ready_state(ns, NS_STATUS_OK(ns)); ns_nand_write_byte()
2002 if (NS_STATE(ns->state) == STATE_DATAOUT_STATUS ns_nand_write_byte()
2003 || NS_STATE(ns->state) == STATE_DATAOUT) { ns_nand_write_byte()
2004 int row = ns->regs.row; ns_nand_write_byte()
2006 switch_state(ns); ns_nand_write_byte()
2008 ns->regs.row = row; ns_nand_write_byte()
2012 if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) { ns_nand_write_byte()
2014 if (!(ns->regs.command == NAND_CMD_READID && ns_nand_write_byte()
2015 NS_STATE(ns->state) == STATE_DATAOUT_ID && ns->regs.count == 2)) { ns_nand_write_byte()
2022 "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate)); ns_nand_write_byte()
2024 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_byte()
2029 ns->regs.command = byte; ns_nand_write_byte()
2030 switch_state(ns); ns_nand_write_byte()
2032 } else if (ns->lines.ale == 1) { ns_nand_write_byte()
2037 if (NS_STATE(ns->nxstate) == STATE_UNKNOWN) { ns_nand_write_byte()
2041 if (find_operation(ns, 1) < 0) ns_nand_write_byte()
2044 if ((ns->state & ACTION_MASK) && do_state_action(ns, ns->state) < 0) { ns_nand_write_byte()
2045 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_byte()
2049 ns->regs.count = 0; ns_nand_write_byte()
2050 switch (NS_STATE(ns->nxstate)) { ns_nand_write_byte()
2052 ns->regs.num = ns->geom.pgaddrbytes; ns_nand_write_byte()
2055 ns->regs.num = ns->geom.secaddrbytes; ns_nand_write_byte()
2058 ns->regs.num = 1; ns_nand_write_byte()
2066 if (!(ns->nxstate & STATE_ADDR_MASK)) { ns_nand_write_byte()
2068 "switch to STATE_READY\n", (uint)byte, get_state_name(ns->nxstate)); ns_nand_write_byte()
2069 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_byte()
2074 if (ns->regs.count == ns->regs.num) { ns_nand_write_byte()
2076 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_byte()
2080 accept_addr_byte(ns, byte); ns_nand_write_byte()
2082 ns->regs.count += 1; ns_nand_write_byte()
2085 (uint)byte, ns->regs.count, ns->regs.num); ns_nand_write_byte()
2087 if (ns->regs.count == ns->regs.num) { ns_nand_write_byte()
2088 NS_DBG("address (%#x, %#x) is accepted\n", ns->regs.row, ns->regs.column); ns_nand_write_byte()
2089 switch_state(ns); ns_nand_write_byte()
2098 if (!(ns->state & STATE_DATAIN_MASK)) { ns_nand_write_byte()
2101 get_state_name(ns->state), get_state_name(STATE_READY)); ns_nand_write_byte()
2102 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_byte()
2107 if (ns->regs.count == ns->regs.num) { ns_nand_write_byte()
2109 ns->regs.num); ns_nand_write_byte()
2113 if (ns->busw == 8) { ns_nand_write_byte()
2114 ns->buf.byte[ns->regs.count] = byte; ns_nand_write_byte()
2115 ns->regs.count += 1; ns_nand_write_byte()
2117 ns->buf.word[ns->regs.count >> 1] = cpu_to_le16((uint16_t)byte); ns_nand_write_byte()
2118 ns->regs.count += 2; ns_nand_write_byte()
2127 struct nandsim *ns = ((struct nand_chip *)mtd->priv)->priv; ns_hwcontrol() local
2129 ns->lines.cle = bitmask & NAND_CLE ? 1 : 0; ns_hwcontrol()
2130 ns->lines.ale = bitmask & NAND_ALE ? 1 : 0; ns_hwcontrol()
2131 ns->lines.ce = bitmask & NAND_NCE ? 1 : 0; ns_hwcontrol()
2154 struct nandsim *ns = ((struct nand_chip *)mtd->priv)->priv; ns_nand_write_buf() local
2157 if (!(ns->state & STATE_DATAIN_MASK)) { ns_nand_write_buf()
2159 "switch to STATE_READY\n", get_state_name(ns->state)); ns_nand_write_buf()
2160 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_buf()
2165 if (ns->regs.count + len > ns->regs.num) { ns_nand_write_buf()
2167 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_write_buf()
2171 memcpy(ns->buf.byte + ns->regs.count, buf, len); ns_nand_write_buf()
2172 ns->regs.count += len; ns_nand_write_buf()
2174 if (ns->regs.count == ns->regs.num) { ns_nand_write_buf()
2175 NS_DBG("write_buf: %d bytes were written\n", ns->regs.count); ns_nand_write_buf()
2181 struct nandsim *ns = ((struct nand_chip *)mtd->priv)->priv; ns_nand_read_buf() local
2184 if (!ns->lines.ce) { ns_nand_read_buf()
2188 if (ns->lines.ale || ns->lines.cle) { ns_nand_read_buf()
2192 if (!(ns->state & STATE_DATAOUT_MASK)) { ns_nand_read_buf()
2194 get_state_name(ns->state)); ns_nand_read_buf()
2198 if (NS_STATE(ns->state) != STATE_DATAOUT) { ns_nand_read_buf()
2208 if (ns->regs.count + len > ns->regs.num) { ns_nand_read_buf()
2210 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); ns_nand_read_buf()
2214 memcpy(buf, ns->buf.byte + ns->regs.count, len); ns_nand_read_buf()
2215 ns->regs.count += len; ns_nand_read_buf()
2217 if (ns->regs.count == ns->regs.num) { ns_nand_read_buf()
2218 if (NS_STATE(ns->nxstate) == STATE_READY) ns_nand_read_buf()
2219 switch_state(ns); ns_nand_read_buf()
2409 struct nandsim *ns = ((struct nand_chip *)nsmtd->priv)->priv; ns_cleanup_module() local
2412 nandsim_debugfs_remove(ns); ns_cleanup_module()
2413 free_nandsim(ns); /* Free nandsim private resources */ ns_cleanup_module()
2415 for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i) ns_cleanup_module()
2416 kfree(ns->partitions[i].name); ns_cleanup_module()
/linux-4.1.27/drivers/block/drbd/
H A Ddrbd_state.c37 union drbd_state ns; member in struct:after_state_chg_work
53 union drbd_state ns, enum chg_state_flags flags);
56 static enum drbd_state_rv is_valid_transition(union drbd_state os, union drbd_state ns);
58 union drbd_state ns, enum sanitize_state_warnings *warn);
235 * @ns: new (wanted) state.
238 union drbd_state os, union drbd_state ns) cl_wide_st_chg()
240 return (os.conn >= C_CONNECTED && ns.conn >= C_CONNECTED && cl_wide_st_chg()
241 ((os.role != R_PRIMARY && ns.role == R_PRIMARY) || cl_wide_st_chg()
242 (os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) || cl_wide_st_chg()
243 (os.conn != C_STARTING_SYNC_S && ns.conn == C_STARTING_SYNC_S) || cl_wide_st_chg()
244 (os.disk != D_FAILED && ns.disk == D_FAILED))) || cl_wide_st_chg()
245 (os.conn >= C_CONNECTED && ns.conn == C_DISCONNECTING) || cl_wide_st_chg()
246 (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S) || cl_wide_st_chg()
247 (os.conn == C_CONNECTED && ns.conn == C_WF_REPORT_PARAMS); cl_wide_st_chg()
253 union drbd_state ns; apply_mask_val() local
254 ns.i = (os.i & ~mask.i) | val.i; apply_mask_val()
255 return ns; apply_mask_val()
263 union drbd_state ns; drbd_change_state() local
267 ns = apply_mask_val(drbd_read_state(device), mask, val); drbd_change_state()
268 rv = _drbd_set_state(device, ns, f, NULL); drbd_change_state()
290 union drbd_state os, ns; _req_st_cond() local
302 ns = sanitize_state(device, os, apply_mask_val(os, mask, val), NULL); _req_st_cond()
303 rv = is_valid_transition(os, ns); _req_st_cond()
307 if (!cl_wide_st_chg(device, os, ns)) _req_st_cond()
310 rv = is_valid_state(device, ns); _req_st_cond()
312 rv = is_valid_soft_transition(os, ns, first_peer_device(device)->connection); _req_st_cond()
338 union drbd_state os, ns; drbd_req_state() local
348 ns = sanitize_state(device, os, apply_mask_val(os, mask, val), NULL); drbd_req_state()
349 rv = is_valid_transition(os, ns); drbd_req_state()
355 if (cl_wide_st_chg(device, os, ns)) { drbd_req_state()
356 rv = is_valid_state(device, ns); drbd_req_state()
358 rv = is_valid_soft_transition(os, ns, first_peer_device(device)->connection); drbd_req_state()
363 print_st_err(device, os, ns, rv); drbd_req_state()
370 print_st_err(device, os, ns, rv); drbd_req_state()
379 print_st_err(device, os, ns, rv); drbd_req_state()
383 ns = apply_mask_val(drbd_read_state(device), mask, val); drbd_req_state()
384 rv = _drbd_set_state(device, ns, f, &done); drbd_req_state()
386 rv = _drbd_set_state(device, ns, f, &done); drbd_req_state()
441 static void print_st(struct drbd_device *device, const char *name, union drbd_state ns) print_st() argument
445 drbd_conn_str(ns.conn), print_st()
446 drbd_role_str(ns.role), print_st()
447 drbd_role_str(ns.peer), print_st()
448 drbd_disk_str(ns.disk), print_st()
449 drbd_disk_str(ns.pdsk), print_st()
450 is_susp(ns) ? 's' : 'r', print_st()
451 ns.aftr_isp ? 'a' : '-', print_st()
452 ns.peer_isp ? 'p' : '-', print_st()
453 ns.user_isp ? 'u' : '-', print_st()
454 ns.susp_fen ? 'F' : '-', print_st()
455 ns.susp_nod ? 'N' : '-' print_st()
460 union drbd_state ns, enum drbd_state_rv err) print_st_err()
466 print_st(device, "wanted", ns); print_st_err()
469 static long print_state_change(char *pb, union drbd_state os, union drbd_state ns, print_state_change() argument
476 if (ns.role != os.role && flags & CS_DC_ROLE) print_state_change()
479 drbd_role_str(ns.role)); print_state_change()
480 if (ns.peer != os.peer && flags & CS_DC_PEER) print_state_change()
483 drbd_role_str(ns.peer)); print_state_change()
484 if (ns.conn != os.conn && flags & CS_DC_CONN) print_state_change()
487 drbd_conn_str(ns.conn)); print_state_change()
488 if (ns.disk != os.disk && flags & CS_DC_DISK) print_state_change()
491 drbd_disk_str(ns.disk)); print_state_change()
492 if (ns.pdsk != os.pdsk && flags & CS_DC_PDSK) print_state_change()
495 drbd_disk_str(ns.pdsk)); print_state_change()
500 static void drbd_pr_state_change(struct drbd_device *device, union drbd_state os, union drbd_state ns, drbd_pr_state_change() argument
506 pbp += print_state_change(pbp, os, ns, flags ^ CS_DC_MASK); drbd_pr_state_change()
508 if (ns.aftr_isp != os.aftr_isp) drbd_pr_state_change()
511 ns.aftr_isp); drbd_pr_state_change()
512 if (ns.peer_isp != os.peer_isp) drbd_pr_state_change()
515 ns.peer_isp); drbd_pr_state_change()
516 if (ns.user_isp != os.user_isp) drbd_pr_state_change()
519 ns.user_isp); drbd_pr_state_change()
525 static void conn_pr_state_change(struct drbd_connection *connection, union drbd_state os, union drbd_state ns, conn_pr_state_change() argument
531 pbp += print_state_change(pbp, os, ns, flags); conn_pr_state_change()
533 if (is_susp(ns) != is_susp(os) && flags & CS_DC_SUSP) conn_pr_state_change()
536 is_susp(ns)); conn_pr_state_change()
544 * is_valid_state() - Returns an SS_ error code if ns is not valid
546 * @ns: State to consider.
549 is_valid_state(struct drbd_device *device, union drbd_state ns) is_valid_state() argument
566 if (!nc->two_primaries && ns.role == R_PRIMARY) { is_valid_state()
567 if (ns.peer == R_PRIMARY) is_valid_state()
576 else if (ns.role == R_SECONDARY && device->open_cnt) is_valid_state()
579 else if (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.disk < D_UP_TO_DATE) is_valid_state()
583 ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk >= D_UNKNOWN) is_valid_state()
586 else if (ns.role == R_PRIMARY && ns.disk <= D_INCONSISTENT && ns.pdsk <= D_INCONSISTENT) is_valid_state()
589 else if (ns.conn > C_CONNECTED && ns.disk < D_INCONSISTENT) is_valid_state()
592 else if (ns.conn > C_CONNECTED && ns.pdsk < D_INCONSISTENT) is_valid_state()
595 else if (ns.conn > C_CONNECTED && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE) is_valid_state()
598 else if ((ns.conn == C_CONNECTED || is_valid_state()
599 ns.conn == C_WF_BITMAP_S || is_valid_state()
600 ns.conn == C_SYNC_SOURCE || is_valid_state()
601 ns.conn == C_PAUSED_SYNC_S) && is_valid_state()
602 ns.disk == D_OUTDATED) is_valid_state()
605 else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && is_valid_state()
609 else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && is_valid_state()
613 else if (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE) is_valid_state()
616 else if ((ns.conn == C_STARTING_SYNC_S || ns.conn == C_STARTING_SYNC_T) && is_valid_state()
617 ns.pdsk == D_UNKNOWN) is_valid_state()
620 else if (ns.conn >= C_CONNECTED && ns.pdsk == D_UNKNOWN) is_valid_state()
633 * @ns: new state.
637 is_valid_soft_transition(union drbd_state os, union drbd_state ns, struct drbd_connection *connection) is_valid_soft_transition() argument
641 if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) && is_valid_soft_transition()
645 if (ns.conn == C_DISCONNECTING && os.conn == C_STANDALONE) is_valid_soft_transition()
648 if (ns.disk > D_ATTACHING && os.disk == D_DISKLESS) is_valid_soft_transition()
651 if (ns.conn == C_WF_CONNECTION && os.conn < C_UNCONNECTED) is_valid_soft_transition()
654 if (ns.disk == D_OUTDATED && os.disk < D_OUTDATED && os.disk != D_ATTACHING) is_valid_soft_transition()
657 if (ns.conn == C_DISCONNECTING && os.conn == C_UNCONNECTED) is_valid_soft_transition()
663 !((ns.conn == C_WF_REPORT_PARAMS && os.conn == C_WF_CONNECTION) || is_valid_soft_transition()
664 (ns.conn >= C_CONNECTED && os.conn == C_WF_REPORT_PARAMS))) is_valid_soft_transition()
667 if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && os.conn < C_CONNECTED) is_valid_soft_transition()
670 if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && is_valid_soft_transition()
671 ns.conn != os.conn && os.conn > C_CONNECTED) is_valid_soft_transition()
674 if ((ns.conn == C_STARTING_SYNC_S || ns.conn == C_STARTING_SYNC_T) && is_valid_soft_transition()
678 if ((ns.conn == C_SYNC_TARGET || ns.conn == C_SYNC_SOURCE) is_valid_soft_transition()
682 if (ns.conn == C_DISCONNECTING && ns.pdsk == D_OUTDATED && is_valid_soft_transition()
726 * @ns: new state.
730 is_valid_transition(union drbd_state os, union drbd_state ns) is_valid_transition() argument
734 rv = is_valid_conn_transition(os.conn, ns.conn); is_valid_transition()
737 if (ns.disk == D_FAILED && os.disk == D_DISKLESS) is_valid_transition()
762 * @ns: new state.
769 union drbd_state ns, enum sanitize_state_warnings *warn) sanitize_state()
786 if (ns.conn < C_CONNECTED) { sanitize_state()
787 ns.peer_isp = 0; sanitize_state()
788 ns.peer = R_UNKNOWN; sanitize_state()
789 if (ns.pdsk > D_UNKNOWN || ns.pdsk < D_INCONSISTENT) sanitize_state()
790 ns.pdsk = D_UNKNOWN; sanitize_state()
794 if (ns.conn == C_STANDALONE && ns.disk == D_DISKLESS && ns.role == R_SECONDARY) sanitize_state()
795 ns.aftr_isp = 0; sanitize_state()
799 if (ns.conn > C_CONNECTED && (ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) { sanitize_state()
801 *warn = ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T ? sanitize_state()
803 ns.conn = C_CONNECTED; sanitize_state()
807 if (ns.conn < C_CONNECTED && ns.disk == D_NEGOTIATING && sanitize_state()
810 ns.disk = device->new_state_tmp.disk; sanitize_state()
811 ns.pdsk = device->new_state_tmp.pdsk; sanitize_state()
815 ns.disk = D_DISKLESS; sanitize_state()
816 ns.pdsk = D_UNKNOWN; sanitize_state()
822 if (ns.conn >= C_CONNECTED && ns.conn < C_AHEAD) { sanitize_state()
823 if (ns.disk == D_CONSISTENT || ns.disk == D_OUTDATED) sanitize_state()
824 ns.disk = D_UP_TO_DATE; sanitize_state()
825 if (ns.pdsk == D_CONSISTENT || ns.pdsk == D_OUTDATED) sanitize_state()
826 ns.pdsk = D_UP_TO_DATE; sanitize_state()
834 switch ((enum drbd_conns)ns.conn) { sanitize_state()
892 if (ns.disk > disk_max) sanitize_state()
893 ns.disk = disk_max; sanitize_state()
895 if (ns.disk < disk_min) { sanitize_state()
898 ns.disk = disk_min; sanitize_state()
900 if (ns.pdsk > pdsk_max) sanitize_state()
901 ns.pdsk = pdsk_max; sanitize_state()
903 if (ns.pdsk < pdsk_min) { sanitize_state()
906 ns.pdsk = pdsk_min; sanitize_state()
910 (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED) && sanitize_state()
912 ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */ sanitize_state()
915 (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE) && sanitize_state()
917 ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */ sanitize_state()
919 if (ns.aftr_isp || ns.peer_isp || ns.user_isp) { sanitize_state()
920 if (ns.conn == C_SYNC_SOURCE) sanitize_state()
921 ns.conn = C_PAUSED_SYNC_S; sanitize_state()
922 if (ns.conn == C_SYNC_TARGET) sanitize_state()
923 ns.conn = C_PAUSED_SYNC_T; sanitize_state()
925 if (ns.conn == C_PAUSED_SYNC_S) sanitize_state()
926 ns.conn = C_SYNC_SOURCE; sanitize_state()
927 if (ns.conn == C_PAUSED_SYNC_T) sanitize_state()
928 ns.conn = C_SYNC_TARGET; sanitize_state()
931 return ns; sanitize_state()
970 * @ns: new state.
977 __drbd_set_state(struct drbd_device *device, union drbd_state ns, __drbd_set_state() argument
989 ns = sanitize_state(device, os, ns, &ssw); __drbd_set_state()
990 if (ns.i == os.i) __drbd_set_state()
993 rv = is_valid_transition(os, ns); __drbd_set_state()
998 /* pre-state-change checks ; only look at ns */ __drbd_set_state()
1001 rv = is_valid_state(device, ns); __drbd_set_state()
1007 rv = is_valid_soft_transition(os, ns, connection); __drbd_set_state()
1009 rv = is_valid_soft_transition(os, ns, connection); __drbd_set_state()
1014 print_st_err(device, os, ns, rv); __drbd_set_state()
1020 drbd_pr_state_change(device, os, ns, flags); __drbd_set_state()
1026 conn_pr_state_change(connection, os, ns, __drbd_set_state()
1033 if ((os.disk != D_FAILED && ns.disk == D_FAILED) || __drbd_set_state()
1034 (os.disk != D_DISKLESS && ns.disk == D_DISKLESS)) __drbd_set_state()
1037 if (!is_sync_state(os.conn) && is_sync_state(ns.conn)) __drbd_set_state()
1044 device->state.i = ns.i; __drbd_set_state()
1045 device->resource->susp = ns.susp; __drbd_set_state()
1046 device->resource->susp_nod = ns.susp_nod; __drbd_set_state()
1047 device->resource->susp_fen = ns.susp_fen; __drbd_set_state()
1052 drbd_should_do_remote((union drbd_dev_state)ns.i)) __drbd_set_state()
1055 if (os.disk == D_ATTACHING && ns.disk >= D_NEGOTIATING) __drbd_set_state()
1059 if (os.conn == C_WF_REPORT_PARAMS && ns.conn != C_WF_REPORT_PARAMS && __drbd_set_state()
1072 ns.conn <= C_CONNECTED) { __drbd_set_state()
1081 (ns.conn == C_SYNC_TARGET || ns.conn == C_SYNC_SOURCE)) { __drbd_set_state()
1085 if (ns.conn == C_SYNC_TARGET) __drbd_set_state()
1090 (ns.conn == C_PAUSED_SYNC_T || ns.conn == C_PAUSED_SYNC_S)) { __drbd_set_state()
1096 (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T)) { __drbd_set_state()
1100 set_ov_position(device, ns.conn); __drbd_set_state()
1113 if (ns.conn == C_VERIFY_S) { __drbd_set_state()
1143 if (os.disk < D_CONSISTENT && ns.disk >= D_CONSISTENT) __drbd_set_state()
1150 os.peer == R_SECONDARY && ns.peer == R_PRIMARY) __drbd_set_state()
1154 if (os.conn != C_DISCONNECTING && ns.conn == C_DISCONNECTING) __drbd_set_state()
1158 if (os.conn != C_STANDALONE && ns.conn == C_STANDALONE) __drbd_set_state()
1163 ns.conn <= C_TEAR_DOWN && ns.conn >= C_TIMEOUT) __drbd_set_state()
1167 if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) { __drbd_set_state()
1176 ns.disk > D_NEGOTIATING) __drbd_set_state()
1182 ascw->ns = ns; __drbd_set_state()
1202 after_state_ch(device, ascw->os, ascw->ns, ascw->flags); w_after_state_ch()
1252 * @ns: new state.
1256 union drbd_state ns, enum chg_state_flags flags) after_state_ch()
1265 sib.ns = ns; after_state_ch()
1268 && (ns.disk == D_UP_TO_DATE && ns.pdsk == D_UP_TO_DATE)) { after_state_ch()
1278 (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)) after_state_ch()
1284 if (ns.susp_nod) { after_state_ch()
1305 if (ns.susp_fen) {
1330 (ns.conn == C_SYNC_SOURCE || ns.conn == C_PAUSED_SYNC_S) &&
1338 ns.pdsk > D_DISKLESS && ns.pdsk != D_UNKNOWN) { /* attach on the peer */
1347 drbd_send_state(peer_device, ns);
1352 if (os.conn != C_WF_BITMAP_S && ns.conn == C_WF_BITMAP_S &&
1362 && (ns.pdsk < D_INCONSISTENT ||
1363 ns.pdsk == D_UNKNOWN ||
1364 ns.pdsk == D_OUTDATED)) {
1366 if ((ns.role == R_PRIMARY || ns.peer == R_PRIMARY) &&
1367 device->ldev->md.uuid[UI_BITMAP] == 0 && ns.disk >= D_UP_TO_DATE) {
1379 if (ns.pdsk < D_INCONSISTENT && get_ldev(device)) {
1380 if (os.peer == R_SECONDARY && ns.peer == R_PRIMARY &&
1381 device->ldev->md.uuid[UI_BITMAP] == 0 && ns.disk >= D_UP_TO_DATE) {
1386 if (os.peer == R_PRIMARY && ns.peer == R_SECONDARY)
1398 if (os.role == R_PRIMARY && ns.role == R_SECONDARY &&
1408 if (ns.conn >= C_CONNECTED &&
1409 os.disk == D_ATTACHING && ns.disk == D_NEGOTIATING) {
1412 drbd_send_state(peer_device, ns);
1416 if (ns.conn >= C_CONNECTED &&
1417 ((os.aftr_isp != ns.aftr_isp) ||
1418 (os.user_isp != ns.user_isp)))
1419 drbd_send_state(peer_device, ns);
1423 (ns.aftr_isp || ns.peer_isp || ns.user_isp))
1428 if (os.conn == C_WF_REPORT_PARAMS && ns.conn >= C_CONNECTED)
1429 drbd_send_state(peer_device, ns);
1431 if (os.conn != C_AHEAD && ns.conn == C_AHEAD)
1432 drbd_send_state(peer_device, ns);
1435 if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) ||
1436 (os.conn != C_STARTING_SYNC_S && ns.conn == C_STARTING_SYNC_S))
1444 if (os.disk != D_FAILED && ns.disk == D_FAILED) {
1485 if (ns.conn >= C_CONNECTED)
1486 drbd_send_state(peer_device, ns);
1501 if (os.disk != D_DISKLESS && ns.disk == D_DISKLESS) {
1509 if (ns.conn >= C_CONNECTED)
1510 drbd_send_state(peer_device, ns);
1517 if (os.disk == D_UP_TO_DATE && ns.disk == D_INCONSISTENT && ns.conn >= C_CONNECTED)
1518 drbd_send_state(peer_device, ns);
1521 if (ns.disk > D_NEGOTIATING && ns.pdsk > D_NEGOTIATING &&
1523 if (ns.conn == C_CONNECTED)
1528 if ((os.conn > C_CONNECTED && ns.conn <= C_CONNECTED) ||
1529 (os.peer_isp && !ns.peer_isp) ||
1530 (os.user_isp && !ns.user_isp))
1535 if (os.disk < D_UP_TO_DATE && os.conn >= C_SYNC_SOURCE && ns.conn == C_CONNECTED)
1536 drbd_send_state(peer_device, ns);
1541 if (os.conn == C_VERIFY_S && ns.conn == C_CONNECTED
1543 drbd_send_state(peer_device, ns);
1552 if (os.conn > C_CONNECTED && ns.conn <= C_CONNECTED && get_ldev(device)) {
1558 if (ns.disk == D_DISKLESS &&
1559 ns.conn == C_STANDALONE &&
1560 ns.role == R_SECONDARY) {
1561 if (os.aftr_isp != ns.aftr_isp)
1687 union drbd_state ns, os; conn_is_valid_transition() local
1695 ns = sanitize_state(device, os, apply_mask_val(os, mask, val), NULL); conn_is_valid_transition()
1697 if (flags & CS_IGN_OUTD_FAIL && ns.disk == D_OUTDATED && os.disk < D_OUTDATED) conn_is_valid_transition()
1698 ns.disk = os.disk; conn_is_valid_transition()
1700 if (ns.i == os.i) conn_is_valid_transition()
1703 rv = is_valid_transition(os, ns); conn_is_valid_transition()
1706 rv = is_valid_state(device, ns); conn_is_valid_transition()
1709 rv = is_valid_soft_transition(os, ns, connection); conn_is_valid_transition()
1711 rv = is_valid_soft_transition(os, ns, connection); conn_is_valid_transition()
1716 print_st_err(device, os, ns, rv); conn_is_valid_transition()
1729 union drbd_state ns, os, ns_max = { }; conn_set_state() local
1756 ns = apply_mask_val(os, mask, val); conn_set_state()
1757 ns = sanitize_state(device, os, ns, NULL); conn_set_state()
1759 if (flags & CS_IGN_OUTD_FAIL && ns.disk == D_OUTDATED && os.disk < D_OUTDATED) conn_set_state()
1760 ns.disk = os.disk; conn_set_state()
1762 rv = __drbd_set_state(device, ns, flags, NULL); conn_set_state()
1766 ns.i = device->state.i; conn_set_state()
1767 ns_max.role = max_role(ns.role, ns_max.role); conn_set_state()
1768 ns_max.peer = max_role(ns.peer, ns_max.peer); conn_set_state()
1769 ns_max.conn = max_t(enum drbd_conns, ns.conn, ns_max.conn); conn_set_state()
1770 ns_max.disk = max_t(enum drbd_disk_state, ns.disk, ns_max.disk); conn_set_state()
1771 ns_max.pdsk = max_t(enum drbd_disk_state, ns.pdsk, ns_max.pdsk); conn_set_state()
1773 ns_min.role = min_role(ns.role, ns_min.role); conn_set_state()
1774 ns_min.peer = min_role(ns.peer, ns_min.peer); conn_set_state()
1775 ns_min.conn = min_t(enum drbd_conns, ns.conn, ns_min.conn); conn_set_state()
1776 ns_min.disk = min_t(enum drbd_disk_state, ns.disk, ns_min.disk); conn_set_state()
1777 ns_min.pdsk = min_t(enum drbd_disk_state, ns.pdsk, ns_min.pdsk); conn_set_state()
237 cl_wide_st_chg(struct drbd_device *device, union drbd_state os, union drbd_state ns) cl_wide_st_chg() argument
459 print_st_err(struct drbd_device *device, union drbd_state os, union drbd_state ns, enum drbd_state_rv err) print_st_err() argument
768 sanitize_state(struct drbd_device *device, union drbd_state os, union drbd_state ns, enum sanitize_state_warnings *warn) sanitize_state() argument
1255 after_state_ch(struct drbd_device *device, union drbd_state os, union drbd_state ns, enum chg_state_flags flags) after_state_ch() argument
/linux-4.1.27/fs/
H A Dnsfs.c27 struct ns_common *ns = inode->i_private; ns_prune_dentry() local
28 atomic_long_set(&ns->stashed, 0); ns_prune_dentry()
41 struct ns_common *ns = inode->i_private; nsfs_evict() local
43 ns->ops->put(ns); nsfs_evict()
53 struct ns_common *ns; ns_get_path() local
57 ns = ns_ops->get(task); ns_get_path()
58 if (!ns) { ns_get_path()
63 d = atomic_long_read(&ns->stashed); ns_get_path()
70 ns_ops->put(ns); ns_get_path()
79 ns_ops->put(ns); ns_get_path()
83 inode->i_ino = ns->inum; ns_get_path()
88 inode->i_private = ns; ns_get_path()
98 d = atomic_long_cmpxchg(&ns->stashed, 0, (unsigned long)dentry); ns_get_path()
111 struct ns_common *ns; ns_get_name() local
113 ns = ns_ops->get(task); ns_get_name()
114 if (ns) { ns_get_name()
115 res = snprintf(buf, size, "%s:[%u]", ns_ops->name, ns->inum); ns_get_name()
116 ns_ops->put(ns); ns_get_name()
H A Dproc_namespace.c21 struct mnt_namespace *ns = p->ns; mounts_poll() local
25 poll_wait(file, &p->ns->poll, wait); mounts_poll()
27 event = ACCESS_ONCE(ns->event); mounts_poll()
238 struct mnt_namespace *ns = NULL; mounts_open_common() local
253 ns = nsp->mnt_ns; mounts_open_common()
254 get_mnt_ns(ns); mounts_open_common()
275 p->ns = ns; mounts_open_common()
277 p->m.poll_event = ns->event; mounts_open_common()
288 put_mnt_ns(ns); mounts_open_common()
297 put_mnt_ns(p->ns); mounts_release()
H A Dmount.h9 struct ns_common ns; member in struct:mnt_namespace
102 static inline void get_mnt_ns(struct mnt_namespace *ns) get_mnt_ns() argument
104 atomic_inc(&ns->count); get_mnt_ns()
121 struct mnt_namespace *ns; member in struct:proc_mounts
H A Dnamespace.c700 struct mnt_namespace *ns = current->nsproxy->mnt_ns; __is_local_mountpoint() local
708 list_for_each_entry(mnt, &ns->list, mnt_list) { __is_local_mountpoint()
779 static void touch_mnt_namespace(struct mnt_namespace *ns) touch_mnt_namespace() argument
781 if (ns) { touch_mnt_namespace()
782 ns->event = ++event; touch_mnt_namespace()
783 wake_up_interruptible(&ns->poll); touch_mnt_namespace()
790 static void __touch_mnt_namespace(struct mnt_namespace *ns) __touch_mnt_namespace() argument
792 if (ns && ns->event != event) { __touch_mnt_namespace()
793 ns->event = event; __touch_mnt_namespace()
794 wake_up_interruptible(&ns->poll); __touch_mnt_namespace()
1221 if (p->cached_event == p->ns->event) { m_start()
1226 v = seq_list_next(v, &p->ns->list, &p->cached_index); m_start()
1231 p->cached_event = p->ns->event; m_start()
1232 p->cached_mount = seq_list_start(&p->ns->list, *pos); m_start()
1241 p->cached_mount = seq_list_next(v, &p->ns->list, pos); m_next()
1643 struct mnt_namespace *to_mnt_ns(struct ns_common *ns) to_mnt_ns() argument
1645 return container_of(ns, struct mnt_namespace, ns); to_mnt_ns()
2333 /* that's acceptable only for automounts done in private ns */ do_add_mount()
2723 static void free_mnt_ns(struct mnt_namespace *ns) free_mnt_ns() argument
2725 ns_free_inum(&ns->ns); free_mnt_ns()
2726 put_user_ns(ns->user_ns); free_mnt_ns()
2727 kfree(ns); free_mnt_ns()
2747 ret = ns_alloc_inum(&new_ns->ns); alloc_mnt_ns()
2752 new_ns->ns.ops = &mntns_operations; alloc_mnt_ns()
2763 struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, copy_mnt_ns() argument
2773 BUG_ON(!ns); copy_mnt_ns()
2776 get_mnt_ns(ns); copy_mnt_ns()
2777 return ns; copy_mnt_ns()
2780 old = ns->root; copy_mnt_ns()
2789 if (user_ns != ns->user_ns) copy_mnt_ns()
2856 struct mnt_namespace *ns; mount_subtree() local
2861 ns = create_mnt_ns(mnt); mount_subtree()
2862 if (IS_ERR(ns)) mount_subtree()
2863 return ERR_CAST(ns); mount_subtree()
2868 put_mnt_ns(ns); mount_subtree()
3069 struct mnt_namespace *ns; init_mount_tree() local
3081 ns = create_mnt_ns(mnt); init_mount_tree()
3082 if (IS_ERR(ns)) init_mount_tree()
3085 init_task.nsproxy->mnt_ns = ns; init_mount_tree()
3086 get_mnt_ns(ns); init_mount_tree()
3136 void put_mnt_ns(struct mnt_namespace *ns) put_mnt_ns() argument
3138 if (!atomic_dec_and_test(&ns->count)) put_mnt_ns()
3140 drop_collected_mounts(&ns->root->mnt); put_mnt_ns()
3141 free_mnt_ns(ns); put_mnt_ns()
3201 struct mnt_namespace *ns = current->nsproxy->mnt_ns; fs_fully_visible() local
3206 if (unlikely(!ns)) fs_fully_visible()
3210 list_for_each_entry(mnt, &ns->list, mnt_list) { fs_fully_visible()
3262 struct ns_common *ns = NULL; mntns_get() local
3268 ns = &nsproxy->mnt_ns->ns; mntns_get()
3269 get_mnt_ns(to_mnt_ns(ns)); mntns_get()
3273 return ns; mntns_get()
3276 static void mntns_put(struct ns_common *ns) mntns_put() argument
3278 put_mnt_ns(to_mnt_ns(ns)); mntns_put()
3281 static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns) mntns_install() argument
3284 struct mnt_namespace *mnt_ns = to_mnt_ns(ns); mntns_install()
/linux-4.1.27/fs/proc/
H A Dthread_self.c13 struct pid_namespace *ns = dentry->d_sb->s_fs_info; proc_thread_self_readlink() local
14 pid_t tgid = task_tgid_nr_ns(current, ns); proc_thread_self_readlink()
15 pid_t pid = task_pid_nr_ns(current, ns); proc_thread_self_readlink()
25 struct pid_namespace *ns = dentry->d_sb->s_fs_info; proc_thread_self_follow_link() local
26 pid_t tgid = task_tgid_nr_ns(current, ns); proc_thread_self_follow_link()
27 pid_t pid = task_pid_nr_ns(current, ns); proc_thread_self_follow_link()
51 struct pid_namespace *ns = s->s_fs_info; proc_setup_thread_self() local
78 ns->proc_thread_self = thread_self; proc_setup_thread_self()
H A Droot.c35 struct pid_namespace *ns = (struct pid_namespace *)data; proc_set_super() local
36 sb->s_fs_info = get_pid_ns(ns); proc_set_super()
105 struct pid_namespace *ns; proc_mount() local
109 ns = (struct pid_namespace *)data; proc_mount()
112 ns = task_active_pid_ns(current); proc_mount()
116 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN)) proc_mount()
120 sb = sget(fs_type, proc_test_super, proc_set_super, flags, ns); proc_mount()
131 if (!proc_parse_options(options, ns)) { proc_mount()
151 struct pid_namespace *ns; proc_kill_sb() local
153 ns = (struct pid_namespace *)sb->s_fs_info; proc_kill_sb()
154 if (ns->proc_self) proc_kill_sb()
155 dput(ns->proc_self); proc_kill_sb()
156 if (ns->proc_thread_self) proc_kill_sb()
157 dput(ns->proc_thread_self); proc_kill_sb()
159 put_pid_ns(ns); proc_kill_sb()
262 int pid_ns_prepare_proc(struct pid_namespace *ns) pid_ns_prepare_proc() argument
266 mnt = kern_mount_data(&proc_fs_type, ns); pid_ns_prepare_proc()
270 ns->proc_mnt = mnt; pid_ns_prepare_proc()
274 void pid_ns_release_proc(struct pid_namespace *ns) pid_ns_release_proc() argument
276 kern_unmount(ns->proc_mnt); pid_ns_release_proc()
H A Dself.c13 struct pid_namespace *ns = dentry->d_sb->s_fs_info; proc_self_readlink() local
14 pid_t tgid = task_tgid_nr_ns(current, ns); proc_self_readlink()
24 struct pid_namespace *ns = dentry->d_sb->s_fs_info; proc_self_follow_link() local
25 pid_t tgid = task_tgid_nr_ns(current, ns); proc_self_follow_link()
50 struct pid_namespace *ns = s->s_fs_info; proc_setup_self() local
77 ns->proc_self = self; proc_setup_self()
H A Darray.c134 static inline void task_state(struct seq_file *m, struct pid_namespace *ns, task_state() argument
147 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; task_state()
151 tpid = task_pid_nr_ns(tracer, ns); task_state()
153 tgid = task_tgid_nr_ns(p, ns); task_state()
174 tgid, ngid, pid_nr_ns(pid, ns), ppid, tpid, task_state()
193 for (g = ns->level; g <= pid->level; g++) task_state()
195 task_tgid_nr_ns(p, pid->numbers[g].ns)); task_state()
197 for (g = ns->level; g <= pid->level; g++) task_state()
199 task_pid_nr_ns(p, pid->numbers[g].ns)); task_state()
201 for (g = ns->level; g <= pid->level; g++) task_state()
203 task_pgrp_nr_ns(p, pid->numbers[g].ns)); task_state()
205 for (g = ns->level; g <= pid->level; g++) task_state()
207 task_session_nr_ns(p, pid->numbers[g].ns)); task_state()
343 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, proc_pid_status() argument
349 task_state(m, ns, pid, task); proc_pid_status()
364 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, do_task_stat() argument
409 tty_pgrp = pid_nr_ns(pgrp, ns); do_task_stat()
439 sid = task_session_nr_ns(task, ns); do_task_stat()
440 ppid = task_tgid_nr_ns(task->real_parent, ns); do_task_stat()
441 pgid = task_pgrp_nr_ns(task, ns); do_task_stat()
463 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state); do_task_stat()
544 int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, proc_tid_stat() argument
547 return do_task_stat(m, ns, pid, task, 0); proc_tid_stat()
550 int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, proc_tgid_stat() argument
553 return do_task_stat(m, ns, pid, task, 1); proc_tgid_stat()
556 int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, proc_pid_statm() argument
H A Dproc_net.c110 struct nsproxy *ns; get_proc_task_net() local
117 ns = task->nsproxy; get_proc_task_net()
118 if (ns != NULL) get_proc_task_net()
119 net = get_net(ns->net_ns); get_proc_task_net()
H A Dbase.c199 static int proc_pid_cmdline(struct seq_file *m, struct pid_namespace *ns, proc_pid_cmdline() argument
211 static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns, proc_pid_auxv() argument
233 static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, proc_pid_wchan() argument
272 static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, proc_pid_stack() argument
309 static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns, proc_pid_schedstat() argument
381 static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, proc_oom_score() argument
422 static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns, proc_pid_limits() argument
464 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns, proc_pid_syscall() argument
582 struct pid_namespace *ns; proc_single_show() local
587 ns = inode->i_sb->s_fs_info; proc_single_show()
593 ret = PROC_I(inode)->op.proc_show(m, ns, pid, task); proc_single_show()
1957 struct pid_namespace *ns; member in struct:timers_private
2018 pid_nr_ns(timer->it_pid, tp->ns)); show_timer()
2041 tp->ns = inode->i_sb->s_fs_info; proc_timers_open()
2385 static int proc_tid_io_accounting(struct seq_file *m, struct pid_namespace *ns, proc_tid_io_accounting() argument
2391 static int proc_tgid_io_accounting(struct seq_file *m, struct pid_namespace *ns, proc_tgid_io_accounting() argument
2402 struct user_namespace *ns = NULL; proc_id_map_open() local
2410 ns = get_user_ns(task_cred_xxx(task, user_ns)); proc_id_map_open()
2414 if (!ns) proc_id_map_open()
2422 seq->private = ns; proc_id_map_open()
2426 put_user_ns(ns); proc_id_map_open()
2434 struct user_namespace *ns = seq->private; proc_id_map_release() local
2435 put_user_ns(ns); proc_id_map_release()
2480 struct user_namespace *ns = NULL; proc_setgroups_open() local
2488 ns = get_user_ns(task_cred_xxx(task, user_ns)); proc_setgroups_open()
2492 if (!ns) proc_setgroups_open()
2497 if (!ns_capable(ns, CAP_SYS_ADMIN)) proc_setgroups_open()
2501 ret = single_open(file, &proc_setgroups_show, ns); proc_setgroups_open()
2507 put_user_ns(ns); proc_setgroups_open()
2515 struct user_namespace *ns = seq->private; proc_setgroups_release() local
2517 put_user_ns(ns); proc_setgroups_release()
2530 static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns, proc_pid_personality() argument
2554 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
2749 proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr, proc_flush_task()
2787 struct pid_namespace *ns; proc_pid_lookup() local
2793 ns = dentry->d_sb->s_fs_info; proc_pid_lookup()
2795 task = find_task_by_pid_ns(tgid, ns); proc_pid_lookup()
2816 static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter iter) next_tgid() argument
2825 pid = find_ge_pid(iter.tgid, ns); next_tgid()
2827 iter.tgid = pid_nr_ns(pid, ns); next_tgid()
2857 struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info; proc_pid_readdir() local
2864 struct inode *inode = d_inode(ns->proc_self); proc_pid_readdir()
2870 struct inode *inode = d_inode(ns->proc_thread_self); proc_pid_readdir()
2877 for (iter = next_tgid(ns, iter); proc_pid_readdir()
2879 iter.tgid += 1, iter = next_tgid(ns, iter)) { proc_pid_readdir()
2882 if (!has_pid_permissions(ns, iter.task, 2)) proc_pid_readdir()
2903 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
3041 struct pid_namespace *ns; proc_task_lookup() local
3050 ns = dentry->d_sb->s_fs_info; proc_task_lookup()
3052 task = find_task_by_pid_ns(tid, ns); proc_task_lookup()
3083 struct pid_namespace *ns) first_tid()
3098 pos = find_task_by_pid_ns(tid, ns); first_tid()
3152 struct pid_namespace *ns; proc_task_readdir() local
3164 ns = inode->i_sb->s_fs_info; proc_task_readdir()
3167 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); proc_task_readdir()
3172 tid = task_pid_nr_ns(task, ns); proc_task_readdir()
3082 first_tid(struct pid *pid, int tid, loff_t f_pos, struct pid_namespace *ns) first_tid() argument
/linux-4.1.27/arch/blackfin/mach-bf548/include/mach/
H A Dbf54x_keys.h16 u32 debounce_time; /* in ns */
17 u32 coldrive_time; /* in ns */
/linux-4.1.27/drivers/clk/qcom/
H A Dclk-rcg.c26 static u32 ns_to_src(struct src_sel *s, u32 ns) ns_to_src() argument
28 ns >>= s->src_sel_shift; ns_to_src()
29 ns &= SRC_SEL_MASK; ns_to_src()
30 return ns; ns_to_src()
33 static u32 src_to_ns(struct src_sel *s, u8 src, u32 ns) src_to_ns() argument
39 ns &= ~mask; src_to_ns()
41 ns |= src << s->src_sel_shift; src_to_ns()
42 return ns; src_to_ns()
49 u32 ns; clk_rcg_get_parent() local
52 ret = regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); clk_rcg_get_parent()
55 ns = ns_to_src(&rcg->s, ns); clk_rcg_get_parent()
57 if (ns == rcg->s.parent_map[i].cfg) clk_rcg_get_parent()
76 u32 ns, reg; clk_dyn_rcg_get_parent() local
87 ret = regmap_read(rcg->clkr.regmap, rcg->ns_reg[bank], &ns); clk_dyn_rcg_get_parent()
90 ns = ns_to_src(s, ns); clk_dyn_rcg_get_parent()
93 if (ns == s->parent_map[i].cfg) clk_dyn_rcg_get_parent()
105 u32 ns; clk_rcg_set_parent() local
107 regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); clk_rcg_set_parent()
108 ns = src_to_ns(&rcg->s, rcg->s.parent_map[index].cfg, ns); clk_rcg_set_parent()
109 regmap_write(rcg->clkr.regmap, rcg->ns_reg, ns); clk_rcg_set_parent()
121 static u32 ns_to_pre_div(struct pre_div *p, u32 ns) ns_to_pre_div() argument
123 ns >>= p->pre_div_shift; ns_to_pre_div()
124 ns &= BIT(p->pre_div_width) - 1; ns_to_pre_div()
125 return ns; ns_to_pre_div()
128 static u32 pre_div_to_ns(struct pre_div *p, u8 pre_div, u32 ns) pre_div_to_ns() argument
134 ns &= ~mask; pre_div_to_ns()
136 ns |= pre_div << p->pre_div_shift; pre_div_to_ns()
137 return ns; pre_div_to_ns()
157 static u32 ns_m_to_n(struct mn *mn, u32 ns, u32 m) ns_m_to_n() argument
159 ns = ~ns >> mn->n_val_shift; ns_m_to_n()
160 ns &= BIT(mn->width) - 1; ns_m_to_n()
161 return ns + m; ns_m_to_n()
171 static u32 mn_to_ns(struct mn *mn, u32 m, u32 n, u32 ns) mn_to_ns() argument
177 ns &= ~mask; mn_to_ns()
184 ns |= n; mn_to_ns()
187 return ns; mn_to_ns()
208 u32 ns, md, reg; configure_bank() local
228 ret = regmap_read(rcg->clkr.regmap, ns_reg, &ns); configure_bank()
236 ns |= BIT(mn->mnctr_reset_bit); configure_bank()
237 ret = regmap_write(rcg->clkr.regmap, ns_reg, ns); configure_bank()
248 ns = mn_to_ns(mn, f->m, f->n, ns); configure_bank()
249 ret = regmap_write(rcg->clkr.regmap, ns_reg, ns); configure_bank()
255 ns = mn_to_reg(mn, f->m, f->n, ns); configure_bank()
256 ret = regmap_write(rcg->clkr.regmap, ns_reg, ns); configure_bank()
267 ns &= ~BIT(mn->mnctr_reset_bit); configure_bank()
268 ret = regmap_write(rcg->clkr.regmap, ns_reg, ns); configure_bank()
275 ns = pre_div_to_ns(p, f->pre_div - 1, ns); configure_bank()
282 ns = src_to_ns(s, s->parent_map[index].cfg, ns); configure_bank()
283 ret = regmap_write(rcg->clkr.regmap, ns_reg, ns); configure_bank()
302 u32 ns, md, reg; clk_dyn_rcg_set_parent() local
311 regmap_read(rcg->clkr.regmap, rcg->ns_reg[bank], &ns); clk_dyn_rcg_set_parent()
316 f.n = ns_m_to_n(&rcg->mn[bank], ns, f.m); clk_dyn_rcg_set_parent()
320 f.pre_div = ns_to_pre_div(&rcg->p[bank], ns) + 1; clk_dyn_rcg_set_parent()
353 u32 pre_div, m = 0, n = 0, ns, md, mode = 0; clk_rcg_recalc_rate() local
356 regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); clk_rcg_recalc_rate()
357 pre_div = ns_to_pre_div(&rcg->p, ns); clk_rcg_recalc_rate()
362 n = ns_m_to_n(mn, ns, m); clk_rcg_recalc_rate()
367 mode = ns; clk_rcg_recalc_rate()
378 u32 m, n, pre_div, ns, md, mode, reg; clk_dyn_rcg_recalc_rate() local
387 regmap_read(rcg->clkr.regmap, rcg->ns_reg[bank], &ns); clk_dyn_rcg_recalc_rate()
394 n = ns_m_to_n(mn, ns, m); clk_dyn_rcg_recalc_rate()
397 reg = ns; clk_dyn_rcg_recalc_rate()
402 pre_div = ns_to_pre_div(&rcg->p[bank], ns); clk_dyn_rcg_recalc_rate()
489 u32 ns, md, ctl; __clk_rcg_set_rate() local
507 regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); __clk_rcg_set_rate()
514 ns = mn_to_reg(mn, f->m, f->n, ns); __clk_rcg_set_rate()
516 ns = mn_to_ns(mn, f->m, f->n, ns); __clk_rcg_set_rate()
518 regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); __clk_rcg_set_rate()
521 ns = pre_div_to_ns(&rcg->p, f->pre_div - 1, ns); __clk_rcg_set_rate()
522 regmap_write(rcg->clkr.regmap, rcg->ns_reg, ns); __clk_rcg_set_rate()
/linux-4.1.27/security/keys/
H A Dpersistent.c22 static int key_create_persistent_register(struct user_namespace *ns) key_create_persistent_register() argument
33 ns->persistent_keyring_register = reg; key_create_persistent_register()
42 static key_ref_t key_create_persistent(struct user_namespace *ns, kuid_t uid, key_create_persistent() argument
48 if (!ns->persistent_keyring_register) { key_create_persistent()
49 long err = key_create_persistent_register(ns); key_create_persistent()
53 reg_ref = make_key_ref(ns->persistent_keyring_register, true); key_create_persistent()
64 ns->persistent_keyring_register); key_create_persistent()
75 static long key_get_persistent(struct user_namespace *ns, kuid_t uid, key_get_persistent() argument
87 index_key.desc_len = sprintf(buf, "_persistent.%u", from_kuid(ns, uid)); key_get_persistent()
89 if (ns->persistent_keyring_register) { key_get_persistent()
90 reg_ref = make_key_ref(ns->persistent_keyring_register, true); key_get_persistent()
91 down_read(&ns->persistent_keyring_register_sem); key_get_persistent()
93 up_read(&ns->persistent_keyring_register_sem); key_get_persistent()
102 down_write(&ns->persistent_keyring_register_sem); key_get_persistent()
103 persistent_ref = key_create_persistent(ns, uid, &index_key); key_get_persistent()
104 up_write(&ns->persistent_keyring_register_sem); key_get_persistent()
131 struct user_namespace *ns = current_user_ns(); keyctl_get_persistent() local
140 uid = make_kuid(ns, _uid); keyctl_get_persistent()
149 !ns_capable(ns, CAP_SETUID)) keyctl_get_persistent()
162 ret = key_get_persistent(ns, uid, dest_ref); keyctl_get_persistent()
/linux-4.1.27/arch/mips/include/asm/
H A Ddelay.h17 extern void __ndelay(unsigned long ns);
20 #define ndelay(ns) __ndelay(ns)
/linux-4.1.27/security/apparmor/
H A Dpolicy.c68 * eg. :ns:/bin/bash//bin/ls
243 * aa_na_name - Find the ns name to display for @view from @curr
256 /* at this point if a ns is visible it is in a view ns aa_ns_name()
257 * thus the curr ns.hname is a prefix of its name. aa_ns_name()
277 struct aa_namespace *ns; alloc_namespace() local
279 ns = kzalloc(sizeof(*ns), GFP_KERNEL); alloc_namespace()
280 AA_DEBUG("%s(%p)\n", __func__, ns); alloc_namespace()
281 if (!ns) alloc_namespace()
283 if (!policy_init(&ns->base, prefix, name)) alloc_namespace()
286 INIT_LIST_HEAD(&ns->sub_ns); alloc_namespace()
287 mutex_init(&ns->lock); alloc_namespace()
290 ns->unconfined = aa_alloc_profile("unconfined"); alloc_namespace()
291 if (!ns->unconfined) alloc_namespace()
294 ns->unconfined->flags = PFLAG_IX_ON_NAME_ERROR | alloc_namespace()
296 ns->unconfined->mode = APPARMOR_UNCONFINED; alloc_namespace()
298 /* ns and ns->unconfined share ns->unconfined refcount */ alloc_namespace()
299 ns->unconfined->ns = ns; alloc_namespace()
301 atomic_set(&ns->uniq_null, 0); alloc_namespace()
303 return ns; alloc_namespace()
306 kzfree(ns->base.hname); alloc_namespace()
308 kzfree(ns); alloc_namespace()
314 * @ns: the namespace to free (MAYBE NULL)
319 static void free_namespace(struct aa_namespace *ns) free_namespace() argument
321 if (!ns) free_namespace()
324 policy_destroy(&ns->base); free_namespace()
325 aa_put_namespace(ns->parent); free_namespace()
327 ns->unconfined->ns = NULL; free_namespace()
328 aa_free_profile(ns->unconfined); free_namespace()
329 kzfree(ns); free_namespace()
360 struct aa_namespace *ns = NULL; aa_find_namespace() local
363 ns = aa_get_namespace(__aa_find_namespace(&root->sub_ns, name)); aa_find_namespace()
366 return ns; aa_find_namespace()
377 struct aa_namespace *ns, *root; aa_prepare_namespace() local
379 root = aa_current_profile()->ns; aa_prepare_namespace()
383 /* if name isn't specified the profile is loaded to the current ns */ aa_prepare_namespace()
386 ns = aa_get_namespace(root); aa_prepare_namespace()
390 /* try and find the specified ns and if it doesn't exist create it */ aa_prepare_namespace()
392 ns = aa_get_namespace(__aa_find_namespace(&root->sub_ns, name)); aa_prepare_namespace()
393 if (!ns) { aa_prepare_namespace()
394 ns = alloc_namespace(root->base.hname, name); aa_prepare_namespace()
395 if (!ns) aa_prepare_namespace()
397 if (__aa_fs_namespace_mkdir(ns, ns_subns_dir(root), name)) { aa_prepare_namespace()
398 AA_ERROR("Failed to create interface for ns %s\n", aa_prepare_namespace()
399 ns->base.name); aa_prepare_namespace()
400 free_namespace(ns); aa_prepare_namespace()
401 ns = NULL; aa_prepare_namespace()
404 ns->parent = aa_get_namespace(root); aa_prepare_namespace()
405 list_add_rcu(&ns->base.list, &root->sub_ns); aa_prepare_namespace()
407 aa_get_namespace(ns); aa_prepare_namespace()
413 return ns; aa_prepare_namespace()
464 __aa_update_replacedby(profile, profile->ns->unconfined); __remove_profile()
485 * destroy_namespace - remove everything contained by @ns
486 * @ns: namespace to have it contents removed (NOT NULL)
488 static void destroy_namespace(struct aa_namespace *ns) destroy_namespace() argument
490 if (!ns) destroy_namespace()
493 mutex_lock(&ns->lock); destroy_namespace()
495 __profile_list_release(&ns->base.profiles); destroy_namespace()
498 __ns_list_release(&ns->sub_ns); destroy_namespace()
500 if (ns->parent) destroy_namespace()
501 __aa_update_replacedby(ns->unconfined, ns->parent->unconfined); destroy_namespace()
502 __aa_fs_namespace_rmdir(ns); destroy_namespace()
503 mutex_unlock(&ns->lock); destroy_namespace()
508 * @ns: namespace to be removed (NOT NULL)
510 * Requires: ns->parent->lock be held and ns removed from parent.
512 static void __remove_namespace(struct aa_namespace *ns) __remove_namespace() argument
514 /* remove ns from namespace list */ __remove_namespace()
515 list_del_rcu(&ns->base.list); __remove_namespace()
516 destroy_namespace(ns); __remove_namespace()
517 aa_put_namespace(ns); __remove_namespace()
528 struct aa_namespace *ns, *tmp; __ns_list_release() local
529 list_for_each_entry_safe(ns, tmp, head, base.list) __ns_list_release()
530 __remove_namespace(ns); __ns_list_release()
555 struct aa_namespace *ns = root_ns; aa_free_root_ns() local
558 destroy_namespace(ns); aa_free_root_ns()
559 aa_put_namespace(ns); aa_free_root_ns()
601 aa_put_namespace(profile->ns); aa_free_profile()
625 free_namespace(p->ns); aa_free_profile_rcu()
692 int uniq = atomic_inc_return(&parent->ns->uniq_null); aa_new_null_profile()
712 profile->ns = aa_get_namespace(parent->ns); aa_new_null_profile()
714 mutex_lock(&profile->ns->lock); aa_new_null_profile()
716 mutex_unlock(&profile->ns->lock); aa_new_null_profile()
778 * @ns: namespace to lookup profile in (NOT NULL)
789 static struct aa_policy *__lookup_parent(struct aa_namespace *ns, __lookup_parent() argument
796 policy = &ns->base; __lookup_parent()
808 return &ns->base; __lookup_parent()
847 * @ns: the namespace to start from (NOT NULL)
852 struct aa_profile *aa_lookup_profile(struct aa_namespace *ns, const char *hname) aa_lookup_profile() argument
858 profile = __lookup_profile(&ns->base, hname); aa_lookup_profile()
864 profile = aa_get_newest_profile(ns->unconfined); aa_lookup_profile()
1032 * @ns - namespace the lookup occurs in
1040 static int __lookup_replace(struct aa_namespace *ns, const char *hname, __lookup_replace() argument
1044 *p = aa_get_profile(__lookup_profile(&ns->base, hname)); __lookup_replace()
1071 struct aa_namespace *ns = NULL; aa_replace_profiles() local
1083 ns = aa_prepare_namespace(ns_name); aa_replace_profiles()
1084 if (!ns) { aa_replace_profiles()
1091 mutex_lock(&ns->lock); aa_replace_profiles()
1092 /* setup parent and ns info */ aa_replace_profiles()
1097 error = __lookup_replace(ns, ent->new->base.hname, noreplace, aa_replace_profiles()
1103 error = __lookup_replace(ns, ent->new->rename, aa_replace_profiles()
1111 ent->new->ns = aa_get_namespace(ns); aa_replace_profiles()
1117 policy = __lookup_parent(ns, ent->new->base.hname); aa_replace_profiles()
1128 } else if (policy != &ns->base) { aa_replace_profiles()
1151 parent = ns_subprofs_dir(ent->new->ns); aa_replace_profiles()
1202 __list_add_profile(&ns->base.profiles, ent->new); aa_replace_profiles()
1206 mutex_unlock(&ns->lock); aa_replace_profiles()
1209 aa_put_namespace(ns); aa_replace_profiles()
1216 mutex_unlock(&ns->lock); aa_replace_profiles()
1242 struct aa_namespace *root, *ns = NULL; aa_remove_profiles() local
1253 root = aa_current_profile()->ns; aa_remove_profiles()
1259 ns = aa_find_namespace(root, ns_name); aa_remove_profiles()
1260 if (!ns) { aa_remove_profiles()
1267 ns = aa_get_namespace(root); aa_remove_profiles()
1271 mutex_lock(&ns->parent->lock); aa_remove_profiles()
1272 __remove_namespace(ns); aa_remove_profiles()
1273 mutex_unlock(&ns->parent->lock); aa_remove_profiles()
1276 mutex_lock(&ns->lock); aa_remove_profiles()
1277 profile = aa_get_profile(__lookup_profile(&ns->base, name)); aa_remove_profiles()
1285 mutex_unlock(&ns->lock); aa_remove_profiles()
1290 aa_put_namespace(ns); aa_remove_profiles()
1295 mutex_unlock(&ns->lock); aa_remove_profiles()
1296 aa_put_namespace(ns); aa_remove_profiles()
H A Dapparmorfs.c421 id_len = snprintf(NULL, 0, ".%ld", profile->ns->uniq_id); __aa_fs_profile_mkdir()
428 sprintf(profile->dirname + len, ".%ld", profile->ns->uniq_id++); __aa_fs_profile_mkdir()
477 void __aa_fs_namespace_rmdir(struct aa_namespace *ns) __aa_fs_namespace_rmdir() argument
483 if (!ns) __aa_fs_namespace_rmdir()
486 list_for_each_entry(child, &ns->base.profiles, base.list) __aa_fs_namespace_rmdir()
489 list_for_each_entry(sub, &ns->sub_ns, base.list) { __aa_fs_namespace_rmdir()
496 securityfs_remove(ns->dents[i]); __aa_fs_namespace_rmdir()
497 ns->dents[i] = NULL; __aa_fs_namespace_rmdir()
501 int __aa_fs_namespace_mkdir(struct aa_namespace *ns, struct dentry *parent, __aa_fs_namespace_mkdir() argument
510 name = ns->base.name; __aa_fs_namespace_mkdir()
515 ns_dir(ns) = dir = dent; __aa_fs_namespace_mkdir()
520 ns_subprofs_dir(ns) = dent; __aa_fs_namespace_mkdir()
525 ns_subns_dir(ns) = dent; __aa_fs_namespace_mkdir()
527 list_for_each_entry(child, &ns->base.profiles, base.list) { __aa_fs_namespace_mkdir()
528 error = __aa_fs_profile_mkdir(child, ns_subprofs_dir(ns)); __aa_fs_namespace_mkdir()
533 list_for_each_entry(sub, &ns->sub_ns, base.list) { __aa_fs_namespace_mkdir()
535 error = __aa_fs_namespace_mkdir(sub, ns_subns_dir(ns), NULL); __aa_fs_namespace_mkdir()
547 __aa_fs_namespace_rmdir(ns); __aa_fs_namespace_mkdir()
560 * @ns: current ns position (NOT NULL)
562 * Find the next namespace from @ns under @root and handle all locking needed
566 * Requires: ns->parent->lock to be held
570 struct aa_namespace *ns) __next_namespace()
575 if (!list_empty(&ns->sub_ns)) { __next_namespace()
576 next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list); __next_namespace()
581 /* check if the next ns is a sibling, parent, gp, .. */ __next_namespace()
582 parent = ns->parent; __next_namespace()
583 while (ns != root) { __next_namespace()
584 mutex_unlock(&ns->lock); __next_namespace()
585 next = list_entry_next(ns, base.list); __next_namespace()
590 ns = parent; __next_namespace()
600 * @ns: namespace to start in (NOT NULL)
603 * Requires: profile->ns.lock to be held
606 struct aa_namespace *ns) __first_profile()
608 for (; ns; ns = __next_namespace(root, ns)) { __first_profile()
609 if (!list_empty(&ns->base.profiles)) __first_profile()
610 return list_first_entry(&ns->base.profiles, __first_profile()
623 * Requires: profile->ns.lock to be held
628 struct aa_namespace *ns = p->ns; __next_profile() local
637 mutex_is_locked(&p->ns->lock)); __next_profile()
644 mutex_is_locked(&parent->ns->lock)); __next_profile()
649 if (!list_entry_is_head(p, &ns->base.profiles, base.list)) __next_profile()
670 return __first_profile(root, __next_namespace(root, profile->ns)); next_profile()
680 * acquires first ns->lock
685 struct aa_namespace *root = aa_current_profile()->ns; p_start()
714 struct aa_namespace *ns = f->private; p_next() local
717 return next_profile(ns, profile); p_next()
730 struct aa_namespace *root = f->private, *ns; p_stop() local
733 for (ns = profile->ns; ns && ns != root; ns = ns->parent) p_stop()
734 mutex_unlock(&ns->lock); p_stop()
752 if (profile->ns != root) seq_show_profile()
753 seq_printf(f, ":%s://", aa_ns_name(root, profile->ns)); seq_show_profile()
569 __next_namespace(struct aa_namespace *root, struct aa_namespace *ns) __next_namespace() argument
605 __first_profile(struct aa_namespace *root, struct aa_namespace *ns) __first_profile() argument
H A Ddomain.c88 * @ns: the namespace being switched to (NOT NULL)
96 struct aa_namespace *ns, change_profile_perms()
110 } else if ((ns == profile->ns)) { change_profile_perms()
118 state = aa_dfa_match(profile->file.dfa, start, ns->base.name); change_profile_perms()
167 * @ns: the current namespace (NOT NULL)
173 static struct aa_profile *find_attach(struct aa_namespace *ns, find_attach() argument
242 struct aa_namespace *ns = profile->ns; x_table_lookup() local
270 new_ns = aa_find_namespace(ns, ns_name); x_table_lookup()
282 new_profile = aa_lookup_profile(new_ns ? new_ns : ns, xname); x_table_lookup()
304 struct aa_namespace *ns = profile->ns; x_to_profile() local
314 new_profile = find_attach(ns, &profile->base.profiles, x_to_profile()
318 new_profile = find_attach(ns, &ns->base.profiles, x_to_profile()
341 struct aa_namespace *ns; apparmor_bprm_set_creds() local
365 ns = profile->ns; apparmor_bprm_set_creds()
388 new_profile = find_attach(ns, &ns->base.profiles, name); apparmor_bprm_set_creds()
412 cp = change_profile_perms(profile, cxt->onexec->ns, apparmor_bprm_set_creds()
435 new_profile = aa_get_newest_profile(ns->unconfined); apparmor_bprm_set_creds()
752 struct aa_namespace *ns = NULL; aa_change_profile() local
786 ns = aa_find_namespace(profile->ns, ns_name); aa_change_profile()
787 if (!ns) { aa_change_profile()
796 ns = aa_get_namespace(profile->ns); aa_change_profile()
801 hname = ns->unconfined->base.hname; aa_change_profile()
806 perms = change_profile_perms(profile, ns, hname, request, aa_change_profile()
814 target = aa_lookup_profile(ns, hname); aa_change_profile()
849 aa_put_namespace(ns); aa_change_profile()
95 change_profile_perms(struct aa_profile *profile, struct aa_namespace *ns, const char *name, u32 request, unsigned int start) change_profile_perms() argument
H A Dprocattr.c42 struct aa_namespace *ns = profile->ns; aa_getprocattr() local
43 struct aa_namespace *current_ns = __aa_current_profile()->ns; aa_getprocattr()
46 if (!aa_ns_visible(current_ns, ns)) aa_getprocattr()
49 ns_name = aa_ns_name(current_ns, ns); aa_getprocattr()
H A Dpolicy_unpack.c636 * @ns: Returns - namespace if one is specified else NULL (NOT NULL)
640 static int verify_header(struct aa_ext *e, int required, const char **ns) verify_header() argument
644 *ns = NULL; verify_header()
665 if (*ns && strcmp(*ns, name)) verify_header()
666 audit_iface(NULL, NULL, "invalid ns change", e, error); verify_header()
667 else if (!*ns) verify_header()
668 *ns = name; verify_header()
741 * @ns: Returns namespace profile is in if specified else NULL (NOT NULL)
749 int aa_unpack(void *udata, size_t size, struct list_head *lh, const char **ns) aa_unpack() argument
760 *ns = NULL; aa_unpack()
763 error = verify_header(&e, e.pos == e.start, ns); aa_unpack()
H A Dlib.c27 * @ns_name: pointer to portion of the string containing the ns name (NOT NULL)
53 /* a ns name without a following profile is allowed */ aa_split_fqname()
/linux-4.1.27/tools/perf/util/
H A Dtsc.h8 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
H A Dtsc.c6 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc) perf_time_to_tsc() argument
10 t = ns - tc->time_zero; perf_time_to_tsc()
/linux-4.1.27/fs/sysfs/
H A Dmount.c30 void *ns; sysfs_mount() local
38 ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); sysfs_mount()
40 SYSFS_MAGIC, &new_sb, ns); sysfs_mount()
42 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns); sysfs_mount()
48 void *ns = (void *)kernfs_super_ns(sb); sysfs_kill_sb() local
51 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns); sysfs_kill_sb()
H A Dsysfs.h35 umode_t amode, const void *ns);
H A Dsymlink.c123 const void *ns = NULL; sysfs_delete_link() local
132 ns = targ->sd->ns; sysfs_delete_link()
134 kernfs_remove_by_name_ns(kobj->sd, name, ns); sysfs_delete_link()
178 old_ns = targ->sd->ns; sysfs_rename_link_ns()
H A Dfile.c240 umode_t mode, const void *ns) sysfs_add_file_mode_ns()
298 (void *)attr, ns, key); sysfs_add_file_mode_ns()
314 * sysfs_create_file_ns - create an attribute file for an object with custom ns
317 * @ns: namespace the new file should belong to
320 const void *ns) sysfs_create_file_ns()
324 return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode, ns); sysfs_create_file_ns()
401 * sysfs_remove_file_ns - remove an object attribute with a custom ns tag
404 * @ns: namespace tag of the file to remove
409 const void *ns) sysfs_remove_file_ns()
413 kernfs_remove_by_name_ns(parent, attr->name, ns); sysfs_remove_file_ns()
238 sysfs_add_file_mode_ns(struct kernfs_node *parent, const struct attribute *attr, bool is_bin, umode_t mode, const void *ns) sysfs_add_file_mode_ns() argument
319 sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr, const void *ns) sysfs_create_file_ns() argument
408 sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, const void *ns) sysfs_remove_file_ns() argument
H A Ddir.c39 * @ns: the namespace tag to use
41 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) sysfs_create_dir_ns() argument
56 S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns); sysfs_create_dir_ns()
/linux-4.1.27/tools/testing/selftests/timers/
H A Dnsleep-lat.c90 struct timespec timespec_add(struct timespec ts, unsigned long long ns) timespec_add() argument
92 ts.tv_nsec += ns; timespec_add()
109 int nanosleep_lat_test(int clockid, long long ns) nanosleep_lat_test() argument
115 target.tv_sec = ns/NSEC_PER_SEC; nanosleep_lat_test()
116 target.tv_nsec = ns%NSEC_PER_SEC; nanosleep_lat_test()
131 if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) { nanosleep_lat_test()
132 printf("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns); nanosleep_lat_test()
139 target = timespec_add(start, ns); nanosleep_lat_test()
146 printf("Large abs latency: %lld ns :", latency/count); nanosleep_lat_test()
H A Dnanosleep.c101 struct timespec timespec_add(struct timespec ts, unsigned long long ns) timespec_add() argument
103 ts.tv_nsec += ns; timespec_add()
111 int nanosleep_test(int clockid, long long ns) nanosleep_test() argument
118 target = timespec_add(now, ns); nanosleep_test()
131 rel = timespec_add(rel, ns); nanosleep_test()
132 target = timespec_add(now, ns); nanosleep_test()
H A Draw_skew.c63 struct timespec nsec_to_ts(long long ns) nsec_to_ts() argument
67 ts.tv_sec = ns/NSEC_PER_SEC; nsec_to_ts()
68 ts.tv_nsec = ns%NSEC_PER_SEC; nsec_to_ts()
H A Dmqueue-lat.c59 struct timespec timespec_add(struct timespec ts, unsigned long long ns) timespec_add() argument
61 ts.tv_nsec += ns; timespec_add()
/linux-4.1.27/security/selinux/
H A Dnetif.c48 * @ns: the network namespace
56 static inline u32 sel_netif_hashfn(const struct net *ns, int ifindex) sel_netif_hashfn() argument
58 return (((uintptr_t)ns + ifindex) & (SEL_NETIF_HASH_SIZE - 1)); sel_netif_hashfn()
63 * @ns: the network namespace
71 static inline struct sel_netif *sel_netif_find(const struct net *ns, sel_netif_find() argument
74 int idx = sel_netif_hashfn(ns, ifindex); sel_netif_find()
78 if (net_eq(netif->nsec.ns, ns) && sel_netif_find()
101 idx = sel_netif_hashfn(netif->nsec.ns, netif->nsec.ifindex); sel_netif_insert()
125 * @ns: the network namespace
136 static int sel_netif_sid_slow(struct net *ns, int ifindex, u32 *sid) sel_netif_sid_slow() argument
146 dev = dev_get_by_index(ns, ifindex); sel_netif_sid_slow()
155 netif = sel_netif_find(ns, ifindex); sel_netif_sid_slow()
169 new->nsec.ns = ns; sel_netif_sid_slow()
191 * @ns: the network namespace
203 int sel_netif_sid(struct net *ns, int ifindex, u32 *sid) sel_netif_sid() argument
208 netif = sel_netif_find(ns, ifindex); sel_netif_sid()
216 return sel_netif_sid_slow(ns, ifindex, sid); sel_netif_sid()
221 * @ns: the network namespace
229 static void sel_netif_kill(const struct net *ns, int ifindex) sel_netif_kill() argument
235 netif = sel_netif_find(ns, ifindex); sel_netif_kill()
/linux-4.1.27/arch/tile/kernel/vdso/
H A Dvgettimeofday.c67 u64 ns; do_realtime() local
72 ns = vdso->wall_time_snsec; do_realtime()
73 ns += vgetsns(vdso); do_realtime()
74 ns >>= vdso->shift; do_realtime()
77 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); do_realtime()
78 ts->tv_nsec = ns; do_realtime()
86 u64 ns; do_monotonic() local
91 ns = vdso->monotonic_time_snsec; do_monotonic()
92 ns += vgetsns(vdso); do_monotonic()
93 ns >>= vdso->shift; do_monotonic()
96 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); do_monotonic()
97 ts->tv_nsec = ns; do_monotonic()
/linux-4.1.27/drivers/pcmcia/
H A Dsoc_common.h157 * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
158 * a minimum value of 165ns, as well. Section 4.7.2 (describing
160 * minimum value of 150ns for a 250ns cycle time (for 5V operation;
161 * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
163 * has a maximum value of 150ns for a 300ns cycle time (for 5V
164 * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
168 * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
169 * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
170 * memory command width time is 300ns.
H A Di82365.c93 /* External clock time, in nanoseconds. 120 ns = 8.33 MHz */
448 static u_int __init set_bridge_opts(u_short s, u_short ns) set_bridge_opts() argument
454 for (i = s; i < s+ns; i++) { set_bridge_opts()
565 static int to_cycles(int ns) to_cycles() argument
567 return ns/cycle_time; to_cycles()
673 static void __init add_pcic(int ns, int type) add_pcic() argument
677 struct i82365_socket *t = &socket[sockets-ns]; add_pcic()
679 base = sockets-ns; add_pcic()
684 printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); add_pcic()
692 mask &= I365_MASK & set_bridge_opts(base, ns); add_pcic()
727 for (i = 0; i < ns; i++) { add_pcic()
755 int i, j, sock, k, ns, id; isa_probe() local
811 for (j = ns = 0; j < 2; j++) { isa_probe()
822 add_socket(port, sock+j, id); ns++; isa_probe()
824 if (ns != 0) add_pcic(ns, id); isa_probe()
1036 pr_debug("SetIOMap(%d, %d, %#2.2x, %d ns, " i365_set_io_map()
1066 pr_debug("SetMemMap(%d, %d, %#2.2x, %d ns, %#llx-%#llx, " i365_set_mem_map()
/linux-4.1.27/arch/powerpc/boot/
H A Daddnote.c123 long nnote, nnote2, ns; main() local
178 ns = ph + 2 * ps; main()
181 PUT_32(ph + PH_OFFSET, ns); main()
183 PUT_64(ph + PH_OFFSET, ns); main()
192 PUT_32(ns, strlen(arch) + 1); main()
193 PUT_32(ns + 4, N_DESCR * 4); main()
194 PUT_32(ns + 8, 0x1275); main()
195 strcpy((char *) &buf[ns + 12], arch); main()
196 ns += 12 + strlen(arch) + 1; main()
197 for (i = 0; i < N_DESCR; ++i, ns += 4) main()
198 PUT_32BE(ns, descr[i]); main()
204 PUT_32(ph + PH_OFFSET, ns); main()
206 PUT_64(ph + PH_OFFSET, ns); main()
214 PUT_32(ns, strlen(rpaname) + 1); main()
215 PUT_32(ns + 4, sizeof(rpanote)); main()
216 PUT_32(ns + 8, 0x12759999); main()
217 strcpy((char *) &buf[ns + 12], rpaname); main()
218 ns += 12 + ROUNDUP(strlen(rpaname) + 1); main()
219 for (i = 0; i < N_RPA_DESCR; ++i, ns += 4) main()
220 PUT_32BE(ns, rpanote[i]); main()
H A Dsimpleboot.c31 const u32 *na, *ns, *reg, *timebase; platform_init() local
46 ns = fdt_getprop(_dtb_start, node, "#size-cells", &size); platform_init()
47 if (!ns || (size != 4)) platform_init()
56 if (size < (*na+*ns) * sizeof(u32)) platform_init()
66 for (i = 0; i < *ns; i++) platform_init()
/linux-4.1.27/tools/perf/scripts/python/
H A Dfutex-contention.py24 def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
32 thread_blocktime[tid] = nsecs(s, ns)
34 def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
37 elapsed = nsecs(s, ns) - thread_blocktime[tid]
48 print "%s[%d] lock %x contended %d times, %d avg ns" % \
/linux-4.1.27/drivers/scsi/bfa/
H A Dbfa_fcs_lport.c3654 static void bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s *ns,
3656 static void bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s *ns,
3658 static void bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s *ns,
3660 static void bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s *ns,
3663 struct bfa_fcs_lport_ns_s *ns,
3665 static void bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s *ns,
3667 static void bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s *ns,
3670 struct bfa_fcs_lport_ns_s *ns,
3672 static void bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s *ns,
3674 static void bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s *ns,
3677 struct bfa_fcs_lport_ns_s *ns,
3679 static void bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s *ns,
3681 static void bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s *ns,
3684 struct bfa_fcs_lport_ns_s *ns,
3686 static void bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s *ns,
3688 static void bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s *ns,
3690 static void bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s *ns,
3693 struct bfa_fcs_lport_ns_s *ns,
3695 static void bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s *ns,
3697 static void bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s *ns,
3700 struct bfa_fcs_lport_ns_s *ns,
3702 static void bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s *ns,
3705 struct bfa_fcs_lport_ns_s *ns,
3711 bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_offline() argument
3714 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_offline()
3715 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_offline()
3719 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_sending); bfa_fcs_lport_ns_sm_offline()
3720 bfa_fcs_lport_ns_send_plogi(ns, NULL); bfa_fcs_lport_ns_sm_offline()
3727 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_offline()
3732 bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_plogi_sending() argument
3735 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_plogi_sending()
3736 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi_sending()
3740 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi); bfa_fcs_lport_ns_sm_plogi_sending()
3744 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_plogi_sending()
3745 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_plogi_sending()
3746 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_plogi_sending()
3750 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi_sending()
3755 bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_plogi() argument
3758 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_plogi()
3759 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi()
3766 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_retry); bfa_fcs_lport_ns_sm_plogi()
3767 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_plogi()
3768 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_plogi()
3769 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_plogi() local
3774 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rnn_id); bfa_fcs_lport_ns_sm_plogi()
3775 ns->num_rnnid_retries = 0; bfa_fcs_lport_ns_sm_plogi()
3776 bfa_fcs_lport_ns_send_rnn_id(ns, NULL); bfa_fcs_lport_ns_sm_plogi()
3780 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_plogi()
3781 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_plogi()
3785 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi()
3790 bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_plogi_retry() argument
3793 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_plogi_retry()
3794 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi_retry()
3801 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_sending); bfa_fcs_lport_ns_sm_plogi_retry()
3802 bfa_fcs_lport_ns_send_plogi(ns, NULL); bfa_fcs_lport_ns_sm_plogi_retry()
3806 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_plogi_retry()
3807 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_plogi_retry()
3811 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_plogi_retry()
3816 bfa_fcs_lport_ns_sm_sending_rnn_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_rnn_id() argument
3819 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_rnn_id()
3820 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rnn_id()
3824 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rnn_id); bfa_fcs_lport_ns_sm_sending_rnn_id()
3828 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_rnn_id()
3829 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_rnn_id()
3830 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_rnn_id()
3833 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rnn_id()
3838 bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rnn_id() argument
3841 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rnn_id()
3842 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rnn_id()
3846 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rsnn_nn); bfa_fcs_lport_ns_sm_rnn_id()
3847 ns->num_rnnid_retries = 0; bfa_fcs_lport_ns_sm_rnn_id()
3848 ns->num_rsnn_nn_retries = 0; bfa_fcs_lport_ns_sm_rnn_id()
3849 bfa_fcs_lport_ns_send_rsnn_nn(ns, NULL); bfa_fcs_lport_ns_sm_rnn_id()
3853 if (ns->num_rnnid_retries < BFA_FCS_MAX_NS_RETRIES) { bfa_fcs_lport_ns_sm_rnn_id()
3854 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rnn_id_retry); bfa_fcs_lport_ns_sm_rnn_id()
3855 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_rnn_id()
3856 ns->num_rnnid_retries++; bfa_fcs_lport_ns_sm_rnn_id()
3857 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_rnn_id()
3858 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_rnn_id() local
3861 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rnn_id()
3863 bfa_fcs_lport_ns_send_rspn_id(ns, NULL); bfa_fcs_lport_ns_sm_rnn_id()
3868 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_rnn_id()
3869 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rnn_id()
3873 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rnn_id()
3878 bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rnn_id_retry() argument
3881 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rnn_id_retry()
3882 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rnn_id_retry()
3886 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rnn_id); bfa_fcs_lport_ns_sm_rnn_id_retry()
3887 bfa_fcs_lport_ns_send_rnn_id(ns, NULL); bfa_fcs_lport_ns_sm_rnn_id_retry()
3891 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rnn_id_retry()
3892 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_rnn_id_retry()
3896 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rnn_id_retry()
3901 bfa_fcs_lport_ns_sm_sending_rsnn_nn(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_rsnn_nn() argument
3904 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3905 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3909 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rsnn_nn); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3913 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3914 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3915 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3919 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rsnn_nn()
3924 bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rsnn_nn() argument
3927 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rsnn_nn()
3928 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rsnn_nn()
3932 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rspn_id); bfa_fcs_lport_ns_sm_rsnn_nn()
3933 ns->num_rsnn_nn_retries = 0; bfa_fcs_lport_ns_sm_rsnn_nn()
3934 bfa_fcs_lport_ns_send_rspn_id(ns, NULL); bfa_fcs_lport_ns_sm_rsnn_nn()
3938 if (ns->num_rsnn_nn_retries < BFA_FCS_MAX_NS_RETRIES) { bfa_fcs_lport_ns_sm_rsnn_nn()
3939 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rsnn_nn_retry); bfa_fcs_lport_ns_sm_rsnn_nn()
3940 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_rsnn_nn()
3941 ns->num_rsnn_nn_retries++; bfa_fcs_lport_ns_sm_rsnn_nn()
3942 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_rsnn_nn()
3943 &ns->timer, bfa_fcs_lport_ns_timeout, bfa_fcs_lport_ns_sm_rsnn_nn()
3944 ns, BFA_FCS_RETRY_TIMEOUT); bfa_fcs_lport_ns_sm_rsnn_nn() local
3946 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rsnn_nn()
3948 bfa_fcs_lport_ns_send_rspn_id(ns, NULL); bfa_fcs_lport_ns_sm_rsnn_nn()
3953 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rsnn_nn()
3954 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_rsnn_nn()
3958 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rsnn_nn()
3963 bfa_fcs_lport_ns_sm_rsnn_nn_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rsnn_nn_retry() argument
3966 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3967 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3971 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rsnn_nn); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3972 bfa_fcs_lport_ns_send_rsnn_nn(ns, NULL); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3976 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3977 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3981 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rsnn_nn_retry()
3986 bfa_fcs_lport_ns_sm_sending_rspn_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_rspn_id() argument
3989 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_rspn_id()
3990 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rspn_id()
3994 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rspn_id); bfa_fcs_lport_ns_sm_sending_rspn_id()
3998 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_rspn_id()
3999 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_rspn_id()
4000 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_rspn_id()
4004 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rspn_id()
4009 bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rspn_id() argument
4012 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rspn_id()
4013 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rspn_id()
4020 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rspn_id_retry); bfa_fcs_lport_ns_sm_rspn_id()
4021 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_rspn_id()
4022 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_rspn_id()
4023 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_rspn_id() local
4028 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rft_id); bfa_fcs_lport_ns_sm_rspn_id()
4029 bfa_fcs_lport_ns_send_rft_id(ns, NULL); bfa_fcs_lport_ns_sm_rspn_id()
4033 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_rspn_id()
4034 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rspn_id()
4038 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rspn_id()
4043 bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rspn_id_retry() argument
4046 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rspn_id_retry()
4047 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rspn_id_retry()
4054 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rspn_id); bfa_fcs_lport_ns_sm_rspn_id_retry()
4055 bfa_fcs_lport_ns_send_rspn_id(ns, NULL); bfa_fcs_lport_ns_sm_rspn_id_retry()
4059 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rspn_id_retry()
4060 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_rspn_id_retry()
4064 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rspn_id_retry()
4069 bfa_fcs_lport_ns_sm_sending_rft_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_rft_id() argument
4072 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_rft_id()
4073 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rft_id()
4077 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rft_id); bfa_fcs_lport_ns_sm_sending_rft_id()
4081 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_rft_id()
4082 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_rft_id()
4083 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_rft_id()
4087 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rft_id()
4092 bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rft_id() argument
4095 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rft_id()
4096 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rft_id()
4101 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rff_id); bfa_fcs_lport_ns_sm_rft_id()
4102 bfa_fcs_lport_ns_send_rff_id(ns, NULL); bfa_fcs_lport_ns_sm_rft_id()
4109 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rft_id_retry); bfa_fcs_lport_ns_sm_rft_id()
4110 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_rft_id()
4111 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_rft_id()
4112 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_rft_id() local
4117 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rft_id()
4118 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_rft_id()
4122 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rft_id()
4127 bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rft_id_retry() argument
4130 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rft_id_retry()
4131 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rft_id_retry()
4135 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rft_id); bfa_fcs_lport_ns_sm_rft_id_retry()
4136 bfa_fcs_lport_ns_send_rft_id(ns, NULL); bfa_fcs_lport_ns_sm_rft_id_retry()
4140 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rft_id_retry()
4141 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_rft_id_retry()
4145 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rft_id_retry()
4150 bfa_fcs_lport_ns_sm_sending_rff_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_rff_id() argument
4153 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_rff_id()
4154 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rff_id()
4158 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rff_id); bfa_fcs_lport_ns_sm_sending_rff_id()
4162 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_rff_id()
4163 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_rff_id()
4164 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_rff_id()
4168 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_rff_id()
4173 bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rff_id() argument
4176 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rff_id()
4177 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rff_id()
4187 if (__fcs_min_cfg(ns->port->fcs)) { bfa_fcs_lport_ns_sm_rff_id()
4188 bfa_fcs_lport_ns_boot_target_disc(ns->port); bfa_fcs_lport_ns_sm_rff_id()
4189 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_online); bfa_fcs_lport_ns_sm_rff_id()
4197 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) { bfa_fcs_lport_ns_sm_rff_id()
4198 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rff_id()
4200 bfa_fcs_lport_ns_send_gid_ft(ns, NULL); bfa_fcs_lport_ns_sm_rff_id()
4205 bfa_fcs_lport_ms_online(ns->port); bfa_fcs_lport_ns_sm_rff_id()
4212 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rff_id_retry); bfa_fcs_lport_ns_sm_rff_id()
4213 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_rff_id()
4214 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_rff_id()
4215 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_rff_id() local
4220 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rff_id()
4221 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_rff_id()
4225 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rff_id()
4230 bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_rff_id_retry() argument
4233 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_rff_id_retry()
4234 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rff_id_retry()
4238 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rff_id); bfa_fcs_lport_ns_sm_rff_id_retry()
4239 bfa_fcs_lport_ns_send_rff_id(ns, NULL); bfa_fcs_lport_ns_sm_rff_id_retry()
4243 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_rff_id_retry()
4244 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_rff_id_retry()
4248 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_rff_id_retry()
4252 bfa_fcs_lport_ns_sm_sending_gid_ft(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_sending_gid_ft() argument
4255 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_sending_gid_ft()
4256 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_gid_ft()
4260 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_gid_ft); bfa_fcs_lport_ns_sm_sending_gid_ft()
4264 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_sending_gid_ft()
4265 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_sending_gid_ft()
4266 &ns->fcxp_wqe); bfa_fcs_lport_ns_sm_sending_gid_ft()
4270 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_sending_gid_ft()
4275 bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_gid_ft() argument
4278 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_gid_ft()
4279 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_gid_ft()
4283 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_online); bfa_fcs_lport_ns_sm_gid_ft()
4293 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_gid_ft_retry); bfa_fcs_lport_ns_sm_gid_ft()
4294 ns->port->stats.ns_retries++; bfa_fcs_lport_ns_sm_gid_ft()
4295 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), bfa_fcs_lport_ns_sm_gid_ft()
4296 &ns->timer, bfa_fcs_lport_ns_timeout, ns, bfa_fcs_lport_ns_sm_gid_ft() local
4301 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_gid_ft()
4302 bfa_fcxp_discard(ns->fcxp); bfa_fcs_lport_ns_sm_gid_ft()
4309 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_gid_ft()
4314 bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_gid_ft_retry() argument
4317 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_gid_ft_retry()
4318 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_gid_ft_retry()
4322 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_gid_ft); bfa_fcs_lport_ns_sm_gid_ft_retry()
4323 bfa_fcs_lport_ns_send_gid_ft(ns, NULL); bfa_fcs_lport_ns_sm_gid_ft_retry()
4327 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_gid_ft_retry()
4328 bfa_timer_stop(&ns->timer); bfa_fcs_lport_ns_sm_gid_ft_retry()
4332 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_gid_ft_retry()
4337 bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s *ns, bfa_fcs_lport_ns_sm_online() argument
4340 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn); bfa_fcs_lport_ns_sm_online()
4341 bfa_trc(ns->port->fcs, event); bfa_fcs_lport_ns_sm_online()
4345 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_sm_online()
4353 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) { bfa_fcs_lport_ns_sm_online()
4354 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_online()
4356 bfa_fcs_lport_ns_send_gid_ft(ns, NULL); bfa_fcs_lport_ns_sm_online()
4361 bfa_sm_fault(ns->port->fcs, event); bfa_fcs_lport_ns_sm_online()
4374 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_plogi() local
4375 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_plogi()
4386 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_plogi()
4387 bfa_fcs_lport_ns_send_plogi, ns, BFA_TRUE); bfa_fcs_lport_ns_send_plogi()
4390 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_plogi()
4401 bfa_fcs_lport_ns_plogi_response, (void *)ns, bfa_fcs_lport_ns_send_plogi()
4405 bfa_sm_send_event(ns, NSSM_EVENT_PLOGI_SENT); bfa_fcs_lport_ns_send_plogi()
4413 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_plogi_response() local
4414 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_plogi_response()
4428 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_plogi_response()
4440 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_plogi_response()
4444 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_plogi_response()
4455 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_plogi_response()
4461 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_plogi_response()
4471 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_rnn_id() local
4472 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_rnn_id()
4483 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_rnn_id()
4484 bfa_fcs_lport_ns_send_rnn_id, ns, BFA_TRUE); bfa_fcs_lport_ns_send_rnn_id()
4488 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_rnn_id()
4497 bfa_fcs_lport_ns_rnn_id_response, (void *)ns, bfa_fcs_lport_ns_send_rnn_id()
4501 bfa_sm_send_event(ns, NSSM_EVENT_RNNID_SENT); bfa_fcs_lport_ns_send_rnn_id()
4511 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_rnn_id_response() local
4512 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_rnn_id_response()
4523 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rnn_id_response()
4532 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rnn_id_response()
4539 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rnn_id_response()
4548 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_rsnn_nn() local
4549 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_rsnn_nn()
4561 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_rsnn_nn()
4562 bfa_fcs_lport_ns_send_rsnn_nn, ns, BFA_TRUE); bfa_fcs_lport_ns_send_rsnn_nn()
4565 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_rsnn_nn()
4576 bfa_fcs_lport_ns_rsnn_nn_response, (void *)ns, bfa_fcs_lport_ns_send_rsnn_nn()
4581 bfa_sm_send_event(ns, NSSM_EVENT_RSNN_NN_SENT); bfa_fcs_lport_ns_send_rsnn_nn()
4590 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_rsnn_nn_response() local
4591 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_rsnn_nn_response()
4602 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rsnn_nn_response()
4611 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rsnn_nn_response()
4618 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rsnn_nn_response()
4627 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_rspn_id() local
4628 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_rspn_id()
4643 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_rspn_id()
4644 bfa_fcs_lport_ns_send_rspn_id, ns, BFA_TRUE); bfa_fcs_lport_ns_send_rspn_id()
4647 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_rspn_id()
4682 bfa_fcs_lport_ns_rspn_id_response, (void *)ns, bfa_fcs_lport_ns_send_rspn_id()
4687 bfa_sm_send_event(ns, NSSM_EVENT_RSPNID_SENT); bfa_fcs_lport_ns_send_rspn_id()
4696 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_rspn_id_response() local
4697 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_rspn_id_response()
4708 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rspn_id_response()
4717 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rspn_id_response()
4724 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rspn_id_response()
4733 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_rft_id() local
4734 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_rft_id()
4745 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_rft_id()
4746 bfa_fcs_lport_ns_send_rft_id, ns, BFA_TRUE); bfa_fcs_lport_ns_send_rft_id()
4749 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_rft_id()
4756 bfa_fcs_lport_ns_rft_id_response, (void *)ns, bfa_fcs_lport_ns_send_rft_id()
4760 bfa_sm_send_event(ns, NSSM_EVENT_RFTID_SENT); bfa_fcs_lport_ns_send_rft_id()
4769 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_rft_id_response() local
4770 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_rft_id_response()
4781 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rft_id_response()
4790 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rft_id_response()
4797 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rft_id_response()
4806 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_rff_id() local
4807 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_rff_id()
4819 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_rff_id()
4820 bfa_fcs_lport_ns_send_rff_id, ns, BFA_TRUE); bfa_fcs_lport_ns_send_rff_id()
4823 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_rff_id()
4825 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) bfa_fcs_lport_ns_send_rff_id()
4834 bfa_fcs_lport_ns_rff_id_response, (void *)ns, bfa_fcs_lport_ns_send_rff_id()
4838 bfa_sm_send_event(ns, NSSM_EVENT_RFFID_SENT); bfa_fcs_lport_ns_send_rff_id()
4847 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_rff_id_response() local
4848 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_rff_id_response()
4859 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rff_id_response()
4868 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rff_id_response()
4878 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_rff_id_response()
4880 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_rff_id_response()
4891 struct bfa_fcs_lport_ns_s *ns = ns_cbarg; bfa_fcs_lport_ns_send_gid_ft() local
4892 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_send_gid_ft()
4903 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_send_gid_ft()
4904 bfa_fcs_lport_ns_send_gid_ft, ns, BFA_TRUE); bfa_fcs_lport_ns_send_gid_ft()
4907 ns->fcxp = fcxp; bfa_fcs_lport_ns_send_gid_ft()
4913 ns->port->pid, FC_TYPE_FCP); bfa_fcs_lport_ns_send_gid_ft()
4917 bfa_fcs_lport_ns_gid_ft_response, (void *)ns, bfa_fcs_lport_ns_send_gid_ft()
4922 bfa_sm_send_event(ns, NSSM_EVENT_GIDFT_SENT); bfa_fcs_lport_ns_send_gid_ft()
4931 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg; bfa_fcs_lport_ns_gid_ft_response() local
4932 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_gid_ft_response()
4944 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_gid_ft_response()
4971 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_gid_ft_response()
4987 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK); bfa_fcs_lport_ns_gid_ft_response()
4992 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_gid_ft_response()
4999 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR); bfa_fcs_lport_ns_gid_ft_response()
5018 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) arg; bfa_fcs_lport_ns_timeout() local
5020 ns->port->stats.ns_timeouts++; bfa_fcs_lport_ns_timeout()
5021 bfa_sm_send_event(ns, NSSM_EVENT_TIMEOUT); bfa_fcs_lport_ns_timeout()
5100 * These will send relevant Events to the ns state machine.
5105 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port); bfa_fcs_lport_ns_init() local
5107 ns->port = port; bfa_fcs_lport_ns_init()
5108 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline); bfa_fcs_lport_ns_init()
5114 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port); bfa_fcs_lport_ns_offline() local
5116 ns->port = port; bfa_fcs_lport_ns_offline()
5117 bfa_sm_send_event(ns, NSSM_EVENT_PORT_OFFLINE); bfa_fcs_lport_ns_offline()
5123 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port); bfa_fcs_lport_ns_online() local
5125 ns->port = port; bfa_fcs_lport_ns_online()
5126 bfa_sm_send_event(ns, NSSM_EVENT_PORT_ONLINE); bfa_fcs_lport_ns_online()
5132 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port); bfa_fcs_lport_ns_query() local
5135 if (bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_online)) bfa_fcs_lport_ns_query()
5136 bfa_sm_send_event(ns, NSSM_EVENT_NS_QUERY); bfa_fcs_lport_ns_query()
5159 struct bfa_fcs_lport_ns_s *ns = cbarg; bfa_fcs_lport_ns_util_send_rspn_id() local
5160 struct bfa_fcs_lport_s *port = ns->port; bfa_fcs_lport_ns_util_send_rspn_id()
5168 if (bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_offline) || bfa_fcs_lport_ns_util_send_rspn_id()
5169 bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi_sending) || bfa_fcs_lport_ns_util_send_rspn_id()
5170 bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi) || bfa_fcs_lport_ns_util_send_rspn_id()
5171 bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi_retry) || bfa_fcs_lport_ns_util_send_rspn_id()
5172 bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_rspn_id_retry)) bfa_fcs_lport_ns_util_send_rspn_id()
5182 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe, bfa_fcs_lport_ns_util_send_rspn_id()
5183 bfa_fcs_lport_ns_util_send_rspn_id, ns, BFA_FALSE); bfa_fcs_lport_ns_util_send_rspn_id()
5187 ns->fcxp = fcxp; bfa_fcs_lport_ns_util_send_rspn_id()
/linux-4.1.27/arch/sparc/kernel/
H A Dof_device_common.h15 const u32 *size, int na, int ns);
16 int of_bus_default_map(u32 *addr, const u32 *range, int na, int ns, int pna);
32 int na, int ns, int pna);
H A Dof_device_32.c49 int na, int ns, int pna) of_bus_pci_map()
59 na - 1, ns)) of_bus_pci_map()
121 int na, int ns, int pna) of_bus_ambapp_map()
123 return of_bus_default_map(addr, range, na, ns, pna); of_bus_ambapp_map()
190 int na, int ns, int pna) build_one_resource()
212 rone = na + pna + ns; build_one_resource()
214 if (!bus->map(addr, ranges, na, ns, pna)) build_one_resource()
249 int na, ns; build_device_resources() local
258 bus->count_cells(op->dev.of_node, &na, &ns); build_device_resources()
268 num_reg /= na + ns; build_device_resources()
275 const u32 *reg = (preg + (index * ((na + ns) * 4))); build_device_resources()
284 size = of_read_addr(reg + na, ns); build_device_resources()
296 dns = ns; build_device_resources()
48 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) of_bus_pci_map() argument
120 of_bus_ambapp_map(u32 *addr, const u32 *range, int na, int ns, int pna) of_bus_ambapp_map() argument
186 build_one_resource(struct device_node *parent, struct of_bus *bus, struct of_bus *pbus, u32 *addr, int na, int ns, int pna) build_one_resource() argument
H A Dof_device_common.c96 const u32 *size, int na, int ns) of_out_of_range()
104 b += of_read_addr(size, ns); of_out_of_range()
111 int of_bus_default_map(u32 *addr, const u32 *range, int na, int ns, int pna) of_bus_default_map() argument
116 if (ns > 2) { of_bus_default_map()
117 printk("of_device: Cannot handle size cells (%d) > 2.", ns); of_bus_default_map()
121 if (of_out_of_range(addr, range, range + na + pna, na, ns)) of_bus_default_map()
95 of_out_of_range(const u32 *addr, const u32 *base, const u32 *size, int na, int ns) of_out_of_range() argument
H A Dof_device_64.c87 int na, int ns, int pna) of_bus_simba_map()
102 int na, int ns, int pna) of_bus_pci_map()
122 na - 1, ns)) of_bus_pci_map()
244 int na, int ns, int pna) build_one_resource()
265 rone = na + pna + ns; build_one_resource()
267 if (!bus->map(addr, ranges, na, ns, pna)) build_one_resource()
319 int na, ns; build_device_resources() local
328 bus->count_cells(op->dev.of_node, &na, &ns); build_device_resources()
338 num_reg /= na + ns; build_device_resources()
353 const u32 *reg = (preg + (index * ((na + ns) * 4))); build_device_resources()
362 size = of_read_addr(reg + na, ns); build_device_resources()
373 dns = ns; build_device_resources()
86 of_bus_simba_map(u32 *addr, const u32 *range, int na, int ns, int pna) of_bus_simba_map() argument
101 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) of_bus_pci_map() argument
240 build_one_resource(struct device_node *parent, struct of_bus *bus, struct of_bus *pbus, u32 *addr, int na, int ns, int pna) build_one_resource() argument
/linux-4.1.27/include/linux/usb/
H A Disp116x.h24 /* Inter-io delay (ns). The chip is picky about access timings; it
26 150ns delay between consecutive accesses to DATA_REG,
27 300ns delay between access to ADDR_REG and DATA_REG
H A Disp1362.h36 /* Inter-io delay (ns). The chip is picky about access timings; it
38 * 110ns delay between consecutive accesses to DATA_REG,
39 * 300ns delay between access to ADDR_REG and DATA_REG (registers)
40 * 462ns delay between access to ADDR_REG and DATA_REG (buffer memory)
/linux-4.1.27/init/
H A Dversion.c38 .ns.inum = PROC_UTS_INIT_INO,
40 .ns.ops = &utsns_operations,
/linux-4.1.27/arch/cris/include/arch-v32/arch/
H A Dtimex.h15 /* The timer0 values gives 10 ns resolution but interrupts at HZ. */
19 /* Convert the value in step of 10 ns to 1us without overflow: */
/linux-4.1.27/drivers/ptp/
H A Dptp_ixp46x.c56 u64 ns; ixp_systime_read() local
62 ns = ((u64) hi) << 32; ixp_systime_read()
63 ns |= lo; ixp_systime_read()
64 ns <<= TICKS_NS_SHIFT; ixp_systime_read()
66 return ns; ixp_systime_read()
69 static void ixp_systime_write(struct ixp46x_ts_regs *regs, u64 ns) ixp_systime_write() argument
73 ns >>= TICKS_NS_SHIFT; ixp_systime_write()
74 hi = ns >> 32; ixp_systime_write()
75 lo = ns & 0xffffffff; ixp_systime_write()
180 u64 ns; ptp_ixp_gettime() local
188 ns = ixp_systime_read(regs); ptp_ixp_gettime()
192 ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); ptp_ixp_gettime()
200 u64 ns; ptp_ixp_settime() local
205 ns = ts->tv_sec * 1000000000ULL; ptp_ixp_settime()
206 ns += ts->tv_nsec; ptp_ixp_settime()
210 ixp_systime_write(regs, ns); ptp_ixp_settime()
H A Dptp_pch.c159 u64 ns; pch_systime_read() local
165 ns = ((u64) hi) << 32; pch_systime_read()
166 ns |= lo; pch_systime_read()
167 ns <<= TICKS_NS_SHIFT; pch_systime_read()
169 return ns; pch_systime_read()
172 static void pch_systime_write(struct pch_ts_regs __iomem *regs, u64 ns) pch_systime_write() argument
176 ns >>= TICKS_NS_SHIFT; pch_systime_write()
177 hi = ns >> 32; pch_systime_write()
178 lo = ns & 0xffffffff; pch_systime_write()
257 u64 ns; pch_rx_snap_read() local
263 ns = ((u64) hi) << 32; pch_rx_snap_read()
264 ns |= lo; pch_rx_snap_read()
265 ns <<= TICKS_NS_SHIFT; pch_rx_snap_read()
267 return ns; pch_rx_snap_read()
274 u64 ns; pch_tx_snap_read() local
280 ns = ((u64) hi) << 32; pch_tx_snap_read()
281 ns |= lo; pch_tx_snap_read()
282 ns <<= TICKS_NS_SHIFT; pch_tx_snap_read()
284 return ns; pch_tx_snap_read()
454 u64 ns; ptp_pch_gettime() local
461 ns = pch_systime_read(regs); ptp_pch_gettime()
464 ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); ptp_pch_gettime()
472 u64 ns; ptp_pch_settime() local
477 ns = ts->tv_sec * 1000000000ULL; ptp_pch_settime()
478 ns += ts->tv_nsec; ptp_pch_settime()
481 pch_systime_write(regs, ns); ptp_pch_settime()
/linux-4.1.27/drivers/of/
H A Dfdt_address.c23 #define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
24 (ns) > 0)
44 int na, int ns, int pna); of_dump_addr()
72 int na, int ns, int pna) fdt_bus_default_map()
77 s = of_read_number(range + na + pna, ns); fdt_bus_default_map()
113 int na, int ns, int pna, const char *rprop) fdt_translate_one()
134 rone = na + pna + ns; fdt_translate_one()
136 offset = bus->map(addr, ranges, na, ns, pna); fdt_translate_one()
170 int na, ns, pna, pns; fdt_translate_address() local
190 bus->count_cells(blob, parent, &na, &ns); fdt_translate_address()
191 if (!OF_CHECK_COUNTS(na, ns)) { fdt_translate_address()
198 pr_debug("FDT: bus (na=%d, ns=%d) on %s\n", fdt_translate_address()
199 na, ns, fdt_get_name(blob, parent, NULL)); fdt_translate_address()
224 pr_debug("FDT: parent bus (na=%d, ns=%d) on %s\n", fdt_translate_address()
229 addr, na, ns, pna, "ranges")) fdt_translate_address()
234 ns = pns; fdt_translate_address()
71 fdt_bus_default_map(__be32 *addr, const __be32 *range, int na, int ns, int pna) fdt_bus_default_map() argument
110 fdt_translate_one(const void *blob, int parent, const struct of_bus *bus, const struct of_bus *pbus, __be32 *addr, int na, int ns, int pna, const char *rprop) fdt_translate_one() argument
H A Daddress.c15 #define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0)
43 int na, int ns, int pna); of_dump_addr()
62 int na, int ns, int pna) of_bus_default_map()
67 s = of_read_number(range + na + pna, ns); of_bus_default_map()
140 static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int na, int ns, of_bus_pci_map() argument
155 s = of_read_number(range + na + pna, ns); of_bus_pci_map()
181 int onesize, i, na, ns; of_get_pci_address() local
192 bus->count_cells(dev, &na, &ns); of_get_pci_address()
203 onesize = na + ns; of_get_pci_address()
208 *size = of_read_number(prop + na, ns); of_get_pci_address()
235 const int na = 3, ns = 2; of_pci_range_parser_init() local
240 parser->np = parser->pna + na + ns; of_pci_range_parser_init()
255 const int na = 3, ns = 2; of_pci_range_parser_one() local
265 range->pci_addr = of_read_number(parser->range + 1, ns); of_pci_range_parser_one()
268 range->size = of_read_number(parser->range + parser->pna + na, ns); of_pci_range_parser_one()
279 pci_addr = of_read_number(parser->range + 1, ns); of_pci_range_parser_one()
282 size = of_read_number(parser->range + parser->pna + na, ns); of_pci_range_parser_one()
363 static u64 of_bus_isa_map(__be32 *addr, const __be32 *range, int na, int ns, of_bus_isa_map() argument
374 s = of_read_number(range + na + pna, ns); of_bus_isa_map()
475 int na, int ns, int pna, const char *rprop) of_translate_one()
513 rone = na + pna + ns; of_translate_one()
515 offset = bus->map(addr, ranges, na, ns, pna); of_translate_one()
549 int na, ns, pna, pns; __of_translate_address() local
564 bus->count_cells(dev, &na, &ns); __of_translate_address()
565 if (!OF_CHECK_COUNTS(na, ns)) { __of_translate_address()
571 pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n", __of_translate_address()
572 bus->name, na, ns, of_node_full_name(parent)); __of_translate_address()
598 pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n", __of_translate_address()
602 if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop)) __of_translate_address()
607 ns = pns; __of_translate_address()
638 int onesize, i, na, ns; of_get_address() local
645 bus->count_cells(dev, &na, &ns); of_get_address()
656 onesize = na + ns; of_get_address()
660 *size = of_read_number(prop + na, ns); of_get_address()
61 of_bus_default_map(__be32 *addr, const __be32 *range, int na, int ns, int pna) of_bus_default_map() argument
473 of_translate_one(struct device_node *parent, struct of_bus *bus, struct of_bus *pbus, __be32 *addr, int na, int ns, int pna, const char *rprop) of_translate_one() argument
/linux-4.1.27/kernel/time/
H A Dntp_internal.h6 /* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
H A Dsched_clock.c3 * hardware time counters to full 64-bit ns values.
145 u64 ns; update_sched_clock() local
151 ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) & rd.sched_clock_mask, rd.mult, rd.shift); update_sched_clock()
153 rd.epoch_ns = ns; update_sched_clock()
170 u64 res, wrap, new_mask, new_epoch, cyc, ns; sched_clock_register() local
181 /* Calculate the mult/shift to convert counter ticks to ns. */ sched_clock_register()
196 ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) & rd.sched_clock_mask, rd.mult, rd.shift); sched_clock_register()
204 rd.epoch_ns = ns; sched_clock_register()
221 /* Calculate the ns resolution of this counter */ sched_clock_register()
H A Dtimecounter.c85 u64 ns = (u64) cycles; cc_cyc2ns_backwards() local
87 ns = ((ns * cc->mult) - frac) >> cc->shift; cc_cyc2ns_backwards()
89 return ns; cc_cyc2ns_backwards()
/linux-4.1.27/tools/perf/scripts/perl/
H A Dwakeup-latency.pl71 printf("avg_wakeup_latency (ns): %u\n",
74 printf("avg_wakeup_latency (ns): N/A\n");
76 printf("min_wakeup_latency (ns): %u\n", $min_wakeup_latency);
77 printf("max_wakeup_latency (ns): %u\n", $max_wakeup_latency);
/linux-4.1.27/arch/s390/include/asm/
H A Dtimex.h144 * ns = (todval * 125) >> 9;
150 * ns = ((2^32 * th + tl) * 125 ) >> 9;
151 * -> ns = (2^23 * th * 125) + ((tl * 125) >> 9);
156 unsigned long long ns; tod_to_ns() local
158 ns = ((todval >> 32) << 23) * 125; tod_to_ns()
159 ns += ((todval & 0xffffffff) * 125) >> 9; tod_to_ns()
160 return ns; tod_to_ns()
/linux-4.1.27/drivers/block/
H A Dnvme-scsi.c671 static int nvme_trans_standard_inquiry_page(struct nvme_ns *ns, nvme_trans_standard_inquiry_page() argument
675 struct nvme_dev *dev = ns->dev; nvme_trans_standard_inquiry_page()
694 /* nvme ns identify - use DPS value for PROTECT field */ nvme_trans_standard_inquiry_page()
695 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_standard_inquiry_page()
737 static int nvme_trans_supported_vpd_pages(struct nvme_ns *ns, nvme_trans_supported_vpd_pages() argument
760 static int nvme_trans_unit_serial_page(struct nvme_ns *ns, nvme_trans_unit_serial_page() argument
764 struct nvme_dev *dev = ns->dev; nvme_trans_unit_serial_page()
779 static int nvme_trans_device_id_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_device_id_page() argument
782 struct nvme_dev *dev = ns->dev; nvme_trans_device_id_page()
788 __be32 tmp_id = cpu_to_be32(ns->ns_id); nvme_trans_device_id_page()
804 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_device_id_page()
860 static int nvme_trans_ext_inq_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_ext_inq_page() argument
866 struct nvme_dev *dev = ns->dev; nvme_trans_ext_inq_page()
893 /* nvme ns identify */ nvme_trans_ext_inq_page()
894 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_ext_inq_page()
944 static int nvme_trans_bdev_limits_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_bdev_limits_page() argument
948 nvme_block_nr(ns, queue_max_hw_sectors(ns->queue))); nvme_trans_bdev_limits_page()
949 __be32 max_discard = cpu_to_be32(ns->queue->limits.max_discard_sectors); nvme_trans_bdev_limits_page()
964 static int nvme_trans_bdev_char_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_bdev_char_page() argument
994 static int nvme_trans_log_supp_pages(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_log_supp_pages() argument
1022 static int nvme_trans_log_info_exceptions(struct nvme_ns *ns, nvme_trans_log_info_exceptions() argument
1029 struct nvme_dev *dev = ns->dev; nvme_trans_log_info_exceptions()
1089 static int nvme_trans_log_temperature(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_log_temperature() argument
1096 struct nvme_dev *dev = ns->dev; nvme_trans_log_temperature()
1196 static int nvme_trans_fill_blk_desc(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_fill_blk_desc() argument
1201 struct nvme_dev *dev = ns->dev; nvme_trans_fill_blk_desc()
1220 /* nvme ns identify */ nvme_trans_fill_blk_desc()
1221 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_fill_blk_desc()
1256 static int nvme_trans_fill_control_page(struct nvme_ns *ns, nvme_trans_fill_control_page() argument
1278 static int nvme_trans_fill_caching_page(struct nvme_ns *ns, nvme_trans_fill_caching_page() argument
1284 struct nvme_dev *dev = ns->dev; nvme_trans_fill_caching_page()
1310 static int nvme_trans_fill_pow_cnd_page(struct nvme_ns *ns, nvme_trans_fill_pow_cnd_page() argument
1326 static int nvme_trans_fill_inf_exc_page(struct nvme_ns *ns, nvme_trans_fill_inf_exc_page() argument
1343 static int nvme_trans_fill_all_pages(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_fill_all_pages() argument
1354 res = nvme_trans_fill_caching_page(ns, hdr, &resp[mode_pages_offset_1], nvme_trans_fill_all_pages()
1358 res = nvme_trans_fill_control_page(ns, hdr, &resp[mode_pages_offset_2], nvme_trans_fill_all_pages()
1362 res = nvme_trans_fill_pow_cnd_page(ns, hdr, &resp[mode_pages_offset_3], nvme_trans_fill_all_pages()
1366 res = nvme_trans_fill_inf_exc_page(ns, hdr, &resp[mode_pages_offset_4], nvme_trans_fill_all_pages()
1385 static int nvme_trans_mode_page_create(struct nvme_ns *ns, nvme_trans_mode_page_create() argument
1425 res = nvme_trans_fill_blk_desc(ns, hdr, nvme_trans_mode_page_create()
1431 res = mode_page_fill_func(ns, hdr, &response[mode_pages_offset_1], nvme_trans_mode_page_create()
1485 static int nvme_trans_power_state(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_power_state() argument
1490 struct nvme_dev *dev = ns->dev; nvme_trans_power_state()
1569 static int nvme_trans_send_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_send_fw_cmd() argument
1575 struct nvme_dev *dev = ns->dev; nvme_trans_send_fw_cmd()
1646 static void nvme_trans_modesel_save_bd(struct nvme_ns *ns, u8 *parm_list, nvme_trans_modesel_save_bd() argument
1657 ns->mode_select_num_blocks = nvme_trans_modesel_save_bd()
1662 ns->mode_select_block_len = nvme_trans_modesel_save_bd()
1668 ns->mode_select_num_blocks = nvme_trans_modesel_save_bd()
1678 ns->mode_select_block_len = nvme_trans_modesel_save_bd()
1686 static int nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_modesel_get_mp() argument
1691 struct nvme_dev *dev = ns->dev; nvme_trans_modesel_get_mp()
1734 static int nvme_trans_modesel_data(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_modesel_data() argument
1762 nvme_trans_modesel_save_bd(ns, parm_list, index, bd_len, llbaa); nvme_trans_modesel_data()
1790 res = nvme_trans_modesel_get_mp(ns, hdr, &parm_list[index], nvme_trans_modesel_data()
1805 static int nvme_trans_fmt_set_blk_size_count(struct nvme_ns *ns, nvme_trans_fmt_set_blk_size_count() argument
1810 struct nvme_dev *dev = ns->dev; nvme_trans_fmt_set_blk_size_count()
1823 if (ns->mode_select_num_blocks == 0 || ns->mode_select_block_len == 0) { nvme_trans_fmt_set_blk_size_count()
1830 /* nvme ns identify */ nvme_trans_fmt_set_blk_size_count()
1831 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_fmt_set_blk_size_count()
1841 if (ns->mode_select_num_blocks == 0) nvme_trans_fmt_set_blk_size_count()
1842 ns->mode_select_num_blocks = le64_to_cpu(id_ns->ncap); nvme_trans_fmt_set_blk_size_count()
1843 if (ns->mode_select_block_len == 0) { nvme_trans_fmt_set_blk_size_count()
1845 ns->mode_select_block_len = nvme_trans_fmt_set_blk_size_count()
1916 static int nvme_trans_fmt_send_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_fmt_send_cmd() argument
1921 struct nvme_dev *dev = ns->dev; nvme_trans_fmt_send_cmd()
1938 /* nvme ns identify */ nvme_trans_fmt_send_cmd()
1939 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_fmt_send_cmd()
1952 if (ns->mode_select_block_len == (1 << (id_ns->lbaf[i].ds))) { nvme_trans_fmt_send_cmd()
1962 if (ns->mode_select_num_blocks != le64_to_cpu(id_ns->ncap)) { nvme_trans_fmt_send_cmd()
1972 c.format.nsid = cpu_to_le32(ns->ns_id); nvme_trans_fmt_send_cmd()
2051 static u16 nvme_trans_io_get_control(struct nvme_ns *ns, nvme_trans_io_get_control() argument
2064 static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_do_nvme_io() argument
2069 struct nvme_dev *dev = ns->dev; nvme_trans_do_nvme_io()
2081 u32 max_blocks = queue_max_hw_sectors(ns->queue); nvme_trans_do_nvme_io()
2105 unit_num_blocks = unit_len >> ns->lba_shift; nvme_trans_do_nvme_io()
2110 unit_len = unit_num_blocks << ns->lba_shift; nvme_trans_do_nvme_io()
2112 ((1 << ns->lba_shift) * nvme_offset); nvme_trans_do_nvme_io()
2116 c.rw.nsid = cpu_to_le32(ns->ns_id); nvme_trans_do_nvme_io()
2119 control = nvme_trans_io_get_control(ns, cdb_info); nvme_trans_do_nvme_io()
2143 nvme_sc = nvme_submit_io_cmd(dev, ns, &c, NULL); nvme_trans_do_nvme_io()
2166 static int nvme_trans_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, u8 is_write, nvme_trans_io() argument
2212 if (sgl.iov_len % (1 << ns->lba_shift) != 0) { nvme_trans_io()
2229 if (xfer_bytes != (cdb_info.xfer_len << ns->lba_shift)) { nvme_trans_io()
2239 res = nvme_trans_do_nvme_io(ns, hdr, &cdb_info, is_write); nvme_trans_io()
2247 static int nvme_trans_inquiry(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_inquiry() argument
2269 res = nvme_trans_standard_inquiry_page(ns, hdr, nvme_trans_inquiry()
2281 res = nvme_trans_supported_vpd_pages(ns, hdr, nvme_trans_inquiry()
2285 res = nvme_trans_unit_serial_page(ns, hdr, inq_response, nvme_trans_inquiry()
2289 res = nvme_trans_device_id_page(ns, hdr, inq_response, nvme_trans_inquiry()
2293 res = nvme_trans_ext_inq_page(ns, hdr, alloc_len); nvme_trans_inquiry()
2296 res = nvme_trans_bdev_limits_page(ns, hdr, inq_response, nvme_trans_inquiry()
2300 res = nvme_trans_bdev_char_page(ns, hdr, alloc_len); nvme_trans_inquiry()
2316 static int nvme_trans_log_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_log_sense() argument
2344 res = nvme_trans_log_supp_pages(ns, hdr, alloc_len); nvme_trans_log_sense()
2347 res = nvme_trans_log_info_exceptions(ns, hdr, alloc_len); nvme_trans_log_sense()
2350 res = nvme_trans_log_temperature(ns, hdr, alloc_len); nvme_trans_log_sense()
2363 static int nvme_trans_mode_select(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_mode_select() argument
2392 res = nvme_trans_modesel_data(ns, hdr, cmd, parm_list_len, nvme_trans_mode_select()
2399 static int nvme_trans_mode_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_mode_sense() argument
2429 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, nvme_trans_mode_sense()
2435 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, nvme_trans_mode_sense()
2441 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, nvme_trans_mode_sense()
2447 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, nvme_trans_mode_sense()
2453 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, nvme_trans_mode_sense()
2469 static int nvme_trans_read_capacity(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_read_capacity() argument
2478 struct nvme_dev *dev = ns->dev; nvme_trans_read_capacity()
2496 /* nvme ns identify */ nvme_trans_read_capacity()
2497 nvme_sc = nvme_identify(dev, ns->ns_id, 0, dma_addr); nvme_trans_read_capacity()
2525 static int nvme_trans_report_luns(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_report_luns() argument
2533 struct nvme_dev *dev = ns->dev; nvme_trans_report_luns()
2611 static int nvme_trans_request_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_request_sense() argument
2661 static int nvme_trans_security_protocol(struct nvme_ns *ns, nvme_trans_security_protocol() argument
2670 static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_start_stop() argument
2699 c.common.nsid = cpu_to_le32(ns->ns_id); nvme_trans_start_stop()
2701 nvme_sc = nvme_submit_io_cmd(ns->dev, ns, &c, NULL); nvme_trans_start_stop()
2711 res = nvme_trans_power_state(ns, hdr, pc, pcmod, start); nvme_trans_start_stop()
2718 static int nvme_trans_synchronize_cache(struct nvme_ns *ns, nvme_trans_synchronize_cache() argument
2727 c.common.nsid = cpu_to_le32(ns->ns_id); nvme_trans_synchronize_cache()
2729 nvme_sc = nvme_submit_io_cmd(ns->dev, ns, &c, NULL); nvme_trans_synchronize_cache()
2741 static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_format_unit() argument
2787 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, 0, 0, 0); nvme_trans_format_unit()
2790 res = nvme_trans_fmt_set_blk_size_count(ns, hdr); nvme_trans_format_unit()
2794 res = nvme_trans_fmt_send_cmd(ns, hdr, nvme_pf_code); nvme_trans_format_unit()
2800 static int nvme_trans_test_unit_ready(struct nvme_ns *ns, nvme_trans_test_unit_ready() argument
2805 struct nvme_dev *dev = ns->dev; nvme_trans_test_unit_ready()
2817 static int nvme_trans_write_buffer(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_write_buffer() argument
2847 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_download_fw, nvme_trans_write_buffer()
2852 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, nvme_trans_write_buffer()
2857 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_download_fw, nvme_trans_write_buffer()
2862 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, nvme_trans_write_buffer()
2890 static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr, nvme_trans_unmap() argument
2893 struct nvme_dev *dev = ns->dev; nvme_trans_unmap()
2932 c.dsm.nsid = cpu_to_le32(ns->ns_id); nvme_trans_unmap()
2937 nvme_sc = nvme_submit_io_cmd(dev, ns, &c, NULL); nvme_trans_unmap()
2947 static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr) nvme_scsi_translate() argument
2973 retcode = nvme_trans_io(ns, hdr, 0, cmd); nvme_scsi_translate()
2979 retcode = nvme_trans_io(ns, hdr, 1, cmd); nvme_scsi_translate()
2982 retcode = nvme_trans_inquiry(ns, hdr, cmd); nvme_scsi_translate()
2985 retcode = nvme_trans_log_sense(ns, hdr, cmd); nvme_scsi_translate()
2989 retcode = nvme_trans_mode_select(ns, hdr, cmd); nvme_scsi_translate()
2993 retcode = nvme_trans_mode_sense(ns, hdr, cmd); nvme_scsi_translate()
2996 retcode = nvme_trans_read_capacity(ns, hdr, cmd); nvme_scsi_translate()
3000 retcode = nvme_trans_read_capacity(ns, hdr, cmd); nvme_scsi_translate()
3005 retcode = nvme_trans_report_luns(ns, hdr, cmd); nvme_scsi_translate()
3008 retcode = nvme_trans_request_sense(ns, hdr, cmd); nvme_scsi_translate()
3012 retcode = nvme_trans_security_protocol(ns, hdr, cmd); nvme_scsi_translate()
3015 retcode = nvme_trans_start_stop(ns, hdr, cmd); nvme_scsi_translate()
3018 retcode = nvme_trans_synchronize_cache(ns, hdr, cmd); nvme_scsi_translate()
3021 retcode = nvme_trans_format_unit(ns, hdr, cmd); nvme_scsi_translate()
3024 retcode = nvme_trans_test_unit_ready(ns, hdr, cmd); nvme_scsi_translate()
3027 retcode = nvme_trans_write_buffer(ns, hdr, cmd); nvme_scsi_translate()
3030 retcode = nvme_trans_unmap(ns, hdr, cmd); nvme_scsi_translate()
3042 int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr) nvme_sg_io() argument
3056 retcode = nvme_scsi_translate(ns, &hdr); nvme_sg_io()
H A Dnvme-core.c506 struct nvme_ns *ns = req->rq_disk->private_data; nvme_dif_remap() local
512 if (!ns->pi_type || ns->pi_type == NVME_NS_DPS_PI_TYPE3) nvme_dif_remap()
523 phys = nvme_block_nr(ns, blk_rq_pos(req)); nvme_dif_remap()
524 nlb = (blk_rq_bytes(req) >> ns->lba_shift); nvme_dif_remap()
525 ts = ns->disk->integrity->tuple_size; nvme_dif_remap()
551 static void nvme_init_integrity(struct nvme_ns *ns) nvme_init_integrity() argument
555 switch (ns->pi_type) { nvme_init_integrity()
567 integrity.tuple_size = ns->ms; nvme_init_integrity()
568 blk_integrity_register(ns->disk, &integrity); nvme_init_integrity()
569 blk_queue_max_integrity_segments(ns->queue, 1); nvme_init_integrity()
582 static void nvme_init_integrity(struct nvme_ns *ns) nvme_init_integrity() argument
720 static void nvme_submit_discard(struct nvme_queue *nvmeq, struct nvme_ns *ns, nvme_submit_discard() argument
728 range->nlb = cpu_to_le32(blk_rq_bytes(req) >> ns->lba_shift); nvme_submit_discard()
729 range->slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req))); nvme_submit_discard()
734 cmnd->dsm.nsid = cpu_to_le32(ns->ns_id); nvme_submit_discard()
744 static void nvme_submit_flush(struct nvme_queue *nvmeq, struct nvme_ns *ns, nvme_submit_flush() argument
752 cmnd->common.nsid = cpu_to_le32(ns->ns_id); nvme_submit_flush()
760 struct nvme_ns *ns) nvme_submit_iod()
780 cmnd->rw.nsid = cpu_to_le32(ns->ns_id); nvme_submit_iod()
783 cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req))); nvme_submit_iod()
784 cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1); nvme_submit_iod()
788 switch (ns->pi_type) { nvme_submit_iod()
797 nvme_block_nr(ns, blk_rq_pos(req))); nvme_submit_iod()
800 } else if (ns->ms) nvme_submit_iod()
816 struct nvme_ns *ns = hctx->queue->queuedata; nvme_queue_rq() local
828 if (ns->ms && !blk_integrity_rq(req)) { nvme_queue_rq()
829 if (!(ns->pi_type && ns->ms == 8)) { nvme_queue_rq()
836 iod = nvme_alloc_iod(req, ns->dev, GFP_ATOMIC); nvme_queue_rq()
891 nvme_submit_discard(nvmeq, ns, req, iod); nvme_queue_rq()
893 nvme_submit_flush(nvmeq, ns, req->tag); nvme_queue_rq()
895 nvme_submit_iod(nvmeq, iod, ns); nvme_queue_rq()
1086 int nvme_submit_io_cmd(struct nvme_dev *dev, struct nvme_ns *ns, nvme_submit_io_cmd() argument
1092 req = blk_mq_alloc_request(ns->queue, WRITE, (GFP_KERNEL|__GFP_WAIT), nvme_submit_io_cmd()
1746 static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) nvme_submit_io() argument
1748 struct nvme_dev *dev = ns->dev; nvme_submit_io()
1760 length = (io.nblocks + 1) << ns->lba_shift; nvme_submit_io()
1761 meta_len = (io.nblocks + 1) * ns->ms; nvme_submit_io()
1763 if (meta_len && ((io.metadata & 3) || !io.metadata) && !ns->ext) nvme_submit_io()
1765 else if (meta_len && ns->ext) { nvme_submit_io()
1811 c.rw.nsid = cpu_to_le32(ns->ns_id); nvme_submit_io()
1822 status = nvme_submit_io_cmd(dev, ns, &c, NULL); nvme_submit_io()
1836 static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns, nvme_user_cmd() argument
1879 else if (ns) { nvme_user_cmd()
1882 req = blk_mq_alloc_request(ns->queue, WRITE, nvme_user_cmd()
1909 struct nvme_ns *ns = bdev->bd_disk->private_data; nvme_ioctl() local
1914 return ns->ns_id; nvme_ioctl()
1916 return nvme_user_cmd(ns->dev, NULL, (void __user *)arg); nvme_ioctl()
1918 return nvme_user_cmd(ns->dev, ns, (void __user *)arg); nvme_ioctl()
1920 return nvme_submit_io(ns, (void __user *)arg); nvme_ioctl()
1924 return nvme_sg_io(ns, (void __user *)arg); nvme_ioctl()
1947 struct nvme_ns *ns; nvme_open() local
1950 ns = bdev->bd_disk->private_data; nvme_open()
1951 if (!ns) nvme_open()
1953 else if (!kref_get_unless_zero(&ns->dev->kref)) nvme_open()
1964 struct nvme_ns *ns = disk->private_data; nvme_release() local
1965 struct nvme_dev *dev = ns->dev; nvme_release()
1979 static void nvme_config_discard(struct nvme_ns *ns) nvme_config_discard() argument
1981 u32 logical_block_size = queue_logical_block_size(ns->queue); nvme_config_discard()
1982 ns->queue->limits.discard_zeroes_data = 0; nvme_config_discard()
1983 ns->queue->limits.discard_alignment = logical_block_size; nvme_config_discard()
1984 ns->queue->limits.discard_granularity = logical_block_size; nvme_config_discard()
1985 ns->queue->limits.max_discard_sectors = 0xffffffff; nvme_config_discard()
1986 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue); nvme_config_discard()
1991 struct nvme_ns *ns = disk->private_data; nvme_revalidate_disk() local
1992 struct nvme_dev *dev = ns->dev; nvme_revalidate_disk()
2006 if (nvme_identify(dev, ns->ns_id, 0, dma_addr)) { nvme_revalidate_disk()
2008 "identify failed ns:%d, setting capacity to 0\n", nvme_revalidate_disk()
2009 ns->ns_id); nvme_revalidate_disk()
2013 old_ms = ns->ms; nvme_revalidate_disk()
2015 ns->lba_shift = id->lbaf[lbaf].ds; nvme_revalidate_disk()
2016 ns->ms = le16_to_cpu(id->lbaf[lbaf].ms); nvme_revalidate_disk()
2017 ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT); nvme_revalidate_disk()
2023 if (ns->lba_shift == 0) nvme_revalidate_disk()
2024 ns->lba_shift = 9; nvme_revalidate_disk()
2025 bs = 1 << ns->lba_shift; nvme_revalidate_disk()
2028 pi_type = ns->ms == sizeof(struct t10_pi_tuple) ? nvme_revalidate_disk()
2031 if (blk_get_integrity(disk) && (ns->pi_type != pi_type || nvme_revalidate_disk()
2032 ns->ms != old_ms || nvme_revalidate_disk()
2034 (ns->ms && ns->ext))) nvme_revalidate_disk()
2037 ns->pi_type = pi_type; nvme_revalidate_disk()
2038 blk_queue_logical_block_size(ns->queue, bs); nvme_revalidate_disk()
2040 if (ns->ms && !blk_get_integrity(disk) && (disk->flags & GENHD_FL_UP) && nvme_revalidate_disk()
2041 !ns->ext) nvme_revalidate_disk()
2042 nvme_init_integrity(ns); nvme_revalidate_disk()
2044 if (id->ncap == 0 || (ns->ms && !blk_get_integrity(disk))) nvme_revalidate_disk()
2047 set_capacity(disk, le64_to_cpup(&id->nsze) << (ns->lba_shift - 9)); nvme_revalidate_disk()
2050 nvme_config_discard(ns); nvme_revalidate_disk()
2109 struct nvme_ns *ns; nvme_alloc_ns() local
2113 ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); nvme_alloc_ns()
2114 if (!ns) nvme_alloc_ns()
2117 ns->queue = blk_mq_init_queue(&dev->tagset); nvme_alloc_ns()
2118 if (IS_ERR(ns->queue)) nvme_alloc_ns()
2120 queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue); nvme_alloc_ns()
2121 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue); nvme_alloc_ns()
2122 queue_flag_set_unlocked(QUEUE_FLAG_SG_GAPS, ns->queue); nvme_alloc_ns()
2123 ns->dev = dev; nvme_alloc_ns()
2124 ns->queue->queuedata = ns; nvme_alloc_ns()
2130 ns->ns_id = nsid; nvme_alloc_ns()
2131 ns->disk = disk; nvme_alloc_ns()
2132 ns->lba_shift = 9; /* set to a default value for 512 until disk is validated */ nvme_alloc_ns()
2133 list_add_tail(&ns->list, &dev->namespaces); nvme_alloc_ns()
2135 blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); nvme_alloc_ns()
2137 blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors); nvme_alloc_ns()
2139 blk_queue_chunk_sectors(ns->queue, dev->stripe_size >> 9); nvme_alloc_ns()
2141 blk_queue_flush(ns->queue, REQ_FLUSH | REQ_FUA); nvme_alloc_ns()
2146 disk->private_data = ns; nvme_alloc_ns()
2147 disk->queue = ns->queue; nvme_alloc_ns()
2159 nvme_revalidate_disk(ns->disk); nvme_alloc_ns()
2160 add_disk(ns->disk); nvme_alloc_ns()
2161 if (ns->ms) nvme_alloc_ns()
2162 revalidate_disk(ns->disk); nvme_alloc_ns()
2165 blk_cleanup_queue(ns->queue); nvme_alloc_ns()
2167 kfree(ns); nvme_alloc_ns()
2588 struct nvme_ns *ns; nvme_freeze_queues() local
2590 list_for_each_entry(ns, &dev->namespaces, list) { nvme_freeze_queues()
2591 blk_mq_freeze_queue_start(ns->queue); nvme_freeze_queues()
2593 spin_lock(ns->queue->queue_lock); nvme_freeze_queues()
2594 queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue); nvme_freeze_queues()
2595 spin_unlock(ns->queue->queue_lock); nvme_freeze_queues()
2597 blk_mq_cancel_requeue_work(ns->queue); nvme_freeze_queues()
2598 blk_mq_stop_hw_queues(ns->queue); nvme_freeze_queues()
2604 struct nvme_ns *ns; nvme_unfreeze_queues() local
2606 list_for_each_entry(ns, &dev->namespaces, list) { nvme_unfreeze_queues()
2607 queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue); nvme_unfreeze_queues()
2608 blk_mq_unfreeze_queue(ns->queue); nvme_unfreeze_queues()
2609 blk_mq_start_stopped_hw_queues(ns->queue, true); nvme_unfreeze_queues()
2610 blk_mq_kick_requeue_list(ns->queue); nvme_unfreeze_queues()
2643 struct nvme_ns *ns; nvme_dev_remove() local
2645 list_for_each_entry(ns, &dev->namespaces, list) { nvme_dev_remove()
2646 if (ns->disk->flags & GENHD_FL_UP) { nvme_dev_remove()
2647 if (blk_get_integrity(ns->disk)) nvme_dev_remove()
2648 blk_integrity_unregister(ns->disk); nvme_dev_remove()
2649 del_gendisk(ns->disk); nvme_dev_remove()
2651 if (!blk_queue_dying(ns->queue)) { nvme_dev_remove()
2652 blk_mq_abort_requeue_list(ns->queue); nvme_dev_remove()
2653 blk_cleanup_queue(ns->queue); nvme_dev_remove()
2713 struct nvme_ns *ns, *next; nvme_free_namespaces() local
2715 list_for_each_entry_safe(ns, next, &dev->namespaces, list) { nvme_free_namespaces()
2716 list_del(&ns->list); nvme_free_namespaces()
2719 ns->disk->private_data = NULL; nvme_free_namespaces()
2722 put_disk(ns->disk); nvme_free_namespaces()
2723 kfree(ns); nvme_free_namespaces()
2777 struct nvme_ns *ns; nvme_dev_ioctl() local
2785 ns = list_first_entry(&dev->namespaces, struct nvme_ns, list); nvme_dev_ioctl()
2786 return nvme_user_cmd(dev, ns, (void __user *)arg); nvme_dev_ioctl()
759 nvme_submit_iod(struct nvme_queue *nvmeq, struct nvme_iod *iod, struct nvme_ns *ns) nvme_submit_iod() argument
/linux-4.1.27/arch/cris/include/uapi/asm/
H A Detraxgpio.h149 PWM_FAST = 2, /* variable freq, w/ 10ns active pulse len */
158 /* Only for mode PWM_VARFREQ. Period lo/high set in increments of 10ns
159 * from 10ns (value = 0) to 81920ns (value = 8191)
160 * (Resulting frequencies range from 50 MHz (10ns + 10ns) down to
161 * 6.1 kHz (81920ns + 81920ns) at 50% duty cycle, to 12.2 kHz at min/max duty
162 * cycle (81920 + 10ns or 10ns + 81920ns, respectively).)
176 * is a 10ns pulse surrounded by a high or low level depending on duty
188 * lo: Length of the latest low period, in units of 10ns.
189 * hi: Length of the latest high period, in units of 10ns.
190 * cnt: Time since last detected edge, in units of 10ns.
/linux-4.1.27/drivers/net/ethernet/freescale/
H A Dgianfar_ptp.c159 u64 ns; tmr_cnt_read() local
164 ns = ((u64) hi) << 32; tmr_cnt_read()
165 ns |= lo; tmr_cnt_read()
166 return ns; tmr_cnt_read()
170 static void tmr_cnt_write(struct etsects *etsects, u64 ns) tmr_cnt_write() argument
172 u32 hi = ns >> 32; tmr_cnt_write()
173 u32 lo = ns & 0xffffffff; tmr_cnt_write()
182 u64 ns; set_alarm() local
185 ns = tmr_cnt_read(etsects) + 1500000000ULL; set_alarm()
186 ns = div_u64(ns, 1000000000UL) * 1000000000ULL; set_alarm()
187 ns -= etsects->tclk_period; set_alarm()
188 hi = ns >> 32; set_alarm()
189 lo = ns & 0xffffffff; set_alarm()
210 u64 ns; isr() local
246 ns = etsects->alarm_value + etsects->alarm_interval; isr()
247 hi = ns >> 32; isr()
248 lo = ns & 0xffffffff; isr()
253 etsects->alarm_value = ns; isr()
328 u64 ns; ptp_gianfar_gettime() local
334 ns = tmr_cnt_read(etsects); ptp_gianfar_gettime()
338 *ts = ns_to_timespec64(ns); ptp_gianfar_gettime()
346 u64 ns; ptp_gianfar_settime() local
350 ns = timespec64_to_ns(ts); ptp_gianfar_settime()
354 tmr_cnt_write(etsects, ns); ptp_gianfar_settime()
H A Dfec_ptp.c116 u64 ns; fec_ptp_enable_pps() local
165 ns = timecounter_cyc2time(&fep->tc, tempval); fec_ptp_enable_pps()
166 ts.tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder); fec_ptp_enable_pps()
176 * - ts.tv_nsec is close to be zero(For example 20ns); Since the timer fec_ptp_enable_pps()
232 * cyclecounter structure used to construct a ns counter from the
258 * structures for use in generated a ns counter from the arbitrary
272 /* 1ns counter */ fec_ptp_start_cyclecounter()
287 /* reset the ns time counter */ fec_ptp_start_cyclecounter()
390 * read the timecounter and return the correct value on ns,
397 u64 ns; fec_ptp_gettime() local
401 ns = timecounter_read(&adapter->tc); fec_ptp_gettime()
404 *ts = ns_to_timespec64(ns); fec_ptp_gettime()
423 u64 ns; fec_ptp_settime() local
434 ns = timespec64_to_ns(ts); fec_ptp_settime()
438 counter = ns & fep->cc.mask; fec_ptp_settime()
442 timecounter_init(&fep->tc, &fep->cc, ns); fec_ptp_settime()
545 u64 ns; fec_time_keep() local
551 ns = timecounter_read(&fep->tc); fec_time_keep()
/linux-4.1.27/arch/x86/vdso/
H A Dvclock_gettime.c233 u64 ns; do_realtime() local
240 ns = gtod->wall_time_snsec; do_realtime()
241 ns += vgetsns(&mode); do_realtime()
242 ns >>= gtod->shift; do_realtime()
245 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); do_realtime()
246 ts->tv_nsec = ns; do_realtime()
254 u64 ns; do_monotonic() local
261 ns = gtod->monotonic_time_snsec; do_monotonic()
262 ns += vgetsns(&mode); do_monotonic()
263 ns >>= gtod->shift; do_monotonic()
266 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); do_monotonic()
267 ts->tv_nsec = ns; do_monotonic()
/linux-4.1.27/drivers/net/ethernet/ti/
H A Dcpts.c172 u64 ns; cpts_ptp_gettime() local
177 ns = timecounter_read(&cpts->tc); cpts_ptp_gettime()
180 *ts = ns_to_timespec64(ns); cpts_ptp_gettime()
188 u64 ns; cpts_ptp_settime() local
192 ns = timespec64_to_ns(ts); cpts_ptp_settime()
195 timecounter_init(&cpts->tc, &cpts->cc, ns); cpts_ptp_settime()
288 u64 ns = 0; cpts_find_ts() local
312 ns = timecounter_cyc2time(&cpts->tc, event->low); cpts_find_ts()
320 return ns; cpts_find_ts()
325 u64 ns; cpts_rx_timestamp() local
330 ns = cpts_find_ts(cpts, skb, CPTS_EV_RX); cpts_rx_timestamp()
331 if (!ns) cpts_rx_timestamp()
335 ssh->hwtstamp = ns_to_ktime(ns); cpts_rx_timestamp()
340 u64 ns; cpts_tx_timestamp() local
345 ns = cpts_find_ts(cpts, skb, CPTS_EV_TX); cpts_tx_timestamp()
346 if (!ns) cpts_tx_timestamp()
349 ssh.hwtstamp = ns_to_ktime(ns); cpts_tx_timestamp()
/linux-4.1.27/drivers/ssb/
H A Ddriver_extif.c86 void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns) ssb_extif_timing_init() argument
94 tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; ssb_extif_timing_init()
95 tmp |= DIV_ROUND_UP(40, ns) << SSB_PROG_WCNT_1_SHIFT; ssb_extif_timing_init()
96 tmp |= DIV_ROUND_UP(120, ns); ssb_extif_timing_init()
100 tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; ssb_extif_timing_init()
101 tmp |= DIV_ROUND_UP(20, ns) << SSB_PROG_WCNT_2_SHIFT; ssb_extif_timing_init()
102 tmp |= DIV_ROUND_UP(100, ns) << SSB_PROG_WCNT_1_SHIFT; ssb_extif_timing_init()
103 tmp |= DIV_ROUND_UP(120, ns); ssb_extif_timing_init()
H A Ddriver_chipcommon.c435 unsigned long ns) ssb_chipco_timing_init()
443 tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; /* Waitcount-3 = 10ns */ ssb_chipco_timing_init()
444 tmp |= DIV_ROUND_UP(40, ns) << SSB_PROG_WCNT_1_SHIFT; /* Waitcount-1 = 40ns */ ssb_chipco_timing_init()
445 tmp |= DIV_ROUND_UP(240, ns); /* Waitcount-0 = 240ns */ ssb_chipco_timing_init()
449 tmp = DIV_ROUND_UP(10, ns) << SSB_FLASH_WCNT_3_SHIFT; /* Waitcount-3 = 10nS */ ssb_chipco_timing_init()
450 tmp |= DIV_ROUND_UP(10, ns) << SSB_FLASH_WCNT_1_SHIFT; /* Waitcount-1 = 10nS */ ssb_chipco_timing_init()
451 tmp |= DIV_ROUND_UP(120, ns); /* Waitcount-0 = 120nS */ ssb_chipco_timing_init()
462 tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; /* Waitcount-3 = 10ns */ ssb_chipco_timing_init()
463 tmp |= DIV_ROUND_UP(20, ns) << SSB_PROG_WCNT_2_SHIFT; /* Waitcount-2 = 20ns */ ssb_chipco_timing_init()
464 tmp |= DIV_ROUND_UP(100, ns) << SSB_PROG_WCNT_1_SHIFT; /* Waitcount-1 = 100ns */ ssb_chipco_timing_init()
465 tmp |= DIV_ROUND_UP(120, ns); /* Waitcount-0 = 120ns */ ssb_chipco_timing_init()
434 ssb_chipco_timing_init(struct ssb_chipcommon *cc, unsigned long ns) ssb_chipco_timing_init() argument
H A Ddriver_mipscore.c296 unsigned long hz, ns; ssb_mipscore_init() local
308 ns = 1000000000 / hz; ssb_mipscore_init()
311 ssb_extif_timing_init(&bus->extif, ns); ssb_mipscore_init()
313 ssb_chipco_timing_init(&bus->chipco, ns); ssb_mipscore_init()
/linux-4.1.27/arch/cris/arch-v32/lib/
H A Ddelay.c17 * getting 32-bit 10ns precision, theoretically good for 42.94967295
/linux-4.1.27/fs/kernfs/
H A Dmount.c105 return sb_info->root == info->root && sb_info->ns == info->ns; kernfs_test_super()
127 return info->ns; kernfs_super_ns()
137 * @ns: optional namespace tag of the mount
142 * and @ns, respectively.
148 bool *new_sb_created, const void *ns) kernfs_mount_ns()
159 info->ns = ns; kernfs_mount_ns()
217 * @ns: the namespace tag
226 struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns) kernfs_pin_sb() argument
233 if (info->ns == ns) { kernfs_pin_sb()
146 kernfs_mount_ns(struct file_system_type *fs_type, int flags, struct kernfs_root *root, unsigned long magic, bool *new_sb_created, const void *ns) kernfs_mount_ns() argument
H A Ddir.c181 * @ns: Namespace tag to hash
183 * Returns 31 bit hash of ns + name (so it fits in an off_t )
185 static unsigned int kernfs_name_hash(const char *name, const void *ns) kernfs_name_hash() argument
191 hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31)); kernfs_name_hash()
202 const void *ns, const struct kernfs_node *kn) kernfs_name_compare()
208 if (ns < kn->ns) kernfs_name_compare()
210 if (ns > kn->ns) kernfs_name_compare()
218 return kernfs_name_compare(left->hash, left->name, left->ns, right); kernfs_sd_compare()
467 kernfs_info(dentry->d_sb)->ns != kn->ns) kernfs_dop_revalidate()
587 if (WARN(has_ns != (bool)kn->ns, KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n", kernfs_add_one()
601 kn->hash = kernfs_name_hash(kn->name, kn->ns); kernfs_add_one()
636 * @ns: the namespace tag to use
643 const void *ns) kernfs_find_ns()
651 if (has_ns != (bool)ns) { kernfs_find_ns()
652 WARN(1, KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n", kernfs_find_ns()
657 hash = kernfs_name_hash(name, ns); kernfs_find_ns()
663 result = kernfs_name_compare(hash, name, ns, kn); kernfs_find_ns()
678 * @ns: the namespace tag to use
685 const char *name, const void *ns) kernfs_find_and_get_ns()
690 kn = kernfs_find_ns(parent, name, ns); kernfs_find_and_get_ns()
760 * @ns: optional namespace tag of the directory
766 void *priv, const void *ns) kernfs_create_dir_ns()
777 kn->ns = ns; kernfs_create_dir_ns()
809 kn->ns = NULL; kernfs_create_empty_dir()
829 const void *ns = NULL; kernfs_iop_lookup() local
834 ns = kernfs_info(dir->i_sb)->ns; kernfs_iop_lookup()
836 kn = kernfs_find_ns(parent, dentry->d_name.name, ns); kernfs_iop_lookup()
1241 * @ns: namespace tag of the kernfs_node to remove
1243 * Look for the kernfs_node with @name and @ns under @parent and remove it.
1247 const void *ns) kernfs_remove_by_name_ns()
1259 kn = kernfs_find_ns(parent, name, ns); kernfs_remove_by_name_ns()
1297 if ((kn->parent == new_parent) && (kn->ns == new_ns) && kernfs_rename_ns()
1327 kn->ns = new_ns; kernfs_rename_ns()
1335 kn->hash = kernfs_name_hash(kn->name, kn->ns); kernfs_rename_ns()
1359 static struct kernfs_node *kernfs_dir_pos(const void *ns, kernfs_dir_pos() argument
1383 while (pos && (!kernfs_active(pos) || pos->ns != ns)) { kernfs_dir_pos()
1393 static struct kernfs_node *kernfs_dir_next_pos(const void *ns, kernfs_dir_next_pos() argument
1396 pos = kernfs_dir_pos(ns, parent, ino, pos); kernfs_dir_next_pos()
1404 } while (pos && (!kernfs_active(pos) || pos->ns != ns)); kernfs_dir_next_pos()
1414 const void *ns = NULL; kernfs_fop_readdir() local
1421 ns = kernfs_info(dentry->d_sb)->ns; kernfs_fop_readdir()
1423 for (pos = kernfs_dir_pos(ns, parent, ctx->pos, pos); kernfs_fop_readdir()
1425 pos = kernfs_dir_next_pos(ns, parent, ctx->pos, pos)) { kernfs_fop_readdir()
201 kernfs_name_compare(unsigned int hash, const char *name, const void *ns, const struct kernfs_node *kn) kernfs_name_compare() argument
641 kernfs_find_ns(struct kernfs_node *parent, const unsigned char *name, const void *ns) kernfs_find_ns() argument
684 kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns) kernfs_find_and_get_ns() argument
764 kernfs_create_dir_ns(struct kernfs_node *parent, const char *name, umode_t mode, void *priv, const void *ns) kernfs_create_dir_ns() argument
1246 kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name, const void *ns) kernfs_remove_by_name_ns() argument
H A Dkernfs-internal.h56 * identified by the root and ns it's associated with.
66 const void *ns; member in struct:kernfs_super_info
H A Dsymlink.c37 kn->ns = target->ns; kernfs_create_link()
/linux-4.1.27/arch/arm/mach-pxa/
H A Dmp900.c31 /* 400Mhz PXA2 = 2.5ns / instruction */ isp116x_pfm_delay()
35 /* 4 Instructions = 4 x 2.5ns = 10ns */ isp116x_pfm_delay()
/linux-4.1.27/security/apparmor/include/
H A Dpolicy.h165 * @ns: namespace the profile is in
204 struct aa_namespace *ns; member in struct:aa_profile
248 struct aa_profile *aa_lookup_profile(struct aa_namespace *ns, const char *name);
249 struct aa_profile *aa_match_profile(struct aa_namespace *ns, const char *name);
263 mutex_is_locked(&p->ns->lock)); aa_deref_parent()
365 mutex_is_locked(&orig->ns->lock)); __aa_update_replacedby()
372 * aa_get_namespace - increment references count on @ns
373 * @ns: namespace to increment reference count of (MAYBE NULL)
375 * Returns: pointer to @ns, if @ns is NULL returns NULL
376 * Requires: @ns must be held with valid refcount when called
378 static inline struct aa_namespace *aa_get_namespace(struct aa_namespace *ns) aa_get_namespace() argument
380 if (ns) aa_get_namespace()
381 aa_get_profile(ns->unconfined); aa_get_namespace()
383 return ns; aa_get_namespace()
387 * aa_put_namespace - decrement refcount on @ns
388 * @ns: namespace to put reference of
390 * Decrement reference count of @ns and if no longer in use free it
392 static inline void aa_put_namespace(struct aa_namespace *ns) aa_put_namespace() argument
394 if (ns) aa_put_namespace()
395 aa_put_profile(ns->unconfined); aa_put_namespace()
H A Dpath.h23 PATH_CHROOT_NSCONNECT = 0x10, /* connect paths that are at ns root */
H A Dpolicy_unpack.h37 int aa_unpack(void *udata, size_t size, struct list_head *lh, const char **ns);
H A Dapparmorfs.h100 void __aa_fs_namespace_rmdir(struct aa_namespace *ns);
101 int __aa_fs_namespace_mkdir(struct aa_namespace *ns, struct dentry *parent,
/linux-4.1.27/drivers/net/ethernet/stmicro/stmmac/
H A Dstmmac_hwtstamp.c47 /* 0.465ns accuracy */ stmmac_config_sub_second_increment()
132 u64 ns; stmmac_get_systime() local
134 ns = readl(ioaddr + PTP_STNSR); stmmac_get_systime()
136 ns += readl(ioaddr + PTP_STSR) * 1000000000ULL; stmmac_get_systime()
138 return ns; stmmac_get_systime()
H A Dstmmac_ptp.c113 u64 ns; stmmac_get_time() local
117 ns = priv->hw->ptp->get_systime(priv->ioaddr); stmmac_get_time()
121 *ts = ns_to_timespec64(ns); stmmac_get_time()
H A Denh_desc.c351 u64 ns; enh_desc_get_timestamp() local
355 ns = p->des6; enh_desc_get_timestamp()
357 ns += p->des7 * 1000000000ULL; enh_desc_get_timestamp()
360 ns = p->des2; enh_desc_get_timestamp()
361 ns += p->des3 * 1000000000ULL; enh_desc_get_timestamp()
364 return ns; enh_desc_get_timestamp()
H A Dnorm_desc.c234 u64 ns; ndesc_get_timestamp() local
236 ns = p->des2; ndesc_get_timestamp()
238 ns += p->des3 * 1000000000ULL; ndesc_get_timestamp()
240 return ns; ndesc_get_timestamp()
/linux-4.1.27/net/llc/
H A Dllc_c_ev.c52 * @ns: sequence number of received pdu.
59 static u16 llc_util_ns_inside_rx_window(u8 ns, u8 vr, u8 rw) llc_util_ns_inside_rx_window() argument
61 return !llc_circular_between(vr, ns, llc_util_ns_inside_rx_window()
201 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns() local
204 LLC_I_PF_IS_0(pdu) && ns != vr && llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns()
205 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns()
213 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns() local
216 LLC_I_PF_IS_1(pdu) && ns != vr && llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns()
217 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns()
225 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns() local
227 ns != vr && llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns()
228 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns()
230 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns()
231 __func__, llc_sk(sk)->state, ns, vr); llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns()
268 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns() local
271 LLC_I_PF_IS_0(pdu) && ns != vr && llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns()
272 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns()
280 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns() local
283 LLC_I_PF_IS_1(pdu) && ns != vr && llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns()
284 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns()
292 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns() local
294 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns()
295 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns()
303 const u8 ns = LLC_I_GET_NS(pdu); llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns() local
305 ns != vr && llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns()
306 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns()
308 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns()
309 __func__, llc_sk(sk)->state, ns, vr); llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns()
/linux-4.1.27/drivers/gpu/drm/i915/
H A Ddvo_ns2501.c379 struct ns2501_priv *ns = dvo->dev_priv; ns2501_readb() local
407 if (!ns->quiet) { ns2501_readb()
424 struct ns2501_priv *ns = dvo->dev_priv; ns2501_writeb() local
442 if (!ns->quiet) { ns2501_writeb()
460 struct ns2501_priv *ns; ns2501_init() local
463 ns = kzalloc(sizeof(struct ns2501_priv), GFP_KERNEL); ns2501_init()
464 if (ns == NULL) ns2501_init()
468 dvo->dev_priv = ns; ns2501_init()
469 ns->quiet = true; ns2501_init()
488 ns->quiet = false; ns2501_init()
495 kfree(ns); ns2501_init()
537 struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); ns2501_mode_set() local
557 ns->regs = regs_1024x768[mode_idx]; ns2501_mode_set()
560 ns2501_writeb(dvo, ns->regs[i].offset, ns->regs[i].value); ns2501_mode_set()
577 struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); ns2501_dpms() local
582 if (WARN_ON(ns->regs[83].offset != 0x08 || ns2501_dpms()
583 ns->regs[84].offset != 0x41 || ns2501_dpms()
584 ns->regs[85].offset != 0xc0)) ns2501_dpms()
587 ns2501_writeb(dvo, 0xc0, ns->regs[85].value | 0x08); ns2501_dpms()
589 ns2501_writeb(dvo, 0x41, ns->regs[84].value); ns2501_dpms()
595 if (!(ns->regs[83].value & NS2501_8_BPAS)) ns2501_dpms()
601 ns2501_writeb(dvo, 0xc0, ns->regs[85].value); ns2501_dpms()
615 struct ns2501_priv *ns = dvo->dev_priv; ns2501_destroy() local
617 if (ns) { ns2501_destroy()
618 kfree(ns); ns2501_destroy()
/linux-4.1.27/drivers/staging/lustre/lustre/include/
H A Dlustre_dlm.h507 * Returns 1 if namespace \a ns is a client namespace.
509 static inline int ns_is_client(struct ldlm_namespace *ns) ns_is_client() argument
511 LASSERT(ns != NULL); ns_is_client()
512 LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT | ns_is_client()
514 LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT || ns_is_client()
515 ns->ns_client == LDLM_NAMESPACE_SERVER); ns_is_client()
516 return ns->ns_client == LDLM_NAMESPACE_CLIENT; ns_is_client()
520 * Returns 1 if namespace \a ns is a server namespace.
522 static inline int ns_is_server(struct ldlm_namespace *ns) ns_is_server() argument
524 LASSERT(ns != NULL); ns_is_server()
525 LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT | ns_is_server()
527 LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT || ns_is_server()
528 ns->ns_client == LDLM_NAMESPACE_SERVER); ns_is_server()
529 return ns->ns_client == LDLM_NAMESPACE_SERVER; ns_is_server()
533 * Returns 1 if namespace \a ns supports early lock cancel (ELC).
535 static inline int ns_connect_cancelset(struct ldlm_namespace *ns) ns_connect_cancelset() argument
537 LASSERT(ns != NULL); ns_connect_cancelset()
538 return !!(ns->ns_connect_flags & OBD_CONNECT_CANCELSET); ns_connect_cancelset()
544 static inline int ns_connect_lru_resize(struct ldlm_namespace *ns) ns_connect_lru_resize() argument
546 LASSERT(ns != NULL); ns_connect_lru_resize()
547 return !!(ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE); ns_connect_lru_resize()
550 static inline void ns_register_cancel(struct ldlm_namespace *ns, ns_register_cancel() argument
553 LASSERT(ns != NULL); ns_register_cancel()
554 ns->ns_cancel_for_recovery = arg; ns_register_cancel()
966 ldlm_ns_name(struct ldlm_namespace *ns) ldlm_ns_name() argument
968 return ns->ns_rs_hash->hs_name; ldlm_ns_name()
997 struct ldlm_namespace *ns = ldlm_res_to_ns(res); ldlm_lvbo_init() local
999 if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_init != NULL) ldlm_lvbo_init()
1000 return ns->ns_lvbo->lvbo_init(res); ldlm_lvbo_init()
1007 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lvbo_size() local
1009 if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_size != NULL) ldlm_lvbo_size()
1010 return ns->ns_lvbo->lvbo_size(lock); ldlm_lvbo_size()
1017 struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ldlm_lvbo_fill() local
1019 if (ns->ns_lvbo != NULL) { ldlm_lvbo_fill()
1020 LASSERT(ns->ns_lvbo->lvbo_fill != NULL); ldlm_lvbo_fill()
1021 return ns->ns_lvbo->lvbo_fill(lock, buf, len); ldlm_lvbo_fill()
1124 void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter,
1154 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
1259 ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
1270 void ldlm_reprocess_all_ns(struct ldlm_namespace *ns);
1279 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags);
1280 void ldlm_namespace_free(struct ldlm_namespace *ns,
1282 void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client);
1283 void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client);
1284 void ldlm_namespace_get(struct ldlm_namespace *ns);
1285 void ldlm_namespace_put(struct ldlm_namespace *ns);
1295 struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, ldlm_proc_cleanup()
1355 int ldlm_handle_enqueue0(struct ldlm_namespace *ns, struct ptlrpc_request *req,
1362 int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
1380 int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
1461 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
/linux-4.1.27/drivers/net/ethernet/mellanox/mlx4/
H A Den_clock.c164 * Read the timecounter and return the correct value in ns after converting
173 u64 ns; mlx4_en_phc_gettime() local
176 ns = timecounter_read(&mdev->clock); mlx4_en_phc_gettime()
179 *ts = ns_to_timespec64(ns); mlx4_en_phc_gettime()
197 u64 ns = timespec64_to_ns(ts); mlx4_en_phc_settime() local
202 timecounter_init(&mdev->clock, &mdev->cycles, ns); mlx4_en_phc_settime()
261 u64 ns, zero = 0; mlx4_en_init_timestamp() local
281 ns = cyclecounter_cyc2ns(&mdev->cycles, mdev->cycles.mask, zero, &zero); mlx4_en_init_timestamp()
282 do_div(ns, NSEC_PER_SEC / 2 / HZ); mlx4_en_init_timestamp()
283 mdev->overflow_period = ns; mlx4_en_init_timestamp()
/linux-4.1.27/security/tomoyo/
H A Dcommon.c339 * @ns: Pointer to "struct tomoyo_policy_namespace".
343 void tomoyo_init_policy_namespace(struct tomoyo_policy_namespace *ns) tomoyo_init_policy_namespace() argument
347 INIT_LIST_HEAD(&ns->acl_group[idx]); tomoyo_init_policy_namespace()
349 INIT_LIST_HEAD(&ns->group_list[idx]); tomoyo_init_policy_namespace()
351 INIT_LIST_HEAD(&ns->policy_list[idx]); tomoyo_init_policy_namespace()
352 ns->profile_version = 20110903; tomoyo_init_policy_namespace()
354 list_add_tail_rcu(&ns->namespace_list, &tomoyo_namespace_list); tomoyo_init_policy_namespace()
369 container_of(head->r.ns, tomoyo_print_namespace()
479 * @ns: Pointer to "struct tomoyo_policy_namespace".
485 (struct tomoyo_policy_namespace *ns, const unsigned int profile) tomoyo_assign_profile()
491 ptr = ns->profile_ptr[profile]; tomoyo_assign_profile()
497 ptr = ns->profile_ptr[profile]; tomoyo_assign_profile()
510 ns->profile_ptr[profile] = ptr; tomoyo_assign_profile()
522 * @ns: Pointer to "struct tomoyo_policy_namespace".
527 struct tomoyo_profile *tomoyo_profile(const struct tomoyo_policy_namespace *ns, tomoyo_profile() argument
531 struct tomoyo_profile *ptr = ns->profile_ptr[profile]; tomoyo_profile()
666 if (sscanf(data, "PROFILE_VERSION=%u", &head->w.ns->profile_version) tomoyo_write_profile()
673 profile = tomoyo_assign_profile(head->w.ns, i); tomoyo_write_profile()
731 struct tomoyo_policy_namespace *ns = tomoyo_read_profile() local
732 container_of(head->r.ns, typeof(*ns), namespace_list); tomoyo_read_profile()
738 profile = ns->profile_ptr[index]; tomoyo_read_profile()
743 ns->profile_version); tomoyo_read_profile()
749 if (ns->profile_ptr[head->r.index]) tomoyo_read_profile()
847 /* .ns = &tomoyo_kernel_namespace, */ tomoyo_update_manager_entry()
1091 * @ns: Pointer to "struct tomoyo_policy_namespace".
1100 static int tomoyo_write_domain2(struct tomoyo_policy_namespace *ns, tomoyo_write_domain2() argument
1105 .ns = ns, tomoyo_write_domain2()
1149 struct tomoyo_policy_namespace *ns; tomoyo_write_domain() local
1168 ns = domain->ns; tomoyo_write_domain()
1171 if (!tomoyo_policy_loaded || ns->profile_ptr[profile]) tomoyo_write_domain()
1188 return tomoyo_write_domain2(ns, &domain->acl_info_list, data, tomoyo_write_domain()
1707 .ns = head->w.ns, tomoyo_write_exception()
1726 (head->w.ns, &head->w.ns->acl_group[group], tomoyo_write_exception()
1744 struct tomoyo_policy_namespace *ns = tomoyo_read_group() local
1745 container_of(head->r.ns, typeof(*ns), namespace_list); tomoyo_read_group()
1746 struct list_head *list = &ns->group_list[idx]; tomoyo_read_group()
1800 struct tomoyo_policy_namespace *ns = tomoyo_read_policy() local
1801 container_of(head->r.ns, typeof(*ns), namespace_list); tomoyo_read_policy()
1802 struct list_head *list = &ns->policy_list[idx]; tomoyo_read_policy()
1857 struct tomoyo_policy_namespace *ns = tomoyo_read_exception() local
1858 container_of(head->r.ns, typeof(*ns), namespace_list); tomoyo_read_exception()
1875 if (!tomoyo_read_domain2(head, &ns->acl_group tomoyo_read_exception()
1978 if (!tomoyo_write_domain2(domain->ns, &domain->acl_info_list, buffer, tomoyo_add_entry()
2472 struct list_head *ns; tomoyo_set_namespace_cursor() local
2480 ns = head->r.ns; tomoyo_set_namespace_cursor()
2481 if (!ns || (head->r.eof && ns->next != &tomoyo_namespace_list)) { tomoyo_set_namespace_cursor()
2484 head->r.ns = ns ? ns->next : tomoyo_namespace_list.next; tomoyo_set_namespace_cursor()
2499 head->r.ns->next != &tomoyo_namespace_list; tomoyo_has_more_namespace()
2560 head->w.ns = tomoyo_assign_namespace(line); tomoyo_parse_policy()
2563 head->w.ns = NULL; tomoyo_parse_policy()
2565 head->w.ns = &tomoyo_kernel_namespace; tomoyo_parse_policy()
2567 if (!head->w.ns) tomoyo_parse_policy()
2627 head->w.ns = &tomoyo_kernel_namespace; tomoyo_write_control()
2706 const struct tomoyo_policy_namespace *ns = domain->ns; tomoyo_check_profile() local
2707 if (ns->profile_version != 20110903) tomoyo_check_profile()
2710 ns->profile_version); tomoyo_check_profile()
2711 else if (!ns->profile_ptr[profile]) tomoyo_check_profile()
484 tomoyo_assign_profile(struct tomoyo_policy_namespace *ns, const unsigned int profile) tomoyo_assign_profile() argument
H A Ddomain.c179 list = &domain->ns->acl_group[domain->group];
265 param->list = &param->ns->policy_list[TOMOYO_ID_TRANSITION_CONTROL]; tomoyo_write_transition_control()
319 * @ns: Pointer to "struct tomoyo_policy_namespace".
332 (const struct tomoyo_policy_namespace *ns, tomoyo_transition_type()
340 &ns->policy_list[TOMOYO_ID_TRANSITION_CONTROL]; tomoyo_transition_type()
402 param->list = &param->ns->policy_list[TOMOYO_ID_AGGREGATOR]; tomoyo_write_aggregator()
425 struct tomoyo_policy_namespace *ns; tomoyo_find_namespace() local
426 list_for_each_entry(ns, &tomoyo_namespace_list, namespace_list) { tomoyo_find_namespace()
427 if (strncmp(name, ns->name, len) || tomoyo_find_namespace()
430 return ns; tomoyo_find_namespace()
519 !entry->ns->profile_ptr[entry->profile]) tomoyo_assign_domain()
536 e.ns = tomoyo_assign_namespace(domainname); tomoyo_assign_domain()
537 if (!e.ns) tomoyo_assign_domain()
604 ee->r.mode = tomoyo_get_mode(r->domain->ns, ee->r.profile, tomoyo_environ()
711 &old_domain->ns->policy_list[TOMOYO_ID_AGGREGATOR]; tomoyo_find_next_domain()
774 switch (tomoyo_transition_type(old_domain->ns, old_domain->domainname,
791 old_domain->ns->name, candidate->name);
331 tomoyo_transition_type(const struct tomoyo_policy_namespace *ns, const struct tomoyo_path_info *domainname, const struct tomoyo_path_info *program) tomoyo_transition_type() argument
/linux-4.1.27/drivers/scsi/
H A Ddc395x.h380 /* 000 100ns, 10.0 MHz */
381 /* 001 150ns, 6.6 MHz */
382 /* 010 200ns, 5.0 MHz */
383 /* 011 250ns, 4.0 MHz */
384 /* 100 300ns, 3.3 MHz */
385 /* 101 350ns, 2.8 MHz */
386 /* 110 400ns, 2.5 MHz */
387 /* 111 450ns, 2.2 MHz */
392 /* 000 50ns, 20.0 MHz */
393 /* 001 75ns, 13.3 MHz */
394 /* 010 100ns, 10.0 MHz */
395 /* 011 125ns, 8.0 MHz */
396 /* 100 150ns, 6.6 MHz */
397 /* 101 175ns, 5.7 MHz */
398 /* 110 200ns, 5.0 MHz */
399 /* 111 250ns, 4.0 MHz KG: Maybe 225ns, 4.4 MHz */
404 /* 000 25ns, 40.0 MHz */
405 /* 001 50ns, 20.0 MHz */
406 /* 010 75ns, 13.3 MHz */
407 /* 011 100ns, 10.0 MHz */
408 /* 100 125ns, 8.0 MHz */
409 /* 101 150ns, 6.6 MHz */
410 /* 110 175ns, 5.7 MHz */
411 /* 111 200ns, 5.0 MHz */
H A Dnsp32.c150 {0x1, 0, 0x0c, 0x0c, SMPL_40M}, /* 20.0 : 50ns, 25ns */
151 {0x2, 0, 0x0d, 0x18, SMPL_40M}, /* 13.3 : 75ns, 25ns */
152 {0x3, 1, 0x19, 0x19, SMPL_40M}, /* 10.0 : 100ns, 50ns */
153 {0x4, 1, 0x1a, 0x1f, SMPL_20M}, /* 8.0 : 125ns, 50ns */
154 {0x5, 2, 0x20, 0x25, SMPL_20M}, /* 6.7 : 150ns, 75ns */
155 {0x6, 2, 0x26, 0x31, SMPL_20M}, /* 5.7 : 175ns, 75ns */
156 {0x7, 3, 0x32, 0x32, SMPL_20M}, /* 5.0 : 200ns, 100ns */
157 {0x8, 3, 0x33, 0x38, SMPL_10M}, /* 4.4 : 225ns, 100ns */
158 {0x9, 3, 0x39, 0x3e, SMPL_10M}, /* 4.0 : 250ns, 100ns */
162 {0x1, 0, 0x19, 0x19, SMPL_40M}, /* 10.0 : 100ns, 50ns */
163 {0x2, 0, 0x1a, 0x25, SMPL_20M}, /* 6.7 : 150ns, 50ns */
164 {0x3, 1, 0x26, 0x32, SMPL_20M}, /* 5.0 : 200ns, 100ns */
165 {0x4, 1, 0x33, 0x3e, SMPL_10M}, /* 4.0 : 250ns, 100ns */
166 {0x5, 2, 0x3f, 0x4b, SMPL_10M}, /* 3.3 : 300ns, 150ns */
167 {0x6, 2, 0x4c, 0x57, SMPL_10M}, /* 2.8 : 350ns, 150ns */
168 {0x7, 3, 0x58, 0x64, SMPL_10M}, /* 2.5 : 400ns, 200ns */
169 {0x8, 3, 0x65, 0x70, SMPL_10M}, /* 2.2 : 450ns, 200ns */
170 {0x9, 3, 0x71, 0x7d, SMPL_10M}, /* 2.0 : 500ns, 200ns */
174 {0x1, 0, 0x0c, 0x0f, SMPL_40M}, /* 16.6 : 60ns, 30ns */
175 {0x2, 0, 0x10, 0x16, SMPL_40M}, /* 11.1 : 90ns, 30ns */
176 {0x3, 1, 0x17, 0x1e, SMPL_20M}, /* 8.3 : 120ns, 60ns */
177 {0x4, 1, 0x1f, 0x25, SMPL_20M}, /* 6.7 : 150ns, 60ns */
178 {0x5, 2, 0x26, 0x2d, SMPL_20M}, /* 5.6 : 180ns, 90ns */
179 {0x6, 2, 0x2e, 0x34, SMPL_10M}, /* 4.8 : 210ns, 90ns */
180 {0x7, 3, 0x35, 0x3c, SMPL_10M}, /* 4.2 : 240ns, 120ns */
181 {0x8, 3, 0x3d, 0x43, SMPL_10M}, /* 3.7 : 270ns, 120ns */
182 {0x9, 3, 0x44, 0x4b, SMPL_10M}, /* 3.3 : 300ns, 120ns */
2604 * dividing * 100ns/4). nsp32_detect()
/linux-4.1.27/net/nfc/hci/
H A Dllc_shdlc.c60 int ns; /* next seq num for send */ member in struct:llc_shdlc
235 struct sk_buff *skb, int ns, int nr) llc_shdlc_rcv_i_frame()
237 int x_ns = ns; llc_shdlc_rcv_i_frame()
240 pr_debug("recvd I-frame %d, remote waiting frame %d\n", ns, nr); llc_shdlc_rcv_i_frame()
264 if (llc_shdlc_x_lt_y_lteq_z(shdlc->dnr, y_nr, shdlc->ns)) { llc_shdlc_rcv_i_frame()
278 if (llc_shdlc_x_lt_y_lteq_z(shdlc->dnr, y_nr, shdlc->ns)) { llc_shdlc_rcv_ack()
288 pr_debug("ns reset to %d\n", shdlc->dnr); llc_shdlc_requeue_ack_pending()
294 shdlc->ns = shdlc->dnr; llc_shdlc_requeue_ack_pending()
303 if (llc_shdlc_x_lteq_y_lt_z(shdlc->dnr, y_nr, shdlc->ns)) { llc_shdlc_rcv_rej()
361 shdlc->ns = 0; llc_shdlc_connect_complete()
475 int ns; llc_shdlc_handle_rcv_queue() local
491 ns = (control & SHDLC_CONTROL_NS_MASK) >> 3; llc_shdlc_handle_rcv_queue()
493 llc_shdlc_rcv_i_frame(shdlc, skb, ns, nr); llc_shdlc_handle_rcv_queue()
516 static int llc_shdlc_w_used(int ns, int dnr) llc_shdlc_w_used() argument
520 if (dnr <= ns) llc_shdlc_w_used()
521 unack_count = ns - dnr; llc_shdlc_w_used()
523 unack_count = 8 - dnr + ns; llc_shdlc_w_used()
537 ("sendQlen=%d ns=%d dnr=%d rnr=%s w_room=%d unackQlen=%d\n", llc_shdlc_handle_send_queue()
538 shdlc->send_q.qlen, shdlc->ns, shdlc->dnr, llc_shdlc_handle_send_queue()
540 shdlc->w - llc_shdlc_w_used(shdlc->ns, shdlc->dnr), llc_shdlc_handle_send_queue()
554 *skb_push(skb, 1) = SHDLC_CONTROL_HEAD_I | (shdlc->ns << 3) | llc_shdlc_handle_send_queue()
557 pr_debug("Sending I-Frame %d, waiting to rcv %d\n", shdlc->ns, llc_shdlc_handle_send_queue()
567 shdlc->ns = (shdlc->ns + 1) % 8; llc_shdlc_handle_send_queue()
234 llc_shdlc_rcv_i_frame(struct llc_shdlc *shdlc, struct sk_buff *skb, int ns, int nr) llc_shdlc_rcv_i_frame() argument
/linux-4.1.27/samples/bpf/
H A Dtracex3_user.c69 printf("|1ns |10ns |100ns |1us |10us |100us" print_banner()
/linux-4.1.27/security/selinux/include/
H A Dnetif.h24 int sel_netif_sid(struct net *ns, int ifindex, u32 *sid);
/linux-4.1.27/sound/drivers/pcsp/
H A Dpcsp_lib.c40 /* write the port and returns the next expire time in ns;
46 u64 ns; pcsp_timer_update() local
82 ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem); pcsp_timer_update()
83 chip->ns_rem -= ns; pcsp_timer_update()
84 return ns; pcsp_timer_update()
132 u64 ns; pcsp_do_timer() local
138 ns = pcsp_timer_update(chip); pcsp_do_timer()
139 if (!ns) { pcsp_do_timer()
147 hrtimer_forward(handle, hrtimer_get_expires(handle), ns_to_ktime(ns)); pcsp_do_timer()
/linux-4.1.27/fs/ntfs/
H A Dunistr.c340 unsigned char *ns; ntfs_ucstonls() local
345 ns = *outs; ntfs_ucstonls()
347 if (ns && !ns_len) { ntfs_ucstonls()
351 if (!ns) { ntfs_ucstonls()
353 ns = kmalloc(ns_len + 1, GFP_NOFS); ntfs_ucstonls()
354 if (!ns) ntfs_ucstonls()
358 retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o, ntfs_ucstonls()
365 else if (wc == -ENAMETOOLONG && ns != *outs) { ntfs_ucstonls()
371 memcpy(tc, ns, ns_len); ntfs_ucstonls()
373 kfree(ns); ntfs_ucstonls()
374 ns = tc; ntfs_ucstonls()
380 ns[o] = 0; ntfs_ucstonls()
381 *outs = ns; ntfs_ucstonls()
390 if (ns != *outs) ntfs_ucstonls()
391 kfree(ns); ntfs_ucstonls()
/linux-4.1.27/arch/mips/lib/
H A Ddelay.c58 void __ndelay(unsigned long ns) __ndelay() argument
62 __delay((ns * 0x00000005ull * HZ * lpj) >> 32); __ndelay()
/linux-4.1.27/arch/blackfin/include/asm/
H A Dtime.h17 * If you take the fastest clock (1ns, or 1GHz to make the math work easier)
19 * (32 bit counter is 4,294,967,296ns or 4.2 seconds) so, we don't need
/linux-4.1.27/drivers/memory/
H A Dti-aemif.c88 * @wstrobe: write strobe width, ns
89 * @rstrobe: read strobe width, ns
90 * @wsetup: write setup width, ns
91 * @whold: write hold width, ns
92 * @rsetup: read setup width, ns
93 * @rhold: read hold width, ns
94 * @ta: minimum turn around time, ns
293 if (!of_property_read_u32(np, "ti,cs-min-turnaround-ns", &val)) of_aemif_parse_abus_config()
296 if (!of_property_read_u32(np, "ti,cs-read-hold-ns", &val)) of_aemif_parse_abus_config()
299 if (!of_property_read_u32(np, "ti,cs-read-strobe-ns", &val)) of_aemif_parse_abus_config()
302 if (!of_property_read_u32(np, "ti,cs-read-setup-ns", &val)) of_aemif_parse_abus_config()
305 if (!of_property_read_u32(np, "ti,cs-write-hold-ns", &val)) of_aemif_parse_abus_config()
308 if (!of_property_read_u32(np, "ti,cs-write-strobe-ns", &val)) of_aemif_parse_abus_config()
311 if (!of_property_read_u32(np, "ti,cs-write-setup-ns", &val)) of_aemif_parse_abus_config()
H A Domap-gpmc.c420 * tick format: gpmc,name = <value> /&zwj;* x ns -- y ns; x ticks *&zwj;/
421 * Where x ns -- y ns result in the same tick value.
453 /* DTS tick format for timings in ns */ get_gpmc_timing_reg()
460 pr_info("gpmc,%s = <%u> /* %u ns - %u ns; %i ticks%s*/\n", get_gpmc_timing_reg()
537 GPMC_GET_TICKS(GPMC_CS_CONFIG2, 0, 3, "cs-on-ns"); gpmc_cs_show_timings()
538 GPMC_GET_TICKS(GPMC_CS_CONFIG2, 8, 12, "cs-rd-off-ns"); gpmc_cs_show_timings()
539 GPMC_GET_TICKS(GPMC_CS_CONFIG2, 16, 20, "cs-wr-off-ns"); gpmc_cs_show_timings()
541 GPMC_GET_TICKS(GPMC_CS_CONFIG3, 0, 3, "adv-on-ns"); gpmc_cs_show_timings()
542 GPMC_GET_TICKS(GPMC_CS_CONFIG3, 8, 12, "adv-rd-off-ns"); gpmc_cs_show_timings()
543 GPMC_GET_TICKS(GPMC_CS_CONFIG3, 16, 20, "adv-wr-off-ns"); gpmc_cs_show_timings()
545 GPMC_GET_TICKS(GPMC_CS_CONFIG4, 0, 3, "oe-on-ns"); gpmc_cs_show_timings()
546 GPMC_GET_TICKS(GPMC_CS_CONFIG4, 8, 12, "oe-off-ns"); gpmc_cs_show_timings()
547 GPMC_GET_TICKS(GPMC_CS_CONFIG4, 16, 19, "we-on-ns"); gpmc_cs_show_timings()
548 GPMC_GET_TICKS(GPMC_CS_CONFIG4, 24, 28, "we-off-ns"); gpmc_cs_show_timings()
550 GPMC_GET_TICKS(GPMC_CS_CONFIG5, 0, 4, "rd-cycle-ns"); gpmc_cs_show_timings()
551 GPMC_GET_TICKS(GPMC_CS_CONFIG5, 8, 12, "wr-cycle-ns"); gpmc_cs_show_timings()
552 GPMC_GET_TICKS(GPMC_CS_CONFIG5, 16, 20, "access-ns"); gpmc_cs_show_timings()
554 GPMC_GET_TICKS(GPMC_CS_CONFIG5, 24, 27, "page-burst-access-ns"); gpmc_cs_show_timings()
556 GPMC_GET_TICKS(GPMC_CS_CONFIG6, 0, 3, "bus-turnaround-ns"); gpmc_cs_show_timings()
557 GPMC_GET_TICKS(GPMC_CS_CONFIG6, 8, 11, "cycle2cycle-delay-ns"); gpmc_cs_show_timings()
561 "wait-monitoring-ns", GPMC_CD_CLK); gpmc_cs_show_timings()
564 "clk-activation-ns", GPMC_CD_FCLK); gpmc_cs_show_timings()
566 GPMC_GET_TICKS(GPMC_CS_CONFIG6, 16, 19, "wr-data-mux-bus-ns"); gpmc_cs_show_timings()
567 GPMC_GET_TICKS(GPMC_CS_CONFIG6, 24, 28, "wr-access-ns"); gpmc_cs_show_timings()
586 * @time: Timing parameter in ns.
608 pr_err("%s: GPMC CS%d: %s %d ns, %d ticks > %d ticks\n", set_gpmc_timing_reg()
617 "GPMC CS%d: %-17s: %3d ticks, %3lu ns (was %3i ticks) %3d ns\n", set_gpmc_timing_reg()
648 * @wait_monitoring: WAITMONITORINGTIME in ns.
723 pr_err("%s: waitmonitoringtime %3d ns too large for greatest gpmcfclkdivider.\n", gpmc_cs_set_timings()
771 pr_info("GPMC CS%d CLK period is %lu ns (div %d)\n", gpmc_cs_set_timings()
1515 * has to be modified to handle timings in ps instead of ns
1719 of_property_read_u32(np, "gpmc,cs-on-ns", &gpmc_t->cs_on); gpmc_read_timings_dt()
1720 of_property_read_u32(np, "gpmc,cs-rd-off-ns", &gpmc_t->cs_rd_off); gpmc_read_timings_dt()
1721 of_property_read_u32(np, "gpmc,cs-wr-off-ns", &gpmc_t->cs_wr_off); gpmc_read_timings_dt()
1724 of_property_read_u32(np, "gpmc,adv-on-ns", &gpmc_t->adv_on); gpmc_read_timings_dt()
1725 of_property_read_u32(np, "gpmc,adv-rd-off-ns", &gpmc_t->adv_rd_off); gpmc_read_timings_dt()
1726 of_property_read_u32(np, "gpmc,adv-wr-off-ns", &gpmc_t->adv_wr_off); gpmc_read_timings_dt()
1729 of_property_read_u32(np, "gpmc,we-on-ns", &gpmc_t->we_on); gpmc_read_timings_dt()
1730 of_property_read_u32(np, "gpmc,we-off-ns", &gpmc_t->we_off); gpmc_read_timings_dt()
1733 of_property_read_u32(np, "gpmc,oe-on-ns", &gpmc_t->oe_on); gpmc_read_timings_dt()
1734 of_property_read_u32(np, "gpmc,oe-off-ns", &gpmc_t->oe_off); gpmc_read_timings_dt()
1737 of_property_read_u32(np, "gpmc,page-burst-access-ns", gpmc_read_timings_dt()
1739 of_property_read_u32(np, "gpmc,access-ns", &gpmc_t->access); gpmc_read_timings_dt()
1740 of_property_read_u32(np, "gpmc,rd-cycle-ns", &gpmc_t->rd_cycle); gpmc_read_timings_dt()
1741 of_property_read_u32(np, "gpmc,wr-cycle-ns", &gpmc_t->wr_cycle); gpmc_read_timings_dt()
1742 of_property_read_u32(np, "gpmc,bus-turnaround-ns", gpmc_read_timings_dt()
1744 of_property_read_u32(np, "gpmc,cycle2cycle-delay-ns", gpmc_read_timings_dt()
1746 of_property_read_u32(np, "gpmc,wait-monitoring-ns", gpmc_read_timings_dt()
1748 of_property_read_u32(np, "gpmc,clk-activation-ns", gpmc_read_timings_dt()
1752 of_property_read_u32(np, "gpmc,wr-access-ns", &gpmc_t->wr_access); gpmc_read_timings_dt()
1753 of_property_read_u32(np, "gpmc,wr-data-mux-bus-ns", gpmc_read_timings_dt()
/linux-4.1.27/drivers/video/fbdev/omap/
H A Dhwa742.c640 /* CSOnTime 0, WEOnTime 2 ns, REOnTime 2 ns, calc_reg_timing()
641 * AccessTime 2 ns + 12.2 ns (regs), calc_reg_timing()
642 * WEOffTime = WEOnTime + 1 ns, calc_reg_timing()
643 * REOffTime = REOnTime + 16 ns (regs), calc_reg_timing()
644 * CSOffTime = REOffTime + 1 ns calc_reg_timing()
645 * ReadCycle = 2ns + 2*SYSCLK (regs), calc_reg_timing()
646 * WriteCycle = 2*SYSCLK + 2 ns, calc_reg_timing()
647 * CSPulseWidth = 10 ns */ calc_reg_timing()
686 /* CSOnTime 0, WEOnTime 2 ns, REOnTime 2 ns, calc_lut_timing()
687 * AccessTime 2 ns + 4 * SYSCLK + 26 (lut), calc_lut_timing()
688 * WEOffTime = WEOnTime + 1 ns, calc_lut_timing()
689 * REOffTime = REOnTime + 4*SYSCLK + 26 ns (lut), calc_lut_timing()
690 * CSOffTime = REOffTime + 1 ns calc_lut_timing()
691 * ReadCycle = 2ns + 4*SYSCLK + 26 ns (lut), calc_lut_timing()
692 * WriteCycle = 2*SYSCLK + 2 ns, calc_lut_timing()
693 * CSPulseWidth = 10 ns calc_lut_timing()
/linux-4.1.27/net/core/
H A Dnet_namespace.c306 struct net *ns = p; net_drop_ns() local
307 if (ns && atomic_dec_and_test(&ns->passive)) net_drop_ns()
308 net_free(ns); net_drop_ns()
424 struct ns_common *ns; get_net_ns_by_fd() local
431 ns = get_proc_ns(file_inode(file)); get_net_ns_by_fd()
432 if (ns->ops == &netns_operations) get_net_ns_by_fd()
433 net = get_net(container_of(ns, struct net, ns)); get_net_ns_by_fd()
474 net->ns.ops = &netns_operations; net_ns_net_init()
476 return ns_alloc_inum(&net->ns); net_ns_net_init()
481 ns_free_inum(&net->ns); net_ns_net_exit()
932 return net ? &net->ns : NULL; netns_get()
935 static inline struct net *to_net_ns(struct ns_common *ns) to_net_ns() argument
937 return container_of(ns, struct net, ns); to_net_ns()
940 static void netns_put(struct ns_common *ns) netns_put() argument
942 put_net(to_net_ns(ns)); netns_put()
945 static int netns_install(struct nsproxy *nsproxy, struct ns_common *ns) netns_install() argument
947 struct net *net = to_net_ns(ns); netns_install()
H A Dnet-sysfs.c851 const void *ns = NULL; rx_queue_namespace() local
854 ns = dev->class->namespace(dev); rx_queue_namespace()
856 return ns; rx_queue_namespace()
1246 const void *ns = NULL; netdev_queue_namespace() local
1249 ns = dev->class->namespace(dev); netdev_queue_namespace()
1251 return ns; netdev_queue_namespace()
1375 struct net *ns = current->nsproxy->net_ns; net_grab_current_ns() local
1377 if (ns) net_grab_current_ns()
1378 atomic_inc(&ns->passive); net_grab_current_ns()
1380 return ns; net_grab_current_ns()
1539 const void *ns) netdev_class_create_file_ns()
1541 return class_create_file_ns(&net_class, class_attr, ns); netdev_class_create_file_ns()
1546 const void *ns) netdev_class_remove_file_ns()
1548 class_remove_file_ns(&net_class, class_attr, ns); netdev_class_remove_file_ns()
1538 netdev_class_create_file_ns(struct class_attribute *class_attr, const void *ns) netdev_class_create_file_ns() argument
1545 netdev_class_remove_file_ns(struct class_attribute *class_attr, const void *ns) netdev_class_remove_file_ns() argument
/linux-4.1.27/drivers/media/pci/cx23885/
H A Dcx23885-input.c167 /* RC-5: 2,222,222 ns = 1/36 kHz * 32 cycles * 2 marks * 1.25*/ cx23885_input_ir_start()
168 /* RC-6A: 3,333,333 ns = 1/36 kHz * 16 cycles * 6 marks * 1.25*/ cx23885_input_ir_start()
169 params.max_pulse_width = 3333333; /* ns */ cx23885_input_ir_start()
170 /* RC-5: 666,667 ns = 1/36 kHz * 32 cycles * 1 mark * 0.75 */ cx23885_input_ir_start()
171 /* RC-6A: 333,333 ns = 1/36 kHz * 16 cycles * 1 mark * 0.75 */ cx23885_input_ir_start()
172 params.noise_filter_min_width = 333333; /* ns */ cx23885_input_ir_start()
201 * (64/3)/(455 kHz/12) * 16 nec_units * 1.375 = 12378022 ns cx23885_input_ir_start()
203 params.max_pulse_width = 12378022; /* ns */ cx23885_input_ir_start()
207 * (64/3)/(455 kHz/12) * 1 nec_units * 0.625 = 351648 ns cx23885_input_ir_start()
209 params.noise_filter_min_width = 351648; /* ns */ cx23885_input_ir_start()
H A Dcx23888-ir.c173 * (0xffff + 1) * 1000 / 108/2 MHz = 1,213,629.629... ns
187 static inline u16 ns_to_clock_divider(unsigned int ns) ns_to_clock_divider() argument
190 DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ / 1000000 * ns, 1000)); ns_to_clock_divider()
195 /* Period of the Rx or Tx clock in ns */ clock_divider_to_ns()
229 * 0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns
241 static inline u16 ns_to_lpf_count(unsigned int ns) ns_to_lpf_count() argument
244 DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ / 1000000 * ns, 1000)); ns_to_lpf_count()
249 /* Duration of the Low Pass Filter rejection window in ns */ lpf_count_to_ns()
268 * not readable, hence the << 2. This function returns ns. clock_divider_to_resolution()
284 rem = do_div(n, CX23888_IR_REFCLK_FREQ / 1000000); /* / MHz => ns */ pulse_width_count_to_ns()
314 static u64 ns_to_pulse_clocks(u32 ns) ns_to_pulse_clocks() argument
318 clocks = CX23888_IR_REFCLK_FREQ / 1000000 * (u64) ns; /* millicycles */ ns_to_pulse_clocks()
458 static u32 txclk_tx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns, txclk_tx_s_max_pulse_width() argument
463 if (ns > IR_MAX_DURATION) txclk_tx_s_max_pulse_width()
464 ns = IR_MAX_DURATION; txclk_tx_s_max_pulse_width()
465 pulse_clocks = ns_to_pulse_clocks(ns); txclk_tx_s_max_pulse_width()
471 static u32 rxclk_rx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns, rxclk_rx_s_max_pulse_width() argument
476 if (ns > IR_MAX_DURATION) rxclk_rx_s_max_pulse_width()
477 ns = IR_MAX_DURATION; rxclk_rx_s_max_pulse_width()
478 pulse_clocks = ns_to_pulse_clocks(ns); rxclk_rx_s_max_pulse_width()
704 v4l2_dbg(2, ir_888_debug, sd, "rx read: %10u ns %s %s\n", cx23888_ir_rx_read()
1023 v4l2_info(sd, "\tMax measurable pulse width: %u us, %llu ns\n", cx23888_ir_log_status()
1030 "%u ns\n", cx23888_ir_log_status()
1068 v4l2_info(sd, "\tMax pulse width: %u us, %llu ns\n", cx23888_ir_log_status()
1147 /* RC-5: 666,667 ns = 1/36 kHz * 32 cycles * 1 mark * 0.75 */
1148 /* RC-6A: 333,333 ns = 1/36 kHz * 16 cycles * 1 mark * 0.75 */
1149 .noise_filter_min_width = 333333, /* ns */
/linux-4.1.27/net/ax25/
H A Dax25_std_in.c144 static int ax25_std_state3_machine(ax25_cb *ax25, struct sk_buff *skb, int frametype, int ns, int nr, int pf, int type) ax25_std_state3_machine() argument
226 if (ns == ax25->vr) { ax25_std_state3_machine()
230 ax25->vr = ns; /* ax25->vr - 1 */ ax25_std_state3_machine()
269 static int ax25_std_state4_machine(ax25_cb *ax25, struct sk_buff *skb, int frametype, int ns, int nr, int pf, int type) ax25_std_state4_machine() argument
381 if (ns == ax25->vr) { ax25_std_state4_machine()
385 ax25->vr = ns; /* ax25->vr - 1 */ ax25_std_state4_machine()
424 int queued = 0, frametype, ns, nr, pf; ax25_std_frame_in() local
426 frametype = ax25_decode(ax25, skb, &ns, &nr, &pf); ax25_std_frame_in()
436 queued = ax25_std_state3_machine(ax25, skb, frametype, ns, nr, pf, type); ax25_std_frame_in()
439 queued = ax25_std_state4_machine(ax25, skb, frametype, ns, nr, pf, type); ax25_std_frame_in()
H A Dax25_ds_in.c148 static int ax25_ds_state3_machine(ax25_cb *ax25, struct sk_buff *skb, int frametype, int ns, int nr, int pf, int type) ax25_ds_state3_machine() argument
241 if (ns == ax25->vr) { ax25_ds_state3_machine()
245 ax25->vr = ns; /* ax25->vr - 1 */ ax25_ds_state3_machine()
284 int queued = 0, frametype, ns, nr, pf; ax25_ds_frame_in() local
286 frametype = ax25_decode(ax25, skb, &ns, &nr, &pf); ax25_ds_frame_in()
296 queued = ax25_ds_state3_machine(ax25, skb, frametype, ns, nr, pf, type); ax25_ds_frame_in()
H A Dax25_subr.c100 int ax25_decode(ax25_cb *ax25, struct sk_buff *skb, int *ns, int *nr, int *pf) ax25_decode() argument
106 *ns = *nr = *pf = 0; ax25_decode()
111 *ns = (frame[0] >> 1) & 0x07; ax25_decode()
126 *ns = (frame[0] >> 1) & 0x7F; ax25_decode()
/linux-4.1.27/drivers/media/i2c/cx25840/
H A Dcx25840-ir.c139 * (0xffff + 1) * 1000 / 108/2 MHz = 1,213,629.629... ns
153 static inline u16 ns_to_clock_divider(unsigned int ns) ns_to_clock_divider() argument
156 DIV_ROUND_CLOSEST(CX25840_IR_REFCLK_FREQ / 1000000 * ns, 1000)); ns_to_clock_divider()
161 /* Period of the Rx or Tx clock in ns */ clock_divider_to_ns()
195 * 0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns
207 static inline u16 ns_to_lpf_count(unsigned int ns) ns_to_lpf_count() argument
210 DIV_ROUND_CLOSEST(CX25840_IR_REFCLK_FREQ / 1000000 * ns, 1000)); ns_to_lpf_count()
215 /* Duration of the Low Pass Filter rejection window in ns */ lpf_count_to_ns()
234 * not readable, hence the << 2. This function returns ns. clock_divider_to_resolution()
250 rem = do_div(n, CX25840_IR_REFCLK_FREQ / 1000000); /* / MHz => ns */ pulse_width_count_to_ns()
258 static u16 ns_to_pulse_width_count(u32 ns, u16 divider)
268 n = ((u64) ns) * CX25840_IR_REFCLK_FREQ / 1000000; /* millicycles */
306 static u64 ns_to_pulse_clocks(u32 ns) ns_to_pulse_clocks() argument
310 clocks = CX25840_IR_REFCLK_FREQ / 1000000 * (u64) ns; /* millicycles */ ns_to_pulse_clocks()
443 static u32 txclk_tx_s_max_pulse_width(struct i2c_client *c, u32 ns, txclk_tx_s_max_pulse_width() argument
448 if (ns > IR_MAX_DURATION) txclk_tx_s_max_pulse_width()
449 ns = IR_MAX_DURATION; txclk_tx_s_max_pulse_width()
450 pulse_clocks = ns_to_pulse_clocks(ns); txclk_tx_s_max_pulse_width()
456 static u32 rxclk_rx_s_max_pulse_width(struct i2c_client *c, u32 ns, rxclk_rx_s_max_pulse_width() argument
461 if (ns > IR_MAX_DURATION) rxclk_rx_s_max_pulse_width()
462 ns = IR_MAX_DURATION; rxclk_rx_s_max_pulse_width()
463 pulse_clocks = ns_to_pulse_clocks(ns); rxclk_rx_s_max_pulse_width()
714 v4l2_dbg(2, ir_debug, sd, "rx read: %10u ns %s %s\n", cx25840_ir_rx_read()
869 * from the tx_kfifo, or converted from ns to the proper units from the cx25840_ir_tx_write()
1121 v4l2_info(sd, "\tMax measurable pulse width: %u us, %llu ns\n", cx25840_ir_log_status()
1128 "%u ns\n", cx25840_ir_log_status()
1164 v4l2_info(sd, "\tMax pulse width: %u us, %llu ns\n", cx25840_ir_log_status()
1200 /* RC-5: 666,667 ns = 1/36 kHz * 32 cycles * 1 mark * 0.75 */
1201 /* RC-6: 333,333 ns = 1/36 kHz * 16 cycles * 1 mark * 0.75 */
1202 .noise_filter_min_width = 333333, /* ns */
/linux-4.1.27/drivers/net/ethernet/intel/e1000e/
H A Dptp.c106 * Read the timecounter and return the correct value in ns after converting
114 u64 ns; e1000e_phc_gettime() local
117 ns = timecounter_read(&adapter->tc); e1000e_phc_gettime()
120 *ts = ns_to_timespec64(ns); e1000e_phc_gettime()
139 u64 ns; e1000e_phc_settime() local
141 ns = timespec64_to_ns(ts); e1000e_phc_settime()
145 timecounter_init(&adapter->tc, &adapter->cc, ns); e1000e_phc_settime()
/linux-4.1.27/drivers/cpufreq/
H A Dsa1110-cpufreq.c39 u_char tck; /* clock cycle time (ns) */
40 u_char trcd; /* activate to r/w (ns) */
41 u_char trp; /* precharge to activate (ns) */
42 u_char twr; /* write recovery time (ns) */
121 * Given a period in ns and frequency in khz, calculate the number of
125 static inline u_int ns_to_cycles(u_int ns, u_int khz) ns_to_cycles() argument
127 return (ns * khz + 999999) / 1000000; ns_to_cycles()
H A Ds3c24xx-cpufreq-debugfs.c54 seq_printf(seq, "SDRAM refresh %u ns\n", brd->refresh); board_show()
88 seq_printf(seq, " HCLK %ld Hz (%lu.%lu ns)\n", info_show()
145 seq_printf(seq, "hclk period is %lu.%lu ns\n", print_ns(cfg->freq.hclk_tns)); io_show()
/linux-4.1.27/include/trace/events/
H A Dkvm.h41 TP_PROTO(__u64 ns, bool waited),
42 TP_ARGS(ns, waited),
45 __field( __u64, ns )
50 __entry->ns = ns;
54 TP_printk("%s time %lld ns",
56 __entry->ns)
/linux-4.1.27/drivers/net/ethernet/intel/ixgbe/
H A Dixgbe_ptp.c41 * period of 6.4ns. In order to convert the scale counter into
43 * used. The SYSTIME registers need to be converted to ns values by use
55 * For the X540, MaxWidth is 31 bits, and the base period is 6.4 ns
56 * For the 82599, MaxWidth is 24 bits, and the base period is 6.4 ns
60 * At 1Gb link, the period is multiplied by 10. (64ns)
61 * At 100Mb link, the period is multiplied by 100. (640ns)
124 u64 ns = 0, clock_edge = 0; ixgbe_ptp_setup_sdp() local
156 * using the converted ns value of the current time to ixgbe_ptp_setup_sdp()
161 ns = timecounter_cyc2time(&adapter->tc, clock_edge); ixgbe_ptp_setup_sdp()
163 div_u64_rem(ns, IXGBE_PTP_PPS_HALF_SECOND, &rem); ixgbe_ptp_setup_sdp()
189 * cyclecounter structure used to construct a ns counter from the
279 * read the timecounter and return the correct value on ns,
286 u64 ns; ixgbe_ptp_gettime() local
290 ns = timecounter_read(&adapter->tc); ixgbe_ptp_gettime()
293 *ts = ns_to_timespec64(ns); ixgbe_ptp_gettime()
311 u64 ns; ixgbe_ptp_settime() local
314 ns = timespec64_to_ns(ts); ixgbe_ptp_settime()
318 timecounter_init(&adapter->tc, &adapter->cc, ns); ixgbe_ptp_settime()
456 * if the timestamp is valid, we convert it into the timecounter ns
464 u64 regval = 0, ns; ixgbe_ptp_tx_hwtstamp() local
471 ns = timecounter_cyc2time(&adapter->tc, regval); ixgbe_ptp_tx_hwtstamp()
475 shhwtstamps.hwtstamp = ns_to_ktime(ns); ixgbe_ptp_tx_hwtstamp()
521 * if the timestamp is valid, we convert it into the timecounter ns
529 u64 regval = 0, ns; ixgbe_ptp_rx_hwtstamp() local
541 ns = timecounter_cyc2time(&adapter->tc, regval); ixgbe_ptp_rx_hwtstamp()
545 shhwtstamps->hwtstamp = ns_to_ktime(ns); ixgbe_ptp_rx_hwtstamp()
829 /* reset the ns time counter */ ixgbe_ptp_reset()
/linux-4.1.27/drivers/net/phy/
H A Ddp83640.c68 /* phyter seems to miss the mark by 16 ns */
83 u16 ns_lo; /* ns[15:0] */
84 u16 ns_hi; /* overflow[1:0], ns[29:16] */
92 u16 ns_lo; /* ns[15:0] */
93 u16 ns_hi; /* overflow[1:0], ns[29:16] */
101 u64 ns; member in struct:rxts
262 ext_write(bc, dev, PAGE4, PTP_TDR, ts->tv_nsec & 0xffff);/* ns[15:0] */ tdr_write()
263 ext_write(bc, dev, PAGE4, PTP_TDR, ts->tv_nsec >> 16); /* ns[31:16] */ tdr_write()
281 rxts->ns = p->ns_lo; phy2rxts()
282 rxts->ns |= (p->ns_hi & 0x3fff) << 16; phy2rxts()
283 rxts->ns += ((u64)sec) * 1000000000ULL; phy2rxts()
292 u64 ns; phy2txts() local
298 ns = p->ns_lo; phy2txts()
299 ns |= (p->ns_hi & 0x3fff) << 16; phy2txts()
300 ns += ((u64)sec) * 1000000000ULL; phy2txts()
302 return ns; phy2txts()
353 ext_write(0, phydev, PAGE4, PTP_TDR, nsec & 0xffff); /* ns[15:0] */ periodic_output()
354 ext_write(0, phydev, PAGE4, PTP_TDR, nsec >> 16); /* ns[31:16] */ periodic_output()
357 ext_write(0, phydev, PAGE4, PTP_TDR, pwidth & 0xffff); /* ns[15:0] */ periodic_output()
358 ext_write(0, phydev, PAGE4, PTP_TDR, pwidth >> 16); /* ns[31:16] */ periodic_output()
442 val[0] = ext_read(phydev, PAGE4, PTP_TDR); /* ns[15:0] */ ptp_dp83640_gettime()
443 val[1] = ext_read(phydev, PAGE4, PTP_TDR); /* ns[31:16] */ ptp_dp83640_gettime()
863 shhwtstamps->hwtstamp = ns_to_ktime(rxts->ns); decode_rxts()
882 u64 ns; decode_txts() local
904 ns = phy2txts(phy_txts); decode_txts()
906 shhwtstamps.hwtstamp = ns_to_ktime(ns); decode_txts()
1409 shhwtstamps->hwtstamp = ns_to_ktime(rxts->ns); dp83640_rxtstamp()
/linux-4.1.27/drivers/media/rc/
H A Dir-xmp-decoder.c23 #define XMP_UNIT 136000 /* ns */
24 #define XMP_LEADER 210000 /* ns */
25 #define XMP_NIBBLE_PREFIX 760000 /* ns */
26 #define XMP_HALFFRAME_SPACE 13800000 /* ns */
H A Dene_ir.h144 /* detected RX carrier period (resolution: 500 ns) */
148 /* detected RX carrier pulse width (resolution: 500 ns) */
151 /* TX period (resolution: 500 ns, minimum 2)*/
158 /* TX pulse width (resolution: 500 ns)*/
/linux-4.1.27/arch/x86/kvm/
H A Di8254.h28 s64 period; /* unit: ns */
/linux-4.1.27/arch/tile/include/asm/
H A Dhardwall.h26 int proc_pid_hardwall(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task);
/linux-4.1.27/include/linux/regulator/
H A Dfixed.h73 #define regulator_register_fixed(id, s, ns) regulator_register_always_on(id, \
74 "fixed-dummy", s, ns, 0)
/linux-4.1.27/arch/sh/include/mach-common/mach/
H A Dsh2007.h79 #define IW5 6 /* 60ns PIO mode 4 */
80 #define IW6 15 /* 250ns */
/linux-4.1.27/arch/avr32/boards/hammerhead/
H A Dflash.c109 .ncs_read_pulse = 75, /* min. 33ns */
110 .nrd_pulse = 75, /* min. 33ns */
111 .ncs_write_pulse = 75, /* min. 26ns */
112 .nwe_pulse = 75, /* min. 26ns */
114 .read_cycle = 225, /* min. 143ns */
115 .write_cycle = 225, /* min. 136ns */
/linux-4.1.27/net/x25/
H A Dx25_in.c204 static int x25_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype, int ns, int nr, int q, int d, int m) x25_state3_machine() argument
257 if ((ns != x25->vr) || !x25_validate_nr(sk, nr)) { x25_state3_machine()
270 if (ns == x25->vr) { x25_state3_machine()
384 int queued = 0, frametype, ns, nr, q, d, m; x25_process_rx_frame() local
389 frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m); x25_process_rx_frame()
399 queued = x25_state3_machine(sk, skb, frametype, ns, nr, q, d, m); x25_process_rx_frame()
/linux-4.1.27/net/l2tp/
H A Dl2tp_core.c95 u32 ns; member in struct:l2tp_skb_cb
379 u32 ns = L2TP_SKB_CB(skb)->ns; l2tp_recv_queue_skb() local
383 if (L2TP_SKB_CB(skbp)->ns > ns) { l2tp_recv_queue_skb()
387 session->name, ns, L2TP_SKB_CB(skbp)->ns, l2tp_recv_queue_skb()
456 session->name, L2TP_SKB_CB(skb)->ns, l2tp_recv_dequeue()
472 L2TP_SKB_CB(skb)->ns); l2tp_recv_dequeue()
474 session->nr = L2TP_SKB_CB(skb)->ns; l2tp_recv_dequeue()
476 if (L2TP_SKB_CB(skb)->ns != session->nr) { l2tp_recv_dequeue()
479 session->name, L2TP_SKB_CB(skb)->ns, l2tp_recv_dequeue()
516 if (!l2tp_seq_check_rx_window(session, L2TP_SKB_CB(skb)->ns)) { l2tp_recv_data_seq()
522 session->name, L2TP_SKB_CB(skb)->ns, l2tp_recv_data_seq()
529 * reorder queue, in order of ns. l2tp_recv_data_seq()
540 if (L2TP_SKB_CB(skb)->ns == session->nr) { l2tp_recv_data_seq()
543 u32 nr_oos = L2TP_SKB_CB(skb)->ns; l2tp_recv_data_seq()
562 session->name, L2TP_SKB_CB(skb)->ns, l2tp_recv_data_seq()
643 u32 ns, nr; l2tp_recv_common() local
673 ns = nr = 0; l2tp_recv_common()
677 ns = ntohs(*(__be16 *) ptr); l2tp_recv_common()
683 L2TP_SKB_CB(skb)->ns = ns; l2tp_recv_common()
687 "%s: recv data ns=%u, nr=%u, session nr=%u\n", l2tp_recv_common()
688 session->name, ns, nr, session->nr); l2tp_recv_common()
694 ns = l2h & 0x00ffffff; l2tp_recv_common()
697 L2TP_SKB_CB(skb)->ns = ns; l2tp_recv_common()
701 "%s: recv data ns=%u, session nr=%u\n", l2tp_recv_common()
702 session->name, ns, session->nr); l2tp_recv_common()
996 *bufp++ = htons(session->ns); l2tp_build_l2tpv2_header()
998 session->ns++; l2tp_build_l2tpv2_header()
999 session->ns &= 0xffff; l2tp_build_l2tpv2_header()
1000 l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated ns to %u\n", l2tp_build_l2tpv2_header()
1001 session->name, session->ns); l2tp_build_l2tpv2_header()
1034 l2h = 0x40000000 | session->ns; l2tp_build_l2tpv3_header()
1035 session->ns++; l2tp_build_l2tpv3_header()
1036 session->ns &= 0xffffff; l2tp_build_l2tpv3_header()
1038 "%s: updated ns to %u\n", l2tp_build_l2tpv3_header()
1039 session->name, session->ns); l2tp_build_l2tpv3_header()
1061 l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes, ns=%u\n", l2tp_xmit_core()
1062 session->name, data_len, session->ns - 1); l2tp_xmit_core()
H A Dl2tp_debugfs.c173 seq_printf(m, " nr %hu, ns %hu\n", session->nr, session->ns); l2tp_dfs_seq_session_show()
208 session->nr, session->ns, l2tp_dfs_seq_session_show()
236 seq_puts(m, " nr/ns tx-pkts/bytes/errs rx-pkts/bytes/errs\n"); l2tp_dfs_seq_show()
/linux-4.1.27/drivers/staging/comedi/drivers/
H A Dcomedi_8254.c88 * ns timing.
92 * clock (in ns).
359 * @nanosec: the desired ns time
376 unsigned int ns; comedi_8254_cascade_ns_to_timer() local
398 ns = i8254->osc_base * d1 * d2; comedi_8254_cascade_ns_to_timer()
399 if (ns <= *nanosec && ns > ns_glb) { comedi_8254_cascade_ns_to_timer()
400 ns_glb = ns; comedi_8254_cascade_ns_to_timer()
404 if (ns >= *nanosec && ns < ns_lub) { comedi_8254_cascade_ns_to_timer()
405 ns_lub = ns; comedi_8254_cascade_ns_to_timer()
444 * @nanosec: the desired ns time
620 * @osc_base: base time of the counter in ns
637 * @osc_base: base time of the counter in ns
H A Ddt2814.c103 static int dt2814_ns_to_timer(unsigned int *ns, unsigned int flags) dt2814_ns_to_timer() argument
110 f = 10000; /* ns */ dt2814_ns_to_timer()
112 if ((2 * (*ns)) < (f * 11)) dt2814_ns_to_timer()
117 *ns = f; dt2814_ns_to_timer()
/linux-4.1.27/drivers/net/ethernet/chelsio/cxgb/
H A Dcxgb2.c299 struct net_device_stats *ns = &p->netstats; t1_get_stats() local
306 ns->tx_packets = pstats->TxUnicastFramesOK + t1_get_stats()
309 ns->rx_packets = pstats->RxUnicastFramesOK + t1_get_stats()
312 ns->tx_bytes = pstats->TxOctetsOK; t1_get_stats()
313 ns->rx_bytes = pstats->RxOctetsOK; t1_get_stats()
315 ns->tx_errors = pstats->TxLateCollisions + pstats->TxLengthErrors + t1_get_stats()
317 ns->rx_errors = pstats->RxDataErrors + pstats->RxJabberErrors + t1_get_stats()
322 ns->multicast = pstats->RxMulticastFramesOK; t1_get_stats()
323 ns->collisions = pstats->TxTotalCollisions; t1_get_stats()
326 ns->rx_length_errors = pstats->RxFrameTooLongErrors + t1_get_stats()
328 ns->rx_over_errors = 0; t1_get_stats()
329 ns->rx_crc_errors = pstats->RxFCSErrors; t1_get_stats()
330 ns->rx_frame_errors = pstats->RxAlignErrors; t1_get_stats()
331 ns->rx_fifo_errors = 0; t1_get_stats()
332 ns->rx_missed_errors = 0; t1_get_stats()
335 ns->tx_aborted_errors = pstats->TxFramesAbortedDueToXSCollisions; t1_get_stats()
336 ns->tx_carrier_errors = 0; t1_get_stats()
337 ns->tx_fifo_errors = pstats->TxUnderrun; t1_get_stats()
338 ns->tx_heartbeat_errors = 0; t1_get_stats()
339 ns->tx_window_errors = pstats->TxLateCollisions; t1_get_stats()
340 return ns; t1_get_stats()
/linux-4.1.27/drivers/i2c/busses/
H A Di2c-jz4780.c271 * standard mode, min LOW and HIGH period are 4700 ns and 4000 ns jz4780_i2c_set_speed()
272 * fast mode, min LOW and HIGH period are 1300 ns and 600 ns jz4780_i2c_set_speed()
311 * a i2c device must internally provide a hold time at least 300ns jz4780_i2c_set_speed()
313 * Standard Mode: min=300ns, max=3450ns jz4780_i2c_set_speed()
314 * Fast Mode: min=0ns, max=900ns jz4780_i2c_set_speed()
316 * Standard Mode: min=250ns, max=infinite jz4780_i2c_set_speed()
317 * Fast Mode: min=100(250ns is recommended), max=infinite jz4780_i2c_set_speed()
320 * on FPGA, dev_clk_khz = 12000, so 1i2c_clk = 1000/12 = 83ns jz4780_i2c_set_speed()
321 * on Pisces(1008M), dev_clk_khz=126000, so 1i2c_clk = 1000 / 126 = 8ns jz4780_i2c_set_speed()
H A Di2c-axxia.c124 * ns_to_clk - Convert time (ns) to clock cycles for the given clock frequency.
126 static u32 ns_to_clk(u64 ns, u32 clk_mhz) ns_to_clk() argument
128 return div_u64(ns * clk_mhz, 1000); ns_to_clk()
158 /* Standard mode SCL 50/50, tSU:DAT = 250 ns */ axxia_i2c_init()
163 /* Fast mode SCL 33/66, tSU:DAT = 100 ns */ axxia_i2c_init()
175 /* SDA Hold Time, 300ns */ axxia_i2c_init()
177 /* Filter <50ns spikes */ axxia_i2c_init()
H A Di2c-mxs.c730 * tLOW (SCL LOW period) 4700 ns 1300 ns mxs_i2c_derive_timing()
731 * tHIGH (SCL HIGH period) 4000 ns 600 ns mxs_i2c_derive_timing()
732 * tSU;DAT (data setup time) 250 ns 100 ns mxs_i2c_derive_timing()
733 * tHD;STA (START hold time) 4000 ns 600 ns mxs_i2c_derive_timing()
734 * tBUF (bus free time) 4700 ns 1300 ns mxs_i2c_derive_timing()
/linux-4.1.27/net/netrom/
H A Dnr_in.c155 unsigned short nr, ns; nr_state3_machine() local
159 ns = skb->data[17]; nr_state3_machine()
237 ns = skbn->data[17]; nr_state3_machine()
238 if (ns == nrom->vr) { nr_state3_machine()
245 } else if (nr_in_rx_window(sk, ns)) { nr_state3_machine()
/linux-4.1.27/net/rose/
H A Drose_in.c104 static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype, int ns, int nr, int q, int d, int m) rose_state3_machine() argument
165 if (ns == rose->vr) { rose_state3_machine()
266 int queued = 0, frametype, ns, nr, q, d, m; rose_process_rx_frame() local
271 frametype = rose_decode(skb, &ns, &nr, &q, &d, &m); rose_process_rx_frame()
281 queued = rose_state3_machine(sk, skb, frametype, ns, nr, q, d, m); rose_process_rx_frame()
/linux-4.1.27/drivers/net/
H A Dsb1000.c748 int ioaddr, ns; sb1000_rx() local
773 for (ns = 0; ns < NPIDS; ns++) { sb1000_rx()
774 session_id = lp->rx_session_id[ns]; sb1000_rx()
775 frame_id = lp->rx_frame_id[ns]; sb1000_rx()
796 skb = lp->rx_skb[ns]; sb1000_rx()
807 lp->rx_frame_id[ns] = 0x30 | ((st[1] + 1) & 0x0f); sb1000_rx()
834 lp->rx_dlen[ns] = dlen; sb1000_rx()
850 lp->rx_skb[ns] = skb; sb1000_rx()
863 skb = lp->rx_skb[ns]; sb1000_rx()
866 dlen = lp->rx_dlen[ns]; sb1000_rx()
869 lp->rx_session_id[ns] &= ~0x40; sb1000_rx()
878 lp->rx_skb[ns] = NULL; sb1000_rx()
879 lp->rx_session_id[ns] |= 0x40; sb1000_rx()
893 if (ns < NPIDS) { sb1000_rx()
894 if ((skb = lp->rx_skb[ns])) { sb1000_rx()
896 lp->rx_skb[ns] = NULL; sb1000_rx()
898 lp->rx_session_id[ns] |= 0x40; sb1000_rx()
/linux-4.1.27/drivers/cpuidle/
H A Dcpuidle-powernv.c191 "ibm,cpu-idle-state-latencies-ns", latency_ns, dt_idle_states); powernv_add_idle_states()
193 pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n"); powernv_add_idle_states()
199 "ibm,cpu-idle-state-residency-ns", residency_ns, dt_idle_states); powernv_add_idle_states()
/linux-4.1.27/arch/mips/cavium-octeon/
H A Doct_ilm.c41 seq_printf(m, "cnt: %10lld, avg: %7lld ns, max: %7lld ns, min: %7lld ns\n", show_latency()
/linux-4.1.27/arch/powerpc/kernel/
H A Dsysfs.c93 static unsigned int get_idle_ticks_bit(u64 ns) get_idle_ticks_bit() argument
97 if (ns >= 10000) get_idle_ticks_bit()
98 cycle = div_u64(ns + 500, 1000) * tb_ticks_per_usec; get_idle_ticks_bit()
100 cycle = div_u64(ns * tb_ticks_per_usec, 1000); get_idle_ticks_bit()
176 /* convert ms to ns */ show_pw20_wait_time()
298 /* convert ms to ns */ show_altivec_idle_wait_time()
369 * 1~48(ns): TB[63]
370 * 49~97(ns): TB[62]
371 * 98~195(ns): TB[61]
372 * 196~390(ns): TB[60]
373 * 391~780(ns): TB[59]
374 * 781~1560(ns): TB[58]
/linux-4.1.27/arch/arm/mach-omap2/
H A Dsdram-nokia.c24 /* In picoseconds, except for tREF (ns), tXP, tCKE, tWTR (clks) */
37 u32 tREF; /* in ns */
174 printk(KERN_INFO "SDRC %s: %i ticks %i ns\n", name, ticks, set_sdrc_timing_regval()
/linux-4.1.27/lib/
H A Dkobject_uevent.c103 const void *sock_ns, *ns; kobj_bcast_filter() local
104 ns = kobj->ktype->namespace(kobj); kobj_bcast_filter()
106 return sock_ns != ns; kobj_bcast_filter()
120 const void *init_ns, *ns; kobj_usermode_filter() local
121 ns = kobj->ktype->namespace(kobj); kobj_usermode_filter()
123 return ns != init_ns; kobj_usermode_filter()
/linux-4.1.27/drivers/net/ethernet/intel/i40e/
H A Di40e_ptp.c37 * At 40Gb link or no link, the period is 1.6ns.
38 * At 10Gb link, the period is multiplied by 2. (3.2ns)
39 * At 1Gb link, the period is multiplied by 20. (32ns)
64 u64 ns; i40e_ptp_read() local
70 ns = (((u64)hi) << 32) | lo; i40e_ptp_read()
72 *ts = ns_to_timespec64(ns); i40e_ptp_read()
87 u64 ns = timespec64_to_ns(ts); i40e_ptp_write() local
92 wr32(hw, I40E_PRTTSYN_TIME_L, ns & 0xFFFFFFFF); i40e_ptp_write()
93 wr32(hw, I40E_PRTTSYN_TIME_H, ns >> 32); i40e_ptp_write()
181 * Read the device clock and return the correct value on ns, after converting it
202 * to ns happens in the write function.
311 u64 ns; i40e_ptp_tx_hwtstamp() local
323 ns = (((u64)hi) << 32) | lo; i40e_ptp_tx_hwtstamp()
325 i40e_ptp_convert_to_hwtstamp(&shhwtstamps, ns); i40e_ptp_tx_hwtstamp()
341 * one exists. The RXTIME registers are in ns, so we must convert the result
348 u64 ns; i40e_ptp_rx_hwtstamp() local
366 ns = (((u64)hi) << 32) | lo; i40e_ptp_rx_hwtstamp()
368 i40e_ptp_convert_to_hwtstamp(skb_hwtstamps(skb), ns); i40e_ptp_rx_hwtstamp() local
/linux-4.1.27/drivers/net/ethernet/intel/igb/
H A Digb_ptp.c28 /* The 82580 timesync updates the system timer every 8ns by 8ns,
171 u64 ns; igb_ptp_systim_to_hwtstamp() local
180 ns = timecounter_cyc2time(&adapter->tc, systim); igb_ptp_systim_to_hwtstamp()
185 hwtstamps->hwtstamp = ns_to_ktime(ns); igb_ptp_systim_to_hwtstamp()
190 /* Upper 32 bits contain s, lower 32 bits contain ns. */ igb_ptp_systim_to_hwtstamp()
292 u64 ns; igb_ptp_gettime_82576() local
296 ns = timecounter_read(&igb->tc); igb_ptp_gettime_82576()
300 *ts = ns_to_timespec64(ns); igb_ptp_gettime_82576()
327 u64 ns; igb_ptp_settime_82576() local
329 ns = timespec64_to_ns(ts); igb_ptp_settime_82576()
333 timecounter_init(&igb->tc, &igb->cc, ns); igb_ptp_settime_82576()
470 s64 ns; igb_ptp_feature_enable_i210() local
512 ns = timespec_to_ns(&ts); igb_ptp_feature_enable_i210()
513 ns = ns >> 1; igb_ptp_feature_enable_i210()
514 if (on && ns < 500000LL) { igb_ptp_feature_enable_i210()
518 ts = ns_to_timespec(ns); igb_ptp_feature_enable_i210()
/linux-4.1.27/drivers/net/ethernet/adi/
H A Dbfin_mac.c856 u64 ns; bfin_tx_hwtstamp() local
862 ns = regval << lp->shift; bfin_tx_hwtstamp()
863 shhwtstamps.hwtstamp = ns_to_ktime(ns); bfin_tx_hwtstamp()
873 u64 regval, ns; bfin_rx_hwtstamp() local
887 ns = regval << lp->shift; bfin_rx_hwtstamp()
889 shhwtstamps->hwtstamp = ns_to_ktime(ns); bfin_rx_hwtstamp()
917 u64 ns; bfin_ptp_time_read() local
923 ns = ((u64) hi) << 32; bfin_ptp_time_read()
924 ns |= lo; bfin_ptp_time_read()
925 ns <<= lp->shift; bfin_ptp_time_read()
927 return ns; bfin_ptp_time_read()
930 static void bfin_ptp_time_write(struct bfin_mac_local *lp, u64 ns) bfin_ptp_time_write() argument
934 ns >>= lp->shift; bfin_ptp_time_write()
935 hi = ns >> 32; bfin_ptp_time_write()
936 lo = ns & 0xffffffff; bfin_ptp_time_write()
988 u64 ns; bfin_ptp_gettime() local
995 ns = bfin_ptp_time_read(lp); bfin_ptp_gettime()
999 *ts = ns_to_timespec64(ns); bfin_ptp_gettime()
1007 u64 ns; bfin_ptp_settime() local
1012 ns = timespec64_to_ns(ts); bfin_ptp_settime()
1016 bfin_ptp_time_write(lp, ns); bfin_ptp_settime()
/linux-4.1.27/drivers/net/fddi/skfp/h/
H A Dsba_def.h58 /*#define T_REPORT 0x59682F00L*/ /* 120s/80ns in Hex */
/linux-4.1.27/drivers/devfreq/exynos/
H A Dexynos_ppmu.h66 unsigned long long ns; member in struct:exynos_ppmu
/linux-4.1.27/drivers/block/rsxx/
H A Drsxx_cfg.h51 __u32 latency;/* Max wait time (in ns) */
/linux-4.1.27/include/linux/platform_data/
H A Dpxa_sdhci.h30 * pxa910: each step is 1ns, 4bits width
/linux-4.1.27/arch/avr32/boards/merisc/
H A Dflash.c17 /* Will be translated to units of 14.3 ns, rounded up */
/linux-4.1.27/arch/m68k/coldfire/
H A Ddma_timer.c55 * get a ~213 ns resolution and the 32bit register will overflow almost init_cf_dt_clocksource()
/linux-4.1.27/arch/arm/mach-s3c24xx/
H A Dcpufreq-utils.c39 /* Reduce both the refresh time (in ns) and the frequency (in MHz) s3c2410_cpufreq_setrefresh()
/linux-4.1.27/arch/arm/include/asm/
H A Dvdso_datapage.h46 u64 xtime_clock_snsec; /* CLOCK_REALTIME sub-ns base */
/linux-4.1.27/net/netfilter/
H A Dnf_conntrack_netbios_ns.c50 .name = "netbios-ns",
/linux-4.1.27/drivers/ata/
H A Dpata_at32.c63 * Mode 0 | 3.3 | 600 ns | 0x01
64 * Mode 1 | 5.2 | 383 ns | 0x03
65 * Mode 2 | 8.3 | 240 ns | 0x07
66 * Mode 3 | 11.1 | 180 ns | 0x0f
67 * Mode 4 | 16.7 | 120 ns | 0x1f
/linux-4.1.27/virt/kvm/arm/
H A Darch_timer.c46 static void timer_arm(struct arch_timer_cpu *timer, u64 ns) timer_arm() argument
49 hrtimer_start(&timer->timer, ktime_add_ns(ktime_get(), ns), timer_arm()
166 u64 ns; kvm_timer_sync_hwstate() local
182 ns = cyclecounter_cyc2ns(timecounter->cc, cval - now, timecounter->mask, kvm_timer_sync_hwstate()
184 timer_arm(timer, ns); kvm_timer_sync_hwstate()
/linux-4.1.27/drivers/video/fbdev/riva/
H A Driva_hw.c253 long ns; nv3_iterate() local
273 ns = 1000000 * ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz; nv3_iterate()
274 vfsize = ns * ainfo->vdrain_rate / 1000000; nv3_iterate()
285 ns = 1000000 * (ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz; nv3_iterate()
286 gfsize = (ns * (long) ainfo->gdrain_rate)/1000000; nv3_iterate()
340 ns = 1000000 * (vmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz; nv3_iterate()
341 vlwm = ns * ainfo->vdrain_rate/ 1000000; nv3_iterate()
344 ns = 1000000*(misses*state->mem_page_miss + ainfo->vburst_size)/(state->memory_width/8)/state->mclk_khz; nv3_iterate()
345 ainfo->vocc = ainfo->vocc + ainfo->vburst_size - ns*ainfo->vdrain_rate/1000000; nv3_iterate()
346 ainfo->gocc = ainfo->gocc - ns*ainfo->gdrain_rate/1000000; nv3_iterate()
347 ainfo->mocc = ainfo->mocc - ns*ainfo->mdrain_rate/1000000; nv3_iterate()
356 ns = 1000000*(gmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz ; nv3_iterate()
357 glwm = ns * ainfo->gdrain_rate/1000000; nv3_iterate()
360 ns = 1000000*(misses*state->mem_page_miss + ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz; nv3_iterate()
361 ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000; nv3_iterate()
362 ainfo->gocc = ainfo->gocc + ainfo->gburst_size - ns*ainfo->gdrain_rate/1000000; nv3_iterate()
363 ainfo->mocc = ainfo->mocc + 0 - ns*ainfo->mdrain_rate/1000000; nv3_iterate()
370 ns = 1000000*(misses*state->mem_page_miss + mburst_size/(state->memory_width/8))/state->mclk_khz; nv3_iterate()
371 ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000; nv3_iterate()
372 ainfo->gocc = ainfo->gocc + 0 - ns*ainfo->gdrain_rate/1000000; nv3_iterate()
373 ainfo->mocc = ainfo->mocc + mburst_size - ns*ainfo->mdrain_rate/1000000; nv3_iterate()
381 ns = 1000000*ainfo->gburst_size/(state->memory_width/8)/state->mclk_khz; nv3_iterate()
382 tmp = ns * ainfo->gdrain_rate/1000000; nv3_iterate()
388 ns = 1000000*ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz; nv3_iterate()
389 tmp = ns * ainfo->vdrain_rate/1000000; nv3_iterate()
/linux-4.1.27/arch/x86/kernel/
H A Dtsc.c54 * This means that we can always use an {offset, mul} pair to compute a ns
161 * ns = cycles / (freq / ns_per_sec)
162 * ns = cycles * (ns_per_sec / freq)
163 * ns = cycles * (10^9 / (cpu_khz * 10^3))
164 * ns = cycles * (10^6 / cpu_khz)
167 * ns = cycles * (10^6 * SC / cpu_khz) / SC
168 * ns = cycles * cyc2ns_scale / SC
204 unsigned long long ns; cycles_2_ns() local
218 ns = data->cyc2ns_offset; cycles_2_ns()
219 ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR); cycles_2_ns()
225 ns = data->cyc2ns_offset; cycles_2_ns()
226 ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR); cycles_2_ns()
235 return ns; cycles_2_ns()
296 /* return the value in ns */ native_sched_clock()
/linux-4.1.27/drivers/spi/
H A Dspi-bitbang.c64 unsigned ns, bitbang_txrx_8()
77 word = txrx_word(spi, ns, word, bits); bitbang_txrx_8()
90 unsigned ns, bitbang_txrx_16()
103 word = txrx_word(spi, ns, word, bits); bitbang_txrx_16()
116 unsigned ns, bitbang_txrx_32()
129 word = txrx_word(spi, ns, word, bits); bitbang_txrx_32()
59 bitbang_txrx_8( struct spi_device *spi, u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits), unsigned ns, struct spi_transfer *t ) bitbang_txrx_8() argument
85 bitbang_txrx_16( struct spi_device *spi, u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits), unsigned ns, struct spi_transfer *t ) bitbang_txrx_16() argument
111 bitbang_txrx_32( struct spi_device *spi, u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits), unsigned ns, struct spi_transfer *t ) bitbang_txrx_32() argument
/linux-4.1.27/arch/powerpc/include/asm/
H A Deeh.h427 int ns) eeh_readsb()
429 _insb(addr, buf, ns); eeh_readsb()
430 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8)) eeh_readsb()
435 int ns) eeh_readsw()
437 _insw(addr, buf, ns); eeh_readsw()
438 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16)) eeh_readsw()
426 eeh_readsb(const volatile void __iomem *addr, void * buf, int ns) eeh_readsb() argument
434 eeh_readsw(const volatile void __iomem *addr, void * buf, int ns) eeh_readsw() argument

Completed in 4611 milliseconds

1234