Re: How to get a device_t

2003-08-10 Thread Bernd Walter
On Wed, Aug 06, 2003 at 03:34:01PM -0400, Eric Jacobs wrote:
> On Wed, 6 Aug 2003 13:00:13 +0200
> Bernd Walter <[EMAIL PROTECTED]> wrote:
> 
> > 
> > Back to the original question:
> > How do I get the device_t from nexus?
> > Is there a get_nexus() function somewhere?
> 
> You can do it this way:
> 
> devclass_t nexusdc = devclass_find("nexus");
> device_t nexus = devclass_get_device(nexusdc, 0);
> 
> It is in fact in the code path as "parent" in nexus_pcib_identify,
> but not in the special PCI bridge identification function. If you
> call BUS_ADD_CHILD at that time, you don't need to probe or attach
> your device; it will be automatically probed and attached later and
> you can whatever logic you want in your probe and attach routines.

Thank you - I think that were they key parts missing.

-- 
B.Walter   BWCThttp://www.bwct.de
[EMAIL PROTECTED]  [EMAIL PROTECTED]

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: How to get a device_t

2003-08-10 Thread Bernd Walter
On Wed, Aug 06, 2003 at 12:45:43PM +0200, Poul-Henning Kamp wrote:
> In message <[EMAIL PROTECTED]>, Bernd Walter writes:
> >On Wed, Aug 06, 2003 at 12:18:28PM +0200, Poul-Henning Kamp wrote:
> >> In message <[EMAIL PROTECTED]>, Bernd Walter writes:
> >> >>From the logicaly standpoint the extensions had to be attached to
> >> >nexus, but nowhere is the current code path there is a handle for
> >> >nexus or any other device_t.
> >> 
> >> In fact what you may want to do is hang the entire MMCR off the nexus
> >> as a bus, and hang the various drivers off that bus.
> >
> >What needs to be in *_probe() to conditionalize on elan existence?
> 
> Well, my idea was to hang the mmcr bus on nexus when we find out it
> is an elan.

Back to the original question:
How do I get the device_t from nexus?
Is there a get_nexus() function somewhere?

> It may be that you are not allowed to attach a bus to the nexus when
> we find out it is an elan in the host/pci bridge probe, but then I guess
> you could just hang it off that instead.

There is also no other device_t in the code path available.
The last function knowing a device_t is nexus_pcib_identify.
We then have to pass this as an argument to nexus_pcib_is_host_bridge().

> Pressumably some newbus magic will then probe that bus.  If its not
> an elan, there is no mmcr bus and nothing will get probed.

Yes - that part is clear.

-- 
B.Walter   BWCThttp://www.bwct.de
[EMAIL PROTECTED]  [EMAIL PROTECTED]

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


hang in sio driver when interrupt occurs while in siocnputc()

2003-08-10 Thread Don Bowman

I find that if the kernel is in the middle of a printf,
is using a serial console, and a key is pressed, that i
may end up stuck in the siointr. I added a counter to
siointr1() so that if it receives more than 100 characters
in a single interrupt it panics. What I find happens is
that the chip (a winbond w83627HF in this case, 16550 compat)
claims to have more characters to read (the fifo is not empty),
but no interrupt is pending. The siointr1() loops forever on
this, reading the com_data register.

I created a simple kernel module that, on command from a sysctl,
outputs many characters in a callout. When this is going, I hit
enter a few times, and my panic occurs.

Debugger(c03093aa) at Debugger+0x35
panic(c0330173,ce098000,3f8,ff807e60,8) at panic+0xb8
siointr1(ce098000,c0382788,3f8,ff807e44,c02c1e40) at siointr1+0x146
siointr(ce098000) at siointr+0x17
Xfastintr4(ff807e60,3f8,1c200,45,0) at Xfastintr4+0x20
siocnputc(c0362c44,45) at siocnputc+0x4d
cnputc(45,1,63,0,ff807f40) at cnputc+0x4c
putchar(45,ff807f60) at putchar+0x9d
kvprintf(ce3bd75c,c01cb490,ff807f60,a,ff807f7c) at kvprintf+0x38e
printf(ce3bd75c,45,0,ce3bd670,ff807fa8) at printf+0x44
so_timeout(0,4000,,0,) at so_timeout+0x3b
softclock(0,ff800018,c02e0010,ce090010,) at softclock+0xfe
doreti_swi(0,ff808000,0,0,f323a000) at doreti_swi+0xf
idle_loop() at idle_loop+0x44

siocnputc() just takes spltty(), which doesn't prevent
the interrupt from happening.

this doesn't seem right, do you think that the siocn* routines
should take COM_LOCK()?

This is on RELENG_4. The system is SMP.

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: [patch] Re: getfsent(3) and spaces in fstab

2003-08-10 Thread mitrohin a.s.
On Mon, Aug 04, 2003 at 02:33:31AM +0200, Simon Barner wrote:
> Hi Terry,
> 
> > You need to add '\\' to the list of characters that can be escaped,
> > or you've just traded the inability to specify '\t' or ' ' for an
> > inability to speciy '\\'.
> 
> Oh yes, I have overlook this special case. I revised my patch in order
> to get this right.
> 
> Simon

helo.

imho - expensive algorithm... i want to see anything more simple... 
like "gtok()" instead "es_strsep() + remove_escapes()"?

#include 
#include 
#include 

char *gtok(char **s, char const *delim)
{
int quoted, escaped;
static char const esc_set[] = {  't',  'r',  'n',  'a', 0 };
static char const esc_rep[] = { '\t', '\r', '\n', '\a', 0 };
char *tok, *r, *w, *p;

if (!s || !*s || !*(tok = *s + strspn(*s, delim)) || *tok == '#')
return NULL;

for (quoted = escaped = 0, r = w = tok; *r; r++) {
if (!escaped) {
if (*r == '\\') {
escaped = 1;
continue;
}
if (*r == '\"') {
quoted ^= -1;
continue;
}
if (!quoted && strchr(delim, *r)) {
r++;
break;
}
} else {
escaped = 0;
if ((p = strchr(esc_set, *r)) != NULL) {
*w++ = esc_rep[p - esc_set];
continue;
}
}
*w++ = *r;
}
*w = 0;
*s = r;

return tok;
}

#if 0
main()
{
char *s, *t, buf[0x1000];

while (fgets(buf, sizeof buf, stdin))
for (s = buf; t = gtok(&s, " \t\r\n"); )
printf("\"%s\"\n", t);

return 0;
}
#endif

/swp

> --- fstab.c.orig  Fri Aug  1 17:18:00 2003
> +++ fstab.c   Mon Aug  4 01:46:55 2003
> @@ -49,6 +49,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -84,6 +85,140 @@
>   _fs_fstab.fs_spec = buf;
>  }
>  
> +/*
> + * Get next token from string *stringp, where tokens are possibly-empty
> + * strings separated by characters from delim.
> + *
> + * Writes NULs into the string at *stringp to end tokens.
> + * delim need not remain constant from call to call.
> + * On return, *stringp points past the last NUL written (if there might
> + * be further tokens), or is NULL (if there are definitely no more tokens).
> + *
> + * If *stringp is NULL, es_strsep returns NULL.
> + *
> + * In contrast to strsep(3), es_strsep will allow escaped delimiters
> + * within a token. These escaped characters as well as the special case
> + * '\\' will be converted appropriately ('\' -> ', '\\' -> '\'
> + *
> + */
> +char *
> +es_strsep(char **stringp, const char *delim)
> +{
> + boolescaped=false;
> + char*s, *t, *u;
> + int i;
> +
> +
> + if (*stringp == '\0')   /* empty string */
> + return NULL;
> + s = *stringp;
> + s += strspn (s, delim); /* skip delimiters */
> +
> + if (*s == '\0') /* string consists only of delimiters */
> + return NULL;
> + 
> + /*
> +  * skip a string consisting of non-delimiters,
> +  * escapted delimiters or '\\'
> + */
> + for (t = s; *t != '\0'; ++t) {
> + if (*t == '\\') {
> + if (escaped) {  /* convert \\ to \ */
> + --t;
> + u = t;
> + escaped = false;
> + while (u[0] != '\0') {
> + u[0] = u[1];
> + ++u;
> + }
> + } else  /* start \-Sequence */
> + escaped = true;
> + continue;
> + }
> + 
> + /* search for delimiter */
> + for (i=0; delim[i] != '\0'; ++i) {
> + if (*t == delim[i])
> + break;
> + }
> + 
> + /* un-escaped delimiter found => end of token */
> + if (!escaped && delim[i] != '\0')
> + break;
> + 
> + /* escaped delimiter found => remove / */
> + if (escaped) {
> + --t;
> + u = t;
> +escaped = false;
> + while (u[0] != '\0') {
> + u[0] = u[1];
> + ++u;
> + }
> + }
> + }
> +
> + if (*t != '\0') {
> + *t = '\0';  /* end current token */
> + *stringp = t+1; /* *t != '\0' => *(t+1) is valid */
> + } else
> + *stringp = 0;

Re: COW and mprotect on non-shared memory

2003-08-10 Thread David Schultz
On Thu, Aug 07, 2003, Ed L Cashin wrote:
> "Luoqi Chen" <[EMAIL PROTECTED]> writes:
> 
> [Ed writes]
> >> That means that if I do this:
> >> 
> >> for (i = 0; i < n; ++i) {
> >>   assert(!mprotect(p, pgsiz, PROT_NONE));
> >>   assert(!mprotect(p, pgsiz, PROT_READ|PROT_WRITE|PROT_EXEC));
> >>   p[i] = i & 0xff;
> >> }
> >> 
> >> ... I get n minor page faults!  Pretty amazing, but I guess they
> >> figured nobody does that.  
> 
> ...
> > The first mprotect() removes the physical mapping from the page
> > table, the second mprotect() doesn't do anything because the mapping
> > isn't there. So when the page is accessed, a fault is needed to
> > insert the mapping back to the page table.
> 
> OK, thanks.  I can see that in sys/i386/i386/pmap.c.  It leaves me
> wondering what MAP_ENTRY_COW is for, though.

It's an optimization that makes the map entries and corresponding
vm_objects themselves copy-on-write.  Specifically, when a process
forks, FreeBSD does not allocate new shadow objects immediately.
This is deferred until the object needs to be modified, which is
usually never if the process subsequently calls exec.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: BSD make question

2003-08-10 Thread Ruslan Ermilov
On Thu, Aug 07, 2003 at 02:50:51PM -0400, Andrew Gallatin wrote:
> 
> Ruslan Ermilov writes:
>  > On Thu, Aug 07, 2003 at 02:42:30PM -0400, Andrew Gallatin wrote:
>  > > 
>  > > Using BSD make, how can I apply different rules based on different
>  > > directories while using only a single makefile?
>  > > 
>  > There's a .CURDIR variable that can be used to conditionalize
>  > parts of a makefile.
>  > 
>  > > Ie, the appended Makefile results in the following compilations:
>  > > 
>  > > gcc -DLIB -c lib/foo.c -o lib/foo.o
>  > > gcc -DLIB -c lib/bar.c -o lib/bar.o
>  > > gcc -DMCP -c mcp/baz.c -o mcp/baz.o
>  > > 
>  > > Is it possible to do something similar with BSD make?
>  > > 
>  > It just works "as is" with bmake.  What's your problem, Drew?  ;-)
>  > 
>  > $ make -n
>  > cc -O -pipe -march=pentiumpro -c lib/foo.c
> 
> ;)  But its missing the -DLIB or -DMCP.
> 
> Thanks for the .CURDIR hint.
> 
Ah, didn't notice it.  Try this:

