mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 06:49:16 +08:00
mmc: Optimize mmc_wait_for_req()
Use a self-contained RTEMS binary semaphore instead of msleep() and wakeup(). This is itself more efficient and in addition allows the use of mmc_wakeup() in interrupt context.
This commit is contained in:
parent
4b1426368b
commit
c7e162abd8
@ -394,6 +394,7 @@ mmc_highest_voltage(uint32_t ocr)
|
||||
static void
|
||||
mmc_wakeup(struct mmc_request *req)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct mmc_softc *sc;
|
||||
|
||||
sc = (struct mmc_softc *)req->done_data;
|
||||
@ -401,12 +402,18 @@ mmc_wakeup(struct mmc_request *req)
|
||||
req->flags |= MMC_REQ_DONE;
|
||||
MMC_UNLOCK(sc);
|
||||
wakeup(req);
|
||||
#else /* __rtems__ */
|
||||
rtems_binary_semaphore_post(&req->req_done);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
static int
|
||||
mmc_wait_for_req(struct mmc_softc *sc, struct mmc_request *req)
|
||||
{
|
||||
|
||||
#ifdef __rtems__
|
||||
rtems_binary_semaphore_init(&req->req_done, "mmc_req_done");
|
||||
#endif /* __rtems__ */
|
||||
req->done = mmc_wakeup;
|
||||
req->done_data = sc;
|
||||
if (mmc_debug > 1) {
|
||||
@ -418,10 +425,15 @@ mmc_wait_for_req(struct mmc_softc *sc, struct mmc_request *req)
|
||||
printf("\n");
|
||||
}
|
||||
MMCBR_REQUEST(device_get_parent(sc->dev), sc->dev, req);
|
||||
#ifndef __rtems__
|
||||
MMC_LOCK(sc);
|
||||
while ((req->flags & MMC_REQ_DONE) == 0)
|
||||
msleep(req, &sc->sc_mtx, 0, "mmcreq", 0);
|
||||
MMC_UNLOCK(sc);
|
||||
#else /* __rtems__ */
|
||||
rtems_binary_semaphore_wait(&req->req_done);
|
||||
rtems_binary_semaphore_destroy(&req->req_done);
|
||||
#endif /* __rtems__ */
|
||||
if (mmc_debug > 2 || (mmc_debug > 0 && req->cmd->error != MMC_ERR_NONE))
|
||||
device_printf(sc->dev, "CMD%d RESULT: %d\n",
|
||||
req->cmd->opcode, req->cmd->error);
|
||||
|
@ -54,6 +54,9 @@
|
||||
|
||||
#ifndef DEV_MMC_MMCREG_H
|
||||
#define DEV_MMC_MMCREG_H
|
||||
#ifdef __rtems__
|
||||
#include <rtems/thread.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* This file contains the register definitions for the mmc and sd buses.
|
||||
@ -173,8 +176,12 @@ struct mmc_request {
|
||||
struct mmc_command *stop;
|
||||
void (*done)(struct mmc_request *); /* Completion function */
|
||||
void *done_data; /* requestor set data */
|
||||
#ifndef __rtems__
|
||||
uint32_t flags;
|
||||
#define MMC_REQ_DONE 1
|
||||
#else /* __rtems__ */
|
||||
rtems_binary_semaphore req_done;
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
|
||||
/* Command definitions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user