Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Apr 2001 11:27:33 +0100 (BST)
From:      Doug Rabson <dfr@nlsystems.com>
To:        Mike Smith <msmith@freebsd.org>
Cc:        Michael Richards <michael@fastmail.ca>, <freebsd-alpha@FreeBSD.ORG>, <mjacob@feral.com>
Subject:   Re: Proposed Loader fix 
Message-ID:  <Pine.BSF.4.33.0104021125160.5113-100000@herring.nlsystems.com>
In-Reply-To: <200104020705.f3275IC08101@mass.dis.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2 Apr 2001, Mike Smith wrote:

> > My proposed solution is:
> > Modify the devsw struct. Here is the original:
> ...
> > This appears to carry info about the device. So I say that I should
> > be able to add a flag to it so it will not be opened multiple times.
>
> Don't do this.  Try adding some caching to libalpha so that it doesn't
> open the prom device more than once.  Since we only need one handle (SRM
> doesn't support more than one device), once we've got one, we can always
> reuse it.

How about something like this (untested) patch. I'm not entirely happy
with it since it will never call prom_close and I remember having problems
with ncr hardware not probing properly if we didn't close it in the
loader. Possibly an 'open count' or similar would suffice.

Index: srmdisk.c
===================================================================
RCS file: /home/ncvs/src/sys/boot/alpha/libalpha/srmdisk.c,v
retrieving revision 1.9
diff -u -r1.9 srmdisk.c
--- srmdisk.c	2000/03/15 01:53:34	1.9
+++ srmdisk.c	2001/04/02 10:22:17
@@ -96,6 +96,7 @@
     int		bd_unit;		/* SRM unit number */
     int		bd_namelen;
     int		bd_flags;
+    int		bd_fd;
 } bdinfo [MAXBDDEV];
 static int nbdinfo = 0;

@@ -113,6 +114,7 @@
     ret.bits = prom_getenv(PROM_E_BOOTED_DEV,
 			   bdinfo[0].bd_name, sizeof(bdinfo[0].bd_name));
     bdinfo[0].bd_namelen = ret.u.retval;
+    bdinfo[0].bd_fd = -1;
     nbdinfo++;

     return (0);
@@ -155,7 +157,7 @@
     struct disklabel		*lp;
     int				sector, slice, i;
     int				error;
-    int				unit;
+    int				unit, fd;
     prom_return_t		ret;

     va_start(args, f);
@@ -169,11 +171,16 @@
     }

     /* Call the prom to open the disk. */
-    ret.bits = prom_open(bdinfo[unit].bd_name, bdinfo[unit].bd_namelen);
-    if (ret.u.status == 2)
-	return (ENXIO);
-    if (ret.u.status == 3)
-	return (EIO);
+    if (bdinfo[unit].bd_fd < 0) {
+	ret.bits = prom_open(bdinfo[unit].bd_name, bdinfo[unit].bd_namelen);
+	if (ret.u.status == 2)
+	    return (ENXIO);
+	if (ret.u.status == 3)
+	    return (EIO);
+	bdinfo[unit].bd_fd = fd = ret.u.retval;
+    } else {
+	fd = bdinfo[unit].bd_fd;
+    }

     od = (struct open_disk *) malloc(sizeof(struct open_disk));
     if (!od) {
@@ -182,7 +189,7 @@
     }

     /* Look up SRM unit number, intialise open_disk structure */
-    od->od_fd = ret.u.retval;
+    od->od_fd = fd;
     od->od_unit = dev->d_kind.srmdisk.unit;
     od->od_flags = bdinfo[od->od_unit].bd_flags;
     od->od_boff = 0;
@@ -321,7 +328,9 @@
 {
     struct open_disk	*od = f->f_devdata;

+#if 0
     (void)prom_close(od->od_fd);
+#endif

     free(od);
     f->f_devdata = NULL;

-- 
Doug Rabson				Mail:  dfr@nlsystems.com
					Phone: +44 20 8348 6160



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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.33.0104021125160.5113-100000>