Tue Sep 23 22:22:41 2008 UTC ()
PR/39583: Brad du Plessis: acrmsr(4) driver doesn't report number of volumes correctly
to bioctl(8)
PR/39584: Juan RP: arcmsr(4) driver disk state values are incorrect (for ARC-1220)


(christos)
diff -r1.21 -r1.22 src/sys/dev/pci/arcmsr.c
diff -r1.12 -r1.13 src/sys/dev/pci/arcmsrvar.h

cvs diff -r1.21 -r1.22 src/sys/dev/pci/arcmsr.c (expand / switch to unified diff)

--- src/sys/dev/pci/arcmsr.c 2008/06/24 10:14:41 1.21
+++ src/sys/dev/pci/arcmsr.c 2008/09/23 22:22:41 1.22
@@ -1,37 +1,37 @@ @@ -1,37 +1,37 @@
1/* $NetBSD: arcmsr.c,v 1.21 2008/06/24 10:14:41 gmcgarry Exp $ */ 1/* $NetBSD: arcmsr.c,v 1.22 2008/09/23 22:22:41 christos Exp $ */
2/* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ 2/* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2007, 2008 Juan Romero Pardines <xtraeme@netbsd.org> 5 * Copyright (c) 2007, 2008 Juan Romero Pardines <xtraeme@netbsd.org>
6 * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> 6 * Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21#include "bio.h" 21#include "bio.h"
22 22
23#include <sys/cdefs.h> 23#include <sys/cdefs.h>
24__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.21 2008/06/24 10:14:41 gmcgarry Exp $"); 24__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.22 2008/09/23 22:22:41 christos Exp $");
25 25
26#include <sys/param.h> 26#include <sys/param.h>
27#include <sys/buf.h> 27#include <sys/buf.h>
28#include <sys/kernel.h> 28#include <sys/kernel.h>
29#include <sys/malloc.h> 29#include <sys/malloc.h>
30#include <sys/device.h> 30#include <sys/device.h>
31#include <sys/kmem.h> 31#include <sys/kmem.h>
32#include <sys/kthread.h> 32#include <sys/kthread.h>
33#include <sys/mutex.h> 33#include <sys/mutex.h>
34#include <sys/condvar.h> 34#include <sys/condvar.h>
35#include <sys/rwlock.h> 35#include <sys/rwlock.h>
36 36
37#if NBIO > 0 37#if NBIO > 0
@@ -1188,28 +1188,27 @@ arc_bio_inq(struct arc_softc *sc, struct @@ -1188,28 +1188,27 @@ arc_bio_inq(struct arc_softc *sc, struct
1188 sc->sc_maxraidset = sysinfo->max_raid_set; 1188 sc->sc_maxraidset = sysinfo->max_raid_set;
1189 sc->sc_maxvolset = sysinfo->max_volume_set; 1189 sc->sc_maxvolset = sysinfo->max_volume_set;
1190 sc->sc_cchans = sysinfo->ide_channels; 1190 sc->sc_cchans = sysinfo->ide_channels;
1191 } 1191 }
1192 1192
1193 request[0] = ARC_FW_RAIDINFO; 1193 request[0] = ARC_FW_RAIDINFO;
1194 for (i = 0; i < sc->sc_maxraidset; i++) { 1194 for (i = 0; i < sc->sc_maxraidset; i++) {
1195 request[1] = i; 1195 request[1] = i;
1196 error = arc_msgbuf(sc, request, sizeof(request), raidinfo, 1196 error = arc_msgbuf(sc, request, sizeof(request), raidinfo,
1197 sizeof(struct arc_fw_raidinfo)); 1197 sizeof(struct arc_fw_raidinfo));
1198 if (error != 0) 1198 if (error != 0)
1199 goto out; 1199 goto out;
1200 1200
1201 if (raidinfo->volumes) 1201 nvols += raidinfo->volumes;
1202 nvols++; 
1203 } 1202 }
1204 1203
1205 strlcpy(bi->bi_dev, device_xname(sc->sc_dev), sizeof(bi->bi_dev)); 1204 strlcpy(bi->bi_dev, device_xname(sc->sc_dev), sizeof(bi->bi_dev));
1206 bi->bi_novol = nvols; 1205 bi->bi_novol = nvols;
1207 bi->bi_nodisk = sc->sc_cchans; 1206 bi->bi_nodisk = sc->sc_cchans;
1208 1207
1209out: 1208out:
1210 if (sysinfo) 1209 if (sysinfo)
1211 kmem_free(sysinfo, sizeof(*sysinfo)); 1210 kmem_free(sysinfo, sizeof(*sysinfo));
1212 kmem_free(raidinfo, sizeof(*raidinfo)); 1211 kmem_free(raidinfo, sizeof(*raidinfo));
1213 return error; 1212 return error;
1214} 1213}
1215 1214
@@ -1368,32 +1367,37 @@ out: @@ -1368,32 +1367,37 @@ out:
1368 kmem_free(diskinfo, sizeof(*diskinfo)); 1367 kmem_free(diskinfo, sizeof(*diskinfo));
1369 return error; 1368 return error;
1370} 1369}
1371 1370
1372static void 1371static void
1373arc_bio_disk_filldata(struct arc_softc *sc, struct bioc_disk *bd, 1372arc_bio_disk_filldata(struct arc_softc *sc, struct bioc_disk *bd,
1374 struct arc_fw_diskinfo *diskinfo, int diskid) 1373 struct arc_fw_diskinfo *diskinfo, int diskid)
1375{ 1374{
1376 uint64_t blocks; 1375 uint64_t blocks;
1377 char model[81]; 1376 char model[81];
1378 char serial[41]; 1377 char serial[41];
1379 char rev[17]; 1378 char rev[17];
1380 1379
 1380 /* Ignore bit zero for now, we don't know what it means */
 1381 diskinfo->device_state &= ~0x1;
 1382
