public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* please help me understand a line code about pci
@ 2003-01-04  7:24 fretre lewis
  0 siblings, 0 replies; 4+ messages in thread
From: fretre lewis @ 2003-01-04  7:24 UTC (permalink / raw)
  To: linux-kernel


hi,all

  I am reading code about pci, and I can't understand some lines in
pci_check_direct(), in arch/i386/kernel/pci-pc.c

well, I wonder why need "outb (0x01, 0xCFB);" if check configuration type 1 
? and why "outb (0x00, 0xCFB);" if check configuration type 2?
  please help me,thanks a lot.


406 static struct pci_ops * __devinit pci_check_direct(void)
407 {
408         unsigned int tmp;
409         unsigned long flags;
410
411         __save_flags(flags); __cli();
412
413         /*
414          * Check if configuration type 1 works.
415          */
416         if (pci_probe & PCI_PROBE_CONF1) {
417                 outb (0x01, 0xCFB);  <<<=========
418                 tmp = inl (0xCF8);
419                 outl (0x80000000, 0xCF8);
420                 if (inl (0xCF8) == 0x80000000 &&
421                     pci_sanity_check(&pci_direct_conf1)) {
422                         outl (tmp, 0xCF8);
423                         __restore_flags(flags);
424                         printk(KERN_INFO "PCI: Using configuration type 
1\n");
425                         request_region(0xCF8, 8, "PCI conf1");
426                         return &pci_direct_conf1;
427                 }
428                 outl (tmp, 0xCF8);
429         }
430
431         /*
432          * Check if configuration type 2 works.
433          */
434         if (pci_probe & PCI_PROBE_CONF2) {
435                 outb (0x00, 0xCFB);   <<<=========
436                 outb (0x00, 0xCF8);
437                 outb (0x00, 0xCFA);
438                 if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
439                     pci_sanity_check(&pci_direct_conf2)) {
440                         __restore_flags(flags);
441                         printk(KERN_INFO "PCI: Using configuration type 
2\n");
442                         request_region(0xCF8, 4, "PCI conf2");
443                         return &pci_direct_conf2;
444                 }
445         }
446
447         __restore_flags(flags);
448         return NULL;
449 }
450
451 #endif





_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus


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

* please help me understand a line code about pci
@ 2003-01-04 11:59 fretre lewis
  2003-01-04 12:14 ` John Bradford
  0 siblings, 1 reply; 4+ messages in thread
From: fretre lewis @ 2003-01-04 11:59 UTC (permalink / raw)
  To: linux-kernel



hi,all

  I am reading code about pci, and I can't understand some lines in
pci_check_direct(), in arch/i386/kernel/pci-pc.c

the PCI spec v2.0 say: ( page32)

"Anytime a host bridge sees a full DWORD I/O write from the host to
CONFIG_ADDRESS, the bridge must latch the data into its CONFIG_ADDRESS
register. On full DWORD I/O reads to CONFIG_ADDRESS,the bridge must return 
the
data in CONFIG_ADDRESS. Any other types of accesses to this 
address(non-DWORD)
have no effect on CONFIG_ADDRESS and are excuted as normal I/O transaction 
on PCI bus......"

CONFIG_ADDRESS = 0xcf8
CONFIG_data = 0xcfc

so , I wonder why need "outb (0x01, 0xCFB);" if check configuration type 1 ? 
and why "outb (0x00, 0xCFB);" if check configuration type 2?

  please help me, thanks a lot.


406 static struct pci_ops * __devinit pci_check_direct(void)
407 {
408         unsigned int tmp;
409         unsigned long flags;
410
411         __save_flags(flags); __cli();
412
413         /*
414          * Check if configuration type 1 works.
415          */
416         if (pci_probe & PCI_PROBE_CONF1) {
417                 outb (0x01, 0xCFB);  <<<=========
418                 tmp = inl (0xCF8);
419                 outl (0x80000000, 0xCF8);
420                 if (inl (0xCF8) == 0x80000000 &&
421                     pci_sanity_check(&pci_direct_conf1)) {
422                         outl (tmp, 0xCF8);
423                         __restore_flags(flags);
424                         printk(KERN_INFO "PCI: Using configuration type 
1\n");
425                         request_region(0xCF8, 8, "PCI conf1");
426                         return &pci_direct_conf1;
427                 }
428                 outl (tmp, 0xCF8);
429         }
430
431         /*
432          * Check if configuration type 2 works.
433          */
434         if (pci_probe & PCI_PROBE_CONF2) {
435                 outb (0x00, 0xCFB);   <<<=========
436                 outb (0x00, 0xCF8);
437                 outb (0x00, 0xCFA);
438                 if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
439                     pci_sanity_check(&pci_direct_conf2)) {
440                         __restore_flags(flags);
441                         printk(KERN_INFO "PCI: Using configuration type 
2\n");
442                         request_region(0xCF8, 4, "PCI conf2");
443                         return &pci_direct_conf2;
444                 }
445         }
446
447         __restore_flags(flags);
448         return NULL;
449 }
450
451 #endif





_________________________________________________________________
Help STOP SPAM: Try the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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

* Re: please help me understand a line code about pci
  2003-01-04 11:59 please help me understand a line code about pci fretre lewis
@ 2003-01-04 12:14 ` John Bradford
  2003-01-04 20:54   ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: John Bradford @ 2003-01-04 12:14 UTC (permalink / raw)
  To: fretre lewis; +Cc: linux-kernel

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

>   I am reading code about pci, and I can't understand some lines in
> pci_check_direct(), in arch/i386/kernel/pci-pc.c
> 
> the PCI spec v2.0 say: ( page32)
> 
> "Anytime a host bridge sees a full DWORD I/O write from the host to
> CONFIG_ADDRESS, the bridge must latch the data into its CONFIG_ADDRESS
> register. On full DWORD I/O reads to CONFIG_ADDRESS,the bridge must return 
> the
> data in CONFIG_ADDRESS. Any other types of accesses to this 
> address(non-DWORD)
> have no effect on CONFIG_ADDRESS and are excuted as normal I/O transaction 
> on PCI bus......"
> 
> CONFIG_ADDRESS = 0xcf8
> CONFIG_data = 0xcfc
> 
> so , I wonder why need "outb (0x01, 0xCFB);" if check configuration type 1 ? 
> and why "outb (0x00, 0xCFB);" if check configuration type 2?

It looks to me like a workaround for broken hardware, but I could be
wrong.

Incidently, wouldn't it be worth printing some debugging info, such as
the values read from 0xCF8 and 0xCFA, when neither configuration type
works?  I've attached an, (untested), patch to do so.

John.

[-- Attachment #2: ASCII text --]
[-- Type: text/plain, Size: 816 bytes --]

--- pci-pc.c.orig	2003-01-04 12:09:35.000000000 +0000
+++ pci-pc.c	2003-01-04 12:12:37.000000000 +0000
@@ -459,6 +459,8 @@
 {
 	unsigned int tmp;
 	unsigned long flags;
+	unsigned int foo;
+	unsigned int bar;
 
 	__save_flags(flags); __cli();
 
@@ -493,13 +495,17 @@
 		outb (0x00, 0xCFB);
 		outb (0x00, 0xCF8);
 		outb (0x00, 0xCFA);
-		if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
+		foo = inb (0xCF8);
+		bar = inb (0xCFA);
+		if (foo == 0x00 && bar == 0x00 &&
 		    pci_sanity_check(&pci_direct_conf2)) {
 			__restore_flags(flags);
 			printk(KERN_INFO "PCI: Using configuration type 2\n");
 			request_region(0xCF8, 4, "PCI conf2");
 			return &pci_direct_conf2;
 		}
+	printk ((KERN_INFO, "PCI: Failed to use configuration type 1 or 2.
+0xCF8:%x 0xCFA:%x\n", foo, bar);
 	}
 
 	__restore_flags(flags);

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

* Re: please help me understand a line code about pci
  2003-01-04 12:14 ` John Bradford
@ 2003-01-04 20:54   ` Alan Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2003-01-04 20:54 UTC (permalink / raw)
  To: John Bradford; +Cc: fretre lewis, Linux Kernel Mailing List

On Sat, 2003-01-04 at 12:14, John Bradford wrote:
> Incidently, wouldn't it be worth printing some debugging info, such as
> the values read from 0xCF8 and 0xCFA, when neither configuration type
> works?  I've attached an, (untested), patch to do so.

That just indicates a system using a non standard conf type - thats
perfectly reasonable.



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

end of thread, other threads:[~2003-01-04 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-04 11:59 please help me understand a line code about pci fretre lewis
2003-01-04 12:14 ` John Bradford
2003-01-04 20:54   ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2003-01-04  7:24 fretre lewis

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