linux-bk/arch/alpha/kernel/core_cia.c
<<
>>
Prefs
   1/*
   2 *      linux/arch/alpha/kernel/core_cia.c
   3 *
   4 * Written by David A Rusling (david.rusling@reo.mts.dec.com).
   5 * December 1995.
   6 *
   7 *      Copyright (C) 1995  David A Rusling
   8 *      Copyright (C) 1997, 1998  Jay Estabrook
   9 *      Copyright (C) 1998, 1999, 2000  Richard Henderson
  10 *
  11 * Code common to all CIA core logic chips.
  12 */
  13
  14#include <linux/kernel.h>
  15#include <linux/types.h>
  16#include <linux/pci.h>
  17#include <linux/sched.h>
  18#include <linux/init.h>
  19
  20#include <asm/system.h>
  21#include <asm/ptrace.h>
  22#include <asm/hwrpb.h>
  23
  24#define __EXTERN_INLINE inline
  25#include <asm/io.h>
  26#include <asm/core_cia.h>
  27#undef __EXTERN_INLINE
  28
  29#include <linux/bootmem.h>
  30
  31#include "proto.h"
  32#include "pci_impl.h"
  33
  34
  35/*
  36 * NOTE: Herein lie back-to-back mb instructions.  They are magic. 
  37 * One plausible explanation is that the i/o controller does not properly
  38 * handle the system transaction.  Another involves timing.  Ho hum.
  39 */
  40
  41#define DEBUG_CONFIG 0
  42#if DEBUG_CONFIG
  43# define DBGC(args)     printk args
  44#else
  45# define DBGC(args)
  46#endif
  47
  48#define vip     volatile int  *
  49
  50/*
  51 * Given a bus, device, and function number, compute resulting
  52 * configuration space address.  It is therefore not safe to have
  53 * concurrent invocations to configuration space access routines, but
  54 * there really shouldn't be any need for this.
  55 *
  56 * Type 0:
  57 *
  58 *  3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 
  59 *  3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  61 * | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0|
  62 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  63 *
  64 *      31:11   Device select bit.
  65 *      10:8    Function number
  66 *       7:2    Register number
  67 *
  68 * Type 1:
  69 *
  70 *  3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 
  71 *  3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  73 * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  75 *
  76 *      31:24   reserved
  77 *      23:16   bus number (8 bits = 128 possible buses)
  78 *      15:11   Device number (5 bits)
  79 *      10:8    function number
  80 *       7:2    register number
  81 *  
  82 * Notes:
  83 *      The function number selects which function of a multi-function device 
  84 *      (e.g., SCSI and Ethernet).
  85 * 
  86 *      The register selects a DWORD (32 bit) register offset.  Hence it
  87 *      doesn't get shifted by 2 bits as we want to "drop" the bottom two
  88 *      bits.
  89 */
  90
  91static int
  92mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr,
  93             unsigned char *type1)
  94{
  95        u8 bus = dev->bus->number;
  96        u8 device_fn = dev->devfn;
  97
  98        *type1 = (bus != 0);
  99        *pci_addr = (bus << 16) | (device_fn << 8) | where;
 100
 101        DBGC(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
 102              " returning address 0x%p\n"
 103              bus, device_fn, where, *pci_addr));
 104
 105        return 0;
 106}
 107
 108static unsigned int
 109conf_read(unsigned long addr, unsigned char type1)
 110{
 111        unsigned long flags;
 112        int stat0, value;
 113        int cia_cfg = 0;
 114
 115        DBGC(("conf_read(addr=0x%lx, type1=%d) ", addr, type1));
 116        local_irq_save(flags);
 117
 118        /* Reset status register to avoid losing errors.  */
 119        stat0 = *(vip)CIA_IOC_CIA_ERR;
 120        *(vip)CIA_IOC_CIA_ERR = stat0;
 121        mb();
 122        *(vip)CIA_IOC_CIA_ERR; /* re-read to force write */
 123
 124        /* If Type1 access, must set CIA CFG. */
 125        if (type1) {
 126                cia_cfg = *(vip)CIA_IOC_CFG;
 127                *(vip)CIA_IOC_CFG = (cia_cfg & ~3) | 1;
 128                mb();
 129                *(vip)CIA_IOC_CFG;
 130        }
 131
 132        mb();
 133        draina();
 134        mcheck_expected(0) = 1;
 135        mcheck_taken(0) = 0;
 136        mb();
 137
 138        /* Access configuration space.  */
 139        value = *(vip)addr;
 140        mb();
 141        mb();  /* magic */
 142        if (mcheck_taken(0)) {
 143                mcheck_taken(0) = 0;
 144                value = 0xffffffff;
 145                mb();
 146        }
 147        mcheck_expected(0) = 0;
 148        mb();
 149
 150        /* If Type1 access, must reset IOC CFG so normal IO space ops work.  */
 151        if (type1) {
 152                *(vip)CIA_IOC_CFG = cia_cfg;
 153                mb();
 154                *(vip)CIA_IOC_CFG;
 155        }
 156
 157        local_irq_restore(flags);
 158        DBGC(("done\n"));
 159
 160        return value;
 161}
 162
 163static void
 164conf_write(unsigned long addr, unsigned int value, unsigned char type1)
 165{
 166        unsigned long flags;
 167        int stat0, cia_cfg = 0;
 168
 169        DBGC(("conf_write(addr=0x%lx, type1=%d) ", addr, type1));
 170        local_irq_save(flags);
 171
 172        /* Reset status register to avoid losing errors.  */
 173        stat0 = *(vip)CIA_IOC_CIA_ERR;
 174        *(vip)CIA_IOC_CIA_ERR = stat0;
 175        mb();
 176        *(vip)CIA_IOC_CIA_ERR; /* re-read to force write */
 177
 178        /* If Type1 access, must set CIA CFG.  */
 179        if (type1) {
 180                cia_cfg = *(vip)CIA_IOC_CFG;
 181                *(vip)CIA_IOC_CFG = (cia_cfg & ~3) | 1;
 182                mb();
 183                *(vip)CIA_IOC_CFG;
 184        }
 185
 186        mb();
 187        draina();
 188        mcheck_expected(0) = 1;
 189        mcheck_taken(0) = 0;
 190        mb();
 191
 192        /* Access configuration space.  */
 193        *(vip)addr = value;
 194        mb();
 195        *(vip)addr; /* read back to force the write */
 196
 197        mcheck_expected(0) = 0;
 198        mb();
 199
 200        /* If Type1 access, must reset IOC CFG so normal IO space ops work.  */
 201        if (type1) {
 202                *(vip)CIA_IOC_CFG = cia_cfg;
 203                mb();
 204                *(vip)CIA_IOC_CFG;
 205        }
 206
 207        local_irq_restore(flags);
 208        DBGC(("done\n"));
 209}
 210
 211static int
 212cia_read_config_byte(struct pci_dev *dev, int where, u8 *value)
 213{
 214        unsigned long addr, pci_addr;
 215        unsigned char type1;
 216
 217        if (mk_conf_addr(dev, where, &pci_addr, &type1))
 218                return PCIBIOS_DEVICE_NOT_FOUND;
 219
 220        addr = (pci_addr << 5) + 0x00 + CIA_CONF;
 221        *value = conf_read(addr, type1) >> ((where & 3) * 8);
 222        return PCIBIOS_SUCCESSFUL;
 223}
 224
 225static int 
 226cia_read_config_word(struct pci_dev *dev, int where, u16 *value)
 227{
 228        unsigned long addr, pci_addr;
 229        unsigned char type1;
 230
 231        if (mk_conf_addr(dev, where, &pci_addr, &type1))
 232                return PCIBIOS_DEVICE_NOT_FOUND;
 233
 234        addr = (pci_addr << 5) + 0x08 + CIA_CONF;
 235        *value = conf_read(addr, type1) >> ((where & 3) * 8);
 236        return PCIBIOS_SUCCESSFUL;
 237}
 238
 239static int 
 240cia_read_config_dword(struct pci_dev *dev, int where, u32 *value)
 241{
 242        unsigned long addr, pci_addr;
 243        unsigned char type1;
 244
 245        if (mk_conf_addr(dev, where, &pci_addr, &type1))
 246                return PCIBIOS_DEVICE_NOT_FOUND;
 247
 248        addr = (pci_addr << 5) + 0x18 + CIA_CONF;
 249        *value = conf_read(addr, type1);
 250        return PCIBIOS_SUCCESSFUL;
 251}
 252
 253static int 
 254cia_write_config(struct pci_dev *dev, int where, u32 value, long mask)
 255{
 256        unsigned long addr, pci_addr;
 257        unsigned char type1;
 258
 259        if (mk_conf_addr(dev, where, &pci_addr, &type1))
 260                return PCIBIOS_DEVICE_NOT_FOUND;
 261
 262        addr = (pci_addr << 5) + mask + CIA_CONF;
 263        conf_write(addr, value << ((where & 3) * 8), type1);
 264        return PCIBIOS_SUCCESSFUL;
 265}
 266
 267static int
 268cia_write_config_byte(struct pci_dev *dev, int where, u8 value)
 269{
 270        return cia_write_config(dev, where, value, 0x00);
 271}
 272
 273static int 
 274cia_write_config_word(struct pci_dev *dev, int where, u16 value)
 275{
 276        return cia_write_config(dev, where, value, 0x08);
 277}
 278
 279static int 
 280cia_write_config_dword(struct pci_dev *dev, int where, u32 value)
 281{
 282        return cia_write_config(dev, where, value, 0x18);
 283}
 284
 285struct pci_ops cia_pci_ops = 
 286{
 287        read_byte:      cia_read_config_byte,
 288        read_word:      cia_read_config_word,
 289        read_dword:     cia_read_config_dword,
 290        write_byte:     cia_write_config_byte,
 291        write_word:     cia_write_config_word,
 292        write_dword:    cia_write_config_dword
 293};
 294
 295/*
 296 * CIA Pass 1 and PYXIS Pass 1 and 2 have a broken scatter-gather tlb.
 297 * It cannot be invalidated.  Rather than hard code the pass numbers,
 298 * actually try the tbia to see if it works.
 299 */
 300
 301void
 302cia_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end)
 303{
 304        wmb();
 305        *(vip)CIA_IOC_PCI_TBIA = 3;     /* Flush all locked and unlocked.  */
 306        mb();
 307        *(vip)CIA_IOC_PCI_TBIA;
 308}
 309
 310/*
 311 * On PYXIS, even if the tbia works, we cannot use it. It effectively locks
 312 * the chip (as well as direct write to the tag registers) if there is a
 313 * SG DMA operation in progress. This is true at least for PYXIS rev. 1,
 314 * so always use the method below.
 315 */
 316/*
 317 * This is the method NT and NetBSD use.
 318 *
 319 * Allocate mappings, and put the chip into DMA loopback mode to read a
 320 * garbage page.  This works by causing TLB misses, causing old entries to
 321 * be purged to make room for the new entries coming in for the garbage page.
 322 */
 323
 324#define CIA_BROKEN_TBIA_BASE    0x30000000
 325#define CIA_BROKEN_TBIA_SIZE    1024
 326
 327/* Always called with interrupts disabled */
 328void
 329cia_pci_tbi_try2(struct pci_controller *hose,
 330                 dma_addr_t start, dma_addr_t end)
 331{
 332        unsigned long bus_addr;
 333        int ctrl;
 334
 335        /* Put the chip into PCI loopback mode.  */
 336        mb();
 337        ctrl = *(vip)CIA_IOC_CIA_CTRL;
 338        *(vip)CIA_IOC_CIA_CTRL = ctrl | CIA_CTRL_PCI_LOOP_EN;
 339        mb();
 340        *(vip)CIA_IOC_CIA_CTRL;
 341        mb();
 342
 343        /* Read from PCI dense memory space at TBI_ADDR, skipping 32k on
 344           each read.  This forces SG TLB misses.  NetBSD claims that the
 345           TLB entries are not quite LRU, meaning that we need to read more
 346           times than there are actual tags.  The 2117x docs claim strict
 347           round-robin.  Oh well, we've come this far...  */
 348        /* Even better - as seen on the PYXIS rev 1 the TLB tags 0-3 can
 349           be filled by the TLB misses *only once* after being invalidated
 350           (by tbia or direct write). Next misses won't update them even
 351           though the lock bits are cleared. Tags 4-7 are "quite LRU" though,
 352           so use them and read at window 3 base exactly 4 times. Reading
 353           more sometimes makes the chip crazy.  -ink */
 354
 355        bus_addr = cia_ioremap(CIA_BROKEN_TBIA_BASE, 32768 * 4);
 356
 357        cia_readl(bus_addr + 0x00000);
 358        cia_readl(bus_addr + 0x08000);
 359        cia_readl(bus_addr + 0x10000);
 360        cia_readl(bus_addr + 0x18000);
 361
 362        cia_iounmap(bus_addr);
 363
 364        /* Restore normal PCI operation.  */
 365        mb();
 366        *(vip)CIA_IOC_CIA_CTRL = ctrl;
 367        mb();
 368        *(vip)CIA_IOC_CIA_CTRL;
 369        mb();
 370}
 371
 372static inline void
 373cia_prepare_tbia_workaround(void)
 374{
 375        unsigned long *ppte, pte;
 376        long i;
 377
 378        /* Use minimal 1K map. */
 379        ppte = __alloc_bootmem(CIA_BROKEN_TBIA_SIZE, 32768, 0);
 380        pte = (virt_to_phys(ppte) >> (PAGE_SHIFT - 1)) | 1;
 381
 382        for (i = 0; i < CIA_BROKEN_TBIA_SIZE / sizeof(unsigned long); ++i)
 383                ppte[i] = pte;
 384
 385        *(vip)CIA_IOC_PCI_W1_BASE = CIA_BROKEN_TBIA_BASE | 3;
 386        *(vip)CIA_IOC_PCI_W1_MASK = (CIA_BROKEN_TBIA_SIZE*1024 - 1)
 387                                    & 0xfff00000;
 388        *(vip)CIA_IOC_PCI_T1_BASE = virt_to_phys(ppte) >> 2;
 389}
 390
 391static void __init
 392verify_tb_operation(void)
 393{
 394        static int page[PAGE_SIZE/4]
 395                __attribute__((aligned(PAGE_SIZE)))
 396                __initdata = { 0 };
 397
 398        struct pci_iommu_arena *arena = pci_isa_hose->sg_isa;
 399        int ctrl, addr0, tag0, pte0, data0;
 400        int temp, use_tbia_try2 = 0;
 401        unsigned long bus_addr;
 402
 403        /* pyxis -- tbia is broken */
 404        if (pci_isa_hose->dense_io_base)
 405                use_tbia_try2 = 1;
 406
 407        /* Put the chip into PCI loopback mode.  */
 408        mb();
 409        ctrl = *(vip)CIA_IOC_CIA_CTRL;
 410        *(vip)CIA_IOC_CIA_CTRL = ctrl | CIA_CTRL_PCI_LOOP_EN;
 411        mb();
 412        *(vip)CIA_IOC_CIA_CTRL;
 413        mb();
 414
 415        /* Write a valid entry directly into the TLB registers.  */
 416
 417        addr0 = arena->dma_base;
 418        tag0 = addr0 | 1;
 419        pte0 = (virt_to_phys(page) >> (PAGE_SHIFT - 1)) | 1;
 420
 421        *(vip)CIA_IOC_TB_TAGn(0) = tag0;
 422        *(vip)CIA_IOC_TB_TAGn(1) = 0;
 423        *(vip)CIA_IOC_TB_TAGn(2) = 0;
 424        *(vip)CIA_IOC_TB_TAGn(3) = 0;
 425        *(vip)CIA_IOC_TB_TAGn(4) = 0;
 426        *(vip)CIA_IOC_TB_TAGn(5) = 0;
 427        *(vip)CIA_IOC_TB_TAGn(6) = 0;
 428        *(vip)CIA_IOC_TB_TAGn(7) = 0;
 429        *(vip)CIA_IOC_TBn_PAGEm(0,0) = pte0;
 430        *(vip)CIA_IOC_TBn_PAGEm(0,1) = 0;
 431        *(vip)CIA_IOC_TBn_PAGEm(0,2) = 0;
 432        *(vip)CIA_IOC_TBn_PAGEm(0,3) = 0;
 433        mb();
 434
 435        /* Get a usable bus address */
 436        bus_addr = cia_ioremap(addr0, 8*PAGE_SIZE);
 437
 438        /* First, verify we can read back what we've written.  If
 439           this fails, we can't be sure of any of the other testing
 440           we're going to do, so bail.  */
 441        /* ??? Actually, we could do the work with machine checks.
 442           By passing this register update test, we pretty much
 443           guarantee that cia_pci_tbi_try1 works.  If this test
 444           fails, cia_pci_tbi_try2 might still work.  */
 445
 446        temp = *(vip)CIA_IOC_TB_TAGn(0);
 447        if (temp != tag0) {
 448                printk("pci: failed tb register update test "
 449                       "(tag0 %#x != %#x)\n", temp, tag0);
 450                goto failed;
 451        }
 452        temp = *(vip)CIA_IOC_TB_TAGn(1);
 453        if (temp != 0) {
 454                printk("pci: failed tb register update test "
 455                       "(tag1 %#x != 0)\n", temp);
 456                goto failed;
 457        }
 458        temp = *(vip)CIA_IOC_TBn_PAGEm(0,0);
 459        if (temp != pte0) {
 460                printk("pci: failed tb register update test "
 461                       "(pte0 %#x != %#x)\n", temp, pte0);
 462                goto failed;
 463        }
 464        printk("pci: passed tb register update test\n");
 465
 466        /* Second, verify we can actually do I/O through this entry.  */
 467
 468        data0 = 0xdeadbeef;
 469        page[0] = data0;
 470        mcheck_expected(0) = 1;
 471        mcheck_taken(0) = 0;
 472        mb();
 473        temp = cia_readl(bus_addr);
 474        mb();
 475        mcheck_expected(0) = 0;
 476        mb();
 477        if (mcheck_taken(0)) {
 478                printk("pci: failed sg loopback i/o read test (mcheck)\n");
 479                goto failed;
 480        }
 481        if (temp != data0) {
 482                printk("pci: failed sg loopback i/o read test "
 483                       "(%#x != %#x)\n", temp, data0);
 484                goto failed;
 485        }
 486        printk("pci: passed sg loopback i/o read test\n");
 487
 488        /* Third, try to invalidate the TLB.  */
 489
 490        if (! use_tbia_try2) {
 491                cia_pci_tbi(arena->hose, 0, -1);
 492                temp = *(vip)CIA_IOC_TB_TAGn(0);
 493                if (temp & 1) {
 494                        use_tbia_try2 = 1;
 495                        printk("pci: failed tbia test; workaround available\n");
 496                } else {
 497                        printk("pci: passed tbia test\n");
 498                }
 499        }
 500
 501        /* Fourth, verify the TLB snoops the EV5's caches when
 502           doing a tlb fill.  */
 503
 504        data0 = 0x5adda15e;
 505        page[0] = data0;
 506        arena->ptes[4] = pte0;
 507        mcheck_expected(0) = 1;
 508        mcheck_taken(0) = 0;
 509        mb();
 510        temp = cia_readl(bus_addr + 4*PAGE_SIZE);
 511        mb();
 512        mcheck_expected(0) = 0;
 513        mb();
 514        if (mcheck_taken(0)) {
 515                printk("pci: failed pte write cache snoop test (mcheck)\n");
 516                goto failed;
 517        }
 518        if (temp != data0) {
 519                printk("pci: failed pte write cache snoop test "
 520                       "(%#x != %#x)\n", temp, data0);
 521                goto failed;
 522        }
 523        printk("pci: passed pte write cache snoop test\n");
 524
 525        /* Fifth, verify that a previously invalid PTE entry gets
 526           filled from the page table.  */
 527
 528        data0 = 0xabcdef12;
 529        page[0] = data0;
 530        arena->ptes[5] = pte0;
 531        mcheck_expected(0) = 1;
 532        mcheck_taken(0) = 0;
 533        mb();
 534        temp = cia_readl(bus_addr + 5*PAGE_SIZE);
 535        mb();
 536        mcheck_expected(0) = 0;
 537        mb();
 538        if (mcheck_taken(0)) {
 539                printk("pci: failed valid tag invalid pte reload test "
 540                       "(mcheck; workaround available)\n");
 541                /* Work around this bug by aligning new allocations
 542                   on 4 page boundaries.  */
 543                arena->align_entry = 4;
 544        } else if (temp != data0) {
 545                printk("pci: failed valid tag invalid pte reload test "
 546                       "(%#x != %#x)\n", temp, data0);
 547                goto failed;
 548        } else {
 549                printk("pci: passed valid tag invalid pte reload test\n");
 550        }
 551
 552        /* Sixth, verify machine checks are working.  Test invalid
 553           pte under the same valid tag as we used above.  */
 554
 555        mcheck_expected(0) = 1;
 556        mcheck_taken(0) = 0;
 557        mb();
 558        temp = cia_readl(bus_addr + 6*PAGE_SIZE);
 559        mb();
 560        mcheck_expected(0) = 0;
 561        mb();
 562        printk("pci: %s pci machine check test\n",
 563               mcheck_taken(0) ? "passed" : "failed");
 564
 565        /* Clean up after the tests.  */
 566        arena->ptes[4] = 0;
 567        arena->ptes[5] = 0;
 568
 569        if (use_tbia_try2) {
 570                alpha_mv.mv_pci_tbi = cia_pci_tbi_try2;
 571
 572                /* Tags 0-3 must be disabled if we use this workaraund. */
 573                wmb();
 574                *(vip)CIA_IOC_TB_TAGn(0) = 2;
 575                *(vip)CIA_IOC_TB_TAGn(1) = 2;
 576                *(vip)CIA_IOC_TB_TAGn(2) = 2;
 577                *(vip)CIA_IOC_TB_TAGn(3) = 2;
 578
 579                printk("pci: tbia workaround enabled\n");
 580        }
 581        alpha_mv.mv_pci_tbi(arena->hose, 0, -1);
 582
 583exit:
 584        /* unmap the bus addr */
 585        cia_iounmap(bus_addr);
 586
 587        /* Restore normal PCI operation.  */
 588        mb();
 589        *(vip)CIA_IOC_CIA_CTRL = ctrl;
 590        mb();
 591        *(vip)CIA_IOC_CIA_CTRL;
 592        mb();
 593        return;
 594
 595failed:
 596        printk("pci: disabling sg translation window\n");
 597        *(vip)CIA_IOC_PCI_W0_BASE = 0;
 598        *(vip)CIA_IOC_PCI_W1_BASE = 0;
 599        pci_isa_hose->sg_isa = NULL;
 600        alpha_mv.mv_pci_tbi = NULL;
 601        goto exit;
 602}
 603
 604static void __init
 605do_init_arch(int is_pyxis)
 606{
 607        struct pci_controller *hose;
 608        int temp;
 609        int cia_rev;
 610
 611        cia_rev = *(vip)CIA_IOC_CIA_REV & CIA_REV_MASK;
 612        printk("pci: cia revision %d%s\n",
 613               cia_rev, is_pyxis ? " (pyxis)" : "");
 614
 615        /* Set up error reporting.  */
 616        temp = *(vip)CIA_IOC_ERR_MASK;
 617        temp &= ~(CIA_ERR_CPU_PE | CIA_ERR_MEM_NEM | CIA_ERR_PA_PTE_INV
 618                  | CIA_ERR_RCVD_MAS_ABT | CIA_ERR_RCVD_TAR_ABT);
 619        *(vip)CIA_IOC_ERR_MASK = temp;
 620
 621        /* Clear all currently pending errors.  */
 622        temp = *(vip)CIA_IOC_CIA_ERR;
 623        *(vip)CIA_IOC_CIA_ERR = temp;
 624
 625        /* Turn on mchecks.  */
 626        temp = *(vip)CIA_IOC_CIA_CTRL;
 627        temp |= CIA_CTRL_FILL_ERR_EN | CIA_CTRL_MCHK_ERR_EN;
 628        *(vip)CIA_IOC_CIA_CTRL = temp;
 629
 630        /* Clear the CFG register, which gets used for PCI config space
 631           accesses.  That is the way we want to use it, and we do not
 632           want to depend on what ARC or SRM might have left behind.  */
 633        *(vip)CIA_IOC_CFG = 0;
 634 
 635        /* Zero the HAEs.  */
 636        *(vip)CIA_IOC_HAE_MEM = 0;
 637        *(vip)CIA_IOC_HAE_IO = 0;
 638
 639        /* For PYXIS, we always use BWX bus and i/o accesses.  To that end,
 640           make sure they're enabled on the controller.  At the same time,
 641           enable the monster window.  */
 642        if (is_pyxis) {
 643                temp = *(vip)CIA_IOC_CIA_CNFG;
 644                temp |= CIA_CNFG_IOA_BWEN | CIA_CNFG_PCI_MWEN;
 645                *(vip)CIA_IOC_CIA_CNFG = temp;
 646        }
 647
 648        /* Syncronize with all previous changes.  */
 649        mb();
 650        *(vip)CIA_IOC_CIA_REV;
 651
 652        /*
 653         * Create our single hose.
 654         */
 655
 656        pci_isa_hose = hose = alloc_pci_controller();
 657        hose->io_space = &ioport_resource;
 658        hose->mem_space = &iomem_resource;
 659        hose->index = 0;
 660
 661        if (! is_pyxis) {
 662                struct resource *hae_mem = alloc_resource();
 663                hose->mem_space = hae_mem;
 664
 665                hae_mem->start = 0;
 666                hae_mem->end = CIA_MEM_R1_MASK;
 667                hae_mem->name = pci_hae0_name;
 668                hae_mem->flags = IORESOURCE_MEM;
 669
 670                if (request_resource(&iomem_resource, hae_mem) < 0)
 671                        printk(KERN_ERR "Failed to request HAE_MEM\n");
 672
 673                hose->sparse_mem_base = CIA_SPARSE_MEM - IDENT_ADDR;
 674                hose->dense_mem_base = CIA_DENSE_MEM - IDENT_ADDR;
 675                hose->sparse_io_base = CIA_IO - IDENT_ADDR;
 676                hose->dense_io_base = 0;
 677        } else {
 678                hose->sparse_mem_base = 0;
 679                hose->dense_mem_base = CIA_BW_MEM - IDENT_ADDR;
 680                hose->sparse_io_base = 0;
 681                hose->dense_io_base = CIA_BW_IO - IDENT_ADDR;
 682        }
 683
 684        /*
 685         * Set up the PCI to main memory translation windows.
 686         *
 687         * Window 0 is scatter-gather 8MB at 8MB (for isa)
 688         * Window 1 is scatter-gather 1MB at 768MB (for tbia)
 689         * Window 2 is direct access 2GB at 2GB
 690         * Window 3 is DAC access 4GB at 8GB
 691         *
 692         * ??? NetBSD hints that page tables must be aligned to 32K,
 693         * possibly due to a hardware bug.  This is over-aligned
 694         * from the 8K alignment one would expect for an 8MB window. 
 695         * No description of what revisions affected.
 696         */
 697
 698        hose->sg_pci = NULL;
 699        hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 32768);
 700        __direct_map_base = 0x80000000;
 701        __direct_map_size = 0x80000000;
 702
 703        *(vip)CIA_IOC_PCI_W0_BASE = hose->sg_isa->dma_base | 3;
 704        *(vip)CIA_IOC_PCI_W0_MASK = (hose->sg_isa->size - 1) & 0xfff00000;
 705        *(vip)CIA_IOC_PCI_T0_BASE = virt_to_phys(hose->sg_isa->ptes) >> 2;
 706
 707        *(vip)CIA_IOC_PCI_W2_BASE = __direct_map_base | 1;
 708        *(vip)CIA_IOC_PCI_W2_MASK = (__direct_map_size - 1) & 0xfff00000;
 709        *(vip)CIA_IOC_PCI_T2_BASE = 0 >> 2;
 710
 711        /* On PYXIS we have the monster window, selected by bit 40, so
 712           there is no need for window3 to be enabled.
 713
 714           On CIA, we don't have true arbitrary addressing -- bits <39:32>
 715           are compared against W_DAC.  We can, however, directly map 4GB,
 716           which is better than before.  However, due to assumptions made
 717           elsewhere, we should not claim that we support DAC unless that
 718           4GB covers all of physical memory.  */
 719        if (is_pyxis || max_low_pfn > (0x100000000 >> PAGE_SHIFT)) {
 720                *(vip)CIA_IOC_PCI_W3_BASE = 0;
 721        } else {
 722                *(vip)CIA_IOC_PCI_W3_BASE = 0x00000000 | 1 | 8;
 723                *(vip)CIA_IOC_PCI_W3_MASK = 0xfff00000;
 724                *(vip)CIA_IOC_PCI_T3_BASE = 0 >> 2;
 725
 726                alpha_mv.pci_dac_offset = 0x200000000;
 727                *(vip)CIA_IOC_PCI_W_DAC = alpha_mv.pci_dac_offset >> 32;
 728        }
 729
 730        /* Prepare workaround for apparently broken tbia. */
 731        cia_prepare_tbia_workaround();
 732}
 733
 734void __init
 735cia_init_arch(void)
 736{
 737        do_init_arch(0);
 738}
 739
 740void __init
 741pyxis_init_arch(void)
 742{
 743        /* On pyxis machines we can precisely calculate the
 744           CPU clock frequency using pyxis real time counter.
 745           It's especially useful for SX164 with broken RTC.
 746
 747           Both CPU and chipset are driven by the single 16.666M
 748           or 16.667M crystal oscillator. PYXIS_RT_COUNT clock is
 749           66.66 MHz. -ink */
 750
 751        unsigned int cc0, cc1;
 752        unsigned long pyxis_cc;
 753
 754        __asm__ __volatile__ ("rpcc %0" : "=r"(cc0));
 755        pyxis_cc = *(vulp)PYXIS_RT_COUNT;
 756        do { } while(*(vulp)PYXIS_RT_COUNT - pyxis_cc < 4096);
 757        __asm__ __volatile__ ("rpcc %0" : "=r"(cc1));
 758        cc1 -= cc0;
 759        hwrpb->cycle_freq = ((cc1 >> 11) * 100000000UL) / 3;
 760        hwrpb_update_checksum(hwrpb);
 761
 762        do_init_arch(1);
 763}
 764
 765void __init
 766cia_init_pci(void)
 767{
 768        /* Must delay this from init_arch, as we need machine checks.  */
 769        verify_tb_operation();
 770        common_init_pci();
 771}
 772
 773static inline void
 774cia_pci_clr_err(void)
 775{
 776        int jd;
 777
 778        jd = *(vip)CIA_IOC_CIA_ERR;
 779        *(vip)CIA_IOC_CIA_ERR = jd;
 780        mb();
 781        *(vip)CIA_IOC_CIA_ERR;          /* re-read to force write.  */
 782}
 783
 784static void
 785cia_decode_pci_error(struct el_CIA_sysdata_mcheck *cia, const char *msg)
 786{
 787        static const char * const pci_cmd_desc[16] = {
 788                "Interrupt Acknowledge", "Special Cycle", "I/O Read",
 789                "I/O Write", "Reserved 0x4", "Reserved 0x5", "Memory Read",
 790                "Memory Write", "Reserved 0x8", "Reserved 0x9",
 791                "Configuration Read", "Configuration Write",
 792                "Memory Read Multiple", "Dual Address Cycle",
 793                "Memory Read Line", "Memory Write and Invalidate"
 794        };
 795
 796        if (cia->cia_err & (CIA_ERR_COR_ERR
 797                            | CIA_ERR_UN_COR_ERR
 798                            | CIA_ERR_MEM_NEM
 799                            | CIA_ERR_PA_PTE_INV)) {
 800                static const char * const window_desc[6] = {
 801                        "No window active", "Window 0 hit", "Window 1 hit",
 802                        "Window 2 hit", "Window 3 hit", "Monster window hit"
 803                };
 804
 805                const char *window;
 806                const char *cmd;
 807                unsigned long addr, tmp;
 808                int lock, dac;
 809        
 810                cmd = pci_cmd_desc[cia->pci_err0 & 0x7];
 811                lock = (cia->pci_err0 >> 4) & 1;
 812                dac = (cia->pci_err0 >> 5) & 1;
 813
 814                tmp = (cia->pci_err0 >> 8) & 0x1F;
 815                tmp = ffs(tmp);
 816                window = window_desc[tmp];
 817
 818                addr = cia->pci_err1;
 819                if (dac) {
 820                        tmp = *(vip)CIA_IOC_PCI_W_DAC & 0xFFUL;
 821                        addr |= tmp << 32;
 822                }
 823
 824                printk(KERN_CRIT "CIA machine check: %s\n", msg);
 825                printk(KERN_CRIT "  DMA command: %s\n", cmd);
 826                printk(KERN_CRIT "  PCI address: %#010lx\n", addr);
 827                printk(KERN_CRIT "  %s, Lock: %d, DAC: %d\n",
 828                       window, lock, dac);
 829        } else if (cia->cia_err & (CIA_ERR_PERR
 830                                   | CIA_ERR_PCI_ADDR_PE
 831                                   | CIA_ERR_RCVD_MAS_ABT
 832                                   | CIA_ERR_RCVD_TAR_ABT
 833                                   | CIA_ERR_IOA_TIMEOUT)) {
 834                static const char * const master_st_desc[16] = {
 835                        "Idle", "Drive bus", "Address step cycle",
 836                        "Address cycle", "Data cycle", "Last read data cycle",
 837                        "Last write data cycle", "Read stop cycle",
 838                        "Write stop cycle", "Read turnaround cycle",
 839                        "Write turnaround cycle", "Reserved 0xB",
 840                        "Reserved 0xC", "Reserved 0xD", "Reserved 0xE",
 841                        "Unknown state"
 842                };
 843                static const char * const target_st_desc[16] = {
 844                        "Idle", "Busy", "Read data cycle", "Write data cycle",
 845                        "Read stop cycle", "Write stop cycle",
 846                        "Read turnaround cycle", "Write turnaround cycle",
 847                        "Read wait cycle", "Write wait cycle",
 848                        "Reserved 0xA", "Reserved 0xB", "Reserved 0xC",
 849                        "Reserved 0xD", "Reserved 0xE", "Unknown state"
 850                };
 851
 852                const char *cmd;
 853                const char *master, *target;
 854                unsigned long addr, tmp;
 855                int dac;
 856
 857                master = master_st_desc[(cia->pci_err0 >> 16) & 0xF];
 858                target = target_st_desc[(cia->pci_err0 >> 20) & 0xF];
 859                cmd = pci_cmd_desc[(cia->pci_err0 >> 24) & 0xF];
 860                dac = (cia->pci_err0 >> 28) & 1;
 861
 862                addr = cia->pci_err2;
 863                if (dac) {
 864                        tmp = *(volatile int *)CIA_IOC_PCI_W_DAC & 0xFFUL;
 865                        addr |= tmp << 32;
 866                }
 867
 868                printk(KERN_CRIT "CIA machine check: %s\n", msg);
 869                printk(KERN_CRIT "  PCI command: %s\n", cmd);
 870                printk(KERN_CRIT "  Master state: %s, Target state: %s\n",
 871                       master, target);
 872                printk(KERN_CRIT "  PCI address: %#010lx, DAC: %d\n",
 873                       addr, dac);
 874        } else {
 875                printk(KERN_CRIT "CIA machine check: %s\n", msg);
 876                printk(KERN_CRIT "  Unknown PCI error\n");
 877                printk(KERN_CRIT "  PCI_ERR0 = %#08lx", cia->pci_err0);
 878                printk(KERN_CRIT "  PCI_ERR1 = %#08lx", cia->pci_err1);
 879                printk(KERN_CRIT "  PCI_ERR2 = %#08lx", cia->pci_err2);
 880        }
 881}
 882
 883static void
 884cia_decode_mem_error(struct el_CIA_sysdata_mcheck *cia, const char *msg)
 885{
 886        unsigned long mem_port_addr;
 887        unsigned long mem_port_mask;
 888        const char *mem_port_cmd;
 889        const char *seq_state;
 890        const char *set_select;
 891        unsigned long tmp;
 892
 893        /* If this is a DMA command, also decode the PCI bits.  */
 894        if ((cia->mem_err1 >> 20) & 1)
 895                cia_decode_pci_error(cia, msg);
 896        else
 897                printk(KERN_CRIT "CIA machine check: %s\n", msg);
 898
 899        mem_port_addr = cia->mem_err0 & 0xfffffff0;
 900        mem_port_addr |= (cia->mem_err1 & 0x83UL) << 32;
 901
 902        mem_port_mask = (cia->mem_err1 >> 12) & 0xF;
 903
 904        tmp = (cia->mem_err1 >> 8) & 0xF;
 905        tmp |= ((cia->mem_err1 >> 20) & 1) << 4;
 906        if ((tmp & 0x1E) == 0x06)
 907                mem_port_cmd = "WRITE BLOCK or WRITE BLOCK LOCK";
 908        else if ((tmp & 0x1C) == 0x08)
 909                mem_port_cmd = "READ MISS or READ MISS MODIFY";
 910        else if (tmp == 0x1C)
 911                mem_port_cmd = "BC VICTIM";
 912        else if ((tmp & 0x1E) == 0x0E)
 913                mem_port_cmd = "READ MISS MODIFY";
 914        else if ((tmp & 0x1C) == 0x18)
 915                mem_port_cmd = "DMA READ or DMA READ MODIFY";
 916        else if ((tmp & 0x1E) == 0x12)
 917                mem_port_cmd = "DMA WRITE";
 918        else
 919                mem_port_cmd = "Unknown";
 920
 921        tmp = (cia->mem_err1 >> 16) & 0xF;
 922        switch (tmp) {
 923        case 0x0:
 924                seq_state = "Idle";
 925                break;
 926        case 0x1:
 927                seq_state = "DMA READ or DMA WRITE";
 928                break;
 929        case 0x2: case 0x3:
 930                seq_state = "READ MISS (or READ MISS MODIFY) with victim";
 931                break;
 932        case 0x4: case 0x5: case 0x6:
 933                seq_state = "READ MISS (or READ MISS MODIFY) with no victim";
 934                break;
 935        case 0x8: case 0x9: case 0xB:
 936                seq_state = "Refresh";
 937                break;
 938        case 0xC:
 939                seq_state = "Idle, waiting for DMA pending read";
 940                break;
 941        case 0xE: case 0xF:
 942                seq_state = "Idle, ras precharge";
 943                break;
 944        default:
 945                seq_state = "Unknown";
 946                break;
 947        }
 948
 949        tmp = (cia->mem_err1 >> 24) & 0x1F;
 950        switch (tmp) {
 951        case 0x00: set_select = "Set 0 selected"; break;
 952        case 0x01: set_select = "Set 1 selected"; break;
 953        case 0x02: set_select = "Set 2 selected"; break;
 954        case 0x03: set_select = "Set 3 selected"; break;
 955        case 0x04: set_select = "Set 4 selected"; break;
 956        case 0x05: set_select = "Set 5 selected"; break;
 957        case 0x06: set_select = "Set 6 selected"; break;
 958        case 0x07: set_select = "Set 7 selected"; break;
 959        case 0x08: set_select = "Set 8 selected"; break;
 960        case 0x09: set_select = "Set 9 selected"; break;
 961        case 0x0A: set_select = "Set A selected"; break;
 962        case 0x0B: set_select = "Set B selected"; break;
 963        case 0x0C: set_select = "Set C selected"; break;
 964        case 0x0D: set_select = "Set D selected"; break;
 965        case 0x0E: set_select = "Set E selected"; break;
 966        case 0x0F: set_select = "Set F selected"; break;
 967        case 0x10: set_select = "No set selected"; break;
 968        case 0x1F: set_select = "Refresh cycle"; break;
 969        default:   set_select = "Unknown"; break;
 970        }
 971
 972        printk(KERN_CRIT "  Memory port command: %s\n", mem_port_cmd);
 973        printk(KERN_CRIT "  Memory port address: %#010lx, mask: %#lx\n",
 974               mem_port_addr, mem_port_mask);
 975        printk(KERN_CRIT "  Memory sequencer state: %s\n", seq_state);
 976        printk(KERN_CRIT "  Memory set: %s\n", set_select);
 977}
 978
 979static void
 980cia_decode_ecc_error(struct el_CIA_sysdata_mcheck *cia, const char *msg)
 981{
 982        long syn;
 983        long i;
 984        const char *fmt;
 985
 986        cia_decode_mem_error(cia, msg);
 987
 988        syn = cia->cia_syn & 0xff;
 989        if (syn == (syn & -syn)) {
 990                fmt = KERN_CRIT "  ECC syndrome %#x -- check bit %d\n";
 991                i = ffs(syn) - 1;
 992        } else {
 993                static unsigned char const data_bit[64] = {
 994                        0xCE, 0xCB, 0xD3, 0xD5,
 995                        0xD6, 0xD9, 0xDA, 0xDC,
 996                        0x23, 0x25, 0x26, 0x29,
 997                        0x2A, 0x2C, 0x31, 0x34,
 998                        0x0E, 0x0B, 0x13, 0x15,
 999                        0x16, 0x19, 0x1A, 0x1C,
1000                        0xE3, 0xE5, 0xE6, 0xE9,
1001                        0xEA, 0xEC, 0xF1, 0xF4,
1002                        0x4F, 0x4A, 0x52, 0x54,
1003                        0x57, 0x58, 0x5B, 0x5D,
1004                        0xA2, 0xA4, 0xA7, 0xA8,
1005                        0xAB, 0xAD, 0xB0, 0xB5,
1006                        0x8F, 0x8A, 0x92, 0x94,
1007                        0x97, 0x98, 0x9B, 0x9D,
1008                        0x62, 0x64, 0x67, 0x68,
1009                        0x6B, 0x6D, 0x70, 0x75
1010                };
1011
1012                for (i = 0; i < 64; ++i)
1013                        if (data_bit[i] == syn)
1014                                break;
1015
1016                if (i < 64)
1017                        fmt = KERN_CRIT "  ECC syndrome %#x -- data bit %d\n";
1018                else
1019                        fmt = KERN_CRIT "  ECC syndrome %#x -- unknown bit\n";
1020        }
1021
1022        printk (fmt, syn, i);
1023}
1024
1025static void
1026cia_decode_parity_error(struct el_CIA_sysdata_mcheck *cia)
1027{
1028        static const char * const cmd_desc[16] = {
1029                "NOP", "LOCK", "FETCH", "FETCH_M", "MEMORY BARRIER",
1030                "SET DIRTY", "WRITE BLOCK", "WRITE BLOCK LOCK",
1031                "READ MISS0", "READ MISS1", "READ MISS MOD0",
1032                "READ MISS MOD1", "BCACHE VICTIM", "Spare",
1033                "READ MISS MOD STC0", "READ MISS MOD STC1"
1034        };
1035
1036        unsigned long addr;
1037        unsigned long mask;
1038        const char *cmd;
1039        int par;
1040
1041        addr = cia->cpu_err0 & 0xfffffff0;
1042        addr |= (cia->cpu_err1 & 0x83UL) << 32;
1043        cmd = cmd_desc[(cia->cpu_err1 >> 8) & 0xF];
1044        mask = (cia->cpu_err1 >> 12) & 0xF;
1045        par = (cia->cpu_err1 >> 21) & 1;
1046
1047        printk(KERN_CRIT "CIA machine check: System bus parity error\n");
1048        printk(KERN_CRIT "  Command: %s, Parity bit: %d\n", cmd, par);
1049        printk(KERN_CRIT "  Address: %#010lx, Mask: %#lx\n", addr, mask);
1050}
1051
1052static int
1053cia_decode_mchk(unsigned long la_ptr)
1054{
1055        struct el_common *com;
1056        struct el_CIA_sysdata_mcheck *cia;
1057        int which;
1058
1059        com = (void *)la_ptr;
1060        cia = (void *)(la_ptr + com->sys_offset);
1061
1062        if ((cia->cia_err & CIA_ERR_VALID) == 0)
1063                return 0;
1064
1065        which = cia->cia_err & 0xfff;
1066        switch (ffs(which) - 1) {
1067        case 0: /* CIA_ERR_COR_ERR */
1068                cia_decode_ecc_error(cia, "Corrected ECC error");
1069                break;
1070        case 1: /* CIA_ERR_UN_COR_ERR */
1071                cia_decode_ecc_error(cia, "Uncorrected ECC error");
1072                break;
1073        case 2: /* CIA_ERR_CPU_PE */
1074                cia_decode_parity_error(cia);
1075                break;
1076        case 3: /* CIA_ERR_MEM_NEM */
1077                cia_decode_mem_error(cia, "Access to nonexistent memory");
1078                break;
1079        case 4: /* CIA_ERR_PCI_SERR */
1080                cia_decode_pci_error(cia, "PCI bus system error");
1081                break;
1082        case 5: /* CIA_ERR_PERR */
1083                cia_decode_pci_error(cia, "PCI data parity error");
1084                break;
1085        case 6: /* CIA_ERR_PCI_ADDR_PE */
1086                cia_decode_pci_error(cia, "PCI address parity error");
1087                break;
1088        case 7: /* CIA_ERR_RCVD_MAS_ABT */
1089                cia_decode_pci_error(cia, "PCI master abort");
1090                break;
1091        case 8: /* CIA_ERR_RCVD_TAR_ABT */
1092                cia_decode_pci_error(cia, "PCI target abort");
1093                break;
1094        case 9: /* CIA_ERR_PA_PTE_INV */
1095                cia_decode_pci_error(cia, "PCI invalid PTE");
1096                break;
1097        case 10: /* CIA_ERR_FROM_WRT_ERR */
1098                cia_decode_mem_error(cia, "Write to flash ROM attempted");
1099                break;
1100        case 11: /* CIA_ERR_IOA_TIMEOUT */
1101                cia_decode_pci_error(cia, "I/O timeout");
1102                break;
1103        }
1104
1105        if (cia->cia_err & CIA_ERR_LOST_CORR_ERR)
1106                printk(KERN_CRIT "CIA lost machine check: "
1107                       "Correctable ECC error\n");
1108        if (cia->cia_err & CIA_ERR_LOST_UN_CORR_ERR)
1109                printk(KERN_CRIT "CIA lost machine check: "
1110                       "Uncorrectable ECC error\n");
1111        if (cia->cia_err & CIA_ERR_LOST_CPU_PE)
1112                printk(KERN_CRIT "CIA lost machine check: "
1113                       "System bus parity error\n");
1114        if (cia->cia_err & CIA_ERR_LOST_MEM_NEM)
1115                printk(KERN_CRIT "CIA lost machine check: "
1116                       "Access to nonexistent memory\n");
1117        if (cia->cia_err & CIA_ERR_LOST_PERR)
1118                printk(KERN_CRIT "CIA lost machine check: "
1119                       "PCI data parity error\n");
1120        if (cia->cia_err & CIA_ERR_LOST_PCI_ADDR_PE)
1121                printk(KERN_CRIT "CIA lost machine check: "
1122                       "PCI address parity error\n");
1123        if (cia->cia_err & CIA_ERR_LOST_RCVD_MAS_ABT)
1124                printk(KERN_CRIT "CIA lost machine check: "
1125                       "PCI master abort\n");
1126        if (cia->cia_err & CIA_ERR_LOST_RCVD_TAR_ABT)
1127                printk(KERN_CRIT "CIA lost machine check: "
1128                       "PCI target abort\n");
1129        if (cia->cia_err & CIA_ERR_LOST_PA_PTE_INV)
1130                printk(KERN_CRIT "CIA lost machine check: "
1131                       "PCI invalid PTE\n");
1132        if (cia->cia_err & CIA_ERR_LOST_FROM_WRT_ERR)
1133                printk(KERN_CRIT "CIA lost machine check: "
1134                       "Write to flash ROM attempted\n");
1135        if (cia->cia_err & CIA_ERR_LOST_IOA_TIMEOUT)
1136                printk(KERN_CRIT "CIA lost machine check: "
1137                       "I/O timeout\n");
1138
1139        return 1;
1140}
1141
1142void
1143cia_machine_check(unsigned long vector, unsigned long la_ptr,
1144                  struct pt_regs * regs)
1145{
1146        int expected;
1147
1148        /* Clear the error before any reporting.  */
1149        mb();
1150        mb();  /* magic */
1151        draina();
1152        cia_pci_clr_err();
1153        wrmces(rdmces());       /* reset machine check pending flag.  */
1154        mb();
1155
1156        expected = mcheck_expected(0);
1157        if (!expected && vector == 0x660)
1158                expected = cia_decode_mchk(la_ptr);
1159        process_mcheck_info(vector, la_ptr, regs, "CIA", expected);
1160}
1161
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.