Module Name:    src
Committed By:   jakllsch
Date:           Fri Mar 12 19:03:14 UTC 2010

Modified Files:
        src/sys/dev/ic: ahcisata_core.c

Log Message:
ata(4) expects IDENTIFY data to be in host endianess.
Logic borrowed from siisata(4) (which I've confirmed works on sparc64).
Should fix PR kern/39659.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ic/ahcisata_core.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/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.24 src/sys/dev/ic/ahcisata_core.c:1.25
--- src/sys/dev/ic/ahcisata_core.c:1.24	Wed Mar 10 19:23:57 2010
+++ src/sys/dev/ic/ahcisata_core.c	Fri Mar 12 19:03:14 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.24 2010/03/10 19:23:57 bouyer Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.24 2010/03/10 19:23:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -831,6 +831,8 @@
 	struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
 	struct ahci_channel *achp = (struct ahci_channel *)chp;
 	struct ata_command *ata_c = xfer->c_cmd;
+	uint16_t *idwordbuf;
+	int i;
 
 	AHCIDEBUG_PRINT(("ahci_cmd_done channel %d\n", chp->ch_channel),
 	    DEBUG_FUNCS);
@@ -849,6 +851,15 @@
 	AHCI_CMDH_SYNC(sc, achp, slot,
 	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
+	/* ata(4) expects IDENTIFY data to be in host endianess */
+	if (ata_c->r_command == WDCC_IDENTIFY ||
+	    ata_c->r_command == ATAPI_IDENTIFY_DEVICE) {
+		idwordbuf = xfer->c_databuf;
+		for (i = 0; i < (xfer->c_bcount / sizeof(*idwordbuf)); i++) {
+			idwordbuf[i] = le16toh(idwordbuf[i]);
+		}
+	}
+
 	ata_c->flags |= AT_DONE;
 	if (achp->ahcic_cmdh[slot].cmdh_prdbc)
 		ata_c->flags |= AT_XFDONE;

Reply via email to