ao_cpu.c revision fb2f18f820d90b001aea4fb27dd654bc1263c440
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * Common Development and Distribution License (the "License").
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * or http://www.opensolaris.org/os/licensing.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
fb2f18f820d90b001aea4fb27dd654bc1263c440esaxe * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/types.h>
fb2f18f820d90b001aea4fb27dd654bc1263c440esaxe#include <sys/pghw.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/cmn_err.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/sysmacros.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/fm/protocol.h>
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm#include <sys/x86_archext.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include "ao.h"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * AMD Opteron CPU Subroutines
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The following three tunables are used to determine the scrubbing rates for
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the D$, L2$, and DRAM hardware scrubbers. The values range from 0x00-0x16
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * as described in BKDG 3.6.6 Scrub Control Register. A value of zero disables
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the scrubber. Values above zero indicate rates in descending order.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The current default values are used on several Sun systems. In the future
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * this code should assign values dynamically based on memory sizing. If you
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * tune these values manually be aware of the following architectural issue:
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * At present, Opteron can only survive certain kinds of multi-bit errors if
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * they are detected by the scrubbers. Therefore in general we want these
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * values tuned as high as possible without impacting workload performance.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_rate_dcache = 8; /* 64B every 5.12 us */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_rate_l2cache = 9; /* 64B every 10.2 us */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_rate_dram = 0xd; /* 64B every 163.8 us */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_system; /* debug stash for system's value */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_bios; /* debug stash for bios's value */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_lo; /* debug stash for system low addr */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiuint32_t ao_scrub_hi; /* debug stash for system high addr */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindienum {
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm AO_SCRUB_BIOSDEFAULT, /* retain system default values */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi AO_SCRUB_FIXED, /* assign ao_scrub_rate_* values */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi AO_SCRUB_MAX /* assign max of system and tunables */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi} ao_scrub_policy = AO_SCRUB_MAX;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindinvlist_t *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiao_fmri_create(ao_data_t *ao, nv_alloc_t *nva)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t *nvl = fm_nvlist_create(nva);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi fm_fmri_hc_set(nvl, FM_HC_SCHEME_VERSION, NULL, NULL, 3,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "motherboard", 0,
fb2f18f820d90b001aea4fb27dd654bc1263c440esaxe "chip", pg_plat_hw_instance_id(ao->ao_cpu, PGHW_CHIP),
fb2f18f820d90b001aea4fb27dd654bc1263c440esaxe "cpu", cpuid_get_clogid(ao->ao_cpu));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (nvl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Return the maximum scrubbing rate between r1 and r2, where r2 is extracted
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * from the specified 'cfg' register value using 'mask' and 'shift'. If a
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * value is zero, scrubbing is off so return the opposite value. Otherwise
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the maximum rate is the smallest non-zero value of the two values.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic uint32_t
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiao_scrubber_max(uint32_t r1, uint32_t cfg, uint32_t mask, uint32_t shift)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint32_t r2 = (cfg & mask) >> shift;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (r1 != 0 && r2 != 0)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (MIN(r1, r2));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (r1 ? r1 : r2);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Enable the chip-specific hardware scrubbers for the D$, L2$, and DRAM, and
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * return a boolean value indicating if we enabled the DRAM scrubber. We set
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the scrubber rate based on a set of tunables defined at the top of the file.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The 'base' parameter is the DRAM Base Address for this chip and is used to
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * determine where the scrubber starts. The 'ilen' value is the IntvlEn field
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * from the DRAM configuration indicating the node-interleaving configuration.
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm *
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * Where chip-select sparing is available the DRAM scrub address registers
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * must not be modified while a swap is in-progress. This can't happen
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * because we (the amd cpu module) take control of the online spare
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * away from the BIOS when we perform NB configuration and we complete
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * that operation before the memory controller driver loads.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiint
8a40a695ee676a322b094e9afe5375567bfb51e3gavinmao_scrubber_enable(void *data, uint64_t base, uint64_t ilen, int csdiscontig)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_data_t *ao = data;
fb2f18f820d90b001aea4fb27dd654bc1263c440esaxe chipid_t chipid = pg_plat_hw_instance_id(ao->ao_cpu, PGHW_CHIP);
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm uint32_t rev = cpuid_getchiprev(ao->ao_cpu);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint32_t scrubctl, lo, hi;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int rv = 1;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Read the initial scrubber configuration and save it for debugging.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If ao_scrub_policy is DEFAULT, return immediately. Otherwise we
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * disable scrubbing activity while we fiddle with the configuration.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi scrubctl = ao_pcicfg_read(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBCTL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi cas32(&ao_scrub_bios, 0, scrubctl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm if (ao_scrub_policy == AO_SCRUB_BIOSDEFAULT)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return ((scrubctl & AMD_NB_SCRUBCTL_DRAM_MASK) != 0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi scrubctl &= ~AMD_NB_SCRUBCTL_DRAM_MASK;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi scrubctl &= ~AMD_NB_SCRUBCTL_L2_MASK;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi scrubctl &= ~AMD_NB_SCRUBCTL_DC_MASK;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_pcicfg_write(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBCTL, scrubctl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Read the DRAM Scrub Address Low and High registers, clear their
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * address fields, enable sequential-redirect mode, and update the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * address fields using the specified DRAM Base Address.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi lo = ao_pcicfg_read(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBADDR_LO);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi hi = ao_pcicfg_read(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBADDR_HI);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi lo &= ~AMD_NB_SCRUBADDR_LO_MASK;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi hi &= ~AMD_NB_SCRUBADDR_HI_MASK;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi lo |= AMD_NB_SCRUBADDR_MKLO(base) | AMD_NB_SCRUBADDR_LO_SCRUBREDIREN;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi hi |= AMD_NB_SCRUBADDR_MKHI(base);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_lo = lo;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_hi = hi;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_pcicfg_write(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBADDR_LO, lo);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_pcicfg_write(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBADDR_HI, hi);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (ao_scrub_rate_dcache > AMD_NB_SCRUBCTL_RATE_MAX) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi cmn_err(CE_WARN, "ao_scrub_rate_dcache is too large; "
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "resetting to 0x%x\n", AMD_NB_SCRUBCTL_RATE_MAX);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_dcache = AMD_NB_SCRUBCTL_RATE_MAX;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (ao_scrub_rate_l2cache > AMD_NB_SCRUBCTL_RATE_MAX) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi cmn_err(CE_WARN, "ao_scrub_rate_l2cache is too large; "
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "resetting to 0x%x\n", AMD_NB_SCRUBCTL_RATE_MAX);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_l2cache = AMD_NB_SCRUBCTL_RATE_MAX;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (ao_scrub_rate_dram > AMD_NB_SCRUBCTL_RATE_MAX) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi cmn_err(CE_WARN, "ao_scrub_rate_dram is too large; "
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "resetting to 0x%x\n", AMD_NB_SCRUBCTL_RATE_MAX);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_dram = AMD_NB_SCRUBCTL_RATE_MAX;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm switch (ao_scrub_policy) {
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm case AO_SCRUB_FIXED:
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm /* Use the system values checked above */
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm break;
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm default:
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm cmn_err(CE_WARN, "Unknown ao_scrub_policy value %d - "
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm "using default policy of AO_SCRUB_MAX", ao_scrub_policy);
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm /*FALLTHRU*/
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm case AO_SCRUB_MAX:
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_dcache =
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrubber_max(ao_scrub_rate_dcache, ao_scrub_bios,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi AMD_NB_SCRUBCTL_DC_MASK, AMD_NB_SCRUBCTL_DC_SHIFT);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_l2cache =
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrubber_max(ao_scrub_rate_l2cache, ao_scrub_bios,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi AMD_NB_SCRUBCTL_L2_MASK, AMD_NB_SCRUBCTL_L2_SHIFT);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_dram =
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrubber_max(ao_scrub_rate_dram, ao_scrub_bios,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi AMD_NB_SCRUBCTL_DRAM_MASK, AMD_NB_SCRUBCTL_DRAM_SHIFT);
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm break;
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm }
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm#ifdef OPTERON_ERRATUM_99
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm /*
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * This erratum applies on revisions D and earlier.
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm *
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * Do not enable the dram scrubber is the chip-select ranges
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * for the node are not contiguous.
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm */
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm if (csdiscontig && !X86_CHIPREV_ATLEAST(rev, X86_CHIPREV_AMD_F_REV_E)) {
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm cmn_err(CE_CONT, "?Opteron DRAM scrubber disabled on revision "
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm "%s chip because DRAM hole is present on this node",
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm cpuid_getchiprevstr(ao->ao_cpu));
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm ao_scrub_rate_dram = 0;
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm rv = 0;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm#endif
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#ifdef OPTERON_ERRATUM_101
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm * This erratum applies on revisions D and earlier.
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If the DRAM Base Address register's IntlvEn field indicates that
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * node interleaving is enabled, we must disable the DRAM scrubber
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and return zero to indicate that Solaris should use s/w instead.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm if (ilen != 0 && ao_scrub_rate_dram != 0 &&
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm !X86_CHIPREV_ATLEAST(rev, X86_CHIPREV_AMD_F_REV_E)) {
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm cmn_err(CE_CONT, "?Opteron DRAM scrubber disabled on revision "
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm "%s chip because DRAM memory is node-interleaved",
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm cpuid_getchiprevstr(ao->ao_cpu));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_dram = 0;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi rv = 0;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#endif
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi scrubctl |= AMD_NB_MKSCRUBCTL(ao_scrub_rate_dcache,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_rate_l2cache, ao_scrub_rate_dram);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_scrub_system = scrubctl;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ao_pcicfg_write(chipid, AMD_NB_FUNC, AMD_NB_REG_SCRUBCTL, scrubctl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (rv);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}