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

Commit 39094443 authored by Borislav Petkov's avatar Borislav Petkov
Browse files

EDAC: Fixup scrubrate manipulation



Make the ->{get|set}_sdram_scrub_rate return the actual scrub rate
bandwidth it succeeded setting and remove superfluous arg pointer used
for that. A negative value returned still means that an error occurred
while setting the scrubrate. Document this for future reference.

Signed-off-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
parent 360b7f3c
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -77,7 +77,11 @@ static int ddr3_dbam[] = { [0] = -1,
 *FIXME: Produce a better mapping/linearisation.
 */

struct scrubrate scrubrates[] = {

struct scrubrate {
       u32 scrubval;           /* bit pattern for scrub rate */
       u32 bandwidth;          /* bandwidth consumed (bytes/sec) */
} scrubrates[] = {
	{ 0x01, 1600000000UL},
	{ 0x02, 800000000UL},
	{ 0x03, 400000000UL},
@@ -151,14 +155,12 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
	}

	scrubval = scrubrates[i].scrubval;
	if (scrubval)
		amd64_info("Setting scrub rate bandwidth: %u\n",
			   scrubrates[i].bandwidth);
	else
		amd64_info("Turning scrubbing off.\n");

	pci_write_bits32(ctl, K8_SCRCTRL, scrubval, 0x001F);

	if (scrubval)
		return scrubrates[i].bandwidth;

	return 0;
}

@@ -169,11 +171,11 @@ static int amd64_set_scrub_rate(struct mem_ctl_info *mci, u32 bw)
	return __amd64_set_scrub_rate(pvt->F3, bw, pvt->min_scrubrate);
}

static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
static int amd64_get_scrub_rate(struct mem_ctl_info *mci)
{
	struct amd64_pvt *pvt = mci->pvt_info;
	u32 scrubval = 0;
	int status = -1, i;
	int i, retval = -EINVAL;

	amd64_read_pci_cfg(pvt->F3, K8_SCRCTRL, &scrubval);

@@ -183,13 +185,11 @@ static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw)

	for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
		if (scrubrates[i].scrubval == scrubval) {
			*bw = scrubrates[i].bandwidth;
			status = 0;
			retval = scrubrates[i].bandwidth;
			break;
		}
	}

	return status;
	return retval;
}

/* Map from a CSROW entry to the mask entry that operates on it */
+0 −6
Original line number Diff line number Diff line
@@ -482,12 +482,6 @@ struct ecc_settings {
	} flags;
};

struct scrubrate {
       u32 scrubval;           /* bit pattern for scrub rate */
       u32 bandwidth;          /* bandwidth consumed (bytes/sec) */
};

extern struct scrubrate scrubrates[23];
extern const char *tt_msgs[4];
extern const char *ll_msgs[4];
extern const char *rrrr_msgs[16];
+5 −4
Original line number Diff line number Diff line
@@ -818,9 +818,10 @@ static void cpc925_del_edac_devices(void)
}

/* Convert current back-ground scrub rate into byte/sec bandwith */
static int cpc925_get_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
static int cpc925_get_sdram_scrub_rate(struct mem_ctl_info *mci)
{
	struct cpc925_mc_pdata *pdata = mci->pvt_info;
	int bw;
	u32 mscr;
	u8 si;

@@ -832,11 +833,11 @@ static int cpc925_get_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
	if (((mscr & MSCR_SCRUB_MOD_MASK) != MSCR_BACKGR_SCRUB) ||
	    (si == 0)) {
		cpc925_mc_printk(mci, KERN_INFO, "Scrub mode not enabled\n");
		*bw = 0;
		bw = 0;
	} else
		*bw = CPC925_SCRUB_BLOCK_SIZE * 0xFA67 / si;
		bw = CPC925_SCRUB_BLOCK_SIZE * 0xFA67 / si;

	return 0;
	return bw;
}

/* Return 0 for single channel; 1 for dual channel */
+3 −5
Original line number Diff line number Diff line
@@ -983,11 +983,11 @@ static int set_sdram_scrub_rate(struct mem_ctl_info *mci, u32 new_bw)

	pci_write_config_word(pdev, E752X_MCHSCRB, scrubrates[i].scrubval);

	return 0;
	return scrubrates[i].bandwidth;
}

/* Convert current scrub rate value into byte/sec bandwidth */
static int get_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
static int get_sdram_scrub_rate(struct mem_ctl_info *mci)
{
	const struct scrubrate *scrubrates;
	struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info;
@@ -1013,10 +1013,8 @@ static int get_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
			"Invalid sdram scrub control value: 0x%x\n", scrubval);
		return -1;
	}
	return scrubrates[i].bandwidth;

	*bw = scrubrates[i].bandwidth;

	return 0;
}

/* Return 1 if dual channel mode is active.  Else return 0. */
+1 −1
Original line number Diff line number Diff line
@@ -387,7 +387,7 @@ struct mem_ctl_info {
	   representation and converts it to the closest matching
	   bandwith in bytes/sec.
	 */
	int (*get_sdram_scrub_rate) (struct mem_ctl_info * mci, u32 * bw);
	int (*get_sdram_scrub_rate) (struct mem_ctl_info * mci);


	/* pointer to edac checking routine */
Loading