diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-01-15 10:28:18 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-01-15 10:28:18 +0000 |
commit | 2ff294f1b2d08257fa18966165e6e2d28810136e (patch) | |
tree | bd0dd8984f1733e3db04be89a055047740fed761 /sys/dev | |
parent | 7cb21437ce6acbba8ec9be80f0347045282fe62d (diff) |
In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/amdpm.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/ichiic.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/piixpm.c | 11 |
3 files changed, 24 insertions, 9 deletions
diff --git a/sys/dev/pci/amdpm.c b/sys/dev/pci/amdpm.c index cc351b1c1c5..bec6c05d64b 100644 --- a/sys/dev/pci/amdpm.c +++ b/sys/dev/pci/amdpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amdpm.c,v 1.11 2006/01/09 19:32:14 deraadt Exp $ */ +/* $OpenBSD: amdpm.c,v 1.12 2006/01/15 10:28:17 grange Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -316,8 +316,13 @@ amdpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, DPRINTF(("%s: exec: op %d, addr 0x%x, cmdlen %d, len %d, flags 0x%x\n", sc->sc_dev.dv_xname, op, addr, cmdlen, len, flags)); - /* Check if there's a transfer already running */ - st = bus_space_read_2(sc->sc_iot, sc->sc_ioh, AMDPM_SMBSTAT); + /* Wait for bus to be idle */ + for (retries = 100; retries > 0; retries--) { + st = bus_space_read_2(sc->sc_iot, sc->sc_ioh, AMDPM_SMBSTAT); + if (!(st & AMDPM_SMBSTAT_BSY)) + break; + DELAY(AMDPM_SMBUS_DELAY); + } DPRINTF(("%s: exec: st 0x%b\n", sc->sc_dev.dv_xname, st, AMDPM_SMBSTAT_BITS)); if (st & AMDPM_SMBSTAT_BSY) diff --git a/sys/dev/pci/ichiic.c b/sys/dev/pci/ichiic.c index 4cdc1066008..fc9547e45c6 100644 --- a/sys/dev/pci/ichiic.c +++ b/sys/dev/pci/ichiic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ichiic.c,v 1.11 2006/01/15 10:06:06 grange Exp $ */ +/* $OpenBSD: ichiic.c,v 1.12 2006/01/15 10:28:16 grange Exp $ */ /* * Copyright (c) 2005, 2006 Alexander Yurchenko <grange@openbsd.org> @@ -202,8 +202,13 @@ ichiic_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, DPRINTF(("%s: exec: op %d, addr 0x%x, cmdlen %d, len %d, flags 0x%x\n", sc->sc_dev.dv_xname, op, addr, cmdlen, len, flags)); - /* Check if there's a transfer already running */ - st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ICH_SMB_HS); + /* Wait for bus to be idle */ + for (retries = 100; retries > 0; retries--) { + st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ICH_SMB_HS); + if (!(st & ICH_SMB_HS_BUSY)) + break; + DELAY(ICHIIC_DELAY); + } DPRINTF(("%s: exec: st 0x%b\n", sc->sc_dev.dv_xname, st, ICH_SMB_HS_BITS)); if (st & ICH_SMB_HS_BUSY) diff --git a/sys/dev/pci/piixpm.c b/sys/dev/pci/piixpm.c index 1ead1f0bcf4..446b44d7516 100644 --- a/sys/dev/pci/piixpm.c +++ b/sys/dev/pci/piixpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: piixpm.c,v 1.16 2006/01/15 10:04:39 grange Exp $ */ +/* $OpenBSD: piixpm.c,v 1.17 2006/01/15 10:28:17 grange Exp $ */ /* * Copyright (c) 2005, 2006 Alexander Yurchenko <grange@openbsd.org> @@ -198,8 +198,13 @@ piixpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, DPRINTF(("%s: exec: op %d, addr 0x%x, cmdlen %d, len %d, flags 0x%x\n", sc->sc_dev.dv_xname, op, addr, cmdlen, len, flags)); - /* Check if there's a transfer already running */ - st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS); + /* Wait for bus to be idle */ + for (retries = 100; retries > 0; retries--) { + st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS); + if (!(st & PIIX_SMB_HS_BUSY)) + break; + DELAY(PIIXPM_DELAY); + } DPRINTF(("%s: exec: st 0x%b\n", sc->sc_dev.dv_xname, st, PIIX_SMB_HS_BITS)); if (st & PIIX_SMB_HS_BUSY) |