Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Oct 2000 11:20:15 -0700 (PDT)
From:      Soren Schmidt <sos@freebsd.dk>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/21773: panic w/nexus + ata (ivar problem)
Message-ID:  <200010051820.LAA89244@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/21773; it has been noted by GNATS.

From: Soren Schmidt <sos@freebsd.dk>
To: jlemon@flugsvamp.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/21773: panic w/nexus + ata (ivar problem)
Date: Thu, 5 Oct 2000 20:19:01 +0200 (CEST)

 It seems Jonathan Lemon wrote:
 > 
 > 	After the nexus/ivar change around Sep 28, my kernel no longer
 > 	boots.  This seems to be a disagreement over how ivars are used
 > 	in the kernel.  Within nexus_alloc_resource(), we have the 
 > 	following:
 > 
 > #define DEVTONX(dev)       ((struct nexus_device *)device_get_ivars(dev))
 > 		struct nexus_device *ndev = DEVTONX(child);
 > 
 > 	where ``child'' happens to be ata1.  However, within ata/ata-all.c,
 > 	There is the following statement:
 > 
 > 		device_set_ivars(child, (void *)(uintptr_t) unit);
 > 
 > 	So when nexus_alloc_resource() is called, it ends up treating the
 > 	unit as a pointer.  I'm not sure what the new world order mandates
 > 	here; what is the legal usage of ivar?
 
 Not sure either, but the below patch makes ata use the ivar as a pointer,
 could you try that out for me please, I'm still a PRE_SMPNG as i need
 working machines....
 
 Index: ata-all.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/ata/ata-all.c,v
 retrieving revision 1.74
 diff -u -r1.74 ata-all.c
 --- ata-all.c	2000/10/05 08:28:06	1.74
 +++ ata-all.c	2000/10/05 16:02:49
 @@ -358,6 +359,7 @@
  ata_pci_add_child(device_t dev, int unit)
  {
      device_t child;
 +    int *ivar;
  
      /* check if this is located at one of the std addresses */
      if (ATA_MASTERDEV(dev)) {
 @@ -368,7 +370,10 @@
  	if (!(child = device_add_child(dev, "ata", 2)))
  	    return ENOMEM;
      }
 -    device_set_ivars(child, (void *)(uintptr_t) unit);
 +    if (!(ivar = (int *)malloc(sizeof(int *), M_ATA, M_NOWAIT)))
 +	return ENOMEM;
 +    *ivar = unit;
 +    device_set_ivars(child, ivar);
      return 0;
  }
  
 @@ -492,7 +497,7 @@
  ata_pci_print_child(device_t dev, device_t child)
  {
      struct ata_softc *scp = device_get_softc(child);
 -    int unit = (uintptr_t) device_get_ivars(child);
 +    int unit = *((int *)device_get_ivars(child));
      int retval = 0;
  
      retval += bus_print_child_header(dev, child);
 @@ -511,7 +516,7 @@
  		       u_long start, u_long end, u_long count, u_int flags)
  {
      struct ata_pci_softc *sc = device_get_softc(dev);
 -    int unit = (intptr_t)device_get_ivars(child);
 +    int unit = *((int *)device_get_ivars(child));
      int myrid;
  
      if (type == SYS_RES_IOPORT) {
 @@ -601,7 +606,7 @@
  			 struct resource *r)
  {
      struct ata_pci_softc *sc = device_get_softc(dev);
 -    int unit = (uintptr_t) device_get_ivars(child);
 +    int unit = *((int *)device_get_ivars(child));
      int myrid = 0;
  
      if (type == SYS_RES_IOPORT) {
 @@ -725,8 +730,8 @@
      struct ata_softc *scp = device_get_softc(dev);
  
      /* kids of pci ata chipsets has their physical unit number in ivars */
 -    scp->unit = (uintptr_t) device_get_ivars(dev);
 +    scp->unit = *((int *)device_get_ivars(dev));
      scp->chiptype = pci_get_devid(device_get_parent(dev));
      return ata_probe(dev);
  }
  
 
 -Søren
 


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




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