Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a895bf8b authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

edac: move nr_pages to dimm struct



The number of pages is a dimm property. Move it to the dimm struct.

After this change, it is possible to add sysfs nodes for the DIMM's that
will properly represent the DIMM stick properties, including its size.

A TODO fix here is to properly represent dual-rank/quad-rank DIMMs when
the memory controller represents the memory via chip select rows.

Reviewed-by: default avatarAristeu Rozanski <arozansk@redhat.com>
Acked-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
Acked-by: default avatarChris Metcalf <cmetcalf@tilera.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5e2af0c0
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -2152,7 +2152,7 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr)
	nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT);
	nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT);


	debugf0("  (csrow=%d) DBAM map index= %d\n", csrow_nr, cs_mode);
	debugf0("  (csrow=%d) DBAM map index= %d\n", csrow_nr, cs_mode);
	debugf0("    nr_pages= %u  channel-count = %d\n",
	debugf0("    nr_pages/channel= %u  channel-count = %d\n",
		nr_pages, pvt->channel_count);
		nr_pages, pvt->channel_count);


	return nr_pages;
	return nr_pages;
@@ -2171,6 +2171,7 @@ static int init_csrows(struct mem_ctl_info *mci)
	int i, j, empty = 1;
	int i, j, empty = 1;
	enum mem_type mtype;
	enum mem_type mtype;
	enum edac_type edac_mode;
	enum edac_type edac_mode;
	int nr_pages = 0;


	amd64_read_pci_cfg(pvt->F3, NBCFG, &val);
	amd64_read_pci_cfg(pvt->F3, NBCFG, &val);


@@ -2194,9 +2195,9 @@ static int init_csrows(struct mem_ctl_info *mci)


		empty = 0;
		empty = 0;
		if (csrow_enabled(i, 0, pvt))
		if (csrow_enabled(i, 0, pvt))
			csrow->nr_pages = amd64_csrow_nr_pages(pvt, 0, i);
			nr_pages = amd64_csrow_nr_pages(pvt, 0, i);
		if (csrow_enabled(i, 1, pvt))
		if (csrow_enabled(i, 1, pvt))
			csrow->nr_pages += amd64_csrow_nr_pages(pvt, 1, i);
			nr_pages += amd64_csrow_nr_pages(pvt, 1, i);


		get_cs_base_and_mask(pvt, i, 0, &base, &mask);
		get_cs_base_and_mask(pvt, i, 0, &base, &mask);
		/* 8 bytes of resolution */
		/* 8 bytes of resolution */
