Skip to content

Commit

Permalink
drm/nouveau/gsp: initialise SW state for falcon from constructor
Browse files Browse the repository at this point in the history
This will allow us to register the falcon with ACR, and further customise
its behaviour by providing the nvkm_falcon_func structure directly.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Jan 15, 2020
1 parent 78b10b7 commit 334815e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
5 changes: 2 additions & 3 deletions drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#define __NVKM_GSP_H__
#define nvkm_gsp(p) container_of((p), struct nvkm_gsp, subdev)
#include <core/subdev.h>
#include <core/falcon.h>

struct nvkm_gsp {
struct nvkm_subdev subdev;
u32 addr;

struct nvkm_falcon *falcon;
struct nvkm_falcon falcon;
};

int gv100_gsp_new(struct nvkm_device *, int, struct nvkm_gsp **);
Expand Down
19 changes: 4 additions & 15 deletions drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,17 @@
#include <subdev/acr.h>
#include <subdev/top.h>

static int
nvkm_gsp_oneinit(struct nvkm_subdev *subdev)
{
struct nvkm_gsp *gsp = nvkm_gsp(subdev);

gsp->addr = nvkm_top_addr(subdev->device, subdev->index);
if (!gsp->addr)
return -EINVAL;

return nvkm_falcon_v1_new(subdev, "GSP", gsp->addr, &gsp->falcon);
}

static void *
nvkm_gsp_dtor(struct nvkm_subdev *subdev)
{
struct nvkm_gsp *gsp = nvkm_gsp(subdev);
nvkm_falcon_del(&gsp->falcon);
nvkm_falcon_dtor(&gsp->falcon);
return gsp;
}

static const struct nvkm_subdev_func
nvkm_gsp = {
.dtor = nvkm_gsp_dtor,
.oneinit = nvkm_gsp_oneinit,
};

int
Expand All @@ -66,5 +53,7 @@ nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device,
if (IS_ERR(fwif))
return PTR_ERR(fwif);

return 0;
return nvkm_falcon_ctor(fwif->flcn, &gsp->subdev,
nvkm_subdev_name[gsp->subdev.index], 0,
&gsp->falcon);
}
16 changes: 15 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gv100.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
*/
#include "priv.h"

static const struct nvkm_falcon_func
gv100_gsp_flcn = {
.load_imem = nvkm_falcon_v1_load_imem,
.load_dmem = nvkm_falcon_v1_load_dmem,
.read_dmem = nvkm_falcon_v1_read_dmem,
.bind_context = nvkm_falcon_v1_bind_context,
.wait_for_halt = nvkm_falcon_v1_wait_for_halt,
.clear_interrupt = nvkm_falcon_v1_clear_interrupt,
.set_start_addr = nvkm_falcon_v1_set_start_addr,
.start = nvkm_falcon_v1_start,
.enable = nvkm_falcon_v1_enable,
.disable = nvkm_falcon_v1_disable,
};

static int
gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
{
Expand All @@ -29,7 +43,7 @@ gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)

struct nvkm_gsp_fwif
gv100_gsp[] = {
{ -1, gv100_gsp_nofw },
{ -1, gv100_gsp_nofw, &gv100_gsp_flcn },
{}
};

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/gsp/priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum nvkm_acr_lsf_id;
struct nvkm_gsp_fwif {
int version;
int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *);
const struct nvkm_falcon_func *flcn;
};

int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, int,
Expand Down

0 comments on commit 334815e

Please sign in to comment.