Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Mar 2001 18:31:18 -0700
From:      "Kenneth D. Merry" <ken@kdm.org>
To:        scsi@FreeBSD.org
Cc:        current@FreeBSD.org
Subject:   aic(4) driver patch
Message-ID:  <20010315183118.A9399@panzer.kdm.org>

next in thread | raw e-mail | index | archive | help

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Attached is a patch for the aic(4) driver to do the following:

 - enable 10MHz (fast SCSI) operation on boards that support it.  (only
   aic6360 boards with fast SCSI enabled can do it)
 - bounds check sync periods and offsets passed in from the transport layer
 - tell the user which resource allocation failed (for the ISA probe) if we
   weren't able to allocate an IRQ, DRQ or I/O port.

Anyway, this patch should apply and run on both -stable and -current.

It works for me, but I'd appreciate feedback.

Ken
-- 
Kenneth Merry
ken@kdm.org

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="aic.sync_diffs.20010315"

==== //depot/FreeBSD-adaptec/src/sys/dev/aic/aic.c#2 - /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic.c ====
*** /tmp/tmp.77783.0	Thu Mar 15 18:25:00 2001
--- /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic.c	Thu Mar 15 18:03:03 2001
***************
*** 196,211 ****
  
  		if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) != 0) {
  			ti->goal.period = cts->sync_period;
! 			if (ti->goal.period != ti->current.period)
! 				ti->flags |= TINFO_SDTR_NEGO;
  		}
  
  		if ((cts->valid & CCB_TRANS_SYNC_OFFSET_VALID) != 0) {
  			ti->goal.offset = cts->sync_offset;
! 			if (ti->goal.offset != ti->current.offset)
! 				ti->flags |= TINFO_SDTR_NEGO;
  		}
  
  		splx(s);
  		ccb->ccb_h.status = CAM_REQ_CMP;
  		xpt_done(ccb);
--- 196,221 ----
  
  		if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) != 0) {
  			ti->goal.period = cts->sync_period;
! 
! 			if (ti->goal.period > aic->min_period) {
! 				ti->goal.period = 0;
! 				ti->goal.offset = 0;
! 			} else if (ti->goal.period < aic->max_period)
! 				ti->goal.period = aic->max_period;
  		}
  
  		if ((cts->valid & CCB_TRANS_SYNC_OFFSET_VALID) != 0) {
  			ti->goal.offset = cts->sync_offset;
! 			if (ti->goal.offset == 0)
! 				ti->goal.period = 0;
! 			else if (ti->goal.offset > AIC_SYNC_OFFSET)
! 				ti->goal.offset = AIC_SYNC_OFFSET;
  		}
  
+ 		if ((ti->goal.period != ti->current.period)
+ 		 || (ti->goal.offset != ti->current.offset))
+ 			ti->flags |= TINFO_SDTR_NEGO;
+ 
  		splx(s);
  		ccb->ccb_h.status = CAM_REQ_CMP;
  		xpt_done(ccb);
***************
*** 1427,1435 ****
  		aic->flags |= AIC_DISC_ENABLE;
  	if (PORTB_DMA(portb))
  		aic->flags |= AIC_DMA_ENABLE;
! 	if (aic_inb(aic, REV))
  		aic->flags |= AIC_DWIO_ENABLE;
  
  	free_scbs = NULL;
  	for (i = 255; i >= 0; i--) {
  		scb = &aic->scbs[i];
--- 1437,1461 ----
  		aic->flags |= AIC_DISC_ENABLE;
  	if (PORTB_DMA(portb))
  		aic->flags |= AIC_DMA_ENABLE;
! 
! 	/*
! 	 * We can do fast SCSI (10MHz clock rate) if bit 4 of portb
! 	 * is set and we've got a 6360.  The 6260 can only do standard
! 	 * 5MHz SCSI.
! 	 */
! 	if (aic_inb(aic, REV)) {
! 		if (PORTB_FSYNC(portb)) {
! 			aic->max_period = AIC_FAST_SYNC_PERIOD;
! 			aic->flags |= AIC_FAST_ENABLE;
! 		} else
! 			aic->max_period = AIC_SYNC_PERIOD;
! 
  		aic->flags |= AIC_DWIO_ENABLE;
+ 	} else
+ 		aic->max_period = AIC_SYNC_PERIOD;
  
+ 	aic->min_period = AIC_MIN_SYNC_PERIOD;
+ 	
  	free_scbs = NULL;
  	for (i = 255; i >= 0; i--) {
  		scb = &aic->scbs[i];
***************
*** 1445,1451 ****
  		ti->flags = TINFO_TAG_ENB;
  		if (aic->flags & AIC_DISC_ENABLE)
  			ti->flags |= TINFO_DISC_ENB;
! 		ti->user.period = AIC_SYNC_PERIOD;
  		ti->user.offset = AIC_SYNC_OFFSET;
  		ti->scsirate = 0;
  	}
--- 1471,1477 ----
  		ti->flags = TINFO_TAG_ENB;
  		if (aic->flags & AIC_DISC_ENABLE)
  			ti->flags |= TINFO_DISC_ENB;
! 		ti->user.period = aic->max_period;
  		ti->user.offset = AIC_SYNC_OFFSET;
  		ti->scsirate = 0;
  	}
***************
*** 1513,1518 ****
--- 1539,1546 ----
  		printf(", disconnection");
  	if (aic->flags & AIC_PARITY_ENABLE)
  		printf(", parity check");
+ 	if (aic->flags & AIC_FAST_ENABLE)
+ 		printf(", fast SCSI");
  	printf("\n");
  
  	aic_cam_rescan(aic);	/* have CAM rescan the bus */
==== //depot/FreeBSD-adaptec/src/sys/dev/aic/aic6360reg.h#1 - /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic6360reg.h ====
*** /tmp/tmp.77783.1	Thu Mar 15 18:25:00 2001
--- /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic6360reg.h	Mon Mar 12 18:31:29 2001
***************
*** 320,327 ****
--- 320,329 ----
  #define PORTA_PARITY(a)	((a) & 0x80)
  
  /* PORTB */
+ #define PORTB_EXTTRAN(b)((b) & 1)
  #define PORTB_DISC(b)	((b) & 4)
  #define PORTB_SYNC(b)	((b) & 8)
+ #define PORTB_FSYNC(b)	((b) & 0x10)
  #define PORTB_BOOT(b)	((b) & 0x40)
  #define PORTB_DMA(b)	((b) & 0x80)
  
==== //depot/FreeBSD-adaptec/src/sys/dev/aic/aic_isa.c#2 - /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic_isa.c ====
*** /tmp/tmp.77783.2	Thu Mar 15 18:25:00 2001
--- /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aic_isa.c	Thu Mar 15 18:20:27 2001
***************
*** 68,81 ****
  	rid = 0;
  	sc->sc_port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
  					0ul, ~0ul, AIC_ISA_PORTSIZE, RF_ACTIVE);
! 	if (!sc->sc_port)
  		return (ENOMEM);
  
  	if (isa_get_irq(dev) != -1) {
  		rid = 0;
  		sc->sc_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
  						0ul, ~0ul, 1, RF_ACTIVE);
  		if (!sc->sc_irq) {
  			aic_isa_release_resources(dev);
  			return (ENOMEM);
  		}
--- 68,84 ----
  	rid = 0;
  	sc->sc_port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
  					0ul, ~0ul, AIC_ISA_PORTSIZE, RF_ACTIVE);
! 	if (!sc->sc_port) {
! 		device_printf(dev, "I/O port allocation failed\n");
  		return (ENOMEM);
+ 	}
  
  	if (isa_get_irq(dev) != -1) {
  		rid = 0;
  		sc->sc_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
  						0ul, ~0ul, 1, RF_ACTIVE);
  		if (!sc->sc_irq) {
+ 			device_printf(dev, "IRQ allocation failed\n");
  			aic_isa_release_resources(dev);
  			return (ENOMEM);
  		}
***************
*** 86,91 ****
--- 89,95 ----
  		sc->sc_drq = bus_alloc_resource(dev, SYS_RES_DRQ, &rid,
  						0ul, ~0ul, 1, RF_ACTIVE);
  		if (!sc->sc_drq) {
+ 			device_printf(dev, "DRQ allocation failed\n");
  			aic_isa_release_resources(dev);
  			return (ENOMEM);
  		}
==== //depot/FreeBSD-adaptec/src/sys/dev/aic/aicvar.h#1 - /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aicvar.h ====
*** /tmp/tmp.77783.3	Thu Mar 15 18:25:00 2001
--- /a/ken/perforce/FreeBSD-adaptec/src/sys/dev/aic/aicvar.h	Thu Mar 15 17:52:12 2001
***************
*** 91,96 ****
--- 91,99 ----
  
  	struct aic_tinfo	tinfo[8];
  	struct aic_scb		scbs[256];
+ 
+ 	int			min_period;
+ 	int			max_period;
  };
  
  #define	AIC_DISC_ENABLE		0x01
***************
*** 100,105 ****
--- 103,109 ----
  #define	AIC_RESOURCE_SHORTAGE	0x10
  #define	AIC_DROP_MSGIN		0x20
  #define	AIC_BUSFREE_OK		0x40
+ #define	AIC_FAST_ENABLE		0x80
  
  #define	AIC_IDLE		0x00
  #define	AIC_SELECTING		0x01
***************
*** 114,119 ****
--- 118,125 ----
  #define	AIC_MSG_MSGBUF		0x80
  
  #define	AIC_SYNC_PERIOD		(200 / 4)
+ #define	AIC_FAST_SYNC_PERIOD	(100 / 4)
+ #define	AIC_MIN_SYNC_PERIOD	112
  #define	AIC_SYNC_OFFSET		8
  
  #define	aic_inb(aic, port) \

--XsQoSWH+UP9D9v3l--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010315183118.A9399>