lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a2a439f677254260c3c4dd6369b8b478d3581889.camel@linux.intel.com>
Date:   Wed, 22 Jun 2022 13:55:58 +0200
From:   Thomas Hellström 
        <thomas.hellstrom@...ux.intel.com>
To:     Robert Beckett <bob.beckett@...labora.com>,
        dri-devel@...ts.freedesktop.org, intel-gfx@...ts.freedesktop.org,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>
Cc:     kernel@...labora.com, Matthew Auld <matthew.auld@...el.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 08/10] drm/i915: allow memory region creators to
 alloc and free the region

Hi, Bob,

On Tue, 2022-06-21 at 20:00 +0000, Robert Beckett wrote:
> add callbacks for alloc and free.
> this allows region creators to allocate any extra storage they may
> require.
> 
> Signed-off-by: Robert Beckett <bob.beckett@...labora.com>

I think the correct solution here would be to, similar to ttm, export
an alloc_reserved() or alloc_locked() interface, that simply skips the
unlock at bo alloc time.

Then the stolen alloc wrapper could simply pin as/if needed under the
lock.

/Thomas



> ---
>  drivers/gpu/drm/i915/intel_memory_region.c | 16 +++++++++++++---
>  drivers/gpu/drm/i915/intel_memory_region.h |  2 ++
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_memory_region.c
> b/drivers/gpu/drm/i915/intel_memory_region.c
> index e38d2db1c3e3..3da07a712f90 100644
> --- a/drivers/gpu/drm/i915/intel_memory_region.c
> +++ b/drivers/gpu/drm/i915/intel_memory_region.c
> @@ -231,7 +231,10 @@ intel_memory_region_create(struct
> drm_i915_private *i915,
>         struct intel_memory_region *mem;
>         int err;
>  
> -       mem = kzalloc(sizeof(*mem), GFP_KERNEL);
> +       if (ops->alloc)
> +               mem = ops->alloc();
> +       else
> +               mem = kzalloc(sizeof(*mem), GFP_KERNEL);
>         if (!mem)
>                 return ERR_PTR(-ENOMEM);
>  
> @@ -265,7 +268,10 @@ intel_memory_region_create(struct
> drm_i915_private *i915,
>         if (mem->ops->release)
>                 mem->ops->release(mem);
>  err_free:
> -       kfree(mem);
> +       if (mem->ops->free)
> +               mem->ops->free(mem);
> +       else
> +               kfree(mem);
>         return ERR_PTR(err);
>  }
>  
> @@ -288,7 +294,11 @@ void intel_memory_region_destroy(struct
> intel_memory_region *mem)
>  
>         GEM_WARN_ON(!list_empty_careful(&mem->objects.list));
>         mutex_destroy(&mem->objects.lock);
> -       if (!ret)
> +       if (ret)
> +               return;
> +       if (mem->ops->free)
> +               mem->ops->free(mem);
> +       else
>                 kfree(mem);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_memory_region.h
> b/drivers/gpu/drm/i915/intel_memory_region.h
> index 3d8378c1b447..048955b5429f 100644
> --- a/drivers/gpu/drm/i915/intel_memory_region.h
> +++ b/drivers/gpu/drm/i915/intel_memory_region.h
> @@ -61,6 +61,8 @@ struct intel_memory_region_ops {
>                            resource_size_t size,
>                            resource_size_t page_size,
>                            unsigned int flags);
> +       struct intel_memory_region *(*alloc)(void);
> +       void (*free)(struct intel_memory_region *mem);
>  };
>  
>  struct intel_memory_region {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