summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-07-01 00:02:08 +0000
committerkrw <krw@openbsd.org>2020-07-01 00:02:08 +0000
commit56332b02304b252ce9f7aaa920f0c13aa7f881bd (patch)
treec5622f7052dc2218ceedacff646be5a28d637f04
parentFix two places where carp backup state is misspelled in comments. (diff)
downloadwireguard-openbsd-56332b02304b252ce9f7aaa920f0c13aa7f881bd.tar.xz
wireguard-openbsd-56332b02304b252ce9f7aaa920f0c13aa7f881bd.zip
If the adapter card needs to keep track of its own id on the bus, or
the width of the bus it is providing, it should rely on info in its softc. i.e. not on info in the prototype scsi_link that is passed out for other bits of the kernel to fiddle with. Most drivers already do this. Make it so for the laggards iha(4) and siop(4). Actually use the existing softc value in wd33c93.c. No intentional functional change.
-rw-r--r--sys/dev/ic/iha.c7
-rw-r--r--sys/dev/ic/iha.h3
-rw-r--r--sys/dev/ic/siop.c18
-rw-r--r--sys/dev/ic/siop_common.c22
-rw-r--r--sys/dev/ic/siopvar_common.h3
-rw-r--r--sys/dev/ic/wd33c93.c4
6 files changed, 30 insertions, 27 deletions
diff --git a/sys/dev/ic/iha.c b/sys/dev/ic/iha.c
index bd531055a3c..ac1d0a19cce 100644
--- a/sys/dev/ic/iha.c
+++ b/sys/dev/ic/iha.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iha.c,v 1.48 2020/02/18 17:08:35 krw Exp $ */
+/* $OpenBSD: iha.c,v 1.49 2020/07/01 00:02:08 krw Exp $ */
/*-------------------------------------------------------------------------
*
* Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
@@ -366,6 +366,7 @@ iha_init_tulip(struct iha_softc *sc)
sc->HCS_Semaph = ~SEMAPH_IN_MAIN;
sc->HCS_JSStatus0 = 0;
sc->HCS_ActScb = NULL;
+ sc->sc_id = pScsi->NVM_SCSI_Id;
error = iha_alloc_scbs(sc);
if (error != 0)
@@ -407,7 +408,7 @@ iha_init_tulip(struct iha_softc *sc)
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSMOD);
/* Program HBA's SCSI ID */
- bus_space_write_1(iot, ioh, TUL_SID, sc->sc_link.adapter_target << 4);
+ bus_space_write_1(iot, ioh, TUL_SID, sc->sc_id << 4);
/*
* Configure the channel as requested by the NVRAM settings read
@@ -941,7 +942,7 @@ iha_scsi(struct iha_softc *sc, bus_space_tag_t iot, bus_space_handle_t ioh)
/* program HBA's SCSI ID & target SCSI ID */
bus_space_write_1(iot, ioh, TUL_SID,
- (sc->sc_link.adapter_target << 4) | pScb->SCB_Target);
+ (sc->sc_id << 4) | pScb->SCB_Target);
if ((pScb->SCB_Flags & SCSI_RESET) == 0) {
bus_space_write_1(iot, ioh, TUL_SYNCM, pTcs->TCS_JS_Period);
diff --git a/sys/dev/ic/iha.h b/sys/dev/ic/iha.h
index 8d794eb291e..13941dd579a 100644
--- a/sys/dev/ic/iha.h
+++ b/sys/dev/ic/iha.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iha.h,v 1.21 2020/02/18 17:07:38 krw Exp $ */
+/* $OpenBSD: iha.h,v 1.22 2020/07/01 00:02:08 krw Exp $ */
/*-------------------------------------------------------------------------
*
* Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
@@ -134,6 +134,7 @@ struct iha_softc {
bus_dmamap_t sc_dmamap;
struct scsi_link sc_link;
+ u_int16_t sc_id;
void *sc_ih;
diff --git a/sys/dev/ic/siop.c b/sys/dev/ic/siop.c
index a15ce0e608c..e841ce574ea 100644
--- a/sys/dev/ic/siop.c
+++ b/sys/dev/ic/siop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siop.c,v 1.77 2020/06/27 17:28:58 krw Exp $ */
+/* $OpenBSD: siop.c,v 1.78 2020/07/01 00:02:08 krw Exp $ */
/* $NetBSD: siop.c,v 1.79 2005/11/18 23:10:32 bouyer Exp $ */
/*
@@ -222,7 +222,7 @@ void
siop_reset(sc)
struct siop_softc *sc;
{
- int i, j;
+ int i, j, buswidth;
struct siop_lunsw *lunsw;
siop_common_reset(&sc->sc_c);
@@ -298,7 +298,8 @@ siop_reset(sc)
}
TAILQ_INIT(&sc->lunsw_list);
/* restore reselect switch */
- for (i = 0; i < sc->sc_c.sc_link.adapter_buswidth; i++) {
+ buswidth = (sc->sc_c.features & SF_BUS_WIDE) ? 16 : 8;
+ for (i = 0; i < buswidth; i++) {
struct siop_target *target;
if (sc->sc_c.targets[i] == NULL)
continue;
@@ -1258,7 +1259,7 @@ siop_handle_reset(sc)
struct cmd_list reset_list;
struct siop_cmd *siop_cmd, *next_siop_cmd;
struct siop_lun *siop_lun;
- int target, lun, tag;
+ int target, lun, tag, buswidth;
/*
* scsi bus reset. reset the chip and restart
* the queue. Need to clean up all active commands
@@ -1270,8 +1271,8 @@ siop_handle_reset(sc)
/*
* Process all commands: first commands being executed
*/
- for (target = 0; target < sc->sc_c.sc_link.adapter_buswidth;
- target++) {
+ buswidth = (sc->sc_c.features & SF_BUS_WIDE) ? 16 : 8;
+ for (target = 0; target < buswidth; target++) {
if (sc->sc_c.targets[target] == NULL)
continue;
for (lun = 0; lun < 8; lun++) {
@@ -2076,7 +2077,7 @@ siop_add_dev(sc, target, lun)
struct siop_target *siop_target =
(struct siop_target *)sc->sc_c.targets[target];
struct siop_lun *siop_lun = siop_target->siop_lun[lun];
- int i, ntargets;
+ int i, ntargets, buswidth;
if (siop_lun->reseloff > 0)
return;
@@ -2093,7 +2094,8 @@ siop_add_dev(sc, target, lun)
return;
}
/* count how many free targets we still have to probe */
- ntargets = (sc->sc_c.sc_link.adapter_buswidth - 1) - 1 - sc->sc_ntargets;
+ buswidth = (sc->sc_c.features & SF_BUS_WIDE) ? 16 : 8;
+ ntargets = (buswidth - 1) - 1 - sc->sc_ntargets;
/*
* we need 8 bytes for the lun sw additional entry, and
diff --git a/sys/dev/ic/siop_common.c b/sys/dev/ic/siop_common.c
index 2995f87b812..b74ed73334b 100644
--- a/sys/dev/ic/siop_common.c
+++ b/sys/dev/ic/siop_common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siop_common.c,v 1.39 2020/06/19 14:51:44 krw Exp $ */
+/* $OpenBSD: siop_common.c,v 1.40 2020/07/01 00:02:08 krw Exp $ */
/* $NetBSD: siop_common.c,v 1.37 2005/02/27 00:27:02 perry Exp $ */
/*
@@ -56,7 +56,7 @@ int
siop_common_attach(sc)
struct siop_common_softc *sc;
{
- int error, i;
+ int error, i, buswidth;
bus_dma_segment_t seg;
int rseg;
@@ -103,15 +103,13 @@ siop_common_attach(sc)
* for devices attached to this adapter. It is passed to
* the upper layers in config_found().
*/
+ buswidth = (sc->features & SF_BUS_WIDE) ? 16 : 8;
+ sc->sc_id = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_SCID);
+ if (sc->sc_id == 0 || sc->sc_id >= buswidth)
+ sc->sc_id = SIOP_DEFAULT_TARGET;
sc->sc_link.adapter_softc = sc;
- sc->sc_link.adapter_buswidth =
- (sc->features & SF_BUS_WIDE) ? 16 : 8;
- sc->sc_link.adapter_target =
- bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_SCID);
- if (sc->sc_link.adapter_target == 0 ||
- sc->sc_link.adapter_target >=
- sc->sc_link.adapter_buswidth)
- sc->sc_link.adapter_target = SIOP_DEFAULT_TARGET;
+ sc->sc_link.adapter_target = sc->sc_id;
+ sc->sc_link.adapter_buswidth = buswidth;
for (i = 0; i < 16; i++)
sc->targets[i] = NULL;
@@ -171,9 +169,9 @@ siop_common_reset(sc)
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_STIME0,
(0xb << STIME0_SEL_SHIFT));
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCID,
- sc->sc_link.adapter_target | SCID_RRE);
+ sc->sc_id | SCID_RRE);
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_RESPID0,
- 1 << sc->sc_link.adapter_target);
+ 1 << sc->sc_id);
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_DCNTL,
(sc->features & SF_CHIP_PF) ? DCNTL_COM | DCNTL_PFEN : DCNTL_COM);
if (sc->features & SF_CHIP_AAIP)
diff --git a/sys/dev/ic/siopvar_common.h b/sys/dev/ic/siopvar_common.h
index 7fc3d37ef15..7940c5e8b82 100644
--- a/sys/dev/ic/siopvar_common.h
+++ b/sys/dev/ic/siopvar_common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: siopvar_common.h,v 1.30 2020/02/17 02:50:23 krw Exp $ */
+/* $OpenBSD: siopvar_common.h,v 1.31 2020/07/01 00:02:08 krw Exp $ */
/* $NetBSD: siopvar_common.h,v 1.33 2005/11/18 23:10:32 bouyer Exp $ */
/*
@@ -130,6 +130,7 @@ struct siop_common_target {
struct siop_common_softc {
struct device sc_dev;
struct scsi_link sc_link; /* link to upper level */
+ u_int16_t sc_id; /* adapter's target on bus */
int features; /* chip's features */
int ram_size;
int maxburst;
diff --git a/sys/dev/ic/wd33c93.c b/sys/dev/ic/wd33c93.c
index 1a4237ed7b9..913b781d73d 100644
--- a/sys/dev/ic/wd33c93.c
+++ b/sys/dev/ic/wd33c93.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd33c93.c,v 1.14 2020/06/27 14:29:45 krw Exp $ */
+/* $OpenBSD: wd33c93.c,v 1.15 2020/07/01 00:02:08 krw Exp $ */
/* $NetBSD: wd33c93.c,v 1.24 2010/11/13 13:52:02 uebayasi Exp $ */
/*
@@ -283,7 +283,7 @@ wd33c93_reset(struct wd33c93_softc *sc)
if (sc->sc_reset != NULL)
(*sc->sc_reset)(sc);
- my_id = sc->sc_link.adapter_target & SBIC_ID_MASK;
+ my_id = sc->sc_id & SBIC_ID_MASK;
/* Enable advanced features and really(!) advanced features */
#if 1