linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* VIA PCI IRQ router bug fix
@ 2003-07-03 19:19 Aleksey Gorelov
  2003-07-03 23:52 ` [PATCH] " Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Aleksey Gorelov @ 2003-07-03 19:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: mj

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

Hi.

  I found & fixed a problem with #PIRQD line setup for VIA PCI IRQ
router. Kernel was not able to receive any interrupts from network card,
which PCI slot IRQ pin A was routed to PIRQ line D of VIA PCI IRQ
router. According to VIA specs, PIRQ D routing is out of standard
'nibble' scheme.
  I tested patch with 2.4.20 kernel, it can be applied to 2.4.22-pre2 as
well.
  Thanks to my employer (Phoenix Technologies) who kindly allowed me to
make this patch public.

Aleks.


[-- Attachment #2: pci-irq-patch.txt --]
[-- Type: text/plain, Size: 922 bytes --]

--- linux-2.4.20/arch/i386/kernel/pci-irq_old.c	2002-11-28 15:53:09.000000000 -0800
+++ linux-2.4.20/arch/i386/kernel/pci-irq.c	2003-05-21 17:27:40.000000000 -0700
@@ -198,12 +198,27 @@
  */
 static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
 {
-	return read_config_nybble(router, 0x55, pirq);
+    u8 x;
+
+    if ( pirq == 4 ) {
+        pci_read_config_byte(router, 0x57, &x);
+        return (x >> 4);
+    } else {
+        return read_config_nybble(router, 0x55, pirq);
+    }
 }
 
 static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
 {
-	write_config_nybble(router, 0x55, pirq, irq);
+  	u8 x;
+
+    if ( pirq == 4 ) {
+        pci_read_config_byte(router, 0x57, &x);
+        x = (x & 0x0f) | (irq << 4);
+       	pci_write_config_byte(router, 0x57, x);
+    } else {
+        write_config_nybble(router, 0x55, pirq, irq);
+    }
 	return 1;
 }
 

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

* [PATCH] Re: VIA PCI IRQ router bug fix
  2003-07-03 19:19 VIA PCI IRQ router bug fix Aleksey Gorelov
@ 2003-07-03 23:52 ` Jeff Garzik
  2003-07-04  7:31   ` Arjan van de Ven
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2003-07-03 23:52 UTC (permalink / raw)
  To: Aleksey Gorelov; +Cc: linux-kernel, mj, alan

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

Aleksey Gorelov wrote:
> Hi.
> 
>   I found & fixed a problem with #PIRQD line setup for VIA PCI IRQ
> router. Kernel was not able to receive any interrupts from network card,
> which PCI slot IRQ pin A was routed to PIRQ line D of VIA PCI IRQ
> router. According to VIA specs, PIRQ D routing is out of standard
> 'nibble' scheme.
>   I tested patch with 2.4.20 kernel, it can be applied to 2.4.22-pre2 as
> well.
>   Thanks to my employer (Phoenix Technologies) who kindly allowed me to
> make this patch public.

Thanks much!  Please continue to encourage your employer to contribute 
to open source.  Posting patches like this means that all Linux via 
users have a more stable system to use.


> --- linux-2.4.20/arch/i386/kernel/pci-irq_old.c	2002-11-28 15:53:09.000000000 -0800
> +++ linux-2.4.20/arch/i386/kernel/pci-irq.c	2003-05-21 17:27:40.000000000 -0700
> @@ -198,12 +198,27 @@
>   */
>  static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
>  {
> -	return read_config_nybble(router, 0x55, pirq);
> +    u8 x;
> +
> +    if ( pirq == 4 ) {
> +        pci_read_config_byte(router, 0x57, &x);
> +        return (x >> 4);
> +    } else {
> +        return read_config_nybble(router, 0x55, pirq);
> +    }
>  }

If you don't mind, I would prefer the attached patch, which is a little 
bit less verbose.

I will make sure this fix is merged into 2.4 and 2.5, if noone beats me 
to it.

	Jeff



[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 767 bytes --]

===== arch/i386/pci/irq.c 1.25 vs edited =====
--- 1.25/arch/i386/pci/irq.c	Thu Jun 19 17:58:11 2003
+++ edited/arch/i386/pci/irq.c	Thu Jul  3 19:49:14 2003
@@ -196,15 +196,16 @@
 /*
  * The VIA pirq rules are nibble-based, like ALI,
  * but without the ugly irq number munging.
+ * However, PIRQD is in the upper instead of lower 4 bits.
  */
 static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
 {
-	return read_config_nybble(router, 0x55, pirq);
+	return read_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq);
 }
 
 static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
 {
-	write_config_nybble(router, 0x55, pirq, irq);
+	write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
 	return 1;
 }
 

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

* Re: [PATCH] Re: VIA PCI IRQ router bug fix
  2003-07-03 23:52 ` [PATCH] " Jeff Garzik
@ 2003-07-04  7:31   ` Arjan van de Ven
  2003-07-04 13:44     ` Jeff Garzik
  2003-07-04 15:12     ` Davide Libenzi
  0 siblings, 2 replies; 5+ messages in thread
From: Arjan van de Ven @ 2003-07-04  7:31 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Aleksey Gorelov, linux-kernel, mj, alan

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


>  
>  static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
>  {
> -	write_config_nybble(router, 0x55, pirq, irq);
> +	write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
>  	return 1;
>  }


you missed the 
> +        return (x >> 4);
in the original patch... so your code is NOT identical. 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] Re: VIA PCI IRQ router bug fix
  2003-07-04  7:31   ` Arjan van de Ven
@ 2003-07-04 13:44     ` Jeff Garzik
  2003-07-04 15:12     ` Davide Libenzi
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2003-07-04 13:44 UTC (permalink / raw)
  To: arjanv; +Cc: Aleksey Gorelov, linux-kernel, mj, alan

Arjan van de Ven wrote:
>> 
>> static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
>> {
>>-	write_config_nybble(router, 0x55, pirq, irq);
>>+	write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
>> 	return 1;
>> }
> 
> 
> 
> you missed the 
> 
>>+        return (x >> 4);
> 
> in the original patch... so your code is NOT identical. 

Look at read_config_nybble...

	return (nr & 1) ? (x >> 4) : (x & 0xf);

Can you spell out which part is different?  I don't see it.

	Jeff



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

* Re: [PATCH] Re: VIA PCI IRQ router bug fix
  2003-07-04  7:31   ` Arjan van de Ven
  2003-07-04 13:44     ` Jeff Garzik
@ 2003-07-04 15:12     ` Davide Libenzi
  1 sibling, 0 replies; 5+ messages in thread
From: Davide Libenzi @ 2003-07-04 15:12 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Jeff Garzik, Aleksey Gorelov, Linux Kernel Mailing List, mj, alan

On Fri, 4 Jul 2003, Arjan van de Ven wrote:

>
> >
> >  static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
> >  {
> > -	write_config_nybble(router, 0x55, pirq, irq);
> > +	write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
> >  	return 1;
> >  }
>
>
> you missed the
> > +        return (x >> 4);
> in the original patch... so your code is NOT identical.

It's ok :

nybble(0x57, 1) == nybble(0x55, 5)



- Davide


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

end of thread, other threads:[~2003-07-04 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-03 19:19 VIA PCI IRQ router bug fix Aleksey Gorelov
2003-07-03 23:52 ` [PATCH] " Jeff Garzik
2003-07-04  7:31   ` Arjan van de Ven
2003-07-04 13:44     ` Jeff Garzik
2003-07-04 15:12     ` Davide Libenzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).