.for f in $(LIB)
$(f:.c=.o): $(f)
gcc -DLIB -c $< -o $@
.endfor

.for f in $(MCP)
$(f:.c=.o): $(f)
gcc -DMCP -c $< -o $@
.endfor


Cheers,
-- 
Ruslan Ermilov  Sysadmin and DBA,
[EMAIL PROTECTED]   Sunbay Software Ltd,
[EMAIL PROTECTED]   FreeBSD committer


pgp0.pgp
Description: PGP signature


Re: panic during nfs operations in 4.8S on Dell 2650

2003-08-10 Thread Kip Macy
Can you get a backtrace? Not knowing anything at this point,
bumping up the number of mbuf clusters *might* help.


-Kip


FYI: I'm not representing NetApp in any official capacity on this,
I just happen to have a vested interest in both OnTap and FreeBSD. 
 



On Thu, 7 Aug 2003, Mark Powell wrote:

> On Thu, 7 Aug 2003, Mark Powell wrote:
> >   We've recently got a couple of Dell Poweredge 2650's with 2x2.8GHz
> > Xeons, 4GB RAM, PERC 3/Di (aac) RAID controller. They are mounting a 700GB
> > fs over NFS from a NetAPP. They are connected to a Cisco 3550-12T gigabit
> > over copper switch. I tried them first on the intel em cards and they
> > panicked and also the internal bge adapters with the same result.
> >   Thought everything was fine until I was rsyncing the POP3 mail stores
> > from the old machines onto these. Rsync runs for about an hour or so and
> > get's large. In the 300M-600M region the system will always panic. This
> > happens on both systems, so doesn't seem a hardware fault.
> 
> This is a 4.8S kernel and world rebuilt as of today.
> 
> -- 
> Mark Powell - UNIX System Administrator - The University of Salford
> Information Services Division, Clifford Whitworth Building,
> Salford University, Manchester, M5 4WT, UK.
> Tel: +44 161 295 5936  Fax: +44 161 295 5888  www.pgp.com for PGP key
> ___
> [EMAIL PROTECTED] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
> 


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"