drm/nouveau/secboot: store ucode offset in base image structure
authorAlexandre Courbot <acourbot@nvidia.com>
Tue, 15 Nov 2016 06:02:27 +0000 (15:02 +0900)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 7 Mar 2017 07:05:12 +0000 (17:05 +1000)
This allows the bootloader descriptor generation code to not rely on
specialized ls_ucode_img structures, making it reusable in other
instances.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h

index f7946ed01acb244a8df1b7c41b0b3817ebc966a1..8f32d113f5afe13d2fa7bd7dea9df7a7b28ae454 100644 (file)
@@ -95,15 +95,14 @@ struct acr_r352_flcn_bl_desc {
  */
 static void
 acr_r352_generate_flcn_bl_desc(const struct nvkm_acr *acr,
-                              const struct ls_ucode_img *_img, u64 wpr_addr,
+                              const struct ls_ucode_img *img, u64 wpr_addr,
                               void *_desc)
 {
-       struct ls_ucode_img_r352 *img = ls_ucode_img_r352(_img);
        struct acr_r352_flcn_bl_desc *desc = _desc;
-       const struct ls_ucode_img_desc *pdesc = &_img->ucode_desc;
+       const struct ls_ucode_img_desc *pdesc = &img->ucode_desc;
        u64 base, addr_code, addr_data;
 
-       base = wpr_addr + img->lsb_header.ucode_off + pdesc->app_start_offset;
+       base = wpr_addr + img->ucode_off + pdesc->app_start_offset;
        addr_code = (base + pdesc->app_resident_code_offset) >> 8;
        addr_data = (base + pdesc->app_resident_data_offset) >> 8;
 
@@ -255,7 +254,7 @@ acr_r352_ls_img_fill_headers(struct acr_r352 *acr,
         * image size
         */
        offset = ALIGN(offset, LSF_UCODE_DATA_ALIGN);
-       lhdr->ucode_off = offset;
+       _img->ucode_off = lhdr->ucode_off = offset;
        offset += _img->ucode_size;
 
        /*
index ebb185e0b4a876e8ccb79c5225536bd34fdbd37b..ea6230cfb87017f060658d7f2d91317bd5c55d30 100644 (file)
@@ -63,15 +63,14 @@ struct acr_r361_flcn_bl_desc {
 
 static void
 acr_r361_generate_flcn_bl_desc(const struct nvkm_acr *acr,
-                              const struct ls_ucode_img *_img, u64 wpr_addr,
+                              const struct ls_ucode_img *img, u64 wpr_addr,
                               void *_desc)
 {
-       struct ls_ucode_img_r352 *img = ls_ucode_img_r352(_img);
        struct acr_r361_flcn_bl_desc *desc = _desc;
-       const struct ls_ucode_img_desc *pdesc = &img->base.ucode_desc;
+       const struct ls_ucode_img_desc *pdesc = &img->ucode_desc;
        u64 base, addr_code, addr_data;
 
-       base = wpr_addr + img->lsb_header.ucode_off + pdesc->app_start_offset;
+       base = wpr_addr + img->ucode_off + pdesc->app_start_offset;
        addr_code = base + pdesc->app_resident_code_offset;
        addr_data = base + pdesc->app_resident_data_offset;
 
index 00886cee57ebcc5f6c6aaf4e86a238c0267c6cef..181c0d80d194aef65413dd8c3f4da37d245d31ad 100644 (file)
@@ -83,6 +83,7 @@ struct ls_ucode_img_desc {
  * @ucode_desc:                loaded or generated map of ucode_data
  * @ucode_data:                firmware payload (code and data)
  * @ucode_size:                size in bytes of data in ucode_data
+ * @ucode_off:         offset of the ucode in ucode_data
  * @sig:               signature for this firmware
  * @sig:size:          size of the signature in bytes
  *
@@ -97,6 +98,7 @@ struct ls_ucode_img {
        struct ls_ucode_img_desc ucode_desc;
        u8 *ucode_data;
        u32 ucode_size;
+       u32 ucode_off;
 
        u8 *sig;
        u32 sig_size;