From owner-p4-projects@FreeBSD.ORG Mon Oct 2 21:04:45 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DF45E16A559; Mon, 2 Oct 2006 21:04:44 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A580416A557 for ; Mon, 2 Oct 2006 21:04:44 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BAAD43D53 for ; Mon, 2 Oct 2006 21:04:44 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k92L4iBA098337 for ; Mon, 2 Oct 2006 21:04:44 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k92L4hTe098333 for perforce@freebsd.org; Mon, 2 Oct 2006 21:04:43 GMT (envelope-from imp@freebsd.org) Date: Mon, 2 Oct 2006 21:04:43 GMT Message-Id: <200610022104.k92L4hTe098333@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 107123 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Oct 2006 21:04:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=107123 Change 107123 by imp@imp_lighthouse on 2006/10/02 21:04:16 implement ivars and passing requests fix locking on done, I think... Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#13 edit .. //depot/projects/arm/src/sys/dev/mmc/mmcbus_if.m#5 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#13 (text+ko) ==== @@ -37,6 +37,7 @@ #include #include +#include #include "mmcbr_if.h" #include "mmcbus_if.h" @@ -102,6 +103,7 @@ /* We'll probe and attach our children later, but before / mount */ sc->config_intrhook.ich_func = mmc_delayed_attach; sc->config_intrhook.ich_arg = sc; + printf("arg is %p\n", sc); if (config_intrhook_establish(&sc->config_intrhook) != 0) device_printf(dev, "config_intrhook_establish failed\n"); return (0); @@ -156,7 +158,14 @@ static void mmc_wakeup(struct mmc_request *req) { + struct mmc_softc *sc; + + printf("Wakeup for req %p done_data %p\n", req, req->done_data); + sc = (struct mmc_softc *)req->done_data; + MMC_LOCK(sc); + req->flags |= MMC_REQ_DONE; wakeup(req); + MMC_UNLOCK(sc); } static int @@ -165,17 +174,30 @@ int err; req->done = mmc_wakeup; + req->done_data = sc; + printf("Submitting request %p sc %p\n", req, sc); MMCBR_REQUEST(device_get_parent(sc->dev), sc->dev, req); MMC_LOCK(sc); do { err = msleep(req, &sc->sc_mtx, PZERO | PCATCH, "mmcreq", hz / 10); - } while (!(req->flags & MMC_REQ_DONE) && err == 0); + printf("err is %d flags %x\n", err, req->flags); + } while (!(req->flags & MMC_REQ_DONE) && err == EAGAIN); + printf("Request %p done with error %d\n", req, err); MMC_UNLOCK(sc); return (err); } static int +mmc_wait_for_request(device_t brdev, device_t reqdev, struct mmc_request *req) +{ + struct mmc_softc *sc = device_get_softc(brdev); + + printf("passing along request %p\n", req); + return mmc_wait_for_req(sc, req); +} + +static int mmc_wait_for_cmd(struct mmc_softc *sc, struct mmc_command *cmd, int retries) { struct mmc_request mreq; @@ -555,6 +577,42 @@ // XXX probe/attach/detach children? } +static int +mmc_read_ivar(device_t bus, device_t child, int which, u_char *result) +{ +// struct at91_mci_softc *sc = device_get_softc(bus); + struct mmc_ivars *ivar = device_get_ivars(child); + + switch (which) { + default: + return (EINVAL); + case MMC_IVAR_MEDIA_SIZE: + *(int *)result = ivar->csd.capacity; + break; + case MMC_IVAR_MODE: + *(int *)result = ivar->mode; + break; + case MMC_IVAR_SECTOR_SIZE: + *(int *)result = 512; + break; + } + return (0); +} + +static int +mmc_write_ivar(device_t bus, device_t child, int which, uintptr_t value) +{ +// struct at91_mci_softc *sc = device_get_softc(bus); +// struct mmc_ivars *ivar = device_get_ivars(child); + + switch (which) { + default: + return (EINVAL); + } + return (0); +} + + static void mmc_delayed_attach(void *xsc) { @@ -566,9 +624,18 @@ } static device_method_t mmc_methods[] = { + /* device_if */ DEVMETHOD(device_probe, mmc_probe), DEVMETHOD(device_attach, mmc_attach), DEVMETHOD(device_detach, mmc_detach), + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, mmc_read_ivar), + DEVMETHOD(bus_write_ivar, mmc_write_ivar), + + /* MMC Bus interface */ + DEVMETHOD(mmcbus_wait_for_request, mmc_wait_for_request), + {0, 0}, }; ==== //depot/projects/arm/src/sys/dev/mmc/mmcbus_if.m#5 (text+ko) ==== @@ -43,7 +43,6 @@ device_t brdev; device_t reqdev; struct mmc_request *req; - int *status; }; #