@@ -2204,7 +2205,7 @@ static int init_csrows(struct mem_ctl_info *mci)
		mtype = amd64_determine_memory_type(pvt, i);
		mtype = amd64_determine_memory_type(pvt, i);


		debugf1("  for MC node %d csrow %d:\n", pvt->mc_node_id, i);
		debugf1("  for MC node %d csrow %d:\n", pvt->mc_node_id, i);
		debugf1("    nr_pages: %u\n", csrow->nr_pages);
		debugf1("    nr_pages: %u\n", nr_pages * pvt->channel_count);


		/*
		/*
		 * determine whether CHIPKILL or JUST ECC or NO ECC is operating
		 * determine whether CHIPKILL or JUST ECC or NO ECC is operating
@@ -2218,6 +2219,7 @@ static int init_csrows(struct mem_ctl_info *mci)
		for (j = 0; j < pvt->channel_count; j++) {
		for (j = 0; j < pvt->channel_count; j++) {
			csrow->channels[j].dimm->mtype = mtype;
			csrow->channels[j].dimm->mtype = mtype;
			csrow->channels[j].dimm->edac_mode = edac_mode;
			csrow->channels[j].dimm->edac_mode = edac_mode;
			csrow->channels[j].dimm->nr_pages = nr_pages;
		}
		}
	}
	}


+3 −3
Original line number Original line Diff line number Diff line
@@ -205,10 +205,10 @@ static void amd76x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
		mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
		mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
		pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
		pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
		csrow->first_page = mba_base >> PAGE_SHIFT;
		csrow->first_page = mba_base >> PAGE_SHIFT;
		csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
		dimm->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
		csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
		csrow->last_page = csrow->first_page + dimm->nr_pages - 1;
		csrow->page_mask = mba_mask >> PAGE_SHIFT;
		csrow->page_mask = mba_mask >> PAGE_SHIFT;
		dimm->grain = csrow->nr_pages << PAGE_SHIFT;
		dimm->grain = dimm->nr_pages << PAGE_SHIFT;
		dimm->mtype = MEM_RDDR;
		dimm->mtype = MEM_RDDR;
		dimm->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
		dimm->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
		dimm->edac_mode = edac_mode;
		dimm->edac_mode = edac_mode;
+5 −3
Original line number Original line Diff line number Diff line
@@ -128,6 +128,7 @@ static void __devinit cell_edac_init_csrows(struct mem_ctl_info *mci)
	struct cell_edac_priv		*priv = mci->pvt_info;
	struct cell_edac_priv		*priv = mci->pvt_info;
	struct device_node		*np;
	struct device_node		*np;
	int				j;
	int				j;
	u32				nr_pages;


	for (np = NULL;
	for (np = NULL;
	     (np = of_find_node_by_name(np, "memory")) != NULL;) {
	     (np = of_find_node_by_name(np, "memory")) != NULL;) {
@@ -142,19 +143,20 @@ static void __devinit cell_edac_init_csrows(struct mem_ctl_info *mci)
		if (of_node_to_nid(np) != priv->node)
		if (of_node_to_nid(np) != priv->node)
			continue;
			continue;
		csrow->first_page = r.start >> PAGE_SHIFT;
		csrow->first_page = r.start >> PAGE_SHIFT;
		csrow->nr_pages = resource_size(&r) >> PAGE_SHIFT;
		nr_pages = resource_size(&r) >> PAGE_SHIFT;
		csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
		csrow->last_page = csrow->first_page + nr_pages - 1;


		for (j = 0; j < csrow->nr_channels; j++) {
		for (j = 0; j < csrow->nr_channels; j++) {
			dimm = csrow->channels[j].dimm;
			dimm = csrow->channels[j].dimm;
			dimm->mtype = MEM_XDR;
			dimm->mtype = MEM_XDR;
			dimm->edac_mode = EDAC_SECDED;
			dimm->edac_mode = EDAC_SECDED;
			dimm->nr_pages = nr_pages / csrow->nr_channels;
		}
		}
		dev_dbg(mci->dev,
		dev_dbg(mci->dev,
			"Initialized on node %d, chanmask=0x%x,"
			"Initialized on node %d, chanmask=0x%x,"
			" first_page=0x%lx, nr_pages=0x%x\n",
			" first_page=0x%lx, nr_pages=0x%x\n",
			priv->node, priv->chanmask,
			priv->node, priv->chanmask,
			csrow->first_page, csrow->nr_pages);
			csrow->first_page, dimm->nr_pages);
		break;
		break;
	}
	}
}
}
+5 −3
Original line number Original line Diff line number Diff line
@@ -332,7 +332,7 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
	struct dimm_info *dimm;
	struct dimm_info *dimm;
	int index, j;
	int index, j;
	u32 mbmr, mbbar, bba;
	u32 mbmr, mbbar, bba;
	unsigned long row_size, last_nr_pages = 0;
	unsigned long row_size, nr_pages, last_nr_pages = 0;


	get_total_mem(pdata);
	get_total_mem(pdata);


@@ -351,12 +351,14 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)


		row_size = bba * (1UL << 28);	/* 256M */
		row_size = bba * (1UL << 28);	/* 256M */
		csrow->first_page = last_nr_pages;
		csrow->first_page = last_nr_pages;
		csrow->nr_pages = row_size >> PAGE_SHIFT;
		nr_pages = row_size >> PAGE_SHIFT;
		csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
		csrow->last_page = csrow->first_page + nr_pages - 1;
		last_nr_pages = csrow->last_page + 1;
		last_nr_pages = csrow->last_page + 1;


		for (j = 0; j < csrow->nr_channels; j++) {
		for (j = 0; j < csrow->nr_channels; j++) {
			dimm = csrow->channels[j].dimm;
			dimm = csrow->channels[j].dimm;

			dimm->nr_pages = nr_pages / csrow->nr_channels;
			dimm->mtype = MEM_RDDR;
			dimm->mtype = MEM_RDDR;
			dimm->edac_mode = EDAC_SECDED;
			dimm->edac_mode = EDAC_SECDED;


+4 −2
Original line number Original line Diff line number Diff line
@@ -1044,7 +1044,7 @@ static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
	int drc_drbg;		/* DRB granularity 0=64mb, 1=128mb */
	int drc_drbg;		/* DRB granularity 0=64mb, 1=128mb */
	int drc_ddim;		/* DRAM Data Integrity Mode 0=none, 2=edac */
	int drc_ddim;		/* DRAM Data Integrity Mode 0=none, 2=edac */
	u8 value;
	u8 value;
	u32 dra, drc, cumul_size, i;
	u32 dra, drc, cumul_size, i, nr_pages;


	dra = 0;
	dra = 0;
	for (index = 0; index < 4; index++) {
	for (index = 0; index < 4; index++) {
@@ -1078,11 +1078,13 @@ static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,


		csrow->first_page = last_cumul_size;
		csrow->first_page = last_cumul_size;
		csrow->last_page = cumul_size - 1;
		csrow->last_page = cumul_size - 1;
		csrow->nr_pages = cumul_size - last_cumul_size;
		nr_pages = cumul_size - last_cumul_size;
		last_cumul_size = cumul_size;
		last_cumul_size = cumul_size;


		for (i = 0; i < drc_chan + 1; i++) {
		for (i = 0; i < drc_chan + 1; i++) {
			struct dimm_info *dimm = csrow->channels[i].dimm;
			struct dimm_info *dimm = csrow->channels[i].dimm;

			dimm->nr_pages = nr_pages / (drc_chan + 1);
			dimm->grain = 1 << 12;	/* 4KiB - resolution of CELOG */
			dimm->grain = 1 << 12;	/* 4KiB - resolution of CELOG */
			dimm->mtype = MEM_RDDR;	/* only one type supported */
			dimm->mtype = MEM_RDDR;	/* only one type supported */
			dimm->dtype = mem_dev ? DEV_X4 : DEV_X8;
			dimm->dtype = mem_dev ? DEV_X4 : DEV_X8;
Loading