summaryrefslogtreecommitdiff
path: root/sys/dev/ata/ata-disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ata/ata-disk.c')
-rw-r--r--sys/dev/ata/ata-disk.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 1fda7dff49a3..964b21e241d4 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998,1999,2000 Søren Schmidt
+ * Copyright (c) 1998,1999,2000,2001 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,6 @@
* $FreeBSD$
*/
-#include "apm.h"
#include "opt_global.h"
#include "opt_ata.h"
#include <sys/param.h>
@@ -41,6 +40,7 @@
#include <sys/disk.h>
#include <sys/devicestat.h>
#include <sys/cons.h>
+#include <sys/syslog.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
@@ -98,7 +98,7 @@ static int ad_version(u_int16_t);
/* internal vars */
static u_int32_t adp_lun_map = 0;
-MALLOC_DEFINE(M_AD, "AD driver", "ATA disk driver");
+static MALLOC_DEFINE(M_AD, "AD driver", "ATA disk driver");
/* defines */
#define AD_MAX_RETRIES 3
@@ -115,11 +115,10 @@ ad_attach(struct ata_softc *scp, int device)
int secsperint;
- if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT))) {
+ if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT | M_ZERO))) {
ata_printf(scp, device, "failed to allocate driver storage\n");
return;
}
- bzero(adp, sizeof(struct ad_softc));
scp->dev_softc[ATA_DEV(device)] = adp;
adp->controller = scp;
adp->unit = device;
@@ -153,10 +152,15 @@ ad_attach(struct ata_softc *scp, int device)
0, 0, 0, 0, ATA_C_F_ENAB_RCACHE, ATA_WAIT_INTR))
printf("ad%d: enabling readahead cache failed\n", adp->lun);
+#if defined(ATA_ENABLE_WC) || defined(ATA_ENABLE_TAGS)
if (ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES,
0, 0, 0, 0, ATA_C_F_ENAB_WCACHE, ATA_WAIT_INTR))
printf("ad%d: enabling write cache failed\n", adp->lun);
-
+#else
+ if (ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES,
+ 0, 0, 0, 0, ATA_C_F_DIS_WCACHE, ATA_WAIT_INTR))
+ printf("ad%d: disabling write cache failed\n", adp->lun);
+#endif
/* use DMA if drive & controller supports it */
ata_dmainit(adp->controller, adp->unit,
ata_pmode(AD_PARAM), ata_wmode(AD_PARAM), ata_umode(AD_PARAM));
@@ -376,13 +380,12 @@ ad_start(struct ad_softc *adp)
return;
}
- if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT))) {
+ if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT|M_ZERO))) {
printf("ad%d: out of memory in start\n", adp->lun);
return;
}
/* setup request */
- bzero(request, sizeof(struct ad_request));
request->device = adp;
request->bp = bp;
request->blockaddr = bp->b_pblkno;
@@ -592,16 +595,18 @@ ad_interrupt(struct ad_request *request)
/* do we have a corrected soft error ? */
if (adp->controller->status & ATA_S_CORR)
- printf("ad%d: soft error ECC corrected\n", adp->lun);
+ diskerr(request->bp, "soft (ECC corrected)", LOG_PRINTF,
+ request->blockaddr + (request->donecount / DEV_BSIZE),
+ &adp->disk.d_label);
/* did any real errors happen ? */
if ((adp->controller->status & ATA_S_ERROR) ||
(request->flags & ADR_F_DMA_USED && dma_stat & ATA_BMSTAT_ERROR)) {
adp->controller->error = inb(adp->controller->ioaddr + ATA_ERROR);
- printf("ad%d: %s %s ERROR blk# %d", adp->lun,
- (adp->controller->error & ATA_E_ICRC) ? "UDMA ICRC" : "HARD",
- (request->flags & ADR_F_READ) ? "READ" : "WRITE",
- request->blockaddr + (request->donecount / DEV_BSIZE));
+ diskerr(request->bp,
+ (adp->controller->error & ATA_E_ICRC) ? "UDMA ICRC" : "hard",
+ LOG_PRINTF, request->blockaddr + (request->donecount/DEV_BSIZE),
+ &adp->disk.d_label);
/* if this is a UDMA CRC error, reinject request */
if (request->flags & ADR_F_DMA_USED &&