From patchwork Sat Sep 7 11:07:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Manna, Animesh" X-Patchwork-Id: 11136423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3422C13BD for ; Sat, 7 Sep 2019 11:15:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BB63218AE for ; Sat, 7 Sep 2019 11:15:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BB63218AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A151389DFF; Sat, 7 Sep 2019 11:15:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A71789DFC for ; Sat, 7 Sep 2019 11:15:45 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2019 04:15:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,477,1559545200"; d="scan'208";a="177883248" Received: from amanna.iind.intel.com ([10.223.74.216]) by orsmga008.jf.intel.com with ESMTP; 07 Sep 2019 04:15:43 -0700 From: Animesh Manna To: intel-gfx@lists.freedesktop.org Date: Sat, 7 Sep 2019 16:37:32 +0530 Message-Id: <20190907110735.10302-9-animesh.manna@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190907110735.10302-1-animesh.manna@intel.com> References: <20190907110735.10302-1-animesh.manna@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v5 08/11] drm/i915/dsb: added dsb refcount to synchronize between get/put. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jani Nikula Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The lifetime of command buffer can be controlled by the dsb user throuh refcount. Added refcount mechanism is dsb get/put call which create/destroy dsb context. Cc: Jani Nikula Cc: Shashank Sharma Signed-off-by: Animesh Manna --- drivers/gpu/drm/i915/display/intel_dsb.c | 22 ++++++++++++++++------ drivers/gpu/drm/i915/display/intel_dsb.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c index 853685751540..b951a6b5264a 100644 --- a/drivers/gpu/drm/i915/display/intel_dsb.c +++ b/drivers/gpu/drm/i915/display/intel_dsb.c @@ -78,7 +78,12 @@ intel_dsb_get(struct intel_crtc *crtc) struct intel_dsb *dsb = &crtc->dsb; intel_wakeref_t wakeref; - if ((!HAS_DSB(i915)) || dsb->cmd_buf) + if (!HAS_DSB(i915)) + return dsb; + + atomic_inc(&dsb->refcount); + + if (dsb->cmd_buf) return dsb; dsb->id = DSB1; @@ -94,6 +99,7 @@ intel_dsb_get(struct intel_crtc *crtc) if (IS_ERR(vma)) { DRM_ERROR("Vma creation failed.\n"); i915_gem_object_put(obj); + atomic_dec(&dsb->refcount); goto err; } @@ -102,6 +108,7 @@ intel_dsb_get(struct intel_crtc *crtc) DRM_ERROR("Command buffer creation failed.\n"); i915_vma_unpin_and_release(&vma, 0); dsb->cmd_buf = NULL; + atomic_dec(&dsb->refcount); goto err; } dsb->vma = vma; @@ -121,11 +128,14 @@ void intel_dsb_put(struct intel_dsb *dsb) return; if (dsb->cmd_buf) { - mutex_lock(&i915->drm.struct_mutex); - i915_gem_object_unpin_map(dsb->vma->obj); - i915_vma_unpin_and_release(&dsb->vma, 0); - dsb->cmd_buf = NULL; - mutex_unlock(&i915->drm.struct_mutex); + atomic_dec(&dsb->refcount); + if (!atomic_read(&dsb->refcount)) { + mutex_lock(&i915->drm.struct_mutex); + i915_gem_object_unpin_map(dsb->vma->obj); + i915_vma_unpin_and_release(&dsb->vma, 0); + dsb->cmd_buf = NULL; + mutex_unlock(&i915->drm.struct_mutex); + } } } diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h index 7389c8c5b665..dca4e632dd3c 100644 --- a/drivers/gpu/drm/i915/display/intel_dsb.h +++ b/drivers/gpu/drm/i915/display/intel_dsb.h @@ -20,6 +20,7 @@ enum dsb_id { }; struct intel_dsb { + atomic_t refcount; enum dsb_id id; u32 *cmd_buf; struct i915_vma *vma;