Module Name: src Committed By: jdolecek Date: Mon Sep 17 18:36:14 UTC 2018
Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c ata_subr.c ata_wdc.c atavar.h src/sys/dev/ic [jdolecek-ncqfixes]: ahcisata_core.c mvsata.c siisata.c wdc.c src/sys/dev/scsipi [jdolecek-ncqfixes]: atapi_wdc.c Log Message: move low-level protocol handlers hooks from ata_xfer to separate struct, initialized statically primarily to reduce ata_xfer struct size, but also improves readibility, and enforces consistency To generate a diff of this commit: cvs rdiff -u -r1.141.6.2 -r1.141.6.3 src/sys/dev/ata/ata.c cvs rdiff -u -r1.6.2.1 -r1.6.2.2 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.110.4.1 -r1.110.4.2 src/sys/dev/ata/ata_wdc.c cvs rdiff -u -r1.99.2.1 -r1.99.2.2 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.62.2.2 -r1.62.2.3 src/sys/dev/ic/ahcisata_core.c cvs rdiff -u -r1.41.2.1 -r1.41.2.2 src/sys/dev/ic/mvsata.c cvs rdiff -u -r1.35.6.2 -r1.35.6.3 src/sys/dev/ic/siisata.c cvs rdiff -u -r1.288.6.1 -r1.288.6.2 src/sys/dev/ic/wdc.c cvs rdiff -u -r1.129.6.1 -r1.129.6.2 src/sys/dev/scsipi/atapi_wdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.2 src/sys/dev/ata/ata.c:1.141.6.3 --- src/sys/dev/ata/ata.c:1.141.6.2 Sat Sep 1 09:48:32 2018 +++ src/sys/dev/ata/ata.c Mon Sep 17 18:36:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.2 2018/09/01 09:48:32 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.3 2018/09/17 18:36:13 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.2 2018/09/01 09:48:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.3 2018/09/17 18:36:13 jdolecek Exp $"); #include "opt_ata.h" @@ -1238,7 +1238,7 @@ ata_xfer_start(struct ata_xfer *xfer) KASSERT(mutex_owned(&chp->ch_lock)); - rv = xfer->c_start(chp, xfer); + rv = xfer->ops->c_start(chp, xfer); switch (rv) { case ATASTART_STARTED: /* nothing to do */ @@ -1250,14 +1250,14 @@ ata_xfer_start(struct ata_xfer *xfer) case ATASTART_POLL: /* can happen even in thread context for some ATAPI devices */ ata_channel_unlock(chp); - KASSERT(xfer->c_poll != NULL); - xfer->c_poll(chp, xfer); + KASSERT(xfer->ops != NULL && xfer->ops->c_poll != NULL); + xfer->ops->c_poll(chp, xfer); ata_channel_lock(chp); break; case ATASTART_ABORT: ata_channel_unlock(chp); - KASSERT(xfer->c_abort != NULL); - xfer->c_abort(chp, xfer); + KASSERT(xfer->ops != NULL && xfer->ops->c_abort != NULL); + xfer->ops->c_abort(chp, xfer); ata_channel_lock(chp); break; } @@ -1337,7 +1337,7 @@ ata_waitdrain_xfer_check(struct ata_chan if (chp->ch_drive[drive].drive_flags & ATA_DRIVE_WAITDRAIN) { ata_channel_unlock(chp); - (*xfer->c_kill_xfer)(chp, xfer, KILL_GONE); + xfer->ops->c_kill_xfer(chp, xfer, KILL_GONE); ata_channel_lock(chp); chp->ch_drive[drive].drive_flags &= ~ATA_DRIVE_WAITDRAIN; @@ -1404,7 +1404,7 @@ ata_kill_active(struct ata_channel *chp, KASSERT(mutex_owned(&chp->ch_lock)); TAILQ_FOREACH_SAFE(xfer, &chq->active_xfers, c_activechain, xfernext) { - (*xfer->c_kill_xfer)(xfer->c_chp, xfer, reason); + xfer->ops->c_kill_xfer(xfer->c_chp, xfer, reason); } if (flags & AT_RST_EMERG) @@ -1438,7 +1438,7 @@ ata_kill_pending(struct ata_drive_datas * data corruption, if the hook tries to call back into * middle layer for inactive xfer. */ - (*xfer->c_kill_xfer)(chp, xfer, KILL_GONE_INACTIVE); + xfer->ops->c_kill_xfer(chp, xfer, KILL_GONE_INACTIVE); } /* Wait until all active transfers on the drive finish */ Index: src/sys/dev/ata/ata_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.6.2.1 src/sys/dev/ata/ata_subr.c:1.6.2.2 --- src/sys/dev/ata/ata_subr.c:1.6.2.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ata/ata_subr.c Mon Sep 17 18:36:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.6.2.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.6.2.2 2018/09/17 18:36:13 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.2 2018/09/17 18:36:13 jdolecek Exp $"); #include "opt_ata.h" @@ -326,6 +326,7 @@ ata_free_xfer(struct ata_channel *chp, s goto out; } + /* XXX move PIOBM and free_gw to deactivate? */ #if NATA_PIOBM /* XXX wdc dependent code */ if (xfer->c_flags & C_PIOBM) { struct wdc_softc *wdc = CHAN_TO_WDC(chp); @@ -386,7 +387,7 @@ ata_timeout(void *v) /* Mark as timed out. Do not print anything, wd(4) will. */ xfer->c_flags |= C_TIMEOU; - xfer->c_intr(xfer->c_chp, xfer, 0); + xfer->ops->c_intr(xfer->c_chp, xfer, 0); } splx(s); Index: src/sys/dev/ata/ata_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.110.4.1 src/sys/dev/ata/ata_wdc.c:1.110.4.2 --- src/sys/dev/ata/ata_wdc.c:1.110.4.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ata/ata_wdc.c Mon Sep 17 18:36:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.110.4.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.110.4.2 2018/09/17 18:36:13 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.110.4.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.110.4.2 2018/09/17 18:36:13 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -131,6 +131,14 @@ const struct ata_bustype wdc_ata_bustype ata_kill_pending, }; +static const struct ata_xfer_ops wdc_bio_xfer_ops = { + .c_start = wdc_ata_bio_start, + .c_poll = wdc_ata_bio_poll, + .c_abort = wdc_ata_bio_done, + .c_intr = wdc_ata_bio_intr, + .c_kill_xfer = wdc_ata_bio_kill_xfer +}; + /* * Handle block I/O operation. Return ATACMD_COMPLETE, ATACMD_QUEUED, or * ATACMD_TRY_AGAIN. Must be called at splbio(). @@ -161,11 +169,7 @@ wdc_ata_bio(struct ata_drive_datas *drvp xfer->c_drive = drvp->drive; xfer->c_databuf = ata_bio->databuf; xfer->c_bcount = ata_bio->bcount; - xfer->c_start = wdc_ata_bio_start; - xfer->c_poll = wdc_ata_bio_poll; - xfer->c_abort = wdc_ata_bio_done; - xfer->c_intr = wdc_ata_bio_intr; - xfer->c_kill_xfer = wdc_ata_bio_kill_xfer; + xfer->ops = &wdc_bio_xfer_ops; ata_exec_xfer(chp, xfer); return (ata_bio->flags & ATA_ITSDONE) ? ATACMD_COMPLETE : ATACMD_QUEUED; } Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.99.2.1 src/sys/dev/ata/atavar.h:1.99.2.2 --- src/sys/dev/ata/atavar.h:1.99.2.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ata/atavar.h Mon Sep 17 18:36:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.99.2.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99.2.2 2018/09/17 18:36:13 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -125,6 +125,7 @@ struct ata_command { /* Forward declaration for ata_xfer */ struct scsipi_xfer; +struct ata_xfer_ops; /* * Description of a command to be handled by an ATA controller. These @@ -166,6 +167,10 @@ struct ata_xfer { SLIST_ENTRY(ata_xfer) c_retrychain; /* Low-level protocol handlers. */ + const struct ata_xfer_ops *ops; +}; + +struct ata_xfer_ops { int (*c_start)(struct ata_channel *, struct ata_xfer *); #define ATASTART_STARTED 0 /* xfer started, waiting for intr */ #define ATASTART_TH 1 /* xfer needs to be run in thread */ Index: src/sys/dev/ic/ahcisata_core.c diff -u src/sys/dev/ic/ahcisata_core.c:1.62.2.2 src/sys/dev/ic/ahcisata_core.c:1.62.2.3 --- src/sys/dev/ic/ahcisata_core.c:1.62.2.2 Sat Sep 1 10:13:41 2018 +++ src/sys/dev/ic/ahcisata_core.c Mon Sep 17 18:36:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.62.2.2 2018/09/01 10:13:41 jdolecek Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.62.2.3 2018/09/17 18:36:13 jdolecek Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62.2.2 2018/09/01 10:13:41 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62.2.3 2018/09/17 18:36:13 jdolecek Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -647,7 +647,7 @@ ahci_intr_port(struct ahci_softc *sc, st if ((achp->ahcic_cmds_active & __BIT(slot)) != 0 && (sact & __BIT(slot)) == 0) { xfer = ata_queue_hwslot_to_xfer(chp, slot); - xfer->c_intr(chp, xfer, tfd); + xfer->ops->c_intr(chp, xfer, tfd); } } else { /* @@ -665,7 +665,7 @@ ahci_intr_port(struct ahci_softc *sc, st if ((aslots & __BIT(slot)) != 0 && (sact & __BIT(slot)) == 0) { xfer = ata_queue_hwslot_to_xfer(chp, slot); - xfer->c_intr(chp, xfer, tfd); + xfer->ops->c_intr(chp, xfer, tfd); } } } @@ -1003,6 +1003,14 @@ ahci_setup_channel(struct ata_channel *c return; } +static const struct ata_xfer_ops ahci_cmd_xfer_ops = { + .c_start = ahci_cmd_start, + .c_poll = ahci_cmd_poll, + .c_abort = ahci_cmd_abort, + .c_intr = ahci_cmd_complete, + .c_kill_xfer = ahci_cmd_kill_xfer, +}; + static int ahci_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1022,11 +1030,7 @@ ahci_exec_command(struct ata_drive_datas xfer->c_drive = drvp->drive; xfer->c_databuf = ata_c->data; xfer->c_bcount = ata_c->bcount; - xfer->c_start = ahci_cmd_start; - xfer->c_poll = ahci_cmd_poll; - xfer->c_abort = ahci_cmd_abort; - xfer->c_intr = ahci_cmd_complete; - xfer->c_kill_xfer = ahci_cmd_kill_xfer; + xfer->ops = &ahci_cmd_xfer_ops; s = splbio(); ata_exec_xfer(chp, xfer); #ifdef DIAGNOSTIC @@ -1142,7 +1146,7 @@ ahci_cmd_poll(struct ata_channel *chp, s if ((xfer->c_ata_c.flags & AT_DONE) == 0) { xfer->c_ata_c.flags |= AT_TIMEOU; - xfer->c_intr(chp, xfer, 0); + xfer->ops->c_intr(chp, xfer, 0); } /* reenable interrupts */ AHCI_WRITE(sc, AHCI_GHC, AHCI_READ(sc, AHCI_GHC) | AHCI_GHC_IE); @@ -1279,6 +1283,14 @@ ahci_cmd_done_end(struct ata_channel *ch ata_c->flags |= AT_DONE; } +static const struct ata_xfer_ops ahci_bio_xfer_ops = { + .c_start = ahci_bio_start, + .c_poll = ahci_bio_poll, + .c_abort = ahci_bio_abort, + .c_intr = ahci_bio_complete, + .c_kill_xfer = ahci_bio_kill_xfer, +}; + static int ahci_ata_bio(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1294,11 +1306,7 @@ ahci_ata_bio(struct ata_drive_datas *drv xfer->c_drive = drvp->drive; xfer->c_databuf = ata_bio->databuf; xfer->c_bcount = ata_bio->bcount; - xfer->c_start = ahci_bio_start; - xfer->c_poll = ahci_bio_poll; - xfer->c_abort = ahci_bio_abort; - xfer->c_intr = ahci_bio_complete; - xfer->c_kill_xfer = ahci_bio_kill_xfer; + xfer->ops = &ahci_bio_xfer_ops; ata_exec_xfer(chp, xfer); return (ata_bio->flags & ATA_ITSDONE) ? ATACMD_COMPLETE : ATACMD_QUEUED; } @@ -1386,7 +1394,7 @@ ahci_bio_poll(struct ata_channel *chp, s DEBUG_XFERS); if ((xfer->c_bio.flags & ATA_ITSDONE) == 0) { xfer->c_bio.error = TIMEOUT; - xfer->c_intr(chp, xfer, 0); + xfer->ops->c_intr(chp, xfer, 0); } /* reenable interrupts */ AHCI_WRITE(sc, AHCI_GHC, AHCI_READ(sc, AHCI_GHC) | AHCI_GHC_IE); @@ -1671,7 +1679,7 @@ ahci_channel_recover(struct ahci_softc * if ((achp->ahcic_cmds_active & (1U << eslot)) != 0) { xfer = ata_queue_hwslot_to_xfer(chp, eslot); xfer->c_flags |= C_RECOVERED; - xfer->c_intr(chp, xfer, + xfer->ops->c_intr(chp, xfer, (err << AHCI_P_TFD_ERR_SHIFT) | st); } break; @@ -1684,7 +1692,7 @@ ahci_channel_recover(struct ahci_softc * for (slot = 0; slot < sc->sc_ncmds; slot++) { if ((achp->ahcic_cmds_active & (1U << slot)) != 0) { xfer = ata_queue_hwslot_to_xfer(chp, slot); - xfer->c_intr(chp, xfer, tfd); + xfer->ops->c_intr(chp, xfer, tfd); } } break; @@ -1718,7 +1726,7 @@ reset: if (drive != xfer->c_drive) continue; - xfer->c_kill_xfer(chp, xfer, + xfer->ops->c_kill_xfer(chp, xfer, (error == 0) ? KILL_REQUEUE : KILL_RESET); } @@ -1827,6 +1835,14 @@ ahci_atapi_kill_pending(struct scsipi_pe ata_kill_pending(&chp->ch_drive[periph->periph_target]); } +static const struct ata_xfer_ops ahci_atapi_xfer_ops = { + .c_start = ahci_atapi_start, + .c_poll = ahci_atapi_poll, + .c_abort = ahci_atapi_abort, + .c_intr = ahci_atapi_complete, + .c_kill_xfer = ahci_atapi_kill_xfer, +}; + static void ahci_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) @@ -1864,11 +1880,7 @@ ahci_atapi_scsipi_request(struct scsipi_ xfer->c_scsipi = sc_xfer; xfer->c_databuf = sc_xfer->data; xfer->c_bcount = sc_xfer->datalen; - xfer->c_start = ahci_atapi_start; - xfer->c_poll = ahci_atapi_poll; - xfer->c_abort = ahci_atapi_abort; - xfer->c_intr = ahci_atapi_complete; - xfer->c_kill_xfer = ahci_atapi_kill_xfer; + xfer->ops = &ahci_atapi_xfer_ops; xfer->c_dscpoll = 0; s = splbio(); ata_exec_xfer(atac->atac_channels[channel], xfer); @@ -1972,7 +1984,7 @@ ahci_atapi_poll(struct ata_channel *chp, DEBUG_XFERS); if ((xfer->c_scsipi->xs_status & XS_STS_DONE) == 0) { xfer->c_scsipi->error = XS_TIMEOUT; - xfer->c_intr(chp, xfer, 0); + xfer->ops->c_intr(chp, xfer, 0); } /* reenable interrupts */ AHCI_WRITE(sc, AHCI_GHC, AHCI_READ(sc, AHCI_GHC) | AHCI_GHC_IE); Index: src/sys/dev/ic/mvsata.c diff -u src/sys/dev/ic/mvsata.c:1.41.2.1 src/sys/dev/ic/mvsata.c:1.41.2.2 --- src/sys/dev/ic/mvsata.c:1.41.2.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ic/mvsata.c Mon Sep 17 18:36:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mvsata.c,v 1.41.2.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: mvsata.c,v 1.41.2.2 2018/09/17 18:36:14 jdolecek Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.41.2.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.41.2.2 2018/09/17 18:36:14 jdolecek Exp $"); #include "opt_mvsata.h" @@ -457,7 +457,7 @@ mvsata_nondma_handle(struct mvsata_port return 0; } - ret = xfer->c_intr(chp, xfer, 1); + ret = xfer->ops->c_intr(chp, xfer, 1); return (ret); } @@ -609,7 +609,7 @@ mvsata_channel_recover(struct mvsata_por xfer->c_flags |= C_RECOVERED; xfer->c_bio.error = ERROR; xfer->c_bio.r_error = err; - xfer->c_intr(chp, xfer, 1); + xfer->ops->c_intr(chp, xfer, 1); } break; @@ -624,7 +624,7 @@ mvsata_channel_recover(struct mvsata_por if (xfer->c_drive != drive) continue; - xfer->c_intr(chp, xfer, 1); + xfer->ops->c_intr(chp, xfer, 1); } } break; @@ -657,7 +657,7 @@ mvsata_channel_recover(struct mvsata_por if (xfer->c_drive != drive) continue; - xfer->c_kill_xfer(chp, xfer, + xfer->ops->c_kill_xfer(chp, xfer, (error == 0) ? KILL_REQUEUE : KILL_RESET); } @@ -1081,6 +1081,14 @@ no_edma: } #ifndef MVSATA_WITHOUTDMA +static const struct ata_xfer_ops mvsata_bio_xfer_ops = { + .c_start = mvsata_bio_start, + .c_intr = mvsata_bio_intr, + .c_poll = mvsata_bio_poll, + .c_abort = mvsata_bio_done, + .c_kill_xfer = mvsata_bio_kill_xfer, +}; + static int mvsata_bio(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1103,11 +1111,7 @@ mvsata_bio(struct ata_drive_datas *drvp, xfer->c_drive = drvp->drive; xfer->c_databuf = ata_bio->databuf; xfer->c_bcount = ata_bio->bcount; - xfer->c_start = mvsata_bio_start; - xfer->c_intr = mvsata_bio_intr; - xfer->c_poll = mvsata_bio_poll; - xfer->c_abort = mvsata_bio_done; - xfer->c_kill_xfer = mvsata_bio_kill_xfer; + xfer->ops = &mvsata_bio_xfer_ops; ata_exec_xfer(chp, xfer); return (ata_bio->flags & ATA_ITSDONE) ? ATACMD_COMPLETE : ATACMD_QUEUED; } @@ -1676,6 +1680,14 @@ ctrldone: return -1; } +static const struct ata_xfer_ops mvsata_wdc_cmd_xfer_ops = { + .c_start = mvsata_wdc_cmd_start, + .c_intr = mvsata_wdc_cmd_intr, + .c_poll = mvsata_wdc_cmd_poll, + .c_abort = mvsata_wdc_cmd_done, + .c_kill_xfer = mvsata_wdc_cmd_kill_xfer, +}; + static int mvsata_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1699,11 +1711,7 @@ mvsata_exec_command(struct ata_drive_dat xfer->c_drive = drvp->drive; xfer->c_databuf = ata_c->data; xfer->c_bcount = ata_c->bcount; - xfer->c_start = mvsata_wdc_cmd_start; - xfer->c_intr = mvsata_wdc_cmd_intr; - xfer->c_poll = mvsata_wdc_cmd_poll; - xfer->c_abort = mvsata_wdc_cmd_done; - xfer->c_kill_xfer = mvsata_wdc_cmd_kill_xfer; + xfer->ops = &mvsata_wdc_cmd_xfer_ops; s = splbio(); ata_exec_xfer(chp, xfer); #ifdef DIAGNOSTIC @@ -2041,6 +2049,14 @@ mvsata_wdc_cmd_done_end(struct ata_chann } #if NATAPIBUS > 0 +static const struct ata_xfer_ops mvsata_atapi_xfer_ops = { + .c_start = mvsata_atapi_start, + .c_intr = mvsata_atapi_intr, + .c_poll = mvsata_atapi_poll, + .c_abort = mvsata_atapi_reset, + .c_kill_xfer = mvsata_atapi_kill_xfer, +}; + static void mvsata_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) @@ -2079,11 +2095,7 @@ mvsata_atapi_scsipi_request(struct scsip xfer->c_scsipi = sc_xfer; xfer->c_databuf = sc_xfer->data; xfer->c_bcount = sc_xfer->datalen; - xfer->c_start = mvsata_atapi_start; - xfer->c_intr = mvsata_atapi_intr; - xfer->c_poll = mvsata_atapi_poll; - xfer->c_abort = mvsata_atapi_reset; - xfer->c_kill_xfer = mvsata_atapi_kill_xfer; + xfer->ops = &mvsata_atapi_xfer_ops; xfer->c_dscpoll = 0; s = splbio(); ata_exec_xfer(chp, xfer); Index: src/sys/dev/ic/siisata.c diff -u src/sys/dev/ic/siisata.c:1.35.6.2 src/sys/dev/ic/siisata.c:1.35.6.3 --- src/sys/dev/ic/siisata.c:1.35.6.2 Sat Sep 1 10:13:41 2018 +++ src/sys/dev/ic/siisata.c Mon Sep 17 18:36:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: siisata.c,v 1.35.6.2 2018/09/01 10:13:41 jdolecek Exp $ */ +/* $NetBSD: siisata.c,v 1.35.6.3 2018/09/17 18:36:14 jdolecek Exp $ */ /* from ahcisata_core.c */ @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.2 2018/09/01 10:13:41 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.3 2018/09/17 18:36:14 jdolecek Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -563,7 +563,7 @@ siisata_intr_port(struct siisata_channel process: if (xfer != NULL) { - xfer->c_intr(chp, xfer, tfd); + xfer->ops->c_intr(chp, xfer, tfd); } else { /* * For NCQ, HBA halts processing when error is notified, @@ -580,7 +580,7 @@ process: if ((aslots & __BIT(slot)) != 0 && (pss & PR_PXSS(slot)) == 0) { xfer = ata_queue_hwslot_to_xfer(chp, slot); - xfer->c_intr(chp, xfer, 0); + xfer->ops->c_intr(chp, xfer, 0); } } } @@ -659,7 +659,7 @@ siisata_channel_recover(struct ata_chann if ((schp->sch_active_slots & (1 << eslot)) != 0) { xfer = ata_queue_hwslot_to_xfer(chp, eslot); xfer->c_flags |= C_RECOVERED; - xfer->c_intr(chp, xfer, ATACH_ERR_ST(err, st)); + xfer->ops->c_intr(chp, xfer, ATACH_ERR_ST(err, st)); } break; @@ -674,7 +674,7 @@ siisata_channel_recover(struct ata_chann if (xfer->c_drive != drive) continue; - xfer->c_intr(chp, xfer, tfd); + xfer->ops->c_intr(chp, xfer, tfd); } } break; @@ -708,7 +708,7 @@ reset: if (xfer->c_drive != drive) continue; - xfer->c_kill_xfer(chp, xfer, + xfer->ops->c_kill_xfer(chp, xfer, (error == 0) ? KILL_REQUEUE : KILL_RESET); } @@ -970,6 +970,14 @@ siisata_setup_channel(struct ata_channel return; } +static const struct ata_xfer_ops siisata_cmd_xfer_ops = { + .c_start = siisata_cmd_start, + .c_intr = siisata_cmd_complete, + .c_poll = siisata_cmd_poll, + .c_abort = siisata_cmd_abort, + .c_kill_xfer = siisata_cmd_kill_xfer, +}; + int siisata_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -989,11 +997,7 @@ siisata_exec_command(struct ata_drive_da xfer->c_drive = drvp->drive; xfer->c_databuf = ata_c->data; xfer->c_bcount = ata_c->bcount; - xfer->c_start = siisata_cmd_start; - xfer->c_intr = siisata_cmd_complete; - xfer->c_poll = siisata_cmd_poll; - xfer->c_abort = siisata_cmd_abort; - xfer->c_kill_xfer = siisata_cmd_kill_xfer; + xfer->ops = &siisata_cmd_xfer_ops; s = splbio(); ata_exec_xfer(chp, xfer); #ifdef DIAGNOSTIC @@ -1223,6 +1227,14 @@ siisata_cmd_done_end(struct ata_channel ata_c->flags |= AT_DONE; } +static const struct ata_xfer_ops siisata_bio_xfer_ops = { + .c_start = siisata_bio_start, + .c_intr = siisata_bio_complete, + .c_poll = siisata_bio_poll, + .c_abort = siisata_bio_abort, + .c_kill_xfer = siisata_bio_kill_xfer, +}; + int siisata_ata_bio(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1240,11 +1252,7 @@ siisata_ata_bio(struct ata_drive_datas * xfer->c_drive = drvp->drive; xfer->c_databuf = ata_bio->databuf; xfer->c_bcount = ata_bio->bcount; - xfer->c_start = siisata_bio_start; - xfer->c_intr = siisata_bio_complete; - xfer->c_poll = siisata_bio_poll; - xfer->c_abort = siisata_bio_abort; - xfer->c_kill_xfer = siisata_bio_kill_xfer; + xfer->ops = &siisata_bio_xfer_ops; ata_exec_xfer(chp, xfer); return (ata_bio->flags & ATA_ITSDONE) ? ATACMD_COMPLETE : ATACMD_QUEUED; @@ -1782,6 +1790,14 @@ siisata_atapi_probe_device(struct atapib } } +static const struct ata_xfer_ops siisata_atapi_xfer_ops = { + .c_start = siisata_atapi_start, + .c_intr = siisata_atapi_complete, + .c_poll = siisata_atapi_poll, + .c_abort = siisata_atapi_abort, + .c_kill_xfer = siisata_atapi_kill_xfer, +}; + void siisata_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) @@ -1824,11 +1840,7 @@ siisata_atapi_scsipi_request(struct scsi xfer->c_scsipi = sc_xfer; xfer->c_databuf = sc_xfer->data; xfer->c_bcount = sc_xfer->datalen; - xfer->c_start = siisata_atapi_start; - xfer->c_intr = siisata_atapi_complete; - xfer->c_poll = siisata_atapi_poll; - xfer->c_abort = siisata_atapi_abort; - xfer->c_kill_xfer = siisata_atapi_kill_xfer; + xfer->ops = &siisata_atapi_xfer_ops; xfer->c_dscpoll = 0; s = splbio(); ata_exec_xfer(atac->atac_channels[channel], xfer); Index: src/sys/dev/ic/wdc.c diff -u src/sys/dev/ic/wdc.c:1.288.6.1 src/sys/dev/ic/wdc.c:1.288.6.2 --- src/sys/dev/ic/wdc.c:1.288.6.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ic/wdc.c Mon Sep 17 18:36:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.288.6.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: wdc.c,v 1.288.6.2 2018/09/17 18:36:14 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.288.6.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.288.6.2 2018/09/17 18:36:14 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -919,8 +919,8 @@ ignore: } #endif chp->ch_flags &= ~ATACH_IRQ_WAIT; - KASSERT(xfer->c_intr != NULL); - ret = xfer->c_intr(chp, xfer, 1); + KASSERT(xfer->ops != NULL && xfer->ops->c_intr != NULL); + ret = xfer->ops->c_intr(chp, xfer, 1); if (ret == 0) /* irq was not for us, still waiting for irq */ chp->ch_flags |= ATACH_IRQ_WAIT; return (ret); @@ -1367,13 +1367,21 @@ wdctimeout(void *arg) */ callout_reset(&chp->c_timo_callout, hz, wdctimeout, chp); xfer->c_flags |= C_TIMEOU; - KASSERT(xfer->c_intr != NULL); - xfer->c_intr(chp, xfer, 1); + KASSERT(xfer->ops != NULL && xfer->ops->c_intr != NULL); + xfer->ops->c_intr(chp, xfer, 1); out: splx(s); } +static const struct ata_xfer_ops wdc_cmd_xfer_ops = { + .c_start = __wdccommand_start, + .c_poll = __wdccommand_poll, + .c_abort = __wdccommand_done, + .c_intr = __wdccommand_intr, + .c_kill_xfer = __wdccommand_kill_xfer, +}; + int wdc_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer) { @@ -1395,11 +1403,7 @@ wdc_exec_command(struct ata_drive_datas xfer->c_drive = drvp->drive; xfer->c_databuf = ata_c->data; xfer->c_bcount = ata_c->bcount; - xfer->c_start = __wdccommand_start; - xfer->c_poll = __wdccommand_poll; - xfer->c_abort = __wdccommand_done; - xfer->c_intr = __wdccommand_intr; - xfer->c_kill_xfer = __wdccommand_kill_xfer; + xfer->ops = &wdc_cmd_xfer_ops; s = splbio(); ata_exec_xfer(chp, xfer); Index: src/sys/dev/scsipi/atapi_wdc.c diff -u src/sys/dev/scsipi/atapi_wdc.c:1.129.6.1 src/sys/dev/scsipi/atapi_wdc.c:1.129.6.2 --- src/sys/dev/scsipi/atapi_wdc.c:1.129.6.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/scsipi/atapi_wdc.c Mon Sep 17 18:36:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atapi_wdc.c,v 1.129.6.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: atapi_wdc.c,v 1.129.6.2 2018/09/17 18:36:14 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.129.6.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.129.6.2 2018/09/17 18:36:14 jdolecek Exp $"); #ifndef ATADEBUG #define ATADEBUG @@ -359,6 +359,14 @@ wdc_atapi_probe_device(struct atapibus_s } } +static const struct ata_xfer_ops wdc_atapi_xfer_ops = { + .c_start = wdc_atapi_start, + .c_intr = wdc_atapi_intr, + .c_poll = wdc_atapi_poll, + .c_abort = wdc_atapi_reset, + .c_kill_xfer = wdc_atapi_kill_xfer, +}; + static void wdc_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) @@ -452,11 +460,7 @@ wdc_atapi_scsipi_request(struct scsipi_c xfer->c_scsipi = sc_xfer; xfer->c_databuf = sc_xfer->data; xfer->c_bcount = sc_xfer->datalen; - xfer->c_start = wdc_atapi_start; - xfer->c_intr = wdc_atapi_intr; - xfer->c_poll = wdc_atapi_poll; - xfer->c_abort = wdc_atapi_reset; - xfer->c_kill_xfer = wdc_atapi_kill_xfer; + xfer->ops = &wdc_atapi_xfer_ops; xfer->c_dscpoll = 0; s = splbio(); ata_exec_xfer(atac->atac_channels[channel], xfer);