From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keith Packard Subject: Re: [Mesa-dev] [PATCH] intel: Track known prime buffers for re-use Date: Mon, 25 Nov 2013 13:21:42 -0800 Message-ID: <86eh645g9l.fsf@miki.keithp.com> References: <1385127354-28573-1-git-send-email-keithp@keithp.com> <20131125153946.GC27344@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1047989695==" Return-path: In-Reply-To: <20131125153946.GC27344@phenom.ffwll.local> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Daniel Vetter Cc: mesa-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1047989695== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --=-=-= Content-Transfer-Encoding: quoted-printable Daniel Vetter writes: > Yeah, it unfortunately took a few rounds of kernel fixes and other > haggling to get the semantics right on this one. The kernel atm promises > to userspace (minus one big in a racy corner case no one should care > about, still need to fix that one) that it'll return the same gem handle > if userspace already has one for the underlying object. That's definitely something we want it to do -- returning different handles to the same object would result in madness. We just need to deal wi= th the userspace consequences. > We need that to make sure userspace doesn't submit the same bo in execbuf > multiple times and then upsets the kernel - we'll reject such batches as > userspace bugs. Oh, I'm well aware of that; you can imagine the adventures I had trying to debug this... >> - DRMINITLISTHEAD(&bo_gem->name_list); >> DRMINITLISTHEAD(&bo_gem->vma_list); >> + DRMLISTADDTAIL(&bo_gem->name_list, &bufmgr_gem->prime); > > Won't this result in us having fun when a buffer is both imported from a > prime buffer and then also used with legacy flink? Or is this something > the X server won't support? Well, the whole point of prime-based FD buffer passing is to *not* use flink, of course. However, you could use both DRI2 and DRI3 on the same pixmap (presumably through different APIs). Ok, I just tried to create a completely separate prime list for this, and I think that's wrong. If the question is whether the kernel might return the same object from two calls, then we'd best actually keep a single list and look things up for both APIs there. *and*, I think we need to do the flink->gem handle conversion and then look in the list again to see if that gem handle was already returned from another flink or prime fd. > The second one is about exporting: With flink names we also add the name > to the lookup list in drm_intel_gem_bo_flink. I think we should do the > same for exported prime buffers just as a precaution - the kernel will > return the (existing) gem name also for a prime buffer that has been > exported by yourself. I guess that would imply insane userspace, but > better safe than sorry. yeah, that would seem like crazy user-space behaviour, but user space often seems insane. Thanks for your review; replacement patch to follow shortly. =2D-=20 keith.packard@intel.com --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iQIVAwUBUpO/ZtsiGmkAAAARAQhYgQ//UOCB9pJ/jYaB0Q8x+rzmgKFwAhg4W7WR zUnYp/Lm84j9Eokg7rD1HR1/XIgPHOgHOjZUSqkIkNaYkXc1UWzD4TjY9D4e3FfA tB7cjvB1JyLewnY/lriaQMz0VAu21RJcR4dZnptDgnI6PL1YYU4vxxlnzKLhV0Df 77UciTx5pRTZN9W0yal7MTgbIFRZVQjFrPcDp57OVmJzfV6G5EXa7Vtmf07dDnDZ XMnh6x0PrtpJdiyX5Q7LLimVc1BcOCWo7XX1KuafMZ/Za9Lo4mYcW89SJEArdBK8 Otuy7mhNWJE1yfkqDMaVkekUY9NjPFOceJnS4quu2MOktrCPGOvjmVq0H0+PknqG ctE61dZXCbZhz00XBy2FC4OmuCwTM2S9f+53TqTcdCtdfTdLrv+2TFJtgCB5ydGb WCUx/NWGSPu7MCxlMyQ32UIpzUlt7KPSJWeN7LyY88uPgXGk8sITizENtB4bQPph /7iVslnczJJUJq1hO8VKZIhTJtTSz9vdUx5Exe4mYAEtjo55QmE5+NHird1oSTut YaHB0RHBkb5Jz7poBoTZbE6g4ty9gMKqHxpW0aOJYoIhfJDbrofA5GObPjdHzlJq 0Qg2TgH3lPqpzkwMi/maiwac58Zl1xuAmcx/gLmhyZB4sQ3SyvJ4g1hrnY1GIWgS UYIIM5yawKg= =b5Yx -----END PGP SIGNATURE----- --=-=-=-- --===============1047989695== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1047989695==--