All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Tvrtko Ursulin <tursulin@ursulin.net>,
	Intel-gfx@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [PATCH] drm/i915: Use the existing pages when retrying to DMA map
Date: Tue, 20 Dec 2016 14:21:18 +0000	[thread overview]
Message-ID: <05286733-3915-f0d9-e4ae-e0e6f586ea58@linux.intel.com> (raw)
In-Reply-To: <20161220141414.GF1046@nuc-i3427.alporthouse.com>


On 20/12/2016 14:14, Chris Wilson wrote:
> On Tue, Dec 20, 2016 at 01:42:47PM +0000, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Rather than freeing and re-allocating the pages when DMA mapping
>> in large chunks fails, we can just rebuild the sg table with no
>> coalescing.
>
> You are freeing and reallocating the pages - I thought you meant the
> sg_table. The cost for recovering the shmemfs after allocation/swapin
> already performed in the first pass should be a look up in the radix tree.
> Not worrisome.

Maybe not, but looks a bit unsightly to me. This is simple enough and 
one re-allocation less. From both pages and sg entries, to just the sg 
entries.

>> Also change back the page counter to unsigned int because that
>> is what the sg API supports.
>
> Rather go the other way and start reporting an error when we overflow.
> Being strict all page_counts should be u64. :|

As I wrote in the other thread, that's already in 
i915_gem_object_create. Added there at the time when I spotted the 
sg_alloc_table unsigned int business.

>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> ---
>> Only compile tested!
>> ---
>>  drivers/gpu/drm/i915/i915_gem.c | 40 ++++++++++++++++++++++++++++++----------
>>  1 file changed, 30 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>> index 5275f6248ce3..e73f9f5a5d23 100644
>> --- a/drivers/gpu/drm/i915/i915_gem.c
>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>> @@ -2340,12 +2340,36 @@ static void i915_sg_trim(struct sg_table *orig_st)
>>  	*orig_st = new_st;
>>  }
>>
>> +static void i915_sg_uncoalesce(struct sg_table *orig_st, unsigned long nents)
>> +{
>> +	struct sg_table new_st;
>> +	struct scatterlist *new_sg;
>> +	struct sgt_iter sgt_iter;
>> +	struct page *page;
>> +
>> +	if (sg_alloc_table(&new_st, nents, GFP_KERNEL))
>> +		return;
>
> I was hoping for a way to use the pages already allocated. Feels
> possible, just reversing the chain and walking backwards will be fun.

For a rainy day as you said. :)

>
>> +	new_sg = new_st.sgl;
>> +	for_each_sgt_page(page, sgt_iter, orig_st) {
>> +		sg_set_page(new_sg, page, PAGE_SIZE, 0);
>> +		/* called before being DMA mapped, no need to copy sg->dma_* */
>> +		new_sg = sg_next(new_sg);
>> +	}
>> +
>> +	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */
>> +
>> +	sg_free_table(orig_st);
>> +
>> +	*orig_st = new_st;
>> +}
>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-12-20 14:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 13:42 [PATCH] drm/i915: Use the existing pages when retrying to DMA map Tvrtko Ursulin
2016-12-20 14:14 ` Chris Wilson
2016-12-20 14:21   ` Tvrtko Ursulin [this message]
2016-12-20 15:54 ` ✗ Fi.CI.BAT: failure for " Patchwork
2017-01-09 12:23 ` [PATCH] " Tvrtko Ursulin
2017-01-09 12:28   ` Chris Wilson
2017-01-09 12:40     ` Tvrtko Ursulin
2017-01-09 13:04       ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05286733-3915-f0d9-e4ae-e0e6f586ea58@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=tursulin@ursulin.net \
    --cc=tvrtko.ursulin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.