Re: [PATCH 5/7] drm: Don't compute obj counts expensively in get_resources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 09, 2016 at 03:19:42PM +0100, Daniel Vetter wrote:
> Looping when we keep track of this is silly. Only thing we have to
> be careful is with sampling the connector count. To avoid inconsisten
> results due to gcc re-computing this, use READ_ONCE.

Later on in the function we take the mutex that should prevent the
values from changing.

If each block was like

mutex_lock(&mode_config->lockc);

count = dev->mode_config.num_crtc;
if (card_res->count_crtcs >= count) {
	u32 __user id = u64_to_user_ptr(card_res->crtc_id_ptr);
	unsigned int copied = 0;

	drm_for_each_crtc(crtc, dev) {
		if (copied >= count)
			break;

		if (put_user(crtc->base.id, id + copied)) {
			ret = -EFAULT;
			goto out;
		}

		copied++;
	}

	count = copied;
}
card_res->count_crtcs = count;

...

mutex_unlock(&mode_config->lockc);

it would look a bit neater.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux