Subject: port-sun3/1929: it's not easy to change si_coptions per kernel
To: None <gnats-bugs@gnats.netbsd.org>
From: Jason R. Thorpe <thorpej@SJ.Xenotropic.COM>
List: netbsd-bugs
Date: 01/11/1996 08:53:49
>Number:         1929
>Category:       port-sun3
>Synopsis:       it's not easy to change si_coptions per kernel
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 11 12:05:00 1996
>Last-Modified:
>Originator:     
>Organization:
Just me and my collection of obsolete computer gear(s).
>Release:        NetBSD 1.1A, Jan 10, 1996
>Environment:
	
System: NetBSD ovation 1.1 NetBSD 1.1 (OVATION) #44: Sun Dec 10 17:55:35 PST 1995 thorpej@ovation:/tmp_mnt/basalt/work/netbsd/src/sys/arch/sun3/compile/OVATION sun3


>Description:
	The "si_options" flags are hard-coded in the driver.  This makes
	it difficult to change the settings from machine to machine.
>How-To-Repeat:
	Own 2 sun3s.  Try to enable reselects in the driver on one and
	not on the other.  You have to edit code.
>Fix:
	Here's a patch that pulls in the "si_options" handling code
	that I added when I ported the ncr_si driver to NetBSD/sparc.
	You can change the options using the `flags' directive in your
	kernel configuration file.  It also prints which options
	are enabled at attach time.

Index: ncr_si.c
===================================================================
RCS file: /usr/og/devsrc/netbsd/src/sys/arch/sun3/dev/ncr_si.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 ncr_si.c
*** ncr_si.c	1996/01/02 04:53:59	1.1.1.2
--- ncr_si.c	1996/01/11 16:51:42
***************
*** 150,162 ****
  	int		sc_adapter_iv_am; /* int. vec + address modifier */
  	struct si_dma_handle *sc_dma;
  	int 	sc_xlen;		/* length of current DMA segment. */
  };
  
! /* Options.  Interesting values are: 1,3,7 */
! int si_options = 0;
  #define SI_ENABLE_DMA	1	/* Use DMA (maybe polled) */
  #define SI_DMA_INTR 	2	/* DMA completion interrupts */
  #define	SI_DO_RESELECT	4	/* Allow disconnect/reselect */
  
  /* How long to wait for DMA before declaring an error. */
  int si_dma_intr_timo = 500;	/* ticks (sec. X 100) */
--- 150,172 ----
  	int		sc_adapter_iv_am; /* int. vec + address modifier */
  	struct si_dma_handle *sc_dma;
  	int 	sc_xlen;		/* length of current DMA segment. */
+ 	int	sc_options;		/* options for this instance */
  };
  
! /*
!  * Options.  By default, no options are enabled.  You may enable additional
!  * features using the `flags' directive in your kernel's configuration file.
!  * 
!  * Alternatively, you can patch your kernel with DDB or some other
!  * mechanism.  The sc_options member of the softc is OR'd with
!  * the value in si_options.
!  */
  #define SI_ENABLE_DMA	1	/* Use DMA (maybe polled) */
  #define SI_DMA_INTR 	2	/* DMA completion interrupts */
  #define	SI_DO_RESELECT	4	/* Allow disconnect/reselect */
+ #define SI_OPTIONS_MASK	(SI_ENABLE_DMA|SI_DMA_INTR|SI_DO_RESELECT)
+ #define SI_OPTIONS_BITS	"\10\3RESELECT\2DMA_INTR\1DMA"
+ int si_options = 0;
  
  /* How long to wait for DMA before declaring an error. */
  int si_dma_intr_timo = 500;	/* ticks (sec. X 100) */
***************
*** 281,286 ****
--- 291,300 ----
  	struct confargs *ca = args;
  	int i;
  
+ 	/* Pull in options flags. */
+ 	sc->sc_options =
+ 	  ((ncr_sc->sc_dev.dv_cfdata->cf_flags | si_options) & SI_OPTIONS_MASK);
+ 
  	switch (ca->ca_bustype) {
  
  	case BUS_OBIO:
***************
*** 298,303 ****
--- 312,320 ----
  		return;
  	}
  	printf("\n");
+ 	if (sc->sc_options)
+ 		printf("%s: options=%b\n", ncr_sc->sc_dev.dv_xname,
+ 		    sc->sc_options, SI_OPTIONS_BITS);
  
  	/*
  	 * Fill in the prototype scsi_link.
***************
*** 334,340 ****
  		ncr_sc->sc_dma_start = si_vme_dma_start;
  		ncr_sc->sc_dma_eop   = si_vme_dma_stop;
  		ncr_sc->sc_dma_stop  = si_vme_dma_stop;
! 		if (si_options & SI_DO_RESELECT) {
  			/*
  			 * Need to enable interrupts (and DMA!)
  			 * on this H/W for reselect to work.
--- 351,357 ----
  		ncr_sc->sc_dma_start = si_vme_dma_start;
  		ncr_sc->sc_dma_eop   = si_vme_dma_stop;
  		ncr_sc->sc_dma_stop  = si_vme_dma_stop;
! 		if (sc->sc_options & SI_DO_RESELECT) {
  			/*
  			 * Need to enable interrupts (and DMA!)
  			 * on this H/W for reselect to work.
***************
*** 349,357 ****
  		ncr_sc->sc_dma_stop  = si_obio_dma_stop;
  	}
  	ncr_sc->sc_flags = 0;
! 	if (si_options & SI_DO_RESELECT)
  		ncr_sc->sc_flags |= NCR5380_PERMIT_RESELECT;
! 	if ((si_options & SI_DMA_INTR) == 0)
  		ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;
  	ncr_sc->sc_min_dma_len = MIN_DMA_LEN;
  
--- 366,374 ----
  		ncr_sc->sc_dma_stop  = si_obio_dma_stop;
  	}
  	ncr_sc->sc_flags = 0;
! 	if (sc->sc_options & SI_DO_RESELECT)
  		ncr_sc->sc_flags |= NCR5380_PERMIT_RESELECT;
! 	if ((sc->sc_options & SI_DMA_INTR) == 0)
  		ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;
  	ncr_sc->sc_min_dma_len = MIN_DMA_LEN;
  
***************
*** 525,531 ****
  
  #if 1	/* XXX - Temporary */
  	/* XXX - In case we think DMA is completely broken... */
! 	if ((si_options & SI_ENABLE_DMA) == 0)
  		return;
  #endif
  
--- 542,548 ----
  
  #if 1	/* XXX - Temporary */
  	/* XXX - In case we think DMA is completely broken... */
! 	if ((sc->sc_options & SI_ENABLE_DMA) == 0)
  		return;
  #endif
  
>Audit-Trail:
>Unformatted: