From owner-svn-src-all@FreeBSD.ORG Tue Dec 20 00:33:56 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90EF4106564A; Tue, 20 Dec 2011 00:33:56 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 759C08FC08; Tue, 20 Dec 2011 00:33:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBK0XuTL082939; Tue, 20 Dec 2011 00:33:56 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBK0XuQj082936; Tue, 20 Dec 2011 00:33:56 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201112200033.pBK0XuQj082936@svn.freebsd.org> From: Adrian Chadd Date: Tue, 20 Dec 2011 00:33:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228725 - in head/sys: dev/gpio mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2011 00:33:56 -0000 Author: adrian Date: Tue Dec 20 00:33:56 2011 New Revision: 228725 URL: http://svn.freebsd.org/changeset/base/228725 Log: Remove these locks - they aren't strictly needed and cause measurable performance issues. * Access to the GPIO bus is already locked by requesting and releasing the bus - thus the lock isn't really needed for each GPIO pin change. * Don't lock and unlock the GPIO bus for -each- i2c access - the i2c bus code is already doing this by calling the upper layer callback to request/release the bus. This thus locks the bus for the entirety of the transaction. TODO: * Further verify that everything is correctly requesting/ releasing the GPIO bus. * Look at how to lock the GPIO pin configuration stuff, potentially by locking/unlocking the bus at the gpiobus layer. Modified: head/sys/dev/gpio/gpioiic.c head/sys/mips/atheros/ar71xx_gpio.c Modified: head/sys/dev/gpio/gpioiic.c ============================================================================== --- head/sys/dev/gpio/gpioiic.c Tue Dec 20 00:16:52 2011 (r228724) +++ head/sys/dev/gpio/gpioiic.c Tue Dec 20 00:33:56 2011 (r228725) @@ -55,7 +55,6 @@ struct gpioiic_softc { device_t sc_dev; device_t sc_busdev; - struct mtx sc_mtx; struct cdev *sc_leddev; int scl_pin; int sda_pin; @@ -148,7 +147,6 @@ gpioiic_setsda(device_t dev, int val) { struct gpioiic_softc *sc = device_get_softc(dev); - GPIOBUS_LOCK_BUS(sc->sc_busdev); if (val == 0) { GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->sda_pin, 0); GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, @@ -157,7 +155,6 @@ gpioiic_setsda(device_t dev, int val) GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, GPIO_PIN_INPUT); } - GPIOBUS_UNLOCK_BUS(sc->sc_busdev); } static void @@ -165,7 +162,6 @@ gpioiic_setscl(device_t dev, int val) { struct gpioiic_softc *sc = device_get_softc(dev); - GPIOBUS_LOCK_BUS(sc->sc_busdev); if (val == 0) { GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->scl_pin, 0); GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, @@ -174,7 +170,6 @@ gpioiic_setscl(device_t dev, int val) GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, GPIO_PIN_INPUT); } - GPIOBUS_UNLOCK_BUS(sc->sc_busdev); } static int @@ -183,11 +178,9 @@ gpioiic_getscl(device_t dev) struct gpioiic_softc *sc = device_get_softc(dev); unsigned int val; - GPIOBUS_LOCK_BUS(sc->sc_busdev); GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, GPIO_PIN_INPUT); GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, sc->scl_pin, &val); - GPIOBUS_UNLOCK_BUS(sc->sc_busdev); return ((int)val); } @@ -198,11 +191,9 @@ gpioiic_getsda(device_t dev) struct gpioiic_softc *sc = device_get_softc(dev); unsigned int val; - GPIOBUS_LOCK_BUS(sc->sc_busdev); GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, GPIO_PIN_INPUT); GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, sc->sda_pin, &val); - GPIOBUS_UNLOCK_BUS(sc->sc_busdev); return ((int)val); } @@ -212,13 +203,11 @@ gpioiic_reset(device_t dev, u_char speed { struct gpioiic_softc *sc = device_get_softc(dev); - GPIOBUS_LOCK_BUS(sc->sc_busdev); GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev); gpioiic_reset_bus(sc->sc_dev); GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev); - GPIOBUS_UNLOCK_BUS(sc->sc_busdev); return (IIC_ENOADDR); } Modified: head/sys/mips/atheros/ar71xx_gpio.c ============================================================================== --- head/sys/mips/atheros/ar71xx_gpio.c Tue Dec 20 00:16:52 2011 (r228724) +++ head/sys/mips/atheros/ar71xx_gpio.c Tue Dec 20 00:33:56 2011 (r228725) @@ -89,17 +89,13 @@ static int ar71xx_gpio_pin_toggle(device static void ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, uint32_t mask) { - GPIO_LOCK(sc); GPIO_SET_BITS(sc, AR71XX_GPIO_FUNCTION, mask); - GPIO_UNLOCK(sc); } static void ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, uint32_t mask) { - GPIO_LOCK(sc); GPIO_CLEAR_BITS(sc, AR71XX_GPIO_FUNCTION, mask); - GPIO_UNLOCK(sc); } static void @@ -109,7 +105,6 @@ ar71xx_gpio_pin_configure(struct ar71xx_ uint32_t mask; mask = 1 << pin->gp_pin; - GPIO_LOCK(sc); /* * Manage input/output @@ -125,8 +120,6 @@ ar71xx_gpio_pin_configure(struct ar71xx_ GPIO_CLEAR_BITS(sc, AR71XX_GPIO_OE, mask); } } - - GPIO_UNLOCK(sc); } static int @@ -253,12 +246,10 @@ ar71xx_gpio_pin_set(device_t dev, uint32 if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); if (value) GPIO_WRITE(sc, AR71XX_GPIO_SET, (1 << pin)); else GPIO_WRITE(sc, AR71XX_GPIO_CLEAR, (1 << pin)); - GPIO_UNLOCK(sc); return (0); } @@ -277,9 +268,7 @@ ar71xx_gpio_pin_get(device_t dev, uint32 if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); *val = (GPIO_READ(sc, AR71XX_GPIO_IN) & (1 << pin)) ? 1 : 0; - GPIO_UNLOCK(sc); return (0); } @@ -298,13 +287,11 @@ ar71xx_gpio_pin_toggle(device_t dev, uin if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); res = (GPIO_READ(sc, AR71XX_GPIO_IN) & (1 << pin)) ? 1 : 0; if (res) GPIO_WRITE(sc, AR71XX_GPIO_CLEAR, (1 << pin)); else GPIO_WRITE(sc, AR71XX_GPIO_SET, (1 << pin)); - GPIO_UNLOCK(sc); return (0); }