0001-Avoiding-an-infinite-loop-during-P-state-adjustment-.patch

vadaszi, 02/22/2014 04:48 PM

Download (2.24 KB)

View differences:

sys/platform/pc64/x86_64/cpufreq_machdep.c
67 67
int
68 68
amd0f_set_fidvid(const struct amd0f_fidvid *fv, const struct amd0f_xsit *xsit)
69 69
{
70
	uint32_t val, cfid, cvid, tvid;
70
	uint32_t val, cfid, cvid;
71
	int rvo;
71 72
	uint64_t status;
72 73

  
73 74
	/*
......
84 85
		return 0;
85 86

  
86 87
	/*
87
	 * Phase 1: Raise core voltage to the TargetVID
88
	 * Phase 1: Raise core voltage to requested VID if frequency is
89
	 * going up.
88 90
	 */
89 91
	if ((fv->fid & ~0x1) > (cfid & ~0x1) || cvid > fv->vid) {
90 92
		KKASSERT(fv->vid >= xsit->rvo);
91
		tvid = fv->vid - xsit->rvo;
92 93
	} else {
93 94
		KKASSERT(cvid >= xsit->rvo);
94
		tvid = cvid - xsit->rvo;
95 95
	}
96
	while (cvid > tvid) {
96
	while (cvid > fv->vid) {
97 97
		if (cvid > (1 << xsit->mvs))
98 98
			val = cvid - (1 << xsit->mvs);
99 99
		else
......
103 103
		cvid = AMD0F_STA_CVID(status);
104 104
		AMD0F_DELAY_VST(xsit->vst);
105 105
	}
106
	/* ... then raise to voltage + RVO (if required) */
107
	for (rvo = xsit->rvo; rvo > 0 && cvid > 0; --rvo) {
108
		/* XXX It's not clear from spec if we have to do that
109
		 * in 0.25 step or in MVS.  Therefore do it as it's done
110
		 * under Linux */
111
		AMD0F_WRITE_FIDVID(cfid, cvid - 1, 0ULL);
112
		AMD0F_WAIT_FIDVID_CHG(status);
113
		cvid = AMD0F_STA_CVID(status);
114
		AMD0F_DELAY_VST(xsit->vst);
115
	}
106 116

  
107 117
	/*
108 118
	 * Phase 2: Change to requested core frequency
109
-