59 int nvclks, mclks, pclks, crtpagemiss;
60 int found, mclk_extra, mclk_loop,
cbs, m1,
p1;
61 int mclk_freq, pclk_freq, nvclk_freq;
62 int us_m, us_n, us_p, crtc_drain_rate;
63 int cpm_us, us_crt, clwm;
83 mclk_loop = mclks + mclk_extra;
84 us_m = mclk_loop * 1000 * 1000 / mclk_freq;
85 us_n = nvclks * 1000 * 1000 / nvclk_freq;
86 us_p = nvclks * 1000 * 1000 / pclk_freq;
88 crtc_drain_rate = pclk_freq * bpp / 8;
91 cpm_us = crtpagemiss * pagemiss * 1000 * 1000 / mclk_freq;
92 us_crt = cpm_us + us_m + us_n + us_p;
93 clwm = us_crt * crtc_drain_rate / (1000 * 1000);
96 m1 = clwm + cbs - 512;
97 p1 = m1 * pclk_freq / mclk_freq;
99 if ((p1 < m1 && m1 > 0) || clwm > 519) {
114 int fill_rate, drain_rate;
115 int pclks, nvclks, mclks, xclks;
116 int pclk_freq, nvclk_freq, mclk_freq;
117 int fill_lat, extra_lat;
118 int max_burst_o, max_burst_l;
119 int fifo_len, min_lwm, max_lwm;
120 const int burst_lat = 80;
128 drain_rate = pclk_freq * arb->
bpp / 8;
156 fill_lat = mclks * 1000 * 1000 / mclk_freq
157 + nvclks * 1000 * 1000 / nvclk_freq
158 + pclks * 1000 * 1000 / pclk_freq;
165 + (arb->
bpp == 32 ? 8 : 4);
167 extra_lat = xclks * 1000 * 1000 / mclk_freq;
171 extra_lat += fill_lat + extra_lat + burst_lat;
176 max_burst_o = (1 + fifo_len - extra_lat * drain_rate / (1000 * 1000))
177 * (fill_rate / 1000) / ((fill_rate - drain_rate) / 1000);
178 fifo->
burst =
min(max_burst_o, 1024);
181 max_burst_l = burst_lat * fill_rate / (1000 * 1000);
188 min_lwm = (fill_lat + extra_lat) * drain_rate / (1000 * 1000) + 1;
189 max_lwm = fifo_len - fifo->
burst
190 + fill_lat * drain_rate / (1000 * 1000)
191 + fifo->
burst * drain_rate / fill_rate;
193 fifo->
lwm = min_lwm + 10 * (max_lwm - min_lwm) / 100;
198 int *burst,
int *lwm)
208 sim_data.pclk_khz = VClk;
209 sim_data.mclk_khz = MClk;
210 sim_data.nvclk_khz = NVClk;
212 sim_data.two_heads = nv_two_heads(dev);
213 if ((dev->pci_device & 0xffff) == 0x01a0 ||
214 (dev->pci_device & 0xffff) == 0x01f0 ) {
219 sim_data.memory_type = (type >> 12) & 1;
220 sim_data.memory_width = 64;
221 sim_data.mem_latency = 3;
222 sim_data.mem_page_miss = 10;
226 sim_data.mem_latency = cfg1 & 0xf;
227 sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
230 if (nv_device(drm->
device)->card_type == NV_04)
231 nv04_calc_arb(&fifo_data, &sim_data);
233 nv10_calc_arb(&fifo_data, &sim_data);
235 *burst =
ilog2(fifo_data.burst >> 4);
236 *lwm = fifo_data.lwm >> 3;
240 nv20_update_arb(
int *burst,
int *lwm)
242 unsigned int fifo_size, burst_size, graphics_lwm;
246 graphics_lwm = fifo_size - burst_size;
248 *burst =
ilog2(burst_size >> 5);
249 *lwm = graphics_lwm >> 3;
257 if (nv_device(drm->
device)->card_type < NV_20)
258 nv04_update_arb(dev, vclk, bpp, burst, lwm);
259 else if ((dev->pci_device & 0xfff0) == 0x0240 ||
260 (dev->pci_device & 0xfff0) == 0x03d0 ) {
264 nv20_update_arb(burst, lwm);