From 7a9b6b4f1edd2464ef77f0dfcf75ab393be0e9cd Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Fri, 10 Dec 2004 04:09:46 +0000 Subject: [PATCH] Remove unnecessary weird locking macro I added to blindly replace mtx_*() functions. Original code needed the mutex functions because spl*() functions are practically no-ops on FreeBSD 5.x and later while they aren't on FreeBSD 4.x or DragonFly. Tested on both UP and SMP boxes without a problem. No noticeable difference on performance though. DragonFly_Stable tag will be slipped in a few days if no bug reports are posted to bugs@. --- sys/dev/raid/ips/ips.c | 4 +--- sys/dev/raid/ips/ips.h | 18 +---------------- sys/dev/raid/ips/ips_commands.c | 44 ++++++++--------------------------------- sys/dev/raid/ips/ips_pci.c | 3 +-- 4 files changed, 11 insertions(+), 58 deletions(-) diff --git a/sys/dev/raid/ips/ips.c b/sys/dev/raid/ips/ips.c index 678d42c01c..576f98b35f 100644 --- a/sys/dev/raid/ips/ips.c +++ b/sys/dev/raid/ips/ips.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ips/ips.c,v 1.12 2004/05/30 04:01:29 scottl Exp $ - * $DragonFly: src/sys/dev/raid/ips/ips.c,v 1.9 2004/09/15 15:22:02 joerg Exp $ + * $DragonFly: src/sys/dev/raid/ips/ips.c,v 1.10 2004/12/10 04:09:46 y0netan1 Exp $ */ #include @@ -454,7 +454,6 @@ ips_adapter_init(ips_softc_t *sc) callout_init(&sc->timer); if (sc->ips_adapter_reinit(sc, 0)) goto error; - IPS_LOCK_INIT(sc); /* initialize ffdc values */ microtime(&sc->ffdc_resettime); sc->ffdc_resetcount = 1; @@ -578,7 +577,6 @@ ips_adapter_free(ips_softc_t *sc) mask = splbio(); callout_stop(&sc->timer); splx(mask); - IPS_LOCK_FREE(sc); if (sc->sg_dmatag) bus_dma_tag_destroy(sc->sg_dmatag); if (sc->command_dmatag) diff --git a/sys/dev/raid/ips/ips.h b/sys/dev/raid/ips/ips.h index c5bc3b4bbc..c551291f8b 100644 --- a/sys/dev/raid/ips/ips.h +++ b/sys/dev/raid/ips/ips.h @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ips/ips.h,v 1.10 2004/05/30 20:08:34 phk Exp $ - * $DragonFly: src/sys/dev/raid/ips/ips.h,v 1.4 2004/09/15 15:22:02 joerg Exp $ + * $DragonFly: src/sys/dev/raid/ips/ips.h,v 1.5 2004/12/10 04:09:46 y0netan1 Exp $ */ @@ -216,21 +216,6 @@ struct mtx { intrmask_t spl; }; -#define IPS_LOCK_INIT(sc) (sc)->cmd_mtx.locked = 0 -#define IPS_LOCK(sc) do { \ - int s = splbio(); \ - if ((sc)->cmd_mtx.locked++ == 0) \ - (sc)->cmd_mtx.spl = s; \ - else \ - splx(s); \ -} while (0) -#define IPS_UNLOCK(sc) do { \ - if ((sc)->cmd_mtx.locked) { \ - if (--((sc)->cmd_mtx.locked) == 0) \ - splx((sc)->cmd_mtx.spl); \ - } \ -} while (0) -#define IPS_LOCK_FREE(sc) #define disk_open_t d_open_t #define disk_close_t d_close_t @@ -484,7 +469,6 @@ typedef struct ips_softc { void (*ips_adapter_intr)(void *sc); void (*ips_issue_cmd)(ips_command_t *command); ips_copper_queue_t *copper_queue; - struct mtx cmd_mtx; } ips_softc_t; /* function defines from ips_ioctl.c */ diff --git a/sys/dev/raid/ips/ips_commands.c b/sys/dev/raid/ips/ips_commands.c index 9ba16aaee6..91f1c96e70 100644 --- a/sys/dev/raid/ips/ips_commands.c +++ b/sys/dev/raid/ips/ips_commands.c @@ -25,23 +25,11 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ips/ips_commands.c,v 1.10 2004/05/30 04:01:29 scottl Exp $ - * $DragonFly: src/sys/dev/raid/ips/ips_commands.c,v 1.7 2004/09/06 16:39:47 joerg Exp $ + * $DragonFly: src/sys/dev/raid/ips/ips_commands.c,v 1.8 2004/12/10 04:09:46 y0netan1 Exp $ */ #include -static int -ips_msleep(void *ident, struct ips_softc *sc, int priority, const char *wmesg, - int timo) -{ - int r; - - IPS_UNLOCK(sc); - r = tsleep(ident, priority, wmesg, timo); - IPS_LOCK(sc); - return r; -} - /* * This is an interrupt callback. It is called from * interrupt context when the adapter has completed the @@ -58,9 +46,7 @@ ips_wakeup_callback(ips_command_t *command) status->value = command->status.value; bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap, BUS_DMASYNC_POSTWRITE); - IPS_LOCK(command->sc); wakeup(status); - IPS_UNLOCK(command->sc); } /* @@ -264,14 +250,12 @@ ips_send_adapter_info_cmd(ips_command_t *command) goto exit; } command->callback = ips_wakeup_callback; - IPS_LOCK(sc); bus_dmamap_load(command->data_dmatag, command->data_dmamap, command->data_buffer, IPS_ADAPTER_INFO_LEN, ips_adapter_info_callback, command, BUS_DMA_NOWAIT); if ((status->value == IPS_ERROR_STATUS) || - ips_msleep(status, sc, 0, "ips", 30 * hz) == EWOULDBLOCK) + tsleep(status, 0, "ips", 30 * hz) == EWOULDBLOCK) error = ETIMEDOUT; - IPS_UNLOCK(sc); if (error == 0) { bus_dmamap_sync(command->data_dmatag, command->data_dmamap, BUS_DMASYNC_POSTREAD); @@ -371,14 +355,12 @@ ips_send_drive_info_cmd(ips_command_t *command) goto exit; } command->callback = ips_wakeup_callback; - IPS_LOCK(sc); bus_dmamap_load(command->data_dmatag, command->data_dmamap, command->data_buffer,IPS_DRIVE_INFO_LEN, ips_drive_info_callback, command, BUS_DMA_NOWAIT); if ((status->value == IPS_ERROR_STATUS) || - ips_msleep(status, sc, 0, "ips", 10 * hz) == EWOULDBLOCK) + tsleep(status, 0, "ips", 10 * hz) == EWOULDBLOCK) error = ETIMEDOUT; - IPS_UNLOCK(sc); if (error == 0) { bus_dmamap_sync(command->data_dmatag, command->data_dmamap, @@ -435,11 +417,9 @@ ips_send_flush_cache_cmd(ips_command_t *command) command_struct->id = command->id; bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, BUS_DMASYNC_PREWRITE); - IPS_LOCK(sc); sc->ips_issue_cmd(command); if (status->value != IPS_ERROR_STATUS) - ips_msleep(status, sc, 0, "flush2", 0); - IPS_UNLOCK(sc); + tsleep(status, 0, "flush2", 0); ips_insert_free_cmd(sc, command); return 0; } @@ -529,11 +509,9 @@ ips_send_ffdc_reset_cmd(ips_command_t *command) ips_ffdc_settime(command_struct, sc->ffdc_resettime.tv_sec); bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, BUS_DMASYNC_PREWRITE); - IPS_LOCK(sc); sc->ips_issue_cmd(command); if (status->value != IPS_ERROR_STATUS) - ips_msleep(status, sc, 0, "ffdc", 0); - IPS_UNLOCK(sc); + tsleep(status, 0, "ffdc", 0); ips_insert_free_cmd(sc, command); return 0; } @@ -647,14 +625,12 @@ ips_read_nvram(ips_command_t *command) goto exit; } command->callback = ips_write_nvram; - IPS_LOCK(sc); bus_dmamap_load(command->data_dmatag, command->data_dmamap, command->data_buffer, IPS_NVRAM_PAGE_SIZE, ips_read_nvram_callback, command, BUS_DMA_NOWAIT); if ((status->value == IPS_ERROR_STATUS) || - ips_msleep(status, sc, 0, "ips", 0) == EWOULDBLOCK) + tsleep(status, 0, "ips", 0) == EWOULDBLOCK) error = ETIMEDOUT; - IPS_UNLOCK(sc); if (error == 0) { bus_dmamap_sync(command->data_dmatag, command->data_dmamap, BUS_DMASYNC_POSTWRITE); @@ -704,11 +680,9 @@ ips_send_config_sync_cmd(ips_command_t *command) command_struct->reserve2 = IPS_POCL; bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, BUS_DMASYNC_PREWRITE); - IPS_LOCK(sc); sc->ips_issue_cmd(command); if (status->value != IPS_ERROR_STATUS) - ips_msleep(status, sc, 0, "ipssyn", 0); - IPS_UNLOCK(sc); + tsleep(status, 0, "ipssyn", 0); ips_insert_free_cmd(sc, command); return 0; } @@ -728,11 +702,9 @@ ips_send_error_table_cmd(ips_command_t *command) command_struct->reserve2 = IPS_CSL; bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, BUS_DMASYNC_PREWRITE); - IPS_LOCK(sc); sc->ips_issue_cmd(command); if (status->value != IPS_ERROR_STATUS) - ips_msleep(status, sc, 0, "ipsetc", 0); - IPS_UNLOCK(sc); + tsleep(status, 0, "ipsetc", 0); ips_insert_free_cmd(sc, command); return 0; } diff --git a/sys/dev/raid/ips/ips_pci.c b/sys/dev/raid/ips/ips_pci.c index be51e47426..0b4ba2f385 100644 --- a/sys/dev/raid/ips/ips_pci.c +++ b/sys/dev/raid/ips/ips_pci.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ips/ips_pci.c,v 1.10 2004/03/19 17:36:47 scottl Exp $ - * $DragonFly: src/sys/dev/raid/ips/ips_pci.c,v 1.8 2004/09/26 05:30:24 dillon Exp $ + * $DragonFly: src/sys/dev/raid/ips/ips_pci.c,v 1.9 2004/12/10 04:09:46 y0netan1 Exp $ */ #include @@ -199,7 +199,6 @@ ips_pci_detach(device_t dev) if (ips_adapter_free(sc)) return EBUSY; ips_pci_free(sc); - IPS_LOCK_FREE(sc); } return 0; } -- 2.11.4.GIT