@@ -142,12 +142,14 @@ int wolfkmod_vecreg_save(int flags_unused)
142142 if (is_fpu_kern_thread (0 )) {
143143 /* kernel fpu threads are special, do nothing. They own a
144144 * persistent, dedicated fpu context. */
145+ #if defined(WOLFSSL_BSDKM_FPU_DEBUG )
145146 printf ("info: wolfkmod_vecreg_save: is fpu kern thread\n" );
147+ #endif
146148 return (0 );
147149 }
148150
149151 if (curthread -> td_pcb -> pcb_flags & PCB_KERNFPU ) {
150- /* fpu context already active. check td_tid and
152+ /* kern fpu is active for this thread . check td_tid and
151153 * increment nesting level. */
152154 lwpid_t td_tid = wolfkmod_fpu_get_tid ();
153155 if (td_tid != curthread -> td_tid ) {
@@ -158,7 +160,7 @@ int wolfkmod_vecreg_save(int flags_unused)
158160 fpu_states [PCPU_GET (cpuid )].nest ++ ;
159161 }
160162 else {
161- /* fpu context not active, call fpu_kern_enter().
163+ /* kern fpu not active for this thread , call fpu_kern_enter().
162164 * after calling fpu_kern_enter():
163165 * - kernel fpu is enabled
164166 * - migration is disabled
@@ -190,14 +192,18 @@ void wolfkmod_vecreg_restore(void)
190192 if (is_fpu_kern_thread (0 )) {
191193 /* kernel fpu threads are special, do nothing. They own a
192194 * persistent, dedicated fpu context. */
195+ #if defined(WOLFSSL_BSDKM_FPU_DEBUG )
193196 printf ("info: wolfkmod_vecreg_restore: is fpu kern thread\n" );
197+ #endif
194198 return ;
195199 }
196200
197201 if (curthread -> td_pcb -> pcb_flags & PCB_KERNFPU ) {
198- if (fpu_states [PCPU_GET (cpuid )].td_tid != curthread -> td_tid ) {
199- printf ("error: wolfkmod_vecreg_restore: got tid = %d, expected %d\n" ,
200- fpu_states [PCPU_GET (cpuid )].td_tid , curthread -> td_tid );
202+ /* kern fpu is active for this thread. check tid and nesting level. */
203+ lwpid_t td_tid = wolfkmod_fpu_get_tid ();
204+ if (td_tid != curthread -> td_tid ) {
205+ printf ("error: wolfkmod_vecreg_restore: got tid = %d, "
206+ "expected %d\n" , td_tid , curthread -> td_tid );
201207 return ;
202208 }
203209
@@ -206,7 +212,7 @@ void wolfkmod_vecreg_restore(void)
206212 fpu_states [PCPU_GET (cpuid )].nest -- ;
207213 }
208214
209- /* if last level, zero the thread id and call fpu_kern_leave */
215+ /* if last level, zero the thread id then call fpu_kern_leave */
210216 if (fpu_states [PCPU_GET (cpuid )].nest == 0 ) {
211217 fpu_states [PCPU_GET (cpuid )].td_tid = 0 ;
212218 wolfkmod_fpu_kern_leave ();
0 commit comments