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>,
	ankitprasad.r.sharma@intel.com, intel-gfx@lists.freedesktop.org,
	akash.goel@intel.com, shashidhar.hiremath@intel.com
Subject: Re: [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem backed objects
Date: Thu, 02 Jul 2015 12:27:42 +0100	[thread overview]
Message-ID: <5595202E.2010907@linux.intel.com> (raw)
In-Reply-To: <20150702110059.GU21398@nuc-i3427.alporthouse.com>


On 07/02/2015 12:00 PM, Chris Wilson wrote:
>>> +		/* This is a slow read/write as it tries to read from
>>> +		 * and write to user memory which may result into page
>>> +		 * faults
>>> +		 */
>>> +		ret = slow_user_access(dev_priv->gtt.mappable, page_base,
>>> +				       page_offset, user_data,
>>> +				       page_length, write);
>>> +
>>> +		if (ret) {
>>> +			ret = -EINVAL;
>
> Would be better to return the right errno from slow_user_access or if it
> is a bool, treat is a bool!

It returns a number of unwritten bytes.

Actually just spotted the return type for slow_user_access is also 
wrong, it is an int, to which it implicitly casts an unsigned long.

And it is customary to return -EFAULT on rather than -EINVAL so I 
suggest changing that as well.

>>> +			break;
>>> +		}
>>> +
>>> +		remain -= page_length;
>>> +		user_data += page_length;
>>> +		offset += page_length;
>>> +	}
>>> +
>>> +	mutex_lock(&dev->struct_mutex);
>>
>> Caller had it interruptible.
>
> On second access, it is preferrable not to risk interruption -
> especially when catching up with state to return to userspace.


Second access is only in pwrite case and more so, it makes no sense to 
make such decisions on behalf of the caller. If it is a real concern, 
caller should do it.

Yes I see that there is a problem where this helper doesn't know what 
type of mutex caller had, but, it is still bad imho and could be fixed 
in a different way.

Regards,

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

  reply	other threads:[~2015-07-02 11:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  9:25 [PATCH v4 0/4] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2015-07-01  9:25 ` [PATCH 1/4] drm/i915: Clearing buffer objects via blitter engine ankitprasad.r.sharma
2015-07-01 14:54   ` Tvrtko Ursulin
2015-07-01 16:30     ` Chris Wilson
2015-07-02  9:30       ` Tvrtko Ursulin
2015-07-02  9:50         ` Chris Wilson
2015-07-07  7:42           ` Ankitprasad Sharma
2015-07-07  8:46             ` Chris Wilson
2015-07-07  8:52               ` Ankitprasad Sharma
2015-07-01  9:25 ` [PATCH 2/4] drm/i915: Support for creating Stolen memory backed objects ankitprasad.r.sharma
2015-07-01 15:06   ` Tvrtko Ursulin
2015-07-01 16:19     ` Chris Wilson
2015-07-02  9:37       ` Tvrtko Ursulin
2015-07-02  9:43         ` Chris Wilson
2015-07-01 16:20   ` Tvrtko Ursulin
2015-07-01  9:25 ` [PATCH 3/4] drm/i915: Add support for stealing purgable stolen pages ankitprasad.r.sharma
2015-07-01 16:17   ` Tvrtko Ursulin
2015-07-01  9:25 ` [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem backed objects ankitprasad.r.sharma
2015-07-01  9:54   ` Chris Wilson
2015-07-02 10:42   ` Tvrtko Ursulin
2015-07-02 11:00     ` Chris Wilson
2015-07-02 11:27       ` Tvrtko Ursulin [this message]
2015-07-02 11:58         ` Chris Wilson
2015-07-03  5:07   ` shuang.he
  -- strict thread matches above, loose matches on Subject: below --
2015-09-15  8:33 [PATCH v6 0/4] Support for creating/using Stolen memory " ankitprasad.r.sharma
2015-09-15  8:33 ` [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem " ankitprasad.r.sharma
2015-09-15  9:54   ` Chris Wilson
2015-09-15 10:35     ` Ankitprasad Sharma
2015-07-22 13:51 [PATCH v5 0/4] Support for creating/using Stolen memory " ankitprasad.r.sharma
2015-07-22 13:51 ` [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem " ankitprasad.r.sharma
2015-07-22 14:39   ` Chris Wilson
2015-07-31 13:16     ` Goel, Akash
2015-09-10 17:50       ` Ankitprasad Sharma
2015-09-15  9:58       ` Chris Wilson
2015-07-22 15:46   ` Tvrtko Ursulin
2015-07-22 16:05     ` Daniel Vetter
2015-07-22 16:17       ` Tvrtko Ursulin
2015-05-06 10:15 [PATCH v3 0/4] Support for creating/using Stolen memory " ankitprasad.r.sharma
2015-05-06 10:16 ` [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem " ankitprasad.r.sharma

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=5595202E.2010907@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=akash.goel@intel.com \
    --cc=ankitprasad.r.sharma@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=shashidhar.hiremath@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.