Commit ed05ba72 authored by Ilia Mirkin's avatar Ilia Mirkin Committed by Ben Skeggs

drm/nouveau/clk: allow end-user reclocking for nv40, nvaa, and nve0 clock types

Use with caution.
Signed-off-by: default avatarIlia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent d2ed15b2
...@@ -77,6 +77,8 @@ struct nouveau_clock { ...@@ -77,6 +77,8 @@ struct nouveau_clock {
int tstate; /* thermal adjustment (max-) */ int tstate; /* thermal adjustment (max-) */
int dstate; /* display adjustment (min+) */ int dstate; /* display adjustment (min+) */
bool allow_reclock;
int (*read)(struct nouveau_clock *, enum nv_clk_src); int (*read)(struct nouveau_clock *, enum nv_clk_src);
int (*calc)(struct nouveau_clock *, struct nouveau_cstate *); int (*calc)(struct nouveau_clock *, struct nouveau_cstate *);
int (*prog)(struct nouveau_clock *); int (*prog)(struct nouveau_clock *);
...@@ -106,8 +108,8 @@ struct nouveau_clocks { ...@@ -106,8 +108,8 @@ struct nouveau_clocks {
int mdiv; int mdiv;
}; };
#define nouveau_clock_create(p,e,o,i,d) \ #define nouveau_clock_create(p,e,o,i,r,d) \
nouveau_clock_create_((p), (e), (o), (i), sizeof(**d), (void **)d) nouveau_clock_create_((p), (e), (o), (i), (r), sizeof(**d), (void **)d)
#define nouveau_clock_destroy(p) ({ \ #define nouveau_clock_destroy(p) ({ \
struct nouveau_clock *clk = (p); \ struct nouveau_clock *clk = (p); \
_nouveau_clock_dtor(nv_object(clk)); \ _nouveau_clock_dtor(nv_object(clk)); \
...@@ -121,7 +123,7 @@ struct nouveau_clocks { ...@@ -121,7 +123,7 @@ struct nouveau_clocks {
int nouveau_clock_create_(struct nouveau_object *, struct nouveau_object *, int nouveau_clock_create_(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, struct nouveau_oclass *,
struct nouveau_clocks *, int, void **); struct nouveau_clocks *, bool, int, void **);
void _nouveau_clock_dtor(struct nouveau_object *); void _nouveau_clock_dtor(struct nouveau_object *);
int _nouveau_clock_init(struct nouveau_object *); int _nouveau_clock_init(struct nouveau_object *);
#define _nouveau_clock_fini _nouveau_subdev_fini #define _nouveau_clock_fini _nouveau_subdev_fini
......
...@@ -346,7 +346,7 @@ nouveau_clock_ustate_update(struct nouveau_clock *clk, int req) ...@@ -346,7 +346,7 @@ nouveau_clock_ustate_update(struct nouveau_clock *clk, int req)
struct nouveau_pstate *pstate; struct nouveau_pstate *pstate;
int i = 0; int i = 0;
/* YKW repellant */ if (!clk->allow_reclock)
return -ENOSYS; return -ENOSYS;
if (req != -1 && req != -2) { if (req != -1 && req != -2) {
...@@ -456,6 +456,7 @@ nouveau_clock_create_(struct nouveau_object *parent, ...@@ -456,6 +456,7 @@ nouveau_clock_create_(struct nouveau_object *parent,
struct nouveau_object *engine, struct nouveau_object *engine,
struct nouveau_oclass *oclass, struct nouveau_oclass *oclass,
struct nouveau_clocks *clocks, struct nouveau_clocks *clocks,
bool allow_reclock,
int length, void **object) int length, void **object)
{ {
struct nouveau_device *device = nv_device(parent); struct nouveau_device *device = nv_device(parent);
...@@ -478,6 +479,8 @@ nouveau_clock_create_(struct nouveau_object *parent, ...@@ -478,6 +479,8 @@ nouveau_clock_create_(struct nouveau_object *parent,
ret = nouveau_pstate_new(clk, idx++); ret = nouveau_pstate_new(clk, idx++);
} while (ret == 0); } while (ret == 0);
clk->allow_reclock = allow_reclock;
mode = nouveau_stropt(device->cfgopt, "NvClkMode", &arglen); mode = nouveau_stropt(device->cfgopt, "NvClkMode", &arglen);
if (mode) { if (mode) {
if (!strncasecmpz(mode, "disabled", arglen)) { if (!strncasecmpz(mode, "disabled", arglen)) {
......
...@@ -82,7 +82,8 @@ nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -82,7 +82,8 @@ nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv04_clock_priv *priv; struct nv04_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, &priv); ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, false,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -213,7 +213,8 @@ nv40_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -213,7 +213,8 @@ nv40_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv40_clock_priv *priv; struct nv40_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nv40_domain, &priv); ret = nouveau_clock_create(parent, engine, oclass, nv40_domain, true,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -507,7 +507,7 @@ nv50_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -507,7 +507,7 @@ nv50_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, pclass->domains, ret = nouveau_clock_create(parent, engine, oclass, pclass->domains,
&priv); false, &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -302,7 +302,8 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -302,7 +302,8 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nva3_clock_priv *priv; struct nva3_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nva3_domain, &priv); ret = nouveau_clock_create(parent, engine, oclass, nva3_domain, false,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -421,7 +421,8 @@ nvaa_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -421,7 +421,8 @@ nvaa_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nvaa_clock_priv *priv; struct nvaa_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, &priv); ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, true,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -437,7 +437,8 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -437,7 +437,8 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nvc0_clock_priv *priv; struct nvc0_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nvc0_domain, &priv); ret = nouveau_clock_create(parent, engine, oclass, nvc0_domain, false,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
...@@ -473,7 +473,8 @@ nve0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -473,7 +473,8 @@ nve0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nve0_clock_priv *priv; struct nve0_clock_priv *priv;
int ret; int ret;
ret = nouveau_clock_create(parent, engine, oclass, nve0_domain, &priv); ret = nouveau_clock_create(parent, engine, oclass, nve0_domain, true,
&priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment