From 5b75384146d581f1f0b31a634371334fa8d4fe74 Mon Sep 17 00:00:00 2001 From: jakllsch Date: Sat, 4 Jul 2009 20:57:15 +0000 Subject: [PATCH] Further corrections for siisata. Reset ch_status and ch_error at the beginning of any operation. The chip only writes the RDH FIS to the SRAM when the error bit is set in a RDH FIS (per the datasheet). Thus, satafis_sdb_parse() is replaced with satafis_rhd_parse(). A valid FIS type field seems to not be written to the SRAM, so don't bother checking it for the correct magic. Additionally, append 2009 to copyright year set, and remove obsolete CVS Id lines from when this was in my repository. --- sys/dev/ata/satafis_subr.c | 15 +++++++++------ sys/dev/ata/satafisvar.h | 4 ++-- sys/dev/ic/siisata.c | 17 +++++++++++++---- sys/dev/ic/siisatareg.h | 5 ++--- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/sys/dev/ata/satafis_subr.c b/sys/dev/ata/satafis_subr.c index 850ceeb16764..d4cf79c54859 100644 --- a/sys/dev/ata/satafis_subr.c +++ b/sys/dev/ata/satafis_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: satafis_subr.c,v 1.2 2009/06/17 03:55:04 jakllsch Exp $ */ +/* $NetBSD: satafis_subr.c,v 1.3 2009/07/04 20:57:15 jakllsch Exp $ */ /*- * Copyright (c) 2009 Jonathan A. Kollasch. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.2 2009/06/17 03:55:04 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.3 2009/07/04 20:57:15 jakllsch Exp $"); #include #include @@ -148,11 +148,14 @@ satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis) #endif /* NATAPIBUS */ void -satafis_sdb_parse(struct ata_channel *chp, uint8_t *fis) +satafis_rdh_parse(struct ata_channel *chp, uint8_t *fis) { - KASSERT(fis[fis_type] != SDB_FISTYPE); - chp->ch_status = fis[sdb_status]; - chp->ch_error = fis[sdb_error]; +#if 0 + /* siisata doesn't do enough for this to work */ + KASSERT(fis[fis_type] == RDH_FISTYPE); +#endif + chp->ch_status = fis[rdh_status]; + chp->ch_error = fis[rdh_error]; return; } diff --git a/sys/dev/ata/satafisvar.h b/sys/dev/ata/satafisvar.h index c616d97ff850..ff59189b8147 100644 --- a/sys/dev/ata/satafisvar.h +++ b/sys/dev/ata/satafisvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: satafisvar.h,v 1.1 2009/06/17 03:07:51 jakllsch Exp $ */ +/* $NetBSD: satafisvar.h,v 1.2 2009/07/04 20:57:15 jakllsch Exp $ */ /*- * Copyright (c) 2009 Jonathan A. Kollasch. @@ -33,6 +33,6 @@ void satafis_rhd_construct_cmd(struct ata_command *, uint8_t *); void satafis_rhd_construct_bio(struct ata_xfer *, uint8_t *); void satafis_rhd_construct_atapi(struct ata_xfer *, uint8_t *); -void satafis_sdb_parse(struct ata_channel *, uint8_t *); +void satafis_rdh_parse(struct ata_channel *, uint8_t *); #endif /* _DEV_ATA_FISVAR_H_ */ diff --git a/sys/dev/ic/siisata.c b/sys/dev/ic/siisata.c index d001d58b8f1a..2d9e0a9364b9 100644 --- a/sys/dev/ic/siisata.c +++ b/sys/dev/ic/siisata.c @@ -1,4 +1,4 @@ -/* $NetBSD: siisata.c,v 1.6 2009/06/27 21:04:47 jakllsch Exp $ */ +/* $NetBSD: siisata.c,v 1.7 2009/07/04 20:57:15 jakllsch Exp $ */ /* from ahcisata_core.c */ @@ -64,7 +64,7 @@ */ /*- - * Copyright (c) 2007, 2008 Jonathan A. Kollasch. + * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -479,13 +479,13 @@ siisata_intr_port(struct siisata_channel *schp) ec = PRREAD(sc, PRX(chp->ch_channel, PRO_PCE)); if (ec <= PR_PCE_DATAFISERROR) { - if (ec != PR_PCE_DATAFISERROR) { + if (ec == PR_PCE_DEVICEERROR) { /* read in specific information about error */ prbfis = bus_space_read_stream_4( sc->sc_prt, sc->sc_prh, PRSX(chp->ch_channel, slot, PRSO_FIS)); /* set ch_status and ch_error */ - satafis_sdb_parse(chp, (uint8_t *)&prbfis); + satafis_rdh_parse(chp, (uint8_t *)&prbfis); } siisata_reinit_port(chp); } else { @@ -774,6 +774,9 @@ siisata_cmd_start(struct ata_channel *chp, struct ata_xfer *xfer) SIISATA_DEBUG_PRINT(("%s: %s port %d, slot %d\n", SIISATANAME(sc), __func__, chp->ch_channel, slot), DEBUG_FUNCS); + chp->ch_status = 0; + chp->ch_error = 0; + prb = schp->sch_prb[slot]; memset(prb, 0, sizeof(struct siisata_prb)); @@ -978,6 +981,9 @@ siisata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer) SIISATANAME(sc), __func__, chp->ch_channel, slot), DEBUG_FUNCS); + chp->ch_status = 0; + chp->ch_error = 0; + prb = schp->sch_prb[slot]; memset(prb, 0, sizeof(struct siisata_prb)); @@ -1515,6 +1521,9 @@ siisata_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer) chp->ch_drive[xfer->c_drive].drive, sc_xfer->xs_control), DEBUG_XFERS); + chp->ch_status = 0; + chp->ch_error = 0; + prbp = schp->sch_prb[slot]; memset(prbp, 0, sizeof(struct siisata_prb)); diff --git a/sys/dev/ic/siisatareg.h b/sys/dev/ic/siisatareg.h index 01de6bd04b6f..661ad251de75 100644 --- a/sys/dev/ic/siisatareg.h +++ b/sys/dev/ic/siisatareg.h @@ -1,8 +1,7 @@ -/* $NetBSD: siisatareg.h,v 1.3 2009/06/17 04:37:57 jakllsch Exp $ */ -/* Id: siisatareg.h,v 1.10 2008/05/21 15:51:36 jakllsch Exp */ +/* $NetBSD: siisatareg.h,v 1.4 2009/07/04 20:57:15 jakllsch Exp $ */ /*- - * Copyright (c) 2007, 2008 Jonathan A. Kollasch. + * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without