Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Nov 2019 15:47:56 -0700
From:      Ian Lepore <ian@freebsd.org>
To:        Vladimir Kondratyev <wulf@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r354322 - head/sys/dev/ichiic
Message-ID:  <bfd57ca2f5f72fff468aa26da24ea8964c33f0ff.camel@freebsd.org>
In-Reply-To: <201911032117.xA3LHpKK078186@repo.freebsd.org>
References:  <201911032117.xA3LHpKK078186@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2019-11-03 at 21:17 +0000, Vladimir Kondratyev wrote:
> Author: wulf
> Date: Sun Nov  3 21:17:50 2019
> New Revision: 354322
> URL: https://svnweb.freebsd.org/changeset/base/354322
> 
> Log:
>   [ig4] Convert ithread interrupt handler to filter based one.
> 

This doesn't seem like a very good idea.  I2c comms is way too slow to
benefit from handling the interrupt in the primary interrupt context.
All it will accomplish is to make other (perhaps more time-critical)
interrupts wait for service while this handler runs (although,
admittedly, this handler doesn't do much more than a couple register
accesses and a wakeup()).

-- Ian



> Modified:
>   head/sys/dev/ichiic/ig4_iic.c
> 
> Modified: head/sys/dev/ichiic/ig4_iic.c
> =====================================================================
> =========
> --- head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 21:17:01 2019	(r354
> 321)
> +++ head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 21:17:50 2019	(r354
> 322)
> @@ -122,7 +122,7 @@ static const struct ig4_hw ig4iic_hw[] = {
>  };
>  
>  static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset);
> -static void ig4iic_intr(void *cookie);
> +static driver_filter_t ig4iic_intr;
>  static void ig4iic_dump(ig4iic_softc_t *sc);
>  
>  static int ig4_dump;
> @@ -297,12 +297,12 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr)
>  		 * When polling is not requested let the interrupt do
> its work.
>  		 */
>  		if (!DO_POLL(sc)) {
> -			mtx_lock(&sc->io_lock);
> +			mtx_lock_spin(&sc->io_lock);
>  			set_intr_mask(sc, intr | IG4_INTR_ERR_MASK);
> -			mtx_sleep(sc, &sc->io_lock, 0, "i2cwait",
> +			msleep_spin(sc, &sc->io_lock, "i2cwait",
>  				  (hz + 99) / 100); /* sleep up to 10ms
> */
>  			set_intr_mask(sc, 0);
> -			mtx_unlock(&sc->io_lock);
> +			mtx_unlock_spin(&sc->io_lock);
>  			count_us += 10000;
>  		} else {
>  			DELAY(25);
> @@ -1010,7 +1010,7 @@ ig4iic_attach(ig4iic_softc_t *sc)
>  {
>  	int error;
>  
> -	mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF);
> +	mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_SPIN);
>  	sx_init(&sc->call_lock, "IG4 call lock");
>  
>  	ig4iic_get_config(sc);
> @@ -1037,7 +1037,7 @@ ig4iic_attach(ig4iic_softc_t *sc)
>  		goto done;
>  	}
>  	error = bus_setup_intr(sc->dev, sc->intr_res, INTR_TYPE_MISC |
> INTR_MPSAFE,
> -			       NULL, ig4iic_intr, sc, &sc-
> >intr_handle);
> +			       ig4iic_intr, NULL, sc, &sc-
> >intr_handle);
>  	if (error) {
>  		device_printf(sc->dev,
>  			      "Unable to setup irq: error %d\n",
> error);
> @@ -1127,19 +1127,23 @@ int ig4iic_resume(ig4iic_softc_t *sc)
>  /*
>   * Interrupt Operation, see ig4_var.h for locking semantics.
>   */
> -static void
> +static int
>  ig4iic_intr(void *cookie)
>  {
>  	ig4iic_softc_t *sc = cookie;
> +	int retval = FILTER_STRAY;
>  
> -	mtx_lock(&sc->io_lock);
> +	mtx_lock_spin(&sc->io_lock);
>  	/* Ignore stray interrupts */
>  	if (sc->intr_mask != 0 && reg_read(sc, IG4_REG_INTR_STAT) != 0)
> {
>  		/* Interrupt bits are cleared in wait_intr() loop */
>  		set_intr_mask(sc, 0);
>  		wakeup(sc);
> +		retval = FILTER_HANDLED;
>  	}
> -	mtx_unlock(&sc->io_lock);
> +	mtx_unlock_spin(&sc->io_lock);
> +
> +	return (retval);
>  }
>  
>  #define REGDUMP(sc, reg)	\




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