Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions sys/dev/ichsmb/ichsmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@
int
ichsmb_callback(device_t dev, int index, void *data)
{
const sc_p sc = device_get_softc(dev);
int smb_error = 0;

DBG("index=%d how=%d\n", index, data ? *(int *)data : -1);
switch (index) {
case SMB_REQUEST_BUS:
if ((bus_read_1(sc->io_res, ICH_HST_STA) & ICH_HST_STA_INUSE_STS) != 0)

Check warning on line 154 in sys/dev/ichsmb/ichsmb.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
return (EBUSY);
break;
case SMB_RELEASE_BUS:
bus_write_1(sc->io_res, ICH_HST_STA, ICH_HST_STA_INUSE_STS);
break;
default:
smb_error = SMB_EABORT; /* XXX */
Expand Down Expand Up @@ -507,10 +511,18 @@
DBG("%d stat=0x%02x\n", count, status);
}
#endif
status &= ~(ICH_HST_STA_INUSE_STS | ICH_HST_STA_HOST_BUSY |
ICH_HST_STA_SMBALERT_STS);
if (status == 0)
status &= ~(ICH_HST_STA_HOST_BUSY | ICH_HST_STA_SMBALERT_STS);
if ((status & ~ICH_HST_STA_INUSE_STS) == 0) {
// We're not the target of the interrupt. In that case,
// reading the status register can acquire the
// semaphore which will lock subsequent accesses to the

Check warning on line 518 in sys/dev/ichsmb/ichsmb.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
// SMBus. For that reason, release the semaphore if
// we've acquired it.
if ((status & ICH_HST_STA_INUSE_STS) == 0)
bus_write_1(sc->io_res, ICH_HST_STA, ICH_HST_STA_INUSE_STS);
break;
}
status &= ~ICH_HST_STA_INUSE_STS;

/* Check for unexpected interrupt */
ok_bits = ICH_HST_STA_SMBALERT_STS;
Expand Down
23 changes: 21 additions & 2 deletions sys/dev/smbus/smbconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
Expand Down Expand Up @@ -118,6 +119,8 @@
struct smbus_softc *sc = device_get_softc(bus);
device_t parent;
int error;
int retries = 0;
int max_retries = 20;

/* first, ask the underlying layers if the request is ok */
parent = device_get_parent(bus);
Expand All @@ -127,8 +130,24 @@
error = SMBUS_CALLBACK(parent, SMB_REQUEST_BUS, &how);
mtx_lock(&sc->lock);

if (error)
error = smbus_poll(sc, how);
/* Check if we've successfully got bus access. */
if (error == 0)
break;
/* Check for timeout.*/
if (retries++ < max_retries)

Check failure on line 137 in sys/dev/smbus/smbconf.c

View workflow job for this annotation

GitHub Actions / Style Checker

spaces required around that '|' (ctx:VxV)

Check warning on line 137 in sys/dev/smbus/smbconf.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
return (EBUSY);

switch (how) {

Check warning on line 140 in sys/dev/smbus/smbconf.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
case SMB_WAIT | SMB_INTR:
error = msleep(sc, &sc->lock, SMBPRI|PCATCH, "smbreq", hz / 100);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if hz < 100?

break;
case SMB_WAIT | SMB_NOINTR:
error = msleep(sc, &sc->lock, SMBPRI, "smbreq", hz / 100);
break;
default:
/* We're in non blocking mode, so exit early. */
return (EWOULDBLOCK);
}
} while (error == EWOULDBLOCK);

while (error == 0) {
Expand Down
Loading