PERFORCE change 120788 for review

Attilio Rao attilio at FreeBSD.org
Mon Jun 18 11:07:30 UTC 2007


Rui Paulo wrote:
> At Fri, 8 Jun 2007 20:00:18 +0200,
> Attilio Rao wrote:
>> 2007/6/8, John Baldwin <jhb at freebsd.org>:
>>> On Wednesday 06 June 2007 09:31:28 am Attilio Rao wrote:
>>>> Rui Paulo wrote:
>>>>> If I'm not doing something wrong, I need to use spin locks on my
>>>>> interrupt handler, or else witness_checkorder will complain with
>>>>> "blockable sleep lock".
>>>>>
>>>>> Note that I'm using FILTERs.
>>>> So you are doing this in the wrong way.
>>>> In order to use correctly filters, please note that the support for them
>>>> is compile time choosen, so you need to wrapper all filter specific
>>>> parts using INTR_FILTER compat macro.
>>> Actually, if you only use a filter and not an ithread handler, you can do that
>>> now w/o needing to have any #ifdef INTR_FILTER stuff.
>> In the case your kernel doesn't use filters (!INTR_FILTER) and you
>> pass a filter, it is automatically mapped to work as a fast handler?
> 
> Ok, I've looked at sio(4) to see how it was setting up a fast intr
> handler. 
> 
> Does the following diff look correct? Thanks.
> 
> ==== //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#13 - /home/rpaulo/p4/rpaulo-macbook/dev/asmc/asmc.c ====
> --- /tmp/tmp.96695.67	2007-06-17 03:44:50.000000000 +0100
> +++ /home/rpaulo/p4/rpaulo-macbook/dev/asmc/asmc.c	2007-06-17 03:44:17.000000000 +0100
> @@ -77,11 +77,8 @@ static int	asmc_fan_getvalue(device_t, c
>  static int	asmc_temp_getvalue(device_t, const char *);
>  static int	asmc_sms_read(device_t, const char *, int16_t *);
>  static void	asmc_sms_calibrate(device_t);
> -#ifdef INTR_FILTER
>  static int	asmc_sms_intr(void *);
> -#else
>  static void	asmc_sms_fastintr(void *);
> -#endif
>  static void	asmc_sms_printintr(device_t, uint8_t);
>  
>  /*
> @@ -236,7 +233,7 @@ static int
>  asmc_attach(device_t dev)
>  {
>  	int i, j;
> -	int error;
> +	int ret;
>  	char name[2];
>  	struct asmc_softc *sc = device_get_softc(dev);
>  	struct asmc_model *model;
> @@ -378,16 +375,21 @@ asmc_attach(device_t dev)
>  		goto out;
>  	}
>  
> -#ifdef INTR_FILTER
> -	error = bus_setup_intr(dev, sc->sc_res, 
> -			       INTR_TYPE_MISC | INTR_MPSAFE,
> -			       asmc_sms_intr, NULL, dev, &sc->sc_cookie);
> -#else
> -	error = bus_setup_intr(dev, sc->sc_res,
> -			       INTR_TYPE_MISC | INTR_MPSAFE | INTR_FAST,
> -			       NULL,  asmc_sms_fastintr, dev, &sc->sc_cookie);
> -#endif
> -	if (error) {
> +	ret = bus_setup_intr(dev, sc->sc_res, 
> +			     INTR_TYPE_MISC | INTR_MPSAFE,
> +			     asmc_sms_intr, NULL, dev, &sc->sc_cookie);
> +
> +	if (ret) {
> +		ret = bus_setup_intr(dev, sc->sc_res,
> +				     INTR_TYPE_MISC | INTR_MPSAFE,
> +				     NULL,  asmc_sms_fastintr, dev,
> +				     &sc->sc_cookie);
> +		if (ret == 0)
> +			device_printf(dev, "unable to setup fast interrupt. "
> +				      "Using normal mode.\n");
> +	}
> +
> +	if (ret) {
>  		device_printf(dev, "unable to setup SMS IRQ\n");
>  		bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid,
>  				     sc->sc_res);

Generally, I don't like much the if (ret == 0) device_printf() since you 
are doing a probe-by-try and so it should not display in this way IMHO.
Maybe having it under some debugging mechanism (e.g. KTR and similar) 
would be acceptable.

My 2 cents.

Attilio



More information about the p4-projects mailing list