From owner-p4-projects@FreeBSD.ORG Sun Apr 16 22:43:41 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D6CB816A404; Sun, 16 Apr 2006 22:43:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 829A716A401 for ; Sun, 16 Apr 2006 22:43:40 +0000 (UTC) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 34F1143D45 for ; Sun, 16 Apr 2006 22:43:40 +0000 (GMT) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3GMhedr079312 for ; Sun, 16 Apr 2006 22:43:40 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3GMhdjZ079309 for perforce@freebsd.org; Sun, 16 Apr 2006 22:43:39 GMT (envelope-from jmg@freebsd.org) Date: Sun, 16 Apr 2006 22:43:39 GMT Message-Id: <200604162243.k3GMhdjZ079309@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney To: Perforce Change Reviews Cc: Subject: PERFORCE change 95401 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2006 22:43:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=95401 Change 95401 by jmg@jmg_arlene on 2006/04/16 22:43:18 pull in latest ata code.. there's been a few revs, this'll make it easier for sos to help us... Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-all.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-all.h#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-chipset.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-disk.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-pci.h#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-queue.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-raid.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-usb.c#1 branch .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/atapi-cam.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/atapi-cd.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/atapi-fd.c#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/dev/ata/atapi-fd.h#3 integrate .. //depot/projects/kmacy_sun4v/src/sys/sys/ata.h#3 integrate Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-all.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.264 2006/02/09 20:54:42 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.272 2006/04/14 16:25:42 sos Exp $"); #include "opt_ata.h" #include @@ -73,13 +73,13 @@ /* global vars */ MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer"); int (*ata_raid_ioctl_func)(u_long cmd, caddr_t data) = NULL; +struct intr_config_hook *ata_delayed_attach = NULL; devclass_t ata_devclass; uma_zone_t ata_request_zone; uma_zone_t ata_composite_zone; int ata_wc = 1; /* local vars */ -static struct intr_config_hook *ata_delayed_attach = NULL; static int ata_dma = 1; static int atapi_dma = 1; @@ -160,6 +160,11 @@ if (!ch->r_irq) return ENXIO; + /* grap the channel lock so no new requests gets launched */ + mtx_lock(&ch->state_mtx); + ch->state |= ATA_STALL_QUEUE; + mtx_unlock(&ch->state_mtx); + /* detach & delete all children */ if (!device_get_children(dev, &children, &nchildren)) { for (i = 0; i < nchildren; i++) @@ -196,9 +201,14 @@ while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit) tsleep(&dev, PRIBIO, "atarini", 1); + /* catch eventual request in ch->running */ + mtx_lock(&ch->state_mtx); + if ((request = ch->running)) + callout_stop(&request->callout); + ch->running = NULL; + /* unconditionally grap the channel lock */ - mtx_lock(&ch->state_mtx); - ch->state = ATA_STALL_QUEUE; + ch->state |= ATA_STALL_QUEUE; mtx_unlock(&ch->state_mtx); /* reset the controller HW, the channel and device(s) */ @@ -208,53 +218,37 @@ if (!device_get_children(dev, &children, &nchildren)) { mtx_lock(&Giant); /* newbus suckage it needs Giant */ for (i = 0; i < nchildren; i++) { - if (children[i] && device_is_attached(children[i])) - if (ATA_REINIT(children[i])) { - /* - * if we have a running request and its device matches - * this child we need to inform the request that the - * device is gone and remove it from ch->running - */ - mtx_lock(&ch->state_mtx); - if (ch->running && ch->running->dev == children[i]) { - callout_stop(&ch->running->callout); - request = ch->running; - ch->running = NULL; - } - else - request = NULL; - mtx_unlock(&ch->state_mtx); + /* did any children go missing ? */ + if (children[i] && device_is_attached(children[i]) && + ATA_REINIT(children[i])) { + /* + * if we had a running request and its device matches + * this child we need to inform the request that the + * device is gone. + */ + if (request && request->dev == children[i]) { + request->result = ENXIO; + device_printf(request->dev, "FAILURE - device detached\n"); - if (request) { - request->result = ENXIO; - device_printf(request->dev, - "FAILURE - device detached\n"); - - /* if not timeout finish request here */ - if (!(request->flags & ATA_R_TIMEOUT)) + /* if not timeout finish request here */ + if (!(request->flags & ATA_R_TIMEOUT)) ata_finish(request); - } - device_delete_child(dev, children[i]); + request = NULL; } + device_delete_child(dev, children[i]); + } } free(children, M_TEMP); mtx_unlock(&Giant); /* newbus suckage dealt with, release Giant */ } - /* catch request in ch->running if we havn't already */ - mtx_lock(&ch->state_mtx); - if ((request = ch->running)) - callout_stop(&request->callout); - ch->running = NULL; - mtx_unlock(&ch->state_mtx); - - /* if we got one put it on the queue again */ - if (request) { + /* if we still have a good request put it on the queue again */ + if (request && !(request->flags & ATA_R_TIMEOUT)) { device_printf(request->dev, "WARNING - %s requeued due to channel reset", ata_cmd2str(request)); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); request->flags |= ATA_R_REQUEUE; ata_queue_request(request); @@ -283,8 +277,8 @@ if (!dev || !(ch = device_get_softc(dev))) return ENXIO; - /* wait for the channel to be IDLE before entering suspend mode */ - while (1) { + /* wait for the channel to be IDLE or detached before suspending */ + while (ch->r_irq) { mtx_lock(&ch->state_mtx); if (ch->state == ATA_IDLE) { ch->state = ATA_ACTIVE; @@ -335,13 +329,13 @@ ATA_DEBUG_RQ(request, "interrupt"); /* safetycheck for the right state */ - if (ch->state != ATA_ACTIVE && ch->state != ATA_STALL_QUEUE) { + if (ch->state == ATA_IDLE) { device_printf(request->dev, "interrupt on idle channel ignored\n"); break; } /* - * we have the HW locks, so end the tranaction for this request + * we have the HW locks, so end the transaction for this request * if it finishes immediately otherwise wait for next interrupt */ if (ch->hw.end_transaction(request) == ATA_OP_FINISHED) { @@ -491,7 +485,11 @@ if (ioc_request->flags & ATA_CMD_WRITE) request->flags |= ATA_R_WRITE; ata_queue_request(request); - if (!(request->flags & ATA_R_ATAPI)) { + if (request->flags & ATA_R_ATAPI) { + bcopy(&request->u.atapi.sense, &ioc_request->u.atapi.sense, + sizeof(struct atapi_sense)); + } + else { ioc_request->u.ata.command = request->u.ata.command; ioc_request->u.ata.feature = request->u.ata.feature; ioc_request->u.ata.lba = request->u.ata.lba; @@ -631,7 +629,8 @@ if (bootverbose) printf("ata%d-%s: pio=%s wdma=%s udma=%s cable=%s wire\n", - ch->unit, atadev->unit == ATA_MASTER ? "master":"slave", + device_get_unit(ch->dev), + atadev->unit == ATA_MASTER ? "master" : "slave", ata_mode2str(ata_pmode(atacap)), ata_mode2str(ata_wmode(atacap)), ata_mode2str(ata_umode(atacap)), @@ -853,6 +852,9 @@ case ATA_UDMA6: return "UDMA133"; case ATA_SA150: return "SATA150"; case ATA_SA300: return "SATA300"; + case ATA_USB: return "USB"; + case ATA_USB1: return "USB1"; + case ATA_USB2: return "USB2"; default: if (mode & ATA_DMA_MASK) return "BIOSDMA"; ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-all.h#3 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.114 2006/02/23 20:15:22 sos Exp $ + * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.117 2006/03/31 08:09:04 sos Exp $ */ /* ATA register defines */ @@ -53,24 +53,7 @@ #define ATA_E_MC 0x20 /* media changed */ #define ATA_E_UNC 0x40 /* uncorrectable data */ #define ATA_E_ICRC 0x80 /* UDMA crc error */ -#define ATA_E_MASK 0x0f /* error mask */ -#define ATA_SK_MASK 0xf0 /* sense key mask */ -#define ATA_SK_NO_SENSE 0x00 /* no specific sense key info */ -#define ATA_SK_RECOVERED_ERROR 0x10 /* command OK, data recovered */ -#define ATA_SK_NOT_READY 0x20 /* no access to drive */ -#define ATA_SK_MEDIUM_ERROR 0x30 /* non-recovered data error */ -#define ATA_SK_HARDWARE_ERROR 0x40 /* non-recoverable HW failure */ -#define ATA_SK_ILLEGAL_REQUEST 0x50 /* invalid command param(s) */ -#define ATA_SK_UNIT_ATTENTION 0x60 /* media changed */ -#define ATA_SK_DATA_PROTECT 0x70 /* write protect */ -#define ATA_SK_BLANK_CHECK 0x80 /* blank check */ -#define ATA_SK_VENDOR_SPECIFIC 0x90 /* vendor specific skey */ -#define ATA_SK_COPY_ABORTED 0xa0 /* copy aborted */ -#define ATA_SK_ABORTED_COMMAND 0xb0 /* command aborted, try again */ -#define ATA_SK_EQUAL 0xc0 /* equal */ -#define ATA_SK_VOLUME_OVERFLOW 0xd0 /* volume overflow */ -#define ATA_SK_MISCOMPARE 0xe0 /* data dont match the medium */ -#define ATA_SK_RESERVED 0xf0 +#define ATA_E_ATAPI_SENSE_MASK 0xf0 /* ATAPI sense key mask */ #define ATA_IREASON 9 /* (R) interrupt reason */ #define ATA_I_CMD 0x01 /* cmd (1) | data (0) */ @@ -284,7 +267,8 @@ #define ATA_PC98_BANKADDR_RID 9 #define ATA_IRQ_RID 0 #define ATA_DEV(device) ((device == ATA_MASTER) ? 0 : 1) -#define ATA_CFA_MAGIC 0x848A +#define ATA_CFA_MAGIC1 0x844A +#define ATA_CFA_MAGIC2 0x848A #define ATAPI_MAGIC_LSB 0x14 #define ATAPI_MAGIC_MSB 0xeb #define ATAPI_P_READ (ATA_S_DRQ | ATA_I_IN) @@ -298,28 +282,6 @@ #define ATA_OP_FINISHED 1 #define ATA_MAX_28BIT_LBA 268435455UL -/* ATAPI request sense structure */ -struct atapi_sense { - u_int8_t error_code :7; /* current or deferred errors */ - u_int8_t valid :1; /* follows ATAPI spec */ - u_int8_t segment; /* Segment number */ - u_int8_t sense_key :4; /* sense key */ - u_int8_t reserved2_4 :1; /* reserved */ - u_int8_t ili :1; /* incorrect length indicator */ - u_int8_t eom :1; /* end of medium */ - u_int8_t filemark :1; /* filemark */ - u_int32_t cmd_info __packed; /* cmd information */ - u_int8_t sense_length; /* additional sense len (n-7) */ - u_int32_t cmd_specific_info __packed; /* additional cmd spec info */ - u_int8_t asc; /* additional sense code */ - u_int8_t ascq; /* additional sense code qual */ - u_int8_t replaceable_unit_code; /* replaceable unit code */ - u_int8_t sk_specific :7; /* sense key specific */ - u_int8_t sksv :1; /* sense key specific info OK */ - u_int8_t sk_specific1; /* sense key specific */ - u_int8_t sk_specific2; /* sense key specific */ -}; - /* structure used for composite atomic operations */ #define MAX_COMPOSITES 32 /* u_int32_t bits */ struct ata_composite { @@ -348,9 +310,8 @@ } ata; struct { u_int8_t ccb[16]; /* ATAPI command block */ - struct atapi_sense sense_data; /* ATAPI request sense data */ - u_int8_t sense_key; /* ATAPI request sense key */ - u_int8_t sense_cmd; /* ATAPI saved command */ + struct atapi_sense sense; /* ATAPI request sense data */ + u_int8_t saved_cmd; /* ATAPI saved command */ } atapi; } u; u_int32_t bytecount; /* bytes to transfer */ @@ -372,6 +333,8 @@ #define ATA_R_DIRECT 0x00001000 #define ATA_R_DEBUG 0x10000000 +#define ATA_R_DANGER1 0x20000000 +#define ATA_R_DANGER2 0x40000000 u_int8_t status; /* ATA status */ u_int8_t error; /* ATA error */ @@ -525,6 +488,7 @@ /* externs */ extern int (*ata_raid_ioctl_func)(u_long cmd, caddr_t data); +extern struct intr_config_hook *ata_delayed_attach; extern devclass_t ata_devclass; extern int ata_wc; @@ -569,8 +533,10 @@ /* macros for alloc/free of struct ata_request */ extern uma_zone_t ata_request_zone; #define ata_alloc_request() uma_zalloc(ata_request_zone, M_NOWAIT | M_ZERO) -#define ata_free_request(request) uma_zfree(ata_request_zone, request) - +#define ata_free_request(request) { \ + if (!(request->flags & ATA_R_DANGER2)) \ + uma_zfree(ata_request_zone, request); \ + } /* macros for alloc/free of struct ata_composite */ extern uma_zone_t ata_composite_zone; #define ata_alloc_composite() uma_zalloc(ata_composite_zone, M_NOWAIT | M_ZERO) ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-chipset.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.160 2006/02/23 18:52:15 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.161 2006/03/13 14:01:37 sos Exp $"); #include "opt_ata.h" #include @@ -2068,8 +2068,11 @@ struct ata_pci_controller *ctlr = device_get_softc(dev); struct ata_chip_id *idx; static struct ata_chip_id ids[] = - {{ ATA_JMB360, 0, 0, 0, ATA_SA300, "JMB360" }, - { ATA_JMB363, 0, 1, 0, ATA_SA300, "JMB363" }, + {{ ATA_JMB360, 0, 1, 0, ATA_SA300, "JMB360" }, + { ATA_JMB361, 0, 1, 1, ATA_SA300, "JMB361" }, + { ATA_JMB363, 0, 2, 1, ATA_SA300, "JMB363" }, + { ATA_JMB365, 0, 1, 2, ATA_SA300, "JMB365" }, + { ATA_JMB366, 0, 2, 2, ATA_SA300, "JMB366" }, { 0, 0, 0, 0, 0, 0}}; char buffer[64]; @@ -2094,6 +2097,7 @@ /* set controller configuration to a setup we support */ pci_write_config(dev, 0x40, 0x80c0a131, 4); + pci_write_config(dev, 0x80, 0x01200000, 4); ctlr->allocate = ata_jmicron_allocate; ctlr->reset = ata_jmicron_reset; @@ -2118,10 +2122,6 @@ ATA_OUTL(ctlr->r_res2, ATA_AHCI_GHC, ATA_INL(ctlr->r_res2, ATA_AHCI_GHC) | ATA_AHCI_GHC_AE); - /* get the number of HW channels */ - ctlr->channels = - (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_NPMASK) + 1; - /* clear interrupts */ ATA_OUTL(ctlr->r_res2, ATA_AHCI_IS, ATA_INL(ctlr->r_res2, ATA_AHCI_IS)); @@ -2134,21 +2134,22 @@ pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); } - /* add in PATA channel(s) */ - ctlr->channels += ctlr->chip->cfg1; + /* set the number of HW channels */ + ctlr->channels = ctlr->chip->cfg1 + ctlr->chip->cfg2; return 0; } static int ata_jmicron_allocate(device_t dev) { + struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); int error; - if (ch->unit >= 2) { - ch->unit -= 2; + if (ch->unit >= ctlr->chip->cfg1) { + ch->unit -= ctlr->chip->cfg1; error = ata_pci_allocate(dev); - ch->unit += 2; + ch->unit += ctlr->chip->cfg1; } else error = ata_ahci_allocate(dev); @@ -2158,9 +2159,10 @@ static void ata_jmicron_reset(device_t dev) { + struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); - if (ch->unit >= 2) + if (ch->unit >= ctlr->chip->cfg1) ata_generic_reset(dev); else ata_ahci_reset(dev); @@ -2169,9 +2171,10 @@ static void ata_jmicron_dmainit(device_t dev) { + struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); - if (ch->unit >= 2) + if (ch->unit >= ctlr->chip->cfg1) ata_pci_dmainit(dev); else ata_ahci_dmainit(dev); @@ -2180,9 +2183,10 @@ static void ata_jmicron_setmode(device_t dev, int mode) { + struct ata_pci_controller *ctlr = device_get_softc(GRANDPARENT(dev)); struct ata_channel *ch = device_get_softc(device_get_parent(dev)); - if (ch->unit >= 2) { + if (ch->unit >= ctlr->chip->cfg1) { struct ata_device *atadev = device_get_softc(dev); /* check for 80pin cable present */ ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-disk.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-disk.c,v 1.193 2006/01/18 09:14:55 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-disk.c,v 1.197 2006/03/31 08:09:04 sos Exp $"); #include "opt_ata.h" #include @@ -71,7 +71,8 @@ struct ata_device *atadev = device_get_softc(dev); if (!(atadev->param.config & ATA_PROTO_ATAPI) || - (atadev->param.config == ATA_CFA_MAGIC)) + (atadev->param.config == ATA_CFA_MAGIC1) || + (atadev->param.config == ATA_CFA_MAGIC2)) return 0; else return ENXIO; @@ -295,8 +296,14 @@ struct bio bp; /* length zero is special and really means flush buffers to media */ - if (!length) - return ata_controlcmd(dp->d_drv1, ATA_FLUSHCACHE, 0, 0, 0); + if (!length) { + struct ata_device *atadev = device_get_softc(dp->d_drv1); + int error = 0; + + if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) + error = ata_controlcmd(dp->d_drv1, ATA_FLUSHCACHE, 0, 0, 0); + return error; + } bzero(&bp, sizeof(struct bio)); bp.bio_disk = dp; @@ -365,19 +372,17 @@ strncpy(product, atadev->param.model, 40); } - device_printf(dev, "%lluMB <%s%s %.8s> at ata%d-%s %s%s\n", - (unsigned long long)(adp->total_secs / (1048576 / DEV_BSIZE)), + device_printf(dev, "%juMB <%s%s %.8s> at ata%d-%s %s%s\n", + adp->total_secs / (1048576 / DEV_BSIZE), vendor, product, atadev->param.revision, device_get_unit(ch->dev), (atadev->unit == ATA_MASTER) ? "master" : "slave", (adp->flags & AD_F_TAG_ENABLED) ? "tagged " : "", ata_mode2str(atadev->mode)); if (bootverbose) { - device_printf(dev, "%llu sectors [%lldC/%dH/%dS] " - "%d sectors/interrupt %d depth queue\n", - (unsigned long long)adp->total_secs, - (unsigned long long)(adp->total_secs / - (adp->heads * adp->sectors)), + device_printf(dev, "%ju sectors [%juC/%dH/%dS] " + "%d sectors/interrupt %d depth queue\n", adp->total_secs, + adp->total_secs / (adp->heads * adp->sectors), adp->heads, adp->sectors, atadev->max_iosize / DEV_BSIZE, adp->num_tags + 1); } ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-pci.h#3 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ata/ata-pci.h,v 1.63 2006/02/16 17:09:24 sos Exp $ + * $FreeBSD: src/sys/dev/ata/ata-pci.h,v 1.64 2006/03/13 14:01:37 sos Exp $ */ /* structure holding chipset config info */ @@ -161,7 +161,10 @@ #define ATA_JMICRON_ID 0x197b #define ATA_JMB360 0x2360197b +#define ATA_JMB361 0x2361197b #define ATA_JMB363 0x2363197b +#define ATA_JMB365 0x2365197b +#define ATA_JMB366 0x2366197b #define ATA_MARVELL_ID 0x11ab #define ATA_M88SX5040 0x504011ab ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-queue.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.56 2006/02/23 20:15:22 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.63 2006/03/31 08:09:05 sos Exp $"); #include "opt_ata.h" #include @@ -51,17 +51,24 @@ void ata_queue_request(struct ata_request *request) { - struct ata_channel *ch = device_get_softc(device_get_parent(request->dev)); + struct ata_channel *ch; - /* mark request as virgin (this might be a ATA_R_REQUEUE) */ + /* treat request as virgin (this might be an ATA_R_REQUEUE) */ request->result = request->status = request->error = 0; - request->parent = device_get_parent(request->dev); + + /* check that that the device is still valid */ + if (!(request->parent = device_get_parent(request->dev))) { + request->result = ENXIO; + if (request->callback) + (request->callback)(request); + return; + } + ch = device_get_softc(request->parent); callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED); - if (!request->callback && !(request->flags & ATA_R_REQUEUE)) sema_init(&request->done, 0, "ATA request done"); - /* in ATA_STALL_QUEUE state we call HW directly (used only during reinit) */ + /* in ATA_STALL_QUEUE state we call HW directly */ if ((ch->state & ATA_STALL_QUEUE) && (request->flags & ATA_R_CONTROL)) { mtx_lock(&ch->state_mtx); ch->running = request; @@ -95,12 +102,14 @@ /* if this is not a callback wait until request is completed */ if (!request->callback) { ATA_DEBUG_RQ(request, "wait for completition"); - while (!dumping && - sema_timedwait(&request->done, request->timeout * hz * 4)) { + if (!dumping && + sema_timedwait(&request->done, request->timeout * hz * 4)) { device_printf(request->dev, - "req=%p %s semaphore timeout !! DANGER Will Robinson !!\n", - request, ata_cmd2str(request)); - ata_start(ch->dev); + "WARNING - %s taskqueue timeout " + "- completing request directly\n", + ata_cmd2str(request)); + request->flags |= ATA_R_DANGER1; + ata_completed(request, 0); } sema_destroy(&request->done); } @@ -252,15 +261,28 @@ struct ata_device *atadev = device_get_softc(request->dev); struct ata_composite *composite; + if (request->flags & ATA_R_DANGER2) { + device_printf(request->dev, + "WARNING - %s freeing taskqueue zombie request\n", + ata_cmd2str(request)); + request->flags &= ~(ATA_R_DANGER1 | ATA_R_DANGER2); + ata_free_request(request); + return; + } + if (request->flags & ATA_R_DANGER1) + request->flags |= ATA_R_DANGER2 + ATA_DEBUG_RQ(request, "completed entered"); /* if we had a timeout, reinit channel and deal with the falldown */ if (request->flags & ATA_R_TIMEOUT) { /* - * if reinit succeeds and the device doesn't get detached and + * if the channel is still present and + * reinit succeeds and + * the device doesn't get detached and * there are retries left we reinject this request */ - if (!ata_reinit(ch->dev) && !request->result && + if (ch && !ata_reinit(ch->dev) && !request->result && (request->retries-- > 0)) { if (!(request->flags & ATA_R_QUIET)) { device_printf(request->dev, @@ -268,7 +290,7 @@ ata_cmd2str(request), request->retries, request->retries == 1 ? "y" : "ies"); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); } request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG); @@ -285,15 +307,14 @@ device_printf(request->dev, "FAILURE - %s timed out", ata_cmd2str(request)); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", - (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); } } request->result = EIO; } } - else { + else if (!(request->flags & ATA_R_ATAPI) ){ /* if this is a soft ECC error warn about it */ /* XXX SOS we could do WARF here */ if ((request->status & (ATA_S_CORR | ATA_S_ERROR)) == ATA_S_CORR) { @@ -301,7 +322,7 @@ "WARNING - %s soft error (ECC corrected)", ata_cmd2str(request)); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); } @@ -312,7 +333,7 @@ "WARNING - %s UDMA ICRC error (retrying request)", ata_cmd2str(request)); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); request->flags |= (ATA_R_AT_HEAD | ATA_R_REQUEUE); ata_queue_request(request); @@ -340,7 +361,7 @@ (request->dmastat & ATA_BMSTAT_ERROR)) printf(" dma=0x%02x", request->dmastat); if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL))) - printf(" LBA=%llu", (unsigned long long)request->u.ata.lba); + printf(" LBA=%ju", request->u.ata.lba); printf("\n"); } request->result = EIO; @@ -354,16 +375,15 @@ break; /* if we have a sensekey -> request sense from device */ - if (request->error & ATA_SK_MASK && - request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE) { + if ((request->error & ATA_E_ATAPI_SENSE_MASK) && + (request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE)) { static u_int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0, sizeof(struct atapi_sense), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - request->u.atapi.sense_key = request->error; - request->u.atapi.sense_cmd = request->u.atapi.ccb[0]; + request->u.atapi.saved_cmd = request->u.atapi.ccb[0]; bcopy(ccb, request->u.atapi.ccb, 16); - request->data = (caddr_t)&request->u.atapi.sense_data; + request->data = (caddr_t)&request->u.atapi.sense; request->bytecount = sizeof(struct atapi_sense); request->donecount = 0; request->transfersize = sizeof(struct atapi_sense); @@ -375,21 +395,21 @@ return; } - switch (request->u.atapi.sense_key & ATA_SK_MASK) { - case ATA_SK_RECOVERED_ERROR: + switch (request->u.atapi.sense.key & ATA_SENSE_KEY_MASK) { + case ATA_SENSE_RECOVERED_ERROR: device_printf(request->dev, "WARNING - %s recovered error\n", ata_cmd2str(request)); /* FALLTHROUGH */ - case ATA_SK_NO_SENSE: + case ATA_SENSE_NO_SENSE: request->result = 0; break; - case ATA_SK_NOT_READY: + case ATA_SENSE_NOT_READY: request->result = EBUSY; break; - case ATA_SK_UNIT_ATTENTION: + case ATA_SENSE_UNIT_ATTENTION: atadev->flags |= ATA_D_MEDIA_CHANGED; request->result = EIO; break; @@ -402,22 +422,19 @@ device_printf(request->dev, "FAILURE - %s %s asc=0x%02x ascq=0x%02x ", ata_cmd2str(request), ata_skey2str( - (request->u.atapi.sense_key & ATA_SK_MASK) >> 4), - request->u.atapi.sense_data.asc, - request->u.atapi.sense_data.ascq); - if (request->u.atapi.sense_data.sksv) - printf("sks=0x%02x 0x%02x 0x%02x ", - request->u.atapi.sense_data.sk_specific, - request->u.atapi.sense_data.sk_specific1, - request->u.atapi.sense_data.sk_specific2); - printf("error=%b\n", - (request->u.atapi.sense_key & ATA_E_MASK), - "\20\4MEDIA_CHANGE_REQUEST\3ABORTED" - "\2NO_MEDIA\1ILLEGAL_LENGTH"); + (request->u.atapi.sense.key & ATA_SENSE_KEY_MASK)), + request->u.atapi.sense.asc, + request->u.atapi.sense.ascq); + if (request->u.atapi.sense.specific & ATA_SENSE_SPEC_VALID) + printf("sks=0x%02x 0x%02x 0x%02x\n", + request->u.atapi.sense.specific & ATA_SENSE_SPEC_MASK, + request->u.atapi.sense.specific1, + request->u.atapi.sense.specific2); } - if ((request->u.atapi.sense_key ? - request->u.atapi.sense_key : request->error) & ATA_E_MASK) + if ((request->u.atapi.sense.key & ATA_SENSE_KEY_MASK ? + request->u.atapi.sense.key & ATA_SENSE_KEY_MASK : + request->error)) request->result = EIO; } @@ -461,7 +478,9 @@ else sema_post(&request->done); - ata_start(ch->dev); + /* only call ata_start if channel is present */ + if (ch) + ata_start(ch->dev); } void @@ -505,7 +524,6 @@ if ((request = ch->running) && (!dev || request->dev == dev)) { callout_stop(&request->callout); ch->running = NULL; - ch->state = ATA_IDLE; request->result = ENXIO; TAILQ_INSERT_TAIL(&fail_requests, request, chain); } @@ -527,9 +545,6 @@ TAILQ_REMOVE(&fail_requests, request, chain); ata_finish(request); } - - /* we might have work for the other device on this channel */ - ata_start(ch->dev); } static u_int64_t @@ -613,8 +628,8 @@ static char buffer[20]; if (request->flags & ATA_R_ATAPI) { - switch (request->u.atapi.sense_key ? - request->u.atapi.sense_cmd : request->u.atapi.ccb[0]) { + switch (request->u.atapi.sense.key ? + request->u.atapi.saved_cmd : request->u.atapi.ccb[0]) { case 0x00: return ("TEST_UNIT_READY"); case 0x01: return ("REZERO"); case 0x03: return ("REQUEST_SENSE"); @@ -655,6 +670,7 @@ case 0x5b: return ("CLOSE_TRACK/SESSION"); case 0x5c: return ("READ_BUFFER_CAPACITY"); case 0x5d: return ("SEND_CUE_SHEET"); + case 0x96: return ("SERVICE_ACTION_IN"); case 0xa1: return ("BLANK_CMD"); case 0xa3: return ("SEND_KEY"); case 0xa4: return ("REPORT_KEY"); ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/ata-raid.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-raid.c,v 1.118 2006/02/17 13:02:09 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-raid.c,v 1.120 2006/04/15 10:27:41 maxim Exp $"); #include "opt_ata.h" #include @@ -148,14 +148,14 @@ rdp->disk->d_unit = rdp->lun; disk_create(rdp->disk, DISK_VERSION); - printf("ar%d: %lluMB <%s %s%s> status: %s\n", rdp->lun, - (unsigned long long)(rdp->total_sectors / ((1024L*1024L)/DEV_BSIZE)), + printf("ar%d: %juMB <%s %s%s> status: %s\n", rdp->lun, + rdp->total_sectors / ((1024L * 1024L) / DEV_BSIZE), ata_raid_format(rdp), ata_raid_type(rdp), buffer, ata_raid_flags(rdp)); if (testing || bootverbose) - printf("ar%d: %llu sectors [%dC/%dH/%dS] <%s> subdisks defined as:\n", - rdp->lun, (unsigned long long)rdp->total_sectors, + printf("ar%d: %ju sectors [%dC/%dH/%dS] <%s> subdisks defined as:\n", + rdp->lun, rdp->total_sectors, rdp->cylinders, rdp->heads, rdp->sectors, rdp->name); for (disk = 0; disk < rdp->total_disks; disk++) { @@ -974,7 +974,7 @@ * metadata format from the disks (if we support it). */ printf("WARNING!! - not able to determine metadata format\n" - "WARNING!! - Using FreeBSD PsuedoRAID metadata\n" + "WARNING!! - Using FreeBSD PseudoRAID metadata\n" "If that is not what you want, use the BIOS to " "create the array\n"); ctlr = AR_F_FREEBSD_RAID; @@ -4234,13 +4234,11 @@ printf("type %s\n", ata_raid_type(raid)); printf("flags 0x%02x %b\n", raid->status, raid->status, "\20\3REBUILDING\2DEGRADED\1READY\n"); - printf("magic_0 0x%016llx\n",(unsigned long long)raid->magic_0); - printf("magic_1 0x%016llx\n",(unsigned long long)raid->magic_1); + printf("magic_0 0x%016jx\n", raid->magic_0); + printf("magic_1 0x%016jx\n",raid->magic_1); printf("generation %u\n", raid->generation); - printf("total_sectors %llu\n", - (unsigned long long)raid->total_sectors); - printf("offset_sectors %llu\n", - (unsigned long long)raid->offset_sectors); + printf("total_sectors %ju\n", raid->total_sectors); + printf("offset_sectors %ju\n", raid->offset_sectors); printf("heads %u\n", raid->heads); printf("sectors %u\n", raid->sectors); printf("cylinders %u\n", raid->cylinders); @@ -4252,8 +4250,8 @@ raid->disks[i].flags, "\20\4ONLINE\3SPARE\2ASSIGNED\1PRESENT\n"); if (raid->disks[i].dev) { printf(" "); - device_printf(raid->disks[i].dev, " sectors %lld\n", - (long long)raid->disks[i].sectors); + device_printf(raid->disks[i].dev, " sectors %jd\n", + raid->disks[i].sectors); } } printf("=================================================\n"); @@ -4426,9 +4424,9 @@ printf("config_entries 0x%02x\n", meta->config_entries); for (i = 0; i < meta->config_entries; i++) { printf("config %d:\n", i); - printf(" total_sectors %llu\n", - (unsigned long long)(meta->configs[0].total_sectors + - ((u_int64_t)meta->configs_high[0].total_sectors << 32))); + printf(" total_sectors %ju\n", + meta->configs[0].total_sectors + + ((u_int64_t)meta->configs_high[0].total_sectors << 32)); printf(" type %s\n", ata_raid_hptv3_type(meta->configs[i].type)); printf(" total_disks %u\n", meta->configs[i].total_disks); @@ -4437,9 +4435,9 @@ printf(" status %b\n", meta->configs[i].status, "\20\2RAID5\1NEED_REBUILD\n"); printf(" critical_disks %u\n", meta->configs[i].critical_disks); - printf(" rebuild_lba %llu\n", - (unsigned long long)(meta->configs_high[0].rebuild_lba + - ((u_int64_t)meta->configs_high[0].rebuild_lba << 32))); + printf(" rebuild_lba %ju\n", + meta->configs_high[0].rebuild_lba + + ((u_int64_t)meta->configs_high[0].rebuild_lba << 32)); } printf("name <%.16s>\n", meta->name); printf("timestamp 0x%08x\n", meta->timestamp); @@ -4491,8 +4489,7 @@ map = (struct intel_raid_mapping *)&meta->disk[meta->total_disks]; for (j = 0; j < meta->total_volumes; j++) { printf("name %.16s\n", map->name); - printf("total_sectors %llu\n", - (unsigned long long)map->total_sectors); + printf("total_sectors %ju\n", map->total_sectors); printf("state %u\n", map->state); printf("reserved %u\n", map->reserved); printf("offset %u\n", map->offset); @@ -4537,8 +4534,7 @@ *((u_int16_t *)meta->timestamp_0), meta->timestamp_0[2], meta->timestamp_0[3], meta->timestamp_0[5], meta->timestamp_0[4], meta->timestamp_0[7], meta->timestamp_0[6]); - printf("total_sectors %lld\n", - (unsigned long long)meta->total_sectors); + printf("total_sectors %jd\n", meta->total_sectors); printf("type %s\n", ata_raid_ite_type(meta->type)); printf("stripe_1kblocks %u\n", meta->stripe_1kblocks); printf("timestamp_1 %04x/%02x/%02x %02x:%02x:%02x.%02x\n", @@ -4732,8 +4728,8 @@ printf("revision %.4s\n", meta->revision); printf("dummy_1 0x%08x\n", meta->dummy_1); printf("magic_0 0x%08x\n", meta->magic_0); - printf("magic_1 0x%016llx\n",(unsigned long long)meta->magic_1); - printf("magic_2 0x%016llx\n",(unsigned long long)meta->magic_2); + printf("magic_1 0x%016jx\n", meta->magic_1); + printf("magic_2 0x%016jx\n", meta->magic_2); printf("flags 0x%02x\n", meta->flags); printf("array_width %d\n", meta->array_width); printf("total_disks %d\n", meta->total_disks); @@ -4777,7 +4773,7 @@ printf("********* ATA Promise FastTrak Metadata *********\n"); printf("promise_id <%s>\n", meta->promise_id); printf("dummy_0 0x%08x\n", meta->dummy_0); - printf("magic_0 0x%016llx\n",(unsigned long long)meta->magic_0); + printf("magic_0 0x%016jx\n", meta->magic_0); printf("magic_1 0x%04x\n", meta->magic_1); printf("magic_2 0x%08x\n", meta->magic_2); printf("integrity 0x%08x %b\n", meta->raid.integrity, @@ -4789,8 +4785,7 @@ printf("disk_number %d\n", meta->raid.disk_number); printf("channel 0x%02x\n", meta->raid.channel); printf("device 0x%02x\n", meta->raid.device); - printf("magic_0 0x%016llx\n", - (unsigned long long)meta->raid.magic_0); + printf("magic_0 0x%016jx\n", meta->raid.magic_0); printf("disk_offset %u\n", meta->raid.disk_offset); printf("disk_sectors %u\n", meta->raid.disk_sectors); printf("rebuild_lba 0x%08x\n", meta->raid.rebuild_lba); @@ -4807,8 +4802,7 @@ printf("cylinders %u\n", meta->raid.cylinders); printf("heads %u\n", meta->raid.heads); printf("sectors %u\n", meta->raid.sectors); - printf("magic_1 0x%016llx\n", - (unsigned long long)meta->raid.magic_1); + printf("magic_1 0x%016jx\n", meta->raid.magic_1); printf("DISK# flags dummy_0 channel device magic_0\n"); for (i = 0; i < 8; i++) { printf(" %d %b 0x%02x 0x%02x 0x%02x ", @@ -4816,8 +4810,7 @@ "\20\10READY\7DOWN\6REDIR\5DUPLICATE\4SPARE" "\3ASSIGNED\2ONLINE\1VALID\n", meta->raid.disk[i].dummy_0, meta->raid.disk[i].channel, meta->raid.disk[i].device); - printf("0x%016llx\n", - (unsigned long long)meta->raid.disk[i].magic_0); + printf("0x%016jx\n", meta->raid.disk[i].magic_0); } printf("checksum 0x%08x\n", meta->checksum); printf("=================================================\n"); @@ -4842,8 +4835,7 @@ ata_raid_sii_print_meta(struct sii_raid_conf *meta) { printf("******* ATA Silicon Image Medley Metadata *******\n"); - printf("total_sectors %llu\n", - (unsigned long long)meta->total_sectors); + printf("total_sectors %ju\n", meta->total_sectors); printf("dummy_0 0x%04x\n", meta->dummy_0); printf("dummy_1 0x%04x\n", meta->dummy_1); printf("controller_pci_id 0x%08x\n", meta->controller_pci_id); @@ -4860,7 +4852,7 @@ printf("raid0_ident %u\n", meta->raid0_ident); printf("raid1_disks %u\n", meta->raid1_disks); printf("raid1_ident %u\n", meta->raid1_ident); - printf("rebuild_lba %llu\n", (unsigned long long)meta->rebuild_lba); + printf("rebuild_lba %ju\n", meta->rebuild_lba); printf("generation 0x%08x\n", meta->generation); printf("status 0x%02x %b\n", meta->status, meta->status, @@ -4943,8 +4935,7 @@ printf(" stripe_disks %d\n", meta->stripe_layout & VIA_L_DISKS); printf(" stripe_sectors %d\n", 0x08 << ((meta->stripe_layout & VIA_L_MASK) >> VIA_L_SHIFT)); - printf("disk_sectors %llu\n", - (unsigned long long)meta->disk_sectors); + printf("disk_sectors %ju\n", meta->disk_sectors); printf("disk_id 0x%08x\n", meta->disk_id); printf("DISK# disk_id\n"); for (i = 0; i < 8; i++) { ==== //depot/projects/kmacy_sun4v/src/sys/dev/ata/atapi-cam.c#3 (text+ko) ==== >>> TRUNCATED FOR MAIL (1000 lines) <<<