CVS commit: src/sys/dev/ata
Module Name:src Committed By: jmcneill Date: Sun Dec 27 15:15:45 UTC 2020 Modified Files: src/sys/dev/ata: satareg.h Log Message: Add G3 and DevSleep definitions. This changes the mask used by SControl_IPM_NONE from 0x3 to 0x7. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ata/satareg.h 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/satareg.h diff -u src/sys/dev/ata/satareg.h:1.5 src/sys/dev/ata/satareg.h:1.6 --- src/sys/dev/ata/satareg.h:1.5 Mon Apr 28 20:23:47 2008 +++ src/sys/dev/ata/satareg.h Sun Dec 27 15:15:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: satareg.h,v 1.5 2008/04/28 20:23:47 martin Exp $ */ +/* $NetBSD: satareg.h,v 1.6 2020/12/27 15:15:45 jmcneill Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -65,6 +65,7 @@ #define SStatus_SPD_NONE (0x0 << 4) /* no negotiated speed */ #define SStatus_SPD_G1 (0x1 << 4) /* Generation 1 (1.5Gb/s) */ #define SStatus_SPD_G2 (0x2 << 4) /* Generation 2 (3.0Gb/s) */ +#define SStatus_SPD_G3 (0x3 << 4) /* Generation 3 (6.0Gb/s) */ #define SStatus_SPD_mask (0xf << 4) #define SStatus_SPD_shift 4 /* @@ -75,6 +76,7 @@ #define SStatus_IPM_ACTIVE (0x1 << 8) /* ACTIVE state */ #define SStatus_IPM_PARTIAL (0x2 << 8) /* PARTIAL pm state */ #define SStatus_IPM_SLUMBER (0x6 << 8) /* SLUMBER pm state */ +#define SStatus_IPM_DEVSLEEP (0x8 << 8) /* DevSleep pm state */ #define SStatus_IPM_mask (0xf << 8) #define SStatus_IPM_shift 8 @@ -130,6 +132,7 @@ #define SControl_SPD_ANY (0x0 << 4) /* No restrictions */ #define SControl_SPD_G1 (0x1 << 4) /* Generation 1 (1.5Gb/s) */ #define SControl_SPD_G2 (0x2 << 4) /* Generation 2 (3.0Gb/s) */ +#define SControl_SPD_G3 (0x3 << 4) /* Generation 3 (6.0Gb/s) */ /* * The IPM field represents the enabled interface power management * states that can be invoked via the Serial ATA interface power @@ -138,7 +141,8 @@ #define SControl_IPM_ANY (0x0 << 8) /* No restrictions */ #define SControl_IPM_NOPARTIAL (0x1 << 8) /* PARTIAL disabled */ #define SControl_IPM_NOSLUMBER (0x2 << 8) /* SLUMBER disabled */ -#define SControl_IPM_NONE (0x3 << 8) /* No power management */ +#define SControl_IPM_NODEVSLEEP (0x4 << 8) /* DevSleep disabled */ +#define SControl_IPM_NONE (0x7 << 8) /* No power management */ /* * The SPM field selects a power management state. A non-zero * value written to this field causes initiation of the selected
CVS commit: src/sys/dev/ata
Module Name:src Committed By: skrll Date: Wed Dec 23 08:17:01 UTC 2020 Modified Files: src/sys/dev/ata: ata_subr.c Log Message: Add missing '\n' in debug To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ata/ata_subr.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_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.12 src/sys/dev/ata/ata_subr.c:1.13 --- src/sys/dev/ata/ata_subr.c:1.12 Sat Dec 19 18:09:44 2020 +++ src/sys/dev/ata/ata_subr.c Wed Dec 23 08:17:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.12 2020/12/19 18:09:44 jmcneill Exp $ */ +/* $NetBSD: ata_subr.c,v 1.13 2020/12/23 08:17:01 skrll Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.12 2020/12/19 18:09:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.13 2020/12/23 08:17:01 skrll Exp $"); #include "opt_ata.h" @@ -306,7 +306,7 @@ ata_queue_alloc_slot(struct ata_channel KASSERT(mutex_owned(&chp->ch_lock)); KASSERT(chq->queue_active < chq->queue_openings); - ATADEBUG_PRINT(("%s: channel %d qavail 0x%x qact %d", + ATADEBUG_PRINT(("%s: channel %d qavail 0x%x qact %d\n", __func__, chp->ch_channel, chq->queue_xfers_avail, chq->queue_active), DEBUG_XFERS);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jmcneill Date: Sat Dec 19 18:09:44 UTC 2020 Modified Files: src/sys/dev/ata: ata_subr.c Log Message: ata_timeout: restore spl in ATACH_RECOVERING path To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/ata_subr.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_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.11 src/sys/dev/ata/ata_subr.c:1.12 --- src/sys/dev/ata/ata_subr.c:1.11 Sat May 2 19:09:56 2020 +++ src/sys/dev/ata/ata_subr.c Sat Dec 19 18:09:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.11 2020/05/02 19:09:56 thorpej Exp $ */ +/* $NetBSD: ata_subr.c,v 1.12 2020/12/19 18:09:44 jmcneill Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.11 2020/05/02 19:09:56 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.12 2020/12/19 18:09:44 jmcneill Exp $"); #include "opt_ata.h" @@ -237,7 +237,7 @@ ata_timeout(void *v) if (chp->ch_flags & ATACH_RECOVERING) { /* Do nothing, recovery will requeue the xfers */ - return; + goto done; } /* @@ -259,6 +259,7 @@ ata_timeout(void *v) xfer->ops->c_intr(xfer->c_chp, xfer, 0); } +done: splx(s); }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Mon Sep 28 12:47:49 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: fix typo that prevented bytes/physsect reporting from working To generate a diff of this commit: cvs rdiff -u -r1.464 -r1.465 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.464 src/sys/dev/ata/wd.c:1.465 --- src/sys/dev/ata/wd.c:1.464 Sun Sep 27 16:58:11 2020 +++ src/sys/dev/ata/wd.c Mon Sep 28 12:47:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.464 2020/09/27 16:58:11 christos Exp $ */ +/* $NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.464 2020/09/27 16:58:11 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -453,7 +453,7 @@ wdattach(device_t parent, device_t self, wd->sc_blksize, (unsigned long long)wd->sc_capacity); if (wd->sc_sectoralign.dsa_alignment != 1) { aprint_normal(" (%d bytes/physsect", - wd->sc_sectoralign.dsa_alignment & wd->sc_blksize); + wd->sc_sectoralign.dsa_alignment * wd->sc_blksize); if (wd->sc_sectoralign.dsa_firstaligned != 0) { aprint_normal("; first aligned sector: %jd", (intmax_t)wd->sc_sectoralign.dsa_firstaligned);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: christos Date: Sun Sep 27 16:58:11 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: de-quadruplicate, remove unused argument To generate a diff of this commit: cvs rdiff -u -r1.463 -r1.464 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.463 src/sys/dev/ata/wd.c:1.464 --- src/sys/dev/ata/wd.c:1.463 Sun May 24 18:12:29 2020 +++ src/sys/dev/ata/wd.c Sun Sep 27 12:58:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.463 2020/05/24 22:12:29 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.464 2020/09/27 16:58:11 christos Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.463 2020/05/24 22:12:29 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.464 2020/09/27 16:58:11 christos Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -203,7 +203,7 @@ static void wdbiorequeue(void *); static void wddone(device_t, struct ata_xfer *); static int wd_get_params(struct wd_softc *, struct ataparams *); static void wd_set_geometry(struct wd_softc *); -static int wd_flushcache(struct wd_softc *, int, bool); +static int wd_flushcache(struct wd_softc *, int); static int wd_trim(struct wd_softc *, daddr_t, long); static bool wd_shutdown(device_t, int); @@ -512,7 +512,7 @@ wd_suspend(device_t dv, const pmf_qual_t if (sc->atabus->ata_addref(sc->drvp)) return true; /* no need to complain */ - wd_flushcache(sc, AT_WAIT, false); + wd_flushcache(sc, AT_WAIT); wd_standby(sc, AT_WAIT); sc->atabus->ata_delref(sc->drvp); @@ -1194,7 +1194,7 @@ wd_lastclose(device_t self) KASSERTMSG(bufq_peek(wd->sc_dksc.sc_bufq) == NULL, "bufq not empty"); if (wd->sc_flags & WDF_DIRTY) - wd_flushcache(wd, AT_WAIT, false); + wd_flushcache(wd, AT_WAIT); wd->atabus->ata_delref(wd->drvp); wd->sc_flags &= ~WDF_OPEN; @@ -1373,7 +1373,7 @@ wdioctl(dev_t dev, u_long cmd, void *add return wd_setcache(wd, *(int *)addr); case DIOCCACHESYNC: - return wd_flushcache(wd, AT_WAIT, true); + return wd_flushcache(wd, AT_WAIT); case ATAIOCCOMMAND: /* @@ -1765,7 +1765,28 @@ wd_getcache(struct wd_softc *wd, int *bi return 0; } -const char at_errbits[] = "\20\10ERROR\11TIMEOU\12DF"; + +static int +wd_check_error(const struct dk_softc *dksc, const struct ata_xfer *xfer, +const char *func) +{ + static const char at_errbits[] = "\20\10ERROR\11TIMEOU\12DF"; + + int flags = xfer->c_ata_c.flags; + + if ((flags & AT_ERROR) != 0 && xfer->c_ata_c.r_error == WDCE_ABRT) { + /* command not supported */ + aprint_debug_dev(dksc->sc_dev, "%s: not supported\n", func); + return ENODEV; + } + if (flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { + char sbuf[sizeof(at_errbits) + 64]; + snprintb(sbuf, sizeof(sbuf), at_errbits, flags); + aprint_error_dev(dksc->sc_dev, "%s: status=%s\n", func, sbuf); + return EIO; + } + return 0; +} int wd_setcache(struct wd_softc *wd, int bits) @@ -1802,17 +1823,7 @@ wd_setcache(struct wd_softc *wd, int bit wd->atabus->ata_exec_command(wd->drvp, xfer); ata_wait_cmd(wd->drvp->chnl_softc, xfer); - if (xfer->c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { - char sbuf[sizeof(at_errbits) + 64]; - snprintb(sbuf, sizeof(sbuf), at_errbits, xfer->c_ata_c.flags); - aprint_error_dev(dksc->sc_dev, "wd_setcache: status=%s\n", sbuf); - error = EIO; - goto out; - } - - error = 0; - -out: + error = wd_check_error(dksc, xfer, __func__); ata_free_xfer(wd->drvp->chnl_softc, xfer); return error; } @@ -1836,31 +1847,13 @@ wd_standby(struct wd_softc *wd, int flag wd->atabus->ata_exec_command(wd->drvp, xfer); ata_wait_cmd(wd->drvp->chnl_softc, xfer); - if (xfer->c_ata_c.flags & AT_ERROR) { - if (xfer->c_ata_c.r_error == WDCE_ABRT) { - /* command not supported */ - aprint_debug_dev(dksc->sc_dev, -"standby immediate not supported\n"); - error = ENODEV; - goto out; - } - } - if (xfer->c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { - char sbuf[sizeof(at_errbits) + 64]; - snprintb(sbuf, sizeof(sbuf), at_errbits, xfer->c_ata_c.flags); - aprint_error_dev(dksc->sc_dev, "wd_standby: status=%s\n", sbuf); - error = EIO; - goto out; - } - error = 0; - -out: + error = wd_check_error(dksc, xfer, __func__); ata_free_xfer(wd->drvp->chnl_softc, xfer); return error; } int -wd_flushcache(struct wd_softc *wd, int flags, bool start_self) +wd_flushcache(struct wd_softc *wd, int flags) { struct dk_softc *dksc = &wd->sc_dksc; struct ata_xfer *xfer; @@ -1891,25 +1884,8 @@ wd_flushcache(struct wd_softc *wd, int f wd->atabus->ata_exec_command(wd->drvp, xfer); ata_wait_cmd(wd->drvp->chnl_softc, xfer); - if (xfer->c_ata_c.flags & AT_ERROR) { - if (xfer->c_ata_c.r_error == WDCE_ABRT) { - /* command not supported */ - error = ENODEV; - goto out_xfer; - } - } -
CVS commit: src/sys/dev/ata
Module Name:src Committed By: skrll Date: Tue Aug 25 13:42:09 UTC 2020 Modified Files: src/sys/dev/ata: ata_raid.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ata/ata_raid.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_raid.c diff -u src/sys/dev/ata/ata_raid.c:1.42 src/sys/dev/ata/ata_raid.c:1.43 --- src/sys/dev/ata/ata_raid.c:1.42 Fri Apr 26 11:51:56 2019 +++ src/sys/dev/ata/ata_raid.c Tue Aug 25 13:42:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid.c,v 1.42 2019/04/26 11:51:56 pgoyette Exp $ */ +/* $NetBSD: ata_raid.c,v 1.43 2020/08/25 13:42:09 skrll Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.42 2019/04/26 11:51:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.43 2020/08/25 13:42:09 skrll Exp $"); #include #include @@ -141,9 +141,9 @@ ata_raid_type_name(u_int type) }; if (type < __arraycount(ata_raid_type_names)) - return (ata_raid_type_names[type]); + return ata_raid_type_names[type]; - return (NULL); + return NULL; } /* @@ -176,7 +176,7 @@ ata_raid_finalize(device_t self) ataraid_cd.cd_name); out: - return (1); + return 1; } /* @@ -189,7 +189,7 @@ ataraid_match(device_t parent, cfdata_t { /* pseudo-device; always present */ - return (1); + return 1; } /* @@ -233,7 +233,7 @@ ataraid_print(void *aux, const char *pnp if (pnp != NULL) aprint_normal("block device at %s", pnp); aprint_normal(" vendtype %d unit %d", aai->aai_type, aai->aai_arrayno); - return (UNCONF); + return UNCONF; } /* @@ -295,7 +295,7 @@ ata_raid_get_array_info(u_int type, u_in TAILQ_INSERT_TAIL(&ataraid_array_info_list, aai, aai_list); out: - return (aai); + return aai; } int @@ -317,7 +317,7 @@ ata_raid_config_block_rw(struct vnode *v error = biowait(bp); putiobuf(bp); - return (error); + return error; } MODULE(MODULE_CLASS_DRIVER, ataraid, NULL);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon May 25 19:05:30 UTC 2020 Modified Files: src/sys/dev/ata: ata.c Log Message: disable downgrade of ATA mode from DMA, as generally not relevant any more - while it has been instrumental to inadvertedly discover driver bugs in PIO mode under QEMU recently, generally the switch more hurts than helps, so now only warn when DMA errors happen code kept under ATA_DOWNGRADE_MODE ifdef, disabled by default To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/sys/dev/ata/ata.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.158 src/sys/dev/ata/ata.c:1.159 --- src/sys/dev/ata/ata.c:1.158 Mon May 25 18:29:25 2020 +++ src/sys/dev/ata/ata.c Mon May 25 19:05:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.158 2020/05/25 18:29:25 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.158 2020/05/25 18:29:25 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $"); #include "opt_ata.h" @@ -84,7 +84,7 @@ int atadebug_mask = ATADEBUG_MASK; #define ATADEBUG_PRINT(args, level) #endif -#if NATA_DMA +#if defined(ATA_DOWNGRADE_MODE) && NATA_DMA static int ata_downgrade_mode(struct ata_drive_datas *, int); #endif @@ -965,8 +965,19 @@ ata_dmaerr(struct ata_drive_datas *drvp, */ drvp->n_dmaerrs++; if (drvp->n_dmaerrs >= NERRS_MAX && drvp->n_xfers <= NXFER) { +#ifdef ATA_DOWNGRADE_MODE ata_downgrade_mode(drvp, flags); drvp->n_dmaerrs = NERRS_MAX-1; +#else + static struct timeval last; + static const struct timeval serrintvl = { 300, 0 }; + + if (ratecheck(&last, &serrintvl)) { + aprint_error_dev(drvp->drv_softc, + "excessive DMA errors - %d in last %d transfers\n", + drvp->n_dmaerrs, drvp->n_xfers); + } +#endif drvp->n_xfers = 0; return; } @@ -1752,7 +1763,7 @@ ata_print_modes(struct ata_channel *chp) } } -#if NATA_DMA +#if defined(ATA_DOWNGRADE_MODE) && NATA_DMA /* * downgrade the transfer mode of a drive after an error. return 1 if * downgrade was possible, 0 otherwise. @@ -1809,7 +1820,7 @@ ata_downgrade_mode(struct ata_drive_data ata_thread_run(chp, flags, ATACH_TH_RESET, ATACH_NODRIVE); return 1; } -#endif /* NATA_DMA */ +#endif /* ATA_DOWNGRADE_MODE && NATA_DMA */ /* * Probe drive's capabilities, for use by the controller later
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon May 25 18:29:25 UTC 2020 Modified Files: src/sys/dev/ata: ata.c atavar.h Log Message: make ata_downgrade_mode() static, it's not used anywhere else To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/sys/dev/ata/ata.c cvs rdiff -u -r1.107 -r1.108 src/sys/dev/ata/atavar.h 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.157 src/sys/dev/ata/ata.c:1.158 --- src/sys/dev/ata/ata.c:1.157 Sat May 2 19:09:56 2020 +++ src/sys/dev/ata/ata.c Mon May 25 18:29:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $ */ +/* $NetBSD: ata.c,v 1.158 2020/05/25 18:29:25 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.158 2020/05/25 18:29:25 jdolecek Exp $"); #include "opt_ata.h" @@ -84,6 +84,10 @@ int atadebug_mask = ATADEBUG_MASK; #define ATADEBUG_PRINT(args, level) #endif +#if NATA_DMA +static int ata_downgrade_mode(struct ata_drive_datas *, int); +#endif + static ONCE_DECL(ata_init_ctrl); static struct pool ata_xfer_pool; @@ -1755,7 +1759,7 @@ ata_print_modes(struct ata_channel *chp) * * MUST BE CALLED AT splbio()! */ -int +static int ata_downgrade_mode(struct ata_drive_datas *drvp, int flags) { struct ata_channel *chp = drvp->chnl_softc; Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.107 src/sys/dev/ata/atavar.h:1.108 --- src/sys/dev/ata/atavar.h:1.107 Sat May 2 19:09:56 2020 +++ src/sys/dev/ata/atavar.h Mon May 25 18:29:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.107 2020/05/02 19:09:56 thorpej Exp $ */ +/* $NetBSD: atavar.h,v 1.108 2020/05/25 18:29:25 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -559,9 +559,6 @@ int ata_addref(struct ata_channel *); void ata_delref(struct ata_channel *); void atastart(struct ata_channel *); void ata_print_modes(struct ata_channel *); -#if NATA_DMA -int ata_downgrade_mode(struct ata_drive_datas *, int); -#endif void ata_probe_caps(struct ata_drive_datas *); #if NATA_DMA
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun May 24 22:12:29 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: account for already transferred data (partially done I/O) when retrying an xfer, to avoid reading/writing data from/to wrong offset, and eventually beyond the end of data buffer fixes data corruption under QEMU observed by Paul Ripke for emulated IDE drives To generate a diff of this commit: cvs rdiff -u -r1.462 -r1.463 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.462 src/sys/dev/ata/wd.c:1.463 --- src/sys/dev/ata/wd.c:1.462 Mon Apr 13 10:49:34 2020 +++ src/sys/dev/ata/wd.c Sun May 24 22:12:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.462 2020/04/13 10:49:34 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.463 2020/05/24 22:12:29 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.462 2020/04/13 10:49:34 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.463 2020/05/24 22:12:29 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -663,6 +663,7 @@ static void wdstart1(struct wd_softc *wd, struct buf *bp, struct ata_xfer *xfer) { struct dk_softc *dksc = &wd->sc_dksc; + const uint32_t secsize = dksc->sc_dkdev.dk_geom.dg_secsize; KASSERT(bp == xfer->c_bio.bp || xfer->c_bio.bp == NULL); KASSERT((xfer->c_flags & (C_WAITACT|C_FREE)) == 0); @@ -680,6 +681,14 @@ wdstart1(struct wd_softc *wd, struct buf xfer->c_bio.blkdone = 0; xfer->c_bio.bp = bp; + /* Adjust blkno and bcount if xfer has been already partially done */ + if (__predict_false(xfer->c_skip > 0)) { + KASSERT(xfer->c_skip < xfer->c_bio.bcount); + KASSERT((xfer->c_skip % secsize) == 0); + xfer->c_bio.bcount -= xfer->c_skip; + xfer->c_bio.blkno += xfer->c_skip / secsize; + } + #ifdef WD_CHAOS_MONKEY /* * Override blkno to be over device capacity to trigger error, @@ -714,10 +723,9 @@ wdstart1(struct wd_softc *wd, struct buf * and needed by transfer offset or size. */ if (wd->sc_flags & WDF_LBA48 && - (((xfer->c_bio.blkno + - xfer->c_bio.bcount / dksc->sc_dkdev.dk_geom.dg_secsize) > + (((xfer->c_bio.blkno + xfer->c_bio.bcount / secsize) > wd->sc_capacity28) || - ((xfer->c_bio.bcount / dksc->sc_dkdev.dk_geom.dg_secsize) > 128))) + ((xfer->c_bio.bcount / secsize) > 128))) xfer->c_bio.flags |= ATA_LBA48; /*
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Thu May 21 09:11:33 UTC 2020 Modified Files: src/sys/dev/ata: ata_wdc.c Log Message: stop timeout handler while scheduling another part of partial I/O, to avoid race between the timeout and I/O submission; the I/O submission can sleep with xfer while waiting for the controller to be ready once it gets to thread context, and timeout might cause the xfer to be freed, leading to crashes due to use-after-free this fixes another type of crashes with slow devices under QEMU reported by Paul Ripke - thanks a lot with extensive debugging help To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/ata/ata_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_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.117 src/sys/dev/ata/ata_wdc.c:1.118 --- src/sys/dev/ata/ata_wdc.c:1.117 Tue May 19 08:08:51 2020 +++ src/sys/dev/ata/ata_wdc.c Thu May 21 09:11:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.117 2020/05/19 08:08:51 jdolecek Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.118 2020/05/21 09:11:33 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.117 2020/05/19 08:08:51 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.118 2020/05/21 09:11:33 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -769,6 +769,8 @@ end: if (xfer->c_bcount > 0) { if ((ata_bio->flags & ATA_POLL) == 0) { /* Start the next operation */ + KASSERT((chp->ch_flags & ATACH_IRQ_WAIT) == 0); + callout_stop(&chp->c_timo_callout); ata_xfer_start(xfer); } else { /* Let _wdc_ata_bio_start do the loop */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri May 15 21:56:14 UTC 2020 Modified Files: src/sys/dev/ata: atareg.h Log Message: remove unused atacmd_tostatq() To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ata/atareg.h 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/atareg.h diff -u src/sys/dev/ata/atareg.h:1.44 src/sys/dev/ata/atareg.h:1.45 --- src/sys/dev/ata/atareg.h:1.44 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/atareg.h Fri May 15 21:56:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atareg.h,v 1.44 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: atareg.h,v 1.45 2020/05/15 21:56:14 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -186,23 +186,6 @@ atacmd_to48(int cmd32) #define WDCC_READ_FPDMA_QUEUED 0x60 /* SATA native queued read (48bit) */ #define WDCC_WRITE_FPDMA_QUEUED 0x61 /* SATA native queued write (48bit) */ -#ifdef _KERNEL -/* Convert a 32-bit command to a Native SATA Queued command. */ -static __inline int -atacmd_tostatq(int cmd32) -{ - switch (cmd32) { - case WDCC_READDMA: - return WDCC_READ_FPDMA_QUEUED; - case WDCC_WRITEDMA: - return WDCC_WRITE_FPDMA_QUEUED; - default: - panic("atacmd_tosataq: illegal 32-bit command: %d", cmd32); - /* NOTREACHED */ - } -} -#endif /* _KERNEL */ - /* Subcommands for SET_FEATURES (features register) */ #define WDSF_8BIT_PIO_EN 0x01 #define WDSF_WRITE_CACHE_EN 0x02
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri May 15 16:58:28 UTC 2020 Modified Files: src/sys/dev/ata: ata_wdc.c Log Message: whitespace (bad indent) To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/dev/ata/ata_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_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.115 src/sys/dev/ata/ata_wdc.c:1.116 --- src/sys/dev/ata/ata_wdc.c:1.115 Mon Apr 13 10:49:34 2020 +++ src/sys/dev/ata/ata_wdc.c Fri May 15 16:58:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.115 2020/04/13 10:49:34 jdolecek Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.116 2020/05/15 16:58:28 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.115 2020/04/13 10:49:34 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.116 2020/05/15 16:58:28 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -557,8 +557,8 @@ _wdc_ata_bio_start(struct ata_channel *c /* The number of blocks in the last stretch may be smaller. */ nblks = xfer->c_bcount / drvp->lp->d_secsize; if (ata_bio->nblks > nblks) { - ata_bio->nblks = nblks; - ata_bio->nbytes = xfer->c_bcount; + ata_bio->nblks = nblks; + ata_bio->nbytes = xfer->c_bcount; } } /* If this was a write and not using DMA, push the data. */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: thorpej Date: Sat May 2 19:09:56 UTC 2020 Modified Files: src/sys/dev/ata: ata.c ata_subr.c atavar.h Log Message: Back out changes to use a threadpool for now; it's causing trouble for some folks on Thinkpads. To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/dev/ata/ata.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ata/atavar.h 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.156 src/sys/dev/ata/ata.c:1.157 --- src/sys/dev/ata/ata.c:1.156 Sat Apr 25 00:07:27 2020 +++ src/sys/dev/ata/ata.c Sat May 2 19:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $ */ +/* $NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $"); #include "opt_ata.h" @@ -425,60 +425,47 @@ atabusconfig_thread(void *arg) } /* - * atabus_tp_job: + * atabus_thread: * * Worker thread for the ATA bus. */ static void -atabus_tp_job(struct threadpool_job *j) +atabus_thread(void *arg) { - struct ata_channel *chp = - container_of(j, struct ata_channel, ch_tp_job); - struct atabus_softc *sc = device_private(chp->atabus); + struct atabus_softc *sc = arg; + struct ata_channel *chp = sc->sc_chan; struct ata_queue *chq = chp->ch_queue; struct ata_xfer *xfer; int i, rv; - /* XXX MPSAFE?? */ - KERNEL_LOCK(1, NULL); - ata_channel_lock(chp); - chp->ch_job_thread = curlwp; /* XXX gross */ + KASSERT(ata_is_thread_run(chp)); - /* XXX gross */ - if (__predict_false(!chp->ch_initial_config_done)) { - /* - * Probe the drives. Reset type to indicate to controllers - * that can re-probe that all drives must be probed.. - * - * Note: ch_ndrives may be changed during the probe. - */ - KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); - for (i = 0; i < chp->ch_ndrives; i++) { - chp->ch_drive[i].drive_flags = 0; - chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; - } - chp->ch_initial_config_done = true; - ata_channel_unlock(chp); - atabusconfig(sc); - ata_channel_lock(chp); + /* + * Probe the drives. Reset type to indicate to controllers + * that can re-probe that all drives must be probed.. + * + * Note: ch_ndrives may be changed during the probe. + */ + KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); + for (i = 0; i < chp->ch_ndrives; i++) { + chp->ch_drive[i].drive_flags = 0; + chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; } + ata_channel_unlock(chp); -#define WORK_TO_DO \ - (ATACH_TH_RESCAN | ATACH_TH_RESET | ATACH_TH_DRIVE_RESET | \ - ATACH_TH_RECOVERY) + atabusconfig(sc); + ata_channel_lock(chp); for (;;) { - if (chp->ch_flags & ATACH_SHUTDOWN) { - break; - } - if ((chp->ch_flags & WORK_TO_DO) == 0 && + if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_TH_DRIVE_RESET + | ATACH_TH_RECOVERY | ATACH_SHUTDOWN)) == 0 && (chq->queue_active == 0 || chq->queue_freeze == 0)) { + cv_wait(&chp->ch_thr_idle, &chp->ch_lock); + } + if (chp->ch_flags & ATACH_SHUTDOWN) { break; } - -#undef WORK_TO_DO - if (chp->ch_flags & ATACH_TH_RESCAN) { chp->ch_flags &= ~ATACH_TH_RESCAN; ata_channel_unlock(chp); @@ -547,11 +534,10 @@ atabus_tp_job(struct threadpool_job *j) ata_channel_lock(chp); } } - chp->ch_job_thread = NULL; /* XXX gross */ - threadpool_job_done(&chp->ch_tp_job); + chp->ch_thread = NULL; + cv_signal(&chp->ch_thr_idle); ata_channel_unlock(chp); - - KERNEL_UNLOCK_ONE(NULL); + kthread_exit(0); } bool @@ -559,7 +545,7 @@ ata_is_thread_run(struct ata_channel *ch { KASSERT(mutex_owned(&chp->ch_lock)); - return (chp->ch_job_thread == curlwp && !cpu_intr_p()); + return (chp->ch_thread == curlwp && !cpu_intr_p()); } static void @@ -567,7 +553,7 @@ ata_thread_wake_locked(struct ata_channe { KASSERT(mutex_owned(&chp->ch_lock)); ata_channel_freeze_locked(chp); - threadpool_schedule_job(chp->ch_tp, &chp->ch_tp_job); + cv_signal(&chp->ch_thr_idle); } /* @@ -601,6 +587,7 @@ atabus_attach(device_t parent, device_t struct atabus_softc *sc = device_private(self); struct ata_channel *chp = aux; struct atabus_initq *initq; + int error; sc->sc_chan = chp; @@ -621,15 +608,11 @@ atabus_attach(device_t parent, device_t mutex_exit(&atabus_qlock); config_pending_incr(sc->sc_dev); - /* Initialize our threadpool job. */ - threadpool_job_init(&chp->ch_tp_job, atabus_tp_job, - &chp->ch_lock, "%s", device_xname(self)); - - /* ...and run it now to scan the bus. */ - KASSERT(chp->ch_tp != NULL); - ata_channel_lock(chp); - threadpool_schedule_job(c
CVS commit: src/sys/dev/ata
Module Name:src Committed By: thorpej Date: Sat Apr 25 00:07:27 UTC 2020 Modified Files: src/sys/dev/ata: ata.c ata_subr.c atavar.h Log Message: Rather than creating a kthread-per-channel, use a threadpool and a threadpool-job-per-channel for the in-thread-context work that needs to be done (which is rare). On one of my test systems, this results in the total number of LWPs after multi-user boot dropping from 116 to 78. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/sys/dev/ata/ata.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.105 -r1.106 src/sys/dev/ata/atavar.h 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.155 src/sys/dev/ata/ata.c:1.156 --- src/sys/dev/ata/ata.c:1.155 Mon Apr 13 10:49:34 2020 +++ src/sys/dev/ata/ata.c Sat Apr 25 00:07:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.155 2020/04/13 10:49:34 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.155 2020/04/13 10:49:34 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $"); #include "opt_ata.h" @@ -425,47 +425,60 @@ atabusconfig_thread(void *arg) } /* - * atabus_thread: + * atabus_tp_job: * * Worker thread for the ATA bus. */ static void -atabus_thread(void *arg) +atabus_tp_job(struct threadpool_job *j) { - struct atabus_softc *sc = arg; - struct ata_channel *chp = sc->sc_chan; + struct ata_channel *chp = + container_of(j, struct ata_channel, ch_tp_job); + struct atabus_softc *sc = device_private(chp->atabus); struct ata_queue *chq = chp->ch_queue; struct ata_xfer *xfer; int i, rv; + /* XXX MPSAFE?? */ + KERNEL_LOCK(1, NULL); + ata_channel_lock(chp); - KASSERT(ata_is_thread_run(chp)); + chp->ch_job_thread = curlwp; /* XXX gross */ - /* - * Probe the drives. Reset type to indicate to controllers - * that can re-probe that all drives must be probed.. - * - * Note: ch_ndrives may be changed during the probe. - */ - KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); - for (i = 0; i < chp->ch_ndrives; i++) { - chp->ch_drive[i].drive_flags = 0; - chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; + /* XXX gross */ + if (__predict_false(!chp->ch_initial_config_done)) { + /* + * Probe the drives. Reset type to indicate to controllers + * that can re-probe that all drives must be probed.. + * + * Note: ch_ndrives may be changed during the probe. + */ + KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); + for (i = 0; i < chp->ch_ndrives; i++) { + chp->ch_drive[i].drive_flags = 0; + chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; + } + chp->ch_initial_config_done = true; + ata_channel_unlock(chp); + atabusconfig(sc); + ata_channel_lock(chp); } - ata_channel_unlock(chp); - atabusconfig(sc); +#define WORK_TO_DO \ + (ATACH_TH_RESCAN | ATACH_TH_RESET | ATACH_TH_DRIVE_RESET | \ + ATACH_TH_RECOVERY) - ata_channel_lock(chp); for (;;) { - if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_TH_DRIVE_RESET - | ATACH_TH_RECOVERY | ATACH_SHUTDOWN)) == 0 && - (chq->queue_active == 0 || chq->queue_freeze == 0)) { - cv_wait(&chp->ch_thr_idle, &chp->ch_lock); - } if (chp->ch_flags & ATACH_SHUTDOWN) { break; } + if ((chp->ch_flags & WORK_TO_DO) == 0 && + (chq->queue_active == 0 || chq->queue_freeze == 0)) { + break; + } + +#undef WORK_TO_DO + if (chp->ch_flags & ATACH_TH_RESCAN) { chp->ch_flags &= ~ATACH_TH_RESCAN; ata_channel_unlock(chp); @@ -534,10 +547,11 @@ atabus_thread(void *arg) ata_channel_lock(chp); } } - chp->ch_thread = NULL; - cv_signal(&chp->ch_thr_idle); + chp->ch_job_thread = NULL; /* XXX gross */ + threadpool_job_done(&chp->ch_tp_job); ata_channel_unlock(chp); - kthread_exit(0); + + KERNEL_UNLOCK_ONE(NULL); } bool @@ -545,7 +559,7 @@ ata_is_thread_run(struct ata_channel *ch { KASSERT(mutex_owned(&chp->ch_lock)); - return (chp->ch_thread == curlwp && !cpu_intr_p()); + return (chp->ch_job_thread == curlwp && !cpu_intr_p()); } static void @@ -553,7 +567,7 @@ ata_thread_wake_locked(struct ata_channe { KASSERT(mutex_owned(&chp->ch_lock)); ata_channel_freeze_locked(chp); - cv_signal(&chp->ch_thr_idle); + threadpool_schedule_job(chp->ch_tp, &chp->ch_tp_job); } /* @@ -587,7 +601,6 @@ atabus_attach(device_t parent, device_t struct atabus_softc *sc = device_private(self); struct ata_channel *chp = aux; struct atabus_initq *initq; - int error; sc->sc_chan = chp; @@ -608,11 +621,15 @@ atabus_attach(device_t parent, device_t mutex_exit(&atabus_qlock); config_pending_incr(sc->sc_dev); - /* XXX MPSAFE - no KTHREAD_MPSAFE, so protected by KERNEL_LOCK() */ - if ((er
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Tue Apr 7 13:22:05 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: drop wd lock in wdstart1() before calling the ata_bio hook; when called from ata thread context, that can still need to sleep for wdc attachments in wdcwait() To generate a diff of this commit: cvs rdiff -u -r1.459 -r1.460 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.459 src/sys/dev/ata/wd.c:1.460 --- src/sys/dev/ata/wd.c:1.459 Mon Mar 2 16:01:56 2020 +++ src/sys/dev/ata/wd.c Tue Apr 7 13:22:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.459 2020/03/02 16:01:56 riastradh Exp $ */ +/* $NetBSD: wd.c,v 1.460 2020/04/07 13:22:05 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.459 2020/03/02 16:01:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.460 2020/04/07 13:22:05 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -666,6 +666,7 @@ wdstart1(struct wd_softc *wd, struct buf KASSERT(bp == xfer->c_bio.bp || xfer->c_bio.bp == NULL); KASSERT((xfer->c_flags & (C_WAITACT|C_FREE)) == 0); + KASSERT(mutex_owned(&wd->sc_lock)); /* Reset state, so that retries don't use stale info */ if (__predict_false(xfer->c_retries > 0)) { @@ -757,6 +758,8 @@ wdstart1(struct wd_softc *wd, struct buf if (xfer->c_retries == 0) wd->inflight++; + mutex_exit(&wd->sc_lock); + switch (wd->atabus->ata_bio(wd->drvp, xfer)) { case ATACMD_TRY_AGAIN: panic("wdstart1: try again"); @@ -767,6 +770,8 @@ wdstart1(struct wd_softc *wd, struct buf default: panic("wdstart1: bad return code from ata_bio()"); } + + mutex_enter(&wd->sc_lock); } static int
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Apr 4 22:30:03 UTC 2020 Modified Files: src/sys/dev/ata: ata_recovery.c ata_subr.c Log Message: stop xfer timeouts during recovery, all xfers will be requeued anyway this avoids race with the timeout routine when processing the xfers for requeueing should fix PR kern/54790 by Izumi Tsutsui To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/ata_recovery.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/ata_subr.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_recovery.c diff -u src/sys/dev/ata/ata_recovery.c:1.2 src/sys/dev/ata/ata_recovery.c:1.3 --- src/sys/dev/ata/ata_recovery.c:1.2 Mon Oct 22 20:13:47 2018 +++ src/sys/dev/ata/ata_recovery.c Sat Apr 4 22:30:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_recovery.c,v 1.2 2018/10/22 20:13:47 jdolecek Exp $ */ +/* $NetBSD: ata_recovery.c,v 1.3 2020/04/04 22:30:02 jdolecek Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_recovery.c,v 1.2 2018/10/22 20:13:47 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_recovery.c,v 1.3 2020/04/04 22:30:02 jdolecek Exp $"); #include "opt_ata.h" @@ -171,6 +171,9 @@ ata_recovery_resume(struct ata_channel * ata_queue_hold(chp); + /* Stop the timeout callout, recovery will requeue once done */ + callout_stop(&chp->c_timo_callout); + KASSERT(drive < chp->ch_ndrives); drvp = &chp->ch_drive[drive]; Index: src/sys/dev/ata/ata_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.8 src/sys/dev/ata/ata_subr.c:1.9 --- src/sys/dev/ata/ata_subr.c:1.8 Wed Nov 7 17:05:54 2018 +++ src/sys/dev/ata/ata_subr.c Sat Apr 4 22:30:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.8 2018/11/07 17:05:54 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.9 2020/04/04 22:30:02 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.8 2018/11/07 17:05:54 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.9 2020/04/04 22:30:02 jdolecek Exp $"); #include "opt_ata.h" @@ -235,6 +235,11 @@ ata_timeout(void *v) callout_ack(&chp->c_timo_callout); + if (chp->ch_flags & ATACH_RECOVERING) { + /* Do nothing, recovery will requeue the xfers */ + return; + } + /* * If there is a timeout, means the last enqueued command * timed out, and thus all commands timed out.
CVS commit: src/sys/dev/ata
Module Name:src Committed By: simonb Date: Sat Jan 18 11:24:40 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: Tidy quirk table and remove outdated quick from the quirk format string. To generate a diff of this commit: cvs rdiff -u -r1.456 -r1.457 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.456 src/sys/dev/ata/wd.c:1.457 --- src/sys/dev/ata/wd.c:1.456 Sat Jan 18 11:22:49 2020 +++ src/sys/dev/ata/wd.c Sat Jan 18 11:24:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.456 2020/01/18 11:22:49 simonb Exp $ */ +/* $NetBSD: wd.c,v 1.457 2020/01/18 11:24:40 simonb Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.456 2020/01/18 11:22:49 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.457 2020/01/18 11:24:40 simonb Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -232,7 +232,7 @@ static void bad144intern(struct wd_softc #define WD_QUIRK_SPLIT_MOD15_WRITE 0x0001 /* must split certain writes */ -#define WD_QUIRK_FMT "\20\1SPLIT_MOD15_WRITE\2FORCE_LBA48" +#define WD_QUIRK_FMT "\20\1SPLIT_MOD15_WRITE" /* * Quirk table for IDE drives. Put more-specific matches first, since @@ -259,12 +259,9 @@ static const struct wd_quirk { * Seagate Barracuda Serial ATA V family. * */ - { "ST3120023AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, - { "ST380023AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, - { "ST360015AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, + { "ST3120023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, + { "ST380023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, + { "ST360015AS", WD_QUIRK_SPLIT_MOD15_WRITE }, { NULL, 0 } };
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Tue Jan 14 21:08:06 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: enable the BAD_NCQ quirk for all 860 EVO drives XXX work-in-progress, it's not clear whether this is driver or controller XXX problem To generate a diff of this commit: cvs rdiff -u -r1.454 -r1.455 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.454 src/sys/dev/ata/wd.c:1.455 --- src/sys/dev/ata/wd.c:1.454 Mon Jan 13 21:20:17 2020 +++ src/sys/dev/ata/wd.c Tue Jan 14 21:08:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.454 2020/01/13 21:20:17 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.455 2020/01/14 21:08:06 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.454 2020/01/13 21:20:17 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.455 2020/01/14 21:08:06 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -263,8 +263,7 @@ static const struct wd_quirk { { "ST3120023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, { "ST380023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, { "ST360015AS", WD_QUIRK_SPLIT_MOD15_WRITE }, - { "Samsung SSD 860 EVO 1TB", WD_QUIRK_BAD_NCQ }, - { "Samsung SSD 860 EVO 500GB", WD_QUIRK_BAD_NCQ }, + { "Samsung SSD 860 EVO *", WD_QUIRK_BAD_NCQ }, { NULL, 0 } };
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Jan 13 21:20:17 UTC 2020 Modified Files: src/sys/dev/ata: wd.c Log Message: disable NCQ by default for "Samsung SSD 860 EVO 1TB" and "Samsung SSD 860 EVO 500GB" - these drives have known broken NCQ support particularly when used with AMD SB710/750 chipsets, problem occur also under Linux and Windows https://eu.community.samsung.com/t5/Cameras-IT-Everything-Else/860-EVO-250GB-causing-freezes-on-AMD-system/td-p/575813 https://bugzilla.kernel.org/show_bug.cgi?id=201693 It seems there is no Samsung firmware update to fix this even. Disable NCQ regardless of the controller, it's likely same problem exists with other controllers too. This should fix PR kern/54790 and PR kern/54855 To generate a diff of this commit: cvs rdiff -u -r1.453 -r1.454 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.453 src/sys/dev/ata/wd.c:1.454 --- src/sys/dev/ata/wd.c:1.453 Fri Dec 27 09:41:50 2019 +++ src/sys/dev/ata/wd.c Mon Jan 13 21:20:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.453 2019/12/27 09:41:50 msaitoh Exp $ */ +/* $NetBSD: wd.c,v 1.454 2020/01/13 21:20:17 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.453 2019/12/27 09:41:50 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.454 2020/01/13 21:20:17 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -231,8 +231,9 @@ static void bad144intern(struct wd_softc #endif #define WD_QUIRK_SPLIT_MOD15_WRITE 0x0001 /* must split certain writes */ +#define WD_QUIRK_BAD_NCQ 0x0002 /* drive NCQ support broken */ -#define WD_QUIRK_FMT "\20\1SPLIT_MOD15_WRITE\2FORCE_LBA48" +#define WD_QUIRK_FMT "\20\1SPLIT_MOD15_WRITE\2BAD_NCQ" /* * Quirk table for IDE drives. Put more-specific matches first, since @@ -259,14 +260,12 @@ static const struct wd_quirk { * Seagate Barracuda Serial ATA V family. * */ - { "ST3120023AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, - { "ST380023AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, - { "ST360015AS", - WD_QUIRK_SPLIT_MOD15_WRITE }, - { NULL, - 0 } + { "ST3120023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, + { "ST380023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, + { "ST360015AS", WD_QUIRK_SPLIT_MOD15_WRITE }, + { "Samsung SSD 860 EVO 1TB", WD_QUIRK_BAD_NCQ }, + { "Samsung SSD 860 EVO 500GB", WD_QUIRK_BAD_NCQ }, + { NULL, 0 } }; static const struct wd_quirk * @@ -375,6 +374,10 @@ wdattach(device_t parent, device_t self, if (wd->sc_quirks & WD_QUIRK_SPLIT_MOD15_WRITE) { aprint_error_dev(self, "drive corrupts write transfers with certain controllers, consider replacing\n"); } + + if (wd->sc_quirks & WD_QUIRK_BAD_NCQ) { + aprint_error_dev(self, "drive NCQ support broken, NCQ disabled, consider replacing\n"); + } } if ((wd->sc_params.atap_multi & 0xff) > 1) { @@ -2181,7 +2184,7 @@ wd_sysctl_attach(struct wd_softc *wd) return; } - wd->drv_ncq = true; + wd->drv_ncq = ((wd->sc_quirks & WD_QUIRK_BAD_NCQ) == 0) ? true : false; if ((error = sysctl_createv(&wd->nodelog, 0, NULL, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "use_ncq", SYSCTL_DESCR("use NCQ if supported"),
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Sun Apr 7 13:00:00 UTC 2019 Modified Files: src/sys/dev/ata: wd.c Log Message: Really implement WDF_DIRTY. patch(1) did something silly here ... To generate a diff of this commit: cvs rdiff -u -r1.448 -r1.449 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.448 src/sys/dev/ata/wd.c:1.449 --- src/sys/dev/ata/wd.c:1.448 Fri Apr 5 21:31:44 2019 +++ src/sys/dev/ata/wd.c Sun Apr 7 13:00:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.448 2019/04/05 21:31:44 bouyer Exp $ */ +/* $NetBSD: wd.c,v 1.449 2019/04/07 13:00:00 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.448 2019/04/05 21:31:44 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.449 2019/04/07 13:00:00 bouyer Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -719,8 +719,12 @@ wdstart1(struct wd_softc *wd, struct buf if (wd->sc_flags & WDF_LBA) xfer->c_bio.flags |= ATA_LBA; - if (bp->b_flags & B_READ) + if (bp->b_flags & B_READ) { xfer->c_bio.flags |= ATA_READ; + } else { + /* it's a write */ + wd->sc_flags |= WDF_DIRTY; + } if (bp->b_flags & B_MEDIA_FUA) { /* If not using NCQ, the command WRITE DMA FUA EXT is LBA48 */ KASSERT((wd->sc_flags & WDF_LBA48) != 0); @@ -1144,7 +1148,8 @@ wd_lastclose(device_t self) KASSERTMSG(bufq_peek(wd->sc_dksc.sc_bufq) == NULL, "bufq not empty"); - wd_flushcache(wd, AT_WAIT, false); + if (wd->sc_flags & WDF_DIRTY) + wd_flushcache(wd, AT_WAIT, false); wd->atabus->ata_delref(wd->drvp); wd->sc_flags &= ~WDF_OPEN; @@ -1847,6 +1852,7 @@ wd_flushcache(struct wd_softc *wd, int f error = EIO; goto out_xfer; } + wd->sc_flags &= ~WDF_DIRTY; error = 0; out_xfer: @@ -2235,7 +2241,6 @@ wddebug(void) atachannel_debug(wd->drvp->chnl_softc); } - wd->sc_flags &= ~WDF_DIRTY; return 0; } #endif /* ATADEBUG */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: uwe Date: Sat Apr 6 00:35:26 UTC 2019 Modified Files: src/sys/dev/ata: ata.c Log Message: Make sure the aprint_verbose chain is terminated with a newline. Check sep instead of printed, b/c the latter is reset several times. To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/sys/dev/ata/ata.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.147 src/sys/dev/ata/ata.c:1.148 --- src/sys/dev/ata/ata.c:1.147 Tue Dec 11 23:06:30 2018 +++ src/sys/dev/ata/ata.c Sat Apr 6 00:35:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.147 2018/12/11 23:06:30 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.148 2019/04/06 00:35:25 uwe Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.147 2018/12/11 23:06:30 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.148 2019/04/06 00:35:25 uwe Exp $"); #include "opt_ata.h" @@ -2040,6 +2040,8 @@ ata_probe_caps(struct ata_drive_datas *d #if NATA_DMA if ((atac->atac_cap & ATAC_CAP_DMA) == 0) { /* don't care about DMA modes */ + if (*sep != '\0') + aprint_verbose("\n"); return; } if (cf_flags & ATA_CONFIG_DMA_SET) { @@ -2086,7 +2088,7 @@ ata_probe_caps(struct ata_drive_datas *d } ata_channel_unlock(chp); - if (printed) + if (*sep != '\0') aprint_verbose("\n"); #if NATA_UDMA
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Fri Apr 5 21:31:44 UTC 2019 Modified Files: src/sys/dev/ata: atavar.h wd.c Log Message: drop AT_RST_NOCMD, it's a cut'n'paste side effect To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.447 -r1.448 src/sys/dev/ata/wd.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/atavar.h diff -u src/sys/dev/ata/atavar.h:1.102 src/sys/dev/ata/atavar.h:1.103 --- src/sys/dev/ata/atavar.h:1.102 Fri Apr 5 20:44:09 2019 +++ src/sys/dev/ata/atavar.h Fri Apr 5 21:31:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.102 2019/04/05 20:44:09 christos Exp $ */ +/* $NetBSD: atavar.h,v 1.103 2019/04/05 21:31:44 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -117,7 +117,6 @@ struct ata_command { #define AT_READREG 0x1000 /* Read registers on completion */ #define AT_LBA 0x2000 /* LBA28 */ #define AT_LBA48 0x4000 /* LBA48 */ -#define AT_RST_NOCMD 0x8000 /* ??? */ int timeout; /* timeout (in ms) */ void *data; /* Data buffer address */ Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.447 src/sys/dev/ata/wd.c:1.448 --- src/sys/dev/ata/wd.c:1.447 Fri Apr 5 18:23:45 2019 +++ src/sys/dev/ata/wd.c Fri Apr 5 21:31:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.447 2019/04/05 18:23:45 bouyer Exp $ */ +/* $NetBSD: wd.c,v 1.448 2019/04/05 21:31:44 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.447 2019/04/05 18:23:45 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.448 2019/04/05 21:31:44 bouyer Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -1647,8 +1647,7 @@ again: case CMD_ERR: if (retry == 0) { retry++; - (*wd->atabus->ata_reset_drive)(wd->drvp, - flags | AT_RST_NOCMD, NULL); + (*wd->atabus->ata_reset_drive)(wd->drvp, flags, NULL); goto again; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: christos Date: Fri Apr 5 20:44:09 UTC 2019 Modified Files: src/sys/dev/ata: atavar.h Log Message: unbreak the build, someone forgot to commit more stuff :-) To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/dev/ata/atavar.h 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/atavar.h diff -u src/sys/dev/ata/atavar.h:1.101 src/sys/dev/ata/atavar.h:1.102 --- src/sys/dev/ata/atavar.h:1.101 Wed Oct 24 15:38:00 2018 +++ src/sys/dev/ata/atavar.h Fri Apr 5 16:44:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.101 2018/10/24 19:38:00 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.102 2019/04/05 20:44:09 christos Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -103,20 +103,21 @@ struct ata_command { command */ volatile uint16_t flags; -#define AT_READ 0x0001 /* There is data to read */ -#define AT_WRITE0x0002 /* There is data to write (excl. with AT_READ) */ -#define AT_WAIT 0x0008 /* wait in controller code for command completion */ -#define AT_POLL 0x0010 /* poll for command completion (no interrupts) */ -#define AT_DONE 0x0020 /* command is done */ -#define AT_XFDONE 0x0040 /* data xfer is done */ -#define AT_ERROR0x0080 /* command is done with error */ -#define AT_TIMEOU 0x0100 /* command timed out */ -#define AT_DF 0x0200 /* Drive fault */ -#define AT_RESET0x0400 /* command terminated by channel reset */ -#define AT_GONE 0x0800 /* command terminated because device is gone */ -#define AT_READREG 0x1000 /* Read registers on completion */ -#define AT_LBA 0x2000 /* LBA28 */ -#define AT_LBA480x4000 /* LBA48 */ +#define AT_READ 0x0001 /* There is data to read */ +#define AT_WRITE 0x0002 /* There is data to write (excl. with AT_READ) */ +#define AT_WAIT 0x0008 /* wait in controller for command completion */ +#define AT_POLL 0x0010 /* poll for command completion (no interrupts) */ +#define AT_DONE 0x0020 /* command is done */ +#define AT_XFDONE 0x0040 /* data xfer is done */ +#define AT_ERROR 0x0080 /* command is done with error */ +#define AT_TIMEOU 0x0100 /* command timed out */ +#define AT_DF 0x0200 /* Drive fault */ +#define AT_RESET 0x0400 /* command terminated by channel reset */ +#define AT_GONE 0x0800 /* command terminated because device is gone */ +#define AT_READREG 0x1000 /* Read registers on completion */ +#define AT_LBA 0x2000 /* LBA28 */ +#define AT_LBA48 0x4000 /* LBA48 */ +#define AT_RST_NOCMD 0x8000 /* ??? */ int timeout; /* timeout (in ms) */ void *data; /* Data buffer address */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Fri Apr 5 18:23:45 UTC 2019 Modified Files: src/sys/dev/ata: wd.c wdvar.h Log Message: Implement a DIRTY flag (copied from sd(4)) so avoid flushing the cache if there has been no write. This avoids a (long) timeout on the flush cache command triggered by atactl sleep, when the device is open only by the atactl command itself. If a drive has no partition open and goes to sleep, the WDF_LOADED flag is clear, and the next open will issue wd_get_params() command. But to wake up the drive a reset is required, and wd_get_params() doens't issue a reset on timeout, so there's no way to wake up the disk. Add a retry after reset to wd_get_params(). Tested by Hauke Fath; fixes PR kern/49457 To generate a diff of this commit: cvs rdiff -u -r1.446 -r1.447 src/sys/dev/ata/wd.c cvs rdiff -u -r1.48 -r1.49 src/sys/dev/ata/wdvar.h 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/wd.c diff -u src/sys/dev/ata/wd.c:1.446 src/sys/dev/ata/wd.c:1.447 --- src/sys/dev/ata/wd.c:1.446 Tue Mar 19 16:56:29 2019 +++ src/sys/dev/ata/wd.c Fri Apr 5 18:23:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.446 2019/03/19 16:56:29 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.447 2019/04/05 18:23:45 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.446 2019/03/19 16:56:29 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.447 2019/04/05 18:23:45 bouyer Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -1638,11 +1638,20 @@ wd_set_geometry(struct wd_softc *wd) int wd_get_params(struct wd_softc *wd, uint8_t flags, struct ataparams *params) { + int retry = 0; +again: switch (wd->atabus->ata_get_params(wd->drvp, flags, params)) { case CMD_AGAIN: return 1; case CMD_ERR: + if (retry == 0) { + retry++; + (*wd->atabus->ata_reset_drive)(wd->drvp, + flags | AT_RST_NOCMD, NULL); + goto again; + } + if (wd->drvp->drive_type != ATA_DRIVET_OLD) return 1; /* @@ -2227,6 +2236,7 @@ wddebug(void) atachannel_debug(wd->drvp->chnl_softc); } + wd->sc_flags &= ~WDF_DIRTY; return 0; } #endif /* ATADEBUG */ Index: src/sys/dev/ata/wdvar.h diff -u src/sys/dev/ata/wdvar.h:1.48 src/sys/dev/ata/wdvar.h:1.49 --- src/sys/dev/ata/wdvar.h:1.48 Tue Mar 19 06:51:05 2019 +++ src/sys/dev/ata/wdvar.h Fri Apr 5 18:23:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wdvar.h,v 1.48 2019/03/19 06:51:05 mlelstv Exp $ */ +/* $NetBSD: wdvar.h,v 1.49 2019/04/05 18:23:45 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -53,6 +53,7 @@ struct wd_softc { #define WDF_WAIT 0x020 /* waiting for resources */ #define WDF_LBA 0x040 /* using LBA mode */ #define WDF_LBA48 0x100 /* using 48-bit LBA mode */ +#define WDF_DIRTY 0x200 /* disk cache dirty */ #define WDF_OPEN 0x400 /* device is open */ uint64_t sc_capacity; /* full capacity of the device */ uint64_t sc_capacity512; /* ... in DEV_BSIZE blocks */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Tue Mar 19 16:56:29 UTC 2019 Modified Files: src/sys/dev/ata: wd.c Log Message: The NCQ support added a private request queue to the wd driver. This makes the regular buffer queue ineffective, it also allowed to queue an unlimited number of requests. Fix this by limiting the number of requests queued to the driver to the possible number of concurrent NCQ transactions. To generate a diff of this commit: cvs rdiff -u -r1.445 -r1.446 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.445 src/sys/dev/ata/wd.c:1.446 --- src/sys/dev/ata/wd.c:1.445 Tue Mar 19 06:51:05 2019 +++ src/sys/dev/ata/wd.c Tue Mar 19 16:56:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.445 2019/03/19 06:51:05 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.446 2019/03/19 16:56:29 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.445 2019/03/19 06:51:05 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.446 2019/03/19 16:56:29 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -321,6 +321,7 @@ wdattach(device_t parent, device_t self, SLIST_INIT(&wd->sc_bslist); #endif wd->atabus = adev->adev_bustype; + wd->inflight = 0; wd->drvp = adev->adev_drv_data; wd->drvp->drv_openings = 1; @@ -729,6 +730,7 @@ wdstart1(struct wd_softc *wd, struct buf xfer->c_bio.flags |= ATA_FUA; } + wd->inflight++; switch (wd->atabus->ata_bio(wd->drvp, xfer)) { case ATACMD_TRY_AGAIN: panic("wdstart1: try again"); @@ -749,10 +751,25 @@ wd_diskstart(device_t dev, struct buf *b struct dk_softc *dksc = &wd->sc_dksc; #endif struct ata_xfer *xfer; + struct ata_channel *chp; + unsigned openings; mutex_enter(&wd->sc_lock); - xfer = ata_get_xfer(wd->drvp->chnl_softc, false); + chp = wd->drvp->chnl_softc; + + ata_channel_lock(chp); + openings = ata_queue_openings(chp); + ata_channel_unlock(chp); + + openings = uimin(openings, wd->drvp->drv_openings); + + if (wd->inflight >= openings) { + mutex_exit(&wd->sc_lock); + return EAGAIN; + } + + xfer = ata_get_xfer(chp, false); if (xfer == NULL) { ATADEBUG_PRINT(("wd_diskstart %s no xfer\n", dksc->sc_xname), DEBUG_XFERS); @@ -952,7 +969,9 @@ noerror: if ((xfer->c_bio.flags & ATA_CO ata_free_xfer(wd->drvp->chnl_softc, xfer); + wd->inflight--; dk_done(dksc, bp); + dk_start(dksc, NULL); } static void
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Tue Mar 19 06:51:05 UTC 2019 Modified Files: src/sys/dev/ata: wd.c wdvar.h Log Message: Set disk model name as disk type. The information can be queried through drvctl(4). To generate a diff of this commit: cvs rdiff -u -r1.444 -r1.445 src/sys/dev/ata/wd.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/ata/wdvar.h 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/wd.c diff -u src/sys/dev/ata/wd.c:1.444 src/sys/dev/ata/wd.c:1.445 --- src/sys/dev/ata/wd.c:1.444 Tue Mar 19 06:47:12 2019 +++ src/sys/dev/ata/wd.c Tue Mar 19 06:51:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.444 2019/03/19 06:47:12 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.445 2019/03/19 06:51:05 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.444 2019/03/19 06:47:12 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.445 2019/03/19 06:51:05 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -309,7 +309,7 @@ wdattach(device_t parent, device_t self, struct dk_softc *dksc = &wd->sc_dksc; struct ata_device *adev= aux; int i, blank; - char tbuf[41], pbuf[9], c, *p, *q; + char tbuf[41],pbuf[9], c, *p, *q; const struct wd_quirk *wdq; int dtype = DKTYPE_UNKNOWN; @@ -359,7 +359,8 @@ wdattach(device_t parent, device_t self, } *q++ = '\0'; - aprint_normal_dev(self, "<%s>\n", tbuf); + wd->sc_typename = kmem_asprintf("%s", tbuf); + aprint_normal_dev(self, "<%s>\n", wd->sc_typename); wdq = wd_lookup_quirks(tbuf); if (wdq != NULL) @@ -555,6 +556,10 @@ wddetach(device_t self, int flags) } wd->sc_bscount = 0; #endif + if (wd->sc_typename != NULL) { + kmem_free(wd->sc_typename, strlen(wd->sc_typename) + 1); + wd->sc_typename = NULL; + } pmf_device_deregister(self); @@ -1608,7 +1613,7 @@ wd_set_geometry(struct wd_softc *wd) if ((wd->sc_flags & WDF_LBA) == 0) dg->dg_ncylinders = wd->sc_params.atap_cylinders; - disk_set_info(dksc->sc_dev, &dksc->sc_dkdev, NULL); + disk_set_info(dksc->sc_dev, &dksc->sc_dkdev, wd->sc_typename); } int Index: src/sys/dev/ata/wdvar.h diff -u src/sys/dev/ata/wdvar.h:1.47 src/sys/dev/ata/wdvar.h:1.48 --- src/sys/dev/ata/wdvar.h:1.47 Mon Oct 22 20:13:47 2018 +++ src/sys/dev/ata/wdvar.h Tue Mar 19 06:51:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wdvar.h,v 1.47 2018/10/22 20:13:47 jdolecek Exp $ */ +/* $NetBSD: wdvar.h,v 1.48 2019/03/19 06:51:05 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -86,6 +86,8 @@ struct wd_softc { int drv_chaos_freq; /* frequency of simulated bio errors */ int drv_chaos_cnt; /* count of processed bio read xfers */ #endif + unsigned inflight; + char *sc_typename; }; #endif /* _DEV_ATA_WDVAR_H_ */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Tue Mar 19 06:47:12 UTC 2019 Modified Files: src/sys/dev/ata: wd.c Log Message: Move standby on detach after wedges deletion in case wedges trigger I/O on the parent disk. Add debug messages. To generate a diff of this commit: cvs rdiff -u -r1.443 -r1.444 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.443 src/sys/dev/ata/wd.c:1.444 --- src/sys/dev/ata/wd.c:1.443 Wed Oct 24 19:46:44 2018 +++ src/sys/dev/ata/wd.c Tue Mar 19 06:47:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.443 2018/10/24 19:46:44 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.444 2019/03/19 06:47:12 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.443 2018/10/24 19:46:44 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.444 2019/03/19 06:47:12 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -534,12 +534,12 @@ wddetach(device_t self, int flags) bufq_free(dksc->sc_bufq); - if (flags & DETACH_POWEROFF) - wd_standby(wd, AT_POLL); - /* Delete all of our wedges. */ dkwedge_delall(&dksc->sc_dkdev); + if (flags & DETACH_POWEROFF) + wd_standby(wd, AT_POLL); + /* Detach from the disk list. */ disk_detach(&dksc->sc_dkdev); disk_destroy(&dksc->sc_dkdev); @@ -1729,6 +1729,7 @@ wd_standby(struct wd_softc *wd, int flag struct ata_xfer *xfer; int error; + aprint_debug_dev(dksc->sc_dev, "standby immediate\n"); xfer = ata_get_xfer(wd->drvp->chnl_softc, true); xfer->c_ata_c.r_command = WDCC_STANDBY_IMMED; @@ -1745,6 +1746,8 @@ wd_standby(struct wd_softc *wd, int flag if (xfer->c_ata_c.flags & AT_ERROR) { if (xfer->c_ata_c.r_error == WDCE_ABRT) { /* command not supported */ + aprint_debug_dev(dksc->sc_dev, +"standby immediate not supported\n"); error = ENODEV; goto out; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Tue Dec 11 23:06:30 UTC 2018 Modified Files: src/sys/dev/ata: ata.c Log Message: in atabus_detach(), shutdown the channel thread only after all the children successfully detach; this is especially important for atapibus, which needs the thread to execute commands fixes hang on poweroff with root on ATAPI cd(4), reported by Christoph Badura To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sys/dev/ata/ata.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.146 src/sys/dev/ata/ata.c:1.147 --- src/sys/dev/ata/ata.c:1.146 Mon Nov 12 18:51:01 2018 +++ src/sys/dev/ata/ata.c Tue Dec 11 23:06:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.146 2018/11/12 18:51:01 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.147 2018/12/11 23:06:30 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.146 2018/11/12 18:51:01 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.147 2018/12/11 23:06:30 jdolecek Exp $"); #include "opt_ata.h" @@ -630,15 +630,6 @@ atabus_detach(device_t self, int flags) device_t dev = NULL; int i, error = 0; - /* Shutdown the channel. */ - ata_channel_lock(chp); - chp->ch_flags |= ATACH_SHUTDOWN; - while (chp->ch_thread != NULL) { - cv_signal(&chp->ch_thr_idle); - cv_wait(&chp->ch_thr_idle, &chp->ch_lock); - } - ata_channel_unlock(chp); - /* * Detach atapibus and its children. */ @@ -673,6 +664,16 @@ atabus_detach(device_t self, int flags) KASSERT(chp->ch_drive[i].drive_type == 0); } } + + /* Shutdown the channel. */ + ata_channel_lock(chp); + chp->ch_flags |= ATACH_SHUTDOWN; + while (chp->ch_thread != NULL) { + cv_signal(&chp->ch_thr_idle); + cv_wait(&chp->ch_thr_idle, &chp->ch_lock); + } + ata_channel_unlock(chp); + atabus_free_drives(chp); out:
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Nov 7 17:05:54 UTC 2018 Modified Files: src/sys/dev/ata: ata_subr.c Log Message: don't touch the queue structure in ata_queue_active() if atabus is already detached from the channel fixes panic on null pointer derefence during shutdown reported privately by Launey Thomas To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/ata_subr.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_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.7 src/sys/dev/ata/ata_subr.c:1.8 --- src/sys/dev/ata/ata_subr.c:1.7 Mon Oct 22 20:13:47 2018 +++ src/sys/dev/ata/ata_subr.c Wed Nov 7 17:05:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.7 2018/10/22 20:13:47 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.8 2018/11/07 17:05:54 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.7 2018/10/22 20:13:47 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.8 2018/11/07 17:05:54 jdolecek Exp $"); #include "opt_ata.h" @@ -364,6 +364,9 @@ ata_queue_active(struct ata_channel *chp { struct ata_queue *chq = chp->ch_queue; + if (chp->ch_flags & ATACH_DETACHED) + return 0; + return chq->active_xfers_used; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 24 20:25:52 UTC 2018 Modified Files: src/sys/dev/ata: ata.c Log Message: ata_kill_active() needs to drop channel drop before calling kill_xfer() hook, otherwise code tries to lock against itself when deactivating the xfer To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/dev/ata/ata.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.144 src/sys/dev/ata/ata.c:1.145 --- src/sys/dev/ata/ata.c:1.144 Wed Oct 24 20:01:13 2018 +++ src/sys/dev/ata/ata.c Wed Oct 24 20:25:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.144 2018/10/24 20:01:13 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.145 2018/10/24 20:25:52 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.144 2018/10/24 20:01:13 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.145 2018/10/24 20:25:52 jdolecek Exp $"); #include "opt_ata.h" @@ -1445,7 +1445,9 @@ ata_kill_active(struct ata_channel *chp, KASSERT(mutex_owned(&chp->ch_lock)); TAILQ_FOREACH_SAFE(xfer, &chq->active_xfers, c_activechain, xfernext) { + ata_channel_unlock(chp); xfer->ops->c_kill_xfer(xfer->c_chp, xfer, reason); + ata_channel_lock(chp); } }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 24 20:03:07 UTC 2018 Removed Files: src/sys/dev/ata: TODO.ncq Log Message: remove TODO.ncq; the FIS note was added to atastart(), and the note about dump to unopened wd(4) device was attached to PR kern/16789, and nothing else remains To generate a diff of this commit: cvs rdiff -u -r1.12 -r0 src/sys/dev/ata/TODO.ncq Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 24 20:01:13 UTC 2018 Modified Files: src/sys/dev/ata: ata.c Log Message: add further note about FIS-based switching to atastart() To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/sys/dev/ata/ata.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.143 src/sys/dev/ata/ata.c:1.144 --- src/sys/dev/ata/ata.c:1.143 Wed Oct 24 19:38:00 2018 +++ src/sys/dev/ata/ata.c Wed Oct 24 20:01:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.143 2018/10/24 19:38:00 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.144 2018/10/24 20:01:13 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.143 2018/10/24 19:38:00 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.144 2018/10/24 20:01:13 jdolecek Exp $"); #include "opt_ata.h" @@ -1053,6 +1053,14 @@ ata_exec_xfer(struct ata_channel *chp, s * are shared. * * MUST BE CALLED AT splbio()! + * + * XXX FIS-based switching with PMP + * Currently atastart() never schedules concurrent NCQ transfers to more than + * one drive, even when channel has several SATA drives attached via PMP. + * To support concurrent transfers to different drives with PMP, it would be + * necessary to implement FIS-based switching support in controller driver, + * and then adjust error handling and recovery to stop assuming at most + * one active drive. */ void atastart(struct ata_channel *chp)
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 24 19:46:44 UTC 2018 Modified Files: src/sys/dev/ata: TODO.ncq wd.c Log Message: move the comment (and expand) about NCQ TRIM to wd_trim() To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.442 -r1.443 src/sys/dev/ata/wd.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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.11 src/sys/dev/ata/TODO.ncq:1.12 --- src/sys/dev/ata/TODO.ncq:1.11 Wed Oct 24 19:38:00 2018 +++ src/sys/dev/ata/TODO.ncq Wed Oct 24 19:46:44 2018 @@ -12,5 +12,3 @@ set - not easy to fix, open needs to read disklabel and all this mechanics is too much for emergency crash dump code path - old bug - kern/16789 - -add support for the NCQ TRIM if supported by device? Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.442 src/sys/dev/ata/wd.c:1.443 --- src/sys/dev/ata/wd.c:1.442 Mon Oct 22 20:13:47 2018 +++ src/sys/dev/ata/wd.c Wed Oct 24 19:46:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.442 2018/10/22 20:13:47 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.443 2018/10/24 19:46:44 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.442 2018/10/22 20:13:47 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.443 2018/10/24 19:46:44 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -1819,6 +1819,9 @@ out_xfer: return error; } +/* + * Execute TRIM command, assumes sleep context. + */ static int wd_trim(struct wd_softc *wd, daddr_t bno, long size) { @@ -1839,6 +1842,14 @@ wd_trim(struct wd_softc *wd, daddr_t bno req[6] = size & 0xff; req[7] = (size >> 8) & 0xff; + /* + * XXX We could possibly use NCQ TRIM, which supports executing + * this command concurrently. It would need some investigation, some + * early or not so early disk firmware caused data loss with NCQ TRIM. + * atastart() et.al would need to be adjusted to allow and support + * running several non-I/O ATA commands in parallel. + */ + xfer->c_ata_c.r_command = ATA_DATA_SET_MANAGEMENT; xfer->c_ata_c.r_count = 1; xfer->c_ata_c.r_features = ATA_SUPPORT_DSM_TRIM;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 24 06:53:26 UTC 2018 Modified Files: src/sys/dev/ata: files.ata Log Message: only include ata_recovery.c with atabus (same as ata.c which provides ata_thread_run() used here) To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ata/files.ata 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/files.ata diff -u src/sys/dev/ata/files.ata:1.28 src/sys/dev/ata/files.ata:1.29 --- src/sys/dev/ata/files.ata:1.28 Mon Oct 22 20:13:47 2018 +++ src/sys/dev/ata/files.ata Wed Oct 24 06:53:26 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.ata,v 1.28 2018/10/22 20:13:47 jdolecek Exp $ +# $NetBSD: files.ata,v 1.29 2018/10/24 06:53:26 jdolecek Exp $ # # Config file and device description for machine-independent devices # which attach to ATA busses. Included by ports that need it. Ports @@ -16,7 +16,7 @@ defflag opt_wd.h WD_CHAOS_MONKEY file dev/ata/ata.c (ata_hl | atapi) & atabus file dev/ata/ata_subr.c (ata_hl | atapi) -file dev/ata/ata_recovery.c (ata_hl | atapi) +file dev/ata/ata_recovery.c (ata_hl | atapi) & atabus # ATA RAID configuration support defpseudodev ataraid {[vendtype = -1], [unit = -1]}
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Tue Oct 23 22:05:01 UTC 2018 Modified Files: src/sys/dev/ata: TODO.ncq ld_ataraid.c Log Message: add support for DIOCCACHESYNC (!), and DIOCGCACHE; code adapted from ccd(4) tested with Intel ATA Raid To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.47 -r1.48 src/sys/dev/ata/ld_ataraid.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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.9 src/sys/dev/ata/TODO.ncq:1.10 --- src/sys/dev/ata/TODO.ncq:1.9 Mon Oct 22 21:25:23 2018 +++ src/sys/dev/ata/TODO.ncq Tue Oct 23 22:05:01 2018 @@ -15,4 +15,5 @@ set add support for the NCQ TRIM if supported by device? -implement DIOCGCACHE/DIOCCACHESYNC for ld@ataraid? just passthrough, like ccd +ahcisata(4)/siisata(4) - enable detach on shutdown, and fix the issue +with atabus being detached several times Index: src/sys/dev/ata/ld_ataraid.c diff -u src/sys/dev/ata/ld_ataraid.c:1.47 src/sys/dev/ata/ld_ataraid.c:1.48 --- src/sys/dev/ata/ld_ataraid.c:1.47 Mon Oct 22 19:36:28 2018 +++ src/sys/dev/ata/ld_ataraid.c Tue Oct 23 22:05:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "bio.h" @@ -102,6 +102,8 @@ static int ld_ataraid_match(device_t, cf static void ld_ataraid_attach(device_t, device_t, void *); static int ld_ataraid_dump(struct ld_softc *, void *, int, int); +static int ld_ataraid_ioctl(struct ld_softc *, u_long, void *, int32_t, +bool); static int cbufpool_ctor(void *, void *, int); static voidcbufpool_dtor(void *, void *); @@ -170,6 +172,7 @@ ld_ataraid_attach(device_t parent, devic ld->sc_secsize = 512;/* XXX */ ld->sc_maxqueuecnt = 128; /* XXX */ ld->sc_dump = ld_ataraid_dump; + ld->sc_ioctl = ld_ataraid_ioctl; switch (aai->aai_level) { case AAI_L_SPAN: @@ -715,6 +718,72 @@ ld_ataraid_biodisk(struct ld_ataraid_sof } #endif /* NBIO > 0 */ +static int +ld_ataraid_ioctl(struct ld_softc *ld, u_long cmd, void *addr, int32_t flag, +bool poll) +{ + struct ld_ataraid_softc *sc = (void *)ld; + int error, i, j; + kauth_cred_t uc; + + uc = kauth_cred_get(); + + switch (cmd) { + case DIOCGCACHE: + { + int dkcache = 0; + + /* + * We pass this call down to all components and report + * intersection of the flags returned by the components. + * If any errors out, we return error. ATA RAID components + * can only change via BIOS, device feature flags will remain + * static. RCE/WCE can change if set directly on underlying + * device. + */ + for (error = 0, i = 0; i < sc->sc_aai->aai_ndisks; i++) { + KASSERT(sc->sc_vnodes[i] != NULL); + + error = VOP_IOCTL(sc->sc_vnodes[i], cmd, &j, + flag, uc); + if (error) +break; + + if (i == 0) +dkcache = j; + else +dkcache = DKCACHE_COMBINE(dkcache, j); + } + + *((int *)addr) = dkcache; + break; + } + + case DIOCCACHESYNC: + { + /* + * We pass this call down to all components and report + * the first error we encounter. + */ + for (error = 0, i = 0; i < sc->sc_aai->aai_ndisks; i++) { + KASSERT(sc->sc_vnodes[i] != NULL); + + j = VOP_IOCTL(sc->sc_vnodes[i], cmd, addr, + flag, uc); + if (j != 0 && error == 0) +error = j; + } + break; + } + + default: + error = EPASSTHROUGH; + break; + } + + return error; +} + MODULE(MODULE_CLASS_DRIVER, ld_ataraid, "ld,ataraid"); #ifdef _MODULE
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Oct 22 21:25:23 UTC 2018 Modified Files: src/sys/dev/ata: TODO.ncq Log Message: remove the note for dump, moral equivalent is done and biodone() most certainly should not be done To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/TODO.ncq 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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.8 src/sys/dev/ata/TODO.ncq:1.9 --- src/sys/dev/ata/TODO.ncq:1.8 Mon Oct 22 21:24:18 2018 +++ src/sys/dev/ata/TODO.ncq Mon Oct 22 21:25:23 2018 @@ -1,9 +1,5 @@ Other random notes (do outside the NCQ branch): - -do biodone() in wddone() starting the dump to not leak bufs when dumping from -active system? make sure to not trigger atastart() -- call ata_kill_active() + ata_kill_pending() when dumping - implement support for PM FIS-based switching, remove restriction in atastart() for hw which supports it, adjust error handling in controller drivers to handle xfers for several different drives
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Oct 22 21:24:18 UTC 2018 Modified Files: src/sys/dev/ata: TODO.ncq Log Message: remove the wd* at umass? entry (comment moved to umass_isdata.c and manpage) remove MSI for ahcisata(4), siisata(4) - these were done To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/TODO.ncq 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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.7 src/sys/dev/ata/TODO.ncq:1.8 --- src/sys/dev/ata/TODO.ncq:1.7 Mon Oct 22 20:30:52 2018 +++ src/sys/dev/ata/TODO.ncq Mon Oct 22 21:24:18 2018 @@ -1,7 +1,3 @@ -Bugs - -test wd* at umass?, confirm the ata_channel kludge works - Other random notes (do outside the NCQ branch): - do biodone() in wddone() starting the dump to not leak bufs when dumping from @@ -24,5 +20,3 @@ set add support for the NCQ TRIM if supported by device? implement DIOCGCACHE/DIOCCACHESYNC for ld@ataraid? just passthrough, like ccd - -MSI/MSI-X support for ahcisata(4), siisata(4)
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Oct 22 19:38:06 UTC 2018 Modified Files: src/sys/dev/ata: ata_raid.c ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c ata_raid_nvidia.c ata_raid_promise.c ata_raid_via.c Log Message: convert from malloc(9) to kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/ata/ata_raid.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_raid_adaptec.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/ata_raid_intel.c \ src/sys/dev/ata/ata_raid_via.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ata/ata_raid_jmicron.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ata_raid_nvidia.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ata/ata_raid_promise.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_raid.c diff -u src/sys/dev/ata/ata_raid.c:1.40 src/sys/dev/ata/ata_raid.c:1.41 --- src/sys/dev/ata/ata_raid.c:1.40 Fri Jun 22 09:06:04 2018 +++ src/sys/dev/ata/ata_raid.c Mon Oct 22 19:38:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $ */ +/* $NetBSD: ata_raid.c,v 1.41 2018/10/22 19:38:06 jdolecek Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.41 2018/10/22 19:38:06 jdolecek Exp $"); #include #include @@ -50,7 +50,6 @@ __KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v #include #include #include -#include #include #include #include @@ -274,7 +273,7 @@ ata_raid_get_array_info(u_int type, u_in } /* Need to allocate a new one. */ - aai = malloc(sizeof(*aai), M_DEVBUF, M_WAITOK | M_ZERO); + aai = kmem_zalloc(sizeof(*aai), KM_SLEEP); aai->aai_type = type; aai->aai_arrayno = arrayno; aai->aai_curdisk = 0; Index: src/sys/dev/ata/ata_raid_adaptec.c diff -u src/sys/dev/ata/ata_raid_adaptec.c:1.10 src/sys/dev/ata/ata_raid_adaptec.c:1.11 --- src/sys/dev/ata/ata_raid_adaptec.c:1.10 Wed Nov 1 19:34:46 2017 +++ src/sys/dev/ata/ata_raid_adaptec.c Mon Oct 22 19:38:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $ */ +/* $NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $"); #include #include @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: ata_raid_ada #include #include #include -#include #include #include @@ -77,7 +76,7 @@ ata_raid_read_config_adaptec(struct wd_s struct ataraid_array_info *aai; struct ataraid_disk_info *adi; - info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK); + info = kmem_zalloc(sizeof(*info), KM_SLEEP); bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0); @@ -189,6 +188,6 @@ ata_raid_read_config_adaptec(struct wd_s error = 0; out: - free(info, M_DEVBUF); + kmem_free(info, sizeof(*info)); return (error); } Index: src/sys/dev/ata/ata_raid_intel.c diff -u src/sys/dev/ata/ata_raid_intel.c:1.8 src/sys/dev/ata/ata_raid_intel.c:1.9 --- src/sys/dev/ata/ata_raid_intel.c:1.8 Wed Nov 1 19:34:46 2017 +++ src/sys/dev/ata/ata_raid_intel.c Mon Oct 22 19:38:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $ */ +/* $NetBSD: ata_raid_intel.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $ */ /*- * Copyright (c) 2000-2008 Søren Schmidt @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $"); #include #include @@ -43,7 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: ata_raid_int #include #include #include -#include #include #include @@ -138,6 +137,7 @@ ata_raid_read_config_intel(struct wd_sof { struct dk_softc *dksc = &sc->sc_dksc; struct intel_raid_conf *info; + const size_t infosz = 1536; struct intel_raid_mapping *map; struct ataraid_array_info *aai; struct ataraid_disk_info *adi; @@ -148,7 +148,7 @@ ata_raid_read_config_intel(struct wd_sof dev_t dev; int volumeid, diskidx; - info = malloc(1536, M_DEVBUF, M_WAITOK|M_ZERO); + info = kmem_zalloc(infosz, KM_SLEEP); bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0); @@ -298,7 +298,7 @@ findvol: } out: - free(info, M_DEVBUF); + kmem_free(info, infosz); return error; } Index: src/sys/dev/ata/ata_raid_via.c diff -u src/sys/dev/ata/ata_raid_via.c:1.8 src/sys/dev/ata/ata_raid_via.c:1.9 --- src/sys/dev/ata/ata_raid_via.c:1.8 Wed Nov 1 19:34:46 2017 +++ src/sys/dev/ata/ata_raid_via.c Mon Oct 22 19:38:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Oct 22 19:36:28 UTC 2018 Modified Files: src/sys/dev/ata: ld_ataraid.c Log Message: no need for here To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ata/ld_ataraid.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/ld_ataraid.c diff -u src/sys/dev/ata/ld_ataraid.c:1.46 src/sys/dev/ata/ld_ataraid.c:1.47 --- src/sys/dev/ata/ld_ataraid.c:1.46 Mon Sep 3 16:29:30 2018 +++ src/sys/dev/ata/ld_ataraid.c Mon Oct 22 19:36:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.46 2018/09/03 16:29:30 riastradh Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.46 2018/09/03 16:29:30 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "bio.h" @@ -64,7 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c #include #include #include -#include #include #include #include
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri Aug 31 18:44:04 UTC 2018 Modified Files: src/sys/dev/ata: TODO.ncq Log Message: one less To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/TODO.ncq 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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.3 src/sys/dev/ata/TODO.ncq:1.4 --- src/sys/dev/ata/TODO.ncq:1.3 Wed Nov 1 21:27:22 2017 +++ src/sys/dev/ata/TODO.ncq Fri Aug 31 18:44:04 2018 @@ -32,8 +32,7 @@ implement DIOCGCACHE/DIOCCACHESYNC for l MSI/MSI-X support for AHCI and mvsata(4) -mvsata - constify mvsata_pci_products and move pci-specific code to -the pci attach code +mvsata - move pci-specific code to the pci attach code mvsata(4) 64-bit DMA - at least with AHA1430SA does not really work, crash in mvsata_intr() on boot
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri Aug 10 22:43:22 UTC 2018 Modified Files: src/sys/dev/ata: ata_subr.c atavar.h wd.c Log Message: fix race in wd_lastclose() on systems with two ide disks on same channel, which happened when one disk had pending I/O while the other disk executed the final disk flush - need to restart bufq processing once xfer is freed in this case it could happen e.g. on boot when system executes fsck on different partitions on the two drives in parallell and hence open and closes the disk devices repeatedly add KASSERT() for empty bufq on wd_lastclose(), and fix similar issue also on suspend/standby path this was introduced by the NCQ merge and not dksubr - before the merge each drive had their own xfer, so they could not block each other fixes PR kern/52783 by Onno van der Linden; many thanks for extensive help with tracking this down To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.98 -r1.99 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.440 -r1.441 src/sys/dev/ata/wd.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_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.5 src/sys/dev/ata/ata_subr.c:1.6 --- src/sys/dev/ata/ata_subr.c:1.5 Mon Aug 6 20:07:05 2018 +++ src/sys/dev/ata/ata_subr.c Fri Aug 10 22:43:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.5 2018/08/06 20:07:05 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.6 2018/08/10 22:43:22 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.5 2018/08/06 20:07:05 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6 2018/08/10 22:43:22 jdolecek Exp $"); #include "opt_ata.h" @@ -377,7 +377,7 @@ out: * released. */ void -ata_channel_start(struct ata_channel *chp, int drive) +ata_channel_start(struct ata_channel *chp, int drive, bool start_self) { int i, s; struct ata_drive_datas *drvp; @@ -413,7 +413,8 @@ ata_channel_start(struct ata_channel *ch } /* Now try to kick off xfers on the current drive */ - ATA_DRIVE_START(chp, drive); + if (start_self) + ATA_DRIVE_START(chp, drive); splx(s); #undef ATA_DRIVE_START Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.98 src/sys/dev/ata/atavar.h:1.99 --- src/sys/dev/ata/atavar.h:1.98 Mon Aug 6 20:07:05 2018 +++ src/sys/dev/ata/atavar.h Fri Aug 10 22:43:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.98 2018/08/06 20:07:05 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99 2018/08/10 22:43:22 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -538,7 +538,7 @@ void ata_kill_active(struct ata_channel void ata_reset_channel(struct ata_channel *, int); void ata_channel_freeze(struct ata_channel *); void ata_channel_thaw(struct ata_channel *); -void ata_channel_start(struct ata_channel *, int); +void ata_channel_start(struct ata_channel *, int, bool); void ata_channel_lock(struct ata_channel *); void ata_channel_unlock(struct ata_channel *); void ata_channel_lock_owned(struct ata_channel *); Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.440 src/sys/dev/ata/wd.c:1.441 --- src/sys/dev/ata/wd.c:1.440 Mon Aug 6 20:07:05 2018 +++ src/sys/dev/ata/wd.c Fri Aug 10 22:43:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.440 2018/08/06 20:07:05 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441 2018/08/10 22:43:22 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.440 2018/08/06 20:07:05 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441 2018/08/10 22:43:22 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -917,7 +917,7 @@ noerror: if ((xfer->c_bio.flags & ATA_CO ata_free_xfer(wd->drvp->chnl_softc, xfer); dk_done(dksc, bp); - ata_channel_start(wd->drvp->chnl_softc, wd->drvp->drive); + ata_channel_start(wd->drvp->chnl_softc, wd->drvp->drive, true); } static void @@ -1072,6 +1072,8 @@ wd_lastclose(device_t self) { struct wd_softc *wd = device_private(self); + KASSERTMSG(bufq_peek(wd->sc_dksc.sc_bufq) == NULL, "bufq not empty"); + wd_flushcache(wd, AT_WAIT, false); wd->atabus->ata_delref(wd->drvp); @@ -1667,7 +1669,7 @@ wd_setcache(struct wd_softc *wd, int bit out: ata_free_xfer(wd->drvp->chnl_softc, xfer); - ata_channel_start(wd->drvp->chnl_softc, wd->drvp->drive); + ata_channel_start(wd->drvp->chnl_softc, wd->drvp->drive, true); return error; } @@ -1711,12 +1713,18 @@ wd_standby(struct wd_softc *wd, int flag out: ata_free_xfer(wd->drvp->chnl_softc, xfer); - /* drive is supposed to go idle, do not call ata_channel_start() */ + + /* + * Drive is supposed to go idle, start only other drives. + * bufq might be actually already freed at this moment.
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Aug 6 20:07:05 UTC 2018 Modified Files: src/sys/dev/ata: ata_subr.c atavar.h wd.c Log Message: add wddebug() which dumps some status for attached disks; indended for debugging of PR kern/52783 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.97 -r1.98 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.439 -r1.440 src/sys/dev/ata/wd.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_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.4 src/sys/dev/ata/ata_subr.c:1.5 --- src/sys/dev/ata/ata_subr.c:1.4 Fri Oct 20 07:06:07 2017 +++ src/sys/dev/ata/ata_subr.c Mon Aug 6 20:07:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.4 2017/10/20 07:06:07 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.5 2018/08/06 20:07:05 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.4 2017/10/20 07:06:07 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.5 2018/08/06 20:07:05 jdolecek Exp $"); #include "opt_ata.h" @@ -436,3 +436,31 @@ ata_channel_lock_owned(struct ata_channe { KASSERT(mutex_owned(&chp->ch_lock)); } + +#ifdef ATADEBUG +void +atachannel_debug(struct ata_channel *chp) +{ + struct ata_queue *chq = chp->ch_queue; + + printf(" ch %s flags 0x%x ndrives %d\n", + device_xname(chp->atabus), chp->ch_flags, chp->ch_ndrives); + printf(" que: flags 0x%x avail 0x%x used 0x%x\n", + chq->queue_flags, chq->queue_xfers_avail, chq->active_xfers_used); + printf("act %d freez %d open %u\n", + chq->queue_active, chq->queue_freeze, chq->queue_openings); + +#if 0 + printf(" xfers:\n"); + for(int i=0; i < chq->queue_openings; i++) { + struct ata_xfer *xfer = &chq->queue_xfers[i]; + + printf("#%d sl %d drv %d retr %d fl %x", + i, xfer->c_slot, xfer->c_drive, xfer->c_retries, + xfer->c_flags); + printf(" data %p bcount %d skip %d\n", + xfer->c_databuf, xfer->c_bcount, xfer->c_skip); + } +#endif +} +#endif /* ATADEBUG */ Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.97 src/sys/dev/ata/atavar.h:1.98 --- src/sys/dev/ata/atavar.h:1.97 Fri Jun 1 18:13:30 2018 +++ src/sys/dev/ata/atavar.h Mon Aug 6 20:07:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.97 2018/06/01 18:13:30 macallan Exp $ */ +/* $NetBSD: atavar.h,v 1.98 2018/08/06 20:07:05 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -575,6 +575,10 @@ bool ata_waitdrain_xfer_check(struct ata void atacmd_toncq(struct ata_xfer *, uint8_t *, uint16_t *, uint16_t *, uint8_t *); +#ifdef ATADEBUG +void atachannel_debug(struct ata_channel *); +#endif + #endif /* _KERNEL */ #endif /* _DEV_ATA_ATAVAR_H_ */ Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.439 src/sys/dev/ata/wd.c:1.440 --- src/sys/dev/ata/wd.c:1.439 Sun Jun 3 18:38:35 2018 +++ src/sys/dev/ata/wd.c Mon Aug 6 20:07:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.440 2018/08/06 20:07:05 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.440 2018/08/06 20:07:05 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -2162,3 +2162,26 @@ wd_sysctl_detach(struct wd_softc *wd) sysctl_teardown(&wd->nodelog); } +#ifdef ATADEBUG +int wddebug(void); + +int +wddebug(void) +{ + struct wd_softc *wd; + struct dk_softc *dksc; + int unit; + + for (unit = 0; unit <= 3; unit++) { + wd = device_lookup_private(&wd_cd, unit); + if (wd == NULL) +continue; + dksc = &wd->sc_dksc; + printf("%s fl %x bufq %p:\n", + dksc->sc_xname, wd->sc_flags, bufq_peek(dksc->sc_bufq)); + + atachannel_debug(wd->drvp->chnl_softc); + } + return 0; +} +#endif /* ATADEBUG */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Jul 29 14:11:30 UTC 2018 Modified Files: src/sys/dev/ata: satapmp_subr.c satapmpvar.h Log Message: mark satapmp_rescan() static, it's not to be used outside satapmp_subr.c To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ata/satapmp_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/satapmpvar.h 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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.13 src/sys/dev/ata/satapmp_subr.c:1.14 --- src/sys/dev/ata/satapmp_subr.c:1.13 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/satapmp_subr.c Sun Jul 29 14:11:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.13 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.14 2018/07/29 14:11:30 jdolecek Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.13 2017/10/07 16:05:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.14 2018/07/29 14:11:30 jdolecek Exp $"); #include #include @@ -239,7 +239,7 @@ satapmp_reset_device_port(struct ata_cha return(sstatus & SStatus_DET_mask); } -void +static void __noinline satapmp_rescan(struct ata_channel *chp, struct ata_xfer *xfer) { int i; Index: src/sys/dev/ata/satapmpvar.h diff -u src/sys/dev/ata/satapmpvar.h:1.4 src/sys/dev/ata/satapmpvar.h:1.5 --- src/sys/dev/ata/satapmpvar.h:1.4 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/satapmpvar.h Sun Jul 29 14:11:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmpvar.h,v 1.4 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: satapmpvar.h,v 1.5 2018/07/29 14:11:30 jdolecek Exp $ */ /* @@ -29,7 +29,6 @@ #define _DEV_ATA_SATAPMPVAR_H_ void satapmp_attach(struct ata_channel *); -void satapmp_rescan(struct ata_channel *, struct ata_xfer *); #endif /* _DEV_ATA_SATAPMPVAR_H_ */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: pgoyette Date: Fri Jun 22 09:06:04 UTC 2018 Modified Files: src/sys/dev/ata: ata_raid.c Log Message: Call config_cfattach_attach() regardless of whether the module is being built as part of a kernel or as a external module. Addresses kern/53389 - thanks for the report! XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/ata/ata_raid.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_raid.c diff -u src/sys/dev/ata/ata_raid.c:1.39 src/sys/dev/ata/ata_raid.c:1.40 --- src/sys/dev/ata/ata_raid.c:1.39 Tue Sep 27 08:05:34 2016 +++ src/sys/dev/ata/ata_raid.c Fri Jun 22 09:06:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $ */ +/* $NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $"); #include #include @@ -338,26 +338,27 @@ ataraid_modcmd(modcmd_t cmd, void *arg) error = config_cfdriver_attach(&ataraid_cd); if (error) break; +#endif error = config_cfattach_attach(ataraid_cd.cd_name, &ataraid_ca); if (error) { +#ifdef _MODULE config_cfdriver_detach(&ataraid_cd); +#endif aprint_error("%s: unable to register cfattach for \n" "%s, error %d", __func__, ataraid_cd.cd_name, error); break; } -#endif break; case MODULE_CMD_FINI: -#ifdef _MODULE - error = config_cfattach_detach(ataraid_cd.cd_name, &ataraid_ca); if (error) { aprint_error("%s: failed to detach %s cfattach, " "error %d\n", __func__, ataraid_cd.cd_name, error); break; } +#ifdef _MODULE error = config_cfdriver_detach(&ataraid_cd); if (error) { (void)config_cfattach_attach(ataraid_cd.cd_name,
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Thu Jun 21 21:52:15 UTC 2018 Modified Files: src/sys/dev/ata: sata_subr.c satavar.h Log Message: split the port status reporting to new function sata_interpret_det() so it can be called separately from sata_reset_interface() do not treat PHY offline as an error, it's pretty normal when there is no device actually connected debugging aid for PR kern/52372 To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/ata/sata_subr.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/satavar.h 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/sata_subr.c diff -u src/sys/dev/ata/sata_subr.c:1.23 src/sys/dev/ata/sata_subr.c:1.24 --- src/sys/dev/ata/sata_subr.c:1.23 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/sata_subr.c Thu Jun 21 21:52:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sata_subr.c,v 1.23 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: sata_subr.c,v 1.24 2018/06/21 21:52:15 jdolecek Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ * Common functions for Serial ATA. */ #include -__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.23 2017/10/07 16:05:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.24 2018/06/21 21:52:15 jdolecek Exp $"); #include #include @@ -121,6 +121,14 @@ sata_reset_interface(struct ata_channel } } + sata_interpret_det(chp, sstatus); + + return (sstatus & SStatus_DET_mask); +} + +void +sata_interpret_det(struct ata_channel *chp, uint32_t sstatus) +{ switch (sstatus & SStatus_DET_mask) { case SStatus_DET_NODEV: /* No Device; be silent. */ @@ -133,7 +141,7 @@ sata_reset_interface(struct ata_channel break; case SStatus_DET_OFFLINE: - aprint_error("%s port %d: PHY offline\n", + aprint_normal("%s port %d: PHY offline\n", device_xname(chp->ch_atac->atac_dev), chp->ch_channel); break; @@ -147,7 +155,6 @@ sata_reset_interface(struct ata_channel device_xname(chp->ch_atac->atac_dev), chp->ch_channel, sstatus); } - return(sstatus & SStatus_DET_mask); } void Index: src/sys/dev/ata/satavar.h diff -u src/sys/dev/ata/satavar.h:1.9 src/sys/dev/ata/satavar.h:1.10 --- src/sys/dev/ata/satavar.h:1.9 Wed Apr 3 17:15:07 2013 +++ src/sys/dev/ata/satavar.h Thu Jun 21 21:52:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: satavar.h,v 1.9 2013/04/03 17:15:07 bouyer Exp $ */ +/* $NetBSD: satavar.h,v 1.10 2018/06/21 21:52:15 jdolecek Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -42,6 +42,7 @@ const char *sata_speed(uint32_t); uint32_t sata_reset_interface(struct ata_channel *, bus_space_tag_t, bus_space_handle_t, bus_space_handle_t, int); +void sata_interpret_det(struct ata_channel *, uint32_t); void sata_interpret_sig(struct ata_channel *, int, uint32_t); #endif /* _DEV_ATA_SATAVAR_H_ */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Jun 3 18:38:36 UTC 2018 Modified Files: src/sys/dev/ata: wd.c Log Message: take mutex around check for pending flush, as the code before dksubr conversion had, to avoid possible race on my system doesn't really change behaviour, besides the test runs being slightly faster (3x parallell pkgsrc archive extraction, up to 5% difference), thought that can just be noise done as part of investigation for PR kern/53183 by Sevan Janiyan To generate a diff of this commit: cvs rdiff -u -r1.438 -r1.439 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.438 src/sys/dev/ata/wd.c:1.439 --- src/sys/dev/ata/wd.c:1.438 Sun Jan 7 11:37:30 2018 +++ src/sys/dev/ata/wd.c Sun Jun 3 18:38:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -765,6 +765,8 @@ wdstart(device_t self) if (!device_is_active(dksc->sc_dev)) return; + mutex_enter(&wd->sc_lock); + /* * Do not queue any transfers until flush is finished, so that * once flush is pending, it will get handled as soon as xfer @@ -773,9 +775,12 @@ wdstart(device_t self) if (ISSET(wd->sc_flags, WDF_FLUSH_PEND)) { ATADEBUG_PRINT(("wdstart %s flush pend\n", dksc->sc_xname), DEBUG_XFERS); + mutex_exit(&wd->sc_lock); return; } + mutex_exit(&wd->sc_lock); + dk_start(dksc, NULL); }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: martin Date: Sun Jun 3 10:20:55 UTC 2018 Modified Files: src/sys/dev/ata: ld_ataraid.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ata/ld_ataraid.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/ld_ataraid.c diff -u src/sys/dev/ata/ld_ataraid.c:1.44 src/sys/dev/ata/ld_ataraid.c:1.45 --- src/sys/dev/ata/ld_ataraid.c:1.44 Tue Sep 27 08:05:34 2016 +++ src/sys/dev/ata/ld_ataraid.c Sun Jun 3 10:20:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.44 2016/09/27 08:05:34 pgoyette Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.45 2018/06/03 10:20:54 martin Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -42,12 +42,12 @@ * controllers we're dealing with (Promise, etc.) only support * configuration data on the component disks, with the BIOS supporting * booting from the RAID volumes. - * + * * bio(4) support was written by Juan Romero Pardines . */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.44 2016/09/27 08:05:34 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.45 2018/06/03 10:20:54 martin Exp $"); #if defined(_KERNEL_OPT) #include "bio.h" @@ -92,11 +92,11 @@ struct ld_ataraid_softc { void (*sc_iodone)(struct buf *); - pool_cache_t sc_cbufpool; + pool_cache_t sc_cbufpool; - SIMPLEQ_HEAD(, cbuf) sc_cbufq; + SIMPLEQ_HEAD(, cbuf) sc_cbufq; - void*sc_sih_cookie; + void *sc_sih_cookie; }; static int ld_ataraid_match(device_t, cfdata_t, void *); @@ -125,14 +125,14 @@ CFATTACH_DECL_NEW(ld_ataraid, sizeof(str ld_ataraid_match, ld_ataraid_attach, NULL, NULL); struct cbuf { - struct buf cb_buf; /* new I/O buf */ + struct buf cb_buf; /* new I/O buf */ struct buf *cb_obp; /* ptr. to original I/O buf */ - struct ld_ataraid_softc *cb_sc; /* pointer to ld softc */ + struct ld_ataraid_softc *cb_sc; /* pointer to ld softc */ u_int cb_comp; /* target component */ SIMPLEQ_ENTRY(cbuf) cb_q; /* fifo of component buffers */ struct cbuf *cb_other; /* other cbuf in case of mirror */ int cb_flags; -#define CBUF_IODONE 0x0001 /* I/O is already successfully done */ +#define CBUF_IODONE 0x0001 /* I/O is already successfully done */ }; #defineCBUF_GET() pool_cache_get(sc->sc_cbufpool, PR_NOWAIT); @@ -159,10 +159,10 @@ ld_ataraid_attach(device_t parent, devic ld->sc_dv = self; - sc->sc_cbufpool = pool_cache_init(sizeof(struct cbuf), 0, - 0, 0, "ldcbuf", NULL, IPL_BIO, cbufpool_ctor, cbufpool_dtor, sc); - sc->sc_sih_cookie = softint_establish(SOFTINT_BIO, - ld_ataraid_start_vstrategy, sc); + sc->sc_cbufpool = pool_cache_init(sizeof(struct cbuf), 0, + 0, 0, "ldcbuf", NULL, IPL_BIO, cbufpool_ctor, cbufpool_dtor, sc); + sc->sc_sih_cookie = softint_establish(SOFTINT_BIO, + ld_ataraid_start_vstrategy, sc); sc->sc_aai = aai; /* this data persists */ @@ -260,24 +260,24 @@ ld_ataraid_attach(device_t parent, devic static int cbufpool_ctor(void *arg, void *obj, int flags) { - struct ld_ataraid_softc *sc = arg; - struct ld_softc *ld = &sc->sc_ld; - struct cbuf *cbp = obj; - - /* We release/reacquire the spinlock before calling buf_init() */ - mutex_exit(&ld->sc_mutex); - buf_init(&cbp->cb_buf); - mutex_enter(&ld->sc_mutex); + struct ld_ataraid_softc *sc = arg; + struct ld_softc *ld = &sc->sc_ld; + struct cbuf *cbp = obj; + + /* We release/reacquire the spinlock before calling buf_init() */ + mutex_exit(&ld->sc_mutex); + buf_init(&cbp->cb_buf); + mutex_enter(&ld->sc_mutex); - return 0; + return 0; } static void cbufpool_dtor(void *arg, void *obj) { - struct cbuf *cbp = obj; + struct cbuf *cbp = obj; - buf_destroy(&cbp->cb_buf); + buf_destroy(&cbp->cb_buf); } static struct cbuf * @@ -288,7 +288,7 @@ ld_ataraid_make_cbuf(struct ld_ataraid_s cbp = CBUF_GET(); if (cbp == NULL) - return NULL; + return NULL; cbp->cb_buf.b_flags = bp->b_flags; cbp->cb_buf.b_oflags = bp->b_oflags; cbp->cb_buf.b_cflags = bp->b_cflags; @@ -307,24 +307,24 @@ ld_ataraid_make_cbuf(struct ld_ataraid_s cbp->cb_other = NULL; cbp->cb_flags = 0; - return cbp; + return cbp; } static void ld_ataraid_start_vstrategy(void *arg) { - struct ld_ataraid_softc *sc = arg; - struct cbuf *cbp; + struct ld_ataraid_softc *sc = arg; + struct cbuf *cbp; - while ((cbp = SIMPLEQ_FIRST(&sc->sc_cbufq)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&sc->sc_cbufq, cb_q); - if ((cbp->cb_buf.b_flags & B_READ) == 0) { - mutex_enter(cbp->cb_buf.b_vp->v_interlock); - cbp->cb_buf.b_vp->v_numoutput++; - mutex_exit(cbp->cb_buf.b_vp->v_interlock); - } - V
CVS commit: src/sys/dev/ata
Module Name:src Committed By: macallan Date: Fri Jun 1 18:13:30 UTC 2018 Modified Files: src/sys/dev/ata: ata_wdc.c atavar.h Log Message: add a flag to start DMA before issuing commands - needed to work around a bug in some SATA chips which get confused if the disk responds too fast Mostly for K2 SATA / svwsata found in G5 Macs adapted from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/dev/ata/ata_wdc.c cvs rdiff -u -r1.96 -r1.97 src/sys/dev/ata/atavar.h 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_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.109 src/sys/dev/ata/ata_wdc.c:1.110 --- src/sys/dev/ata/ata_wdc.c:1.109 Tue Oct 17 18:52:50 2017 +++ src/sys/dev/ata/ata_wdc.c Fri Jun 1 18:13:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.109 2017/10/17 18:52:50 jdolecek Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.110 2018/06/01 18:13:30 macallan Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.109 2017/10/17 18:52:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.110 2018/06/01 18:13:30 macallan Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -455,6 +455,10 @@ _wdc_ata_bio_start(struct ata_channel *c case WDCWAIT_THR: return ATASTART_TH; } + /* start the DMA channel before */ + if ((chp->ch_flags & ATACH_DMA_BEFORE_CMD) != 0) +(*wdc->dma_start)(wdc->dma_arg, +chp->ch_channel, xfer->c_drive); if (ata_bio->flags & ATA_LBA48) { uint8_t device = WDSD_LBA; cmd = atacmd_to48(cmd); @@ -468,9 +472,10 @@ _wdc_ata_bio_start(struct ata_channel *c wdccommand(chp, xfer->c_drive, cmd, cyl, head, sect, count, features); } - /* start the DMA channel */ - (*wdc->dma_start)(wdc->dma_arg, - chp->ch_channel, xfer->c_drive); + /* start the DMA channel after */ + if ((chp->ch_flags & ATACH_DMA_BEFORE_CMD) == 0) +(*wdc->dma_start)(wdc->dma_arg, +chp->ch_channel, xfer->c_drive); chp->ch_flags |= ATACH_DMA_WAIT; /* start timeout machinery */ if ((xfer->c_flags & C_POLL) == 0) Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.96 src/sys/dev/ata/atavar.h:1.97 --- src/sys/dev/ata/atavar.h:1.96 Mon Apr 16 22:33:28 2018 +++ src/sys/dev/ata/atavar.h Fri Jun 1 18:13:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.96 2018/04/16 22:33:28 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.97 2018/06/01 18:13:30 macallan Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -407,6 +407,7 @@ struct ata_channel { #define ATACH_TH_RESET 0x200 /* someone ask the thread to reset */ #define ATACH_TH_RESCAN 0x400 /* rescan requested */ #define ATACH_NCQ 0x800 /* channel executing NCQ commands */ +#define ATACH_DMA_BEFORE_CMD 0x1000 /* start DMA first */ /* for the reset callback */ int ch_reset_flags;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Apr 16 22:33:28 UTC 2018 Modified Files: src/sys/dev/ata: atavar.h Log Message: remove superfluous semicolon To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/sys/dev/ata/atavar.h 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/atavar.h diff -u src/sys/dev/ata/atavar.h:1.95 src/sys/dev/ata/atavar.h:1.96 --- src/sys/dev/ata/atavar.h:1.95 Tue Oct 17 18:52:50 2017 +++ src/sys/dev/ata/atavar.h Mon Apr 16 22:33:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.95 2017/10/17 18:52:50 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.96 2018/04/16 22:33:28 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -522,7 +522,7 @@ int ata_read_log_ext_ncq(struct ata_driv #define CMD_AGAIN 2 struct ata_xfer *ata_get_xfer_ext(struct ata_channel *, int, uint8_t); -#define ata_get_xfer(chp) ata_get_xfer_ext((chp), C_WAIT, 0); +#define ata_get_xfer(chp) ata_get_xfer_ext((chp), C_WAIT, 0) void ata_free_xfer(struct ata_channel *, struct ata_xfer *); void ata_deactivate_xfer(struct ata_channel *, struct ata_xfer *); void ata_exec_xfer(struct ata_channel *, struct ata_xfer *);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Sun Jan 7 11:37:30 UTC 2018 Modified Files: src/sys/dev/ata: wd.c Log Message: Fix block address calculation for bad sectors. To generate a diff of this commit: cvs rdiff -u -r1.437 -r1.438 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.437 src/sys/dev/ata/wd.c:1.438 --- src/sys/dev/ata/wd.c:1.437 Wed Dec 13 10:24:31 2017 +++ src/sys/dev/ata/wd.c Sun Jan 7 11:37:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.437 2017/12/13 10:24:31 pgoyette Exp $ */ +/* $NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.437 2017/12/13 10:24:31 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -585,9 +585,18 @@ wdstrategy(struct buf *bp) * up failing again. */ if (__predict_false(!SLIST_EMPTY(&wd->sc_bslist))) { + struct disklabel *lp = dksc->sc_dkdev.dk_label; struct disk_badsectors *dbs; - daddr_t maxblk = bp->b_rawblkno + - (bp->b_bcount / wd->sc_blksize) - 1; + daddr_t blkno, maxblk; + + /* convert the block number to absolute */ + if (lp->d_secsize >= DEV_BSIZE) + blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE); + else + blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize); + if (WDPART(bp->b_dev) != RAW_PART) + blkno += lp->d_partitions[WDPART(bp->b_dev)].p_offset; + maxblk = blkno + (bp->b_bcount / wd->sc_blksize) - 1; mutex_enter(&wd->sc_lock); SLIST_FOREACH(dbs, &wd->sc_bslist, dbs_next)
CVS commit: src/sys/dev/ata
Module Name:src Committed By: pgoyette Date: Wed Dec 13 10:24:31 UTC 2017 Modified Files: src/sys/dev/ata: wd.c Log Message: Fix build for WD_SOFTBADSECT option. PR kern/52814 XXX No clue if this option actually works. This fix just makes it XXX compile without error. To generate a diff of this commit: cvs rdiff -u -r1.436 -r1.437 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.436 src/sys/dev/ata/wd.c:1.437 --- src/sys/dev/ata/wd.c:1.436 Tue Nov 7 04:09:08 2017 +++ src/sys/dev/ata/wd.c Wed Dec 13 10:24:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.436 2017/11/07 04:09:08 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.437 2017/12/13 10:24:31 pgoyette Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.436 2017/11/07 04:09:08 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.437 2017/12/13 10:24:31 pgoyette Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -535,12 +535,12 @@ wddetach(device_t self, int flags) #ifdef WD_SOFTBADSECT /* Clean out the bad sector list */ - while (!SLIST_EMPTY(&sc->sc_bslist)) { - void *head = SLIST_FIRST(&sc->sc_bslist); - SLIST_REMOVE_HEAD(&sc->sc_bslist, dbs_next); + while (!SLIST_EMPTY(&wd->sc_bslist)) { + void *head = SLIST_FIRST(&wd->sc_bslist); + SLIST_REMOVE_HEAD(&wd->sc_bslist, dbs_next); free(head, M_TEMP); } - sc->sc_bscount = 0; + wd->sc_bscount = 0; #endif pmf_device_deregister(self); @@ -586,11 +586,13 @@ wdstrategy(struct buf *bp) */ if (__predict_false(!SLIST_EMPTY(&wd->sc_bslist))) { struct disk_badsectors *dbs; - daddr_t maxblk = blkno + (bp->b_bcount / wd->sc_blksize) - 1; + daddr_t maxblk = bp->b_rawblkno + + (bp->b_bcount / wd->sc_blksize) - 1; mutex_enter(&wd->sc_lock); SLIST_FOREACH(dbs, &wd->sc_bslist, dbs_next) - if ((dbs->dbs_min <= blkno && blkno <= dbs->dbs_max) || + if ((dbs->dbs_min <= bp->b_rawblkno && + bp->b_rawblkno <= dbs->dbs_max) || (dbs->dbs_min <= maxblk && maxblk <= dbs->dbs_max)){ mutex_exit(&wd->sc_lock); goto err;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Tue Nov 7 04:09:08 UTC 2017 Modified Files: src/sys/dev/ata: wd.c Log Message: Make wddone poll all drives of a channel again. To generate a diff of this commit: cvs rdiff -u -r1.435 -r1.436 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.435 src/sys/dev/ata/wd.c:1.436 --- src/sys/dev/ata/wd.c:1.435 Fri Nov 3 13:01:26 2017 +++ src/sys/dev/ata/wd.c Tue Nov 7 04:09:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.435 2017/11/03 13:01:26 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.436 2017/11/07 04:09:08 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.435 2017/11/03 13:01:26 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.436 2017/11/07 04:09:08 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -901,7 +901,7 @@ noerror: if ((xfer->c_bio.flags & ATA_CO ata_free_xfer(wd->drvp->chnl_softc, xfer); dk_done(dksc, bp); - dk_start(dksc, NULL); + ata_channel_start(wd->drvp->chnl_softc, wd->drvp->drive); } static void
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Fri Nov 3 13:01:26 UTC 2017 Modified Files: src/sys/dev/ata: wd.c wdvar.h Log Message: Add WDF_OPEN flag to really disallow opening of a disk that has been invalidated. Restore wdbiorestart function to actually retry the failed I/O request instead of just restarting the queue. Fix compilation without ATADEBUG. To generate a diff of this commit: cvs rdiff -u -r1.434 -r1.435 src/sys/dev/ata/wd.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ata/wdvar.h 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/wd.c diff -u src/sys/dev/ata/wd.c:1.434 src/sys/dev/ata/wd.c:1.435 --- src/sys/dev/ata/wd.c:1.434 Wed Nov 1 19:34:46 2017 +++ src/sys/dev/ata/wd.c Fri Nov 3 13:01:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.434 2017/11/01 19:34:46 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.435 2017/11/03 13:01:26 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.434 2017/11/01 19:34:46 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.435 2017/11/03 13:01:26 mlelstv Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -194,6 +194,7 @@ static struct wd_ioctl *wi_get(struct wd static void wdioctlstrategy(struct buf *); static void wdstart(device_t); +static void wdstart1(struct wd_softc *, struct buf *, struct ata_xfer *); static int wd_diskstart(device_t, struct buf *); static int wd_dumpblocks(device_t, void *, daddr_t, int); static void wd_iosize(device_t, int *); @@ -607,23 +608,10 @@ err: biodone(bp); } -static int -wd_diskstart(device_t dev, struct buf *bp) +static void +wdstart1(struct wd_softc *wd, struct buf *bp, struct ata_xfer *xfer) { - struct wd_softc *wd = device_private(dev); struct dk_softc *dksc = &wd->sc_dksc; - struct ata_xfer *xfer; - - mutex_enter(&wd->sc_lock); - - xfer = ata_get_xfer_ext(wd->drvp->chnl_softc, 0, - WD_USE_NCQ(wd) ? WD_MAX_OPENINGS(wd) : 0); - if (xfer == NULL) { - ATADEBUG_PRINT(("wdstart %s no xfer\n", - dksc->sc_xname), DEBUG_XFERS); - mutex_exit(&wd->sc_lock); - return EAGAIN; - } KASSERT(bp == xfer->c_bio.bp || xfer->c_bio.bp == NULL); KASSERT((xfer->c_flags & (C_WAITACT|C_FREE)) == 0); @@ -722,6 +710,29 @@ wd_diskstart(device_t dev, struct buf *b default: panic("wdstart1: bad return code from ata_bio()"); } +} + +static int +wd_diskstart(device_t dev, struct buf *bp) +{ + struct wd_softc *wd = device_private(dev); +#ifdef ATADEBUG + struct dk_softc *dksc = &wd->sc_dksc; +#endif + struct ata_xfer *xfer; + + mutex_enter(&wd->sc_lock); + + xfer = ata_get_xfer_ext(wd->drvp->chnl_softc, 0, + WD_USE_NCQ(wd) ? WD_MAX_OPENINGS(wd) : 0); + if (xfer == NULL) { + ATADEBUG_PRINT(("wd_diskstart %s no xfer\n", + dksc->sc_xname), DEBUG_XFERS); + mutex_exit(&wd->sc_lock); + return EAGAIN; + } + + wdstart1(wd, bp, xfer); mutex_exit(&wd->sc_lock); @@ -825,7 +836,7 @@ retry2: /* Rerun ASAP if just requeued */ callout_reset(&xfer->c_retry_callout, (xfer->c_bio.error == REQUEUE) ? 1 : RECOVERYTIME, - wdbiorestart, wd); + wdbiorestart, xfer); mutex_exit(&wd->sc_lock); return; @@ -896,13 +907,19 @@ noerror: if ((xfer->c_bio.flags & ATA_CO static void wdbiorestart(void *v) { - struct wd_softc *wd = v; + struct ata_xfer *xfer = v; + struct buf *bp = xfer->c_bio.bp; + struct wd_softc *wd = device_lookup_private(&wd_cd, WDUNIT(bp->b_dev)); +#ifdef ATADEBUG struct dk_softc *dksc = &wd->sc_dksc; +#endif - ATADEBUG_PRINT(("wdrestart %s\n", dksc->sc_xname), + ATADEBUG_PRINT(("wdbiorestart %s\n", dksc->sc_xname), DEBUG_XFERS); - dk_start(dksc, NULL); + mutex_enter(&wd->sc_lock); + wdstart1(wd, bp, xfer); + mutex_exit(&wd->sc_lock); } static void @@ -985,7 +1002,7 @@ wdopen(dev_t dev, int flag, int fmt, str * If any partition is open, but the disk has been invalidated, * disallow further opens. */ - if ((wd->sc_flags & WDF_LOADED) == 0) { + if ((wd->sc_flags & (WDF_OPEN | WDF_LOADED)) == WDF_OPEN) { if (part != RAW_PART || fmt != S_IFCHR) return EIO; } @@ -1023,6 +1040,7 @@ wd_firstopen(device_t self, dev_t dev, i wd->sc_flags |= WDF_LOADED; } + wd->sc_flags |= WDF_OPEN; return 0; bad: @@ -1041,6 +1059,7 @@ wd_lastclose(device_t self) wd_flushcache(wd, AT_WAIT, false); wd->atabus->ata_delref(wd->drvp); + wd->sc_flags &= ~WDF_OPEN; return 0; } Index: src/sys/dev/ata/wdvar.h diff -u src/sys/dev/ata/wdvar.h:1.45 src/sys/dev/ata/wdvar.h:1.46 --- src/sys/dev/ata/wdvar.h:1.45 Wed Nov 1 19:34:46 2017 +++ src/sys/dev/ata/wdvar.h Fri Nov 3 13:01:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wdvar.h,v 1.45 2017/11/01 19:34:46 mlelstv Exp $ */ +/* $NetBSD: wdvar.h,v 1.46 2017/11/03 13:01:26 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -54,6 +54,7 @@ struct wd_softc { #
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Nov 1 21:27:22 UTC 2017 Modified Files: src/sys/dev/ata: TODO.ncq Log Message: one down - mlelstv converted wd(4) to dksubr To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/TODO.ncq 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/TODO.ncq diff -u src/sys/dev/ata/TODO.ncq:1.2 src/sys/dev/ata/TODO.ncq:1.3 --- src/sys/dev/ata/TODO.ncq:1.2 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/TODO.ncq Wed Nov 1 21:27:22 2017 @@ -17,8 +17,6 @@ done on a mpata branch?) queue is allocated regardless if there are any drives, fix? -change wd(4) to use dksubr - dump to unopened disk fails (e.g. dump do wd1b when wd1a not mounted), due to the open path executing ata_get_params(), which eventually tsleeps() while waiting for the command to finish; specifically, if WDF_LOADED is not
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Thu Oct 19 20:45:07 UTC 2017 Modified Files: src/sys/dev/ata: ata.c ata_subr.c wd.c Log Message: more detailed debug info; also sync DEBUG_* values in wd.c with ata.c To generate a diff of this commit: cvs rdiff -u -r1.138 -r1.139 src/sys/dev/ata/ata.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.432 -r1.433 src/sys/dev/ata/wd.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.138 src/sys/dev/ata/ata.c:1.139 --- src/sys/dev/ata/ata.c:1.138 Wed Oct 18 08:38:35 2017 +++ src/sys/dev/ata/ata.c Thu Oct 19 20:45:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.139 2017/10/19 20:45:07 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.139 2017/10/19 20:45:07 jdolecek Exp $"); #include "opt_ata.h" @@ -1132,15 +1132,15 @@ atastart(struct ata_channel *chp) again: KASSERT(chq->queue_active <= chq->queue_openings); if (chq->queue_active == chq->queue_openings) { - ATADEBUG_PRINT(("%s: channel completely busy\n", __func__), - DEBUG_XFERS); + ATADEBUG_PRINT(("%s(chp=%p): channel %d completely busy\n", + __func__, chp, chp->ch_channel), DEBUG_XFERS); goto out; } /* is there a xfer ? */ if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) { - ATADEBUG_PRINT(("%s: queue_xfer is empty\n", __func__), - DEBUG_XFERS); + ATADEBUG_PRINT(("%s(chp=%p): channel %d queue_xfer is empty\n", + __func__, chp, chp->ch_channel), DEBUG_XFERS); goto out; } Index: src/sys/dev/ata/ata_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.2 src/sys/dev/ata/ata_subr.c:1.3 --- src/sys/dev/ata/ata_subr.c:1.2 Tue Oct 17 18:52:50 2017 +++ src/sys/dev/ata/ata_subr.c Thu Oct 19 20:45:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.2 2017/10/17 18:52:50 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.3 2017/10/19 20:45:07 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.2 2017/10/17 18:52:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.3 2017/10/19 20:45:07 jdolecek Exp $"); #include "opt_ata.h" @@ -248,8 +248,9 @@ ata_get_xfer_ext(struct ata_channel *chp uint32_t avail, slot, mask; int error; - ATADEBUG_PRINT(("%s: channel %d flags %x openings %d\n", - __func__, chp->ch_channel, flags, openings), + ATADEBUG_PRINT(("%s: channel %d fl 0x%x op %d qavail 0x%x qact %d", + __func__, chp->ch_channel, flags, openings, + chq->queue_xfers_avail, chq->queue_active), DEBUG_XFERS); ata_channel_lock(chp); @@ -307,6 +308,8 @@ retry: out: ata_channel_unlock(chp); + + ATADEBUG_PRINT((" xfer %p\n", xfer), DEBUG_XFERS); return xfer; } @@ -352,6 +355,11 @@ out: } ata_channel_unlock(chp); + + ATADEBUG_PRINT(("%s: channel %d xfer %p qavail 0x%x qact %d\n", + __func__, chp->ch_channel, xfer, chq->queue_xfers_avail, + chq->queue_active), + DEBUG_XFERS); } /* Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.432 src/sys/dev/ata/wd.c:1.433 --- src/sys/dev/ata/wd.c:1.432 Sat Oct 14 13:20:32 2017 +++ src/sys/dev/ata/wd.c Thu Oct 19 20:45:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.432 2017/10/14 13:20:32 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.433 2017/10/19 20:45:07 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.432 2017/10/14 13:20:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.433 2017/10/19 20:45:07 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -102,11 +102,10 @@ __KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.432 #define WDLABELDEV(dev) (MAKEWDDEV(major(dev), WDUNIT(dev), RAW_PART)) -#define DEBUG_INTR 0x01 -#define DEBUG_XFERS 0x02 -#define DEBUG_STATUS 0x04 #define DEBUG_FUNCS 0x08 #define DEBUG_PROBE 0x10 +#define DEBUG_DETACH 0x20 +#define DEBUG_XFERS 0x40 #ifdef ATADEBUG int wdcdebug_wd_mask = 0x0; #define ATADEBUG_PRINT(args, level) \ @@ -659,15 +658,21 @@ wdstart(device_t self) * once flush is pending, it will get handled as soon as xfer * is available. */ - if (ISSET(wd->sc_flags, WDF_FLUSH_PEND)) + if (ISSET(wd->sc_flags, WDF_FLUSH_PEND)) { + ATADEBUG_PRINT(("wdstart %s flush pend\n", + device_xname(wd->sc_dev)), DEBUG_XFERS); goto out; + } while (bufq_peek(wd->sc_q) != NULL) { /* First try to get xfer. Limit to drive openings iff NCQ. */ xfer = ata_get_xfer_ext(wd->drvp->chnl_softc, 0, WD_USE_NCQ(wd) ? WD_MAX_OPENINGS(wd) : 0)
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 18 08:38:35 UTC 2017 Modified Files: src/sys/dev/ata: ata.c Log Message: add newlines to the debug messages To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/dev/ata/ata.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.137 src/sys/dev/ata/ata.c:1.138 --- src/sys/dev/ata/ata.c:1.137 Sun Oct 15 14:41:06 2017 +++ src/sys/dev/ata/ata.c Wed Oct 18 08:38:35 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $"); #include "opt_ata.h" @@ -1132,14 +1132,14 @@ atastart(struct ata_channel *chp) again: KASSERT(chq->queue_active <= chq->queue_openings); if (chq->queue_active == chq->queue_openings) { - ATADEBUG_PRINT(("%s: channel completely busy", __func__), + ATADEBUG_PRINT(("%s: channel completely busy\n", __func__), DEBUG_XFERS); goto out; } /* is there a xfer ? */ if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) { - ATADEBUG_PRINT(("%s: queue_xfer is empty", __func__), + ATADEBUG_PRINT(("%s: queue_xfer is empty\n", __func__), DEBUG_XFERS); goto out; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Oct 15 14:41:07 UTC 2017 Modified Files: src/sys/dev/ata: ata.c Log Message: move the extra thaw for scheduled ata_reset_channel() to the function itself, so it's done regardless if the actual reset is run from thread context or e.g. call with AT_POLL; fixes a hang after xfer failure and dma downgrade add some debugging printfs, so freeze/thaw issues are easier to track To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/dev/ata/ata.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.136 src/sys/dev/ata/ata.c:1.137 --- src/sys/dev/ata/ata.c:1.136 Tue Oct 10 17:19:38 2017 +++ src/sys/dev/ata/ata.c Sun Oct 15 14:41:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.136 2017/10/10 17:19:38 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.136 2017/10/10 17:19:38 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $"); #include "opt_ata.h" @@ -477,11 +477,7 @@ atabus_thread(void *arg) ata_channel_lock(chp); } if (chp->ch_flags & ATACH_TH_RESET) { - /* - * ata_reset_channel() will freeze 2 times, so - * unfreeze one time. Not a problem as we're at splbio - */ - ata_channel_thaw_locked(chp); + /* ata_reset_channel() will unfreeze the channel */ ata_channel_unlock(chp); s = splbio(); ata_reset_channel(chp, AT_WAIT | chp->ch_reset_flags); @@ -1136,12 +1132,17 @@ atastart(struct ata_channel *chp) again: KASSERT(chq->queue_active <= chq->queue_openings); if (chq->queue_active == chq->queue_openings) { - goto out; /* channel completely busy */ + ATADEBUG_PRINT(("%s: channel completely busy", __func__), + DEBUG_XFERS); + goto out; } /* is there a xfer ? */ - if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) + if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) { + ATADEBUG_PRINT(("%s: queue_xfer is empty", __func__), + DEBUG_XFERS); goto out; + } recovery = ISSET(xfer->c_flags, C_RECOVERY); @@ -1151,7 +1152,12 @@ again: chq->queue_flags &= ~QF_IDLE_WAIT; cv_signal(&chp->ch_queue->queue_idle); } - goto out; /* queue frozen */ + ATADEBUG_PRINT(("%s(chp=%p): channel %d drive %d " + "queue frozen: %d (recovery: %d)\n", + __func__, chp, chp->ch_channel, xfer->c_drive, + chq->queue_freeze, recovery), + DEBUG_XFERS); + goto out; } /* all xfers on same queue must belong to the same channel */ @@ -1190,8 +1196,8 @@ again: if (!atac->atac_claim_hw(chp, 0)) goto out; - ATADEBUG_PRINT(("atastart: xfer %p channel %d drive %d\n", xfer, - chp->ch_channel, xfer->c_drive), DEBUG_XFERS); + ATADEBUG_PRINT(("%s(chp=%p): xfer %p channel %d drive %d\n", + __func__, chp, xfer, chp->ch_channel, xfer->c_drive), DEBUG_XFERS); if (drvp->drive_flags & ATA_DRIVE_RESET) { drvp->drive_flags &= ~ATA_DRIVE_RESET; drvp->state = 0; @@ -1488,6 +1494,9 @@ static void ata_channel_freeze_locked(struct ata_channel *chp) { chp->ch_queue->queue_freeze++; + + ATADEBUG_PRINT(("%s(chp=%p) -> %d\n", __func__, chp, + chp->ch_queue->queue_freeze), DEBUG_FUNCS | DEBUG_XFERS); } void @@ -1502,8 +1511,12 @@ static void ata_channel_thaw_locked(struct ata_channel *chp) { KASSERT(mutex_owned(&chp->ch_lock)); + KASSERT(chp->ch_queue->queue_freeze > 0); chp->ch_queue->queue_freeze--; + + ATADEBUG_PRINT(("%s(chp=%p) -> %d\n", __func__, chp, + chp->ch_queue->queue_freeze), DEBUG_FUNCS | DEBUG_XFERS); } void @@ -1526,6 +1539,7 @@ ata_reset_channel(struct ata_channel *ch { struct atac_softc *atac = chp->ch_atac; int drive; + bool threset = false; #ifdef ATA_DEBUG int spl1, spl2; @@ -1540,7 +1554,7 @@ ata_reset_channel(struct ata_channel *ch splx(spl1); #endif /* ATA_DEBUG */ - ata_channel_freeze(chp); + ata_channel_lock(chp); /* * If we can poll or wait it's OK, otherwise wake up the @@ -1551,10 +1565,15 @@ ata_reset_channel(struct ata_channel *ch if ((flags & (AT_POLL | AT_WAIT)) == 0) { if (chp->ch_flags & ATACH_TH_RESET) { /* No need to schedule a reset more than one time. */ - ata_channel_thaw(chp); + ata_channel_unlock(chp); return; } - ata_channel_lock(chp); + + /* + * Block execution of other commands while reset is scheduled + * to a thread. + */ + ata_channel_freeze_locked(chp); chp->ch_flags |= ATACH_TH_RESET; chp->ch_reset_flags = flags & AT_RST_EMERG; cv_signal(&chp->ch_thr_idle); @@ -1562,6 +1581,21 @@ ata_reset_channel(struct ata_channel *ch return; } + /* Block execution of other commands during reset */ + ata_channel_freeze_locked(chp); + + /* + * If reset h
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Oct 15 11:27:14 UTC 2017 Modified Files: src/sys/dev/ata: ata_wdc.c Log Message: revert the logic for wdc_wait_for_unbusy() in wdc_ata_bio_intr() to pre-NCQ, wdcintr() and wdctimeout() need that; follows same change in atapi_wdc.c rev. 1.128 To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/dev/ata/ata_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_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.107 src/sys/dev/ata/ata_wdc.c:1.108 --- src/sys/dev/ata/ata_wdc.c:1.107 Sun Oct 8 13:35:03 2017 +++ src/sys/dev/ata/ata_wdc.c Sun Oct 15 11:27:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.108 2017/10/15 11:27:14 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.108 2017/10/15 11:27:14 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -618,14 +618,13 @@ wdc_ata_bio_poll(struct ata_channel *chp } static int -wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int is) +wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) { struct atac_softc *atac = chp->ch_atac; struct wdc_softc *wdc = CHAN_TO_WDC(chp); struct ata_bio *ata_bio = &xfer->c_bio; struct ata_drive_datas *drvp = &chp->ch_drive[xfer->c_drive]; int drv_err, tfd; - bool poll = ((xfer->c_flags & C_POLL) != 0); ATADEBUG_PRINT(("wdc_ata_bio_intr %s:%d:%d\n", device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive), @@ -659,8 +658,9 @@ wdc_ata_bio_intr(struct ata_channel *chp #endif /* Ack interrupt done by wdc_wait_for_unbusy */ - if (wdc_wait_for_unbusy(chp, poll ? ATA_DELAY : 0, AT_POLL, &tfd) < 0) { - if (!poll && (xfer->c_flags & C_TIMEOU) == 0) { + if (wdc_wait_for_unbusy(chp, + (irq == 0) ? ATA_DELAY : 0, AT_POLL, &tfd) < 0) { + if (irq && (xfer->c_flags & C_TIMEOU) == 0) { ata_channel_unlock(chp); return 0; /* IRQ was not for us */ }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 14 13:20:32 UTC 2017 Modified Files: src/sys/dev/ata: wd.c Log Message: do not use the NCQ priority by default; seems it negatively affects performance at least with some drives, so this needs better understood first To generate a diff of this commit: cvs rdiff -u -r1.431 -r1.432 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.431 src/sys/dev/ata/wd.c:1.432 --- src/sys/dev/ata/wd.c:1.431 Sat Oct 14 13:15:14 2017 +++ src/sys/dev/ata/wd.c Sat Oct 14 13:20:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.431 2017/10/14 13:15:14 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.432 2017/10/14 13:20:32 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.431 2017/10/14 13:15:14 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.432 2017/10/14 13:20:32 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -2362,7 +2362,7 @@ wd_sysctl_attach(struct wd_softc *wd) return; } - wd->drv_ncq_prio = true; + wd->drv_ncq_prio = false; if ((error = sysctl_createv(&wd->nodelog, 0, NULL, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "use_ncq_prio", SYSCTL_DESCR("use NCQ PRIORITY if supported"),
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 14 13:15:14 UTC 2017 Modified Files: src/sys/dev/ata: wd.c Log Message: only call drive reset with AT_POLL when the command itself was polled, so that the logic for AT_POLL matches how e.g. ata_dmaerr() is called; this was the original intent of the change in 1.428.2.25, to make the error handling safe wrt. polled xfers this is stopgap fix for ATA channel wedge after DMA error, as reported by Martin Husemann in PR kern/52606, and PR kern/52605 problem happened due to ata_reset_channel() being called once in ata_dmaerr() with flags == 0, which freezed channel and set flag to reset via thread, then ata_reset_channel() was called via wdc_drive_reset() with AT_POLL, which just executed the reset and cleared the flag, without clearing the extra freeze; that logic will be refactored in separate commit To generate a diff of this commit: cvs rdiff -u -r1.430 -r1.431 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.430 src/sys/dev/ata/wd.c:1.431 --- src/sys/dev/ata/wd.c:1.430 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/wd.c Sat Oct 14 13:15:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.430 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.431 2017/10/14 13:15:14 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.430 2017/10/07 16:05:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.431 2017/10/14 13:15:14 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -829,8 +829,10 @@ wddone(device_t self, struct ata_xfer *x errmsg = "error"; do_perror = 1; retry: /* Just reset and retry. Can we do more ? */ - if ((xfer->c_flags & C_RECOVERED) == 0) - (*wd->atabus->ata_reset_drive)(wd->drvp, AT_POLL, NULL); + if ((xfer->c_flags & C_RECOVERED) == 0) { + int wflags = (xfer->c_flags & C_POLL) ? AT_POLL : 0; + (*wd->atabus->ata_reset_drive)(wd->drvp, wflags, NULL); + } retry2: mutex_enter(&wd->sc_lock);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Tue Oct 10 17:19:39 UTC 2017 Modified Files: src/sys/dev/ata: ata.c ataconf.h atavar.h files.ata Added Files: src/sys/dev/ata: ata_subr.c Log Message: split off functions used by 'wd* at umass?' into separate file, unfortunately the previous approach with NATABUS doesn't work for kernels which include MODULAR, but not atabus - such as macppc and evbarm To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/dev/ata/ata.c cvs rdiff -u -r0 -r1.1 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ataconf.h cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ata/files.ata 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.135 src/sys/dev/ata/ata.c:1.136 --- src/sys/dev/ata/ata.c:1.135 Sun Oct 8 19:00:29 2017 +++ src/sys/dev/ata/ata.c Tue Oct 10 17:19:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.135 2017/10/08 19:00:29 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.136 2017/10/10 17:19:38 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.135 2017/10/08 19:00:29 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.136 2017/10/10 17:19:38 jdolecek Exp $"); #include "opt_ata.h" @@ -83,7 +83,6 @@ int atadebug_mask = ATADEBUG_MASK; #define ATADEBUG_PRINT(args, level) #endif -#if NATABUS static ONCE_DECL(ata_init_ctrl); /* @@ -134,7 +133,6 @@ static void ata_channel_idle(struct ata_ static void ata_channel_thaw_locked(struct ata_channel *); static void ata_activate_xfer_locked(struct ata_channel *, struct ata_xfer *); static void ata_channel_freeze_locked(struct ata_channel *); -static struct ata_xfer *ata_queue_get_active_xfer_locked(struct ata_channel *); static void ata_thread_wake_locked(struct ata_channel *); /* @@ -186,177 +184,7 @@ ataprint(void *aux, const char *pnp) return (UNCONF); } -#endif /* NATABUS */ -static void -ata_queue_reset(struct ata_queue *chq) -{ - /* make sure that we can use polled commands */ - TAILQ_INIT(&chq->queue_xfer); - TAILQ_INIT(&chq->active_xfers); - chq->queue_freeze = 0; - chq->queue_active = 0; - chq->active_xfers_used = 0; - chq->queue_xfers_avail = __BIT(chq->queue_openings) - 1; -} - -struct ata_xfer * -ata_queue_hwslot_to_xfer(struct ata_channel *chp, int hwslot) -{ - struct ata_queue *chq = chp->ch_queue; - struct ata_xfer *xfer = NULL; - - ata_channel_lock(chp); - - KASSERTMSG(hwslot < chq->queue_openings, "hwslot %d > openings %d", - hwslot, chq->queue_openings); - KASSERTMSG((chq->active_xfers_used & __BIT(hwslot)) != 0, - "hwslot %d not active", hwslot); - - /* Usually the first entry will be the one */ - TAILQ_FOREACH(xfer, &chq->active_xfers, c_activechain) { - if (xfer->c_slot == hwslot) - break; - } - - ata_channel_unlock(chp); - - KASSERTMSG((xfer != NULL), - "%s: xfer with slot %d not found (active %x)", __func__, - hwslot, chq->active_xfers_used); - - return xfer; -} - -static struct ata_xfer * -ata_queue_get_active_xfer_locked(struct ata_channel *chp) -{ - struct ata_xfer *xfer; - - KASSERT(mutex_owned(&chp->ch_lock)); - xfer = TAILQ_FIRST(&chp->ch_queue->active_xfers); - - if (xfer && ISSET(xfer->c_flags, C_NCQ)) { - /* Spurious call, never return NCQ xfer from this interface */ - xfer = NULL; - } - - return xfer; -} - -/* - * This interface is supposed only to be used when there is exactly - * one outstanding command, when there is no information about the slot, - * which triggered the command. ata_queue_hwslot_to_xfer() interface - * is preferred in all NCQ cases. - */ -struct ata_xfer * -ata_queue_get_active_xfer(struct ata_channel *chp) -{ - struct ata_xfer *xfer = NULL; - - ata_channel_lock(chp); - xfer = ata_queue_get_active_xfer_locked(chp); - ata_channel_unlock(chp); - - return xfer; -} - -struct ata_xfer * -ata_queue_drive_active_xfer(struct ata_channel *chp, int drive) -{ - struct ata_xfer *xfer = NULL; - - ata_channel_lock(chp); - - TAILQ_FOREACH(xfer, &chp->ch_queue->active_xfers, c_activechain) { - if (xfer->c_drive == drive) - break; - } - KASSERT(xfer != NULL); - - ata_channel_unlock(chp); - - return xfer; -} - -static void -ata_xfer_init(struct ata_xfer *xfer, uint8_t slot) -{ - memset(xfer, 0, sizeof(*xfer)); - - xfer->c_slot = slot; - - cv_init(&xfer->c_active, "ataact"); - cv_init(&xfer->c_finish, "atafin"); - callout_init(&xfer->c_timo_callout, 0); /* XXX MPSAFE */ - callout_init(&xfer->c_retry_callout, 0); /* XXX MPSAFE */ -} - -static void -ata_xfer_destroy(struct ata_xfer *xfer) -{ - callout_halt(&xfer->c_timo_callout, NULL); /* XXX MPSAFE */ - callout_destroy(&xfer->c_timo_callout); - callout_halt(&xfer->c_retry_callout, NULL); /* XXX MPSAFE */ - callout_destroy(&xfer->c_retry_callout
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Oct 8 19:00:29 UTC 2017 Modified Files: src/sys/dev/ata: ata.c ataconf.h files.ata Log Message: as a stopgap measure, include necessary parts of dev/ata/ata.c even if no atabus is configured, so that kernels with just 'wd* at umass?' and no atabus compile; fixes kernel builds for vax, pmax and evbmips after NCQ branch merge XXX wd* at umass? still actually untested after the merge, need to discuss XXX what to do with it To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/dev/ata/ata.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ataconf.h cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ata/files.ata 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.134 src/sys/dev/ata/ata.c:1.135 --- src/sys/dev/ata/ata.c:1.134 Sun Oct 8 04:52:33 2017 +++ src/sys/dev/ata/ata.c Sun Oct 8 19:00:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.134 2017/10/08 04:52:33 mlelstv Exp $ */ +/* $NetBSD: ata.c,v 1.135 2017/10/08 19:00:29 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.134 2017/10/08 04:52:33 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.135 2017/10/08 19:00:29 jdolecek Exp $"); #include "opt_ata.h" @@ -83,6 +83,7 @@ int atadebug_mask = ATADEBUG_MASK; #define ATADEBUG_PRINT(args, level) #endif +#if NATABUS static ONCE_DECL(ata_init_ctrl); /* @@ -185,6 +186,7 @@ ataprint(void *aux, const char *pnp) return (UNCONF); } +#endif /* NATABUS */ static void ata_queue_reset(struct ata_queue *chq) @@ -347,6 +349,14 @@ ata_channel_init(struct ata_channel *chp cv_init(&chp->ch_thr_idle, "atath"); } +void +ata_channel_destroy(struct ata_channel *chp) +{ + mutex_destroy(&chp->ch_lock); + cv_destroy(&chp->ch_thr_idle); +} + +#if NATABUS /* * ata_channel_attach: * @@ -366,13 +376,6 @@ ata_channel_attach(struct ata_channel *c atabusprint); } -void -ata_channel_destroy(struct ata_channel *chp) -{ - mutex_destroy(&chp->ch_lock); - cv_destroy(&chp->ch_thr_idle); -} - /* * ata_channel_detach: * @@ -1428,6 +1431,7 @@ ata_xfer_start(struct ata_xfer *xfer) return rv; } +#endif /* NATABUS */ /* * Does it's own locking, does not require splbio(). @@ -1549,6 +1553,7 @@ out: ata_channel_unlock(chp); } +#if NATABUS static void ata_activate_xfer_locked(struct ata_channel *chp, struct ata_xfer *xfer) { @@ -2547,6 +2552,7 @@ atacmd_toncq(struct ata_xfer *xfer, uint if (xfer->c_bio.flags & ATA_FUA) *device |= WDSD_FUA; } +#endif /* NATABUS */ /* * Must be called without any locks, i.e. with both drive and channel locks @@ -2613,6 +2619,7 @@ ata_channel_lock_owned(struct ata_channe KASSERT(mutex_owned(&chp->ch_lock)); } +#if NATABUS void ata_wait_xfer(struct ata_channel *chp, struct ata_xfer *xfer) { @@ -2628,3 +2635,4 @@ ata_wake_xfer(struct ata_channel *chp, s cv_signal(&xfer->c_finish); } +#endif /* NATABUS */ Index: src/sys/dev/ata/ataconf.h diff -u src/sys/dev/ata/ataconf.h:1.3 src/sys/dev/ata/ataconf.h:1.4 --- src/sys/dev/ata/ataconf.h:1.3 Fri Feb 13 22:41:04 2009 +++ src/sys/dev/ata/ataconf.h Sun Oct 8 19:00:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ataconf.h,v 1.3 2009/02/13 22:41:04 apb Exp $ */ +/* $NetBSD: ataconf.h,v 1.4 2017/10/08 19:00:29 jdolecek Exp $ */ /* * Written in 2006 by ITOH Yasufumi. @@ -18,6 +18,7 @@ # define NATA_DMA 1 # define NATA_UDMA 1 # define NATA_PIOBM 1 +# define NATABUS 1 #else Index: src/sys/dev/ata/files.ata diff -u src/sys/dev/ata/files.ata:1.25 src/sys/dev/ata/files.ata:1.26 --- src/sys/dev/ata/files.ata:1.25 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/files.ata Sun Oct 8 19:00:29 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.ata,v 1.25 2017/10/07 16:05:32 jdolecek Exp $ +# $NetBSD: files.ata,v 1.26 2017/10/08 19:00:29 jdolecek Exp $ # # Config file and device description for machine-independent devices # which attach to ATA busses. Included by ports that need it. Ports @@ -14,7 +14,7 @@ file dev/ata/ata_wdc.c wd & atabus & wd defflag opt_wd.h WD_SOFTBADSECT defflag opt_wd.h WD_CHAOS_MONKEY -file dev/ata/ata.c (ata_hl | atapi) & atabus +file dev/ata/ata.c (ata_hl | atapi) # ATA RAID configuration support defpseudodev ataraid {[vendtype = -1], [unit = -1]}
CVS commit: src/sys/dev/ata
Module Name:src Committed By: christos Date: Sun Oct 8 13:35:04 UTC 2017 Modified Files: src/sys/dev/ata: ata_wdc.c Log Message: Re-use the err label more so it is not unused for drivers that don't support dma. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ata/ata_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_wdc.c diff -u src/sys/dev/ata/ata_wdc.c:1.106 src/sys/dev/ata/ata_wdc.c:1.107 --- src/sys/dev/ata/ata_wdc.c:1.106 Sat Oct 7 12:05:32 2017 +++ src/sys/dev/ata/ata_wdc.c Sun Oct 8 09:35:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.106 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.106 2017/10/07 16:05:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -647,9 +647,7 @@ wdc_ata_bio_intr(struct ata_channel *chp */ if ((xfer->c_flags & (C_TIMEOU | C_DMA)) == C_TIMEOU) { ata_bio->error = TIMEOUT; - ata_channel_unlock(chp); - wdc_ata_bio_done(chp, xfer); - return 1; + goto err; } #if NATA_PIOBM @@ -667,12 +665,10 @@ wdc_ata_bio_intr(struct ata_channel *chp return 0; /* IRQ was not for us */ } printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip%d\n", - device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, - xfer->c_bcount, xfer->c_skip); + device_xname(atac->atac_dev), chp->ch_channel, + xfer->c_drive, xfer->c_bcount, xfer->c_skip); ata_bio->error = TIMEOUT; - ata_channel_unlock(chp); - wdc_ata_bio_done(chp, xfer); - return 1; + goto err; } if (wdc->irqack) wdc->irqack(chp); @@ -720,19 +716,17 @@ wdc_ata_bio_intr(struct ata_channel *chp goto end; if (ata_bio->r_error & WDCE_CRC || ata_bio->error == ERR_DMA) { ata_channel_unlock(chp); - ata_dmaerr(drvp, (xfer->c_flags & C_POLL) ? AT_POLL : 0); + ata_dmaerr(drvp, + (xfer->c_flags & C_POLL) ? AT_POLL : 0); + ata_channel_lock(chp); goto err; } } #endif /* NATA_DMA */ /* if we had an error, end */ - if (drv_err == WDC_ATA_ERR) { - ata_channel_unlock(chp); -err: - wdc_ata_bio_done(chp, xfer); - return 1; - } + if (drv_err == WDC_ATA_ERR) + goto err; /* If this was a read and not using DMA, fetch the data. */ if ((ata_bio->flags & ATA_READ) != 0) { @@ -741,9 +735,7 @@ err: device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive); ata_bio->error = TIMEOUT; - ata_channel_unlock(chp); - wdc_ata_bio_done(chp, xfer); - return 1; + goto err; } #if NATA_PIOBM if (xfer->c_flags & C_PIOBM) { @@ -755,7 +747,7 @@ err: chp->ch_flags |= ATACH_DMA_WAIT | ATACH_PIOBM_WAIT; ata_channel_unlock(chp); return 1; - } else + } #endif wdc->datain_pio(chp, drvp->drive_flags, (char *)xfer->c_databuf + xfer->c_skip, ata_bio->nbytes); @@ -778,11 +770,13 @@ end: /* Let _wdc_ata_bio_start do the loop */ } ata_channel_unlock(chp); - } else { /* Done with this transfer */ - ata_bio->error = NOERROR; - ata_channel_unlock(chp); - wdc_ata_bio_done(chp, xfer); + return 1; } + + /* Done with this transfer */ + ata_bio->error = NOERROR; +err: ata_channel_unlock(chp); + wdc_ata_bio_done(chp, xfer); return 1; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Sun Oct 8 04:52:33 UTC 2017 Modified Files: src/sys/dev/ata: ata.c Log Message: Don't assert channel lock in polled mode. ahcisata (and maybe others) use ata_delay during initialization where lock isn't taken. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/dev/ata/ata.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.133 src/sys/dev/ata/ata.c:1.134 --- src/sys/dev/ata/ata.c:1.133 Sat Oct 7 16:05:32 2017 +++ src/sys/dev/ata/ata.c Sun Oct 8 04:52:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.133 2017/10/07 16:05:32 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.134 2017/10/08 04:52:33 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.133 2017/10/07 16:05:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.134 2017/10/08 04:52:33 mlelstv Exp $"); #include "opt_ata.h" @@ -2503,7 +2503,6 @@ atabus_rescan(device_t self, const char void ata_delay(struct ata_channel *chp, int ms, const char *msg, int flags) { - KASSERT(mutex_owned(&chp->ch_lock)); if ((flags & (AT_WAIT | AT_POLL)) == AT_POLL) { /* @@ -2513,6 +2512,8 @@ ata_delay(struct ata_channel *chp, int m delay(ms * 1000); } else { int pause = mstohz(ms); + + KASSERT(mutex_owned(&chp->ch_lock)); kpause(msg, false, pause > 0 ? pause : 1, &chp->ch_lock); } }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: maxv Date: Sun Jun 25 12:29:32 UTC 2017 Modified Files: src/sys/dev/ata: ata_raid_subr.c Log Message: dumb instruction To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/ata_raid_subr.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_raid_subr.c diff -u src/sys/dev/ata/ata_raid_subr.c:1.2 src/sys/dev/ata/ata_raid_subr.c:1.3 --- src/sys/dev/ata/ata_raid_subr.c:1.2 Thu Jun 24 13:03:08 2010 +++ src/sys/dev/ata/ata_raid_subr.c Sun Jun 25 12:29:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_subr.c,v 1.2 2010/06/24 13:03:08 hannken Exp $ */ +/* $NetBSD: ata_raid_subr.c,v 1.3 2017/06/25 12:29:32 maxv Exp $ */ /*- * Copyright (c) 2008 Juan Romero Pardines. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_subr.c,v 1.2 2010/06/24 13:03:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_subr.c,v 1.3 2017/06/25 12:29:32 maxv Exp $"); #include #include @@ -72,7 +72,6 @@ ata_raid_disk_vnode_find(struct ataraid_ return adv->adv_vnode; } - adv = NULL; adv = kmem_zalloc(sizeof(struct ataraid_disk_vnode), KM_SLEEP); bmajor = devsw_name2blk(device_xname(adi->adi_dev), NULL, 0);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: msaitoh Date: Wed May 10 08:46:39 UTC 2017 Modified Files: src/sys/dev/ata: sata_subr.c Log Message: KNF. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ata/sata_subr.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/sata_subr.c diff -u src/sys/dev/ata/sata_subr.c:1.21 src/sys/dev/ata/sata_subr.c:1.22 --- src/sys/dev/ata/sata_subr.c:1.21 Wed Apr 3 17:15:07 2013 +++ src/sys/dev/ata/sata_subr.c Wed May 10 08:46:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sata_subr.c,v 1.21 2013/04/03 17:15:07 bouyer Exp $ */ +/* $NetBSD: sata_subr.c,v 1.22 2017/05/10 08:46:39 msaitoh Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ * Common functions for Serial ATA. */ #include -__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.21 2013/04/03 17:15:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.22 2017/05/10 08:46:39 msaitoh Exp $"); #include #include @@ -85,14 +85,15 @@ sata_reset_interface(struct ata_channel uint32_t scontrol, sstatus; int i; - /* bring the PHYs online. + /* + * bring the PHYs online. * The work-around for errata #1 of the Intel GD31244 says that we must * write 0 to the port first to be sure of correctly initializing * the device. It doesn't hurt for other devices. */ bus_space_write_4(sata_t, scontrol_r, 0, 0); scontrol = SControl_IPM_NONE | SControl_SPD_ANY | SControl_DET_INIT; - bus_space_write_4 (sata_t, scontrol_r, 0, scontrol); + bus_space_write_4(sata_t, scontrol_r, 0, scontrol); ata_delay(50, "sataup", flags); scontrol &= ~SControl_DET_INIT;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Apr 24 09:42:52 UTC 2017 Modified Files: src/sys/dev/ata: wd.c Log Message: remove the workaround for Seagate 'mod15write' bug, now driver only prints error on boog; unfortunately the code actually doesn't work, and there is little point trying to fix To generate a diff of this commit: cvs rdiff -u -r1.428 -r1.429 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.428 src/sys/dev/ata/wd.c:1.429 --- src/sys/dev/ata/wd.c:1.428 Sun Mar 5 23:07:12 2017 +++ src/sys/dev/ata/wd.c Mon Apr 24 09:42:52 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.428 2017/03/05 23:07:12 mlelstv Exp $ */ +/* $NetBSD: wd.c,v 1.429 2017/04/24 09:42:52 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428 2017/03/05 23:07:12 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.429 2017/04/24 09:42:52 jdolecek Exp $"); #include "opt_ata.h" @@ -344,6 +344,10 @@ wdattach(device_t parent, device_t self, char sbuf[sizeof(WD_QUIRK_FMT) + 64]; snprintb(sbuf, sizeof(sbuf), WD_QUIRK_FMT, wd->sc_quirks); aprint_normal_dev(self, "quirks %s\n", sbuf); + + if (wd->sc_quirks & WD_QUIRK_SPLIT_MOD15_WRITE) { + aprint_error_dev(self, "drive corrupts write transfers with certain controllers, consider replacing\n"); + } } if ((wd->sc_params.atap_multi & 0xff) > 1) { @@ -647,110 +651,10 @@ wdstart(void *arg) } } -static void -wd_split_mod15_write(struct buf *bp) -{ - struct buf *obp = bp->b_private; - struct wd_softc *sc = - device_lookup_private(&wd_cd, DISKUNIT(obp->b_dev)); - int s; - - if (__predict_false(bp->b_error != 0)) { - /* - * Propagate the error. If this was the first half of - * the original transfer, make sure to account for that - * in the residual. - */ - if (bp->b_data == obp->b_data) - bp->b_resid += bp->b_bcount; - goto done; - } - - /* - * If this was the second half of the transfer, we're all done! - */ - if (bp->b_data != obp->b_data) - goto done; - - /* - * Advance the pointer to the second half and issue that command - * using the same opening. - */ - bp->b_flags = obp->b_flags; - bp->b_oflags = obp->b_oflags; - bp->b_cflags = obp->b_cflags; - bp->b_data = (char *)bp->b_data + bp->b_bcount; - bp->b_blkno += (bp->b_bcount / DEV_BSIZE); - bp->b_rawblkno += (bp->b_bcount / sc->sc_blksize); - s = splbio(); - wdstart1(sc, bp); - splx(s); - return; - - done: - obp->b_error = bp->b_error; - obp->b_resid = bp->b_resid; - s = splbio(); - putiobuf(bp); - biodone(obp); - sc->openings++; - splx(s); - /* wddone() will call wdstart() */ -} - void wdstart1(struct wd_softc *wd, struct buf *bp) { - /* - * Deal with the "split mod15 write" quirk. We just divide the - * transfer in two, doing the first half and then then second half - * with the same command opening. - * - * Note we MUST do this here, because we can't let insertion - * into the bufq cause the transfers to be re-merged. - */ - if (__predict_false((wd->sc_quirks & WD_QUIRK_SPLIT_MOD15_WRITE) != 0 && - (bp->b_flags & B_READ) == 0 && - bp->b_bcount > 512 && - ((bp->b_bcount / 512) % 15) == 1)) { - struct buf *nbp; - - /* already at splbio */ - nbp = getiobuf(NULL, false); - if (__predict_false(nbp == NULL)) { - /* No memory -- fail the iop. */ - bp->b_error = ENOMEM; - bp->b_resid = bp->b_bcount; - biodone(bp); - wd->openings++; - return; - } - - nbp->b_error = 0; - nbp->b_proc = bp->b_proc; - nbp->b_dev = bp->b_dev; - - nbp->b_bcount = bp->b_bcount / 2; - nbp->b_bufsize = bp->b_bcount / 2; - nbp->b_data = bp->b_data; - - nbp->b_blkno = bp->b_blkno; - nbp->b_rawblkno = bp->b_rawblkno; - - nbp->b_flags = bp->b_flags; - nbp->b_oflags = bp->b_oflags; - nbp->b_cflags = bp->b_cflags; - nbp->b_iodone = wd_split_mod15_write; - - /* Put ptr to orig buf in b_private and use new buf */ - nbp->b_private = bp; - - BIO_COPYPRIO(nbp, bp); - - bp = nbp; - } - wd->sc_wdc_bio.blkno = bp->b_rawblkno; wd->sc_wdc_bio.bcount = bp->b_bcount; wd->sc_wdc_bio.databuf = bp->b_data; @@ -882,13 +786,8 @@ noerror: if ((wd->sc_wdc_bio.flags & ATA disk_unbusy(&wd->sc_dk, (bp->b_bcount - bp->b_resid), (bp->b_flags & B_READ)); rnd_add_uint32(&wd->rnd_source, bp->b_blkno); - /* XXX Yuck, but we don't want to increment openings in this case */ - if (__predict_false(bp->b_iodone == wd_split_mod15_write)) - biodone(bp); - else { - biodone(bp); - wd->openings++; - } + biodone(bp); + wd->openings++; KASSERT(wd->sc_bp != NULL); wd->sc_bp = NULL; wdstart(wd);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: pgoyette Date: Tue Sep 27 08:05:34 UTC 2016 Modified Files: src/sys/dev/ata: ata_raid.c ld_ataraid.c Log Message: Remove some debug printf's that slipped through. Thanks, wiz! To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ata/ata_raid.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/ata/ld_ataraid.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_raid.c diff -u src/sys/dev/ata/ata_raid.c:1.38 src/sys/dev/ata/ata_raid.c:1.39 --- src/sys/dev/ata/ata_raid.c:1.38 Tue Sep 27 03:33:32 2016 +++ src/sys/dev/ata/ata_raid.c Tue Sep 27 08:05:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid.c,v 1.38 2016/09/27 03:33:32 pgoyette Exp $ */ +/* $NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.38 2016/09/27 03:33:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $"); #include #include @@ -177,7 +177,6 @@ ata_raid_finalize(device_t self) ataraid_cd.cd_name); out: -printf("%s: exit\n", __func__); return (1); } Index: src/sys/dev/ata/ld_ataraid.c diff -u src/sys/dev/ata/ld_ataraid.c:1.43 src/sys/dev/ata/ld_ataraid.c:1.44 --- src/sys/dev/ata/ld_ataraid.c:1.43 Tue Sep 27 03:33:32 2016 +++ src/sys/dev/ata/ld_ataraid.c Tue Sep 27 08:05:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.43 2016/09/27 03:33:32 pgoyette Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.44 2016/09/27 08:05:34 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.43 2016/09/27 03:33:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.44 2016/09/27 08:05:34 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "bio.h" @@ -754,7 +754,6 @@ ld_ataraid_modcmd(modcmd_t cmd, void *op error = ENOTTY; break; } -printf("%s: return %d\n", __func__, error); #endif return error;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: christos Date: Fri Aug 5 06:54:22 UTC 2016 Modified Files: src/sys/dev/ata: wd.c Log Message: CID 1364758: Integer handling issues, avoid sign extension to 64 bits. To generate a diff of this commit: cvs rdiff -u -r1.425 -r1.426 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.425 src/sys/dev/ata/wd.c:1.426 --- src/sys/dev/ata/wd.c:1.425 Fri Jul 22 08:55:34 2016 +++ src/sys/dev/ata/wd.c Fri Aug 5 02:54:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.425 2016/07/22 12:55:34 jakllsch Exp $ */ +/* $NetBSD: wd.c,v 1.426 2016/08/05 06:54:22 christos Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.425 2016/07/22 12:55:34 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.426 2016/08/05 06:54:22 christos Exp $"); #include "opt_ata.h" @@ -394,8 +394,8 @@ wdattach(device_t parent, device_t self, if ((wd->sc_params.atap_secsz & ATA_SECSZ_VALID_MASK) == ATA_SECSZ_VALID && ((wd->sc_params.atap_secsz & ATA_SECSZ_LLS) != 0)) { wd->sc_blksize = 2ULL * - (wd->sc_params.atap_lls_secsz[1] << 16 | - wd->sc_params.atap_lls_secsz[0] << 0); + ((uint32_t)((wd->sc_params.atap_lls_secsz[1] << 16) | + wd->sc_params.atap_lls_secsz[0])); } else { wd->sc_blksize = 512; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Fri Jul 22 12:55:34 UTC 2016 Modified Files: src/sys/dev/ata: wd.c Log Message: Space before tab and trailing whitespace fixes. To generate a diff of this commit: cvs rdiff -u -r1.424 -r1.425 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.424 src/sys/dev/ata/wd.c:1.425 --- src/sys/dev/ata/wd.c:1.424 Fri Jul 22 04:08:10 2016 +++ src/sys/dev/ata/wd.c Fri Jul 22 12:55:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.424 2016/07/22 04:08:10 jakllsch Exp $ */ +/* $NetBSD: wd.c,v 1.425 2016/07/22 12:55:34 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.424 2016/07/22 04:08:10 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.425 2016/07/22 12:55:34 jakllsch Exp $"); #include "opt_ata.h" @@ -245,7 +245,7 @@ static const struct wd_quirk { WD_QUIRK_SPLIT_MOD15_WRITE }, { "ST380023AS", WD_QUIRK_SPLIT_MOD15_WRITE }, - { "ST360015AS", + { "ST360015AS", WD_QUIRK_SPLIT_MOD15_WRITE }, { NULL, 0 } @@ -847,7 +847,7 @@ retry2: */ if ((bp->b_flags & B_READ) && ((wd->drvp->ata_vers >= 4 && wd->sc_wdc_bio.r_error & 64) || - (wd->drvp->ata_vers < 4 && wd->sc_wdc_bio.r_error & 192))) { + (wd->drvp->ata_vers < 4 && wd->sc_wdc_bio.r_error & 192))) { struct disk_badsectors *dbs; dbs = malloc(sizeof *dbs, M_TEMP, M_WAITOK); @@ -1029,7 +1029,7 @@ wdopen(dev_t dev, int flag, int fmt, str return error; } -/* +/* * Caller must hold wd->sc_dk.dk_openlock. */ static int @@ -1494,7 +1494,7 @@ wdioctl(dev_t dev, u_long xfer, void *ad return 0; } - + case DIOCSSTRATEGY: { struct disk_strategy *dks = (void *)addr; @@ -1704,7 +1704,7 @@ wddump(dev_t dev, daddr_t blkno, void *v err = 0; break; default: - panic("wddump: unknown error type %d", err); + panic("wddump: unknown error type %d", err); } if (err != 0) { printf("\n");
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Fri Jul 22 04:08:10 UTC 2016 Modified Files: src/sys/dev/ata: wd.c wdvar.h Log Message: Add ATA8-ACS Long Logical Sector Feature Set support to wd(4). To generate a diff of this commit: cvs rdiff -u -r1.423 -r1.424 src/sys/dev/ata/wd.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ata/wdvar.h 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/wd.c diff -u src/sys/dev/ata/wd.c:1.423 src/sys/dev/ata/wd.c:1.424 --- src/sys/dev/ata/wd.c:1.423 Thu Jul 21 19:05:03 2016 +++ src/sys/dev/ata/wd.c Fri Jul 22 04:08:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.423 2016/07/21 19:05:03 jakllsch Exp $ */ +/* $NetBSD: wd.c,v 1.424 2016/07/22 04:08:10 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.423 2016/07/21 19:05:03 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.424 2016/07/22 04:08:10 jakllsch Exp $"); #include "opt_ata.h" @@ -391,7 +391,16 @@ wdattach(device_t parent, device_t self, wd->sc_params.atap_heads * wd->sc_params.atap_sectors; } - format_bytes(pbuf, sizeof(pbuf), wd->sc_capacity * DEV_BSIZE); + if ((wd->sc_params.atap_secsz & ATA_SECSZ_VALID_MASK) == ATA_SECSZ_VALID + && ((wd->sc_params.atap_secsz & ATA_SECSZ_LLS) != 0)) { + wd->sc_blksize = 2ULL * + (wd->sc_params.atap_lls_secsz[1] << 16 | + wd->sc_params.atap_lls_secsz[0] << 0); + } else { + wd->sc_blksize = 512; + } + wd->sc_capacity512 = (wd->sc_capacity * wd->sc_blksize) / DEV_BSIZE; + format_bytes(pbuf, sizeof(pbuf), wd->sc_capacity * wd->sc_blksize); aprint_normal_dev(self, "%s, %d cyl, %d head, %d sec, " "%d bytes/sect x %llu sectors\n", pbuf, @@ -399,11 +408,17 @@ wdattach(device_t parent, device_t self, (wd->sc_params.atap_heads * wd->sc_params.atap_sectors)) : wd->sc_params.atap_cylinders, wd->sc_params.atap_heads, wd->sc_params.atap_sectors, - DEV_BSIZE, (unsigned long long)wd->sc_capacity); + wd->sc_blksize, (unsigned long long)wd->sc_capacity); ATADEBUG_PRINT(("%s: atap_dmatiming_mimi=%d, atap_dmatiming_recom=%d\n", device_xname(self), wd->sc_params.atap_dmatiming_mimi, wd->sc_params.atap_dmatiming_recom), DEBUG_PROBE); + + if (wd->sc_blksize <= 0 || !powerof2(wd->sc_blksize) || + wd->sc_blksize < DEV_BSIZE || wd->sc_blksize > MAXPHYS) { + aprint_normal_dev(self, "WARNING: block size %u " + "might not actually work\n", wd->sc_blksize); + } out: /* * Initialize and attach the disk structure. @@ -544,7 +559,7 @@ wdstrategy(struct buf *bp) */ if (WDPART(bp->b_dev) == RAW_PART) { if (bounds_check_with_mediasize(bp, DEV_BSIZE, - wd->sc_capacity) <= 0) + wd->sc_capacity512) <= 0) goto done; } else { if (bounds_check_with_label(&wd->sc_dk, bp, @@ -577,7 +592,7 @@ wdstrategy(struct buf *bp) */ if (__predict_false(!SLIST_EMPTY(&wd->sc_bslist))) { struct disk_badsectors *dbs; - daddr_t maxblk = blkno + (bp->b_bcount >> DEV_BSHIFT) - 1; + daddr_t maxblk = blkno + (bp->b_bcount / wd->sc_blksize) - 1; SLIST_FOREACH(dbs, &wd->sc_bslist, dbs_next) if ((dbs->dbs_min <= blkno && blkno <= dbs->dbs_max) || @@ -664,8 +679,8 @@ wd_split_mod15_write(struct buf *bp) bp->b_oflags = obp->b_oflags; bp->b_cflags = obp->b_cflags; bp->b_data = (char *)bp->b_data + bp->b_bcount; - bp->b_blkno += (bp->b_bcount / 512); - bp->b_rawblkno += (bp->b_bcount / 512); + bp->b_blkno += (bp->b_bcount / DEV_BSIZE); + bp->b_rawblkno += (bp->b_bcount / sc->sc_blksize); s = splbio(); wdstart1(sc, bp); splx(s); @@ -837,7 +852,8 @@ retry2: dbs = malloc(sizeof *dbs, M_TEMP, M_WAITOK); dbs->dbs_min = bp->b_rawblkno; - dbs->dbs_max = dbs->dbs_min + (bp->b_bcount >> DEV_BSHIFT) - 1; + dbs->dbs_max = dbs->dbs_min + + (bp->b_bcount /wd->sc_blksize) - 1; microtime(&dbs->dbs_failedat); SLIST_INSERT_HEAD(&wd->sc_bslist, dbs, dbs_next); wd->sc_bscount++; @@ -894,9 +910,11 @@ wdrestart(void *v) static void wdminphys(struct buf *bp) { + const struct wd_softc * const wd = + device_lookup_private(&wd_cd, WDUNIT(bp->b_dev)); - if (bp->b_bcount > (512 * 128)) { - bp->b_bcount = (512 * 128); + if (bp->b_bcount > (wd->sc_blksize * 128)) { + bp->b_bcount = (wd->sc_blksize * 128); } minphys(bp); } @@ -1065,7 +1083,7 @@ wdgetdefaultlabel(struct wd_softc *wd, s ATADEBUG_PRINT(("wdgetdefaultlabel\n"), DEBUG_FUNCS); memset(lp, 0, sizeof(struct disklabel)); - lp->d_secsize = DEV_BSIZE; + lp->d_secsize = wd->sc_blksize; lp->d_ntracks = wd->sc_params.atap_heads; lp->d_nsectors = wd->sc_params.atap_sectors; lp->d_ncylinders = (wd->sc_flags & WDF_LBA) ? wd->sc_capacity / @@ -1537,8 +1555,8 @@ wddiscard(dev_t dev, off_t pos, off_t le return EIO; /* round the start up and the end down */ - bno = (pos + DE
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Thu Jul 21 19:05:03 UTC 2016 Modified Files: src/sys/dev/ata: wd.c Log Message: Call wd_params_to_properties() after softc is sufficently initialized. To generate a diff of this commit: cvs rdiff -u -r1.422 -r1.423 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.422 src/sys/dev/ata/wd.c:1.423 --- src/sys/dev/ata/wd.c:1.422 Thu Jul 21 18:54:13 2016 +++ src/sys/dev/ata/wd.c Thu Jul 21 19:05:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.422 2016/07/21 18:54:13 jakllsch Exp $ */ +/* $NetBSD: wd.c,v 1.423 2016/07/21 19:05:03 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.422 2016/07/21 18:54:13 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.423 2016/07/21 19:05:03 jakllsch Exp $"); #include "opt_ata.h" @@ -194,6 +194,7 @@ void wdstart(void *); void wdstart1(struct wd_softc*, struct buf *); void wdrestart(void *); void wddone(void *); +static void wd_params_to_properties(struct wd_softc *); int wd_get_params(struct wd_softc *, uint8_t, struct ataparams *); int wd_flushcache(struct wd_softc *, int); int wd_trim(struct wd_softc *, int, daddr_t, long); @@ -411,6 +412,7 @@ out: disk_init(&wd->sc_dk, device_xname(wd->sc_dev), &wddkdriver); disk_attach(&wd->sc_dk); wd->sc_wdc_bio.lp = wd->sc_dk.dk_label; + wd_params_to_properties(wd); rnd_attach_source(&wd->rnd_source, device_xname(wd->sc_dev), RND_TYPE_DISK, RND_FLAG_DEFAULT); @@ -1774,7 +1776,6 @@ wd_get_params(struct wd_softc *wd, uint8 wd->drvp->ata_vers = -1; /* Mark it as pre-ATA */ /* FALLTHROUGH */ case CMD_OK: - wd_params_to_properties(wd); return 0; default: panic("wd_get_params: bad return code from ata_get_params");
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Thu Jul 21 18:54:13 UTC 2016 Modified Files: src/sys/dev/ata: wd.c Log Message: Remove unused 'params' argument of local function wd_params_to_properties() To generate a diff of this commit: cvs rdiff -u -r1.421 -r1.422 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.421 src/sys/dev/ata/wd.c:1.422 --- src/sys/dev/ata/wd.c:1.421 Sun Jun 19 09:35:06 2016 +++ src/sys/dev/ata/wd.c Thu Jul 21 18:54:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.421 2016/06/19 09:35:06 bouyer Exp $ */ +/* $NetBSD: wd.c,v 1.422 2016/07/21 18:54:13 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.421 2016/06/19 09:35:06 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.422 2016/07/21 18:54:13 jakllsch Exp $"); #include "opt_ata.h" @@ -1728,7 +1728,7 @@ bad144intern(struct wd_softc *wd) #endif static void -wd_params_to_properties(struct wd_softc *wd, struct ataparams *params) +wd_params_to_properties(struct wd_softc *wd) { struct disk_geom *dg = &wd->sc_dk.dk_geom; @@ -1774,7 +1774,7 @@ wd_get_params(struct wd_softc *wd, uint8 wd->drvp->ata_vers = -1; /* Mark it as pre-ATA */ /* FALLTHROUGH */ case CMD_OK: - wd_params_to_properties(wd, params); + wd_params_to_properties(wd); return 0; default: panic("wd_get_params: bad return code from ata_get_params");
CVS commit: src/sys/dev/ata
Module Name:src Committed By: mlelstv Date: Sat Oct 11 14:05:12 UTC 2014 Modified Files: src/sys/dev/ata: wd.c Log Message: The partition size is always computed in native blocks. The code also assumes that native blocks are always DEVB_SIZE (a few lines earlier) which makes the current calculation a no-op. To generate a diff of this commit: cvs rdiff -u -r1.413 -r1.414 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.413 src/sys/dev/ata/wd.c:1.414 --- src/sys/dev/ata/wd.c:1.413 Wed Sep 10 07:04:48 2014 +++ src/sys/dev/ata/wd.c Sat Oct 11 14:05:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.413 2014/09/10 07:04:48 matt Exp $ */ +/* $NetBSD: wd.c,v 1.414 2014/10/11 14:05:11 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.413 2014/09/10 07:04:48 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.414 2014/10/11 14:05:11 mlelstv Exp $"); #include "opt_ata.h" @@ -1082,8 +1082,7 @@ wdgetdefaultlabel(struct wd_softc *wd, s lp->d_flags = 0; lp->d_partitions[RAW_PART].p_offset = 0; - lp->d_partitions[RAW_PART].p_size = - lp->d_secperunit * (lp->d_secsize / DEV_BSIZE); + lp->d_partitions[RAW_PART].p_size = lp->d_secperunit; lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED; lp->d_npartitions = RAW_PART + 1;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: matt Date: Wed Sep 10 07:04:48 UTC 2014 Modified Files: src/sys/dev/ata: ata.c ata_raidreg.h ata_wdc.c atavar.h wd.c wdvar.h Log Message: g/u_int[0-9]*_t/ s/u_int/uint/g To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/sys/dev/ata/ata.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/ata_raidreg.h cvs rdiff -u -r1.103 -r1.104 src/sys/dev/ata/ata_wdc.c cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.412 -r1.413 src/sys/dev/ata/wd.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/ata/wdvar.h 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.131 src/sys/dev/ata/ata.c:1.132 --- src/sys/dev/ata/ata.c:1.131 Fri Jul 25 08:10:36 2014 +++ src/sys/dev/ata/ata.c Wed Sep 10 07:04:48 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.131 2014/07/25 08:10:36 dholland Exp $ */ +/* $NetBSD: ata.c,v 1.132 2014/09/10 07:04:48 matt Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.131 2014/07/25 08:10:36 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132 2014/09/10 07:04:48 matt Exp $"); #include "opt_ata.h" @@ -724,7 +724,7 @@ atabus_free_drives(struct ata_channel *c /* Get the disk's parameters */ int -ata_get_params(struct ata_drive_datas *drvp, u_int8_t flags, +ata_get_params(struct ata_drive_datas *drvp, uint8_t flags, struct ataparams *prms) { struct ata_command ata_c; @@ -732,7 +732,7 @@ ata_get_params(struct ata_drive_datas *d struct atac_softc *atac = chp->ch_atac; char *tb; int i, rv; - u_int16_t *p; + uint16_t *p; ATADEBUG_PRINT(("%s\n", __func__), DEBUG_FUNCS); @@ -806,15 +806,15 @@ ata_get_params(struct ata_drive_datas *d } #undef M for (i = 0; i < sizeof(prms->atap_model); i += 2) { - p = (u_int16_t *)(prms->atap_model + i); + p = (uint16_t *)(prms->atap_model + i); *p = bswap16(*p); } for (i = 0; i < sizeof(prms->atap_serial); i += 2) { - p = (u_int16_t *)(prms->atap_serial + i); + p = (uint16_t *)(prms->atap_serial + i); *p = bswap16(*p); } for (i = 0; i < sizeof(prms->atap_revision); i += 2) { - p = (u_int16_t *)(prms->atap_revision + i); + p = (uint16_t *)(prms->atap_revision + i); *p = bswap16(*p); } @@ -825,7 +825,7 @@ ata_get_params(struct ata_drive_datas *d } int -ata_set_mode(struct ata_drive_datas *drvp, u_int8_t mode, u_int8_t flags) +ata_set_mode(struct ata_drive_datas *drvp, uint8_t mode, uint8_t flags) { struct ata_command ata_c; struct ata_channel *chp = drvp->chnl_softc; Index: src/sys/dev/ata/ata_raidreg.h diff -u src/sys/dev/ata/ata_raidreg.h:1.8 src/sys/dev/ata/ata_raidreg.h:1.9 --- src/sys/dev/ata/ata_raidreg.h:1.8 Thu Sep 11 11:08:50 2008 +++ src/sys/dev/ata/ata_raidreg.h Wed Sep 10 07:04:48 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raidreg.h,v 1.8 2008/09/11 11:08:50 tron Exp $ */ +/* $NetBSD: ata_raidreg.h,v 1.9 2014/09/10 07:04:48 matt Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt @@ -207,30 +207,30 @@ struct via_raid_conf { #define NVIDIA_LBA(wd) ((wd)->sc_capacity - 2) struct nvidia_raid_conf { -u_int8_tnvidia_id[8]; +uint8_tnvidia_id[8]; #define NV_MAGIC"NVIDIA " -u_int32_t config_size; -u_int32_t checksum; -u_int16_t version; -u_int8_tdisk_number; -u_int8_tdummy_0; -u_int32_t total_sectors; -u_int32_t sector_size; -u_int8_tserial[16]; -u_int8_trevision[4]; -u_int32_t dummy_1; +uint32_t config_size; +uint32_t checksum; +uint16_t version; +uint8_tdisk_number; +uint8_tdummy_0; +uint32_t total_sectors; +uint32_t sector_size; +uint8_tserial[16]; +uint8_trevision[4]; +uint32_t dummy_1; -u_int32_t magic_0; +uint32_t magic_0; #define NV_MAGIC0 0x00640044 -u_int64_t magic_1; -u_int64_t magic_2; -u_int8_tflags; -u_int8_tarray_width; -u_int8_ttotal_disks; -u_int8_tdummy_2; -u_int16_t type; +uint64_t magic_1; +uint64_t magic_2; +uint8_tflags; +uint8_tarray_width; +uint8_ttotal_disks; +uint8_tdummy_2; +uint16_t type; #define NV_T_RAID0 0x0080 #define NV_T_RAID1 0x0081 #define NV_T_RAID3 0x0083 @@ -238,21 +238,21 @@ struct nvidia_raid_conf { #define NV_T_RAID01 0x8180 #define NV_T_SPAN 0x00ff -
CVS commit: src/sys/dev/ata
Module Name:src Committed By: dholland Date: Fri Jul 25 08:34:27 UTC 2014 Modified Files: src/sys/dev/ata: wd.c Log Message: Drop the old discard/trim ioctls from wd.c. To generate a diff of this commit: cvs rdiff -u -r1.410 -r1.411 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.410 src/sys/dev/ata/wd.c:1.411 --- src/sys/dev/ata/wd.c:1.410 Fri Jul 25 08:22:08 2014 +++ src/sys/dev/ata/wd.c Fri Jul 25 08:34:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.410 2014/07/25 08:22:08 dholland Exp $ */ +/* $NetBSD: wd.c,v 1.411 2014/07/25 08:34:27 dholland Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.410 2014/07/25 08:22:08 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.411 2014/07/25 08:34:27 dholland Exp $"); #include "opt_ata.h" @@ -1552,24 +1552,6 @@ wdioctl(dev_t dev, u_long xfer, void *ad return 0; } - case DIOCGDISCARDPARAMS: { - struct disk_discard_params * tp; - - if (!(wd->sc_params.atap_ata_major & WDC_VER_ATA7) - || !(wd->sc_params.support_dsm & ATA_SUPPORT_DSM_TRIM)) - return ENOTTY; - tp = (struct disk_discard_params *)addr; - tp->maxsize = 0x; /*wd->sc_params.max_dsm_blocks*/ - aprint_debug_dev(wd->sc_dev, "TRIM maxsize %ld\n", tp->maxsize); - return 0; - } - case DIOCDISCARD: { - struct disk_discard_range *dr; - - dr = addr; - return wd_trim(wd, WDPART(dev), dr->bno, dr->size); - } - default: return ENOTTY; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: dholland Date: Fri Jul 25 08:22:08 UTC 2014 Modified Files: src/sys/dev/ata: wd.c Log Message: Implement d_discard for wd. To generate a diff of this commit: cvs rdiff -u -r1.409 -r1.410 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.409 src/sys/dev/ata/wd.c:1.410 --- src/sys/dev/ata/wd.c:1.409 Fri Jul 25 08:10:36 2014 +++ src/sys/dev/ata/wd.c Fri Jul 25 08:22:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.409 2014/07/25 08:10:36 dholland Exp $ */ +/* $NetBSD: wd.c,v 1.410 2014/07/25 08:22:08 dholland Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.409 2014/07/25 08:10:36 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.410 2014/07/25 08:22:08 dholland Exp $"); #include "opt_ata.h" @@ -140,6 +140,7 @@ dev_type_ioctl(wdioctl); dev_type_strategy(wdstrategy); dev_type_dump(wddump); dev_type_size(wdsize); +static dev_type_discard(wddiscard); const struct bdevsw wd_bdevsw = { .d_open = wdopen, @@ -148,7 +149,7 @@ const struct bdevsw wd_bdevsw = { .d_ioctl = wdioctl, .d_dump = wddump, .d_psize = wdsize, - .d_discard = nodiscard, + .d_discard = wddiscard, .d_flag = D_DISK }; @@ -163,7 +164,7 @@ const struct cdevsw wd_cdevsw = { .d_poll = nopoll, .d_mmap = nommap, .d_kqfilter = nokqfilter, - .d_discard = nodiscard, + .d_discard = wddiscard, .d_flag = D_DISK }; @@ -195,7 +196,7 @@ void wdrestart(void *); void wddone(void *); int wd_get_params(struct wd_softc *, u_int8_t, struct ataparams *); int wd_flushcache(struct wd_softc *, int); -int wd_trim(struct wd_softc *, int, struct disk_discard_range *); +int wd_trim(struct wd_softc *, int, daddr_t, long); bool wd_shutdown(device_t, int); int wd_getcache(struct wd_softc *, int *); @@ -1562,8 +1563,12 @@ wdioctl(dev_t dev, u_long xfer, void *ad aprint_debug_dev(wd->sc_dev, "TRIM maxsize %ld\n", tp->maxsize); return 0; } - case DIOCDISCARD: - return wd_trim(wd, WDPART(dev), (struct disk_discard_range *)addr); + case DIOCDISCARD: { + struct disk_discard_range *dr; + + dr = addr; + return wd_trim(wd, WDPART(dev), dr->bno, dr->size); + } default: return ENOTTY; @@ -1574,6 +1579,47 @@ wdioctl(dev_t dev, u_long xfer, void *ad #endif } +static int +wddiscard(dev_t dev, off_t pos, off_t len) +{ + struct wd_softc *wd = device_lookup_private(&wd_cd, WDUNIT(dev)); + daddr_t bno; + long size, done; + long maxatonce, amount; + int result; + + if (!(wd->sc_params.atap_ata_major & WDC_VER_ATA7) + || !(wd->sc_params.support_dsm & ATA_SUPPORT_DSM_TRIM)) { + /* not supported; ignore request */ + ATADEBUG_PRINT(("wddiscard (unsupported)\n"), DEBUG_FUNCS); + return 0; + } + maxatonce = 0x; /*wd->sc_params.max_dsm_blocks*/ + + ATADEBUG_PRINT(("wddiscard\n"), DEBUG_FUNCS); + + if ((wd->sc_flags & WDF_LOADED) == 0) + return EIO; + + /* round the start up and the end down */ + bno = (pos + DEV_BSIZE - 1) >> DEV_BSHIFT; + size = ((pos + len) >> DEV_BSHIFT) - bno; + + done = 0; + while (done < size) { + amount = size - done; + if (amount > maxatonce) { + amount = maxatonce; + } + result = wd_trim(wd, WDPART(dev), bno + done, amount); + if (result) { + return result; + } + done += amount; + } + return 0; +} + #ifdef B_FORMAT int wdformat(struct buf *bp) @@ -1940,11 +1986,10 @@ wd_flushcache(struct wd_softc *wd, int f } int -wd_trim(struct wd_softc *wd, int part, struct disk_discard_range *tr) +wd_trim(struct wd_softc *wd, int part, daddr_t bno, long size) { struct ata_command ata_c; unsigned char *req; - daddr_t bno = tr->bno; if (part != RAW_PART) bno += wd->sc_dk.dk_label->d_partitions[part].p_offset;; @@ -1956,8 +2001,8 @@ wd_trim(struct wd_softc *wd, int part, s req[3] = (bno >> 24) & 0xff; req[4] = (bno >> 32) & 0xff; req[5] = (bno >> 40) & 0xff; - req[6] = tr->size & 0xff; - req[7] = (tr->size >> 8) & 0xff; + req[6] = size & 0xff; + req[7] = (size >> 8) & 0xff; memset(&ata_c, 0, sizeof(struct ata_command)); ata_c.r_command = ATA_DATA_SET_MANAGEMENT;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: drochner Date: Wed Oct 30 15:41:14 UTC 2013 Modified Files: src/sys/dev/ata: wd.c Log Message: play the addref/delref game on suspend, prevents crash if the disk/CF Card is eg. in a PCMCIA adapter and not mounted To generate a diff of this commit: cvs rdiff -u -r1.405 -r1.406 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.405 src/sys/dev/ata/wd.c:1.406 --- src/sys/dev/ata/wd.c:1.405 Mon Aug 19 14:58:57 2013 +++ src/sys/dev/ata/wd.c Wed Oct 30 15:41:14 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.405 2013/08/19 14:58:57 skrll Exp $ */ +/* $NetBSD: wd.c,v 1.406 2013/10/30 15:41:14 drochner Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.405 2013/08/19 14:58:57 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.406 2013/10/30 15:41:14 drochner Exp $"); #include "opt_ata.h" @@ -405,8 +405,14 @@ wd_suspend(device_t dv, const pmf_qual_t { struct wd_softc *sc = device_private(dv); + /* the adapter needs to be enabled */ + if (sc->atabus->ata_addref(sc->drvp)) + return true; /* no need to complain */ + wd_flushcache(sc, AT_WAIT); wd_standby(sc, AT_WAIT); + + sc->atabus->ata_delref(sc->drvp); return true; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: skrll Date: Mon Aug 19 14:58:57 UTC 2013 Modified Files: src/sys/dev/ata: wd.c Log Message: Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL To generate a diff of this commit: cvs rdiff -u -r1.404 -r1.405 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.404 src/sys/dev/ata/wd.c:1.405 --- src/sys/dev/ata/wd.c:1.404 Tue Aug 6 19:13:13 2013 +++ src/sys/dev/ata/wd.c Mon Aug 19 14:58:57 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.404 2013/08/06 19:13:13 soren Exp $ */ +/* $NetBSD: wd.c,v 1.405 2013/08/19 14:58:57 skrll Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.404 2013/08/06 19:13:13 soren Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.405 2013/08/19 14:58:57 skrll Exp $"); #include "opt_ata.h" @@ -1169,7 +1169,7 @@ wdioctl(dev_t dev, u_long xfer, void *ad { struct wd_softc *wd = device_lookup_private(&wd_cd, WDUNIT(dev)); - int error = 0, s; + int error, s; #ifdef __HAVE_OLD_DISKLABEL struct disklabel *newlabel = NULL; #endif @@ -1183,6 +1183,7 @@ wdioctl(dev_t dev, u_long xfer, void *ad if (error != EPASSTHROUGH) return (error); + error = 0; switch (xfer) { #ifdef HAS_BAD144_HANDLING case DIOCSBAD:
CVS commit: src/sys/dev/ata
Module Name:src Committed By: blymn Date: Wed Aug 7 12:50:17 UTC 2013 Modified Files: src/sys/dev/ata: ata.c Log Message: Make sure a channel has drives attached before resetting it otherwise wdc_reset will panic the kernel due to a null derefrence of ch_drives. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/dev/ata/ata.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.127 src/sys/dev/ata/ata.c:1.128 --- src/sys/dev/ata/ata.c:1.127 Wed Apr 3 17:15:07 2013 +++ src/sys/dev/ata/ata.c Wed Aug 7 12:50:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.127 2013/04/03 17:15:07 bouyer Exp $ */ +/* $NetBSD: ata.c,v 1.128 2013/08/07 12:50:17 blymn Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.127 2013/04/03 17:15:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.128 2013/08/07 12:50:17 blymn Exp $"); #include "opt_ata.h" @@ -1678,7 +1678,10 @@ atabus_resume(device_t dv, const pmf_qua KASSERT(chp->ch_queue->queue_freeze > 0); /* unfreeze the queue and reset drives */ chp->ch_queue->queue_freeze--; - ata_reset_channel(chp, AT_WAIT); + + /* reset channel only if there are drives attached */ + if (chp->ch_ndrives > 0) + ata_reset_channel(chp, AT_WAIT); splx(s); return true;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Fri May 3 20:02:09 UTC 2013 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: Wait for DRDY after the PMP commands and don't wait before. Should fix the worst part of PR kern/47793. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.11 src/sys/dev/ata/satapmp_subr.c:1.12 --- src/sys/dev/ata/satapmp_subr.c:1.11 Wed Apr 17 12:22:43 2013 +++ src/sys/dev/ata/satapmp_subr.c Fri May 3 20:02:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.12 2013/05/03 20:02:08 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.12 2013/05/03 20:02:08 jakllsch Exp $"); #include #include @@ -66,8 +66,8 @@ satapmp_read_8(struct ata_channel *chp, ata_c.r_features = reg; ata_c.r_device = port; ata_c.timeout = 3000; /* 3s */ - ata_c.r_st_bmask = WDCS_DRDY; - ata_c.r_st_pmask = 0; + ata_c.r_st_bmask = 0; + ata_c.r_st_pmask = WDCS_DRDY; ata_c.flags = AT_LBA48 | AT_READREG | AT_WAIT; if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, @@ -134,8 +134,8 @@ satapmp_write_8(struct ata_channel *chp, ata_c.r_count = (((value >> 32) & 0xff) << 8) | (((value >> 0) & 0xff) << 0); ata_c.timeout = 3000; /* 3s */ - ata_c.r_st_bmask = WDCS_DRDY; - ata_c.r_st_pmask = 0; + ata_c.r_st_bmask = 0; + ata_c.r_st_pmask = WDCS_DRDY; ata_c.flags = AT_LBA48 | AT_WAIT; if ((*atac->atac_bustype_ata->ata_exec_command)(drvp,
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Wed Apr 17 12:22:44 UTC 2013 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: Also print port multiplier port number when register accesses fail. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.10 src/sys/dev/ata/satapmp_subr.c:1.11 --- src/sys/dev/ata/satapmp_subr.c:1.10 Wed Aug 1 09:38:55 2012 +++ src/sys/dev/ata/satapmp_subr.c Wed Apr 17 12:22:43 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.10 2012/08/01 09:38:55 bouyer Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.10 2012/08/01 09:38:55 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.11 2013/04/17 12:22:43 jakllsch Exp $"); #include #include @@ -73,19 +73,19 @@ satapmp_read_8(struct ata_channel *chp, if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, &ata_c) != ATACMD_COMPLETE) { aprint_error_dev(chp->atabus, - "PMP register %d read failed\n", reg); + "PMP port %d register %d read failed\n", port, reg); return EIO; } if (ata_c.flags & (AT_TIMEOU | AT_DF)) { aprint_error_dev(chp->atabus, - "PMP register %d read failed, flags 0x%x\n", - reg, ata_c.flags); + "PMP port %d register %d read failed, flags 0x%x\n", + port, reg, ata_c.flags); return EIO; } if (ata_c.flags & AT_ERROR) { aprint_verbose_dev(chp->atabus, - "PMP register %d read failed, error 0x%x\n", - reg, ata_c.r_error); + "PMP port %d register %d read failed, error 0x%x\n", + port, reg, ata_c.r_error); return EIO; } @@ -141,19 +141,19 @@ satapmp_write_8(struct ata_channel *chp, if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, &ata_c) != ATACMD_COMPLETE) { aprint_error_dev(chp->atabus, - "PMP register %d write failed\n", reg); + "PMP port %d register %d write failed\n", port, reg); return EIO; } if (ata_c.flags & (AT_TIMEOU | AT_DF)) { aprint_error_dev(chp->atabus, - "PMP register %d write failed, flags 0x%x\n", - reg, ata_c.flags); + "PMP port %d register %d write failed, flags 0x%x\n", + port, reg, ata_c.flags); return EIO; } if (ata_c.flags & AT_ERROR) { aprint_verbose_dev(chp->atabus, - "PMP register %d write failed, error 0x%x\n", - reg, ata_c.r_error); + "PMP port %d register %d write failed, error 0x%x\n", + port, reg, ata_c.r_error); return EIO; } return 0;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: riastradh Date: Wed Jan 9 22:03:49 UTC 2013 Modified Files: src/sys/dev/ata: wd.c Log Message: Initialize b_resid before biodone in wdioctlstrategy error branch. Otherwise we may panic when physio's biodone callback kasserts something about b_resid, since nothing will have initialized it. To generate a diff of this commit: cvs rdiff -u -r1.401 -r1.402 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.401 src/sys/dev/ata/wd.c:1.402 --- src/sys/dev/ata/wd.c:1.401 Fri Oct 19 17:09:07 2012 +++ src/sys/dev/ata/wd.c Wed Jan 9 22:03:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.401 2012/10/19 17:09:07 drochner Exp $ */ +/* $NetBSD: wd.c,v 1.402 2013/01/09 22:03:49 riastradh Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.401 2012/10/19 17:09:07 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.402 2013/01/09 22:03:49 riastradh Exp $"); #include "opt_ata.h" @@ -2195,5 +2195,6 @@ wdioctlstrategy(struct buf *bp) return; bad: bp->b_error = error; + bp->b_resid = bp->b_bcount; biodone(bp); }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: riastradh Date: Wed Jan 9 17:55:04 UTC 2013 Modified Files: src/sys/dev/ata: atareg.h Log Message: Name the ATA SECURITY commands. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/ata/atareg.h 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/atareg.h diff -u src/sys/dev/ata/atareg.h:1.41 src/sys/dev/ata/atareg.h:1.42 --- src/sys/dev/ata/atareg.h:1.41 Fri Oct 19 17:09:07 2012 +++ src/sys/dev/ata/atareg.h Wed Jan 9 17:55:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: atareg.h,v 1.41 2012/10/19 17:09:07 drochner Exp $ */ +/* $NetBSD: atareg.h,v 1.42 2013/01/09 17:55:04 riastradh Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -127,7 +127,13 @@ #define WDCC_STANDBY_IMMED 0xe0 /* enter standby mode */ #define WDCC_CHECK_PWR 0xe5 /* check power mode */ -#define WDCC_SECURITY_FREEZE 0xf5 /* freeze locking state */ +/* Security feature set */ +#define WDCC_SECURITY_SET_PASSWORD 0xf1 +#define WDCC_SECURITY_UNLOCK 0xf2 +#define WDCC_SECURITY_ERASE_PREPARE 0xf3 +#define WDCC_SECURITY_ERASE_UNIT 0xf4 +#define WDCC_SECURITY_FREEZE 0xf5 +#define WDCC_SECURITY_DISABLE_PASSWORD 0xf6 /* Big Drive support */ #define WDCC_READ_EXT 0x24 /* read 48-bit addressing */
CVS commit: src/sys/dev/ata
Module Name:src Committed By: abs Date: Thu Nov 1 13:46:52 UTC 2012 Modified Files: src/sys/dev/ata: ata.c Log Message: Allow setting ATADEBUG_MASK to default value of atadebug_mask To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/dev/ata/ata.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.125 src/sys/dev/ata/ata.c:1.126 --- src/sys/dev/ata/ata.c:1.125 Sat Aug 4 21:21:09 2012 +++ src/sys/dev/ata/ata.c Thu Nov 1 13:46:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.125 2012/08/04 21:21:09 bouyer Exp $ */ +/* $NetBSD: ata.c,v 1.126 2012/11/01 13:46:52 abs Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.125 2012/08/04 21:21:09 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.126 2012/11/01 13:46:52 abs Exp $"); #include "opt_ata.h" @@ -70,7 +70,10 @@ __KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.12 #define DEBUG_DETACH 0x20 #define DEBUG_XFERS 0x40 #ifdef ATADEBUG -int atadebug_mask = 0; +#ifndef ATADEBUG_MASK +#define ATADEBUG_MASK 0 +#endif +int atadebug_mask = ATADEBUG_MASK; #define ATADEBUG_PRINT(args, level) \ if (atadebug_mask & (level)) \ printf args
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Sat Aug 4 21:21:10 UTC 2012 Modified Files: src/sys/dev/ata: ata.c Log Message: If ch_ndrives is > 0, then ch_drive is not supposed to be NULL. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/dev/ata/ata.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.124 src/sys/dev/ata/ata.c:1.125 --- src/sys/dev/ata/ata.c:1.124 Tue Jul 31 15:50:34 2012 +++ src/sys/dev/ata/ata.c Sat Aug 4 21:21:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.124 2012/07/31 15:50:34 bouyer Exp $ */ +/* $NetBSD: ata.c,v 1.125 2012/08/04 21:21:09 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.124 2012/07/31 15:50:34 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.125 2012/08/04 21:21:09 bouyer Exp $"); #include "opt_ata.h" @@ -212,7 +212,7 @@ atabusconfig(struct atabus_softc *atabus if (chp->ch_satapmp_nports == 0) (*atac->atac_probe)(chp); - if (chp->ch_drive != NULL && chp->ch_ndrives >= 2) { + if (chp->ch_ndrives >= 2) { ATADEBUG_PRINT(("atabusattach: ch_drive_type 0x%x 0x%x\n", chp->ch_drive[0].drive_type, chp->ch_drive[1].drive_type), DEBUG_PROBE);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Wed Aug 1 09:38:55 UTC 2012 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: Make this compile again after DRIVET rename To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.9 src/sys/dev/ata/satapmp_subr.c:1.10 --- src/sys/dev/ata/satapmp_subr.c:1.9 Wed Aug 1 09:02:03 2012 +++ src/sys/dev/ata/satapmp_subr.c Wed Aug 1 09:38:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.9 2012/08/01 09:02:03 bouyer Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.10 2012/08/01 09:38:55 bouyer Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.9 2012/08/01 09:02:03 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.10 2012/08/01 09:38:55 bouyer Exp $"); #include #include @@ -229,7 +229,7 @@ satapmp_rescan(struct ata_channel *chp) KASSERT(chp->ch_satapmp_nports <= chp->ch_ndrives); for (i = 0; i < chp->ch_satapmp_nports; i++) { - if (chp->ch_drive[i].drive_type != DRIVET_NONE || + if (chp->ch_drive[i].drive_type != ATA_DRIVET_NONE || satapmp_reset_device_port(chp, i) != SStatus_DET_DEV) { continue; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Wed Aug 1 09:02:04 UTC 2012 Added Files: src/sys/dev/ata: satapmp_subr.c satapmpvar.h Log Message: Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc cleanup and SATA PMP support), now that I'm back to fix the fallouts. To generate a diff of this commit: cvs rdiff -u -r0 -r1.9 src/sys/dev/ata/satapmp_subr.c cvs rdiff -u -r0 -r1.3 src/sys/dev/ata/satapmpvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/dev/ata/satapmp_subr.c diff -u /dev/null src/sys/dev/ata/satapmp_subr.c:1.9 --- /dev/null Wed Aug 1 09:02:04 2012 +++ src/sys/dev/ata/satapmp_subr.c Wed Aug 1 09:02:03 2012 @@ -0,0 +1,278 @@ +/* $NetBSD: satapmp_subr.c,v 1.9 2012/08/01 09:02:03 bouyer Exp $ */ + +/* + * Copyright (c) 2012 Manuel Bouyer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.9 2012/08/01 09:02:03 bouyer Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +static int +satapmp_read_8(struct ata_channel *chp, int port, int reg, uint64_t *value) +{ + struct ata_command ata_c; + struct atac_softc *atac = chp->ch_atac; + struct ata_drive_datas *drvp; + + KASSERT(port < PMP_MAX_DRIVES); + KASSERT(reg < PMP_GSCR_NREGS); + KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); + drvp = &chp->ch_drive[PMP_PORT_CTL]; + KASSERT(drvp->drive == PMP_PORT_CTL); + + memset(&ata_c, 0, sizeof(struct ata_command)); + + ata_c.r_command = PMPC_READ_PORT; + ata_c.r_features = reg; + ata_c.r_device = port; + ata_c.timeout = 3000; /* 3s */ + ata_c.r_st_bmask = WDCS_DRDY; + ata_c.r_st_pmask = 0; + ata_c.flags = AT_LBA48 | AT_READREG | AT_WAIT; + + if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, + &ata_c) != ATACMD_COMPLETE) { + aprint_error_dev(chp->atabus, + "PMP register %d read failed\n", reg); + return EIO; + } + if (ata_c.flags & (AT_TIMEOU | AT_DF)) { + aprint_error_dev(chp->atabus, + "PMP register %d read failed, flags 0x%x\n", + reg, ata_c.flags); + return EIO; + } + if (ata_c.flags & AT_ERROR) { + aprint_verbose_dev(chp->atabus, + "PMP register %d read failed, error 0x%x\n", + reg, ata_c.r_error); + return EIO; + } + + *value = ((uint64_t)((ata_c.r_lba >> 24) & 0xff) << 40) | + ((uint64_t)((ata_c.r_count >> 8) & 0xff) << 32) | + ((uint64_t)((ata_c.r_lba >> 0) & 0xff) << 8) | + ((uint64_t)((ata_c.r_count >> 0) & 0xff) << 0); + + return 0; +} + +static inline int +satapmp_read(struct ata_channel *chp, int port, int reg, uint32_t *value) +{ + uint64_t value64; + int ret; + + ret = satapmp_read_8(chp, port, reg, &value64); + if (ret) + return ret; + + *value = value64 & 0x; + return ret; +} + +static int +satapmp_write_8(struct ata_channel *chp, int port, int reg, uint64_t value) +{ + struct ata_command ata_c; + struct atac_softc *atac = chp->ch_atac; + struct ata_drive_datas *drvp; + + KASSERT(port < PMP_MAX_DRIVES); + KASSERT(reg < PMP_GSCR_NREGS); + KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); + drvp = &chp->ch_drive[PMP_PORT_CTL]; + KASSERT(drvp->drive == PMP_PORT_CTL); + + memset(&ata_c, 0, sizeof(struct ata_command)); + + ata_c.r_command = PMPC_WRITE_PORT; + ata_c.r_features = reg; + ata_c.r_device = port; + ata_c.r_lba = (((value >> 40) & 0xff) << 24) | + (((value >> 8) & 0xff) << 0); + ata_c.r_count = (((value >> 32) & 0xff) << 8) | + (((value >> 0) & 0xff) << 0); + ata_c.timeout = 3000; /* 3s */ + ata_c.r_st_bmask = WDCS_DRDY; + ata_c.r_st_pmask = 0;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 29 21:10:50 UTC 2012 Modified Files: src/sys/dev/ata: ata.c atavar.h Log Message: Remove ata_channel->ata_drives, it's redundant with the pointer in ata_drive_datas. Originally part of a commit by bouyer@. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/dev/ata/ata.c cvs rdiff -u -r1.88 -r1.89 src/sys/dev/ata/atavar.h 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.122 src/sys/dev/ata/ata.c:1.123 --- src/sys/dev/ata/ata.c:1.122 Thu Jul 26 20:49:47 2012 +++ src/sys/dev/ata/ata.c Sun Jul 29 21:10:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.122 2012/07/26 20:49:47 jakllsch Exp $ */ +/* $NetBSD: ata.c,v 1.123 2012/07/29 21:10:50 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.122 2012/07/26 20:49:47 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.123 2012/07/29 21:10:50 jakllsch Exp $"); #include "opt_ata.h" @@ -307,9 +307,10 @@ atabusconfig_thread(void *arg) adev.adev_channel = chp->ch_channel; adev.adev_openings = 1; adev.adev_drv_data = &chp->ch_drive[i]; - chp->ata_drives[i] = config_found_ia(atabus_sc->sc_dev, + KASSERT(chp->ch_drive[i].drv_softc == NULL); + chp->ch_drive[i].drv_softc = config_found_ia(atabus_sc->sc_dev, "ata_hl", &adev, ataprint); - if (chp->ata_drives[i] != NULL) + if (chp->ch_drive[i].drv_softc != NULL) ata_probe_caps(&chp->ch_drive[i]); else { s = splbio(); @@ -325,10 +326,15 @@ atabusconfig_thread(void *arg) ata_print_modes(chp); } #if NATARAID > 0 - if (atac->atac_cap & ATAC_CAP_RAID) - for (i = 0; i < chp->ch_ndrive; i++) - if (chp->ata_drives[i] != NULL) -ata_raid_check_component(chp->ata_drives[i]); + if (atac->atac_cap & ATAC_CAP_RAID) { + for (i = 0; i < chp->ch_ndrive; i++) { + if ((chp->ch_drive[i].drv_softc != NULL) && + (chp->ch_drive[i].drive_flags & DRIVE_ATA)) { +ata_raid_check_component( +chp->ch_drive[i].drv_softc); + } + } + } #endif /* NATARAID > 0 */ /* @@ -528,16 +534,15 @@ atabus_detach(device_t self, int flags) for (i = 0; i < chp->ch_ndrive; i++) { if (chp->ch_drive[i].drive_flags & DRIVE_ATAPI) continue; - if ((dev = chp->ata_drives[i]) != NULL) { + if ((dev = chp->ch_drive[i].drv_softc) != NULL) { ATADEBUG_PRINT(("%s.%d: %s: detaching %s\n", __func__, __LINE__, device_xname(self), device_xname(dev)), DEBUG_DETACH); - KASSERT(chp->ch_drive[i].drv_softc == - chp->ata_drives[i]); error = config_detach(dev, flags); if (error) goto out; - KASSERT(chp->ata_drives[i] == NULL); + KASSERT(chp->ch_drive[i].drv_softc == NULL); + KASSERT((chp->ch_drive[i].drive_flags & DRIVE) == 0); } } @@ -574,10 +579,7 @@ atabus_childdetached(device_t self, devi for (i = 0; i < chp->ch_ndrive; i++) { if (chp->ch_drive[i].drive_flags & DRIVE_ATAPI) continue; - if (child == chp->ata_drives[i]) { - KASSERT(chp->ata_drives[i] == - chp->ch_drive[i].drv_softc); - chp->ata_drives[i] = NULL; + if (child == chp->ch_drive[i].drv_softc) { chp->ch_drive[i].drv_softc = NULL; chp->ch_drive[i].drive_flags = 0; found = true; @@ -1580,7 +1582,7 @@ atabus_rescan(device_t self, const char } for (i = 0; i < ATA_MAXDRIVES; i++) { - if (chp->ata_drives[i] != NULL) { + if (chp->ch_drive[i].drv_softc != NULL) { return EBUSY; } } Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.88 src/sys/dev/ata/atavar.h:1.89 --- src/sys/dev/ata/atavar.h:1.88 Thu Jul 26 20:49:47 2012 +++ src/sys/dev/ata/atavar.h Sun Jul 29 21:10:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.88 2012/07/26 20:49:47 jakllsch Exp $ */ +/* $NetBSD: atavar.h,v 1.89 2012/07/29 21:10:50 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -356,9 +356,6 @@ struct ata_channel { device_t atapibus; struct scsipi_channel ch_atapi_channel; - /* ATA children */ - device_t ata_drives[ATA_MAXDRIVES]; - /* * Channel queues. May be the same for all channels, if hw * channels are not independent.
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 19:07:34 UTC 2012 Modified Files: src/sys/dev/ata: ata.c Log Message: It turns out my previous commit here was off by one. To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/sys/dev/ata/ata.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.119 src/sys/dev/ata/ata.c:1.120 --- src/sys/dev/ata/ata.c:1.119 Sun Jul 15 15:49:46 2012 +++ src/sys/dev/ata/ata.c Sun Jul 22 19:07:33 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.119 2012/07/15 15:49:46 jakllsch Exp $ */ +/* $NetBSD: ata.c,v 1.120 2012/07/22 19:07:33 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.119 2012/07/15 15:49:46 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.120 2012/07/22 19:07:33 jakllsch Exp $"); #include "opt_ata.h" @@ -212,7 +212,7 @@ atabusconfig(struct atabus_softc *atabus if (chp->ch_satapmp_nports == 0) (*atac->atac_probe)(chp); - if (chp->ch_drive != NULL && chp->ch_ndrives >= 1) { + if (chp->ch_drive != NULL && chp->ch_ndrives >= 2) { ATADEBUG_PRINT(("atabusattach: ch_drive_type 0x%x 0x%x\n", chp->ch_drive[0].drive_type, chp->ch_drive[1].drive_type), DEBUG_PROBE);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:42:11 UTC 2012 Modified Files: src/sys/dev/ata: wd.c Log Message: FLUSH CACHE EXT is a 48-bit command, issue as such. Both FLUSH CACHE commands will return the LBA of first failure in the return task file, specifiy that we want it read, even if we don't look at the value. To generate a diff of this commit: cvs rdiff -u -r1.396 -r1.397 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.396 src/sys/dev/ata/wd.c:1.397 --- src/sys/dev/ata/wd.c:1.396 Sun Jul 22 18:37:31 2012 +++ src/sys/dev/ata/wd.c Sun Jul 22 18:42:11 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.396 2012/07/22 18:37:31 jakllsch Exp $ */ +/* $NetBSD: wd.c,v 1.397 2012/07/22 18:42:11 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.396 2012/07/22 18:37:31 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.397 2012/07/22 18:42:11 jakllsch Exp $"); #include "opt_ata.h" @@ -1906,13 +1906,14 @@ wd_flushcache(struct wd_softc *wd, int f return ENODEV; memset(&ata_c, 0, sizeof(struct ata_command)); if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0 && - (wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0) + (wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0) { ata_c.r_command = WDCC_FLUSHCACHE_EXT; - else + flags |= AT_LBA48; + } else ata_c.r_command = WDCC_FLUSHCACHE; ata_c.r_st_bmask = WDCS_DRDY; ata_c.r_st_pmask = WDCS_DRDY; - ata_c.flags = flags; + ata_c.flags = flags | AT_READREG; ata_c.timeout = 30; /* 5m timeout */ if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { aprint_error_dev(wd->sc_dev,
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:37:31 UTC 2012 Modified Files: src/sys/dev/ata: wd.c Log Message: ATA-6 and ACS-2 drafts both say the flush cache commands may take longer than 30 seconds to complete. For now assume 5 minutes will always be enough. To generate a diff of this commit: cvs rdiff -u -r1.395 -r1.396 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.395 src/sys/dev/ata/wd.c:1.396 --- src/sys/dev/ata/wd.c:1.395 Sun Jul 15 10:55:29 2012 +++ src/sys/dev/ata/wd.c Sun Jul 22 18:37:31 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.395 2012/07/15 10:55:29 dsl Exp $ */ +/* $NetBSD: wd.c,v 1.396 2012/07/22 18:37:31 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.395 2012/07/15 10:55:29 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.396 2012/07/22 18:37:31 jakllsch Exp $"); #include "opt_ata.h" @@ -1913,7 +1913,7 @@ wd_flushcache(struct wd_softc *wd, int f ata_c.r_st_bmask = WDCS_DRDY; ata_c.r_st_pmask = WDCS_DRDY; ata_c.flags = flags; - ata_c.timeout = 3; /* 30s timeout */ + ata_c.timeout = 30; /* 5m timeout */ if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { aprint_error_dev(wd->sc_dev, "flush cache command didn't complete\n");
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:21:17 UTC 2012 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: Port multiplier registers are 64-bits wide (although the ones we need only implement 32-bits). Implement the access routines using 64-bit values and add 32-bit wrappers thereto. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.5 src/sys/dev/ata/satapmp_subr.c:1.6 --- src/sys/dev/ata/satapmp_subr.c:1.5 Sun Jul 22 18:17:30 2012 +++ src/sys/dev/ata/satapmp_subr.c Sun Jul 22 18:21:17 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.5 2012/07/22 18:17:30 jakllsch Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.6 2012/07/22 18:21:17 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.5 2012/07/22 18:17:30 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.6 2012/07/22 18:21:17 jakllsch Exp $"); #include #include @@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: satapmp_subr #include static int -satapmp_read(struct ata_channel *chp, int port, int reg, uint32_t *value) +satapmp_read_8(struct ata_channel *chp, int port, int reg, uint64_t *value) { struct ata_command ata_c; struct atac_softc *atac = chp->ch_atac; @@ -88,12 +88,31 @@ satapmp_read(struct ata_channel *chp, in reg, ata_c.r_error); return EIO; } - *value = ata_c.r_lba << 8 | ata_c.r_count; + + *value = ((uint64_t)((ata_c.r_lba >> 24) & 0xff) << 40) | + ((uint64_t)((ata_c.r_count >> 8) & 0xff) << 32) | + ((uint64_t)((ata_c.r_lba >> 0) & 0xff) << 8) | + ((uint64_t)((ata_c.r_count >> 0) & 0xff) << 0); + return 0; } +static inline int +satapmp_read(struct ata_channel *chp, int port, int reg, uint32_t *value) +{ + uint64_t value64; + int ret; + + ret = satapmp_read_8(chp, port, reg, &value64); + if (ret) + return ret; + + *value = value64 & 0x; + return ret; +} + static int -satapmp_write(struct ata_channel *chp, int port, int reg, uint32_t value) +satapmp_write_8(struct ata_channel *chp, int port, int reg, uint64_t value) { struct ata_command ata_c; struct atac_softc *atac = chp->ch_atac; @@ -110,8 +129,10 @@ satapmp_write(struct ata_channel *chp, i ata_c.r_command = PMPC_WRITE_PORT; ata_c.r_features = reg; ata_c.r_device = port; - ata_c.r_lba = (value & 0xff00) >> 8; - ata_c.r_count = value & 0xff; + ata_c.r_lba = (((value >> 40) & 0xff) << 24) | + (((value >> 8) & 0xff) << 0); + ata_c.r_count = (((value >> 32) & 0xff) << 8) | + (((value >> 0) & 0xff) << 0); ata_c.timeout = 3000; /* 3s */ ata_c.r_st_bmask = WDCS_DRDY; ata_c.r_st_pmask = 0; @@ -138,6 +159,12 @@ satapmp_write(struct ata_channel *chp, i return 0; } +static inline int +satapmp_write(struct ata_channel *chp, int port, int reg, uint32_t value) +{ + return satapmp_write_8(chp, port, reg, value); +} + /* * Reset one port's PHY and bring it online * XXX duplicate of sata_reset_interface()
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:17:30 UTC 2012 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: The vendor and product IDs are 16-bit, print out as such. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.4 src/sys/dev/ata/satapmp_subr.c:1.5 --- src/sys/dev/ata/satapmp_subr.c:1.4 Sun Jul 22 18:12:01 2012 +++ src/sys/dev/ata/satapmp_subr.c Sun Jul 22 18:17:30 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.4 2012/07/22 18:12:01 jakllsch Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.5 2012/07/22 18:17:30 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.4 2012/07/22 18:12:01 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.5 2012/07/22 18:17:30 jakllsch Exp $"); #include #include @@ -233,7 +233,7 @@ satapmp_attach(struct ata_channel *chp) aprint_normal_dev(chp->atabus, "SATA port multiplier, %d ports\n", PMP_INF_NPORTS(inf)); aprint_verbose_dev(chp->atabus, - "vendor 0x%x, product 0x%x", + "vendor 0x%04x, product 0x%04x", PMP_ID_VEND(id), PMP_ID_DEV(id)); if (rev & PMP_REV_SPEC_11) { aprint_verbose(", revision 1.1");
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:12:01 UTC 2012 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: Correctly issue port multiplier register access commands as LBA48 now that the FIS code doesn't get in the way of doing that. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.3 src/sys/dev/ata/satapmp_subr.c:1.4 --- src/sys/dev/ata/satapmp_subr.c:1.3 Sun Jul 22 18:03:34 2012 +++ src/sys/dev/ata/satapmp_subr.c Sun Jul 22 18:12:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.3 2012/07/22 18:03:34 jakllsch Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.4 2012/07/22 18:12:01 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.3 2012/07/22 18:03:34 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.4 2012/07/22 18:12:01 jakllsch Exp $"); #include #include @@ -64,11 +64,11 @@ satapmp_read(struct ata_channel *chp, in ata_c.r_command = PMPC_READ_PORT; ata_c.r_features = reg; - ata_c.r_lba = (port & 0xf) << 24; + ata_c.r_device = port; ata_c.timeout = 3000; /* 3s */ ata_c.r_st_bmask = WDCS_DRDY; ata_c.r_st_pmask = 0; - ata_c.flags = AT_READREG | AT_WAIT; + ata_c.flags = AT_LBA48 | AT_READREG | AT_WAIT; if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, &ata_c) != ATACMD_COMPLETE) { @@ -92,7 +92,6 @@ satapmp_read(struct ata_channel *chp, in return 0; } -static int satapmp_write(struct ata_channel *chp, int, int, uint32_t) __unused; static int satapmp_write(struct ata_channel *chp, int port, int reg, uint32_t value) { @@ -110,13 +109,13 @@ satapmp_write(struct ata_channel *chp, i ata_c.r_command = PMPC_WRITE_PORT; ata_c.r_features = reg; - ata_c.r_lba = (port & 0xf) << 24; - ata_c.r_lba |= (value & 0xff00) >> 8; + ata_c.r_device = port; + ata_c.r_lba = (value & 0xff00) >> 8; ata_c.r_count = value & 0xff; ata_c.timeout = 3000; /* 3s */ ata_c.r_st_bmask = WDCS_DRDY; ata_c.r_st_pmask = 0; - ata_c.flags = AT_WAIT; + ata_c.flags = AT_LBA48 | AT_WAIT; if ((*atac->atac_bustype_ata->ata_exec_command)(drvp, &ata_c) != ATACMD_COMPLETE) {
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 18:03:34 UTC 2012 Modified Files: src/sys/dev/ata: satapmp_subr.c Log Message: KASSERT if we attempt to access an invalid port. Also, small whitespace change for internal consistency. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.2 src/sys/dev/ata/satapmp_subr.c:1.3 --- src/sys/dev/ata/satapmp_subr.c:1.2 Sun Jul 15 10:55:29 2012 +++ src/sys/dev/ata/satapmp_subr.c Sun Jul 22 18:03:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.2 2012/07/15 10:55:29 dsl Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.3 2012/07/22 18:03:34 jakllsch Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.2 2012/07/15 10:55:29 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.3 2012/07/22 18:03:34 jakllsch Exp $"); #include #include @@ -54,6 +54,7 @@ satapmp_read(struct ata_channel *chp, in struct atac_softc *atac = chp->ch_atac; struct ata_drive_datas *drvp; + KASSERT(port < PMP_MAX_DRIVES); KASSERT(reg < PMP_GSCR_NREGS); KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); drvp = &chp->ch_drive[PMP_PORT_CTL]; @@ -99,12 +100,12 @@ satapmp_write(struct ata_channel *chp, i struct atac_softc *atac = chp->ch_atac; struct ata_drive_datas *drvp; + KASSERT(port < PMP_MAX_DRIVES); KASSERT(reg < PMP_GSCR_NREGS); KASSERT(chp->ch_ndrives >= PMP_MAX_DRIVES); drvp = &chp->ch_drive[PMP_PORT_CTL]; KASSERT(drvp->drive == PMP_PORT_CTL); - memset(&ata_c, 0, sizeof(struct ata_command)); ata_c.r_command = PMPC_WRITE_PORT;
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 22 17:57:58 UTC 2012 Modified Files: src/sys/dev/ata: satafis_subr.c Log Message: SATA uses the head portion of the device register in the command protocol for port multiplier register access. Thus, in the LBA48 case, pass the complete r(hd|dh)_dh byte back and forth to the upper layers. (This is irrelevant in the LBA28/CHS code path for what should be obvious reasons.) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ata/satafis_subr.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/satafis_subr.c diff -u src/sys/dev/ata/satafis_subr.c:1.6 src/sys/dev/ata/satafis_subr.c:1.7 --- src/sys/dev/ata/satafis_subr.c:1.6 Tue Jan 24 20:04:07 2012 +++ src/sys/dev/ata/satafis_subr.c Sun Jul 22 17:57:57 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: satafis_subr.c,v 1.6 2012/01/24 20:04:07 jakllsch Exp $ */ +/* $NetBSD: satafis_subr.c,v 1.7 2012/07/22 17:57:57 jakllsch Exp $ */ /*- * Copyright (c) 2009 Jonathan A. Kollasch. @@ -51,7 +51,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.6 2012/01/24 20:04:07 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.7 2012/07/22 17:57:57 jakllsch Exp $"); #include #include @@ -81,14 +81,14 @@ satafis_rhd_construct_cmd(struct ata_com fis[rhd_lba1] = (ata_c->r_lba >> 8) & 0xff; fis[rhd_lba2] = (ata_c->r_lba >> 16) & 0xff; if ((ata_c->flags & AT_LBA48) != 0) { - fis[rhd_dh] = WDSD_LBA; + fis[rhd_dh] = ata_c->r_device; fis[rhd_lba3] = (ata_c->r_lba >> 24) & 0xff; fis[rhd_lba4] = (ata_c->r_lba >> 32) & 0xff; fis[rhd_lba5] = (ata_c->r_lba >> 40) & 0xff; fis[rhd_features1] = (ata_c->r_features >> 8) & 0xff; } else { - fis[rhd_dh] = ((ata_c->r_lba >> 24) & 0x0f) | - (((ata_c->flags & AT_LBA) != 0) ? WDSD_LBA : 0); + fis[rhd_dh] = (ata_c->r_device & 0xf0) | + ((ata_c->r_lba >> 24) & 0x0f); } fis[rhd_count0] = (ata_c->r_count >> 0) & 0xff; @@ -170,8 +170,10 @@ satafis_rdh_cmd_readreg(struct ata_comma ata_c->r_lba |= (uint64_t)fis[rdh_lba3] << 24; ata_c->r_lba |= (uint64_t)fis[rdh_lba4] << 32; ata_c->r_lba |= (uint64_t)fis[rdh_lba5] << 40; + ata_c->r_device = fis[rdh_dh]; } else { ata_c->r_lba |= (uint64_t)(fis[rdh_dh] & 0x0f) << 24; + ata_c->r_device = fis[rdh_dh] & 0xf0; } ata_c->r_count = fis[rdh_count0] << 0; @@ -181,6 +183,4 @@ satafis_rdh_cmd_readreg(struct ata_comma ata_c->r_error = fis[rdh_error]; ata_c->r_status = fis[rdh_status]; - - ata_c->r_device = fis[rdh_dh] & 0xf0; }
CVS commit: src/sys/dev/ata
Module Name:src Committed By: jakllsch Date: Sun Jul 15 15:49:46 UTC 2012 Modified Files: src/sys/dev/ata: ata.c Log Message: Stopgap crash prevention when atadebug_mask includes DEBUG_PROBE bit. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/dev/ata/ata.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.118 src/sys/dev/ata/ata.c:1.119 --- src/sys/dev/ata/ata.c:1.118 Sun Jul 15 10:55:29 2012 +++ src/sys/dev/ata/ata.c Sun Jul 15 15:49:46 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.118 2012/07/15 10:55:29 dsl Exp $ */ +/* $NetBSD: ata.c,v 1.119 2012/07/15 15:49:46 jakllsch Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.118 2012/07/15 10:55:29 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.119 2012/07/15 15:49:46 jakllsch Exp $"); #include "opt_ata.h" @@ -212,9 +212,11 @@ atabusconfig(struct atabus_softc *atabus if (chp->ch_satapmp_nports == 0) (*atac->atac_probe)(chp); - ATADEBUG_PRINT(("atabusattach: ch_drive_type 0x%x 0x%x\n", - chp->ch_drive[0].drive_type, chp->ch_drive[1].drive_type), - DEBUG_PROBE); + if (chp->ch_drive != NULL && chp->ch_ndrives >= 1) { + ATADEBUG_PRINT(("atabusattach: ch_drive_type 0x%x 0x%x\n", + chp->ch_drive[0].drive_type, chp->ch_drive[1].drive_type), + DEBUG_PROBE); + } /* next operations will occurs in a separate thread */ s = splbio();
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Tue Jun 26 09:49:25 UTC 2012 Modified Files: src/sys/dev/ata: wd.c Log Message: In some case, when an error is reported by the disk, the ahci controller still reports a number of bytes transfered equal to bcount. This then triggers a KASSERT in physio_biodone: if (done == todo) KASSERT(bp->b_error == 0); Detect this case in wd(4) (so that the workaround works for other controllers too if they have the same issue, or if the issue is with the drive) and claim we didn't read/write anything. To generate a diff of this commit: cvs rdiff -u -r1.392 -r1.393 src/sys/dev/ata/wd.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/wd.c diff -u src/sys/dev/ata/wd.c:1.392 src/sys/dev/ata/wd.c:1.393 --- src/sys/dev/ata/wd.c:1.392 Thu Feb 2 19:43:02 2012 +++ src/sys/dev/ata/wd.c Tue Jun 26 09:49:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.392 2012/02/02 19:43:02 tls Exp $ */ +/* $NetBSD: wd.c,v 1.393 2012/06/26 09:49:24 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.392 2012/02/02 19:43:02 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.393 2012/06/26 09:49:24 bouyer Exp $"); #include "opt_ata.h" @@ -819,6 +819,14 @@ noerror: if ((wd->sc_wdc_bio.flags & ATA bp->b_error = EIO; break; } + if (__predict_false(bp->b_error != 0) && bp->b_resid == 0) { + /* + * the disk or controller sometimes report a complete + * xfer, when there has been an error. This is wrong, + * assume nothing got transfered in this case + */ + bp->b_resid = bp->b_bcount; + } disk_unbusy(&wd->sc_dk, (bp->b_bcount - bp->b_resid), (bp->b_flags & B_READ)); rnd_add_uint32(&wd->rnd_source, bp->b_blkno);
CVS commit: src/sys/dev/ata
Module Name:src Committed By: bouyer Date: Tue May 15 19:01:10 UTC 2012 Modified Files: src/sys/dev/ata: sata_subr.c Log Message: If the PHY reports link up but no communication, wait 5 more seconds for communications to be established. This seems to be needed for some configurations. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ata/sata_subr.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/sata_subr.c diff -u src/sys/dev/ata/sata_subr.c:1.14 src/sys/dev/ata/sata_subr.c:1.15 --- src/sys/dev/ata/sata_subr.c:1.14 Sun Dec 12 00:38:07 2010 +++ src/sys/dev/ata/sata_subr.c Tue May 15 19:01:10 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: sata_subr.c,v 1.14 2010/12/12 00:38:07 jakllsch Exp $ */ +/* $NetBSD: sata_subr.c,v 1.15 2012/05/15 19:01:10 bouyer Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ * Common functions for Serial ATA. */ #include -__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.14 2010/12/12 00:38:07 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.15 2012/05/15 19:01:10 bouyer Exp $"); #include #include @@ -105,6 +105,18 @@ sata_reset_interface(struct ata_channel break; tsleep(chp, PRIBIO, "sataup", mstohz(10)); } + /* + * if we have a link up without device, wait a few more seconds + * for connection to establish + */ + if ((sstatus & SStatus_DET_mask) == SStatus_DET_DEV_NE) { + for (i = 0; i < 500; i++) { + tsleep(chp, PRIBIO, "sataup", mstohz(10)); + sstatus = bus_space_read_4(sata_t, sstatus_r, 0); + if ((sstatus & SStatus_DET_mask) == SStatus_DET_DEV) +break; + } + } switch (sstatus & SStatus_DET_mask) { case SStatus_DET_NODEV: