[Intel-gfx] [PATCH 4/5] drm/i915: Make scatter-gather helper available to the driver
Chris Wilson
chris at chris-wilson.co.uk
Mon Nov 3 21:30:20 CET 2014
On Mon, Nov 03, 2014 at 05:05:55PM +0100, Daniel Vetter wrote:
> On Thu, Oct 30, 2014 at 04:39:37PM +0000, Tvrtko Ursulin wrote:
> > From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> >
> > It will be used by other call sites shortly.
> >
> > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_dma.c | 38 +++++++++++++++++++++++++++++
> > drivers/gpu/drm/i915/i915_gem_userptr.c | 43 ++-------------------------------
> > drivers/gpu/drm/i915/intel_drv.h | 4 +++
> > 3 files changed, 44 insertions(+), 41 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > index 5b157bb..0b34571 100644
> > --- a/drivers/gpu/drm/i915/i915_dma.c
> > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > @@ -2070,3 +2070,41 @@ int i915_driver_device_is_agp(struct drm_device *dev)
> > {
> > return 1;
> > }
> > +
> > +#if IS_ENABLED(CONFIG_SWIOTLB)
> > +#define swiotlb_active() swiotlb_nr_tbl()
> > +#else
> > +#define swiotlb_active() 0
> > +#endif
> > +
> > +int i915_st_set_pages(struct sg_table **st, struct page **pvec, int num_pages)
> > +{
> > + struct scatterlist *sg;
> > + int ret, n;
> > +
> > + *st = kmalloc(sizeof(**st), GFP_KERNEL);
> > + if (*st == NULL)
> > + return -ENOMEM;
> > +
> > + if (swiotlb_active()) {
> > + ret = sg_alloc_table(*st, num_pages, GFP_KERNEL);
> > + if (ret)
> > + goto err;
> > +
> > + for_each_sg((*st)->sgl, sg, num_pages, n)
> > + sg_set_page(sg, pvec[n], PAGE_SIZE, 0);
> > + } else {
> > + ret = sg_alloc_table_from_pages(*st, pvec, num_pages,
> > + 0, num_pages << PAGE_SHIFT,
> > + GFP_KERNEL);
> > + if (ret)
> > + goto err;
> > + }
>
> Ok, I don't really understand why we don't just always use
> sg_alloc_table_from_pages undconditionally - if swiotlb _ever_ gets in
> between us and the hw, everything will pretty much fall apart.
>
> git blame doesn't shed light on this particular issue. Chris?
This is Imre's work...
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list