[Intel-gfx] [PATCH libdrm v2 5/5] intel: get gen once for gen >= 9

Chris Wilson chris at chris-wilson.co.uk
Wed Aug 29 14:31:11 UTC 2018


Quoting Lucas De Marchi (2018-08-29 01:35:32)
> We don't need to call IS_GEN() for each gen >= 9: we can rather use the
> new intel_is_genx() helper to iterate the pciids array once.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
>  intel/intel_bufmgr_gem.c | 8 +-------
>  intel/intel_decode.c     | 8 ++------
>  2 files changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index 8c3a4b20..d6587b76 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -3656,13 +3656,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
>                 bufmgr_gem->gen = 7;
>         else if (IS_GEN8(bufmgr_gem->pci_device))
>                 bufmgr_gem->gen = 8;
> -       else if (IS_GEN9(bufmgr_gem->pci_device))
> -               bufmgr_gem->gen = 9;
> -       else if (IS_GEN10(bufmgr_gem->pci_device))
> -               bufmgr_gem->gen = 10;
> -       else if (IS_GEN11(bufmgr_gem->pci_device))
> -               bufmgr_gem->gen = 11;
> -       else {
> +       else if (!intel_get_genx(bufmgr_gem->pci_device, &bufmgr_gem->gen)) {
>                 free(bufmgr_gem);
>                 bufmgr_gem = NULL;
>                 goto exit;

And while you are here, don't exit for an unknown gen, just pretend it's
a future one. i915_pciids.h should contain *all* ids, even reserved, for
exactly this reason. (The same behaviour is relied on elsewhere so that
we don't get caught out by some one retrospectively introducing a new
chip. Don't even get started on the abuse of pci-id for sub-gen
encoding...)
-Chris


More information about the Intel-gfx mailing list