Re: newbus and isa auto irq

1999-04-20 Thread Doug Rabson
On Mon, 19 Apr 1999, Luoqi Chen wrote:

> > This is not happening for the maddr stuff.   
> > I suspect this would do better:
> > 
> > if (portsize > 0)
> > isa_set_portsize(dev, portsize);
> > if (dvp->id_iobase >= 0)
> > isa_set_port(dev, dvp->id_iobase);
> > if (dvp->id_irq != 0)
> > isa_set_irq(dev, ffs(dvp->id_irq) - 1);
> > if (dvp->id_drq != -1)
> > isa_set_drq(dev, dvp->id_drq);
> > if (dvp->id_maddr != 0)
> > isa_set_maddr(dev,
> >   (int) dvp->id_maddr - 
> > KERNBASE);
> > if (dvp->id_msize != 0)
> > isa_set_msize(dev, dvp->id_msize);
> > I'm not sure about the "nothing" value for id_drq though, it might need to
> > be 0 - but that's a valid dma channel.
> > 
> > IMHO, isa_release_resources() clearing of the default values for the probe
> > hints is a timebomb...  I thought about adding a seperate store for the
> > "hint" values rather than using the id_foo[0] entries, and leaving the
> > tracked resource entries for alloc/free without risking the hints.
> > 
> > Cheers,
> > -Peter
> > 
> Off the topic, I think we should replace (dvp->id_maddr - KERNBASE) with
> kvtop(dvp->id_maddr), too much assumption about vm layout...

I agree. I think your fix for the irq problem is the correct one too.

--
Doug Rabson Mail:  d...@nlsystems.com
Nonlinear Systems Ltd.  Phone: +44 181 442 9037




To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



Re: newbus and isa auto irq

1999-04-19 Thread Luoqi Chen
> This is not happening for the maddr stuff.   
> I suspect this would do better:
> 
> if (portsize > 0)
> isa_set_portsize(dev, portsize);
> if (dvp->id_iobase >= 0)
> isa_set_port(dev, dvp->id_iobase);
> if (dvp->id_irq != 0)
> isa_set_irq(dev, ffs(dvp->id_irq) - 1);
> if (dvp->id_drq != -1)
> isa_set_drq(dev, dvp->id_drq);
> if (dvp->id_maddr != 0)
> isa_set_maddr(dev,
>   (int) dvp->id_maddr - KERNBASE);
> if (dvp->id_msize != 0)
> isa_set_msize(dev, dvp->id_msize);
> I'm not sure about the "nothing" value for id_drq though, it might need to
> be 0 - but that's a valid dma channel.
> 
> IMHO, isa_release_resources() clearing of the default values for the probe
> hints is a timebomb...  I thought about adding a seperate store for the
> "hint" values rather than using the id_foo[0] entries, and leaving the
> tracked resource entries for alloc/free without risking the hints.
> 
> Cheers,
> -Peter
> 
Off the topic, I think we should replace (dvp->id_maddr - KERNBASE) with
kvtop(dvp->id_maddr), too much assumption about vm layout...

-lq


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



Re: newbus and isa auto irq

1999-04-19 Thread Peter Wemm
John Hay wrote:
[..]
> Apr 19 19:22:28 orca /kernel.doug: ppc0: interrupting at irq 7
> Apr 19 19:22:28 orca /kernel.doug: ed0 at port 0x280-0x29f on isa0
> Apr 19 19:22:28 orca /kernel.doug: ed0: address 00:00:c0:1d:43:db, type SMC82
16/
> SMC8216C (16 bit) 
> Apr 19 19:22:28 orca /kernel.doug: Intel Pentium detected, installing workaro
und
>  for F00F bug
> 
> 
> > -   if (dvp->id_irq != (1 << isa_get_irq(dev)))
> > +   if (dvp->id_irq != (1 << isa_get_irq(dev))) {
> > +printf("isa_compat_probe: old irq=%d, new mask=%x, new irq=%d\n",
> > +   irq_get_irq(dev), dvp->id_irq, ffs(dvp->id_irq) - 1);
> > isa_set_irq(dev, ffs(dvp->id_irq) - 1);
> > +   }
> 
> I assume the irq_get_irq() should be isa_get_irq().
> 
> I have tried the patch that Luoqi posted and that works for me. Although
> even with that the the userconfig by booting with -c don't work. It just
> plain ignores what you do there.

An additional datapoint...  We have:

dvp->id_maddr = (void *)isa_get_maddr(dev);
[..]
void *maddr;
isa_compat_alloc_resources(dev, &res);
if (res.memory)  
maddr = rman_get_virtual(res.memory);
else
maddr = 0;
dvp->id_maddr = maddr;
portsize = dvp->id_driver->probe(dvp);
isa_compat_release_resources(dev, &res);
if (portsize != 0) {
if (portsize > 0)
isa_set_portsize(dev, portsize);
if (dvp->id_iobase != isa_get_port(dev))
isa_set_port(dev, dvp->id_iobase);
if (dvp->id_irq != (1 << isa_get_irq(dev)))
isa_set_irq(dev, ffs(dvp->id_irq) - 1);
if (dvp->id_drq != isa_get_drq(dev))
isa_set_drq(dev, dvp->id_drq);
if (dvp->id_maddr != maddr)
isa_set_maddr(dev,
  (int) dvp->id_maddr - KERNBASE);
  ^^
if (dvp->id_msize != isa_get_msize(dev))
isa_set_msize(dev, dvp->id_msize);

There is the problem..  isa_compat_release_resources() is clearing the
hints.  The only reason it works for the other devices is things like:
   if (dvp->id_iobase != isa_get_port(dev))
isa_set_port(dev, dvp->id_iobase);
.. ie: if (id_iobase != )
  reset_hint(id_iobase);
.. etc.
This is not happening for the maddr stuff.   
I suspect this would do better:

if (portsize > 0)
isa_set_portsize(dev, portsize);
if (dvp->id_iobase >= 0)
isa_set_port(dev, dvp->id_iobase);
if (dvp->id_irq != 0)
isa_set_irq(dev, ffs(dvp->id_irq) - 1);
if (dvp->id_drq != -1)
isa_set_drq(dev, dvp->id_drq);
if (dvp->id_maddr != 0)
isa_set_maddr(dev,
  (int) dvp->id_maddr - KERNBASE);
if (dvp->id_msize != 0)
isa_set_msize(dev, dvp->id_msize);
I'm not sure about the "nothing" value for id_drq though, it might need to
be 0 - but that's a valid dma channel.

IMHO, isa_release_resources() clearing of the default values for the probe
hints is a timebomb...  I thought about adding a seperate store for the
"hint" values rather than using the id_foo[0] entries, and leaving the
tracked resource entries for alloc/free without risking the hints.

Cheers,
-Peter



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



Re: newbus and isa auto irq

1999-04-19 Thread John Hay
> > 
> > I ave found one more thing that seems to be broken. I have used the 
> > irq "autodetect" feature of the ed(4) for a long time, but it seems
> > that the newbus compatability shim is not doing the right thing
> > with it. My kernel config file have a line like this:
> > 
> > device ed0 at isa? port 0x280 net irq ? iomem 0xd8000
> > 
> > The card gets probed but you just get device timeouts and there is no
> > mention of an irq for that device in the probe output. Booting with
> > -c and specifying the irq there also didn't work. Rebuilding the kernel
> > with a config file which specified the irq did work though.
> 
> Could you run a test kernel for me with this patch and tell me what it
> prints.
> 

It doesn't print anything for the ed0 device. It does print 2 lines though,
one for wdc0 and one for the printer port:

---
Apr 19 19:22:27 orca /kernel.doug: fdc0: FIFO enabled, 8 bytes threshold
Apr 19 19:22:27 orca /kernel.doug: fd0: <1440-KB 3.5" drive> at fdc0 drive 0
Apr 19 19:22:27 orca /kernel.doug: isa_compat_probe: old irq=-1, new mask=4000, 
new irq=14
Apr 19 19:22:27 orca /kernel.doug: wdc0 at port 0x1f0-0x1f7 irq 14 on isa0
Apr 19 19:22:27 orca /kernel.doug: wdc0: unit 0 (wd0): 
Apr 19 19:22:27 orca /kernel.doug: wd0: 610MB (1249920 sectors), 1240 cyls, 16 h
eads, 63 S/T, 512 B/S
Apr 19 19:22:27 orca /kernel.doug: wdc0: interrupting at irq 14
...
Apr 19 19:22:28 orca /kernel.doug: isa_compat_probe: old irq=-1, new mask=80, 
new irq=7
Apr 19 19:22:28 orca /kernel.doug: ppc0 at port 0x378 irq 7 on isa0
Apr 19 19:22:28 orca /kernel.doug: ppc0: SMC FDC37C665GT chipset (PS2/NIBBLE) 
in COMPATIBLE mode
Apr 19 19:22:28 orca /kernel.doug: ppb0: IEEE1284 device found 
Apr 19 19:22:28 orca /kernel.doug: Probing for PnP devices on ppbus0:
Apr 19 19:22:28 orca /kernel.doug: lpt0:  on ppbus 0
Apr 19 19:22:28 orca /kernel.doug: lpt0: Interrupt-driven port
Apr 19 19:22:28 orca /kernel.doug: ppc0: interrupting at irq 7
Apr 19 19:22:28 orca /kernel.doug: ed0 at port 0x280-0x29f on isa0
Apr 19 19:22:28 orca /kernel.doug: ed0: address 00:00:c0:1d:43:db, type SMC8216/
SMC8216C (16 bit) 
Apr 19 19:22:28 orca /kernel.doug: Intel Pentium detected, installing workaround
 for F00F bug


> - if (dvp->id_irq != (1 << isa_get_irq(dev)))
> + if (dvp->id_irq != (1 << isa_get_irq(dev))) {
> +printf("isa_compat_probe: old irq=%d, new mask=%x, new irq=%d\n",
> +   irq_get_irq(dev), dvp->id_irq, ffs(dvp->id_irq) - 1);
>   isa_set_irq(dev, ffs(dvp->id_irq) - 1);
> + }

I assume the irq_get_irq() should be isa_get_irq().

I have tried the patch that Luoqi posted and that works for me. Although
even with that the the userconfig by booting with -c don't work. It just
plain ignores what you do there.

John
-- 
John Hay -- john@mikom.csir.co.za


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



Re: newbus and isa auto irq

1999-04-19 Thread Luoqi Chen
> Hi,
> 
> I ave found one more thing that seems to be broken. I have used the 
> irq "autodetect" feature of the ed(4) for a long time, but it seems
> that the newbus compatability shim is not doing the right thing
> with it. My kernel config file have a line like this:
> 
> device ed0 at isa? port 0x280 net irq ? iomem 0xd8000
> 
> The card gets probed but you just get device timeouts and there is no
> mention of an irq for that device in the probe output. Booting with
> -c and specifying the irq there also didn't work. Rebuilding the kernel
> with a config file which specified the irq did work though.
> 
> John
> -- 
> John Hay -- john@mikom.csir.co.za
> 
I had the same problem. Here's a fix:

Index: isa_compat.c
===
RCS file: /home/ncvs/src/sys/i386/isa/isa_compat.c,v
retrieving revision 1.3
diff -u -r1.3 isa_compat.c
--- isa_compat.c1999/04/19 08:42:39 1.3
+++ isa_compat.c1999/04/19 10:07:41
@@ -131,12 +131,14 @@
}
 }
 
+#defineirqmask(x)  ((x) < 0 ? 0 : (1 << (x)))
+
 static int
 isa_compat_probe(device_t dev)
 {
struct isa_device *dvp = device_get_softc(dev);
struct isa_compat_resources res;
-   
+
bzero(&res, sizeof(res));
/*
 * Fill in the isa_device fields.
@@ -144,7 +146,7 @@
dvp->id_id = isa_compat_nextid();
dvp->id_driver = device_get_driver(dev)->priv;
dvp->id_iobase = isa_get_port(dev);
-   dvp->id_irq = (1 << isa_get_irq(dev));
+   dvp->id_irq = irqmask(isa_get_irq(dev));
dvp->id_drq = isa_get_drq(dev);
dvp->id_maddr = (void *)isa_get_maddr(dev);
dvp->id_msize = isa_get_msize(dev);
@@ -171,7 +173,7 @@
isa_set_portsize(dev, portsize);
if (dvp->id_iobase != isa_get_port(dev))
isa_set_port(dev, dvp->id_iobase);
-   if (dvp->id_irq != (1 << isa_get_irq(dev)))
+   if (dvp->id_irq != irqmask(isa_get_irq(dev)))
isa_set_irq(dev, ffs(dvp->id_irq) - 1);
if (dvp->id_drq != isa_get_drq(dev))
isa_set_drq(dev, dvp->id_drq);


-lq


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



Re: newbus and isa auto irq

1999-04-19 Thread Doug Rabson
On Sun, 18 Apr 1999, John Hay wrote:

> Hi,
> 
> I ave found one more thing that seems to be broken. I have used the 
> irq "autodetect" feature of the ed(4) for a long time, but it seems
> that the newbus compatability shim is not doing the right thing
> with it. My kernel config file have a line like this:
> 
> device ed0 at isa? port 0x280 net irq ? iomem 0xd8000
> 
> The card gets probed but you just get device timeouts and there is no
> mention of an irq for that device in the probe output. Booting with
> -c and specifying the irq there also didn't work. Rebuilding the kernel
> with a config file which specified the irq did work though.

Could you run a test kernel for me with this patch and tell me what it
prints.

Index: isa_compat.c
===
RCS file: /home/ncvs/src/sys/i386/isa/isa_compat.c,v
retrieving revision 1.3
diff -u -r1.3 isa_compat.c
--- isa_compat.c1999/04/19 08:42:39 1.3
+++ isa_compat.c1999/04/19 08:52:29
@@ -171,8 +171,11 @@
isa_set_portsize(dev, portsize);
if (dvp->id_iobase != isa_get_port(dev))
isa_set_port(dev, dvp->id_iobase);
-   if (dvp->id_irq != (1 << isa_get_irq(dev)))
+   if (dvp->id_irq != (1 << isa_get_irq(dev))) {
+printf("isa_compat_probe: old irq=%d, new mask=%x, new irq=%d\n",
+   irq_get_irq(dev), dvp->id_irq, ffs(dvp->id_irq) - 1);
isa_set_irq(dev, ffs(dvp->id_irq) - 1);
+   }
if (dvp->id_drq != isa_get_drq(dev))
isa_set_drq(dev, dvp->id_drq);
if (dvp->id_maddr != maddr)

--
Doug Rabson Mail:  d...@nlsystems.com
Nonlinear Systems Ltd.  Phone: +44 181 442 9037




To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message



newbus and isa auto irq

1999-04-18 Thread John Hay
Hi,

I ave found one more thing that seems to be broken. I have used the 
irq "autodetect" feature of the ed(4) for a long time, but it seems
that the newbus compatability shim is not doing the right thing
with it. My kernel config file have a line like this:

device ed0 at isa? port 0x280 net irq ? iomem 0xd8000

The card gets probed but you just get device timeouts and there is no
mention of an irq for that device in the probe output. Booting with
-c and specifying the irq there also didn't work. Rebuilding the kernel
with a config file which specified the irq did work though.

John
-- 
John Hay -- john@mikom.csir.co.za


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message