Skip to content

Commit

Permalink
drm/nouveau/devinit: add interface to check if a mmio access by scrip…
Browse files Browse the repository at this point in the history
…ts is ok

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Mar 26, 2014
1 parent 0a8649f commit 3219adc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/core/include/subdev/devinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct nouveau_devinit {
bool post;
void (*meminit)(struct nouveau_devinit *);
int (*pll_set)(struct nouveau_devinit *, u32 type, u32 freq);
u32 (*mmio)(struct nouveau_devinit *, u32 addr);
};

static inline struct nouveau_devinit *
Expand Down
11 changes: 8 additions & 3 deletions drivers/gpu/drm/nouveau/core/subdev/bios/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ init_conn(struct nvbios_init *init)
static inline u32
init_nvreg(struct nvbios_init *init, u32 reg)
{
struct nouveau_devinit *devinit = nouveau_devinit(init->bios);

/* C51 (at least) sometimes has the lower bits set which the VBIOS
* interprets to mean that access needs to go through certain IO
* ports instead. The NVIDIA binary driver has been seen to access
Expand Down Expand Up @@ -147,14 +149,17 @@ init_nvreg(struct nvbios_init *init, u32 reg)

if (reg & ~0x00fffffc)
warn("unknown bits in register 0x%08x\n", reg);

if (devinit->mmio)
reg = devinit->mmio(devinit, reg);
return reg;
}

static u32
init_rd32(struct nvbios_init *init, u32 reg)
{
reg = init_nvreg(init, reg);
if (init_exec(init))
if (reg != ~0 && init_exec(init))
return nv_rd32(init->subdev, reg);
return 0x00000000;
}
Expand All @@ -163,15 +168,15 @@ static void
init_wr32(struct nvbios_init *init, u32 reg, u32 val)
{
reg = init_nvreg(init, reg);
if (init_exec(init))
if (reg != ~0 && init_exec(init))
nv_wr32(init->subdev, reg, val);
}

static u32
init_mask(struct nvbios_init *init, u32 reg, u32 mask, u32 val)
{
reg = init_nvreg(init, reg);
if (init_exec(init)) {
if (reg != ~0 && init_exec(init)) {
u32 tmp = nv_rd32(init->subdev, reg);
nv_wr32(init->subdev, reg, (tmp & ~mask) | val);
return tmp;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/core/subdev/devinit/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ nouveau_devinit_create_(struct nouveau_object *parent,
devinit->post = nouveau_boolopt(device->cfgopt, "NvForcePost", false);
devinit->meminit = impl->meminit;
devinit->pll_set = impl->pll_set;
devinit->mmio = impl->mmio;
return 0;
}
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/core/subdev/devinit/priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct nouveau_devinit_impl {
void (*meminit)(struct nouveau_devinit *);
int (*pll_set)(struct nouveau_devinit *, u32 type, u32 freq);
u64 (*disable)(struct nouveau_devinit *);
u32 (*mmio)(struct nouveau_devinit *, u32);
};

#define nouveau_devinit_create(p,e,o,d) \
Expand Down

0 comments on commit 3219adc

Please sign in to comment.