Skip to content

Commit a51c69e

Browse files
author
Ben Skeggs
committed
drm/nouveau/fb/ga102: load and boot VPR scrubber FW
v2. fixup for ga103 early merge Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Gourav Samaiya <[email protected]>
1 parent 21876b0 commit a51c69e

File tree

19 files changed

+551
-5
lines changed

19 files changed

+551
-5
lines changed

drivers/gpu/drm/nouveau/include/nvfw/hs.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ struct nvfw_hs_header {
1717

1818
const struct nvfw_hs_header *nvfw_hs_header(struct nvkm_subdev *, const void *);
1919

20+
struct nvfw_hs_header_v2 {
21+
u32 sig_prod_offset;
22+
u32 sig_prod_size;
23+
u32 patch_loc;
24+
u32 patch_sig;
25+
u32 meta_data_offset;
26+
u32 meta_data_size;
27+
u32 num_sig;
28+
u32 header_offset;
29+
u32 header_size;
30+
};
31+
32+
const struct nvfw_hs_header_v2 *nvfw_hs_header_v2(struct nvkm_subdev *, const void *);
33+
2034
struct nvfw_hs_load_header {
2135
u32 non_sec_code_off;
2236
u32 non_sec_code_size;
@@ -28,4 +42,18 @@ struct nvfw_hs_load_header {
2842

2943
const struct nvfw_hs_load_header *
3044
nvfw_hs_load_header(struct nvkm_subdev *, const void *);
45+
46+
struct nvfw_hs_load_header_v2 {
47+
u32 os_code_offset;
48+
u32 os_code_size;
49+
u32 os_data_offset;
50+
u32 os_data_size;
51+
u32 num_apps;
52+
struct {
53+
u32 offset;
54+
u32 size;
55+
} app[0];
56+
};
57+
58+
const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
3159
#endif

drivers/gpu/drm/nouveau/include/nvkm/core/falcon.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ struct nvkm_falcon_func_pio {
3131
void (*rd)(struct nvkm_falcon *, u8 port, const u8 *img, int len);
3232
};
3333

34+
struct nvkm_falcon_func_dma {
35+
int (*init)(struct nvkm_falcon *, u64 dma_addr, int xfer_len,
36+
enum nvkm_falcon_mem, bool sec, u32 *cmd);
37+
void (*xfer)(struct nvkm_falcon *, u32 mem_base, u32 dma_base, u32 cmd);
38+
bool (*done)(struct nvkm_falcon *);
39+
};
40+
3441
int nvkm_falcon_ctor(const struct nvkm_falcon_func *, struct nvkm_subdev *owner,
3542
const char *name, u32 addr, struct nvkm_falcon *);
3643
void nvkm_falcon_dtor(struct nvkm_falcon *);
@@ -39,6 +46,8 @@ int nvkm_falcon_pio_wr(struct nvkm_falcon *, const u8 *img, u32 img_base, u8 por
3946
enum nvkm_falcon_mem mem_type, u32 mem_base, int len, u16 tag, bool sec);
4047
int nvkm_falcon_pio_rd(struct nvkm_falcon *, u8 port, enum nvkm_falcon_mem type, u32 mem_base,
4148
const u8 *img, u32 img_base, int len);
49+
int nvkm_falcon_dma_wr(struct nvkm_falcon *, const u8 *img, u64 dma_addr, u32 dma_base,
50+
enum nvkm_falcon_mem mem_type, u32 mem_base, int len, bool sec);
4251

4352
int gm200_flcn_reset_wait_mem_scrubbing(struct nvkm_falcon *);
4453
int gm200_flcn_disable(struct nvkm_falcon *);
@@ -52,6 +61,10 @@ void gm200_flcn_tracepc(struct nvkm_falcon *);
5261
int gp102_flcn_reset_eng(struct nvkm_falcon *);
5362
extern const struct nvkm_falcon_func_pio gp102_flcn_emem_pio;
5463

64+
int ga102_flcn_reset_prep(struct nvkm_falcon *);
65+
int ga102_flcn_reset_wait_mem_scrubbing(struct nvkm_falcon *);
66+
extern const struct nvkm_falcon_func_dma ga102_flcn_dma;
67+
5568
void nvkm_falcon_v1_load_imem(struct nvkm_falcon *,
5669
void *, u32, u32, u16, u8, bool);
5770
void nvkm_falcon_v1_load_dmem(struct nvkm_falcon *, void *, u32, u32, u8);
@@ -87,6 +100,9 @@ struct nvkm_falcon_fw {
87100
u32 sig_size;
88101
int sig_nr;
89102
u8 *sigs;
103+
u32 fuse_ver;
104+
u32 engine_id;
105+
u32 ucode_id;
90106

91107
u32 nmem_base_img;
92108
u32 nmem_base;
@@ -117,6 +133,9 @@ int nvkm_falcon_fw_ctor(const struct nvkm_falcon_fw_func *, const char *name, st
117133
int nvkm_falcon_fw_ctor_hs(const struct nvkm_falcon_fw_func *, const char *name,
118134
struct nvkm_subdev *, const char *bl, const char *img, int ver,
119135
struct nvkm_falcon *falcon, struct nvkm_falcon_fw *fw);
136+
int nvkm_falcon_fw_ctor_hs_v2(const struct nvkm_falcon_fw_func *, const char *name,
137+
struct nvkm_subdev *, const char *img, int ver, struct nvkm_falcon *,
138+
struct nvkm_falcon_fw *);
120139
int nvkm_falcon_fw_sign(struct nvkm_falcon_fw *, u32 sig_base_img, u32 sig_size, const u8 *sigs,
121140
int sig_nr_prd, u32 sig_base_prd, int sig_nr_dbg, u32 sig_base_dbg);
122141
int nvkm_falcon_fw_patch(struct nvkm_falcon_fw *);
@@ -132,6 +151,12 @@ int gm200_flcn_fw_reset(struct nvkm_falcon_fw *);
132151
int gm200_flcn_fw_load(struct nvkm_falcon_fw *);
133152
int gm200_flcn_fw_boot(struct nvkm_falcon_fw *, u32 *, u32 *, u32, u32);
134153

154+
int ga100_flcn_fw_signature(struct nvkm_falcon_fw *, u32 *);
155+
156+
extern const struct nvkm_falcon_fw_func ga102_flcn_fw;
157+
int ga102_flcn_fw_load(struct nvkm_falcon_fw *);
158+
int ga102_flcn_fw_boot(struct nvkm_falcon_fw *, u32 *, u32 *, u32, u32);
159+
135160
#define FLCNFW_PRINTK(f,l,p,fmt,a...) FLCN_PRINTK((f)->falcon, l, p, "%s: "fmt, (f)->fw.name, ##a)
136161
#define FLCNFW_DBG(f,fmt,a...) FLCNFW_PRINTK((f), DEBUG, info, fmt"\n", ##a)
137162
#define FLCNFW_ERR(f,fmt,a...) FLCNFW_PRINTK((f), ERROR, err, fmt"\n", ##a)

drivers/gpu/drm/nouveau/include/nvkm/engine/falcon.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct nvkm_falcon {
1919
struct nvkm_subdev *owner;
2020
const char *name;
2121
u32 addr;
22+
u32 addr2;
2223

2324
struct mutex mutex;
2425
struct mutex dmem_mutex;
@@ -59,8 +60,10 @@ int nvkm_falcon_new_(const struct nvkm_falcon_func *, struct nvkm_device *,
5960
struct nvkm_falcon_func {
6061
int (*disable)(struct nvkm_falcon *);
6162
int (*enable)(struct nvkm_falcon *);
63+
u32 addr2;
6264
bool reset_pmc;
6365
int (*reset_eng)(struct nvkm_falcon *);
66+
int (*reset_prep)(struct nvkm_falcon *);
6467
int (*reset_wait_mem_scrubbing)(struct nvkm_falcon *);
6568

6669
u32 debug;
@@ -69,7 +72,10 @@ struct nvkm_falcon_func {
6972
bool bind_intr;
7073

7174
const struct nvkm_falcon_func_pio *imem_pio;
75+
const struct nvkm_falcon_func_dma *imem_dma;
76+
7277
const struct nvkm_falcon_func_pio *dmem_pio;
78+
const struct nvkm_falcon_func_dma *dmem_dma;
7379

7480
u32 emem_addr;
7581
const struct nvkm_falcon_func_pio *emem_pio;

drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ struct nvkm_nvdec {
1212
};
1313

1414
int gm107_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
15+
int ga102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
1516
#endif

drivers/gpu/drm/nouveau/nvkm/engine/device/base.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,7 @@ nv172_chipset = {
26152615
.disp = { 0x00000001, ga102_disp_new },
26162616
.dma = { 0x00000001, gv100_dma_new },
26172617
.fifo = { 0x00000001, ga102_fifo_new },
2618+
.nvdec = { 0x00000001, ga102_nvdec_new },
26182619
};
26192620

26202621
static const struct nvkm_device_chip
@@ -2639,6 +2640,7 @@ nv173_chipset = {
26392640
.disp = { 0x00000001, ga102_disp_new },
26402641
.dma = { 0x00000001, gv100_dma_new },
26412642
.fifo = { 0x00000001, ga102_fifo_new },
2643+
.nvdec = { 0x00000001, ga102_nvdec_new },
26422644
};
26432645

26442646
static const struct nvkm_device_chip
@@ -2663,6 +2665,7 @@ nv174_chipset = {
26632665
.disp = { 0x00000001, ga102_disp_new },
26642666
.dma = { 0x00000001, gv100_dma_new },
26652667
.fifo = { 0x00000001, ga102_fifo_new },
2668+
.nvdec = { 0x00000001, ga102_nvdec_new },
26662669
};
26672670

26682671
static const struct nvkm_device_chip
@@ -2687,6 +2690,7 @@ nv176_chipset = {
26872690
.disp = { 0x00000001, ga102_disp_new },
26882691
.dma = { 0x00000001, gv100_dma_new },
26892692
.fifo = { 0x00000001, ga102_fifo_new },
2693+
.nvdec = { 0x00000001, ga102_nvdec_new },
26902694
};
26912695

26922696
static const struct nvkm_device_chip
@@ -2711,6 +2715,7 @@ nv177_chipset = {
27112715
.disp = { 0x00000001, ga102_disp_new },
27122716
.dma = { 0x00000001, gv100_dma_new },
27132717
.fifo = { 0x00000001, ga102_fifo_new },
2718+
.nvdec = { 0x00000001, ga102_nvdec_new },
27142719
};
27152720

27162721
struct nvkm_subdev *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: MIT
22
nvkm-y += nvkm/engine/nvdec/base.o
33
nvkm-y += nvkm/engine/nvdec/gm107.o
4+
nvkm-y += nvkm/engine/nvdec/ga102.o

drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ nvkm_nvdec = {
3737

3838
int
3939
nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
40-
enum nvkm_subdev_type type, int inst, struct nvkm_nvdec **pnvdec)
40+
enum nvkm_subdev_type type, int inst, u32 addr, struct nvkm_nvdec **pnvdec)
4141
{
4242
struct nvkm_nvdec *nvdec;
4343
int ret;
@@ -57,5 +57,5 @@ nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
5757
nvdec->func = fwif->func;
5858

5959
return nvkm_falcon_ctor(nvdec->func->flcn, &nvdec->engine.subdev,
60-
nvdec->engine.subdev.name, 0, &nvdec->falcon);
60+
nvdec->engine.subdev.name, addr, &nvdec->falcon);
6161
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2021 Red Hat Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#include "priv.h"
23+
24+
#include <subdev/mc.h>
25+
#include <subdev/timer.h>
26+
27+
static const struct nvkm_falcon_func
28+
ga102_nvdec_flcn = {
29+
.disable = gm200_flcn_disable,
30+
.enable = gm200_flcn_enable,
31+
.addr2 = 0x1c00,
32+
.reset_pmc = true,
33+
.reset_prep = ga102_flcn_reset_prep,
34+
.reset_wait_mem_scrubbing = ga102_flcn_reset_wait_mem_scrubbing,
35+
.imem_dma = &ga102_flcn_dma,
36+
.dmem_dma = &ga102_flcn_dma,
37+
};
38+
39+
static const struct nvkm_nvdec_func
40+
ga102_nvdec = {
41+
.flcn = &ga102_nvdec_flcn,
42+
};
43+
44+
static int
45+
ga102_nvdec_nofw(struct nvkm_nvdec *nvdec, int ver, const struct nvkm_nvdec_fwif *fwif)
46+
{
47+
return 0;
48+
}
49+
50+
static const struct nvkm_nvdec_fwif
51+
ga102_nvdec_fwif[] = {
52+
{ -1, ga102_nvdec_nofw, &ga102_nvdec },
53+
{}
54+
};
55+
56+
int
57+
ga102_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
58+
struct nvkm_nvdec **pnvdec)
59+
{
60+
return nvkm_nvdec_new_(ga102_nvdec_fwif, device, type, inst, 0x848000, pnvdec);
61+
}

drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gm107.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ int
5454
gm107_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
5555
struct nvkm_nvdec **pnvdec)
5656
{
57-
return nvkm_nvdec_new_(gm107_nvdec_fwif, device, type, inst, pnvdec);
57+
return nvkm_nvdec_new_(gm107_nvdec_fwif, device, type, inst, 0, pnvdec);
5858
}

drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ struct nvkm_nvdec_fwif {
1515
};
1616

1717
int nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *,
18-
enum nvkm_subdev_type, int, struct nvkm_nvdec **);
18+
enum nvkm_subdev_type, int, u32 addr, struct nvkm_nvdec **);
1919
#endif

0 commit comments

Comments
 (0)