Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Hunting the ahc boot-time panic



On Wed, 19 Oct 2011, Michael wrote:

printf("%s: %d\n", __func__, __LINE__);

Thanks.  I knew there were macros/features that would report function
and line (and __FILE__ IIRC?), but I couldn't remember their syntax.

- is AHC_ALLOW_MEMIO defined?

If the preprocessor is playing fair, this is defined for any non-i386
target:

     70 /* XXXX some i386 on-board chips act weird when memory-mapped */
     71 #ifndef __i386__
     72 #define AHC_ALLOW_MEMIO
     73 #endif

- does ioh_valid contain something non-zero?

I put printfs inside the guarded code segments, etc.:

[...]
    818         ioh_valid = 0;
    819
    820 #ifdef AHC_ALLOW_MEMIO
    821 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    822         memh_valid = 0;
    823         memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AHC_PCI_MEMADDR
    823 );
    824         switch (memtype) {
    825         case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
    826         case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
    827                 memh_valid = (pci_mapreg_map(pa, AHC_PCI_MEMADDR,
    828                                              memtype, 0, &memt, &memh, N
    828 ULL, NULL) == 0);
    829                 break;
    830         default:
    831                 memh_valid = 0;
    832         }
    833 #endif
    834         ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
    835                                     PCI_MAPREG_TYPE_IO, 0, &iot,
    836                                     &ioh, NULL, NULL) == 0);
    837 #if 1
    838         printf("%s: bus info: memt 0x%lx, memh 0x%lx, iot 0x%lx, ioh 0x%
    838 lx\n",
    839             ahc_name(ahc), (u_long)memt, (u_long)memh, (u_long)iot,
    840             (u_long)ioh);
    841         printf("%s: bus info: csr 0x%lx\n", ahc_name(ahc), (u_long)comma
    841 nd);
    842 #endif
    843 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    844         if (ioh_valid) {
    845                 st = iot;
    846                 sh = ioh;
    847 #ifdef AHC_ALLOW_MEMIO
    848 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    849         } else if (memh_valid) {
    850                 st = memt;
    851                 sh = memh;
    852 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    853 #endif
    854         } else {
    855                 printf(": unable to map registers\n");
    856 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    857                 return;
    858         }
    859         ahc->tag = st;
    860         ahc->bsh = sh;
    861
    862         ahc->chip |= AHC_PCI;
    863         /*
    864          * Before we continue probing the card, ensure that
    865          * its interrupts are *disabled*.  We don't want
    866          * a misstep to hang the machine in an interrupt
    867          * storm.
    868          */
    869 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
    870         ahc_intr_enable(ahc, FALSE);
    871 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
[...]

I couldn't capture enough message buffer from a userconf boot, but my
printf()s fire at lines 821, 843, 848, and 869.

This would indicate that yes, AHC_ALLOW_MEMIO is defined, and that yes,
ioh_valid is non-zero.

I did likewise with ".../src/sys/dev/ic/aic7xxx.c", where
"ahc_intr_enable()" is defined:

[...]
   4899 void
   4900 ahc_intr_enable(struct ahc_softc *ahc, int enable)
   4901 {
   4902         u_int hcntrl;
   4903
   4904 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
   4905         hcntrl = ahc_inb(ahc, HCNTRL);
   4906 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
   4907         hcntrl &= ~INTEN;
   4908         ahc->pause &= ~INTEN;
   4909         ahc->unpause &= ~INTEN;
   4910         if (enable) {
   4911                 hcntrl |= INTEN;
   4912                 ahc->pause |= INTEN;
   4913                 ahc->unpause |= INTEN;
   4914         }
   4915 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
   4916         ahc_outb(ahc, HCNTRL, hcntrl);
   4917 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
   4918 }
[...]

The one printf at line 4904 fired and then came the panic:

[...]
trap: pid 0.1 (system): kernel MCHK trap @ 0x101990 (SRR1=0x41030)
panic: trap
Stoped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x10:        lwz     r0, 
0x14(r1)
at panic+0x25c
at trap+0x100
kernel MCHK trap by bsr1+0x4: srr1=0x41030
r1=0x957550 cr=0x24022044 xer=0x20000000 ctr=0x10198c
at ahc_intr_enable+0x54
at ahc_pci_attach+0x2e4
[...]

And from the debugger:

(gdb) list *(ahc_intr_enable+0x54)
0x1281ec is in ahc_intr_enable (/d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4904).
4899    void
4900    ahc_intr_enable(struct ahc_softc *ahc, int enable)
4901    {
4902            u_int hcntrl;
4903 4904 printf("%s():\n %s:%d\n", __func__, __FILE__, __LINE__);
4905            hcntrl = ahc_inb(ahc, HCNTRL);
4906    printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
4907            hcntrl &= ~INTEN;
4908            ahc->pause &= ~INTEN;

[snip]
will try those things later...

So, maybe ahc should ignore IO BARs that contain NULL? Or prefer MMIO
whenever available?
An easy test would be to always set ioh_valid to 0 and see if things
work with that.

Bingo!  Inserting a couple of lines:

[...]
    843 /* force to zero to see if panic is due to umapped/mismapped IOBAR */
    844 ioh_valid = 0;
    845 printf("%s():\n  %s:%d\n", __func__, __FILE__, __LINE__);
846 if (ioh_valid) { [...]

and ahc attaches without problems.  Excerpt from dmesg with extra
printf()s:

[...]
ppb0 at pci1 dev 13 function 0: Digital Equipment DC21154 PCI-PCI Bridge (rev. 
0x05)
pci2 at ppb0 bus 1
pci2: i/o space, memory space enabled
ahc0 at pci2 dev 2 function 0: Adaptec 2902/04/10/15/20/30C SCSI adapter
ahc_pci_attach():
  /d0/nbsd/current/src/sys/dev/pci/ahc_pci.c:821
ahc0: bus info: memt 0xd4722c80, memh 0x80083000, iot 0xd4722bf8, ioh 0xf2000000
ahc0: bus info: csr 0x2900016
ahc_pci_attach():
  /d0/nbsd/current/src/sys/dev/pci/ahc_pci.c:845
ahc_pci_attach():
  /d0/nbsd/current/src/sys/dev/pci/ahc_pci.c:854
ahc_pci_attach():
  /d0/nbsd/current/src/sys/dev/pci/ahc_pci.c:871
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4904
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4906
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4915
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4917
ahc_pci_attach():
  /d0/nbsd/current/src/sys/dev/pci/ahc_pci.c:873
genppc_pci_intr_map: pin: 3, line: 52
ahc0: interrupting at irq 52
ahc0: aic7850: Ultra Single Channel A, SCSI Id=7, 3/253 SCBs
scsibus0 at ahc0: 8 targets, 8 luns per target
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4904
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4906
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4915
ahc_intr_enable():
  /d0/nbsd/current/src/sys/dev/ic/aic7xxx.c:4917
[...]

I'll try building an up-to-the-minute HEAD kernel with this quick hack
to see if there are other issues with which to contend.

--
|/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
|\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
| X  No HTML/proprietary data in email.   BSD just sits there and works!
|/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645


Home | Main Index | Thread Index | Old Index