[Nouveau] [PATCH 3/3] nouveau/gsp: add some basic registry entries.

Timur Tabi timur at kernel.org
Mon Nov 27 20:47:39 UTC 2023


On Tue, Oct 31, 2023 at 12:20 AM Dave Airlie <airlied at gmail.com> wrote:
>         rpc->size = sizeof(*rpc);
> -       rpc->numEntries = 1;
> -       rpc->entries[0].nameOffset = offsetof(typeof(*rpc), entries[1]);
> -       rpc->entries[0].type = 1;
> -       rpc->entries[0].data = 0;
> -       rpc->entries[0].length = 4;
> -
> -       strings = (char *)&rpc->entries[1];
> -       strings[0] = '\0';
> +       rpc->numEntries = NV_GSP_REG_NUM_ENTRIES;
> +
> +       str_offset = offsetof(typeof(*rpc), entries[NV_GSP_REG_NUM_ENTRIES]);
> +       strings = (char *)&rpc->entries[NV_GSP_REG_NUM_ENTRIES];
> +       for (i = 0; i < NV_GSP_REG_NUM_ENTRIES; i++) {
> +               int name_len = strlen(r535_registry_entries[i].name) + 1;
> +               rpc->entries[i].nameOffset = str_offset;
> +               rpc->entries[i].type = 1;
> +               rpc->entries[i].data = r535_registry_entries[i].value;
> +               rpc->entries[i].length = 4;
> +               memcpy(strings, r535_registry_entries[i].name, name_len);
> +               strings += name_len;
> +               str_offset += name_len;
> +       }

I'm working on a patch that replaces this code with a
dynamically-generated registry so that we can set registry keys via
the driver's command-line (like the Nvidia driver).  However, you have
a bug here.  rpc->size must be the total size of the RPC, including
all the PACKED_REGISTRY_ENTRY structs and the strings that follow
them.  You can see this by looking at RmPackageRegistry() and
regCountEntriesAndSize() in OpenRM.


More information about the Nouveau mailing list