Add a "max_target" member to struct scsi_link, which is filled in by
host adapter drivers, indicating the highest SCSI target they can address. Use this value to dynamically allocate data structures, rather than hard-coding 8 targets. These changes allow targets > 7 to be addressed on wide SCSI busses. Fixes PRs #1674 and #2892.
This commit is contained in:
parent
e4f6e48c7d
commit
f113ac70dd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsiconf.c,v 1.71 1996/12/05 01:06:41 cgd Exp $ */
|
||||
/* $NetBSD: scsiconf.c,v 1.72 1996/12/10 21:06:29 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -167,10 +167,27 @@ scsibusattach(parent, self, aux)
|
|||
{
|
||||
struct scsibus_softc *sb = (struct scsibus_softc *)self;
|
||||
struct scsi_link *sc_link_proto = aux;
|
||||
size_t nbytes;
|
||||
int i;
|
||||
|
||||
sc_link_proto->scsibus = sb->sc_dev.dv_unit;
|
||||
sb->adapter_link = sc_link_proto;
|
||||
printf("\n");
|
||||
sb->sc_maxtarget = sc_link_proto->max_target;
|
||||
printf(": %d targets\n", sb->sc_maxtarget + 1);
|
||||
|
||||
nbytes = sb->sc_maxtarget * sizeof(struct scsi_link **);
|
||||
sb->sc_link = (struct scsi_link ***)malloc(nbytes, M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (sb->sc_link == NULL)
|
||||
panic("scsibusattach: can't allocate target links");
|
||||
|
||||
nbytes = 8 * sizeof(struct scsi_link *);
|
||||
for (i = 0; i <= sb->sc_maxtarget; i++) {
|
||||
sb->sc_link[i] = (struct scsi_link **)malloc(nbytes,
|
||||
M_DEVBUF, M_NOWAIT);
|
||||
if (sb->sc_link[i] == NULL)
|
||||
panic("scsibusattach: can't allocate lun links");
|
||||
}
|
||||
|
||||
#if defined(SCSI_DELAY) && SCSI_DELAY > 2
|
||||
printf("%s: waiting for scsi devices to settle\n",
|
||||
|
@ -252,10 +269,10 @@ scsi_probe_bus(bus, target, lun)
|
|||
scsi_addr = scsi->adapter_link->adapter_target;
|
||||
|
||||
if (target == -1) {
|
||||
maxtarget = 7;
|
||||
maxtarget = scsi->sc_maxtarget;
|
||||
mintarget = 0;
|
||||
} else {
|
||||
if (target < 0 || target > 7)
|
||||
if (target < 0 || target > scsi->sc_maxtarget)
|
||||
return EINVAL;
|
||||
maxtarget = mintarget = target;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsiconf.h,v 1.33 1996/10/23 07:25:42 matthias Exp $ */
|
||||
/* $NetBSD: scsiconf.h,v 1.34 1996/12/10 21:06:31 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -163,6 +163,8 @@ struct scsi_link {
|
|||
void *device_softc; /* needed for call to foo_start */
|
||||
struct scsi_adapter *adapter; /* adapter entry points etc. */
|
||||
void *adapter_softc; /* needed for call to foo_scsi_cmd */
|
||||
int max_target; /* XXX max target supported by
|
||||
adapter */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -198,7 +200,8 @@ struct scsi_inquiry_pattern {
|
|||
struct scsibus_softc {
|
||||
struct device sc_dev;
|
||||
struct scsi_link *adapter_link; /* prototype supplied by adapter */
|
||||
struct scsi_link *sc_link[8][8];
|
||||
struct scsi_link ***sc_link; /* dynamically allocated */
|
||||
int sc_maxtarget;
|
||||
u_int8_t moreluns;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsiconf.c,v 1.71 1996/12/05 01:06:41 cgd Exp $ */
|
||||
/* $NetBSD: scsiconf.c,v 1.72 1996/12/10 21:06:29 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -167,10 +167,27 @@ scsibusattach(parent, self, aux)
|
|||
{
|
||||
struct scsibus_softc *sb = (struct scsibus_softc *)self;
|
||||
struct scsi_link *sc_link_proto = aux;
|
||||
size_t nbytes;
|
||||
int i;
|
||||
|
||||
sc_link_proto->scsibus = sb->sc_dev.dv_unit;
|
||||
sb->adapter_link = sc_link_proto;
|
||||
printf("\n");
|
||||
sb->sc_maxtarget = sc_link_proto->max_target;
|
||||
printf(": %d targets\n", sb->sc_maxtarget + 1);
|
||||
|
||||
nbytes = sb->sc_maxtarget * sizeof(struct scsi_link **);
|
||||
sb->sc_link = (struct scsi_link ***)malloc(nbytes, M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (sb->sc_link == NULL)
|
||||
panic("scsibusattach: can't allocate target links");
|
||||
|
||||
nbytes = 8 * sizeof(struct scsi_link *);
|
||||
for (i = 0; i <= sb->sc_maxtarget; i++) {
|
||||
sb->sc_link[i] = (struct scsi_link **)malloc(nbytes,
|
||||
M_DEVBUF, M_NOWAIT);
|
||||
if (sb->sc_link[i] == NULL)
|
||||
panic("scsibusattach: can't allocate lun links");
|
||||
}
|
||||
|
||||
#if defined(SCSI_DELAY) && SCSI_DELAY > 2
|
||||
printf("%s: waiting for scsi devices to settle\n",
|
||||
|
@ -252,10 +269,10 @@ scsi_probe_bus(bus, target, lun)
|
|||
scsi_addr = scsi->adapter_link->adapter_target;
|
||||
|
||||
if (target == -1) {
|
||||
maxtarget = 7;
|
||||
maxtarget = scsi->sc_maxtarget;
|
||||
mintarget = 0;
|
||||
} else {
|
||||
if (target < 0 || target > 7)
|
||||
if (target < 0 || target > scsi->sc_maxtarget)
|
||||
return EINVAL;
|
||||
maxtarget = mintarget = target;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsiconf.h,v 1.33 1996/10/23 07:25:42 matthias Exp $ */
|
||||
/* $NetBSD: scsiconf.h,v 1.34 1996/12/10 21:06:31 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -163,6 +163,8 @@ struct scsi_link {
|
|||
void *device_softc; /* needed for call to foo_start */
|
||||
struct scsi_adapter *adapter; /* adapter entry points etc. */
|
||||
void *adapter_softc; /* needed for call to foo_scsi_cmd */
|
||||
int max_target; /* XXX max target supported by
|
||||
adapter */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -198,7 +200,8 @@ struct scsi_inquiry_pattern {
|
|||
struct scsibus_softc {
|
||||
struct device sc_dev;
|
||||
struct scsi_link *adapter_link; /* prototype supplied by adapter */
|
||||
struct scsi_link *sc_link[8][8];
|
||||
struct scsi_link ***sc_link; /* dynamically allocated */
|
||||
int sc_maxtarget;
|
||||
u_int8_t moreluns;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue