Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
@ 2001-10-04 15:12 Mads Peter Bach
  2001-10-04 15:28 ` Jay Estabrook
  2001-10-04 17:09 ` Michal Jaegermann
  0 siblings, 2 replies; 13+ messages in thread
From: Mads Peter Bach @ 2001-10-04 15:12 UTC (permalink / raw)
  To: RedHat Alphalinux List

Hello,

I've been trying to a net install of RedHat 7.1 on a machine with a Digital
AlphaPC 164 (not SX/LX) motherboard, but failed miserably, due to machine
hangs.

Last week, I finally installed from a CDROM instead, which went smoothly. It
turns out, that the reason the net install didn't work, was that any heavy
100baseTX ethernet activity, using normal size packets hung the machine.
I've tried multiple ethernet interfaces, both RealTek RTL-8139 based, and
DC21040 based, in 32 and 64 bit slots. When I finally dug up an old 10baseTX
ISA card, the problems went away.

The strange thing is, that the cards work fine, if I use a 2.2 kernel
(tested with 2.2.19). Others have posted that they needed to enable
CONFIG_PCI_QUIRKS, but that doesn't seem to be necessary for me (I've
haven't tested with heavy trafic more than 15 minutes, though).

I've tested the default 2.4 kernels, that come with RedHat 7.1, Linus'
Kernel 2.4.0 and 2.4.10, and all of them hang. I can still press the halt
button, and return to the SRM console, if that could be of any help in
discovering the cause of this.

I've seen other people, with what seems to the same problem post to the
list, without seeing any solutions posted, but hope that this detailed
description of the problem will spark an idea in someone :-)

Best regards

Mads Bach




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 15:12 Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164 Mads Peter Bach
@ 2001-10-04 15:28 ` Jay Estabrook
  2001-10-04 19:21   ` Mads Peter Bach
  2001-10-04 17:09 ` Michal Jaegermann
  1 sibling, 1 reply; 13+ messages in thread
From: Jay Estabrook @ 2001-10-04 15:28 UTC (permalink / raw)
  To: axp-list

[-- Attachment #1: Type: text/plain, Size: 1754 bytes --]

On Thu, Oct 04, 2001 at 05:12:49PM +0200, Mads Peter Bach wrote:
> 
> I've been trying to a net install of RedHat 7.1 on a machine with a
> Digital AlphaPC 164 (not SX/LX) motherboard, but failed miserably,
> due to machine hangs.

I'll bet you're running from SRM console, right?

> Last week, I finally installed from a CDROM instead, which went
> smoothly. It turns out, that the reason the net install didn't work,
> was that any heavy 100baseTX ethernet activity, using normal size
> packets hung the machine.  I've tried multiple ethernet interfaces,
> both RealTek RTL-8139 based, and DC21040 based, in 32 and 64 bit
> slots. When I finally dug up an old 10baseTX ISA card, the problems
> went away.

Yes, network traffic (even "ping" did it for me) seems to exacerbate
the problem.

> The strange thing is, that the cards work fine, if I use a 2.2 kernel
> (tested with 2.2.19). Others have posted that they needed to enable
> CONFIG_PCI_QUIRKS, but that doesn't seem to be necessary for me (I've
> haven't tested with heavy trafic more than 15 minutes, though).

Yes, well, the 2.2. kernels dealt with a PC164 "anomaly" much better,
and even 2.4.10 deals with it, but ONLY if you've booted from MILO.

Use the attached patch against 2.4.10, and you should have better
results. These patches, among others, are in the process of being
submitted to Linus for 2.4.11, hopefully.

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook                            Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20         (508) 467-2080
200 Forest Street, Marlboro MA 01752       Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------

[-- Attachment #2: pc164-diffs --]
[-- Type: text/plain, Size: 5533 bytes --]

diff -ur LINUX/linux-2.4.10/arch/alpha/kernel/setup.c PATCH/linux-2.4.10/arch/alpha/kernel/setup.c
--- LINUX/linux-2.4.10/arch/alpha/kernel/setup.c	Thu Aug 16 23:48:33 2001
+++ PATCH/linux-2.4.10/arch/alpha/kernel/setup.c	Thu Sep 27 17:45:08 2001
@@ -85,7 +93,7 @@
 
 static struct alpha_machine_vector *get_sysvec(long, long, long);
 static struct alpha_machine_vector *get_sysvec_byname(const char *);
-static void get_sysnames(long, long, char **, char **);
+static void get_sysnames(long, long, long, char **, char **);
 
 static char command_line[COMMAND_LINE_SIZE];
 char saved_command_line[COMMAND_LINE_SIZE];
@@ -537,14 +545,14 @@
 	/*
 	 * Indentify and reconfigure for the current system.
 	 */
+	cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
+
 	get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
-		     &type_name, &var_name);
+		     cpu->type, &type_name, &var_name);
 	if (*var_name == '0')
 		var_name = "";
 
 	if (!vec) {
-		cpu = (struct percpu_struct*)
-			((char*)hwrpb + hwrpb->processor_offset);
 		vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
 				 cpu->type);
 	}
@@ -801,6 +809,8 @@
 		/* Member ID is a bit-field. */
 		long member = (variation >> 10) & 0x3f;
 
+		cpu &= 0xffffffff; /* make it usable */
+
 		switch (type) {
 		case ST_DEC_ALCOR:
 			if (member < N(alcor_indices))
@@ -809,6 +819,10 @@
 		case ST_DEC_EB164:
 			if (member < N(eb164_indices))
 				vec = eb164_vecs[eb164_indices[member]];
+			/* PC164 may show as EB164 variation with EV56 CPU,
+			   but, since no true EB164 had anything but EV5... */
+			if (vec == &eb164_mv && cpu == EV56_CPU)
+				vec = &pc164_mv;
 			break;
 		case ST_DEC_EB64P:
 			if (member < N(eb64p_indices))
@@ -827,21 +841,18 @@
 				vec = tsunami_vecs[tsunami_indices[member]];
 			break;
 		case ST_DEC_1000:
-			cpu &= 0xffffffff;
 			if (cpu == EV5_CPU || cpu == EV56_CPU)
 				vec = &mikasa_primo_mv;
 			else
 				vec = &mikasa_mv;
 			break;
 		case ST_DEC_NORITAKE:
-			cpu &= 0xffffffff;
 			if (cpu == EV5_CPU || cpu == EV56_CPU)
 				vec = &noritake_primo_mv;
 			else
 				vec = &noritake_mv;
 			break;
 		case ST_DEC_2100_A500:
-			cpu &= 0xffffffff;
 			if (cpu == EV5_CPU || cpu == EV56_CPU)
 				vec = &sable_gamma_mv;
 			else
@@ -905,7 +916,7 @@
 }
 
 static void
-get_sysnames(long type, long variation,
+get_sysnames(long type, long variation, long cpu,
 	     char **type_name, char **variation_name)
 {
 	long member;
@@ -938,12 +949,18 @@
 
 	member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
 
+	cpu &= 0xffffffff; /* make it usable */
+
 	switch (type) { /* select by family */
 	default: /* default to variation "0" for now */
 		break;
 	case ST_DEC_EB164:
 		if (member < N(eb164_indices))
 			*variation_name = eb164_names[eb164_indices[member]];
+		/* PC164 may show as EB164 variation, but with EV56 CPU,
+		   so, since no true EB164 had anything but EV5... */
+		if (eb164_indices[member] == 0 && cpu == EV56_CPU)
+			*variation_name = eb164_names[1]; /* make it PC164 */
 		break;
 	case ST_DEC_ALCOR:
 		if (member < N(alcor_indices))
@@ -1054,7 +1071,7 @@
 		cpu_name = cpu_names[cpu_index];
 
 	get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
-		     &systype_name, &sysvariation_name);
+		     cpu->type, &systype_name, &sysvariation_name);
 
 	nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
 
diff -ur LINUX/linux-2.4.10/arch/alpha/kernel/sys_cabriolet.c PATCH/linux-2.4.10/arch/alpha/kernel/sys_cabriolet.c
--- LINUX/linux-2.4.10/arch/alpha/kernel/sys_cabriolet.c	Sat Feb 24 22:54:55 2001
+++ PATCH/linux-2.4.10/arch/alpha/kernel/sys_cabriolet.c	Fri Sep 28 10:34:51 2001
@@ -106,12 +106,12 @@
 }
 
 static void __init
-cabriolet_init_irq(void)
+common_init_irq(void (*srm_dev_int)(unsigned long v, struct pt_regs *r))
 {
 	init_i8259a_irqs();
 
 	if (alpha_using_srm) {
-		alpha_mv.device_interrupt = srm_device_interrupt;
+		alpha_mv.device_interrupt = srm_dev_int;
 		init_srm_irqs(35, 0);
 	}
 	else {
@@ -131,8 +131,43 @@
 	setup_irq(16+4, &isa_cascade_irqaction);
 }
 
+static void __init
+cabriolet_init_irq(void)
+{
+	common_init_irq(srm_device_interrupt);
+}
+
 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
 static void
+pc164_srm_device_interrupt(unsigned long v, struct pt_regs *r)
+{
+	/* In theory, the PC164 has the same interrupt hardware as
+	   the other Cabriolet based systems.  However, something 
+	   got screwed up late in the development cycle which broke
+	   the interrupt masking hardware.  Repeat, it is not 
+	   possible to mask and ack interrupts.  At all.
+
+	   In an attempt to work around this, while processing 
+	   interrupts, we do not allow the IPL to drop below what
+	   it is currently.  This prevents the possibility of
+	   recursion.  
+
+	   ??? Another option might be to force all PCI devices
+	   to use edge triggered rather than level triggered
+	   interrupts.  That might be too invasive though.  */
+
+	__min_ipl = getipl();
+	srm_device_interrupt(v, r);
+	__min_ipl = 0;
+}
+
+static void __init
+pc164_init_irq(void)
+{
+	common_init_irq(pc164_srm_device_interrupt);
+}
+
+static void
 pc164_device_interrupt(unsigned long v, struct pt_regs *r)
 {
 	/* In theory, the PC164 has the same interrupt hardware as
@@ -419,7 +454,7 @@
 	device_interrupt:	pc164_device_interrupt,
 
 	init_arch:		cia_init_arch,
-	init_irq:		cabriolet_init_irq,
+	init_irq:		pc164_init_irq,
 	init_rtc:		common_init_rtc,
 	init_pci:		alphapc164_init_pci,
 	pci_map_irq:		alphapc164_map_irq,

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 15:12 Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164 Mads Peter Bach
  2001-10-04 15:28 ` Jay Estabrook
@ 2001-10-04 17:09 ` Michal Jaegermann
  2001-10-04 18:30   ` Jay Estabrook
  1 sibling, 1 reply; 13+ messages in thread
From: Michal Jaegermann @ 2001-10-04 17:09 UTC (permalink / raw)
  To: axp-list

On Thu, Oct 04, 2001 at 05:12:49PM +0200, Mads Peter Bach wrote:

>
> It
> turns out, that the reason the net install didn't work, was that any heavy
> 100baseTX ethernet activity, using normal size packets hung the machine.

Hm, I wonder how this is related to the very recent discussion with
subjects like "limiting IRQ load, irq-rewrite-2.4.11-B5" on
linux-kernel list.  In your place I would check relevant discussions
in recent archives and post a detailed description to
linux-kernel@vger.kernel.org (and maybe 'cc' to main participants).
You do not have to subscribe to post there although you may not see
followups that way. :-)

Sounds strangely familiar and it may be much bigger problem than
Linus seems to believe.

  Michal




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 17:09 ` Michal Jaegermann
@ 2001-10-04 18:30   ` Jay Estabrook
  0 siblings, 0 replies; 13+ messages in thread
From: Jay Estabrook @ 2001-10-04 18:30 UTC (permalink / raw)
  To: axp-list

On Thu, Oct 04, 2001 at 11:09:46AM -0600, Michal Jaegermann wrote:
> On Thu, Oct 04, 2001 at 05:12:49PM +0200, Mads Peter Bach wrote:
> 
> > It
> > turns out, that the reason the net install didn't work, was that any heavy
> > 100baseTX ethernet activity, using normal size packets hung the machine.
> 
> Hm, I wonder how this is related to the very recent discussion with
> subjects like "limiting IRQ load, irq-rewrite-2.4.11-B5" on
> linux-kernel list.  In your place I would check relevant discussions
> in recent archives and post a detailed description to
> linux-kernel@vger.kernel.org (and maybe 'cc' to main participants).
> You do not have to subscribe to post there although you may not see
> followups that way. :-)
> 
> Sounds strangely familiar and it may be much bigger problem than
> Linus seems to believe.

I don't believe it is; the problem is related to PC164 with SRM only,
and has been present through all the 2.4.x kernels, as far as I can
tell.

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook                            Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20         (508) 467-2080
200 Forest Street, Marlboro MA 01752       Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 15:28 ` Jay Estabrook
@ 2001-10-04 19:21   ` Mads Peter Bach
  2001-10-04 22:26     ` Jay Estabrook
  0 siblings, 1 reply; 13+ messages in thread
From: Mads Peter Bach @ 2001-10-04 19:21 UTC (permalink / raw)
  To: axp-list

Jay Estabrook wrote:
> 
> On Thu, Oct 04, 2001 at 05:12:49PM +0200, Mads Peter Bach wrote:
> >
> > I've been trying to a net install of RedHat 7.1 on a machine with a
> > Digital AlphaPC 164 (not SX/LX) motherboard, but failed miserably,
> > due to machine hangs.
> 
> I'll bet you're running from SRM console, right?

Yes. I upgraded to make the install easier :-)
> 
> > Last week, I finally installed from a CDROM instead, which went
> > smoothly. It turns out, that the reason the net install didn't work,
> > was that any heavy 100baseTX ethernet activity, using normal size
> > packets hung the machine.
[snip]

> Yes, network traffic (even "ping" did it for me) seems to exacerbate
> the problem.
> 
> > The strange thing is, that the cards work fine, if I use a 2.2 kernel
> > (tested with 2.2.19). Others have posted that they needed to enable
> > CONFIG_PCI_QUIRKS, but that doesn't seem to be necessary for me (I've
> > haven't tested with heavy trafic more than 15 minutes, though).
> 
> Yes, well, the 2.2. kernels dealt with a PC164 "anomaly" much better,
> and even 2.4.10 deals with it, but ONLY if you've booted from MILO.

Ahhh :-) Palcode fixes?
> 
> Use the attached patch against 2.4.10, and you should have better
> results. These patches, among others, are in the process of being
> submitted to Linus for 2.4.11, hopefully.

Colour me impressed! That was quick. The patch seems to work great. Is there
a patch for the clock detection problem among the ones that have been
submitted to Linus? (I currently have to use the cycle kernel parameter, to
get sane BogoMIPS and timer ticks - even though I was quite impressed with
2900 BogoMIPS from a 366 MHz EV56)

I sure hope that Compaq/HP appreciate your work here, I'm sure that we are
many here who do!

Best regards,

Mads Bach




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 19:21   ` Mads Peter Bach
@ 2001-10-04 22:26     ` Jay Estabrook
  2001-10-04 23:02       ` Mads Peter Bach
  2001-10-05 10:31       ` Ivan Kokshaysky
  0 siblings, 2 replies; 13+ messages in thread
From: Jay Estabrook @ 2001-10-04 22:26 UTC (permalink / raw)
  To: axp-list

On Thu, Oct 04, 2001 at 09:21:46PM +0200, Mads Peter Bach wrote:
>
> > Yes, well, the 2.2. kernels dealt with a PC164 "anomaly" much better,
> > and even 2.4.10 deals with it, but ONLY if you've booted from MILO.
> 
> Ahhh:-) Palcode fixes?

Actually, no.

History
-------

The PC164 mobos were shipping before it was detected that the IRQ
masking hardware chips were broken. The problem was never fixed in
hardware, correct functioning depends on a software workaround.

Kernel 2.0 and 2.2 IRQ processing didn't require, or could easily be
prevented from, working IRQ masking hardware.

Kernel 2.4 originally did require working IRQ masking hardware because it
wants to:

1. MASK off the current interrupt
2. lower IPL to allow any other interrupts (ie any priority) to come
   through

Patches were introduced specifically for PC164 that worked around the
problem by not lowering IPL below the current interrupt.

However, they worked only for PC164 running with MILO, because MILO
correctly sets up the HWRPB to indicate EB164 family and PC164
variation, while SRM console indicates EB164 family and (erroneously)
EB164 variation. I don't know how it ever worked even as well as it
did (from SRM).

So, the new patches correctly identify the PC164 variation and
correctly activate the above workaround.

> Colour me impressed! That was quick. The patch seems to work great.

Well, I'd actually worked it out last week from some other reports of
the same problem... ;-}

> Is there a patch for the clock detection problem among the ones that
> have been submitted to Linus? (I currently have to use the cycle
> kernel parameter, to get sane BogoMIPS and timer ticks - even though
> I was quite impressed with 2900 BogoMIPS from a 366 MHz EV56)

Maybe; I solved a problem with a machine which was hanging hard in
the new code that attempts to use the programmable interval timer
to calculate the correct cycle frequency, but I'm not sure it's the
same problem.

I think maybe Ivan has some patches that do a better job in that area,
and I know he's going to submit them soon. Maybe he'll post them here
for some additional testing... :-) :-)

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook                            Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20         (508) 467-2080
200 Forest Street, Marlboro MA 01752       Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 22:26     ` Jay Estabrook
@ 2001-10-04 23:02       ` Mads Peter Bach
  2001-10-05 10:31       ` Ivan Kokshaysky
  1 sibling, 0 replies; 13+ messages in thread
From: Mads Peter Bach @ 2001-10-04 23:02 UTC (permalink / raw)
  To: axp-list

Jay Estabrook wrote:
> 
> On Thu, Oct 04, 2001 at 09:21:46PM +0200, Mads Peter Bach wrote:
> 
> > Is there a patch for the clock detection problem among the ones that
> > have been submitted to Linus? (I currently have to use the cycle
> > kernel parameter, to get sane BogoMIPS and timer ticks - even though
> > I was quite impressed with 2900 BogoMIPS from a 366 MHz EV56)
> 
> Maybe; I solved a problem with a machine which was hanging hard in
> the new code that attempts to use the programmable interval timer
> to calculate the correct cycle frequency, but I'm not sure it's the
> same problem.

OK. When starting up, I get the following in syslog:

Oct  4 19:33:58 heretic kernel: HWRPB cycle frequency bogus.  Estimated
1362855637 Hz 
Oct  4 19:33:58 heretic kernel: Calibrating delay loop... 2870.08 BogoMIPS 

So I use cycle=366000000 as a parameter i aboot.conf, which gives much saner values.
 
> I think maybe Ivan has some patches that do a better job in that area,
> and I know he's going to submit them soon. Maybe he'll post them here
> for some additional testing... :-) :-)

That'd be great. I'll be more than happy to test them :-)
I hammered the Alphas NIC hard for half an hour (15 GB rx&tx), and it stayed
rock-solid, so it looks good.

Best regards

Mads Bach




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-04 22:26     ` Jay Estabrook
  2001-10-04 23:02       ` Mads Peter Bach
@ 2001-10-05 10:31       ` Ivan Kokshaysky
  2001-10-07  7:48         ` Richard Henderson
  1 sibling, 1 reply; 13+ messages in thread
From: Ivan Kokshaysky @ 2001-10-05 10:31 UTC (permalink / raw)
  To: axp-list

On Thu, Oct 04, 2001 at 06:26:10PM -0400, Jay Estabrook wrote:
> I think maybe Ivan has some patches that do a better job in that area,
> and I know he's going to submit them soon. Maybe he'll post them here
> for some additional testing... :-) :-)

Sure, especially because my latest patch doesn't work on a pc164,
as Richard reported. :-(
So I would return to my previous thought - compare the measured frequency
with one reported in the hwrpb and return failure if we see twofold or higher
difference. Also emergency timeout added, as you suggested.

Ivan.

--- 2.4.10/arch/alpha/kernel/time.c	Fri Oct  5 13:43:01 2001
+++ linux/arch/alpha/kernel/time.c	Fri Oct  5 13:53:20 2001
@@ -170,28 +170,28 @@ common_init_rtc(void)
 }
 
 /*
- * Calibrate CPU clock using legacy 8254 timer/counter. Stolen from
- * arch/i386/time.c.
+ * Calibrate CPU clock using legacy 8254 programmable interval timer.
+ * Based on arch/i386/time.c.
  */
 
-#define CALIBRATE_LATCH	(52 * LATCH)
-#define CALIBRATE_TIME	(52 * 1000020 / HZ)
+#define CALIBRATE_LATCH	0xffff
+#define TIMEOUT_COUNT	0x100000
 
 static unsigned long __init
-calibrate_cc_with_pic(void)
+calibrate_cc_with_pit(void)
 {
-	int cc;
-	unsigned long count = 0;
+	int cc, count = 0;
+	unsigned long freq, hwrpbfreq = hwrpb->cycle_freq;
 
 	/* Set the Gate high, disable speaker */
 	outb((inb(0x61) & ~0x02) | 0x01, 0x61);
 
 	/*
-	 * Now let's take care of CTC channel 2
+	 * Now let's take care of PIT channel 2
 	 *
-	 * Set the Gate high, program CTC channel 2 for mode 0,
+	 * Set the Gate high, program PIT channel 2 for mode 0,
 	 * (interrupt on terminal count mode), binary count,
-	 * load 5 * LATCH count, (LSB and MSB) to begin countdown.
+	 * load CALIBRATE_LATCH count (LSB and MSB) to begin countdown.
 	 */
 	outb(0xb0, 0x43);		/* binary, mode 0, LSB/MSB, Ch 2 */
 	outb(CALIBRATE_LATCH & 0xff, 0x42);	/* LSB of count */
@@ -200,29 +200,23 @@ calibrate_cc_with_pic(void)
 	cc = rpcc();
 	do {
 		count++;
-	} while ((inb(0x61) & 0x20) == 0);
+	} while (!(inb(0x61) & 0x20) && count < TIMEOUT_COUNT);
 	cc = rpcc() - cc;
 
-	/* Error: ECTCNEVERSET */
-	if (count <= 1)
-		goto bad_ctc;
-
-	/* Error: ECPUTOOFAST */
-	if (count >> 32)
-		goto bad_ctc;
-
-	/* Error: ECPUTOOSLOW */
-	if (cc <= CALIBRATE_TIME)
-		goto bad_ctc;
+	/* Error: EPITNEVERSET or ECPUTOOFAST */
+	if (count <= 1 || count == TIMEOUT_COUNT)
+		goto bad_pit;
+
+	freq = ((long)cc * CLOCK_TICK_RATE) / (CALIBRATE_LATCH + 1);
+
+	/* CPU cycle frequency reported in the hwrpb is often bogus.
+	   However, even in the worst case the difference shouldn't
+	   exceed 30-40%, so we can still use hwrpb value to validate
+	   the frequency we've found with PIT. */
+	if ((max(freq, hwrpbfreq) + 1) / (min(freq, hwrpbfreq) + 1) < 2)
+		return freq;
 
-	return ((long)cc * 1000000) / CALIBRATE_TIME;
-
-	/*
-	 * The CTC wasn't reliable: we got a hit on the very first read,
-	 * or the CPU was so fast/slow that the quotient wouldn't fit in
-	 * 32 bits..
-	 */
- bad_ctc:
+ bad_pit:
 	return 0;
 }
 
@@ -249,7 +243,7 @@ time_init(void)
 
 	/* Calibrate CPU clock -- attempt #1.  */
 	if (!est_cycle_freq)
-		est_cycle_freq = calibrate_cc_with_pic();
+		est_cycle_freq = calibrate_cc_with_pit();
 
 	cc1 = rpcc_after_update_in_progress();
 




^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
@ 2001-10-05 13:17 Jemiolo, John
  0 siblings, 0 replies; 13+ messages in thread
From: Jemiolo, John @ 2001-10-05 13:17 UTC (permalink / raw)
  To: axp-list

The emergency time-out worked just fine :^)   I installed your patch in
place of the fix Jay performed last week on my xp1000..

That plus the ac4 patch, seems to make 2.4.10  stable (for me), as I
have been unable to hang it anymore.. 

Thanks
JJ 

-----Original Message-----
From: Ivan Kokshaysky [mailto:ink@jurassic.park.msu.ru]
Sent: Friday, October 05, 2001 6:32 AM
To: axp-list@redhat.com
Subject: Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC
164


