Skip to content

Commit c4605bd

Browse files
yghannambp3tk0v
authored andcommitted
EDAC/amd64: Remove early_channel_count()
The early_channel_count() function seems to have been useful in the past for knowing how many EDAC mci structures to populate. However, this is no longer needed as the maximum channel count for a system is used instead. Remove the early_channel_count() helper functions and related code. Use the size of the channel layer when iterating over channel structures. Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cf98156 commit c4605bd

File tree

2 files changed

+2
-116
lines changed

2 files changed

+2
-116
lines changed

drivers/edac/amd64_edac.c

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,24 +1703,6 @@ static void determine_memory_type(struct amd64_pvt *pvt)
17031703
pvt->dram_type = (pvt->dclr0 & BIT(16)) ? MEM_DDR3 : MEM_RDDR3;
17041704
}
17051705

1706-
/* Get the number of DCT channels the memory controller is using. */
1707-
static int k8_early_channel_count(struct amd64_pvt *pvt)
1708-
{
1709-
int flag;
1710-
1711-
if (pvt->ext_model >= K8_REV_F)
1712-
/* RevF (NPT) and later */
1713-
flag = pvt->dclr0 & WIDTH_128;
1714-
else
1715-
/* RevE and earlier */
1716-
flag = pvt->dclr0 & REVE_WIDTH_128;
1717-
1718-
/* not used */
1719-
pvt->dclr1 = 0;
1720-
1721-
return (flag) ? 2 : 1;
1722-
}
1723-
17241706
/* On F10h and later ErrAddr is MC4_ADDR[47:1] */
17251707
static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m)
17261708
{
@@ -1972,69 +1954,6 @@ static int k8_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct,
19721954
}
19731955
}
19741956

