Use msleep() when we sleep waiting for a GPE, since we are holding the

ACPI mutex.

Add some comments to EcWaitEventIntr.

Clean up deviant style, add debugging to be consistent.
This commit is contained in:
Mike Smith 2001-06-29 20:31:37 +00:00
parent cb9b0d80fb
commit a9cf0dff08
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78992

View file

@ -152,7 +152,7 @@
/*
* Hooks for the ACPI CA debugging infrastructure
*/
#define _COMPONENT ACPI_EMBEDDED_CONTROLLER
#define _COMPONENT ACPI_EC
MODULE_NAME("EC")
struct acpi_ec_softc {
@ -424,10 +424,15 @@ EcGpeQueryHandler(void *Context)
return_VOID;
}
static void EcGpeHandler(void *Context)
/*
* Handle a GPE sent to us.
*/
static void
EcGpeHandler(void *Context)
{
struct acpi_ec_softc *sc = Context;
int csrvalue;
/*
* If EC is locked, the intr must process EcRead/Write wait only.
* Query request must be pending.
@ -513,33 +518,47 @@ EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, UIN
return_ACPI_STATUS(Status);
}
/*
* Wait for an event interrupt for a specific condition.
*/
static ACPI_STATUS
EcWaitEventIntr(struct acpi_ec_softc *sc, EC_EVENT Event)
{
EC_STATUS EcStatus;
int i;
FUNCTION_TRACE_U32(__func__, (UINT32)Event);
/* XXX this should test whether interrupts are available some other way */
if(cold)
return EcWaitEvent(sc, Event);
return_ACPI_STATUS(EcWaitEvent(sc, Event));
if (!EcIsLocked(sc))
device_printf(sc->ec_dev, "EcWaitEventIntr called without EC lock!\n");
EcStatus = EC_GET_CSR(sc);
/*Too long?*/
/* XXX waiting too long? */
for(i = 0; i < 10; i++){
/*
* Check EC status against the desired event.
*/
if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) &&
(EcStatus & EC_FLAG_OUTPUT_BUFFER))
return(AE_OK);
return_ACPI_STATUS(AE_OK);
if ((Event == EC_EVENT_INPUT_BUFFER_EMPTY) &&
!(EcStatus & EC_FLAG_INPUT_BUFFER))
return(AE_OK);
return_ACPI_STATUS(AE_OK);
sc->ec_csrvalue = 0;
if(tsleep(&sc->ec_csrvalue, 0,"ECTRANS",1) != EWOULDBLOCK){
if (ACPI_MSLEEP(&sc->ec_csrvalue, &acpi_mutex, PZERO, "EcWait", 1) != EWOULDBLOCK){
EcStatus = sc->ec_csrvalue;
}else{
EcStatus = EC_GET_CSR(sc);
}
}
return AE_ERROR;
return_ACPI_STATUS(AE_ERROR);
}
static ACPI_STATUS
@ -606,7 +625,6 @@ EcQuery(struct acpi_ec_softc *sc, UINT8 *Data)
return(Status);
}
static ACPI_STATUS
EcTransaction(struct acpi_ec_softc *sc, EC_REQUEST *EcRequest)
{