On Thu, Oct 04, 2001 at 06:26:10PM -0400, Jay Estabrook wrote:
> I think maybe Ivan has some patches that do a better job in that area,
> and I know he's going to submit them soon. Maybe he'll post them here
> for some additional testing... :-) :-)

Sure, especially because my latest patch doesn't work on a pc164,
as Richard reported. :-(
So I would return to my previous thought - compare the measured
frequency
with one reported in the hwrpb and return failure if we see twofold or
higher
difference. Also emergency timeout added, as you suggested.

Ivan.

--- 2.4.10/arch/alpha/kernel/time.c	Fri Oct  5 13:43:01 2001
+++ linux/arch/alpha/kernel/time.c	Fri Oct  5 13:53:20 2001
@@ -170,28 +170,28 @@ common_init_rtc(void)
 }
 
 /*
- * Calibrate CPU clock using legacy 8254 timer/counter. Stolen from
- * arch/i386/time.c.
+ * Calibrate CPU clock using legacy 8254 programmable interval timer.
+ * Based on arch/i386/time.c.
  */
 
-#define CALIBRATE_LATCH	(52 * LATCH)
-#define CALIBRATE_TIME	(52 * 1000020 / HZ)
+#define CALIBRATE_LATCH	0xffff
+#define TIMEOUT_COUNT	0x100000
 
 static unsigned long __init
-calibrate_cc_with_pic(void)
+calibrate_cc_with_pit(void)
 {
-	int cc;
-	unsigned long count = 0;
+	int cc, count = 0;
+	unsigned long freq, hwrpbfreq = hwrpb->cycle_freq;
 
 	/* Set the Gate high, disable speaker */
 	outb((inb(0x61) & ~0x02) | 0x01, 0x61);
 
 	/*
-	 * Now let's take care of CTC channel 2
+	 * Now let's take care of PIT channel 2
 	 *
-	 * Set the Gate high, program CTC channel 2 for mode 0,
+	 * Set the Gate high, program PIT channel 2 for mode 0,
 	 * (interrupt on terminal count mode), binary count,
-	 * load 5 * LATCH count, (LSB and MSB) to begin countdown.
+	 * load CALIBRATE_LATCH count (LSB and MSB) to begin countdown.
 	 */
 	outb(0xb0, 0x43);		/* binary, mode 0, LSB/MSB, Ch 2
*/
 	outb(CALIBRATE_LATCH & 0xff, 0x42);	/* LSB of count */
@@ -200,29 +200,23 @@ calibrate_cc_with_pic(void)
 	cc = rpcc();
 	do {
 		count++;
-	} while ((inb(0x61) & 0x20) == 0);
+	} while (!(inb(0x61) & 0x20) && count < TIMEOUT_COUNT);
 	cc = rpcc() - cc;
 
-	/* Error: ECTCNEVERSET */
-	if (count <= 1)
-		goto bad_ctc;
-
-	/* Error: ECPUTOOFAST */
-	if (count >> 32)
-		goto bad_ctc;
-
-	/* Error: ECPUTOOSLOW */
-	if (cc <= CALIBRATE_TIME)
-		goto bad_ctc;
+	/* Error: EPITNEVERSET or ECPUTOOFAST */
+	if (count <= 1 || count == TIMEOUT_COUNT)
+		goto bad_pit;
+
+	freq = ((long)cc * CLOCK_TICK_RATE) / (CALIBRATE_LATCH + 1);
+
+	/* CPU cycle frequency reported in the hwrpb is often bogus.
+	   However, even in the worst case the difference shouldn't
+	   exceed 30-40%, so we can still use hwrpb value to validate
+	   the frequency we've found with PIT. */
+	if ((max(freq, hwrpbfreq) + 1) / (min(freq, hwrpbfreq) + 1) < 2)
+		return freq;
 
-	return ((long)cc * 1000000) / CALIBRATE_TIME;
-
-	/*
-	 * The CTC wasn't reliable: we got a hit on the very first read,
-	 * or the CPU was so fast/slow that the quotient wouldn't fit in
-	 * 32 bits..
-	 */
- bad_ctc:
+ bad_pit:
 	return 0;
 }
 
@@ -249,7 +243,7 @@ time_init(void)
 
 	/* Calibrate CPU clock -- attempt #1.  */
 	if (!est_cycle_freq)
-		est_cycle_freq = calibrate_cc_with_pic();
+		est_cycle_freq = calibrate_cc_with_pit();
 
 	cc1 = rpcc_after_update_in_progress();
 



_______________________________________________
Axp-list mailing list
Axp-list@redhat.com
https://listman.redhat.com/mailman/listinfo/axp-list




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-05 10:31       ` Ivan Kokshaysky
@ 2001-10-07  7:48         ` Richard Henderson
  2001-10-07 17:29           ` Jay Estabrook
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2001-10-07  7:48 UTC (permalink / raw)
  To: axp-list

On Fri, Oct 05, 2001 at 02:31:30PM +0400, Ivan Kokshaysky wrote:
> So I would return to my previous thought - compare the measured frequency
> with one reported in the hwrpb and return failure if we see twofold or higher
> difference.

The reason I originally added bits to estimate the value
is that sometimes one gets zero in this field.


r~




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-07  7:48         ` Richard Henderson
@ 2001-10-07 17:29           ` Jay Estabrook
  2001-10-08  7:28             ` Richard Henderson
  0 siblings, 1 reply; 13+ messages in thread
From: Jay Estabrook @ 2001-10-07 17:29 UTC (permalink / raw)
  To: axp-list

On Sun, Oct 07, 2001 at 12:48:04AM -0700, Richard Henderson wrote:
> On Fri, Oct 05, 2001 at 02:31:30PM +0400, Ivan Kokshaysky wrote:
> > So I would return to my previous thought - compare the measured frequency
> > with one reported in the hwrpb and return failure if we see twofold or
> > higher difference.
> 
> The reason I originally added bits to estimate the value
> is that sometimes one gets zero in this field.

Yes, that has always been a problem on some boxes - do you remember if
they involved MILO or SRM (or both)?

As you say, that was the reason to have put in the original RPCC-based
code.

But what was the reason that that was no longer deemed sufficient?

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook                            Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20         (508) 467-2080
200 Forest Street, Marlboro MA 01752       Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-07 17:29           ` Jay Estabrook
@ 2001-10-08  7:28             ` Richard Henderson
  2001-10-08 14:39               ` Ivan Kokshaysky
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2001-10-08  7:28 UTC (permalink / raw)
  To: axp-list

On Sun, Oct 07, 2001 at 01:29:38PM -0400, Jay Estabrook wrote:
> Yes, that has always been a problem on some boxes - do you remember if
> they involved MILO or SRM (or both)?

No.

> But what was the reason that that was no longer deemed sufficient?

IIRC, someone thought that the PIT would be more accurate.


r~




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164
  2001-10-08  7:28             ` Richard Henderson
@ 2001-10-08 14:39               ` Ivan Kokshaysky
  0 siblings, 0 replies; 13+ messages in thread
From: Ivan Kokshaysky @ 2001-10-08 14:39 UTC (permalink / raw)
  To: axp-list

On Mon, Oct 08, 2001 at 12:28:32AM -0700, Richard Henderson wrote:
> IIRC, someone thought that the PIT would be more accurate.

I think originally it was an attempt to fix some UP2000+ with
broken RTC.

BTW, I suspected that hwrpb->cycle_freq might be zero, that's why
there is "+1" in the check. In this case the PIT routine will fail,
and we'll fall back to the RTC calibration.

Ivan.




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2001-10-08 14:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-04 15:12 Hangs with 100baseTX, RedHat 7.1, kernel 2.4.x and AlphaPC 164 Mads Peter Bach
2001-10-04 15:28 ` Jay Estabrook
2001-10-04 19:21   ` Mads Peter Bach
2001-10-04 22:26     ` Jay Estabrook
2001-10-04 23:02       ` Mads Peter Bach
2001-10-05 10:31       ` Ivan Kokshaysky
2001-10-07  7:48         ` Richard Henderson
2001-10-07 17:29           ` Jay Estabrook
2001-10-08  7:28             ` Richard Henderson
2001-10-08 14:39               ` Ivan Kokshaysky
2001-10-04 17:09 ` Michal Jaegermann
2001-10-04 18:30   ` Jay Estabrook
  -- strict thread matches above, loose matches on Subject: below --
2001-10-05 13:17 Jemiolo, John

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox