diff mbox series

[3/4] drm/i915/perf: do not warn when OA buffer is already allocated

Message ID 20181010165533.23345-4-lionel.g.landwerlin@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/perf: Add OA buffer size uAPI parameter | expand

Commit Message

Lionel Landwerlin Oct. 10, 2018, 4:55 p.m. UTC
If 2 processes race to open the perf stream, it's possible that one of them
will see that OA buffer has already been allocated, while a previous process
is still finishing to reprogram the hardware (on gen8+).

The opening sequence has been reworked a few times and we probably lost
track of the order in which things are supposed to happen.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Matthew Auld Oct. 10, 2018, 7:24 p.m. UTC | #1
On Wed, 10 Oct 2018 at 19:55, Lionel Landwerlin
<lionel.g.landwerlin@intel.com> wrote:
>
> If 2 processes race to open the perf stream, it's possible that one of them
> will see that OA buffer has already been allocated, while a previous process
> is still finishing to reprogram the hardware (on gen8+).
>
> The opening sequence has been reworked a few times and we probably lost
> track of the order in which things are supposed to happen.
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

Accidental resend, or did the locking actually change recently?
Lionel Landwerlin Oct. 11, 2018, 10:06 a.m. UTC | #2
On 10/10/2018 20:24, Matthew Auld wrote:
> On Wed, 10 Oct 2018 at 19:55, Lionel Landwerlin
> <lionel.g.landwerlin@intel.com> wrote:
>> If 2 processes race to open the perf stream, it's possible that one of them
>> will see that OA buffer has already been allocated, while a previous process
>> is still finishing to reprogram the hardware (on gen8+).
>>
>> The opening sequence has been reworked a few times and we probably lost
>> track of the order in which things are supposed to happen.
>>
>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> Accidental resend, or did the locking actually change recently?
>
Indeed.... Sorry for that, dropping for good!

-
Lionel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 88f3f9b6a353..a648ded97969 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1494,13 +1494,15 @@  static int alloc_oa_buffer(struct drm_i915_private *dev_priv)
 	struct i915_vma *vma;
 	int ret;
 
-	if (WARN_ON(dev_priv->perf.oa.oa_buffer.vma))
-		return -ENODEV;
-
 	ret = i915_mutex_lock_interruptible(&dev_priv->drm);
 	if (ret)
 		return ret;
 
+	if (dev_priv->perf.oa.oa_buffer.vma) {
+		ret = -EBUSY;
+		goto unlock;
+	}
+
 	BUILD_BUG_ON_NOT_POWER_OF_2(OA_BUFFER_SIZE);
 	BUILD_BUG_ON(OA_BUFFER_SIZE < SZ_128K || OA_BUFFER_SIZE > SZ_16M);