Hi Timur Tabi,

On 18/04/24 3:23 am, Timur Tabi wrote:
> Add the NVreg_RegistryDwords command line parameter, which allows
> specifying additional registry keys to be sent to GSP-RM.  This
> allows additional configuration, debugging, and experimentation
> with GSP-RM, which uses these keys to alter its behavior.
> 
> Note that these keys are passed as-is to GSP-RM, and Nouveau does
> not parse them.  This is in contrast to the Nvidia driver, which may
> parse some of the keys to configure some functionality in concert with
> GSP-RM.  Therefore, any keys which also require action by the driver
> may not function correctly when passed by Nouveau.  Caveat emptor.
> 
> The name and format of NVreg_RegistryDwords is the same as used by
> the Nvidia driver, to maintain compatibility.
> 

This patch seems to be breaking latest linux-next (tag: next-20240429).
While building kernel for arm64 on latest linux-next with defconfig, I
see build failure with below error.

❯ make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-

  CALL    scripts/checksyscalls.sh
  CC [M]  drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.o
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c: In function
‘build_registry’:
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1266:3: error: label at
end of compound statement
 1266 |   default:
      |   ^~~~~~~
make[6]: *** [scripts/Makefile.build:244:
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.o] Error 1
make[5]: *** [scripts/Makefile.build:485: drivers/gpu/drm/nouveau] Error 2
make[4]: *** [scripts/Makefile.build:485: drivers/gpu/drm] Error 2
make[3]: *** [scripts/Makefile.build:485: drivers/gpu] Error 2
make[2]: *** [scripts/Makefile.build:485: drivers] Error 2
make[1]: *** [/home/danish/workspace/linux-next/Makefile:1924: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2

> Signed-off-by: Timur Tabi <[email protected]>
> ---
> v7:
>   rebase onto drm-misc-next
>   rename vlen to alloc_size
> 
>  .../gpu/drm/nouveau/include/nvkm/subdev/gsp.h |   6 +
>  .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c    | 355 ++++++++++++++++--
>  2 files changed, 337 insertions(+), 24 deletions(-)

[...]

> +
> +/**
> + * build_registry -- create the registry RPC data
> + * @gsp: gsp pointer
> + * @registry: pointer to the RPC payload to fill
> + *
> + * After all registry key/value pairs have been added, call this function to
> + * build the RPC.
> + *
> + * The registry RPC looks like this:
> + *
> + * +-----------------+
> + * |NvU32 size;      |
> + * |NvU32 numEntries;|
> + * +-----------------+
> + * +----------------------------------------+
> + * |PACKED_REGISTRY_ENTRY                   |
> + * +----------------------------------------+
> + * |Null-terminated key (string) for entry 0|
> + * +----------------------------------------+
> + * |Binary/string data value for entry 0    | (only if necessary)
> + * +----------------------------------------+
> + *
> + * +----------------------------------------+
> + * |PACKED_REGISTRY_ENTRY                   |
> + * +----------------------------------------+
> + * |Null-terminated key (string) for entry 1|
> + * +----------------------------------------+
> + * |Binary/string data value for entry 1    | (only if necessary)
> + * +----------------------------------------+
> + * ... (and so on, one copy for each entry)
> + *
> + *
> + * The 'data' field of an entry is either a 32-bit integer (for type DWORD)
> + * or an offset into the PACKED_REGISTRY_TABLE (for types BINARY and STRING).
> + *
> + * All memory allocated by add_registry() is released.
> + */
> +static void build_registry(struct nvkm_gsp *gsp, PACKED_REGISTRY_TABLE 
> *registry)
> +{
> +     struct registry_list_entry *reg, *n;
> +     size_t str_offset;
> +     unsigned int i = 0;
> +
> +     registry->numEntries = list_count_nodes(&gsp->registry_list);
> +     str_offset = struct_size(registry, entries, registry->numEntries);
> +
> +     list_for_each_entry_safe(reg, n, &gsp->registry_list, head) {
> +             registry->entries[i].type = reg->type;
> +             registry->entries[i].length = reg->vlen;
> +
> +             /* Append the key name to the table */
> +             registry->entries[i].nameOffset = str_offset;
> +             memcpy((void *)registry + str_offset, reg->key, reg->klen);
> +             str_offset += reg->klen;
> +
> +             switch (reg->type) {
> +             case REGISTRY_TABLE_ENTRY_TYPE_DWORD:
> +                     registry->entries[i].data = reg->dword;
> +                     break;
> +             case REGISTRY_TABLE_ENTRY_TYPE_BINARY:
> +             case REGISTRY_TABLE_ENTRY_TYPE_STRING:
> +                     /* If the type is binary or string, also append the 
> value */
> +                     memcpy((void *)registry + str_offset, reg->binary, 
> reg->vlen);
> +                     registry->entries[i].data = str_offset;
> +                     str_offset += reg->vlen;
> +                     break;
> +             default:

This line seems to be the culprit.

> +             }
> +
> +             i++;
> +             list_del(&reg->head);
> +             kfree(reg);
> +     }
> +
> +     /* Double-check that we calculated the sizes correctly */
> +     WARN_ON(gsp->registry_rpc_size != str_offset);
> +
> +     registry->size = gsp->registry_rpc_size;
> +}
> +

[...]

-- 
Thanks and Regards,
Danish

Reply via email to