1381 switch (diskinfo->device_state) { 1383 switch (diskinfo->device_state) {
 1384 case ARC_FW_DISK_FAILED:
 1385 bd->bd_status = BIOC_SDFAILED;
 1386 break;
1382 case ARC_FW_DISK_PASSTHRU: 1387 case ARC_FW_DISK_PASSTHRU:
1383 bd->bd_status = BIOC_SDPASSTHRU; 1388 bd->bd_status = BIOC_SDPASSTHRU;
1384 break; 1389 break;
1385 case ARC_FW_DISK_INITIALIZED: 1390 case ARC_FW_DISK_NORMAL:
1386 case ARC_FW_DISK_RAIDMEMBER: 
1387 bd->bd_status = BIOC_SDONLINE; 1391 bd->bd_status = BIOC_SDONLINE;
1388 break; 1392 break;
1389 case ARC_FW_DISK_HOTSPARE: 1393 case ARC_FW_DISK_HOTSPARE:
1390 bd->bd_status = BIOC_SDHOTSPARE; 1394 bd->bd_status = BIOC_SDHOTSPARE;
1391 break; 1395 break;
1392 case ARC_FW_DISK_UNUSED: 1396 case ARC_FW_DISK_UNUSED:
1393 bd->bd_status = BIOC_SDUNUSED; 1397 bd->bd_status = BIOC_SDUNUSED;
1394 break; 1398 break;
1395 case 0: 1399 case 0:
1396 /* disk has been disconnected */ 1400 /* disk has been disconnected */
1397 bd->bd_status = BIOC_SDOFFLINE; 1401 bd->bd_status = BIOC_SDOFFLINE;
1398 bd->bd_channel = 1; 1402 bd->bd_channel = 1;
1399 bd->bd_target = 0; 1403 bd->bd_target = 0;

cvs diff -r1.12 -r1.13 src/sys/dev/pci/arcmsrvar.h (expand / switch to unified diff)

--- src/sys/dev/pci/arcmsrvar.h 2008/04/03 13:59:01 1.12
+++ src/sys/dev/pci/arcmsrvar.h 2008/09/23 22:22:41 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: arcmsrvar.h,v 1.12 2008/04/03 13:59:01 xtraeme Exp $ */ 1/* $NetBSD: arcmsrvar.h,v 1.13 2008/09/23 22:22:41 christos Exp $ */
2/* Derived from $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ 2/* Derived from $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2007 Juan Romero Pardines <xtraeme@netbsd.org> 5 * Copyright (c) 2007 Juan Romero Pardines <xtraeme@netbsd.org>
6 * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> 6 * Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -337,31 +337,31 @@ struct arc_fw_volinfo { @@ -337,31 +337,31 @@ struct arc_fw_volinfo {
337 uint8_t new_member_disks; 337 uint8_t new_member_disks;
338 uint8_t new_raid_level; 338 uint8_t new_raid_level;
339 uint8_t raid_set_number; 339 uint8_t raid_set_number;
340 uint8_t reserved[5]; 340 uint8_t reserved[5];
341} __packed; 341} __packed;
342 342
343struct arc_fw_diskinfo { 343struct arc_fw_diskinfo {
344 uint8_t model[40]; 344 uint8_t model[40];
345 uint8_t serial[20]; 345 uint8_t serial[20];
346 uint8_t firmware_rev[8]; 346 uint8_t firmware_rev[8];
347 uint32_t capacity; 347 uint32_t capacity;
348 uint32_t capacity2; 348 uint32_t capacity2;
349 uint8_t device_state; 349 uint8_t device_state;
350#define ARC_FW_DISK_INITIALIZED 0x88 /* disk has been initialized */ 350#define ARC_FW_DISK_NORMAL 0x88 /* disk attached/initialized */
351#define ARC_FW_DISK_RAIDMEMBER 0x89 /* disk is member of a raid set */ 351#define ARC_FW_DISK_PASSTHRU 0x8a /* pass through disk in normal state */
352#define ARC_FW_DISK_PASSTHRU 0x8b /* pass through disk */ 352#define ARC_FW_DISK_HOTSPARE 0xa8 /* hotspare disk in normal state */
353#define ARC_FW_DISK_HOTSPARE 0xa9 /* hotspare disk */ 353#define ARC_FW_DISK_UNUSED 0xc8 /* free/unused disk in normal state */
354#define ARC_FW_DISK_UNUSED 0xc9 /* free/unused disk */ 354#define ARC_FW_DISK_FAILED 0x10 /* disk in failed state */
355 uint8_t pio_mode; 355 uint8_t pio_mode;
356 uint8_t current_udma_mode; 356 uint8_t current_udma_mode;
357 uint8_t udma_mode; 357 uint8_t udma_mode;
358 uint8_t drive_select; 358 uint8_t drive_select;
359 uint8_t raid_number; /* 0xff unowned */ 359 uint8_t raid_number; /* 0xff unowned */
360 struct arc_fw_scsiattr scsi_attr; 360 struct arc_fw_scsiattr scsi_attr;
361 uint8_t reserved[40]; 361 uint8_t reserved[40];
362} __packed; 362} __packed;
363 363
364struct arc_fw_sysinfo { 364struct arc_fw_sysinfo {
365 uint8_t vendor_name[40]; 365 uint8_t vendor_name[40];
366 uint8_t serial_number[16]; 366 uint8_t serial_number[16];
367 uint8_t firmware_version[16]; 367 uint8_t firmware_version[16];