1975-
/*
1976-
* Get the number of DCT channels in use.
1977-
*
1978-
* Return:
1979-
* number of Memory Channels in operation
1980-
* Pass back:
1981-
* contents of the DCL0_LOW register
1982-
*/
1983-
static int f1x_early_channel_count(struct amd64_pvt *pvt)
1984-
{
1985-
int i, j, channels = 0;
1986-
1987-
/* On F10h, if we are in 128 bit mode, then we are using 2 channels */
1988-
if (pvt->fam == 0x10 && (pvt->dclr0 & WIDTH_128))
1989-
return 2;
1990-
1991-
/*
1992-
* Need to check if in unganged mode: In such, there are 2 channels,
1993-
* but they are not in 128 bit mode and thus the above 'dclr0' status
1994-
* bit will be OFF.
1995-
*
1996-
* Need to check DCT0[0] and DCT1[0] to see if only one of them has
1997-
* their CSEnable bit on. If so, then SINGLE DIMM case.
1998-
*/
1999-
edac_dbg(0, "Data width is not 128 bits - need more decoding\n");
2000-
2001-
/*
2002-
* Check DRAM Bank Address Mapping values for each DIMM to see if there
2003-
* is more than just one DIMM present in unganged mode. Need to check
2004-
* both controllers since DIMMs can be placed in either one.
2005-
*/
2006-
for (i = 0; i < 2; i++) {
2007-
u32 dbam = (i ? pvt->dbam1 : pvt->dbam0);
2008-
2009-
for (j = 0; j < 4; j++) {
2010-
if (DBAM_DIMM(j, dbam) > 0) {
2011-
channels++;
2012-
break;
2013-
}
2014-
}
2015-
}
2016-
2017-
if (channels > 2)
2018-
channels = 2;
2019-
2020-
amd64_info("MCT channel count: %d\n", channels);
2021-
2022-
return channels;
2023-
}
2024-
2025-
static int f17_early_channel_count(struct amd64_pvt *pvt)
2026-
{
2027-
int i, channels = 0;
2028-
2029-
/* SDP Control bit 31 (SdpInit) is clear for unused UMC channels */
2030-
for_each_umc(i)
2031-
channels += !!(pvt->umc[i].sdp_ctrl & UMC_SDP_INIT);
2032-
2033-
amd64_info("MCT channel count: %d\n", channels);
2034-
2035-
return channels;
2036-
}
2037-
20381957
static int ddr3_cs_size(unsigned i, bool dct_width)
20391958
{
20401959
unsigned shift = 0;
@@ -2829,7 +2748,6 @@ static struct amd64_family_type family_types[] = {
28292748
.f2_id = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
28302749
.max_mcs = 2,
28312750
.ops = {
2832-
.early_channel_count = k8_early_channel_count,
28332751
.map_sysaddr_to_csrow = k8_map_sysaddr_to_csrow,
28342752
.dbam_to_cs = k8_dbam_to_chip_select,
28352753
}
@@ -2840,7 +2758,6 @@ static struct amd64_family_type family_types[] = {
28402758
.f2_id = PCI_DEVICE_ID_AMD_10H_NB_DRAM,
28412759
.max_mcs = 2,
28422760
.ops = {
2843-
.early_channel_count = f1x_early_channel_count,
28442761
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
28452762
.dbam_to_cs = f10_dbam_to_chip_select,
28462763
}
@@ -2851,7 +2768,6 @@ static struct amd64_family_type family_types[] = {
28512768
.f2_id = PCI_DEVICE_ID_AMD_15H_NB_F2,
28522769
.max_mcs = 2,
28532770
.ops = {
2854-
.early_channel_count = f1x_early_channel_count,
28552771
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
28562772
.dbam_to_cs = f15_dbam_to_chip_select,
28572773
}
@@ -2862,7 +2778,6 @@ static struct amd64_family_type family_types[] = {
28622778
.f2_id = PCI_DEVICE_ID_AMD_15H_M30H_NB_F2,
28632779
.max_mcs = 2,
28642780
.ops = {
2865-
.early_channel_count = f1x_early_channel_count,
28662781
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
28672782
.dbam_to_cs = f16_dbam_to_chip_select,
28682783
}
@@ -2873,7 +2788,6 @@ static struct amd64_family_type family_types[] = {
28732788
.f2_id = PCI_DEVICE_ID_AMD_15H_M60H_NB_F2,
28742789
.max_mcs = 2,
28752790
.ops = {
2876-
.early_channel_count = f1x_early_channel_count,
28772791
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
28782792
.dbam_to_cs = f15_m60h_dbam_to_chip_select,
28792793
}
@@ -2884,7 +2798,6 @@ static struct amd64_family_type family_types[] = {
28842798
.f2_id = PCI_DEVICE_ID_AMD_16H_NB_F2,
28852799
.max_mcs = 2,
28862800
.ops = {
2887-
.early_channel_count = f1x_early_channel_count,
28882801
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
28892802
.dbam_to_cs = f16_dbam_to_chip_select,
28902803
}
@@ -2895,7 +2808,6 @@ static struct amd64_family_type family_types[] = {
28952808
.f2_id = PCI_DEVICE_ID_AMD_16H_M30H_NB_F2,
28962809
.max_mcs = 2,
28972810
.ops = {
2898-
.early_channel_count = f1x_early_channel_count,
28992811
.map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow,
29002812
.dbam_to_cs = f16_dbam_to_chip_select,
29012813
}
@@ -2904,47 +2816,41 @@ static struct amd64_family_type family_types[] = {
29042816
.ctl_name = "F17h",
29052817
.max_mcs = 2,
29062818
.ops = {
2907-
.early_channel_count = f17_early_channel_count,
29082819
.dbam_to_cs = f17_addr_mask_to_cs_size,
29092820
}
29102821
},
29112822
[F17_M10H_CPUS] = {
29122823
.ctl_name = "F17h_M10h",
29132824
.max_mcs = 2,
29142825
.ops = {
2915-
.early_channel_count = f17_early_channel_count,
29162826
.dbam_to_cs = f17_addr_mask_to_cs_size,
29172827
}
29182828
},
29192829
[F17_M30H_CPUS] = {
29202830
.ctl_name = "F17h_M30h",
29212831
.max_mcs = 8,
29222832
.ops = {
2923-
.early_channel_count = f17_early_channel_count,
29242833
.dbam_to_cs = f17_addr_mask_to_cs_size,
29252834
}
29262835
},
29272836
[F17_M60H_CPUS] = {
29282837
.ctl_name = "F17h_M60h",
29292838
.max_mcs = 2,
29302839
.ops = {
2931-
.early_channel_count = f17_early_channel_count,
29322840
.dbam_to_cs = f17_addr_mask_to_cs_size,
29332841
}
29342842
},
29352843
[F17_M70H_CPUS] = {
29362844
.ctl_name = "F17h_M70h",
29372845
.max_mcs = 2,
29382846
.ops = {
2939-
.early_channel_count = f17_early_channel_count,
29402847
.dbam_to_cs = f17_addr_mask_to_cs_size,
29412848
}
29422849
},
29432850
[F19_CPUS] = {
29442851
.ctl_name = "F19h",
29452852
.max_mcs = 8,
29462853
.ops = {
2947-
.early_channel_count = f17_early_channel_count,
29482854
.dbam_to_cs = f17_addr_mask_to_cs_size,
29492855
}
29502856
},
@@ -2953,15 +2859,13 @@ static struct amd64_family_type family_types[] = {
29532859
.max_mcs = 12,
29542860
.flags.zn_regs_v2 = 1,
29552861
.ops = {
2956-
.early_channel_count = f17_early_channel_count,
29572862
.dbam_to_cs = f17_addr_mask_to_cs_size,
29582863
}
29592864
},
29602865
[F19_M50H_CPUS] = {
29612866
.ctl_name = "F19h_M50h",
29622867
.max_mcs = 2,
29632868
.ops = {
2964-
.early_channel_count = f17_early_channel_count,
29652869
.dbam_to_cs = f17_addr_mask_to_cs_size,
29662870
}
29672871
},
@@ -3620,7 +3524,7 @@ static int init_csrows(struct mem_ctl_info *mci)
36203524
: EDAC_SECDED;
36213525
}
36223526

3623-
for (j = 0; j < pvt->channel_count; j++) {
3527+
for (j = 0; j < fam_type->max_mcs; j++) {
36243528
dimm = csrow->channels[j]->dimm;
36253529
dimm->mtype = pvt->dram_type;
36263530
dimm->edac_mode = edac_mode;
@@ -4057,28 +3961,12 @@ static int init_one_instance(struct amd64_pvt *pvt)
40573961
{
40583962
struct mem_ctl_info *mci = NULL;
40593963
struct edac_mc_layer layers[2];
4060-
int ret = -EINVAL;
3964+
int ret = -ENOMEM;
40613965

4062-
/*
4063-
* We need to determine how many memory channels there are. Then use
4064-
* that information for calculating the size of the dynamic instance
4065-
* tables in the 'mci' structure.
4066-
*/
4067-
pvt->channel_count = pvt->ops->early_channel_count(pvt);
4068-
if (pvt->channel_count < 0)
4069-
return ret;
4070-
4071-
ret = -ENOMEM;
40723966
layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
40733967
layers[0].size = pvt->csels[0].b_cnt;
40743968
layers[0].is_virt_csrow = true;
40753969
layers[1].type = EDAC_MC_LAYER_CHANNEL;
4076-
4077-
/*
4078-
* Always allocate two channels since we can have setups with DIMMs on
4079-
* only one channel. Also, this simplifies handling later for the price
4080-
* of a couple of KBs tops.
4081-
*/
40823970
layers[1].size = fam_type->max_mcs;
40833971
layers[1].is_virt_csrow = false;
40843972

drivers/edac/amd64_edac.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ struct amd64_pvt {
346346
u8 stepping; /* ... stepping */
347347

348348
int ext_model; /* extended model value of this node */
349-
int channel_count;
350349

351350
/* Raw registers */
352351
u32 dclr0; /* DRAM Configuration Low DCT0 reg */
@@ -466,7 +465,6 @@ struct ecc_settings {
466465
* functions and per device encoding/decoding logic.
467466
*/
468467
struct low_ops {
469-
int (*early_channel_count) (struct amd64_pvt *pvt);
470468
void (*map_sysaddr_to_csrow) (struct mem_ctl_info *mci, u64 sys_addr,
471469
struct err_info *);
472470
int (*dbam_to_cs) (struct amd64_pvt *pvt, u8 dct,

0 commit comments

Comments
 (0)