Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
c63fe2e7
Commit
c63fe2e7
authored
Jan 15, 2020
by
Ben Skeggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drm/nouveau/acr: add loaders for currently available LS firmware images
Signed-off-by:
Ben Skeggs
<
bskeggs@redhat.com
>
parent
67e7c6cf
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
598 additions
and
0 deletions
+598
-0
drivers/gpu/drm/nouveau/include/nvfw/fw.h
drivers/gpu/drm/nouveau/include/nvfw/fw.h
+28
-0
drivers/gpu/drm/nouveau/include/nvfw/ls.h
drivers/gpu/drm/nouveau/include/nvfw/ls.h
+53
-0
drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h
drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h
+6
-0
drivers/gpu/drm/nouveau/include/nvkm/subdev/acr.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/acr.h
+54
-0
drivers/gpu/drm/nouveau/nvkm/Kbuild
drivers/gpu/drm/nouveau/nvkm/Kbuild
+1
-0
drivers/gpu/drm/nouveau/nvkm/core/firmware.c
drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+34
-0
drivers/gpu/drm/nouveau/nvkm/nvfw/Kbuild
drivers/gpu/drm/nouveau/nvkm/nvfw/Kbuild
+3
-0
drivers/gpu/drm/nouveau/nvkm/nvfw/fw.c
drivers/gpu/drm/nouveau/nvkm/nvfw/fw.c
+51
-0
drivers/gpu/drm/nouveau/nvkm/nvfw/ls.c
drivers/gpu/drm/nouveau/nvkm/nvfw/ls.c
+108
-0
drivers/gpu/drm/nouveau/nvkm/subdev/acr/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/acr/Kbuild
+1
-0
drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c
+4
-0
drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
+249
-0
drivers/gpu/drm/nouveau/nvkm/subdev/acr/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/acr/priv.h
+6
-0
No files found.
drivers/gpu/drm/nouveau/include/nvfw/fw.h
0 → 100644
View file @
c63fe2e7
/* SPDX-License-Identifier: MIT */
#ifndef __NVFW_FW_H__
#define __NVFW_FW_H__
#include <core/os.h>
struct
nvkm_subdev
;
struct
nvfw_bin_hdr
{
u32
bin_magic
;
u32
bin_ver
;
u32
bin_size
;
u32
header_offset
;
u32
data_offset
;
u32
data_size
;
};
const
struct
nvfw_bin_hdr
*
nvfw_bin_hdr
(
struct
nvkm_subdev
*
,
const
void
*
);
struct
nvfw_bl_desc
{
u32
start_tag
;
u32
dmem_load_off
;
u32
code_off
;
u32
code_size
;
u32
data_off
;
u32
data_size
;
};
const
struct
nvfw_bl_desc
*
nvfw_bl_desc
(
struct
nvkm_subdev
*
,
const
void
*
);
#endif
drivers/gpu/drm/nouveau/include/nvfw/ls.h
0 → 100644
View file @
c63fe2e7
/* SPDX-License-Identifier: MIT */
#ifndef __NVFW_LS_H__
#define __NVFW_LS_H__
#include <core/os.h>
struct
nvkm_subdev
;
struct
nvfw_ls_desc_head
{
u32
descriptor_size
;
u32
image_size
;
u32
tools_version
;
u32
app_version
;
char
date
[
64
];
u32
bootloader_start_offset
;
u32
bootloader_size
;
u32
bootloader_imem_offset
;
u32
bootloader_entry_point
;
u32
app_start_offset
;
u32
app_size
;
u32
app_imem_offset
;
u32
app_imem_entry
;
u32
app_dmem_offset
;
u32
app_resident_code_offset
;
u32
app_resident_code_size
;
u32
app_resident_data_offset
;
u32
app_resident_data_size
;
};
struct
nvfw_ls_desc
{
struct
nvfw_ls_desc_head
head
;
u32
nb_overlays
;
struct
{
u32
start
;
u32
size
;
}
load_ovl
[
64
];
u32
compressed
;
};
const
struct
nvfw_ls_desc
*
nvfw_ls_desc
(
struct
nvkm_subdev
*
,
const
void
*
);
struct
nvfw_ls_desc_v1
{
struct
nvfw_ls_desc_head
head
;
u32
nb_imem_overlays
;
u32
nb_dmem_overlays
;
struct
{
u32
start
;
u32
size
;
}
load_ovl
[
64
];
u32
compressed
;
};
const
struct
nvfw_ls_desc_v1
*
nvfw_ls_desc_v1
(
struct
nvkm_subdev
*
,
const
void
*
);
#endif
drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h
View file @
c63fe2e7
...
...
@@ -11,6 +11,12 @@ int nvkm_firmware_get(const struct nvkm_subdev *, const char *fwname,
const
struct
firmware
**
);
void
nvkm_firmware_put
(
const
struct
firmware
*
);
int
nvkm_firmware_load_blob
(
const
struct
nvkm_subdev
*
subdev
,
const
char
*
path
,
const
char
*
name
,
int
ver
,
struct
nvkm_blob
*
);
int
nvkm_firmware_load_name
(
const
struct
nvkm_subdev
*
subdev
,
const
char
*
path
,
const
char
*
name
,
int
ver
,
const
struct
firmware
**
);
#define nvkm_firmware_load(s,l,o,p...) ({ \
struct nvkm_subdev *_s = (s); \
const char *_opts = (o); \
...
...
drivers/gpu/drm/nouveau/include/nvkm/subdev/acr.h
View file @
c63fe2e7
...
...
@@ -5,9 +5,21 @@
#include <core/subdev.h>
struct
nvkm_falcon
;
enum
nvkm_acr_lsf_id
{
NVKM_ACR_LSF_PMU
=
0
,
NVKM_ACR_LSF_GSPLITE
=
1
,
NVKM_ACR_LSF_FECS
=
2
,
NVKM_ACR_LSF_GPCCS
=
3
,
NVKM_ACR_LSF_NVDEC
=
4
,
NVKM_ACR_LSF_SEC2
=
7
,
NVKM_ACR_LSF_MINION
=
10
,
};
struct
nvkm_acr
{
const
struct
nvkm_acr_func
*
func
;
struct
nvkm_subdev
subdev
;
struct
list_head
lsfw
;
};
int
gm200_acr_new
(
struct
nvkm_device
*
,
int
,
struct
nvkm_acr
**
);
...
...
@@ -15,4 +27,46 @@ int gm20b_acr_new(struct nvkm_device *, int, struct nvkm_acr **);
int
gp102_acr_new
(
struct
nvkm_device
*
,
int
,
struct
nvkm_acr
**
);
int
gp108_acr_new
(
struct
nvkm_device
*
,
int
,
struct
nvkm_acr
**
);
int
gp10b_acr_new
(
struct
nvkm_device
*
,
int
,
struct
nvkm_acr
**
);
struct
nvkm_acr_lsfw
{
const
struct
nvkm_acr_lsf_func
*
func
;
struct
nvkm_falcon
*
falcon
;
enum
nvkm_acr_lsf_id
id
;
struct
list_head
head
;
struct
nvkm_blob
img
;
const
struct
firmware
*
sig
;
u32
bootloader_size
;
u32
bootloader_imem_offset
;
u32
app_size
;
u32
app_start_offset
;
u32
app_imem_entry
;
u32
app_resident_code_offset
;
u32
app_resident_code_size
;
u32
app_resident_data_offset
;
u32
app_resident_data_size
;
u32
ucode_size
;
u32
data_size
;
};
struct
nvkm_acr_lsf_func
{
};
int
nvkm_acr_lsfw_load_sig_image_desc
(
struct
nvkm_subdev
*
,
struct
nvkm_falcon
*
,
enum
nvkm_acr_lsf_id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
);
int
nvkm_acr_lsfw_load_sig_image_desc_v1
(
struct
nvkm_subdev
*
,
struct
nvkm_falcon
*
,
enum
nvkm_acr_lsf_id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
);
int
nvkm_acr_lsfw_load_bl_inst_data_sig
(
struct
nvkm_subdev
*
,
struct
nvkm_falcon
*
,
enum
nvkm_acr_lsf_id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
);
#endif
drivers/gpu/drm/nouveau/nvkm/Kbuild
View file @
c63fe2e7
# SPDX-License-Identifier: MIT
include $(src)/nvkm/core/Kbuild
include $(src)/nvkm/nvfw/Kbuild
include $(src)/nvkm/falcon/Kbuild
include $(src)/nvkm/subdev/Kbuild
include $(src)/nvkm/engine/Kbuild
drivers/gpu/drm/nouveau/nvkm/core/firmware.c
View file @
c63fe2e7
...
...
@@ -22,6 +22,40 @@
#include <core/device.h>
#include <core/firmware.h>
int
nvkm_firmware_load_name
(
const
struct
nvkm_subdev
*
subdev
,
const
char
*
base
,
const
char
*
name
,
int
ver
,
const
struct
firmware
**
pfw
)
{
char
path
[
64
];
int
ret
;
snprintf
(
path
,
sizeof
(
path
),
"%s%s"
,
base
,
name
);
ret
=
nvkm_firmware_get_version
(
subdev
,
path
,
ver
,
ver
,
pfw
);
if
(
ret
<
0
)
return
ret
;
return
0
;
}
int
nvkm_firmware_load_blob
(
const
struct
nvkm_subdev
*
subdev
,
const
char
*
base
,
const
char
*
name
,
int
ver
,
struct
nvkm_blob
*
blob
)
{
const
struct
firmware
*
fw
;
int
ret
;
ret
=
nvkm_firmware_load_name
(
subdev
,
base
,
name
,
ver
,
&
fw
);
if
(
ret
==
0
)
{
blob
->
data
=
kmemdup
(
fw
->
data
,
fw
->
size
,
GFP_KERNEL
);
blob
->
size
=
fw
->
size
;
nvkm_firmware_put
(
fw
);
if
(
!
blob
->
data
)
return
-
ENOMEM
;
}
return
ret
;
}
/**
* nvkm_firmware_get - load firmware from the official nvidia/chip/ directory
* @subdev subdevice that will use that firmware
...
...
drivers/gpu/drm/nouveau/nvkm/nvfw/Kbuild
0 → 100644
View file @
c63fe2e7
# SPDX-License-Identifier: MIT
nvkm-y += nvkm/nvfw/fw.o
nvkm-y += nvkm/nvfw/ls.o
drivers/gpu/drm/nouveau/nvkm/nvfw/fw.c
0 → 100644
View file @
c63fe2e7
/*
* Copyright 2019 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <core/subdev.h>
#include <nvfw/fw.h>
const
struct
nvfw_bin_hdr
*
nvfw_bin_hdr
(
struct
nvkm_subdev
*
subdev
,
const
void
*
data
)
{
const
struct
nvfw_bin_hdr
*
hdr
=
data
;
nvkm_debug
(
subdev
,
"binHdr:
\n
"
);
nvkm_debug
(
subdev
,
"
\t
binMagic : 0x%08x
\n
"
,
hdr
->
bin_magic
);
nvkm_debug
(
subdev
,
"
\t
binVer : %d
\n
"
,
hdr
->
bin_ver
);
nvkm_debug
(
subdev
,
"
\t
binSize : %d
\n
"
,
hdr
->
bin_size
);
nvkm_debug
(
subdev
,
"
\t
headerOffset : 0x%x
\n
"
,
hdr
->
header_offset
);
nvkm_debug
(
subdev
,
"
\t
dataOffset : 0x%x
\n
"
,
hdr
->
data_offset
);
nvkm_debug
(
subdev
,
"
\t
dataSize : 0x%x
\n
"
,
hdr
->
data_size
);
return
hdr
;
}
const
struct
nvfw_bl_desc
*
nvfw_bl_desc
(
struct
nvkm_subdev
*
subdev
,
const
void
*
data
)
{
const
struct
nvfw_bl_desc
*
hdr
=
data
;
nvkm_debug
(
subdev
,
"blDesc
\n
"
);
nvkm_debug
(
subdev
,
"
\t
startTag : 0x%x
\n
"
,
hdr
->
start_tag
);
nvkm_debug
(
subdev
,
"
\t
dmemLoadOff : 0x%x
\n
"
,
hdr
->
dmem_load_off
);
nvkm_debug
(
subdev
,
"
\t
codeOff : 0x%x
\n
"
,
hdr
->
code_off
);
nvkm_debug
(
subdev
,
"
\t
codeSize : 0x%x
\n
"
,
hdr
->
code_size
);
nvkm_debug
(
subdev
,
"
\t
dataOff : 0x%x
\n
"
,
hdr
->
data_off
);
nvkm_debug
(
subdev
,
"
\t
dataSize : 0x%x
\n
"
,
hdr
->
data_size
);
return
hdr
;
}
drivers/gpu/drm/nouveau/nvkm/nvfw/ls.c
0 → 100644
View file @
c63fe2e7
/*
* Copyright 2019 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <core/subdev.h>
#include <nvfw/ls.h>
static
void
nvfw_ls_desc_head
(
struct
nvkm_subdev
*
subdev
,
const
struct
nvfw_ls_desc_head
*
hdr
)
{
char
*
date
;
nvkm_debug
(
subdev
,
"lsUcodeImgDesc:
\n
"
);
nvkm_debug
(
subdev
,
"
\t
descriptorSize : %d
\n
"
,
hdr
->
descriptor_size
);
nvkm_debug
(
subdev
,
"
\t
imageSize : %d
\n
"
,
hdr
->
image_size
);
nvkm_debug
(
subdev
,
"
\t
toolsVersion : 0x%x
\n
"
,
hdr
->
tools_version
);
nvkm_debug
(
subdev
,
"
\t
appVersion : 0x%x
\n
"
,
hdr
->
app_version
);
date
=
kstrndup
(
hdr
->
date
,
sizeof
(
hdr
->
date
),
GFP_KERNEL
);
nvkm_debug
(
subdev
,
"
\t
date : %s
\n
"
,
date
);
kfree
(
date
);
nvkm_debug
(
subdev
,
"
\t
bootloaderStartOffset: 0x%x
\n
"
,
hdr
->
bootloader_start_offset
);
nvkm_debug
(
subdev
,
"
\t
bootloaderSize : 0x%x
\n
"
,
hdr
->
bootloader_size
);
nvkm_debug
(
subdev
,
"
\t
bootloaderImemOffset : 0x%x
\n
"
,
hdr
->
bootloader_imem_offset
);
nvkm_debug
(
subdev
,
"
\t
bootloaderEntryPoint : 0x%x
\n
"
,
hdr
->
bootloader_entry_point
);
nvkm_debug
(
subdev
,
"
\t
appStartOffset : 0x%x
\n
"
,
hdr
->
app_start_offset
);
nvkm_debug
(
subdev
,
"
\t
appSize : 0x%x
\n
"
,
hdr
->
app_size
);
nvkm_debug
(
subdev
,
"
\t
appImemOffset : 0x%x
\n
"
,
hdr
->
app_imem_offset
);
nvkm_debug
(
subdev
,
"
\t
appImemEntry : 0x%x
\n
"
,
hdr
->
app_imem_entry
);
nvkm_debug
(
subdev
,
"
\t
appDmemOffset : 0x%x
\n
"
,
hdr
->
app_dmem_offset
);
nvkm_debug
(
subdev
,
"
\t
appResidentCodeOffset: 0x%x
\n
"
,
hdr
->
app_resident_code_offset
);
nvkm_debug
(
subdev
,
"
\t
appResidentCodeSize : 0x%x
\n
"
,
hdr
->
app_resident_code_size
);
nvkm_debug
(
subdev
,
"
\t
appResidentDataOffset: 0x%x
\n
"
,
hdr
->
app_resident_data_offset
);
nvkm_debug
(
subdev
,
"
\t
appResidentDataSize : 0x%x
\n
"
,
hdr
->
app_resident_data_size
);
}
const
struct
nvfw_ls_desc
*
nvfw_ls_desc
(
struct
nvkm_subdev
*
subdev
,
const
void
*
data
)
{
const
struct
nvfw_ls_desc
*
hdr
=
data
;
int
i
;
nvfw_ls_desc_head
(
subdev
,
&
hdr
->
head
);
nvkm_debug
(
subdev
,
"
\t
nbOverlays : %d
\n
"
,
hdr
->
nb_overlays
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
hdr
->
load_ovl
);
i
++
)
{
nvkm_debug
(
subdev
,
"
\t
loadOvl[%d] : 0x%x %d
\n
"
,
i
,
hdr
->
load_ovl
[
i
].
start
,
hdr
->
load_ovl
[
i
].
size
);
}
nvkm_debug
(
subdev
,
"
\t
compressed : %d
\n
"
,
hdr
->
compressed
);
return
hdr
;
}
const
struct
nvfw_ls_desc_v1
*
nvfw_ls_desc_v1
(
struct
nvkm_subdev
*
subdev
,
const
void
*
data
)
{
const
struct
nvfw_ls_desc_v1
*
hdr
=
data
;
int
i
;
nvfw_ls_desc_head
(
subdev
,
&
hdr
->
head
);
nvkm_debug
(
subdev
,
"
\t
nbImemOverlays : %d
\n
"
,
hdr
->
nb_imem_overlays
);
nvkm_debug
(
subdev
,
"
\t
nbDmemOverlays : %d
\n
"
,
hdr
->
nb_imem_overlays
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
hdr
->
load_ovl
);
i
++
)
{
nvkm_debug
(
subdev
,
"
\t
loadOvl[%2d] : 0x%x %d
\n
"
,
i
,
hdr
->
load_ovl
[
i
].
start
,
hdr
->
load_ovl
[
i
].
size
);
}
nvkm_debug
(
subdev
,
"
\t
compressed : %d
\n
"
,
hdr
->
compressed
);
return
hdr
;
}
drivers/gpu/drm/nouveau/nvkm/subdev/acr/Kbuild
View file @
c63fe2e7
# SPDX-License-Identifier: MIT
nvkm-y += nvkm/subdev/acr/base.o
nvkm-y += nvkm/subdev/acr/lsfw.o
nvkm-y += nvkm/subdev/acr/gm200.o
nvkm-y += nvkm/subdev/acr/gm20b.o
nvkm-y += nvkm/subdev/acr/gp102.o
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c
View file @
c63fe2e7
...
...
@@ -27,6 +27,9 @@ static void *
nvkm_acr_dtor
(
struct
nvkm_subdev
*
subdev
)
{
struct
nvkm_acr
*
acr
=
nvkm_acr
(
subdev
);
nvkm_acr_lsfw_del_all
(
acr
);
return
acr
;
}
...
...
@@ -44,6 +47,7 @@ nvkm_acr_new_(const struct nvkm_acr_fwif *fwif, struct nvkm_device *device,
if
(
!
(
acr
=
*
pacr
=
kzalloc
(
sizeof
(
*
acr
),
GFP_KERNEL
)))
return
-
ENOMEM
;
nvkm_subdev_ctor
(
&
nvkm_acr
,
device
,
index
,
&
acr
->
subdev
);
INIT_LIST_HEAD
(
&
acr
->
lsfw
);
fwif
=
nvkm_firmware_load
(
&
acr
->
subdev
,
fwif
,
"Acr"
,
acr
);
if
(
IS_ERR
(
fwif
))
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
0 → 100644
View file @
c63fe2e7
/*
* Copyright 2019 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "priv.h"
#include <core/falcon.h>
#include <core/firmware.h>
#include <nvfw/fw.h>
#include <nvfw/ls.h>
void
nvkm_acr_lsfw_del
(
struct
nvkm_acr_lsfw
*
lsfw
)
{
nvkm_blob_dtor
(
&
lsfw
->
img
);
nvkm_firmware_put
(
lsfw
->
sig
);
list_del
(
&
lsfw
->
head
);
kfree
(
lsfw
);
}
void
nvkm_acr_lsfw_del_all
(
struct
nvkm_acr
*
acr
)
{
struct
nvkm_acr_lsfw
*
lsfw
,
*
lsft
;
list_for_each_entry_safe
(
lsfw
,
lsft
,
&
acr
->
lsfw
,
head
)
{
nvkm_acr_lsfw_del
(
lsfw
);
}
}
static
struct
nvkm_acr_lsfw
*
nvkm_acr_lsfw_get
(
struct
nvkm_acr
*
acr
,
enum
nvkm_acr_lsf_id
id
)
{
struct
nvkm_acr_lsfw
*
lsfw
;
list_for_each_entry
(
lsfw
,
&
acr
->
lsfw
,
head
)
{
if
(
lsfw
->
id
==
id
)
return
lsfw
;
}
return
NULL
;
}
struct
nvkm_acr_lsfw
*
nvkm_acr_lsfw_add
(
const
struct
nvkm_acr_lsf_func
*
func
,
struct
nvkm_acr
*
acr
,
struct
nvkm_falcon
*
falcon
,
enum
nvkm_acr_lsf_id
id
)
{
struct
nvkm_acr_lsfw
*
lsfw
=
nvkm_acr_lsfw_get
(
acr
,
id
);
if
(
lsfw
&&
lsfw
->
func
)
{
nvkm_error
(
&
acr
->
subdev
,
"LSFW %d redefined
\n
"
,
id
);
return
ERR_PTR
(
-
EEXIST
);
}
if
(
!
lsfw
)
{
if
(
!
(
lsfw
=
kzalloc
(
sizeof
(
*
lsfw
),
GFP_KERNEL
)))
return
ERR_PTR
(
-
ENOMEM
);
lsfw
->
id
=
id
;
list_add_tail
(
&
lsfw
->
head
,
&
acr
->
lsfw
);
}
lsfw
->
func
=
func
;
lsfw
->
falcon
=
falcon
;
return
lsfw
;
}
static
struct
nvkm_acr_lsfw
*
nvkm_acr_lsfw_load_sig_image_desc_
(
struct
nvkm_subdev
*
subdev
,
struct
nvkm_falcon
*
falcon
,
enum
nvkm_acr_lsf_id
id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
func
,
const
struct
firmware
**
pdesc
)
{
struct
nvkm_acr
*
acr
=
subdev
->
device
->
acr
;
struct
nvkm_acr_lsfw
*
lsfw
;
int
ret
;
if
(
IS_ERR
((
lsfw
=
nvkm_acr_lsfw_add
(
func
,
acr
,
falcon
,
id
))))
return
lsfw
;
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"sig"
,
ver
,
&
lsfw
->
sig
);
if
(
ret
)
goto
done
;
ret
=
nvkm_firmware_load_blob
(
subdev
,
path
,
"image"
,
ver
,
&
lsfw
->
img
);
if
(
ret
)
goto
done
;
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"desc"
,
ver
,
pdesc
);
done:
if
(
ret
)
{
nvkm_acr_lsfw_del
(
lsfw
);
return
ERR_PTR
(
ret
);
}
return
lsfw
;
}
static
void
nvkm_acr_lsfw_from_desc
(
const
struct
nvfw_ls_desc_head
*
desc
,
struct
nvkm_acr_lsfw
*
lsfw
)
{
lsfw
->
bootloader_size
=
ALIGN
(
desc
->
bootloader_size
,
256
);
lsfw
->
bootloader_imem_offset
=
desc
->
bootloader_imem_offset
;
lsfw
->
app_size
=
ALIGN
(
desc
->
app_size
,
256
);
lsfw
->
app_start_offset
=
desc
->
app_start_offset
;
lsfw
->
app_imem_entry
=
desc
->
app_imem_entry
;
lsfw
->
app_resident_code_offset
=
desc
->
app_resident_code_offset
;
lsfw
->
app_resident_code_size
=
desc
->
app_resident_code_size
;
lsfw
->
app_resident_data_offset
=
desc
->
app_resident_data_offset
;
lsfw
->
app_resident_data_size
=
desc
->
app_resident_data_size
;
lsfw
->
ucode_size
=
ALIGN
(
lsfw
->
app_resident_data_offset
,
256
)
+
lsfw
->
bootloader_size
;
lsfw
->
data_size
=
lsfw
->
app_size
+
lsfw
->
bootloader_size
-
lsfw
->
ucode_size
;
}
int
nvkm_acr_lsfw_load_sig_image_desc
(
struct
nvkm_subdev
*
subdev
,
struct
nvkm_falcon
*
falcon
,
enum
nvkm_acr_lsf_id
id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
func
)
{
const
struct
firmware
*
fw
;
struct
nvkm_acr_lsfw
*
lsfw
;
lsfw
=
nvkm_acr_lsfw_load_sig_image_desc_
(
subdev
,
falcon
,
id
,
path
,
ver
,
func
,
&
fw
);
if
(
IS_ERR
(
lsfw
))
return
PTR_ERR
(
lsfw
);
nvkm_acr_lsfw_from_desc
(
&
nvfw_ls_desc
(
subdev
,
fw
->
data
)
->
head
,
lsfw
);
nvkm_firmware_put
(
fw
);
return
0
;
}
int
nvkm_acr_lsfw_load_sig_image_desc_v1
(
struct
nvkm_subdev
*
subdev
,
struct
nvkm_falcon
*
falcon
,
enum
nvkm_acr_lsf_id
id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
func
)
{
const
struct
firmware
*
fw
;
struct
nvkm_acr_lsfw
*
lsfw
;
lsfw
=
nvkm_acr_lsfw_load_sig_image_desc_
(
subdev
,
falcon
,
id
,
path
,
ver
,
func
,
&
fw
);
if
(
IS_ERR
(
lsfw
))
return
PTR_ERR
(
lsfw
);
nvkm_acr_lsfw_from_desc
(
&
nvfw_ls_desc_v1
(
subdev
,
fw
->
data
)
->
head
,
lsfw
);
nvkm_firmware_put
(
fw
);
return
0
;
}
int
nvkm_acr_lsfw_load_bl_inst_data_sig
(
struct
nvkm_subdev
*
subdev
,
struct
nvkm_falcon
*
falcon
,
enum
nvkm_acr_lsf_id
id
,
const
char
*
path
,
int
ver
,
const
struct
nvkm_acr_lsf_func
*
func
)
{
struct
nvkm_acr
*
acr
=
subdev
->
device
->
acr
;
struct
nvkm_acr_lsfw
*
lsfw
;
const
struct
firmware
*
bl
=
NULL
,
*
inst
=
NULL
,
*
data
=
NULL
;
const
struct
nvfw_bin_hdr
*
hdr
;
const
struct
nvfw_bl_desc
*
desc
;
u32
*
bldata
;
int
ret
;
if
(
IS_ERR
((
lsfw
=
nvkm_acr_lsfw_add
(
func
,
acr
,
falcon
,
id
))))
return
PTR_ERR
(
lsfw
);
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"bl"
,
ver
,
&
bl
);
if
(
ret
)
goto
done
;
hdr
=
nvfw_bin_hdr
(
subdev
,
bl
->
data
);
desc
=
nvfw_bl_desc
(
subdev
,
bl
->
data
+
hdr
->
header_offset
);
bldata
=
(
void
*
)(
bl
->
data
+
hdr
->
data_offset
);
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"inst"
,
ver
,
&
inst
);
if
(
ret
)
goto
done
;
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"data"
,
ver
,
&
data
);
if
(
ret
)
goto
done
;
ret
=
nvkm_firmware_load_name
(
subdev
,
path
,
"sig"
,
ver
,
&
lsfw
->
sig
);
if
(
ret
)
goto
done
;
lsfw
->
bootloader_size
=
ALIGN
(
desc
->
code_size
,
256
);
lsfw
->
bootloader_imem_offset
=
desc
->
start_tag
<<
8
;
lsfw
->
app_start_offset
=
lsfw
->
bootloader_size
;
lsfw
->
app_imem_entry
=
0
;
lsfw
->
app_resident_code_offset
=
0
;
lsfw
->
app_resident_code_size
=
ALIGN
(
inst
->
size
,
256
);
lsfw
->
app_resident_data_offset
=
lsfw
->
app_resident_code_size
;
lsfw
->
app_resident_data_size
=
ALIGN
(
data
->
size
,
256
);
lsfw
->
app_size
=
lsfw
->
app_resident_code_size
+
lsfw
->
app_resident_data_size
;
lsfw
->
img
.
size
=
lsfw
->
bootloader_size
+
lsfw
->
app_size
;
if
(
!
(
lsfw
->
img
.
data
=
kzalloc
(
lsfw
->
img
.
size
,
GFP_KERNEL
)))
{
ret
=
-
ENOMEM
;
goto
done
;
}
memcpy
(
lsfw
->
img
.
data
,
bldata
,
lsfw
->
bootloader_size
);
memcpy
(
lsfw
->
img
.
data
+
lsfw
->
app_start_offset
+
lsfw
->
app_resident_code_offset
,
inst
->
data
,
inst
->
size
);
memcpy
(
lsfw
->
img
.
data
+
lsfw
->
app_start_offset
+
lsfw
->
app_resident_data_offset
,
data
->
data
,
data
->
size
);
lsfw
->
ucode_size
=
ALIGN
(
lsfw
->
app_resident_data_offset
,
256
)
+
lsfw
->
bootloader_size
;
lsfw
->
data_size
=
lsfw
->
app_size
+
lsfw
->
bootloader_size
-
lsfw
->
ucode_size
;
done:
if
(
ret
)
nvkm_acr_lsfw_del
(
lsfw
);
nvkm_firmware_put
(
data
);
nvkm_firmware_put
(
inst
);
nvkm_firmware_put
(
bl
);
return
ret
;
}
drivers/gpu/drm/nouveau/nvkm/subdev/acr/priv.h
View file @
c63fe2e7
...
...
@@ -17,4 +17,10 @@ struct nvkm_acr_func {
int
nvkm_acr_new_
(
const
struct
nvkm_acr_fwif
*
,
struct
nvkm_device
*
,
int
,
struct
nvkm_acr
**
);
struct
nvkm_acr_lsfw
*
nvkm_acr_lsfw_add
(
const
struct
nvkm_acr_lsf_func
*
,
struct
nvkm_acr
*
,
struct
nvkm_falcon
*
,
enum
nvkm_acr_lsf_id
);
void
nvkm_acr_lsfw_del
(
struct
nvkm_acr_lsfw
*
);
void
nvkm_acr_lsfw_del_all
(
struct
nvkm_acr
*
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment