~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/gpu/drm/nouveau/nouveau_perf.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        pm->nr_perflvl = 1;
73
73
}
74
74
 
 
75
static struct nouveau_pm_memtiming *
 
76
nouveau_perf_timing(struct drm_device *dev, struct bit_entry *P,
 
77
                    u16 memclk, u8 *entry, u8 recordlen, u8 entries)
 
78
{
 
79
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
80
        struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
 
81
        struct nvbios *bios = &dev_priv->vbios;
 
82
        u8 ramcfg;
 
83
        int i;
 
84
 
 
85
        /* perf v2 has a separate "timing map" table, we have to match
 
86
         * the target memory clock to a specific entry, *then* use
 
87
         * ramcfg to select the correct subentry
 
88
         */
 
89
        if (P->version == 2) {
 
90
                u8 *tmap = ROMPTR(bios, P->data[4]);
 
91
                if (!tmap) {
 
92
                        NV_DEBUG(dev, "no timing map pointer\n");
 
93
                        return NULL;
 
94
                }
 
95
 
 
96
                if (tmap[0] != 0x10) {
 
97
                        NV_WARN(dev, "timing map 0x%02x unknown\n", tmap[0]);
 
98
                        return NULL;
 
99
                }
 
100
 
 
101
                entry = tmap + tmap[1];
 
102
                recordlen = tmap[2] + (tmap[4] * tmap[3]);
 
103
                for (i = 0; i < tmap[5]; i++, entry += recordlen) {
 
104
                        if (memclk >= ROM16(entry[0]) &&
 
105
                            memclk <= ROM16(entry[2]))
 
106
                                break;
 
107
                }
 
108
 
 
109
                if (i == tmap[5]) {
 
110
                        NV_WARN(dev, "no match in timing map table\n");
 
111
                        return NULL;
 
112
                }
 
113
 
 
114
                entry += tmap[2];
 
115
                recordlen = tmap[3];
 
116
                entries   = tmap[4];
 
117
        }
 
118
 
 
119
        ramcfg = (nv_rd32(dev, NV_PEXTDEV_BOOT_0) & 0x0000003c) >> 2;
 
120
        if (bios->ram_restrict_tbl_ptr)
 
121
                ramcfg = bios->data[bios->ram_restrict_tbl_ptr + ramcfg];
 
122
 
 
123
        if (ramcfg >= entries) {
 
124
                NV_WARN(dev, "ramcfg strap out of bounds!\n");
 
125
                return NULL;
 
126
        }
 
127
 
 
128
        entry += ramcfg * recordlen;
 
129
        if (entry[1] >= pm->memtimings.nr_timing) {
 
130
                NV_WARN(dev, "timingset %d does not exist\n", entry[1]);
 
131
                return NULL;
 
132
        }
 
133
 
 
134
        return &pm->memtimings.timing[entry[1]];
 
135
}
 
136
 
75
137
void
76
138
nouveau_perf_init(struct drm_device *dev)
77
139
{
120
182
                entries   = perf[2];
121
183
        }
122
184
 
 
185
        if (entries > NOUVEAU_PM_MAX_LEVEL) {
 
186
                NV_DEBUG(dev, "perf table has too many entries - buggy vbios?\n");
 
187
                entries = NOUVEAU_PM_MAX_LEVEL;
 
188
        }
 
189
 
123
190
        entry = perf + headerlen;
124
191
        for (i = 0; i < entries; i++) {
125
192
                struct nouveau_pm_level *perflvl = &pm->perflvl[pm->nr_perflvl];
126
193
 
 
194
                perflvl->timing = NULL;
 
195
 
127
196
                if (entry[0] == 0xff) {
128
197
                        entry += recordlen;
129
198
                        continue;
174
243
#define subent(n) entry[perf[2] + ((n) * perf[3])]
175
244
                        perflvl->fanspeed = 0; /*XXX*/
176
245
                        perflvl->voltage = entry[2];
177
 
                        perflvl->core = (ROM16(subent(0)) & 0xfff) * 1000;
178
 
                        perflvl->shader = (ROM16(subent(1)) & 0xfff) * 1000;
179
 
                        perflvl->memory = (ROM16(subent(2)) & 0xfff) * 1000;
 
246
                        if (dev_priv->card_type == NV_50) {
 
247
                                perflvl->core = ROM16(subent(0)) & 0xfff;
 
248
                                perflvl->shader = ROM16(subent(1)) & 0xfff;
 
249
                                perflvl->memory = ROM16(subent(2)) & 0xfff;
 
250
                        } else {
 
251
                                perflvl->shader = ROM16(subent(3)) & 0xfff;
 
252
                                perflvl->core   = perflvl->shader / 2;
 
253
                                perflvl->unk0a  = ROM16(subent(4)) & 0xfff;
 
254
                                perflvl->memory = ROM16(subent(5)) & 0xfff;
 
255
                        }
 
256
 
 
257
                        perflvl->core *= 1000;
 
258
                        perflvl->shader *= 1000;
 
259
                        perflvl->memory *= 1000;
 
260
                        perflvl->unk0a *= 1000;
180
261
                        break;
181
262
                }
182
263
 
190
271
                        }
191
272
                }
192
273
 
 
274
                /* get the corresponding memory timings */
 
275
                if (version > 0x15) {
 
276
                        /* last 3 args are for < 0x40, ignored for >= 0x40 */
 
277
                        perflvl->timing =
 
278
                                nouveau_perf_timing(dev, &P,
 
279
                                                    perflvl->memory / 1000,
 
280
                                                    entry + perf[3],
 
281
                                                    perf[5], perf[4]);
 
282
                }
 
283
 
193
284
                snprintf(perflvl->name, sizeof(perflvl->name),
194
285
                         "performance_level_%d", i);
195
286
                perflvl->id = i;