203d63b81e7025b98571f910eb0971cf12a1623d
[coreboot.git] / src / cpu / amd / model_lx / cpubug.c
1 /*
2  * This file is part of the coreboot project.
3  *
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.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
21  */
22
23 #include <console/console.h>
24 #include <arch/io.h>
25 #include <stdint.h>
26 #include <device/device.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <bitops.h>
30 #include <cpu/x86/msr.h>
31 #include <cpu/amd/lxdef.h>
32
33 /**************************************************************************
34  *
35  *      pcideadlock
36  *
37  *      Bugtool #465 and #609
38  *      PCI cache deadlock
39  *      There is also fix code in cache and PCI functions. This bug is very is pervasive.
40  *
41  **************************************************************************/
42 static void pcideadlock(void)
43 {
44         msr_t msr;
45
46         /*
47          * forces serialization of all load misses. Setting this bit prevents the 
48          * DM pipe from backing up if a read request has to be held up waiting 
49          * for PCI writes to complete.
50          */
51         msr = rdmsr(CPU_DM_CONFIG0);
52         msr.lo |= DM_CONFIG0_LOWER_MISSER_SET;
53         wrmsr(CPU_DM_CONFIG0, msr);
54
55         /* write serialize memory hole to PCI. Need to unWS when something is 
56          * shadowed regardless of cachablility.
57          */
58         msr.lo = 0x021212121;
59         msr.hi = 0x021212121;
60         wrmsr(CPU_RCONF_A0_BF, msr);
61         wrmsr(CPU_RCONF_C0_DF, msr);
62         wrmsr(CPU_RCONF_E0_FF, msr);
63 }
64
65 /****************************************************************************/
66 /***/
67 /**     DisableMemoryReorder*/
68 /***/
69 /**     PBZ 3659:*/
70 /**      The MC reordered transactions incorrectly and breaks coherency.*/
71 /**      Disable reording and take a potential performance hit.*/
72 /**      This is safe to do here and not in MC init since there is nothing*/
73 /**      to maintain coherency with and the cache is not enabled yet.*/
74 /***/
75 /****************************************************************************/
76 static void disablememoryreadorder(void)
77 {
78         msr_t msr;
79
80         msr = rdmsr(MC_CF8F_DATA);
81         msr.hi |= CF8F_UPPER_REORDER_DIS_SET;
82         wrmsr(MC_CF8F_DATA, msr);
83 }
84
85 /* For cpu version C3. Should be the only released version */
86 void cpubug(void)
87 {
88         pcideadlock();
89         disablememoryreadorder();
90         printk(BIOS_DEBUG, "Done cpubug fixes \n");
91 }