blob: 6638a83173ad5e36de54adf355941fb30f37c158 [file] [log] [blame]
Jordan Crouse68182452007-05-03 21:36:51 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Jordan Crouse68182452007-05-03 21:36:51 +00003 *
4 * Copyright (C) 2006 Indrek Kruusa <indrek.kruusa@artecdesign.ee>
5 * Copyright (C) 2006 Ronald G. Minnich <rminnich@gmail.com>
6 * Copyright (C) 2007 Advanced Micro Devices, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Jordan Crouse68182452007-05-03 21:36:51 +000017 */
18
Ron Minnich5e9dc232006-07-28 16:06:16 +000019#include <console/console.h>
20#include <arch/io.h>
21#include <stdint.h>
22#include <device/device.h>
Ron Minnich5e9dc232006-07-28 16:06:16 +000023#include <stdlib.h>
24#include <string.h>
Ron Minnich5e9dc232006-07-28 16:06:16 +000025#include <cpu/x86/msr.h>
Marc Jonesbc8176c2007-05-04 18:24:55 +000026#include <cpu/amd/lxdef.h>
Ron Minnich5e9dc232006-07-28 16:06:16 +000027
Edward O'Callaghancd2c1242014-08-09 15:51:19 +100028/**
Ron Minnich5e9dc232006-07-28 16:06:16 +000029 *
30 * pcideadlock
31 *
32 * Bugtool #465 and #609
33 * PCI cache deadlock
Edward O'Callaghancd2c1242014-08-09 15:51:19 +100034 * There is also fix code in cache and PCI functions.
35 * This bug is very is pervasive.
36 */
Jordan Crouse9934b812007-05-10 18:32:28 +000037static void pcideadlock(void)
38{
Ron Minnich5e9dc232006-07-28 16:06:16 +000039 msr_t msr;
40
41 /*
Stefan Reinauer14e22772010-04-27 06:56:47 +000042 * forces serialization of all load misses. Setting this bit prevents the
43 * DM pipe from backing up if a read request has to be held up waiting
Ron Minnich5e9dc232006-07-28 16:06:16 +000044 * for PCI writes to complete.
Jordan Crouse9934b812007-05-10 18:32:28 +000045 */
Ron Minnich5e9dc232006-07-28 16:06:16 +000046 msr = rdmsr(CPU_DM_CONFIG0);
Ron Minnich5e9dc232006-07-28 16:06:16 +000047 msr.lo |= DM_CONFIG0_LOWER_MISSER_SET;
48 wrmsr(CPU_DM_CONFIG0, msr);
49
Stefan Reinauer14e22772010-04-27 06:56:47 +000050 /* write serialize memory hole to PCI. Need to unWS when something is
Ron Minnich5e9dc232006-07-28 16:06:16 +000051 * shadowed regardless of cachablility.
52 */
53 msr.lo = 0x021212121;
54 msr.hi = 0x021212121;
Jordan Crouse9934b812007-05-10 18:32:28 +000055 wrmsr(CPU_RCONF_A0_BF, msr);
56 wrmsr(CPU_RCONF_C0_DF, msr);
57 wrmsr(CPU_RCONF_E0_FF, msr);
Ron Minnich5e9dc232006-07-28 16:06:16 +000058}
59
Edward O'Callaghancd2c1242014-08-09 15:51:19 +100060/**
61 * DisableMemoryReorder
62 *
63 * PBZ 3659:
64 * The MC reordered transactions incorrectly and breaks coherency.
65 * Disable reordering and take a potential performance hit.
66 * This is safe to do here and not in MC init since there is nothing
67 * to maintain coherency with and the cache is not enabled yet.
68 */
Jordan Crouse9934b812007-05-10 18:32:28 +000069static void disablememoryreadorder(void)
70{
Ron Minnich5e9dc232006-07-28 16:06:16 +000071 msr_t msr;
Ron Minnich5e9dc232006-07-28 16:06:16 +000072
Marc Jonesbc8176c2007-05-04 18:24:55 +000073 msr = rdmsr(MC_CF8F_DATA);
Jordan Crouse9934b812007-05-10 18:32:28 +000074 msr.hi |= CF8F_UPPER_REORDER_DIS_SET;
Ron Minnich5e9dc232006-07-28 16:06:16 +000075 wrmsr(MC_CF8F_DATA, msr);
76}
77
Marc Jonesbc8176c2007-05-04 18:24:55 +000078/* For cpu version C3. Should be the only released version */
Jordan Crouse9934b812007-05-10 18:32:28 +000079void cpubug(void)
80{
81 pcideadlock();
Ron Minnich5e9dc232006-07-28 16:06:16 +000082 disablememoryreadorder();
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000083 printk(BIOS_DEBUG, "Done cpubug fixes \n");
Ron Minnich5e9dc232006-07-28 16:06:16 +000084}