14 #define __EXTERN_INLINE inline
17 #undef __EXTERN_INLINE
19 #include <linux/types.h>
20 #include <linux/pci.h>
21 #include <linux/sched.h>
25 #include <asm/ptrace.h>
38 #define DEBUG_CONFIG 0
40 # define DBGC(args) printk args
45 #define vip volatile int *
89 mk_conf_addr(
struct pci_bus *bus_dev,
unsigned int device_fn,
int where,
90 unsigned long *
pci_addr,
unsigned char *type1)
95 *pci_addr = (bus << 16) | (device_fn << 8) | where;
97 DBGC((
"mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
98 " returning address 0x%p\n"
99 bus, device_fn, where, *pci_addr));
111 DBGC((
"conf_read(addr=0x%lx, type1=%d) ", addr, type1));
160 conf_write(
unsigned long addr,
unsigned int value,
unsigned char type1)
163 int stat0, cia_cfg = 0;
165 DBGC((
"conf_write(addr=0x%lx, type1=%d) ", addr, type1));
216 if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
219 mask = (size - 1) * 8;
220 shift = (where & 3) * 8;
221 addr = (pci_addr << 5) + mask +
CIA_CONF;
222 *value =
conf_read(addr, type1) >> (shift);
227 cia_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
int size,
234 if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
237 mask = (size - 1) * 8;
238 addr = (pci_addr << 5) + mask +
CIA_CONF;
239 conf_write(addr, value << ((where & 3) * 8), type1);
245 .read = cia_read_config,
246 .write = cia_write_config,
278 #define CIA_BROKEN_TBIA_BASE 0x30000000
279 #define CIA_BROKEN_TBIA_SIZE 1024
311 cia_readl(bus_addr + 0x00000);
312 cia_readl(bus_addr + 0x08000);
313 cia_readl(bus_addr + 0x10000);
314 cia_readl(bus_addr + 0x18000);
316 cia_iounmap(bus_addr);
327 cia_prepare_tbia_workaround(
int window)
329 unsigned long *ppte,
pte;
346 verify_tb_operation(
void)
354 int temp, use_tbia_try2 = 0;
390 bus_addr = cia_ioremap(addr0, 8*
PAGE_SIZE);
402 printk(
"pci: failed tb register update test "
403 "(tag0 %#x != %#x)\n", temp, tag0);
408 printk(
"pci: failed tb register update test "
409 "(tag1 %#x != 0)\n", temp);
414 printk(
"pci: failed tb register update test "
415 "(pte0 %#x != %#x)\n", temp, pte0);
418 printk(
"pci: passed tb register update test\n");
427 temp = cia_readl(bus_addr);
432 printk(
"pci: failed sg loopback i/o read test (mcheck)\n");
436 printk(
"pci: failed sg loopback i/o read test "
437 "(%#x != %#x)\n", temp, data0);
440 printk(
"pci: passed sg loopback i/o read test\n");
444 if (! use_tbia_try2) {
449 printk(
"pci: failed tbia test; workaround available\n");
451 printk(
"pci: passed tbia test\n");
460 arena->
ptes[4] = pte0;
464 temp = cia_readl(bus_addr + 4*
PAGE_SIZE);
469 printk(
"pci: failed pte write cache snoop test (mcheck)\n");
473 printk(
"pci: failed pte write cache snoop test "
474 "(%#x != %#x)\n", temp, data0);
477 printk(
"pci: passed pte write cache snoop test\n");
484 arena->
ptes[5] = pte0;
488 temp = cia_readl(bus_addr + 5*
PAGE_SIZE);
493 printk(
"pci: failed valid tag invalid pte reload test "
494 "(mcheck; workaround available)\n");
498 }
else if (temp != data0) {
499 printk(
"pci: failed valid tag invalid pte reload test "
500 "(%#x != %#x)\n", temp, data0);
503 printk(
"pci: passed valid tag invalid pte reload test\n");
512 temp = cia_readl(bus_addr + 6*
PAGE_SIZE);
516 printk(
"pci: %s pci machine check test\n",
533 printk(
"pci: tbia workaround enabled\n");
535 alpha_mv.mv_pci_tbi(arena->
hose, 0, -1);
539 cia_iounmap(bus_addr);
550 printk(
"pci: disabling sg translation window\n");
554 alpha_mv.mv_pci_tbi =
NULL;
558 #if defined(ALPHA_RESTORE_SRM_SETUP)
562 unsigned int hae_mem;
564 unsigned int pci_dac_offset;
565 unsigned int err_mask;
566 unsigned int cia_ctrl;
567 unsigned int cia_cnfg;
590 saved_config.cia_cnfg = 0;
593 for (i = 0; i < 4; i++) {
606 for (i = 0; i < 4; i++) {
618 if (saved_config.cia_cnfg)
624 #define cia_save_srm_settings(p) do {} while (0)
625 #define cia_restore_srm_settings() do {} while (0)
630 do_init_arch(
int is_pyxis)
633 int temp, cia_rev, tbia_window;
636 printk(
"pci: cia revision %d%s\n",
637 cia_rev, is_pyxis ?
" (pyxis)" :
"");
690 hose->mem_space = hae_mem;
702 hose->sparse_io_base =
CIA_IO - IDENT_ADDR;
703 hose->dense_io_base = 0;
705 hose->sparse_mem_base = 0;
706 hose->dense_mem_base =
CIA_BW_MEM - IDENT_ADDR;
707 hose->sparse_io_base = 0;
708 hose->dense_io_base =
CIA_BW_IO - IDENT_ADDR;
756 }
else if (cia_rev == 1) {
766 alpha_mv.pci_dac_offset = 0x200000000
UL;
771 cia_prepare_tbia_workaround(tbia_window);
791 unsigned int cc0, cc1;
792 unsigned long pyxis_cc;
794 __asm__ __volatile__ (
"rpcc %0" :
"=r"(cc0));
797 __asm__ __volatile__ (
"rpcc %0" :
"=r"(cc1));
799 hwrpb->cycle_freq = ((cc1 >> 11) * 100000000
UL) / 3;
800 hwrpb_update_checksum(
hwrpb);
816 verify_tb_operation();
821 cia_pci_clr_err(
void)
831 #ifdef CONFIG_VERBOSE_MCHECK
835 static const char *
const pci_cmd_desc[16] = {
836 "Interrupt Acknowledge",
"Special Cycle",
"I/O Read",
837 "I/O Write",
"Reserved 0x4",
"Reserved 0x5",
"Memory Read",
838 "Memory Write",
"Reserved 0x8",
"Reserved 0x9",
839 "Configuration Read",
"Configuration Write",
840 "Memory Read Multiple",
"Dual Address Cycle",
841 "Memory Read Line",
"Memory Write and Invalidate"
848 static const char *
const window_desc[6] = {
849 "No window active",
"Window 0 hit",
"Window 1 hit",
850 "Window 2 hit",
"Window 3 hit",
"Monster window hit"
858 cmd = pci_cmd_desc[cia->
pci_err0 & 0x7];
864 window = window_desc[
tmp];
882 static const char *
const master_st_desc[16] = {
883 "Idle",
"Drive bus",
"Address step cycle",
884 "Address cycle",
"Data cycle",
"Last read data cycle",
885 "Last write data cycle",
"Read stop cycle",
886 "Write stop cycle",
"Read turnaround cycle",
887 "Write turnaround cycle",
"Reserved 0xB",
888 "Reserved 0xC",
"Reserved 0xD",
"Reserved 0xE",
891 static const char *
const target_st_desc[16] = {
892 "Idle",
"Busy",
"Read data cycle",
"Write data cycle",
893 "Read stop cycle",
"Write stop cycle",
894 "Read turnaround cycle",
"Write turnaround cycle",
895 "Read wait cycle",
"Write wait cycle",
896 "Reserved 0xA",
"Reserved 0xB",
"Reserved 0xC",
897 "Reserved 0xD",
"Reserved 0xE",
"Unknown state"
901 const char *master, *
target;
905 master = master_st_desc[(cia->
pci_err0 >> 16) & 0xF];
906 target = target_st_desc[(cia->
pci_err0 >> 20) & 0xF];
907 cmd = pci_cmd_desc[(cia->
pci_err0 >> 24) & 0xF];
934 unsigned long mem_port_addr;
935 unsigned long mem_port_mask;
936 const char *mem_port_cmd;
937 const char *seq_state;
938 const char *set_select;
943 cia_decode_pci_error(cia, msg);
947 mem_port_addr = cia->
mem_err0 & 0xfffffff0;
948 mem_port_addr |= (cia->
mem_err1 & 0x83
UL) << 32;
950 mem_port_mask = (cia->
mem_err1 >> 12) & 0xF;
953 tmp |= ((cia->
mem_err1 >> 20) & 1) << 4;
954 if ((tmp & 0x1E) == 0x06)
955 mem_port_cmd =
"WRITE BLOCK or WRITE BLOCK LOCK";
956 else if ((tmp & 0x1C) == 0x08)
957 mem_port_cmd =
"READ MISS or READ MISS MODIFY";
958 else if (tmp == 0x1C)
959 mem_port_cmd =
"BC VICTIM";
960 else if ((tmp & 0x1E) == 0x0E)
961 mem_port_cmd =
"READ MISS MODIFY";
962 else if ((tmp & 0x1C) == 0x18)
963 mem_port_cmd =
"DMA READ or DMA READ MODIFY";
964 else if ((tmp & 0x1E) == 0x12)
965 mem_port_cmd =
"DMA WRITE";
967 mem_port_cmd =
"Unknown";
975 seq_state =
"DMA READ or DMA WRITE";
978 seq_state =
"READ MISS (or READ MISS MODIFY) with victim";
980 case 0x4:
case 0x5:
case 0x6:
981 seq_state =
"READ MISS (or READ MISS MODIFY) with no victim";
983 case 0x8:
case 0x9:
case 0xB:
984 seq_state =
"Refresh";
987 seq_state =
"Idle, waiting for DMA pending read";
990 seq_state =
"Idle, ras precharge";
993 seq_state =
"Unknown";
999 case 0x00: set_select =
"Set 0 selected";
break;
1000 case 0x01: set_select =
"Set 1 selected";
break;
1001 case 0x02: set_select =
"Set 2 selected";
break;
1002 case 0x03: set_select =
"Set 3 selected";
break;
1003 case 0x04: set_select =
"Set 4 selected";
break;
1004 case 0x05: set_select =
"Set 5 selected";
break;
1005 case 0x06: set_select =
"Set 6 selected";
break;
1006 case 0x07: set_select =
"Set 7 selected";
break;
1007 case 0x08: set_select =
"Set 8 selected";
break;
1008 case 0x09: set_select =
"Set 9 selected";
break;
1009 case 0x0A: set_select =
"Set A selected";
break;
1010 case 0x0B: set_select =
"Set B selected";
break;
1011 case 0x0C: set_select =
"Set C selected";
break;
1012 case 0x0D: set_select =
"Set D selected";
break;
1013 case 0x0E: set_select =
"Set E selected";
break;
1014 case 0x0F: set_select =
"Set F selected";
break;
1015 case 0x10: set_select =
"No set selected";
break;
1016 case 0x1F: set_select =
"Refresh cycle";
break;
1017 default: set_select =
"Unknown";
break;
1022 mem_port_addr, mem_port_mask);
1034 cia_decode_mem_error(cia, msg);
1037 if (syn == (syn & -syn)) {
1038 fmt =
KERN_CRIT " ECC syndrome %#x -- check bit %d\n";
1041 static unsigned char const data_bit[64] = {
1042 0xCE, 0xCB, 0xD3, 0xD5,
1043 0xD6, 0xD9, 0xDA, 0xDC,
1044 0x23, 0x25, 0x26, 0x29,
1045 0x2A, 0x2C, 0x31, 0x34,
1046 0x0E, 0x0B, 0x13, 0x15,
1047 0x16, 0x19, 0x1A, 0x1C,
1048 0xE3, 0xE5, 0xE6, 0xE9,
1049 0xEA, 0xEC, 0xF1, 0xF4,
1050 0x4F, 0x4A, 0x52, 0x54,
1051 0x57, 0x58, 0x5B, 0x5D,
1052 0xA2, 0xA4, 0xA7, 0xA8,
1053 0xAB, 0xAD, 0xB0, 0xB5,
1054 0x8F, 0x8A, 0x92, 0x94,
1055 0x97, 0x98, 0x9B, 0x9D,
1056 0x62, 0x64, 0x67, 0x68,
1057 0x6B, 0x6D, 0x70, 0x75
1060 for (i = 0; i < 64; ++
i)
1061 if (data_bit[i] == syn)
1065 fmt =
KERN_CRIT " ECC syndrome %#x -- data bit %d\n";
1067 fmt =
KERN_CRIT " ECC syndrome %#x -- unknown bit\n";
1076 static const char *
const cmd_desc[16] = {
1077 "NOP",
"LOCK",
"FETCH",
"FETCH_M",
"MEMORY BARRIER",
1078 "SET DIRTY",
"WRITE BLOCK",
"WRITE BLOCK LOCK",
1079 "READ MISS0",
"READ MISS1",
"READ MISS MOD0",
1080 "READ MISS MOD1",
"BCACHE VICTIM",
"Spare",
1081 "READ MISS MOD STC0",
"READ MISS MOD STC1"
1091 cmd = cmd_desc[(cia->
cpu_err1 >> 8) & 0xF];
1092 mask = (cia->
cpu_err1 >> 12) & 0xF;
1103 cia_decode_mchk(
unsigned long la_ptr)
1108 com = (
void *)la_ptr;
1114 #ifdef CONFIG_VERBOSE_MCHECK
1115 if (!alpha_verbose_mcheck)
1120 cia_decode_ecc_error(cia,
"Corrected ECC error");
1123 cia_decode_ecc_error(cia,
"Uncorrected ECC error");
1126 cia_decode_parity_error(cia);
1129 cia_decode_mem_error(cia,
"Access to nonexistent memory");
1132 cia_decode_pci_error(cia,
"PCI bus system error");
1135 cia_decode_pci_error(cia,
"PCI data parity error");
1138 cia_decode_pci_error(cia,
"PCI address parity error");
1141 cia_decode_pci_error(cia,
"PCI master abort");
1144 cia_decode_pci_error(cia,
"PCI target abort");
1147 cia_decode_pci_error(cia,
"PCI invalid PTE");
1150 cia_decode_mem_error(cia,
"Write to flash ROM attempted");
1153 cia_decode_pci_error(cia,
"I/O timeout");
1159 "Correctable ECC error\n");
1162 "Uncorrectable ECC error\n");
1165 "System bus parity error\n");
1168 "Access to nonexistent memory\n");
1171 "PCI data parity error\n");
1174 "PCI address parity error\n");
1177 "PCI master abort\n");
1180 "PCI target abort\n");
1183 "PCI invalid PTE\n");
1186 "Write to flash ROM attempted\n");
1209 if (!expected && vector == 0x660)
1210 expected = cia_decode_mchk(la_ptr);