svn commit: r228725 - in head/sys: dev/gpio mips/atheros
Adrian Chadd
adrian at FreeBSD.org
Tue Dec 20 00:33:56 UTC 2011
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);
}
More information about the svn-src-head
mailing list