Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jun 2006 17:01:38 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Paolo Pisati <piso@freebsd.org>
Cc:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   Re: PERFORCE change 99318 for review
Message-ID:  <200606151701.39207.jhb@freebsd.org>
In-Reply-To: <200606152051.k5FKpxJu097604@repoman.freebsd.org>
References:  <200606152051.k5FKpxJu097604@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 15 June 2006 16:51, Paolo Pisati wrote:
> http://perforce.freebsd.org/chv.cgi?CH=99318
> 
> Change 99318 by piso@piso_newluxor on 2006/06/15 20:51:44
> 
> 	Make i386 aware of filters, checking the return code:
> 	
> 	-FILTER_STRAY: 			interrupt was not for us,
> 		        		ignore it  
> 	
> 	-FILTER_HANDLED: 		interrupt completely served
> 	
> 	-FILTER_SCHEDULE_THREAD: 	there's more work to do,
> 					stamp this handler and schedule 
> 					the ithread hanlder to run
> 	
> 	Legacy INTR_FAST were all changed to return FILTER_HANDLED 
> 	or FILTER_STRAY, while legacy ithread handlers should work 	
> 	with no problem.

If you move all the code to handle fast interrupts to sys/kern/kern_intr.c
first, then you only have to do this step once rather than N times.

> Affected files ...
> 
> .. //depot/projects/soc2006/intr_filter/i386/i386/intr_machdep.c#2 edit
> .. //depot/projects/soc2006/intr_filter/kern/kern_intr.c#2 edit
> 
> Differences ...
> 
> ==== //depot/projects/soc2006/intr_filter/i386/i386/intr_machdep.c#2 
(text+ko) ====
> 
> @@ -171,7 +171,8 @@
>  	struct thread *td;
>  	struct intr_event *ie;
>  	struct intr_handler *ih;
> -	int error, vector, thread;
> +	int error, vector, thread, ret;
> +	void *arg;
>  
>  	td = curthread;
>  
> @@ -210,27 +211,45 @@
>  		return;
>  	}
>  
> -	/*
> -	 * Execute fast interrupt handlers directly.
> -	 * To support clock handlers, if a handler registers
> -	 * with a NULL argument, then we pass it a pointer to
> -	 * a trapframe as its argument.
> -	 */
>  	td->td_intr_nesting_level++;
> -	thread = 0;
> +	thread = 0; 
>  	critical_enter();
>  	TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
> -		if (!(ih->ih_flags & IH_FAST)) {
> +		/*
> +		 * Execute fast interrupt handlers directly.
> +		 * To support clock handlers, if a handler registers
> +		 * with a NULL argument, then we pass it a pointer to
> +		 * a trapframe as its argument.
> +		 */
> +		arg = ((ih->ih_argument == NULL) ? frame : ih->ih_argument);
> +		
> +		CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
> +		     ih->ih_handler, arg, ih->ih_name);
> +
> +		if (ih->ih_flags & IH_FAST) {
> +			// XXX - actually should call ih_filter()...
> +			ret = ((driver_filter_t *)ih->ih_handler)(arg);
> +		} else { 		
> +			/* old ithread handler */
>  			thread = 1;
>  			continue;
>  		}
> -		CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
> -		    ih->ih_handler, ih->ih_argument == NULL ? frame :
> -		    ih->ih_argument, ih->ih_name);
> -		if (ih->ih_argument == NULL)
> -			ih->ih_handler(frame);
> -		else
> -			ih->ih_handler(ih->ih_argument);
> +
> +		/* try with the next handler... */
> +		if (ret == FILTER_STRAY) 
> +			continue;
> +
> +		/* interrupt served, get out of here... */
> +		if (ret == FILTER_HANDLED) {
> +			thread = 0;
> +			break;
> +		}
> +
> +		/* mark handler for later execution */
> +		if (ret == FILTER_SCHEDULE_THREAD) {
> +			ih->ih_need = 1; 
> +			thread = 1;
> +		}
>  	}
>  
>  	/*
> 
> ==== //depot/projects/soc2006/intr_filter/kern/kern_intr.c#2 (text+ko) ====
> 
> @@ -636,6 +636,8 @@
>  			continue;
>  		}
>  
> +		// XXX - with filters, we will execute only 
> +		// handlers marked in ih_need too...
>  		/*
>  		 * For software interrupt threads, we only execute
>  		 * handlers that have their need flag set.  Hardware
> 

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606151701.39207.jhb>