Subject: port-sparc/668: patch for /sys/arch/sparc/dev/esp.c
To: None <gnats-admin@NetBSD.ORG>
From: Darren Reed <darrenr@vitruvius.arbld.unimelb.EDU.AU>
List: netbsd-bugs
Date: 12/30/1994 22:05:07
>Number: 668
>Category: port-sparc
>Synopsis: netbsd-current won't work on a Sun sparc
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Dec 30 22:05:04 1994
>Originator: Darren Reed
>Organization:
University of Melbourne
>Release: netbsd-curent
>Environment:
Sun 4/40, NetBSD-current, sparc
System: NetBSD candella.arbld.unimelb.edu.au 1.0A NetBSD 1.0A (1.0A) #15: Sat Dec 31 16:35:44 EST 1994 darrenr@candella.arbld.unimelb.edu.au:/usr/src/sys/arch/sparc/compile/1.0A sparc
>Description:
NetBSD-current doesn't find a boot device (or any of the disk
devices) when it boots and initialises the esp scsi driver.
>How-To-Repeat:
Build netbsd-current kernel for a Sun sparc and boot using it.
>Fix:
The following patch allowed both the new sd.c to work along with the old
cgthree.c, etc. The other sparc scsi drivers need more work. This has
been tested.
*** /sys/arch/sparc/dev/esp.c.orig Fri Dec 30 20:11:10 1994
--- /sys/arch/sparc/dev/esp.c Sat Dec 31 16:20:21 1994
***************
*** 64,71 ****
int esp_debug = ESP_SHOWPHASE|ESP_SHOWMISC|ESP_SHOWTRAC|ESP_SHOWCMDS; /**/
! void espattach __P((struct device *, struct device *, void *));
! int espmatch __P((struct device *, void *, void *));
void esp_minphys __P((struct buf *));
u_int esp_adapter_info __P((struct esp_softc *));
int espprint __P((void *, char *));
--- 64,71 ----
int esp_debug = ESP_SHOWPHASE|ESP_SHOWMISC|ESP_SHOWTRAC|ESP_SHOWCMDS; /**/
! void esp_attach __P((struct device *, struct device *, void *));
! int esp_probe __P((struct device *, void *, void *));
void esp_minphys __P((struct buf *));
u_int esp_adapter_info __P((struct esp_softc *));
int espprint __P((void *, char *));
***************
*** 87,103 ****
/* Linkup to the rest of the kernel */
struct cfdriver espcd = {
! NULL, "esp", espmatch, espattach,
DV_DULL, sizeof(struct esp_softc)
};
struct scsi_adapter esp_switch = {
esp_scsi_cmd,
esp_minphys,
! 0,
! 0,
! esp_adapter_info,
! "esp"
};
struct scsi_device esp_dev = {
--- 87,101 ----
/* Linkup to the rest of the kernel */
struct cfdriver espcd = {
! NULL, "esp", esp_probe, esp_attach,
DV_DULL, sizeof(struct esp_softc)
};
struct scsi_adapter esp_switch = {
esp_scsi_cmd,
esp_minphys,
! NULL,
! NULL,
};
struct scsi_device esp_dev = {
***************
*** 105,112 ****
NULL, /* have a queue, served by this */
NULL, /* have no async handler */
NULL, /* Use default 'done' routine */
- "esp",
- 0
};
/*
--- 103,108 ----
***************
*** 217,223 ****
}
int
! espmatch(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
--- 213,219 ----
}
int
! esp_probe(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
***************
*** 237,243 ****
* Attach this instance, and then all the sub-devices
*/
void
! espattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
--- 233,239 ----
* Attach this instance, and then all the sub-devices
*/
void
! esp_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
***************
*** 387,395 ****
* fill in the prototype scsi_link.
*/
sc->sc_link.adapter_softc = sc;
! sc->sc_link.adapter_targ = sc->sc_id;
sc->sc_link.adapter = &esp_switch;
sc->sc_link.device = &esp_dev;
/*
* If the boot path is "esp" at the moment and it's me, then
--- 383,392 ----
* fill in the prototype scsi_link.
*/
sc->sc_link.adapter_softc = sc;
! sc->sc_link.adapter_target = sc->sc_id;
sc->sc_link.adapter = &esp_switch;
sc->sc_link.device = &esp_dev;
+ sc->sc_link.openings = 2;
/*
* If the boot path is "esp" at the moment and it's me, then
***************
*** 557,577 ****
flags = xs->flags;
/* Get a esp command block */
! if (!(flags & SCSI_NOMASK)) {
/* Critical region */
- s = splbio();
ecb = sc->free_list.tqh_first;
if (ecb) {
TAILQ_REMOVE(&sc->free_list, ecb, chain);
}
- splx(s);
} else {
ecb = sc->free_list.tqh_first;
if (ecb) {
TAILQ_REMOVE(&sc->free_list, ecb, chain);
}
}
!
if (ecb == NULL) {
xs->error = XS_DRIVER_STUFFUP;
ESP_MISC(("TRY_AGAIN_LATER"));
--- 554,574 ----
flags = xs->flags;
/* Get a esp command block */
! s = splbio();
! if (!(flags & SCSI_POLL)) {
/* Critical region */
ecb = sc->free_list.tqh_first;
if (ecb) {
TAILQ_REMOVE(&sc->free_list, ecb, chain);
}
} else {
ecb = sc->free_list.tqh_first;
if (ecb) {
TAILQ_REMOVE(&sc->free_list, ecb, chain);
}
}
! splx(s);
!
if (ecb == NULL) {
xs->error = XS_DRIVER_STUFFUP;
ESP_MISC(("TRY_AGAIN_LATER"));
***************
*** 587,603 ****
ecb->dleft = xs->datalen;
ecb->stat = 0;
! if (!(flags & SCSI_NOMASK))
! s = splbio();
TAILQ_INSERT_TAIL(&sc->ready_list, ecb, chain);
timeout(esp_timeout, ecb, (xs->timeout*hz)/1000);
if (sc->sc_state == ESP_IDLE)
esp_sched(sc);
! if (!(flags & SCSI_NOMASK)) { /* Almost done. Wait outside */
! splx(s);
ESP_MISC(("SUCCESSFULLY_QUEUED"));
return SUCCESSFULLY_QUEUED;
}
--- 584,599 ----
ecb->dleft = xs->datalen;
ecb->stat = 0;
! s = splbio();
TAILQ_INSERT_TAIL(&sc->ready_list, ecb, chain);
timeout(esp_timeout, ecb, (xs->timeout*hz)/1000);
if (sc->sc_state == ESP_IDLE)
esp_sched(sc);
+ splx(s);
! if (!(flags & SCSI_POLL)) { /* Almost done. Wait outside */
ESP_MISC(("SUCCESSFULLY_QUEUED"));
return SUCCESSFULLY_QUEUED;
}
***************
*** 656,663 ****
esp_timeout((caddr_t)ecb);
}
- if (xs->error)
- return HAD_ERROR;
return COMPLETE;
}
--- 652,657 ----
***************
*** 762,768 ****
xs->status = ecb->stat;
/* Next, setup a request sense command block */
bzero(ss, sizeof(*ss));
! ss->op_code = REQUEST_SENSE;
ss->byte2 = sc_link->lun << 5;
ss->length = sizeof(struct scsi_sense_data);
ecb->clen = sizeof(*ss);
--- 756,762 ----
xs->status = ecb->stat;
/* Next, setup a request sense command block */
bzero(ss, sizeof(*ss));
! ss->opcode = REQUEST_SENSE;
ss->byte2 = sc_link->lun << 5;
ss->length = sizeof(struct scsi_sense_data);
ecb->clen = sizeof(*ss);
***************
*** 783,792 ****
}
}
! if (xs->flags & SCSI_ERR_OK) {
! xs->resid = 0;
! xs->error = XS_NOERROR;
! } else if (xs->error == XS_NOERROR && (ecb->flags & ECB_CHKSENSE)) {
xs->error = XS_SENSE;
} else {
xs->resid = ecb->dleft;
--- 777,783 ----
}
}
! if (xs->error == XS_NOERROR && (ecb->flags & ECB_CHKSENSE)) {
xs->error = XS_SENSE;
} else {
xs->resid = ecb->dleft;
>Audit-Trail:
>Unformatted: