> Date: Fri, 12 Jan 2018 15:05:31 +1100
> From: Jonathan Gray <[email protected]>
> 
> Tested on radeon.
> 
> This should cause no change in behaviour on inteldrm systems that require
> firmware (ie skylake, kabylake, broxton) until a mountroot hook is
> added and firmware installed but I have no way of testing that here.

This doesn't make inteldrm load any firmware since:

1. intel_csr.c calls request_firmware_nowait, which still returns EINVAL
2. intel_guc_loader.c is still stubbed out

So this diff is fine.

ok kettenis@

> Index: drm_linux.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/drm/drm_linux.h,v
> retrieving revision 1.65
> diff -u -p -r1.65 drm_linux.h
> --- drm_linux.h       29 Nov 2017 03:59:34 -0000      1.65
> +++ drm_linux.h       12 Jan 2018 03:43:03 -0000
> @@ -2161,6 +2161,7 @@ size_t sg_copy_from_buffer(struct scatte
>      const void *, size_t);
>  
>  struct firmware {
> +     size_t size;
>       const u8 *data;
>  };
>  
> @@ -2168,7 +2169,14 @@ static inline int
>  request_firmware(const struct firmware **fw, const char *name,
>      struct device *device)
>  {
> -     return -EINVAL;
> +     int r;
> +     struct firmware *f = malloc(sizeof(struct firmware), M_DRM, M_WAITOK);
> +     *fw = f;
> +     r = loadfirmware(name, __DECONST(u_char **, &f->data), &f->size);
> +     if (r != 0)
> +             return -r;
> +     else
> +             return 0;
>  }
>  
>  #define request_firmware_nowait(a, b, c, d, e, f, g) -EINVAL
> @@ -2176,6 +2184,8 @@ request_firmware(const struct firmware *
>  static inline void
>  release_firmware(const struct firmware *fw)
>  {
> +     free(__DECONST(u_char *, fw->data), M_DRM, fw->size);
> +     free(__DECONST(struct firmware *, fw), M_DRM, sizeof(*fw));
>  }
>  
>  void *memchr_inv(const void *, int, size_t);
> 
> 

Reply via email to