On Fri, Jun 12, 2026 at 4:34 AM Christian König
<[email protected]> wrote:
>
> On 6/11/26 21:49, Guilherme Ivo Bozi wrote:
> > This series converts the GPIO HW translation logic used by
> > multiple DCN generations from large switch statements to
> > static lookup tables with shared helper functions.
>
> Not to block this patch set, but please keep in mind that when some array 
> index comes from userspace to use array_index_nospec() to avoid security 
> problems caused by speculative execution.
>

Thanks for the feedback. I reviewed the relevant GPIO and DDC paths.
In all cases, the offsets and indices are derived from DC BIOS tables
or internal DC GPIO service mappings, not userspace-controlled input.

If you still prefer additional hardening for consistency, I can send a
v2 with array_index_nospec().

> We already had problems with that in the past when people converted switch 
> statements into an array lockup.
>

I’ll keep this in mind for other paths where array indices may be
influenced by userspace.

Kind regards,
Guilherme Ivo


> Regards,
> Christian.
>
> >
> > The new implementation reduces duplicated translation logic
> > across generations and makes the GPIO mappings easier to
> > maintain and extend.
> >
> > The series introduces generic GPIO translation helpers first,
> > followed by per-generation conversions.
> >
> > The following generations were converted:
> >
> >   - dcn10
> >   - dcn20
> >   - dcn21
> >   - dcn30
> >   - dcn315
> >   - dcn32
> >   - dcn401
> >   - dcn42
> >
> > The dce60, dce80, dce110 and dce120 implementations were
> > left unchanged for now.
> >
> > dce60 and dce80 contain special switch-case handling paths
> > that currently do not map cleanly to the new table-based
> > representation, so they were intentionally excluded from
> > this refactor.
> >
> > No functional changes intended.
> >
> > v1 resend:
> >
> > No changes since original submission.
> >
> > Automated review:
> > https://lore.gitlab.freedesktop.org/drm-ai-reviews/[email protected]/
> >
> > Guilherme Ivo Bozi (9):
> >   drm/amd/display: add GPIO HW translation helpers
> >   drm/amd/display: convert dcn10 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn20 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn21 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn30 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn315 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn32 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn401 GPIO translation to lookup tables
> >   drm/amd/display: convert dcn42 GPIO translation to lookup tables
> >
> >  .../dc/gpio/dcn10/hw_translate_dcn10.c        | 484 +++++++-----------
> >  .../dc/gpio/dcn20/hw_translate_dcn20.c        | 432 ++++++----------
> >  .../dc/gpio/dcn21/hw_translate_dcn21.c        | 417 ++++++---------
> >  .../dc/gpio/dcn30/hw_translate_dcn30.c        | 432 ++++++----------
> >  .../dc/gpio/dcn315/hw_translate_dcn315.c      | 418 ++++++---------
> >  .../dc/gpio/dcn32/hw_translate_dcn32.c        | 386 +++++---------
> >  .../dc/gpio/dcn401/hw_translate_dcn401.c      | 392 +++++---------
> >  .../dc/gpio/dcn42/hw_translate_dcn42.c        | 193 +++----
> >  .../drm/amd/display/dc/gpio/hw_translate.c    |  86 ++++
> >  .../drm/amd/display/dc/gpio/hw_translate.h    |  21 +
> >  .../gpu/drm/amd/display/include/gpio_types.h  |  48 ++
> >  11 files changed, 1274 insertions(+), 2035 deletions(-)
> >
>

Reply via email to