Lines Matching +full:is +full:- +full:decoded +full:- +full:cs

1 // SPDX-License-Identifier: GPL-2.0
11 #include <asm/intel-family.h>
24 pci_read_config_dword((d)->uracu, 0xd0, &(reg))
26 pci_read_config_dword((d)->uracu, \
27 (res_cfg->type == GNR ? 0xd4 : 0xd8) + (i) * 4, &(reg))
29 pci_read_config_dword((d)->sad_all, (offset) + (i) * \
30 (res_cfg->type == GNR ? 12 : 8), &(reg))
32 pci_read_config_dword((d)->uracu, 0xd4, &(reg))
34 pci_read_config_dword((d)->pcu_cr3, \
35 res_cfg->type == GNR ? 0x290 : 0x90, &(reg))
37 pci_read_config_dword((d)->pcu_cr3, \
38 res_cfg->type == GNR ? 0x298 : 0x98, &(reg))
40 readl((m)->mbase + ((m)->hbm_mc ? 0x80c : \
41 (res_cfg->type == GNR ? 0xc0c : 0x2080c)) + \
42 (i) * (m)->chan_mmio_sz + (j) * 4)
44 readl((m)->mbase + ((m)->hbm_mc ? 0x970 : 0x20970) + \
45 (i) * (m)->chan_mmio_sz)
47 readl((m)->mbase + ((m)->hbm_mc ? 0xef8 : \
48 (res_cfg->type == GNR ? 0xaf8 : 0x20ef8)) + \
49 (i) * (m)->chan_mmio_sz)
51 readl((m)->mbase + (i) * (m)->chan_mmio_sz + (offset))
53 readq((m)->mbase + (i) * (m)->chan_mmio_sz + (offset))
55 writel(v, (m)->mbase + (i) * (m)->chan_mmio_sz + (offset))
59 #define I10NM_GET_IMC_MMIO_SIZE(reg) ((GET_BITFIELD(reg, 13, 23) - \
111 imc->chan[chan].retry_rd_err_log_s = s; in __enable_retry_rd_err_log()
112 imc->chan[chan].retry_rd_err_log_d = d; in __enable_retry_rd_err_log()
114 imc->chan[chan].retry_rd_err_log_d2 = d2; in __enable_retry_rd_err_log()
128 if (imc->chan[chan].retry_rd_err_log_s & RETRY_RD_ERR_LOG_UC) in __enable_retry_rd_err_log()
130 if (imc->chan[chan].retry_rd_err_log_s & RETRY_RD_ERR_LOG_NOOVER) in __enable_retry_rd_err_log()
132 if (!(imc->chan[chan].retry_rd_err_log_s & RETRY_RD_ERR_LOG_EN)) in __enable_retry_rd_err_log()
134 if (imc->chan[chan].retry_rd_err_log_d & RETRY_RD_ERR_LOG_UC) in __enable_retry_rd_err_log()
136 if (imc->chan[chan].retry_rd_err_log_d & RETRY_RD_ERR_LOG_NOOVER) in __enable_retry_rd_err_log()
138 if (!(imc->chan[chan].retry_rd_err_log_d & RETRY_RD_ERR_LOG_EN)) in __enable_retry_rd_err_log()
142 if (imc->chan[chan].retry_rd_err_log_d2 & RETRY_RD_ERR_LOG_UC) in __enable_retry_rd_err_log()
144 if (!(imc->chan[chan].retry_rd_err_log_d2 & RETRY_RD_ERR_LOG_NOOVER)) in __enable_retry_rd_err_log()
146 if (!(imc->chan[chan].retry_rd_err_log_d2 & RETRY_RD_ERR_LOG_EN)) in __enable_retry_rd_err_log()
166 imc_num = res_cfg->ddr_imc_num; in enable_retry_rd_err_log()
167 chan_num = res_cfg->ddr_chan_num; in enable_retry_rd_err_log()
170 imc = &d->imc[i]; in enable_retry_rd_err_log()
171 if (!imc->mbase) in enable_retry_rd_err_log()
176 res_cfg->offsets_scrub, in enable_retry_rd_err_log()
177 res_cfg->offsets_demand, in enable_retry_rd_err_log()
178 res_cfg->offsets_demand2); in enable_retry_rd_err_log()
181 imc_num += res_cfg->hbm_imc_num; in enable_retry_rd_err_log()
182 chan_num = res_cfg->hbm_chan_num; in enable_retry_rd_err_log()
185 imc = &d->imc[i]; in enable_retry_rd_err_log()
186 if (!imc->mbase || !imc->hbm_mc) in enable_retry_rd_err_log()
191 res_cfg->offsets_scrub_hbm0, in enable_retry_rd_err_log()
192 res_cfg->offsets_demand_hbm0, in enable_retry_rd_err_log()
195 res_cfg->offsets_scrub_hbm1, in enable_retry_rd_err_log()
196 res_cfg->offsets_demand_hbm1, in enable_retry_rd_err_log()
206 struct skx_imc *imc = &res->dev->imc[res->imc]; in show_retry_rd_err_log()
216 if (!imc->mbase) in show_retry_rd_err_log()
219 if (imc->hbm_mc) { in show_retry_rd_err_log()
220 pch = res->cs & 1; in show_retry_rd_err_log()
223 offsets = scrub_err ? res_cfg->offsets_scrub_hbm1 : in show_retry_rd_err_log()
224 res_cfg->offsets_demand_hbm1; in show_retry_rd_err_log()
226 offsets = scrub_err ? res_cfg->offsets_scrub_hbm0 : in show_retry_rd_err_log()
227 res_cfg->offsets_demand_hbm0; in show_retry_rd_err_log()
230 offsets = res_cfg->offsets_scrub; in show_retry_rd_err_log()
232 offsets = res_cfg->offsets_demand; in show_retry_rd_err_log()
233 xffsets = res_cfg->offsets_demand2; in show_retry_rd_err_log()
237 log0 = I10NM_GET_REG32(imc, res->channel, offsets[0]); in show_retry_rd_err_log()
238 log1 = I10NM_GET_REG32(imc, res->channel, offsets[1]); in show_retry_rd_err_log()
239 log3 = I10NM_GET_REG32(imc, res->channel, offsets[3]); in show_retry_rd_err_log()
240 log4 = I10NM_GET_REG32(imc, res->channel, offsets[4]); in show_retry_rd_err_log()
241 log5 = I10NM_GET_REG64(imc, res->channel, offsets[5]); in show_retry_rd_err_log()
244 lxg0 = I10NM_GET_REG32(imc, res->channel, xffsets[0]); in show_retry_rd_err_log()
245 lxg1 = I10NM_GET_REG32(imc, res->channel, xffsets[1]); in show_retry_rd_err_log()
246 lxg3 = I10NM_GET_REG32(imc, res->channel, xffsets[3]); in show_retry_rd_err_log()
247 lxg4 = I10NM_GET_REG32(imc, res->channel, xffsets[4]); in show_retry_rd_err_log()
248 lxg5 = I10NM_GET_REG64(imc, res->channel, xffsets[5]); in show_retry_rd_err_log()
251 if (res_cfg->type == SPR) { in show_retry_rd_err_log()
252 log2a = I10NM_GET_REG64(imc, res->channel, offsets[2]); in show_retry_rd_err_log()
256 if (len - n > 0) { in show_retry_rd_err_log()
258 lxg2a = I10NM_GET_REG64(imc, res->channel, xffsets[2]); in show_retry_rd_err_log()
259 n += snprintf(msg + n, len - n, " %.8x %.8x %.16llx %.8x %.8x %.16llx]", in show_retry_rd_err_log()
262 n += snprintf(msg + n, len - n, "]"); in show_retry_rd_err_log()
266 log2 = I10NM_GET_REG32(imc, res->channel, offsets[2]); in show_retry_rd_err_log()
271 if (imc->hbm_mc) { in show_retry_rd_err_log()
273 corr0 = I10NM_GET_REG32(imc, res->channel, 0x2c18); in show_retry_rd_err_log()
274 corr1 = I10NM_GET_REG32(imc, res->channel, 0x2c1c); in show_retry_rd_err_log()
275 corr2 = I10NM_GET_REG32(imc, res->channel, 0x2c20); in show_retry_rd_err_log()
276 corr3 = I10NM_GET_REG32(imc, res->channel, 0x2c24); in show_retry_rd_err_log()
278 corr0 = I10NM_GET_REG32(imc, res->channel, 0x2818); in show_retry_rd_err_log()
279 corr1 = I10NM_GET_REG32(imc, res->channel, 0x281c); in show_retry_rd_err_log()
280 corr2 = I10NM_GET_REG32(imc, res->channel, 0x2820); in show_retry_rd_err_log()
281 corr3 = I10NM_GET_REG32(imc, res->channel, 0x2824); in show_retry_rd_err_log()
284 corr0 = I10NM_GET_REG32(imc, res->channel, 0x22c18); in show_retry_rd_err_log()
285 corr1 = I10NM_GET_REG32(imc, res->channel, 0x22c1c); in show_retry_rd_err_log()
286 corr2 = I10NM_GET_REG32(imc, res->channel, 0x22c20); in show_retry_rd_err_log()
287 corr3 = I10NM_GET_REG32(imc, res->channel, 0x22c24); in show_retry_rd_err_log()
290 if (len - n > 0) in show_retry_rd_err_log()
291 snprintf(msg + n, len - n, in show_retry_rd_err_log()
302 I10NM_SET_REG32(imc, res->channel, offsets[0], log0); in show_retry_rd_err_log()
307 I10NM_SET_REG32(imc, res->channel, xffsets[0], lxg0); in show_retry_rd_err_log()
335 * i10nm_get_imc_num() - Get the number of present DDR memory controllers.
340 * at runtime overwrites the value statically configured in @cfg->ddr_imc_num.
341 * For other CPUs, the number of present DDR memory controllers is statically
342 * configured in @cfg->ddr_imc_num.
353 d->pcu_cr3 = pci_get_dev_wrapper(d->seg, d->bus[res_cfg->pcu_cr3_bdf.bus], in i10nm_get_imc_num()
354 res_cfg->pcu_cr3_bdf.dev, in i10nm_get_imc_num()
355 res_cfg->pcu_cr3_bdf.fun); in i10nm_get_imc_num()
356 if (!d->pcu_cr3) in i10nm_get_imc_num()
372 switch (cfg->type) { in i10nm_get_imc_num()
381 return -ENODEV; in i10nm_get_imc_num()
386 return -EINVAL; in i10nm_get_imc_num()
389 if (cfg->ddr_imc_num != imc_num) { in i10nm_get_imc_num()
393 cfg->ddr_imc_num = imc_num; in i10nm_get_imc_num()
401 * is statically pre-configured in cfg->ddr_imc_num. in i10nm_get_imc_num()
414 d->sad_all = pci_get_dev_wrapper(d->seg, d->bus[res_cfg->sad_all_bdf.bus], in i10nm_check_2lm()
415 res_cfg->sad_all_bdf.dev, in i10nm_check_2lm()
416 res_cfg->sad_all_bdf.fun); in i10nm_check_2lm()
417 if (!d->sad_all) in i10nm_check_2lm()
421 I10NM_GET_SAD(d, cfg->sad_all_offset, i, reg); in i10nm_check_2lm()
423 edac_dbg(2, "2-level memory configuration.\n"); in i10nm_check_2lm()
438 switch (res_cfg->type) { in i10nm_mscod_is_ddrt()
479 if ((mce->status & (MCI_STATUS_MISCV | MCI_STATUS_ADDRV)) in i10nm_mc_decode_available()
483 bank = mce->bank; in i10nm_mc_decode_available()
485 switch (res_cfg->type) { in i10nm_mc_decode_available()
487 /* Check whether the bank is one of {13,14,17,18,21,22,25,26} */ in i10nm_mc_decode_available()
499 /* DDRT errors can't be decoded from MCA bank registers */ in i10nm_mc_decode_available()
500 if (MCI_MISC_ECC_MODE(mce->misc) == MCI_MISC_ECC_DDRT) in i10nm_mc_decode_available()
503 if (i10nm_mscod_is_ddrt(MCI_STATUS_MSCOD(mce->status))) in i10nm_mc_decode_available()
511 struct mce *m = res->mce; in i10nm_mc_decode()
519 if (d->imc[0].src_id == m->socketid) { in i10nm_mc_decode()
520 res->socket = m->socketid; in i10nm_mc_decode()
521 res->dev = d; in i10nm_mc_decode()
526 switch (res_cfg->type) { in i10nm_mc_decode()
528 bank = m->bank - 13; in i10nm_mc_decode()
529 res->imc = bank / 4; in i10nm_mc_decode()
530 res->channel = bank % 2; in i10nm_mc_decode()
531 res->column = GET_BITFIELD(m->misc, 9, 18) << 2; in i10nm_mc_decode()
532 res->row = GET_BITFIELD(m->misc, 19, 39); in i10nm_mc_decode()
533 res->bank_group = GET_BITFIELD(m->misc, 40, 41); in i10nm_mc_decode()
534 res->bank_address = GET_BITFIELD(m->misc, 42, 43); in i10nm_mc_decode()
535 res->bank_group |= GET_BITFIELD(m->misc, 44, 44) << 2; in i10nm_mc_decode()
536 res->rank = GET_BITFIELD(m->misc, 56, 58); in i10nm_mc_decode()
537 res->dimm = res->rank >> 2; in i10nm_mc_decode()
538 res->rank = res->rank % 4; in i10nm_mc_decode()
541 bank = m->bank - 13; in i10nm_mc_decode()
542 res->imc = bank / 2; in i10nm_mc_decode()
543 res->channel = bank % 2; in i10nm_mc_decode()
544 res->column = GET_BITFIELD(m->misc, 9, 18) << 2; in i10nm_mc_decode()
545 res->row = GET_BITFIELD(m->misc, 19, 36); in i10nm_mc_decode()
546 res->bank_group = GET_BITFIELD(m->misc, 37, 38); in i10nm_mc_decode()
547 res->bank_address = GET_BITFIELD(m->misc, 39, 40); in i10nm_mc_decode()
548 res->bank_group |= GET_BITFIELD(m->misc, 41, 41) << 2; in i10nm_mc_decode()
549 res->rank = GET_BITFIELD(m->misc, 57, 57); in i10nm_mc_decode()
550 res->dimm = GET_BITFIELD(m->misc, 58, 58); in i10nm_mc_decode()
556 if (!res->dev) { in i10nm_mc_decode()
558 m->socketid, res->imc); in i10nm_mc_decode()
566 * get_gnr_mdev() - Get the PCI device of the @logical_idx-th DDR memory controller.
569 * @logical_idx : The logical index of the present memory controller (0 ~ max present MC# - 1).
572 * RETURNS : The PCI device of the @logical_idx-th DDR memory controller, NULL on failure.
582 * Detect present memory controllers from { PCI device: 8-5, function 7-1 } in get_gnr_mdev()
585 mdev = pci_get_dev_wrapper(d->seg, in get_gnr_mdev()
586 d->bus[res_cfg->ddr_mdev_bdf.bus], in get_gnr_mdev()
587 res_cfg->ddr_mdev_bdf.dev + i / 7, in get_gnr_mdev()
588 res_cfg->ddr_mdev_bdf.fun + i % 7); in get_gnr_mdev()
605 * get_ddr_munit() - Get the resource of the i-th DDR memory controller.
609 * @offset : To store the MMIO offset of the i-th DDR memory controller.
610 * @size : To store the MMIO size of the i-th DDR memory controller.
612 * RETURNS : The PCI device of the i-th DDR memory controller, NULL on failure.
620 switch (res_cfg->type) { in get_ddr_munit()
643 mdev = pci_get_dev_wrapper(d->seg, in get_ddr_munit()
644 d->bus[res_cfg->ddr_mdev_bdf.bus], in get_ddr_munit()
645 res_cfg->ddr_mdev_bdf.dev + i, in get_ddr_munit()
646 res_cfg->ddr_mdev_bdf.fun); in get_ddr_munit()
658 * i10nm_imc_absent() - Check whether the memory controller @imc is absent
662 * RETURNS : true if the memory controller EDAC device is absent, false otherwise.
669 switch (res_cfg->type) { in i10nm_imc_absent()
671 for (i = 0; i < res_cfg->ddr_chan_num; i++) { in i10nm_imc_absent()
704 d->util_all = pci_get_dev_wrapper(d->seg, d->bus[res_cfg->util_all_bdf.bus], in i10nm_get_ddr_munits()
705 res_cfg->util_all_bdf.dev, in i10nm_get_ddr_munits()
706 res_cfg->util_all_bdf.fun); in i10nm_get_ddr_munits()
707 if (!d->util_all) in i10nm_get_ddr_munits()
708 return -ENODEV; in i10nm_get_ddr_munits()
710 d->uracu = pci_get_dev_wrapper(d->seg, d->bus[res_cfg->uracu_bdf.bus], in i10nm_get_ddr_munits()
711 res_cfg->uracu_bdf.dev, in i10nm_get_ddr_munits()
712 res_cfg->uracu_bdf.fun); in i10nm_get_ddr_munits()
713 if (!d->uracu) in i10nm_get_ddr_munits()
714 return -ENODEV; in i10nm_get_ddr_munits()
718 return -ENODEV; in i10nm_get_ddr_munits()
725 for (lmc = 0, i = 0; i < res_cfg->ddr_imc_num; i++) { in i10nm_get_ddr_munits()
730 return -ENODEV; in i10nm_get_ddr_munits()
742 return -ENODEV; in i10nm_get_ddr_munits()
745 d->imc[lmc].mbase = mbase; in i10nm_get_ddr_munits()
746 if (i10nm_imc_absent(&d->imc[lmc])) { in i10nm_get_ddr_munits()
749 d->imc[lmc].mbase = NULL; in i10nm_get_ddr_munits()
753 d->imc[lmc].mdev = mdev; in i10nm_get_ddr_munits()
784 if (!d->pcu_cr3) in i10nm_get_hbm_munits()
785 return -ENODEV; in i10nm_get_hbm_munits()
789 return -ENODEV; in i10nm_get_hbm_munits()
794 return -ENODEV; in i10nm_get_hbm_munits()
800 return -ENODEV; in i10nm_get_hbm_munits()
804 lmc = res_cfg->ddr_imc_num; in i10nm_get_hbm_munits()
806 for (i = 0; i < res_cfg->hbm_imc_num; i++) { in i10nm_get_hbm_munits()
807 mdev = pci_get_dev_wrapper(d->seg, d->bus[res_cfg->hbm_mdev_bdf.bus], in i10nm_get_hbm_munits()
808 res_cfg->hbm_mdev_bdf.dev + i / 4, in i10nm_get_hbm_munits()
809 res_cfg->hbm_mdev_bdf.fun + i % 4); in i10nm_get_hbm_munits()
813 return -ENODEV; in i10nm_get_hbm_munits()
818 d->imc[lmc].mdev = mdev; in i10nm_get_hbm_munits()
826 pci_dev_put(d->imc[lmc].mdev); in i10nm_get_hbm_munits()
827 d->imc[lmc].mdev = NULL; in i10nm_get_hbm_munits()
831 return -ENOMEM; in i10nm_get_hbm_munits()
834 d->imc[lmc].mbase = mbase; in i10nm_get_hbm_munits()
835 d->imc[lmc].hbm_mc = true; in i10nm_get_hbm_munits()
837 mcmtr = I10NM_GET_MCMTR(&d->imc[lmc], 0); in i10nm_get_hbm_munits()
839 iounmap(d->imc[lmc].mbase); in i10nm_get_hbm_munits()
840 d->imc[lmc].mbase = NULL; in i10nm_get_hbm_munits()
841 d->imc[lmc].hbm_mc = false; in i10nm_get_hbm_munits()
842 pci_dev_put(d->imc[lmc].mdev); in i10nm_get_hbm_munits()
843 d->imc[lmc].mdev = NULL; in i10nm_get_hbm_munits()
846 return -ENODEV; in i10nm_get_hbm_munits()
968 struct skx_pvt *pvt = mci->pvt_info; in i10nm_get_dimm_config()
969 struct skx_imc *imc = pvt->imc; in i10nm_get_dimm_config()
974 for (i = 0; i < imc->num_channels; i++) { in i10nm_get_dimm_config()
975 if (!imc->mbase) in i10nm_get_dimm_config()
980 if (res_cfg->type != GNR) in i10nm_get_dimm_config()
983 for (j = 0; j < imc->num_dimms; j++) { in i10nm_get_dimm_config()
987 mtr, mcddrtcfg, imc->mc, i, j); in i10nm_get_dimm_config()
997 i10nm_printk(KERN_ERR, "ECC is disabled on imc %d channel %d\n", in i10nm_get_dimm_config()
998 imc->mc, i); in i10nm_get_dimm_config()
999 return -ENODEV; in i10nm_get_dimm_config()
1025 return -EBUSY; in i10nm_init()
1029 return -EBUSY; in i10nm_init()
1032 return -ENODEV; in i10nm_init()
1036 return -ENODEV; in i10nm_init()
1038 cfg = (struct res_config *)id->driver_data; in i10nm_init()
1050 return -ENODEV; in i10nm_init()
1065 imc_num = res_cfg->ddr_imc_num + res_cfg->hbm_imc_num; in i10nm_init()
1078 if (!d->imc[i].mdev) in i10nm_init()
1081 d->imc[i].mc = mc++; in i10nm_init()
1082 d->imc[i].lmc = i; in i10nm_init()
1083 d->imc[i].src_id = src_id; in i10nm_init()
1084 d->imc[i].node_id = node_id; in i10nm_init()
1085 if (d->imc[i].hbm_mc) { in i10nm_init()
1086 d->imc[i].chan_mmio_sz = cfg->hbm_chan_mmio_sz; in i10nm_init()
1087 d->imc[i].num_channels = cfg->hbm_chan_num; in i10nm_init()
1088 d->imc[i].num_dimms = cfg->hbm_dimm_num; in i10nm_init()
1090 d->imc[i].chan_mmio_sz = cfg->ddr_chan_mmio_sz; in i10nm_init()
1091 d->imc[i].num_channels = cfg->ddr_chan_num; in i10nm_init()
1092 d->imc[i].num_dimms = cfg->ddr_dimm_num; in i10nm_init()
1095 rc = skx_register_mci(&d->imc[i], d->imc[i].mdev, in i10nm_init()
1111 if (retry_rd_err_log && res_cfg->offsets_scrub && res_cfg->offsets_demand) { in i10nm_init()
1131 if (retry_rd_err_log && res_cfg->offsets_scrub && res_cfg->offsets_demand) { in i10nm_exit()
1154 return -EINVAL; in set_decoding_via_mca()
1158 return -EIO; in set_decoding_via_mca()